Merge from subtype.
authorStefan Ring <stefan@complang.tuwien.ac.at>
Fri, 28 Nov 2008 09:58:39 +0000 (10:58 +0100)
committerStefan Ring <stefan@complang.tuwien.ac.at>
Fri, 28 Nov 2008 09:58:39 +0000 (10:58 +0100)
--HG--
branch : subtype-trunk

746 files changed:
.hgignore
.hgtags
ChangeLog
ChangeLog-2007 [new file with mode: 0644]
INSTALL
Makefile.am
NEWS
THIRDPARTY
autogen.sh
configure.ac
contrib/Makefile.am
contrib/mapfile-vers-product
contrib/svn2cl.xsl [deleted file]
doc/doxygen/Makefile.am
m4/ax_compiler_vendor.m4 [new file with mode: 0644]
m4/cacaoh.m4 [deleted file]
m4/cycle-stats.m4 [new file with mode: 0644]
m4/disassembler.m4 [new file with mode: 0644]
m4/dl.m4 [new file with mode: 0644]
m4/handles.m4 [new file with mode: 0644]
m4/ifconv.m4 [new file with mode: 0644]
m4/inlining.m4 [new file with mode: 0644]
m4/jasmin.m4 [new file with mode: 0644]
m4/java-runtime-library.m4
m4/jitcache.m4 [new file with mode: 0644]
m4/jmm.m4 [new file with mode: 0644]
m4/junit.m4 [new file with mode: 0644]
m4/jvm.m4 [new file with mode: 0644]
m4/jvmti.m4 [new file with mode: 0644]
m4/ltdl.m4 [deleted file]
m4/memcheck.m4 [new file with mode: 0644]
m4/opagent.m4 [new file with mode: 0644]
m4/replacement.m4 [new file with mode: 0644]
m4/rt-timing.m4 [new file with mode: 0644]
m4/statistics.m4 [new file with mode: 0644]
m4/threads.m4
m4/verifier.m4 [new file with mode: 0644]
m4/vm-zip.m4 [new file with mode: 0644]
m4/vmlog.m4 [new file with mode: 0644]
src/Makefile.am
src/cacao/Makefile.am
src/cacao/cacao.c [deleted file]
src/cacao/cacao.cpp [new file with mode: 0644]
src/cacaoh/Makefile.am [deleted file]
src/cacaoh/cacaoh.c [deleted file]
src/cacaoh/dummy.c [deleted file]
src/cacaoh/headers.c [deleted file]
src/cacaoh/headers.h [deleted file]
src/classes/Makefile.am
src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java
src/classes/gnuclasspath/java/lang/VMThread.java
src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java
src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java
src/fdlibm/ieeefp.h
src/mm/Makefile.am
src/mm/boehm-gc/Makefile.am
src/mm/boehm-gc/autogen.sh [deleted file]
src/mm/boehm-gc/configure.ac
src/mm/boehm-gc/include/gc.h
src/mm/boehm-gc/include/include.am
src/mm/boehm-gc/include/private/gcconfig.h
src/mm/boehm-gc/libatomic_ops-1.2/autogen.sh [deleted file]
src/mm/boehm-gc/libatomic_ops-1.2/doc/Makefile.am
src/mm/boehm-gc/libatomic_ops-1.2/mkinstalldirs [deleted file]
src/mm/boehm-gc/libatomic_ops-1.2/src/Makefile.am
src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/Makefile.am
src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/Makefile.am
src/mm/boehm-gc/libatomic_ops-1.2/tests/test_atomic_include.h
src/mm/boehm-gc/libtool.m4 [deleted file]
src/mm/boehm-gc/m4/dummy [new file with mode: 0644]
src/mm/boehm-gc/mkinstalldirs [deleted file]
src/mm/boehm-gc/pthread_stop_world.c
src/mm/boehm.c [deleted file]
src/mm/cacao-gc/final.c
src/mm/cacao-gc/final.h
src/mm/cacao-gc/gc.c
src/mm/cacao-gc/gc.h
src/mm/cacao-gc/heap.c
src/mm/cacao-gc/heap.h
src/mm/cacao-gc/mark.c
src/mm/cacao-gc/rootset.c
src/mm/cacao-gc/rootset.h
src/mm/codememory.c
src/mm/codememory.h
src/mm/dumpmemory.c [deleted file]
src/mm/dumpmemory.cpp [new file with mode: 0644]
src/mm/dumpmemory.h [deleted file]
src/mm/dumpmemory.hpp [new file with mode: 0644]
src/mm/gc-boehm.cpp [new file with mode: 0644]
src/mm/gc-common.h [deleted file]
src/mm/gc-none.cpp [new file with mode: 0644]
src/mm/gc.hpp [new file with mode: 0644]
src/mm/memory.c
src/mm/memory.h
src/mm/nogc.c [deleted file]
src/mm/tlh.c [new file with mode: 0644]
src/mm/tlh.h [new file with mode: 0644]
src/native/Makefile.am
src/native/include/Makefile.am
src/native/jni.c [deleted file]
src/native/jni.cpp [new file with mode: 0644]
src/native/jni.h [deleted file]
src/native/jni.hpp [new file with mode: 0644]
src/native/jvmti/cacaodbg.c
src/native/jvmti/cacaodbg.h
src/native/jvmti/jvmti.c
src/native/jvmti/jvmti.h
src/native/llni.c
src/native/llni.h
src/native/localref.c [deleted file]
src/native/localref.cpp [new file with mode: 0644]
src/native/localref.h [deleted file]
src/native/localref.hpp [new file with mode: 0644]
src/native/native.c [deleted file]
src/native/native.cpp [new file with mode: 0644]
src/native/native.h [deleted file]
src/native/native.hpp [new file with mode: 0644]
src/native/vm/Makefile.am
src/native/vm/cldc1.1/Makefile.am
src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c [deleted file]
src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c [deleted file]
src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c [deleted file]
src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c [deleted file]
src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/java_lang_Class.c [deleted file]
src/native/vm/cldc1.1/java_lang_Class.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/java_lang_Double.c [deleted file]
src/native/vm/cldc1.1/java_lang_Double.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/java_lang_Float.c [deleted file]
src/native/vm/cldc1.1/java_lang_Float.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/java_lang_Math.c [deleted file]
src/native/vm/cldc1.1/java_lang_Math.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/java_lang_Object.c [deleted file]
src/native/vm/cldc1.1/java_lang_Object.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/java_lang_Runtime.c [deleted file]
src/native/vm/cldc1.1/java_lang_Runtime.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/java_lang_String.c [deleted file]
src/native/vm/cldc1.1/java_lang_String.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/java_lang_System.c [deleted file]
src/native/vm/cldc1.1/java_lang_System.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/java_lang_Thread.c [deleted file]
src/native/vm/cldc1.1/java_lang_Thread.cpp [new file with mode: 0644]
src/native/vm/cldc1.1/java_lang_Throwable.c [deleted file]
src/native/vm/cldc1.1/java_lang_Throwable.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/Makefile.am
src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c [deleted file]
src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.c [deleted file]
src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMFrame.c
src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMMethod.c
src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMVirtualMachine.c
src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.c [deleted file]
src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c [deleted file]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.c [deleted file]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.c [deleted file]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.c [deleted file]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMClass.c [deleted file]
src/native/vm/gnuclasspath/java_lang_VMClass.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMClassLoader.c [deleted file]
src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMObject.c [deleted file]
src/native/vm/gnuclasspath/java_lang_VMObject.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMRuntime.c [deleted file]
src/native/vm/gnuclasspath/java_lang_VMRuntime.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMString.c [deleted file]
src/native/vm/gnuclasspath/java_lang_VMString.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMSystem.c [deleted file]
src/native/vm/gnuclasspath/java_lang_VMSystem.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMThread.c [deleted file]
src/native/vm/gnuclasspath/java_lang_VMThread.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMThrowable.c [deleted file]
src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.c [deleted file]
src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.c [deleted file]
src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_reflect_VMField.c [deleted file]
src/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.c [deleted file]
src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c
src/native/vm/gnuclasspath/java_security_VMAccessController.c [deleted file]
src/native/vm/gnuclasspath/java_security_VMAccessController.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.c [deleted file]
src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.cpp [new file with mode: 0644]
src/native/vm/gnuclasspath/sun_reflect_ConstantPool.c [deleted file]
src/native/vm/gnuclasspath/sun_reflect_ConstantPool.cpp [new file with mode: 0644]
src/native/vm/nativevm.c [deleted file]
src/native/vm/nativevm.cpp [new file with mode: 0644]
src/native/vm/nativevm.h [deleted file]
src/native/vm/nativevm.hpp [new file with mode: 0644]
src/native/vm/openjdk/Makefile.am
src/native/vm/openjdk/hpi.c [deleted file]
src/native/vm/openjdk/hpi.cpp [new file with mode: 0644]
src/native/vm/openjdk/hpi.h [deleted file]
src/native/vm/openjdk/hpi.hpp [new file with mode: 0644]
src/native/vm/openjdk/jvm.c [deleted file]
src/native/vm/openjdk/jvm.cpp [new file with mode: 0644]
src/native/vm/openjdk/management.cpp [new file with mode: 0644]
src/native/vm/openjdk/management.hpp [new file with mode: 0644]
src/native/vm/reflect.c [deleted file]
src/native/vm/reflect.h [deleted file]
src/native/vm/reflection.cpp [new file with mode: 0644]
src/native/vm/reflection.hpp [new file with mode: 0644]
src/native/vm/sun_misc_Unsafe.c [deleted file]
src/native/vm/sun_misc_Unsafe.cpp [new file with mode: 0644]
src/threads/Makefile.am
src/threads/atomic.cpp [new file with mode: 0644]
src/threads/atomic.hpp [new file with mode: 0644]
src/threads/condition.hpp [new file with mode: 0644]
src/threads/critical.c [deleted file]
src/threads/critical.h [deleted file]
src/threads/lock-common.h [deleted file]
src/threads/lock.cpp [new file with mode: 0644]
src/threads/lock.hpp [new file with mode: 0644]
src/threads/lockword.cpp [new file with mode: 0644]
src/threads/lockword.hpp [new file with mode: 0644]
src/threads/mutex.h [deleted file]
src/threads/mutex.hpp [new file with mode: 0644]
src/threads/none/lock.h
src/threads/none/thread-none.c
src/threads/none/thread-none.h
src/threads/posix/Makefile.am
src/threads/posix/condition-posix.hpp [new file with mode: 0644]
src/threads/posix/generic-primitives.h [deleted file]
src/threads/posix/lock.c [deleted file]
src/threads/posix/lock.h [deleted file]
src/threads/posix/mutex-posix.h [deleted file]
src/threads/posix/mutex-posix.hpp [new file with mode: 0644]
src/threads/posix/thread-posix.c [deleted file]
src/threads/posix/thread-posix.cpp [new file with mode: 0644]
src/threads/posix/thread-posix.h [deleted file]
src/threads/posix/thread-posix.hpp [new file with mode: 0644]
src/threads/removeme.cpp [new file with mode: 0644]
src/threads/thread.c [deleted file]
src/threads/thread.cpp [new file with mode: 0644]
src/threads/thread.h [deleted file]
src/threads/thread.hpp [new file with mode: 0644]
src/threads/threadlist.c [deleted file]
src/threads/threadlist.cpp [new file with mode: 0644]
src/threads/threadlist.h [deleted file]
src/threads/threadlist.hpp [new file with mode: 0644]
src/toolbox/Makefile.am
src/toolbox/avl.c
src/toolbox/avl.h
src/toolbox/bitvector.c
src/toolbox/chain.c [deleted file]
src/toolbox/chain.h [deleted file]
src/toolbox/hashtable.c
src/toolbox/hashtable.h
src/toolbox/list.c [deleted file]
src/toolbox/list.h [deleted file]
src/toolbox/list.hpp [new file with mode: 0644]
src/toolbox/logging.c
src/toolbox/logging.h
src/toolbox/set.c
src/toolbox/set.h
src/toolbox/tree.c [deleted file]
src/toolbox/tree.h [deleted file]
src/toolbox/util.c
src/toolbox/util.h
src/vm/Makefile.am
src/vm/access.c [deleted file]
src/vm/access.cpp [new file with mode: 0644]
src/vm/access.h [deleted file]
src/vm/access.hpp [new file with mode: 0644]
src/vm/annotation.c [new file with mode: 0644]
src/vm/annotation.h [new file with mode: 0644]
src/vm/array.c [deleted file]
src/vm/array.cpp [new file with mode: 0644]
src/vm/array.h [deleted file]
src/vm/array.hpp [new file with mode: 0644]
src/vm/assertion.c [deleted file]
src/vm/assertion.cpp [new file with mode: 0644]
src/vm/assertion.h [deleted file]
src/vm/assertion.hpp [new file with mode: 0644]
src/vm/builtin.c [deleted file]
src/vm/builtin.h [deleted file]
src/vm/builtintable.inc [deleted file]
src/vm/class.cpp [new file with mode: 0644]
src/vm/class.hpp [new file with mode: 0644]
src/vm/classcache.cpp [new file with mode: 0644]
src/vm/classcache.hpp [new file with mode: 0644]
src/vm/descriptor.c [new file with mode: 0644]
src/vm/descriptor.h [new file with mode: 0644]
src/vm/exceptions.c [deleted file]
src/vm/exceptions.cpp [new file with mode: 0644]
src/vm/exceptions.h [deleted file]
src/vm/exceptions.hpp [new file with mode: 0644]
src/vm/field.cpp [new file with mode: 0644]
src/vm/field.hpp [new file with mode: 0644]
src/vm/finalizer.c
src/vm/finalizer.h
src/vm/global.h
src/vm/globals.cpp [new file with mode: 0644]
src/vm/globals.hpp [new file with mode: 0644]
src/vm/initialize.c [deleted file]
src/vm/initialize.cpp [new file with mode: 0644]
src/vm/initialize.h [deleted file]
src/vm/initialize.hpp [new file with mode: 0644]
src/vm/javaobjects.cpp [new file with mode: 0644]
src/vm/javaobjects.hpp [new file with mode: 0644]
src/vm/jit/Makefile.am
src/vm/jit/abi.h
src/vm/jit/allocator/liveness.c
src/vm/jit/allocator/lsra.c
src/vm/jit/allocator/simplereg.c
src/vm/jit/allocator/simplereg.h
src/vm/jit/alpha/Makefile.am
src/vm/jit/alpha/arch.h
src/vm/jit/alpha/asmpart.S
src/vm/jit/alpha/codegen.c
src/vm/jit/alpha/codegen.h
src/vm/jit/alpha/emit.c
src/vm/jit/alpha/freebsd/md-os.c
src/vm/jit/alpha/linux/md-os.c
src/vm/jit/alpha/machine-instr.h [deleted file]
src/vm/jit/alpha/md-abi.c
src/vm/jit/alpha/md-atomic.hpp [new file with mode: 0644]
src/vm/jit/alpha/md-stubs.hpp [new file with mode: 0644]
src/vm/jit/alpha/md-trap.h
src/vm/jit/alpha/md.c
src/vm/jit/alpha/md.h
src/vm/jit/alpha/patcher.c
src/vm/jit/argument.c [deleted file]
src/vm/jit/argument.cpp [new file with mode: 0644]
src/vm/jit/argument.h [deleted file]
src/vm/jit/argument.hpp [new file with mode: 0644]
src/vm/jit/arm/Makefile.am
src/vm/jit/arm/arch.h
src/vm/jit/arm/asmpart.S
src/vm/jit/arm/codegen.c
src/vm/jit/arm/codegen.h
src/vm/jit/arm/emit.c
src/vm/jit/arm/linux/md-os.c
src/vm/jit/arm/machine-instr.h [deleted file]
src/vm/jit/arm/md-abi.c
src/vm/jit/arm/md-atomic.hpp [new file with mode: 0644]
src/vm/jit/arm/md-stubs.hpp [new file with mode: 0644]
src/vm/jit/arm/md-trap.h
src/vm/jit/arm/md.c
src/vm/jit/arm/md.h
src/vm/jit/arm/patcher.c
src/vm/jit/asmpart.h
src/vm/jit/builtin.cpp [new file with mode: 0644]
src/vm/jit/builtin.hpp [new file with mode: 0644]
src/vm/jit/builtintable.inc [new file with mode: 0644]
src/vm/jit/cfg.c
src/vm/jit/cfg.h
src/vm/jit/code.c [deleted file]
src/vm/jit/code.cpp [new file with mode: 0644]
src/vm/jit/code.h [deleted file]
src/vm/jit/code.hpp [new file with mode: 0644]
src/vm/jit/codegen-common.c [deleted file]
src/vm/jit/codegen-common.cpp [new file with mode: 0644]
src/vm/jit/codegen-common.h [deleted file]
src/vm/jit/codegen-common.hpp [new file with mode: 0644]
src/vm/jit/disass.h
src/vm/jit/dseg.c
src/vm/jit/dseg.h
src/vm/jit/emit-common.c [deleted file]
src/vm/jit/emit-common.cpp [new file with mode: 0644]
src/vm/jit/emit-common.h [deleted file]
src/vm/jit/emit-common.hpp [new file with mode: 0644]
src/vm/jit/exceptiontable.c
src/vm/jit/exceptiontable.h
src/vm/jit/executionstate.c
src/vm/jit/executionstate.h
src/vm/jit/i386/Makefile.am
src/vm/jit/i386/arch.h
src/vm/jit/i386/codegen.c
src/vm/jit/i386/codegen.h
src/vm/jit/i386/cygwin/md-os.c
src/vm/jit/i386/darwin/md-os.c
src/vm/jit/i386/emit.c
src/vm/jit/i386/emit.h
src/vm/jit/i386/freebsd/md-os.c
src/vm/jit/i386/linux/md-os.c
src/vm/jit/i386/machine-instr.h [deleted file]
src/vm/jit/i386/md-abi.c
src/vm/jit/i386/md-atomic.hpp [new file with mode: 0644]
src/vm/jit/i386/md-stubs.hpp [new file with mode: 0644]
src/vm/jit/i386/md-trap.h
src/vm/jit/i386/md.c
src/vm/jit/i386/md.h
src/vm/jit/i386/patcher.c
src/vm/jit/i386/solaris/Makefile.am [new file with mode: 0644]
src/vm/jit/i386/solaris/md-asm.h [new file with mode: 0644]
src/vm/jit/i386/solaris/md-os.c [new file with mode: 0644]
src/vm/jit/icmdtable.inc [deleted file]
src/vm/jit/inline/Makefile.am
src/vm/jit/inline/inline.c [deleted file]
src/vm/jit/inline/inline.cpp [new file with mode: 0644]
src/vm/jit/inline/inline.h [deleted file]
src/vm/jit/inline/inline.hpp [new file with mode: 0644]
src/vm/jit/intrp/Makefile.am
src/vm/jit/intrp/asmpart.c
src/vm/jit/intrp/codegen.c
src/vm/jit/intrp/disass.c [deleted file]
src/vm/jit/intrp/disass.cpp [new file with mode: 0644]
src/vm/jit/intrp/dynamic-super.c
src/vm/jit/intrp/engine.c
src/vm/jit/intrp/intrp.h
src/vm/jit/intrp/patcher.c
src/vm/jit/intrp/peephole.c
src/vm/jit/ir/Makefile.am
src/vm/jit/ir/icmd.cpp [new file with mode: 0644]
src/vm/jit/ir/icmd.hpp [new file with mode: 0644]
src/vm/jit/ir/icmdtable.inc [new file with mode: 0644]
src/vm/jit/ir/instruction.cpp [new file with mode: 0644]
src/vm/jit/ir/instruction.hpp [new file with mode: 0644]
src/vm/jit/jit.c [deleted file]
src/vm/jit/jit.cpp [new file with mode: 0644]
src/vm/jit/jit.h [deleted file]
src/vm/jit/jit.hpp [new file with mode: 0644]
src/vm/jit/linenumbertable.c [deleted file]
src/vm/jit/linenumbertable.cpp [new file with mode: 0644]
src/vm/jit/linenumbertable.h [deleted file]
src/vm/jit/linenumbertable.hpp [new file with mode: 0644]
src/vm/jit/loop/analyze.c
src/vm/jit/loop/analyze.h
src/vm/jit/loop/graph.c
src/vm/jit/loop/graph.h
src/vm/jit/loop/loop.c
src/vm/jit/loop/loop.h
src/vm/jit/loop/tracing.c
src/vm/jit/loop/tracing.h
src/vm/jit/m68k/Makefile.am
src/vm/jit/m68k/arch.h
src/vm/jit/m68k/codegen.c
src/vm/jit/m68k/codegen.h
src/vm/jit/m68k/emit.c
src/vm/jit/m68k/emit.h
src/vm/jit/m68k/linux/md-os.c
src/vm/jit/m68k/machine-instr.h [deleted file]
src/vm/jit/m68k/md-atomic.hpp [new file with mode: 0644]
src/vm/jit/m68k/md-stubs.hpp [new file with mode: 0644]
src/vm/jit/m68k/md-trap.h
src/vm/jit/m68k/md.c
src/vm/jit/m68k/md.h
src/vm/jit/m68k/patcher.c
src/vm/jit/methodtree.c
src/vm/jit/methodtree.h
src/vm/jit/mips/Makefile.am
src/vm/jit/mips/arch.h
src/vm/jit/mips/asmpart.S
src/vm/jit/mips/codegen.c
src/vm/jit/mips/codegen.h
src/vm/jit/mips/emit.c
src/vm/jit/mips/irix/md-os.c
src/vm/jit/mips/linux/md-os.c
src/vm/jit/mips/machine-instr.h [deleted file]
src/vm/jit/mips/md-abi.c
src/vm/jit/mips/md-atomic.hpp [new file with mode: 0644]
src/vm/jit/mips/md-stubs.hpp [new file with mode: 0644]
src/vm/jit/mips/md-trap.h
src/vm/jit/mips/md.c
src/vm/jit/mips/md.h
src/vm/jit/mips/patcher.c
src/vm/jit/mips/uclinux/md-os.c
src/vm/jit/oprofile-agent.cpp [new file with mode: 0644]
src/vm/jit/oprofile-agent.hpp [new file with mode: 0644]
src/vm/jit/optimizing/Makefile.am
src/vm/jit/optimizing/bytecode_escape.c
src/vm/jit/optimizing/dominators.c [deleted file]
src/vm/jit/optimizing/dominators.cpp [new file with mode: 0644]
src/vm/jit/optimizing/dominators.h [deleted file]
src/vm/jit/optimizing/dominators.hpp [new file with mode: 0644]
src/vm/jit/optimizing/escape.c
src/vm/jit/optimizing/escape.h
src/vm/jit/optimizing/graph.c
src/vm/jit/optimizing/graph.h
src/vm/jit/optimizing/ifconv.c
src/vm/jit/optimizing/ifconv.h
src/vm/jit/optimizing/lifetimes.c
src/vm/jit/optimizing/lifetimes.h
src/vm/jit/optimizing/lsra.c
src/vm/jit/optimizing/profile.c
src/vm/jit/optimizing/profile.h
src/vm/jit/optimizing/recompile.c [deleted file]
src/vm/jit/optimizing/recompile.h [deleted file]
src/vm/jit/optimizing/recompiler.cpp [new file with mode: 0644]
src/vm/jit/optimizing/recompiler.hpp [new file with mode: 0644]
src/vm/jit/optimizing/reorder.c
src/vm/jit/optimizing/reorder.h
src/vm/jit/optimizing/ssa.c
src/vm/jit/optimizing/ssa.h
src/vm/jit/optimizing/ssa2.c
src/vm/jit/optimizing/ssa3.c
src/vm/jit/optimizing/ssa_phi.c
src/vm/jit/optimizing/ssa_rename.c
src/vm/jit/parisc/arch.h
src/vm/jit/parse.c [deleted file]
src/vm/jit/parse.cpp [new file with mode: 0644]
src/vm/jit/parse.h [deleted file]
src/vm/jit/parse.hpp [new file with mode: 0644]
src/vm/jit/patcher-common.c [deleted file]
src/vm/jit/patcher-common.cpp [new file with mode: 0644]
src/vm/jit/patcher-common.h [deleted file]
src/vm/jit/patcher-common.hpp [new file with mode: 0644]
src/vm/jit/powerpc/Makefile.am
src/vm/jit/powerpc/arch.h
src/vm/jit/powerpc/asmpart.S
src/vm/jit/powerpc/codegen.c
src/vm/jit/powerpc/codegen.h
src/vm/jit/powerpc/darwin/md-abi.c
src/vm/jit/powerpc/darwin/md-os.c
src/vm/jit/powerpc/emit.c
src/vm/jit/powerpc/linux/md-abi.c
src/vm/jit/powerpc/linux/md-os.c
src/vm/jit/powerpc/machine-instr.h [deleted file]
src/vm/jit/powerpc/md-atomic.hpp [new file with mode: 0644]
src/vm/jit/powerpc/md-stubs.hpp [new file with mode: 0644]
src/vm/jit/powerpc/md-trap.h
src/vm/jit/powerpc/md.c
src/vm/jit/powerpc/md.h
src/vm/jit/powerpc/netbsd/md-os.c
src/vm/jit/powerpc/patcher.c
src/vm/jit/powerpc64/Makefile.am
src/vm/jit/powerpc64/arch.h
src/vm/jit/powerpc64/codegen.c
src/vm/jit/powerpc64/codegen.h
src/vm/jit/powerpc64/emit.c
src/vm/jit/powerpc64/linux/md-abi.c
src/vm/jit/powerpc64/linux/md-os.c
src/vm/jit/powerpc64/machine-instr.h [deleted file]
src/vm/jit/powerpc64/md-atomic.hpp [new file with mode: 0644]
src/vm/jit/powerpc64/md-stubs.hpp [new file with mode: 0644]
src/vm/jit/powerpc64/md-trap.h
src/vm/jit/powerpc64/md.c
src/vm/jit/powerpc64/md.h
src/vm/jit/powerpc64/patcher.c
src/vm/jit/python.c
src/vm/jit/python.h
src/vm/jit/reg.c
src/vm/jit/reg.h
src/vm/jit/replace.c [deleted file]
src/vm/jit/replace.cpp [new file with mode: 0644]
src/vm/jit/replace.h [deleted file]
src/vm/jit/replace.hpp [new file with mode: 0644]
src/vm/jit/s390/Makefile.am
src/vm/jit/s390/arch.h
src/vm/jit/s390/codegen.c
src/vm/jit/s390/codegen.h
src/vm/jit/s390/emit.c
src/vm/jit/s390/machine-instr.h [deleted file]
src/vm/jit/s390/md-abi.c
src/vm/jit/s390/md-atomic.hpp [new file with mode: 0644]
src/vm/jit/s390/md-stubs.hpp [new file with mode: 0644]
src/vm/jit/s390/md-trap.h
src/vm/jit/s390/md.c
src/vm/jit/s390/md.h
src/vm/jit/s390/patcher.c
src/vm/jit/show.c [deleted file]
src/vm/jit/show.cpp [new file with mode: 0644]
src/vm/jit/show.h [deleted file]
src/vm/jit/show.hpp [new file with mode: 0644]
src/vm/jit/sparc64/Makefile.am
src/vm/jit/sparc64/arch.h
src/vm/jit/sparc64/codegen.c
src/vm/jit/sparc64/codegen.h
src/vm/jit/sparc64/emit.c
src/vm/jit/sparc64/linux/md-os.c
src/vm/jit/sparc64/machine-instr.h [deleted file]
src/vm/jit/sparc64/md-abi.c
src/vm/jit/sparc64/md-atomic.hpp [new file with mode: 0644]
src/vm/jit/sparc64/md-stubs.hpp [new file with mode: 0644]
src/vm/jit/sparc64/md-trap.h
src/vm/jit/sparc64/md.c
src/vm/jit/sparc64/md.h
src/vm/jit/sparc64/patcher.c
src/vm/jit/sparc64/solaris/md-os.c
src/vm/jit/stack.c
src/vm/jit/stack.h
src/vm/jit/stacktrace.c [deleted file]
src/vm/jit/stacktrace.cpp [new file with mode: 0644]
src/vm/jit/stacktrace.h [deleted file]
src/vm/jit/stacktrace.hpp [new file with mode: 0644]
src/vm/jit/stubs.cpp [new file with mode: 0644]
src/vm/jit/stubs.hpp [new file with mode: 0644]
src/vm/jit/trace.c [deleted file]
src/vm/jit/trace.cpp [new file with mode: 0644]
src/vm/jit/trace.h [deleted file]
src/vm/jit/trace.hpp [new file with mode: 0644]
src/vm/jit/trap.c
src/vm/jit/trap.h
src/vm/jit/verify/Makefile.am
src/vm/jit/verify/icmds.c [deleted file]
src/vm/jit/verify/icmds.cpp [new file with mode: 0644]
src/vm/jit/verify/typecheck-common.c [deleted file]
src/vm/jit/verify/typecheck-common.cpp [new file with mode: 0644]
src/vm/jit/verify/typecheck-common.h [deleted file]
src/vm/jit/verify/typecheck-common.hpp [new file with mode: 0644]
src/vm/jit/verify/typecheck-stackbased.c [deleted file]
src/vm/jit/verify/typecheck-stackbased.cpp [new file with mode: 0644]
src/vm/jit/verify/typecheck-typeinferer.c [deleted file]
src/vm/jit/verify/typecheck-typeinferer.cpp [new file with mode: 0644]
src/vm/jit/verify/typecheck-typeinferer.h [deleted file]
src/vm/jit/verify/typecheck-typeinferer.hpp [new file with mode: 0644]
src/vm/jit/verify/typecheck.c [deleted file]
src/vm/jit/verify/typecheck.cpp [new file with mode: 0644]
src/vm/jit/verify/typecheck.h [deleted file]
src/vm/jit/verify/typecheck.hpp [new file with mode: 0644]
src/vm/jit/verify/typeinfo.c [deleted file]
src/vm/jit/verify/typeinfo.cpp [new file with mode: 0644]
src/vm/jit/verify/typeinfo.h [deleted file]
src/vm/jit/verify/typeinfo.hpp [new file with mode: 0644]
src/vm/jit/x86_64/Makefile.am
src/vm/jit/x86_64/arch.h
src/vm/jit/x86_64/asmpart.S
src/vm/jit/x86_64/codegen.c
src/vm/jit/x86_64/codegen.h
src/vm/jit/x86_64/emit.c
src/vm/jit/x86_64/emit.h
src/vm/jit/x86_64/freebsd/md-os.c
src/vm/jit/x86_64/linux/md-os.c
src/vm/jit/x86_64/machine-instr.h [deleted file]
src/vm/jit/x86_64/md-abi.c
src/vm/jit/x86_64/md-atomic.hpp [new file with mode: 0644]
src/vm/jit/x86_64/md-stubs.hpp [new file with mode: 0644]
src/vm/jit/x86_64/md-trap.h
src/vm/jit/x86_64/md.c
src/vm/jit/x86_64/md.h
src/vm/jit/x86_64/patcher.c
src/vm/jit/x86_64/solaris/Makefile.am [new file with mode: 0644]
src/vm/jit/x86_64/solaris/md-os.c [new file with mode: 0644]
src/vm/jit_interface.h [deleted file]
src/vm/linker.cpp [new file with mode: 0644]
src/vm/linker.hpp [new file with mode: 0644]
src/vm/loader.cpp [new file with mode: 0644]
src/vm/loader.hpp [new file with mode: 0644]
src/vm/method.cpp [new file with mode: 0644]
src/vm/method.hpp [new file with mode: 0644]
src/vm/options.c [new file with mode: 0644]
src/vm/options.h [new file with mode: 0644]
src/vm/os.cpp [new file with mode: 0644]
src/vm/os.hpp [new file with mode: 0644]
src/vm/package.c [deleted file]
src/vm/package.cpp [new file with mode: 0644]
src/vm/package.h [deleted file]
src/vm/package.hpp [new file with mode: 0644]
src/vm/primitive.c [deleted file]
src/vm/primitive.cpp [new file with mode: 0644]
src/vm/primitive.h [deleted file]
src/vm/primitive.hpp [new file with mode: 0644]
src/vm/properties.c [deleted file]
src/vm/properties.cpp [new file with mode: 0644]
src/vm/properties.h [deleted file]
src/vm/properties.hpp [new file with mode: 0644]
src/vm/references.h [new file with mode: 0644]
src/vm/resolve.c [deleted file]
src/vm/resolve.cpp [new file with mode: 0644]
src/vm/resolve.h [deleted file]
src/vm/resolve.hpp [new file with mode: 0644]
src/vm/rt-timing.c [new file with mode: 0644]
src/vm/rt-timing.h [new file with mode: 0644]
src/vm/signal.c
src/vm/signallocal.h
src/vm/stackmap.c [new file with mode: 0644]
src/vm/stackmap.h [new file with mode: 0644]
src/vm/statistics.c [new file with mode: 0644]
src/vm/statistics.h [new file with mode: 0644]
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/suck.cpp [new file with mode: 0644]
src/vm/suck.hpp [new file with mode: 0644]
src/vm/utf8.c [new file with mode: 0644]
src/vm/utf8.h [new file with mode: 0644]
src/vm/vftbl.hpp [new file with mode: 0644]
src/vm/vm.c [deleted file]
src/vm/vm.cpp [new file with mode: 0644]
src/vm/vm.h [deleted file]
src/vm/vm.hpp [new file with mode: 0644]
src/vm/zip.cpp [new file with mode: 0644]
src/vm/zip.hpp [new file with mode: 0644]
src/vmcore/Makefile.am [deleted file]
src/vmcore/annotation.c [deleted file]
src/vmcore/annotation.h [deleted file]
src/vmcore/class.c [deleted file]
src/vmcore/class.h [deleted file]
src/vmcore/classcache.c [deleted file]
src/vmcore/classcache.h [deleted file]
src/vmcore/descriptor.c [deleted file]
src/vmcore/descriptor.h [deleted file]
src/vmcore/field.c [deleted file]
src/vmcore/field.h [deleted file]
src/vmcore/linker.c [deleted file]
src/vmcore/linker.h [deleted file]
src/vmcore/loader.c [deleted file]
src/vmcore/loader.h [deleted file]
src/vmcore/method.c [deleted file]
src/vmcore/method.h [deleted file]
src/vmcore/options.c [deleted file]
src/vmcore/options.h [deleted file]
src/vmcore/primitivecore.c [deleted file]
src/vmcore/references.h [deleted file]
src/vmcore/rt-timing.c [deleted file]
src/vmcore/rt-timing.h [deleted file]
src/vmcore/stackmap.c [deleted file]
src/vmcore/stackmap.h [deleted file]
src/vmcore/statistics.c [deleted file]
src/vmcore/statistics.h [deleted file]
src/vmcore/suck.c [deleted file]
src/vmcore/suck.h [deleted file]
src/vmcore/system.c [deleted file]
src/vmcore/system.h [deleted file]
src/vmcore/utf8.c [deleted file]
src/vmcore/utf8.h [deleted file]
src/vmcore/zip.c [deleted file]
src/vmcore/zip.h [deleted file]
tests/regression/Makefile.am
tests/regression/base/All.java [new file with mode: 0644]
tests/regression/base/Makefile.am [new file with mode: 0644]
tests/regression/base/TestExceptionInStaticClassInitializer.java [new file with mode: 0644]
tests/regression/base/TestPatcher.java [new file with mode: 0644]
tests/regression/bugzilla/All.java
tests/regression/bugzilla/Makefile.am
tests/regression/bugzilla/PR52.java
tests/regression/bugzilla/PR57.java
tests/regression/bugzilla/PR58.java
tests/regression/bugzilla/PR65.java
tests/regression/bugzilla/PR80.java [new file with mode: 0644]
tests/regression/bugzilla/PR89.java [new file with mode: 0644]
tests/regression/jasmin/Makefile.am
tests/regression/junit/All.java [deleted file]
tests/regression/junit/Makefile.am [deleted file]
tests/regression/junit/TestExceptionInStaticClassInitializer.java [deleted file]
tests/regression/junit/TestPatcher.java [deleted file]
tests/regression/native/checkjni.c
tests/regression/native/test.c
tests/regression/native/testarguments.c
tests/regression/native/testgetobjectclass0.c
tests/threads/sableContention.java [new file with mode: 0644]
tests/threads/sableContention.patch [new file with mode: 0644]
tests/threads/threadpooltest.java [new file with mode: 0644]

index b46a9a618fccd20bea72320c55c1f967126dc4c9..f1aa443c5a2c37a80048c5e159a0a0dc182e52f9 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -56,9 +56,9 @@ tests/*.class
 tests/regression/*.class
 tests/regression/assertion/*.class
 tests/regression/assertion/packagetest/*.class
+tests/regression/base/*.class
 tests/regression/bugzilla/*.class
 tests/regression/jasmin/*.class
-tests/regression/junit/*.class
 tests/regression/native/*.class
 tests/regression/native/*.h
 tests/regression/native/*.so
diff --git a/.hgtags b/.hgtags
index 734924606376b67f0099ad84b9a2490d6166e1ff..cb0d3f7d545ead38464c7c30fd42167b95d5bf21 100644 (file)
--- a/.hgtags
+++ b/.hgtags
@@ -12,3 +12,6 @@ f0bbc765d01fd58f0c42e25de02f059c2f9a9598 cacao-0.95
 31f9c3186dded73dab4ed3f519c1cc28940c98dd cacao-0.96
 ae597ed07b16e08575c39f88b93004049f663b2b new_instruction_format_branch_point
 d19da1d8ff91d76df914b1d2455d6faaec4fbcdf unified_variables_branch_point
+ce7b6a16a176be6285837629912e8be7fa955086 cacao-0.97
+430cdebdf7d1fb22e8c78fbfadae72b9ee6bc9dd cacao-0.98
+633b9803f4f4067a40edb0d1172516e1e9d3c5b5 cacao-0.99
index c26a79c5725fae8649ce3cf9e780ef8c26acab34..048694e0b64c8f272eb73e40e42041402fc3cd1f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
-2007-06-06 09:24  twisti
-
-       * configure.ac (AC_INIT): Changed version to 0.98.
-
-2007-06-05 23:46  twisti
-
-       * src/native/vm/gnu/java_lang_VMString.c
-       (native/vm/java_lang_String.h): Added.
-       (intern): Call _Jv_java_lang_String_intern.
-       
-       * src/native/vm/java_lang_String.c: New file.
-       * src/native/vm/java_lang_String.h: Likewise.
-       
-       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
-       java_lang_String.[ch].
-
-2007-06-05 22:11  twisti
-
-       * src/native/native.c (native_init): Check nativevm_init return value.
-       
-       * src/native/vm/nativevm.c (nativevm_init): Changed signature.
-       * src/native/vm/nativevm.h (nativevm_init): Likewise.
-
-2007-06-05 20:58  twisti
-
-       * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES): Removed
-       sun_misc_Unsafe.c.
-       
-       * src/native/vm/Makefile.am [ENABLE_JAVASE] (SUN_MISC_UNSAFE_SOURCES):
-       Added.
-       (libnativevm_la_SOURCES): Added SUN_MISC_UNSAFE_SOURCES.
-       
-       * src/native/vm/gnu/sun_misc_Unsafe.c: Removed.
-       * src/native/vm/sun_misc_Unsafe.c: Added.
-
-2007-06-05 12:53  twisti
-
-       * src/vm/jit/codegen-common.c [__ARM__] (md-abi.h): Removed.
-       (codegen_reg_of_var) [__ARM__]: Removed split-code.
-
-2007-06-05 10:19  twisti
-
-       * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 8]: Use
-       reguse instead of i.
-
-2007-06-05 10:14  twisti
-
-       * src/vm/jit/mips/md-abi.c (md_param_alloc_native)
-       [SIZEOF_VOID_P == 8]: Fixed compilation.
-
-2007-06-05 10:06  twisti
-
-       * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 4]: Use
-       internally a different calling convention. It's the same as on n64
-       with register skipping and, but with long alignment (as on ARM).
-       (md_param_alloc_native) [SIZEOF_VOID_P == 4]: Use the o32 ABI.
-       
-       * src/vm/jit/mips/codegen.c (codegen_emit) [SIZEOF_VOID_P == 4]:
-       Changes for new internal calling conventions.
-       (codegen_emit_stub_native) [SIZEOF_VOID_P == 4]: Likewise.
-       
-       * src/vm/jit/mips/asmpart.S (asm_vm_call_method) [SIZEOF_VOID_P == 4]:
-       Adjusted reserved stack-space to 4*4.
-
-2007-06-05 09:00  twisti
-
-       * src/vm/jit/mips/codegen.c (codegen_emit): Use FLTMOVE and DBLMOVE to
-       save some moves.
-
-2007-06-05 07:56  twisti
-
-       * src/vm/jit/mips/codegen.c (codegen_emit): Small code-layout change.
-
-2007-06-05 07:44  twisti
-
-       * src/vm/vm.c: Set Id keyword.
-
-2007-06-05 07:42  twisti
-
-       * src/vm/vm.c (vmcore/statistics.h): Added.
-
-2007-06-05 07:40  twisti
-
-       * src/vmcore/statistics.c (count_calls_java_to_native): Added.
-       (count_calls_native_to_java): Likewise.
-       (count_native_function_calls): Removed.
-       (nativeinvokation): Likewise.
-       (print_stats): Print new variables.
-       
-       * src/vmcore/statistics.h (count_calls_java_to_native): Added.
-       (count_calls_native_to_java): Likewise.
-       (nativeinvokation): Removed.
-       
-       * src/vm/jit/codegen-common.c (codegen_start_native_call)
-       [ENABLE_STATISTICS]: Increase count_calls_java_to_native.
-       
-       * src/vm/vm.c (vm_call_method_vmarg) [ENABLE_STATISTICS]: Increase
-       count_calls_native_to_java.
-       (vm_call_method_int_vmarg): Likewise.
-       (vm_call_method_long_vmarg): Likewise.
-       (vm_call_method_float_vmarg): Likewise.
-       (vm_call_method_double_vmarg): Likewise.
-
-2007-06-04 13:12  twisti
-
-       * src/vm/signal.c (unistd.h): Removed.
-       (sys/mman.h): Likewise.
-       (signal_init): Moved mmap of page 0x0 and the hardware-exceptions
-       check into exceptions_init.
-       
-       * src/vm/exceptions.c (unistd.h): Added.
-       (sys/mman.h): Likewise.
-       (exceptions_init): See above.
-
-2007-06-04 12:59  twisti
-
-       * src/vm/signal.c (signal_init): Use if-vm_abort instead of assert.
-       * src/vm/exceptions.h: Changed hardware-exception comment accordingly.
-
-2007-06-03 18:42  twisti
-
-       * src/threads/threads-common.c (threads_thread_start_internal):
-       Changed order of initialization stuff, so we can leave the join-mutex
-       very early.
-       (threads_thread_start): Likewise.
-       
-       * src/threads/native/threads.c (threads_mutex_join_lock): New
-       function.
-       (threads_mutex_join_unlock): Likewise.
-       (threads_attach_current_thread): Changed order of initialization
-       stuff, so we can leave the join-mutex very early.
-       (threads_detach_thread): Send the signal inside the join-mutex.
-       (threads_join_all_threads): Use join-mutex functions.
-       
-       * src/threads/threads-common.h (threads_mutex_join_lock): Added.
-       (threads_mutex_join_unlock): Likewise.
-
-2007-06-03 18:24  pm
-
-       * configure.ac: Fix broken regex.h test.
-
-2007-06-02 17:47  pm
-
-       * contrib/vmlog/vmlogfilter.c: Added a tool that filters a vmlog log
-       file the same way as -XXfi and -XXfx do.
-       
-       * contrib/vmlog/vmlog.c,
-       contrib/vmlog/vmlog.h (vmlog_thread_log_append): Made not-static.
-       
-       * contrib/vmlog/Makefile.am,
-       configure.ac: Conditional building of vmlogfilter if ENABLE_VMLOG is
-       set and regex.h present.
-
-2007-06-01 19:34  ajordan
-
-       * src/vm/signal.c: Added ifdefs to fix compiling with disabled
-       threads.
-
-2007-06-01 00:45  ajordan
-
-       * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed the
-       way
-       float arguments are preserved over codegen_start_native_call.
-       * src/vm/jit/sparc64/md-abi.c (codegen_start_native_call): Likewise.
-       
-       * src/vm/jit/sparc64/machine-instr.h (compare_and_swap): Changed
-       inline
-       assembly, so it survives gcc optimization.
-       
-       * src/vm/jit/sparc64/asmpart.S (asm_patcher_wrapper): Saving and
-       restoring
-       float return register.
-       * src/vm/jit/sparc64/md-asm.h: Likewise.
-
-2007-06-01 00:29  twisti
-
-       * m4/ac_pthreads_implementation.m4: Reverted rev7996.
-       * m4/threads.m4: Likewise.
-       
-       * src/threads/threads-common.c [__LINUX__]
-       (threads_pthreads_implementation_nptl): Added.
-       (threads_preinit) [__LINUX__]: Check which thread-implementation we
-       are using.
-       
-       * src/threads/threads-common.h [__LINUX__]
-       (threads_pthreads_implementation_nptl): Added.
-       
-       * src/vm/signal.c (signal_init) [__LINUX__]: Check for
-       threads_pthreads_implementation_nptl.
-       
-       * src/vm/vm.c (vm_create) [__LINUX__]: Likewise.
-
-2007-05-31 23:26  twisti
-
-       * src/vm/jit/mips/irix/md-os.c (vm/jit/mips/codegen.h): Added.
-       (md_signal_handler_sigsegv): Updated to new exception-handling.
-       (thread_restartcriticalsection): Renamed to
-       md_critical_section_restart.
-
-2007-05-31 23:05  twisti
-
-       * m4/ac_pthreads_implementation.m4: New file.
-       
-       * m4/threads.m4 (AC_CHECK_ENABLE_THREADS): Call
-       AC_CHECK_PTHREADS_IMPLEMENTATION for posix and linux.
-       
-       * configure.ac (AC_CHECK_HEADERS): Added stdlib.h.
-       (AC_CHECK_FUNCS): Added confstr, strstr.
-       
-       * src/vm/signal.c (signal_init) [!PTHREADS_IS_LINUXTHREADS]: Only
-       block the signals if we are not on LinuxThreads.
-       (signal_thread): Set state accordingly.
-       
-       * src/vm/vm.c (vm_create) [!PTHREADS_IS_LINUXTHREADS]: Only start
-       signal-thread if we are not on LinuxThreads.
-
-2007-05-31 22:45  twisti
-
-       * src/vm/signal.c: Reverted rev7978.
-
-2007-05-31 16:10  twisti
-
-       * src/vm/vm.c (vm_create): Added comment.
-
-2007-05-30 22:32  twisti
-
-       * src/vm/jit/powerpc64/emit.c (emit_branch): Removed debug output.
-
-2007-05-30 22:01  twisti
-
-       * NEWS: Added some 0.98 release notes.
-
-2007-05-30 21:59  twisti
-
-       * ChangeLog: Updated.
-       * ChangeLog-2006: New file.
-
-2007-05-30 21:05  twisti
-
-       * src/vm/jit/powerpc/darwin/md-os.c (thread_restartcriticalsection):
-       Renamed to md_critical_section_restart.
-
-2007-05-30 21:04  twisti
-
-       * src/vm/jit/powerpc/asmpart.S [ENABLE_REPLACEMENT] (L_replace_me)
-       (L_replace_build_execution_state, L_replace_free_safestack): Only if
-       replacement is enabled, otherwise we get a linker error.
-
-2007-05-30 20:53  twisti
-
-       * src/vm/jit/powerpc/darwin/md-abi.c,
-       src/vm/jit/powerpc/darwin/md-abi.h: Removed Contact, Authors, Changes
-       from header.
-
-2007-05-30 20:51  twisti
-
-       * src/vm/signal.c (signal_thread) [!__DARWIN__]: Don't do the
-       GC_signum stuff on Darwin (should also be done on Solaris, but let's
-       wait how the exact-GC is doing).
-
-2007-05-30 20:45  twisti
-
-       * src/vm/builtin.c (math.h): Removed because we don't need it as we
-       include fdlibm.h and it does not work on some OSs, like Darwin.
-
-2007-05-30 20:40  twisti
-
-       * src/mm/boehm-gc/pthread_stop_world.c (GC_signum1, GC_signum2): No it
-       did not work, reverted rev7981.
-
-2007-05-30 20:30  twisti
-
-       * src/threads/native/threads.c (threads_impl_preinit): Initialize
-       mutex_threads_list.
-       (threads_impl_table_init): Removed.
-       (threads_impl_table_init, threads_list_unlock): Fixed debug message.
-       
-       * src/threads/threads-common.h (threads_impl_table_init): Removed.
-
-2007-05-30 20:04  twisti
-
-       * src/vm/resolve.c (resolve_subtype_check): Don't free the memory
-       before it's used.
-
-2007-05-30 20:01  twisti
-
-       * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native): Fixed
-       typo.
-       
-       * src/vm/jit/powerpc64/emit.c [!NDEBUG] (emit_verbosecall_enter)
-       (emit_verbosecall_exit): Only compile conditionally.
-
-2007-05-30 19:43  twisti
-
-       * src/mm/boehm-gc/pthread_stop_world.c (cacao_suspendhandler):
-       Commented.
-       (GC_suspend_handler): Commented cacao_suspendhandler call.
-       (GC_signum1, GC_signum2): Define for all configurations (hope that
-       works).
-       
-       * src/threads/native/threads.c: Commented all critical-sections code,
-       as it does not work anyway and it does not compile everywhere.
-
-2007-05-30 16:01  twisti
-
-       * src/vm/jit/powerpc64/md.c (md_get_method_patch_address): Use
-       vm_abort and fixed warning.
-       (md_codegen_get_pv_from_pc): Likewise.
-
-2007-05-30 15:52  twisti
-
-       * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed --disable-debug
-       build.
-
-2007-05-30 14:09  twisti
-
-       * src/vm/signal.c (mm/boehm-gc/include/gc.h): Added.
-       (GC_suspend_handler): Defined.
-       (GC_restart_handler): Likewise.
-       (signal_thread): Add the Boehm-GC signals to the mask and call the
-       appropriate Boehm-function. This is a workaround for the
-       Boehm-LinuxThreads bug.
-
-2007-05-29 12:34  twisti
-
-       * src/vm/signal.c (signal_init): Changed signature.
-       * src/vm/signallocal.h (signal_init): Likewise.
-       
-       * src/vm/vm.c (vm_create): Call signal_init right after gc_init and
-       check return value.
-
-2007-05-29 12:22  twisti
-
-       * src/vm/access.c (string.h): Added.
-       (mm/memory.h): Likewise.
-       (vmcore/field.h): Likewise.
-       (vmcore/method.h): Likewise.
-       (access_check_member): Removed.
-       (access_check_field): New function.
-       (access_check_method): Likewise.
-       
-       * src/vm/access.h (vmcore/field.h): Added.
-       (vmcore/method.h): Likewise.
-       (access_check_member): Removed.
-       (access_check_field): New function.
-       (access_check_method): Likewise.
-       
-       * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): Call
-       access_check_method instead of access_check_member.
-       
-       * src/native/vm/gnu/java_lang_reflect_Constructor.c (constructNative):
-       Likewise.
-       
-       * src/native/vm/gnu/java_lang_reflect_Field.c
-       (cacao_get_field_address): Call access_check_field instead of
-       access_check_member.
-
-2007-05-29 11:44  pm
-
-       * src/vm/jit/show.c (vm/vm.h) add missing include,
-       (_no_threads_filterverbosecallctr) fix type: u2 instead of u4
-
-2007-05-29 11:30  twisti
-
-       * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed warnings, some
-       indent.
-
-2007-05-29 09:03  twisti
-
-       * src/vm/exceptions.c (exceptions_throw_illegalaccessexception):
-       Changed signature.
-       * src/vm/exceptions.h: Likewise.
-       
-       * src/vm/resolve.c (resolve_class_from_name): Make utf8-string out of
-       exception message.
-       (resolve_subtype_check): Likewise.
-       (resolve_field_verifier_checks): Likewise.
-       (resolve_method_verifier_checks): Likewise.
-
-2007-05-28 00:05  ajordan
-
-       * src/vm/jit/sparc64/codegen.h: Removed asserts for stores with sethi.
-       
-       * src/vm/jit/sparc64/codegen.c: Added code to fill with nops when a
-       patcher is right at the
-       end of a basic block.
-       
-       * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method_end): Returning 0
-       when an exception occurs.
-       
-       * src/vm/jit/sparc64/md.c (md_get_method_patch_address): Improved
-       handling of mptr loads when
-       a sethi is involved.
-
-2007-05-26 15:26  pm
-
-       * contrib/vmlog/vmlog.c: Use autoconf define WORDS_BIGENDIAN to
-       determine endianess.
-
-2007-05-25 15:23  twisti
-
-       * src/threads/threads-common.c (threads_thread_start_internal)
-       [WITH_CLASSPATH_CLDC1_1]: Set name to NULL, but this needs a fix.
-       (threads_thread_print_info) [ENABLE_JAVAME_CLDC1_1]: Set name to
-       utf_null.
-
-2007-05-25 15:05  twisti
-
-       * src/vm/jit/optimizing/ifconv.c (vm/vm.h): Added.
-       (ifconv_static): Fixed warning, use vm_abort.
-       * src/vm/jit/powerpc/md.c (md_get_method_patch_address): Fixed
-       warning, use vm_abort.
-
-2007-05-25 15:03  twisti
-
-       * src/vm/string.c (javastring_new_from_utf_buffer): Made static.
-       * src/vm/stringlocal.h (javastring_new_from_utf_buffer): Removed.
-
-2007-05-25 12:41  pm
-
-       * src/vm/jit/show.h (show_filters_init, show_filters_apply,
-       show_filters_test_verbosecall_enter,
-       show_filters_test_verbosecall_exit): Added.
-       * src/vm/jit/show.c: Likewise.
-       * src/vm/jit/jit.c (jit_compile_intern): Honour filters.
-       * src/vm/jit/codegen-common.c (codegen_add_patch_ref,
-       codegen_generate_stub_native): Honour PATCHER_LONGBRANCHES_NOPS if
-       defined, honour filters.
-       * src/vm/builtin.c (builtin_trace_exception,
-       builtin_verbosecall_enter, builtin_verbosecall_exit): Honour filters.
-       * src/vm/signal.c (signal_init): Register SIGILL handler on s390.
-       * src/vm/vm.c: Handle -XXfi, -XXfe, -XXfm commandline options.
-       * src/vm/signallocal.h (md_signal_handler_sigill): Forward declare on
-       s390.
-       * src/threads/none/threads.h (_no_threads_filterverbosecallctr,
-       FILTERVERBOSECALLCTR): Added.
-       * src/threads/native/threads.h (struct threadobject): Added
-       filterverbosecallctr.
-       * src/threads/native/threads.c (threads_impl_thread_new): Initialize
-       filterverbosecallctr.
-       * src/threads/critical.c (critical_comparator): On s390, clear bit 32
-       of pointer when comparing.
-       * src/vmcore/options.h (opt_filter_verbosecall_include,
-       opt_filter_verbosecall_exclude, opt_filter_show_method): Added.
-       * src/vmcore/options.c: Likewise.
-       * src/vmcore/method.h (struct methodinfo): Added filtermatches.
-       * configure.ac: If no NDEBUG and regex.h header is present, define
-       ENABLE_DEBUG_FILTER.
-       * src/vm/jit/s390/emit.c,
-       src/vm/jit/s390/md.c,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/codegen.h,
-       src/vm/jit/s390/tests/dacapo.status,
-       src/vm/jit/s390/patcher.c: Changed a lot.
-
-2007-05-24 13:25  michi
-
-       * src/vmcore/linker.c (link_class_intern) [__ARM_EABI__]: Fixed field
-       alignment bug. Double and Long fields are 8-byte aligned with EABI.
-
-2007-05-24 10:23  twisti
-
-       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv): Fixed
-       warning.
-
-2007-05-24 10:21  twisti
-
-       * src/threads/threads-common.c (mm/memory.h): Added.
-       (toolbox/list.h): Likewise.
-       (threads_table): Removed.
-       (list_threads, list_threads_free): Added.
-       (threads_preinit): Initialize lists.
-       (threads_table_init): Removed.
-       (threads_table_add): Likewise.
-       (threads_table_remove): Likewise.
-       (threads_table_get): Likewise.
-       (threads_table_get_threads): Likewise.
-       (threads_table_get_non_daemons): Likewise.
-       (threads_table_first): Likewise.
-       (threads_table_next): Likewise.
-       (threads_table_dump): Likewise.
-       (threads_list_first): New function.
-       (threads_list_next): Likewise.
-       (threads_list_get_non_daemons): Likewise.
-       (threads_thread_new): Likewise.
-       (threads_thread_free): Likewise.
-       (threads_thread_print_info): Added state-assert, print thread index.
-       (threads_thread_state_runnable): New function.
-       (threads_thread_state_waiting): Likewise.
-       (threads_thread_state_timed_waiting): Likewise.
-       (threads_thread_state_terminated): Likewise.
-       (threads_dump): Use threads-list functions.
-       
-       * src/threads/threads-common.h: Likewise.
-       (threads_table_entry_t): Removed.
-       (threads_table_t): Likewise.
-       
-       * src/threads/native/threads.c (mutex_threads_table): Renamed to
-       mutex_threads_list.
-       (threads_cast_sendsignals): Use threads-list functions.
-       (threads_table_lock): Renamed to threads_list_lock.
-       (threads_table_unlock): Renamed to threads_list_unlock.
-       (threads_startup_thread): Use threads-state functions.
-       (threads_detach_thread): Likewise.
-       (threads_wait_with_timeout): Likewise.
-       (threads_join_all_threads): Use threads-list functions.
-       
-       * src/threads/native/threads.h (threadobject): Added linkage.
-
-2007-05-23 23:56  ajordan
-
-       * src/vm/jit/sparc64/Makefile.am: Added missing emit.h.
-
-2007-05-23 22:54  ajordan
-
-       * src/vm/jit/sparc64/Makefile.am:
-       md-asm.h was not properly added to noinst_HEADERS.
-
-2007-05-23 22:04  twisti
-
-       * configure.ac (AM_INIT_AUTOMAKE): Added dist-bzip2.
-
-2007-05-23 19:37  twisti
-
-       * src/threads/threads-common.h (THREAD_STATE_NEW)
-       (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING)
-       (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Start states
-       with 1, so we can catch unset states.
-
-2007-05-23 19:11  twisti
-
-       * src/vm/jit/powerpc64/linux/md-os.c (md_critical_section_restart):
-       Fixed typo.
-
-2007-05-23 18:28  twisti
-
-       * src/vm/jit/mips/Makefile.am (DIST_SUBDIRS): Added uclinux.
-
-2007-05-23 18:08  twisti
-
-       * src/vmcore/statistics.c (statistics_print_memory_usage): Smaller
-       output changes.
-
-2007-05-23 18:05  twisti
-
-       * src/vm/jit/arm/linux/md-os.c,
-       src/vm/jit/alpha/linux/md-os.c,
-       src/vm/jit/i386/linux/md-os.c,
-       src/vm/jit/powerpc/linux/md-os.c,
-       src/vm/jit/powerpc64/linux/md-os.c,
-       src/vm/jit/x86_64/linux/md-os.c (md_critical_section_restart): Removed
-       debug output.
-
-2007-05-23 17:58  twisti
-
-       * src/threads/native/lock.c: Set Id keyword.
-       * src/threads/native/lock.h: Likewise.
-
-2007-05-23 17:56  twisti
-
-       * src/native/vm/gnu/java_lang_VMClassLoader.c (getPrimitiveClass):
-       Return NULL in error case.
-
-2007-05-23 17:53  twisti
-
-       * src/vm/jit/optimizing/profile.c: Set Id keyword.
-
-2007-05-23 17:51  twisti
-
-       * src/vm/jit/optimizing/profile.c (profile_thread): Replaced table-
-       with list-functions.
-       * src/vm/vm.c (vm_create): Use vm_abort for profile_start_thread.
-
-2007-05-23 17:46  twisti
-
-       * src/vm/jit/jit.c (jit_compile_intern): Fixed typo.
-
-2007-05-23 16:00  twisti
-
-       * src/vm/exceptions.c (exceptions_new_hardware_exception): Fixed
-       warning.
-
-2007-05-23 15:57  twisti
-
-       * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Fixed warning.
-       * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv):
+2008-06-14  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac:
+       * configure.ac (AC_INIT): Bumped version to 0.99. (OPT_CFLAGS): Set
+       to -O2.
+       [ea12d8e7f38d] [tip]
+
+       * NEWS:
+       * NEWS: Added latest 0.99 news.
+       [3d976222eac4]
+
+       * src/vm/properties.c:
+       * src/vm/properties.c (properties_set): Changed java.vm.vendor to
+       CACAOVM - Verein zur Foerderung der freien virtuellen Maschine
+       CACAO.
+       [801e8faac4a0]
+
+       * .hgignore, configure.ac, tests/regression/Makefile.am,
+       tests/regression/base/All.java, tests/regression/base/Makefile.am,
+       tests/regression/base/TestExceptionInStaticClassInitializer.java,
+       tests/regression/base/TestPatcher.java,
+       tests/regression/junit/All.java, tests/regression/junit/Makefile.am,
+       tests/regression/junit/TestExceptionInStaticClassInitializer.java,
+       tests/regression/junit/TestPatcher.java:
+       * .hgignore: Removed tests/regression/junit/*.class, added
+       tests/regression/base/*.class.
+       * configure.ac (AC_CONFIG_FILES): Removed
+       tests/regression/junit/Makefile, added
+       tests/regression/base/Makefile.
+       * tests/regression/Makefile.am (SUBDIRS): Removed junit, added base.
+       * tests/regression/junit/All.java, tests/regression/junit/Makefile.am,
+       tests/regression/junit/TestExceptionInStaticClassInitializer.java,
+       tests/regression/junit/TestPatcher.java: Moved from here...
+       * tests/regression/base/All.java, tests/regression/base/Makefile.am,
+       tests/regression/base/TestExceptionInStaticClassInitializer.java,
+       tests/regression/base/TestPatcher.java: ...to here.
+       [c08a0a544e42]
+
+2008-06-13  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac:
+       * configure.ac: Bumped _XOPEN_SOURCE version to 600.
+       [fcabb9585a21]
+
+       * src/vm/builtin.c, tests/regression/bugzilla/All.java,
+       tests/regression/bugzilla/PR80.java:
+       Fixes PR80.
+       * src/vm/builtin.c (builtin_arraycopy): Fixed range checks, cast to
+       unsigned values.
+       * tests/regression/bugzilla/All.java (suite): Added PR80.
+       * tests/regression/bugzilla/PR80.java: New file.
+       [75bfed30df25]
+
+       * autogen.sh:
+       * autogen.sh (CACAO_ACLOCAL): Added aclocal-1.10. (CACAO_AUTOMAKE):
+       Added automake-1.10.
+       [f1f4b00872fb]
+
+2008-06-12  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac:
+       * configure.ac (AC_INIT): Bumped version to 0.99rc7.
+       (AM_INIT_AUTOMAKE): Added tar-ustar for long filename support
+       (thanks to Mark Wielaard). (OPT_CFLAGS): Only use -g to be portable.
+       [b35960d5977e]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_run): Fixed compiler warning.
+       [62e3843fdbfa]
+
+       * src/vm/jit/i386/darwin/md-os.c:
+       * src/vm/jit/i386/darwin/md-os.c: Ported to UNIX03
+       (__DARWIN_UNIX03).
+       [f8847b43a1aa]
+
+       * src/threads/posix/thread-posix.c:
+       * src/threads/posix/thread-posix.c (threads_startup_thread)
+       [__DARWIN__]: Don't register the thread to Boehm-GC, it's not
+       implemented yet.
+       [dfff3126e8cb]
+
+       * configure.ac, src/vm/global.h:
+       * configure.ac (INTRP_CFLAGS, ARCH_CFLAGS): Use -std=c99 instead of
+       -ansi and bumped _POSIX_C_SOURCE to version 200112L.
+       (AC_CHECK_HEADERS): Added stdbool.h and stdint.h.
+       * src/vm/global.h (boolm true, false): Removed.
+       [f2cd982f6ab5]
+
+       * src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/x86_64/emit.c (emit_store): Removed inline keyword.
+       [6c549a21d7ec]
+
+       * src/toolbox/set.c, src/toolbox/set.h:
+       * src/toolbox/set.c (config.h): Added. (vm/global.h): Likewise.
+       * src/toolbox/set.h (config.h): Likewise.
+       [7b5a9fbd4309]
+
+       * * Merged with tip.
+       [e195cdba0d70]
+
+       * configure.ac, m4/dl.m4, m4/ltdl.m4, src/cacao/cacao.c,
+       src/native/native.c, src/native/native.h,
+       src/native/vm/gnuclasspath/java_lang_VMRuntime.c,
+       src/vmcore/system.h:
+       * configure.ac (AC_CHECK_ENABLE_LTDL): Removed.
+       (AC_CHECK_ENABLE_DL): Added.
+       * m4/ltdl.m4: Removed.
+       * m4/dl.m4: New file.
+
+       * src/cacao/cacao.c [ENABLE_LIBJVM] (ltdl.h): Removed.
+       (vmcore/system.h): Added. (LIBJVM_NAME): New define. (main): Use
+       system_dl* functions.
+
+       * src/native/native.c: Replaced ltdl stuff with sytem_dl* stuff.
+       * src/native/native.h (NATIVE_LIBRARY_PREFIX): New define.
+       (NATIVE_LIBRARY_SUFFIX): Likewise.
+
+       * src/native/vm/gnuclasspath/java_lang_VMRuntime.c (mapLibraryName):
+       Use NATIVE_LIBRARY_* defines.
+
+       * src/vmcore/system.h [HAVE_DLFCN_H] (dlfcn.h): Added.
+       (system_dlclose): New function. (system_dlerror): Likewise.
+       (system_dlopen): Likewise. (system_dlsym): Likewise.
+       [9ce78261b91c]
+
+       * src/native/include/Makefile.am:
+       * src/native/include/Makefile.am (VM_ZIP) [ENABLE_ZLIB]: Added if.
+       [aba8982958ea]
+
+       * src/vm/jit/i386/darwin/md-os.c:
+       * src/vm/jit/i386/darwin/md-os.c: Fixed indent.
+       [377f38200eb2]
+
+       * src/native/jni.c, src/threads/posix/thread-posix.c,
+       src/threads/posix/thread-posix.h, src/threads/thread.c,
+       src/threads/thread.h, src/vm/vm.c:
+       Fixes PR77.
+       * src/native/jni.c (jni_attach_current_thread): Call
+       thread_attach_current_external_thread instead of
+       threads_attach_current_thread. (_Jv_JNI_AttachCurrentThread):
+       Renamed to jni_AttachCurrentThread. (_Jv_JNI_DetachCurrentThread):
+       Renamed to jni_DetachCurrentThread, call
+       thread_detach_current_external_thread instead of
+       threads_detach_thread. (_Jv_JNI_AttachCurrentThreadAsDaemon):
+       Renamed to jni_AttachCurrentThreadAsDaemon.
+
+       * src/threads/posix/thread-posix.c (threads_startup_thread)
+       [ENABLE_GC_BOEHM]: Call GC_register_my_thread. Call
+       thread_detach_current_thread instead of threads_detach_thread.
+       (threads_detach_thread): Removed. (thread_detach_current_thread):
+       New function.
+       * src/threads/posix/thread-posix.h (threads_detach_thread): Removed.
+
+       * src/threads/thread.c [ENABLE_GC_BOEHM] (mm/boehm-gc/include/gc.h):
+       Added. (threads_attach_current_thread): Renamed to
+       thread_attach_current_thread.
+       (thread_attach_current_external_thread): New function.
+       (thread_detach_current_external_thread): Likewise.
+       * src/threads/thread.h (threads_attach_current_thread): Removed.
+       (thread_attach_current_thread): Added.
+       (thread_attach_current_external_thread): Likewise.
+       (thread_detach_current_thread): Likewise.
+       (thread_detach_current_external_thread): Likewise.
+
+       * src/vm/vm.c (vm_run): Call thread_detach_current_thread instead of
+       threads_detach_thread. (vm_destroy): Call
+       thread_attach_current_thread instead of
+       threads_attach_current_thread.
+       [9aa5016cca58]
+
+2008-06-12  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * .hgtags:
+       Oops. Corrected cacao-0.97 tag.
+       [1bcb1eb6f00b]
+
+       * .hgtags:
+       Added tag cacao-0.98 for changeset 430cdebdf7d1
+       [93eb8ccd253b]
+
+       * .hgtags:
+       Added tag cacao-0.97 for changeset 430cdebdf7d1
+       [32222043ce3e]
+
+2008-06-09  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/cacaoh/dummy.c, src/vm/builtin.c, src/vm/builtin.h, src/vm/jit
+       /emit-common.h, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/emit.h, src/vmcore/class.c, src/vmcore/linker.c,
+       src/vmcore/linker.h:
+       * src/vm/builtin.c: Added fast_subtype_check.
+       (builtin_fast_canstore, builtin_fast_canstore_onedim,
+       builtin_fast_canstore_onedim_class): Using fast subtype check. Don't
+       need to lock linker_classrenumber_lock anymore.
+       * src/vm/builtin.h: Added fast_subtype_check.
+
+       * src/vm/jit/emit-common.h: Added more branch labels.
+
+       * src/vm/jit/x86_64/codegen.c (gen_method): New subtype checking
+       code.
+       * src/vm/jit/x86_64/codegen.h: Added some new mnemonics.
+       * src/vm/jit/x86_64/emit.c: New mnemonics. (emit_classcast_check): New
+       branch modes.
+       * src/vm/jit/x86_64/emit.h: New mnemonics.
+       * src/vmcore/class.c (class_isanysubclass): Using fast_subtype_check.
+
+       * src/vmcore/linker.c: Removed linker_classrenumber_lock.
+       (build_display): Implemented. (link_class_intern, link_array,
+       linker_compute_subclasses): Minor changes.
+
+       * src/vmcore/linker.h: Removed linker_compute_subclasses. Added
+       subtype-related fields to _vftbl.
+
+       * src/cacaoh/dummy.c: Added fast_subtype_check (link dependency).
+       [f4d2cd262a58]
+
+2008-06-11  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/emit.h,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/emit.h:
+       Fixes PR72.
+       * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Return value
+       expansion in native stubs (for gcc 4.3).
+       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Likewise.
+
+       * src/vm/jit/i386/codegen.h: Added more value extension operations.
+       * src/vm/jit/i386/emit.c: Likewise.
+       * src/vm/jit/i386/emit.h: Likewise.
+       * src/vm/jit/x86_64/codegen.h: Likewise.
+       * src/vm/jit/x86_64/emit.c: Likewise.
+       * src/vm/jit/x86_64/emit.h: Likewise.
+       [f4e23a5fb467]
+
+2008-06-11  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/arm/emit.c:
+       Fixes PR63.
+       * src/vm/jit/arm/emit.c (emit_verbosecall_enter) [ENABLE_SOFTFLOAT]:
+       Save and restore floating point types correctly.
+       [cc3688ed7116]
+
+       * src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/arm.h:
+       * src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/arm.h: Fixed comment
+       type.
+       [d5092d317d71]
+
+       * tests/havoc.class:
+       * tests/havoc.class: Removed binary file.
+       [0ec52c695779]
+
+2008-06-09  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_GetEnv): Renamed to jni_GetEnv.
+       [5e61d64d83a9]
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_PushLocalFrame): Renamed to
+       jni_PushLocalFrame, added trace output. (_Jv_JNI_PopLocalFrame):
+       Renamed to jni_PopLocalFrame. (_Jv_JNI_DeleteLocalRef): Renamed to
+       jni_DeleteLocalRef. (_Jv_JNI_NewLocalRef): Renamed to
+       jni_NewLocalRef. (_Jv_JNI_EnsureLocalCapacity): Renamed to
+       jni_EnsureLocalCapacity.
+       [b8487bde49f1]
+
+       * src/threads/thread.c:
+       * src/threads/thread.c (threads_preinit): Check if main thread index
+       is 1.
+       [e747bbe9a38e]
+
+       * src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java:
+       * src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java:
+       Updated to current GNU Classpath CVS version.
+       [d6187703cf55]
+
+2008-06-08  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * * Merged with 7d4cc49cbd31.
+       [b5d519382b16]
+
+       * configure.ac:
+       * configure.ac (AC_INIT): Bumped version to 0.99rc6. This reflects
+       the update to Boehm-GC 7.1.
+       [a7955e22203b]
+
+       * configure.ac, src/mm/boehm-gc/configure.in, src/mm/boehm-
+       gc/doc/Makefile.am, src/mm/boehm-gc/gcc_support.c, src/mm/boehm-
+       gc/include/Makefile.am, src/mm/boehm-gc/include/gc_alloc.h, src/mm
+       /boehm-gc/include/gc_inl.h, src/mm/boehm-
+       gc/include/gc_local_alloc.h, src/mm/boehm-
+       gc/include/private/solaris_threads.h, src/mm/boehm-gc/ltconfig,
+       src/mm/boehm-gc/pc_excludes, src/mm/boehm-
+       gc/powerpc_darwin_mach_dep.s, src/mm/boehm-gc/solaris_pthreads.c,
+       src/mm/boehm-gc/solaris_threads.c, src/mm/boehm-
+       gc/tests/trace_test.c, src/mm/boehm-gc/version.h:
+       * Merged with 31f9198caefc.
+       [fee37d480fb4]
+
+2008-06-05  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/mips.h:
+       Missed a file again, grrrrrrrrr.
+
+       * src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/mips.h: Patched.
+       [31f9198caefc]
+
+       * src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/s390.h:
+       S390 patch applied from Thiemo Seufer. This is also already applied
+       to bdwgc CVS.
+
+       * src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/s390.h: Patched.
+       [b5631b6d091a]
+
+       * src/mm/boehm-gc/include/private/gcconfig.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/Makefile.am, src/mm
+       /boehm-gc/mach_dep.c:
+       MIPS patches applied from Thiemo Seufer. These are also already
+       applied to bdwgc CVS.
+
+       * src/mm/boehm-gc/include/private/gcconfig.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/Makefile.am, src/mm
+       /boehm-gc/mach_dep.c: Patched.
+       [1386a607d249]
+
+       * src/mm/boehm-gc/Makefile.am:
+       * src/mm/boehm-gc/Makefile.am (AM_CPPFLAGS): Use libatomic_ops
+       instead of libatomic_ops-1.2, because only the former is linked into
+       the build directory. Maybe this should go upstream?
+       [8157901df4bf]
+
+       * src/threads/posix/thread-posix.c:
+       * src/threads/posix/thread-posix.c: Added a comment why we include
+       Boehm's gc.h.
+       [1382eba18ad3]
+
+       * configure.ac, src/mm/boehm-gc/configure.in, src/mm/boehm-
+       gc/doc/Makefile.am, src/mm/boehm-gc/gcc_support.c, src/mm/boehm-
+       gc/include/Makefile.am, src/mm/boehm-gc/include/gc_alloc.h, src/mm
+       /boehm-gc/include/gc_inl.h, src/mm/boehm-
+       gc/include/gc_local_alloc.h, src/mm/boehm-
+       gc/include/private/solaris_threads.h, src/mm/boehm-gc/ltconfig,
+       src/mm/boehm-gc/pc_excludes, src/mm/boehm-
+       gc/powerpc_darwin_mach_dep.s, src/mm/boehm-gc/solaris_pthreads.c,
+       src/mm/boehm-gc/solaris_threads.c, src/mm/boehm-
+       gc/tests/trace_test.c, src/mm/boehm-gc/version.h, src/threads/posix
+       /thread-posix.c:
+       * Merged gc7-branch to default.
+       [71c85ba866cf]
+
+2008-06-08  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.h,
+       src/vm/jit/optimizing/bytecode_escape.c,
+       src/vm/jit/optimizing/escape.c, src/vm/jit/optimizing/escape.h:
+       * src/vm/jit/i386/codegen.c (codegen_emit): Commented out escape
+       checks.
+       * src/vm/jit/i386/emit.h: Fixed typo.
+       * src/vm/jit/optimizing/bytecode_escape.c,
+       src/vm/jit/optimizing/escape.c, src/vm/jit/optimizing/escape.h:
+       Added copyright header.
+       [7d4cc49cbd31]
+
+2008-06-06  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/optimizing/escape.h:
+       * src/vm/jit/optimizing/escape.h: Added forgotten file.
+       [c8ec78cfd2db]
+
+       * configure.ac, src/vm/global.h, src/vm/jit/asmpart.h,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/emit.h,
+       src/vm/jit/optimizing/escape.c:
+       * configure.ac: [ENABLE_SSA] define ENABLE_ESCAPE_CHECK.
+       * src/vm/global.h [ENABLE_ESCAPE_CHECK] add additional fields to
+       java_object_t for escape analysis verification.
+       * src/vm/jit/asmpart.h, src/vm/jit/i386/asmpart.S
+       [ENABLE_ESCAPE_CHECK] (asm_escape_check): new symbol.
+       * src/vm/jit/i386/codegen.c [ENABLE_ESCAPE_CHECK] (codegen_emit):
+       First stetps of annotating all objects with escape information and
+       checking that information upon every access to an object.
+       * src/vm/jit/i386/emit.c, src/vm/jit/i386/emit.h (emit_escape_check):
+       New symbol.
+       * src/vm/jit/optimizing/escape.c (escape_analysis_escape_check): New
+       symbol.
+       [348a7d510d11]
+
+2008-06-05  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * .hgignore, src/mm/boehm-gc/NT_X64_THREADS_MAKEFILE, src/mm/boehm-
+       gc/include/extra/gc.h, src/mm/boehm-gc/include/extra/gc_cpp.h,
+       src/mm/boehm-gc/include/gc_version.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/armcc/arm_v6.h, src/mm
+       /boehm-gc/tests/huge_test.c, src/mm/boehm-gc/tests/smash_test.c,
+       src/mm/boehm-gc/version.h:
+       Files missed in the Boehm-GC 7.1 import (sorry).
+
+       * .hgignore: Added src/mm/boehm-gc/.dirstamp.
+       * src/mm/boehm-gc/NT_X64_THREADS_MAKEFILE: Added.
+       * src/mm/boehm-gc/include/extra/gc.h, src/mm/boehm-
+       gc/include/extra/gc_cpp.h, src/mm/boehm-gc/include/gc_version.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/armcc/arm_v6.h, src/mm
+       /boehm-gc/tests/huge_test.c, src/mm/boehm-gc/tests/smash_test.c:
        Likewise.
-
-2007-05-23 15:43  twisti
-
-       * configure.ac (OPT_CFLAGS): Changed to -O2.
-
-2007-05-23 15:25  twisti
-
-       * src/vm/jit/powerpc64/codegen.c (codegen_emit): ICMD_INSTANCEOF:
-       Removed unused supervftbl.
-       
-       * src/vm/jit/emit-common.h [__POWERPC64__] (emit_bnan): Enabled.
-
-2007-05-23 14:15  tbfg
-
-       * src/vm/jit/powerpc64/emit.c (MCODECHECK): Increase values to fix
-       canary corruption.
-       * src/vm/jit/powerpc64/codegen.c (MCODECHECK): Increase values to fix
-       canary corruption.
-
-2007-05-23 13:09  twisti
-
-       * src/vmcore/linker.c (linker_compute_subclasses): We don't ship the
-       critical-section stuff with this release, since it's broken on some
-       architectures because of boehm.
-
-2007-05-23 12:40  twisti
-
-       * src/vm/exceptions.c (threads/lock-common.h): Added.
-       [ENABLE_THREADS] (threads/native/threads.h): Removed.
-       [!ENABLE_THREADS] (threads/none/threads.h): Likewise.
-       (threads/threads-common.h): Added.
-       (new_exception_message): Removed.
-       (exceptions_throw_classcircularityerror): Use
-       exceptions_throw_utf_utf.
-       (exceptions_throw_classformaterror): Likewise.
-       (classnotfoundexception_to_noclassdeffounderror): Fixed warning.
-       (exceptions_throw_incompatibleclasschangeerror): Use
-       exceptions_throw_utf_utf.
-       (exceptions_throw_internalerror): Likewise.
-       (exceptions_throw_unsupportedclassversionerror): Likewise.
-       (exceptions_throw_verifyerror): Likewise.
-       (exceptions_throw_verifyerror_for_stack): Likewise.
-       (exceptions_new_arithmeticexception): Likewise.
-       (exceptions_new_classcastexception): Use exceptions_new_class_utf.
-       (exceptions_print_exception): Fixed warnings.
-       
-       * src/vmcore/utf8.c (utf_division_by_zero): Added.
-       (utf8_init): Likewise.
-       
-       * src/vmcore/utf8.h (utf_division_by_zero): Likewise.
-
-2007-05-23 11:59  twisti
-
-       * src/vm/exceptions.c (new_exception_int): Removed.
-       * src/vm/exceptions.h (new_exception_int): Likewise.
-       
-       * src/native/native.c (native_new_and_init_int): Likewise.
-       * src/native/native.h (native_new_and_init_int): Likewise.
-
-2007-05-23 09:40  tbfg
-
-       * src/vm/jit/m68k/codegen.c (codegen_emit): Remove NOP after each
-       ICMD.
-       Add NOP generation at end of basci block when patcher is longer than
-       instruction to be patched.
-       
-       * src/vm/jit/m68k/patcher.c (patcher_get_putfield): Implemented.
-       
-       * src/vm/jit/m68k/codegen.h (COMPILERSTUB_CODESIZE): Correct value.
-       
-       * src/vm/jit/codegen-common.c (codegen_increase): Enable NOP after
-       patcher generation at end of basic block.
-
-2007-05-23 09:37  tbfg
-
-       * src/vm/jit/abi.h (abi_registers_address_name): Added.
-       (abi_registers_address_argument): Likewise.
-       (abi_registers_address_saved): Likewise.
-       (abi_registers_address_temporary): Likewise.
-
-2007-05-22 11:18  twisti
-
-       * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Replaced
-       assert with vm_abort.
-
-2007-05-22 10:07  michi
-
-       * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Removed
-       obsolete SPLIT-stuff.
-
-2007-05-22 07:21  michi
-
-       * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Removed obsolete
-       SPLIT-stuff.
-
-2007-05-22 07:00  michi
-
-       * src/vm/jit/arm/md-abi.c (md_param_alloc): Align stack arguments as
-       well.
-       * src/vm/jit/arm/asmpart.S (asm_vm_call_method): Use EABI internally.
-
-2007-05-21 14:42  twisti
-
-       * src/vm/jit/arm/md-abi.c (md_param_alloc): Use EABI internally.
-       (ALIGN_2): Removed.
-       
-       * src/vm/jit/arm/codegen.c (codegen_emit): Removed SPLIT-stuff.
-       * src/vm/jit/arm/emit.c (emit_store): Likewise.
-
-2007-05-21 14:40  twisti
-
-       * src/vm/global.h (ALIGN_2): Added.
-
-2007-05-21 11:45  michi
-
-       * src/vm/jit/arm/codegen.h (M_EORLE): Added.
-       
-       * src/vm/jit/arm/codegen.c (codegen_emit): Fixed superindex overflow
-       for ICMD_INSTANCEOF and ICMD_CHECKCAST.
-       
-       * src/vm/jit/arm/patcher.c (patcher_checkcast_instanceof_interface):
-       Adapted patcher to above changes.
-
-2007-05-21 08:48  twisti
-
-       * src/native/include/Makefile.am (CLEANFILES): Simply clean an *.h
-       files.
-
-2007-05-21 08:27  twisti
-
-       * src/native/jni.c (_Jv_jni_CallLongMethodA): New function.
-       (_Jv_jni_CallFloatMethodA): Likewise.
-       (_Jv_jni_CallDoubleMethodA): Likewise.
-       (_Jv_JNI_CallStaticBooleanMethodA): Implemented.
-       (_Jv_JNI_CallStaticByteMethodA): Likewise.
-       (_Jv_JNI_CallStaticCharMethodA): Likewise.
-       (_Jv_JNI_CallStaticShortMethodA): Likewise.
-       (_Jv_JNI_CallStaticIntMethodA): Likewise.
-       (_Jv_JNI_CallStaticLongMethodA): Likewise.
-       (_Jv_JNI_CallStaticFloatMethodA): Likewise.
-       (_Jv_JNI_CallStaticDoubleMethodA): Likewise.
-
-2007-05-18 15:05  twisti
-
-       * src/native/vm/cldc1.1/java_lang_Object.c (getClass): Fixed
-       signature.
-
-2007-05-18 14:24  twisti
-
-       * src/vmcore/statistics.c (count_nstub_len): Renamed to
-       size_stub_native.
-       (statistics_print_memory_usage): Likewise.
-       
-       * src/vmcore/statistics.h: Likewise.
-       
-       * src/vm/jit/codegen-common.c (codegen_generate_stub_native):
-       Likewise, moved statistics-calculation after codegen_finish(), so
-       actually something is counted.
-
-2007-05-18 14:22  twisti
-
-       * src/toolbox/list.c (list_create): Use LOCK_INIT_OBJECT_LOCK-macro.
-
-2007-05-18 14:17  twisti
-
-       * src/threads/threads-common.c (threads_thread_get_state): Fixed
-       compiler warning.
-       (threads_thread_is_alive): Likewise.
-
-2007-05-18 13:45  twisti
-
-       * src/native/vm/cldc1.1/java_lang_String.c (methods): Removed
-       quick-hack.
-       
-       * src/native/vm/cldc1.1/java_lang_Throwable.c (fillInStackTrace):
-       Fixed signature.
-
-2007-05-18 13:12  twisti
-
-       * src/native/native.c (native_tree_native_methods_comparator): Compare
-       classname, name and descriptor.
-       (native_method_register): Set all structure members.
-       (native_method_find): Changed argument-type to methodinfo.
-       (native_resolve_function): Likewise.
-       
-       * src/native/native.h (native_methods_node_t): Added classname and
-       descriptor, renamed method to function.
-       
-       * src/native/vm/gnu/java_lang_VMClass.c: Updated wrong signatures.
-       * src/native/vm/gnu/java_lang_VMObject.c: Likewise.
-       * src/native/vm/gnu/java_lang_VMThread.c: Likewise.
-       * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise.
-
-2007-05-16 09:01  twisti
-
-       * src/native/native.c (native_library_open): New function.
-       (native_hashtable_library_add): Renamed to native_library_add.
-       (native_hashtable_library_find): Renamed to native_library_find.
-       * src/native/native.h: Likewise.
-       
-       * src/native/vm/java_lang_Runtime.c (loadLibrary): Use
-       native_library_open.
-
-2007-05-16 08:02  twisti
-
-       * src/native/native.c: Removed all native-includes.
-       (dummynativetable): Removed.
-       (mainhandle): Likewise.
-       (native_init): Don't dlopen libjvm, initialize the native-methods
-       tree.
-       (native_tree_native_methods_comparator): New function.
-       (native_method_symbol): Likewise.
-       (native_method_find): Likewise.
-       (native_resolve_function): Use native-methods tree for internal native
-       methods.
-       
-       * src/native/native.h (native/jni.h): Added.
-       (NATIVE_METHODS_COUNT): Defined.
-       (native_methods_node_t): New structure.
-       (native_method_register): Added.
-       
-       * src/native/vm/nativevm.c: New file.
-       * src/native/vm/nativevm.h: Likewise.
-       
-       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
-       nativevm.[ch].
-       
-       * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
-       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
-       src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c,
-       src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
-       src/native/vm/cldc1.1/java_lang_Class.c,
-       src/native/vm/cldc1.1/java_lang_Double.c,
-       src/native/vm/cldc1.1/java_lang_Float.c,
-       src/native/vm/cldc1.1/java_lang_Math.c,
-       src/native/vm/cldc1.1/java_lang_Object.c,
-       src/native/vm/cldc1.1/java_lang_Runtime.c,
-       src/native/vm/cldc1.1/java_lang_String.c,
-       src/native/vm/cldc1.1/java_lang_System.c,
-       src/native/vm/cldc1.1/java_lang_Thread.c,
-       src/native/vm/cldc1.1/java_lang_Throwable.c,
+       * src/mm/boehm-gc/version.h: Removed.
+       [0340b2f6a236]
+
+       * src/mm/boehm-gc/configure.ac, src/mm/boehm-
+       gc/libatomic_ops-1.2/configure.ac:
+       * src/mm/boehm-gc/configure.ac: Made autogen.sh warning free.
+       * src/mm/boehm-gc/libatomic_ops-1.2/configure.ac: Likewise.
+       [7256403a4a32]
+
+       * src/mm/boehm-gc/ChangeLog, src/mm/boehm-gc/Makefile.am, src/mm
+       /boehm-gc/Makefile.direct, src/mm/boehm-gc/Makefile.dj, src/mm
+       /boehm-gc/NT_X64_STATIC_THREADS_MAKEFILE, src/mm/boehm-
+       gc/add_gc_prefix.c, src/mm/boehm-gc/allchblk.c, src/mm/boehm-
+       gc/alloc.c, src/mm/boehm-gc/backgraph.c, src/mm/boehm-
+       gc/configure.ac, src/mm/boehm-gc/darwin_stop_world.c, src/mm/boehm-
+       gc/dbg_mlc.c, src/mm/boehm-gc/doc/README, src/mm/boehm-
+       gc/doc/README.macros, src/mm/boehm-gc/doc/README.win32, src/mm
+       /boehm-gc/doc/README.win64, src/mm/boehm-gc/doc/gcinterface.html,
+       src/mm/boehm-gc/doc/scale.html, src/mm/boehm-gc/dyn_load.c, src/mm
+       /boehm-gc/finalize.c, src/mm/boehm-gc/gc_cpp.cc, src/mm/boehm-
+       gc/gcname.c, src/mm/boehm-gc/headers.c, src/mm/boehm-
+       gc/include/gc.h, src/mm/boehm-gc/include/gc_cpp.h, src/mm/boehm-
+       gc/include/gc_inline.h, src/mm/boehm-gc/include/gc_tiny_fl.h, src/mm
+       /boehm-gc/include/include.am, src/mm/boehm-
+       gc/include/private/gc_locks.h, src/mm/boehm-
+       gc/include/private/gc_pmark.h, src/mm/boehm-
+       gc/include/private/gc_priv.h, src/mm/boehm-
+       gc/include/private/gcconfig.h, src/mm/boehm-
+       gc/include/private/thread_local_alloc.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/ChangeLog, src/mm/boehm-
+       gc/libatomic_ops-1.2/doc/README.txt, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/generalize.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/arm.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/powerpc.h, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86.h, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86_64.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc/x86.h, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc/x86_64.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/standard_ao_double_t.h,
+       src/mm/boehm-gc/mach_dep.c, src/mm/boehm-gc/malloc.c, src/mm/boehm-
+       gc/mark.c, src/mm/boehm-gc/mark_rts.c, src/mm/boehm-gc/misc.c,
+       src/mm/boehm-gc/msvc_dbg.c, src/mm/boehm-gc/obj_map.c, src/mm/boehm-
+       gc/os_dep.c, src/mm/boehm-gc/pthread_stop_world.c, src/mm/boehm-
+       gc/pthread_support.c, src/mm/boehm-gc/reclaim.c, src/mm/boehm-
+       gc/tests/test.c, src/mm/boehm-gc/tests/tests.am, src/mm/boehm-
+       gc/thread_local_alloc.c, src/mm/boehm-gc/typd_mlc.c, src/mm/boehm-
+       gc/win32_threads.c:
+       * Imported Boehm-GC 7.1.
+       [a09ac5792898]
+
+       * .hgignore:
+       * .hgignore: Added src/mm/boehm-gc/atomic_ops.c, src/mm/boehm-
+       gc/atomic_ops_sysdeps.S, src/mm/boehm-gc/bdw-gc.pc, src/mm/boehm-
+       gc/libatomic_ops, src/mm/boehm-gc/cord/.dirstamp.
+       [c0c33aa59df7]
+
+       * configure.ac, src/mm/boehm-gc/Makefile.am, src/mm/boehm-
+       gc/cord/cord.am:
+       * configure.ac (ac_configure_args): Removed --disable-shared, add
+       --disable-static.
+       * src/mm/boehm-gc/Makefile.am (lib_LTLIBRARIES): Renamed to
+       noinst_LTLIBRARIES.
+       * src/mm/boehm-gc/cord/cord.am: Likewise.
+       [ded63b659817]
+
+2008-06-01  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * configure.ac, src/vm/global.h, src/vm/jit/cfg.c, src/vm/jit/jit.c,
+       src/vm/jit/jit.h, src/vm/jit/optimizing/Makefile.am,
+       src/vm/jit/optimizing/bytecode_escape.c,
+       src/vm/jit/optimizing/escape.c, src/vm/jit/optimizing/ssa3.c,
+       src/vmcore/method.h:
+       * configure.ac: Define ENABLE_ESCAPE if ENABLE_SSA is defined.
+       * src/vm/global.h (ACC_METHOD_EA): new symbol.
+       * src/vm/jit/cfg.c (cfg_add_root): correctly initialize method member
+       of basicblock.
+       * src/vm/jit/jit.c (basicblock) [ENABLE_SSA]: new members phis and
+       phicount.
+       * src/vm/jit/jit.h (jit_compile_intern): Transform exception handlers
+       only if -lsra is given.
+       * src/vm/jit/optimizing/Makefile.am: Adpated.
+       * src/vm/jit/optimizing/bytecode_escape.c: New file. Implementation of
+       escape analysis on bytecode.
+       * src/vm/jit/optimizing/escape.c: Changed a lot.
+       * src/vm/jit/optimizing/ssa3.c: Changed a lot.
+       * src/vmcore/method.h (methodinfo) [ENABLE_ESCAPE]: New member
+       paramescape.
+       [76f979c4a7dc]
+
+2008-05-19  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * m4/classpath.m4, src/classes/gnu/gnu/classpath/VMStackWalker.java,
+       src/classes/gnu/gnu/classpath/VMSystemProperties.java,
+       src/classes/gnu/gnu/java/lang/CPStringBuilder.java,
+       src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java,
+       src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java,
+       src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/classes/gnu/java/lang/VMClassLoader.java,
+       src/classes/gnu/java/lang/VMString.java,
+       src/classes/gnu/java/lang/VMThread.java,
+       src/classes/gnu/java/lang/reflect/Constructor.java,
+       src/classes/gnu/java/lang/reflect/Field.java,
+       src/classes/gnu/java/lang/reflect/Method.java,
+       src/classes/gnu/java/lang/reflect/Modifier.java,
+       src/classes/gnu/java/lang/reflect/VMConstructor.java,
+       src/classes/gnu/java/lang/reflect/VMField.java,
+       src/classes/gnu/java/lang/reflect/VMMethod.java,
+       src/classes/gnu/java/security/VMAccessController.java,
+       src/classes/gnu/sun/misc/Unsafe.java,
+       src/classes/gnu/sun/reflect/ConstantPool.java,
+       src/classes/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/classes/gnu/sun/reflect/annotation/AnnotationType.java, src/clas
+       ses/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.
+       java, src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentE
+       xceptionProxy.java,
+       src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java, src/clas
+       ses/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java,
+       src/native/vm/gnu/Makefile.am, src/native/vm/gnu/VMjdwp.c,
+       src/native/vm/gnu/VMjdwp.h,
        src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
        src/native/vm/gnu/gnu_classpath_VMSystemProperties.c,
-       src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c,
+       src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c, src/native/vm/g
+       nu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
        src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
        src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
        src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
        src/native/vm/gnu/java_lang_VMThread.c,
        src/native/vm/gnu/java_lang_VMThrowable.c,
        src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
-       src/native/vm/gnu/java_lang_reflect_Constructor.c,
-       src/native/vm/gnu/java_lang_reflect_Field.c,
-       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/java_lang_reflect_VMConstructor.c,
+       src/native/vm/gnu/java_lang_reflect_VMField.c,
+       src/native/vm/gnu/java_lang_reflect_VMMethod.c,
        src/native/vm/gnu/java_lang_reflect_VMProxy.c,
        src/native/vm/gnu/java_security_VMAccessController.c,
-       src/native/vm/gnu/sun_misc_Unsafe.c: Added methods table and init
-       function to register the native methods.
-
-2007-05-15 10:32  tbfg
-
-       * src/vm/jit/powerpc64/patcher.c
-       (patcher_resolve_classref_to_classinfo): Patch back original code.
-       
-       (patcher_resolve_classref_to_vftbl): Likewise.
-       (patcher_resolve_classref_to_flags): Likewise.
-       
-       * src/vm/jit/powerpc64/asmpart.S (DARWIN): Removed all darwin
-       ifdefed code for readability. Needs to be ported carefully anyways.
-       
-       (asm_vm_call_method): When handling arguments treat address type as
-       long.
-
-2007-05-15 09:55  christian
-
-       * src/vm/jit/codegen-common.c: (codegen_emit_phi_moves): Added.
-       (Former
-       codegen_insert_phi_moves from codegen.c)
-       
-       * src/vm/jit/codegen-common.h: Function prototype for
-       codegen_emit_phi_moves
-       added.
-       
-       * src/vm/jit/optimizing/lsra.c: Adapted to new instruction format and
-       unified
+       src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/openjdk/jvm.c, src/native/vm/sun/Makefile.am,
+       src/native/vm/sun/hpi.c, src/native/vm/sun/hpi.h,
+       src/native/vm/sun/jvm.c:
+       * Merged with tip.
+       [b3b00c455d2b]
+
+2008-05-08  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/m68k/linux/md-os.h, tests/regression/HelloWorld.java,
+       tests/regression/codepatching/Makefile.am,
+       tests/regression/codepatching/aastoreconstClass.java,
+       tests/regression/codepatching/checkcastC.java,
+       tests/regression/codepatching/checkcastI.java,
+       tests/regression/codepatching/getfieldD.java,
+       tests/regression/codepatching/getfieldF.java,
+       tests/regression/codepatching/getfieldI.java,
+       tests/regression/codepatching/getfieldJ.java,
+       tests/regression/codepatching/getfieldL.java,
+       tests/regression/codepatching/getstaticD.java,
+       tests/regression/codepatching/getstaticF.java,
+       tests/regression/codepatching/getstaticI.java,
+       tests/regression/codepatching/getstaticJ.java,
+       tests/regression/codepatching/getstaticL.java,
+       tests/regression/codepatching/instanceofC.java,
+       tests/regression/codepatching/instanceofI.java,
+       tests/regression/codepatching/invokespecial.java,
+       tests/regression/codepatching/invokestatic.java,
+       tests/regression/codepatching/multianewarray.java,
+       tests/regression/codepatching/newarray.java,
+       tests/regression/codepatching/putfieldD.java,
+       tests/regression/codepatching/putfieldF.java,
+       tests/regression/codepatching/putfieldI.java,
+       tests/regression/codepatching/putfieldJ.java,
+       tests/regression/codepatching/putfieldL.java,
+       tests/regression/codepatching/putfieldconstC.java,
+       tests/regression/codepatching/putfieldconstD.java,
+       tests/regression/codepatching/putfieldconstF.java,
+       tests/regression/codepatching/putfieldconstI.java,
+       tests/regression/codepatching/putfieldconstJ.java,
+       tests/regression/codepatching/putfieldconstL.java,
+       tests/regression/codepatching/putstaticD.java,
+       tests/regression/codepatching/putstaticF.java,
+       tests/regression/codepatching/putstaticI.java,
+       tests/regression/codepatching/putstaticJ.java,
+       tests/regression/codepatching/putstaticL.java,
+       tests/regression/codepatching/putstaticconstC.java,
+       tests/regression/codepatching/putstaticconstD.java,
+       tests/regression/codepatching/putstaticconstF.java,
+       tests/regression/codepatching/putstaticconstI.java,
+       tests/regression/codepatching/putstaticconstJ.java,
+       tests/regression/codepatching/putstaticconstL.java,
+       tests/regression/codepatching/test.java,
+       tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j,
+       tests/regression/jasmin/test_verify_fail_jsr_recursion.j,
+       tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j:
+       * Merged with tip.
+       [b0f1bca06030]
+
+2008-04-26  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_GetEnclosingMethodInfo): Use
+       class_get_enclosingmethod_raw instead of class_get_enclosingmethod.
+       [14d10bd7f425]
+
+2008-05-15  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/classes/gnuclasspath/java/lang/.VMClassLoader.java.swp:
+       * src/classes/gnuclasspath/java/lang/.VMClassLoader.java.swp:
+       Removed. How did this get in?
+       [7c99307ac907]
+
+2008-05-14  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * m4/classpath.m4, src/classes/gnu/gnu/classpath/VMStackWalker.java,
+       src/classes/gnu/gnu/classpath/VMSystemProperties.java,
+       src/classes/gnu/gnu/java/lang/CPStringBuilder.java,
+       src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java,
+       src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java,
+       src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/classes/gnu/java/lang/VMClassLoader.java,
+       src/classes/gnu/java/lang/VMString.java,
+       src/classes/gnu/java/lang/VMThread.java,
+       src/classes/gnu/java/lang/reflect/Constructor.java,
+       src/classes/gnu/java/lang/reflect/Field.java,
+       src/classes/gnu/java/lang/reflect/Method.java,
+       src/classes/gnu/java/lang/reflect/Modifier.java,
+       src/classes/gnu/java/lang/reflect/VMConstructor.java,
+       src/classes/gnu/java/lang/reflect/VMField.java,
+       src/classes/gnu/java/lang/reflect/VMMethod.java,
+       src/classes/gnu/java/security/VMAccessController.java,
+       src/classes/gnu/sun/misc/Unsafe.java,
+       src/classes/gnu/sun/reflect/ConstantPool.java,
+       src/classes/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/classes/gnu/sun/reflect/annotation/AnnotationType.java, src/clas
+       ses/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.
+       java, src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentE
+       xceptionProxy.java,
+       src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java, src/clas
+       ses/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java,
+       src/classes/gnuclasspath/java/lang/.VMClassLoader.java.swp,
+       src/native/vm/gnu/Makefile.am, src/native/vm/gnu/VMjdwp.c,
+       src/native/vm/gnu/VMjdwp.h,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c,
+       src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c, src/native/vm/g
+       nu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
+       src/native/vm/gnu/java_lang_reflect_VMConstructor.c,
+       src/native/vm/gnu/java_lang_reflect_VMField.c,
+       src/native/vm/gnu/java_lang_reflect_VMMethod.c,
+       src/native/vm/gnu/java_lang_reflect_VMProxy.c,
+       src/native/vm/gnu/java_security_VMAccessController.c,
+       src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/sun/Makefile.am, src/native/vm/sun/hpi.c,
+       src/native/vm/sun/hpi.h, src/native/vm/sun/jvm.c, src/vm/jit/jit.c:
+       Merging 8179.
+       [e1df59a7c5b8]
+
+       * src/vm/jit/cfg.c, src/vm/jit/optimizing/ssa3.c:
+       * src/vm/jit/cfg.c: Changed all occurences of class to clazz.
+       * src/vm/jit/optimizing/ssa3.c: Removed accidentally forgotten diff
+       marker resulting from previous merge.
+       [3497103d748b]
+
+       * src/vm/jit/allocator/simplereg.c, src/vm/jit/cfg.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/icmdtable.inc,
+       src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/optimizing/ssa.c,
+       src/vm/jit/optimizing/ssa3.c, src/vm/jit/show.c:
+       * src/vm/jit/allocator/simplereg.c (simplereg_allocate_temporaries):
+       Support for ICMD_GETEXCEPTION.
+       * src/vm/jit/cfg.c (cfg_eliminate_edges_to_unreachable,
+       cfg_calculate_reachability, cfg_remove_predecessors,
+       cfg_eliminate_edges_to_unreachable): new functions.
+       * src/vm/jit/i386/codegen.c [ENABLE_SSA] (codegen_emit): Don't copy
+       itmp1 into invar 1 in exh blocks.
+       * src/vm/jit/icmdtable.inc (ICMD_GETEXCEPTION, ICMD_PHI): new opcodes.
+       * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_SSA]: Normalizing
+       exception handlers before SSA transformation.
+       * src/vm/jit/jit.h (var_is_inout): Correctly handling TYPE_RET
        variables.
-       
-       * src/vm/jit/optimizing/lsra.h: Likewise.
-       
-       * src/vm/jit/optimizing/ssa.c: Likewise.
-       
-       * src/vm/jit/optimizing/ssa.h: Likewise.
-       
-       * src/vm/jit/optimizing/graph.c: Likewise.
-       
-       * src/vm/jit/optimizing/graph.h: Likewise.
-       
-       * src/vm/jit/optimizing/dominators.c: Likewise.
-       
-       * src/vm/jit/optimizing/lifetimes.c: Likewise and changed lifetime
-       anaylsis to
-       a worklist algorithmus.
-       
-       * src/vm/jit/optimizing/lifetimes.h: Likewise.
-       
-       * src/vm/jit/i386/codegen.c: (codegen_insert_phi_moves): Moved to
-       src/vm/jit/codegen-common.c codegen_emit_phi_moves
-       (codegen_emit): Necessary Adaptions for SSA.
-       
-       * src/toolbox/worklist.c: (wl_reset): Added.
-       
-       * src/toolbox/worklist.h: Function Prototype for wl_reset added.
-       
-       * src/vm/jit/stack.c: Removed old SSA specific code.
-
-2007-05-15 09:25  tbfg
-
-       * builtin.c (builtin_ldiv): Needed when DISABLE_GC.
-
-2007-05-14 17:25  twisti
-
-       * src/native/native.c (native_class_getdeclaredannotations): Removed.
-
-2007-05-14 14:11  twisti
-
-       * src/toolbox/list.c (list_add_first): Call list_add_first_unsynced.
-       (list_add_first_unsynced): New function.
-       * src/toolbox/list.h (list_add_first_unsynced): Added.
-
-2007-05-14 13:29  twisti
-
-       * src/threads/threads-common.c (threads_create_thread): Renamed to
-       threads_thread_new.
-       (threads_thread_free): New function.
-       (threads_preinit): Renamed threads_create_thread to
-       threads_thread_new.
-       (threads_thread_start_internal): Likewise.
-       (threads_thread_start): Likewise.
-       
-       * src/threads/threads-common.h (threads_create_thread): Renamed to
-       threads_thread_new.
-       (threads_thread_free): Added.
-       (threads_init_threadobject): Renamed to threads_impl_thread_new.
-       (threads_impl_thread_free): Added.
-       
-       * src/threads/native/threads.c (toolbox/avl.h): Removed.
-       (threadattr): Likewise.
-       (threads_init_threadobject): Renamed to threads_impl_thread_new.
-       (threads_impl_thread_free): New function.
-       (threads_init): Use local pthread_attr_t.
-       (threads_impl_thread_start): Use pthread_attr_setdetachstate (fixes
-       memory leak), check more return values of pthread-calls.
-       (threads_attach_current_thread): Renamed threads_create_thread to
-       threads_thread_new.
-       (threads_detach_thread): Removed lock-record pools comment, call
-       threads_thread_free.
-
-2007-05-14 11:15  tbfg
-
-       * src/vm/jit/dseg.h (dseg_adddata): Removed warning due to typo.
-       
-       * src/vm/jit/m68k/arch.h (SUPPORT_LONG) Defined.
-       (SUPPORT_LONG_ADD): Defined.
-       (SUPPORT_CONST_LOGICAL): Defined.
-       
-       * src/vm/jit/m68k/codegen.c (ICMD_LADD): Implemented.
-       (ICMD_LADDCONST): Implemented.
-       (ICMD_LSUB): Implemented.
-       (ICMD_LSUBCONST): Implemented.
-       (ICMD_LNEG): Implemented.
-       
-       * src/vm/jit/m68k/codegen.h (M_ISUBX): Added.
-       (M_INEGX): Added.
-
-2007-05-11 22:33  twisti
-
-       * configure.ac (AC_CHECK_HEADERS): Added time.h.
-       (AC_CHECK_FUNCS): Added localtime, localtime_r, time.
-       
-       * src/vmcore/statistics.c [HAVE_TIME_H] (time.h): Added.
-       (statistics_print_date): New function.
-       * src/vmcore/statistics.h (statistics_print_date): Added.
-       
-       * src/mm/memory.c (memory_thread) [ENABLE_STATISTICS]: Call
-       statistics_print_date.
-
-2007-05-11 21:18  twisti
-
-       * src/vmcore/statistics.c (statistics_print_memory_usage): Use
-       log_println instead of printf.
-
-2007-05-11 20:35  twisti
-
-       * src/vm/jit/arm/codegen.c (codegen_emit): Use
-       CODEGEN_CRITICAL_SECTION_* macros.
-       
-       * src/vm/jit/arm/linux/md-os.c (thread_restartcriticalsection):
-       Renamed to md_critical_section_restart.
-
-2007-05-11 19:31  twisti
-
-       * src/threads/threads-common.c (threads_create_thread): Removed
-       lock_init_execution_env.
-       
-       * src/threads/lock-common.h (lock_init_execution_env): Removed.
-       (lock_record_free_pools): Likewise.
-       
-       * src/threads/native/threads.h (threadobject): Removed ee.
-       
-       * src/threads/native/lock.c (vm/finalizer.h): Added.
-       [ENABLE_GC_BOEHM] (mm/boehm-gc/include/gc.h): Likewise.
-       (lock_global_pool): Removed.
-       (lock_global_pool_lock): Likewise.
-       (lock_init): Don't initialize lock_global_pool_lock.
-       (lock_record_init): Removed.
-       (lock_init_execution_env): Likewise.
-       (lock_record_alloc_new_pool): Likewise.
-       (lock_record_alloc_pool): Likewise.
-       (lock_record_free_pools): Likewise.
-       (lock_record_alloc): Likewise.
-       (lock_record_recycle): Likewise.
-       (lock_hashtable_get_lock_record): Renamed to lock_hashtable_get.
-       (lock_record_new): New function.
-       (lock_record_free): Likewise.
-       (lock_hashtable_remove): Likewise.
-       [ENABLE_GC_BOEHM] (lock_record_finalizer): Likewise.
-       
-       * src/threads/native/lock.h (lock_execution_env_t): Removed.
-       (lock_record_pool_header_t): Likewise.
-       (lock_record_pool_t): Likewise.
-       (lock_record_t): Renamed obj to object, removed nextfree.
-       [ENABLE_JVMTI] (lock_global_pool_lock, lock_global_pool): Removed.
-       
-       * src/vmcore/statistics.c (size_lock_record_pool): Renamed to
-       size_lock_record.
-       (statistics_print_memory_usage): Likewise.
-       * src/vmcore/statistics.h: Likewise.
-
-2007-05-11 18:58  tbfg
-
-       * src/vm/jit/m68k/linux/md-abi.h (ADR_SAV_CNT): Increased by one
-       (%fp).
-       (ADR_RES_CNT): Decreased by one (%fp).
-       
-       * src/vm/jit/m68k/linux/md-abi.c (nregdescadr): Declared %fp a
-       REG_SAV.
-       
-       * src/vm/jit/m68k/arch.h (SUPPORT_DIVISION): Defined.
-       
-       
-       * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Additional
-       logic to restore %fp when unwinding the stack.
-
-2007-05-11 18:23  twisti
-
-       * src/threads/native/threads.h (threadobject): Removed next and prev.
-
-2007-05-11 17:15  tbfg
-
-       * src/vm/jit/m68k/codegen.c (codegen_emit): Fix stackframesize
-       allocation in not synchronized methods which call a builtin returning
-       a double. Merged with ENABLE_THREADS case.
-       Added code to copy interface registers.
-       
-       * src/vm/jit/m68k/asmpart.S (asm_handle_exception):
-       Save temporary registers, dunno if really needed, but its a
-       slow path anyways.
-
-2007-05-10 14:34  tbfg
-
-       * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Make SOFTFLOAT
-       clean.
-       (emit_verbosecall_exit): Likewise.
-       
-       * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Mark comment about
-       gcc abi wiredness.
-       
-       * src/vm/jit/m68k/codegen.h (M_D2F): Fixed.
-       (M_F2D): Fixed.
-
-2007-05-10 14:04  twisti
-
-       * src/vmcore/options.c (opt_verbosethreads): Added.
-       * src/vmcore/options.h (opt_verbosethreads): Likewise.
-       
-       * src/vm/vm.c (XXusage): Added -verbose:threads.
-       (vm_create): Likewise.
-       
-       * src/threads/threads-common.c (threads_create_thread): Renamed
-       variable thread to t.
-       (threads_thread_print_info): New function.
-       (threads_dump): Use threads_thread_print_info.
-       
-       * src/threads/threads-common.h (threads_thread_print_info): Added.
-       
-       * src/threads/native/threads.c (threads_init) [!NDEBUG]: Added
-       -verbose:threads debug-output.
-       (threads_startup_thread): Likewise.
-       (threads_attach_current_thread): Likewise.
-       (threads_detach_thread): Likewise.
-
-2007-05-10 13:27  twisti
-
-       * src/threads/threads-common.c (threads_thread_start_internal): Set
-       thread-flags.
-       (threads_thread_start): Likewise.
-       
-       * src/threads/native/threads.c (threads_startup_thread): Don't set
-       thread-flags.
-
-2007-05-10 12:50  tbfg
-
-       * src/vm/jit/powerpc64/patcher.c (patcher_checkcast_interface):
-       Fixed not flushing all bytes written.
-
-2007-05-09 16:37  tbfg
-
-       * src/vm/jit/powerpc64/codegen.c (ICMD_CHECKCAST): Use
-       branch_label_* instead of harcoded jump offsets.
-       
-       (ICMD_INSTANCEOF): Likewise.
-
-2007-05-09 16:05  twisti
-
-       * src/lib/Makefile.am (VM_JAVA_FILES): Renamed vm/reference/ to gnu/.
-       
-       * src/lib/vm: Removed.
-       * src/lib/gnu: Added.
-       * src/lib/gnu/java: Likewise.
-       * src/lib/gnu/gnu: Likewise.
-
-2007-05-09 08:52  tbfg
-
-       * src/vm/jit/m68k/linux/md-abi.h (LA_SIZE_IN_POINTERS): Defined 0.
-       (PA_SIZE_IN_POINTERS): Removed.
-       (PA_SIZE): Removed.
-       (LA_LR_OFFSET): Removed.
-       (LA_SIZE_ALIGNED): Removed.
-       
-       * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Removed
-       linking instructions, save only used registers.
-       
-       (emit_verbosecall_exit): Likewise.
-       
-       * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Depends on
-       configure option ENABLE_SOFTFLOAT.
-       
-       * src/vm/jit/m68k/codegen.c (codegen_emit): Use M_FSTORE/M_FLOAT
-       to save/restore float registers without converting any values.
-       Fixed offset of IsSync.
-       
-       (codegen_emit_stub_native): Move floating point return values
-       into floating point registers.
-       
-       * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Save/restore
-       floating point registers.
-       
-       (asm_call_jit_compiler): Save/restore volatile floating point
-       registers.
-       
-       (asm_patcher_wrapper): Likewise.
-       
-       (asm_handle_exception): Use fmovemd instructions to restore
-       floatng point registers without converting.
-       
-       * src/vm/jit/m68k/codegen.h (M_FSTORE): Added.
-       (M_FLOAT): Added.
-
-2007-05-09 08:36  tbfg
-
-       * src/vm/jit/powerpc64/linux/md-os.c (thread_restartcriticalsection):
-       Renamed to md_critical_section_restart.
-       
-       * src/vm/jit/powerpc64/codegen.c (codegen_emit): Use
-       CODEGEN_CRITICAL_SECTION_* macros.
-
-2007-05-08 13:03  twisti
-
-       * src/configure.ac (AC_CHECK_HEADERS): Added string.h.
-       (AC_CHECK_FUNCS): Added strdup.
-       
-       * src/src/vmcore/options.c [HAVE_STRING_H] (string.h): Added #ifdef.
-       (options_get) HAVE_STRDUP]: Added.
-
-2007-05-07 21:34  twisti
-
-       * src/vm/jit/alpha/codegen.c (codegen_emit): Use
-       CODEGEN_CRITICAL_SECTION_* macros.
-       
-       * src/vm/jit/alpha/linux/md-os.c (thread_restartcriticalsection):
-       Renamed to md_critical_section_restart.
-
-2007-05-07 21:29  twisti
-
-       * src/threads/native/threads.c (mainthreadobj): Removed.
-       * src/threads/native/threads.h (mainthreadobj): Likewise.
-       
-       * src/vm/jit/optimizing/profile.c (threads/native/threads.h):
-       Likewise.
-       (profile_thread): Rewritten thread iteration.
-
-2007-05-07 15:07  ajordan
-
-       * src/vm/jit/sparc64/codegen.c (codegen_emit): Adapted to critical
-       section renames.
-       * src/vm/jit/sparc64/linux/md-os.c: Likewise.
-
-2007-05-07 14:26  tbfg
-
-       * src/vm/jit/m68k/codegen.c (ICMD_FNEG): Implemented.
-       (ICMD_DNEG): Implemented.
-       
-       * src/vm/jit/m68k/asmpart.S (asm_call_jit_compiler):
-       Store volatile floatregisters.
-       (asm_patcher_wrapper): Likewise.
-       (asm_handle_exception): Restore float registers.
-       
-       * src/vm/jit/m68k/codegen.h (M_FNEG): Added.
-       (M_DNEG): Added.
-
-2007-05-07 14:23  tbfg
-
-       * tests/exception_restore_registers.java: New test, tests if
-       variables get restored in case of exceptions.
-       
-       * tests/exception_restore_registers.output: New file, expected
-       output.
-       
-       * tests/Makefile.am: Added exception_restore_registers target.
-
-2007-05-07 14:16  twisti
-
-       * configure.ac (AC_CONFIG_FILES): Added
-       src/vm/jit/mips/uclinux/Makefile.
-       
-       * src/vm/jit/mips/uclinux: New directory.
-       * src/vm/jit/mips/uclinux/md-os.c: New file.
-       * src/vm/jit/mips/uclinux/Makefile.am: Likewise.
-
-2007-05-07 14:13  twisti
-
-       * src/vm/jit/mips/codegen.c (codegen_emit): Use
-       CODEGEN_CRITICAL_SECTION_* macros.
-       
-       * src/vm/jit/mips/linux/md-os.c (thread_restartcriticalsection):
-       Renamed to md_critical_section_restart.
-
-2007-05-07 13:45  twisti
-
-       * configure.ac (AC_CHECK_HEADERS): Added sys/mman.h, sys/resource.h.
-       (AC_CHECK_FUNCS): Added getrusage, mprotect.
-       
-       * src/vmcore/statistics.c [HAVE_SYS_TIME_H] (sys/time.h): Include
-       conditionally.
-       [HAVE_SYS_RESOURCE_H] (sys/resource.h): Likewise.
-       (getcputime) [!HAVE_GETRUSAGE]: Return 0.
-
-2007-05-07 13:31  twisti
-
-       * src/native/vm/java_lang_Thread.h (threads/native/threads.h):
-       Removed.
-
-2007-05-07 13:02  tbfg
-
-       * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Enabled.
-       (SUPPORT_FLOAT_CMP): Enabled.
-       (SUPPORT_DOUBLE): Enabled.
-       (SUPPORT_DOUBLE_CMP): Enabled.
-       
-       * src/vm/jit/m68k/codegen.c (ICMD_FCMPL): Implemented.
-       (ICMD_DCMPL): Likewise.
-       (ICMD_FCMPG): Likewise.
-       (ICMD_DCMPG): Likewise.
-       (ICMD_FMUL): Likewise.
-       (ICMD_DMUL): Likewise.
-       (ICMD_FDIV): Likewise.
-       (ICMD_DDIV): Likewise.
-       (ICMD_FADD): Likewise.
-       (ICMD_DADD): Likewise.
-       (ICMD_FSUB): Likewise.
-       (ICMD_DSUB): Likewise.
-       (ICMD_F2D): Likewise.
-       (ICMD_D2F): Likewise.
-       (ICMD_BUILTIN): Handle float return values.
-       (codegen_emit_stub_native): Handle float values.
-       
-       * src/vm/jit/m68k/codegen.h (M_FCMP): Added.
-       (M_BFEQ): Added.
-       (M_BFLT): Added.
-       (M_BFGT): Added.
-       (M_BFUN): Added.
-       (M_FADD): Added.
-       (M_DADD): Added.
-       (M_FSUB): Added.
-       (M_DSUB): Added.
-       (M_FMUL): Added.
-       (M_DMUL): Added.
-       (M_FDIV): Added.
-       (M_DDIV): Added.
-       (M_D2F): Added.
-       (M_F2D): Added.
-
-2007-05-07 11:37  twisti
-
-       * src/threads/threads-common.c (threads_dump): Typo.
-
-2007-05-07 11:35  twisti
-
-       * src/threads/threads-common.c (threads_table_get): Made static and
-       removed table lock.
-       (threads_dump): Lock threads table.
-       
-       * src/threads/threads-common.h (threads_table_get): Removed.
-       
-       * src/threads/native/threads.c (threads_cast_stopworld): Lock threads
-       table.
-       (threads_cast_startworld): Likewise.
-
-2007-05-07 01:44  ajordan
-
-       * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed fp
-       arg passing.
-       * src/vm/jit/sparc64/md-abi.h: Likewise.
-       
-       * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method): Likewise, but
-       the other way around.
-       * src/vm/jit/sparc64/md-asm.h: Likewise.
-
-2007-05-06 22:20  tbfg
-
-       * src/vm/jit/m68k/codegen.c (codegen_emit): Allocate 2 additional
-       words in stackframe for long to double conversion.
-       
-       * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Copy exception
-       object into correct register.
-       
-       * src/vm/jit/m68k/codegen.h (M_FLD): Implemented.
-       (M_DLD): Likewise.
-       (M_FST): Likewise.
-       (M_DST): Likewise.
-       (M_FLTMOVE): Likewise.
-       (M_INT2FLTMOVE): Likewise.
-       (M_DBLMOVE): Likewise.
-       (FCONST): Likewise.
-
-2007-05-06 13:32  ajordan
-
-       * src/vm/jit/sparc64/codegen.c: Implemented threads support.
-       * src/vm/jit/sparc64/machine-instr.h: Likewise.
-       * src/vm/jit/sparc64/linux/md-os.c: Likewise.
-
-2007-05-05 13:48  tbfg
-
-       * src/vm/jit/m68k/emit.c (emit_patcher_stubs): Add thread
-       support.
-       (emit_exception_check_areg): Removed dead code.
-       
-       * src/vm/jit/m68k/codegen.c (codegen_emit): Add thread support.
-       
-       * src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Likewise.
-
-2007-05-05 13:46  tbfg
-
-       * linker.c (linker_compute_subclasses):
-       threads_cast_[start|stop]world only available when using GC.
-
-2007-05-05 08:08  pm
-
-       * contrib/vmlog/Makefile.am (AM_CPPFLAGS): Add include directories
-       for vmlog.
-       * src/vm/Makefile.am: Likewise.
-
-2007-05-04 10:13  tbfg
-
-       * linker.c (linker_compute_subclasses): Only call
-       threads_cast_[start|stop]world when ENABLE_THREADS.
-
-2007-05-03 23:31  tbfg
-
-       * src/vm/jit/m68k/md.c (md_stacktrace_get_returnaddress): Removed
-       braindead address check and fixed the real bug.
-       
-       * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Added float
-       argument handling.
-       (asm_call_jit_compiler): Fixed stack offset bug.
-
-2007-05-03 22:32  twisti
-
-       * src/vm/jit/x86_64/codegen.c (codegen_emit): Use
-       CODEGEN_CRITICAL_SECTION_* macros.
-       
-       * src/vm/jit/x86_64/linux/md-os.c (thread_restartcriticalsection):
-       Renamed to md_critical_section_restart.
-
-2007-05-03 21:29  twisti
-
-       * src/vm/jit/i386/codegen.c (codegen_emit): Use
-       CODEGEN_CRITICAL_SECTION_* macros.
-       
-       * src/vm/jit/i386/linux/md-os.c (thread_restartcriticalsection):
-       Renamed to md_critical_section_restart.
-
-2007-05-03 21:17  twisti
-
-       * src/threads/critical.c (critical_compare): Renamed to
-       critical_comparator.
-       (critical_find): Removed.
-       (critical_register_critical_section): Renamed to
-       critical_section_register.
-       (critical_find_restart_point): Call avl_find.
-       (critical_register_asm_critical_sections): Call
-       critical_section_register.
-       
-       * src/threads/critical.h (critical_section_node_t): Renamed members.
-       (thread_restartcriticalsection): Renamed to
-       md_critical_section_restart.
-       
-       * src/threads/native/threads.c (threads_cast_darwinstop): Call
-       md_critical_section_restart.
-       (threads_sigsuspend_handler): Likewise.
-       
-       * src/vmcore/linker.c (linker_compute_subclasses): Call
-       threads_cast_{start,stop}world, removed LOCK_MONITOR_{ENTER,EXIT}.
-       
-       * src/cacaoh/dummy.c (threads_cast_stopworld): Added.
-       (threads_cast_startworld): Likewise.
-       
-       * src/vm/jit/codegen-common.c (codegen_setup): Setup listcritical.
-       (codegen_reset): Likewise.
-       (codegen_critical_section_new): New function.
-       (codegen_critical_section_start): Likewise.
-       (codegen_critical_section_end): Likwise.
-       (codegen_critical_section_finish): Likewise.
-       (codegen_finish): Call codegen_critical_section_finish.
-       (codegen_threadcritrestart): Removed.
-       (codegen_threadcritstart): Likewise.
-       (codegen_threadcritstop): Likewise.
-       
-       * src/vm/jit/codegen-common.h (codegen_critical_section_t): Renamed to
-       critical_section_ref_t.
-       (codegendata): Added listcritical, removed threadcrit,
-       threadcritcurrent and threadcritcount.
-       (CODEGEN_CRITICAL_SECTION_NEW, CODEGEN_CRITICAL_SECTION_START)
-       (CODEGEN_CRITICAL_SECTION_END): Defined.
-       
-       * src/vm/jit/powerpc/codegen.c (codegen_emit): Use
-       CODEGEN_CRITICAL_SECTION_* macros.
-       
-       * src/vm/jit/powerpc/linux/md-os.c (thread_restartcriticalsection):
-       Renamed to md_critical_section_restart.
-
-2007-05-03 20:58  twisti
-
-       * src/mm/boehm-gc/include/gc.h (GC_HAVE_BUILTIN_BACKTRACE): Commented,
-       we don't need it and uClibc doesn't have it.
-
-2007-05-03 14:53  twisti
-
-       * src/toolbox/avl.c (toolbox/logging.h): Added.
-       (vm/global.h): Likewise.
-       (vm/vm.h): Likewise.
-       (avl_insert_intern): Use vm_abort instead of assert.
-       (avl_insert): Removed debug code.
-       (avl_dump): Use logging functions.
-
-2007-05-03 13:49  twisti
-
-       * src/vm/jit/codegen-common.c (codegen_start_native_call)
-       [ENABLE_JAVASE]: This has to be ENABLE_JNI.
-       (codegen_finish_native_call): Likewise.
-
-2007-05-03 12:30  twisti
-
-       * src/toolbox/avl.c (avl_insert_intern): Changed order of
-       comparator-arguments.
-       (avl_find): Likewise.
-       
-       * src/toolbox/avl.h (avl_comparator): Renamed arguments, to reflect
-       the change.
-       
-       * src/vm/jit/codegen-common.c (methodtree_comparator): Likewise.
-
-2007-05-03 08:29  twisti
-
-       * src/toolbox/avl.h (avl_tree): Renamed to avl_tree_t.
-       (avl_node): Renamed to avl_node_t.
-       
-       * src/toolbox/avl.c: Likewise.
-       * src/threads/critical.c: Likewise.
-       * src/vm/jit/codegen-common.c: Likewise.
-
-2007-05-03 08:16  twisti
-
-       * contrib/check_dangerous_printf.pl: Removed this file in favor of
-       pscan.
-
-2007-05-03 00:33  tbfg
-
-       * src/vm/jit/m68k/codegen.c (ICMD_CALOAD): Fixed.
-       
-       * src/vm/jit/m68k/patcher.c (*): Removed patching back of
-       old opcodes from patcher_wrapper, moved into each patcher.
-       (patcher_patch_back): Added.
-
-2007-05-02 22:28  tbfg
-
-       * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Fixed.
-       (ICMD_IREM): Fixed.
-       (ICMD_LASTORE): Use M_LST.
-       (ICMD_DASTORE): Use M_LST.
-       (ICMD_LALOAD): Use M_LLD.
-       (ICMD_DALOAD): Use M_LLD.
-
-2007-05-02 20:46  twisti
-
-       * src/native/vm/cldc1.1/java_lang_Float.c (native/native.h): Removed.
-       (native/include/java_lang_Float.h): Added.
-
-2007-05-02 20:44  twisti
-
-       * src/native/vm/cldc1.1/java_lang_Double.c
-       (native/include/java_lang_Double.h): Added.
-       (longBitsToDouble): Fixed return type.
-
-2007-05-02 20:40  twisti
-
-       * src/threads/threads-common.c (threads_table_get_threads): New
+       * src/vm/jit/optimizing/ssa.c: adapted.
+       * src/vm/jit/optimizing/ssa3.c: Changed a lot.
+       * src/vm/jit/show.c (show_icmd): Support for ICMD_GETEXCEPTION.
+       [3224e4058498]
+
+2008-05-14  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/classes/Makefile.am,
+       src/classes/gnu/gnu/classpath/VMStackWalker.java,
+       src/classes/gnu/gnu/classpath/VMSystemProperties.java,
+       src/classes/gnu/gnu/java/lang/CPStringBuilder.java,
+       src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java,
+       src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java,
+       src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/classes/gnu/java/lang/VMClassLoader.java,
+       src/classes/gnu/java/lang/VMString.java,
+       src/classes/gnu/java/lang/VMThread.java,
+       src/classes/gnu/java/lang/reflect/Constructor.java,
+       src/classes/gnu/java/lang/reflect/Field.java,
+       src/classes/gnu/java/lang/reflect/Method.java,
+       src/classes/gnu/java/lang/reflect/Modifier.java,
+       src/classes/gnu/java/lang/reflect/VMConstructor.java,
+       src/classes/gnu/java/lang/reflect/VMField.java,
+       src/classes/gnu/java/lang/reflect/VMMethod.java,
+       src/classes/gnu/java/security/VMAccessController.java,
+       src/classes/gnu/sun/misc/Unsafe.java,
+       src/classes/gnu/sun/reflect/ConstantPool.java,
+       src/classes/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/classes/gnu/sun/reflect/annotation/AnnotationType.java, src/clas
+       ses/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.
+       java, src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentE
+       xceptionProxy.java,
+       src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java, src/clas
+       ses/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java,
+       src/classes/gnuclasspath/gnu/classpath/VMStackWalker.java,
+       src/classes/gnuclasspath/gnu/classpath/VMSystemProperties.java,
+       src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java,
+       src/classes/gnuclasspath/gnu/java/lang/VMCPStringBuilder.java, src/c
+       lasses/gnuclasspath/gnu/java/lang/management/VMMemoryMXBeanImpl.java
+       , src/classes/gnuclasspath/gnu/java/lang/management/VMRuntimeMXBeanI
+       mpl.java, src/classes/gnuclasspath/java/lang/VMClassLoader.java,
+       src/classes/gnuclasspath/java/lang/VMString.java,
+       src/classes/gnuclasspath/java/lang/VMThread.java,
+       src/classes/gnuclasspath/java/lang/reflect/Constructor.java,
+       src/classes/gnuclasspath/java/lang/reflect/Field.java,
+       src/classes/gnuclasspath/java/lang/reflect/Method.java,
+       src/classes/gnuclasspath/java/lang/reflect/Modifier.java,
+       src/classes/gnuclasspath/java/lang/reflect/VMConstructor.java,
+       src/classes/gnuclasspath/java/lang/reflect/VMField.java,
+       src/classes/gnuclasspath/java/lang/reflect/VMMethod.java,
+       src/classes/gnuclasspath/java/security/VMAccessController.java,
+       src/classes/gnuclasspath/sun/misc/Unsafe.java,
+       src/classes/gnuclasspath/sun/reflect/ConstantPool.java, src/classes/
+       gnuclasspath/sun/reflect/annotation/AnnotationParser.java,
+       src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java,
+       src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismat
+       chExceptionProxy.java, src/classes/gnuclasspath/sun/reflect/annotati
+       on/EnumConstantNotPresentExceptionProxy.java,
+       src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java,
+       src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExcept
+       ionProxy.java:
+       * src/classes/gnu: Renamed to src/classes/gnuclasspath.
+       [caa690b0970d]
+
+       * src/classes/Makefile.am:
+       * src/classes/Makefile.am (BOOTCLASSPATH): Removed, this is set
+       during configure.
+       [b46e2a411a24]
+
+       * configure.ac, src/native/vm/Makefile.am,
+       src/native/vm/gnu/Makefile.am, src/native/vm/gnu/VMjdwp.c,
+       src/native/vm/gnu/VMjdwp.h,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c,
+       src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c, src/native/vm/g
+       nu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
+       src/native/vm/gnu/java_lang_reflect_VMConstructor.c,
+       src/native/vm/gnu/java_lang_reflect_VMField.c,
+       src/native/vm/gnu/java_lang_reflect_VMMethod.c,
+       src/native/vm/gnu/java_lang_reflect_VMProxy.c,
+       src/native/vm/gnu/java_security_VMAccessController.c,
+       src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/gnuclasspath/Makefile.am,
+       src/native/vm/gnuclasspath/VMjdwp.c,
+       src/native/vm/gnuclasspath/VMjdwp.h,
+       src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.c,
+       src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMFrame.c,
+       src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMMethod.c,
+       src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMVirtualMachine.c,
+       src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.c, src/na
+       tive/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanIm
+       pl.c, src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMX
+       BeanImpl.c, src/native/vm/gnuclasspath/gnu_java_lang_management_VMRu
+       ntimeMXBeanImpl.c, src/native/vm/gnuclasspath/gnu_java_lang_manageme
+       nt_VMThreadMXBeanImpl.c,
+       src/native/vm/gnuclasspath/java_lang_VMClass.c,
+       src/native/vm/gnuclasspath/java_lang_VMClassLoader.c,
+       src/native/vm/gnuclasspath/java_lang_VMObject.c,
+       src/native/vm/gnuclasspath/java_lang_VMRuntime.c,
+       src/native/vm/gnuclasspath/java_lang_VMString.c,
+       src/native/vm/gnuclasspath/java_lang_VMSystem.c,
+       src/native/vm/gnuclasspath/java_lang_VMThread.c,
+       src/native/vm/gnuclasspath/java_lang_VMThrowable.c, src/native/vm/gn
+       uclasspath/java_lang_management_VMManagementFactory.c,
+       src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.c,
+       src/native/vm/gnuclasspath/java_lang_reflect_VMField.c,
+       src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.c,
+       src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c,
+       src/native/vm/gnuclasspath/java_security_VMAccessController.c,
+       src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/gnuclasspath/sun_reflect_ConstantPool.c,
+       src/native/vm/nativevm.c, src/native/vm/openjdk/Makefile.am,
+       src/native/vm/openjdk/hpi.c, src/native/vm/openjdk/hpi.h,
+       src/native/vm/openjdk/jvm.c, src/native/vm/sun/Makefile.am,
+       src/native/vm/sun/hpi.c, src/native/vm/sun/hpi.h,
+       src/native/vm/sun/jvm.c:
+       * src/native/vm/gnu: Renamed to src/native/vm/gnuclasspath.
+       * src/native/vm/sun: Renamed to src/native/vm/openjdk.
+       [1c0d84d8f0dc]
+
+       * m4/classpath.m4, m4/java-runtime-library.m4:
+       * m4/classpath.m4: Moved from here...
+       * m4/java-runtime-library.m4: ...to here.
+       [0c5b61d3cdea]
+
+       * contrib/setenvinstalled.in, contrib/setenvsource.in:
+       * contrib/setenvinstalled.in: Missed in renaming.
+       * contrib/setenvsource.in: Likewise.
+       [69c19a930578]
+
+       * configure.ac, contrib/setenvinstalled.in, contrib/setenvsource.in,
+       m4/classpath.m4, m4/hpi.m4, src/cacao/Makefile.am,
+       src/cacaoh/cacaoh.c, src/classes/Makefile.am,
+       src/native/include/Makefile.am, src/native/jni.c,
+       src/native/native.c, src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/nativevm.c, src/native/vm/nativevm.h,
+       src/native/vm/reflect.c, src/native/vm/reflect.h,
+       src/native/vm/sun_misc_Unsafe.c, src/threads/posix/thread-posix.c,
+       src/threads/thread.c, src/vm/access.c, src/vm/assertion.c,
+       src/vm/initialize.c, src/vm/jit/codegen-common.c, src/vm/jit/jit.c,
+       src/vm/jit/stacktrace.c, src/vm/properties.c, src/vm/signal.c,
+       src/vm/vm.c, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/utf8.c,
+       src/vmcore/utf8.h:
+       * m4/classpath.m4: Renamed --with-classpath* options to
+       --with-java-runtime-library* and the defines respectively.
+
+       * configure.ac, contrib/setenvinstalled.in, contrib/setenvsource.in,
+       m4/hpi.m4, src/cacao/Makefile.am, src/cacaoh/cacaoh.c,
+       src/classes/Makefile.am, src/native/include/Makefile.am,
+       src/native/jni.c, src/native/native.c, src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/nativevm.c, src/native/vm/nativevm.h,
+       src/native/vm/reflect.c, src/native/vm/reflect.h,
+       src/native/vm/sun_misc_Unsafe.c, src/threads/posix/thread-posix.c,
+       src/threads/thread.c, src/vm/access.c, src/vm/assertion.c,
+       src/vm/initialize.c, src/vm/jit/codegen-common.c, src/vm/jit/jit.c,
+       src/vm/jit/stacktrace.c, src/vm/properties.c, src/vm/signal.c,
+       src/vm/vm.c, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/utf8.c,
+       src/vmcore/utf8.h: Likewise.
+       [ec4ce9fdb0b0]
+
+2008-05-13  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/vm.c, src/vm/vm.h:
+       * src/vm/vm.c (mainstring): Removed. (mainclass): Made static.
+       (vm_create): Moved main-class argument handling from here...
+       (vm_run): ...to here. (vm_compile_method): Pass class name to the
        function.
-       
-       * src/threads/threads-common.h (threads_table_get_threads): Added.
-       
-       * src/threads/native/threads.c (threads_cast_sendsignals): Rewritten.
-       (threads_cast_stopworld): Likewise.
-
-2007-05-02 20:36  tbfg
-
-       * java_lang_Double.c (Java_java_lang_Double_doubleToLongBits): Added
-       missing JNIEnv* argument to signature.
-
-2007-05-02 19:57  twisti
-
-       * src/vmcore/class.c (class_load_attributes): Disable annotation
-       loading for the release.
-
-2007-05-02 16:21  twisti
-
-       * src/threads/threads-common.c (threads_preinit): Create and
-       initialize the main-thread.
-       (threads_table_init): Changed signature, insert main-thread and
-       maintain a used list too.
-       (threads_table_add): Use locking and maintain used list.
-       (threads_table_remove): Likewise.
-       (threads_table_get): New function.
-       (threads_table_get_non_daemons): Likewise.
-       (threads_table_first): Likewise.
-       (threads_table_next): Likewise.
-       [!NDEBUG] (threads_table_dump): Use log_* functions.
-       (threads_dump): Use threads-table and functions.
-       
-       * src/threads/threads-common.h (threads_table_entry_t): Made a struct
-       and renamed nextfree to next.
-       (threads_table_get): Added
-       (threads_table_get_non_daemons): Likewise.
-       (threads_table_first): Likewise.
-       (threads_table_next): Likewise.
-       [!NDEBUG] (threads_table_dump): Likewise.
-       (threads_impl_table_init): Likewise.
-       (threads_table_lock): Likewise.
-       (threads_table_unlock): Likewise.
-       (threads_set_current_threadobject): Likewise.
-       
-       * src/threads/native/threads.c (threadlistlock): Removed.
-       (threads_impl_preinit): Removed main-thread initialization code.
-       (threads_impl_table_init): New function.
-       (threads_table_lock): New function.
-       (threads_table_unlock): Likewise.
-       (threads_init): Get main-thread from threads-table and removed
-       thread-list code.
-       (threads_attach_current_thread): Likewise.
-       (threads_detach_thread): Removed thread-list code.
-       (threads_find_non_daemon_thread): Removed.
-       (threads_join_all_threads): Use threads_table_get_non_daemons.
-
-2007-05-02 09:57  twisti
-
-       * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): Added
-       uClibc support.
-       (md_signal_handler_sigtrap): Likewise.
-       (md_signal_handler_sigusr2): Likewise.
-       (thread_restartcriticalsection): Likewise.
-
-2007-05-01 21:40  pm
-
-       * src/vm/jit/s390/md.c (md_dump_context): Added. Fatal signals now
-       print the context and a stacktrace.
-       * src/vm/jit/s390/emit.h (emit_restore_pv): Added. Fixes bug where
-       REG_PV recalculation uses dseg value to recalculate REG_PV.
-       * src/vm/jit/s390/emit.c: Likewise.
-       * src/vm/jit/s390/codegen.h (N_RI, N_RI2): Test immediate operand for
-       correct signedness.
-       * src/vm/jit/s390/codegen.c (codegen_emit): Use emit_restore_pv for
-       REG_PV recalculation/
-       * src/vm/jit/s390/disass.c (disass_pseudo_instr): Fix formating.
-       * src/vm/jit/s390/tests/dacapo.status: Added.
-
-2007-05-01 17:35  ajordan
-
-       * src/vm/jit/sparc64/codegen.h: Removed unused var_to_reg_int define.
-       
-       * src/vm/jit/sparc64/codegen.c: Fixed JIT float argument passing via
-       stack.
-       
-       * src/vm/jit/sparc64/asmpart.S (asm_vm_call): Fixed integer argument
-       passing via stack args.
-
-2007-05-01 16:14  pm
-
-       * src/vm/jit/s390/codegen.h (gen_bound_check,
-       gen_nullptr_check_intern, gen_bound_check, N_LONG_0): Remove because
-       obsolete.
-
-2007-05-01 16:05  pm
-
-       * src/vm/jit/s390/codegen.c (codegen_emit): Use new emit_label and
-       emit_label_* functions.
-       * src/vm/jit/s390/disass.c (disass_pseudo_instr): Nicer formatting
-       for ill pseudo instruction.
-
-2007-05-01 15:46  pm
-
-       * src/vm/jit/emit-common.h (BRANCH_LABEL_6): Added.
-
-2007-05-01 13:00  tbfg
-
-       * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill): Support
-       EXCEPTION_HARDWARE_ARITHMETIC.
-       
-       * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Use corret opcode for
-       word forms.
-       
-       * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Implemented.
-       (ICMD_IREMPOW2): Implemented.
-       (ICMD_ISHLCONST): Fixed.
-       (ICMD_ISHRCONST): Fixed.
-       (ICMD_IUSHRCONST): Fixed.
-       (ICMD_SALOAD): Signextension fix.
-       (ICMD_LALOAD): Implemented.
-       (ICMD_LASTORE): Fixed.
-       (ICMD_IASTORE): Fixed.
-       (ICMD_MULITANEWARRAY): Fixed.
-       
-       * src/vm/jit/m68k/codegen.h (M_IADDX): Added.
-       (M_IXOR): Fixed.
-       (M_BCS): Fixed.
-
-2007-04-30 12:44  tbfg
-
-       * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Restore registers
-       correctly.
-
-2007-04-30 11:58  twisti
-
-       * src/vm/jit/inline/Makefile.am (AM_CPPFLAGS): Added
-       -I$(top_builddir)/src.
-
-2007-04-30 10:53  tbfg
-
-       * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Fixed.
-       (emit_arithmetic_check): Implemented.
-       
-       * src/vm/jit/m68k/md.c (md_get_method_patch_address): Changed invoking
-       register.
-       (md_stacktrace_get_returnaddress): Fix for linking words on stack.
-       
-       * src/vm/jit/m68k/codegen.c (IUSHRCONST): Fix.
-       (ICMD_IOR): Implemented.
-       (ICMD_IORCONST): Likewise.
-       (ICMD_IXOR): Likewise.
-       (ICMD_IXORCONST): Likewise.
-       (ICMD_INVOKEVIRTUAL): Changed invoking register.
-       (ICMD_INVOKEINTERFACE): Likewise.
-       
-       * src/vm/jit/m68k/patcher.c (patcher_invokevirtual): Changed
-       invoking register.
-       
-       * src/vm/jit/m68k/asmpart.S (asm_vm_call_method_exception_handler):
-       Proper stack restauration.
-       (L_asm_call_jit_compiler_exception): Implemented.
-       (asm_patcher_wrapper): Fixses.
-       (L_asm_patcher_wrapper_exception): Implemented.
-       
-       * src/vm/jit/m68k/codegen.h (M_IXOR): Added.
-       (M_IOR_IMM): Added.
-       (M_IXOR_IMM): Added.
-       
-       * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe):
-       Comment and further m68k stuff.
-
-2007-04-29 22:46  pm
-
-       * src/vm/jit/s390/emit.c,
-       src/vm/jit/s390/md-abi.h,
-       src/vm/jit/s390/md.c,
-       src/vm/jit/s390/emit.h,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/machine-instr.h,
-       src/vm/jit/s390/codegen.h,
-       src/vm/jit/s390/arch.h,
-       src/vm/jit/s390/md-asm.h,
-       src/vm/jit/s390/disass.c,
-       src/vm/jit/s390/patcher.c,
-       src/vm/jit/s390/asmpart.S,
-       src/vm/jit/s390/md-abi.c: Adapted S390 port to changes from
-       branches/twisti (hardware exceptions, emit_branch, abi_registers_*),
-       jctest works again. Cleaned up almost all dead x86_64 code.
-
-2007-04-28 12:59  ajordan
-
-       * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Fixed stack
-       alignement in first save.
-
-2007-04-27 08:43  tbfg
-
-       * src/vm/jit/m68k/emit.c (emit_arrayindexoutofbounds_check): Fixed.
-       * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill): AIOOB
-       fixed.
-       Editor boiler plate added.
-       
-       * src/vm/jit/m68k/linux/md-os.h: Editor boiler plate.
-       
-       * src/vm/jit/m68k/linux/md-abi.c: Likewise.
-       
-       * src/vm/jit/m68k/md.c: Likewise.
-       
-       * src/vm/jit/m68k/machine-instr.h: Likewise.
-       
-       * src/vm/jit/m68k/patcher.c: Editor boiler plate.
-       (patcher_invokeinterface): Implemented.
-       (patcher_get_putfield): Implemented.
-       (patcher_resolve_class): Implemented.
-       (patcher_get_putstatic): Implemented.
-       
-       * src/vm/jit/m68k/codegen.c: Editor boiler plate.
-       (ICMD_GETSTATIC): Added patcher.
-       (ICMD_AASTORE): Fixed.
-       
-       * src/vm/jit/m68k/asmpart.S: Editor boiler plate.
-       (asm_vm_call_method_exception_handler): Fixed used register.
-       Return values in %d0 and %a0 as gcc sometimes expects pointers
-       in %a0.
-
-2007-04-27 01:37  ajordan
-
-       * src/vm/jit/sparc64/emit.c: Keeping stack 16-byte aligned when
-       calling C/native functions from the stack. (Solaris requires this)
-       * src/vm/jit/sparc64/codegen.c: Likewise.
-       * src/vm/jit/sparc64/codegen.h: Likewise.
-       
-       * src/vm/jit/sparc64/md-abi.c: Removed zero sized abi_register_*
-       arrays. (not allowed in ISO C)
-       
-       * src/vm/jit/sparc64/solaris/md-os.c: Preliminary hardware exception
-       handling. (untested)
-
-2007-04-26 13:43  twisti
-
-       * src/vm/jit/inline/inline.h (config.h): Added.
-       (inline_inline): Likewise.
-       
-       * src/vm/jit/jit.c (threads/threads-common.h): Added.
-       [ENABLE_INLINING] (vm/jit/inline/inline.h): Likewise.
-       [ENABLE_THREADS] (threads/native/threads.h): Removed.
-
-2007-04-26 13:32  twisti
-
-       * src/vm/vm.c [ENABLE_THREADS] (threads/native/threads.h): Removed.
-       (threads/threads-common.h): Added.
-
-2007-04-26 13:07  twisti
-
-       * src/native/vm/java_lang_Thread.c: Set Id keyword.
-
-2007-04-26 13:06  twisti
-
-       * src/native/vm/java_lang_Thread.c (start): Renamed
-       threads_start_javathread to threads_thread_start.
-
-2007-04-26 12:48  twisti
-
-       * src/threads/threads-common.c (threads_thread_create_internal):
-       Renamed to threads_thread_start_internal and start the thread.
-       (threads_start_javathread): Renamed to threads_thread_start.
-       * src/threads/threads-common.h: Likewise.
-       
-       * src/threads/native/threads.c (threads_start_thread): Renamed to
-       threads_impl_thread_start.
-       
-       * src/mm/memory.c (thread_memory): Removed.
-       (memory_start_thread): Call threads_thread_start_internal.
-       
-       * src/vm/finalizer.c (thread_finalizer): Removed.
-       (finalizer_start_thread): Call threads_thread_start_internal.
-       
-       * src/vm/signal.c (thread_signal): Removed.
-       (signal_start_thread): Call threads_thread_start_internal.
-       
-       * src/vm/jit/optimizing/profile.c (thread_profile): Removed.
-       (profile_start_thread): Call threads_thread_start_internal.
-       
-       * src/vm/jit/optimizing/recompile.c (thread_recompile): Removed.
-       (recompile_start_thread): Call threads_thread_start_internal.
-
-2007-04-26 11:14  twisti
-
-       * src/threads/threads-common.c (threads/critical.h): Added.
-       (threads/native/threads.h): Removed.
-       (threads_table): Added.
-       (threads_preinit): New function.
-       (threads_table_init): Moved from implementation file.
-       (threads_table_add): Likewise.
-       (threads_table_remove): Likewise.
-       (threads_table_dump): Likewise.
-       
-       * src/threads/threads-common.h (threads_table_entry_t)
-       (threads_table_t): Added.
-       (threads_preinit): Likewise.
-       (threads_table_add): Likewise.
-       (threads_table_remove): Likewise.
-       (threads_impl_preinit): Likewise.
-       (threads_init_threadobject): Likewise.
-       
-       * src/threads/native/threads.c (threads_table): Removed.
-       (threads_preinit): Renamed to threads_impl_preinit.
-       (threads_table_init): Removed.
-       (threads_table_add): Likewise.
-       (threads_table_remove): Likewise.
-       (threads_table_dump): Likewise.
-       
-       * src/threads/native/threads.h (threads_table_entry_t)
-       (threads_table_t): Removed.
-       (threads_preinit): Likewise.
-
-2007-04-25 21:47  stefan
-
-       * src/vm/jit/i386/darwin/md-os.c: added threads/threads-common.h,
-       removed vm/jit/i386/md-abi.h
-
-2007-04-25 21:23  stefan
-
-       * src/vm/jit/i386/darwin/md-os.c: attempt at porting the exception
-       changes
-       (see r7596 & r7648).
-
-2007-04-25 21:03  twisti
-
-       * src/threads/lock-common.h (threads/threads-common.h): Removed that
-       header again and added a comment about not including thread headers.
-       
-       * src/threads/threads-common.c (threads_start_javathread): Reverted.
-       * src/threads/threads-common.h (threads_start_javathread): Likewise.
-
-2007-04-25 20:56  twisti
-
-       * src/threads/threads-common.c (threads_dump) [!SIZEOF_VOID_P == 8]:
-       Fixed warning.
-
-2007-04-25 20:31  twisti
-
-       * src/threads/threads-common.c (threads_start_javathread): Changed
-       signature.
-       
-       * src/threads/lock-common.h (threads/threads-common.h): Added.
-       [ENABLE_THREADS]: Only define functions when threads are enabled.
-       
-       * src/threads/threads-common.h (native/include/java_lang_Thread.h):
-       Removed.
-       [ENABLE_THREADS]: Only define functions when threads are enabled.
-       (threads_start_javathread): Changed signature.
-
-2007-04-25 20:07  twisti
-
-       * src/vm/jit/mips/codegen.c: Changed lock includes.
-       * src/vm/jit/mips/emit.c: Likewise.
-
-2007-04-25 20:03  twisti
-
-       * src/vm/jit/arm/codegen.c: Changed lock include.
-       * src/vm/jit/arm/emit.c: Likewise.
-
-2007-04-25 20:02  twisti
-
-       * src/vm/jit/arm/emit.c (emit_load): Use switch-case instead of
-       if-else contruct.
-       (emit_store): Likewise.
-       (emit_copy): Likewise.
-
-2007-04-25 19:56  twisti
-
-       * src/vm/jit/alpha/emit.c: Set Id keyword.
-
-2007-04-25 19:55  twisti
-
-       * src/vm/jit/alpha/codegen.c: Changed lock include.
-       * src/vm/jit/alpha/emit.c: Likewise.
-
-2007-04-25 19:54  twisti
-
-       * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Use
-       md->params to save and restore argument registers.
-
-2007-04-25 19:47  twisti
-
-       * src/vm/jit/i386/codegen.c: Changed lock include.
-       * src/vm/jit/i386/emit.c: Likewise.
-
-2007-04-25 19:42  twisti
-
-       * src/vm/jit/powerpc64/codegen.c: Changed lock includes.
-       * src/vm/jit/powerpc64/emit.c: Likewise.
-
-2007-04-25 19:38  twisti
-
-       * src/vm/jit/powerpc/emit.c: Set Id keyword.
-
-2007-04-25 19:37  twisti
-
-       * src/vm/jit/powerpc/codegen.c: Fixed lock include.
-       * src/vm/jit/powerpc/emit.c: Likewise.
-
-2007-04-25 19:36  twisti
-
-       * src/vm/jit/powerpc/linux/md-abi.c (abi_registers_float_temporary):
-       Fixed number of registers.
-
-2007-04-25 19:20  twisti
-
-       * src/threads/lock-common.h: New file.
-       
-       * src/threads/native/lock.h: Removed function prototypes.
-       * src/threads/none/lock.h (LOCK_INIT_OBJECT_LOCK): Added.
-       
-       * src/mm/memory.c,
-       src/native/jni.c,
-       src/native/native.c,
-       src/native/vm/java_lang_Object.c,
-       src/native/vm/java_lang_Thread.c,
-       src/threads/Makefile.am,
-       src/threads/native/threads.c,
-       src/threads/threads-common.c,
-       src/toolbox/avl.c,
-       src/toolbox/hashtable.c,
-       src/toolbox/list.c,
-       src/vm/builtin.c,
-       src/vm/finalizer.c,
-       src/vm/initialize.c,
-       src/vm/jit/inline/inline.c,
-       src/vm/jit/jit.c,
-       src/vm/jit/optimizing/recompile.c,
-       src/vm/jit/parse.c,
-       src/vm/jit/patcher.h,
-       src/vm/jit/show.c,
-       src/vm/jit/x86_64/codegen.c,
-       src/vm/jit/x86_64/emit.c,
-       src/vm/string.c,
-       src/vmcore/class.c,
-       src/vmcore/classcache.c,
-       src/vmcore/linker.c,
-       src/vmcore/loader.c,
-       src/vmcore/suck.c,
-       src/vmcore/utf8.c: Updated headers.
-
-2007-04-25 18:51  twisti
-
-       * src/mm/memory.h: Updated copyright header.
-
-2007-04-25 18:33  twisti
-
-       * src/threads/threads-common.c (threads_create_thread): Renamed to
-       threads_thread_create_internal and a new function.
-       (threads_start_javathread): Use threads_create_thread.
-       
-       * src/threads/threads-common.h (threads_create_thread): Changed
-       signature.
-       (threads_thread_create_internal): Added.
-       
-       * src/threads/native/threads.c (threads_set_current_threadobject):
-       Made non-static.
-       (threads_init_threadobject): Likewise, use threads_create_thread.
-       (threads_init): Cleanup.
-       (threads_startup_thread): Likewise.
-       (threads_attach_current_thread): Use threads_create_thread.
-       
-       * src/vm/jit/optimizing/profile.c (profile_start_thread): Replaced
-       threads_create_thread with threads_thread_create_internal.
-       * src/vm/jit/optimizing/recompile.c (recompile_start_thread):
-       Likewise.
-       * src/vm/signal.c (signal_start_thread): Likewise.
-       * src/vm/finalizer.c (finalizer_start_thread): Likewise.
-       * src/mm/memory.c (memory_start_thread): Likewise.
-
-2007-04-25 16:39  stefan
-
-       * src/vmcore/linker.c (linker_init): added missing
-       lock_init_object_lock.
-
-2007-04-25 15:14  twisti
-
-       * src/threads/native/threads.c (threads_preinit): We always need
-       variable t.
-
-2007-04-25 15:12  twisti
-
-       * src/native/native.c (native/include/java_lang_Object.h): Include
-       always.
-       [ENABLE_JAVAME_CLDC1_1]
-       (native/include/com_sun_cldc_io_ResourceInputStream.h)
-       (native/include/com_sun_cldc_io_j2me_socket_Protocol.h): Added.
-
-2007-04-25 14:24  twisti
-
-       * contrib: Ignore TAGS.
-       * contrib/vmlog: Likewise.
-
-2007-04-25 11:54  twisti
-
-       * src/threads/native/threads.c (threads_init): Use variable t instead
-       of mainthreadobj->object, makes code simpler.
-
-2007-04-25 11:47  twisti
-
-       * src/threads/threads-common.c (threads_create_thread)
-       [ENABLE_GC_BOEHM]: Use GCNEW_UNCOLLECTABLE.
-       (threads_start_javathread) [ENABLE_GC_BOEHM]: Likewise.
-       
-       * src/threads/native/threads.c (threads_preinit) [ENABLE_GC_BOEHM]:
-       Likewise.
-       (threads_init): Removed resizing-of-threadobject code, we don't need
-       it anymore.
-       (threads_attach_current_thread) [ENABLE_GC_BOEHM]: Use
-       GCNEW_UNCOLLECTABLE.
-       (threads_detach_thread) [ENABLE_GC_BOEHM]: Use GCFREE.
-
-2007-04-24 14:29  twisti
-
-       * src/threads/threads-common.c: Set Id keyword.
-       * src/threads/threads-common.h: Likewise.
-
-2007-04-24 14:23  twisti
-
-       * src/threads/threads-common.c (threads_dump): Also print integer
-       thread id, so it's easier to compare with the ones from gdb.
-
-2007-04-24 10:20  tbfg
-
-       * threads.m4: Fixed a typo
-
-2007-04-23 23:51  twisti
-
-       * contrib/.cvsignore,
-       doc/.cvsignore,
-       doc/handbook/.cvsignore,
-       man/.cvsignore,
-       src/.cvsignore,
-       src/cacao/.cvsignore,
-       src/cacaoh/.cvsignore,
-       src/fdlibm/.cvsignore,
-       src/lib/.cvsignore,
-       src/mm/.cvsignore,
-       src/mm/boehm-gc/.cvsignore,
-       src/mm/boehm-gc/doc/.cvsignore,
-       src/mm/boehm-gc/include/.cvsignore,
-       src/mm/cacao-gc/.cvsignore,
-       src/native/.cvsignore,
-       src/native/include/.cvsignore,
-       src/native/jvmti/.cvsignore,
-       src/native/tools/.cvsignore,
-       src/native/vm/.cvsignore,
-       src/native/vm/cldc1.1/.cvsignore,
-       src/native/vm/gnu/.cvsignore,
-       src/scripts/.cvsignore,
-       src/threads/.cvsignore,
-       src/threads/none/.cvsignore,
-       src/threads/posix/.cvsignore,
-       src/toolbox/.cvsignore,
-       src/vm/.cvsignore,
-       src/vm/jit/.cvsignore,
-       src/vm/jit/allocator/.cvsignore,
-       src/vm/jit/alpha/.cvsignore,
-       src/vm/jit/alpha/freebsd/.cvsignore,
-       src/vm/jit/alpha/linux/.cvsignore,
-       src/vm/jit/arm/.cvsignore,
-       src/vm/jit/arm/linux/.cvsignore,
-       src/vm/jit/i386/.cvsignore,
-       src/vm/jit/i386/cygwin/.cvsignore,
-       src/vm/jit/i386/darwin/.cvsignore,
-       src/vm/jit/i386/freebsd/.cvsignore,
-       src/vm/jit/i386/linux/.cvsignore,
-       src/vm/jit/inline/.cvsignore,
-       src/vm/jit/intrp/.cvsignore,
-       src/vm/jit/loop/.cvsignore,
-       src/vm/jit/m68k/.cvsignore,
-       src/vm/jit/m68k/linux/.cvsignore,
-       src/vm/jit/mips/.cvsignore,
-       src/vm/jit/mips/irix/.cvsignore,
-       src/vm/jit/mips/linux/.cvsignore,
-       src/vm/jit/optimizing/.cvsignore,
-       src/vm/jit/parisc/.cvsignore,
-       src/vm/jit/parisc/linux/.cvsignore,
-       src/vm/jit/powerpc/.cvsignore,
-       src/vm/jit/powerpc/darwin/.cvsignore,
-       src/vm/jit/powerpc/linux/.cvsignore,
-       src/vm/jit/powerpc/netbsd/.cvsignore,
-       src/vm/jit/powerpc64/.cvsignore,
-       src/vm/jit/powerpc64/linux/.cvsignore,
-       src/vm/jit/s390/.cvsignore,
-       src/vm/jit/schedule/.cvsignore,
-       src/vm/jit/sparc64/.cvsignore,
-       src/vm/jit/sparc64/linux/.cvsignore,
-       src/vm/jit/sparc64/solaris/.cvsignore,
-       src/vm/jit/tools/.cvsignore,
-       src/vm/jit/verify/.cvsignore,
-       src/vm/jit/x86_64/.cvsignore,
-       src/vm/jit/x86_64/freebsd/.cvsignore,
-       src/vm/jit/x86_64/linux/.cvsignore,
-       src/vmcore/.cvsignore,
-       tests/.cvsignore,
-       tests/regression/.cvsignore,
-       tests/regression/codepatching/.cvsignore,
-       tests/regression/jasmin/.cvsignore,
-       tests/regression/native/.cvsignore,
-       tests/stack/.cvsignore: Removed.
-
-2007-04-23 23:39  twisti
-
-       * .cvsignore: Removed.
-
-2007-04-23 23:03  twisti
-
-       * configure.ac: Removed --enable-threads checks and call instead
-       AC_CHECK_ENABLE_THREADS.
-       * m4/threads.m4: New file.
-
-2007-04-23 20:04  twisti
-
-       * configure.ac: Removed all classpath related checks and made
-       functions for them.
-       * m4/classpath.m4: New file.
-
-2007-04-23 20:03  twisti
-
-       * src/vm/builtin.h (md-abi.h): Added.
-
-2007-04-23 14:29  twisti
-
-       * src/vm/signal.c (signal_thread): Don't check for an error on
-       sigwait (revisit this patch with the exact-GC).
-
-2007-04-22 20:02  tbfg
-
-       * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigsegv):
-       Implemented.
-       (md_signal_handler_sigill): More exceptions handled. Some fixes.
-       
-       * src/vm/jit/m68k/linux/md-os.h
-       (M68K_EXCEPTION_HARDWARE_NULLPOINTER): Used instead of
-       EXCEPTION_HARDWARE_NULLPOINTER, because a trap with value #0 will
-       not be taken.
-       
-       * src/vm/jit/m68k/emit.c (emit_load_[low|high]): Fixed assertion.
-       (emit_arrayindexoutofbounds_check): Implemented.
-       (emit_nullpointer_check): Implemented.
-       (emit_exception_check_ireg): Renamed emit_exception_check.
-       (emit_exception_check_areg): Disabled code.
-       (emit_exception_check): Implemented.
-       
-       * src/vm/jit/m68k/codegen.c (ICMD_LALOAD): Implemented.
-       (ICMD_FALOAD): Implemented.
-       (ICMD_DALOAD): Implemented.
-       (ICMD_LASTORE): Implemented.
-       (ICMD_FASTORE): Implemented.
-       (ICMD_DASTORE): Implemented.
-       (ICMD_BUILTIN): Exception check enabled.
-       (ICMD_MULTIANEWARRAY): Implemented.
-       (codegen_emit_stub_native): Exception check implemented.
-       
-       * src/vm/jit/m68k/asmpart.S (asm_handle_nat_exception): Symbol
-       exported and implemented.
-       
-       * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe): More
-       m68k fixes.
-
-2007-04-22 15:55  ajordan
-
-       * src/vm/jit/sparc64/arch.h: Properly activated all FP features
-       SPARC64 supports in hardware.
-       
-       * src/vm/jit/sparc64/asmpart.S: Added functions to read/write the FP
-       state register.
-       * src/vm/jit/sparc64/md.c: Added prototypes here.
-       
-       * src/vm/jit/sparc64/codegen.h: Added 'branch on FP condition codes'
-       macros.
-       
-       * src/vm/jit/sparc64/emit.c (emit_verbosecall_enter): Fixed FP
-       argument passing.
-       
-       * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed FP conversion
-       functions to (a) use unique slots in the data segment (doh!),
-       (b) catch the case where NaN is converted to an integer value. (JVMS
-       and SPARC do not inherently agree here).
-
-2007-04-21 18:56  edwin
-
-       * tests/regression/resolving/Makefile.am: Added "-classpath ." to
-       javac
-       options so the tests work with ecj out-of-the-box.
-
-2007-04-21 16:42  edwin
-
-       * configure.ac: Generate vmlog Makefiles.
-       * contrib/Makefile.am: Added vmlog to SUBDIRS.
-       * contrib/vmlog/Makefile.am, contrib/vmlog/t/Makefile.am: New files.
-
-2007-04-21 16:26  edwin
-
-       * contrib/vmlog/Makefile: Renamed to maintain.mk.
-
-2007-04-21 12:48  edwin
-
-       * contrib/vmlog/vmlog_cacao.patch: Removed. It is no longer needed.
-       * contrib/vmlog/README: Updated for CACAO's --enable-vmlog.
-
-2007-04-21 12:37  edwin
-
-       * configure.ac (--enable-vmlog): New configure option.
-       
-       * src/vm/jit/Makefile.am, src/vm/Makefile.am,
-       src/threads/native/Makefile.am (AM_CPPFLAGS): Added -I for vmlog
-       includes.
-
-2007-04-21 10:55  edwin
-
-       * src/vm/jit/replace.c, src/vm/jit/intrp/asmpart.c,
-       src/vm/jit/codegen-common.c, src/vm/builtin.c, src/vm/exceptions.c,
-       src/vm/vm.c, src/threads/native/lock.c (ENABLE_VMLOG): Applied the
-       vmlog patch and wrapped all inserted code with
-       #if defined(ENABLE_VMLOG).
-
-2007-04-20 13:51  twisti
-
-       * src/toolbox/list.h (list_t): Added size.
-       
-       * src/toolbox/list.c (list_create): Initialize size.
-       (list_create_dump): Likewise.
-       (list_add_first): Increase size.
-       (list_add_last_unsynced): Likewise.
-       (list_add_before): Likewise.
-       (list_remove_unsynced): Decrease size.
-
-2007-04-20 13:28  twisti
-
-       * src/toolbox/list.h (listnode): Renamed to listnode_t.
-       (list): Renamed to list_t.
-       
-       * src/toolbox/list.c,
-       src/vm/jit/codegen-common.c,
-       src/vm/jit/codegen-common.h,
-       src/vm/jit/emit-common.c,
-       src/vm/jit/optimizing/profile.c,
-       src/vm/jit/optimizing/recompile.c,
-       src/vm/jit/optimizing/recompile.h,
-       src/vm/properties.c,
-       src/vmcore/class.c,
-       src/vmcore/class.h,
-       src/vmcore/suck.c,
-       src/vmcore/suck.h: Likewise.
-
-2007-04-20 13:09  twisti
-
-       * src/vm/vm.c: Changed header order to prevent a warning.
-
-2007-04-20 13:06  twisti
-
-       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c (loadLibrary): Fixed
-       string-internal warnings.
-       * src/native/vm/cldc1.1/java_lang_System.c (getProperty0): Likewise.
-
-2007-04-20 12:53  twisti
-
-       * src/vm/vm.c (version): Print libjvm.so path.
-
-2007-04-20 12:48  twisti
-
-       * src/vm/vm.c (vm_create): Print unknown -verbose option.
-
-2007-04-20 12:40  twisti
-
-       * src/vm/jit/codegen-common.c (codegen_finish_native_call): #ifdef lrt
-       and plrt. Don't set lrt, we don't need it.
-
-2007-04-20 11:21  twisti
-
-       * src/threads/threads-common.h (native/jni.h): Added.
-
-2007-04-19 21:31  twisti
-
-       * src/vm/signal.c (signal_thread): Check return value of sig*
-       functions.
-
-2007-04-19 19:59  twisti
-
-       * tests/regression/resolving/Makefile.am (check): Added missing
-       JAVAFLAGS.
-
-2007-04-19 19:58  twisti
-
-       * configure.ac (AC_INIT): Changed version to 0.98rc.
-
-2007-04-19 19:44  twisti
-
-       * src/vm/exceptions.h: Added a comment about the hardware-exception
-       assert in signal_init.
-
-2007-04-19 19:43  twisti
-
-       * src/vm/signal.c (assert.h): Added.
-       (vm/exceptions.h): Likewise.
-       [ENABLE_STATISTICS] (vmcore/statistics.h): Likewise.
-       (signal_init): Added hardware-exception assert.
-
-2007-04-19 19:41  twisti
-
-       * src/cacaoh/dummy.c (exceptions_print_current_exception): Added
-       abort.
-       (exceptions_throw_outofmemoryerror): Removed.
-       (exceptions_throw_illegalaccessexception): Likewise.
-
-2007-04-19 19:39  twisti
-
-       * src/vm/jit/powerpc/darwin/md-abi.h (REG_FA0, REG_FA1): Added.
-       (REG_A0_A1_PACKED, REG_A2_A3_PACKED): Likewise.
-       
-       * src/vm/jit/powerpc/darwin/md-os.c [ENABLE_THREADS]
-       (threads/native/threads.h): Added.
-       (md_signal_handler_sigsegv): Changed for hardware-exceptions.
-       (md_signal_handler_sigtrap): New function.
-       
-       * src/vm/jit/powerpc/darwin/md-abi.c (vm/descriptor.h): Changed to
-       vmcore/descriptor.h.
-       (regs): Renamed to abi_registers_integer_name.
-       (abi_registers_integer_argument): Added.
-       (abi_registers_integer_saved): Likewise.
-       (abi_registers_integer_temporary): Likewise.
-       (abi_registers_float_argument): Likewise.
-       (abi_registers_float_saved): Likewise.
-       (abi_registers_float_temporary): Likewise.
-       (md_param_alloc): Use new register arrays.
-       (md_param_alloc_native): New function.
-
-2007-04-19 15:01  tbfg
-
-       * src/vm/jit/m68k/linux/md-abi.c (abi_registers_integer_saved): Fixed.
-       (abi_registers_float_saved): Fixed.
-       
-       * src/vm/jit/m68k/emit.c (emit_classcast_check): Fixed.
-       
-       * src/vm/jit/m68k/codegen.c (codegen_emit): Temporary hacked
-       a field for saved adr registers until real patch will be done.
-       (ICMD_INSTANCEOF): Fixed.
-       (ICMD_CHECKCAST): Fixed.
-       (codegen_emit_stub_compiler): Removed useless code.
-       
-       * src/vm/jit/m68k/asmpart.S (L_asm_handle_exception_not_catched):
-       Implemented.
-       
-       * src/vm/jit/m68k/codegen.h (M_BLS): Added.
-
-2007-04-19 12:19  michi
-
-       * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Use long branch
-       construct
-       for exception handling here. This fixes a crash in the following
-       jasmin
-       regression testcase: jasmin/test_verify_fail_areturn_wrong_reftype.
-
-2007-04-19 09:19  twisti
-
-       * src/threads/threads-common.c (threads_start_javathread)
-       [ENABLE_JAVASE]: Check for daemon thread and set the flag.
-
-2007-04-19 09:18  twisti
-
-       * src/threads/native/threads.c (threads_start_javathread): Removed.
-       (threads_detach_thread): Added some comments.
-       
-       * src/threads/native/threads.h (threads_start_javathread): Removed.
-       
-       * src/threads/threads-common.c (assert.h): Added.
-       [ENABLE_STATISTICS] (vmcore/options.h, vmcore/statistics.h): Added.
-       (threads_start_javathread): Added.
-       
-       * src/threads/threads-common.h (vm/global.h): Added.
-       (native/include/java_lang_Thread.h): Likewise.
-       (threads_start_javathread): Likewise.
-
-2007-04-18 21:04  ajordan
-
-       * src/vm/jit/sparc64/emit.c: Migrated to
-       abi_registers_{integer,float}_argument.
-       * src/vm/jit/sparc64/codegen.c: Likewise.
-       * src/vm/jit/sparc64/md-abi.c: Likewise.
-
-2007-04-18 15:31  michi
-
-       * src/vm/jit/powerpc64/linux/Makefile.am (AM_CPPFLAGS): Added
-       -I$(top_builddir)/src.
-
-2007-04-18 14:49  tbfg
-
-       * src/vm/jit/powerpc64/codegen.c (sign_ext): Removed from
-       ICMD_INEG, ICMD_IDIV, ICMD_IREM, ICMD_IMUL, ICMD_IAND and ICMD_IOR
-       to save the if runtime costs.
-       
-       (ICMD_IUSHR): Needs sign extension for 0 bit shift case.
-
-2007-04-18 14:11  twisti
-
-       * src/threads/native/threads.c (mutex_join, cond_join): Added.
-       (threads_init_threadobject): Don't initalize join-mutex and cond.
-       (threads_preinit): Initialize mutex_join and cond_join.
-       (threads_startup_thread): Added vm_abort.
-       (threads_detach_thread): Don't reset thread id and use global mutex
-       and condition.
-       (threads_find_non_daemon_thread): Lock thread list.
-       (threads_join_all_threads): Use global mutex and condition.
-       
-       * src/threads/native/threads.h (threadobject): Removed joinmutex and
-       joincond.
-
-2007-04-18 09:59  twisti
-
-       * src/native/vm/java_lang_ClassLoader.c [ENABLE_STATISTICS]
-       (vmcore/statistics.h): Added.
-
-2007-04-17 23:18  twisti
-
-       * src/vm/jit/emit-common.h (emit_copy): Changed signature.
-       
-       * src/vm/jit/alpha/codegen.c,
-       src/vm/jit/alpha/emit.c,
-       src/vm/jit/arm/codegen.c,
-       src/vm/jit/arm/emit.c,
-       src/vm/jit/i386/codegen.c,
-       src/vm/jit/i386/emit.c,
-       src/vm/jit/m68k/codegen.c,
-       src/vm/jit/m68k/emit.c,
-       src/vm/jit/mips/codegen.c,
-       src/vm/jit/mips/emit.c,
-       src/vm/jit/powerpc/codegen.c,
-       src/vm/jit/powerpc/emit.c,
-       src/vm/jit/powerpc64/codegen.c,
-       src/vm/jit/powerpc64/emit.c,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/emit.c,
-       src/vm/jit/sparc64/codegen.c,
-       src/vm/jit/sparc64/emit.c,
-       src/vm/jit/x86_64/codegen.c,
-       src/vm/jit/x86_64/emit.c: Likewise.
-
-2007-04-17 22:55  twisti
-
-       * src/vm/jit/m68k/emit.c: boilerplate added.
-
-2007-04-17 22:50  twisti
-
-       * src/vm/jit/m68k/codegen.c: Boilerplate added.
-
-2007-04-17 22:06  twisti
-
-       * src/vm/jit/alpha/codegen.c (codegen_emit): Fixed bug in
-       float-argument passing.
-
-2007-04-17 21:37  twisti
-
-       * tests/regression/resolving/Makefile.am (check): Use LD_LIBRARY_PATH
-       for JAVA.
-
-2007-04-17 21:30  edwin
-
-       * src/vm/jit/stack.c (stack_init_javalocals): Use "type" as variable
-       for the type.
-       (stack_analyse): Likewise.
-
-2007-04-17 21:25  edwin
-
-       * src/vm/jit/stack.c (stack_analyse): Do not abuse poor "i" for types,
-       use a separate variable for that.
-
-2007-04-17 21:11  edwin
-
-       * src/vm/jit/stack.c (stack_reanalyse_block, stack_analyse): Renamed
-       variable "j" to a more obvious "varindex".
-
-2007-04-17 21:01  edwin
-
-       * src/vm/jit/verify/typecheck.c: More variable renaming for clarity.
-
-2007-04-17 20:59  twisti
-
-       * src/vm/builtintable.inc (builtintable_function) [ENABLE_JIT]: We
-       need the entries only for JIT.
-
-2007-04-17 20:54  twisti
-
-       * tests/regression/jasmin/Makefile.am (check): Set LD_LIBRARY_PATH.
-
-2007-04-17 20:53  edwin
-
-       * src/vm/jit/stack.c, src/vm/jit/verify/typecheck-common.c,
-       src/vm/jit/verify/typeinfo.c, src/vm/jit/inline/inline.c,
-       src/vm/jit/allocator/simplereg.c: Clarification: Renamed variables
-       that are indices into jd->var to "varindex". Renamed variables that
-       are bytecode variable indices to "javaindex".
-
-2007-04-17 20:37  edwin
-
-       * src/vm/jit/stack.c, src/vm/jit/show.c, src/vm/jit/inline/inline.c,
-       src/vm/jit/replace.c, src/vm/jit/jit.h: Fix and use the new macros
-       for calculating javalocals values representing returnAddresses.
-
-2007-04-17 20:30  edwin
-
-       * src/vm/jit/jit.h (basicblock): Document the javalocal array.
-       (JAVALOCAL_FROM_RETADDR): New macro.
-       (RETADDR_FROM_JAVALOCAL): Likewise.
-
-2007-04-17 20:25  twisti
-
-       * src/threads/native/threads.c (threads_init): Fixed string-internal
-       warnings.
-       (threads_attach_current_thread): Likewise.
-
-2007-04-17 20:17  twisti
-
-       * src/threads/threads-common.c (threads_print_stacktrace): Renamed to
-       threads_thread_print_stacktrace.
-       (threads_print_stacktrace): New function.
-       (threads_dump): Use threads_thread_print_stacktrace.
-       
-       * src/threads/threads-common.h: Likewise.
-       
-       * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Use new
-       threads_print_stacktrace.
-
-2007-04-17 20:06  edwin
-
-       * src/vm/jit/jit.h (jitdata): Cleaned up comments for local_map.
-
-2007-04-17 19:57  edwin
-
-       * src/vm/jit/stack.c (stack_javalocals_store): Added an assert.
-
-2007-04-17 19:24  edwin
-
-       * src/vm/jit/stack.c (stack_analyse): The javalocals array can have
-       negative values != UNUSED (these values < UNUSED represent
-       returnAddresses of local subroutines). Thus >= 0 must be used to
-       check for normal indices.
-
-2007-04-17 18:47  edwin
-
-       * src/vm/jit/parse.c (parse): Small cleanup of local variable
-       renaming.
-       (No code changes.)
-
-2007-04-17 11:15  twisti
-
-       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Use simpler
-       code to save and restore argument registers.
-
-2007-04-16 22:56  twisti
-
-       * src/vm/jit/x86_64/codegen.c (codegen_emit): Made argument passing
-       cleaner.
-
-2007-04-16 22:24  twisti
-
-       * src/vm/jit/codegen-common.c (codegen_setup): Removed maxstack stuff.
-       * src/vm/jit/codegen-common.h (codegendata): Likewise.
-       
-       * src/vm/jit/inline/inline.c: Fixed includes.
-       (inline_jit_compile): Removed maxstack stuff.
-       (inline_transform): Removed basicblockindex.
-
-2007-04-16 21:09  twisti
-
-       * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added m68k.
-       * src/mm/cacao-gc/Makefile.am (libgc_la_SOURCES): Removed heap.c.
-
-2007-04-16 21:07  twisti
-
-       * src/vm/jit/powerpc64/linux/md-abi.c: Argument register changes
-       ported (rev7713).
-       * src/vm/jit/powerpc64/emit.c: Likewise.
-       * src/vm/jit/powerpc64/codegen.c: Likewise.
-
-2007-04-16 15:57  twisti
-
-       * src/native/jni.c (_Jv_JNI_DefineClass): Fixed string-internal
-       warnings.
-       (_Jv_JNI_NewStringUTF): Likewise.
-       (_Jv_JNI_GetStringUTFChars): Likewise.
-
-2007-04-16 15:53  twisti
-
-       * src/native/vm/java_lang_Class.c (forName): Fixed string-internal
-       warnings.
-       (getDeclaredFields): Likewise.
-       (getDeclaredMethods): Likewise.
-       (getEnclosingMethod): Likewise.
-       (getClassSignature): Likewise.
-
-2007-04-16 15:49  twisti
-
-       * src/native/vm/java_lang_ClassLoader.c (defineClass): Fixed
-       string-internal warnings.
-       
-       * src/native/vm/java_lang_Runtime.c (loadLibrary): Likewise.
-       
-       * src/native/vm/gnu/java_lang_reflect_Field.c (getSignature):
-       Likewise.
-       
-       * src/native/vm/gnu/java_lang_reflect_Constructor.c (getSignature):
-       Likewise.
-       
-       * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace): Likewise.
-
-2007-04-16 15:29  twisti
-
-       * src/native/vm/gnu/java_lang_reflect_Method.c (getSignature): Fixed
-       string-internal warnings.
-
-2007-04-16 15:26  twisti
-
-       * src/native/vm/gnu/java_lang_VMRuntime.c (mapLibraryName): Fixed
-       string-internal warnings.
-
-2007-04-16 15:23  twisti
-
-       * src/native/vm/gnu/java_lang_VMClassLoader.c (loadClass): Fixed
-       string-internal warnings.
-       (nativeGetResources): Likewise.
-       (findLoadedClass): Likewise.
-
-2007-04-16 14:29  twisti
-
-       * src/vmcore/utf8.c (utf_get_number_of_u2s): Return 0 instead of NULL.
-
-2007-04-16 14:28  twisti
-
-       * src/threads/threads-common.c (native/include/java_lang_String.h):
-       Added.
-       (threads_create_thread): Fixed string-internal warnings.
-       (threads_dump): Likewise.
-
-2007-04-16 14:11  twisti
-
-       * src/vm/builtin.c (builtin_print_argument): Removed java_lang_String
-       until we know what we do with strings internally (more patches to
-       come).
-
-2007-04-15 21:49  twisti
-
-       * src/vm/jit/reg.c (reg_setup): Removed arg{int,flt}regs stuff.
-       * src/vm/jit/reg.h (registerdata): Removed arg{int,flt}regs.
-       
-       * src/vm/jit/stack.c (stack_analyse): regoff now contains the register
-       number instead of an offset.
-       
-       * src/vm/jit/allocator/simplereg.c: Use
-       abi_registers_{integer,float}_argument instead of arg{int,flt}regs.
-       
-       * src/vm/jit/alpha/codegen.c,
-       src/vm/jit/alpha/emit.c,
-       src/vm/jit/alpha/md-abi.c,
-       src/vm/jit/arm/codegen.c,
-       src/vm/jit/arm/emit.c,
-       src/vm/jit/arm/md-abi.c,
-       src/vm/jit/arm/md-abi.h,
-       src/vm/jit/i386/codegen.c,
-       src/vm/jit/i386/md-abi.c,
-       src/vm/jit/mips/codegen.c,
-       src/vm/jit/mips/emit.c,
-       src/vm/jit/mips/md-abi.c,
-       src/vm/jit/powerpc/codegen.c,
-       src/vm/jit/powerpc/emit.c,
-       src/vm/jit/powerpc/linux/md-abi.c,
-       src/vm/jit/powerpc/linux/md-abi.h,
-       src/vm/jit/x86_64/codegen.c,
-       src/vm/jit/x86_64/emit.c,
-       src/vm/jit/x86_64/md-abi.c: A lot of changes like the ones above.
-
-2007-04-15 21:13  twisti
-
-       * src/vm/jit/mips/emit.c (emit_load): Bugfix: Added missing float
-       instruction.
-       (emit_store): Likewise.
-
-2007-04-15 12:17  michi
-
-       * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument): Fixed.
-
-2007-04-15 12:15  michi
-
-       * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument): Added.
-       (abi_registers_integer_saved): Likewise.
-       (abi_registers_integer_temporary): Likewise.
-
-2007-04-15 11:55  michi
-
-       * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Fixed
-       calculation of stackframesize.
-
-2007-04-15 11:37  twisti
-
-       * tests/regression/resolving/Makefile.am: Added GNU header and fixed
-       srcdir != builddir.
-       * tests/regression/resolving/classes1/Makefile.am: Likewise.
-       * tests/regression/resolving/classes2/Makefile.am: Likewise.
-       * tests/regression/resolving/classes3/Makefile.am: Likewise.
-
-2007-04-13 11:48  twisti
-
-       * src/vm/jit/mips/codegen.c (codegen_emit): ICMD_LDIV, ICMD_LREM: Use
-       REG_Ax_Ax_PACKED defines.
-
-2007-04-13 10:42  twisti
-
-       * src/vm/jit/mips/md-abi.c (md_param_alloc): Code beautified.
-
-2007-04-13 10:12  twisti
-
-       * src/cacao/cacao.c (main): Save the error message of the first
-       lt_dlopenext and print it too when the second fails (thanks Dalibor).
-       Although there's still a problem, when the first fails for some reason
-       and the second picks up and old installed one silently.
-
-2007-04-12 19:49  twisti
-
-       * src/vm/jit/stack.c (stack_analyse): Removed USEBUILTINTABLE, always
-       check for automatic-builtins (compile this is not affected).
-       
-       * src/vm/jit/alpha/arch.h,
-       src/vm/jit/arm/arch.h,
-       src/vm/jit/i386/arch.h,
-       src/vm/jit/m68k/arch.h,
-       src/vm/jit/mips/arch.h,
-       src/vm/jit/powerpc/arch.h,
-       src/vm/jit/powerpc64/arch.h,
-       src/vm/jit/s390/arch.h,
-       src/vm/jit/sparc64/arch.h,
-       src/vm/jit/x86_64/arch.h (USEBUILTINTABLE): Removed.
-
-2007-04-12 15:35  tbfg
-
-       * src/vm/jit/powerpc64/emit.c (emit_patcher_stubs): Removed dead code.
-       
-       * src/vm/jit/powerpc64/codegen.c (ICMD_ISUB): Fixed evil bug.
-       (ICMD_LSHR): Fixed a bug.
-       (createnativestub): Use emit_patcher_stub.
-       
-       * src/vm/jit/powerpc64/patcher.c (patcher_resolve_native): Fixed.
-
-2007-04-12 14:47  twisti
-
-       * src/vm/jit/codegen-common.c (codegen_createnativestub): Renamed to
-       codegen_generate_stub_native and call codegen_finish.
-       
-       * src/vm/jit/codegen-common.h (codegen_createnativestub): Removed.
-       (codegen_generate_stub_native): Added.
-       * src/vm/jit_interface.h: Likewise.
-       * src/cacaoh/dummy.c: Likewise.
-       
-       * src/vmcore/loader.c (load_newly_created_array): Renamed
-       codegen_createnativestub to codegen_generate_stub_native and changed
-       signature.
-       * src/vm/jit/jit.c (jit_compile_intern): Likewise.
-       
-       * src/vm/jit/arm/codegen.c,
-       src/vm/jit/powerpc/codegen.c,
-       src/vm/jit/sparc64/codegen.c,
-       src/vm/jit/alpha/codegen.c,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/mips/codegen.c,
-       src/vm/jit/m68k/codegen.c,
-       src/vm/jit/powerpc64/codegen.c,
-       src/vm/jit/i386/codegen.c,
-       src/vm/jit/x86_64/codegen.c (createnativestub): Renamed to
-       codegen_emit_stub_native and changed signature, don't call
-       codegen_finish.
-
-2007-04-12 12:45  twisti
-
-       * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler): New
-       function.
-       
-       * src/vm/jit/codegen-common.h (createcompilerstub): Removed.
-       (codegen_generate_stub_compiler): Added.
-       * src/vm/jit_interface.h: Likewise.
-       * src/cacaoh/dummy.c: Likewise.
-       
-       * src/vmcore/linker.c (link_class_intern): Replaced createcompilerstub
-       with codegen_generate_stub_compiler.
-       
-       * src/vm/jit/alpha/codegen.c,
-       src/vm/jit/arm/codegen.c,
-       src/vm/jit/i386/codegen.c,
-       src/vm/jit/m68k/codegen.c,
-       src/vm/jit/mips/codegen.c,
-       src/vm/jit/powerpc/codegen.c,
-       src/vm/jit/powerpc64/codegen.c,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/sparc64/codegen.c,
-       src/vm/jit/x86_64/codegen.c (COMPILERSTUB_DATASIZE)
-       (COMPILERSTUB_SIZE): Removed.
-       (createcompilerstub): Renamed to codegen_emit_stub_compiler and
-       changed signature.
-       
-       * src/vm/jit/alpha/codegen.h,
-       src/vm/jit/arm/codegen.h,
-       src/vm/jit/i386/codegen.h,
-       src/vm/jit/m68k/codegen.h,
-       src/vm/jit/mips/codegen.h,
-       src/vm/jit/powerpc/codegen.h,
-       src/vm/jit/powerpc64/codegen.h,
-       src/vm/jit/s390/codegen.h,
-       src/vm/jit/sparc64/codegen.h,
-       src/vm/jit/x86_64/codegen.h (COMPILERSTUB_CODESIZE): Added.
-
-2007-04-12 11:56  twisti
-
-       * src/vm/jit/arm/linux/md-os.c (mm/memory.h): Removed.
-       [ENABLE_THREADS] (threads/native/threads.h): Added.
-
-2007-04-11 16:39  tbfg
-
-       * src/vm/jit/powerpc64/arch.h (SUPPORT_LONG_SHIFT): Enabled.
-       
-       * src/vm/jit/powerpc64/codegen.c (ICMD_LSHLCONST): Implemented.
-       (ICMD_LSHRCONST): Likewise.
-       (ICMD_LUSHRCONST): Likewise.
-       (ICMD_LSHL): Likewise.
-       (ICMD_LSHR): Likewise.
-       (ICMD_LUSHR): Likewise.
-       (ICMD_IUSHR): Fixed.
-       (ICMD_IUSHRCONST): Fixed.
-       
-       * src/vm/jit/powerpc64/codegen.h (M_SRL): Use 64bit opcode.
-       (M_SRA): Likewise.
-       (M_SRA_IMM): Likewise.
-       (M_SRL_IMM): Likewise.
-       (M_SSL_IMM): Likewise.
-       (M_SSL): Likewise.
-       (M_CLR_HIGH): Added.
-
-2007-04-11 08:21  twisti
-
-       * src/toolbox/logging.c (log_finish): Also print a \n in the log-file.
-
-2007-04-11 08:11  twisti
-
-       * src/vm/jit/codegen-common.c (codegen_generate): Added re-generating
-       debug message.
-
-2007-04-10 21:37  twisti
-
-       * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): We only
-       need to check the cause for pre glibc-2.5.
-
-2007-04-10 21:24  twisti
-
-       * src/vm/jit/mips/codegen.c (codegen_emit): Fixed ICMD_IF_Lxx
-       instructions for 64-bit.
-
-2007-04-10 12:22  twisti
-
-       * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Set val
-       accordingly.
-
-2007-04-10 05:02  pm
-
-       * src/vm/jit/s390/emit.c,
-       src/vm/jit/s390/md-abi.h,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/codegen.h,
-       src/vm/jit/s390/arch.h,
-       src/vm/jit/s390/asmpart.S,
-       src/vm/jit/s390/tests/tests.java.pp: Changed very much.
-
-2007-04-09 21:17  twisti
-
-       * src/vm/jit/alpha/emit.c (emit_copy): Check src-type, not dst-type.
-
-2007-04-09 17:23  twisti
-
-       * src/vm/jit/alpha/asmpart.S: Use % instead of @ for progbits as ARM's
-       assembler uses @ as comment character.
-       * src/vm/jit/arm/asmpart.S: Likewise.
-       * src/vm/jit/i386/asmpart.S: Likewise.
-       * src/vm/jit/mips/asmpart.S: Likewise.
-       * src/vm/jit/powerpc/asmpart.S: Likewise.
-       * src/vm/jit/powerpc64/asmpart.S: Likewise.
-       * src/vm/jit/s390/asmpart.S: Likewise.
-       * src/vm/jit/sparc64/asmpart.S: Likewise.
-       * src/vm/jit/x86_64/asmpart.S: Likewise.
-
-2007-04-09 11:51  twisti
-
-       * src/vm/jit/mips/codegen.h (BRANCH_NOPS): Added long-branches case.
-       
-       * src/vm/jit/mips/emit.c (emit_load): Use switch-case instead of
-       if-else contruct.
-       (emit_store): Likewise.
-       (emit_copy): Likewise.
-       (emit_branch): Implemented conditional long-branches.
-
-2007-04-08 21:14  twisti
-
-       * src/native/vm/cldc1.1/java_lang_Object.c (notifyAll): Implemented.
-       * src/native/vm/cldc1.1/java_lang_String.c (lastIndexOf__I): Likewise.
-
-2007-04-05 14:23  michi
-
-       * src/vm/global.h (compiler_lock, compiler_unlock): Removed.
-       * src/cacaoh/dummy.c (compiler_lock, compiler_unlock): Removed.
-       * src/threads/native/threads.c (compiler_lock, compiler_unlock):
-       Removed.
-       
-       * src/vmcore/linker.h (linker_classrenumber_lock): Added.
-       * src/vmcore/linker.c (linker_classrenumber_lock): Added.
-       (linker_compute_subclasses): Uses above lock object instead of
-       compiler_lock.
-       
-       * src/vm/jit/intrp/asmpart.c (intrp_asm_getclassvalues_atomic):
-       Likewise.
-
-2007-04-05 13:22  michi
-
-       * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Inserted
-       ifdef to fix
-       compiler error with disabled threads.
-
-2007-04-05 12:06  twisti
-
-       * src/vm/exceptions.c (exceptions_throw_nosuchmethoderror)
-       [!ENABLE_JAVASE]: Throw an error.
-
-2007-04-05 11:57  twisti
-
-       * src/threads/threads-common.c (threads_get_state): Renamed to
-       threads_thread_get_state.
-       (threads_thread_is_alive): New function.
-       
-       * src/threads/threads-common.h: Likewise.
-       
-       * src/native/vm/java_lang_Thread.c (isAlive): New function.
-       (getState): Renamed threads_get_state to threads_thread_get_state.
-       
-       * src/native/vm/java_lang_Thread.h (isAlive): Added.
-       
-       * src/native/vm/cldc1.1/java_lang_Thread.c (isAlive): New function.
-
-2007-04-05 11:39  twisti
-
-       * src/native/vm/java_lang_Thread.c [ENABLE_THREADS]
-       (threads/native/threads.h): Removed.
-       (threads/threads-common.h): Added.
-       (vm/stringlocal.h): Likewise.
-       (vm/vm.h): Removed.
-       (getState): Implemented.
-       
-       * src/threads/threads-common.c (vm/vm.h): Added.
-       (threads_get_state): New function.
-       (threads_dump): Print thread state.
-       
-       * src/threads/threads-common.h (THREAD_STATE_NEW)
-       (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING)
-       (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Defined.
-       (threads_get_state): Added.
-       
-       * src/threads/native/threads.c (threads_init): Set thread-state.
-       (threads_startup_thread): Likewise.
-       (threads_attach_current_thread): Likewise.
-       (threads_detach_thread): Likewise.
-       (threads_wait_with_timeout): Likewise.
-       
-       * src/threads/native/threads.h (threadobject): Added state field.
-       
-       * src/native/native.c (dummynativetable) [ENABLE_JAVASE]: Added
-       Java_java_lang_VMThread_getState.
-
-2007-04-05 00:14  twisti
-
-       * src/threads/threads-common.c (threads_print_stacktrace): Removed
-       !ENABLE_THREADS code, since this file is only compiled with
-       ENABLE_THREADS.
-
-2007-04-04 22:29  twisti
-
-       * src/vm/jit/verify/typecheck-stackbased.c: Use block directly instead
-       of insindex.
-       * src/vm/jit/verify/typecheck-stackbased-gen.inc: Newly generated.
-
-2007-04-04 22:14  twisti
-
-       * src/vm/jit/parse.c (BYTECODEINDEX_TO_BASICBLOCK): Added.
-       (parsedata_t): Removed instructionstart, added bytecodestart,
-       basicblockstart, bytecodemap, instructionmap.
-       (parse_setup): Allocate new arrays.
-       (parse_bytecodeindex_to_basicblock): New function.
-       (parse_mark_exception_boundaries): Pass parsedata_t.
-       (parse_resolve_exception_table): Likewise.
-       (parse): Completely rewritten so we are able to have basic block
-       boundaries on IR instruction level. We now also resolve basic block
-       pointers in this pass.
-       
-       * src/vm/jit/parse.h (MARK_BASICBLOCK): Pass parsedata_t.
-       (BLOCK_OF): Removed.
-       
-       * src/vm/jit/jit.h (jitdata): Removed basicblockindex.
-       
-       * src/vm/jit/show.c (SHOW_TARGET): Print block instead of insindex.
-       (show_icmd): Likewise.
-       
-       * src/vm/jit/stack.c (BRANCH_TARGET): Directly use block.
-       (stack_analyse): Likewise.
-       * src/vm/jit/verify/icmds.c: Likewise.
-       * src/vm/jit/verify/typecheck-stackbased.c: Likewise.
-
-2007-04-04 14:16  twisti
-
-       * src/native/vm/gnu/sun_misc_Unsafe.c: Header changes.
-       
-       * src/native/native.c [ENABLE_JAVASE]
-       (native/include/sun_misc_Unsafe.h): Added.
-       [ENABLE_JAVASE] (dummynativetable): Added
-       Java_sun_misc_Unsafe_objectFieldOffset and
-       Java_sun_misc_Unsafe_compareAndSwapInt.
-
-2007-04-03 22:29  twisti
-
-       * src/vm/jit/alpha/asmpart.S: Replaced __GNU__ with __linux__ for
-       exec-stacks.
-       * src/vm/jit/arm/asmpart.S: Likewise.
-       * src/vm/jit/i386/asmpart.S: Likewise.
-       * src/vm/jit/mips/asmpart.S: Likewise.
-       * src/vm/jit/powerpc/asmpart.S: Likewise.
-       * src/vm/jit/powerpc64/asmpart.S: Likewise.
-       * src/vm/jit/s390/asmpart.S: Likewise.
-       * src/vm/jit/sparc64/asmpart.S: Likewise.
-       * src/vm/jit/x86_64/asmpart.S: Likewise.
-
-2007-04-03 21:30  twisti
-
-       * src/vm/jit/i386/linux/md-os.c (threads/threads-common.h): Added.
-
-2007-04-03 18:02  twisti
-
-       * src/vm/jit/mips/md-abi.h (REG_FA0, REG_FA1, REG_FA2): Defined.
-
-2007-04-03 16:06  twisti
-
-       * src/threads/threads-common.c (threads_print_stacktrace): Pass
-       stackframeinfo to stacktrace_create.
-       
-       * src/vm/jit/codegen-common.c (threads/native/threads.h): Removed.
-       (threads/threads-common.h): Added.
-       (codegen_get_pv_from_pc): Replaced stacktrace_dump_trace with
-       threads_print_stacktrace.
-       
-       * src/vm/jit/stacktrace.h (stacktrace_print_trace_from_buffer): Added.
-
-2007-04-03 15:51  twisti
-
-       * src/vm/jit/stacktrace.c (stacktrace_create): Changed signature.
-       
-       (stacktrace_fillInStackTrace): Pass stackframeinfo to
-       stacktrace_create.
-       (stacktrace_getClassContext): Likewise.
-       (stacktrace_getCurrentClass): Likewise.
-       (stacktrace_getStack): Likewise.
-       (stacktrace_dump_trace): Removed.
-       
-       * src/vm/jit/stacktrace.h (threads/native/threads.h)
-       (threads/none/threads.h): Removed.
-       (stacktrace_create): Added.
-       (stacktrace_dump_trace): Removed.
-       
-       * src/threads/native/threads.c (threads_dump): Removed.
-       * src/threads/native/threads.h (threads_dump): Likewise.
-       
-       * src/threads/threads-common.c (vm/jit/stacktrace.h): Added.
-       (threads_dump): Added.
-       (threads_print_stacktrace): Likewise.
-       
-       * src/threads/threads-common.h (threads_dump): Added.
-       (threads_print_stacktrace): Likewise.
-
-2007-04-03 15:29  twisti
-
-       * src/vm/jit/replace.c (threads/threads-common.h): Added.
-       
-       * src/vm/jit/replace.h: Moved empty defines to the top of the file to
-       see what's happening when !defined(ENABLE_REPLACEMENT).
-
-2007-04-03 15:22  twisti
-
-       * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigfpe): Use
-       exceptions_new_hardware_exception.
-       * src/vm/exceptions.c (exceptions_fillinstacktrace)
-       [ENABLE_JAVAME_CLDC1_1]: fillInStackTrace has another signature in
-       CLDC-1.1.
-
-2007-04-03 14:34  twisti
-
-       * src/vm/jit/arm/emit.c (emit_exception_stubs): Removed.
-       
-       * src/vm/jit/arm/md.c (md_codegen_patch_branch): Likewise.
-       (md_stacktrace_get_returnaddress): Removed debug code.
-
-2007-04-03 14:23  twisti
-
-       * src/threads/native/threads.h (STACKFRAMEINFO): Return stackframeinfo
-       instead of a pointer to it.
-       * src/threads/none/threads.h (STACKFRAMEINFO): Likewise.
-       
-       * src/vm/jit/codegen-common.c (codegen_finish_native_call):
-       STACKFRAMEINFO changes.
-       
-       * src/vm/jit/replace.c (replace_recover_source_state): Likewise.
-       
-       * src/vm/jit/stacktrace.c (stacktrace_create_stackframeinfo):
-       Likewise.
-       (stacktrace_create_extern_stackframeinfo): Likewise.
-       (stacktrace_create_native_stackframeinfo): Likewise.
-       (stacktrace_remove_stackframeinfo): Likewise.
-
-2007-04-03 14:00  twisti
-
-       * src/vm/jit/stacktrace.c (stacktrace_create_inline_stackframeinfo):
-       Removed.
-       (stacktrace_inline_arithmeticexception): Likewise.
-       (stacktrace_inline_arrayindexoutofboundsexception): Likewise.
-       (stacktrace_inline_arraystoreexception): Likewise.
-       (stacktrace_inline_classcastexception): Likewise.
-       (stacktrace_inline_nullpointerexception): Likewise.
-       (stacktrace_inline_fillInStackTrace): Likewise.
-       (stacktrace_hardware_arithmeticexception): Likewise.
-       (stacktrace_hardware_nullpointerexception): Likewise.
-       
-       * src/vm/jit/stacktrace.h: Likewise.
-
-2007-04-03 13:48  twisti
-
-       * configure.ac: Added armv4 architecture.
-
-2007-04-03 13:47  twisti
-
-       * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Use
-       exceptions_new_hardware_exception.
-       [ENABLE_THREADS] (md_signal_handler_sigusr2): New function.
-
-2007-04-03 13:14  twisti
-
-       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigfpe): Use
-       exceptions_new_hardware_exception.
-
-2007-04-03 12:10  twisti
-
-       * src/vm/jit/jit.h: Includes alpha-sorted.
-
-2007-04-03 11:56  twisti
-
-       * src/vm/jit/replace.c (native/include/java_lang_String.h): Removed.
-       (java_value_print): Don't cast to java_lang_String.
-
-2007-04-03 11:46  twisti
-
-       * src/vm/jit/allocator/simplereg.c (simplereg_make_statistics): Fixed
-       compiler warning.
-
-2007-04-03 11:37  twisti
-
-       * src/vm/jit/x86_64/emit.c (emit_replacement_stubs): Removed unused
-       variable disp.
-
-2007-04-03 11:35  twisti
-
-       * src/vmcore/statistics.c (statistics_print_memory_usage): Prevent
-       compiler warning on 64-bit machines.
-
-2007-04-02 23:13  michi
-
-       * src/vm/jit/replace.c: Added include to fix crash on x86_64.
-
-2007-04-02 21:24  twisti
-
-       * src/vm/jit/alpha/linux/md-os.c [ENABLE_THREADS]
-       (threads/native/threads.h): Added.
-       [ENABLE_THREADS] (md_signal_handler_sigusr2): Added #ifdef.
-
-2007-04-02 20:58  twisti
-
-       * src/vm/jit/alpha/md-abi.c (abi_registers_integer_argument): Added.
-       (abi_registers_integer_saved): Likewise.
-       (abi_registers_integer_temporary): Likewise.
-
-2007-04-02 20:04  michi
-
-       * src/vm/jit/stacktrace.c (stacktrace_create): Returns NULL if there
-       is no
-       stacktrace available for the given thread. Fixed comments.
-
-2007-04-02 19:56  twisti
-
-       * src/vm/jit/x86_64/md-abi.c (abi_registers_integer_argument): Added.
-       (abi_registers_integer_saved): Likewise.
-       (abi_registers_integer_temporary): Likewise.
-
-2007-04-02 19:45  twisti
-
-       * src/vm/jit/parse.c (parse): JAVA_GOTO_W must be converted to a
-       ICMD_GOTO.
-
-2007-04-02 18:56  twisti
-
-       * src/vm/jit/jit.h (INS_FLAG_BASICBLOCK): Defined.
-       (INS_FLAG_ID_SHIFT): Changed to 5.
-       (INSTRUCTION_STARTS_BASICBLOCK): Added.
-       
-       * src/vm/jit/parse.c (parse): Changed basic block determination. Now
-       basic blocks can start at IR instruction level. This is required for
-       slow-fast path builtins.
-
-2007-04-02 16:09  twisti
-
-       * src/vm/jit/stack.c (stack_reach_next_block): Reformatted comments.
-       (stack_analyse): Likewise.
-
-2007-04-02 13:45  twisti
-
-       * src/vm/jit/stack.c (stack_mark_reached): Added assert on b.
-       (stack_mark_reached_from_outvars): Likewise.
-       (stack_reach_next_block): Use NULL instead of !.
-       (stack_analyse): Indent.
-
-2007-04-01 22:53  ajordan
-
-       * src/vm/jit/sparc64/codegen.c: Implemented float argument passing
-       for builtin calls.
-       * src/vm/jit/sparc64/codegen.h: Likewise.
-
-2007-04-01 16:18  stefan
-
-       * src/vm/jit/powerpc/darwin/md-asm.h,
-       src/vm/jit/i386/darwin/md-asm.h: added missing symbol
-       asm_vm_call_method_end.
-
-2007-04-01 10:50  edwin
-
-       * contrib/vmlog: Committed vmlog 0.0.5.
-       * THIRDPARTY: Added copyright notice for vmlog.
-
-2007-03-30 11:41  twisti
-
-       * src/vm/jit/parse.c (parse_realloc_instructions): Renamed ipc to
-       icount.
-       (parse): Renamed ipc to icount, set method variables at the very end
-       and use local variables before.
-       
-       * src/vm/jit/parse.h (INSTRUCTIONS_CHECK): Renamed ipc to icount.
-       (PINC): Likewise.
-       (OP_PREPARE_FLAGS): Likewise.
-
-2007-03-29 23:22  twisti
-
-       * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): Fixed
-       address check (thanks Michi).
-
-2007-03-29 23:01  ajordan
-
-       * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed ICMD_IREMPOW2.
-       Added ICMD_L2F and ICMD_L2D.
-       Fixed constant creation in IF_L* compares.
-
-2007-03-29 21:56  michi
-
-       * src/mm/nogc.c: Fixed merging conflict which was commited to that
-       file.
-
-2007-03-29 21:37  ajordan
-
-       * src/vm/jit/sparc64/md.c (md_get_pv_from_pc): Implemented sethi
-       hanlding.
-       
-       * src/vm/jit/sparc64/codegen.c (createnativestub): Fixed window/stack
-       handling in case of exception.
-       * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Likewise.
-
-2007-03-29 11:04  twisti
-
-       * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): Check
-       for addr == NULL in NPE case.
-
-2007-03-29 06:52  pm
-
-       * src/vm/jit/s390/md-abi.h,
-       src/vm/jit/s390/emit.c,
-       src/vm/jit/s390/emit.h,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/codegen.h,
-       src/vm/jit/s390/arch.h: Changed a lot.
-
-2007-03-28 22:59  twisti
-
-       * src/vm/exceptions.h (exceptionptr): Removed.
-       (_no_threads_exceptionptr): Likewise.
-
-2007-03-28 22:32  twisti
-
-       * svnmerge uninit.
-
-2007-03-28 22:25  michi
-
-       * AUTHORS: Added myself to the list of authors (finally).
-
-2007-03-28 21:05  twisti
-
-       * Merged in twisti-branch.
-
-2007-03-28 20:50  twisti
-
-       Initialized merge tracking via "svnmerge" with revisions "1-6085"
-       from
-       file:///ahome/cacao/svn/cacao/branches/twisti
-
-2007-03-28 20:28  twisti
-
-       Initialized merge tracking via "svnmerge" with revisions "1-6086"
-       from
-       svn+ssh://c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/branches/twisti
-
-2007-03-28 20:22  twisti
-
-       Initialized merge tracking via "svnmerge" with revisions "1-7592"
-       from
-       svn+ssh://c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/branches/twisti
-
-2007-03-28 13:29  twisti
-
-       * src/vm/exceptions.c (throw_exception_exit_intern): Removed.
-       (throw_exception): Likewise.
-       (throw_exception_exit): Likewise.
-       (throw_main_exception): Likewise.
-       (throw_main_exception_exit): Likewise.
-       (throw_cacao_exception_exit): Likewise.
-       (exceptions_print_stacktrace): New function.
-       * src/vm/exceptions.h: Likewise.
-       
-       * src/vm/vm.c (vm_create): Use vm_abort or exceptions_print_stacktrace
-       instead of throw_main_exception_exit.
-       (vm_run): Likewise.
-       (vm_exit): Likewise.
-       (vm_get_mainclass_from_jar): Likewise.
-       
-       * src/threads/native/threads.c (threads_init): Use return instead of
-       throw_exception_exit.
-       (threads_startup_thread): Use vm_abort.
-
-2007-03-26 07:23  pm
-
-       * src/vm/jit/s390/emit.c,
-       src/vm/jit/s390/md-abi.h,
-       src/vm/jit/s390/md.c,
-       src/vm/jit/s390/emit.h,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/codegen.h,
-       src/vm/jit/s390/tests/tests.java.pp,
-       src/vm/jit/s390/patcher.c,
-       src/vm/jit/s390/md-abi.c: Chaned a lot.
-
-2007-03-25 20:30  twisti
-
-       Reverted patch 7268.
-       
-       * src/vm/jit/code.c: Reverted.
-       * src/vm/jit/code.h: Likewise.
-       * src/vm/jit/jit.c: Likewise.
-       * src/vm/jit/jit.h: Likewise.
-       * src/vmcore/loader.c: Likewise.
-       * src/vmcore/method.h: Likewise.
-
-2007-03-25 18:55  twisti
-
-       * src/native/native.c (native_get_parametertypes): Removed.
-       (native_get_exceptiontypes): Likewise.
-       * src/native/native.h: Likewise.
-       
-       * src/vmcore/method.c (vm/builtin.h): Added.
-       (vm/resolve.h): Likewise.
-       (method_get_parametertypearray): New function.
-       (method_get_exceptionarray): Likewise.
-       * src/vmcore/method.h (method_get_parametertypearray): Added.
-       (method_get_exceptionarray): Likewise.
-       
-       * src/cacaoh/dummy.c (builtin_anewarray): Added.
-       (resolve_class_from_typedesc): Likewise.
-       
-       * src/native/vm/gnu/java_lang_reflect_Method.c (getParameterTypes):
-       Use method function.
-       (getExceptionTypes): Likewise.
-       * src/native/vm/gnu/java_lang_reflect_Constructor.c
-       (getParameterTypes): Likewise.
-       (getExceptionTypes): Likewise.
-
-2007-03-23 21:33  twisti
-
-       * src/vm/builtin.c (builtin_isanysubclass): Removed.
-       (builtin_instanceof): Replaced builtin_isanysubclass with
-       class_isanysubclass.
-       (builtin_descriptorscompatible): Likewise.
-       
-       * src/vm/builtin.h (builtin_isanysubclass): Removed.
-       
-       * src/vm/access.c (access_is_accessible_member): Replaced
-       builtin_isanysubclass with class_isanysubclass.
-       * src/native/vm/java_lang_Class.c (isAssignableFrom): Likewise.
-       
-       * src/vm/jit/asmpart.h (castinfo): Removed.
-       
-       * src/vmcore/class.c (vm/jit/asmpart.h): Added.
-       (class_isanysubclass): New function.
-       
-       * src/vmcore/class.h (castinfo): Added.
-       (class_isanysubclass): Likewise.
-       
-       * src/cacaoh/dummy.c (asm_getclassvalues_atomic): New function.
-       (intrp_asm_getclassvalues_atomic): Likewise.
-
-2007-03-23 20:38  twisti
-
-       * src/vm/builtin.c (builtin_isanysubclass_vftbl): Removed.
-       (builtin_descriptorscompatible): Use builtin_isanysubclass instead of
-       builtin_isanysubclass_vftbl.
-
-2007-03-23 19:10  twisti
-
-       * src/vm/global.h (ACC_CLASS_PRIMITIVE): Defined.
-       
-       * src/vm/builtin.c (builtin_isanysubclass): Check for primitive
-       classes.
-       
-       * src/vmcore/linker.c (link_primitivetype_table): Set primitive flag.
-
-2007-03-23 18:51  twisti
-
-       * src/vmcore/classcache.c (classcache_add_constraint)
-       [CLASSCACHE_VERBOSE]: Started to use log-functions.
-       (classcache_debug_dump): Likewise.
-
-2007-03-23 11:56  twisti
-
-       * src/vm/jit/powerpc/emit.c (emit_load): Use switch-case instead of
-       if-else contruct.
-       (emit_store): Likewise.
-       (emit_copy): Likewise.
-
-2007-03-22 13:55  michi
-
-       * src/vm/jit/arm/codegen.c (codegen) [!ENABLE_SOFTFLOAT]: Fixed
-       position of
-       soft null pointer checks in PUTFIELD and GETFIELD.
-
-2007-03-21 14:26  twisti
-
-       * src/vmcore/statistics.c (size_lock_record_pool): Added.
-       (statistics_print_memory_usage): Print new variable.
-       
-       * src/vmcore/statistics.h (size_lock_record_pool): Added.
-       
-       * src/threads/native/lock.c (lock_record_alloc_new_pool): Added
-       statistics.
-
-2007-03-21 13:27  twisti
-
-       * src/vmcore/statistics.c (size_threadobject, size_lock_hashtable)
-       (size_lock_waiter): Added.
-       (statistics_print_memory_usage): Print new variables.
-       
-       * src/vmcore/statistics.h (size_threadobject, size_lock_hashtable)
-       (size_lock_waiter): Added.
-       
-       * src/threads/native/lock.c (vmcore/options.h): Added.
-       [ENABLE_STATISTICS] (vmcore/statistics.h): Added.
-       (lock_hashtable_init): Added statistics.
-       (lock_hashtable_grow): Likewise.
-       (lock_record_add_waiter): Likewise.
-       (lock_record_remove_waiter): Likewise.
-       
-       * src/threads/native/threads.c [ENABLE_STATISTICS]
-       (vmcore/statistics.h): Added.
-       (threads_preinit): Added statistics.
-       (threads_init): Likewise.
-       (threads_start_javathread): Likewise.
-       (threads_attach_current_thread): Likewise.
-       (threads_detach_thread): Likewise.
-
-2007-03-21 13:19  twisti
-
-       * src/vmcore/zip.c (zip_get): Don't assign in if-statement, this makes
-       debugging a bit easier.
-
-2007-03-21 13:18  twisti
-
-       * src/vmcore/linker.c (link_primitivetype_table): Set super class
-       explicitly to NULL.
-       (linker_compute_subclasses): Indent.
-
-2007-03-20 00:25  ajordan
-
-       * src/vm/jit/sparc64/md-abi.c (md_param_alloc_native): using this for
-       native param allocation. No need for my own version of this anymore.
-       * src/vm/jit/sparc64/codegen.c: Likewise.
-
-2007-03-17 13:12  twisti
-
-       * src/vm/builtin.h (builtin_isanysubclass_vftbl): Removed, made
-       static.
-
-2007-03-17 13:11  twisti
-
-       * src/vm/builtin.c (builtin_isanysubclass): Code cleanup.
-       (builtin_isanysubclass_vftbl): Likewise.
-
-2007-03-17 13:10  twisti
-
-       * src/native/vm/gnu/java_lang_reflect_Method.c (vm/resolve.h): Added.
-
-2007-03-17 12:57  twisti
-
-       * src/vm/builtin.c (builtin_isanysubclass): Cleanup and comments.
-
-2007-03-16 23:00  pm
-
-       * src/vm/exceptions.c (exceptions_handle_exception): 31 bit address
-       comparison for S390. These address comparison macros need to be moved
-       to some header.
-       * src/vm/jit/s390/emit.c,
-       src/vm/jit/s390/md.c,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/codegen.h,
-       src/vm/jit/s390/arch.h,
-       src/vm/jit/s390/patcher.c,
-       src/vm/jit/s390/md-abi.c,
-       src/vm/jit/s390/tests/tests.java.pp,
-       src/vm/jit/s390/tests/Makefile: Changed a lot.
-
-2007-03-15 09:28  twisti
-
-       * src/native/jni.c (_Jv_jni_invokeNative): Release memory in exception
-       case.
-
-2007-03-15 08:23  pm
-
-       * src/vm/jit/s390/tests/tests.java.pp: added INT2CHAR test testing
-       negative values.
-
-2007-03-15 07:07  pm
-
-       * src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/codegen.h: Changed a lot.
-       * src/vm/jit/s390/tests,
-       src/vm/jit/s390/tests/tests.java.pp,
-       src/vm/jit/s390/tests/Makefile: Added opcode tests in java.
-
-2007-03-14 21:54  twisti
-
-       * src/vmcore/statistics.c (size_string): Added.
-       (statistics_print_memory_usage): Likewise.
-       * src/vmcore/statistics.h (size_string): Likewise.
-       
-       * src/vm/string.c (vmcore/statistics.h): Added.
-       (literalstring_u2): Added statistics.
-
-2007-03-14 21:18  twisti
-
-       * src/vm/jit/alpha/emit.c (emit_load): Use switch-case instead of
-       if-else contruct.
-       (emit_store): Likewise.
-       (emit_copy): Likewise.
-
-2007-03-14 21:16  twisti
-
-       * src/vm/jit/alpha/md.c (vm/jit/codegen-common.h): Added temporarily.
-
-2007-03-14 17:31  michi
-
-       * src/vm/jit/arm/codegen.c (codegen): All the long compares have a
-       different
-       implementation now.
-
-2007-03-14 16:44  michi
-
-       * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Fixed bug with
-       inmemory
-       arguments, which caused some crashes with verbose-calls.
-
-2007-03-14 12:00  michi
-
-       * src/mm/nogc.c: Fixed includes and exceptions.
-
-2007-03-13 20:31  twisti
-
-       * src/vm/jit/i386/emit.c (emit_load): Use switch-case instead of
-       if-else contruct.
-       (emit_store): Likewise.
-       (emit_copy): Likewise.
-       * src/vm/jit/i386/codegen.c (codegen): Fixed compiler warning.
-
-2007-03-13 16:32  michi
-
-       * src/vm/jit/arm/codegen.c (codegen): Long branches are implemented
-       differently now.
-       
-       * src/vm/jit/arm/codegen.h (M_COMPARE): Easier macros without
-       overjumps.
-       (M_MOVEQ_IMM, M_MOVGT_IMM, M_ADDHI_IMM, M_SUBLO_IMM, M_CMPEQ_IMM):
-       New macro.
-
-2007-03-13 13:19  michi
-
-       * src/vm/jit/arm/linux/Makefile.am: Fixed include path to care about
-       builddir.
-
-2007-03-12 13:34  twisti
-
-       * src/vm/jit/codegen.c (codegen): Change the operand direction of some
-       macros. Started to implement long-compares differently.
-       
-       * src/vm/jit/codegen.h (M_AND, M_ORR, M_EOR, M_AND_IMM, M_MOVEQ)
-       (M_MOVVS_IMM, M_MOVNE_IMM, M_MOVLT_IMM, M_MOVLS_IMM): Changed operand
-       direction.
-       (M_ORR_S, M_CMPEQ, M_CMPLE): New macro.
-
-2007-03-12 13:17  twisti
-
-       * src/vm/jit/arm/md.c (vm/jit/codegen-common.h): Added.
-
-2007-03-12 10:11  twisti
-
-       * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c
-       (vm/vm.h): Added.
-       (open): Call vm_abort.
-       
-       * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c
-       (unistd.h): Added.
-       (readByte): New function.
-       (writeBuf): Likewise.
-       (available0): Likewise.
-       (close0): Likewise.
-
-2007-03-09 21:26  twisti
-
-       * tests/regression/resolving (svn:ignore): Added.
-       * tests/regression/resolving/classes1: Likewise.
-       * tests/regression/resolving/classes2: Likewise.
-       * tests/regression/resolving/classes3: Likewise.
-
-2007-03-08 02:59  michi
-
-       * src/threads/native/threads.c (threads_init) [!ENABLE_GC_CACAO]:
-       Fixed bug for
-       lost java.lang.Thread object of mainthread with BoehmGC.
-       
-       * src/native/vm/java_lang_Thread.c: Fixed includes to prevend
-       compiler warnings.
-
-2007-03-07 14:05  twisti
-
-       * src/vm/jit/mips/md.c (vm/jit/codegen-common.h): Temporarily added.
-
-2007-03-07 13:12  twisti
-
-       * src/vm/jit/x86_64/emit.c (emit_call_reg): Call emit_rex with size 0.
-
-2007-03-07 12:37  twisti
-
-       * src/vm/jit/x86_64/asmpart.S (asm_compare_and_swap): New function.
-       (asm_memory_barrier): Likewise.
-
-2007-03-07 11:47  michi
-
-       * src/threads/native/threads.h (threadobject): This structure is no
-       longer an
-       instance of java.lang.Thread, but contains a reference to it.
-       
-       * src/threads/native/threads.c (threads_start_javathread): Added.
-       
-       * src/threads/threads-common.c: Adapted to above changes.
-       * src/threads/native/threads.c: See above.
-       * src/native/vm/java_lang_Thread.c: See above.
-
-2007-03-07 00:32  ajordan
-
-       * src/vm/jit/sparc64/md-abi.h: increased number of JIT float argument
-       registers to 5.
-       * src/vm/jit/sparc64/md-asm.h: likewise.
-       * src/vm/jit/sparc64/md-abi.c: likewise.
-       
-       * src/vm/jit/sparc64/asmpart.S: added floating point argument
-       handling in asm_vm_call.
-
-2007-03-06 18:55  ajordan
-
-       * src/vm/jit/sparc64/emit.c: emit_{load,store,copy} changed to
-       switch/case for handling different types.
-       
-       * src/vm/jit/sparc64/codegen.h: fixed f2d and d2f conversion.
-       
-       * src/vm/jit/sparc64/md-abi.c: removed md_native_reg_setup(), not
-       needed any longer.
-       
-       * src/vm/jit/sparc64/codegen.c: implemented ICMD_MULTIANEWARRAY.
-       fixed FRETURN, DRETURN.
-       repaired native float arg passing.
-
-2007-03-06 17:01  twisti
-
-       * src/vm/signal.c (arch.h): Added.
-       * src/vm/vm.c (vm_create): Reenabled signal-thread. This only works on
-       NPTL-threads and NOT with linuxthreads!
-       
-       * src/vm/signal.c (signal_init): Reenabled blocking for SIGINT and
-       SIGQUIT.
-
-2007-03-06 11:12  twisti
-
-       * src/vmcore/statistics.c (vm/jit/code.h): Added for codeinfo.
-       (vmcore/class.h): Added.
-       (vmcore/field.h): Likewise.
-       (vmcore/method.h): Likewise.
-       
-       * src/vm/jit/optimizing/recompile.c (vm/jit/code.h): Likewise.
-       (vm/jit/jit.h): Likewise.
-       
-       * src/vm/jit/x86_64/md.c (vm/jit/codegen-common.h): Likewise.
-       * src/vm/jit/x86_64/md-abi.c (vm/jit/jit.h): Likewise.
-
-2007-03-06 00:27  edwin
-
-       * src/vm/jit_interface.h: Added Id keyword.
-
-2007-03-06 00:26  edwin
-
-       * src/vmcore/resolve.c: Moved back to src/vm/resolve.c.
-       * src/vmcore/resolve.h: Moved back to src/vm/resolve.h.
-       * src/vm/jit/code.h (codeinfo): Moved typedef to method.h.
-       (code_get_methodinfo_for_pv): Added prototype.
-       * src/vmcore/method.h (codeinfo): Moved typedef here.
-       
-       * src/vm/jit_interface.h: New file.
-       
-       * src/vm/Makefile.am: Added resolve.[ch] and jit_interface.h.
-       * src/vmcore/Makefile.am: Removed resolve.[ch].
-       
-       * src/vmcore/class.c: Include "arch.h", but don't include "resolve.h".
-       
-       * src/vmcore/method.c (method_vftbl_lookup):
-       Use code_get_methodinfo_for_pv.
-       
-       * src/vmcore/linker.c (resolve_classref_or_classinfo_eager): Added
-       copy of prototype to avoid bootstrapping issues.
-       
-       * src/cacaoh/dummy.c (code_get_methodinfo_for_pv): New dummy.
-       (resolve_classref_or_classinfo_eager): Simple implementation that does
-       not use resolve.c code.
-       (typeinfo_init_class): Removed dummy.
-       (typeinfo_init_classinfo): Likewise.
-       (typeinfo_is_assignable_to_class): Likewise.
-       (typeinfo_print): Likewise.
-       
-       * many other files: Changed #include "vmcore/resolve.h" to
-       "vm/resolve.h".
-
-2007-03-06 00:02  edwin
-
-       * src/vmcore/linker.c (link_class_intern):
-       Use resolve_classref_or_classinfo_eager.
-
-2007-03-05 23:56  edwin
-
-       * src/cacaoh/headers.c: Don't include asmpart.h.
-
-2007-03-05 23:50  edwin
-
-       * src/native/native.c (native_get_exceptiontypes):
-       Use resolve_classref_or_classinfo_eager.
-
-2007-03-05 17:44  edwin
-
-       * src/native/vm/java_lang_Class.c (_Jv_java_lang_Class_getSuperclass),
-       (_Jv_java_lang_Class_getDeclaringClass)
-       (_Jv_java_lang_Class_getDeclaredClasses):
-       Use resolve_classref_or_classinfo_eager.
-
-2007-03-05 17:34  edwin
-
-       * src/vm/builtin.h (builtintable_replace_function): Don't use
-       instruction * to avoid bootstrapping problems.
-       * src/vm/builtin.c (builtintable_replace_function): Likewise.
-
-2007-03-05 17:32  edwin
-
-       * src/vm/jit/code.c (code_get_methodinfo_from_pv): New function.
-
-2007-03-05 16:53  edwin
-
-       * src/vmcore/resolve.h, src/vmcore/resolve.c
-       (resolve_classref_or_classinfo_eager): New function.
-
-2007-03-05 08:38  pm
-
-       * src/vm/jit/s390/md-abi.h,
-       src/vm/jit/s390/emit.c,
-       src/vm/jit/s390/emit.h,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/codegen.h,
-       src/vm/jit/s390/patcher.c: Changed a lot.
-
-2007-03-04 20:10  edwin
-
-       * src/vm/jit/replace.c: Handle countdown traps. Request optimization
-       of hot methods and their callers.
-       
-       * src/vm/jit/jit.c (jit_compile): Set JITDATA_FLAG_COUNTDOWN for
-       inlining.
-       (jit_recompile): Set JITDATA_FLAG_INLINE for inlining.
-
-2007-03-04 19:13  edwin
-
-       * src/vmcore/options.h, src/vmcore/options.c, src/vmcore/method.c,
-       src/vmcore/linker.c: Replayed lost parts of commit 7228.
-       
-       * src/vm/jit/intrp/intrp.h: Added missing #include to make it compile.
-       
-       * src/vm/jit/inline/inline.c: Fixed names of vmcore/ #include files.
-
-2007-03-04 18:07  twisti
-
-       * src/vm/jit/x86_64/emit.c (emit_load): Use switch-case instead of
-       if-else contruct.
-       (emit_store): Likewise.
-       (emit_copy): Likewise.
-
-2007-03-04 14:46  edwin
-
-       * src/vm/jit/i386/codegen.c (codegen): Emit code for countdown traps.
-       
-       * src/vm/jit/i386/emit.c (emit_replacement_stubs): Add jump reference
-       for countdown traps.
-
-2007-03-04 14:22  edwin
-
-       * src/vmcore/method.h (methodinfo): Added hitcountdown field. (Only
-       if ENABLE_REPLACEMENT).
-       
-       * src/vmcore/loader.c (loader_load_method): Initialize hitcountdown
-       field.
-
-2007-03-04 14:02  edwin
-
-       * src/vm/jit/inline/inline.c: Committed breadth-first inlining code.
-
-2007-03-04 12:32  edwin
-
-       * tests/regression/resolving/test_return_subtype_ok.java: New test.
-       
-       * tests/regression/resolving/Makefile.am: Added new test.
-
-2007-03-04 12:28  edwin
-
-       * tests/regression/resolving/test_return_subtype_violated.java:
-       New test.
-       
-       * tests/regression/resolving/Makefile.am: Added new test.
-
-2007-03-02 23:28  pm
-
-       * src/vm/jit/s390/emit.c,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/codegen.h,
-       src/vm/jit/s390/md-asm.h,
-       src/vm/jit/s390/patcher.c,
-       src/vm/jit/s390/asmpart.S: Changed a lot in S390 codegen.
-
-2007-03-02 19:45  edwin
-
-       * src/vmcore/classcache.c: Print debug messages to stdout.
-
-2007-03-02 19:44  edwin
-
-       * configure.ac: Added Makefiles of resolving test suite.
-
-2007-03-02 19:42  edwin
-
-       * tests/regression/resolving: Added resolving test suite. These tests
-       check lazy loading, classloader handling, loading & subtype
-       constraints.
-
-2007-03-01 13:49  edwin
-
-       * src/vmcore/resolve.h, src/vmcore/resolve.c
-       (resolve_class_eager_no_access_check): New function.
-       
-       * src/vm/jit/powerpc/patcher.c: Use
-       resolve_class_eager_no_access_check.
-       * src/vm/jit/arm/patcher.c: Likewise.
-       * src/vm/jit/sparc64/patcher.c: Likewise.
-       * src/vm/jit/alpha/patcher.c: Likewise.
-       * src/vm/jit/s390/patcher.c: Likewise.
-       * src/vm/jit/mips/patcher.c: Likewise.
-       * src/vm/jit/powerpc64/patcher.c: Likewise.
-       * src/vm/jit/i386/patcher.c: Likewise.
-       * src/vm/jit/x86_64/patcher.c: Likewise.
-
-2007-03-01 12:39  twisti
-
-       * src/native/vm/Makefile.am [ENABLE_JAVASE] (CLASSLOADER_SOURCES):
-       Added.
-       (libnativevm_la_SOURCES): Use CLASSLOADER_SOURCES.
-       
-       * src/native/vm/java_lang_ClassLoader.c (native/jni.h): Added.
-
-2007-03-01 12:32  edwin
-
-       * src/vmcore/resolve.c (resolve_classref_or_classinfo): Always use
-       refmethod->class as the referring class, if it is available.
-
-2007-02-28 23:57  twisti
-
-       * src/vmcore/classcache.c (toolbox/logging.h): Added.
-       (classcache_merge_class_entries): Replace log_text with log_println.
-       (classcache_store): Likewise.
-       (classcache_store_defined): Likewise.
+       * src/vm/vm.h (mainstring): Removed. (mainclass): Likewise.
+       [0dc5ef768134]
+
+       * src/threads/none/thread-none.h:
+       * src/threads/none/thread-none.h (THREADINFO): Removed.
+       [a68de3a1d5c6]
+
+       * src/threads/none/thread-none.h, src/threads/posix/thread-posix.h:
+       * src/threads/none/thread-none.h (THREADSPECIFIC): Removed because
+       it's not used anymore.
+       * src/threads/posix/thread-posix.h: Likewise.
+       [5925f8258a23]
+
+2008-05-11  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/vm/jit/x86_64/asmpart.S:
+       * src/vm/jit/x86_64/asmpart.S (asm_get_cycle_count): Repaired
+       --enable-cycles-stats.
+       [a63c117e1ebd]
+
+       * src/mm/boehm-gc/pthread_stop_world.c, src/threads/posix/thread-
+       posix.c:
+       Merged cleanup -> gc7-branch
+       [d12524409a9c]
+
+       * configure.ac, src/lib/Makefile.am,
+       src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java,
+       src/lib/gnu/gnu/classpath/VMStackWalker.java,
+       src/lib/gnu/gnu/classpath/VMSystemProperties.java,
+       src/lib/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java,
+       src/lib/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/lib/gnu/java/lang/VMClassLoader.java,
+       src/lib/gnu/java/lang/VMString.java,
+       src/lib/gnu/java/lang/VMThread.java,
+       src/lib/gnu/java/lang/VMThrowable.java,
+       src/lib/gnu/java/lang/reflect/Constructor.java,
+       src/lib/gnu/java/lang/reflect/Field.java,
+       src/lib/gnu/java/lang/reflect/Method.java,
+       src/lib/gnu/java/security/VMAccessController.java,
+       src/lib/gnu/sun/misc/Unsafe.java,
+       src/lib/gnu/sun/reflect/ConstantPool.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationType.java, src/lib/gnu/
+       sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, sr
+       c/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProx
+       y.java, src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java, src/
+       lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.h,
+       src/native/vm/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_reflect_Method.h,
+       src/threads/native/Makefile.am, src/threads/native/generic-
+       primitives.h, src/threads/native/lock.c, src/threads/native/lock.h,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/none/threads.h, src/threads/posix/thread-posix.c,
+       src/threads/threads-common.c, src/threads/threads-common.h,
+       src/vm/jit/m68k/linux/md-os.h, tests/A2.java, tests/AA.java,
+       tests/AA1.java, tests/AA2.java, tests/BB.java, tests/C.java,
+       tests/C2.java, tests/C3.java, tests/CC.java, tests/D.java,
+       tests/DD.java, tests/EE.java, tests/GG.java, tests/HI2.java,
+       tests/II.java, tests/IIAA.java, tests/IIBB.java, tests/IICC.java,
+       tests/IIexample.java, tests/n.java,
+       tests/regression/HelloWorld.java,
+       tests/regression/clinitexception.2output,
+       tests/regression/clinitexception.java,
+       tests/regression/codepatching/Makefile.am,
+       tests/regression/codepatching/aastoreconstClass.java,
+       tests/regression/codepatching/checkcastC.java,
+       tests/regression/codepatching/checkcastI.java,
+       tests/regression/codepatching/getfieldD.java,
+       tests/regression/codepatching/getfieldF.java,
+       tests/regression/codepatching/getfieldI.java,
+       tests/regression/codepatching/getfieldJ.java,
+       tests/regression/codepatching/getfieldL.java,
+       tests/regression/codepatching/getstaticD.java,
+       tests/regression/codepatching/getstaticF.java,
+       tests/regression/codepatching/getstaticI.java,
+       tests/regression/codepatching/getstaticJ.java,
+       tests/regression/codepatching/getstaticL.java,
+       tests/regression/codepatching/instanceofC.java,
+       tests/regression/codepatching/instanceofI.java,
+       tests/regression/codepatching/invokespecial.java,
+       tests/regression/codepatching/invokestatic.java,
+       tests/regression/codepatching/multianewarray.java,
+       tests/regression/codepatching/newarray.java,
+       tests/regression/codepatching/putfieldD.java,
+       tests/regression/codepatching/putfieldF.java,
+       tests/regression/codepatching/putfieldI.java,
+       tests/regression/codepatching/putfieldJ.java,
+       tests/regression/codepatching/putfieldL.java,
+       tests/regression/codepatching/putfieldconstC.java,
+       tests/regression/codepatching/putfieldconstD.java,
+       tests/regression/codepatching/putfieldconstF.java,
+       tests/regression/codepatching/putfieldconstI.java,
+       tests/regression/codepatching/putfieldconstJ.java,
+       tests/regression/codepatching/putfieldconstL.java,
+       tests/regression/codepatching/putstaticD.java,
+       tests/regression/codepatching/putstaticF.java,
+       tests/regression/codepatching/putstaticI.java,
+       tests/regression/codepatching/putstaticJ.java,
+       tests/regression/codepatching/putstaticL.java,
+       tests/regression/codepatching/putstaticconstC.java,
+       tests/regression/codepatching/putstaticconstD.java,
+       tests/regression/codepatching/putstaticconstF.java,
+       tests/regression/codepatching/putstaticconstI.java,
+       tests/regression/codepatching/putstaticconstJ.java,
+       tests/regression/codepatching/putstaticconstL.java,
+       tests/regression/codepatching/test.java,
+       tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j,
+       tests/regression/jasmin/test_verify_fail_jsr_recursion.j,
+       tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j,
+       tests/scribble.java:
+       Clean merge -> gc7-branch
+       [98fcc574613e]
+
+       * src/mm/boehm-gc/pthread_stop_world.c, src/threads/posix/thread-
+       posix.c, src/threads/posix/thread-posix.h:
+       * src/mm/boehm-gc/pthread_stop_world.c: Cleaned up some old Boehm-
+       based stop-the-world code.
+       * src/threads/posix/thread-posix.c: Likewise.
+       * src/threads/posix/thread-posix.h: Likewise.
+       [f1539535de4a]
+
+2008-05-10  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/s390/codegen.c:
+       * src/vm/jit/s390/codegen.c (codegen_emit): For ICMD_LALOAD,
+       ICMD_LASTORE, ICMD_DALOAD, fixed offset of first array element. This
+       fixes the failing dacapo antlr benchmark.
+       [6d6dc5996014]
+
+2008-05-09  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/threads/posix/lock.c:
+       * src/threads/posix/lock.c: Replaced UTF-8 characters with ASCII.
+       [d3272044b8ba]
+
+2008-05-08  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac:
+       * configure.ac (AC_INIT): Bumped version to 0.99rc5.
+       [487fdcb54770]
+
+       * src/vm/jit/s390/md.c:
+       * src/vm/jit/s390/md.c (md_executionstate_read): New function (stub
+       only). (md_executionstate_write): Likewise.
+       [1f78ff4da6c6]
+
+2008-05-07  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * m4/cacaoh.m4, src/Makefile.am:
+       * m4/cacaoh.m4 (AC_CHECK_WITH_CACAOH): Don't set ENABLE_CACAOH.
+       * src/Makefile.am [ENABLE_CACAOH] (CACAOH_DIR): Removed. (SUBDIRS):
+       Always build cacaoh because it's required e.g. when running make
+       check on the target.
+       [94ddb4bbdab5]
+
+2008-05-06  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac:
+       * configure.ac (AC_INIT): Bumped version to 0.99rc4.
+       [7eb41343fb41]
+
+       * src/vmcore/system.h:
+       * src/vmcore/system.h (system_scandir) [__IRIX__]: On IRIX the
+       signature is a bit different. This prevents a lot of compiler
+       warnings.
+       [07aeecc03c14]
+
+       * src/vm/jit/mips/linux/md-os.c:
+       * src/vm/jit/mips/linux/md-os.c (md_executionstate_read): New
+       function. (md_executionstate_write): Likewise.
+       [a0a153d01b3b]
+
+       * src/vm/jit/mips/asmpart.S, src/vm/jit/mips/md-asm.h:
+       * src/vm/jit/mips/asmpart.S: Replaced ldc1/sdc1 with l.d/s.d macros.
+       * src/vm/jit/mips/md-asm.h: Likewise.
+       [683df1b2eac0]
+
+       * src/vm/jit/alpha/md-asm.h:
+       * src/vm/jit/alpha/md-asm.h (SAVE_RETURN_REGISTERS): Removed, it's
+       not used anymore. (RESTORE_RETURN_REGISTERS): Likewise.
+       [e4ed14b8cf28]
+
+       * src/mm/boehm.c, src/mm/gc-common.h:
+       * src/mm/boehm.c: Use stdint-types.
+       * src/mm/gc-common.h: Likewise.
+       [ddc2fa158b02]
+
+       * tests/regression/jasmin/Makefile.am:
+       * tests/regression/jasmin/Makefile.am (build): Added cup.jar to
+       classpath.
+       [da35822eaaf4]
+
+       * tests/regression/bugzilla/PR65.java:
+       * tests/regression/bugzilla/PR65.java (test): Fixed compiler
+       warning.
+       [7f91d6142bfa]
 
-2007-02-28 23:39  twisti
+2008-05-05  Stefan Ring  <stefan@complang.tuwien.ac.at>
 
-       * src/cacaoh/dummy.c (typeinfo_print): Added.
+       * src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/stacktrace.c:
+       Merged with tip.
+       [630215c2fbf8]
 
-2007-02-28 23:27  edwin
+       * src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/stacktrace.c:
+       * src/vm/jit/i386/darwin/md-asm.h: Repaired --enable-cycles-stats.
+       * src/vm/jit/stacktrace.c: Likewise.
+       [36b6519d4b72]
 
-       * src/vm/jit/verify/typecheck.c (handle_basic_block): Move the
-       printing
-       of the block to a point where jd->var is already valid.
+2008-05-03  Stefan Ring  <stefan@complang.tuwien.ac.at>
 
-2007-02-28 23:20  edwin
+       * src/cacaoh/dummy.c, src/threads/critical.h, src/vm/jit/i386/cygwin
+       /md-asm.h, src/vm/jit/i386/darwin/md-asm.h,
+       src/vm/jit/intrp/asmpart.c:
+       * src/cacaoh/dummy.c: Removed asm_criticalsections and
+       asm_getclassvalues_atomic. They have not been used anywhere in a
+       long time.
+       * src/threads/critical.h: Likewise.
+       * src/vm/jit/i386/cygwin/md-asm.h: Likewise.
+       * src/vm/jit/i386/darwin/md-asm.h: Likewise.
+       * src/vm/jit/intrp/asmpart.c: Likewise.
+       [dc465902bf87]
+
+       * tests/regression/bugzilla/All.java,
+       tests/regression/bugzilla/PR65.java:
+       * tests/regression/bugzilla/All.java: Added test case for PR65.
+       [c1ec27d0f8f0]
+
+2008-05-02  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/vm/builtin.c:
+       * src/vm/builtin.c (builtin_descriptorscompatible): Experimental fix
+       for bugzilla bug #65.
+       [4436cc114a77]
+
+2008-04-30  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * tests/threads/threadInterrupt.java,
+       tests/threads/waitAndInterrupt.java:
+       * tests/threads/threadInterrupt.java: Added brief comment explaining
+       the purpose of this test.
+       * tests/threads/waitAndInterrupt.java: Likewise.
+       [9ca0035d4d04]
+
+       * tests/weakref.java:
+       * tests/weakref.java: New test for weak references.
+       [6647d194cff1]
+
+       * src/vm/jit/i386/machine-instr.h, src/vmcore/linker.c,
+       tests/threads/threadInterrupt.java,
+       tests/threads/waitAndInterrupt.java:
+       Backed out changeset ecf451e74e7e
+       [d0882f1633d5]
+
+       * src/vm/jit/i386/machine-instr.h, src/vmcore/linker.c,
+       tests/threads/threadInterrupt.java,
+       tests/threads/waitAndInterrupt.java:
+       * tests/threads/threadInterrupt.java: Added brief comment explaining
+       the purpose of this test.
+       * tests/threads/waitAndInterrupt.java: Likewise.
+       [ecf451e74e7e]
+
+2008-04-29  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * tests/regression/jasmin/Makefile.am,
+       tests/regression/jasmin/runtest,
+       tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j,
+       tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j-no,
+       tests/regression/jasmin/test_verify_fail_jsr_recursion.j,
+       tests/regression/jasmin/test_verify_fail_jsr_recursion.j-no,
+       tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j,
+       tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j-
+       no:
+       * tests/regression/jasmin/Makefile.am (JAVA): Prefix
+       LD_LIBRARY_PATH. (JASMIN_TESTS): Removed. (EXTRA_DIST): Removed
+       JASMIN_TESTS, added $(srcdir)/*.j. (build): Target added. (run):
+       Likewise.
+       * tests/regression/jasmin/runtest: Removed compilation of the tests.
 
-       * src/vm/jit/stack.c (stack_analyse): Minor STACK_VERBOSE
-       improvements.
+       * tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j:
+       Moved from here...
+       * tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j-no:
+       ... to here.
 
-2007-02-28 22:50  edwin
+       * tests/regression/jasmin/test_verify_fail_jsr_recursion.j:
+       Likewise.
+       * tests/regression/jasmin/test_verify_fail_jsr_recursion.j-no:
+       Likewise.
 
        *
-       tests/regression/jasmin/test_verify_ok_local_as_retaddr_and_reference.j:
-       New test.
-       * tests/regression/jasmin/Makefile.am: Added new test.
-
-2007-02-28 22:31  twisti
-
-       * src/vm/vm.c (vm_create): Changed initialization order. Call
-       properties_postinit later, since it puts a pointer to
-       _Jv_bootclasspath into the properties list.
-
-2007-02-28 22:30  edwin
-
-       * src/vm/jit/stack.c (stack_analyse): Fix: reset TYPE_VOID to
-       TYPE_ADR at the end of stack_analyse.
+       tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j:
+       Likewise.
+       * tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j-
+       no: Likewise.
+       [845282affca0]
+
+       * tests/regression/HelloWorld.java, tests/regression/Makefile.am:
+       * tests/regression/Makefile.am (JAVACCMD): Added -source 1.5 -target
+       1.5 -nowarn. (SOURCE_FILES): Removed HelloWorld.java.
+       (SIMPLE_JAVA_TESTS): Removed. (run): Target added.
+       * tests/regression/HelloWorld.java: Removed.
+       [e91af259734b]
+
+       * tests/regression/assertion/Makefile.am:
+       * tests/regression/assertion/Makefile.am (JAVACCMD): Added -source
+       1.5
+       -target 1.5. (run): Target added.
+       [4c49e26a4bd4]
+
+       * tests/regression/bugzilla/Makefile.am:
+       * tests/regression/bugzilla/Makefile.am (run): Target added.
+       [d4377a3eef9c]
+
+       * tests/regression/junit/Makefile.am:
+       * tests/regression/junit/Makefile.am (JAVACCMD): Added -source 1.5
+       -target 1.5 -nowarn (TODO: move this into a variable). (run): Target
+       added.
+       [46571e5bbf57]
 
-2007-02-28 22:00  twisti
+2008-04-28  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-       * src/vm/access.h (access_check_caller): Renamed to
-       access_check_member.
+       * configure.ac:
+       * configure.ac (AC_INIT): Bumped version to 0.99rc3.
+       [c197b02ff123]
 
-2007-02-28 20:07  twisti
+       * .hgignore:
+       * .hgignore: Added m4/libtool.m4, m4/ltoptions.m4, m4/ltsugar.m4,
+       m4/ltversion.m4, m4/lt~obsolete.m4.
+       [ebbb6e7a1914]
 
-       * src/vm/access.c (access_check_caller): Renamed to
-       access_check_member. Don't call access_is_accessible_class, this is
-       wrong.
-       
-       * src/native/vm/gnu/java_lang_reflect_Constructor.c (constructNative):
-       Use access_check_member.
-       
-       * src/native/vm/gnu/java_lang_reflect_Field.c (CHECKFIELDACCESS):
-       Removed.
-       (cacao_get_field_address): Use access_check_member.
-       
-       * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative):
+       * configure.ac, m4/jre-layout.m4, src/cacao/cacao.c,
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c,
+       src/vm/properties.c, src/vm/vm.c, src/vmcore/system.h:
+       * m4/jre-layout.m4 (AC_CHECK_WITH_JRE_LAYOUT): Renamed to
+       AC_CHECK_ENABLE_JRE_LAYOUT.
+       * configure.ac: Likewise.
+
+       * src/cacao/cacao.c: Renamed WITH_JRE_LAYOUT to ENABLE_JRE_LAYOUT.
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c: Likewise.
+       * src/vm/properties.c: Likewise.
+       * src/vm/vm.c: Likewise.
+       * src/vmcore/system.h: Likewise.
+       [59ee69e0f277]
+
+       * .hgignore, configure.ac, doc/Makefile.am, doc/doxygen/Doxyfile,
+       doc/doxygen/Makefile.am:
+       * .hgignore: Added doc/doxygen/html, doc/doxygen/latex.
+       * configure.ac (AC_CONFIG_FILES): Added doc/doxygen/Makefile.
+       * doc/Makefile.am (SUBDIRS): Added doxygen.
+       * doc/doxygen/Doxyfile: New file.
+       * doc/doxygen/Makefile.am: Likewise.
+       [809dfcaf02f9]
+
+       * src/vm/jit/arm/linux/md-os.c:
+       * src/vm/jit/arm/linux/md-os.c (md_executionstate_read): New
+       function (but not implemted yet). (md_executionstate_write):
        Likewise.
+       [0ad564b6fc63]
+
+       * src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/linux/md-os.h,
+       src/vm/jit/mips/linux/md-os.c, src/vm/vm.c:
+       * Merged in new trap code (twisti-branch).
+       [8a2df154e6e2]
+
+       * src/vm/jit/sparc64/Makefile.am, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c,
+       src/vm/jit/sparc64/md-trap.h, src/vm/jit/sparc64/solaris/md-os.c:
+       * src/vm/jit/sparc64/Makefile.am (libarch_la_SOURCES): Added md-
+       trap.h.
+       * src/vm/jit/sparc64/codegen.c: Use new trap stuff.
+       * src/vm/jit/sparc64/emit.c: Likewise.
+       * src/vm/jit/sparc64/linux/md-os.c: Likewise.
+       * src/vm/jit/sparc64/md-trap.h: New file.
+       * src/vm/jit/sparc64/solaris/md-os.c: Use new trap stuff.
+       [55d40b03e4f4]
+
+       * src/vm/jit/powerpc64/md.c:
+       * src/vm/jit/powerpc64/md.c (md_patch_replacement_point): Use new
+       trap stuff.
+       [6b82b87fc058]
+
+       * src/vm/jit/m68k/linux/Makefile.am, src/vm/jit/m68k/linux/md-os.h:
+       * src/vm/jit/m68k/linux/md-os.h: Removed.
+       * src/vm/jit/m68k/linux/Makefile.am (libmd_la_SOURCES): Removed md-
+       os.h.
+       [64717fad182b]
+
+       * src/vm/jit/patcher-common.c:
+       * src/vm/jit/patcher-common.c (patcher_handler): Fixed compiler
+       warnings.
+       [6e1285e13d18]
+
+       * src/vm/jit/patcher-common.c:
+       * src/vm/jit/patcher-common.c (patcher_handler)
+       [ENABLE_DISASSEMBLER]: Use disassembler to print machine code.
+       [f7850a0245ba]
+
+       * src/vm/jit/m68k/Makefile.am, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/md-trap.h:
+       * src/vm/jit/m68k/Makefile.am (libarch_la_SOURCES): Added md-trap.h.
+       * src/vm/jit/m68k/codegen.c: Use new trap stuff.
+       * src/vm/jit/m68k/emit.c: Likewise.
+       * src/vm/jit/m68k/linux/md-os.c: Likewise.
+       * src/vm/jit/m68k/md-trap.h: New file.
+       [de0973a17a25]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_start_native_call)
+       [__I386__]: Enable tracing native methods.
+       (codegen_finish_native_call): Likewise.
+       [784b956d8ecd]
 
-2007-02-28 13:25  twisti
-
-       * src/native/vm/java_lang_ClassLoader.c (vm/stringlocal.h): Added.
-
-2007-02-28 13:23  twisti
-
-       * src/native/vm/java_lang_ClassLoader.c (defineClass): Added
-       loader-variable for convenience.
+       * * Merged with tip.
+       [22e6633864b8]
 
-2007-02-28 07:22  pm
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_start_native_call): Added
+       __M68K__ to trace native methods. (codegen_finish_native_call):
+       Likewise.
+       [ee12606c51c1]
 
-       * src/vm/jit/s390/codegen.c (codegen): Added ICMD_AASTORE.
-       * src/vm/jit/s390/asmpart.S (asm_patcher_wrapper): Added exception
-       handler.
-       * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Likewise.
+       * src/vm/jit/m68k/codegen.c:
+       * src/vm/jit/m68k/codegen.c (codegen_emit_stub_native): Removed old,
+       deprecated stuff (patcher and call trace).
+       [17c9c2559e52]
 
-2007-02-27 21:13  twisti
+       * src/vm/jit/trace.c:
+       * src/vm/jit/trace.c (trace_java_call_enter): Don't trace builtins,
+       it does not work (because of the ABI). (trace_java_call_exit):
+       Likewise.
+       [928814cce084]
+
+       * src/vmcore/method.h:
+       * src/vmcore/method.h (method_is_builtin): New function.
+       [137038362c4b]
+
+       * src/vm/jit/mips/linux/md-os.c:
+       * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Added
+       patch from http://bugs.debian.org/cgi-
+       bin/bugreport.cgi?bug=441122#35.
+       [4b1912970eac]
+
+       * src/vm/jit/powerpc/Makefile.am, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc/md-trap.h:
+       * src/vm/jit/powerpc/Makefile.am (libarch_la_SOURCES): Added md-
+       trap.h.
+       * src/vm/jit/powerpc/codegen.c: Use new trap stuff.
+       * src/vm/jit/powerpc/emit.c: Likewise.
+       * src/vm/jit/powerpc/linux/md-os.c: Likewise.
+       * src/vm/jit/powerpc/md-trap.h: New file.
+       [f2da4ab3dcba]
+
+       * src/vm/jit/s390/Makefile.am, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md-trap.h,
+       src/vm/jit/s390/md.c:
+       * src/vm/jit/s390/Makefile.am (libarch_la_SOURCES): Added md-trap.h.
+       * src/vm/jit/s390/codegen.c: Use new trap stuff.
+       * src/vm/jit/s390/emit.c: Likewise.
+       * src/vm/jit/s390/md-trap.h: New file.
+       * src/vm/jit/s390/md.c: Use new trap stuff.
+       [e7b71db899d5]
+
+       * src/vm/jit/mips/Makefile.am, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/mips/md-trap.h:
+       * src/vm/jit/mips/Makefile.am (libarch_la_SOURCES): Added md-trap.h.
+       * src/vm/jit/mips/codegen.c: Use new trap stuff.
+       * src/vm/jit/mips/emit.c: Likewise.
+       * src/vm/jit/mips/linux/md-os.c: Likewise.
+       * src/vm/jit/mips/md-trap.h: New file.
+       [64f0215ce5fe]
+
+       * src/vm/jit/arm/Makefile.am, src/vm/jit/arm/emit.c,
+       src/vm/jit/arm/linux/md-os.c, src/vm/jit/arm/md-trap.h:
+       * src/vm/jit/arm/Makefile.am (libarch_la_SOURCES): Added md-trap.h.
+       * src/vm/jit/arm/emit.c: Use new trap stuff.
+       * src/vm/jit/arm/linux/md-os.c: Likewise.
+       * src/vm/jit/arm/md-trap.h: New file.
+       [f7e39c89f923]
+
+       * src/vm/jit/powerpc64/Makefile.am, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c,
+       src/vm/jit/powerpc64/md-trap.h:
+       * src/vm/jit/powerpc64/Makefile.am (libarch_la_SOURCES): Added md-
+       trap.h.
+       * src/vm/jit/powerpc64/codegen.c: Use new trap stuff.
+       * src/vm/jit/powerpc64/emit.c: Likewise.
+       * src/vm/jit/powerpc64/linux/md-os.c: Likewise.
+       * src/vm/jit/powerpc64/md-trap.h: New file.
+       [a9eafa03d678]
+
+       * src/vm/jit/alpha/Makefile.am, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/alpha/md-trap.h, src/vm/jit/alpha/md.c:
+       * src/vm/jit/alpha/Makefile.am (libarch_la_SOURCES): Added md-
+       trap.h.
+       * src/vm/jit/alpha/codegen.c: Use new trap stuff.
+       * src/vm/jit/alpha/emit.c: Likewise.
+       * src/vm/jit/alpha/linux/md-os.c: Likewise.
+       * src/vm/jit/alpha/md-trap.h: New file.
+       * src/vm/jit/alpha/md.c: Use new trap stuff.
+       [f97606f11648]
+
+2008-04-27  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac:
+       * configure.ac (AC_INIT): Bumped version to 0.99rc2.
+       [e0c01948bb61]
+
+       * * Merged with ea434f5851f4.
+       [72249b4c9b1d]
+
+       * .hgignore, configure.ac, tests/regression/Makefile.am,
+       tests/regression/codepatching/Makefile.am,
+       tests/regression/codepatching/aastoreconstClass.java,
+       tests/regression/codepatching/checkcastC.java,
+       tests/regression/codepatching/checkcastI.java,
+       tests/regression/codepatching/getfieldD.java,
+       tests/regression/codepatching/getfieldF.java,
+       tests/regression/codepatching/getfieldI.java,
+       tests/regression/codepatching/getfieldJ.java,
+       tests/regression/codepatching/getfieldL.java,
+       tests/regression/codepatching/getstaticD.java,
+       tests/regression/codepatching/getstaticF.java,
+       tests/regression/codepatching/getstaticI.java,
+       tests/regression/codepatching/getstaticJ.java,
+       tests/regression/codepatching/getstaticL.java,
+       tests/regression/codepatching/instanceofC.java,
+       tests/regression/codepatching/instanceofI.java,
+       tests/regression/codepatching/invokespecial.java,
+       tests/regression/codepatching/invokestatic.java,
+       tests/regression/codepatching/multianewarray.java,
+       tests/regression/codepatching/newarray.java,
+       tests/regression/codepatching/putfieldD.java,
+       tests/regression/codepatching/putfieldF.java,
+       tests/regression/codepatching/putfieldI.java,
+       tests/regression/codepatching/putfieldJ.java,
+       tests/regression/codepatching/putfieldL.java,
+       tests/regression/codepatching/putfieldconstC.java,
+       tests/regression/codepatching/putfieldconstD.java,
+       tests/regression/codepatching/putfieldconstF.java,
+       tests/regression/codepatching/putfieldconstI.java,
+       tests/regression/codepatching/putfieldconstJ.java,
+       tests/regression/codepatching/putfieldconstL.java,
+       tests/regression/codepatching/putstaticD.java,
+       tests/regression/codepatching/putstaticF.java,
+       tests/regression/codepatching/putstaticI.java,
+       tests/regression/codepatching/putstaticJ.java,
+       tests/regression/codepatching/putstaticL.java,
+       tests/regression/codepatching/putstaticconstC.java,
+       tests/regression/codepatching/putstaticconstD.java,
+       tests/regression/codepatching/putstaticconstF.java,
+       tests/regression/codepatching/putstaticconstI.java,
+       tests/regression/codepatching/putstaticconstJ.java,
+       tests/regression/codepatching/putstaticconstL.java,
+       tests/regression/codepatching/test.java,
+       tests/regression/junit/All.java, tests/regression/junit/Makefile.am,
+       tests/regression/junit/TestPatcher.java:
+       * .hgignore: Removed tests/regression/codepatching/*.class.
+       * configure.ac (AC_CONFIG_FILES): Removed
+       tests/regression/codepatching/Makefile.
+       * tests/regression/Makefile.am (SUBDIRS): Removed codepatching.
+       * tests/regression/junit/All.java (suite): Added TestPatcher.
+       * tests/regression/junit/Makefile.am (EXTRA_DIST): Added $(srcdir) to
+       actually find the files.
+       * tests/regression/junit/TestPatcher.java: New file.
+
+       * tests/regression/codepatching/Makefile.am,
+       tests/regression/codepatching/aastoreconstClass.java,
+       tests/regression/codepatching/checkcastC.java,
+       tests/regression/codepatching/checkcastI.java,
+       tests/regression/codepatching/getfieldD.java,
+       tests/regression/codepatching/getfieldF.java,
+       tests/regression/codepatching/getfieldI.java,
+       tests/regression/codepatching/getfieldJ.java,
+       tests/regression/codepatching/getfieldL.java,
+       tests/regression/codepatching/getstaticD.java,
+       tests/regression/codepatching/getstaticF.java,
+       tests/regression/codepatching/getstaticI.java,
+       tests/regression/codepatching/getstaticJ.java,
+       tests/regression/codepatching/getstaticL.java,
+       tests/regression/codepatching/instanceofC.java,
+       tests/regression/codepatching/instanceofI.java,
+       tests/regression/codepatching/invokespecial.java,
+       tests/regression/codepatching/invokestatic.java,
+       tests/regression/codepatching/multianewarray.java,
+       tests/regression/codepatching/newarray.java,
+       tests/regression/codepatching/putfieldD.java,
+       tests/regression/codepatching/putfieldF.java,
+       tests/regression/codepatching/putfieldI.java,
+       tests/regression/codepatching/putfieldJ.java,
+       tests/regression/codepatching/putfieldL.java,
+       tests/regression/codepatching/putfieldconstC.java,
+       tests/regression/codepatching/putfieldconstD.java,
+       tests/regression/codepatching/putfieldconstF.java,
+       tests/regression/codepatching/putfieldconstI.java,
+       tests/regression/codepatching/putfieldconstJ.java,
+       tests/regression/codepatching/putfieldconstL.java,
+       tests/regression/codepatching/putstaticD.java,
+       tests/regression/codepatching/putstaticF.java,
+       tests/regression/codepatching/putstaticI.java,
+       tests/regression/codepatching/putstaticJ.java,
+       tests/regression/codepatching/putstaticL.java,
+       tests/regression/codepatching/putstaticconstC.java,
+       tests/regression/codepatching/putstaticconstD.java,
+       tests/regression/codepatching/putstaticconstF.java,
+       tests/regression/codepatching/putstaticconstI.java,
+       tests/regression/codepatching/putstaticconstJ.java,
+       tests/regression/codepatching/putstaticconstL.java,
+       tests/regression/codepatching/test.java: Removed.
+       [c7fbe6cfa0d0]
+
+       * tests/Makefile.am, tests/regression/bugzilla/Makefile.am:
+       * tests/Makefile.am (EXTRA_DIST): Added $(srcdir) to actually find
+       the files.
+       * tests/regression/bugzilla/Makefile.am: Likewise.
+       [574e4f244959]
+
+2008-04-27  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/threads/posix/lock.c:
+       * src/threads/posix/lock.c (lock_record_notify): Skip the check for
+       interrupted. It was data-race ridden anyway.
+       [ea434f5851f4]
+
+2008-04-26  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * * Merged with f9adc5b4d7f0.
+       [9e1c37400fc1]
+
+       * .hgignore, configure.ac, tests/regression/Makefile.am,
+       tests/regression/clinitexception.2output,
+       tests/regression/clinitexception.java,
+       tests/regression/junit/All.java, tests/regression/junit/Makefile.am,
+       tests/regression/junit/TestExceptionInStaticClassInitializer.java:
+       * .hgignore: Added tests/regression/junit/*.class.
 
-       * src/vm/jit/sparc64/solaris: Set ignore-properties.
+       * configure.ac (AC_CONFIG_FILES): Added
+       tests/regression/junit/Makefile.
 
-2007-02-27 02:07  ajordan
+       * tests/regression/Makefile.am (SUBDIRS): Added junit.
+       (SOURCE_FILES): Removed clinitexceptions.java. (EXTRA_DIST): Removed
+       clinitexceptions.2output. (OUTPUT_JAVA_TESTS): Removed
+       clinitexception.
 
-       * configure.ac: added solaris specific stuff: arch defines, libintl
-       dependency and solaris subdir makefile.
-       
-       * src/vm/jit/stacktrace.h: declared SPARC specific functions.
-       
-       * src/vm/jit/sparc64/emit.c: fixed call to builtin_verbosecall_exit.
-       
-       * src/vm/jit/sparc64/solaris/md-os.c: signal handling disabled, can't
-       test right now.
+       * tests/regression/junit/All.java: Likewise.
+       * tests/regression/junit/Makefile.am: Likewise
+       * tests/regression/junit/TestExceptionInStaticClassInitializer.java:
+       Likewise.
 
-2007-02-26 22:11  twisti
+       * tests/regression/clinitexception.2output: Removed.
+       * tests/regression/clinitexception.java: Likewise.
+       [4201a6a37d6e]
 
-       * src/native/vm/java_lang_ClassLoader.c: New file.
-       * src/native/vm/java_lang_ClassLoader.h: Likewise.
-       
-       * src/native/vm/gnu/java_lang_VMClassLoader.c
-       (native/vm/java_lang_ClassLoader.h): Added.
-       (defineClass): Removed code and call
-       _Jv_java_lang_ClassLoader_defineClass.
-       
-       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
-       java_lang_ClassLoader.[ch].
-       
-       * src/native/jni.c [ENABLE_JAVASE]
-       (native/vm/java_lang_ClassLoader.h): Added.
-       (_Jv_JNI_DefineClass): Removed env and NULL arguments.
+       * tests/regression/bugzilla/Makefile.am:
+       * tests/regression/bugzilla/Makefile.am (build): Changed -cp to
+       -classpath so GCJ works too. (check): Likewise.
+       [5a22603f6b24]
 
-2007-02-25 22:34  pm
+       * src/native/vm/gnu/java_lang_reflect_VMMethod.c:
+       * src/native/vm/gnu/java_lang_reflect_VMMethod.c (getDefaultValue):
+       Pass the correct method object to the Java method.
+       [e2470ff85c70]
 
-       * src/vm/jit/s390/codegen.c (codegen): Fixed ICMD_IF_ACMPNE
-       * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Handling NULL
-       return value of jit_asm_compile.
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_get_mainclass_from_jar): Print error when Main-
+       Class attribute not found.
+       [d446954c2415]
 
-2007-02-25 22:02  pm
+       * m4/jre-layout.m4:
+       * m4/jre-layout.m4 (AC_CHECK_WITH_JRE_LAYOUT): Fixed typo, used
+       enableval instead of withval.
+       [f9adc5b4d7f0]
 
-       * src/vm/jit/s390/asmpart.S (asm_getclassvalues_atomic,
-       asm_criticalsections): Added.
+2008-04-24  Stefan Ring  <stefan@complang.tuwien.ac.at>
 
-2007-02-25 21:31  pm
+       * src/vm/jit/i386/darwin/md-os.c:
+       * src/vm/jit/i386/darwin/md-os.c: Added md-trap.h (same as
+       42dc5863f378).
+       [1c792ca003e4]
 
-       * src/vm/jit/codegen-common.c (methodtree_comparator): Fixed S390
-       related comment.
-       * src/vm/jit/s390/codegen.h: Fixed M_JSR macro, did not store RA.
-       * src/vm/jit/s390/md-asm.h: Added (LOAD|STORE)_TEMPORARY_REGISTERS
-       and (LOAD|STORE)_ARGUMENT_REGISTERS macros.
-       * src/vm/jit/s390/asmpart.S: Implemented asm_handle_exception and
-       asm_vm_call_method_exception_handler.
-       * src/vm/jit/s390/md-abi.c (abi_registers_integer_temporary): did not
-       contain %r0, added.
+2008-04-24  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-02-24 14:47  twisti
+       * src/vm/jit/i386/Makefile.am, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/i386/md-trap.h:
+       * src/vm/jit/i386/Makefile.am (libarch_la_SOURCES): Added md-trap.h.
+       * src/vm/jit/i386/codegen.c: Use new trap stuff.
+       * src/vm/jit/i386/emit.c: Likewise.
+       * src/vm/jit/i386/linux/md-os.c: Likewise.
+       * src/vm/jit/i386/md-trap.h: New file.
+       [42dc5863f378]
+
+       * src/vm/jit/x86_64/Makefile.am:
+       * src/vm/jit/x86_64/Makefile.am (libarch_la_SOURCES): Added md-
+       trap.h.
+       [0db016f6b071]
+
+       * src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_reflect_VMMethod.c:
+       * src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c: Use stdint-types.
+       * src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_reflect_VMMethod.c: Likewise.
+       [208f94c92da1]
 
-       * src/vmcore/zip.c (errno.h): Added.
-       (vm/vm.h): Likewise.
-       (zip_get): Replaced asserts with vm_abort.
+       * src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c:
+       * src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c:
+       Use stdint-types.
+       [555b5c4eefa9]
 
-2007-02-23 22:57  michi
+       * src/cacaoh/dummy.c, src/mm/boehm.c, src/mm/gc-common.h:
+       * src/cacaoh/dummy.c (heap_alloc_uncollectable): Use stdint-types.
+       * src/mm/boehm.c: Likewise.
+       * src/mm/gc-common.h: Likewise.
+       [33887ab24ca7]
 
-       * src/vm/jit/replace.c: Renamed regs to abi_registers_integer_name.
+       * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/Makefile.am,
+       src/vm/jit/trap.c, src/vm/jit/trap.h, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/jit/x86_64/md-trap.h, src/vm/signal.c, src/vm/signallocal.h,
+       src/vm/vm.c:
+       * src/vm/jit/trap.c: New file.
+       * src/vm/jit/trap.h: Likewise.
 
-2007-02-21 23:26  twisti
+       * src/vm/jit/Makefile.am [ENABLE_JIT] (TRAP_SOURCES): Added.
+       (libjit_la_SOURCES): Added TRAP_SOURCES.
 
-       * src/vm/global.h (ACC_CLASS_SOFT_REFERENCE, ACC_CLASS_WEAK_REFERENCE)
-       (ACC_CLASS_PHANTOM_REFERENCE): Added.
-       
-       * src/vmcore/class.c (class_create_classinfo) [ENABLE_JAVASE]: Check
-       if the class is a reference class and flag it.
-       
-       * src/vmcore/loader.c (load_class_from_classbuffer): OR the flags
-       loaded.
-       
-       * src/vmcore/utf8.c (utf_java_lang_ref_SoftReference)
-       (utf_java_lang_ref_WeakReference, utf_java_lang_ref_PhantomReference):
-       Added.
-       (utf8_init): Initialize added variables.
-       * src/vmcore/utf8.h: Likewise.
+       * src/vm/exceptions.c (exceptions_init): Removed.
+       * src/vm/exceptions.h (EXCEPTION_HARDWARE_*): Removed.
 
-2007-02-21 23:23  twisti
+       * src/vm/signal.c (signal_handle): Removed.
+       * src/vm/signallocal.h: Likewise.
 
-       * src/vm/exceptions.c (exceptions_throw_noclassdeffounderror): Abort
-       when VM is initializing.
+       * src/vm/vm.c (vm_create): Removed exceptions_init call, added
+       trap_init call.
 
-2007-02-21 23:12  pm
+       * src/vm/jit/x86_64/codegen.c: Use new trap stuff.
+       * src/vm/jit/x86_64/emit.c: Likewise.
+       * src/vm/jit/x86_64/linux/md-os.c: Likewise.
+       * src/vm/jit/x86_64/md-trap.h: New file.
+       [e1964528a1af]
+
+       * src/cacaoh/dummy.c, src/mm/memory.c, src/mm/memory.h,
+       src/vm/builtin.c, src/vm/builtin.h:
+       * src/cacaoh/dummy.c: Use stdint-types.
+       * src/mm/memory.c, src/mm/memory.h, src/vm/builtin.c,
+       src/vm/builtin.h: Likewise.
+       [3cf50ae219ef]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_GetHostName): Use TRACEJVMCALLSENTER
+       and TRACEJVMCALLSEXIT.
+       [999c2d2889c5]
+
+       * src/vm/jit/arm/codegen.h:
+       * src/vm/jit/arm/codegen.h (SPLIT_LOAD): Removed.
+       [9affd9c7a536]
+
+2008-04-23  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/abi.h, src/vm/jit/allocator/liveness.c,
+       src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/lsra.h,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/md-abi.c,
+       src/vm/jit/arm/md-abi.c, src/vm/jit/i386/asmpart.S, src/vm/jit/i386
+       /md-abi.c, src/vm/jit/jit.h, src/vm/jit/loop/analyze.c,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/mips/md-abi.c,
+       src/vm/jit/optimizing/lifetimes.h, src/vm/jit/optimizing/lsra.c,
+       src/vm/jit/parse.c, src/vm/jit/powerpc/darwin/md-abi.c,
+       src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/netbsd/md-
+       abi.c, src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/s390/md-
+       abi.c, src/vm/jit/sparc64/md-abi.c, src/vm/jit/stack.c,
+       src/vm/jit/stack.h, src/vm/jit/x86_64/md-abi.c:
+       * src/vm/jit/jit.h (stackptr): Removed. (stackelement): Moved from
+       here...
+       * src/vm/jit/stack.h (stackelement_t): ...to here.
+
+       * src/vm/jit/abi.h, src/vm/jit/allocator/liveness.c,
+       src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/lsra.h,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/md-abi.c,
+       src/vm/jit/arm/md-abi.c, src/vm/jit/i386/asmpart.S, src/vm/jit/i386
+       /md-abi.c, src/vm/jit/loop/analyze.c, src/vm/jit/m68k/linux/md-
+       abi.c, src/vm/jit/mips/md-abi.c, src/vm/jit/optimizing/lifetimes.h,
+       src/vm/jit/optimizing/lsra.c, src/vm/jit/parse.c,
+       src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/linux/md-
+       abi.c, src/vm/jit/powerpc/netbsd/md-abi.c,
+       src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/s390/md-abi.c,
+       src/vm/jit/sparc64/md-abi.c, src/vm/jit/stack.c, src/vm/jit/x86_64
+       /md-abi.c: Replaced stackptr with stackelement_t*.
+       [ab0f521edd32]
+
+2008-04-23  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/vm/jit/executionstate.c:
+       * src/native/vm/gnu/java_lang_VMRuntime.c: Compiler warning
+       squashing.
+       * src/vm/jit/executionstate.c (executionstate_println): Likewise.
+       [d26a4fc535cd]
+
+2008-04-23  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * autogen.sh:
+       * autogen.sh: Fixed error output.
+       [a00932f0646f]
+
+       * autogen.sh:
+       * autogen.sh: Support libtool-2.x.
+       [3555026385e5]
+
+       * src/vmcore/system.h:
+       * src/vmcore/system.h (system_scandir) [__LINUX__]: The signature is
+       different on various OSs.
+       [f0e9ab27db0c]
+
+2008-04-22  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/verify/typecheck.c:
+       * src/vm/jit/verify/typecheck.c (typecheck): Fixed compiler warning.
+       [f402b152d1f4]
+
+       * src/cacaoh/dummy.c, src/native/jni.c, src/native/vm/Makefile.am,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/reflect.h, src/native/vm/sun/jvm.c,
+       src/vmcore/class.c, src/vmcore/class.h:
+       * src/native/vm/java_lang_Class.c: Removed.
+       * src/native/vm/java_lang_Class.h: Likewise.
+       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Removed
+       java_lang_Class.[ch].
 
-       * src/vm/jit/s390/codegen.c (codegen): allocate register save area
-       required by C abi for builtin calls
-       * src/vm/jit/s390/codegen.c (createnativestub): fix errornous code
-       generated for return, fix datasp argument to
-       codegen_finish_native_call
+       * src/cacaoh/dummy.c (builtin_instanceof): New function.
+       (reflect_constructor_new, reflect_field_new, reflect_method_new):
+       Likewise.
 
-2007-02-21 22:17  twisti
+       * src/native/jni.c (_Jv_JNI_IsAssignableFrom): Use new class
+       functions. (_Jv_JNI_IsInstanceOf): Likewise.
 
-       * m4/jni.m4: Added ENABLE_JNI AM_CONDITIONAL.
-       
-       * src/vm/vm.c (vm_createjvm): Replaced some ENABLE_JAVASE with
-       ENABLE_JNI.
-       (vm_create): Likewise.
-       
-       * src/native/Makefile.am: Likewise.
-       
-       * src/native/jni.c (jni_init) [ENABLE_JAVASE]: ifdef'ed Java SE stuff.
-       (_Jv_JNI_DefineClass) [!ENABLE_JAVASE]: Abort.
-       (_Jv_JNI_FindClass): Likewise.
-       (_Jv_JNI_FromReflectedMethod): Likewise.
-       (_Jv_JNI_FromReflectedField): Likewise.
-       (_Jv_JNI_NewDirectByteBuffer): Likewise.
-       (_Jv_JNI_GetDirectBufferAddress): Likewise.
-       (_Jv_JNI_GetDirectBufferCapacity): Likewise.
-       (_Jv_JNI_IsAssignableFrom): Call _Jv_java_lang_Class_isAssignableFrom.
-       (_Jv_JNI_IsInstanceOf): Call _Jv_java_lang_Class_isInstance.
-       (_Jv_JNI_EnsureLocalCapacity): Removed debug output.
+       * src/native/vm/cldc1.1/java_lang_Class.c (forName): Implemented
+       directly. (isInstance): Use new class functions. (isAssignableFrom):
+       Likewise. (getName): Likewise.
 
-2007-02-21 20:24  twisti
+       * src/native/vm/gnu/java_lang_VMClass.c (isInstance): Likewise.
+       (isAssignableFrom): Likewise. (getName): Likewise.
+       (getDeclaredClasses): Likewise. (getDeclaredFields): Likewise.
+       (getDeclaredMethods): Likewise. (getDeclaredConstructors): Likewise.
+       (forName): Implemented directly. (getDeclaredAnnotations): Likewise.
+       (getEnclosingConstructor): Use new class functions.
+       (getEnclosingMethod): Likewise.
+       * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace): Likewise.
 
-       * src/vm/jit/Makefile.am [!WITH_BINUTILS_DISASSEMBLER]
-       (DISASS_SOURCES): Removed.
-       
-       * src/vm/jit/disass-common.c: Removed WITH_BINUTILS_DISASSEMBLER
-       ifdefs, since it's compiled conditionally.
+       * src/native/vm/reflect.h (_REFLECT_H): Added.
 
-2007-02-21 18:20  twisti
+       * src/native/vm/sun/jvm.c (JVM_GetStackTraceElement): Use new class
+       functions. (JVM_GetClassName): Likewise.
+       (JVM_GetClassDeclaredFields): Likewise.
+       (JVM_GetClassDeclaredMethods): Likewise.
+       (JVM_GetClassDeclaredConstructors): Likewise. (JVM_LoadLibrary): Use
+       TRACEJVMCALLSENTER and TRACEJVMCALLSEXIT. (JVM_FindLibraryEntry):
+       Likewise.
 
-       * src/vm/jit/x86_64/md-abi.c (regs): Renamed to
-       abi_registers_integer_name.
-       (md_param_alloc): Made code more clear.
-       (md_param_alloc_native): New function.
+       * src/vmcore/class.c (class_is_assignable_from): New function.
+       (class_is_instance): Likewise. (class_get_declaredconstructors):
+       Likewise. (class_get_declaredfields): Likewise.
+       (class_get_declaredmethods): Likewise.
+       (class_get_enclosingconstructor): Likewise.
+       (class_get_enclosingmethod): Renamed to
+       class_get_enclosingmethod_raw. class_get_enclosingmethod): Likewise.
+       * src/vmcore/class.h (class_get_classname): New function.
+       [dfe0c5810056]
+
+       * src/vm/jit/code.h:
+       * src/vm/jit/code.h (codeinfo): Moved stackframesize outside of
+       ENABLE_REPLACEMENT.
+       [5c10cc5e0dce]
+
+       * * Merged twisti branch.
+       [989bfa895cd1]
+
+       * NEWS:
+       Dummy commit to remove twisti branch.
+       * NEWS: Useless.
+       [8bc236b29952]
+
+       * NEWS:
+       Dummy commit to create twisti branch.
+       * NEWS: Useless.
+       [c153a9d8f8ce]
+
+       * * Merged with tip.
+       [30024dee3c14]
+
+       * src/vm/jit/Makefile.am, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/replace.c,
+       src/vm/jit/x86_64/linux/md-os.c:
+       * Merged executionstate branch.
+       [becec2dbe184]
+
+       * src/native/vm/sun/jvm.c:
+       Reverted 40d6392fb38f.
+       * src/native/vm/sun/jvm.c (JVM_FindLibraryEntry): Using HPI function
+       crashes.
+       [8c0ddfb79909]
+
+       * src/vm/jit/i386/darwin/md-os.c:
+       * src/vm/jit/i386/darwin/md-os.c (md_replace_executionstate_read):
+       Renamed to md_executionstate_read.
+       (md_replace_executionstate_write): Renamed to
+       md_executionstate_write.
+       [9bb627fa59f1]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_FindLibraryEntry): Use HPI.
+       [40d6392fb38f]
+
+       * src/vm/jit/powerpc/linux/md-os.c:
+       * src/vm/jit/powerpc/linux/md-os.c (md_executionstate_write): Fixed
+       comment typo.
+       [3c102f278b7a]
+
+       * src/vm/jit/powerpc/linux/md-os.c:
+       * src/vm/jit/powerpc/linux/md-os.c (md_replace_executionstate_read):
+       Renamed to md_executionstate_read.
+       (md_replace_executionstate_write): Renamed to
+       md_executionstate_write.
+       [6f19ebc51c4c]
+
+       * * Merged with tip.
+       [d492fa9b3e05]
+
+2008-04-20  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/jni.c:
+       * src/native/jni.c (jni_GetPrimitiveArrayCritical): Implemented
+       correcly. (jni_ReleasePrimitiveArrayCritical): Likewise.
+       [9c681dc4dcc4]
+
+2008-04-21  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/jni.h:
+       * src/native/jni.h (_Jv_jni_invokeNative): Removed.
+       [50357bec0c1a]
+
+2008-04-17  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/linenumbertable.c:
+       * src/vm/jit/linenumbertable.c (linenumbertable_create): Changed the
+       direction of the list. (linenumbertable_list_entry_add): Likewise.
+       (linenumbertable_list_entry_add_inline_start): Likewise.
+       (linenumbertable_list_entry_add_inline_end): Likewise.
+       [2536b88d4f77]
+
+       * src/vm/jit/emit-common.c:
+       * src/vm/jit/emit-common.c (emit_label_bccz): Code restructured.
+       (emit_label): Likewise.
+       [770ec75a0101]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/patcher-common.c, src/vm/jit
+       /patcher-common.h:
+       * src/vm/jit/patcher-common.c (patcher_resolve): New function.
+       * src/vm/jit/patcher-common.h (patcher_resolve): Export.
+       * src/vm/jit/codegen-common.c (codegen_finish): Use patcher_resolve.
+       [4cc078f655ff]
+
+2008-04-16  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/reg.h, src/vm/jit/verify/typecheck-builtins.inc,
+       src/vm/jit/verify/typecheck-common.h, src/vm/jit/verify/typecheck-
+       fields.inc, src/vm/jit/verify/typecheck-invoke.inc,
+       src/vm/jit/verify/typecheck-stackbased.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/verify/typeinfo.h, src/vm/resolve.c, src/vm/resolve.h:
+       * src/vm/jit/verify/typeinfo.h (typeinfo): Renamed to typeinfo_t.
+       (typeinfo_mergedlist): Renamed to typeinfo_mergedlist_t.
+       (typedescriptor): Renamed to typedescriptor_t.
+
+       * src/vm/jit/reg.h, src/vm/jit/verify/typecheck-builtins.inc,
+       src/vm/jit/verify/typecheck-common.h, src/vm/jit/verify/typecheck-
+       fields.inc, src/vm/jit/verify/typecheck-invoke.inc,
+       src/vm/jit/verify/typecheck-stackbased.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/resolve.c, src/vm/resolve.h: Likewise.
+       [2b2ea4de2f79]
+
+       * src/vmcore/descriptor.c, src/vmcore/references.h:
+       * src/vmcore/references.h (parseddesc): Renamed to parseddesc_t.
+
+       * src/vmcore/descriptor.c: Likewise.
+       [8bf03b52775b]
+
+       * src/native/jni.c, src/native/llni.h, src/vm/builtin.c,
+       src/vm/exceptions.c, src/vm/jit/replace.c, src/vm/jit/trace.c,
+       src/vm/jit/verify/typeinfo.c, src/vmcore/class.c,
+       src/vmcore/linker.c, src/vmcore/linker.h:
+       * src/vmcore/linker.h (_vftbl): Renamed class to clazz.
+
+       * src/native/jni.c, src/native/llni.h, src/vm/builtin.c,
+       src/vm/exceptions.c, src/vm/jit/replace.c, src/vm/jit/trace.c,
+       src/vm/jit/verify/typeinfo.c, src/vmcore/class.c,
+       src/vmcore/linker.c: Likewise.
+       [b28587b87dba]
+
+       * src/native/jni.c, src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c,
+       src/native/vm/sun_misc_Unsafe.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/stacktrace.h, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/classcache.c, src/vmcore/classcache.h,
+       src/vmcore/loader.c, src/vmcore/loader.h:
+       * src/vmcore/loader.h (classloader): Renamed to classloader_t.
+
+       * src/native/jni.c, src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c,
+       src/native/vm/sun_misc_Unsafe.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/stacktrace.h, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/classcache.c, src/vmcore/classcache.h,
+       src/vmcore/loader.c: Likewise.
+       [76cd2f513c2e]
+
+       * src/vmcore/annotation.c, src/vmcore/class.c, src/vmcore/field.c,
+       src/vmcore/loader.c, src/vmcore/loader.h, src/vmcore/method.c,
+       src/vmcore/stackmap.c, src/vmcore/suck.c, src/vmcore/zip.c:
+       * src/vmcore/loader.h (classbuffer): Renamed class to clazz.
+
+       * src/vmcore/annotation.c, src/vmcore/class.c, src/vmcore/field.c,
+       src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/stackmap.c,
+       src/vmcore/suck.c, src/vmcore/zip.c: Likewise.
+       [1386fb01ffaf]
+
+2008-04-15  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/s390/patcher.c:
+       * src/vm/jit/s390/patcher.c (patcher_invokeinterface): Forgot to
+       rename class to clazz.
+       [c8a40a22ee20]
+
+       * src/native/vm/reflect.c, src/vm/access.c,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/disass.c,
+       src/vm/jit/intrp/patcher.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/patcher.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/python.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/resolve.c,
+       src/vmcore/annotation.c, src/vmcore/field.c, src/vmcore/field.h,
+       src/vmcore/references.h:
+       * src/vmcore/field.h (fieldinfo): Renamed class to clazz.
+
+       * src/native/vm/reflect.c, src/vm/access.c,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/disass.c,
+       src/vm/jit/intrp/patcher.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/patcher.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/python.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/resolve.c,
+       src/vmcore/annotation.c, src/vmcore/field.c,
+       src/vmcore/references.h: Likewise.
+       [5a14bfe129aa]
+
+       * src/cacaoh/headers.c, src/native/native.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c, src/native/vm/reflect.c,
+       src/native/vm/sun/jvm.c, src/toolbox/logging.c, src/vm/access.c,
+       src/vm/exceptions.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/patcher.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/intrp/asmpart.c,
+       src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/disass.c,
+       src/vm/jit/intrp/patcher.c, src/vm/jit/jit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/patcher.c,
+       src/vm/jit/optimizing/dominators.c,
+       src/vm/jit/optimizing/lifetimes.c, src/vm/jit/optimizing/lsra.c,
+       src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa3.c,
+       src/vm/jit/optimizing/ssa_rename.c, src/vm/jit/parse.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/python.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, src/vm/jit/show.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/trace.c,
+       src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-common.c,
+       src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/verify/typecheck-
+       invoke.inc, src/vm/jit/verify/typecheck-stackbased-gen.inc,
+       src/vm/jit/verify/typecheck-stackbased.c, src/vm/jit/verify
+       /typecheck-typeinferer-gen.inc, src/vm/jit/verify/typecheck-
+       variablesbased-gen.inc, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/resolve.c,
+       src/vmcore/annotation.c, src/vmcore/linker.c, src/vmcore/loader.c,
+       src/vmcore/method.c, src/vmcore/method.h, src/vmcore/references.h:
+       * src/vmcore/method.h (methodinfo): Renamed class to clazz.
+
+       * src/cacaoh/headers.c, src/native/native.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c, src/native/vm/reflect.c,
+       src/native/vm/sun/jvm.c, src/toolbox/logging.c, src/vm/access.c,
+       src/vm/exceptions.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/patcher.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/intrp/asmpart.c,
+       src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/disass.c,
+       src/vm/jit/intrp/patcher.c, src/vm/jit/jit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/patcher.c,
+       src/vm/jit/optimizing/dominators.c,
+       src/vm/jit/optimizing/lifetimes.c, src/vm/jit/optimizing/lsra.c,
+       src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa3.c,
+       src/vm/jit/optimizing/ssa_rename.c, src/vm/jit/parse.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/python.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, src/vm/jit/show.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/trace.c,
+       src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-common.c,
+       src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/verify/typecheck-
+       invoke.inc, src/vm/jit/verify/typecheck-stackbased-gen.inc,
+       src/vm/jit/verify/typecheck-stackbased.c, src/vm/jit/verify
+       /typecheck-typeinferer-gen.inc, src/vm/jit/verify/typecheck-
+       variablesbased-gen.inc, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/resolve.c,
+       src/vmcore/annotation.c, src/vmcore/linker.c, src/vmcore/loader.c,
+       src/vmcore/method.c, src/vmcore/references.h: Likewise.
+       [d3299bba3c70]
+
+2008-04-14  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/threads/posix/thread-posix.c, src/threads/thread.c,
+       src/threads/thread.h:
+       Merging darwin compile fixes -> trunk.
+       [9d2e729a6841]
+
+       * src/threads/posix/thread-posix.c:
+       Merging fixes.
+       [d852f098fe45]
+
+       * src/native/vm/gnu/java_lang_VMThread.c, src/threads/thread.c,
+       src/threads/thread.h:
+       * src/native/vm/gnu/java_lang_VMThread.c
+       (Java_java_lang_VMThread_getState): Renamed thread_get_state because
+       of a name conflict with mach headers.
+       * src/threads/thread.c (thread_print_info, threads_thread_is_alive):
+       Likewise.
+       * src/threads/thread.h: Likewise.
+       [dfe2ed3a1417]
+
+       * src/threads/posix/thread-posix.c:
+       Merging fixes.
+       [61a938a77b77]
+
+       * src/threads/posix/thread-posix.c:
+       * src/threads/posix/thread-posix.c (threads_startup_thread): Compile
+       fix.
+       [be94e07a636c]
+
+       * src/threads/posix/thread-posix.c:
+       * src/threads/posix/thread-posix.c (sem_*): Fixed compile errors.
+       [bbaa09c52c9b]
+
+2008-04-14  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/thread.c:
+       * src/threads/thread.c (thread_set_state_runnable): Moved
+       DEBUGTHREADS into if, so the output is correct.
+       (thread_set_state_waiting): Likewise.
+       (thread_set_state_timed_waiting): Likewise.
+       [43d16d77d6e5]
+
+       * src/threads/posix/thread-posix.c, src/threads/thread.c,
+       src/threads/thread.h, src/vm/signal.c:
+       * src/threads/thread.c (threads_thread_state_runnable): Renamed to
+       thread_set_state_runnable. (threads_thread_state_waiting): Renamed
+       to thread_set_state_waiting. (threads_thread_state_timed_waiting):
+       Renamed to thread_set_state_timed_waiting.
+       (thread_set_state_terminated): Renamed to
+       thread_set_state_terminated.
+       * src/threads/thread.h: Likewise.
+       * src/threads/posix/thread-posix.c: Use new function names.
+       * src/vm/signal.c: Likewise.
+       [9e11431508ae]
+
+       * src/threads/posix/thread-posix.c:
+       * src/threads/posix/thread-posix.c (threads_sleep): Clear
+       interrupted flag in exception case.
+       [39438e55e9d0]
+
+       * src/native/vm/gnu/java_lang_VMThread.c, src/threads/thread.c,
+       src/threads/thread.h:
+       * src/threads/thread.h (thread_get_state): New function.
+       (threads_thread_get_state): Removed.
+       * src/threads/thread.c (thread_print_info): Use thread_get_state.
+       (threads_thread_is_alive): Likewise. (threads_thread_get_state):
+       Removed.
+       * src/native/vm/gnu/java_lang_VMThread.c (getState): Implemented
+       directly.
+       [d6879d90499a]
+
+       * src/threads/posix/thread-posix.c, src/threads/posix/thread-posix.h:
+       * src/threads/posix/thread-posix.c (threads_sleep): Throw correct
+       exceptions, use stdint.h types
+       * src/threads/posix/thread-posix.h (threads_sleep): Use stdint.h
+       types.
+       [2a41965d0840]
+
+       * src/threads/posix/thread-posix.c:
+       * src/threads/posix/thread-posix.c (threads_detach_thread): Reset
+       threadgroup when thread has terminated.
+       [d10959c776b1]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_IsInterrupted): Handle
+       clear_interrupted.
+       [865bf6ced98b]
+
+       * src/threads/thread.c:
+       * src/threads/thread.c (threads_attach_current_thread)
+       [ENABLE_JAVASE]: Set group to NULL, as it might contain any value.
+       [770449e5df5e]
+
+       * src/threads/thread.c:
+       * src/threads/thread.c (threads_attach_current_thread): Set the
+       thread data-structure in the TSD.
+       [c4f96b0c4d7d]
+
+       * src/threads/posix/thread-posix.c:
+       * src/threads/posix/thread-posix.c (threads_startup_thread): Renamed
+       variable thread to t.
+       [fe21e42f3871]
+
+       * src/native/jni.c:
+       * src/native/jni.c (JNI_NEW_ARRAY): Fixed typo for short array.
+       [ba3de48b4c29]
+
+2008-04-13  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/access.c, src/vm/access.h:
+       * src/vm/access.c [ENABLE_JAVASE] (access_check_field): Added
+       #ifdef. [ENABLE_JAVASE] (access_check_method): Likewise.
+       * src/vm/access.h: Likewise.
+       [0d747a4b03c4]
+
+       * src/native/vm/sun/hpi.c:
+       * src/native/vm/sun/hpi.c (hpi_initialize): Fixed compiler warning.
+       (hpi_initialize_socket_library): Likewise.
+       [04c6c41e37cb]
+
+       * src/vm/jit/stacktrace.c:
+       * src/vm/jit/stacktrace.c (stacktrace_print_entry): Print newline
+       for builtins.
+       [3864e0d2176b]
+
+2008-04-11  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * * Commited with tip.
+       [f86b8b643b79]
+
+       * src/threads/posix/thread-posix.c:
+       * src/threads/posix/thread-posix.c (threads_sleep): Removed
+       threads_check_if_interrupted_and_reset usage and use new functions.
+       [afc6c05d1704]
+
+       * src/native/vm/gnu/java_lang_reflect_VMField.c:
+       * src/native/vm/gnu/java_lang_reflect_VMField.c
+       (native/include/java_lang_reflect_Field.h): Added include.
+       [655d7c04e703]
+
+       * src/native/vm/gnu/java_lang_VMThread.c, src/threads/posix/thread-
+       posix.c, src/threads/posix/thread-posix.h, src/threads/thread.h:
+       * src/threads/thread.h (thread_set_interrupted): New function.
+       * src/threads/posix/thread-posix.c
+       (threads_check_if_interrupted_and_reset): Removed.
+       * src/threads/posix/thread-posix.h: Likewise.
+       * src/native/vm/gnu/java_lang_VMThread.c (interrupted): Use new
+       function.
+       [e33009dc3e7c]
+
+       * src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c,
+       src/threads/posix/thread-posix.c, src/threads/posix/thread-posix.h,
+       src/threads/thread.h:
+       * src/threads/thread.h (thread_is_interrupted): New function.
+       * src/threads/posix/thread-posix.c
+       (threads_thread_has_been_interrupted): Removed.
+       * src/threads/posix/thread-posix.h: Likewise.
+       * src/native/vm/gnu/java_lang_VMThread.c (isInterrupted): Use new
+       function.
+       * src/native/vm/sun/jvm.c (JVM_IsInterrupted): Likewise.
+       [f7128be365f8]
+
+       * src/threads/none/thread-none.h, src/threads/posix/thread-posix.h,
+       src/threads/thread.h:
+       * src/threads/none/thread-none.h: Fixed define name.
+       * src/threads/posix/thread-posix.h: Likewise.
+       * src/threads/thread.h: Likewise.
+       [d3a4c83bd558]
+
+2008-04-10  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/arm/asmpart.S:
+       * src/vm/jit/arm/asmpart.S (asm_cacheflush) [__ARM_EABI__]: Use
+       syscall number 0.
+       [ec144df42ca1]
+
+       * src/Makefile.am, src/cacao/Makefile.am, src/threads/Makefile.am,
+       src/threads/none/Makefile.am, src/threads/none/thread-none.c,
+       src/threads/none/thread-none.h, src/threads/posix/Makefile.am,
+       src/threads/thread.c, src/threads/thread.h, src/vm/jit/methodtree.c,
+       src/vm/jit/s390/md.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/stacktrace.h:
+       src/vm/jit/stacktrace.c (stacktrace_print_entry): New function.
+       (stacktrace_print_current): Likewise. [ENABLE_THREADS]
+       (stacktrace_print_of_thread): Likewise. [!ENABLE_THREADS]
+       (_no_threads_stackframeinfo): Removed.
+       * src/vm/jit/stacktrace.h: Likewise.
 
-2007-02-21 18:19  twisti
+       * src/Makefile.am [ENABLE_THREADS] (THREADS_DIR): Removed.
+       (SUBDIRS): Added threads.
 
-       * src/vm/jit/abi-asm.h: Cosmetic changes.
+       * src/cacao/Makefile.am [ENABLE_THREADS] (THREAD_LIB): Removed.
+       (libjvm_la_LIBADD): Removed $(THREAD_LIB), added
+       $(top_builddir)/src/threads/libthreads.la.
+       * src/threads/Makefile.am [!ENABLE_THREADS]: Recurse into none/.
+       * src/threads/none/Makefile.am (EXTRA_DIST): Removed. (AM_CPPFLAGS):
+       Added. (LIBS): Likewise. (noinst_LTLIBRARIES): Likewise.
+       (libthreadsnone_la_SOURCES): Likewise.
+
+       * src/threads/none/thread-none.c: New file.
+       * src/threads/none/thread-none.h (_no_threads_stackframeinfo): Export.
+
+       * src/threads/posix/Makefile.am (noinst_LTLIBRARIES): Renamed
+       library from libposix to libthreadsposix. (libposix_la_SOURCES):
+       Renamed to libthreadsposix_la_SOURCES.
+
+       * src/threads/thread.c (threads_dump): Use
+       stacktrace_print_of_thread. (threads_thread_print_stacktrace):
+       Removed. (threads_print_stacktrace): Likewise.
+       * src/threads/thread.h (threads_thread_print_stacktrace): Likewise.
+       (threads_print_stacktrace): Likewise.
 
-2007-02-20 01:23  twisti
+       * src/vm/jit/methodtree.c (methodtree_find): Use
+       stacktrace_print_current.
+       * src/vm/jit/s390/md.c (md_dump_context): Likewise.
+       [3457d7de230f]
+
+       * src/vm/jit/arm/linux/md-os.c:
+       * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill): Use
+       vm_abort instead of assert.
+       [98fd037a7854]
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_print_stacktrace) [!NDEBUG]:
+       #ifdef'ed class_print.
+       [6b3787897afb]
+
+       * src/threads/thread.h:
+       * src/threads/thread.h (thread_current_is_attached): Check if t is
+       NULL and return false in this case.
+       [79e7e22055fa]
+
+2008-04-07  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/classes/Makefile.am,
+       src/classes/gnu/gnu/java/lang/CPStringBuilder.java,
+       src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java,
+       src/classes/gnu/java/lang/reflect/Constructor.java,
+       src/classes/gnu/java/lang/reflect/Field.java,
+       src/classes/gnu/java/lang/reflect/Method.java,
+       src/classes/gnu/java/lang/reflect/Modifier.java,
+       src/classes/gnu/java/lang/reflect/VMConstructor.java,
+       src/classes/gnu/java/lang/reflect/VMField.java,
+       src/classes/gnu/java/lang/reflect/VMMethod.java,
+       src/native/include/Makefile.am, src/native/jni.c,
+       src/native/vm/gnu/Makefile.am,
+       src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/java_lang_reflect_VMConstructor.c,
+       src/native/vm/gnu/java_lang_reflect_VMField.c,
+       src/native/vm/gnu/java_lang_reflect_VMMethod.c,
+       src/native/vm/nativevm.c, src/native/vm/nativevm.h,
+       src/native/vm/reflect.c, src/native/vm/sun_misc_Unsafe.c,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c,
+       src/vmcore/loader.c, src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/classes/Makefile.am (VM_JAVA_FILES_GNU): Added new VM
+       interface files.
+       * src/native/include/Makefile.am (JAVASE_HEADER_FILES): Likewise.
+
+       * src/classes/gnu/gnu/java/lang/CPStringBuilder.java,
+       src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java,
+       src/classes/gnu/java/lang/reflect/Modifier.java: New file.
+
+       * src/classes/gnu/java/lang/reflect/Constructor.java,
+       src/classes/gnu/java/lang/reflect/Field.java,
+       src/classes/gnu/java/lang/reflect/Method.java: Updated.
+
+       * src/classes/gnu/java/lang/reflect/VMConstructor.java,
+       src/classes/gnu/java/lang/reflect/VMField.java,
+       src/classes/gnu/java/lang/reflect/VMMethod.java: New file.
+
+       * src/native/jni.c (FromReflectedMethod): Adapted to new VM
+       interface. (FromReflectedField): Likewise.
+
+       * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES):
+       Removed java_lang_reflect_Constructor.c, java_lang_reflect_Field.c,
+       java_lang_reflect_Method.c, added gnu_java_lang_VMCPStringBuilder.c,
+       java_lang_reflect_VMConstructor.c, java_lang_reflect_VMField.c,
+       java_lang_reflect_VMMethod.c.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c: Removed.
 
-       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c (vm/exceptions.h):
-       Added.
-       (vm/stringlocal.h): Likewise.
-       (loadLibrary): Throw error in case.
+       * src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c,
+       src/native/vm/gnu/java_lang_reflect_VMConstructor.c,
+       src/native/vm/gnu/java_lang_reflect_VMField.c,
+       src/native/vm/gnu/java_lang_reflect_VMMethod.c: New file.
 
-2007-02-20 00:42  twisti
+       * src/native/vm/nativevm.c (nativevm_preinit): Added
+       _Jv_gnu_java_lang_VMCPStringBuilder_init.
+       * src/native/vm/nativevm.h: Likewise.
 
-       * src/native/vm/java_lang_Runtime.c (loadLibrary): Different signature
-       for _Jv_java_lang_Runtime_loadLibrary depending on ENABLE_JNI.
-       * src/native/vm/java_lang_Runtime.h: Likewise.
-       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c: Likewise.
-       * src/native/vm/gnu/java_lang_VMRuntime.c: Likewise.
-
-2007-02-20 00:38  twisti
-
-       * configure.ac (AC_CHECK_ENABLE_JAVA): Added.
-       (AC_CHECK_ENABLE_JIT): Likewise.
-       (AC_CHECK_ENABLE_JNI): Likewise.
-       
-       * m4/jni.m4: New file.
-       * m4/java.m4: Likewise.
-       * m4/jit.m4: Likewise.
-
-2007-02-19 23:47  twisti
-
-       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c: New file.
-       
-       * src/native/vm/cldc1.1/Makefile.am (libnativevmcore_la_SOURCES):
-       Added com_sun_cldchi_jvm_JVM.c.
-       
-       * src/native/vm/java_lang_Runtime.c [!WITH_STATIC_CLASSPATH] (ltdl.h):
-       Added.
-       (native/jni.h): Likewise.
-       (native/native.h): Likewise.
-       (native/include/java_lang_String.h): Likewise.
-       (toolbox/logging.h): Likewise.
-       (vm/exceptions.h): Likewise.
-       (vm/stringlocal.h): Likewise.
-       (vmcore/options.h): Likewise.
-       (loadLibrary): New function.
-       
-       * src/native/vm/java_lang_Runtime.h (native/jni.h): Added.
-       (native/include/java_lang_String.h): Likewise.
-       
-       * src/native/vm/gnu/java_lang_VMRuntime.c [!WITH_STATIC_CLASSPATH]
-       (ltdl.h): Removed.
-       (native/native.h): Likewise.
-       (toolbox/logging.h): Likewise.
-       (vmcore/options.h): Likewise.
-       (nativeLoad): Call _Jv_java_lang_Runtime_loadLibrary.
-       
-       * src/native/include/Makefile.am (JAVAME_CLDC1_1_HEADER_FILES): Added
-       com_sun_cldchi_jvm_JVM.h.
-
-2007-02-18 20:16  pm
-
-       * src/vm/jit/s390/patcher.c (patcher_wrapper): Formatting changes.
-       * src/vm/jit/s390/asmpart.S (asm_patcher_wrapper): Did not remove
-       stack frame created by patcher stubs.
-
-2007-02-16 17:56  twisti
-
-       * src/vmcore/statistics.c (mm/gc-common.h): Added.
-       (statistics_print_gc_memory_usage): New function.
-       * src/vmcore/statistics.h (statistics_print_gc_memory_usage):
+       * src/native/vm/reflect.c (reflect_constructor_new): Adapted to new
+       VM interface. (reflect_field_new): Likewise. (reflect_method_new):
        Likewise.
-       
-       * src/cacaoh/dummy.c (gc_get_heap_size): New stub.
-       (gc_get_free_bytes): Likewise.
-       (gc_get_total_bytes): Likewise.
-       (gc_get_max_heap_size): Likewise.
-       
-       * src/mm/memory.c (memory_thread): Call
-       statistics_print_gc_memory_usage.
-
-2007-02-16 07:17  pm
-
-       * src/vm/jit/s390/md.c,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/codegen.h,
-       src/vm/jit/s390/patcher.c,
-       src/vm/jit/s390/asmpart.S,
-       src/vm/jit/s390/md-abi.c: Changed a lot. Mostly adapted to changes in
-       the tree.
-
-2007-02-15 19:48  twisti
-
-       * src/cacaoh/dummy.c (intrp_asm_abstractmethoderror): New stub.
-       (print_dynamic_super_statistics): Likewise.
-       
-       * src/vm/jit/intrp/engine.c (mm/memory.h): Added.
-       * src/vm/jit/intrp/dynamic-super.c [!ENABLE_THREADS]
-       (threads/none/lock.h): Likewise.
-
-2007-02-15 19:42  twisti
-
-       * src/Makefile.am [ENABLE_THREADS] (THREADS_DIR): Added.
-       (SUBDIRS): Added THREADS_DIR.
-       
-       * src/threads/Makefile.am (SUBDIRS): Set always to native.
-       
-       * src/threads/threads-common.c (threads/none/threads.h): Removed.
-       [ENABLE_THREADS] (threads_create_thread): Removed ifdef.
-       (threads_get_current_tid) [ENABLE_THREADS]: Removed.
-
-2007-02-15 11:43  pm
-
-       * src/threads/threads-common.c (threads_get_current_tid): Return 0 if
-       compiled with --enable-threads=none
-
-2007-02-14 11:35  twisti
-
-       * src/vm/jit/intrp/peephole.c: Updated to current codebase.
-       * src/vm/jit/intrp/intrp.h: Likewise.
-       * src/vm/jit/intrp/codegen.c: Likewise.
-       * src/vm/jit/intrp/engine.c: Likewise.
-       * src/vm/jit/intrp/asmpart.c: Likewise.
-       * src/vm/jit/intrp/dynamic-super.c: Likewise.
-       * src/vm/jit/intrp/patcher.c: Likewise.
-       * src/vm/jit/intrp/java.vmg: Likewise.
 
-2007-02-13 23:14  twisti
+       * src/native/vm/sun_misc_Unsafe.c (objectFieldOffset): Likewise.
+       (staticFieldBase): Likewise.
 
-       * src/vm/jit/arm/codegen.c (createnativestub) [!__ARM_EABI__]:
-       #ifdef'ed split-stuff.
-       * src/vm/jit/arm/md-abi.c (md_param_alloc_native) [!__ARM_EABI__]:
-       Added GNU EABI stuff.
+       * src/vmcore/class.c [WITH_CLASSPATH_GNU]
+       (class_java_lang_reflect_VMConstructor)
+       (class_java_lang_reflect_VMField, class_java_lang_reflect_VMMethod):
+       New global variable.
+       * src/vmcore/class.h: Likewise.
+       * src/vmcore/linker.c (linker_init): Added new classes.
+       * src/vmcore/loader.c (loader_init): Likewise.
 
-2007-02-13 22:11  ajordan
+       * src/vmcore/utf8.c [WITH_CLASSPATH_GNU]
+       (utf_java_lang_reflect_VMConstructor, utf_java_lang_reflect_VMField)
+       (utf_java_lang_reflect_VMMethod): New global variable.
+       * src/vmcore/utf8.h: Likewise.
+       [1dba59001474]
 
-       * configure.ac: Added support for compiling on Solaris.
-       
-       * src/vm/jit/sparc64/*: Added os subdir, changes for compiling on
-       Solaris.
+       * src/native/jni.c, src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.h,
+       src/native/vm/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_reflect_Method.h, src/native/vm/reflect.c,
+       src/native/vm/reflect.h, src/native/vm/sun/jvm.c:
+       * src/native/vm/java_lang_reflect_Constructor.c: Removed.
+       * src/native/vm/java_lang_reflect_Constructor.h: Likewise.
+       * src/native/vm/java_lang_reflect_Method.c: Likewise.
+       * src/native/vm/java_lang_reflect_Method.h: Likewise.
+
+       * src/native/jni.c (_Jv_jni_invokeNative): Likewise.
+
+       * src/native/vm/Makefile.am (JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES):
+       Removed. (JAVA_LANG_REFLECT_METHOD_SOURCES): Likewise.
+       (libnativevm_la_SOURCES): Removed
+       JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES and
+       JAVA_LANG_REFLECT_METHOD_SOURCES.
+
+       * src/native/vm/reflect.c (reflect_invoke): New function.
+       (reflect_constructor_newinstance): Likewise.
+       (reflect_method_invoke): Likewise.
+       * src/native/vm/reflect.h (reflect_constructor_newinstance): Export.
+       (reflect_method_invoke): Likewise.
 
-2007-02-13 21:32  twisti
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (constructNative): Use reflect_constructor_newinstance.
+       * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): Use
+       reflect_method_invoke.
+       * src/native/vm/sun/jvm.c (JVM_InvokeMethod): Use
+       reflect_method_invoke. (JVM_NewInstanceFromConstructor): Use
+       reflect_constructor_newinstance.
+       [a3189e2fbd34]
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.h:
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c (getSignature):
+       Implemented directly.
+       * src/native/vm/java_lang_reflect_Constructor.c (getSignature):
+       Removed.
+       * src/native/vm/java_lang_reflect_Constructor.h: Likewise.
+       [d1ea50387ceb]
 
-       * src/vm/jit/mips/md-abi.c (regs): Renamed to
-       abi_registers_integer_name.
-       (md_param_alloc_native): New function.
-       * src/vm/jit/mips/disass.c (disassinstr): Replaced regs with
-       abi_registers_integer_name.
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.h:
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (getExceptionTypes): Implemented directly.
+       * src/native/vm/java_lang_reflect_Constructor.c (getExceptionTypes):
+       Removed.
+       * src/native/vm/java_lang_reflect_Constructor.h: Likewise.
+       [2bfcb5cbdd18]
 
-2007-02-13 21:30  twisti
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.h:
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (getParameterTypes): Implemented directly.
+       * src/native/vm/java_lang_reflect_Constructor.c (getParameterTypes):
+       Removed.
+       * src/native/vm/java_lang_reflect_Constructor.h: Likewise.
+       [5b6da046d461]
 
-       * src/vm/jit/mips/emit.c (emit_verbosecall_exit): Fixed argument
-       passing, but I think there's still something left to fix.
-       * src/vm/jit/mips/md-abi.h (REG_A2_A3_PACKED): Added.
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.h:
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (getModifiersInternal): Implemented directly.
+       * src/native/vm/java_lang_reflect_Constructor.c (getModifiers):
+       Removed.
+       * src/native/vm/java_lang_reflect_Constructor.h: Likewise.
+       [f1da619c1b0b]
+
+2008-04-03  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/posix/Makefile.am, src/threads/posix/threadlist-posix.c,
+       src/threads/threadlist.c:
+       * src/threads/posix/threadlist-posix.c: Removed.
+       * src/threads/posix/Makefile.am (libposix_la_SOURCES): Removed
+       threadlist-posix.c.
+       * src/threads/threadlist.c (threads/mutex.h): Added.
+       (threadlist_mutex): New global variable. (threadlist_init):
+       Initialize mutex. (threadlist_lock, threadlist_unlock): New
+       functions.
+       [d8f389d4b3f7]
+
+2008-04-02  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_new_class_utf): Check for c ==
+       NULL when VM is initializing.
+       [3ac1ce7dadb2]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (TRACEJVMCALLSENTER, TRACEJVMCALLSEXIT):
+       New macro. (JVM_GetClassLoader): Trace return value.
+       [c4ceb9518a19]
+
+       * src/vm/jit/stacktrace.c:
+       * src/vm/jit/stacktrace.c (stacktrace_get): Correctly skip
+       Throwable.init() functions. (stacktrace_stackframeinfo_fill):
+       Changed debugging messge.
+       [18f868142155]
+
+       * src/threads/thread.c, src/threads/thread.h:
+       * src/threads/thread.c (threads_thread_print_info): Renamed to
+       thread_print_info, removed assert on THREAD_STATE_NEW but print as
+       much info as possible. (threads_dump): Use new functio name.
+       * src/threads/thread.h: Likewise.
+       [d6c927d2e029]
+
+       * * Merged with tip.
+       [da113f4ae466]
+
+       * src/vm/string.c:
+       * src/vm/string.c (javastring_safe_new_from_utf8): Don't assert on
+       text is NULL, but return NULL. Checked with jconsole.
+       [af3aa1b2e676]
+
+       * src/mm/Makefile.am:
+       * src/mm/Makefile.am: Changed copyright.
+       [906626e18451]
+
+2008-04-02  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/cacao/cacao.c, src/native/jvmti/cacaodbg.c,
+       src/native/jvmti/cacaodbg.h, src/native/jvmti/jvmti.c,
+       src/threads/Makefile.am, src/threads/mutex.h,
+       src/threads/posix/Makefile.am, src/threads/posix/generic-
+       primitives.h, src/threads/posix/lock.c, src/threads/posix/lock.h,
+       src/threads/posix/mutex-posix.h, src/threads/posix/thread-posix.c,
+       src/threads/posix/thread-posix.h, src/threads/posix/threadlist-
+       posix.c, src/vm/vm.c:
+       * src/threads/Makefile.am: Added mutex.h.
+       * src/threads/posix/Makefile.am: Added mutex-posix.h.
+
+       * src/threads/mutex.h: Added new file.
+       * src/threads/posix/mutex-posix.h: Likewise. (mutex_init): Implemented
+       inline wrapper function. (mutex_lock): Likewise. (mutex_unlock):
+       Likewise. (mutex_destroy): Likewise.
+
+       * src/cacao/cacao.c, src/native/jvmti/cacaodbg.c,
+       src/native/jvmti/cacaodbg.h, src/native/jvmti/jvmti.c,
+       src/threads/posix/generic-primitives.h, src/threads/posix/lock.c,
+       src/threads/posix/lock.h, src/threads/posix/thread-posix.c,
+       src/threads/posix/thread-posix.h, src/threads/posix/threadlist-
+       posix.c, src/vm/vm.c: Included mutex.h and used wrapper functions
+       throughout the whole file.
+       [30bdc35a0486]
+
+2008-04-01  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/none/thread-none.h, src/threads/none/threads.h,
+       src/threads/thread.h:
+       * src/threads/none/threads.h: Renamed from here...
+       * src/threads/none/thread-none.h: ...to here.
+       * src/threads/thread.h: Fixed include.
+       [cce680c919ac]
+
+       * src/native/jni.c, src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c,
+       src/threads/none/threads.h, src/threads/posix/thread-posix.c,
+       src/threads/thread.c, src/threads/thread.h, src/vm/exceptions.c:
+       * src/native/jni.c (_Jv_JNI_FindClass): Renamed to jni_FindClass,
+       call resolve_handle_pending_exception in exception case.
+       (_Jv_JNI_ExceptionDescribe): Renamed to jni_ExceptionDescribe, use
+       exceptions_print_stacktrace. (_Jv_JNI_ExceptionClear): Renamed to
+       jni_ExceptionClear.
+
+       * src/threads/thread.h (threads_thread_get_object): Renamed to
+       thread_get_object. (threads_thread_set_object): Renamed to
+       thread_set_object. (threads_get_current_object): Renamed to
+       thread_get_current_object. (thread_is_attached): Use new function
+       names. (thread_fprint_name): Export.
+
+       * src/threads/none/threads.h (threads_get_current_object): Renamed
+       to thread_get_current_object.
+
+       * src/native/vm/cldc1.1/java_lang_Thread.c (currentThread): Use new
+       function names.
+       * src/native/vm/gnu/java_lang_VMThread.c (currentThread): Likewise.
+       * src/native/vm/sun/jvm.c (JVM_CurrentThread): Likewise.
+       * src/threads/posix/thread-posix.c (threads_startup_thread): Likewise.
+       (threads_detach_thread): Likewise.
+       * src/threads/thread.c (thread_create_object): Likewise.
+       (thread_free): Likewise. (threads_thread_start): Likewise.
+       (thread_fprint_name): New function. (threads_thread_print_info): Use
+       thread_fprint_name.
+
+       * src/vm/exceptions.c (exceptions_print_stacktrace): Implemented
+       (mostly) as in HotSpot.
+       [10f85b96a2de]
+
+       * src/vm/string.c, src/vm/stringlocal.h:
+       * src/vm/string.c (javastring_print): Renamed to javastring_fprint
+       and added a stream argument.
+       * src/vm/stringlocal.h: Likewise.
+       [abde7ae98d1d]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_run) [ENABLE_THREADS]: #ifdef'ed threading stuff.
+       [9d9bdfdef420]
+
+       * configure.ac:
+       * configure.ac (AC_CHECK_HEADERS): Added stdio.h.
+       [68c3572dec69]
+
+       * src/threads/thread.c, src/threads/thread.h,
+       src/threads/threadlist.c:
+       * src/threads/thread.c (thread_create_object): New function.
+       (thread_method_init): Made static. (threadgroup_system,
+       threadgroup_main): Changed type to java_handle_t.
+       (thread_create_initial_threadgroup): Chnaged type of
+       threadgroup_system and threadgroup_main.
+       (thread_create_initial_thread): Use thread_create_object.
+       (threads_thread_start_internal): Likewise.
+       (threads_attach_current_thread): Likewise.
+       (threads_thread_print_info): Use thread_is_daemon.
+       * src/threads/thread.h (thread_method_init): Removed.
+       (thread_is_daemon): New function.
+       * src/threads/threadlist.c (threadlist_get_non_daemons): Use
+       thread_is_daemon.
+       [ea1ec101d6fe]
+
+       * src/threads/posix/thread-posix.c, src/threads/thread.c,
+       src/threads/thread.h:
+       * src/threads/thread.c (threads_thread_new): Renamed to thread_new
+       and made static. (threads_thread_free): Renamed to thread_free.
+       (threads_thread_start_internal): Use new function names.
+       (threads_thread_start): Likewise. (threads_attach_current_thread):
+       Likewise.
+       * src/threads/thread.h (threads_thread_new): Removed.
+       (threads_thread_free): Renamed to thread_free.
+
+       * src/threads/posix/thread-posix.c (threads_detach_thread): Use new
+       function names.
+       [e5e0b246a78b]
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao-
+       gc/rootset.c, src/mm/cacao-gc/rootset.h, src/mm/codememory.c,
+       src/mm/dumpmemory.c, src/mm/memory.c, src/native/jni.c,
+       src/native/jvmti/cacaodbg.c, src/native/jvmti/cacaodbg.h,
+       src/native/jvmti/jvmti.c, src/native/llni.c, src/native/llni.h,
+       src/native/localref.c, src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c,
+       src/threads/Makefile.am, src/threads/posix/Makefile.am,
+       src/threads/posix/lock.c, src/threads/posix/thread-posix.c,
+       src/threads/posix/thread-posix.h, src/threads/posix/threads.c,
+       src/threads/posix/threads.h, src/threads/thread.c,
+       src/threads/thread.h, src/threads/threadlist.c,
+       src/threads/threadlist.h, src/threads/threads-common.c, src/threads
+       /threads-common.h, src/toolbox/logging.c, src/vm/builtin.c,
+       src/vm/exceptions.c, src/vm/finalizer.c, src/vm/jit/alpha/linux/md-
+       os.c, src/vm/jit/arm/linux/md-os.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/intrp/asmpart.c,
+       src/vm/jit/intrp/engine.c, src/vm/jit/jit.c,
+       src/vm/jit/methodtree.c, src/vm/jit/optimizing/profile.c,
+       src/vm/jit/optimizing/recompile.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/powerpc64/linux/md-os.c, src/vm/jit/replace.c,
+       src/vm/jit/s390/md.c, src/vm/jit/show.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/trace.c, src/vm/jit/x86_64/freebsd/md-os.c,
+       src/vm/jit/x86_64/linux/md-os.c, src/vm/signal.c, src/vm/vm.c:
+       * src/threads/posix/threads.c: Renamed from here...
+       * src/threads/posix/threads.h, src/threads/threads-common.c,
+       src/threads/threads-common.h: Likewise.
+
+       * src/threads/posix/thread-posix.c: ...to here.
+       * src/threads/posix/thread-posix.h, src/threads/thread.c,
+       src/threads/thread.h: Likewise.
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao-
+       gc/rootset.c, src/mm/cacao-gc/rootset.h, src/mm/codememory.c,
+       src/mm/dumpmemory.c, src/mm/memory.c, src/native/jni.c,
+       src/native/jvmti/cacaodbg.c, src/native/jvmti/cacaodbg.h,
+       src/native/jvmti/jvmti.c, src/native/llni.c, src/native/llni.h,
+       src/native/localref.c, src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c,
+       src/threads/Makefile.am, src/threads/posix/lock.c,
+       src/threads/posix/Makefile.am, src/threads/threadlist.c,
+       src/threads/threadlist.h, src/toolbox/logging.c, src/vm/builtin.c,
+       src/vm/exceptions.c, src/vm/finalizer.c, src/vm/jit/alpha/linux/md-
+       os.c, src/vm/jit/arm/linux/md-os.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/intrp/asmpart.c,
+       src/vm/jit/intrp/engine.c, src/vm/jit/jit.c,
+       src/vm/jit/methodtree.c, src/vm/jit/optimizing/profile.c,
+       src/vm/jit/optimizing/recompile.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/powerpc64/linux/md-os.c, src/vm/jit/replace.c,
+       src/vm/jit/s390/md.c, src/vm/jit/show.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/trace.c, src/vm/jit/x86_64/freebsd/md-os.c,
+       src/vm/jit/x86_64/linux/md-os.c, src/vm/signal.c, src/vm/vm.c:
+       Changed filename occurrences.
+       [38d26f1a1c95]
+
+2008-03-31  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/jni.c, src/threads/posix/threads.c, src/threads/threads-
+       common.c, src/threads/threads-common.h, src/vm/global.h,
+       src/vm/vm.c:
+       Fixes PR59.
+       * src/native/jni.c (_Jv_JNI_Get##name##Field): Added TRACEJNICALLS.
+       (_Jv_JNI_Set##name##Field): Likewise.
+       (_Jv_JNI_CallStaticObjectMethod): Likewise.
+       (_Jv_JNI_CallStaticObjectMethodV): Likewise.
+       (_Jv_JNI_CallStaticObjectMethodA): Likewise.
+       (_Jv_JNI_CallStaticVoidMethod): Likewise.
+       (_Jv_JNI_CallStaticVoidMethodV): Likewise.
+       (_Jv_JNI_CallStaticVoidMethodA): Likewise. (_Jv_JNI_GetArrayLength):
+       Likewise. (_Jv_JNI_Get##name##ArrayElements): Likewise.
+       (_Jv_JNI_Get##name##ArrayRegion): Likewise.
+       (jni_attach_current_thread): Check correctly if current thread is
+       already attached. (_Jv_JNI_DetachCurrentThread): Check if current
+       thread is already detached.
+       * src/threads/posix/threads.c (threads_detach_thread): Likewise.
+
+       * src/threads/threads-common.c (threads_init) [WITH_CLASSPATH_SUN]:
+       Resolve correct thread init method. (thread_create_object): New
+       function, but not yet implemented. (thread_create_initial_thread):
+       Lot of changes.
+
+       * src/threads/threads-common.h (thread_is_attached): New function.
+       (thread_current_is_attached): Likewise.
+
+       * src/vm/global.h (STR): New macro, stolen from OpenJDK.
+
+       * src/vm/vm.c (vm_run): Detach the main thread before calling
+       vm_destroy. (vm_destroy): Attach the main thread again as
+       DestroyJavaVM thread.
+       [5b1738cbdeac]
+
+       * src/native/jni.c, src/native/jvmti/cacaodbg.c,
+       src/threads/posix/threads.c, src/threads/posix/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/posix/threads.c (threads_set_current_threadobject):
+       Moved from here... (threads_get_current_threadobject): Likewise.
+       * src/threads/posix/threads.h (thread_get_current): ...to here.
+       (thread_set_current): Likewise.
+       * src/threads/threads-common.h (threads_set_current_threadobject):
+       Removed.
 
-2007-02-13 15:15  twisti
+       * src/native/jni.c (jni_attach_current_thread): Use new function
+       name. (_Jv_JNI_DetachCurrentThread): Likewise. (_Jv_JNI_GetEnv):
+       Likewise.
+       * src/native/jvmti/cacaodbg.c (jvmti_get_current_thread): Likewise.
+       * src/threads/threads-common.c (threads_preinit): Likewise.
+       [6bdc40cea36e]
+
+       * configure.ac, m4/classpath.m4, m4/hpi.m4, src/native/vm/nativevm.c,
+       src/native/vm/sun/Makefile.am, src/native/vm/sun/hpi.c,
+       src/native/vm/sun/hpi.h, src/native/vm/sun/jvm.c,
+       src/vmcore/options.c, src/vmcore/options.h:
+       * configure.ac (AC_CHECK_WITH_HPI_MD_H): Added.
+       (AC_CHECK_WITH_HPI_H): Likewise.
+       * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Changed default
+       for OpenJDK. (AC_CHECK_WITH_CLASSPATH_LIBDIR): Likewise.
+       (AC_CHECK_WITH_JNI_MD_H): Likewise. (AC_CHECK_WITH_JNI_H): Likewise.
+
+       * m4/hpi.m4: New file.
+       * src/native/vm/nativevm.c (nativevm_preinit): Call hpi_initialize.
+       * src/native/vm/sun/Makefile.am (libnativevmcore_la_SOURCES): Added
+       hpi.[ch].
+       * src/native/vm/sun/hpi.c: New file.
+       * src/native/vm/sun/hpi.h: Likewise.
+
+       * src/native/vm/sun/jvm.c (JVM_GetLastErrorString): Use HPI
+       function. (JVM_NativePath): Likewise. (JVM_Open): Likewise.
+       (JVM_Close): Likewise. (JVM_Read): Likewise. (JVM_Write): Likewise.
+       (JVM_Available): Likewise. (JVM_Lseek): Likewise. (JVM_SetLength):
+       Likewise. (JVM_Sync): Likewise. (JVM_InitializeSocketLibrary): Call
+       hpi_initialize_socket_library.
+
+       * src/vmcore/options.c (opt_TraceHPI): Added global variable.
+       (options_xx): Handle new option.
+       * src/vmcore/options.h: Likewise.
+       [fceac7c38a1b]
+
+       * src/native/vm/nativevm.c:
+       * src/native/vm/nativevm.c (nativevm_preinit) [WITH_CLASSPATH_SUN]:
+       Check for native_library_open error.
+       [fc69ca6c9fbe]
+
+2008-03-29  Edwin Steiner  <edwin.steiner@gmx.net>
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_analyse): Clean up: removed an obsolete
+       assignment to copy->varkind. (It is set in SET_TEMPVAR anyway.)
+       [da706966db7d]
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_analyse): Use the javaindex instead of
+       the CACAO varindex for checking conflicts with local variables.
+       While there is no real conflict between CACAO variables of different
+       types, the register allocator makes the implicit assumption that
+       variables corresponding to the same javaindex may be coalesced. As
+       long as this assumption is made, we must consider variables with the
+       same javaindex as conflicting (and also check against that in the
+       verifier). This fixes [Bug 49] VerifyError with obfuscated classes.
+       [08444c22b833]
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_analyse): Clean up the ICMD_IINC case so
+       it uses the javaindex variable. (No functional change.)
+       [18e1045d35f2]
+
+       * src/vm/jit/jit.h, src/vm/jit/parse.c, src/vm/jit/verify/typecheck-
+       common.h, src/vm/jit/verify/typecheck.c:
+       * src/vm/jit/jit.h (jitdata): Added reverselocalmap.
+
+       * src/vm/jit/parse.c (parse): Fill the reverselocalmap.
+
+       * src/vm/jit/verify/typecheck-common.h (verifier_state): Removed the
+       reverselocalmap.
+
+       * src/vm/jit/verify/typecheck.c (typecheck_invalidate_locals): Use
+       jd->reverselocalmap. (typecheck): Likewise.
+       [8a9d9cd39976]
+
+       * tests/regression/jasmin/Makefile.am,
+       tests/regression/jasmin/test_load_store_conflict_different_types.j:
+       *
+       tests/regression/jasmin/test_load_store_conflict_different_types.j:
+       New test exposing the bug in conflict checking for local variables
+       ([Bug 49] VerifyError with obfuscated classes).
 
-       * src/threads/native/lock.c (vm/vm.h): Added.
-       (lock_record_add_waiter): New function.
-       (lock_record_remove_waiter): Free the waiter data structure.
-       (lock_record_wait): Use lock_record_add_waiter.
-       * src/threads/native/lock.h: Cosmetic changes.
+       * tests/regression/jasmin/Makefile.am: Added new test.
+       [e5dbef3898c1]
 
-2007-02-13 14:15  twisti
+       * contrib/vmlog/vmlog_cacao.h:
+       * contrib/vmlog/vmlog_cacao.h: Removed #include of a header that
+       does not exist anymore.
+       [5b8c6c097400]
 
-       * src/cacaoh/dummy.c (mem_alloc): Arghhhh, fixed arguments.
+2008-03-27  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-02-13 14:13  twisti
+       * src/threads/posix/threads.c, src/threads/posix/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/posix/threads.c (threads_attach_current_thread):
+       Removed.
+       * src/threads/posix/threads.h: Likewise.
+       * src/threads/threads-common.c (threads_attach_current_thread): Added.
+       * src/threads/threads-common.h: Likewise.
+       [e1fa9148b033]
+
+       * src/native/vm/nativevm.c, src/native/vm/nativevm.h,
+       src/native/vm/sun/jvm.c, src/vm/global.h, src/vm/initialize.c,
+       src/vm/initialize.h, src/vm/vm.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/native/vm/nativevm.c (nativevm_preinit): Changed signature,
+       use system_* functions. (nativevm_init): Changed signature.
+       * src/native/vm/nativevm.h: Likewise.
 
-       * src/cacaoh/dummy.c (mem_alloc): Use calloc instead of malloc.
+       * src/native/vm/sun/jvm.c (JVM_InitProperties): Added
+       sun.nio.MaxDirectMemorySize handling.
 
-2007-02-13 13:23  twisti
+       * src/vm/global.h (PRINTF_FORMAT_INT64_T): Added define for int64_t
+       formater.
 
-       * src/threads/threads-common.c (threads_get_current_tid): Check if
-       thread is NULL and return 0.
+       * src/vm/initialize.c (initialize_init): New function.
+       * src/vm/initialize.h: Likewise.
 
-2007-02-13 13:04  twisti
+       * src/vm/vm.c (vm_create): Added initialize_init.
 
-       * src/threads/threads-common.c (threads_get_current_tid): New
+       * src/vmcore/options.c (opt_MaxDirectMemorySize): New global
+       variable. (options_xx): Use system_* functions.
+       * src/vmcore/options.h: Likewise.
+       [bd1fba089d84]
+
+       * configure.ac, src/vmcore/system.h:
+       * configure.ac (AC_CHECK_FUNCS): Added strcat, strcpy.
+       * src/vmcore/system.h (system_atoi): New function. (system_strcat):
+       Likewise. (system_strcpy): Likewise.
+       [3bc1e510dba5]
+
+2008-03-26  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vmcore/loader.c, tests/regression/bugzilla/PR58.java:
+       * src/vmcore/loader.c (load_class_from_classbuffer_intern): Also
+       call resolve_handle_pending_exception for super interfaces.
+       * tests/regression/bugzilla/PR58.java (test): Renamed to
+       testSuperClass. (testSuperInterface): New method.
+       [a9203003de40]
+
+       * src/cacaoh/dummy.c, src/native/vm/sun/jvm.c, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/resolve.c, src/vm/resolve.h,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c,
+       src/vmcore/loader.c, src/vmcore/utf8.c, src/vmcore/utf8.h,
+       tests/regression/bugzilla/All.java,
+       tests/regression/bugzilla/PR58.java:
+       * src/cacaoh/dummy.c (resolve_handle_pending_exception): New
        function.
-       * src/threads/threads-common.h (threads_get_current_tid): Added.
-       
-       * src/toolbox/logging.c (log_start): Use threads_get_current_tid.
-       
-       * src/cacaoh/dummy.c (threads_get_current_threadobject): Removed.
-       (threads_get_current_tid): Added.
-
-2007-02-13 12:23  ajordan
-
-       * src/vm/jit/Makefile.am: Reverted duplicate changes.
-       
-       * src/vm/signal.c: Reverted one duplicate header include.
-
-2007-02-13 02:36  ajordan
-
-       * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframeinfo):
-       SPARC specific retrieval of the PV.
-       (stacktrace_create): SPARC specific stack walking.
-       
-       * src/vm/jit/Makefile.am: Not compiling verifier source when disabled.
-       
-       * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Included
-       __SPARC_64__ in ifdef to add patcher NOPs from here.
-       
-       * src/vm/signal.c: Added include statements and/or ifdefs to fix
-       compiling without threads.
-       * src/vm/exceptions.c: Likewise.
-       * src/vm/finalizer.c: Likewise.
-       * src/native/jni.c: Likewise.
-       * src/threads/none/threads.h: Likewise.
-       * src/threads/threads-common.c: Likewise.
-       * src/threads/critical.c: Likewise.
-
-2007-02-13 02:12  ajordan
-
-       * src/vm/jit/sparc64/md-abi.h: set TRACE_ARGS_NUM to 6.
-       * src/vm/jit/sparc64/emit.c: using the 6 available integer argument
-       regs for call tracing.
-       
-       * src/vm/jit/sparc64/md-abi.c: added abi register names.
-       Added md_param_alloc_native(), but still using the existing
-       workaround.
 
-2007-02-13 00:51  twisti
+       * src/native/vm/sun/jvm.c (JVM_FindClassFromClassLoader): Added
+       assert on throwError. (JVM_DoPrivileged): Throw
+       PrivilegedActionException only if the exception is an instance of
+       java.lang.Exception but not of java.lang.RuntimeException.
 
-       * src/mm/memory.c (memory_thread) [ENABLE_STATISTICS]: #ifdef'ed
-       statistics_print_memory_usage call.
+       * src/vm/exceptions.c (exceptions_new_class_utf): New function.
+       (exceptions_throw_class_utf): Likewise.
+       (exceptions_throw_classnotfoundexception): Use
+       exceptions_throw_class_utf.
+       (exceptions_classnotfoundexception_to_noclassdeffounderror):
+       Removed.
+       * src/vm/exceptions.h: Likewise.
 
-2007-02-13 00:40  twisti
+       * src/vm/resolve.c (resolve_handle_pending_exception): New function.
+       (resolve_class_from_name): Don't convert exception.
+       * src/vm/resolve.h (resolve_handle_pending_exception): Added.
+
+       * src/vmcore/class.c (class_java_lang_Exception): New global
+       variable. (class_java_lang_ClassNotFoundException): Likewise.
+       (class_java_lang_RuntimeException): Likewise.
+       * src/vmcore/class.h: Likewise.
+
+       * src/vmcore/linker.c (linker_init): Link new global classes.
+       * src/vmcore/loader.c (loader_init): Load new global classes.
+
+       * src/vmcore/utf8.c (utf_java_lang_RuntimeException): New global
+       variable. (utf8_init): Initialize new global variable.
+       * src/vmcore/utf8.h (utf_java_lang_RuntimeException): Export.
+
+       * tests/regression/bugzilla/All.java: Added PR58.
+       * tests/regression/bugzilla/PR58.java: New file.
+       [4067fe3a3bee]
+
+       * tests/A2.java, tests/AA.java, tests/AA1.java, tests/AA2.java,
+       tests/BB.java, tests/C.java, tests/C2.java, tests/C3.java,
+       tests/CC.java, tests/D.java, tests/DD.java, tests/EE.java,
+       tests/GG.java, tests/HI2.java, tests/II.java, tests/IIAA.java,
+       tests/IIBB.java, tests/IICC.java, tests/IIexample.java,
+       tests/Makefile.am, tests/n.java, tests/scribble.java:
+       * tests/Makefile.am: Cleanup, removed checkall, added build target.
+       * tests/A2.java: Removed.
+       * tests/AA.java, tests/AA1.java, tests/AA2.java, tests/BB.java,
+       tests/C.java, tests/C2.java, tests/C3.java, tests/CC.java,
+       tests/D.java, tests/DD.java, tests/EE.java, tests/GG.java,
+       tests/HI2.java, tests/II.java, tests/IIAA.java, tests/IIBB.java,
+       tests/IICC.java, tests/IIexample.java, tests/n.java,
+       tests/scribble.java: Likewise.
+       [91251aac4dec]
+
+       * tests/regression/bugzilla/All.java,
+       tests/regression/bugzilla/PR57.java:
+       * tests/regression/bugzilla/All.java: Added PR57.
+       * tests/regression/bugzilla/PR57.java: New file.
+       [8a65518935cf]
+
+       * tests/regression/bugzilla/Makefile.am:
+       * tests/regression/bugzilla/Makefile.am (JAVA): Added
+       LD_LIBRARY_PATH so we can really overrite JAVA. (build): Added
+       $(srcdir) to find .java files. (check): Removed LD_LIBRARY_PATH.
+       [dbf4b68b6d25]
+
+2008-03-25  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/native/Makefile.am, src/threads/native/generic-
+       primitives.h, src/threads/native/lock.c, src/threads/native/lock.h,
+       src/threads/native/threadlist-posix.c, src/threads/native/threads.c,
+       src/threads/native/threads.h:
+       * src/threads/native/Makefile.am: Removed.
+       * src/threads/native/generic-primitives.h, src/threads/native/lock.c,
+       src/threads/native/lock.h, src/threads/native/threadlist-posix.c,
+       src/threads/native/threads.c, src/threads/native/threads.h:
+       Likewise.
+       [0337947f848f]
+
+       * configure.ac, src/mm/cacao-gc/gc.h, src/mm/cacao-gc/rootset.h,
+       src/native/jvmti/cacaodbg.c, src/native/jvmti/cacaodbg.h,
+       src/native/jvmti/jvmti.c, src/native/llni.h,
+       src/threads/Makefile.am, src/threads/lock-common.h,
+       src/threads/posix/Makefile.am, src/threads/posix/generic-
+       primitives.h, src/threads/posix/lock.c, src/threads/posix/lock.h,
+       src/threads/posix/threadlist-posix.c, src/threads/posix/threads.c,
+       src/threads/posix/threads.h, src/threads/threads-common.c,
+       src/threads/threads-common.h, src/vm/builtintable.inc,
+       src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/intrp/asmpart.c, src/vm/jit/intrp/dynamic-super.c,
+       src/vm/jit/intrp/engine.c, src/vm/jit/powerpc/darwin/md-os.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc64/linux/md-
+       os.c, src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md.c, src/vm/jit/show.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/x86_64/freebsd/md-os.c, src/vm/jit/x86_64/linux/md-os.c:
+       * configure.ac (AC_CONFIG_FILES): Moved src/threads/native/Makefile
+       to src/threads/posix/Makefile.
+
+       * src/threads/posix/Makefile.am, src/threads/posix/generic-
+       primitives.h, src/threads/posix/lock.c, src/threads/posix/lock.h,
+       src/threads/posix/threadlist-posix.c, src/threads/posix/threads.c,
+       src/threads/posix/threads.h: Moved from src/threads/native/.
+
+       * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/rootset.h,
+       src/native/jvmti/cacaodbg.c, src/native/jvmti/cacaodbg.h,
+       src/native/jvmti/jvmti.c, src/native/llni.h,
+       src/threads/Makefile.am, src/threads/lock-common.h, src/threads
+       /threads-common.c, src/threads/threads-common.h,
+       src/vm/builtintable.inc, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/arm/linux/md-os.c, src/vm/jit/intrp/asmpart.c,
+       src/vm/jit/intrp/dynamic-super.c, src/vm/jit/intrp/engine.c,
+       src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, src/vm/jit/show.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/x86_64/freebsd/md-os.c,
+       src/vm/jit/x86_64/linux/md-os.c: Fixed header includes.
+       [e852f2d0d4c4]
+
+       * src/cacaoh/Makefile.am:
+       * src/cacaoh/Makefile.am: Changed copyright.
+       [5974a060a410]
+
+2008-03-25  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/optimizing/ssa.h:
+       Dummy push for testing.
+       [484dcf446038]
+
+       * src/vm/jit/optimizing/ssa.h:
+       Dummy push for testing.
+       [177737032317]
+
+       * src/vm/jit/optimizing/ssa.h:
+       Dummy push for testing.
+       [119782e1ae60]
+
+       * src/vm/jit/optimizing/ssa.h:
+       Dummy push for testing.
+       [0a173b247580]
+
+2008-03-25  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/mark.c, src/mm/cacao-
+       gc/rootset.c, src/threads/native/lock.c, src/threads/threadlist.c,
+       src/toolbox/list.c, src/toolbox/list.h, src/vm/assertion.c,
+       src/vm/jit/codegen-common.c, src/vm/jit/emit-common.c,
+       src/vm/jit/linenumbertable.c, src/vm/jit/optimizing/recompile.c,
+       src/vm/jit/patcher-common.c, src/vm/jit/s390/codegen.c,
+       src/vm/properties.c:
+       * src/toolbox/list.c (list_add_first_unsynced): Removed.
+       (list_add_last_unsynced): Likewise. (list_remove_unsynced):
+       Likewise. (list_first_unsynced): Likewise. (list_last_unsynced):
+       Likewise. (list_next_unsynced): Likewise. (list_prev_unsynced):
+       Likewise.
+       * src/toolbox/list.h: Likewise.
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/mark.c, src/mm/cacao-
+       gc/rootset.c, src/threads/native/lock.c, src/threads/threadlist.c,
+       src/vm/assertion.c, src/vm/jit/codegen-common.c, src/vm/jit/emit-
+       common.c, src/vm/jit/linenumbertable.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/patcher-common.c,
+       src/vm/jit/s390/codegen.c, src/vm/properties.c: Use normal list
+       functions instead of the unsynced ones.
+       [0795aaaa726c]
+
+2008-03-22  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/cfg.c:
+       * src/vm/jit/cfg.c (cfg_build): Fixed off by one in predecessorcount
+       for exception handler blocks. See #53.
+       [2065c6bdf8b7]
+
+2008-03-21  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * .hgignore, configure.ac, src/vm/array.c,
+       tests/regression/Makefile.am, tests/regression/bugzilla/All.java,
+       tests/regression/bugzilla/Makefile.am,
+       tests/regression/bugzilla/PR52.java:
+       Fixes PR52.
+       * src/vm/array.c (array_objectarray_element_set): Use
+       builtin_canstore.
+
+       * .hgignore (tests/regression/assertion/*.class)
+       (tests/regression/assertion/packagetest/*.class)
+       (tests/regression/bugzilla/*.class): Added.
+       * configure.ac (AC_CONFIG_FILES): Added
+       tests/regression/bugzilla/Makefile.
+       * tests/regression/Makefile.am (SUBDIRS): Added bugzilla.
+       * tests/regression/bugzilla/All.java: New file.
+       * tests/regression/bugzilla/Makefile.am: Likewise.
+       * tests/regression/bugzilla/PR52.java: Likewise.
+       [a5fe9a36676e]
+
+2008-03-20  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/sun/jvm.c, src/vm/array.c:
+       * src/vm/array.c (array_length_get): Removed
+       IllegalArgumentException check for size.
+       * src/native/vm/sun/jvm.c (JVM_NewMultiArray): Explicitely check for
+       exceptions.
+       [c6ca807dc249]
+
+       * src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Method.c, src/vm/access.c,
+       src/vm/access.h:
+       * src/vm/access.c (access_check_field): Changed signature, use
+       stacktrace_get_caller_class. (access_check_method): Likewise.
+       * src/vm/access.h: Likewise.
+       * src/native/vm/gnu/java_lang_reflect_Field.c (_field_access_check):
+       Adapted access_check_field call.
+       * src/native/vm/java_lang_reflect_Constructor.c (newInstance):
+       Likewise.
+       * src/native/vm/java_lang_reflect_Method.c (invoke): Likewise.
+       [b4a54e5c1918]
+
+       * src/vm/array.c:
+       * src/vm/array.c (array_element_get): Do a null-pointer check.
+       (array_element_primitive_get): Likewise.
+       (array_element_primitive_set): Likewise.
+       (array_objectarray_element_set): Check if the object can be stored
+       in the array.
+       [5054ec21e133]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_NewArray): Check for error on
+       primitive_arrayclass_get_by_name. (JVM_NewMultiArray): Check for
+       error on array_length_get.
+       [7d1278cb4b5c]
+
+       * src/vm/array.c:
+       * src/vm/array.c (array_##name##array_element_get): Fixed
+       ArrayIndexOutOfBoundsException check.
+       (array_objectarray_element_get): Likewise.
+       (array_##name##array_element_set): Likewise.
+       (array_objectarray_element_set): Likewise.
+       [8dd39f5428c8]
+
+       * src/vm/array.c:
+       * src/vm/array.c (array_length_get): Check length and thrown an
+       exception in case.
+       [73b479b0dc93]
+
+       * src/vm/primitive.c:
+       * src/vm/primitive.c (primitive_unbox): Check for NULL values.
+       [868526f93774]
+
+       * src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/sun/jvm.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/stacktrace.h, src/vm/vm.c, src/vmcore/method.c,
+       src/vmcore/method.h, src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/vm/jit/stacktrace.c [ENABLE_JAVASE]
+       (stacktrace_get_caller_class): New function.
+       * src/vm/jit/stacktrace.h: Likewise.
 
-       * src/vm/vm.c (vm_create) [ENABLE_STATISTICS]: #ifdef opt_stat.
+       * src/native/vm/gnu/gnu_classpath_VMStackWalker.c (getCallingClass):
+       Use stacktrace_get_caller_class. (getCallingClassLoader): Likewise.
+       (firstNonNullClassLoader): Use stacktrace_first_nonnull_classloader.
 
-2007-02-13 00:37  twisti
+       * src/native/vm/sun/jvm.c (JVM_GetCallerClass): Use
+       stacktrace_get_caller_class.
 
-       * src/vm/vm.c (vm_create): Set opt_stat also true for -verbose:memory.
-       * src/mm/memory.c [ENABLE_THREADS] (threads/threads-common.h): Added.
-       (memory_thread): Call statistics_print_memory_usage.
+       * src/vm/vm.c (vm_create): Call method_init.
 
-2007-02-13 00:17  twisti
+       * src/vmcore/method.c (method_java_lang_reflect_Method_invoke): New
+       global variable. (method_init): New function.
+       * src/vmcore/method.h: Likewise.
 
-       * src/vm/jit/optimizing/profile.c (native/jni.h): Removed.
-       (native/include/java_lang_Thread.h): Likewise.
-       (native/include/java_lang_VMThread.h): Likewise.
-       (threads/threads-common.h): Added.
-       (thread_profile): Changed type to threadobject.
-       (profile_start_thread): Use threads_create_thread.
-       * src/vm/jit/optimizing/recompile.c: Likewise.
-       * src/vm/signal.c: Likewise.
-       * src/vm/finalizer.c: Likewise.
-       
-       * src/vm/jit/asmpart.h (threads/native/critical.h): Removed.
-       (threads/critical.h): Added.
-       
-       * src/vmcore/options.c (opt_verbosememory): Added.
-       * src/vmcore/options.h: Likewise.
-       
-       * src/vm/vm.c (XXusage): Added -verbose:memory.
-       (vm_create): Likewise. Start memory thread.
-       
-       * src/cacao/Makefile.am (THREAD_LIB): Changed to
-       $(top_builddir)/src/threads/libthreads.la.
-       
-       * src/mm/memory.c [ENABLE_THREADS] (thread_memory): Added.
-       [ENABLE_THREADS] (memory_thread): New function.
-       [ENABLE_THREADS] (memory_start_thread): Likewise.
-       * src/mm/memory.h [ENABLE_THREADS] (memory_start_thread): Added.
-       
-       * src/threads/native/critical.c: Removed.
-       * src/threads/native/critical.h: Likewise.
-       * src/threads/critical.c: Added.
-       * src/threads/critical.h: Likewise.
-       
-       * src/threads/threads-common.c: New file.
+       * src/vmcore/utf8.c (utf_invoke): New global variable.
+       * src/vmcore/utf8.h: Likewise.
+       [fd282c9caa0b]
+
+       * src/vm/jit/trace.c:
+       * src/vm/jit/trace.c (trace_java_call_print_argument): Pass
+       methodinfo, added sun.misc.Unsafe check. (trace_java_call_enter,
+       trace_java_call_exit): Pass methodinfo to
+       trace_java_call_print_argument.
+       [b6cdad87ff4c]
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (putIntVolatile): Implemented.
+       (putLongVolatile): Likewise. (putOrderedObject): Likewise.
+       (putOrderedInt): Likewise. (putOrderedLong): Likewise.
+       (UNSAFE_GET_VOLATILE): Added macro. (UNSAFE_PUT_VOLATILE): Likewise.
+       (getIntVolatile): Use UNSAFE_GET_VOLATILE. (getLongVolatile
+       [10f08de2a96c]
+
+       * src/vm/jit/trace.c:
+       * src/vm/jit/trace.c (trace_java_call_exit): Workaround for
+       sun.misc.Unsafe.staticFieldBase().
+       [08b89131a6f0]
+
+2008-03-19  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/lib/Makefile.am,
+       src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java,
+       src/lib/gnu/gnu/classpath/VMStackWalker.java,
+       src/lib/gnu/gnu/classpath/VMSystemProperties.java,
+       src/lib/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java,
+       src/lib/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/lib/gnu/java/lang/VMClassLoader.java,
+       src/lib/gnu/java/lang/VMString.java,
+       src/lib/gnu/java/lang/VMThread.java,
+       src/lib/gnu/java/lang/VMThrowable.java,
+       src/lib/gnu/java/lang/reflect/Constructor.java,
+       src/lib/gnu/java/lang/reflect/Field.java,
+       src/lib/gnu/java/lang/reflect/Method.java,
+       src/lib/gnu/java/security/VMAccessController.java,
+       src/lib/gnu/sun/misc/Unsafe.java,
+       src/lib/gnu/sun/reflect/ConstantPool.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationType.java, src/lib/gnu/
+       sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, sr
+       c/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProx
+       y.java, src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java, src/
+       lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java,
+       src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h,
+       tests/threadInterrupt.java:
+       Merging 7971:887db7d64bc9 with 7970:21b063622472.
+       [d870367cbe49]
+
+       * src/vm/jit/cfg.c, src/vm/jit/jit.c, src/vm/jit/optimizing/ssa3.c,
+       src/vm/jit/stack.c:
+       * src/vm/jit/cfg.c (cfg_build): Support for strange basicblocks,
+       where an IF can be followed by a NOP and GOTO.
+       * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_SSA]: Adapted for
+       changes.
+       * src/vm/jit/optimizing/ssa3.c: Changed a lot.
+       * src/vm/jit/stack.c (stack_reach_next_block) [STACK_VERBOSE]: More
+       verbosity to identify basicblocks where an IF can be followed by a
+       GOTO.
+       [887db7d64bc9]
+
+2008-03-19  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/native/generic-primitives.h, src/vm/jit/alpha/machine-
+       instr.h, src/vm/jit/arm/machine-instr.h, src/vm/jit/i386/machine-
+       instr.h, src/vm/jit/m68k/machine-instr.h, src/vm/jit/mips/machine-
+       instr.h, src/vm/jit/powerpc/machine-instr.h, src/vm/jit/powerpc64
+       /machine-instr.h, src/vm/jit/s390/machine-instr.h,
+       src/vm/jit/sparc64/machine-instr.h, src/vm/jit/x86_64/machine-
+       instr.h:
+       * src/threads/native/generic-primitives.h
+       (MEMORY_BARRIER_BEFORE_ATOMIC): Removed.
+       * src/vm/jit/alpha/machine-instr.h, src/vm/jit/arm/machine-instr.h,
+       src/vm/jit/i386/machine-instr.h, src/vm/jit/m68k/machine-instr.h,
+       src/vm/jit/mips/machine-instr.h, src/vm/jit/powerpc/machine-instr.h,
+       src/vm/jit/powerpc64/machine-instr.h, src/vm/jit/s390/machine-
+       instr.h, src/vm/jit/sparc64/machine-instr.h, src/vm/jit/x86_64
+       /machine-instr.h: Likewise.
+       [21b063622472]
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (setMemory): Fixed compiler
+       warning on 32-bit architectures. (copyMemory): Likewise.
+       [a7e35749c949]
+
+       * src/threads/native/generic-primitives.h,
+       src/threads/native/threads.c, src/vm/jit/alpha/machine-instr.h,
+       src/vm/jit/arm/machine-instr.h, src/vm/jit/i386/machine-instr.h,
+       src/vm/jit/mips/machine-instr.h, src/vm/jit/powerpc/machine-instr.h,
+       src/vm/jit/s390/machine-instr.h, src/vm/jit/sparc64/machine-instr.h,
+       src/vm/jit/x86_64/machine-instr.h:
+       * src/threads/native/generic-primitives.h (atomic_add): Removed.
+       * src/threads/native/threads.c [USE_FAKE_ATOMIC_INSTRUCTIONS]
+       (_atomic_add_lock): Removed.
+       * src/vm/jit/alpha/machine-instr.h (atomic_add): Removed.
+       * src/vm/jit/arm/machine-instr.h, src/vm/jit/i386/machine-instr.h,
+       src/vm/jit/mips/machine-instr.h, src/vm/jit/powerpc/machine-instr.h,
+       src/vm/jit/s390/machine-instr.h, src/vm/jit/sparc64/machine-instr.h,
+       src/vm/jit/x86_64/machine-instr.h: Likewise.
+       [c2f69cf3790e]
+
+2008-03-18  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c:
+       * src/native/vm/gnu/java_lang_VMThread.c (interrupt): Use
+       thread_get_thread. (isInterrupted): Likewise. (nativeSetPriority):
+       Likewise. (getState): Likewise.
+       * src/native/vm/sun/jvm.c (threads/threadlist.h): Removed.
+       (JVM_IsThreadAlive): Use thread_get_thread. (JVM_SetThreadPriority):
+       Likewise. (JVM_Interrupt): Implemented. (JVM_IsInterrupted): Use
+       thread_get_thread.
+       [056edaebc79b]
+
+       * src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/threads-common.c (thread_get_thread): New function.
        * src/threads/threads-common.h: Likewise.
-       * src/threads/Makefile.am (AM_CPPFLAGS): Added.
-       (LIB): Likewise.
-       [ENABLE_THREADS] (THREAD_LIB): Likewise.
-       (noinst_LTLIBRARIES): Likewise.
-       (libthreads_la_SOURCES): Likewise.
-       (libthreads_la_LIBADD): Likewise.
-       
-       * src/threads/.cvsignore: New file.
-       
-       * src/threads/native/threads.c (include "threads/threads-common.h):
-       Added.
-       * src/threads/native/threads.h (MIN_PRIORITY, NORM_PRIORITY)
-       (MAX_PRIORITY): Removed.
-       
-       * src/threads/native/Makefile.am (noinst_LTLIBRARIES): Changed to
-       libthreadsposix.la.
-
-2007-02-13 00:05  twisti
-
-       * src/vmcore/annotation.c
-       (annotation_load_attribute_runtimevisibleannotations): Renamed aa to
-       annotations.
-
-2007-02-12 13:28  twisti
-
-       * src/vm/jit/emit-common.h (_EMIT_H): Renamed to _EMIT_COMMON_H.
-       (config.h): Added.
-       (vm/jit/codegen-common.h): Likewise.
-       [SIZEOF_VOID_P == 4] (IS_IMM16): Added.
-
-2007-02-12 10:43  twisti
-
-       * src/vm/jit/alpha/md-abi.c (regs): Renamed to
-       abi_registers_integer_name.
-       (md_param_alloc_native): New function.
-       
-       * src/vm/jit/alpha/disass.c (vm/jit/abi.h): Added.
-       (disassinstr): Replaced regs with abi_registers_integer_name.
-
-2007-02-12 00:34  twisti
-
-       * src/vm/jit/i386/md-abi.c (regs): Renamed to
-       abi_registers_integer_name.
-       (md_param_alloc_native): New function.
-
-2007-02-11 22:17  twisti
-
-       * src/vm/jit/arm/disass.c (stdio.h): Added.
-       (regs): Removed.
-       * src/vm/jit/arm/md-abi.c (abi_registers_integer_name): Added.
-       (md_param_alloc_native): Likewise.
-
-2007-02-11 21:44  twisti
-
-       * src/vm/jit/codegen-common.c (vm/jit/abi.h): Added.
-
-2007-02-11 21:41  twisti
-
-       * src/vm/jit/disass.h (regs): Removed.
-       
-       * src/vm/jit/show.c (vm/jit/abi.h): Added.
-       (show_allocation): Renamed regs to abi_registers_integer_name.
-
-2007-02-11 21:39  twisti
-
-       * src/vm/jit/codegen-common.c (codegen_createnativestub): Call
-       md_param_alloc_native instead of md_param_alloc.
-       
-       * src/vm/jit/powerpc/linux/md-abi.c (assert.h): Added.
-       (regs): Renamed to abi_registers_integer_name.
-       (abi_registers_integer_argument, abi_registers_integer_saved)
-       (abi_registers_integer_temporary, abi_registers_float_name)
-       (abi_registers_float_argument, abi_registers_float_saved)
-       (abi_registers_float_temporary): Added.
-       (md_param_alloc): Reformatted.
-       (md_param_alloc_native): New function.
-
-2007-02-11 21:24  twisti
-
-       * src/vmcore/descriptor.c (vm/jit/abi.h): Added.
-       * src/vmcore/descriptor.h (md_param_alloc): Removed.
-       
-       * src/vm/jit/abi.h (abi_registers_integer_name)
-       (abi_registers_integer_argument, abi_registers_integer_saved)
-       (abi_registers_integer_temporary, abi_registers_float_name)
-       (abi_registers_float_argument, abi_registers_float_saved)
-       (abi_registers_float_temporary): Added.
-       (md_param_alloc): Likewise.
-       (md_param_alloc_native): Likewise.
-
-2007-02-11 21:22  twisti
-
-       * src/native/native.c (native_get_returntype): Removed.
-       * src/native/native.h: Likewise.
-       
-       * src/native/vm/gnu/java_lang_reflect_Method.c (getReturnType): Moved
-       code from native_get_returntype.
-
-2007-02-11 20:16  twisti
-
-       * src/vm/jit/codegen-common.c (vm/jit/md.h): Added.
-
-2007-02-11 20:10  twisti
-
-       * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Keep stack 8-byte
-       aligned.
-       (emit_verbosecall_exit): Added comment.
-       * src/vm/jit/arm/asmpart.S (asm_call_jit_compiler): Keep stack 8-byte
-       aligned.
-
-2007-02-11 17:52  pm
+       [ae7763ff1c13]
+
+       * src/classes/gnu/sun/misc/Unsafe.java,
+       src/native/vm/sun_misc_Unsafe.c:
+       * src/classes/gnu/sun/misc/Unsafe.java: Imported the OpenJDK 6
+       version.
+       * src/native/vm/sun_misc_Unsafe.c (vmcore/system.h): Added.
+       (setMemory, copyMemory): Changed to be OpenJDK 6 compatible.
+       [162965872cfb]
+
+       * contrib/setenvinstalled.in, contrib/setenvsource.in:
+       * contrib/setenvinstalled.in: Updated BOOTCLASSPATH.
+       * contrib/setenvsource.in: Likewise.
+       [ccd8958ff259]
+
+       * .hgignore:
+       * .hgignore: Removed src/lib/classes/ and src/lib/vm.zip, added
+       src/classes/classes/ and src/classes/vm.zip.
+       [3b80e57be422]
+
+       * configure.ac, m4/classpath.m4, src/Makefile.am,
+       src/classes/Makefile.am,
+       src/classes/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java,
+       src/classes/gnu/gnu/classpath/VMStackWalker.java,
+       src/classes/gnu/gnu/classpath/VMSystemProperties.java,
+       src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java,
+       src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/classes/gnu/java/lang/VMClassLoader.java,
+       src/classes/gnu/java/lang/VMString.java,
+       src/classes/gnu/java/lang/VMThread.java,
+       src/classes/gnu/java/lang/reflect/Constructor.java,
+       src/classes/gnu/java/lang/reflect/Field.java,
+       src/classes/gnu/java/lang/reflect/Method.java,
+       src/classes/gnu/java/security/VMAccessController.java,
+       src/classes/gnu/sun/misc/Unsafe.java,
+       src/classes/gnu/sun/reflect/ConstantPool.java,
+       src/classes/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/classes/gnu/sun/reflect/annotation/AnnotationType.java, src/clas
+       ses/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.
+       java, src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentE
+       xceptionProxy.java,
+       src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java, src/clas
+       ses/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java,
+       src/lib/Makefile.am,
+       src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java,
+       src/lib/gnu/gnu/classpath/VMStackWalker.java,
+       src/lib/gnu/gnu/classpath/VMSystemProperties.java,
+       src/lib/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java,
+       src/lib/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/lib/gnu/java/lang/VMClassLoader.java,
+       src/lib/gnu/java/lang/VMString.java,
+       src/lib/gnu/java/lang/VMThread.java,
+       src/lib/gnu/java/lang/reflect/Constructor.java,
+       src/lib/gnu/java/lang/reflect/Field.java,
+       src/lib/gnu/java/lang/reflect/Method.java,
+       src/lib/gnu/java/security/VMAccessController.java,
+       src/lib/gnu/sun/misc/Unsafe.java,
+       src/lib/gnu/sun/reflect/ConstantPool.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationType.java, src/lib/gnu/
+       sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, sr
+       c/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProx
+       y.java, src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java, src/
+       lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java,
+       src/native/include/Makefile.am:
+       * configure.ac (AC_CONFIG_FILES): Removed src/lib/Makefile, added
+       src/classes/Makefile.
+       * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Fixed
+       BOOTCLASSPATH.
+       * src/Makefile.am (DIST_SUBDIRS): Removed lib, added classes.
+       (SUBDIRS): Likewise.
 
-       * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframeinfo):
-       On s390 get return address from stack also in leaf methods.
-       * src/vm/jit/codegen-common.c (methodtree_comparator): On s390
-       compare addresses as 31 bit integers.
-       * src/vm/jit/s390/md.c,
-       src/vm/jit/s390/codegen.c,
-       src/vm/jit/s390/codegen.h,
-       src/vm/jit/s390/patcher.c,
-       src/vm/jit/s390/asmpart.S: Changed a lot, working on s390 port.
+       * src/classes/Makefile.am,
+       src/classes/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java,
+       src/classes/gnu/gnu/classpath/VMStackWalker.java,
+       src/classes/gnu/gnu/classpath/VMSystemProperties.java,
+       src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java,
+       src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/classes/gnu/java/lang/VMClassLoader.java,
+       src/classes/gnu/java/lang/VMString.java,
+       src/classes/gnu/java/lang/VMThread.java,
+       src/classes/gnu/java/lang/reflect/Constructor.java,
+       src/classes/gnu/java/lang/reflect/Field.java,
+       src/classes/gnu/java/lang/reflect/Method.java,
+       src/classes/gnu/java/security/VMAccessController.java,
+       src/classes/gnu/sun/misc/Unsafe.java,
+       src/classes/gnu/sun/reflect/ConstantPool.java,
+       src/classes/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/classes/gnu/sun/reflect/annotation/AnnotationType.java, src/clas
+       ses/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.
+       java, src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentE
+       xceptionProxy.java,
+       src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java, src/clas
+       ses/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java,
+       src/native/include/Makefile.am: Moved from lib.
+
+       * src/lib/Makefile.am,
+       src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java,
+       src/lib/gnu/gnu/classpath/VMStackWalker.java,
+       src/lib/gnu/gnu/classpath/VMSystemProperties.java,
+       src/lib/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java,
+       src/lib/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/lib/gnu/java/lang/VMClassLoader.java,
+       src/lib/gnu/java/lang/VMString.java,
+       src/lib/gnu/java/lang/VMThread.java,
+       src/lib/gnu/java/lang/reflect/Constructor.java,
+       src/lib/gnu/java/lang/reflect/Field.java,
+       src/lib/gnu/java/lang/reflect/Method.java,
+       src/lib/gnu/java/security/VMAccessController.java,
+       src/lib/gnu/sun/misc/Unsafe.java,
+       src/lib/gnu/sun/reflect/ConstantPool.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationType.java, src/lib/gnu/
+       sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, sr
+       c/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProx
+       y.java, src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java, src/
+       lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java:
+       Moved to lib.
+       [79be8092620d]
+
+       * m4/classpath.m4, tests/regression/Makefile.am,
+       tests/regression/assertion/Makefile.am,
+       tests/regression/codepatching/Makefile.am,
+       tests/regression/jasmin/Makefile.am,
+       tests/regression/native/Makefile.am,
+       tests/regression/resolving/Makefile.am:
+       * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Set
+       BOOTCLASSPATH for Makefiles.
+       * tests/regression/Makefile.am,
+       tests/regression/assertion/Makefile.am,
+       tests/regression/codepatching/Makefile.am,
+       tests/regression/jasmin/Makefile.am,
+       tests/regression/native/Makefile.am,
+       tests/regression/resolving/Makefile.am (BOOTCLASSPATH): Removed.
+       [c8c412f3563d]
+
+2008-03-17  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/stacktrace.c:
+       * Merged with 60f051a3c5ae.
+       [66c52d0ae7d3]
+
+       * * Merged with b78ab2bd233a.
+       [60f051a3c5ae]
+
+       * src/vm/jit/m68k/md.h:
+       * src/vm/jit/m68k/md.h: Replaced codegen_get_pv_from_pc with
+       methodtree_find.
+       [17f63c532b66]
+
+       * src/vm/jit/intrp/asmpart.c:
+       * src/vm/jit/intrp/asmpart.c: Replaced codegen_get_pv_from_pc with
+       methodtree_find.
+       [b78ab2bd233a]
+
+       * src/vm/jit/s390/md.c, src/vm/jit/s390/md.h:
+       * src/vm/jit/s390/md.c: Replaced codegen_get_pv_from_pc with
+       methodtree_find.
+       * src/vm/jit/s390/md.h: Likewise.
+       [ba13719a1aab]
+
+       * src/vm/jit/methodtree.c:
+       * src/vm/jit/methodtree.c (threads/threads-common.h): Added.
+       (methodtree_find): Removed unnecessary assert.
+       [929aa234977f]
+
+       * src/vm/jit/i386/asmpart.S, src/vm/jit/i386/cygwin/md-asm.h,
+       src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/i386/md.h:
+       * src/vm/jit/i386/asmpart.S: Replaced codegen_get_pv_from_pc with
+       methodtree_find.
+       * src/vm/jit/i386/cygwin/md-asm.h src/vm/jit/i386/darwin/md-asm.h,
+       src/vm/jit/i386/md.h: Likewise.
+       [726425cd358a]
+
+2008-03-13  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/Makefile.am, src/vm/jit/code.c, src/vm/jit/codegen-
+       common.c, src/vm/jit/codegen-common.h, src/vm/jit/methodtree.c,
+       src/vm/jit/methodtree.h, src/vm/jit/optimizing/profile.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/md.h, src/vm/signal.c, src/vm/vm.c:
+       * src/vm/jit/methodtree.c: New file.
+       * src/vm/jit/methodtree.h: Likewise.
+       * src/vm/jit/Makefile.am (libjit_la_SOURCES): Added methodtree.[ch].
+
+       * src/vm/jit/codegen-common.c (methodtree): Removed. (codegen_init):
+       Removed methodtree stuff. (methodtree_comparator): Removed.
+       (codegen_insertmethod): Likewise. (codegen_get_pv_from_pc):
+       Likewise. (codegen_get_pv_from_pc_nocheck): Likewise.
+       (codegen_finish): Call methodtree_insert.
+       * src/vm/jit/codegen-common.h (methodtree_element): Removed.
+       (codegen_insertmethod): Likewise. (codegen_get_pv_from_pc):
+       Likewise. (codegen_get_pv_from_pc_nocheck): Likewise.
+
+       * src/vm/vm.c (vm_create): Call methodtree_init.
+
+       * src/vm/jit/code.c, src/vm/jit/optimizing/profile.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/md.h, src/vm/signal.c: Replaced
+       codegen_get_pv_from_pc* with methodtree_find*.
+       [414c5fa5f01e]
+
+       * src/vm/jit/inline/inline.c, src/vm/jit/inline/inline_debug.inc:
+       * src/vm/jit/inline/inline.c (inline_add_blocknr_reference):
+       Commented as it's not used and produces a compiler warning.
+       * src/vm/jit/inline/inline_debug.inc (debug_dump_inline_context):
+       Likewise.
+       [9c8901fcff0a]
+
+       * src/lib/Makefile.am, src/lib/gnu/java/lang/VMThrowable.java,
+       src/native/vm/gnu/java_lang_VMThrowable.c, src/vm/jit/stacktrace.c:
+       * src/lib/gnu/java/lang/VMThrowable.java: Removed, as the local
+       changes made years ago are not necessary.
+       * src/lib/Makefile.am (VM_JAVA_FILES_GNU): Removed
+       gnu/java/lang/VMThrowable.java.
+
+       * src/native/vm/gnu/java_lang_VMThrowable.c (fillInStackTrace): Use
+       vmdata instead of vmData. (getStackTrace): Likewise.
+       * src/vm/jit/stacktrace.c (stacktrace_print_exception)
+       [WITH_CLASSPATH_GNU]: Likewise.
+       [ac9fca996d5e]
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_detach_thread): Fixed
+       compiler warning.
+       [2f60b3f9a1da]
+
+       * src/vm/jit/alpha/linux/md-os.c:
+       * src/vm/jit/alpha/linux/md-os.c (md_replace_executionstate_read):
+       Renamed to md_executionstate_read.
+       (md_replace_executionstate_write): Renamed to
+       md_executionstate_write.
+       [190dab35c7f0]
+
+       * src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/jit/x86_64/linux/md-os.c (md_replace_executionstate_read):
+       Renamed to md_executionstate_read.
+       (md_replace_executionstate_write): Renamed to
+       md_executionstate_write.
+       [28eb425cbf17]
+
+       * src/vm/jit/executionstate.c, src/vm/jit/executionstate.h:
+       * src/vm/jit/executionstate.c: Fixed file comment.
+       * src/vm/jit/executionstate.h: Fixed copyright.
+       [d044bbdb3010]
+
+       * src/vm/jit/Makefile.am, src/vm/jit/executionstate.c,
+       src/vm/jit/executionstate.h, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/replace.c, src/vm/jit/replace.h:
+       * src/vm/jit/executionstate.c: New file.
+       * src/vm/jit/executionstate.h: Likewise.
+       * src/vm/jit/Makefile.am (libjit_la_SOURCES): Added
+       executionstate.[ch].
+
+       * src/vm/jit/replace.c (replace_executionstate_println): Moved to
+       executionstate.[ch]. (replace_sanity_check_read_write): Likewise.
+       * src/vm/jit/replace.h (executionstate_t): Likwise.
+       (replace_executionstate_println): Likewise.
+       (md_replace_executionstate_read): Likewise.
+       (md_replace_executionstate_write): Likewise.
+
+       * src/vm/jit/i386/linux/md-os.c (md_replace_executionstate_read):
+       Renamed to md_executionstate_read.
+       (md_replace_executionstate_write): Renamed to
+       md_executionstate_write.
+       [015609f9c237]
+
+       * src/vm/jit/alpha/codegen.c:
+       * src/vm/jit/alpha/codegen.c (codegen_emit): Added thread unsafe
+       comments.
+       [fe0f7708d735]
+
+       * src/threads/none/threads.h, src/threads/threads-common.h:
+       * src/threads/none/threads.h (threads_get_current_object): Changed
+       return type to java_handle_t.
+       * src/threads/threads-common.h: Likewise.
+       [ba1986e7117c]
 
-2007-02-11 10:15  michi
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (TRACEJVMCALLS): Changed to normal macro
+       instead of a variadic one.
+       [ac949484e6cd]
 
-       * src/vm/jit/replace.c: Fixed includes for options.h and classcache.h
-       headers.
-       * src/vm/jit/replace.h: Added forward typedef for rplalloc.
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (PRINTJVMWARNINGS): Changed to normal
+       macro instead of variadic. (JVM_GetStackTraceDepth): Fixed compiler
+       warning. (JVM_GetStackTraceElement): Likewise. (JVM_IsThreadAlive):
+       Likewise.
+       [4a49aeff7fd7]
 
-2007-02-11 09:21  michi
+       * src/native/localref.c:
+       * src/native/localref.c [!NDEBUG] (localref_check_uncleared): Fixed
+       compiler warning.
+       [4126ae263bbd]
 
-       * src/vm/jit/replace.h: Fixed include for method.h header.
+2008-03-12  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-02-11 00:02  twisti
+       * src/cacaoh/dummy.c, src/vm/jit/code.c, src/vm/jit/code.h,
+       src/vm/jit_interface.h, src/vmcore/method.c:
+       * src/vm/jit/code.c (code_find_codeinfo_for_pc): Use void* instead
+       of u1*. (code_find_codeinfo_for_pc_nocheck): Likewise.
+       (code_get_methodinfo_for_pv): Likewise.
+       * src/vm/jit/code.h: Likewise.
+       * src/cacaoh/dummy.c (vm/jit/code.h): Added.
+       (code_get_methodinfo_for_pv): Likewise.
+       * src/vm/jit_interface.h (code_get_methodinfo_for_pv): Removed.
+       * src/vmcore/method.c (vm/jit/code.h): Added.
+       [a2f65e9ce093]
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_GetDirectBufferAddress): Fixed compiler
+       warnings.
+       [42e52f1166c9]
 
-       * src/vm/jit/x86_64/emit.c (emit_verbosecall_enter): Renamed
-       builtin_trace_args to builtin_verbosecall_enter.
-       (builtin_verbosecall_exit): Renamed builtin_displaymethodstop to
-       builtin_verbosecall_exit and changed signature.
-       
-       * src/vm/jit/x86_64/md-abi.h (REG_FA0, REG_FA1): Added.
+       * src/threads/none/threads.h, src/threads/threads-common.c,
+       src/threads/threads-common.h, src/vm/jit/stacktrace.c,
+       src/vm/jit/stacktrace.h:
+       * src/threads/none/threads.h (threads_get_current_object): New
+       function. (threads_get_current_stackframeinfo): Fixed name to
+       threads_set_current_stackframeinfo.
 
-2007-02-10 19:06  twisti
+       * src/threads/threads-common.c (threads_get_current_object):
+       Removed.
+       * src/threads/threads-common.h (threads_get_current_object): New
+       function. (threads_get_current_object): Removed.
+
+       * src/vm/jit/stacktrace.c: Small fix.
+       * src/vm/jit/stacktrace.h [!ENABLE_THREADS]
+       (_no_threads_stackframeinfo): Added.
+       [2b9f0242d4f6]
+
+       * src/native/vm/reflect.c:
+       * src/native/vm/reflect.c (reflect_field_new): Fixed compiler
+       warnings. (reflect_method_new): Likewise.
+       [c71069a7c75a]
+
+       * src/vm/jit/code.c, src/vm/jit/code.h, src/vm/vm.c:
+       * src/vm/jit/code.c (code_init): Changed signature, use vm_abort
+       instead of assert.
+       * src/vm/jit/code.h (code_init): Change signature.
+       * src/vm/vm.c (vm_create): Call code_init.
+       [9f0c6db8a687]
+
+2008-03-12  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/threads/native/threads.c:
+       Oh no, it worketh!
+
+       * src/threads/native/threads.c: Include Boehm header on Darwin.
+       [ac7444e86ffc]
+
+2008-03-11  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * configure.ac, src/mm/boehm-gc/AmigaOS.c, src/mm/boehm-
+       gc/BCC_MAKEFILE, src/mm/boehm-gc/ChangeLog, src/mm/boehm-
+       gc/EMX_MAKEFILE, src/mm/boehm-gc/MacOS.c, src/mm/boehm-
+       gc/Makefile.am, src/mm/boehm-gc/Makefile.direct, src/mm/boehm-
+       gc/Makefile.dj, src/mm/boehm-gc/NT_MAKEFILE, src/mm/boehm-
+       gc/NT_STATIC_THREADS_MAKEFILE, src/mm/boehm-gc/NT_THREADS_MAKEFILE,
+       src/mm/boehm-gc/NT_X64_STATIC_THREADS_MAKEFILE, src/mm/boehm-
+       gc/OS2_MAKEFILE, src/mm/boehm-gc/PCR-Makefile, src/mm/boehm-
+       gc/README.QUICK, src/mm/boehm-gc/SMakefile.amiga, src/mm/boehm-
+       gc/WCC_MAKEFILE, src/mm/boehm-gc/allchblk.c, src/mm/boehm-
+       gc/alloc.c, src/mm/boehm-gc/autogen.sh, src/mm/boehm-gc/backgraph.c,
+       src/mm/boehm-gc/bdw-gc.pc.in, src/mm/boehm-gc/blacklst.c, src/mm
+       /boehm-gc/callprocs, src/mm/boehm-gc/checksums.c, src/mm/boehm-
+       gc/configure.ac, src/mm/boehm-gc/configure.in, src/mm/boehm-
+       gc/configure_atomic_ops.sh, src/mm/boehm-gc/cord/cord.am, src/mm
+       /boehm-gc/cord/de_win.ICO, src/mm/boehm-gc/cord/de_win.c, src/mm
+       /boehm-gc/darwin_stop_world.c, src/mm/boehm-gc/dbg_mlc.c, src/mm
+       /boehm-gc/digimars.mak, src/mm/boehm-gc/doc/Makefile.am, src/mm
+       /boehm-gc/doc/README, src/mm/boehm-gc/doc/README.Mac, src/mm/boehm-
+       gc/doc/README.changes, src/mm/boehm-gc/doc/README.darwin, src/mm
+       /boehm-gc/doc/README.environment, src/mm/boehm-gc/doc/README.linux,
+       src/mm/boehm-gc/doc/README.macros, src/mm/boehm-
+       gc/doc/README.solaris2, src/mm/boehm-gc/doc/README.win32, src/mm
+       /boehm-gc/doc/README.win64, src/mm/boehm-gc/doc/doc.am, src/mm
+       /boehm-gc/doc/gcdescr.html, src/mm/boehm-gc/doc/gcinterface.html,
+       src/mm/boehm-gc/doc/leak.html, src/mm/boehm-gc/doc/overview.html,
+       src/mm/boehm-gc/doc/porting.html, src/mm/boehm-gc/dyn_load.c, src/mm
+       /boehm-gc/finalize.c, src/mm/boehm-gc/gc.mak, src/mm/boehm-
+       gc/gc_cpp.cc, src/mm/boehm-gc/gc_dlopen.c, src/mm/boehm-
+       gc/gcc_support.c, src/mm/boehm-gc/gcj_mlc.c, src/mm/boehm-
+       gc/headers.c, src/mm/boehm-gc/if_mach.c, src/mm/boehm-
+       gc/if_not_there.c, src/mm/boehm-gc/include/Makefile.am, src/mm
+       /boehm-gc/include/gc.h, src/mm/boehm-gc/include/gc_alloc.h, src/mm
+       /boehm-gc/include/gc_allocator.h, src/mm/boehm-
+       gc/include/gc_config_macros.h, src/mm/boehm-gc/include/gc_cpp.h,
+       src/mm/boehm-gc/include/gc_gcj.h, src/mm/boehm-gc/include/gc_inl.h,
+       src/mm/boehm-gc/include/gc_inline.h, src/mm/boehm-
+       gc/include/gc_local_alloc.h, src/mm/boehm-gc/include/gc_mark.h,
+       src/mm/boehm-gc/include/gc_pthread_redirects.h, src/mm/boehm-
+       gc/include/gc_tiny_fl.h, src/mm/boehm-gc/include/gc_typed.h, src/mm
+       /boehm-gc/include/include.am, src/mm/boehm-
+       gc/include/new_gc_alloc.h, src/mm/boehm-
+       gc/include/private/dbg_mlc.h, src/mm/boehm-
+       gc/include/private/gc_hdrs.h, src/mm/boehm-
+       gc/include/private/gc_locks.h, src/mm/boehm-
+       gc/include/private/gc_pmark.h, src/mm/boehm-
+       gc/include/private/gc_priv.h, src/mm/boehm-
+       gc/include/private/gcconfig.h, src/mm/boehm-
+       gc/include/private/msvc_dbg.h, src/mm/boehm-
+       gc/include/private/pthread_support.h, src/mm/boehm-
+       gc/include/private/solaris_threads.h, src/mm/boehm-
+       gc/include/private/specific.h, src/mm/boehm-
+       gc/include/private/thread_local_alloc.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/AUTHORS, src/mm/boehm-
+       gc/libatomic_ops-1.2/COPYING, src/mm/boehm-
+       gc/libatomic_ops-1.2/ChangeLog, src/mm/boehm-
+       gc/libatomic_ops-1.2/INSTALL, src/mm/boehm-
+       gc/libatomic_ops-1.2/Makefile.am, src/mm/boehm-
+       gc/libatomic_ops-1.2/NEWS, src/mm/boehm-gc/libatomic_ops-1.2/README,
+       src/mm/boehm-gc/libatomic_ops-1.2/autogen.sh, src/mm/boehm-
+       gc/libatomic_ops-1.2/configure.ac, src/mm/boehm-
+       gc/libatomic_ops-1.2/doc/COPYING, src/mm/boehm-
+       gc/libatomic_ops-1.2/doc/LICENSING.txt, src/mm/boehm-
+       gc/libatomic_ops-1.2/doc/Makefile.am, src/mm/boehm-
+       gc/libatomic_ops-1.2/doc/README.txt, src/mm/boehm-
+       gc/libatomic_ops-1.2/doc/README_malloc.txt, src/mm/boehm-
+       gc/libatomic_ops-1.2/doc/README_stack.txt, src/mm/boehm-
+       gc/libatomic_ops-1.2/doc/README_win32.txt, src/mm/boehm-
+       gc/libatomic_ops-1.2/mkinstalldirs, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/Makefile.am, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/Makefile.msft, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops.c, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/Makefile.am, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/generalize-small.h, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/generalize-
+       small.template, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/generalize.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/Makefile.am, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/README, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/acquire_release_v
+       olatile.h, src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/
+       aligned_atomic_load_store.h, src/mm/boehm-gc/libatomic_ops-1.2/src/a
+       tomic_ops/sysdeps/all_acquire_release_volatile.h, src/mm/boehm-gc/li
+       batomic_ops-1.2/src/atomic_ops/sysdeps/all_aligned_atomic_load_store
+       .h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/all_atomic_load_store.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ao_t_is_int.h, src/mm
+       /boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/atomic_load_store.h,
+       src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/char_acquir
+       e_release_volatile.h, src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_o
+       ps/sysdeps/char_atomic_load_store.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/emul_cas.h, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/alpha.h,
+       src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/arm.h,
+       src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/cris.h,
+       src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/hppa.h,
+       src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/ia64.h,
+       src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/m68k.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/powerpc.h, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/s390.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/sparc.h, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86.h, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86_64.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/generic_pthread.h,
+       src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc/hppa.h,
+       src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc/ia64.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc/powerpc.h, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc/ia64.h,
+       src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/int_acquire
+       _release_volatile.h, src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_op
+       s/sysdeps/int_aligned_atomic_load_store.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/int_atomic_load_store.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc/x86.h, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc/x86_64.h,
+       src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ordered.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ordered_except_wr.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/read_ordered.h, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/short_acquire_rel
+       ease_volatile.h, src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sy
+       sdeps/short_aligned_atomic_load_store.h, src/mm/boehm-gc/libatomic_o
+       ps-1.2/src/atomic_ops/sysdeps/short_atomic_load_store.h, src/mm
+       /boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/standard_ao_double_t.h,
+       src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc/sparc.S, src/mm
+       /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc/sparc.h,
+       src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/test_and_se
+       t_t_is_ao_t.h, src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysd
+       eps/test_and_set_t_is_char.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops_malloc.c, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops_malloc.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops_stack.c, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops_stack.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/src/atomic_ops_sysdeps.S, src/mm/boehm-
+       gc/libatomic_ops-1.2/tests/Makefile.am, src/mm/boehm-
+       gc/libatomic_ops-1.2/tests/list_atomic.c, src/mm/boehm-
+       gc/libatomic_ops-1.2/tests/list_atomic.template, src/mm/boehm-
+       gc/libatomic_ops-1.2/tests/run_parallel.inc, src/mm/boehm-
+       gc/libatomic_ops-1.2/tests/test_atomic.c, src/mm/boehm-
+       gc/libatomic_ops-1.2/tests/test_atomic.template, src/mm/boehm-
+       gc/libatomic_ops-1.2/tests/test_atomic_include.h, src/mm/boehm-
+       gc/libatomic_ops-1.2/tests/test_malloc.c, src/mm/boehm-
+       gc/libatomic_ops-1.2/tests/test_stack.c, src/mm/boehm-gc/libtool.m4,
+       src/mm/boehm-gc/ltconfig, src/mm/boehm-gc/mach_dep.c, src/mm/boehm-
+       gc/malloc.c, src/mm/boehm-gc/mallocx.c, src/mm/boehm-gc/mark.c,
+       src/mm/boehm-gc/mark_rts.c, src/mm/boehm-gc/misc.c, src/mm/boehm-
+       gc/mkinstalldirs, src/mm/boehm-gc/msvc_dbg.c, src/mm/boehm-
+       gc/new_hblk.c, src/mm/boehm-gc/obj_map.c, src/mm/boehm-gc/os_dep.c,
+       src/mm/boehm-gc/pc_excludes, src/mm/boehm-gc/pcr_interface.c, src/mm
+       /boehm-gc/powerpc_darwin_mach_dep.s, src/mm/boehm-
+       gc/pthread_stop_world.c, src/mm/boehm-gc/pthread_support.c, src/mm
+       /boehm-gc/ptr_chck.c, src/mm/boehm-gc/real_malloc.c, src/mm/boehm-
+       gc/reclaim.c, src/mm/boehm-gc/setjmp_t.c, src/mm/boehm-
+       gc/solaris_pthreads.c, src/mm/boehm-gc/solaris_threads.c, src/mm
+       /boehm-gc/sparc_mach_dep.S, src/mm/boehm-gc/specific.c, src/mm
+       /boehm-gc/stubborn.c, src/mm/boehm-gc/tests/leak_test.c, src/mm
+       /boehm-gc/tests/middle.c, src/mm/boehm-gc/tests/test.c, src/mm
+       /boehm-gc/tests/test_cpp.cc, src/mm/boehm-gc/tests/tests.am, src/mm
+       /boehm-gc/tests/thread_leak_test.c, src/mm/boehm-
+       gc/tests/trace_test.c, src/mm/boehm-gc/thread_local_alloc.c, src/mm
+       /boehm-gc/threadlibs.c, src/mm/boehm-gc/typd_mlc.c, src/mm/boehm-
+       gc/version.h, src/mm/boehm-gc/win32_threads.c, src/mm/boehm.c:
+       Imported and merged Boehm GC 7.0
+       [85f594678514]
+
+       * src/mm/boehm.c:
+       * src/mm/boehm.c: Define GC_DARWIN_THREADS.
+       [6342939f5ec7]
+
+       * Merge -> trunk
+       [785419807437]
+
+2008-03-05  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/mm/boehm-gc/BCC_MAKEFILE, src/mm/boehm-gc/digimars.mak:
+       * src/mm/boehm-gc/BCC_MAKEFILE, src/mm/boehm-gc/digimars.mak:
+       unix2dos'ed the way they were in gc6.8.
+       [70786a061a3c]
+
+2008-03-11  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_thread_start_internal): Code
+       reworked. (threads_thread_start): Likewise.
+       [28798cbb3598]
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c [ENABLE_JAVASE] (threadgroup_system,
+       (threadgroup_main): New variables. (threads_init): Call
+       thread_create_initial_threadgroups and thread_create_initial_thread.
+       (thread_create_initial_threadgroups): New function.
+       (thread_create_initial_thread): Likewise.
+       (threads_get_current_object): Removed empty-group hack.
+       [4587829c96e0]
+
+       * src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/vmcore/utf8.c
+       (utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V): Added.
+       * src/vmcore/utf8.h: Likewise.
+       [11c519559b6e]
+
+       * src/native/jni.c, src/vm/vm.c, src/vm/vm.h:
+       * src/vm/vm.c (vm_created): Added. (vm_create): Set vm_created.
+       (vm_destroy): Unset vm_created.
+       * src/vm/vm.h: (vm_created): Added.
+       * src/native/jni.c (_Jv_JNI_DestroyJavaVM): Added vm_created check.
+       (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_GetEnv): Likewise.
+       (_Jv_JNI_AttachCurrentThreadAsDaemon): Likewise.
+       [df45c6a94042]
+
+       * src/cacaoh/cacaoh.c, src/vm/vm.c, src/vmcore/utf8.c,
+       src/vmcore/utf8.h:
+       * src/vmcore/utf8.c (utf_main): Added. (utf8_init): Changed
+       signature.
+       * src/vmcore/utf8.h: Likewise.
+       * src/cacaoh/cacaoh.c (main): Removed return value check for
+       utf8_init.
+       * src/vm/vm.c (vm_create): Likewise.
+       [b02fb9ce8032]
+
+       * src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h,
+       src/vm/vm.c:
+       * src/threads/native/threads.c (method_thread_init): Removed.
+       (threads_init): Removed. (threads_impl_init): New function.
+       (threads_attach_current_thread): Renamed method_thread_init to
+       thread_method_init.
+       * src/threads/native/threads.h (threads_init): Removed
+
+       * src/threads/threads-common.c (native/native.h): Added.
+       [ENABLE_JAVASE] (native/include/java_lang_ThreadGroup.h): Likewise.
+       [WITH_CLASSPATH_GNU] (native/include/java_lang_Throwable.h):
+       Removed. (toolbox/list.h): Likewise. (vm/exceptions.h): Added.
+       (vmcore/method.h): Likewise. (thread_method_init): Likewise.
+       (threads_init): New function.
+       * src/threads/threads-common.h (thread_method_init): Added.
+       (threads_init): Likewise. (threads_impl_init): Likewise.
+
+       * src/vm/vm.c (vm_create) [ENABLE_THREADS]: Removed return value
+       check for threads_init.
+       [a55398aa6b7a]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_create) [!NDEBUG]: Removed conditional, as we want
+       the config for production builds too.
+       [634e86c4c855]
+
+2008-03-10  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/native/Makefile.am, src/threads/native/lock.c,
+       src/threads/native/threadlist-posix.c, src/threads/native/threads.c,
+       src/threads/threadlist.c, src/threads/threadlist.h, src/threads
+       /threads-common.c, src/threads/threads-common.h,
+       src/vm/jit/optimizing/profile.c:
+       * src/threads/native/threadlist-posix.c: New file.
+       * src/threads/native/Makefile.am (libthreadsposix_la_SOURCES): Added
+       threadlist-posix.c.
+
+       * src/threads/native/threads.c (mutex_threads_list): Removed.
+       (threads_impl_preinit): Removed mutex_threads_list initialization.
+       (threads_list_lock, threads_list_unlock): Removed.
+
+       * src/threads/threadlist.c (threadlist_init): Call
+       threadlist_impl_init.
+
+       * src/threads/threadlist.h (threadlist_impl_init, threadlist_lock)
+       (threadlist_unlock): Added.
+
+       * src/threads/threads-common.h (threads_list_lock)
+       (threads_list_unlock): Removed.
+
+       * src/threads/native/lock.c, src/threads/threads-common.c,
+       src/vm/jit/optimizing/profile.c: Use new threadlist_{lock,unlock}
+       functions.
+       [f47de576dda1]
 
-       * src/vm/builtin.c (builtin_trace_args): Renamed to
-       builtin_verbosecall_enter.
-       (builtin_trace_args): Renamed to builtin_verbosecall_enter.
-       (builtin_displaymethodstop): Renamed to builtin_verbosecall_exit and
-       changed signature.
-       * src/vm/builtin.h: Likewise.
-       
-       * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Likewise.
-       (builtin_verbosecall_exit): Likewise.
-       * src/vm/jit/alpha/emit.c: Likewise.
-       * src/vm/jit/i386/emit.c: Likewise.
-       * src/vm/jit/mips/emit.c: Likewise.
-       * src/vm/jit/powerpc/emit.c: Likewise.
-       
-       * src/vm/jit/alpha/md-abi.h (REG_FA0, REG_FA1, REG_FA2): Added.
-       * src/vm/jit/mips/md-abi.h: Removed multiple defines.
-       * src/vm/jit/powerpc/linux/md-abi.h (REG_FA0, REG_FA1): Added.
-       (REG_A0_A1_PACKED): Likewise.
-       
-       * src/vm/jit/mips/linux/Makefile.am (AM_CPPFLAGS): Added
-       -I$(top_builddir)/src.
-       * src/vm/jit/mips/irix/Makefile.am: Likewise.
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c [ENABLE_JAVASE]
+       (native/include/java_lang_ThreadGroup.h): Only a temporary hack.
+       [8ba3980d54fa]
 
-2007-02-10 15:11  ajordan
+       * src/vm/signal.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.c (opt_TraceTraps): Added.
+       * src/vmcore/options.h: Likewise.
 
-       * src/vm/jit/sparc64/codegen.c (createnativestub): Fixed stack
-       argument passing.
-       
-       * src/vm/jit/sparc64/*: Adapted includes to new cacao structure.
+       * src/vm/signal.c (signal_handle) [!NDEBUG]: Added opt_TraceTraps
+       debug output. This is not finished yet.
+       [ea6e9a832c48]
 
-2007-02-10 14:31  pm
+       * src/cacaoh/dummy.c, src/vmcore/options.c:
+       * src/cacaoh/dummy.c (errno.h): Added. (vmcore/system.h): Likewise.
+       (vm_abort_errno): New function. (vm_abort_errnum): Likewise.
 
-       * s390/codegen.c: fix: ICMD_FCMPL generated wrong branch offset
-       * s390/codegen.h: likewise
-       * s390/asmpart.S: fix: asm_call_jit_compiler did not remove stack
-       frame
+       * src/vmcore/options.c (errno.h): Removed. (options_xx): Use
+       vm_abort_errno.
+       [96dddc7f5487]
 
-2007-02-10 00:49  pm
+       * src/vm/signal.c:
+       * src/vm/signal.c (errno.h): Removed. (signal_init): Use
+       vm_abort_errno. (signal_register_signal): Likewise. (signal_thread):
+       Likewise.
+       [b85835120e85]
 
-       Continued work on S390 codegen. Affected files:
-       
-       * s390/codegen.c
-       * s390/codegen.h
-       * s390/arch.h
-       * s390/patcher.c
-       * s390/asmpart.S
+       * NEWS:
+       * NEWS: Added 0.99 news.
+       [09791a7c5a1b]
 
-2007-02-09 13:20  twisti
+2008-03-06  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-       * src/vm/jit/powerpc64/linux/md-os.c: Fixed includes.
-       * src/vm/jit/powerpc64/linux/md-abi.c: Likewise.
-       * src/vm/jit/powerpc64/md.c: Likewise.
-       * src/vm/jit/powerpc64/codegen.c: Likewise.
-       * src/vm/jit/powerpc64/patcher.c: Likewise.
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (putObjectVolatile): OK, this time
+       WITHOUT debug output. Damn.
+       [f1757b2a1bb3]
 
-2007-02-09 13:00  twisti
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (putObjectVolatile): Implemented.
+       [a8989730157b]
 
-       * src/vm/jit/i386/asmpart.S (asm_compare_and_swap): Added ; after
-       lock, Darwin's assembler requires that.
-       (asm_compare_and_swap): Likewise.
+2008-03-05  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-02-09 12:51  twisti
+       * src/threads/threadlist.c:
+       * src/threads/threadlist.c (threadlist_index_add): Actually set the
+       index in the structure.
+       [70cea5d87e1a]
 
-       * src/mm/boehm.c [ENABLE_THREADS] (threads/native/threads.h): Removed.
+       * src/mm/cacao-gc/rootset.c, src/native/vm/sun/jvm.c,
+       src/vm/jit/optimizing/profile.c:
+       * src/mm/cacao-gc/rootset.c (threads/threadlist.h): Added.
+       (rootset_readout): Use threadlist_* functions.
 
-2007-02-09 12:49  twisti
+       * src/native/vm/sun/jvm.c (threads/threadlist.h): Added.
+       (JVM_IsThreadAlive): Use threadlist_* functions.
+       (JVM_SetThreadPriority): Likewise. (JVM_IsInterrupted): Likewise.
 
-       * src/vm/jit/powerpc/linux/Makefile.am (AM_CPPFLAGS): Added
-       -I$(top_builddir)/src.
-       * src/vm/jit/powerpc/darwin/Makefile.am: Likewise.
-       * src/vm/jit/powerpc/netbsd/Makefile.am: Likewise.
+       * src/vm/jit/optimizing/profile.c (threads/threadlist.h): Added.
+       (profile_thread): Use threadlist_* functions.
+       [bfdd735b3ecb]
 
-2007-02-09 12:47  twisti
+       * src/native/vm/Makefile.am, src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h,
+       src/native/vm/sun/jvm.c, src/threads/threads-common.c, src/threads
+       /threads-common.h:
+       * src/native/vm/java_lang_Thread.c: Removed.
+       * src/native/vm/java_lang_Thread.h: Likewise.
 
-       * src/vmcore/class.h (dummy_java_lang_Class): Added.
-       (classinfo): Use dummy_java_lang_Class.
-       * src/vm/vm.c (vm_create): Check dummy_java_lang_Class size.
+       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Removed
+       java_lang_Thread.[ch].
 
-2007-02-09 11:25  twisti
+       * src/threads/threads-common.c (threads_get_current_object): New
+       function.
+       * src/threads/threads-common.h: Likewise.
 
-       * src/native/vm/java_lang_Runtime.c [ENABLE_JAVASE]
-       (runFinalizersOnExit): Added.
-       * src/native/vm/java_lang_Runtime.h: Likewise.
-       
-       * src/native/vm/gnu/java_lang_VMRuntime.c (exit): Renamed argument
-       par1 to status.
-       (runFinalizersOnExit): Call _Jv_java_lang_Runtime_runFinalizersOnExit.
-
-2007-02-09 11:08  twisti
-
-       * src/vm/exceptions.c (exceptions_throw_unsatisfiedlinkerror)
-       [!ENABLE_JAVASE]: Generate a java.lang.Error.
-       
-       * src/native/vm/cldc1.1/java_lang_Class.c (isInstance): Added.
-       (isAssignableFrom): Likewise.
-       (isInterface): Likewise.
-       (isArray): Likewise.
-       
-       * src/native/vm/cldc1.1/java_lang_Object.c (hashCode): Likewise.
-       (notify): Likewise.
-       (wait): Likewise.
-       
-       * src/native/vm/cldc1.1/java_lang_String.c (hashCode): Smaller
-       implementation changes.
-       (indexOf__II): Likewise.
-       (lastIndexOf__II): Likewise.
-       (indexOf__I): Added.
-       
-       * src/native/vm/cldc1.1/java_lang_Thread.c: Header updated.
-       
-       * src/native/vm/cldc1.1/java_lang_Runtime.c (exitInternal): Fixed
-       signature.
-       (freeMemory): Added.
-       (totalMemory): Likewise.
-       (gc): Likewise.
-       
-       * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c: New
-       file.
-       * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c:
-       Likewise.
-       * src/native/vm/cldc1.1/Makefile.am (libnativevmcore_la_SOURCES):
-       Added com_sun_cldc_io_ResourceInputStream.c and
-       com_sun_cldc_io_j2me_socket_Protocol.c.
-       
-       * src/native/vm/java_lang_Runtime.c: New file.
-       * src/native/vm/java_lang_Runtime.h: Likewise.
-       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
-       java_lang_Runtime.c and java_lang_Runtime.h.
-       
-       
-       * src/native/vm/java_lang_Class.c: Un-ifdef some functions for CLDC.
-       * src/native/vm/java_lang_Class.h: Likewise.
-       
-       * src/native/vm/gnu/java_lang_VMRuntime.c
-       (native/vm/java_lang_Runtime.h): Added.
-       (exit): Call _Jv_java_lang_Runtime function.
-       (freeMemory): Likewise.
-       (totalMemory): Likewise.
-       (gc): Likewise.
-       
-       * src/native/vm/java_lang_Object.h [ENABLE_JAVASE]
-       (native/include/java_lang_Cloneable.h): Only available for JavaSE
-       configurations.
-       
-       * src/native/include/Makefile.am (JAVAME_CLDC1_1_HEADER_FILES): Added
-       com_sun_cldc_io_ResourceInputStream.h and
-       com_sun_cldc_io_j2me_socket_Protocol.h.
-       
-       * src/native/native.c (dummynativetable) [ENABLE_JAVAME_CLDC1_1]:
-       Added new functions.
-
-2007-02-09 10:35  twisti
-
-       * src/vm/jit/alpha/md.c (vm/options.h): Changed to vmcore/options.h.
-       
-       * src/vm/jit/alpha/linux/Makefile.am (AM_CPPFLAGS): Added
-       -I$(top_builddir)/src.
-       * src/vm/jit/alpha/freebsd/Makefile.am: Likewise.
-
-2007-02-08 12:29  michi
-
-       * src/vm/jit/i386/cygwin/Makefile.am: Changed to unix fileformat.
-       * src/vm/jit/i386/cygwin/ucontext.h,
-       src/vm/jit/i386/cygwin/ucontext.c,
-       src/vm/jit/i386/cygwin/md-os.c, src/vm/jit/i386/cygwin/md-asm.h:
+       * src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c:
+       Implemented thread functions directly.
+       [e0404195c823]
+
+       * configure.ac, m4/classpath.m4:
+       * configure.ac (AM_CPPFLAGS): Set to CPPFLAGS.
+
+       * m4/classpath.m4 (AC_CHECK_WITH_JNI_MD_H): Preserve CPPFLAGS.
+       (AC_CHECK_WITH_JNI_H): Likewise.
+       [285ff795b4ba]
+
+       * src/Makefile.am:
+       * src/Makefile.am: Changed copyright.
+       [1c3bd7bb8db1]
+
+       * src/threads/Makefile.am, src/threads/lock-common.h,
+       src/threads/native/lock.c, src/threads/native/threads.c,
+       src/threads/threadlist.c, src/threads/threadlist.h, src/threads
+       /threads-common.c, src/threads/threads-common.h, src/vm/vm.c:
+       * src/threads/threadlist.c: New file.
+       * src/threads/threadlist.h: Likewise.
+
+       * src/threads/Makefile.am (libthreads_la_SOURCES): Added
+       threadlist.[ch].
+
+       * src/threads/lock-common.h: Changed copyright.
+
+       * src/threads/native/lock.c (threads/threadlist.h): Added.
+       (threads_lookup_thread_id): Use threadlist_* functions.
+
+       * src/threads/native/threads.c (threads/threadlist.h): Added.
+       (threads_cast_sendsignals): Use threadlist_* functions.
+       (threads_stopworld): Likewise. (threads_startworld): Likewise.
+       (threads_init): Likewise. (threads_attach_current_thread): Likewise.
+       (threads_join_all_threads): Likewise.
+
+       * src/threads/threads-common.c (threads/threadlist.h): Added.
+       (list_threads, list_free_threads, list_free_thread_index): Removed.
+       (thread_index_t): Removed. (threads_preinit): Don't initialize the
+       thread lists, moved lock_init and critical_init calls into
+       vm_create. (threads_list_first, threads_list_next): Removed.
+       (threads_list_get_non_daemons): Likewise. (threads_thread_new,
+       threads_thread_free): Use threadlist_* functions.
+
+       * src/threads/threads-common.h (threads_list_first): Removed.
+       (threads_list_next): Likewise. (threads_list_get_non_daemons):
        Likewise.
 
-2007-02-08 12:14  twisti
+       * src/vm/vm.c (threads/lock-common.h): Added.
+       (threads/threadlist.h): Added. (vm_create) [ENABLE_THREADS]: Call
+       threadlist_init, lock_init and critical_init.
+       [88c7c1a68bda]
 
-       * src/vm/jit/i386/linux/Makefile.am (AM_CPPFLAGS) Added
-       -I$(top_builddir)/src.
-       * src/vm/jit/i386/cygwin/Makefile.am: Likewise.
-       * src/vm/jit/i386/freebsd/Makefile.am: Likewise.
-
-2007-02-07 22:06  pm
-
-       Continued work on S390 port.
-       java.lang.ClassLoader.getSystemClassLoader is now compiled, patched,
-       called and the patcher trigger compilation of another method.
-       
-       * jit/s390/emit.c: Likiwise.
-       * jit/s390/codegen.c: Likewise.
-       * jit/s390/codegen.h: Likewise.
-       * jit/s390/md-asm.h: Likewise.
-       * jit/s390/patcher.c: Likewise.
-       * jit/s390/asmpart.S: Likewise.
-       * jit/codegen-common.c: Likewise.
-
-2007-02-06 12:17  twisti
-
-       * src/native/vm/cldc1.1/Makefile.am: Updated header.
-
-2007-02-06 10:25  twisti
-
-       * src/native/vm/cldc1.1/java_lang_String.c (hashCode): Implemented.
-       (indexOf__II): Likewise.
-       (lastIndexOf__II): Likewise.
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c [WITH_CLASSPATH_CLDC1_1]
+       (native/include/java_lang_String.h): Added.
+       [5856f0d523a2]
 
-2007-02-06 09:11  twisti
+       * configure.ac, m4/classpath.m4, src/native/jni.h:
+       * configure.ac (AC_CHECK_WITH_CLASSPATH_INCLUDEDIR): Removed.
+       [!WITH_JRE_LAYOUT] (AC_CHECK_WITH_CLASSPATH_LIBDIR): Conditional.
+       (AC_CHECK_WITH_JNI_MD_H): Added. (AC_CHECK_WITH_JNI_H): Likewise.
+       (AM_CPPFLAGS): Added.
 
-       * src/threads/native/Makefile.am (AM_CPPFLAGS): Added
-       -I$(top_builddir)/src.
-       * src/vm/jit/x86_64/Makefile.am: Likewise.
-       * src/vm/jit/x86_64/linux/Makefile.am: Likewise.
-       * src/vm/jit/x86_64/freebsd/Makefile.am: Likewise.
+       * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_INCLUDEDIR): Removed.
+       (AC_CHECK_WITH_JNI_MD_H): New macro. (AC_CHECK_WITH_JNI_H):
+       Likewise.
 
-2007-02-06 08:58  twisti
+       * src/native/jni.h (__GCJ_JNI_MD_H__): Removed the quick hack.
+       (CLASSPATH_JNI_MD_H): Removed. (CLASSPATH_JNI_H): Likewise.
+       (INCLUDE_JNI_MD_H): Added. (INCLUDE_JNI_H): Likewise.
+       [eab0c7885c52]
 
-       * src/vm/jit/powerpc/codegen.c (codegen) [ENABLE_PROFILING]: #ifdef
-       profiling code.
+       * src/lib/Makefile.am:
+       * src/lib/Makefile.am [WITH_CLASSPATH_GNU || WITH_CLASSPATH_CLDC1_1]
+       (pkgdata_DATA): Only define it for GNU or CLDC-1.1 configurations.
+       [1d15fd390244]
 
-2007-02-06 08:50  twisti
+       * src/cacao/Makefile.am:
+       * src/cacao/Makefile.am (libjvm_la_LDFLAGS): Use -version-info
+       instead of -release, as the library interface of libjvm.so will not
+       change.
+       [46784cb01dc1]
 
-       * src/native/vm/Makefile.am (DIST_SUBDIRS): Added missing \.
+2008-03-04  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-02-06 08:49  twisti
+       * man/Makefile.am:
+       * man/Makefile.am: Changed copyright.
+       [46f2ae819ff5]
 
-       * src/vm/jit/tools/genoffsets.c (vm/jit/stacktrace.h): Not required,
-       removed.
+       * doc/Makefile.am:
+       * doc/Makefile.am: Changed copyright.
+       [6c354dd4fcd8]
 
-2007-02-06 08:48  twisti
+       * contrib/Makefile.am:
+       * contrib/Makefile.am: Changed copyright.
+       [3f9fc73789e5]
 
-       * src/vm/jit/tools/Makefile.am: Cosmetic changes.
+       * Makefile.am:
+       * Makefile.am: Changed copyright.
+       [23e283b63784]
 
-2007-02-06 08:47  twisti
+       * NEWS:
+       * NEWS: Fixed month for 0.99.
+       [0fc50ddc4a9f]
 
-       * src/vm/jit/optimizing/Makefile.am (AM_CPPFLAGS): Added
-       -I$(top_builddir)/src.
-       * src/vm/jit/Makefile.am: Likewise.
-       * src/vm/Makefile.am: Likewise.
-       * src/mm/Makefile.am: Likewise.
+2008-03-03  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-02-06 06:37  twisti
+       * NEWS:
+       * NEWS: Added some 0.99 release notes.
+       [5b338798aa0b]
 
-       * src/vm/jit/linux/md-os.c (thread_restartcriticalsection): Added
-       missing cast and pass pc to critical_find_restart_point.
-       * src/vm/jit/freebsd/md-os.c (thread_restartcriticalsection):
-       Likewise.
+2008-03-03  Stefan Ring  <stefan@complang.tuwien.ac.at>
 
-2007-02-05 02:04  twisti
+       * tests/threadInterrupt.java:
+       Merge -> trunk.
+       [2fa6a94596b0]
 
-       * src/cacaoh/dummy.c (builtin_clone, builtin_isanysubclass)
-       (builtin_new): Keep compiler happy and return a value.
+       * src/threads/native/lock.c, src/threads/native/threads.c,
+       src/threads/native/threads.h:
+       interrupt() / notify() fix.
 
-2007-02-05 01:07  twisti
+       * src/threads/native/lock.c (lock_record_wait, lock_record_notify):
+       Correctly handling the signaled and interrupted flags.
 
-       * src/vm/signallocal.h (vm/types.h): Added.
-       (vm/global.h): Likewise.
+       * src/threads/native/threads.c (threads_wait_with_timeout)
+       (threads_wait_with_timeout_relative): No return value, not touching
+       flags. (threads_check_if_interrupted_and_reset): Now locking the
+       waitmutex. (threads_sleep): Adapted to change.
 
-2007-02-05 01:06  twisti
+       * src/threads/native/threads.h (threads_wait_with_timeout_relative):
+       No return value.
+       [9ffa63aa1415]
 
-       * configure.ac (AC_CONFIG_FILES): Added
-       src/vm/jit/x86_64/freebsd/Makefile.
-       
-       * src/vm/jit/x86_64/Makefile.am (DIST_SUBDIRS): Added freebsd.
-       
-       * src/vm/jit/x86_64/freebsd/md-os.c: New file.
-       * src/vm/jit/x86_64/freebsd/Makefile.am: Likewise.
-       * src/vm/jit/x86_64/freebsd/.cvsignore: Likewise.
+       * tests/threads/waitAndInterrupt.java:
+       * tests/threads/waitAndInterrupt.java: New test hanging CACAO.
+       [831d66c6b70a]
 
-2007-02-05 00:52  twisti
+       * .hgignore, tests/threadInterrupt.java,
+       tests/threads/threadInterrupt.java:
+       * .hgignore: Ignoring class files.
+       * tests/threads: New directory for thread tests.
+       * tests/threads/threadInterrupt.java: Moved.
+       [820a5859b970]
 
-       * configure.ac (AC_CONFIG_FILES): Added
-       src/vm/jit/x86_64/linux/Makefile.
-       
-       * src/vm/jit/x86_64/Makefile.am (DIST_SUBDIRS): Added.
-       (SUBDIRS): Likewise.
-       (libarch_la_LIBADD): Likewise.
-       
-       * src/vm/jit/x86_64/md.c (md_signal_handler_sigsegv)
-       (md_signal_handler_sigfpe, md_signal_handler_sigusr2)
-       (thread_restartcriticalsection): Removed.
-       
-       * src/vm/jit/x86_64/linux/md-os.c: New file.
-       * src/vm/jit/x86_64/linux/Makefile.am: Likewise.
-       * src/vm/jit/x86_64/linux/.cvsignore: Likewise.
-
-2007-02-04 19:41  pm
-
-       * jit/codegen-common.h: Enabled dseg_adddata for s390.
-       * jit/dseg.c: Likewise.
-       * jit/s390/md-abi.h: Continued work on s390 port.
-       * jit/s390/emit.c: Likewise.
-       * jit/s390/md.c: Likewise.
-       * jit/s390/codegen.c: Likewise.
-       * jit/s390/codegen.h: Likewise.
-       * jit/s390/md-asm.h: Likewise.
-       * jit/s390/asmpart.S: Likewise.
-       * jit/s390/md-abi.c: Likewise.
-
-2007-02-04 16:08  twisti
-
-       * src/native/jni.c (_Jv_JNI_ExceptionDescribe): Fixed typo.
-
-2007-02-03 19:51  twisti
-
-       * src/vm/jit/x86_64/codegen.c (codegen) [ENABLE_PROFILING]: #ifdef
-       instrumentation code.
-       (createnativestub) [ENABLE_PROFILING]: Likewise.
-       
-       * src/vm/jit/x86_64/codegen.h [ENABLE_PROFILING] (PROFILE_CYCLE_START)
-       (PROFILE_CYCLE_STOP): Added #ifdef.
-
-2007-02-03 19:34  twisti
-
-       * src/vm/builtin.c [ENABLE_THREADS] (threads/native/threads.h):
-       Removed.
-       [ENABLE_THREADS] (threads/native/lock.h): Added.
-       (builtin_throw_exception): Use exceptions_set_exception.
-       
-       * src/vm/finalizer.c (finalizer_run): Likewise.
-       
-       * src/vm/signal.c (signal_start_thread): Use #warning instead of
-       #error (temporarily).
-       
-       * src/native/jni.c (_Jv_jni_invokeNative): Use
-       exceptions_get_exception, and exceptions_clear_exception.
-       (_Jv_JNI_ExceptionDescribe): Likewise.
-       (_Jv_JNI_IsAssignableFrom): Use exceptions_set_exception.
-       (_Jv_JNI_ExceptionOccurred): Use exceptions_get_exception.
-       (_Jv_JNI_ExceptionCheck): Likewise.
-       (_Jv_JNI_ExceptionClear): Use exceptions_clear_exception.
-
-2007-02-02 12:53  twisti
-
-       * src/vm/jit/i386/codegen.c (codegen) [ENABLE_PROFILING]: Profiling
-       code.
-       (createnativestub): Likewise.
+2008-03-01  Stefan Ring  <stefan@complang.tuwien.ac.at>
 
-2007-02-02 12:39  twisti
+       * .hgignore:
+       * .hgignore: Ignoring latex output files.
+       [c68604485dd4]
 
-       * src/native/vm/java_lang_Object.c [ENABLE_JAVAME_CLDC1_1]
-       (native/include/java_lang_String.h): Added.
+2008-03-03  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-02-02 12:28  twisti
+       * src/lib/Makefile.am:
+       * src/lib/Makefile.am (EXTRA_DIST): Removed VM_JAVA_FILES, added
+       VM_JAVA_FILES_GNU, VM_JAVA_FILES_GNU_ANNOTATIONS,
+       VM_JAVA_FILES_CLDC1_1. (VM_JAVA_FILES): Removed.
+       (VM_JAVA_FILES_GNU): Added. (VM_JAVA_FILES_GNU_ANNOTATIONS):
+       Likewise. (VM_JAVA_FILES_CLDC1_1): Likewise.
+       [ec85f6c4026c]
 
-       * src/native/vm/java_lang_Class.h (native/include/java_lang_String.h):
-       Required by java_lang_Class.h for Java ME.
+2008-02-29  Stefan Ring  <stefan@complang.tuwien.ac.at>
 
-2007-02-02 11:58  michi
+       * src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h:
+       Reusing threadobjects.
 
-       * src/vm/jit/arm/md-abi.h: Renamed REG_IP to REG_PV (special favor
-       for twisti).
-       * src/vm/jit/arm/emit.c, src/vm/jit/arm/codegen.c,
-       src/vm/jit/arm/codegen.h:
-       Adapted to the above change.
+       * src/threads/native/threads.c (threads_impl_thread_new): Removed
+       and split up into three new functions. (threads_impl_thread_init,
+       threads_impl_thread_clear) (threads_impl_thread_reuse): New
+       functions. (threads_impl_thread_free): Disabled.
 
-2007-02-02 00:20  twisti
+       * src/threads/native/threads.h (threadobject): Added field for free-
+       list.
 
-       * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_PROFILING]: Call
-       reorder only when profiling.
+       * src/threads/threads-common.c (threads_preinit, threads_thread_new)
+       (threads_thread_free): Reuse threadobjects.
 
-2007-02-02 00:10  twisti
+       * src/threads/threads-common.h: New function declarations.
+       [d73f6705d7ad]
 
-       * src/vm/jit/code.h (codeinfo) [ENABLE_PROFILING]: Made frequency,
-       bbfrequency, and cycles conditional.
-       
-       * src/vm/jit/jit.c (jit_compile) [ENABLE_PROFILING]: Likewise.
-       (jit_compile_intern) [ENABLE_PROFILING]: Likewise.
+2008-02-28  pm  <pm@c8.complang.tuwien.ac.at>
 
-2007-02-02 00:06  twisti
+       * src/vm/jit/cfg.c:
+       * src/vm/jit/cfg.c (cfg_add_exceptional_edges): Conditionally
+       compiling (was forgotten).
+       [97bbdfcfb666]
 
-       * src/vm/jit/optimizing/Makefile.am [ENABLE_PROFILING]
-       (REORDER_SOURCES): Moved here till we have something better.
+2008-02-28  Peter Molnar  <pm@complang.tuwien.ac.at>
 
-2007-02-01 15:35  twisti
+       * src/vm/jit/jit.c:
+       Merging 7888.
+       [42ae5a01ac5a]
 
-       * src/vmcore/suck.c (assert.h): Added.
-       (suck_float): Use assert instead of an exception.
-       (suck_double): Likewise.
+       * src/vm/jit/cfg.c, src/vm/jit/jit.c, src/vm/jit/jit.h,
+       src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa3.c:
+       * src/vm/jit/cfg.c (cfg_add_exceptional_edges): New function
+       * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_SSA]: Adapted.
+       * src/vm/jit/jit.h (struct basicblock) [ENABLE_SSA]: New fileds for
+       exception handlers in cfg.
+       * src/vm/jit/optimizing/ssa.c (ssa): Adapted.
+       * src/vm/jit/optimizing/ssa3.c: Changed a lot, currenly broken.
+       [5faec567ca14]
 
-2007-02-01 15:27  twisti
+       * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md.c:
+       * src/vm/jit/s390/asmpart.S (L_offsets): Removed references to
+       unused functions.
+       * src/vm/jit/s390/md.c: Including vm/jit/s390/md.h.
+       [0d5247355a8c]
 
-       * src/vmcore/linker.c (link_class_intern): Also align double and s8
-       fields to 4-bytes for ARM.
+2008-02-27  Stefan Ring  <stefan@complang.tuwien.ac.at>
 
-2007-02-01 12:58  twisti
+       * tests/threadInterrupt.java:
+       * tests/threadInterrupt.java: Added a test showing a bug in the pre-
+       sable implementation.
+       [048e4ed58d94]
 
-       * src/vmcore/utf8.c (utf_java_lang_InvocationTargetException): Is
-       actually called utf_java_lang_reflect_InvocationTargetException.
-       (utf8_init): Likewise.
-       
-       * src/vmcore/utf8.h (utf_java_lang_InvocationTargetException):
-       Likewise.
-       
-       * src/vm/exceptions.c (exceptions_throw_invocationtargetexception):
+       * src/threads/native/lock.c, src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_set_current_threadobject):
+       Added a few vm_abort_errnum calls. (threads_get_current_thread):
        Likewise.
 
-2007-02-01 12:29  twisti
-
-       * src/vm/jit/code.c [ENABLE_THREADS] (threads/native/lock.h): Added.
+       * src/threads/native/lock.c (lock_record_new): Likewise.
+       (lock_record_free): Likewise.
+       [40e84a6ae6ea]
 
-2007-02-01 12:02  twisti
+2008-02-21  Edwin Steiner  <edwin.steiner@gmx.net>
 
-       * src/vmcore/method.h (methodinfo): Removed member object.
-       * src/vm/jit/code.h (codeinfo): Added member object.
-       
-       * src/vmcore/loader.c (loader_load_method): Removed
-       lock_init_object_lock.
-       (load_newly_created_array): Likewise.
-       * src/vm/jit/code.c (code_codeinfo_new): Added lock_init_object_lock.
-       
-       * src/vm/jit/jit.c (jit_jitdata_new): Changed signature.
-       (jit_compile): Use codeinfo lock object instead of methodinfo.
-       (jit_recompile): Changed signature.
-       * src/vm/jit/jit.h (jit_jitdata_new): Likewise.
+       * src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/jit/x86_64/linux/md-os.c (md_replace_executionstate_read):
+       Fix copy&paste mistake (for reading the PC).
+       [8af912202925]
 
-2007-01-31 17:45  twisti
+2008-02-20  Edwin Steiner  <edwin.steiner@gmx.net>
 
-       * src/cacaoh/dummy.c (pthread.h): Added.
+       * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/replace.c, src/vm/jit/replace.h:
+       * src/vm/jit/replace.h (executionstate_t): Added 'ra' field for
+       return address register. Otherwise replacement code for the PowerPC
+       gets very ugly, as the LR is not part of the intregs on PowerPC.
 
-2007-01-31 17:02  twisti
+       * src/vm/jit/replace.c (replace_executionstate_println): Added print
+       statements. (replace_sanity_check_read_write): Check 'ra' field.
 
-       * src/toolbox/logging.c (log_start): Uncommented thread pointer stuff.
-       * src/cacaoh/dummy.c (threads_get_current_threadobject): Added.
+       * src/vm/jit/alpha/linux/md-os.c (md_replace_executionstate_read):
+       Use new 'ra' field. (md_replace_executionstate_write): Likewise.
 
-2007-01-31 17:00  twisti
+       * src/vm/jit/powerpc/linux/md-os.c (md_replace_executionstate_read):
+       Implemented for PowerPC/Linux. (md_replace_executionstate_write):
+       Likewise.
+       [54cb4d152e6f]
 
-       * src/native/jni.c (_Jv_JNI_ThrowNew): Fixed warnings.
+       * src/vm/jit/alpha/linux/md-os.c:
+       * src/vm/jit/alpha/linux/md-os.c (md_replace_executionstate_read):
+       Do not use the assignment operator for the float registers, as the
+       type conversion messes up their values (they are not 'double' in the
+       context). (md_replace_executionstate_write): Likewise.
+       [9a2f257d4326]
 
-2007-01-31 14:05  twisti
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_sanity_check_read_write): New
+       function. Perform some basic sanity checks of the md_replacement_*
+       implementations. (replace_me_wrapper): Call above function in
+       debugging mode.
+       [401ef412801a]
 
-       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c: Updated year.
+2008-02-20  Roland Lezuo  <tbfg@complang.tuwien.ac.at>
 
-2007-01-31 14:04  twisti
+       * Merged with tip
+       [1c5d66f62119]
 
-       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (string.h):
-       Added.
-       (mm/memory.h): Likewise.
+2008-02-19  Roland Lezuo  <tbfg@complang.tuwien.ac.at>
 
-2007-01-31 10:59  twisti
+       * Merged with cldc-branch
+       [eb7a914bf640]
 
-       * src/vmcore/loader.c (load_newly_created_array) [ENABLE_JAVASE]:
-       Fixed interfacescount.
+2008-02-19  tbfg  <tbfg@c1.complang.tuwien.ac.at>
 
-2007-01-31 10:00  twisti
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h:
+       * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Do not overwrite
+       return address with method to be invoked.
 
-       * src/vm/exceptions.c [ENABLE_JAVAME_CLDC1_1](exceptions_new_error):
-       New function.
-       (exceptions_asm_new_abstractmethoderror) [!ENABLE_JAVASE]: Use
-       exceptions_new_error.
-       (exceptions_throw_virtualmachineerror): Removed.
-       * src/vm/exceptions.h (exceptions_throw_virtualmachineerror):
-       Likewise.
+       * src/vm/jit/m68k/codegen.c (codegen_emit_stub_native): Removed call
+       to trace function as seen in other archs.
 
-2007-01-31 09:51  twisti
-
-       * src/vm/jit/Makefile.am: Fixed !ENABLE_VERIFER build.
-
-2007-01-30 13:58  twisti
-
-       * src/vm/jit/arm/emit.c (mm/memory.h): Added.
-       (vm/global.h): Likewise.
-       (emit_patcher_stubs): Align stack to 8-byte.
-       (emit_verbosecall_exit): Smaller optimizations.
-       
-       * src/vm/jit/arm/md-abi.h (config.h): Added.
-       (REG_A1_A2_PACKED): Defined.
-       
-       * src/vm/jit/arm/md.c: Fixed includes.
-       (md_codegen_get_pv_from_pc): Use vm_abort.
-       
-       * src/vm/jit/arm/codegen.c: Fixed includes.
-       (codegen): Align stack to 8-byte.
-       (createnativestub): Likewise.
-       
-       * src/vm/jit/arm/codegen.h (M_ADD_IMM_EXT_MUL4): Added do-while.
-       (M_SUB_IMM_EXT_MUL4): Likewise.
-       
-       * src/vm/jit/arm/patcher.c: Fixed includes.
-       (patcher_wrapper): Align stack to 8-byte.
-       * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Likewise.
-       
-       * src/vm/jit/arm/md-abi.c: Fixed includes.
-
-2007-01-30 13:53  twisti
-
-       * src/vm/signal.c (signal_init): Disable signal-thread handling
-       temporarily.
-       * src/vm/vm.c (vm_create): Likewise.
+       * src/vm/jit/m68k/codegen.h (COMPILERSTUB_CODESIZE): Fix size for
+       new compiler trap.
+       [3f6144729487]
 
-2007-01-29 23:07  twisti
+2008-02-15  tbfg  <tbfg@c1.complang.tuwien.ac.at>
 
-       * src/vm/string.c (native/jni.h): Added.
-       * src/vm/properties.c (native/jni.h): Likewise.
-       
-       * src/native/vm/cldc1.1/java_lang_Runtime.c: Includes fixed for
-       cacaoh-changes.
-       * src/native/vm/cldc1.1/java_lang_Class.c: Likewise.
-       
-       * src/native/vm/java_lang_Class.c [ENABLE_JAVAME_CLDC1_1]
-       (native/include/java_lang_String.h): Added.
-       (forName): #ifdef'd loader variable.
-       
-       * src/vmcore/class.c (class_resolveclassmethod): Removed Java ME
-       exception handling, we do that in the exception function itself.
-       (class_resolveinterfacemethod): Likewise.
-       * src/vmcore/resolve.c (resolve_method_invokespecial): Likewise.
-       
-       * src/vmcore/utf8.c [ENABLE_JAVASE]
-       (utf_java_lang_AbstractMethodError, utf_java_lang_NoSuchFieldError)
-       (utf_java_lang_NoSuchMethodError): Removed ifdef.
-       * src/vmcore/utf8.h: Likewise.
+       * src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/linux/md-abi.c:
+       * src/vm/jit/m68k/codegen.c (codegen_emit_stub_native): Handle
+       builtin correctly.
+       * src/vm/jit/m68k/linux/md-abi.c (md_param_alloc_native): With 8 bytes
+       stack slots internally natives need a 4 byte stack slot allocation.
+       (md_param_alloc): Set index correctly.
+       [c87ce21ccdf8]
 
-2007-01-29 21:47  ajordan
+2008-02-19  Edwin Steiner  <edwin.steiner@gmx.net>
 
-       * src/vm/jit/sparc64/codegen.h: Fixed double register number packing
-       and fp compare instruction macros.
-       * src/vm/jit/sparc64/codegen.c: Fixed fp compares.
-       Fixed INT2CHAR.
-       Fixed fp argument saving in createnativestub().
-       
-       * src/vm/jit/sparc64/patcher.c: Implemented get/put field patcher.
-       
-       * src/vm/jit/sparc64/md.c: Removed printf.
+       * src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/x86_64/emit.c (emit_alu_imm_membase): Fix emit_rex
+       call.
+       [97f2df303ae7]
 
-2007-01-29 21:39  twisti
+       * src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/x86_64/emit.c (emit_alul_imm_membase): Fix emit_rex
+       call.
+       [0eae2350805d]
 
-       * src/vm/jit/i386/emit.c: Includes fixed for cacaoh-changes.
-       * src/vm/jit/i386/md.c: Likewise.
-       * src/vm/jit/i386/codegen.c: Likewise.
-       * src/vm/jit/i386/patcher.c: Likewise.
-       * src/vm/jit/i386/md-abi.c: Likewise.
+2008-02-18  Edwin Steiner  <edwin.steiner@gmx.net>
 
-2007-01-29 21:38  twisti
+       * src/vm/jit/inline/inline.c, src/vmcore/options.c:
+       * src/vmcore/options.h, src/vmcore/options.c,
+       src/vm/jit/inline/inline.c: Trace levels for inlining.
+       [a572dc07befb]
 
-       * src/vm/jit/i386/asmpart.S (asm_compare_and_swap): New function.
-       (asm_memory_barrier): Likewise.
+       * src/vm/jit/inline/inline.c:
+       * src/vm/jit/inline/inline.c (inline_transform): Make semantics of
+       opt_InlineCount less confusing.
+       [02db2973e156]
 
-2007-01-29 21:37  twisti
+       * src/vm/jit/inline/inline.c, src/vm/jit/jit.c, src/vm/vm.c,
+       src/vmcore/linker.c, src/vmcore/method.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/vmcore/options.h, src/vmcore/options.c, src/vmcore/method.c,
+       src/vmcore/linker.c, src/vm/vm.c, src/vm/jit/jit.c,
+       src/vm/jit/inline/inline.c: Changed inlining options to -XX options.
+       [fcb2ea727c23]
 
-       * src/vm/jit/alpha/asmpart.S (asm_compare_and_swap): Changed comment.
+2008-02-19  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-01-29 21:09  twisti
+       * src/vm/jit/powerpc/linux/md-abi.c:
+       * src/vm/jit/powerpc/linux/md-abi.c (md_return_alloc): Use switch-
+       case.
+       [0b1af4df6ef2]
+
+       * src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): Use switch-case to
+       store return values for invokes.
+       [016cdf940d81]
+
+2008-02-18  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_native): Use
+       switch-case for argument copying.
+       [720c659e4ecc]
+
+       * src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): Removed variable a,
+       added variable i.
+       [bb4a72bd2d52]
+
+       * src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): Use switch-case when
+       argument copying for invokes.
+       [2e2c6db95e46]
+
+       * src/vm/jit/powerpc/codegen.h:
+       * src/vm/jit/powerpc/codegen.h: Grouped and alpha-sorted the code
+       generating macros.
+       [c280412cfc3b]
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_gc_from_native): Fixed typo, again.
+       [897943ebddcc]
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_me): Fixed typo.
+       [273027fcc0d0]
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_me): Use
+       threads_get_current_stackframeinfo(). (replace_gc_from_native):
+       Likewise.
+       [28d447c7b5f7]
+
+       * src/mm/cacao-gc/gc.c, src/native/vm/cldc1.1/java_lang_Throwable.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c, src/native/vm/sun/jvm.c,
+       src/threads/native/threads.h, src/threads/none/threads.h,
+       src/threads/threads-common.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/stacktrace.h:
+       * src/vm/jit/stacktrace.c (stacktrace_get): Changed signature to
+       take again a stackframeinfo_t. (stacktrace_get_current): New
+       function. (stacktrace_stackframeinfo_add): Use
+       threads_get_current_stackframeinfo.
+       (stacktrace_stackframeinfo_remove): Likewise.
+       (stacktrace_first_nonnull_classloader): Likewise.
+       (stacktrace_getClassContext): Likewise.
+       (stacktrace_get_current_class): Likewise. (stacktrace_get_stack):
+       Likewise.
+       * src/vm/jit/stacktrace.h (stacktrace_get): Changed signature.
+       (stacktrace_get_current): New function.
 
-       * src/vm/jit/mips/emit.c: Include fixes for cacaoh-changes.
-       * src/vm/jit/mips/md.c: Likewise.
-       * src/vm/jit/mips/codegen.c: Likewise
-       * src/vm/jit/mips/linux/md-os.c: Likewise
-       * src/vm/jit/mips/disass.c: Likewise
-       * src/vm/jit/mips/patcher.c: Likewise
-       * src/vm/jit/mips/md-abi.c: Likewise
+       * src/mm/cacao-gc/gc.c (gc_collect): Replaced stacktrace_get with
+       stacktrace_get_current.
+       * src/native/vm/cldc1.1/java_lang_Throwable.c (fillInStackTrace):
+       Likewise.
+       * src/native/vm/gnu/java_lang_VMThrowable.c (fillInStackTrace):
+       Likewise.
+       * src/native/vm/sun/jvm.c (JVM_FillInStackTrace): Likewise.
 
-2007-01-29 20:24  twisti
+       * src/threads/native/threads.h (STACKFRAMEINFO): Removed.
+       (threads_get_current_stackframeinfo): New function.
+       (threads_set_current_stackframeinfo): Likewise.
+       * src/threads/none/threads.h: Likewise.
 
-       * src/vm/jit/alpha/emit.c: Fixed includes for cacaoh-changes.
-       * src/vm/jit/alpha/codegen.c: Likewise.
-       * src/vm/jit/alpha/linux/md-os.c: Likewise.
-       * src/vm/jit/alpha/patcher.c: Likewise.
-       * src/vm/jit/alpha/md-abi.c: Likewise.
-
-2007-01-29 19:34  twisti
-
-       * src/native/include/.cvsignore: Ignore all *.h files.
-
-2007-01-29 19:32  twisti
-
-       * src/vm/jit/x86_64/md.c: Fixed includes for cacaoh-changes.
-
-2007-01-29 19:28  twisti
-
-       * src/vm/jit/x86_64/emit.c: Fixed includes for cacaoh-changes.
-       * src/vm/jit/x86_64/codegen.c: Likewise.
-       * src/vm/jit/x86_64/patcher.c: Likewise.
-       * src/vm/jit/x86_64/md-abi.c: Likewise.
-
-2007-01-29 19:15  twisti
-
-       * src/vmcore/stackmap.c [ENABLE_STATISTICS] (vmcore/statistics.h):
-       Removed ifdef.
-       * src/vm/jit/jit.c: Likewise.
-       * src/vm/jit/emit-common.c: Likewise.
-
-2007-01-29 18:49  twisti
-
-       * This is a rather huge commit, which changes the build order of
-       various parts to be able to bootstrap cacaoh without any dependencies
-       on a generated header file. I include the file list from SVN, so we
-       can see what happened to the files.
-       
-       Here we go (D-files were mostly moved to src/vmcore):
-       
-       D src/vm/hashtable.h
-       D src/vm/options.h
-       M src/vm/properties.h
-       D src/vm/zip.c
-       D src/vm/class.c
-       D src/vm/suck.c
-       D src/vm/loader.c
-       M src/vm/builtin.c
-       M src/vm/string.c
-       D src/vm/zip.h
-       D src/vm/class.h
-       D src/vm/rt-timing.c
-       D src/vm/suck.h
-       D src/vm/annotation.c
-       M src/vm/builtin.h
-       D src/vm/loader.h
-       D src/vm/descriptor.c
-       D src/vm/annotation.h
-       D src/vm/rt-timing.h
-       D src/vm/resolve.c
-       D src/vm/method.c
-       D src/vm/descriptor.h
-       M src/vm/finalizer.c
-       D src/vm/resolve.h
-       D src/vm/method.h
-       D src/vm/references.h
-       D src/vm/classcache.c
-       D src/vm/statistics.c
-       D src/vm/classcache.h
-       D src/vm/statistics.h
-       M src/vm/initialize.c
-       M src/vm/access.c
-       D src/vm/stackmap.c
-       M src/vm/jit/powerpc/linux/md-abi.c
-       M src/vm/jit/powerpc/emit.c
-       M src/vm/jit/powerpc/md.c
-       M src/vm/jit/powerpc/codegen.c
-       M src/vm/jit/powerpc/patcher.c
-       M src/vm/jit/codegen-common.h
-       M src/vm/jit/abi.h
-       M src/vm/jit/stack.c
-       M src/vm/jit/optimizing/profile.c
-       M src/vm/jit/optimizing/recompile.c
-       M src/vm/jit/optimizing/ifconv.c
-       M src/vm/jit/optimizing/ifconv.h
-       M src/vm/jit/code.c
-       M src/vm/jit/tools/genoffsets.c
-       M src/vm/jit/code.h
-       M src/vm/jit/show.c
-       M src/vm/jit/dseg.c
-       M src/vm/jit/verify/typeinfo.h
-       M src/vm/jit/verify/typecheck-typeinferer.c
-       M src/vm/jit/verify/typecheck.c
-       M src/vm/jit/verify/typecheck-stackbased.c
-       M src/vm/jit/verify/typeinfo.c
-       M src/vm/jit/dseg.h
-       M src/vm/jit/loop/loop.h
-       M src/vm/jit/loop/graph.h
-       M src/vm/jit/allocator/simplereg.c
-       M src/vm/jit/parse.c
-       M src/vm/jit/asmpart.h
-       M src/vm/jit/stacktrace.c
-       M src/vm/jit/emit-common.c
-       M src/vm/jit/jit.c
-       M src/vm/jit/stacktrace.h
-       M src/vm/jit/codegen-common.c
-       M src/vm/jit/jit.h
-       M src/vm/initialize.h
-       M src/vm/access.h
-       D src/vm/stackmap.h
-       M src/vm/signal.c
-       M src/vm/exceptions.c
-       M src/vm/vm.c
-       D src/vm/field.c
-       D src/vm/linker.c
-       M src/vm/exceptions.h
-       M src/vm/stringlocal.h
-       D src/vm/utf8.c
-       D src/vm/field.h
-       M src/vm/Makefile.am
-       D src/vm/linker.h
-       D src/vm/hashtable.c
-       D src/vm/options.c
-       D src/vm/utf8.h
-       M src/vm/properties.c
-       M src/vm/signallocal.h
-       M src/cacao/Makefile.am
-       M src/native/jni.c
-       M src/native/vm/java_lang_Class.c
-       M src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c
-       M src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c
-       M src/native/vm/gnu/java_security_VMAccessController.c
-       M src/native/vm/gnu/java_lang_VMClassLoader.c
-       M src/native/vm/gnu/java_lang_management_VMManagementFactory.c
-       M src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
-       M src/native/vm/gnu/java_lang_VMClass.c
-       M src/native/vm/gnu/java_lang_VMThread.c
-       M src/native/vm/gnu/gnu_classpath_VMSystemProperties.c
-       M src/native/vm/gnu/java_lang_reflect_Method.c
-       M src/native/vm/gnu/java_lang_VMRuntime.c
-       M src/native/vm/gnu/java_lang_reflect_Field.c
-       M src/native/vm/gnu/gnu_classpath_VMStackWalker.c
-       M
-       src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
-       M src/native/vm/gnu/java_lang_reflect_Constructor.c
-       M src/native/vm/gnu/java_lang_VMThrowable.c
-       M src/native/vm/java_lang_Object.c
-       M src/native/vm/java_lang_Thread.c
-       D src/native/include/java_lang_Thread.h
-       D src/native/include/java_lang_Throwable.h
-       D src/native/include/java_util_Properties.h
-       D src/native/include/java_lang_VMThread.h
-       D src/native/include/java_lang_VMThrowable.h
-       D src/native/include/java_lang_ClassLoader.h
-       M src/native/include/Makefile.am
-       D src/native/include/java_lang_Cloneable.h
-       D src/native/include/java_lang_ThreadGroup.h
-       D src/native/include/java_lang_Class.h
-       D src/native/include/java_lang_Object.h
-       D src/native/include/java_lang_String.h
-       M src/native/jni.h
-       M src/native/native.c
-       M src/native/native.h
-       A src/toolbox/hashtable.h
-       M src/toolbox/list.c
-       M src/toolbox/avl.c
-       M src/toolbox/logging.c
-       M src/toolbox/Makefile.am
-       M src/toolbox/logging.h
-       A src/toolbox/hashtable.c
-       M src/mm/gc-common.h
-       M src/mm/Makefile.am
-       M src/mm/memory.c
-       M src/mm/boehm.c
-       M src/Makefile.am
-       M src/threads/none/threads.h
-       M src/threads/none/lock.h
-       M src/threads/native/threads.h
-       M src/threads/native/lock.c
-       M src/threads/native/threads.c
-       AM src/vmcore
-       A src/vmcore/options.h
-       A src/vmcore/zip.c
-       A src/vmcore/suck.c
-       A src/vmcore/class.c
-       A src/vmcore/loader.c
-       A src/vmcore/zip.h
-       A src/vmcore/annotation.c
-       A src/vmcore/suck.h
-       A src/vmcore/class.h
-       A src/vmcore/rt-timing.c
-       A src/vmcore/loader.h
-       A src/vmcore/descriptor.c
-       A src/vmcore/resolve.c
-       A src/vmcore/annotation.h
-       A src/vmcore/rt-timing.h
-       A src/vmcore/method.c
-       A src/vmcore/descriptor.h
-       A src/vmcore/resolve.h
-       A src/vmcore/method.h
-       A src/vmcore/references.h
-       A src/vmcore/classcache.c
-       A src/vmcore/statistics.c
-       A src/vmcore/.cvsignore
-       A src/vmcore/classcache.h
-       A src/vmcore/statistics.h
-       A src/vmcore/stackmap.c
-       A src/vmcore/stackmap.h
-       A src/vmcore/field.c
-       A src/vmcore/linker.c
-       A src/vmcore/utf8.c
-       A src/vmcore/field.h
-       A src/vmcore/Makefile.am
-       A src/vmcore/linker.h
-       A src/vmcore/options.c
-       A src/vmcore/utf8.h
-       M src/cacaoh/cacaoh.c
-       M src/cacaoh/headers.h
-       M src/cacaoh/Makefile.am
-       M src/cacaoh/headers.c
-       A src/cacaoh/dummy.c
-       M configure.ac
-
-2007-01-29 11:52  twisti
-
-       * src/vm/jit/arm/emit.c [ENABLE_SOFTFLOAT] (emit_load): Implemented.
-       (emit_store): Changed implementation to be more clear.
-       (emit_copy): Likewise.
-
-2007-01-29 10:19  twisti
-
-       * src/vm/jit/arm/codegen.c (codegen): ICMD_DASTORE: bugfix for
-       softfloat.
-
-2007-01-28 23:35  twisti
-
-       * src/vm/jit/mips/codegen.c (createcompilerstub): Don't generate a
-       codeinfo.
-
-2007-01-28 22:57  twisti
-
-       * src/vm/jit/arm/codegen.c (createcompilerstub): Don't generate a
-       codeinfo.
-
-2007-01-27 15:52  twisti
-
-       * configure.ac: Use AC_CHECK_SOFTFLOAT, AC_CHECK_SOFT_FLOAT_CMP and
-       AC_CHECK_SOFT_DOUBLE_CMP.
-       * m4/soft.m4: New file.
-       
-       * src/vm/builtin.c [!SUPPORT_FLOAT_CMP] (builtin_fcmpl): Added
-       conditional.
-       [!SUPPORT_DOUBLE_CMP] (builtin_dcmpl): Likewise.
-       
-       * src/vm/builtintable.inc (builtintable_automatic):
-       [!SUPPORT_FLOAT_CMP] (BUILTIN_fcmpl): Added.
-       [!SUPPORT_DOUBLE_CMP] (BUILTIN_dcmpl): Likewise.
-       (builtintable_function): [__MIPS__ && SIZEOF_VOID_P != 4]
-       (BUILTIN_arraycopy): Added.
-       
-       * src/vm/jit/mips/codegen.c (codegen): Added SUPPORT_FLOAT_CMP for
-       ICMD_FCMPx, and SUPPORT_DOUBLE_CMP for ICMD_DCMPx.
-       
-       * src/vm/jit/arm/arch.h (SUPPORT_FLOAT_CMP, SUPPORT_DOUBLE_CMP):
-       Added.
-       * src/vm/jit/powerpc/arch.h: Likewise.
-       * src/vm/jit/sparc64/arch.h: Likewise.
-       * src/vm/jit/alpha/arch.h: Likewise.
-       * src/vm/jit/s390/arch.h: Likewise.
-       * src/vm/jit/mips/arch.h: Likewise.
-       * src/vm/jit/parisc/arch.h: Likewise.
-       * src/vm/jit/m68k/arch.h: Likewise.
-       * src/vm/jit/i386/arch.h: Likewise.
-       * src/vm/jit/powerpc64/arch.h: Likewise.
-       * src/vm/jit/x86_64/arch.h: Likewise.
-       
-       * src/vm/jit/mips/patcher.c (vm/jit/md.h): Added.
-
-2007-01-27 13:01  twisti
-
-       * src/vm/loader.c (load_newly_created_array): c->interfacescount was
-       always set to 0, fixed.
-
-2007-01-27 00:58  ajordan
-
-       * src/vm/jit/sparc64/emit.c: Moved exception check generation to emit
+       * src/threads/threads-common.c (threads_dump) [ENABLE_GC_CACAO]:
+       Added code to suspend and resume the thread (NOTE: Not tested!).
+       (threads_thread_print_stacktrace): Rewritten to work again.
+       [fa23c7f74264]
+
+       * src/mm/boehm.c, src/mm/codememory.c, src/native/jni.c,
+       src/native/localref.c, src/native/native.c,
+       src/native/vm/nativevm.c, src/threads/native/threads.c, src/threads
+       /threads-common.c, src/vm/builtin.c, src/vm/exceptions.c,
+       src/vm/finalizer.c, src/vm/jit/jit.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/package.c,
+       src/vm/primitive.c, src/vm/properties.c, src/vm/signal.c,
+       src/vm/string.c, src/vmcore/classcache.c, src/vmcore/linker.c,
+       src/vmcore/loader.c, src/vmcore/options.c, src/vmcore/options.h,
+       src/vmcore/primitivecore.c, src/vmcore/suck.c, src/vmcore/utf8.c:
+       * src/vmcore/options.c (opt_TraceSubsystemInitialization): Added.
+       * src/vmcore/options.h (TRACESUBSYSTEMINITIALIZATION): New macro.
+
+       * src/mm/boehm.c, src/mm/codememory.c, src/native/jni.c,
+       src/native/localref.c, src/native/native.c,
+       src/native/vm/nativevm.c, src/threads/native/threads.c, src/threads
+       /threads-common.c, src/vm/builtin.c, src/vm/exceptions.c,
+       src/vm/finalizer.c, src/vm/jit/jit.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/package.c,
+       src/vm/primitive.c, src/vm/properties.c, src/vm/signal.c,
+       src/vm/string.c, src/vmcore/classcache.c, src/vmcore/linker.c,
+       src/vmcore/loader.c, src/vmcore/primitivecore.c, src/vmcore/suck.c,
+       src/vmcore/utf8.c: Added TRACESUBSYSTEMINITIALIZATION to the *_init
        functions.
-       * src/vm/jit/sparc64/codegen.h: Likewise.
-       * src/vm/jit/sparc64/codegen.c: Likewise.
-       
-       * src/vm/jit/sparc64/md.c: Added SPARC specific functions for getting
-       JIT information from the stack frame.
-       
-       * src/vm/jit/sparc64/linux/md-os.c: Fixed icache flushing when start
-       address is not doubleword aligned.
+       [6d9f949cf40f]
 
-2007-01-23 13:05  twisti
+       * src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.c: Use int instead of int32_t for opt_*
+       variables.
+       * src/vmcore/options.h: Likewise.
+       [4df71b1bfc9e]
 
-       * src/vm/jit/mips/emit.c (emit_patcher_stubs): Use
-       dseg_add_functionptr instead of dseg_add_address.
+2008-02-17  Edwin Steiner  <edwin.steiner@gmx.net>
 
-2007-01-22 20:16  twisti
+       * contrib/vmlog/vmlog_cacao.c:
+       * contrib/vmlog/vmlog_cacao.c (vmlog_cacao_do_log): Deal with
+       m->class == NULL.
+       [0bb3cb112e99]
 
-       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (postInit):
-       Added missing file://.
+       * Merged the "edwin-replacement" branch that I pushed accidentally.
+       [a96003ee3eda]
 
-2007-01-22 17:25  twisti
+       * src/vm/signal.c:
+       * src/vm/signal.c (signal_handle): vmlog signal type.
+       [a73070c07207]
 
-       * src/cacao/cacao.c (main): Fixed typo.
+       * src/vm/signal.c:
+       * src/vm/signal.c (signal_handle): vmlog signal type.
+       [4d5807b92748]
 
-2007-01-22 17:22  twisti
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (md_pop_stackframe): New function.
+       (md_push_stackframe): New function. (replace_pop_activation_record):
+       Factored out popping of the stack frame into md_pop_stackframe.
+       (replace_push_activation_record): Factored out pushing of the stack
+       frame into md_push_stackframe.
+       [32ee42dff4a2]
 
-       * src/lib/vm/reference/gnu/classpath/VMSystemProperties.java: New
-       file.
-       
-       * src/lib/Makefile.am (VM_JAVA_FILES): Added
-       gnu/classpath/VMSystemProperties.java.
-       (VM_CLASS_FILES): Likewise.
-       
-       * src/native/include/Makefile.am (VM_ZIP): Added.
-       (DO_HEADER_FILES): Depend on VM_ZIP.
+2008-02-16  Edwin Steiner  <edwin.steiner@gmx.net>
 
-2007-01-22 17:03  twisti
+       * src/vm/jit/code.c, src/vm/jit/code.h:
+       * src/vm/jit/code.h (code_codeinfo_println): New debugging helper.
+       * src/vm/jit/code.c (code_codeinfo_println): Likewise.
+       [97ae058719af]
 
-       * src/vm/properties.c (properties_get): Search list forward, as we
-       don't have duplicate entries anymore.
-       (properties_system_add): New function.
-       * src/vm/properties.h (properties_system_add): Added.
-       
-       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (postInit): New
+       * contrib/vmlog/vmlog_cacao.c, contrib/vmlog/vmlog_cacao.h:
+       * contrib/vmlog/vmlog_cacao.h (vmlog_cacao_signl_type): New
        function.
+       * contrib/vmlog/vmlog_cacao.c (vmlog_cacao_signl_type): Likewise.
+       [ae50a5fdf56f]
+
+2008-02-15  Edwin Steiner  <edwin.steiner@gmx.net>
+
+       * src/vmcore/options.c:
+       * src/vmcore/options.c (TraceJavaCalls): Remove this option when
+       vmlog is enabled. (It does not have the expected effect then).
+       [2015ddd5c931]
+
+       * contrib/vmlog/vmlog.c, contrib/vmlog/vmlog.h,
+       contrib/vmlog/vmlog_cacao.c, contrib/vmlog/vmlog_cacao.h,
+       src/cacaoh/dummy.c, src/vm/vm.c, src/vmcore/options.c:
+       * src/vmcore/options.c (options_xx): Integrated vmlog options
+       handling.
+       * src/vm/vm.c (vm_create): Changed vmlog init interface.
+       * src/cacaoh/dummy.c (vmlog_cacao_set_prefix,
+       vmlog_cacao_set_stringprefix, vmlog_cacao_set_ignoreprefix): Dummies
+       added.
+       * contrib/vmlog/vmlog.h, contrib/vmlog/vmlog.c,
+       contrib/vmlog/vmlog_cacao.h, contrib/vmlog/vmlog_cacao.c: Changed
+       vmlog init interface.
+       [921f7f0fd054]
+
+       * contrib/vmlog/vmlog_cacao.c, contrib/vmlog/vmlog_cacao.h:
+       * contrib/vmlog/vmlog_cacao.c, contrib/vmlog/vmlog_cacao.h: Replaced
+       the old java_objectheader with java_object_t. Adapted lock function
+       calls. This makes cacao compile with --enable-vmlog again.
+       [e7178d529ced]
+
+2008-02-15  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/jit.h, src/vm/jit/optimizing/Makefile.am,
+       src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa2.c,
+       src/vm/jit/optimizing/ssa2.h, src/vm/jit/optimizing/ssa3.c,
+       src/vm/jit/python.c:
+       * src/vm/jit/jit.h (FOR_EACH_BASICBLOCK, FOR_EACH_SUCCESSOR,
+       FOR_EACH_PREDECESSOR, FOR_EACH_INSTRUCTION, basicblock_reached): New
+       symbols.
+       * src/vm/jit/optimizing/Makefile.am (SSA_SOURCES) [ENABLE_SSA]: AddeAd
+       ssa3.c
+       * src/vm/jit/optimizing/ssa.c: Adapted for ssa3.c.
+       * src/vm/jit/optimizing/ssa2.c: Added copyright header.
+       * src/vm/jit/optimizing/ssa3.c: New file. Yet another SSA
+       transofrmation algorithm prototype.
+       * src/vm/jit/python.c: Removed wrappers for creating variables and
+       instructions because they were misdesigned.
+       * src/vm/jit/optimizing/ssa2.h: Removed.
+       [ceb76d8a7b2b]
+
+2008-02-15  twisti  <twisti@vulture.theobroma-systems.com>
+
+       * src/vmcore/field.c:
+       * src/vmcore/field.c (field_print): Print offset for non-static
+       fields.
+       [c77728b36b0d]
+
+2008-02-14  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/codegen.h:
+       * src/vm/jit/powerpc/codegen.h (MI_and, MI_anddot, MI_andi,
+       MI_lwarx) (MI_or, MI_ordot, MI_ori, MI_subf, MI_subfdot,
+       MI_stwcxdot, MI_sync): New macros, these machine instruction macros
+       should make it easier to understand them.
+
+       * src/vm/jit/powerpc/codegen.c: Use new MI macros.
+       [96c26cc7065f]
+
+2008-02-14  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/optimizing/dominators.c:
+       * src/vm/jit/optimizing/dominators.c: Adapted for changes in
+       src/mm/dumpmemory.h.
+       [6a888becb172]
+
+2008-02-14  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_impl_thread_free): Use
+       vm_abort_errnum. (threads_list_lock): Likewise.
+       (threads_list_unlock): Likewise. (threads_mutex_gc_lock): Likewise.
+       (threads_mutex_gc_unlock): Likewise. (threads_mutex_join_lock):
+       Likewise. (threads_mutex_join_unlock): Likewise.
+       (threads_impl_thread_start): Likewise.
+       [b6e1edd8c04e]
+
+       * src/vm/vm.c, src/vm/vm.h:
+       * src/vm/vm.c (vm_abort_errnum): New function. (vm_abort_errno): Use
+       vm_abort_errnum.
+       * src/vm/vm.h (vm_abort_errnum): Added.
+       [60d2963cf5a0]
+
+       * src/vm/vm.c, src/vm/vm.h:
+       * src/vm/vm.c (vm_abort_errno): New function. (vmcore/system.h):
+       Added. (vm_abort): Use system_abort.
+
+       * src/vm/vm.h (stdint.h): Added. (vm_abort_errno): Likewise.
+       [7437e7e4efd6]
+
+       * configure.ac, src/vmcore/system.h:
+       * configure.ac (AC_CHECK_FUNCS): Added abort.
+
+       * src/vmcore/system.h (system_abort): New function.
+       (system_strerror): Likewise.
+       [fb6e241c3df9]
+
+       * tests/regression/Makefile.am,
+       tests/regression/assertion/Makefile.am,
+       tests/regression/codepatching/Makefile.am,
+       tests/regression/jasmin/Makefile.am,
+       tests/regression/native/Makefile.am,
+       tests/regression/resolving/Makefile.am:
+       * tests/regression/Makefile.am: Always use the same bootclasspath
+       for different configurations, it does not matter.
+
+       * tests/regression/assertion/Makefile.am,
+       tests/regression/codepatching/Makefile.am,
+       tests/regression/jasmin/Makefile.am,
+       tests/regression/native/Makefile.am,
+       tests/regression/resolving/Makefile.am: Likewise
+       [4574d7b390ca]
+
+       * * Merged with 3683e6f66d90.
+       [ac5846955a0b]
+
+       * configure.ac, tests/regression/Makefile.am:
+       * configure.ac (AC_CONFIG_FILES): Re-enabled resolving since Edwin
+       fixed the tests.
+       * tests/regression/Makefile.am: Likewise.
+       [37af3c98ade8]
+
+2008-02-11  Edwin Steiner  <edwin.steiner@gmx.net>
+
+       * tests/regression/resolving/TestController.java,
+       tests/regression/resolving/test_instance_subtype_violated.java, test
+       s/regression/resolving/test_param_loading_constraint_violated.java, t
+       ests/regression/resolving/test_param_loading_constraint_violated_der
+       ived.java,
+       tests/regression/resolving/test_param_subtype_violated.java,
+       tests/regression/resolving/test_return_subtype_ok.java,
+       tests/regression/resolving/test_return_subtype_violated.java, tests/
+       regression/resolving/test_retval_loading_constraint_violated.java,
+       tests/regression/resolving/test_simple_lazy_load.java:
+       * tests/regression/resolving/TestController.java: Better error
+       messages and more convenience methods (needed for following adaption
+       of tests).
+       [a6f28893a706]
+
+2008-02-14  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/toolbox/Makefile.am, src/toolbox/bitvector.h, src/toolbox/set.c,
+       src/toolbox/set.h, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/cfg.c, src/vm/jit/cfg.h, src/vm/jit/jit.c,
+       src/vm/jit/jit.h, src/vm/jit/optimizing/Makefile.am,
+       src/vm/jit/optimizing/dominators.c,
+       src/vm/jit/optimizing/dominators.h, src/vm/jit/optimizing/ssa.c,
+       src/vm/jit/optimizing/ssa2.c, src/vm/jit/optimizing/ssa2.h,
+       src/vm/jit/python.c, src/vm/jit/python.h, src/vm/jit/show.c:
+       * src/toolbox/Makefile.am (libtoolbox_la_SOURCES): Added set.[ch]
+       * src/toolbox/bitvector.h: Added missing include
+
+       * src/toolbox/set.c, src/toolbox/set.h: New file. Set (of pointers)
+       implementation.
+
+       * src/vm/jit/allocator/simplereg.c [ENABLE_SSA]: Fix for SSA.
+
+       * src/vm/jit/cfg.c, src/vm/jit/cfg.h (cfg_insert_successors,
+       cfg_add_root): New functions. (cfg_build): Using controlflow
+       constants rather than opcodes, fixed multiple
+       predecessors/successors problem.
+
+       * src/vm/jit/jit.c, src/vm/jit/jit.h: Added various inline accessors
+       for varinfo and instruction. (basicblock [ENABLE_SSA]): Added new
+       fields.
+
+       * src/vm/jit/optimizing/Makefile.am (SSA_SOURCES): Added ssa2.c.
+       * src/vm/jit/optimizing/dominators.c,
+       src/vm/jit/optimizing/dominators.h: Added cleaned up dominator tree
+       and dominance frontier implementation.
+
+       * src/vm/jit/optimizing/ssa.c: Hooked in cleaned up ssa and
+       dominators.
+
+       * src/vm/jit/optimizing/ssa2.c, src/vm/jit/optimizing/ssa2.h: New
+       (temporary) files. Added cleanead up ssa implementation. Currently
+       renames only locals and passes all dacapo benchmarks.
+
+       * src/vm/jit/python.c. src/vm/jit/python.h: Changed a lot.
+
+       * src/vm/jit/show.c (show_basicblock): Support NULL
+       bptr->javalocals.
+       [3683e6f66d90]
+
+2008-02-14  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * * Merged with fd492236e7ac.
+       [fb5bf733f6ef]
+
+2008-02-10  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/native.c, src/native/native.h, src/native/vm/Makefile.am,
+       src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/cldc1.1/java_lang_Runtime.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/java_lang_Runtime.c,
+       src/native/vm/java_lang_Runtime.h, src/native/vm/sun/jvm.c:
+       * src/native/native.c (native_library_load): New function.
+       * src/native/native.h: Likewise.
 
-2007-01-22 15:59  twisti
-
-       * src/vm/jit/mips/md.c (md_get_method_patch_address): Fixed compiler
-       warning.
-
-2007-01-22 14:02  twisti
-
-       * src/cacao/cacao.c (main): Fixed compiler warning.
-
-2007-01-22 11:45  twisti
-
-       * src/vm/jit/arm/codegen.c (vm/jit/md.h): Added.
-       * src/vm/jit/arm/patcher.c (vm/jit/md.h): Likewise.
-
-2007-01-22 01:43  ajordan
-
-       * src/vm/jit/sparc64/codegen.h: Fixed big disp handling.
-       * src/vm/jit/sparc64/codegen.c: Likewise.
-
-2007-01-22 00:58  twisti
-
-       * src/vm/jit/jit.h (md_init, md_get_method_patch_address,)
-       (md_cacheflush, md_icacheflush, md_dcacheflush, intrp_md_init):
-       Removed.
-       
-       * src/vm/jit/md.h: New file.
-       * src/vm/jit/Makefile.am (noinst_HEADERS): Added md.h.
-       
-       * src/vm/jit/jit.c (vm/jit/md.h): Added.
-       * src/vm/jit/codegen-common.c (vm/jit/md.h): Likewise.
-       * src/vm/vm.c (vm/jit/md.h): Likewise.
-
-2007-01-19 01:13  edwin
-
-       * src/vm/options.h, src/vm/method.c, src/vm/jit/inline/inline.c,
-       src/vm/jit/jit.c, src/vm/vm.c, src/vm/linker.c, src/vm/options.c,
-       src/cacaoh/headers.c: Cleaned up inlining options.
-       
-       * src/vm/exceptions.c: Removed a left-over use of "useinlining".
-       
-       * configure.ac: New configure flag --enable-inlining-debug.
+       * src/native/vm/java_lang_Runtime.c: Removed.
+       * src/native/vm/java_lang_Runtime.h: Likewise.
 
-2007-01-18 13:21  twisti
+       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Removed
+       java_lang_Runtime.[ch].
 
-       * src/vm/jit/arm/md-asm.h: Renamed argument defines to start with 0.
-       * src/vm/jit/arm/asmpart.S: Likewise.
+       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c
+       (native/vm/java_lang_Runtime.h): Removed. (loadLibrary): Implemented
+       directly.
 
-2007-01-18 13:11  twisti
+       * src/native/vm/cldc1.1/java_lang_Runtime.c (vm/types.h): Removed.
+       (stdint.h): Added. (mm/gc-common.h): Likewise.
+       (native/vm/java_lang_Runtime.h): Removed. (vm/vm.h): Added.
+       (vmcore/utf8.h): Likewise. (exitInternal): Implemented directly.
+       (freeMemory): Likewise. (totalMemory): Likewise. (gc): Likewise.
 
-       * src/vm/vm.c (usage): Removed CACAO options.
-       (XXusage): New function.
-       (vm_create): Handle OPT_XX.
+       * src/native/vm/gnu/java_lang_VMRuntime.c
+       (native/vm/java_lang_Runtime.h): Removed. (finalizeOnExit): Added.
+       (exit): Likewise. (freeMemory): Likewise. (totalMemory): Likewise.
+       (gc): Likewise. (runFinalizersOnExit): Likewise. (nativeLoad):
+       Likewise.
 
-2007-01-18 12:55  twisti
+       * src/native/vm/sun/jvm.c (native/vm/java_lang_Runtime.h): Removed.
+       (JVM_StartThread): Implemented directly. (JVM_SetThreadPriority):
+       Likewise. (JVM_Sleep): Likewise. (JVM_IsInterrupted): Likewise.
+       [ca8d8d2c5849]
 
-       * src/vm/jit/powerpc/asmpart.S (asm_compare_and_swap): New function.
-       (asm_memory_barrier): Likewise.
+2008-02-09  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-01-18 11:43  twisti
+       * m4/annotations.m4:
+       * m4/annotations.m4 (AC_CHECK_ENABLE_ANNOTATIONS): Changed default
+       value for different configurations.
+       (AC_CHECK_ENABLE_ANNOTATIONS_DEFAULT): New function.
+       [4549e77186f0]
 
-       * src/vm/jit/mips/md-asm.h (RESTORE_ARGUMENT_REGISTERS)
-       (RESTORE_ARGUMENT_REGISTERS, SAVE_TEMPORARY_REGISTERS)
-       (RESTORE_TEMPORARY_REGISTERS): Added missing float registers.
-       
-       * src/vm/jit/mips/asmpart.S (asm_patcher_wrapper): Changed stack size
-       for float registers.
+       * m4/jni.m4:
+       * m4/jni.m4 (AC_CHECK_ENABLE_JNI): Changed the comment for the
+       default value.
+       [a447b8c5bb58]
 
-2007-01-16 22:18  pm
+       * src/vmcore/loader.h:
+       * src/vmcore/loader.h (classbuffer): Use stdint data types.
+       [1e47ce633f93]
 
-       Initial import of s390 codegen, codebase is copyed from x86_64.
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_sigsuspend_handler):
+       Commented.
+       [d930c08c092e]
+
+       * src/vmcore/options.c:
+       * src/vmcore/options.c [HAVE_STRING_H] (string.h): Removed.
+       (vmcore/system.h): Added. (options_get): Use system_* functions.
+       (options_xxusage): Likewise.
+       [f88473e0fdfb]
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_NewLocalRef): Fixed compiler warning.
+       (_Jv_JNI_GetObjectField): Likewise. (_Jv_JNI_GetStaticObjectField):
+       Likewise. (_Jv_JNI_GetDirectBufferAddress): Likewise.
+       [e101e1fc5cae]
+
+       * src/mm/memory.c:
+       * src/mm/memory.c (memory_thread): Fixed compiler warning.
+       [17b0b5f95809]
+
+2008-02-13  Roland Lezuo  <tbfg@complang.tuwien.ac.at>
+
+       * src/vm/jit/m68k/md.c, src/vm/jit/m68k/md.h:
+       (src/vm/jit/m68k/md.c): md_stacktrace_get_returnaddress needs to be
+       exported. (src/vm/jit/m68k/md.h): Likewise.
+       [fd492236e7ac]
+
+2008-02-13  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (version): Changed copyright message.
+       [1e10765ce305]
+
+2008-02-09  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * m4/ac_prog_javac.m4, src/lib/Makefile.am,
+       tests/regression/Makefile.am,
+       tests/regression/assertion/Makefile.am,
+       tests/regression/codepatching/Makefile.am,
+       tests/regression/native/Makefile.am:
+       * m4/ac_prog_javac.m4 (AC_PROG_JAVAC): Removed jikes and
+       -bootclasspath.
+
+       * src/lib/Makefile.am (BOOTCLASSPATH): Added.
+
+       * tests/regression/Makefile.am (BOOTCLASSPATH): Likewise. (JAVACMD):
+       Likewise. (JAVACCMD): Likewise.
+
+       * tests/regression/assertion/Makefile.am: Likewise.
+       * tests/regression/codepatching/Makefile.am: Likewise.
+       * tests/regression/native/Makefile.am: Likewise.
+       [3b3c3e5de94b]
+
+2008-02-08  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac:
+       * configure.ac (AC_CONFIG_FILES): Removed resolving.
+       [aae21148aa9b]
+
+       * src/vm/string.c:
+       * src/vm/string.c (literalstring_free): Commented out, since it's
+       currently not used.
+       [3066b22b8c76]
+
+       * configure.ac, src/vm/assertion.c, src/vmcore/system.h:
+       * configure.ac (AC_CHECK_FUNCS): Added strlen.
+
+       * src/vm/assertion.c [HAVE_STRING_H] (string.h): Removed.
+       (vmcore/system.h): Added. (assertion_ea_da): Use system_* functions.
+       Fixed crash: use list_add_last_unsynced instead of list_add_last.
+
+       * src/vmcore/system.h (system_strdup): New function.
+       (system_strlen): Likewise.
+       [611f3dff023e]
+
+       * src/vm/jit/arm/Makefile.am, src/vm/jit/i386/Makefile.am,
+       src/vm/jit/m68k/Makefile.am, src/vm/jit/mips/Makefile.am,
+       src/vm/jit/powerpc/Makefile.am, src/vm/jit/powerpc64/Makefile.am,
+       src/vm/jit/s390/Makefile.am, src/vm/jit/sparc64/Makefile.am,
+       src/vm/jit/x86_64/Makefile.am:
+       * src/vm/jit/arm/Makefile.am (libarch_la_SOURCES): Added md.h.
+
+       * src/vm/jit/i386/Makefile.am, src/vm/jit/m68k/Makefile.am,
+       src/vm/jit/mips/Makefile.am, src/vm/jit/powerpc/Makefile.am,
+       src/vm/jit/powerpc64/Makefile.am, src/vm/jit/s390/Makefile.am,
+       src/vm/jit/sparc64/Makefile.am, src/vm/jit/x86_64/Makefile.am:
+       Likewise.
+       [a8894d776f9c]
 
-2007-01-16 12:59  twisti
+       * src/vm/jit/intrp/Makefile.am:
+       * src/vm/jit/intrp/Makefile.am ($(BUILT_SOURCES)): Use $(SHELL) to
+       call vmgenx.
+       [398ee2cea293]
 
-       * src/cacaoh/headers.c (asm_compare_and_swap): Added.
-       (asm_memory_barrier): Likewise.
+       * tests/regression/native/Makefile.am:
+       * tests/regression/native/Makefile.am (JAVAHFLAGS): Added.
+       [b216ffaa1e84]
 
-2007-01-16 12:52  twisti
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_call_method_objectarray): Fixed compiler warning.
+       [4849299bd8de]
 
-       * src/vm/jit/x86_64/asmpart.S (asm_patcher_wrapper): Removed unused
-       sizestackframeinfo.
+2008-02-07  Stefan Ring  <stefan@complang.tuwien.ac.at>
 
-2007-01-16 09:54  twisti
+       * src/threads/native/lock.c, src/threads/native/lock.h,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/native/lock.c: Fixed copyright message.
 
-       * src/vm/jit/asmpart.h (asm_compare_and_swap): Added.
-       (asm_memory_barrier): Likewise.
-       
-       * src/vm/jit/alpha/asmpart.S (asm_compare_and_swap): New function.
-       (asm_memory_barrier): Likewise.
+       * src/threads/native/lock.h, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/threads-common.c,
+       src/threads/threads-common.h: Likewise.
+       [2f37becb4a5c]
 
-2007-01-15 10:28  twisti
+       * src/threads/native/lock.c:
+       * src/threads/native/lock.c (notify_flc_waiters): Another deadlock
+       fix.
+       [d283bd3bbb3d]
 
-       * src/vm/jit/powerpc64/codegen.c (codegen): Ported replacement.
+2008-02-06  Stefan Ring  <stefan@complang.tuwien.ac.at>
 
-2007-01-13 22:54  edwin
+       * src/threads/native/lock.c:
+       * src/threads/native/lock.c (lock_monitor_wait,
+       lock_monitor_notify): Bugfix for previous commit, could cause
+       threads to hang forever.
+       [c2c8e3043369]
 
-       * src/vm/jit/verify/typecheck-typeinferer.c: Check basic types in
-       debug mode.
+       * src/threads/native/lock.c, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/vm/global.h:
+       * src/threads/native/lock.c: Implemented Sable extension to tasuki
+       lock.
+       * src/threads/native/threads.c: Likewise.
+       * src/threads/native/threads.h: Likewise.
 
-2007-01-13 22:44  edwin
+       * src/vm/global.h: Removed hdrflags.
+       [2988182011bb]
 
-       * src/vm/jit/verify/generate.pl: Further changes for the type inferer.
-       
-       * src/vm/jit/verify/typecheck-typeinferer-gen.inc: Regenerated.
+       * Merge (tasuki lock modification backout)
+       [a80e9dea4e55]
 
-2007-01-13 22:39  edwin
+       * src/threads/native/lock.c, src/vm/global.h:
+       Backed out changeset 9c85e9af47c9
+       [f79e2f05c4a1]
 
-       * src/vm/rt-timing.h: Fixed position of #include "config.h".
-       (rt_timing_diff_usec): Export.
-       
-       * src/vm/rt-timing.c (rt_timing_diff_usec): Export.
+2008-02-05  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-01-13 22:37  edwin
+       * src/cacaoh/dummy.c:
+       * src/cacaoh/dummy.c (vm/exceptions.h): Added.
+       (exceptions_throw_incompatibleclasschangeerror): Fixed signature.
+       (exceptions_throw_verifyerror): Likewise.
+       (exceptions_throw_unsupportedclassversionerror): Likewise.
+       [37ec16a94863]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/codegen-common.c (codegen_reg_of_var): Removed unused
+       conditional move code. This will not be implemented in the baseline
+       compiler.
+       * src/vm/jit/x86_64/emit.c (emit_store): Likewise.
+       [458d51359eac]
+
+       * tests/regression/TestAnnotations.java:
+       * tests/regression/TestAnnotations.java: Fixed copyright header.
+       [e1d371396063]
+
+2008-02-04  Gregor Kaufmann  <tdn@inode.at>
+
+       * configure.ac, src/vm/vm.c, tests/regression/Makefile.am,
+       tests/regression/assertion/Makefile.am,
+       tests/regression/assertion/Test.sh,
+       tests/regression/assertion/disabled.output,
+       tests/regression/assertion/enabled.output,
+       tests/regression/assertion/packagetest/testassertions.java,
+       tests/regression/assertion/testassertions.java:
+       * configure.ac (AC_CONFIG_FILES): Added
+       tests/regression/assertion/Makefile
 
-       * src/vm/jit/jit.c (jit_compile_intern): Removed unused code and fixed
-       instrumentation.
+       * src/vm/vm.c (opts): Added OPT_EA_NOARG, OPT_EA_NOARG (vm_create):
+       Handle OPT_EA_NOARG, OPT_EA_NOARG
 
-2007-01-13 22:30  edwin
+       * tests/regression/Makefile.am (SUBDIRS): Added assertion
 
-       * src/vm/jit/inline/inline.c: Better inlining decisions. Implemented
-       knapsack heuristics. More statistics. Refactoring and fixes.
-       
-       * src/vm/jit/inline/inline_debug.inc: Fixed to make it compile.
+       * tests/regression/assertion/Makefile.a: New file
 
-2007-01-13 16:52  ajordan
+       * tests/regression/assertion/Test.sh: New file
 
-       * src/vm/jit/sparc64/md-abi.h: The JIT stackframes now also includes
-       the 6 parameter slots required when doing a ABI compliant C call.
-       * src/vm/jit/sparc64/emit.c: Likewise.
-       * src/vm/jit/sparc64/codegen.c: Likewise.
-       * src/vm/jit/sparc64/patcher.c: Likewise.
-       * src/vm/jit/sparc64/asmpart.S: Likewise.
-       
-       * src/vm/jit/sparc64/codegen.h: Added include.
-       
-       * src/vm/jit/sparc64/md.c: Added method, to get framepointer from
-       saved register window. (for temporary fix in JIT stack walking)
+       * tests/regression/assertion/disabled.output: New file
 
-2007-01-12 17:13  twisti
+       * tests/regression/assertion/enabled.output: New file
 
-       * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Use
-       codegen_get_pv_from_pc.
+       * tests/regression/assertion/packagetest/testassertions.java: New
+       file
 
-2007-01-11 22:39  twisti
+       * tests/regression/assertion/testassertions.java: New file
+       [f00e0894e74b]
 
-       * src/vm/jit/mips/md-abi.h: Merged MIPS32 code.
-       * src/vm/jit/mips/emit.c: Likewise.
-       * src/vm/jit/mips/codegen.c: Likewise.
-       * src/vm/jit/mips/codegen.h: Likewise.
-       * src/vm/jit/mips/linux/md-os.c: Likewise.
-       * src/vm/jit/mips/asmpart.S: Likewise.
-       * src/vm/jit/mips/md-abi.c: Likewise.
+2008-02-04  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-01-11 22:36  twisti
+       * m4/annotations.m4:
+       * m4/annotations.m4: Build annotations support by default.
+       [76cce852d53a]
 
-       * src/mm/memory.c (mem_realloc): Fixed compiler warning.
+       * src/mm/cacao-gc/gc.c:
+       * src/mm/cacao-gc/gc.c (gc_collect) [!NDEBUG]: Fixed compilation.
+       [5cba4c25093b]
 
-2007-01-11 14:59  twisti
+       * * Merged with 9c85e9af47c9.
+       [8f3fbc9270d5]
 
-       * file:///ahome/cacao/svn/cacao-m68k/trunk: Moved to...
-       * file:///ahome/cacao/svn/cacao/trunk/src/vm/jit/m68k: ...here.
+2008-01-30  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-01-11 14:28  twisti
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (native/vm/java_lang_ClassLoader.h):
+       Removed.
+       [7b1c5b9fe819]
 
-       * src/vm/exceptions.c (exceptions_throw_internalerror): Don't return a
-       value.
-       (exceptions_throw_outofmemoryerror): Likewise.
+       * src/native/jni.c, src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_ClassLoader.h:
+       * src/native/vm/java_lang_ClassLoader.c: Removed.
+       * src/native/vm/java_lang_ClassLoader.h: Likewise.
 
-2007-01-11 14:22  twisti
+       * src/native/vm/Makefile.am (CLASSLOADER_SOURCES): Removed.
+       (libnativevm_la_SOURCES): Removed CLASSLOADER_SOURCES.
 
-       * src/vm/jit/arm/emit.c (emit_exception_stubs): Renamed eref to er,
-       use md_codegen_patch_branch.
-       
-       * src/vm/jit/arm/codegen.c (codegen): Use codegen_resolve_branchrefs,
-       use exceptions_throw_internalerror.
-       
-       * src/vm/jit/arm/codegen.h (M_STACK_LOAD_FLT_TYPED): Removed.
-       (M_STACK_STORE_FLT_TYPED): Likewise.
+       * src/native/jni.c [ENABLE_JAVASE]
+       (native/vm/java_lang_ClassLoader.h): Removed.
 
-2007-01-11 14:19  twisti
+       * src/native/vm/gnu/java_lang_VMClassLoader.c
+       (native/vm/java_lang_ClassLoader.h): Removed. (defineClass): Moved
+       implementation here.
+       [e02ee62bf5fe]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_DefineClassWithSource): Made data
+       argument non-const.
+       [7c595dadbd5f]
+
+       * src/native/jni.c, src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/sun_misc_Unsafe.c, src/vmcore/class.c,
+       src/vmcore/class.h:
+       * src/vmcore/class.c (class_define): Made data argument non-const.
+       * src/vmcore/class.h: Likewise.
+       * src/native/jni.c (_Jv_JNI_DefineClass): Likewise.
+       * src/native/vm/java_lang_ClassLoader.c (defineClass): Likewise.
+       * src/native/vm/sun_misc_Unsafe.c (defineClass): Likewise.
+       [6495c4982eec]
+
+       * src/vm/properties.c, src/vmcore/system.h:
+       * src/vm/properties.c (properties_set): Use system_access.
+       * src/vmcore/system.h (system_access): New function.
+       [1b6a824c642d]
+
+       * configure.ac, src/vmcore/suck.c, src/vmcore/system.h:
+       * configure.ac (AC_CHECK_FUNCS): Added fclose, fread, stat.
+
+       * src/vmcore/suck.c (dirent.h): Removed. (sys/stat.h): Likewise.
+       (vmcore/system.h): Added. (suck_add_from_property): Use
+       system_scandir. (suck_start): Use system_fopen, system_stat,
+       system_fread, system_fclose.
+
+       * src/vmcore/system.h [HAVE_DIRENT_H] (dirent.h): Added.
+       [HAVE_STDIO_H] (stdio.h): Likewise. [HAVE_SYS_STAT_H] (sys/stat.h):
+       Likewise. (system_fopen): New function. (system_fclose): Likewise.
+       (system_fread): Likewise. (system_scandir): Likewise. (system_stat):
+       Likewise.
+       [d36156ecb50a]
+
+       * src/vm/properties.c, src/vmcore/system.h:
+       * src/vm/properties.c [WITH_JRE_LAYOUT] (libgen.h): Removed.
+       (vmcore/system.h): Added. (properties_set): Use system_dirname.
+
+       * src/vmcore/system.h [WITH_JRE_LAYOUT && HAVE_LIBGEN_H] (libgen.h):
+       Added. [WITH_JRE_LAYOUT] (system_dirname): New function.
+       [9c7fe3420ab9]
+
+       * src/native/jni.c:
+       * src/native/jni.c: Pre-define java_lang_ClassLoader to prevent a
+       compiler warning for Sun configurations.
+       [a91f4c3437d5]
+
+2008-02-03  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/threads/native/lock.c, src/vm/global.h:
+       * src/threads/native/lock.c: Modified tasuki lock such that the FLC
+       bit can be placed in the lockword. Requires atomic instruction at
+       monitor_exit (slower!).
+
+       * src/vm/global.h: Removed useless hdrflags and FLC bit value.
+       [9c85e9af47c9]
+
+2008-02-02  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/vm/jit/i386/machine-instr.h, src/vm/jit/x86_64/machine-instr.h:
+       * src/vm/jit/i386/machine-instr.h (MEMORY_BARRIER_AFTER_ATOMIC): Can
+       become a real NOP. (MEMORY_BARRIER_BEFORE_ATOMIC): Likewise.
+
+       * src/vm/jit/x86_64/machine-instr.h (MEMORY_BARRIER_AFTER_ATOMIC):
+       Can become a real NOP. (MEMORY_BARRIER_BEFORE_ATOMIC): Likewise.
+       [fe3e80ca2479]
+
+       * src/vm/signal.c:
+       * src/vm/signal.c (signal_init): Disable CrashReporter on Darwin.
+       [9bc8277affc1]
+
+2008-02-01  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/threads/native/lock.c:
+       * src/threads/native/lock.c (lock_monitor_enter): Adjusted memory
+       barrier. (lock_monitor_exit): Likewise.
+       [f31015208523]
+
+2008-01-30  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/mm/cacao-gc/gc.c, src/native/native.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c, src/vm/builtin.c,
+       src/vm/jit/intrp/codegen.c, src/vm/jit/jit.c,
+       src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa_rename.c,
+       src/vm/jit/patcher-common.c, src/vm/jit/replace.c,
+       src/vm/jit/show.c, src/vm/jit/trace.c, src/vm/vm.c,
+       src/vmcore/class.c, tests/regression/Makefile.am:
+       * src/mm/cacao-gc/gc.c: Fixed copyright message.
+
+       * src/native/native.c, src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/vm/builtin.c, src/vm/jit/intrp/codegen.c, src/vm/jit/jit.c,
+       src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa_rename.c,
+       src/vm/jit/patcher-common.c, src/vm/jit/replace.c,
+       src/vm/jit/show.c, src/vm/jit/trace.c, src/vm/vm.c,
+       src/vmcore/class.c, tests/regression/Makefile.am: Likewise.
+       [c6a257150aa2]
+
+       * src/mm/dumpmemory.c, src/mm/dumpmemory.h, src/mm/memory.h,
+       src/vm/jit/ir/bytecode.c, src/vm/jit/ir/bytecode.h:
+       * Merged with 0da121c758b9.
+       [b3689d718218]
+
+2008-01-22  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * * Merged with 03e39cff22db.
+       [61bb218662ef]
+
+       * m4/assertion.m4, m4/dump.m4, src/mm/codememory.c,
+       src/mm/codememory.h, src/mm/dumpmemory.c, src/mm/dumpmemory.h,
+       src/mm/memory.c, src/mm/memory.h, src/native/vm/sun_misc_Unsafe.c,
+       src/vm/array.c, src/vm/array.h, src/vm/assertion.c,
+       src/vm/assertion.h, src/vm/jit/exceptiontable.c,
+       src/vm/jit/exceptiontable.h, src/vm/jit/ir/Makefile.am,
+       src/vm/jit/ir/bytecode.c, src/vm/jit/ir/bytecode.h,
+       src/vm/jit/linenumbertable.c, src/vm/jit/linenumbertable.h,
+       src/vmcore/system.c, src/vmcore/system.h:
+       * m4/assertion.m4: Fixed copyright header.
+
+       * m4/dump.m4, src/mm/codememory.c, src/mm/codememory.h,
+       src/mm/dumpmemory.c, src/mm/dumpmemory.h, src/mm/memory.c,
+       src/mm/memory.h, src/native/vm/sun_misc_Unsafe.c, src/vm/array.c,
+       src/vm/array.h, src/vm/assertion.c, src/vm/assertion.h,
+       src/vm/jit/exceptiontable.c, src/vm/jit/exceptiontable.h,
+       src/vm/jit/ir/Makefile.am, src/vm/jit/ir/bytecode.c,
+       src/vm/jit/ir/bytecode.h, src/vm/jit/linenumbertable.c,
+       src/vm/jit/linenumbertable.h, src/vmcore/system.c,
+       src/vmcore/system.h: Likewise.
+       [a8a8474e33d1]
+
+2008-01-29  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_EEXIST): Defined. (JVM_Open):
+       Implemented correctly.
+       [0da121c758b9]
+
+       * src/vm/properties.c:
+       * src/vm/properties.c (properties_set) [WITH_JRE_LAYOUT]: Set
+       java.home as HotSpot does, applications like Ant depend on it.
+       [f517570c02d6]
+
+2008-01-25  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/stacktrace.c:
+       * src/vm/jit/stacktrace.c (native/include/java_lang_Object.h):
+       Added. [WITH_CLASSPATH_GNU]
+       (native/include/gnu_classpath_Pointer.h): Likewise.
+       (stacktrace_print_exception): Fixed compiler warning.
+       [d129a9a3bd48]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_start_native_call): Fixed
+       compiler warning.
+       [bac5c4672afa]
 
-       * configure.ac [ENABLE_STATICVM] (AC_CHECK_LIB(dl)): Only perform the
-       check if we want a static VM.
-       (AC_CONFIG_FILES): Added src/vm/jit/arm/Makefile and
-       src/vm/jit/arm/linux/Makefile.
-       * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added arm.
+2008-01-23  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-01-11 13:58  twisti
+       * * Merged with 03e39cff22db.
+       [2e553378876c]
 
-       * Moved loaded arm files.
+2008-01-19  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-01-10 10:08  twisti
+       * src/vm/jit/ir/bytecode.c, src/vm/jit/ir/bytecode.h,
+       src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/optimizing/ssa.c,
+       src/vm/jit/optimizing/ssa_rename.c, src/vm/jit/parse.c:
+       * src/vm/jit/ir/bytecode.c (bytecode): New table.
+       * src/vm/jit/ir/bytecode.h (bytecode_t): New structure.
 
-       * src/vm/builtin.c (builtin_newarray): Removed debug output.
+       * src/vm/jit/jit.c (stackreq, jcommandsize, opcode_names): Removed.
+       * src/vm/jit/jit.h: Likewise.
 
-2007-01-10 10:03  twisti
+       * src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa_rename.c,
+       src/vm/jit/parse.c: Use new bytecode table.
+       [292ffaab432c]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/jit.c, src/vm/jit/show.c,
+       src/vm/vm.c:
+       * Merged with df1b780317c3.
+       [63d86c604330]
+
+       * src/cacaoh/dummy.c, src/mm/cacao-gc/gc.c, src/mm/dumpmemory.c,
+       src/mm/dumpmemory.h, src/mm/memory.h, src/native/native.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c, src/vm/builtin.c,
+       src/vm/jit/codegen-common.c, src/vm/jit/intrp/codegen.c,
+       src/vm/jit/jit.c, src/vm/jit/replace.c, src/vm/jit/show.c,
+       src/vm/jit/trace.c, src/vm/vm.c, src/vmcore/class.c,
+       src/vmcore/loader.c:
+       * src/mm/dumpmemory.c (dump_release): Renamed to dumpmemory_release.
+       (dump_size): Renamed to dumpmemory_marker.
+
+       * src/mm/dumpmemory.h: Likewise. (DMARKER, DRELEASE): New macros.
+
+       * src/cacaoh/dummy.c, src/mm/cacao-gc/gc.c, src/mm/memory.h,
+       src/native/native.c, src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/vm/builtin.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/intrp/codegen.c, src/vm/jit/jit.c, src/vm/jit/replace.c,
+       src/vm/jit/show.c, src/vm/jit/trace.c, src/vm/vm.c,
+       src/vmcore/class.c, src/vmcore/loader.c: Use new macros.
+       [12502d070d2d]
+
+       * tests/regression/Makefile.am:
+       * tests/regression/Makefile.am (SUBDIRS): Removed resolving. These
+       test are broken.
+       [f9ffd12e7a9f]
+
+2008-01-11  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/cacaoh/dummy.c, src/mm/dumpmemory.c, src/mm/dumpmemory.h,
+       src/vm/jit/verify/typeinfo.h:
+       * src/mm/dumpmemory.c (dump_alloc): Renamed to dumpmemory_get.
+       (dumpmemory_alloc): New function. (dump_realloc): Renamed to
+       dumpmemory_realloc.
+
+       * src/mm/dumpmemory.h (dump_allocation_t): Renamed useddumpsize to
+       used. (dumpinfo_t): Renamed currentdumpblock to block,
+       allocateddumpsize to allocated, useddumpsize to used. (DNEW, DMNEW,
+       DMREALLOC): Defined to new function names.
+
+       * src/cacaoh/dummy.c (dump_alloc): Renamed to dumpmemory_get.
+
+       * src/vm/jit/verify/typeinfo.h (DNEW_TYPEVECTOR): Use DMNEW.
+       (DMNEW_TYPEVECTOR): Likewise. (TYPEINFO_ALLOCMERGED): Likewise.
+       [cee30280dee5]
+
+       * src/vm/jit/patcher-common.c:
+       * src/vm/jit/patcher-common.c (patcher_handler): Fixed compiler
+       warning.
+       [c4732ead00cc]
+
+2008-01-22  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/arm/md.c:
+       * src/vm/jit/arm/md.c (md_asm_codegen_get_pv_from_pc): Removed.
+       [03e39cff22db]
+
+2008-01-17  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/jit.c, src/vm/jit/optimizing/Makefile.am,
+       src/vm/jit/optimizing/graph.c, src/vm/jit/optimizing/lifetimes.c,
+       src/vm/jit/optimizing/lsra.c, src/vm/jit/optimizing/lsra.h,
+       src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa.h,
+       src/vm/jit/optimizing/ssa_phi.c, src/vm/jit/optimizing/ssa_phi.h,
+       src/vm/jit/optimizing/ssa_rename.c,
+       src/vm/jit/optimizing/ssa_rename.h, src/vm/jit/show.c, src/vm/vm.c,
+       src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/jit.c, src/vm/jit/show.c, src/vm/vm.c,
+       src/vmcore/options.c, src/vmcore/options.h: Integrated Christian
+       Ullrichs changes related to SSA and LSRA. The diff against SVN
+       version 8144 was carefully integrated.
+
+       * src/vm/jit/optimizing/Makefile.am, src/vm/jit/optimizing/graph.c,
+       src/vm/jit/optimizing/lifetimes.c, src/vm/jit/optimizing/lsra.c,
+       src/vm/jit/optimizing/lsra.h, src/vm/jit/optimizing/ssa.c,
+       src/vm/jit/optimizing/ssa.h, src/vm/jit/optimizing/ssa_phi.c,
+       src/vm/jit/optimizing/ssa_phi.h, src/vm/jit/optimizing/ssa_rename.c,
+       src/vm/jit/optimizing/ssa_rename.h: Integrated Christian Ullrichs
+       changes related to SSA and LSRA. Those files were just COPYED and
+       adapted from his modified SVN 8144 working copy.
+
+       NOTE: Christian Ullrichs SSA+LSRA related changes to the x86_64
+       codegenerator are NOT MERGED in this commit.
+       [df1b780317c3]
+
+       * src/vm/jit/python.c:
+       * src/vm/jit/python.c: Wrapped control flow and data flow fields and
+       respective constants for instruction.
+       [24dc79f2508c]
+
+2008-01-16  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (getChar, putChar): Implemented.
+       (copyMemory): Likewise.
+       [5265504cc4bf]
+
+2008-01-10  Gregor Kaufmann  <tdn@inode.at>
+
+       * doc/Makefile.am, doc/assertions.tex:
+       * doc/Makefile.am (dist_noinst_DATA): Added assertions.tex.
+       (assertions): New target, creates assertions.dvi. (CLEANFILES):
+       Added assertions.aux/.dvi/.log/.toc.
+
+       * doc/assertions.tex: New file, documentation of the assertion
+       implementation.
+       [eb342d685856]
+
+2008-01-10  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/jit.c, src/vm/jit/python.c:
+       * src/vm/jit/python.c: (python_global_lock) added, (pythonpass_init)
+       creating python lock, (pythonpass_run) locking python lock.
+       * src/vm/jit/jit.c [ENABLE_PYTHON]: Changed name of hardcoded
+       function.
+       [18d4cf443b7a]
 
-       * src/vm/suck.c (suck_add): Use vm_abort instead of
-       throw_cacao_exception_exit.
-       (suck_float, suck_double): Use exceptions_throw_internalerror.
-       
-       * src/vm/loader.c (load_class_bootstrap): Use vm_abort instead of
-       throw_cacao_exception_exit.
-       * src/vm/jit/sparc64/emit.c (emit_patcher_stubs): Likewise.
-       * src/vm/jit/mips/md.c (md_patch_replacement_point): Likewise.
-       * src/vm/vm.c (vm_create): Likewise.
-       
-       * src/vm/builtin.c (builtin_newarray): Use
-       exceptions_throw_outofmemoryerror.
-       
-       * src/vm/descriptor.c (descriptor_pool_lookup_classref): Use
-       exceptions_throw_internalerror.
-       * src/vm/classcache.c (classcache_store_unique): Likewise.
-       * src/vm/jit/powerpc/codegen.c (codegen): Likewise.
-       * src/vm/jit/sparc64/codegen.c (codegen): Likewise.
-       * src/vm/jit/alpha/codegen.c (codegen): Likewise.
-       * src/vm/jit/mips/codegen.c (codegen): Likewise.
-       * src/vm/jit/i386/codegen.c (codegen): Likewise.
-       * src/vm/jit/powerpc64/codegen.c (codegen): Likewise.
-       * src/vm/jit/intrp/codegen.c (codegen): Likewise.
-       * src/vm/jit/x86_64/codegen.c (codegen): Likewise.
-       * src/vm/jit/stack.c (stack_reanalyse_block): Likewise.
-       (stack_analyse): Likewise.
-       * src/vm/jit/verify/typeinfo.c (typeinfos_init_from_methoddesc):
-       Likewise.
-       (typeinfo_init_component): Likewise.
-       * src/vm/jit/verify/typecheck-builtins.inc: Likewise.
-       * src/vm/jit/allocator/lsra.c (lsra_scan_registers_canditates):
-       Likewise.
-       * src/vm/jit/allocator/simplereg.c (simplereg_allocate_temporaries):
-       Likewise.
-       * src/vm/jit/allocator/liveness.c
-       (liveness_scan_registers_canditates): Likewise.
-       
-       * src/vm/exceptions.c (exceptions_throw_outofmemory_exit): Removed.
-       (new_internalerror): Removed.
-       (exceptions_throw_internalerror): Rewritten.
-       (exceptions_throw_outofmemoryerror): Added.
-       
-       * src/vm/exceptions.h: Likewise.
-       
-       * src/vm/utf8.c (utf_get_number_of_u2s): Use
-       exceptions_throw_internalerror instead of throw_cacao_exception_exit.
-       
-       * src/native/native.c (native_init): Changed debug output.
-       
-       * src/mm/memory.c (memory_checked_alloc): Use vm_abort instead of
-       exceptions_throw_outofmemory_exit.
-       (mem_realloc): Changed debug output.
-       * src/mm/boehm.c (gc_out_of_memory): Use vm_abort and
-       exceptions_throw_outofmemoryerror.
-       
-       * src/cacaoh/cacaoh.c (cacaoh_abort): Added.
-       (main): Use cacaoh_abort.
-       
-       * src/cacaoh/headers.c (throw_cacao_exception_exit): Removed.
-       (exceptions_throw_outofmemory_exit): Likewise.
-       (new_internalerror): Renamed to exceptions_throw_internalerror.
-       (exceptions_throw_outofmemoryerror): Added.
-       
-       * src/vm/jit/tools/genoffsets.c (main): Don't print
-       sizestackframeinfo.
-
-2007-01-10 09:28  twisti
-
-       * src/vm/jit/parisc/linux/Makefile.am (libmd_la_SOURCES): Commented.
-
-2007-01-08 23:49  twisti
-
-       * configure.ac: Added GPL header.
-
-2007-01-08 23:48  twisti
-
-       * src/vm/vm.c (vm_create): Fixed off-by-one bug.
-
-2007-01-08 16:56  ajordan
-
-       * src/vm/jit/sparc64/codegen.c: Fixed argument passing via the stack
-       (for JIT methods).
-
-2007-01-07 20:56  ajordan
-
-       * src/vm/jit/sparc64/codegen.c: Implemented INSTANCEOF and CHECKCAST
-       ICMDs
-       * src/vm/jit/sparc64/patcher.c: and their respective patchers.
-       
-       * src/vm/jit/sparc64/codegen.h: Added comparison instructions.
-       
-       * src/vm/jit/sparc64/linux/md-os.c: Implemented instruction cache
-       flush for linux.
-       * src/vm/jit/sparc64/md.c: Likewise.
-
-2007-01-06 14:29  twisti
-
-       * configure.ac: Check for libdl.
-
-2007-01-06 14:27  twisti
-
-       * src/cacao/cacao.c (main): Print function name in error output.
-
-2007-01-06 01:27  edwin
-
-       * src/vm/jit/inline/inline.c: Many refactorings and comments.
-
-2007-01-04 21:48  twisti
-
-       * src/mm/memory.c (mem_realloc): Use vm_abort.
-
-2007-01-03 22:39  edwin
-
-       * src/vm/jit/verify/typecheck-typeinferer.c: New type inference pass.
-       * src/vm/jit/verify/typecheck-typeinferer.h: Likewise.
-       
-       * src/vm/jit/verify/typecheck-common.c: Moved code from typecheck.c
-       that can be shared between the variables-based verifier and the
-       type inference pass to this file.
-       * src/vm/jit/verify/typecheck-common.h: Likewise.
-       
-       * src/vm/jit/verify/typecheck-multianewarray.inc: Moved code for
-       type checking/infering MULTIANEWARRAY to this file.
-       
-       * src/vm/jit/verify/icmds.c: Adapted for generating the type
-       infererence pass.
-       * src/vm/jit/verify/typecheck-invoke.inc: Likewise.
-       * src/vm/jit/verify/typecheck-fields.inc: Likewise.
-       * src/vm/jit/verify/typecheck.c: Likewise.
-       * src/vm/jit/verify/Makefile.am: Likewise.
-       * src/vm/jit/verify/typecheck-builtins.inc: Likewise.
-       
-       * src/vm/jit/verify/typecheck-typeinferer-gen.inc: Generated.
-       
-       * src/vm/jit/verify/typecheck-stackbased-gen.inc: Regenerated.
-       * src/vm/jit/verify/typecheck-variablesbased-gen.inc: Regenerated.
-
-2007-01-03 22:22  edwin
-
-       * src/vm/jit/verify/icmds.c: Added comments.
-       
-       * src/vm/jit/verify/typecheck-stackbased-gen.inc,
-       src/vm/jit/verify/typecheck-variablesbased-gen.inc: Regenerated.
-
-2007-01-03 22:20  edwin
-
-       * src/vm/method.c, src/vm/method.h (method_count_implementations):
-       New function.
+2008-01-08  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-2007-01-03 22:08  edwin
+       * src/mm/Makefile.am, src/mm/codememory.c, src/mm/codememory.h,
+       src/mm/dumpmemory.c, src/mm/dumpmemory.h, src/mm/memory.c,
+       src/mm/memory.h, src/vm/vm.c:
+       * src/mm/Makefile.am (libmm_la_SOURCES): Added codememory.[ch],
+       dumpmemory.[ch].
 
-       * src/vm/jit/verify/generate.pl: Added options --typeinferer and
-       --debug. Prepared for generating the type inference pass.
+       * src/mm/codememory.c: New file.
+       * src/mm/codememory.h: Likewise.
+       * src/mm/dumpmemory.c: Likewise.
+       * src/mm/dumpmemory.h: Likewise.
 
-2007-01-02 21:52  twisti
+       * src/mm/memory.c: Moved code and dump memory related stuff into
+       their respective files.
+       * src/mm/memory.h: Likewise.
 
-       * configure.ac (AC_CONFIG_FILES): Added
-       src/vm/jit/parisc/linux/Makefile.
-       * src/vm/jit/parisc/Makefile.am (SUBDIRS): Set to $(OS_DIR).
-       * src/vm/jit/parisc/linux/Makefile.am: New file.
+       * src/vm/vm.c (mm/codememory.h): Added. (vm_create): Call
+       codememory_init instead of memory_init.
+       [183c2868c78a]
 
-2007-01-02 21:12  edwin
+       * m4/dump.m4:
+       * m4/dump.m4: Smaller changes.
+       [98cf8bd43450]
 
-       * src/vm/jit/emit-common.h (emit_replacement_stubs): Only declare
-       prototype if ENABLE_REPLACEMENT.
+2008-01-05  Peter Molnar  <pm@complang.tuwien.ac.at>
 
-2007-01-02 21:11  edwin
+       * src/vm/jit/jit.c, src/vm/jit/python.c:
+       * src/vm/jit/jit.c [ENABLE_PYTHON]: Changed name of hardcoded
+       script.
+       * src/vm/jit/python.c: Changed a lot.
+       [72c42e1989b2]
 
-       * src/vm/jit/mips/codegen.c (codegen): Use REPLACEMENT_ macros.
+       * src/vm/jit/s390/asmpart.S:
+       * src/vm/jit/s390/asmpart.S (asm_vm_call_method): Fixed stack
+       pointer corruption in case there are stack arguments and an
+       exception escapes.
+       [915392590cd3]
 
-2007-01-02 20:50  edwin
+2008-01-04  Stefan Ring  <stefan@complang.tuwien.ac.at>
 
-       * src/vm/jit/jit.c (jit_invalidate_code): Require ENABLE_REPLACEMENT.
+       * src/vm/jit/i386/asmpart.S:
+       * src/vm/jit/i386/asmpart.S (asm_handle_exception): Correct offsets
+       for 16 byte aligned stack.
+       [0566e94f095d]
 
-2007-01-02 20:40  edwin
+2008-01-03  Christian Thalinger  <twisti@complang.tuwien.ac.at>
 
-       * configure.ac: Added option --enable-replacement.
-       
-       * src/vm/jit/Makefile.am: Compile replace.c only for
-       ENABLE_REPLACEMENT.
-       
-       * src/vm/jit/replace.h: Define empty macros unless ENABLE_REPLACEMENT.
-       
-       * src/vm/jit/powerpc/emit.c: Enclosed replacement-specific code in
-       #if ENABLE_REPLACEMENT.
-       * src/vm/jit/powerpc/md.c: Likewise.
-       * src/vm/jit/powerpc/asmpart.S: Likewise.
-       * src/vm/jit/codegen-common.h: Likewise.
-       * src/vm/jit/sparc64/emit.c: Likewise.
-       * src/vm/jit/sparc64/md.c: Likewise.
-       * src/vm/jit/alpha/emit.c: Likewise.
-       * src/vm/jit/alpha/md.c: Likewise.
-       * src/vm/jit/alpha/asmpart.S: Likewise.
-       * src/vm/jit/code.c: Likewise.
-       * src/vm/jit/code.h: Likewise.
-       * src/vm/jit/tools/genoffsets.c: Likewise.
-       * src/vm/jit/show.c: Likewise.
-       * src/vm/jit/mips/emit.c: Likewise.
-       * src/vm/jit/mips/md.c: Likewise.
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/mips/asmpart.S:
+       * src/vm/jit/alpha/asmpart.S (asm_vm_call_method): Restore SP also
+       in exception case.
        * src/vm/jit/mips/asmpart.S: Likewise.
-       * src/vm/jit/powerpc64/md.c: Likewise.
-       * src/vm/jit/powerpc64/asmpart.S: Likewise.
-       * src/vm/jit/i386/emit.c: Likewise.
-       * src/vm/jit/i386/md.c: Likewise.
-       * src/vm/jit/i386/asmpart.S: Likewise.
-       * src/vm/jit/asmpart.h: Likewise.
-       * src/vm/jit/x86_64/emit.c: Likewise.
-       * src/vm/jit/x86_64/md.c: Likewise.
-       * src/vm/jit/x86_64/asmpart.S: Likewise.
-       * src/vm/jit/codegen-common.c: Likewise.
-       * src/vm/jit/jit.h: Likewise.
-
-2007-01-02 19:40  edwin
+       [17282b574f08]
+
+       * src/vm/jit/x86_64/asmpart.S:
+       * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method): Restore SP also
+       in exception case.
+       [846bcfaf0675]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_FillInStackTrace): Fixed warning.
+       (JVM_GetSystemPackage): Likewise. (JVM_NewMultiArray): Likewise.
+       [e7ab12ab545e]
+
+       * src/native/vm/sun/jvm.c, src/vmcore/system.h:
+       * changed src/vmcore/system.h [HAVE_SYS_SOCKET_H] (sys/socket.h):
+       Added. [HAVE_SYS_TYPES_H] (sys/types.h): Likewise. (system_accept):
+       New function. (system_connect, system_fsync, system_ftruncate,
+       system_gethostname) (system_getsockname, system_getsockopt,
+       system_listen, system_lseek) (system_setsockopt, system_shutdown,
+       system_socket): Likewise.
+
+       * changed src/native/vm/sun/jvm.c: Use new system_* functions.
+       [f6eb3507d28b]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c: Added return values to all functions.
+       [bc6940061b57]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (PRINTJVM): Removed.
+       (native/include/java_lang_Integer.h,
+       native/include/java_lang_Long.h, native/include/java_lang_Short.h,
+       native/include/java_lang_Byte.h,
+       native/include/java_lang_Character.h,
+       native/include/java_lang_Boolean.h,
+       native/include/java_lang_Float.h,
+       native/include/java_lang_Double.h): Likewise.
+       (JVM_RawMonitorCreate): Fixed typo.
+       [d296cb58df1c]
+
+       * configure.ac, src/native/vm/sun/jvm.c, src/vmcore/system.h:
+       * configure.ac (AC_CHECK_FUNCS): Added read, write.
+
+       * src/native/vm/sun/jvm.c (fcntl.h): Removed. (JVM_Open, JVM_Close,
+       JVM_Read, JVM_Write): Use system_* function.
+
+       * src/vmcore/system.h [HAVE_FCNTL_H] (fcntl.h): Added.
+       (system_close, system_open, system_read, system_write): New
+       function.
+       [eb3186f90670]
 
-       * src/vm/jit/i386/codegen.c (codegen): Cleaned up to use REPLACEMENT_
-       macros.
+       * src/native/vm/sun/jvm.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.c (opt_TraceJVMCallsVerbose): Added.
+       * src/vmcore/options.h: Likewise.
 
-2007-01-02 16:20  twisti
+       * src/native/vm/sun/jvm.c (TRACEJVMCALLSVERBOSE): New macro. Use
+       TRACEJVMCALLS in all functions.
+       [7ac7dbdbce71]
 
-       * tests/regression/jctest.java: Print hex numbers too.
-       * tests/regression/jctest.output: Updated.
diff --git a/ChangeLog-2007 b/ChangeLog-2007
new file mode 100644 (file)
index 0000000..4e10a8d
--- /dev/null
@@ -0,0 +1,27561 @@
+2007-12-30  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac, src/vm/jit/Makefile.am, src/vm/jit/ir/Makefile.am,
+       src/vm/jit/ir/bytecode.c, src/vm/jit/ir/bytecode.h,
+       src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/parse.c:
+       * configure.ac (AC_CONFIG_FILES): Added src/vm/jit/ir/Makefile.
+
+       * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added ir. (SUBDIRS):
+       Likewise. (libjit_la_LIBADD): Added ir/libir.la.
+
+       * src/vm/jit/ir/Makefile.am: New file.
+       * src/vm/jit/ir/bytecode.c: Likewise.
+       * src/vm/jit/ir/bytecode.h: Likewise.
+
+       * src/vm/jit/jit.c (vm/jit/ir/bytecode.h): Added.
+       * src/vm/jit/jit.h (vm/jit/ir/bytecode.h): Likewise. Use new BC_*
+       constants in the ICMD-enum.
+
+       * src/vm/jit/parse.c (vm/jit/ir/bytecode.h): Added. (parse): Use new
+       BC_* constants.
+       [d8fe2c3ba284]
+
+2007-12-29  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/mm/memory.c, src/vmcore/system.h:
+       * src/vmcore/system.h (system_mprotect): New function.
+       [HAVE_SYS_MMAN_H] (sys/mman.h): Added.
+
+       * src/mm/memory.c (vmcore/system.h): Added. (memory_mprotect): Use
+       system_mprotect.
+       [3c67f686355c]
+
+2007-12-28  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/powerpc/disass.c:
+       * src/vm/jit/powerpc/disass.c: Fixed copyright header. (stdint.h):
+       Added. (vm/types.h): Removed.
+       [4b313b978a51]
+
+2007-12-20  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * configure.ac, m4/az_python.m4, src/cacao/Makefile.am,
+       src/vm/jit/Makefile.am, src/vm/jit/jit.c, src/vm/jit/python.c,
+       src/vm/jit/python.h, src/vm/vm.c:
+       * configure.ac: Added tests for python.
+       * m4/az_python.m4: New file.
+       * src/cacao/Makefile.am src/vm/jit/Makefile.am: [ENABLE_PYTHON]
+       Building python module and linking with python libs.
+       * src/vm/jit/jit.c [ENABLE_PYTHON] Calling some python function.
+       * src/vm/jit/python.c, src/vm/jit/python.h: New files.
+       * src/vm/vm.c [ENABLE_PYTHON] Initializing python module.
+       [a54c7d83c58a]
+
+2007-12-19  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_GetManagement): Implemented (only
+       returning NULL).
+       [4206fab51a24]
+
+       * src/native/native.c, src/native/native.h, src/native/vm/sun/jvm.c:
+       * src/native/native.c [ENABLE_LTDL] (native_library_close): New
+       function.
+       * src/native/native.h: Likewise.
+
+       * src/native/vm/sun/jvm.c (JVM_UnloadLibrary): Implemented.
+       [59330b2047b9]
+
+2007-12-16  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * m4/debug.m4, m4/dump.m4:
+       * m4/debug.m4: Changed wording to make some defaults less confusing
+       (forgot those in previous commit).
+       * m4/dump.m4: Likewise.
+       [c06d42a7d559]
+
+2007-12-10  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/cldc1.1/java_lang_Throwable.c:
+       * src/native/vm/cldc1.1/java_lang_Throwable.c (vm/types.h): Removed.
+       (stdint.h): Added. (native/llni.h): Added. (printStackTrace): Use
+       new stacktrace functions. (fillInStackTrace): Likewise.
+       [ca9ac6d29332]
+
+2007-12-07  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * configure.ac, m4/jit.m4, m4/libjvm.m4, m4/ltdl.m4, m4/zlib.m4:
+       * configure.ac: Changed wording to make some defaults less
+       confusing.
+       * m4/jit.m4: Likewise.
+       * m4/libjvm.m4: Likewise.
+       * m4/ltdl.m4: Likewise.
+       * m4/zlib.m4: Likewise.
+       [9ee28b82c23e]
+
+2007-12-05  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/sun/jvm.c, src/vmcore/class.c, src/vmcore/class.h:
+       * src/native/vm/sun/jvm.c (JVM_GetEnclosingMethodInfo): Implemented.
+       * src/vmcore/class.c (class_get_enclosingmethod): New function.
+       * src/vmcore/class.h: Likewise.
+       [85ece229beb6]
+
+2007-11-24  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c:
+       * src/vm/jit/i386/codegen.c (codegen_emit,
+       codegen_emit_stub_native): Repaired 16 byte stack alignment.
+
+       * src/vm/jit/i386/emit.c (emit_verbosecall_enter): Likewise.
+       [fb2f760c6d47]
+
+2007-11-21  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * doc/handbook/cacao.tex, doc/handbook/java.bib,
+       doc/handbook/s390.tex:
+       * doc/handbook/s390.tex: New file, docs for the s390 port.
+       * doc/handbook/cacao.tex, doc/handbook/java.bib: Added support for
+       s390.tex.
+       [1e17747d8ae4]
+
+2007-11-13  Stefan Ring  <stefan@complang.tuwien.ac.at>
+
+       * src/vm/jit/i386/darwin/md-os.c:
+       * src/vm/jit/i386/darwin/md-os.c: Synched with linux version.
+       Compiles but doesn't work yet.
+       [7a9776c7f769]
+
+2007-11-08  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/stacktrace.c:
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin):
+       Unflag leafmethod. (codegen_generate_stub_native): Likewise.
+
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native): Added
+       leafmethod sanity check.
+
+       * src/vm/jit/stacktrace.c (stacktrace_stackframeinfo_add): Use
+       code_is_leafmethod.
+       [91f7709c62de]
+
+       * src/vm/jit/m68k/arch.h, src/vm/jit/powerpc64/arch.h,
+       src/vm/jit/s390/arch.h:
+       * src/vm/jit/m68k/arch.h: Removed commented HAS_4BYTE_STACKSLOT.
+       * src/vm/jit/powerpc64/arch.h: Likewise.
+       * src/vm/jit/s390/arch.h: Likewise.
+       [adc81880df67]
+
+       * src/native/jni.c:
+       * src/native/jni.c (TRACEJNICALLS): Don't use a variadic macro but
+       pass the text to log in parentheses. This also fixes a bug when
+       only one argument is passed.
+       [1b6cd680d55a]
+
+       * src/vm/jit/cfg.c, src/vm/jit/cfg.h:
+       * src/vm/jit/cfg.c: Fixed copyright header. (vm/types.h): Removed.
+       (vm/global.h): Added.
+       * src/vm/jit/cfg.h: Likewise.
+       [568ba9fdd84b]
+
+2007-11-07  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/jni.c, src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_security_VMAccessController.c,
+       src/native/vm/sun/jvm.c, src/threads/threads-common.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h:
+       * src/native/jni.c (_Jv_JNI_FindClass): Renamed
+       stacktrace_getCurrentClass to stacktrace_get_current_class.
+
+       * src/native/vm/gnu/java_lang_VMThrowable.c (vm/jit/code.h): Added.
+       (vm/jit/linenumbertable.h): Likewise. (fillInStackTrace): Renamed
+       stacktrace_fillInStackTrace to stacktrace_get. (getStackTrace):
+       Rewritten for new stacktrace code.
+
+       * src/native/vm/gnu/java_security_VMAccessController.c (vm/types.h):
+       Removed. (stdint.h): Added. (vm/builtin.h): Removed. (vm/global.h):
+       Added. (vmcore/class.h): Removed. (vmcore/options.h): Likewise.
+       (vmcore/utf8.h): Added. (getStack): Renamed stacktrace_getStack to
+       stacktrace_get_stack.
+
+       * src/native/vm/sun/jvm.c (JVM_FillInStackTrace): Renamed
+       stacktrace_fillInStackTrace to stacktrace_get.
+       (JVM_GetStackTraceDepth): Rewritten for new stacktrace code and
+       added critical section. (JVM_GetStackTraceElement): Rewritten for
+       new stacktrace code. (JVM_LatestUserDefinedLoader): Implemented.
+
+       * src/threads/threads-common.c (threads_thread_print_stacktrace):
+       Rewritten for new stacktrace code and added critical section.
+
+       * src/vm/jit/stacktrace.c (stacktrace_entry_add): Removed.
+       (stacktrace_method_add): Likewise. (stacktrace_stackframeinfo_fill)
+       [!NDEBUG]: Added debug output. (stacktrace_stackframeinfo_next):
+       Likewise. (stacktrace_stackframeinfo_end_check): Likewise.
+       (stacktrace_create): Removed. (stacktrace_fillInStackTrace):
+       Removed. (stacktrace_depth): New function. (stacktrace_get):
+       Likewise. (stacktrace_first_nonnull_classloader): Likewise.
+       (stacktrace_getClassContext): Rewritten.
+       (stacktrace_getCurrentClass): Renamed to
+       stacktrace_get_current_class and rewritten. (stacktrace_getStack):
+       Renamed to stacktrace_get_stack and rewritten.
+       (stacktrace_print_trace_from_buffer): Renamed to stacktrace_print
+       and rewritten. (stacktrace_print_exception): Rewritten.
+
+       * src/vm/jit/stacktrace.h (stacktracebuffer): Removed.
+       (stacktrace_entry): Likewise. (stacktrace_t): New structure.
+       (stacktrace_entry_t): Likewise.
+       [6ca3d885a0c3]
+
+2007-11-07  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/i386/linux/md-os.c:
+       * src/vm/jit/i386/linux/md-os.c (md_replace_executionstate_read):
+       Implemented. (md_replace_executionstate_write): Likewise.
+       [be521f46a80f]
+
+2007-11-06  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_FillInStackTrace): Use LLNI macro.
+       (JVM_GetStackTraceDepth): Likewise and added a comment about missing
+       critical sections. (JVM_GetStackTraceElement): Likewise.
+       [3d10f5692560]
+
+2007-11-05  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/Makefile.am, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/alpha/linux/md-os.c, src/vm/jit/alpha/md.c,
+       src/vm/jit/alpha/md.h, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/md.c, src/vm/jit/arm/md.h, src/vm/jit/arm/patcher.c,
+       src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c, src/vm/jit
+       /codegen-common.h, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/i386/md.c, src/vm/jit/i386/md.h, src/vm/jit/jit.c,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/md.h,
+       src/vm/jit/m68k/patcher.c, src/vm/jit/md.h,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/md.c,
+       src/vm/jit/mips/md.h, src/vm/jit/mips/patcher.c, src/vm/jit/patcher-
+       common.c, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/md-asm.h,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc/md.c,
+       src/vm/jit/powerpc/md.h, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/powerpc64/md.h, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/replace.c, src/vm/jit/s390/md.c, src/vm/jit/s390/md.h,
+       src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/md.h,
+       src/vm/jit/sparc64/patcher.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/stacktrace.h, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/md.h:
+       * src/vm/jit/md.h: Removed.
+       * src/vm/jit/Makefile.am (noinst_HEADERS): Removed md.h.
+
+       * src/vm/jit/asmpart.h (md_asm_codegen_get_pv_from_pc): Added
+       temporarily.
+
+       * src/vm/jit/codegen-common.c (md.h): Added. (vm/jit/md.h): Removed.
+       (md_asm_codegen_get_pv_from_pc): Added temporarily.
+
+       * src/vm/jit/codegen-common.h (md_codegen_get_pv_from_pc): Removed.
+
+       * src/vm/jit/jit.c (stdint.h): Added. (md.h): Likewise.
+
+       * src/vm/jit/patcher-common.c (md.h): Added. (vm/jit/md.h): Removed.
+       * src/vm/jit/replace.c: Likewise.
+
+       * src/vm/jit/stacktrace.c (md.h): Added.
+       * src/vm/jit/stacktrace.h (md_stacktrace_get_returnaddress): Removed.
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/alpha/md.c, src/vm/jit/alpha/md.h,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/md.c, src/vm/jit/arm/md.h,
+       src/vm/jit/arm/patcher.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/i386/md.c, src/vm/jit/i386/md.h,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/md.h,
+       src/vm/jit/m68k/patcher.c, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/mips/md.c, src/vm/jit/mips/md.h,
+       src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/md-asm.h,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc/md.c,
+       src/vm/jit/powerpc/md.h, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/powerpc64/md.h, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/md.h, src/vm/jit/sparc64/md.c,
+       src/vm/jit/sparc64/md.h, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/x86_64/linux/md-os.c, src/vm/jit/x86_64/md.c,
+       src/vm/jit/x86_64/md.h (md_stacktrace_get_returnaddress): Made
+       inline function. (md_codegen_get_pv_from_pc): Likewise.
+       (md_cacheflush): Likewise. (md_icacheflush): Likewise.
+       (md_dcacheflush): Likewise.
+       [d81d9dc006c9]
+
+       * src/vm/jit/s390/patcher.c:
+       * src/vm/jit/s390/patcher.c: Fixed header.
+       [60fd68b8284c]
+
+2007-10-27  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/linenumbertable.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/md.c:
+       * src/vm/jit/linenumbertable.c (linenumbertable_create,
+       linenumbertable_linenumber_for_pc_intern) [__S390__]: Use 31 bits of
+       addresses as lookup keys.
+       * src/vm/jit/s390/codegen.c (codegen_emit_stub_native): In case of
+       exception, use branch (not following) instruction as XPC.
+       * src/vm/jit/s390/md.c (md_signal_handler_sigill): Fixes to scenario
+       where JIT compiler fails.
+       [1a453b2390aa]
+
+2007-10-27  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/code.c, src/vm/jit/code.h:
+       * src/vm/jit/code.c (vm/jit/methodheader.h): Removed.
+       (code_get_codeinfo_for_pv): Likewise.
+
+       * src/vm/jit/code.h (assert.h): Added. (vm/jit/methodheader.h):
+       Likewise. (code_get_codeinfo_for_pv): New function.
+       [c3b950a4ea8b]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (vm/jit/code.h): Added.
+       (codegen_finish_native_call): Use code_get_codeinfo_for_pv.
+       [18a312bfca4b]
+
+2007-10-26  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_create): Removed codegen_init call, jit_init does
+       that.
+       [c5a79c1e4123]
+
+       * src/vm/jit/arm/codegen.c:
+       * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Removed
+       emit_patcher_traps call.
+       [704dd3fd06bd]
+
+       * src/vm/jit/s390/codegen.c:
+       * src/vm/jit/s390/codegen.c (codegen_emit_stub_native): Removed
+       patcher stuff.
+       [4b58514e5dab]
+
+       * src/vm/jit/i386/codegen.c:
+       * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Removed
+       patcher stuff.
+       [0d991b1b2a50]
+
+       * src/vm/jit/alpha/codegen.c:
+       * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Removed
+       patcher stuff.
+       [5ed32ddf5dcb]
+
+2007-10-25  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/mips/linux/md-os.c:
+       * src/vm/jit/mips/linux/md-os.c (vm/jit/md.h): Removed (accidentally
+       commited). (md_signal_handler_sigsegv): Removed some code.
+       [279a6a754037]
+
+       * src/vm/jit/mips/arch.h, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c:
+       * src/vm/jit/mips/arch.h (JIT_COMPILER_VIA_SIGNAL): Temporarily
+       added.
+
+       * src/vm/jit/mips/asmpart.S (asm_call_jit_compiler): Removed.
+       * src/vm/jit/mips/codegen.c (codegen_emit_stub_compiler): Likewise.
+
+       * src/vm/jit/mips/codegen.h (COMPILERSTUB_CODESIZE): Adapted size.
+
+       * src/vm/jit/mips/emit.c (emit_trap_compiler): New function.
+
+       * src/vm/jit/mips/linux/md-os.c (vm/exceptions.h): Added.
+       (md_signal_handler_sigsegv): Added compiler-by-signals code.
+       [3e911e512e84]
+
+       * src/vm/jit/alpha/md.c:
+       * src/vm/jit/alpha/md.c (md_init): Smaller changes.
+       (md_codegen_get_pv_from_pc): Rewritten.
+       [8484b2af9cb0]
+
+       * src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/md.h, src/vm/vm.c:
+       * src/vm/jit/jit.c (vm/jit/md.h): Removed. (jit_init): Call md_init.
+
+       * src/vm/jit/jit.h [ENABLE_JIT] (md_init): Added. [ENABLE_INTRP]
+       (intrp_md_init): Likewise.
+
+       * src/vm/jit/md.h [ENABLE_JIT] (md_init): Removed. [ENABLE_INTRP]
+       (intrp_md_init): Likewise.
+
+       * src/vm/vm.c (vm/jit/md.h): Removed. (vm_create): Don't call
+       md_init.
+       [86d5f80749fa]
+
+       * src/vm/primitive.c, src/vm/signal.c:
+       * src/vm/primitive.c (primitive_box): Fixed -O2 wanrings.
+       * src/vm/signal.c (signal_handle): Likewise.
+       [e7c1d45ac1cb]
+
+       * src/native/include/Makefile.am:
+       * src/native/include/Makefile.am (COMMON_HEADER_FILES): Removed
+       java_util_HashMap and java_util_Map. (JAVASE_HEADER_FILES): Added
+       java_util_HashMap and java_util_Map.
+       [775bed4b55e1]
+
+2007-10-24  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md.c:
+       * src/vm/jit/s390/arch.h (JIT_COMPILER_VIA_SIGNAL): defined.
+       * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): removed.
+       * src/vm/jit/s390/codegen.c (codegen_emit_stub_compiler): removed.
+       * src/vm/jit/s390/emit.c (emit_trap_compiler): new function.
+       * src/vm/jit/s390/md.c (md_signal_handler_sigill): adapted for
+       compiler call via signal.
+       [c49cadfbd476]
+
+2007-10-24  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/exceptions.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/stacktrace.h:
+       * src/vm/jit/stacktrace.c (stacktrace_print_trace): Renamed to
+       stacktrace_print_exception.
+       * src/vm/jit/stacktrace.h: Likewise.
+
+       * src/vm/exceptions.c (exceptions_handle_exception): Likewise.
+       [8bc0a90cd4f0]
+
+       * src/native/vm/gnu/java_lang_VMThrowable.c:
+       * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace): Removed
+       unused resolving of the init method.
+       [d9b947897586]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_FillInStackTrace): Use TRACEJVMCALLS.
+       (JVM_GetStackTraceElement): Likewise. (JVM_IHashCode): Likewise.
+       [369b6cfa58a6]
+
+       * src/vm/jit/stacktrace.c:
+       * src/vm/jit/stacktrace.c (stacktrace_stackframeinfo_fill): New
+       function. (stacktrace_stack_walk): Renamed to
+       stacktrace_stackframeinfo_next.
+       (stacktrace_stackframeinfo_end_check): New function.
+       (stacktrace_create): Use new stackframeinfo functions.
+       [111e59248e76]
+
+       * src/native/include/Makefile.am:
+       * src/native/include/Makefile.am [ENABLE_ANNOTATIONS]
+       (JAVASE_HEADER_FILES): Removed java_util_Map.h.
+       [d5242eb43dbf]
+
+2007-10-23  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vmcore/linker.c:
+       * src/vmcore/linker.c (linker_preinit): Define
+       LINKER_ALIGNMENT_LONG_DOUBLE. (link_class_intern): Added a compile
+       time check for LINKER_ALIGNMENT_LONG_DOUBLE.
+       [c8300b439942]
+
+       * src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h:
+       * src/native/vm/java_lang_Thread.c (interrupt): Removed.
+       * src/native/vm/java_lang_Thread.h: Likewise.
+
+       * src/native/vm/gnu/java_lang_VMThread.c (interrupt): Use
+       threads_thread_interrupt.
+       [9921ebdac86b]
+
+       * src/vm/jit/argument.c:
+       * src/vm/jit/argument.c (argument_vmarray_from_jvalue): Fixed
+       warning when compiling with Sun's jni.h.
+       [9e21a19e371f]
+
+2007-10-22  Gregor Kaufmann  <tdn@inode.at>
+
+       * configure.ac, m4/assertion.m4,
+       src/lib/gnu/java/lang/VMClassLoader.java,
+       src/native/include/Makefile.am, src/native/jni.h,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/sun/jvm.c, src/vm/Makefile.am, src/vm/assertion.c,
+       src/vm/assertion.h, src/vm/vm.c, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/linker.c, src/vmcore/loader.c:
+       * configure.ac (AC_CHECK_ENABLE_ASSERTION): Added
+
+       * src/lib/gnu/java/lang/VMClassLoader.java
+       (packageAssertionStatus0): New function (classAssertionStatus0):
+       Likewise (defaultUserAssertionStatus): Likewise
+       (defaultAssertionStatus): Implemented (packageAssertionStatus):
+       Likewise (classAssertionStatus): Likewise
+
+       * src/native/include/Makefile.am (COMMON_HEADER_FILES): Added
+       java_util_HashMap.h, java_util_Map.h
+
+       * /src/native/jni.h
+       (_Jv_JavaVM->Java_java_lang_VMClassLoader_defaultAssertionStatus):
+       Removed
+
+       * src/native/vm/gnu/java_lang_VMClassLoader.c
+       (native/include/java_util_HashMap.h): Added
+       (native/include/java_util_Map.h): Likewise
+       (native/include/java_lang_Boolean.h): Likewise (toolbox/list.h):
+       Likewise (vm/assertion.h): Likewise (methods): Added information for
+       defaultUserAssertionStatus, packageAssertionStatus0,
+       classAssertionStatus0
+       (Java_java_lang_VMClassLoader_defaultAssertionStatus): Implemented
+       (Java_java_lang_VMClassLoader_defaultUserAssertionStatus): New
+       function (Java_java_lang_VMClassLoader_packageAssertionStatus0):
+       Likewise (Java_java_lang_VMClassLoader_classAssertionStatus0):
+       Likewise
+
+       * src/native/vm/sun/jvm.c (toolbox/list.h): Added (vm/assertion.h):
+       Likewise (JVM_DesiredAssertionStatus): Implemented
+       (JVM_AssertionStatusDirectives): Now returns a usable
+       java.lang.AssertionStatusDirectives object
+
+       * src/vm/Makefile.am (libvm_la_SOURCES): Added assertion.c,
+       assertion.h
+
+       * src/vm/vm.c (vm/assertion.h): Added (OPT_EA, OPT_DA, OPT_ESA,
+       OPT_DSA): Now handled by assertion module
+
+       * src/vmcore/class.c (class_java_util_HashMap): Added
+
+       * src/vmcore/class.h (class_java_util_HashMap): Added
+
+       * src/vmcore/linker.c (linker_init): Added linking of
+       class_java_util_HashMap
+
+       * src/vmcore/loader.c (loader_init): Added loading of
+       class_java_util_HashMap
+
+       * m4/assertion.m4: New file
+
+       * src/vm/assertion.c: New file
+
+       * src/vm/assertion.h: New file
+       [dfc311608cdb]
+
+2007-10-22  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (unistd.h): Removed.
+       [c55e286b6453]
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (vmcore/system.h): Added. (exceptions_init):
+       Use system_getpagesize and system_mmap_anonymous.
+       [87916090c0dd]
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_handle_exception): Changed
+       signature to use void*.
+       [0787c3ba398d]
+
+       * src/vm/jit/show.c:
+       * src/vm/jit/show.c (stdint.h): Added. (SHOW_INT_CONST): Fixed
+       compiler warnings.
+       [cf051a1d440f]
+
+       * src/vm/jit/show.c:
+       * src/vm/jit/show.c (show_basicblock): Pass correct arguments to
+       linenumbertable_linenumber_for_pc.
+       [5a06e321fc5b]
+
+2007-10-22  Roland Lezuo  <tbfg@complang.tuwien.ac.at>
+
+       * src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/patcher.c:
+       * changed src/vm/jit/m68k/emit.c (builtin_verbosecall_exit): Use
+       trace_java_call_exit.
+
+       * changed src/vm/jit/m68k/linux/md-os.c (emit_trap): Fixed a bug.
+
+       * changed src/vm/jit/m68k/patcher.c (md_signal_handler_sigill): Bug.
+       (PATCH_BACK_ORIGINAL_MCODE): Bug.
+       [6b8e93fdc96b]
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/system.c, src/vm/system.h:
+       * changed src/vm/jit/m68k/asmpart.S: Removed unused method header
+       entries.
+
+       * changed src/vm/jit/m68k/codegen.c (codegen_emit): New
+       linenumbertables code.
+       [c76ff711720f]
+
+       * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/linux/md-os.h, src/vm/jit/m68k/md.c,
+       src/vm/signal.c, src/vm/signallocal.h, src/vmcore/linker.c:
+       * changed src/vm/jit/m68k/arch.h (JIT_COMPILER_VIA_SIGNAL): Added.
+
+       * changed src/vm/jit/m68k/asmpart.S (asm_call_jit_compiler):
+       Removed.
+
+       * changed src/vm/jit/m68k/codegen.c (codegen_emit): All
+       codegen_addpatchref replaced by patcher_add_patch_ref.
+
+       (codegen_emit_stub_native): Use 8 byte stack slots.
+
+       * changed src/vm/jit/m68k/emit.c (emit_verbosecall_enter): New
+       tracer. (emit_trap_compiler): Added. (emit_trap): Likewise.
+
+       * changed src/vm/jit/m68k/linux/md-abi.c (md_param_alloc): Use 8
+       byte stackslots.
+
+       * changed src/vm/jit/m68k/linux/md-os.c (md_init_linux): Removed.
+       (md_signal_handler_sigsegv): Support for patchers and compiler via
+       signal added.
+
+       * changed src/vm/jit/m68k/linux/md-os.h (md_init_linux): Removed.
+
+       * changed src/vm/jit/m68k/md.c (md_init): Call to md_init_linux
+       removed.
+
+       * changed src/vm/signal.c (signal_init): Register sigill for M68K.
+
+       * changed src/vm/signallocal.h (md_signal_handler_sigill): Enabled
+       for M68K.
+
+       * changed src/vmcore/linker.c (link_class_intern): Enable long 4
+       byte alignment.
+       [a1dc04786217]
+
+2007-10-22  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/none/threads.h:
+       * src/threads/none/threads.h (stackframeinfo): Removed.
+       (_no_threads_stackframeinfo): Likewise.
+       [267fff05a72b]
+
+       * src/vm/jit/show.c:
+       * src/vm/jit/show.c (show_basicblock): Forgot to use
+       linenumbertable_linenumber_for_pc.
+       [b24a7f31a843]
+
+       * src/vm/jit/jit.c:
+       * src/vm/jit/jit.c (jit_jitdata_new) [!ENABLE_THREADS]: Fixed
+       compilation.
+       [a8d348dbea79]
+
+       * src/vm/jit/trace.c:
+       * src/vm/jit/trace.c (trace_java_call_enter): Removed unused
+       variable.
+       [4e2ba2f7e85d]
+
+       * src/vm/jit/linenumbertable.c, src/vmcore/statistics.c,
+       src/vmcore/statistics.h:
+       * src/vmcore/statistics.c (count_linenumbertable): New variable.
+       (size_linenumbertable): Likewise. (statistics_print_memory_usage):
+       Adapted.
+       * src/vmcore/statistics.h: Likewise.
+
+       * src/vm/jit/linenumbertable.c [ENABLE_STATISTICS]
+       (vmcore/options.h): Added [ENABLE_STATISTICS] (vmcore/statistics.h):
+       Likewise. (linenumbertable_create) [ENABLE_STATISTICS]: Added
+       statistics calculation.
+       [6727b0adf84a]
+
+       * src/vm/jit/Makefile.am, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/code.h, src/vm/jit/codegen-
+       common.c, src/vm/jit/codegen-common.h, src/vm/jit/dseg.c,
+       src/vm/jit/dseg.h, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/i386/codegen.c, src/vm/jit/linenumbertable.c,
+       src/vm/jit/linenumbertable.h, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/methodheader.h,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/linenumbertable.c: New file.
+       * src/vm/jit/linenumbertable.h: Likewise.
+       * src/vm/jit/Makefile.am (libjit_la_SOURCES): Added
+       linenumbertable.[ch].
+
+       * src/vm/jit/code.h (vm/jit/linenumbertable.h): Added. (codeinfo):
+       Added linenumbertable.
+
+       * src/vm/jit/codegen-common.c (vm/jit/linenumbertable.h): Added.
+       (codegen_setup): Create linenumbers list. (codegen_reset): Likewise.
+       (codegen_finish): Removed old linenumber-resolving code and call
+       linenumbertable_create instead.
+
+       * src/vm/jit/codegen-common.h (codegendata): Removed
+       linenumberreferences, linenumbertablesizepos,
+       linenumbertablestartpos, linenumbertab, added linenumbers.
+
+       * src/vm/jit/dseg.c (dseg_addlinenumbertablesize): Removed.
+       (dseg_addlinenumber): Likewise. (dseg_addlinenumber_inline_start):
+       Likewise. (dseg_addlinenumber_inline_end): Likewise.
+       (dseg_createlinenumbertable): Likewise.
+       (dseg_get_linenumber_from_pc_intern): Likewise.
+       (dseg_get_linenumber_from_pc): Likewise.
+
+       * src/vm/jit/dseg.h: Likewise (linenumbertable_entry): Removed.
+
+       * src/vm/jit/methodheader.h (LineNumberTableSize)
+       (LineNumberTableStart): Removed.
+
+       * src/vm/jit/stacktrace.c (vm/jit/linenumbertable.h): Added.
+       (stacktrace_method_add): Renamed dseg_get_linenumber_from_pc to
+       linenumbertable_linenumber_for_pc.
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S
+       (asm_vm_call_method): Removed obsolete method-header entries.
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c
+       (vm/jit/linenumbertable.h): Added. (codegen_emit): Removed
+       dseg_addlinenumbertablesize call, use new linenumbertable functions,
+       removed dseg_createlinenumbertable. (codegen_emit_stub_native):
+       Removed obsolete method-header entries.
+       [d992be0f02d6]
+
+       * src/vm/jit/arm/codegen.c:
+       * src/vm/jit/arm/codegen.c (codegen_emit): Moved ICMD_POP and
+       ICMD_POP2 to ICMD_NOP case.
+       [093ed0794c43]
+
+       * src/vm/array.c, src/vm/array.h:
+       * src/vm/array.c: Changed copyright.
+       * src/vm/array.h: Likewise.
+       [9b71c7a705e9]
+
+2007-10-20  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/disass.c,
+       src/vm/jit/s390/md.c:
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/disass.c,
+       src/vm/jit/s390/md.c: Fixed compile warnings.
+       [2a39b1f8c18d]
+
+2007-10-19  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/x86_64/md-abi.c:
+       * src/vm/jit/x86_64/md-abi.c (abi_registers_integer_saved): Fixed
+       severe typo.
+       [f3c3d927ba54]
+
+2007-10-19  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/properties.c:
+       * src/vm/properties.c (properties_set) [ENABLE_JAVASE &&
+       WITH_CLASSPATH_GNU]: Fixed endorseddirs length.
+       [fba8f04fd91f]
+
+2007-10-18  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac, src/vmcore/system.c, src/vmcore/system.h:
+       * configure.ac (AC_CHECK_HEADERS): Added assert.h, errno.h.
+       (AC_CHECK_FUNCS): Added memcpy, memset, realloc.
+
+       * src/vmcore/system.c (errno.h): Added. (stdint.h): Likewise.
+       (string.h): Likewise. (unistd.h): Likewise. (sys/mman.h): Likewise.
+       (system_mmap_anonymous): New function.
+
+       * src/vmcore/system.h (stdint.h): Added. (stdlib.h): Likewise.
+       (string.h): Likewise. (unistd.h): Likewise. (system_calloc): New
+       function. (system_free): Likewise. (system_getpagesize): Likewise.
+       (system_malloc): Likewise. (system_memcpy): Likewise.
+       (system_memset): Likewise. (system_realloc): Likewise.
+       (system_mmap_anonymous): Likewise.
+       [cfa50d0a150e]
+
+2007-10-18  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_dump): Ignore NEW threads
+       while dumping.
+       [65dc1b64848f]
+
+2007-10-18  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/gnu/java_lang_VMRuntime.c, src/native/vm/sun/jvm.c,
+       src/vm/Makefile.am, src/vm/system.c, src/vm/system.h,
+       src/vmcore/Makefile.am, src/vmcore/system.c, src/vmcore/system.h:
+       * src/vm/system.c: Removed.
+       * src/vm/system.h: Likewise.
+       * src/vm/Makefile.am (libvm_la_SOURCES): Removed system.[ch].
+
+       * src/vmcore/system.c: Added.
+       * src/vmcore/system.h: Likewise.
+       * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Added system.[ch].
+
+       * src/native/vm/gnu/java_lang_VMRuntime.c (vm/system.h): Renamed to
+       vmcore/system.h.
+       * src/native/vm/sun/jvm.c: Likewise.
+       [28c2716784ad]
+
+2007-10-18  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_handle_exception): Use LLNI macro
+       for unlocking synchronized methods during stack unwinding.
+       [6bd290291ff9]
+
+       * src/vm/builtin.c, src/vm/builtin.h, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/powerpc/darwin/md-os.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc64/linux/md-
+       os.c, src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/builtin.h (builtin_retrieve_exception): Added prototype.
+       * src/vm/builtin.c (builtin_retrieve_exception): Implemented.
+
+       * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Use
+       above builtin.
+       * src/vm/jit/i386/linux/md-os.c,
+       * src/vm/jit/powerpc/darwin/md-os.c,
+       * src/vm/jit/powerpc/linux/md-os.c,
+       * src/vm/jit/powerpc64/linux/md-os.c,
+       * src/vm/jit/x86_64/linux/md-os.c: Likewise.
+       [20827c0dbb8e]
+
+2007-10-18  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * * Merged with 5c4efabb7787.
+       [4e1e7758b87a]
+
+2007-10-14  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/dseg.h:
+       * src/vm/jit/dseg.h (dseg_exception_entry): Removed.
+       [35647a987380]
+
+2007-10-18  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_create_replacement_points): Removed
+       bogus flag tampering of codeinfo.
+       [5c4efabb7787]
+
+2007-10-17  Roland Lezuo  <tbfg@complang.tuwien.ac.at>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/patcher.c, src/vm/jit
+       /patcher-common.h, src/vmcore/linker.c:
+       * changed src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Removed.
+       * changed src/vm/jit/m68k/codegen.c (patcher.h): Include removed.
+       (emit_codegen): Replaced emit_patcher_stubs by emit_patcher_trap.
+       (codegen_emit_stub_native): Likewise.
+
+       * changed src/vm/jit/m68k/emit.c (emit_patcher_stubs): Removed.
+
+       * changed src/vm/jit/m68k/patcher.c
+       (patcher_resolve_classref_to_classinfo): Ported to new patcher
+       signature.
+
+       * changed src/vm/jit/patcher-common.h: Enabled new patchers for
+       __M68K__.
+
+       * changed src/vmcore/linker.c (linker_preinit): __M68K__ has 4 byte
+       long alignment.
+       [b1e5181f9e58]
+
+2007-10-17  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/properties.c:
+       * src/vm/properties.c (properties_set) [ENABLE_JAVASE &&
+       WITH_CLASSPATH_SUN]: Set java.ext.dirs and java.ext.endorsed
+       properly.
+       [455021c09495]
+
+2007-10-14  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/intrp/codegen.c:
+       * src/vm/jit/intrp/codegen.c (intrp_codegen): Ported methodheader
+       changes (IsSync, exception table).
+       [b19e41db4eca]
+
+       * src/native/vm/gnu/java_lang_VMThrowable.c, src/native/vm/sun/jvm.c,
+       src/vm/jit/stacktrace.c:
+       * src/vm/jit/stacktrace.c (stacktrace_stack_walk): Changed return
+       type to bool, fill the temporary stackframe info with the values
+       from the stackframe info chain, if available. (stacktrace_create):
+       Don't include fillInStackTrace and init methods in the trace (as
+       HotSpot does).
+
+       * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace): Removed
+       fillInStackTrace and init checks.
+
+       * src/native/vm/sun/jvm.c (JVM_GetStackTraceDepth): Use
+       TRACEJVMCALLS, check for NPE, check if backtrace is NULL.
+       [e2c1b1f539de]
+
+       * src/vm/system.c, src/vm/system.h:
+       * src/vm/system.c: Changed copyright to CACAOVM.
+       * src/vm/system.h: Likewise.
+       [5db6925c6843]
+
+       * src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): Removed unused
+       variable ex.
+       [1a1bf81aba73]
+
+       * src/vm/exceptions.c, src/vm/jit/Makefile.am,
+       src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/dseg.c,
+       src/vm/jit/exceptiontable.c, src/vm/jit/exceptiontable.h,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/methodheader.h, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/exceptiontable.c: New file.
+       * src/vm/jit/exceptiontable.h: Likewise.
+
+       * src/vm/jit/Makefile.am (libjit_la_SOURCES): Added
+       exceptiontable.[ch].
+
+       * src/vm/exceptions.c (exceptions_handle_exception): Use new
+       exception table.
+
+       * src/vm/jit/code.h (vm/jit/exceptiontable.h): Added. (codeinfo):
+       Added exceptiontable.
+
+       * src/vm/jit/codegen-common.c (codegen_finish): Call
+       exceptiontable_create.
+
+       * src/vm/jit/dseg.c (dseg_addlinenumbertablesize): Removed padding.
+
+       * src/vm/jit/methodheader.h (ExTableSize, ExTableStart): Removed.
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S
+       (asm_vm_call_method): Removed exception table stuff.
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c
+       (codegen_emit): Likewise.
+       [33a0fdfa4121]
+
+2007-10-13  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): Use
+       jit_jitdata_new, this is more safe. (codegen_generate_stub_native):
+       Likewise.
+       [cd5057db2ddd]
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_handle_exception): Handle the
+       asm_vm_call_method special case outside the loop checking for code
+       == NULL.
+       [63c8a32690c6]
+
+       * src/vm/exceptions.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/i386/codegen.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/x86_64/codegen.c:
+       * src/vm/exceptions.c (exceptions_handle_exception): Use
+       code->synchronizedoffset directly for all architectures.
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c
+       (codegen_emit): Set code->synchronizedoffset to rd->memuse * 8.
+       [16ddb27b00ef]
+
+       * src/vm/exceptions.c, src/vm/jit/arm/codegen.c:
+       * src/vm/exceptions.c (exceptions_handle_exception) [__ARM__]: Added
+       #ifdef to the -8 path.
+
+       * src/vm/jit/arm/codegen.c (codegen_emit): Added +1 to rd->memuse
+       for synchronizedoffset.
+       [303bfaab95ac]
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/md.c, src/vm/jit/dseg.c, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/methodheader.h,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/methodheader.h (IsSync): Removed.
+
+       * src/vm/jit/dseg.c (dseg_addlinenumbertablesize): Removed one of
+       the paddings.
+
+       * src/vm/jit/arm/md.c (md_codegen_get_pv_from_pc): Commented the
+       IsLeaf-check (this should be removed).
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S
+       (asm_vm_call_method): Removed IsSync from method-header.
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c
+       (codegen_emit): Removed IsSync-dummy entry.
+       [b9a4396d7410]
+
+       * src/vm/exceptions.c, src/vm/jit/allocator/lsra.c,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/code.c, src/vm/jit/code.h,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/code.h (codeinfo): Added synchronizedoffset
+       (temporarily).
+
+       * src/vm/exceptions.c (exceptions_handle_exception): Don't use
+       IsSync but code->synchronizedoffset.
+
+       * src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/code.c: Use code_is_synchronized.
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c: Use
+       code_is_synchronized and set code->synchronizedoffset.
+       [b2916cc961d6]
+
+2007-10-13  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/Makefile.am:
+       * src/vm/jit/Makefile.am (noinst_HEADERS): Removed patcher.h
+       [29b2f2887b40]
+
+       * src/threads/lock-common.h, src/threads/native/lock.c, src/vm/jit
+       /codegen-common.c, src/vm/jit/codegen-common.h, src/vm/jit/emit-
+       common.h, src/vm/jit/patcher-common.h, src/vm/jit/patcher.h:
+       * src/threads/lock-common.h (lock_get_initial_lock_word): Removed
+       prototype.
+       * src/threads/native/lock.c (lock_get_initial_lock_word): Removed.
+
+       * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Removed.
+       * src/vm/jit/codegen-common.h (patchref) Removed structure.
+       (codegendata): Removed patchrefs. (codegen_add_patch_ref): Removed
+       prototype.
+
+       * src/vm/jit/emit-common.h (emit_patcher_stubs): Removed prototype.
+
+       * src/vm/jit/patcher-common.h: Removed ifdefs around patcher
+       function macros.
+
+       * src/vm/jit/patcher.h: Removed file.
+       [1fe0cccd3f9e]
+
+2007-10-13  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/arm/codegen.c:
+       * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Removed
+       patcher stub.
+       [fb92cc407e44]
+
+       * src/vm/jit/mips/codegen.c:
+       * src/vm/jit/mips/codegen.c (codegen_emit_stub_native): Removed
+       patcher stuff.
+       [a85035fe3af1]
+
+2007-10-13  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_call_method_objectarray): Moved primitive_box into
+       the native world.
+       [daaf716e707f]
+
+2007-10-13  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/stacktrace.c:
+       * src/vm/jit/stacktrace.c (stacktrace_stack_walk): Use the flags in
+       codeinfo to check for leaf-methods.<
+       [88cf8bfaa9ae]
+
+       * src/native/jvmti/jvmti.c, src/vm/jit/replace.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h:
+       * src/vm/jit/stacktrace.h (stackframeinfo_t): Removed method, added
+       code.
+
+       * src/native/jvmti/jvmti.c, src/vm/jit/replace.c,
+       src/vm/jit/stacktrace.c: Likewise.
+       [5ac994bd30b6]
+
+       * src/mm/cacao-gc/gc.c, src/native/jvmti/jvmti.c,
+       src/threads/native/threads.h, src/threads/threads-common.c,
+       src/vm/exceptions.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/jit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/replace.c,
+       src/vm/jit/replace.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h,
+       src/vm/jit/x86_64/codegen.c, src/vm/signal.c:
+       * src/vm/jit/stacktrace.h (stackframeinfo): Renamed to
+       stackframeinfo_t.
+
+       * src/mm/cacao-gc/gc.c, src/native/jvmti/jvmti.c,
+       src/threads/native/threads.h, src/threads/threads-common.c,
+       src/vm/exceptions.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/jit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/replace.c,
+       src/vm/jit/replace.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/x86_64/codegen.c,
+       src/vm/signal.c: Likewise.
+       [cff7e69a6d3e]
+
+2007-10-13  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/threads/native/threads.c, src/threads/threads-common.c:
+       * src/threads/native/threads.c: Fixed some compiler warnings.
+       * src/threads/threads-common.c: Likewise.
+       [ddee8a127826]
+
+       * tests/gc/LockRecords.java, tests/gc/Makefile,
+       tests/gc/NativeWeakRef.java, tests/gc/native.c:
+       * tests/gc/LockRecords.java: Added additional cleanup pass after
+       waiting.
+       * tests/gc/Makefile: Added NativeWeakRef testcase.
+       * tests/gc/NativeWeakRef.java: Added new testcase.
+       * tests/gc/native.c: Added native methods for NativeWeakRef testcase.
+       [eb85b412deb5]
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h,
+       src/threads/native/threads.c, src/threads/threads-common.h:
+       * src/mm/cacao-gc/gc.c (gc_global_lock): Removed obsolete global
+       lock. (gc_collect): Use GC mutex as global gc lock.
+       (gc_reference_register_intern, gc_reference_unregister_intern): Use
+       GC mutex to lock the reference lists.
+
+       * src/mm/cacao-gc/gc.h (GC_MUTEX_LOCK, GC_MUTEX_UNLOCK): Added
+       macros.
+
+       * src/threads/native/threads.c [ENABLE_GC_CACAO] (mutex_gc): Added
+       GC mutex. [ENABLE_GC_CACAO] (threads_mutex_gc_lock,
+       threads_mutex_gc_unlock): Implemented.
+
+       * src/threads/threads-common.h [ENABLE_GC_CACAO]
+       (threads_mutex_gc_lock, threads_mutex_gc_unlock): Added prototypes.
+       [49eb4810d097]
+
+       * src/vm/string.c:
+       * src/vm/string.c (javastring_toutf): Added check for empty strings.
+       [8c1dc97f1d6a]
+
+2007-10-13  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/jit.c, src/vm/jit/jit.h,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/emit.c, src/vm/jit/optimizing/lsra.c,
+       src/vm/jit/optimizing/ssa.c, src/vm/jit/parse.c, src/vm/jit/parse.h,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/md-abi.c,
+       src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/replace.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, src/vm/jit/s390
+       /md-abi.c, src/vm/jit/show.c, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/stack.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.c:
+       * src/vm/jit/jit.h (jitdata): Removed isleafmethod.
+
+       * src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/jit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/emit.c, src/vm/jit/optimizing/lsra.c,
+       src/vm/jit/optimizing/ssa.c, src/vm/jit/parse.c, src/vm/jit/parse.h,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/md-abi.c,
+       src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/replace.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, src/vm/jit/s390
+       /md-abi.c, src/vm/jit/show.c, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/stack.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.c: Replaced jd->isleafmethod with
+       code_is_leafmethod.
+       [14e3f40c0673]
+
+2007-10-12  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao-gc/mark.c,
+       src/mm/cacao-gc/rootset.c, src/mm/gc-common.h,
+       src/threads/native/lock.c:
+       * src/mm/cacao-gc/gc.c (gc_reflist_weak): Added list for weak
+       references. (gc_weakreference_register,
+       gc_weakreference_unregister): Implemented. (gc_collect): Added
+       preliminary call to lock_hashtable_cleanup.
+
+       * src/mm/cacao-gc/gc.h (gc_reflist_weak): Added.
+
+       * src/mm/cacao-gc/mark.c (mark_post): Added postprocessing function.
+
+       * src/mm/cacao-gc/rootset.c (rootset_from_globals): Add weak
+       references. (reftype_names): Adapted to new enumeration.
+
+       * src/mm/gc-common.h: Reference types are now enumerated.
+       (gc_weakreference_register, gc_weakreference_unregister): Added
+       prototypes.
+
+       * src/threads/native/lock.c [ENABLE_GC_CACAO]
+       (lock_hashtable_cleanup): Added. (lock_record_new, lock_record_free)
+       [ENABLE_GC_CACAO]: Register and unregister references to lock object
+       with the GC (as weak references).
+       [fb2f8cea78af]
+
+       * src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/replace.c:
+       * src/vm/jit/code.c (code_get_codeinfo_for_pv): Added new function.
+       (code_find_codeinfo_for_pc): Use above function.
+       (code_get_methodinfo_for_pv): Likewise.
+
+       * src/vm/jit/code.h (code_get_codeinfo_for_pv): Added prototype.
+
+       * src/vm/jit/replace.c (replace_pop_activation_record): Use above
+       function. (replace_patch_method_pointer): Likewise.
+       (replace_pop_native_frame): Skip native stubs with new sfi
+       correctly. (replace_push_native_frame): Likewise.
+       [8a4d773ffcee]
+
+       * * Merged with rev 974c36a815eb.
+       [7a0bc326262a]
+
+       * src/cacaoh/headers.h, src/vm/string.c, src/vm/stringlocal.h:
+       * src/cacaoh/headers.h (literalstring_free): Removed obsolete
+       prototype.
+
+       * src/vm/stringlocal.h (literalstring_u2, literalstring_free):
+       Likewise.
+
+       * src/vm/string.c (heapstring_t): Added typedef.
+       (stringtable_update): Adapted for handles. (javastring_tochar): Code
+       cleanup. (javastring_toutf): Code cleanup. (literalstring_u2): Made
+       static and adapted for handles. (literalstring_free): Likewise.
+       (javastring_intern): Code cleanup and added comments.
+       [f52d56ea383b]
+
+2007-10-12  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac, src/native/vm/sun/jvm.c:
+       * configure.ac (AC_CHECK_FUNCS): Added ftruncate.
+
+       * src/native/vm/sun/jvm.c (JVM_DefineClassWithSource): Handle when
+       name is NULL properly. (JVM_Lseek): Use TRACEJVMCALLS.
+       (JVM_SetLength): Implemented.
+       [974c36a815eb]
+
+2007-10-11  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_detach_thread): Fixed CLDC
+       build.
+       [03703b6d4855]
+
+2007-10-09  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/powerpc64/codegen.c:
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native): Removed
+       patcher stuff.
+       [8d1744a5a128]
+
+       * * Merged with b23caa4282a5.
+       [8f008c01aec4]
+
+       * tests/regression/Makefile.am:
+       * tests/regression/Makefile.am (SOURCE_FILES): Removed
+       extest_clinit.java.
+       [e9d81d59eea6]
+
+       * * Merged with 3b6c3b177749.
+       [b23caa4282a5]
+
+       * tests/regression/extest_clinit.java:
+       * Merged with 59ff46a9e236.
+       [d6f8c68e5b5f]
+
+       * src/vm/jit/code.h:
+       * src/vm/jit/code.h (stdint.h): Added. (CODE_FLAG_SYNCHRONIZED): New
+       flag. (code_is_synchronized): New function.
+       (code_flag_synchronized): Likewise. (code_unflag_synchronized):
+       Likewise.
+       [eed84225afd7]
+
+2007-10-09  Roland Lezuo  <tbfg@complang.tuwien.ac.at>
+
+       * tests/regression/extest_clinit.java:
+       Merged?
+       [3b6c3b177749]
+
+       * src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c, src/vm/jit/patcher-
+       common.h:
+       (codegen_emit_stub_builtin): Removed. (codegen_emit_stub_native):
+       Ported to new interface.
+
+       Ported to new interface, removed warnings.
+       (md_signal_handler_sigill): Likewise.
+
+       (offset.h): Removed.
+
+       (PATCH_BACK_ORIGINAL_MCODE): Added. (patcher_patch_back): Removed.
+       (patcher_patch_code): Added. (patcher_*): Use patchref_t instead of
+       void *sp everywhere.
+       [1f374ab123d9]
+
+2007-10-09  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/system.c:
+       * src/vm/system.c [__DARWIN__]: Fixed includes.
+       [3fc50ec37a00]
+
+       * src/threads/native/lock.c, src/vm/finalizer.c, src/vmcore/options.c,
+       src/vmcore/options.h, tests/gc/LockRecords.java:
+       * src/vm/finalizer.c (finalizer_run): Fixed for handles and added
+       boehm-hack. (finalizer_thread, finalizer_notify): Added debug
+       output.
+
+       * src/vmcore/options.c (opt_DebugFinalizer): Added debug switch.
+       * src/vmcore/options.h (opt_DebugFinalizer): Likewise.
+
+       * src/threads/native/lock.c (lock_hashtable_remove): Also frees the
+       lock record. (lock_record_finalizer): Same as for finalizer_run
+       above. (lock_hashtable_get) [ENABLE_GC_BOEHM]: Fixed registration of
+       finalizer.
+
+       * tests/gc/LockRecords.java: Added new testcase for lock records
+       cleanup.
+       [59ff46a9e236]
+
+       * src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c:
+       * src/native/vm/gnu/java_lang_reflect_Field.c
+       (cacao_get_field_address) Removed. (_field_access_check,
+       _field_get_type, _field_set_type): Added new functions.
+       (Java_java_lang_reflect_Field_XXX): Adapted to above changes and
+       thereby fixing it for handles.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c: Just removed bogus
+       casting.
+       [2ba3107ae158]
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_DeleteLocalRef): Fixed compiler warning.
+       (_Jv_JNI_GetXXXField, _Jv_JNI_SetXXXField): Fixed for handles.
+       (_Jv_JNI_GetStaticObjectField, _Jv_JNI_SetStaticObjectField):
+       Likewise. (_Jv_JNI_SetObjectArrayElement): Adapted to new
+       builtin_canstore. (_Jv_JNI_NewGlobalRef): Made LLNI critical
+       sections smaller to avoid deadlock.
+       [5e87139265f5]
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_detach_thread): Fixed debug
+       output and compiler warning.
+       [06ec3216cf7d]
+
+2007-10-08  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/codegen.h,
+       src/vm/jit/powerpc/darwin/md-asm.h, src/vm/jit/powerpc/darwin/md-
+       os.c, src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-os.c:
+       * src/vm/jit/powerpc/arch.h (JIT_COMPILER_VIA_SIGNAL): Temporarily
+       added.
+
+       * src/vm/jit/powerpc/asmpart.S (asm_call_jit_compiler): Removed.
+       (L_jit_asm_compile$stub): Likewise.
+       (L_exceptions_get_and_clear_exception$stub): Likewise.
+
+       * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_compiler):
+       Removed.
+
+       * src/vm/jit/powerpc/codegen.h (COMPILERSTUB_CODESIZE): Adapted
+       size.
+
+       * src/vm/jit/powerpc/darwin/md-asm.h (asm_call_jit_compiler):
+       Removed. (exceptions_get_and_clear_exception): Likewise.
+       (jit_asm_compile): Likewise.
+
+       * src/vm/jit/powerpc/emit.c (emit_trap_compiler): New function.
+
+       * src/vm/jit/powerpc/darwin/md-os.c (md_signal_handler_sigsegv):
+       Added compiler-by-signals code.
+       * src/vm/jit/powerpc/linux/md-os.c: Likewise.
+       [598cc626e0ee]
+
+       * src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_native): Removed
+       patcher stuff.
+       [e4601e449e45]
+
+       * tests/regression/extest.2output, tests/regression/extest.java,
+       tests/regression/extest_clinit.java:
+       * tests/regression/extest.java: Updated a bit and added another
+       testcase.
+       * tests/regression/extest.2output: Updated.
+       * tests/regression/extest_clinit.java: Removed.
+       [a95b70c0cad9]
+
+       * src/vm/jit/stacktrace.c:
+       * src/vm/jit/stacktrace.c (stacktrace_stackframeinfo_add) [!NDEBUG]:
+       Added DebugStackFrameInfo output.
+       (stacktrace_stackframeinfo_remove): Likewise.
+       (stacktrace_stack_walk): Bugfix when a patcher in a leaf-method
+       causes an exception.
+       [cdbe094feb17]
+
+2007-10-08  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/builtin.c, src/vm/builtin.h:
+       * src/vm/builtin.c: Major cleanup of code and commentes, to much to
+       list here, please accept my apologies for this short commit message.
+       Everything is Handles-ready now.
+
+       * src/vm/builtin.h: Adapted signatures of builtins and added vim
+       boilerplate.
+       [da567e175ac6]
+
+       * src/native/llni.h, src/threads/native/lock.h, src/vm/finalizer.c,
+       src/vm/jit/optimizing/recompile.c:
+       * src/native/llni.h (LLNI_QUICKWRAP): Added new macro.
+
+       * src/threads/native/lock.h: Use above macro for internal locking.
+       (LOCK_WAIT_FOREVER, LOCK_NOTIFY): Added new macros.
+
+       * src/vm/finalizer.c: Use internal locking macros throughout the
+       code.
+       * src/vm/jit/optimizing/recompile.c: Likewise.
+       [6d2627458877]
+
+2007-10-08  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_create_replacement_points): Use new
+       code inline functions. (replace_pop_activation_record): Likewise.
+       (replace_push_activation_record): Likewise.
+       [cd0843508cff]
+
+2007-10-08  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/arm/emit.c:
+       * src/vm/jit/arm/emit.c (emit_verbosecall_exit): Fixed comments.
+       [fbf41207864f]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_create): Moved localref_table_init from
+       vm_createjvm.
+       [b924c9f5250c]
+
+       * src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/gnu/java_lang_VMObject.c, src/native/vm/sun/jvm.c:
+       * src/native/vm/cldc1.1/java_lang_Object.c
+       (Java_java_lang_Object_notify): Adapted to new locking function
+       signatures. (Java_java_lang_Object_notifyAll): Likewise.
+       (Java_java_lang_Object_wait): Likewise.
+
+       * src/native/vm/gnu/java_lang_VMObject.c
+       (Java_java_lang_VMObject_notify): Adapted to new locking function
+       signatures. (Java_java_lang_VMObject_notifyAll): Likewise.
+       (Java_java_lang_VMObject_wait): Likewise.
+
+       * src/native/vm/sun/jvm.c (JVM_MonitorWait): Adapted to new locking
+       function signatures. (JVM_MonitorNotify): Likewise.
+       (JVM_MonitorNotifyAll): Likewise.
+       [6540073cf5a9]
+
+2007-10-08  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * * Merged with ad640e81c710.
+       [890fd7ef3d91]
+
+       * src/vm/jit/code.h, src/vm/jit/jit.c:
+       * src/vm/jit/code.h (codeinfo): Renamed codeflags to flags.
+       (CODE_IS_VALID, CODE_IS_INVALID, CODE_IS_LEAFMETHOD)
+       (CODE_SETFLAG_INVALID, CODE_SETFLAG_LEAFMETHOD): Removed.
+       (code_is_invalid, code_flag_invalid, code_unflag_invalid): New
+       inline function. (code_is_leafmethod, code_flag_leafmethod,
+       code_unflag_leafmethod): Likewise.
+
+       * src/vm/jit/jit.c (jit_invalidate_code): Use new inline functions.
+       (jit_get_current_code): Likewise.
+       [79af8d668a13]
+
+2007-10-08  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/cacaoh/dummy.c, src/threads/lock-common.h,
+       src/threads/native/lock.c:
+       * src/threads/lock-common.h: Changed signature of most locking
+       functions to take handles as arguments.
+
+       * src/cacaoh/dummy.c: Adapted to new signatures.
+
+       * src/threads/native/lock.c: Adapted to new signatures and added
+       LLNI critical sections. Will slow down locking for [ENABLE_HANDLES
+       && ENABLE_GC_CACAO]. (lock_lockword_get). Implemented.
+       (lock_lockword_set): Implemented.
+       [ad640e81c710]
+
+       * src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.h:
+       * src/vm/jit/alpha/emit.c (emit_verbosecall_enter): Adapted to use
+       new tracer. (emit_verbosecall_exit): Likewise.
+
+       * src/vm/jit/alpha/md-abi.h (TRACE_ARGS_NUM): Removed.
+       [9e38d84cc222]
+
+       * src/native/llni.c, src/native/llni.h:
+       * src/native/llni.h (LLNI_CRITICAL_START_THREAD): Added faster
+       macro. (LLNI_CRITICAL_END_THREAD): Likewise.
+
+       * src/native/llni.c (llni_critical_start_thread): Implemented faster
+       function. (llni_critical_end_thread): Likewise.
+       [8cbaddb63fe3]
+
+       * src/native/llni.h:
+       * src/native/llni.h (LLNI_field_set_ref): Fixed problem with NULL
+       references.
+       [c765f13d96ff]
+
+2007-10-07  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/builtin.c:
+       * src/vm/builtin.c (builtin_print_argument): Removed obsolete
+       function. (builtin_verbosecall_enter): Made a dummy function, use
+       new tracer. (builtin_verbosecall_exit): Likewise.
+       [88b3f386c93a]
+
+       * src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-abi.h:
+       * src/vm/jit/powerpc64/emit.c (emit_verbosecall_enter): Adapted to
+       use new tracer. (emit_verbosecall_exit): Likewise.
+
+       * src/vm/jit/powerpc64/linux/md-abi.h (TRACE_ARGS_NUM): Removed.
+       [53674e362433]
+
+       * src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.h:
+       * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Adapted to use new
+       tracer. (emit_verbosecall_exit): Likewise.
+
+       * src/vm/jit/arm/md-abi.h (TRACE_ARGS_NUM): Removed.
+       [b630de06148c]
+
+       * src/vm/jit/i386/emit.c, src/vm/jit/i386/md-abi.h:
+       * src/vm/jit/i386/emit.c (emit_verbosecall_enter): Adapted to use
+       new tracer. (emit_verbosecall_exit): Likewise.
+
+       * src/vm/jit/i386/md-abi.h (TRACE_ARGS_NUM): Removed.
+       [14c64bfb5899]
+
+       * src/vm/jit/powerpc/darwin/md-abi.h, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/powerpc/netbsd/md-
+       abi.h, src/vm/jit/s390/md-abi.h, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.h:
+       * src/vm/jit/x86_64/emit.c (emit_verbosecall_enter): Adapted to use
+       new tracer. (emit_verbosecall_exit): Likewise.
+
+       * src/vm/jit/x86_64/md-abi.h (TRACE_ARGS_NUM): Removed.
+
+       * src/vm/jit/s390/md-abi.h (TRACE_ARGS_NUM): Removed, already uses
+       new tracer.
+
+       * src/vm/jit/powerpc/darwin/md-abi.h (TRACE_ARGS_NUM): Likewise.
+       * src/vm/jit/powerpc/linux/md-abi.h (TRACE_ARGS_NUM): Likewise.
+       * src/vm/jit/powerpc/netbsd/md-abi.h (TRACE_ARGS_NUM): Likewise.
+
+       * src/vm/jit/powerpc/emit.c (vm/builtin.h): Removed obsolete
+       include.
+       [274bd505a69b]
+
+2007-10-06  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/native/vm/java_lang_Thread.c, src/threads/native/threads.c,
+       src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/threads-common.h (threads_thread_get_object): Added.
+       (threads_thread_set_object): Added.
+
+       * src/threads/threads-common.c: Use above functions throughout the
+       code.
+
+       * src/threads/native/threads.c: Likewise.
+
+       * src/native/vm/java_lang_Thread.c: Likewise.
+       (_Jv_java_lang_Thread_start): Fixed compiler warning.
+       (_Jv_java_lang_Thread_currentThread) [ENABLE_JAVASE]: Fixed for
+       handles.
+       [01272c7b7f7e]
+
+       * src/native/jni.c, src/native/llni.h, src/vm/builtin.c:
+       * src/native/llni.h (LLNI_objectarray_element_set) Removed.
+       (LLNI_objectarray_element_get) Removed.
+
+       * src/native/jni.c: Use array_objectarray functions throughout the
+       code.
+       * src/vm/builtin.c: Likewise.
+       [841ec0d005f8]
+
+       * src/native/jni.c, src/native/localref.c:
+       * src/native/jni.c (_Jv_JNI_DeleteLocalRef): Handle NULL references
+       correctly.
+       * src/native/localref.c (localref_add, localref_del): Added assertion.
+       [1b879af9b08e]
+
+2007-10-06  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/jit.c, src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/jit.c (jit_compile_intern): Use native_method_resolve
+       and check for exception.
+
+       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Removed
+       patcher stuff.
+       [3fceed4e5c71]
+
+       * src/native/native.c, src/native/native.h, src/vm/jit/patcher-
+       common.c:
+       * src/native/native.c (native_resolve_function): Renamed to
+       native_method_resolve.
+       * src/native/native.h: Likewise.
+
+       * src/vm/jit/patcher-common.c (patcher_resolve_native_function):
+       Likewise.
+       [fd16ab5d87f1]
+
+       * src/vm/jit/allocator/simplereg.c, src/vm/jit/jit.h,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/show.c, src/vm/jit/stack.c, src/vm/jit/verify/icmds.c:
+       * src/vm/jit/allocator/simplereg.c (ICMD_IF_FCMPxx,
+       ICMD_IF_FCMPL_xx): Removed.
+       * src/vm/jit/jit.h: Likewise.
+       * src/vm/jit/powerpc/codegen.c: Likewise.
+       * src/vm/jit/powerpc64/codegen.c: Likewise.
+       * src/vm/jit/show.c: Likewise.
+       * src/vm/jit/stack.c: Likewise.
+       * src/vm/jit/verify/icmds.c: Likewise.
+       [ba6af13783a8]
+
+2007-10-03  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/cacaoh/dummy.c, src/vm/array.c, src/vm/jit/argument.c,
+       src/vm/jit/stacktrace.c:
+       * src/vm/array.c (array_objectarray_element_set): Fixed for handles.
+       (array_objectarray_element_get): Likewise.
+
+       * src/cacaoh/dummy.c (array_objectarray_element_set): Do not use
+       LLNI_objectarray macros. (array_objectarray_element_get): Likewise.
+
+       * src/vm/jit/argument.c: Use array_objectarray functions instead of
+       LLNI_objectarray.
+
+       * src/vm/jit/stacktrace.c: Likewise.
+       [a4856d5695d8]
+
+2007-10-03  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/exceptions.c, src/vm/jit/codegen-common.c, src/vm/jit/jit.c,
+       src/vm/jit/m68k/patcher.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, src/vm/signal.c:
+       * src/vm/jit/stacktrace.c (stacktrace_create_stackframeinfo):
+       Removed. (stacktrace_create_extern_stackframeinfo): Renamed to
+       stacktrace_stackframeinfo_add. (stacktrace_remove_stackframeinfo):
+       Renamed to stacktrace_stackframeinfo_remove.
+       * src/vm/jit/stacktrace.h: Likewise.
+
+       * src/vm/exceptions.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/jit.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/sparc64/patcher.c, src/vm/signal.c: Renamed functions as
+       above.
+       [25cf57814a88]
+
+2007-10-03  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Fixed
+       stackframesize for (md->paramcount == 0 && md->returntype !=
+       TYPE_VOID) cases.
+       [a7482a807f1e]
+
+       * src/native/localref.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/native/localref.c: Improved debug output with
+       -XX:+DebugLocalReferences. (localref_check_uncleared): Implemented.
+
+       * src/vmcore/options.c (opt_DebugLocalReferences): Added.
+       * src/vmcore/options.h (opt_DebugLocalReferences): Likewise.
+       [8e0d054d7791]
+
+2007-10-03  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/stacktrace.c:
+       * src/vm/jit/codegen-common.c (codegen_start_native_call): Renamed
+       currentsp to sp, removed javara, use
+       stacktrace_create_extern_stackframeinfo instead of
+       stacktrace_create_native_stackframeinfo.
+       (codegen_finish_native_call): Renamed currentsp to sp.
+
+       * src/vm/jit/stacktrace.c (stdint.h): Added.
+       (stacktrace_create_extern_stackframe): Always get methodinfo and
+       store it in stackframeinfo.
+       (stacktrace_create_native_stackframeinfo): Removed.
+       (stacktrace_add_entry): Renamed to stacktrace_entry_add, made
+       inline. (stacktrace_add_method): Renamed to stacktrace_method_add,
+       made inline. (stacktrace_stack_walk): New function.
+       (stacktrace_create): Completely rewritten.
+       [e61772b09f4d]
+
+2007-10-03  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/native/vm/cldc1.1/java_lang_Throwable.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c, src/native/vm/sun/jvm.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h:
+       * src/vm/jit/stacktrace.c (stacktrace_fillInStackTrace): Returns a
+       bytearray. (stacktrace_print_trace): Does not use
+       stacktracecontainer anymore.
+
+       * src/vm/jit/stacktrace.h (stacktracecontainer): Removed.
+       (stacktrace_fillInStackTrace): Adapted prototype to above change.
+
+       * src/native/vm/cldc1.1/java_lang_Throwable.c: Adapted to above
+       changes.
+       * src/native/vm/gnu/java_lang_VMThrowable.c: Likewise.
+       * src/native/vm/sun/jvm.c: Likewise.
+       [d528eb08966a]
+
+2007-10-03  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/jit.c:
+       * src/vm/jit/jit.c (jit_compile_handle): Removed unused variable.
+       [417ec2928806]
+
+       * src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/codegen.h,
+       src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c:
+       * src/vm/jit/powerpc64/arch.h (JIT_COMPILER_VIA_SIGNAL): Temporarily
+       added.
+
+       * src/vm/jit/powerpc64/asmpart.S (asm_call_jit_compiler): Removed.
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_compiler):
+       Likewise.
+
+       * src/vm/jit/powerpc64/codegen.h (COMPILERSTUB_CODESIZE): Adapted
+       size.
+
+       * src/vm/jit/powerpc64/emit.c (emit_trap_compiler): New function.
+
+       * src/vm/jit/powerpc64/linux/md-os.c (md_signal_handler_sigsegv):
+       Added compiler-by-signals code.
+       [f7859b7aea62]
+
+       * src/vm/jit/alpha/arch.h, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/codegen.h,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c:
+       * src/vm/jit/alpha/arch.h (JIT_COMPILER_VIA_SIGNAL): Temporarily
+       added.
+
+       * src/vm/jit/alpha/asmpart.S (asm_call_jit_compiler): Removed.
+       * src/vm/jit/alpha/codegen.c (codegen_emit_stub_compiler): Likewise.
+
+       * src/vm/jit/alpha/codegen.h (COMPILERSTUB_CODESIZE): Adapted size.
+
+       * src/vm/jit/alpha/emit.c (emit_trap_compiler): New function.
+
+       * src/vm/jit/alpha/linux/md-os.c (vm/exceptions.h): Added.
+       (md_signal_handler_sigsegv): Added compiler-by-signals code.
+       [41acab1bbc53]
+
+2007-10-03  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/java_lang_Class.c, src/vm/vm.c:
+       * src/vm/vm.c: Use array_objectarray functions instead of
+       LLNI_objectarray.
+       * src/native/vm/gnu/gnu_classpath_VMStackWalker.c: Likewise.
+       * src/native/vm/gnu/java_lang_VMThrowable.c: Likewise.
+       * src/native/vm/java_lang_Class.c: Likewise.
+       [dfd4ba44560b]
+
+2007-10-03  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/m68k/md.c, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/s390/md.c:
+       * src/vm/jit/m68k/md.c (md_codegen_patch_branch): Removed.
+       * src/vm/jit/powerpc64/md.c: Likewise.
+       * src/vm/jit/s390/md.c: Likewise.
+       [74debb2c5834]
+
+2007-10-03  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/builtintable.inc:
+       * src/vm/builtintable.inc (builtintable_internal): Added preliminary
+       entry for builtin_multianewarray.
+       [4728593261f4]
+
+       * src/mm/memory.h, src/native/localref.c, src/vmcore/class.c,
+       src/vmcore/field.c:
+       * src/mm/memory.h [ENABLE_GC_BOEHM]: GCNEW macros are available for
+       boehm only.
+
+       * src/native/localref.c: Adapted ifdefs to above change.
+
+       * src/vmcore/class.c: Adapted ifdefs to above change. (class_free):
+       Fixed, fields array get freed properly.
+
+       * src/vmcore/field.c: Adapted ifdefs to above change. (field_free):
+       Implemented, field value memory gets freed.
+       [c33e0df79652]
+
+2007-10-01  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/native/vm/reflect.c:
+       * src/native/vm/reflect.c [ENABLE_ANNOTATIONS]: Fixed includes.
+       [fc72108d11a3]
+
+       * doc/Makefile.am, doc/handbook/Makefile.am:
+       * doc/Makefile.am: Fixed clean target to work properly.
+       * doc/handbook/Makefile.am: Likewise.
+       [a380a08533a3]
+
+2007-10-01  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/i386/md.c:
+       * src/vm/jit/i386/md.c (vm/vm.h): Added.
+       (md_jit_method_patch_address): Rewritten to new proposed version.
+       [ec8797d1e6e4]
+
+       * src/vm/jit/i386/linux/md-os.c:
+       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv): Set PV
+       and XPC correctly.
+       [6a09e13f9f75]
+
+       * src/vm/jit/i386/emit.c:
+       * src/vm/jit/i386/emit.c (emit_verbosecall_enter): Use M_CLTD.
+       [c476a916878f]
+
+       * src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/signal.c:
+       * src/vm/jit/jit.c (jit_compile_handle): Changed signature.
+       * src/vm/jit/jit.h: Likewise.
+
+       * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): Set
+       PV and XPC correctly.
+
+       * src/vm/signal.c (signal_handle): Get the methodinfo pointer and
+       pass it to jit_compile_handle.
+       [005f80121869]
+
+       * src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/emit.h,
+       src/vm/jit/i386/linux/md-os.c:
+       * src/vm/jit/i386/arch.h (JIT_COMPILER_VIA_SIGNAL): Temporarily
+       added.
+
+       * src/vm/jit/i386/asmpart.S (asm_call_jit_compiler): Removed.
+
+       * src/vm/jit/i386/codegen.c (codegen_emit_stub_compiler): Likewise.
+
+       * src/vm/jit/i386/codegen.h (COMPILERSTUB_CODESIZE): Adapted size.
+       (M_BYTE1, M_BYTE2): New macros. (M_CLTD, M_RET, M_NOP): Use M_BYTE1.
+       (M_UD2): Use M_BYTE2.
+
+       * src/vm/jit/i386/emit.c (emit_trap_compiler): New function.
+       (emit_trap): Use macros. (emit_cltd, emit_ret, emit_nop): Removed.
+       * src/vm/jit/i386/emit.h (emit_cltd, emit_ret, emit_nop): Likewise.
+
+       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv): Added
+       JIT compiler code.
+       [67dda8c1dc3d]
+
+       * src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/x86_64/emit.c (emit_trap_compiler): Fixed comment.
+       [a3ff74c5b8b0]
+
+       * src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv):
+       Removed debug output.
+       [79001d4e5c15]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_InitProperties): Fixed warning.
+       [f91157763a26]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (vm/system.h): Added.
+       (JVM_ActiveProcessorCount): Implemented.
+       [121bbaac9f59]
+
+       * src/native/vm/gnu/java_lang_VMRuntime.c, src/vm/Makefile.am,
+       src/vm/system.c, src/vm/system.h:
+       * src/native/vm/gnu/java_lang_VMRuntime.c (vm/system.h): Added.
+       (availableProcessors): Use system_processors_online.
+
+       * src/vm/Makefile.am (libvm_la_SOURCES): Added system.[ch].
+
+       * src/vm/system.c: New file.
+       * src/vm/system.h: Likewise.
+       [3215b4903941]
+
+       * src/vm/jit/jit.c, src/vm/vm.c:
+       * src/vm/jit/jit.c (jit_compile_handle): Fixed warning.
+       * src/vm/vm.c (vm_abort_disassemble): Likewise.
+       [294eb7f45035]
+
+       * src/native/vm/sun/jvm.c, src/vmcore/class.h:
+       * src/native/vm/sun/jvm.c (JVM_SetClassSigners): Implemented.
+       * src/vmcore/class.h (classinfo) [WITH_CLASSPATH_SUN]: Added signers.
+       [3fd887e6e438]
+
+       * src/vm/jit/jit.c:
+       * src/vm/jit/jit.c (jit_compile_intern) [WITH_CLASSPATH_SUN]: Don't
+       verify sub-classes of sun/reflect/MagicAccessorImpl.
+       [51ab7abeebc5]
+
+2007-09-29  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/s390/patcher.c:
+       * src/vm/jit/s390/patcher.c
+       (patcher_checkcast_instanceof_interface): Fix error introduced in
+       changeset 7586.
+       [d5b33f1afb30]
+
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/patcher.c:
+       * src/vm/jit/s390/codegen.h: Added functions for instruction parsing
+       and manipulation, added opcode defines.
+       * src/vm/jit/s390/codegen.c (codegen_emit): Replaced handcrafted
+       machined code patching by marco.
+       * src/vm/jit/s390/emit.c (emit_branch): Likewise.
+       * src/vm/jit/s390/md.c (md_jit_method_patch_address,
+       md_signal_handler_sigsegv, md_signal_handler_sigill,
+       md_signal_handler_sigfpe): Replaced handcrafted machine code parsing
+       and patching by calls to new functions.
+       * src/vm/jit/s390/patcher.c (patcher_invokeinterface,
+       patcher_invokevirtual, patcher_get_putfield): Likewise.
+       [4a9b0a8de18b]
+
+2007-09-29  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c, src/vm/jit
+       /codegen-common.h, src/vm/jit/emit-common.h, src/vm/jit/jit.c,
+       src/vm/jit/jit.h, src/vm/jit/x86_64/arch.h,
+       src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/linux/md-os.c, src/vm/signal.c:
+       * src/vm/jit/asmpart.h [!JIT_COMPILER_VIA_SIGNAL]
+       (asm_call_jit_compiler): Added #ifdef.
+
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler)
+       [JIT_COMPILER_VIA_SIGNAL]: Added new code.
+
+       * src/vm/jit/codegen-common.h [!JIT_COMPILER_VIA_SIGNAL]
+       (codegen_emit_stub_compiler): Added #ifdef.
+
+       * src/vm/jit/emit-common.h (emit_trap_compiler): Added.
+
+       * src/vm/jit/jit.c [!JIT_COMPILER_VIA_SIGNAL] (jit_asm_compile):
+       Added #ifdef. (jit_compile_handle): New function.
+
+       * src/vm/jit/jit.h (vm/jit/stacktrace.h): Added.
+       [!JIT_COMPILER_VIA_SIGNAL] (jit_asm_compile): Added #ifdef.
+
+       * src/vm/jit/x86_64/arch.h (JIT_COMPILER_VIA_SIGNAL): Added
+       temporarily.
+
+       * src/vm/jit/x86_64/asmpart.S (asm_call_jit_compiler): Removed.
+
+       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_compiler): Removed.
+       * src/vm/jit/x86_64/codegen.h (COMPILERSTUB_CODESIZE): Adapted.
+
+       * src/vm/jit/x86_64/emit.c (emit_trap_compiler): New function.
+
+       * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): Added
+       JIT compiler handling code.
+       * src/vm/signal.c (signal_handle): Likewise.
+       [1625eb0b4231]
+
+       * src/vm/jit/alpha/md.c, src/vm/jit/arm/md.c, src/vm/jit/i386/md.c,
+       src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/m68k/md.c,
+       src/vm/jit/md.h, src/vm/jit/mips/md.c, src/vm/jit/powerpc/md.c,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/replace.c,
+       src/vm/jit/s390/md.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/x86_64/md.c:
+       * src/vm/jit/md.h (md_get_method_patch_address): Removed.
+       * src/vm/jit/jit.h (md_jit_method_patch_address): Added.
+
+       * src/vm/jit/jit.c (jit_asm_compile): Call
+       md_jit_method_patch_address with new signature.
+
+       * src/vm/jit/replace.c (replace_patch_future_calls): Likewise.
+
+       * src/vm/jit/alpha/md.c, src/vm/jit/arm/md.c, src/vm/jit/i386/md.c,
+       src/vm/jit/m68k/md.c, src/vm/jit/mips/md.c, src/vm/jit/powerpc/md.c,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/s390/md.c,
+       src/vm/jit/sparc64/md.c, src/vm/jit/x86_64/md.c: Tried to fix the
+       includes. (md_get_method_patch_address): Renamed to
+       md_jit_method_patch_address and changed the signature.
+       [5a0a7be1c61c]
+
+       * src/vm/jit/alpha/codegen.h, src/vm/jit/alpha/linux/md-os.c:
+       * src/vm/jit/alpha/codegen.h (M_MEM_GET_Opcode): New macro.
+       (M_MEM_GET_A): Renamed to M_MEM_GET_Ra to be consistent with
+       handbook. (M_MEM_GET_B): Renamed to M_MEM_GET_Rb. (M_MEM_GET_DISP):
+       Renamed to M_MEM_GET_Memory_disp.
+
+       * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Use
+       new macro names.
+       [01d55d426e53]
+
+       * src/vm/vm.c, src/vm/vm.h:
+       * src/vm/vm.c [ENABLE_DISASSEMBLER] (vm/jit/disass.h): Added.
+       (vm_abort_disassemble): New function.
+       * src/vm/vm.h (vm_abort_disassemble): Likewise.
+       [3666493a0162]
+
+2007-09-28  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/jni.c:
+       * src/native/jni.c: Merged with 93595e0b477d.
+       [e03e02f0135d]
+
+       * src/vm/jit/powerpc/asmpart.S:
+       * src/vm/jit/powerpc/asmpart.S (asm_vm_call_method): Don't fake a
+       Java call, because we don't patch this call anymore (TODO: all other
+       architectures as well).
+       [93595e0b477d]
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_GetEnv): Use jni_version_check.
+       [4194e7194975]
+
+       * src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/darwin/md-asm.h:
+       * src/vm/jit/powerpc/asmpart.S
+       (L_stacktrace_create_extern_stackframeinfo$stub): Removed.
+       (L_stacktrace_remove_stackframeinfo$stub): Likewise.
+       (L_replace_me$stub): Likewise.
+       (L_replace_build_execution_state$stub): Likewise.
+       (L_replace_free_safestack$stub): Likewise.
+
+       * src/vm/jit/powerpc/darwin/md-asm.h (jumptable_int,
+       jumptable_long): Removed. (asm_patcher_wrapper): Likewise.
+       (patcher_wrapper): Likewise. (replace_me): Likewise.
+       (replace_build_execution_state): Likewise. (replace_free_safestack):
+       Likewise. (stacktrace_create_extern_stackframeinfo): Likewise.
+       (stacktrace_remove_stackframeinfo): Likewise.
+       [1eea65d453be]
+
+2007-09-28  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/mm/cacao-gc/rootset.c, src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_gc_into_native): Implemented.
+       * src/mm/cacao-gc/rootset.c (rootset_writeback): Use above function.
+       [f324661aa9c8]
+
+       * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/mark.c:
+       * src/mm/cacao-gc/compact.c (compact_thread_classes): Removed
+       obsolete function.
+       * src/mm/cacao-gc/mark.c (mark_classes): Likewise.
+       [70164b6b8eac]
+
+       * src/vm/jit/argument.c, src/vm/vm.c:
+       * src/vm/jit/argument.c: Added missing method comments.
+       (vm/exceptions.h): Removed include.
+       (argument_vmarray_from_objectarray): Do not throw exceptions, but
+       return NULL.
+
+       * src/vm/vm.c (vm_call_method_objectarray): Adapted to above changes
+       and fixed nativeworld sections.
+       [d7d6dadc37c5]
+
+2007-09-28  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/jit.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/jit/jit.c (TRACECOMPILERCALLS): New macro. (jit_compile):
+       Use TRACECOMPILERCALLS. (jit_compile_intern): Removed some
+       DEBUG_JIT_COMPILEVERBOSE.
+
+       * src/vmcore/options.c (opt_TraceCompilerCalls): New variable.
+       (options_xx): Handle opt_TraceCompilerCalls.
+       * src/vmcore/options.h (opt_TraceCompilerCalls): Added.
+       [0d92a96dd835]
+
+2007-09-27  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/s390/codegen.h:
+       * src/vm/jit/s390/codegen.h (N_BRANCH_MIN, N_BRANCH_MAX): Fix
+       (muliply by 2).
+       [b2999afc3d91]
+
+2007-09-27  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/argument.c, src/vm/vm.c:
+       * src/vm/jit/argument.c (argument_vmarray_store_adr): Fixed for
+       handles.
+       * src/vm/vm.c (vm_call_array): Likewise.
+       [ced954316377]
+
+       * src/native/jni.c, src/vm/vm.c, src/vm/vm.h:
+       * src/vm/vm.c (vm_call_array): Made static, removed compiler call.
+       (vm_call_method_objectarray): Added. (vm_call_method_valist): Added
+       nativeworld macros, added compiler call. (vm_call_method_jvalue):
+       Likewise.
+
+       * src/vm/vm.h (vm_call_array): Removed prototypes.
+       (vm_call_method_objectarray): Added prototype.
+
+       * src/native/jni.c (_Jv_jni_invokeNative): Moved parts to vm.c for
+       clearness.
+       [a39b92f53b6a]
+
+2007-09-27  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/code.c:
+       * src/vm/jit/code.c (code_get_methodinfo_for_pv): Return NULL if
+       code is NULL (asm_vm_call_method).
+       [351e6063c865]
+
+2007-09-27  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (vmcore/options.h): Fixed include.
+       [d1a28f42c379]
+
+2007-09-27  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/mm/memory.c, src/mm/memory.h:
+       * src/mm/memory.c (memory_mprotect): Fixed signature, manpage is
+       wrong about the signature of mprotect.
+       * src/mm/memory.h: Likewise.
+       [06d06747d56c]
+
+2007-09-27  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/native/jni.c, src/vm/jit/argument.c, src/vm/jit/argument.h,
+       src/vm/vm.c, src/vm/vm.h:
+       * src/vm/jit/argument.c (argument_vmarray_store_int),
+       (argument_vmarray_store_lng), (argument_vmarray_store_flt),
+       (argument_vmarray_store_dbl), (argument_vmarray_store_adr),
+       (argument_vmarray_from_valist), (argument_vmarray_from_jvalue),
+       (argument_vmarray_from_objectarray): Moved from vm.c to this file.
+
+       * src/vm/jit/argument.h (argument_vmarray_from_valist): Added
+       prototype. (argument_vmarray_from_jvalue): Likewise.
+       (argument_vmarray_from_objectarray): Likewise.
+
+       * src/vm/vm.c: See above!
+
+       * src/vm/vm.h (vm_array_from_objectarray): Removed prototype.
+
+       * src/native/jni.c (_Jv_jni_invokeNative): Adapted to above changes.
+       [cac920852cf7]
+
+2007-09-27  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vmcore/class.c, src/vmcore/class.h:
+       * src/vmcore/class.c (class_is_primitive, class_is_anonymousclass,
+       class_is_array, class_is_interface, class_is_localclass,
+       class_is_memberclass, class_get_classloader, class_get_superclass):
+       Moved to class.h and made them static inline.
+       * src/vmcore/class.h: Likewise.
+       [42bf0070c359]
+
+2007-09-27  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/threads/lock-common.h, src/toolbox/logging.c:
+       * src/threads/lock-common.h: Removed obsolete comment.
+       * src/toolbox/logging.c (threads/threads-common.h): Added include.
+       [efd01191b1ee]
+
+       * src/mm/gc-common.h, src/native/jni.c,
+       src/native/vm/gnu/java_lang_VMSystem.c, src/threads/native/lock.c,
+       src/vmcore/loader.c:
+       * src/mm/gc-common.h (heap_hashcode): Added inline function.
+
+       * src/native/jni.c: Use above function throughout file.
+       * src/native/vm/gnu/java_lang_VMSystem.c: Likewise.
+       * src/threads/native/lock.c: Likewise.
+       * src/vmcore/loader.c: Likewise.
+       [7e2d5fdf3012]
+
+2007-09-26  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/native/lock.c, src/vm/global.h:
+       * src/threads/native/lock.c: Renamed monitorPtr to lockword in the
+       whole file. (stdint.h): Added.
+
+       * src/vm/global.h (stdint.h): Added. (java_object_t): Renamed
+       monitorPtr to lockword and changed the type to uintptr_t.
+       [853865d3df15]
+
+2007-09-26  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/threads/native/threads.c, src/threads/threads-common.c:
+       * src/threads/native/threads.c (threads_init): Removed obsolete call
+       to register references with the GC.
+
+       * src/threads/threads-common.c (threads_thread_new): Also register
+       reference to exception object with the GC.
+       [019681a01270]
+
+       * src/threads/native/threads.c, src/threads/threads-common.c,
+       src/threads/threads-common.h, src/vm/vm.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/threads/native/threads.c: Improved debug output.
+       * src/threads/threads-common.c: Likewise.
+
+       * src/threads/threads-common.h (DEBUGTHREADS): Added.
+
+       * src/vm/vm.c (vm_create): Removed -verbose:threads option.
+
+       * src/vmcore/options.c (opt_DebugThreads): Added -XX:+DebugThreads
+       option.
+       * src/vmcore/options.h (opt_DebugThreads): Likewise.
+       [4ab0c57483a9]
+
+       * src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/native/threads.h (native/include/java_lang_Thread.h):
+       Removed. (threadobject): The object pointer is of type java_object_t
+       now.
+
+       * src/threads/native/threads.c: Adapted to above changes and use
+       LLNI macros.
+
+       * src/threads/threads-common.h (threads_thread_start): Changed
+       signature to not use java_lang_Thread anymore.
+
+       * src/threads/threads-common.c: Adapted to above changes and use
+       LLNI macros. (threads_preinit): Fixed corruption of
+       mainthread->flags.
+       [26e085a276e8]
+
+2007-09-25  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/alpha/md.c, src/vm/jit/i386/md.c, src/vm/jit/mips/md.c,
+       src/vm/jit/powerpc/md.c, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/replace.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/x86_64/md.c:
+       * src/vm/jit/alpha/md.c (md_patch_replacement_point): Removed debug
+       code.
+       * src/vm/jit/i386/md.c: Likewise.
+       * src/vm/jit/mips/md.c: Likewise.
+       * src/vm/jit/powerpc/md.c: Likewise.
+       * src/vm/jit/powerpc64/md.c: Likewise.
+       * src/vm/jit/sparc64/md.c: Likewise.
+       * src/vm/jit/x86_64/md.c: Likewise.
+
+       * src/vm/jit/replace.c (replace_activate_replacement_points)
+       [ENABLE_DISASSEMBLER]: Improved debug.
+       (replace_deactivate_replacement_points) [ENABLE_DISASSEMBLER]:
+       Likewise.
+       [778ca7b0994f]
+
+       * src/native/localref.c, src/native/localref.h, src/vm/jit/argument.c,
+       src/vm/jit/argument.h, src/vm/jit/codegen-common.c:
+       * src/native/localref.c [ENABLE_HANDLES] (localref_native_exit):
+       Implemented. (localref_native_enter): Renamed from localref_fill.
+
+       * src/native/localref.h (localref_native_exit): Added prototype.
+       (localref_native_enter): Renamed from localref_fill.
+
+       * src/vm/jit/argument.c (argument_jitreturn_store): Implemented.
+
+       * src/vm/jit/argument.h (argument_jitreturn_store): Added prototype.
+
+       * src/vm/jit/codegen-common.c (codegen_start_native_call): Improved
+       comments and adapted to above changes. (codegen_finish_native_call):
+       Likewise.
+       [cb9745650425]
+
+       * src/cacaoh/dummy.c:
+       * src/cacaoh/dummy.c (llni_critical_start, llni_critical_end):
+       Removed aborts.
+       [e73922f2480c]
+
+       * src/vm/signal.c:
+       * src/vm/signal.c (signal_handle): Wrap and unwrap references
+       correctly.
+       [a9c206e70c58]
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_find_replacement_point_for_pc):
+       Fixed assertion. (replace_me_wrapper): Simplified search for
+       replacement point.
+       [fd550f06fd83]
+
+       * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/jit/alpha/linux/md-os.c (md_replace_executionstate_write):
+       Fixed compiler warning.
+
+       * src/vm/jit/x86_64/linux/md-os.c (md_replace_executionstate_read):
+       Implemented. (md_replace_executionstate_write): Likewise.
+       [437c4ce74de8]
+
+       * src/vm/jit/i386/arch.h, src/vm/jit/x86_64/arch.h:
+       * src/vm/jit/i386/arch.h (REPLACEMENT_PATCH_SIZE): Adapted to new
+       trap mcode.
+       * src/vm/jit/x86_64/arch.h (REPLACEMENT_PATCH_SIZE): Likewise.
+       [cdd632019391]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/replace.c,
+       src/vm/jit/replace.h, src/vm/signal.c:
+       * src/vm/jit/codegen-common.c (codegen_set_replacement_point): Add
+       NOPs if replacement testing mode is enabled.
+
+       * src/vm/jit/replace.c (replace_me_wrapper): Finished
+       implementation. (replace_me): Major code cleanup. Removed safestack
+       stuff. (replace_build_execution_state): Likewise.
+       (replace_activate_replacement_points): Adapted changes from previous
+       rev. (replace_deactivate_replacement_points): Likewise.
+       (replace_alloc_safestack): Removed. (replace_free_safestack):
+       Removed.
+
+       * src/vm/jit/replace.h (replace_safestack_t): Removed.
+       (md_replace_executionstate_read): Added prototype.
+       (md_replace_executionstate_write): Likewise.
+
+       * src/vm/signal.c (signal_handle): Adapted to new
+       replace_me_wrapper.
+       [a97a8699e3f3]
+
+       * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/m68k/linux/md-os.c, src/vm/jit/mips/irix/md-os.c,
+       src/vm/jit/mips/linux/md-os.c, src/vm/jit/powerpc/darwin/md-os.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc64/linux/md-
+       os.c, src/vm/jit/s390/md.c, src/vm/jit/sparc64/linux/md-os.c,
+       src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/signal.c, src/vm/signallocal.h:
+       * src/vm/signallocal.h (signal_handle): Changed signature.
+
+       * src/vm/signal.c (signal_handles): Create stackframeinfo here.
+
+       * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv):
+       Adapted to new signature and removed stackframeinfo creation.
+
+       * src/vm/jit/arm/linux/md-os.c: Likewise.
+       * src/vm/jit/i386/darwin/md-os.c: Likewise.
+       * src/vm/jit/i386/linux/md-os.c: Likewise.
+       * src/vm/jit/m68k/linux/md-os.c: Likewise.
+       * src/vm/jit/mips/irix/md-os.c: Likewise.
+       * src/vm/jit/mips/linux/md-os.c: Likewise.
+       * src/vm/jit/powerpc/darwin/md-os.c: Likewise.
+       * src/vm/jit/powerpc/linux/md-os.c: Likewise.
+       * src/vm/jit/powerpc64/linux/md-os.c: Likewise.
+       * src/vm/jit/s390/md.c: Likewise.
+       * src/vm/jit/sparc64/linux/md-os.c: Likewise.
+       * src/vm/jit/sparc64/solaris/md-os.c: Likewise.
+       * src/vm/jit/x86_64/linux/md-os.c: Likewise.
+       [60c0ebbe4e43]
+
+2007-09-24  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/i386/asmpart.S, src/vm/jit/i386/cygwin/md-asm.h,
+       src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/darwin/md-asm.h,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/x86_64/asmpart.S:
+       * src/vm/jit/i386/asmpart.S (asm_replacement_in,
+       asm_replacement_out): Removed obsolete functions.
+
+       * src/vm/jit/i386/cygwin/md-asm.h: Likewise.
+       * src/vm/jit/i386/darwin/md-asm.h: Likewise.
+       * src/vm/jit/mips/asmpart.S: Likewise.
+       * src/vm/jit/powerpc/asmpart.S: Likewise.
+       * src/vm/jit/powerpc/darwin/md-asm.h: Likewise.
+       * src/vm/jit/powerpc64/asmpart.S: Likewise.
+       * src/vm/jit/s390/asmpart.S: Likewise.
+       * src/vm/jit/x86_64/asmpart.S: Likewise.
+       [b740aa39a6b3]
+
+       * src/vm/jit/i386/linux/md-os.c, src/vm/jit/m68k/emit.c:
+       * src/vm/jit/m68k/emit.c (emit_replacement_stubs): Removed obsolete
+       function.
+       * src/vm/jit/i386/linux/md-os.c: Reordered functions in file.
+       [ee8508729ad0]
+
+       * src/vm/jit/alpha/md.c, src/vm/jit/i386/md.c, src/vm/jit/mips/md.c,
+       src/vm/jit/powerpc/md.c, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/s390/md.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/x86_64/md.c:
+       * src/vm/jit/alpha/md.c (md_patch_replacement_point): Changed
+       signature.
+
+       * src/vm/jit/i386/md.c: Likewise.
+       * src/vm/jit/mips/md.c: Likewise.
+       * src/vm/jit/powerpc/md.c: Likewise.
+       * src/vm/jit/powerpc64/md.c: Likewise.
+       * src/vm/jit/s390/md.c: Likewise.
+       * src/vm/jit/sparc64/md.c: Likewise.
+       * src/vm/jit/x86_64/md.c: Likewise.
+       [8607a4e4bab5]
+
+       * src/vm/jit/jit.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_REPLACEMENT]:
+       Activate replacement points after code generation if testing option
+       is given.
+
+       * src/vmcore/options.c [ENABLE_REPLACEMENT] (opt_TestReplacement):
+       Added replacement testing option.
+
+       * src/vmcore/options.h [ENABLE_REPLACEMENT] (opt_TestReplacement):
+       Likewise.
+       [b4b8349d4df5]
+
+2007-09-23  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vmcore/statistics.c, src/vmcore/statistics.h:
+       * src/vmcore/statistics.c (size_stacksize): New variable.
+       (statistics_print_memory_usage): Print new variable.
+       * src/vmcore/statistics.h (size_stacksize): Added.
+       [9ffe8678ac20]
+
+       * src/mm/memory.c, src/mm/memory.h:
+       * src/mm/memory.c (memory_mprotect): New function.
+       * src/mm/memory.h: Likewise.
+       [9b7a3aee74a4]
+
+       * src/vm/signal.c:
+       * src/vm/signal.c (signal_handle): Fixed debug output.
+       [18e1db4a4dd2]
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_impl_thread_start): Print
+       error of return value (errno is not set by pthread functions).
+       [1735a75ea91f]
+
+       * src/threads/threads-common.c, src/vmcore/statistics.c,
+       src/vmcore/statistics.h:
+       * src/threads/threads-common.c (list_threads_free): Renamed to
+       list_free_thread_index. (thread_index_t): New type.
+       (threads_preinit): Initialize list_free_thread_index.
+       (threads_thread_new): Use list_free_thread_index
+       (threads_thread_free): Likewise and free the threadobject.
+
+       * src/vmcore/statistics.c (stdint.h): Added. (size_thread_index_t):
+       Likewise. (statistics_print_memory_usage): Print
+       size_thread_index_t.
+       * src/vmcore/statistics.h (stdint.h): Added. (size_thread_index_t):
+       Likewise.
+       [7938bddb23fe]
+
+2007-09-22  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/md-abi.c:
+       * src/vm/jit/codegen-common.c (codegen_start_native_call,
+       codegen_finish_native_call) [__S390__]: Adapted for s390.
+        * src/vm/jit/s390/codegen.c (codegen_emit_stub_native): Adapted for
+       builtin stubs.
+        * src/vm/jit/s390/md-abi.c (md_param_alloc_native): On stack arguments
+       are now already set off by the linkage area size.
+       [cdba3e10f470]
+
+       * src/vm/jit/s390/emit.c:
+       * src/vm/jit/s390/emit.c (emit_verbosecall_enter,
+       emit_verbosecall_exit): Adapted to modified trace_java_call_enter
+       and trace_jave_call_exit.
+       [b0b2a8ecfb7e]
+
+2007-09-21  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac, src/native/vm/sun/jvm.c:
+       * configure.ac (AC_CHECK_FUNCS): Added getsockopt.
+
+       * src/native/vm/sun/jvm.c (stdint.h): Added. (sys/types.h):
+       Likewise. (JVM_HoldsLock): Implemented. (JVM_SocketAvailable):
+       Likewise. (JVM_GetSockOpt): Likewise. (JVM_SetSockOpt)
+       [HAVE_SETSOCKOPT]: Added #ifdef.
+       [808f939f7d6c]
+
+       * src/vm/jit/alpha/codegen.c:
+       * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Save and
+       restore floats as float so the trace functions can print them
+       correctly.
+       [08f6e263bf88]
+
+       * src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.c (opt_DebugStackTrace): Changed type to int.
+       (options_xx): Forgot to handle opt_DebugStackTrace.
+       * src/vmcore/options.h (opt_DebugStackTrace): Changed type to int.
+       [c6701c057d02]
+
+2007-09-20  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vmcore/class.c:
+       * src/vmcore/class.c [!NDEBUG]
+       (class_classref_or_classinfo_println): Added missing #ifdef.
+       [0216ea4e581b]
+
+2007-09-19  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vmcore/loader.c, src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/vmcore/loader.c (loader_init): Don't use utf_java_lang_System.
+
+       * src/vmcore/utf8.c (utf_java_lang_System): Removed. (utf8_init):
+       Likewise.
+       * src/vmcore/utf8.h: Likewise.
+       [3c0f5dc5dd40]
+
+       * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/vm.c:
+       * src/vm/exceptions.c (exceptions_init): Changed return value to
+       void, removed class_java_lang_Throwable loading and linking.
+       (exceptions_throw_linkageerror): Removed unused variable o.
+
+       * src/vm/exceptions.h (exceptions_init): Changed return value to
+       void. (new_exception_utfmessage): Removed.
+
+       * src/vm/vm.c (vm_create): Don't check return value of
+       exceptions_init.
+       [c91eb1105dd8]
+
+       * src/cacaoh/dummy.c, src/vm/exceptions.c, src/vm/initialize.c,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c,
+       src/vmcore/loader.c, src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/cacaoh/dummy.c (vm_initializing): Added.
+
+       * src/vm/exceptions.c (exceptions_init): Removed all class loads and
+       links. (exceptions_abort): New function. (exceptions_new_class):
+       Removed. (exceptions_throw_class): Likewise.
+       (exceptions_new_class_utf): Likewise. (exceptions_throw_class_utf):
+       Likewise. (exceptions_throw_classnotfoundexception): Use
+       exceptions_throw_utf_utf. (exceptions_throw_noclassdeffounderror):
+       Likewise. (exceptions_throw_linkageerror): Likewise.
+       (exceptions_throw_nosuchmethoderror): Likewise.
+       (exceptions_throw_unsatisfiedlinkerror: Likewise.
+       (exceptions_new_classcastexception): Use exceptions_new_utf_utf.
+       (exceptions_throw_outofmemoryerror): Use exceptions_throw_utf.
+       (exceptions_throw_nullpointerexception): Likewise.
+       (exceptions_new_nullpointerexception): Use exceptions_new_utf.
+       (exceptions_classnotfoundexception_to_noclassdeffounderror): Load
+       java/lang/ClassNotFoundException explicitly.
+
+       * src/vm/initialize.c (initialize_class_intern): Load
+       java/lang/Exception explicitly.
+
+       * src/vmcore/class.c (class_java_lang_Error): Removed.
+       (class_java_lang_LinkageError): Likewise.
+       (class_java_lang_NoClassDefFoundError): Likewise.
+       (class_java_lang_OutOfMemoryError): Likewise.
+       (class_java_lang_VirtualMachineError): Likewise.
+       (class_java_lang_Exception): Likewise.
+       (class_java_lang_ClassCastException): Likewise.
+       (class_java_lang_ClassNotFoundException): Likewise.
+       * src/vmcore/class.h: Likewise.
+
+       * src/vmcore/linker.c (linker_init): Added class_java_lang_Throwable
+       and class_java_lang_VMThrowable.
+
+       * src/vmcore/loader.c (loader_preinit): Don't check for error on
+       load_class_bootstrap, this is now done in the exception functions.
+       (loader_init): Likewise. (load_class_bootstrap): Removed
+       utf_java_lang_Object check.
+
+       * src/vmcore/utf8.c (utf_java_lang_VMThrowable): Removed.
+       * src/vmcore/utf8.h: Likewise.
+       [f6e46b5abdac]
+
+       * src/vm/properties.c, src/vm/properties.h:
+       * src/vm/properties.c (properties_dump): New function.
+       * src/vm/properties.h: Likewise.
+       [3fe0447f57b7]
+
+2007-09-18  Mathias Panzenboeck  <panzi@complang.tuwien.ac.at>
+
+       * doc/Makefile.am, doc/annotations.tex, doc/jsr.bib:
+       * doc/Makefile.am (dist_noinst_DATA): Added annotations.tex and
+       jsr.bib (annotations): New target which creates annotations.dvi
+       (clean): Clean the annotations.aux/.bbl/.dvi/... files.
+
+       * doc/annotations.tex: New file. This is the documentation of the
+       annotations support implementation.
+
+       * doc/jsr.bib: New file. Contains bibtex reference for JSR202.
+       [cbc7fae03947]
+
+2007-09-18  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/cacaoh/cacaoh.c, src/vm/vm.c, src/vm/vm.h, src/vmcore/linker.c,
+       src/vmcore/options.c, src/vmcore/options.h:
+       * src/cacaoh/cacaoh.c (main): Removed linkverbose.
+
+       * src/vm/vm.c (vm_printconfig): Made static. (vm_create): Call
+       vm_printconfig after the VM is initialized.
+       * src/vm/vm.h (vm_printconfig): Removed.
+
+       * src/vmcore/linker.c (TRACELINKCLASS): New macro.
+       (link_class_intern): Use TRACELINKCLASS.
+
+       * src/vmcore/options.c (linkverbose): Removed. (opt_TraceLinkClass):
+       Added. (options_xx): OPT_PrintConfig: Don't call vm_printconfig,
+       OPT_TraceLinkClass: Added.
+       * src/vmcore/options.h (linkverbose): Removed. (opt_TraceLinkClass):
+       Added.
+       [b6b94c056c1d]
+
+       * src/vm/jit/patcher-common.c:
+       * src/vm/jit/patcher-common.c (patcher_handler) [!NDEBUG]: #ifdef'ed
+       debug output.
+       [c61a9af5c9b5]
+
+       * src/threads/native/lock.c:
+       * src/threads/native/lock.c (lock_record_notify): Ignore already
+       signaled threads.
+       [2c60bb7d3a11]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_GetClassAccessFlags): Use
+       TRACEJVMCALLS.
+       [6d11c71489c9]
+
+2007-09-17  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * configure.ac, src/native/vm/sun/jvm.c:
+       * configure.ac (AC_CHECK_FUNCS): Added fsync.
+       * src/native/vm/sun/jvm.c (JVM_Sync): Implemented.
+       [3bd273a402ef]
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (staticFieldOffset): Return 0.
+       (staticFieldBase): Return the pointer to value.
+       [0e6f95db8141]
+
+2007-09-16  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/sun/jvm.c, src/vmcore/class.c, src/vmcore/class.h:
+       * src/native/vm/gnu/java_lang_VMClass.c (getModifiers): Use
+       class_get_modifiers.
+       * src/native/vm/sun/jvm.c (JVM_GetClassModifiers): Likewise.
+
+       * src/native/vm/java_lang_Class.c (class_get_modifiers): Removed.
+       * src/native/vm/java_lang_Class.h: Likewise.
+
+       * src/vmcore/class.c (class_get_modifiers): New function.
+       * src/vmcore/class.h: Likewise.
+       [3438316160b3]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_GetStackAccessControlContext): Use
+       TRACEJVMCALLS. (JVM_AssertionStatusDirectives): Likewise.
+       [3fcf29d58b0f]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_IsThreadAlive): Use LLNI_equals.
+       [86b85d556a58]
+
+       * * Merged with 5a268f292149.
+       [07d1c81692ee]
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_NewWeakGlobalRef): Use TRACEJNICALLS.
+       (_Jv_JNI_DeleteWeakGlobalRef): Likewise.
+       [741ac9cf4529]
+
+2007-09-16  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * src/native/llni.h:
+       * src/native/llni.h (LLNI_equals): Added macro.
+       [5a268f292149]
+
+2007-09-16  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/cacaoh/dummy.c, src/native/vm/sun/jvm.c, src/vm/Makefile.am,
+       src/vm/package.c, src/vm/package.h, src/vm/vm.c,
+       src/vmcore/loader.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/cacaoh/dummy.c (package_add): New function.
+
+       * src/native/vm/sun/jvm.c (vm/package.h): Added.
+       (JVM_GetSystemPackage): Implemented.
+
+       * src/vm/Makefile.am (libvm_la_SOURCES): Added package.[ch].
+
+       * src/vm/package.c: New file.
+       * src/vm/package.h: Likewise.
+
+       * src/vm/vm.c (vm/package.h): Added. (vm_create): Call package_init.
+
+       * src/vmcore/loader.c (vm/package.h): Added. (load_class_bootstrap):
+       Call package_add.
+
+       * src/vmcore/options.c (opt_DebugPackage): Added. (options_xx):
+       Likewise.
+       * src/vmcore/options.h (opt_DebugPackage): Added.
+       [e91bea6d1b62]
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_detach_thread): Notify all
+       threads waiting on the Java thread-object.
+       [db035cf768f7]
+
+       * src/mm/nogc.c:
+       * src/mm/nogc.c [HAVE_SYS_MMAN_H] (sys/mman.h): Added #ifdef.
+       (heap_alloc_uncollectable): Added additional parameter for
+       heap_alloc. (gc_init) [HAVE_MMAP]: Added #ifdef.
+       [231910498e40]
+
+2007-09-15  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vmcore/class.c:
+       * src/vmcore/class.c (class_set_packagename): Added '/' to the
+       internal package name.
+       [44ff14c3e9a6]
+
+       * src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h,
+       src/native/vm/sun/jvm.c:
+       * src/native/vm/java_lang_Thread.c (isAlive): Removed.
+       * src/native/vm/java_lang_Thread.h: Likewise.
+
+       * src/native/vm/cldc1.1/java_lang_Thread.c (stdint.h): Added.
+       (isAlive): Use threads_thread_is_alive.
+
+       * src/native/vm/sun/jvm.c (JVM_IsThreadAlive): Likewise.
+       [bc11be8a1e7c]
+
+2007-09-14  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_array_from_objectarray): TYPE_LNG: Added missing
+       primitive_type_get_by_wrapperclass to get type (fixes JBoss).
+       [395643eaf5e9]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_array_from_objectarray): Removed illegal_arg label
+       and throw exception directly. This makes it easier for debugging
+       and newer compilers can optimize that.
+       [2b62829628e6]
+
+       * src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/threads-common.c (threads_thread_state_runnable):
+       Don't change the state if the current state is
+       THREAD_STATE_TERMINATED. (threads_thread_state_waiting): Likewise.
+       (threads_thread_state_timed_waiting): Likewise.
+       (threads_thread_is_alive): Smaller changes.
+       * src/threads/threads-common.h (threads_thread_is_alive): Likewise.
+       [1307fac97706]
+
+       * src/threads/native/lock.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/threads/native/lock.c (LOCK_LOG): Removed. (DEBUGLOCKS): New
+       macro. (lock_record_new): Added DEBUGLOCKS. (lock_record_free):
+       Likewise. (lock_hashtable_grow): Likewise. (lock_hashtable_get):
+       Likewise. (lock_inflate): Likewise. (lock_monitor_enter): Likewise.
+       (lock_monitor_exit): Likewise. (lock_record_wait): Likewise.
+       (lock_record_notify): Likewise.
+
+       * src/vmcore/options.c (opt_DebugLocks): Added. (options_xx):
+       Likewise.
+       * src/vmcore/options.h (opt_DebugLocks): Added.
+       [ab953b0c5ac1]
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (getShort): New function.
+       (putLong): Likewise. (getDouble): Likewise. (putDouble): Likewise.
+       [d4deff26f6d1]
+
+       * src/threads/native/lock.c, src/threads/native/lock.h:
+       * src/threads/native/lock.c (toolbox/list.h): Added.
+       (lock_record_t): Create waiters list. (lock_record_free): Free
+       waiters list. (lock_record_add_waiter): Use list.
+       (lock_record_remove_waiter): Likewise. (lock_record_notify):
+       Likewise.
+
+       * src/threads/native/lock.h (toolbox/list.h): Added.
+       (lock_waiter_t): Removed next, added linkage. (lock_record_t):
+       Changed waiters to a list_t.
+       [ff6d5c593e7f]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c [WITH_CLASSPATH_SUN]
+       (native/include/java_lang_Object.h,
+       native/include/java_lang_String.h,
+       native/include/java_nio_ByteBuffer.h,
+       native/include/java_lang_ClassLoader.h): Added.
+       [d04eadb70c7f]
+
+2007-09-14  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * src/vmcore/annotation.c:
+       * src/vmcore/annotation.c: Fixed comment.
+       [3bc1be6d9164]
+
+2007-09-14  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_wait_with_timeout): Renamed
+       thread to t.
+       [00f8940164ee]
+
+2007-09-13  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/toolbox/list.c, src/toolbox/list.h:
+       * src/toolbox/list.c (list_free): New function. (list_lock):
+       Likewise. (list_unlock): Likewise.
+       * src/toolbox/list.h: Likewise.
+       [70f5642b3e83]
+
+       * src/vm/exceptions.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/exceptions.c (exceptions_get_exception): Simplyfied.
+       (exceptions_set_exception): Added debug output.
+       (exceptions_clear_exception): Use explicit implementation and added
+       debug output. (exceptions_get_and_clear_exception): Only clear when
+       an exception is set.
+
+       * src/vmcore/options.c (opt_DebugExceptions): Added. (options_xx):
+       Likewise.
+       * src/vmcore/options.h: Likewise.
+       [8456a18d18be]
+
+2007-09-13  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/threads/native/lock.c:
+       * src/threads/native/lock.c (lock_record_wait): No longer throws and
+       exception but returns a boolean value indicating the interruption.
+       (lock_monitor_enter): Ignore interruption of lock_record_wait.
+       (lock_monitor_wait): Throw an exception if interrupted.
+       [3433056d2e6e]
+
+2007-09-13  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/cacaoh/headers.h, src/threads/native/threads.h,
+       src/threads/none/threads.h, src/vm/exceptions.c,
+       src/vm/jit/inline/inline.c:
+       * src/cacaoh/headers.h (_exceptionptr): Removed.
+
+       * src/threads/native/threads.h (exceptionptr): Removed.
+       * src/threads/none/threads.h: Likewise.
+
+       * src/vm/exceptions.c (exceptions_get_exception): Rewritten to use
+       threadobject directly. (exceptions_set_exception): Likewise.
+
+       * src/vm/jit/inline/inline.c (inline_transform)
+       [INLINE_VERIFY_RESULT]: Use exceptions_clear_exception.
+       [3bd4728a8c59]
+
+2007-09-13  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/arm/asmpart.S:
+       * src/vm/jit/arm/asmpart.S (asm_exceptionptr): Removed.
+       [f6cbcaf2f4fc]
+
+2007-09-13  tbfg  <tbfg@localhost.localdomain>
+
+       * src/vm/jit/powerpc64/asmpart.S:
+       Removed misleading comment about copying stuff from linux kernel.
+       This was true, but the implementation has been removed and the ppc
+       solution was adapted for pp64.
+       [5f48da04a418]
+
+2007-09-13  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/show.c, src/vm/vm.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/vm/vm.c (vm_create): Removed obsolete -se option.
+       * src/vm/jit/show.c (show_method): No longer show exception stubs.
+       * src/vmcore/options.c (opt_showexceptionstubs): Removed.
+       * src/vmcore/options.h (opt_showexceptionstubs): Likewise.
+       [76dad440809f]
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h:
+       * src/vm/jit/arm/codegen.h: Major code cleanup and support VFP
+       instructions.
+       * src/vm/jit/arm/codegen.c: Adapted to above changes.
+       [979eaad7469b]
+
+       * src/native/vm/sun/jvm.c, src/vm/jit/s390/codegen.c, src/vm/vm.c,
+       src/vmcore/options.c, src/vmcore/options.h:
+       * Merged with michi branch at rev 21fd42e049a3.
+       [4d32767b4c1d]
+
+       * src/vm/builtintable.inc:
+       * src/vm/builtintable.inc (builtintable_internal): Create builtin
+       stubs for LOCK_monitor_enter and LOCK_monitor_exit, because they
+       throw exceptions. This will slow down Cacao, we need the fast-path
+       or inline those builtins!
+       [21fd42e049a3]
+
+       * src/vm/jit/arm/asmpart.S:
+       * src/vm/jit/arm/asmpart.S (asm_cacheflush): Code cleanup and
+       support for EABI syscall calling conventions.
+       [4933a3684852]
+
+2007-09-12  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/s390/codegen.c:
+       * src/vm/jit/s390/codegen.c (codegen_emit_stub_native): Replaced N_*
+       code generation macros by alpha-like M_* ones.
+       [5a4e35cb3ab5]
+
+2007-09-12  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * src/vmcore/annotation.c:
+       * src/vmcore/annotation.c (LLNI_objectarray_copy): Removed macro.
+       (annotation_bytearrays_resize): Use MCOPY instead of my own macro.
+       [86a989abbdea]
+
+2007-09-12  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390
+       /md-abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/md.c:
+       * src/vm/jit/s390/asmpart.S src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390
+       /md-abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/md.c: Changed
+       JIT ABI on s390: R0 is now REG_ITMP3, R12 is a saved register,
+       REG_ITMPs are reordered, REG_ITMP1_XPTR is now REG_ITMP3_XPTR,
+       REG_ITMP2_XPC is now REG_ITMP1_XPC.
+       [75ecbbddead3]
+
+2007-09-12  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * src/native/llni.h, src/vmcore/annotation.c, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/field.c, src/vmcore/method.c:
+       * src/native/llni.h (LLNI_classinfo_field_get): New macro.
+       (LLNI_classinfo_field_set): Likewise.
+
+       * src/vmcore/annotation.c (LLNI_objectarray_copy): New macro. This
+       macro will be replaced by a appropriate array_* function once such a
+       function exists. (annotation_bytearrays_resize): Use above macro and
+       improved variable naming. (annotation_bytearrays_insert): Changed
+       type of parameter 1 and return type and improved variable naming.
+       (annotation_load_attribute_body): Use LLNI_CRITICAL_START and
+       LLNI_CRITICAL_END.
+       (annotation_load_method_attribute_annotationdefault): Use
+       LLNI_classinfo_field_get and LLNI_classinfo_field_set macros. (annot
+       ation_load_method_attribute_runtimevisibleparameterannotations):
+       Likewise.
+       (annotation_load_method_attribute_runtimevisibleannotations):
+       Likewise.
+       (annotation_load_field_attribute_runtimevisibleannotations):
+       Likewise.
+       (annotation_load_class_attribute_runtimevisibleannotations): Use
+       LLNI_classinfo_field_set macro.
+
+       * src/vmcore/class.c (class_get_annotations): Use
+       LLNI_classinfo_field_get macro.
+
+       * src/vmcore/class.h (classinfo.annotations),
+       (classinfo.method_annotations),
+       (classinfo.method_parameterannotations),
+       (classinfo.method_annotationdefaults),
+       (classinfo.field_annotations): Changed type to java_object_t*.
+
+       * src/vmcore/field.c (native/llni.h): Added include.
+       (field_get_annotations): Use LLNI_classinfo_field_get macro.
+
+       * src/vmcore/method.c (method_get_annotations): Use
+       LLNI_classinfo_field_get macro. (method_get_parameterannotations):
+       Likewise. (method_get_annotationdefault): Likewise.
+       [b49f32206108]
+
+2007-09-12  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/jni.c, src/native/jni.h, src/native/vm/sun/jvm.c,
+       src/vm/vm.c:
+       * src/native/jni.c (jni_version_check): New function.
+       * src/native/jni.h: Likewise.
+
+       * src/native/vm/sun/jvm.c (JVM_IsSupportedJNIVersion): Use
+       jni_version_check.
+       * src/vm/vm.c (vm_create): Likewise.
+       [6b9b172f7f02]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_create): Initialize properties list before
+       handling
+       -XX options handling.
+       [066d4ccbfde9]
+
+       * src/vm/properties.c, src/vm/vm.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/vm/properties.c (properties_add) [!NDEBUG]: Added debug
+       output.
+
+       * src/vm/vm.c (opts): Removed XX. (vm_create): Call options_xx
+       almost as first function, so we can enable debugging from all stuff.
+
+       * src/vmcore/options.c (opt_DebugProperties): New option.
+       (options_xx): Changed signature and parse all options in the array.
+       * src/vmcore/options.h (opt_DebugProperties): Added. (options_xx):
+       Changed signature.
+       [313f2b9ea69f]
+
+2007-09-12  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/threads/native/threads.c, src/vm/jit/mips/codegen.c:
+       * src/threads/native/threads.c: Renamed bogus __MIPS__ ifdefs to
+       __IRIX__.
+
+       * src/vm/jit/mips/codegen.c (codegen_emit): Fixed ICMD_BUILTIN stub
+       calling. (codegen_emit_stub_native): Adapted to new signature and
+       builtin stubs.
+       [3e3a6881ae1e]
+
+2007-09-12  Peter Molnar  <pm@complang.tuwien.ac.at>
+
+       * Merged 7484:52fc709fd248.
+       [ab50703b66af]
+
+       * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390
+       /md-asm.h:
+       * src/vm/jit/s390/codegen.c (codegen_emit_stub_native): Changed some
+       N_MOV to M_MOV.
+       * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md-asm.h, src/vm/jit/s390
+       /md-abi.h, src/vm/jit/s390/md-abi.c: Reverted [7237:9a2ce00b716e]
+       where f4 and f6 were made callee saved.
+       [2842827952fd]
+
+2007-09-12  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/patcher-common.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/vm/jit/patcher-common.c: Improved comments. (patcher_handler):
+       Enabled use of -XX:+DebugPatcher.
+
+       * src/vmcore/options.c (opt_DebugPatcher): Added and set by above
+       debug flag.
+       * src/vmcore/options.h (opt_DebugPatcher): Added.
+       [52fc709fd248]
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, src/vm/jit
+       /codegen-common.c:
+       * src/vm/jit/alpha/codegen.c (codegen_emit_stub_builtin): Removed.
+       (codegen_emit_stub_native): Adapted to new signature and builtins.
+
+       * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Adapted to
+       new signature.
+
+       * src/vm/jit/alpha/codegen.c (codegen_start_native_call)
+       [__ALPHA__]: Call tracing is done from here now.
+       (codegen_finish_native_call) [__ALPHA__]: Likewise.
+       [75ee30764b92]
+
+2007-09-12  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/java_util_concurrent_atomic_AtomicLong.h,
+       src/native/vm/sun/jvm.c:
+       * src/native/vm/Makefile.am
+       (JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES): Removed.
+       (libnativevm_la_SOURCES): Removed
+       JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES.
+
+       * src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c
+       (native/vm/java_util_concurrent_atomic_AtomicLong.h): Removed.
+       (native/include/java_util_concurrent_atomic_AtomicLong.h): Added.
+       (methods): VMSupportsCS8: Use
+       Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8.
+       (Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8): New
+       function.
+
+       * src/native/vm/sun/jvm.c
+       (native/vm/java_util_concurrent_atomic_AtomicLong.h): Removed.
+       (JVM_SupportsCX8): Just return 0 for now.
+
+       * src/native/vm/java_util_concurrent_atomic_AtomicLong.c: Removed.
+       * src/native/vm/java_util_concurrent_atomic_AtomicLong.h: Likewise.
+       [063194d7fa99]
+
+       * src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h:
+       * src/native/vm/cldc1.1/java_lang_Class.c (methods): isInterface:
+       Use Java_java_lang_Class_isInterface. (isInterface): New function.
+
+       * src/native/vm/gnu/java_lang_VMClass.c (vm/exceptions.h): Added.
+       (vm/stringlocal.h): Likewise. (isInterface): Use class_is_interface.
+       (getInterfaces): Use class_get_interfaces. (getDeclaredClasses): Use
+       class_get_declaredclasses. (throwException): Use
+       exceptions_set_exception. (getClassSignature): Implemented directly.
+
+       * src/native/vm/java_lang_Class.c (isInterface): Removed.
+       (getInterfaces): Likewise. (getDeclaredClasses): Likewise.
+       (throwException): Likewise. (getClassSignature): Likewise.
+       * src/native/vm/java_lang_Class.h: Likewise.
+       [7b4ace71939e]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_GetClassSignature): Use
+       LLNI_classinfo_unwrap and java_handle_t.
+       [e95f6b9676ca]
+
+2007-09-12  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * src/native/vm/java_lang_Class.c:
+       * Merged with default branch at rev 8806c9bebf3e.
+       [f30b107daf01]
+
+       * src/lib/gnu/java/lang/reflect/Constructor.java,
+       src/lib/gnu/java/lang/reflect/Field.java,
+       src/lib/gnu/java/lang/reflect/Method.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationType.java,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/reflect.c,
+       src/native/vm/sun/jvm.c, src/vmcore/annotation.c,
+       src/vmcore/class.c, src/vmcore/field.c, src/vmcore/method.c,
+       src/vmcore/utf8.c, tests/regression/MinimalClassReflection.java:
+       * src/vmcore/annotation.c: Improved comments.
+       (annotation_bytearrays_resize), (annotation_bytearrays_insert),
+       (annotation_load_method_attribute_annotationdefault), (annotation_lo
+       ad_method_attribute_runtimevisibleparameterannotations),
+       (annotation_load_class_attribute_runtimevisibleannotations),
+       (annotation_load_method_attribute_runtimevisibleannotations),
+       (annotation_load_field_attribute_runtimevisibleannotations):
+       Restructured so that when it comes to the point when I have to use
+       LLNI macros for accessing the java objects I store in classinfo I
+       will have not much to do.
+
+       * src/lib/gnu/java/lang/reflect/Constructor.java: Improved comments.
+       * src/lib/gnu/java/lang/reflect/Field.java: Likewise.
+       * src/lib/gnu/java/lang/reflect/Method.java: Likewise.
+       * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java: Likewise.
+       * src/lib/gnu/sun/reflect/annotation/AnnotationType.java: Likewise.
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise.
+       * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise.
+       * src/native/vm/gnu/java_lang_reflect_Method.c: Likewise.
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c: Likewise.
+       * src/native/vm/java_lang_Class.c: Likewise.
+       * src/native/vm/reflect.c: Likewise.
+       * src/native/vm/sun/jvm.c: Likewise.
+       * src/vmcore/class.c: Likewise.
+       * src/vmcore/field.c: Likewise.
+       * src/vmcore/method.c: Likewise.
+       * src/vmcore/utf8.c: Likewise.
+       * tests/regression/MinimalClassReflection.java: Likewise.
+       [ddc0f25c5fad]
+
+2007-09-11  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h:
+       * src/native/vm/gnu/java_lang_VMClass.c (getSuperclass): Use
+       class_get_superclass.
+       * src/native/vm/java_lang_Class.c (getSuperclass): Removed.
+       * src/native/vm/java_lang_Class.h: Likewise.
+       [8806c9bebf3e]
+
+       * src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h:
+       * src/native/vm/gnu/java_lang_VMClass.c (isPrimitive): Use
+       class_is_primitive.
+       * src/native/vm/java_lang_Class.c (isPrimitive): Removed.
+       * src/native/vm/java_lang_Class.h: Likewise.
+       [11d19ca12473]
+
+2007-09-11  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c,
+       src/vm/properties.c:
+       * src/vm/properties.c (properties_set) [WITH_JRE_LAYOUT]: Fixed old
+       variable.
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c
+       (Java_gnu_classpath_VMSystemProperties_postInit) [WITH_JRE_LAYOUT]:
+       Likewise.
+       [bbd10f4c3e87]
+
+       * src/vm/jit/arm/patcher.c, src/vm/jit/mips/codegen.c:
+       * Merged with default branch at rev bac772081960.
+       [26f4007804bb]
+
+       * src/vm/jit/arm/disass.c, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/disass.h:
+       * src/vm/jit/disass.h (global.h): Added.
+
+       * src/vm/jit/arm/disass.c (disass_pseudo_instr): Implemented.
+       (disassinstr): Call above function.
+
+       * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill): Better
+       debug output.
+       [c41a6282ec30]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c:
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler):
+       Stubs are generated for all archs now. [__POWERPC64__]: Enabled
+       tracing of native and builtin stubs.
+
+       * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_native): Adapted
+       to new signature.
+
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native):
+       Likewise. Removed tracing code. Rewrote argument register saving and
+       restoring code.
+       [808d21867a99]
+
+2007-09-11  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/mips/codegen.c:
+       * src/vm/jit/mips/codegen.c (codegen_emit_stub_native): Fixed offset
+       of result saving and restoring (hint: MIPS32 has a PA).
+       [bac772081960]
+
+2007-09-11  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/sparc64/codegen.c:
+       * src/vm/jit/alpha/codegen.c (codegen_emit): ICMD_BUILTIN no longer
+       checks for exceptions, this is done by the stub itself. Stubs are
+       called now.
+
+       * src/vm/jit/m68k/codegen.c: Likewise.
+       * src/vm/jit/mips/codegen.c: Likewise.
+       * src/vm/jit/powerpc64/codegen.c: Likewise.
+       * src/vm/jit/s390/codegen.c: Likewise.
+       * src/vm/jit/sparc64/codegen.c: Likewise.
+       [cc75afc2b563]
+
+2007-09-11  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h,
+       src/vm/jit/i386/codegen.c, src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): Set
+       skipparams and pass it to codegen_emit_stub_native.
+       (codegen_generate_stub_native): Likewise.
+       * src/vm/jit/codegen-common.h (codegen_emit_stub_native): Changed
+       signature.
+
+       * src/vm/jit/i386/codegen.c (codegen_emit): ICMD_BUILTIN: Removed
+       emit_exception_check. (codegen_emit_stub_builtin): Removed.
+       (codegen_emit_stub_native): Changed signature.
+       * src/vm/jit/x86_64/codegen.c: Likewise.
+       [001bda7ec5c8]
+
+2007-09-08  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/x86_64/patcher.c:
+       * src/vm/jit/x86_64/patcher.c (patcher_resolve_native_function):
+       Removed.
+       [fc26f752bd43]
+
+       * src/vm/jit/patcher-common.h, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/signal.c, src/vm/signallocal.h:
+       * src/vm/jit/patcher-common.h: Added __X86_64__ ifdef.
+       * src/vm/signal.c (signal_init): Likewise.
+       * src/vm/signallocal.h: Likewise.
+
+       * src/vm/jit/x86_64/asmpart.S (asm_patcher_wrapper): Removed.
+
+       * src/vm/jit/x86_64/codegen.c (vm/jit/patcher.h): Removed. (vm/jit
+       /patcher-common.h): Added. (codegen_emit): Implemented patchers-by-
+       signal and load data from data segment instead of moving inline.
+       (codegen_emit_stub_native): Likewise. (codegen_emit_stub_compiler):
+       Quick hack for ALD.
+
+       * src/vm/jit/x86_64/codegen.h (PATCHER_CALL_SIZE): Changed to 2.
+       (PATCHER_NOPS): Likewise. (M_ALD): Handle RIP properly.
+
+       * src/vm/jit/x86_64/emit.c (vm/jit/patcher-common.h): Added.
+       (emit_patcher_stubs): Removed. (emit_trap): Emit UD2.
+
+       * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigill): New
+       function.
+
+       * src/vm/jit/x86_64/patcher.c (vm/jit/patcher.h): Removed. (vm/jit
+       /patcher-common.h): Added. (patcher_wrapper): Removed.
+       (PATCH_BACK_ORIGINAL_MCODE): New macro. (patcher_patch_code): New
+       function. (patcher_resolve_classref_to_classinfo): Likewise.
+       (patcher_resolve_classref_to_vftbl): Likewise.
+       (patcher_resolve_classref_to_flags): Likewise.
+       (patcher_resolve_native_function): Likewise. (patcher_aconst):
+       Removed. (patcher_builtin_multianewarray): Likewise.
+       (patcher_builtin_arraycheckcast): Likewise.
+       (patcher_checkcast_instanceof_flags): Likewise.
+       (patcher_checkcast_class): Likewise. (patcher_instanceof_class):
+       Likewise. (patcher_clinit): Likewise. (patcher_athrow_areturn):
+       Likewise. (patcher_resolve_native): Likewise.
+       [1aca46b07127]
+
+       * src/vm/jit/patcher-common.c:
+       * src/vm/jit/patcher-common.c (patcher_add_patch_ref): Added
+       lastmcodeptr code. This can be removed when we don't use UD2 on i386
+       and x86_64 anymore.
+       [3adba9571bcd]
+
+2007-09-08  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/patcher-common.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/patcher.c:
+       * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Loads
+       function pointer from data segment now.
+
+       * src/vm/jit/patcher-common.c (patcher_resolve_native_function):
+       Implemented generalized version.
+
+       * src/vm/jit/alpha/patcher.c (patcher_resolve_native_function):
+       Removed obsolete function.
+
+       * src/vm/jit/arm/patcher.c: Likewise.
+       * src/vm/jit/i386/patcher.c: Likewise.
+       * src/vm/jit/mips/patcher.c: Likewise.
+       * src/vm/jit/powerpc/patcher.c: Likewise.
+       * src/vm/jit/powerpc64/patcher.c: Likewise.
+       * src/vm/jit/s390/patcher.c: Likewise.
+       [18dcc80c8e9e]
+
+       * src/vm/jit/alpha/md.c, src/vm/jit/arm/md.c:
+       * src/vm/jit/alpha/md.c (md_dcacheflush): Added dummy function.
+       * src/vm/jit/arm/md.c (md_dcacheflush): Does nothing now.
+       [4fff503b29e5]
+
+2007-09-07  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/i386/patcher.c, src/vm/jit/mips/patcher.c, src/vm/jit
+       /patcher-common.c, src/vm/jit/patcher-common.h,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/patcher.c:
+       * src/vm/jit/patcher-common.h (patcher_patch_code): Added prototype.
+
+       * src/vm/jit/patcher-common.c (patcher_handle) [TRACE_PATCHER]:
+       Improved debug. (patcher_initialize_class): Implemented generalized
+       version. (patcher_resolve_class): Likewise.
+
+       * src/vm/jit/alpha/patcher.c (patcher_patch_code): Implemented.
+       (patcher_initialize_class): Removed obsolete patcher function.
+       (patcher_resolve_class): Likewise.
+
+       * src/vm/jit/arm/patcher.c: Likewise.
+       * src/vm/jit/i386/patcher.c: Likewise.
+       * src/vm/jit/mips/patcher.c: Likewise.
+       * src/vm/jit/powerpc/patcher.c: Likewise.
+       * src/vm/jit/powerpc64/patcher.c: Likewise.
+       * src/vm/jit/s390/patcher.c: Likewise.
+       [876be29c51a6]
+
+2007-09-08  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c:
+       * src/vm/jit/arm/codegen.c: Removed patcher NOPs creation, this is
+       done by the patcher_add_patch_ref function itself.
+
+       * src/vm/jit/arm/patcher.c: Patcher NOPs are triggered by the
+       opt_shownops flag.
+       [2855f422cb84]
+
+       * src/vm/jit/arm/codegen.c:
+       * src/vm/jit/arm/codegen.c (codegen_emit_stub_builtin): Removed.
+       (codegen_emit_stub_native): Deals with builtin stubs as well now.
+       [5914becb88b2]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h,
+       src/vm/vm.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/jit/codegen-common.c (codegen_disassemble_stub): Renamed
+       and works with builtin stubs as well.
+       (codegen_generate_stub_builtin) [ENABLE_DISASSEMBLER]: Stub gets
+       disassembled. (codegen_generate_stub_native) [ENABLE_DISASSEMBLER]:
+       Likewise.
+
+       * src/vm/jit/codegen-common.h (codegen_disassemble_stub): Renamed.
+
+       * src/vm/vm.c: Removed old option flag opt_shownativestub.
+
+       * src/vmcore/options.h [ENABLE_DISASSEMBLER] (opt_DisassembleStubs):
+       Added.
+
+       * src/vmcore/options.c [ENABLE_DISASSEMBLER] (opt_DisassembleStubs):
+       Added and included into options list.
+       [cc83f2f16624]
+
+2007-09-08  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/x86_64/patcher.c:
+       * src/vm/jit/x86_64/patcher.c (patcher_resolve_native_function):
+       Removed.
+       [bbee0a3c3f34]
+
+       * src/vm/jit/patcher-common.h, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/signal.c, src/vm/signallocal.h:
+       * src/vm/jit/patcher-common.h: Added __X86_64__ ifdef.
+       * src/vm/signal.c (signal_init): Likewise.
+       * src/vm/signallocal.h: Likewise.
+
+       * src/vm/jit/x86_64/asmpart.S (asm_patcher_wrapper): Removed.
+
+       * src/vm/jit/x86_64/codegen.c (vm/jit/patcher.h): Removed. (vm/jit
+       /patcher-common.h): Added. (codegen_emit): Implemented patchers-by-
+       signal and load data from data segment instead of moving inline.
+       (codegen_emit_stub_native): Likewise. (codegen_emit_stub_compiler):
+       Quick hack for ALD.
+
+       * src/vm/jit/x86_64/codegen.h (PATCHER_CALL_SIZE): Changed to 2.
+       (PATCHER_NOPS): Likewise. (M_ALD): Handle RIP properly.
+
+       * src/vm/jit/x86_64/emit.c (vm/jit/patcher-common.h): Added.
+       (emit_patcher_stubs): Removed. (emit_trap): Emit UD2.
+
+       * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigill): New
+       function.
+
+       * src/vm/jit/x86_64/patcher.c (vm/jit/patcher.h): Removed. (vm/jit
+       /patcher-common.h): Added. (patcher_wrapper): Removed.
+       (PATCH_BACK_ORIGINAL_MCODE): New macro. (patcher_patch_code): New
+       function. (patcher_resolve_classref_to_classinfo): Likewise.
+       (patcher_resolve_classref_to_vftbl): Likewise.
+       (patcher_resolve_classref_to_flags): Likewise.
+       (patcher_resolve_native_function): Likewise. (patcher_aconst):
+       Removed. (patcher_builtin_multianewarray): Likewise.
+       (patcher_builtin_arraycheckcast): Likewise.
+       (patcher_checkcast_instanceof_flags): Likewise.
+       (patcher_checkcast_class): Likewise. (patcher_instanceof_class):
+       Likewise. (patcher_clinit): Likewise. (patcher_athrow_areturn):
+       Likewise. (patcher_resolve_native): Likewise.
+       [0d8acddb33d2]
+
+       * src/vm/jit/patcher-common.c:
+       * src/vm/jit/patcher-common.c (patcher_add_patch_ref): Added
+       lastmcodeptr code. This can be removed when we don't use UD2 on i386
+       and x86_64 anymore.
+       [5f39dedf7b68]
+
+2007-09-08  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/patcher-common.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/patcher.c:
+       * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Loads
+       function pointer from data segment now.
+
+       * src/vm/jit/patcher-common.c (patcher_resolve_native_function):
+       Implemented generalized version.
+
+       * src/vm/jit/alpha/patcher.c (patcher_resolve_native_function):
+       Removed obsolete function.
+
+       * src/vm/jit/arm/patcher.c: Likewise.
+       * src/vm/jit/i386/patcher.c: Likewise.
+       * src/vm/jit/mips/patcher.c: Likewise.
+       * src/vm/jit/powerpc/patcher.c: Likewise.
+       * src/vm/jit/powerpc64/patcher.c: Likewise.
+       * src/vm/jit/s390/patcher.c: Likewise.
+       [8586d2a077ef]
+
+       * src/vm/jit/alpha/md.c, src/vm/jit/arm/md.c:
+       * src/vm/jit/alpha/md.c (md_dcacheflush): Added dummy function.
+       * src/vm/jit/arm/md.c (md_dcacheflush): Does nothing now.
+       [8b25e9581736]
+
+       * * Merged with default branch at rev ce451bbfaf18.
+       [a001beae1804]
+
+2007-09-07  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/i386/patcher.c, src/vm/jit/mips/patcher.c, src/vm/jit
+       /patcher-common.c, src/vm/jit/patcher-common.h,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/patcher.c:
+       * src/vm/jit/patcher-common.h (patcher_patch_code): Added prototype.
+
+       * src/vm/jit/patcher-common.c (patcher_handle) [TRACE_PATCHER]:
+       Improved debug. (patcher_initialize_class): Implemented generalized
+       version. (patcher_resolve_class): Likewise.
+
+       * src/vm/jit/alpha/patcher.c (patcher_patch_code): Implemented.
+       (patcher_initialize_class): Removed obsolete patcher function.
+       (patcher_resolve_class): Likewise.
+
+       * src/vm/jit/arm/patcher.c: Likewise.
+       * src/vm/jit/i386/patcher.c: Likewise.
+       * src/vm/jit/mips/patcher.c: Likewise.
+       * src/vm/jit/powerpc/patcher.c: Likewise.
+       * src/vm/jit/powerpc64/patcher.c: Likewise.
+       * src/vm/jit/s390/patcher.c: Likewise.
+       [5912fd263053]
+
+       * src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/codegen.h, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/patcher.c, src/vm/jit
+       /patcher-common.h, src/vm/jit/patcher.h, src/vm/signal.c,
+       src/vm/signallocal.h:
+       * src/vm/jit/i386/emit.c (emit_patcher_stubs): Removed, this is
+       obsolete. (emit_trap): Fixed trap instruction.
+
+       * src/vm/jit/i386/asmpart.S (asm_patcher_wrapper): Removed, this is
+       obsolete.
+
+       * src/vm/jit/i386/patcher.c: Adapted patchers to new signature for
+       traps. (patcher_wrapper): Removed, this is obsolete.
+
+       * src/vm/jit/i386/codegen.h (PATCHER_CALL_SIZE, PATCHER_NOPS):
+       Adapted to new trap instruction.
+
+       * src/vm/jit/i386/codegen.c (codegen_emit,
+       codegen_emit_stub_native): Call the new patcher functions via traps
+       and adapted to above change.
+
+       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigill):
+       Implemented.
+
+       * src/vm/jit/patcher-common.h [__I386__]: Enabled new patcher stuff.
+
+       * src/vm/jit/patcher.h [__I386__]: Defined away old patcher stuff.
+
+       * src/vm/signal.c (signal_init) [__I386__]: Install SIGILL handler
+       now.
+
+       * src/vm/signallocal.h [__I386__] (md_signal_handler_sigill):
+       Enabled prototype.
+       [ce451bbfaf18]
+
+2007-09-07  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * * Merged with 79e3a1932e59.
+       [7d26a3fdc72c]
+
+       * src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/emit.h:
+       * src/vm/jit/x86_64/codegen.h (M_BYTE1, M_BYTE2): New macros.
+       (M_UD2): Added. (M_RET, M_NOP): Use M_BYTE1.
+
+       * src/vm/jit/x86_64/emit.c (emit_ret): Removed. (emit_nop):
+       Likewise.
+       * src/vm/jit/x86_64/emit.h: Likewise.
+       [5f0db0ae7ffe]
+
+2007-09-07  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vmcore/loader.c:
+       * src/vmcore/loader.c (load_class_from_classloader): Fixed
+       classloader issues.
+       [79e3a1932e59]
+
+       * src/native/vm/cldc1.1/java_lang_System.c,
+       src/native/vm/gnu/java_lang_VMSystem.c, src/native/vm/sun/jvm.c,
+       src/vm/builtin.c, src/vm/builtin.h:
+       * src/vm/builtin.c (builtin_arraycopy): Returns void instead of bool
+       now.
+       * src/vm/builtin.h (builtin_arraycopy): Adapted signature.
+       * src/native/vm/cldc1.1/java_lang_System.c: Removed obsolete void
+       case.
+       * src/native/vm/gnu/java_lang_VMSystem.c: Likewise.
+       * src/native/vm/sun/jvm.c: Likewise.
+       [e8610bdc4cd2]
+
+       * src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): Removed exception
+       check for ICMD_BUILTIN because of the new stubs.
+       (codegen_emit_stub_builtin): Removed obsolete function.
+       (codegen_emit_stub_native): Checks for m->flags instead of nmd being
+       NULL.
+       [29c6007441f2]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h:
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler): Pass
+       bte->md to native stub emmiter. (codegen_stub_builtin_enter):
+       Removed. (codegen_stub_builtin_exit): Likewise.
+
+       * src/vm/jit/codegen-common.h: Removed obsolete prototypes.
+       [c4eab7fd33e2]
+
+       * src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_native): Ported
+       for builtins.
+       [9fd540662096]
+
+       * src/vm/jit/trace.c:
+       * src/vm/jit/trace.c (trace_java_call_enter): Can handle m->class ==
+       NULL now and prints flag for builtin method stubs.
+       (trace_java_call_exit): Likewise.
+       [d5d8d96798c5]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): Calls
+       same emmiter function as for native methods now.
+       (codegen_stub_builtin_enter): Disabled. (codegen_stub_builtin_exit):
+       Disabled.
+       [3a5220bcb252]
+
+       * src/vmcore/method.h:
+       * src/vmcore/method.h (method_new_builtin): Fixed typo in function
+       prototype.
+       [63861f87010d]
+
+       * src/vm/jit/stacktrace.c:
+       * src/vm/jit/stacktrace.c (stacktrace_create): Skip entries for
+       builtin stubs.
+       [4e96d91ad089]
+
+       * src/vm/builtin.c, src/vm/builtin.h, src/vm/jit/codegen-common.c,
+       src/vm/jit/codegen-common.h, src/vmcore/method.c,
+       src/vmcore/method.h:
+       * src/vm/builtin.c (builtintable_init): Create methodinfos for
+       builtins.
+       * src/vm/builtin.h (builtintable_entry): Added forward typedef.
+       * src/vmcore/method.h (method_new_builtin): Added prototype.
+       * src/vmcore/method.c (method_new_builtin): Implemented.
+       * src/vm/jit/codegen-common.h (codegen_generate_stub_builtin): Changed
+       sig.
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): Pass
+       methodinfo.
+       [e3cc0027dbdd]
+
+2007-09-06  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/native/localref.c, src/vm/jit/Makefile.am,
+       src/vm/jit/argument.c, src/vm/jit/argument.h, src/vm/jit/trace.c:
+       * src/vm/jit/argument.c: Added file for argument array handling.
+       * src/vm/jit/argument.h: Likewise.
+
+       * src/vm/jit/Makefile.am (libjit_la_SOURCES): Added above two files.
+
+       * src/vm/jit/trace.c: Moved array handling functions to argument.c
+       and adapted to new name and signature.
+
+       * src/native/localref.c (localref_fill): Likewise.
+       [f596a20dd95f]
+
+       * src/vm/jit/powerpc64/patcher.c:
+       * src/vm/jit/powerpc64/patcher.c: Removed obsolete patcher
+       functions.
+       [90715e4cfa31]
+
+       * src/native/vm/gnu/gnu_classpath_VMStackWalker.c, src/vmcore/class.c,
+       src/vmcore/loader.c, src/vmcore/loader.h:
+       * src/vmcore/loader.h (classloader) [!ENABLE_HANDLES]: Classloader
+       is a object.
+
+       * src/vmcore/loader.c (loader_hashtable_classloader_add)
+       [!ENABLE_HANDLES]: Return classloader object instead of entry. Added
+       some debug output. (loader_hashtable_classloader_find): Likewise.
+
+       * src/vmcore/class.c (class_get_classloader): No need to
+       differentiate between handles or not-handles.
+
+       * src/native/vm/gnu/gnu_classpath_VMStackWalker.c: Fixed bogus
+       classloader usages.
+       [0b269fbf04cd]
+
+2007-09-06  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/native.c:
+       * src/native/native.c (native_resolve_function): Use
+       class_get_classloader.
+       [7d5cec8c47b8]
+
+2007-09-06  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/patcher-common.h, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/patcher.c:
+       * src/vm/jit/patcher-common.h: Removed obsolete patcher function
+       defines.
+
+       * src/vm/jit/powerpc64/codegen.c: Used newer patcher function names.
+       * src/vm/jit/powerpc64/patcher.c: Likewise.
+       * src/vm/jit/s390/codegen.c: Likewise.
+       * src/vm/jit/s390/patcher.c: Likewise.
+       [81ec7f8de378]
+
+       * src/vm/jit/patcher-common.h, src/vm/jit/patcher.h,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c,
+       src/vm/jit/powerpc64/patcher.c:
+       * src/vm/jit/powerpc64/emit.c (emit_patcher_stubs): Removed, this is
+       obsolete. (emit_trap): Fixed trap instruction:
+
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit,
+       codegen_emit_stub_native): Call the new patcher functions and
+       adapted to above change.
+
+       * src/vm/jit/powerpc64/patcher.c: Adapted patchers to new signature
+       for traps. (patcher_wrapper): Removed, this is obsolete.
+
+       * src/vm/jit/powerpc64/asmpart.S (asm_patcher_wrapper): Removed,
+       this is obsolete.
+
+       * src/vm/jit/powerpc64/linux/md-os.c (md_signal_handler_sigsegv):
+       Only calls the exception handling if exception object present.
+
+       * src/vm/jit/patcher-common.h [__POWERPC64__]: Enabled new patcher
+       stuff.
+
+       * src/vm/jit/patcher.h [__POWERPC64__]: Defined away old patcher
+       stuff.
+       [6bc2f1d20c58]
+
+2007-09-06  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * * Merged with 269162803388.
+       [5cb77df28b85]
+
+       * src/native/vm/Makefile.am, src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Object.h,
+       src/native/vm/sun/jvm.c:
+       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Removed
+       java_lang_Object.[ch].
+
+       * src/native/vm/java_lang_Object.c: Removed.
+       * src/native/vm/java_lang_Object.h: Likewise.
+
+       * src/native/vm/cldc1.1/java_lang_Object.c
+       (native/vm/java_lang_Object.h): Removed. (threads/lock-common.h):
+       Added. (vm/exceptions.h): Likewise. (getClass): Use LLNI_class_get.
+       (notify): Use lock_notify_object. (notifyAll): Use
+       lock_notify_all_object. (wait): Use lock_wait_for_object.
+
+       * src/native/vm/gnu/java_lang_VMObject.c (native/llni.h): Added.
+       (native/vm/java_lang_Object.h): Removed. (threads/lock-common.h):
+       Added. (vm/builtin.h): Likewise. (vm/exceptions.h): Likewise.
+       (getClass): Use LLNI_class_get. (clone): Use builtin_clone.
+       (notify): Use lock_notify_object. (notifyAll): Use
+       lock_notify_all_object. (wait): Use lock_wait_for_object.
+
+       * src/native/vm/sun/jvm.c (native/vm/java_lang_Object.h): Removed.
+       (JVM_MonitorWait): Use lock_wait_for_object. (JVM_MonitorNotify):
+       Use lock_notify_object. (JVM_MonitorNotifyAll): Use
+       lock_notify_all_object.
+       [483fb5dd71d3]
+
+2007-09-05  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/codegen-common.c (codegen_start_native_call)
+       [__X86_64__]: Tracer for native methods is called from here now.
+       (codegen_finish_native_call) [__X86_64__]: Likewise.
+
+       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Removed
+       verbosecall tracer.
+       [269162803388]
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, src/vm/jit
+       /codegen-common.c, src/vm/jit/codegen-common.h,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/codegen-common.h (codegen_finish_native_call): Changes
+       signature.
+
+       * src/vm/jit/codegen-common.c (codegen_finish_native_call): Takes
+       the same arguments as the enter pendant now.
+
+       * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Adapted to
+       new signature mentioned above.
+
+       * src/vm/jit/arm/codegen.c: Likewise.
+       * src/vm/jit/i386/codegen.c: Likewise.
+       * src/vm/jit/m68k/codegen.c: Likewise.
+       * src/vm/jit/mips/codegen.c: Likewise.
+       * src/vm/jit/powerpc/codegen.c: Likewise.
+       * src/vm/jit/powerpc64/codegen.c: Likewise.
+       * src/vm/jit/s390/codegen.c: Likewise.
+       * src/vm/jit/x86_64/codegen.c: Likewise.
+       [3d7dd4ddb484]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/trace.c:
+       * src/vm/jit/codegen-common.c (codegen_start_native_call)
+       [__POWERPC__]: Tracer for native methods is called from here now.
+
+       * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_native): Removed
+       verbosecall enter tracer.
+
+       * src/vm/jit/powerpc/emit.c (emit_verbosecall_enter,
+       emit_verbosecall_exit): Adapted to new tracer functions.
+
+       * src/vm/jit/trace.c (_array_load_param, _array_load_return_value):
+       Optimized passing of register arguments.
+       [75c295a0dd45]
+
+2007-09-05  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/sun/jvm.c, tests/regression/jasmin/runtest,
+       tests/regression/jasmin/show:
+       * changed src/native/vm/sun/jvm.c: Throw IllegalArgumentException in
+       all ConstantPool.get*At(int) methods as expected by OpenJDK.
+
+       * changed src/native/vm/gnu/sun_reflect_ConstantPool.c: Likewise.
+       [614a7af9d894]
+
+2007-09-05  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h:
+       * src/native/vm/java_lang_Class.c (getDeclaringClass): Removed.
+       * src/native/vm/java_lang_Class.h: Likewise.
+       * src/native/vm/gnu/java_lang_VMClass.c (getDeclaringClass): Use
+       class_get_declaringclass.
+       [4481d9c381a3]
+
+       * src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h:
+       * src/native/vm/java_lang_Class.c (isArray): Removed.
+       * src/native/vm/java_lang_Class.h: Likewise.
+       * src/native/vm/cldc1.1/java_lang_Class.c (isArray): New function.
+       * src/native/vm/gnu/java_lang_VMClass.c (isArray): Use class_is_array.
+       [10a1c5e2a7ca]
+
+       * src/vm/jit/mips/linux/md-os.c:
+       * src/vm/jit/mips/linux/md-os.c (mm/memory.h): Added. (md_init): Use
+       int instead of u1 for GCNEW.
+       [88289982f1fd]
+
+       * configure.ac, m4/debug.m4, m4/dump.m4, m4/gc.m4, m4/intrp.m4:
+       * configure.ac (AC_CHECK_ENABLE_INTRP): Added. (AC_CHECK_ENABLE_GC):
+       Likewise. (AC_CHECK_ENABLE_DEBUG): Likewise. (AC_CHECK_ENABLE_DUMP):
+       Likewise.
+
+       * m4/debug.m4: New file.
+       * m4/dump.m4: Likewise.
+       * m4/gc.m4: Likewise.
+       * m4/intrp.m4: Likewise.
+       [9af6482b9325]
+
+       * configure.ac, src/cacao/Makefile.am, src/cacao/cacao.c,
+       src/native/Makefile.am, src/native/include/Makefile.am,
+       src/native/native.c, src/native/native.h,
+       src/native/tools/Makefile.am, src/native/tools/gennativetable.c,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/intrp/java.vmg, src/vm/jit/intrp/patcher.c,
+       src/vm/jit/jit.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/patcher.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/patcher-common.h,
+       src/vm/jit/patcher.h, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/patcher.c, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/properties.c:
+       * configure.ac (static-classpath): Removed.
+
+       * src/cacao/Makefile.am, src/native/Makefile.am,
+       src/native/include/Makefile.am: Removed WITH_STATIC_CLASSPATH if's.
+
+       * src/native/native.c (native_findfunction): Removed.
+       * src/native/native.h (nativeref, nativecompref): Removed.
+       (native_findfunction): Removed.
+
+       * src/native/tools/Makefile.am: Removed.
+       * src/native/tools/gennativetable.c: Likewise.
+
+       * src/cacao/cacao.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/patcher.c, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/patcher.c, src/vm/jit/intrp/java.vmg,
+       src/vm/jit/intrp/patcher.c, src/vm/jit/jit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/patcher.c, src/vm/jit
+       /patcher-common.h, src/vm/jit/patcher.h,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/patcher.c,
+       src/vm/properties.c: Removed WITH_STATIC_CLASSPATH #ifdef's.
+       [d2a378158a66]
+
+2007-09-05  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/heap.c, src/mm/cacao-
+       gc/rootset.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/mm/cacao-gc/rootset.c (rootset_readout): Ignore threads in
+       state new.
+
+       * src/mm/cacao-gc/heap.c (heap_alloc): Wrap reference befor
+       returning. (heap_alloc_intern): Respect stress-test option flag.
+
+       * src/mm/cacao-gc/gc.c (gc_collect): Respect debug rootset option
+       flag.
+
+       * src/vmcore/options.h [ENABLE_GC_CACAO] (opt_GCDebugRootSet):
+       Added. [ENABLE_GC_CACAO] (opt_GCStress): Likewise.
+
+       * src/vmcore/options.c (options_xx) [ENABLE_GC_CACAO]: Parse above
+       two options.
+       [2e34e2e4d7ce]
+
+2007-09-05  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * * Merged with 3aaaa9f60c5d.
+       [ec7e530caf47]
+
+       * * Merge with 405cda264bce.
+       [9216d09f671d]
+
+       * * Not sure what this commit should do, let's see.
+       [8a98984ca196]
+
+       * src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/sun/jvm.c, src/vmcore/class.c, src/vmcore/class.h:
+       * src/vmcore/class.c (class_get_classloader): New function.
+       * src/vmcore/class.h: Likewise.
+       * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getClassLoader): Removed.
+       * src/native/vm/java_lang_Class.h: Likewise.
+       * src/native/vm/gnu/java_lang_VMClass.c (getClassLoader): Use
+       class_get_classloader.
+       * src/native/vm/sun/jvm.c (JVM_GetClassLoader): Likewise.
+       [bd4ae591dcc4]
+
+2007-09-05  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/native/llni.h, src/native/vm/reflect.c, src/vm/builtin.c:
+       * src/native/llni.h: Fixed a lot of compiler warnings.
+
+       * src/native/vm/reflect.c (reflect_field_new): Removed bogus cast.
+       (reflect_method_new): Likewise.
+
+       * src/vm/builtin.c (builtin_multianewarray): Fixed compiler warning.
+       [3aaaa9f60c5d]
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, src/vm/jit
+       /codegen-common.c, src/vm/jit/codegen-common.h,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/codegen-common.c (codegen_start_native_call): Return
+       class argument for static native methods.
+
+       * src/vm/jit/codegen-common.h (codegen_start_native_call): Adapted
+       signature.
+
+       * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Class
+       argument is no longer placed onto the data segment.
+
+       * src/vm/jit/arm/codegen.c: Likewise.
+       * src/vm/jit/i386/codegen.c: Likewise.
+       * src/vm/jit/m68k/codegen.c: Likewise.
+       * src/vm/jit/mips/codegen.c: Likewise.
+       * src/vm/jit/powerpc/codegen.c: Likewise.
+       * src/vm/jit/powerpc64/codegen.c: Likewise.
+       * src/vm/jit/s390/codegen.c: Likewise.
+       * src/vm/jit/sparc64/codegen.c: Likewise.
+       * src/vm/jit/x86_64/codegen.c: Likewise.
+       [405cda264bce]
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_handle_exception): Restructured to
+       create sfi.
+       [f23b2db94198]
+
+       * src/mm/cacao-gc/heap.h, src/mm/cacao-gc/mark.c:
+       * src/mm/cacao-gc/heap.h (FOREACH_OBJECT_REF): Adapted to new
+       classinfo->super.
+       * src/mm/cacao-gc/mark.c (mark_recursive): Likewise.
+       [ba936361b758]
+
+       * src/native/localref.c, src/native/localref.h, src/vm/jit/codegen-
+       common.c, src/vm/jit/trace.c:
+       * src/native/localref.h (localref_fill): Added prototype.
+
+       * src/native/localref.c (localref_fill): Implemented.
+       (localref_frame_push): Fixed compiler warning. (_array_store_param):
+       Added temporarily.
+
+       * src/vm/jit/trace.c (_array_load_param): Made non-static.
+
+       * src/vm/jit/codegen-common.c (codegen_start_native_call): Call
+       localref_fill.
+       [ded869549a11]
+
+2007-09-05  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * * Merged with 291b838f1aed.
+       [575e21f5ffea]
+
+       * tests/regression/jasmin/runtest, tests/regression/jasmin/show:
+       * tests/regression/jasmin/runtest: Make executable.
+       * tests/regression/jasmin/show: Likewise.
+       [a1b55f522e0d]
+
+2007-09-04  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): Added
+       workaround for builtins returning booleans to indicate exceptions.
+
+       * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_builtin):
+       Workaround was moved to codegen-common.c to keep codegens clean.
+       [291b838f1aed]
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (Java_sun_misc_Unsafe_defineClass)
+       [ENABLE_HANDLES]: Fixed array access.
+       (Java_sun_misc_Unsafe_allocateInstance): Fixed compiler warning.
+       [37c9348bdbe5]
+
+2007-09-04  edwin  <edwin@localhost.localdomain>
+
+       * src/vmcore/class.c:
+       * src/vmcore/class.c (classref_or_classinfo_println): Fixed infinite
+       recursion.
+       [4c27eb92e935]
+
+2007-09-04  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * tests/regression/native/testarguments.c:
+       * tests/regression/native/testarguments.c: Adapted testcase to
+       support handles.
+       [59b815ba5555]
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, src/vm/jit
+       /codegen-common.c, src/vm/jit/codegen-common.h,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/codegen-common.h (codegen_start_native_call): Changed
+       signature.
+
+       * src/vm/jit/codegen-common.c (codegen_start_native_call): Takes
+       less arguments now and computes values by itself. This makes the
+       codegens simpler.
+
+       * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Adapted to
+       new signature mentioned above.
+
+       * src/vm/jit/arm/codegen.c: Likewise.
+       * src/vm/jit/i386/codegen.c: Likewise.
+       * src/vm/jit/m68k/codegen.c: Likewise.
+       * src/vm/jit/mips/codegen.c: Likewise.
+       * src/vm/jit/powerpc/codegen.c: Likewise.
+       * src/vm/jit/powerpc64/codegen.c: Likewise.
+       * src/vm/jit/s390/codegen.c: Likewise.
+       * src/vm/jit/x86_64/codegen.c: Likewise.
+       [109ce828d62d]
+
+       * tests/gc/NativeGlobalRef.java, tests/gc/native.c:
+       * tests/gc/NativeGlobalRef.java: Improved testcase.
+       * tests/gc/native.c: Likewise.
+       [12a8c1a6d1a7]
+
+2007-09-03  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/native/localref.c:
+       * src/native/localref.c (localref_del): Go through all local frames.
+       [c492fcf2fcc8]
+
+       * src/vm/exceptions.c:
+       src/vm/exceptions.c (exceptions_asm_new_abstractmethoderror): Unwrap
+       exception.
+       [72076f9da934]
+
+       * src/vm/jit/stacktrace.c, src/vmcore/options.c:
+       * src/vm/jit/stacktrace.c (stacktrace_create): Enabled
+       -XX:+DebugStackTrace.
+       * src/vmcore/options.c (options_XX): Added some descriptions.
+       [d2642fe48c1d]
+
+2007-09-03  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_DetachCurrentThread): We need to pop all
+       frames before we can destroy the table.
+       [07bc83b81257]
+
+       * src/vm/jit/trace.c:
+       * src/vm/jit/trace.c (native/jni.h): Added.
+       [6f33e8199e8a]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/linux/md-os.c:
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin)
+       [__POWERPC__]: Define added.
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): ICMD_BUILTIN: Use stub.
+       (codegen_emit_stub_builtin): New function.
+       (codegen_emit_stub_native): Fixed some offsets.
+       * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigusr1): New
+       function.
+       [60976e6fae32]
+
+2007-09-03  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * merge with branch e6c59621d39a
+       [3912aedf3af4]
+
+       * tests/regression/TestAnnotations.java:
+       * tests/regression/TestAnnotations.java: Removed umlauts.
+       [55d7d537bef0]
+
+2007-09-03  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_FindClassFromClassLoader): Add CL to
+       hashtable. (JVM_DefineClassWithSource): Likewise.
+       (JVM_FindLoadedClass): Likewise.
+       [e6c59621d39a]
+
+       * src/vm/builtin.c, src/vm/exceptions.c, src/vm/jit/trace.c,
+       src/vm/jit/trace.h:
+       * src/vm/builtin.c (methodindent, callcount): Removed static
+       variables. (builtin_throw_exception): Use trace_exception_builtin.
+       (builtin_verbosecall_enter): Use thread-specific variables.
+       (builtin_verbosecall_exit): Likewise.
+
+       * src/vm/exceptions.c (exceptions_handle_exception): Fixed
+       methodindent for java call traces.
+
+       * src/vm/jit/trace.c: Added comments and minor cleanups.
+       (trace_exception_builtin): Implemented (moved from builtin.c).
+
+       * src/vm/jit/trace.h (trace_exception_builtin): Added prototype.
+       [9e9d2b28cfea]
+
+       * src/vm/jit/powerpc/emit.c:
+       * src/vm/jit/powerpc/emit.c (emit_verbosecall_exit) [__DARWIN__]:
+       Fixed passing of methodinfo argument.
+       [a64cbc7fdf34]
+
+       * src/vm/builtin.c, src/vm/builtin.h, src/vm/builtintable.inc,
+       src/vm/exceptions.h, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/emit.c, src/vm/jit/emit-common.h,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/stack.c, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/emit.c, src/vm/signal.c:
+       * src/vm/builtin.c (builtin_canstore): Throw an ArrayStoreException.
+       (builtin_fast_canstore): Do not throw any exceptions.
+
+       * src/vm/builtin.h (BUILTIN_canstore): Removed.
+
+       * src/vm/builtintable.inc: Adapted entry for builtin_canstore.
+
+       * src/vm/exceptions.h (EXCEPTION_HARDWARE_ARRAYSTORE): Added.
+
+       * src/vm/signal.c (signal_handle): Added case for
+       ArrayStoreException.
+
+       * src/vm/jit/emit-common.h (emit_arraystore_check): Added prototype.
+
+       * src/vm/jit/stack.c (stack_analyse): ICMD_AASTORE now uses fast
+       canstore.
+
+       * src/vm/jit/alpha/codegen.c (codegen_emit): ICMD_AASTORE uses fast
+       canstore.
+       * src/vm/jit/alpha/emit.c (emit_arraystore_check): Implemented.
+
+       * src/vm/jit/arm/codegen.c: Likewise.
+       * src/vm/jit/arm/emit.c: Likewise.
+       * src/vm/jit/i386/codegen.c: Likewise.
+       * src/vm/jit/i386/emit.c: Likewise.
+       * src/vm/jit/m68k/codegen.c: Likewise.
+       * src/vm/jit/m68k/emit.c: Likewise.
+       * src/vm/jit/mips/codegen.c: Likewise.
+       * src/vm/jit/mips/emit.c: Likewise.
+       * src/vm/jit/powerpc/codegen.c: Likewise.
+       * src/vm/jit/powerpc/emit.c: Likewise.
+       * src/vm/jit/powerpc64/codegen.c: Likewise.
+       * src/vm/jit/powerpc64/emit.c: Likewise.
+       * src/vm/jit/s390/codegen.c: Likewise.
+       * src/vm/jit/s390/emit.c: Likewise.
+       * src/vm/jit/sparc64/codegen.c: Likewise.
+       * src/vm/jit/sparc64/emit.c: Likewise.
+       * src/vm/jit/x86_64/codegen.c: Likewise.
+       * src/vm/jit/x86_64/emit.c: Likewise.
+       [e87c6675ff29]
+
+       * src/vm/array.c:
+       * src/vm/array.c (array_length_get): Better use LLNI_class_get here.
+       [4076f8bfb9f5]
+
+2007-09-03  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * THIRDPARTY, src/lib/Makefile.am, src/lib/gnu/sun/reflect/annotation/
+       EnumConstantNotPresentExceptionProxy.java,
+       src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java:
+       * THIRDPARTY: Added copyright notice for newly imported files.
+
+       * src/lib/Makefile.am (VM_JAVA_FILES) [ENABLE_ANNOTATIONS]: Added
+       $(top_srcdir)/src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java
+       and $(top_srcdir)/src/lib/gnu/sun/reflect/annotation/EnumConstantNot
+       PresentExceptionProxy.java (VM_CLASS_FILES) [ENABLE_ANNOTATIONS]:
+       Added classes/sun/reflect/annotation/ExceptionProxy.class and classe
+       s/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.class
+
+       * src/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentException
+       Proxy.java: Imported from OpenJDK. This file was only an
+       unimplemented stub in GNU Classpath.
+
+       * src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java: Likewise.
+       [0ac069bf6d22]
+
+2007-09-02  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_FindClass) [ENABLE_JAVAME_CLDC1_1]:
+       Implemented.
+       [737aa9376ba1]
+
+       * src/cacaoh/headers.c, src/vm/initialize.c, src/vm/jit/verify
+       /typecheck-invoke.inc, src/vm/jit/verify/typeinfo.c,
+       src/vm/resolve.c, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/linker.c, src/vmcore/loader.c,
+       src/vmcore/primitivecore.c:
+       * src/vmcore/class.h (classinfo): Changed type of super and
+       interfaces to classinfo*.
+       * src/cacaoh/headers.c (printfields): Removed .cls for super class
+       and/or interfaces.
+       * src/vm/initialize.c (initialize_class_intern): Likewise.
+       * src/vm/jit/verify/typecheck-invoke.inc: Likewise.
+       * src/vm/jit/verify/typeinfo.c (interface_extends_interface):
+       Likewise. (typeinfo_merge_nonarrays): Likewise.
+       * src/vm/resolve.c (resolve_method_invokespecial_lookup): Likwise.
+       * src/vmcore/class.c (class_free): Likewise. (class_resolvemethod):
+       Likewise. (class_resolveinterface_intern): Likewise.
+       (class_resolveclassmethod): Likewise. (class_findfield): Likewise.
+       (class_resolvefield_int): Likewise. (class_get_interfaces):
+       Likewise. (class_issubclass): Likewise. (class_get_superclass):
+       Likewise. (class_showmethods): Likewise. (class_showmethods):
+       Likewise. (class_resolve_superclass): Removed.
+       * src/vmcore/linker.c (linker_init): Removed .cls for super class
+       and/or interfaces. (linker_compute_subclasses): Likewise.
+       (linker_addinterface): Likewise. (link_class_intern): Moved verifier
+       checks into classfile parsing stage.
+       * src/vmcore/loader.c (vm/resolve.h): Added.
+       (load_class_from_classbuffer_intern): Resolve super class and super
+       interfaces during loading. This is also done by the RI.
+       (load_newly_created_array): Removed .cls for super class and/or
+       interfaces.
+       * src/vmcore/primitivecore.c (primitive_init): Likewise.
+       [6a2784fb3be7]
+
+       * .hgignore:
+       * .hgignore: Ignore files in tests/.
+       [0d0a9bd7bf72]
+
+2007-09-01  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (llni.h): Added.
+       (codegen_stub_builtin_exit): Use stacktrace function to remove
+       stackframeinfo. (codegen_finish_native_call): Likewise. Unwrap
+       exception object before return.
+       [cc6e8e021e70]
+
+       * src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h,
+       tests/StackTraceBig.java:
+       * src/vm/jit/stacktrace.h (stacktracebuffer): Entries are stored
+       inside stb now. (stacktracecontainer): Removed data field.
+
+       * src/vm/jit/stacktrace.c (stacktrace_add_entry) Adapted to above
+       changes. (stacktrace_add_method): Likewise. (stacktrace_create):
+       Likewise. (stacktrace_fillInStackTrace): Stacktracebuffer can be
+       copied at once.
+
+       * tests/StackTraceBig.java: Added testcase for large stacktraces.
+       [42b041b8ea05]
+
+       * src/vm/builtin.c:
+       * src/vm/builtin.c (builtin_canstore): Fixed severe typo.
+       [fc721266fcd8]
+
+       * src/vm/builtin.c, src/vm/builtin.h, src/vm/exceptions.c,
+       src/vm/jit/trace.c, src/vm/jit/trace.h:
+       * src/vm/builtin.c: Use LLNI macros throughout the file.
+       (builtin_fast_canstore): Previously builtin_canstore.
+       (builtin_canstore): Implemented. (builtin_trace_exception): Moved to
+       trace.c.
+
+       * src/vm/builtin.h: Fixed prototypes.
+
+       * src/vm/exceptions.c (exceptions_handle_exception): Use
+       trace_exception instead of builtin.
+
+       * src/vm/jit/trace.c (trace_exception): Added (moved from
+       builtin.c).
+
+       * src/vm/jit/trace.h (trace_exception): Added prototype.
+       [e2c8ed46c130]
+
+2007-08-31  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/trace.c,
+       src/vm/vm.c:
+       * src/vm/jit/trace.c (trace_java_call_print_argument): Deals with
+       java_object_t.
+
+       * src/vm/exceptions.h (exceptions_asm_new_abstractmethoderror):
+       Fixed prototype.
+
+       * src/vm/exceptions.c: Use LLNI_class_get throughout file.
+       (exceptions_get_exception): Wrap exception object.
+       (exceptions_set_exception): Unwrap exception object.
+
+       * src/vm/vm.c: Use LLNI_class_get throughout file.
+       [f7ad5f22979c]
+
+       * src/cacaoh/dummy.c, src/native/include/Makefile.am,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c:
+       * src/cacaoh/dummy.c (array_objectarray_element_set): Fixed for
+       handles. (array_objectarray_element_get): Likewise.
+       (builtin_anewarray): Likewise. (builtin_newarray_byte): Likewise.
+       (localref_add): Added.
+
+       * src/native/include/Makefile.am [ENABLE_ANNOTATIONS]: Create
+       java_util_Map.h.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c: Use above
+       header.
+       * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise.
+       * src/native/vm/gnu/java_lang_reflect_Method.c: Likewise.
+       [aaaac3a75526]
+
+       * src/native/vm/java_lang_ClassLoader.c:
+       * src/native/vm/java_lang_ClassLoader.c
+       (_Jv_java_lang_ClassLoader_defineClass): Removed bugging assertion.
+       It seems defineClass can take NULL as classloader.
+       [058fbd6b9a45]
+
+       * src/native/jni.c, tests/regression/native/checkjni.c,
+       tests/regression/native/checkjni.java,
+       tests/regression/native/checkjni.output:
+       * src/native/jni.c (_Jv_JNI_GetObjectField): Fixed implementation
+       for handles. (_Jv_JNI_SetObjectField): Likewise.
+
+       * tests/regression/native/checkjni.c: Added testcase for above
+       change.
+       * tests/regression/native/checkjni.java: Likewise.
+       * tests/regression/native/checkjni.output: Adapted output to above
+       changes.
+       [f2aaccf82e27]
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c:
+       * src/vm/jit/i386/codegen.c (codegen_emit_stub_builtin): Removed
+       obsolete assertion.
+
+       * src/vm/jit/m68k/codegen.c (codegen_emit_stub_builtin): Likewise.
+       [245c495034d6]
+
+       * * Merged with exact-gc branch at rev 2d4098fc2ea4.
+       [70720e99787f]
+
+       * src/lib/Makefile.am, src/native/vm/Makefile.am,
+       src/native/vm/java_lang_String.c, src/native/vm/java_lang_String.h:
+       * src/lib/Makefile.am: Fixed another merge problem.
+       * src/native/vm/Makefile.am: Removed resurrected files.
+       * src/native/vm/java_lang_String.c: Removed resurrected file.
+       * src/native/vm/java_lang_String.h: Likewise.
+       [2d4098fc2ea4]
+
+       * src/vmcore/class.c:
+       * src/vmcore/class.c (class_free): Fixed another merge problem (thx
+       to panzi).
+       [0ff8641a2a6d]
+
+       * src/native/vm/gnu/java_lang_VMClassLoader.c:
+       * src/native/vm/gnu/java_lang_VMClassLoader.c
+       (Java_java_lang_VMClassLoader_findLoadedClass): Add classloader to
+       hashtable instead of searching for it.
+       [7789ad4e3f25]
+
+       * src/threads/native/threads.c, src/vm/jit/codegen-common.c:
+       * src/threads/native/threads.c (threads_stopworld) [__DARWIN__]:
+       Disabled. (threads_startworld) [__DARWIN__]: Likewise.
+
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin):
+       Disabled for archs where codegen_emit_stub_builtin is not yet
+       implemented.
+       [123b52988611]
+
+       * tests/gc/ClassUnload.java:
+       * tests/gc/ClassUnload.java: Added testcase for class unloading.
+       [7ef9d758714e]
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_String.c, src/vm/access.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h:
+       * src/native/vm/gnu/java_lang_reflect_Method.c
+       (Java_java_lang_reflect_Method_invokeNative): Fixed LLNI macro
+       usage.
+
+       * src/native/vm/java_lang_String.c (_Jv_java_lang_String_intern):
+       Wrap interned strings into a handle.
+
+       * src/vm/access.c (access_check_field): Use LLNI macro for array
+       access. (access_check_method): Likewise.
+
+       * src/vm/jit/stacktrace.c (stacktrace_getClassContext): Likewise.
+       (stacktrace_getStack): Likewise.
+
+       * src/vm/jit/stacktrace.h (md-abi.h): Added missing include.
+       [2bda8b53eb85]
+
+       * src/mm/cacao-gc/heap.c, src/vm/jit/codegen-common.c:
+       * src/mm/cacao-gc/heap.c (heap_alloc_intern) [!NDEBUG]: Added sanity
+       check.
+
+       * src/vm/jit/codegen-common.c (codegen_stub_builtin_enter): Removed
+       native-world flag manipulation. (codegen_stub_builtin_exit):
+       Likewise. (codegen_start_native_call): Likewise.
+       (codegen_finish_native_call): Likewise.
+       [f561e7cc5606]
+
+       * configure.ac, src/native/jni.c,
+       src/native/vm/java_lang_ClassLoader.c, src/native/vm/nativevm.c,
+       src/vmcore/loader.c:
+       * configure.ac: Added missing newline.
+       * src/native/jni.c: Fixed some merge problems
+       * src/native/vm/java_lang_ClassLoader.c: Likewise.
+       * src/native/vm/nativevm.c: Likewise.
+       * src/vmcore/loader.c: Likewise.
+       [3a5cad64b925]
+
+       * tests/regression/native/checkjni.c,
+       tests/regression/native/checkjni.java,
+       tests/regression/native/checkjni.output:
+       * tests/regression/native/checkjni.java: Added some new JNI
+       testcases.
+       * tests/regression/native/checkjni.c: Likewise.
+       * tests/regression/native/checkjni.output: Adapted output to new
+       testcases.
+       [45a390db1fc6]
+
+2007-08-30  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/mm/cacao-gc/copy.c, src/mm/cacao-gc/copy.h, src/mm/cacao-
+       gc/final.c, src/mm/cacao-gc/final.h, src/mm/cacao-gc/heap.c, src/mm
+       /cacao-gc/heap.h, src/mm/cacao-gc/mark.h, src/mm/cacao-gc/region.c,
+       src/mm/cacao-gc/region.h, src/mm/cacao-gc/rootset.c, src/mm/cacao-
+       gc/rootset.h, src/native/llni.c, src/native/vm/java_lang_String.c,
+       src/native/vm/java_lang_String.h, src/vm/jit/m68k/codegen.h:
+       * Removed leftover Id tags.
+       [6b7f509fc859]
+
+       * AUTHORS, ChangeLog, NEWS, configure.ac, contrib/log2xml.pl,
+       m4/classpath.m4, src/Makefile.am, src/cacaoh/cacaoh.c,
+       src/cacaoh/dummy.c, src/cacaoh/headers.c, src/lib/Makefile.am,
+       src/mm/boehm-gc/callprocs, src/mm/boehm-gc/cord/de_win.ICO, src/mm
+       /boehm-gc/doc/README.arm.cross, src/mm/boehm-
+       gc/pthread_stop_world.c, src/mm/boehm-gc/win32_threads.c,
+       src/mm/boehm.c, src/mm/cacao-gc/Makefile.am, src/mm/cacao-
+       gc/compact.c, src/mm/cacao-gc/compact.h, src/mm/cacao-gc/gc.c,
+       src/mm/cacao-gc/gc.h, src/mm/cacao-gc/mark.c, src/mm/gc-common.h,
+       src/mm/memory.c, src/mm/memory.h, src/mm/nogc.c,
+       src/native/Makefile.am, src/native/include/Makefile.am,
+       src/native/jni.c, src/native/jni.h, src/native/llni.h,
+       src/native/localref.c, src/native/localref.h, src/native/native.c,
+       src/native/native.h, src/native/vm/Makefile.am,
+       src/native/vm/cldc1.1/java_lang_Double.c,
+       src/native/vm/cldc1.1/java_lang_Float.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_Throwable.c,
+       src/native/vm/gnu/Makefile.am,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Thread.c,
+       src/native/vm/java_lang_reflect_Method.c, src/native/vm/nativevm.c,
+       src/native/vm/nativevm.h, src/native/vm/reflect.c,
+       src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c,
+       src/threads/critical.c, src/threads/native/lock.c,
+       src/threads/native/lock.h, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/none/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h,
+       src/toolbox/avl.c, src/toolbox/avl.h, src/toolbox/list.c,
+       src/toolbox/list.h, src/vm/Makefile.am, src/vm/access.c,
+       src/vm/access.h, src/vm/builtin.c, src/vm/builtin.h,
+       src/vm/builtintable.inc, src/vm/exceptions.c, src/vm/exceptions.h,
+       src/vm/finalizer.c, src/vm/global.h, src/vm/jit/Makefile.am,
+       src/vm/jit/abi.h, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/alpha/arch.h, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/codegen.h,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/alpha/md-abi.c, src/vm/jit/alpha/md.c,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/arm/arch.h,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c,
+       src/vm/jit/arm/linux/md-os.c, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/arm/md.c, src/vm/jit/arm/patcher.c, src/vm/jit/asmpart.h,
+       src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/codegen-common.c,
+       src/vm/jit/codegen-common.h, src/vm/jit/disass-common.c,
+       src/vm/jit/disass.h, src/vm/jit/dseg.c, src/vm/jit/dseg.h,
+       src/vm/jit/emit-common.c, src/vm/jit/emit-common.h,
+       src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h,
+       src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md-abi.c,
+       src/vm/jit/i386/md.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/intrp/asmpart.c,
+       src/vm/jit/intrp/intrp.h, src/vm/jit/intrp/patcher.c,
+       src/vm/jit/intrp/peephole-gen, src/vm/jit/intrp/vmgenx,
+       src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/m68k/arch.h,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h,
+       src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/md.c,
+       src/vm/jit/m68k/patcher.c, src/vm/jit/mips/arch.h,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/optimizing/profile.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c,
+       src/vm/jit/parse.h, src/vm/jit/patcher.h, src/vm/jit/powerpc/arch.h,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/codegen.h, src/vm/jit/powerpc/darwin/md-abi.c,
+       src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/codegen.h,
+       src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/Makefile.am,
+       src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/linux/md-
+       abi.h, src/vm/jit/powerpc64/linux/md-os.c,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/reg.c, src/vm/jit/replace.c, src/vm/jit/replace.h,
+       src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/disass.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390
+       /md-abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/s390/tests/dacapo.status,
+       src/vm/jit/s390/tests/tests.java.pp, src/vm/jit/show.c,
+       src/vm/jit/sparc64/Makefile.am, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c,
+       src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h,
+       src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/stack.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h,
+       src/vm/jit/trace.c, src/vm/jit/trace.h,
+       src/vm/jit/verify/generate.pl, src/vm/jit/verify/typecheck-
+       stackbased.c, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/arch.h,
+       src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/emit.h, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/md.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/jit_interface.h,
+       src/vm/primitive.c, src/vm/primitive.h, src/vm/properties.c,
+       src/vm/resolve.c, src/vm/resolve.h, src/vm/signal.c,
+       src/vm/signallocal.h, src/vm/string.c, src/vm/stringlocal.h,
+       src/vm/vm.c, src/vm/vm.h, src/vmcore/Makefile.am,
+       src/vmcore/annotation.c, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/classcache.c, src/vmcore/classcache.h,
+       src/vmcore/descriptor.c, src/vmcore/descriptor.h,
+       src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.c,
+       src/vmcore/linker.h, src/vmcore/loader.c, src/vmcore/loader.h,
+       src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/rt-timing.c, src/vmcore/rt-
+       timing.h, src/vmcore/statistics.c, src/vmcore/statistics.h,
+       src/vmcore/utf8.c, src/vmcore/utf8.h, src/vmcore/zip.c,
+       tests/regression/Makefile.am, tests/regression/jasmin/runtest,
+       tests/regression/jasmin/show, tests/regression/native/Makefile.am,
+       tests/regression/native/testarguments.c,
+       tests/regression/native/testarguments.java,
+       tests/regression/resolving/Makefile.am:
+       * Merged with default branch at rev 16f3633aaa5a.
+       [5580183476bc]
+
+       * * Dummy commit to fix conversion problems with some files.
+       [2a3f176c1847]
+
+2007-08-30  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/jni.c:
+       * src/native/jni.c (native/include/java_lang_Byte.h,
+       native/include/java_lang_Character.h,
+       native/include/java_lang_Short.h,
+       native/include/java_lang_Integer.h,
+       native/include/java_lang_Boolean.h, native/include/java_lang_Long.h,
+       native/include/java_lang_Float.h,
+       native/include/java_lang_Double.h): Removed. [WITH_CLASSPATH_SUN]
+       (class_sun_nio_ch_DirectBuffer) (class_java_nio_DirectByteBuffer,
+       dbb_init): Added. (jni_init) [WITH_CLASSPATH_SUN]: Added direct-
+       buffer stuff. (_Jv_JNI_ExceptionOccurred): Added TRACEJNICALLS.
+       (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_GetStaticMethodID):
+       Likewise. (_Jv_JNI_DestroyJavaVM): Likewise.
+       (_Jv_JNI_ExceptionDescribe): Fixed bug.
+       (_Jv_JNI_NewDirectByteBuffer) [WITH_CLASSPATH_SUN]: Implemented.
+       (_Jv_JNI_GetDirectBufferAddress): Likewise.
+       [16f3633aaa5a]
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (getFloat): Implemented.
+       (getShort): Likewise. (getFloat): Likewise.
+       [e93f7beb4914]
+
+       * src/native/jni.c, src/native/vm/sun/jvm.c:
+       * src/native/jni.c (_Jv_JNI_GetVersion): Return JNI_VERSION_1_6.
+       (GetObjectRefType): New function. (_Jv_JNINativeInterface): Added
+       jni_GetObjectRefType.
+       * src/native/vm/sun/jvm.c (JVM_IsSupportedJNIVersion): Added
+       JNI_VERSION_1_6.
+       [1f464780e928]
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (getLong): Implemented. (putByte):
+       Likewise. (putShort): Likewise. (setMemory): Likewise.
+       [6543e757c0dd]
+
+2007-08-29  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * merge with b3167e4ef780
+       [6ca1619ca330]
+
+       * merge branch
+       [b3167e4ef780]
+
+       * src/vmcore/annotation.c:
+       * src/vmcore/annotations.c (vmcore/loader.h): Added include.
+       [b15974c0c943]
+
+2007-08-28  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * src/native/vm/java_lang_Class.c, src/vmcore/annotation.c:
+       * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getDeclaredAnnotations): Removed unnecessary
+       exceptions_get_exception() check.
+
+       * src/vmcore/annotation.c (annotation_bytearrays_resize): Fixed
+       comment.
+       [487da8dcec58]
+
+2007-08-29  Michael Starzinger  <michi@complang.tuwien.ac.at>
+
+       * src/threads/native/threads.h, src/threads/none/threads.h,
+       src/vm/jit/stacktrace.c:
+       * src/threads/native/threads.h: Added THREAD_NATIVEWORLD macros.
+       * src/threads/none/threads.h: Likewise.
+       * src/vm/jit/stacktrace.c (stacktrace_remove_stackframeinfo): Use
+       above macros. (stacktrace_create_extern_stackframe): Likewise.
+       (stacktrace_create_native_stackframe): Likewise.
+       [3cf6b87e4849]
+
+2007-08-29  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_NewArray): Added NPE check.
+       (JVM_NewMultiArray): Implemented, but needs review at a later point.
+       [dc9b6899f051]
+
+       * src/vmcore/loader.c:
+       * src/vmcore/loader.c (load_class_from_classbuffer): Renamed to
+       load_class_from_classbuffer_intern. (load_class_from_classbuffer):
+       New function.
+       [812cc24606bb]
+
+       * src/vmcore/loader.c, src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/vmcore/loader.c (load_class_from_classloader)
+       [WITH_CLASSPATH_SUN]: Call loadClassInternal.
+       * src/vmcore/utf8.c (utf_loadClassInternal): Added. (utf8_init):
+       Initialize utf_loadClassInternal.
+       * src/vmcore/utf8.h (utf_loadClassInternal): Added.
+       [7065d8389571]
+
+       * src/cacaoh/cacaoh.c, src/vm/primitive.h, src/vm/vm.c,
+       src/vmcore/linker.c, src/vmcore/linker.h, src/vmcore/loader.c,
+       src/vmcore/loader.h, src/vmcore/primitivecore.c:
+       * src/cacaoh/cacaoh.c (main): Added loader_preinit call.
+
+       * src/vm/primitive.h (primitive_init): Changed return type to void.
+       (primitive_postinit): New function.
+
+       * src/vm/vm.c (vm_create): Use new init functions.
+
+       * src/vmcore/linker.c (stdint.h): Added. (linker_preinit): New
+       function. (linker_init): Moved basic stuff into linker_preinit, call
+       vm_abort if error occurred.
+
+       * src/vmcore/linker.h (linker_preinit): New function. (linker_init):
+       Changed return type to void.
+
+       * src/vmcore/loader.c (loader_preinit): New function. (loader_init):
+       Moved basic stuff into loader_preinit, call vm_abort if error
+       occurred.
+
+       * src/vmcore/loader.h (loader_preinit): New function. (loader_init):
+       Changed return type to void.
+
+       * src/vmcore/primitivecore.c (vm/vm.h): Added. (primitive_init):
+       Load and link primitive-type classes and array-class ASAP, this is
+       important for annotations. (primitive_postinit): New function.
+       [b562aa714e92]
+
+2007-08-28  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vmcore/annotation.c:
+       * src/vmcore/annotation.c (stdint.h): Added.
+       [0dbc39d08b63]
+
+2007-08-28  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * src/vmcore/field.c, src/vmcore/method.c:
+       * src/vmcore/field.c (vm/array.h): Added include. (mm/memory.h):
+       Removed doubled include. (field_get_annotations): Added cast for
+       array_length_get()s parameter.
+
+       * src/vmcore/method.c (vm/array.h): Added include.
+       (method_get_annotations): Added cast for array_length_get()s
+       parameter. (method_get_parameterannotations): Added cast for
+       array_length_get()s parameter. (method_get_annotationdefault): Added
+       cast for array_length_get()s parameter.
+       [d6a85336983a]
+
+2007-08-27  Mathias Panzenboeck  <e0427417@student.tuwien.ac.at>
+
+       * src/vmcore/annotation.c, src/vmcore/annotation.h:
+       * src/vmcore/annotation.c (annotation_bytearrays_resize): Removed
+       unused variables.
+
+       * src/vmcore/annotation.h: Sorted includes. (vmcore/utf8.h): Removed
+       include.
+       [6aee3768a843]
+
+       * autogen.sh, src/cacaoh/dummy.c, src/mm/boehm-gc/autogen.sh,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/java_lang_Class.c, src/vmcore/annotation.c,
+       src/vmcore/annotation.h, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/field.c, src/vmcore/loader.c, src/vmcore/method.c,
+       src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * autogen.sh: Made executeable.
+
+       * src/cacaoh/dummy.c (mm/memory.h): Added include. (native/llni.h):
+       Added include. (array_objectarray_element_get): Added dummy
+       implementation. (array_objectarray_element_set): Added dummy
+       implementation. (array_length_get): Added dummy implementation.
+       (builtin_anewarray): Added dummy implementation using MNEW.
+       (builtin_newarray_byte): Added dummy implementation using MNEW.
+       (primitive_arrayclass_get_by_type): Added dummy implementation.
+
+       * src/mm/boehm-gc/autogen.sh: Made executeable.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (Java_java_lang_reflect_Constructor_declaredAnnotations): Removed
+       unused variable o.
+       (Java_java_lang_reflect_Constructor_getParameterAnnotations):
+       Removed unused variable o.
+
+       * src/native/vm/gnu/java_lang_reflect_Field.c
+       (Java_java_lang_reflect_Field_declaredAnnotations): Removed unused
+       variable o.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c
+       (Java_java_lang_reflect_Method_getDefaultValue): Removed unused
+       variable o. (Java_java_lang_reflect_Method_declaredAnnotations):
+       Removed unused variable o.
+       (Java_java_lang_reflect_Method_getParameterAnnotations): Removed
+       unused variable o.
+
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c
+       (_Jv_sun_reflect_ConstantPool_init): Removed usage of global string
+       utf_sun_reflect_ConstantPool.
+
+       * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS]: Sorted includes.
+       (_Jv_java_lang_Class_getDeclaredAnnotations): Fixed comment.
+
+       * src/vmcore/annotation.c (native/llni.h): Added include.
+       (vm/array.h): Added include. (vm/builtin.h): Added include.
+       (vm/primitive.h): Added include. (annotation_bytearray_new):
+       Removed. (annotation_bytearray_free): Removed.
+       (annotation_bytearrays_new): Removed. (annotation_bytearrays_free):
+       Removed. (annotation_bytearrays_resize): Made static and now
+       java_handle_objectarray_t is used instead of my own array type.
+       (annotation_bytearrays_insert): Made static and now
+       java_handle_objectarray_t is used instead of my own array type.
+       (annotation_load_attribute_body): Using java_handle_bytearray_t
+       instead of my own array type.
+       (annotation_load_method_attribute_annotationdefault): Using
+       java_handle_bytearray_t and java_handle_objectarray_t instead of my
+       own array types. (annotation_load_method_attribute_runtimevisiblepar
+       ameterannotations): Using java_handle_bytearray_t and
+       java_handle_objectarray_t instead of my own array types.
+       (annotation_load_method_attribute_runtimevisibleannotations): Using
+       java_handle_bytearray_t and java_handle_objectarray_t instead of my
+       own array types.
+       (annotation_load_field_attribute_runtimevisibleannotations): Using
+       java_handle_bytearray_t and java_handle_objectarray_t instead of my
+       own array types.
+
+       * src/vmcore/annotation.h (annotation_bytearray_t): Removed.
+       (annotation_bytearrays_t): Removed. (annotation_bytearray_new):
+       Removed. (annotation_bytearray_free): Removed.
+       (annotation_bytearrays_new): Removed.
+       (annotation_bytearrays_resize): Removed.
+       (annotation_bytearrays_insert): Removed.
+       (annotation_bytearrays_free): Removed.
+
+       * src/vmcore/class.c
+       (class_sun_reflect_annotation_AnnotationParser): Is only declared
+       when WITH_CLASSPATH_GNU is defined. (class_free)
+       [ENABLE_ANNOTATIONS]: Removed usage of annotation_bytearray*_free()
+       functions. (class_get_annotations): Don't have to copy anything now,
+       just return the java_handle_bytearray_t.
+
+       * src/vmcore/class.h (classinfo): Fixed comments. (classinfo)
+       [ENABLE_ANNOTATIONS]: Now using java_handle_bytearray_t and
+       java_handle_objectarray_t instead of my own array types.
+
+       * src/vmcore/loader.c (loader_init): Removed usage of global string
+       utf_sun_reflect_ConstantPool and
+       utf_sun_reflect_annotation_AnnotationParser.
+
+       * src/vmcore/field.c (vm/array.h): Added include.
+       (field_get_annotations): Don't have to copy anything now, just
+       return the java_handle_bytearray_t.
+
+       * src/vmcore/method.c (vm/array.h): Added include.
+       (method_get_annotations): Don't have to copy anything now, just
+       return the java_handle_bytearray_t.
+       (method_get_parameterannotations): Don't have to copy anything now,
+       just return the java_handle_bytearray_t.
+       (method_get_annotationdefault): Don't have to copy anything now,
+       just return the java_handle_bytearray_t.
+
+       * src/vmcore/utf8.c (utf_sun_reflect_ConstantPool): Removed.
+       (utf_sun_reflect_annotation_AnnotationParser): Removed.
+
+       * src/vmcore/utf8.h (utf_sun_reflect_ConstantPool): Removed.
+       (utf_sun_reflect_annotation_AnnotationParser): Removed.
+       [3e20268e098e]
+
+2007-08-27  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * src/vm/jit/show.c:
+       * src/vm/jit/show.c (show_icmd): ICMD_MULTIANEWARRAY: Print class
+       name.
+       [1d28f69443d0]
+
+       * Makefile.am, autogen.sh, configure.ac, contrib/Makefile.am,
+       contrib/log2xml.pl, doc/Makefile.am, doc/handbook/Makefile.am,
+       m4/annotations.m4, m4/cacaoh.m4, m4/java.m4, m4/jit.m4, m4/jni.m4,
+       m4/jre-layout.m4, m4/libjvm.m4, m4/ltdl.m4, m4/soft.m4,
+       m4/staticvm.m4, m4/threads.m4, m4/zlib.m4, man/Makefile.am,
+       src/Makefile.am, src/cacao/Makefile.am, src/cacao/cacao.c,
+       src/cacaoh/Makefile.am, src/cacaoh/cacaoh.c, src/cacaoh/dummy.c,
+       src/cacaoh/headers.c, src/cacaoh/headers.h, src/fdlibm/Makefile.am,
+       src/lib/Makefile.am, src/lib/gnu/java/lang/VMClassLoader.java,
+       src/mm/Makefile.am, src/mm/boehm-gc/autogen.sh, src/mm/boehm-
+       gc/callprocs, src/mm/boehm-gc/cord/de_win.ICO, src/mm/boehm-
+       gc/doc/README.arm.cross, src/mm/boehm-gc/win32_threads.c,
+       src/mm/boehm.c, src/mm/cacao-gc/Makefile.am, src/mm/cacao-
+       gc/compact.c, src/mm/cacao-gc/compact.h, src/mm/cacao-gc/gc.c,
+       src/mm/cacao-gc/gc.h, src/mm/cacao-gc/mark.c, src/mm/gc-common.h,
+       src/mm/memory.c, src/mm/memory.h, src/mm/nogc.c,
+       src/native/Makefile.am, src/native/include/Makefile.am,
+       src/native/jni.c, src/native/jni.h, src/native/jvmti/Makefile.am,
+       src/native/jvmti/cacaodbg.c, src/native/jvmti/cacaodbg.h,
+       src/native/jvmti/cacaodbgserver.c,
+       src/native/jvmti/cacaodbgserver.h, src/native/jvmti/dbg.h,
+       src/native/jvmti/jvmti.c, src/native/jvmti/jvmti.h,
+       src/native/llni.h, src/native/localref.c, src/native/localref.h,
+       src/native/native.c, src/native/native.h,
+       src/native/tools/Makefile.am, src/native/tools/gennativetable.c,
+       src/native/vm/Makefile.am, src/native/vm/cldc1.1/Makefile.am,
+       src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
+       src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Double.c,
+       src/native/vm/cldc1.1/java_lang_Float.c,
+       src/native/vm/cldc1.1/java_lang_Math.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_Runtime.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_System.c,
+       src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/cldc1.1/java_lang_Throwable.c,
+       src/native/vm/gnu/Makefile.am, src/native/vm/gnu/VMjdwp.c,
+       src/native/vm/gnu/VMjdwp.h,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c,
+       src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c, src/native/
+       vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/java_lang_reflect_VMProxy.c,
+       src/native/vm/gnu/java_security_VMAccessController.c,
+       src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_ClassLoader.h,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Object.h,
+       src/native/vm/java_lang_Runtime.c,
+       src/native/vm/java_lang_Runtime.h, src/native/vm/java_lang_Thread.c,
+       src/native/vm/java_lang_Thread.h,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.h,
+       src/native/vm/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_reflect_Method.h,
+       src/native/vm/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/java_util_concurrent_atomic_AtomicLong.h,
+       src/native/vm/nativevm.c, src/native/vm/nativevm.h,
+       src/native/vm/reflect.c, src/native/vm/reflect.h,
+       src/native/vm/sun/Makefile.am, src/native/vm/sun/jvm.c,
+       src/native/vm/sun_misc_Unsafe.c, src/scripts/Makefile.am,
+       src/scripts/java.in, src/threads/Makefile.am,
+       src/threads/critical.c, src/threads/critical.h, src/threads/lock-
+       common.h, src/threads/native/Makefile.am, src/threads/native
+       /generic-primitives.h, src/threads/native/lock.c,
+       src/threads/native/lock.h, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/none/Makefile.am,
+       src/threads/none/lock.h, src/threads/none/threads.h, src/threads
+       /threads-common.c, src/threads/threads-common.h,
+       src/toolbox/Makefile.am, src/toolbox/avl.c, src/toolbox/avl.h,
+       src/toolbox/bitvector.c, src/toolbox/bitvector.h,
+       src/toolbox/chain.c, src/toolbox/chain.h, src/toolbox/hashtable.c,
+       src/toolbox/hashtable.h, src/toolbox/list.c, src/toolbox/list.h,
+       src/toolbox/logging.c, src/toolbox/logging.h, src/toolbox/tree.c,
+       src/toolbox/tree.h, src/toolbox/util.c, src/toolbox/util.h,
+       src/toolbox/worklist.c, src/toolbox/worklist.h, src/vm/Makefile.am,
+       src/vm/access.c, src/vm/access.h, src/vm/array.c, src/vm/array.h,
+       src/vm/builtin.c, src/vm/builtin.h, src/vm/builtintable.inc, src/vm
+       /cycles-stats.c, src/vm/cycles-stats.h, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/finalizer.c, src/vm/finalizer.h,
+       src/vm/global.h, src/vm/initialize.c, src/vm/initialize.h,
+       src/vm/jit/Makefile.am, src/vm/jit/abi-asm.h, src/vm/jit/abi.h,
+       src/vm/jit/allocator/Makefile.am, src/vm/jit/allocator/liveness.c,
+       src/vm/jit/allocator/liveness.h, src/vm/jit/allocator/lsra.c,
+       src/vm/jit/allocator/lsra.h, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/allocator/simplereg.h, src/vm/jit/alpha/Makefile.am,
+       src/vm/jit/alpha/arch.h, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/codegen.h,
+       src/vm/jit/alpha/disass.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/alpha/freebsd/Makefile.am, src/vm/jit/alpha/freebsd/md-
+       os.c, src/vm/jit/alpha/linux/Makefile.am, src/vm/jit/alpha/linux/md-
+       os.c, src/vm/jit/alpha/md-abi.c, src/vm/jit/alpha/md-abi.h,
+       src/vm/jit/alpha/md-asm.h, src/vm/jit/alpha/md.c,
+       src/vm/jit/alpha/md.h, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/Makefile.am, src/vm/jit/arm/arch.h,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h, src/vm/jit/arm/disass.c,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/Makefile.am,
+       src/vm/jit/arm/linux/md-os.c, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/arm/md-abi.h, src/vm/jit/arm/md-asm.h,
+       src/vm/jit/arm/md.c, src/vm/jit/arm/patcher.c, src/vm/jit/asmpart.h,
+       src/vm/jit/cfg.c, src/vm/jit/cfg.h, src/vm/jit/code.c,
+       src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/codegen-
+       common.h, src/vm/jit/disass-common.c, src/vm/jit/disass.h,
+       src/vm/jit/dseg.c, src/vm/jit/dseg.h, src/vm/jit/emit-common.c,
+       src/vm/jit/emit-common.h, src/vm/jit/i386/Makefile.am,
+       src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h,
+       src/vm/jit/i386/cygwin/Makefile.am, src/vm/jit/i386/cygwin/md-asm.h,
+       src/vm/jit/i386/cygwin/md-os.c, src/vm/jit/i386/darwin/Makefile.am,
+       src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/i386/darwin/md-os.c,
+       src/vm/jit/i386/disass.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/emit.h, src/vm/jit/i386/freebsd/Makefile.am,
+       src/vm/jit/i386/freebsd/md-asm.h, src/vm/jit/i386/freebsd/md-os.c,
+       src/vm/jit/i386/linux/Makefile.am, src/vm/jit/i386/linux/md-asm.h,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md-abi.c,
+       src/vm/jit/i386/md-abi.h, src/vm/jit/i386/md.c,
+       src/vm/jit/i386/patcher.c, src/vm/jit/inline/Makefile.am,
+       src/vm/jit/inline/inline.c, src/vm/jit/inline/inline.h,
+       src/vm/jit/intrp/Makefile.am, src/vm/jit/intrp/asmpart.c,
+       src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/codegen.h,
+       src/vm/jit/intrp/disass.c, src/vm/jit/intrp/dynamic-super.c,
+       src/vm/jit/intrp/engine.c, src/vm/jit/intrp/engine1.c,
+       src/vm/jit/intrp/engine2.c, src/vm/jit/intrp/intrp.h,
+       src/vm/jit/intrp/md.c, src/vm/jit/intrp/patcher.c, src/vm/jit/intrp
+       /peephole-gen, src/vm/jit/intrp/vmgenx, src/vm/jit/jit.c,
+       src/vm/jit/jit.h, src/vm/jit/loop/Makefile.am,
+       src/vm/jit/loop/analyze.c, src/vm/jit/loop/analyze.h,
+       src/vm/jit/loop/graph.c, src/vm/jit/loop/graph.h,
+       src/vm/jit/loop/loop.c, src/vm/jit/loop/loop.h,
+       src/vm/jit/loop/tracing.c, src/vm/jit/loop/tracing.h,
+       src/vm/jit/m68k/Makefile.am, src/vm/jit/m68k/arch.h,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/disass.c,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/emit.h,
+       src/vm/jit/m68k/linux/Makefile.am, src/vm/jit/m68k/linux/md-abi.c,
+       src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/linux/md-os.h, src/vm/jit/m68k/machine-instr.h,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c, src/vm/jit/md.h,
+       src/vm/jit/methodheader.h, src/vm/jit/mips/Makefile.am,
+       src/vm/jit/mips/arch.h, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h,
+       src/vm/jit/mips/disass.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/irix/Makefile.am, src/vm/jit/mips/irix/md-os.c,
+       src/vm/jit/mips/linux/Makefile.am, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md-abi.h, src/vm/jit/mips
+       /md-asm.h, src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c,
+       src/vm/jit/mips/uclinux/Makefile.am, src/vm/jit/mips/uclinux/md-
+       os.c, src/vm/jit/optimizing/Makefile.am,
+       src/vm/jit/optimizing/dominators.c,
+       src/vm/jit/optimizing/dominators.h, src/vm/jit/optimizing/graph.c,
+       src/vm/jit/optimizing/graph.h, src/vm/jit/optimizing/ifconv.c,
+       src/vm/jit/optimizing/ifconv.h, src/vm/jit/optimizing/lifetimes.c,
+       src/vm/jit/optimizing/lifetimes.h, src/vm/jit/optimizing/lsra.c,
+       src/vm/jit/optimizing/lsra.h, src/vm/jit/optimizing/profile.c,
+       src/vm/jit/optimizing/profile.h, src/vm/jit/optimizing/recompile.c,
+       src/vm/jit/optimizing/recompile.h, src/vm/jit/optimizing/reorder.c,
+       src/vm/jit/optimizing/reorder.h, src/vm/jit/optimizing/ssa.c,
+       src/vm/jit/optimizing/ssa.h, src/vm/jit/parisc/Makefile.am,
+       src/vm/jit/parisc/arch.h, src/vm/jit/parisc/linux/Makefile.am,
+       src/vm/jit/parisc/md-abi.h, src/vm/jit/parisc/md.c,
+       src/vm/jit/parse.c, src/vm/jit/parse.h, src/vm/jit/patcher-common.c,
+       src/vm/jit/patcher-common.h, src/vm/jit/patcher.h,
+       src/vm/jit/powerpc/Makefile.am, src/vm/jit/powerpc/arch.h,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/codegen.h, src/vm/jit/powerpc/darwin/Makefile.am,
+       src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md-
+       abi.h, src/vm/jit/powerpc/darwin/md-asm.h, src/vm/jit/powerpc/darwin
+       /md-os.c, src/vm/jit/powerpc/disass.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/Makefile.am, src/vm/jit/powerpc/linux/md-
+       abi.c, src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/powerpc/linux
+       /md-asm.h, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/netbsd/Makefile.am,
+       src/vm/jit/powerpc/netbsd/md-abi.c, src/vm/jit/powerpc/netbsd/md-
+       abi.h, src/vm/jit/powerpc/netbsd/md-asm.h, src/vm/jit/powerpc/netbsd
+       /md-os.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/Makefile.am, src/vm/jit/powerpc64/arch.h,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/codegen.h, src/vm/jit/powerpc64/disass.c,
+       src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/Makefile.am,
+       src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/linux/md-
+       abi.h, src/vm/jit/powerpc64/linux/md-asm.h,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/reg.c, src/vm/jit/reg.h,
+       src/vm/jit/replace.c, src/vm/jit/replace.h,
+       src/vm/jit/s390/Makefile.am, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/disass.c,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md-
+       abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390/md-asm.h,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/schedule/Makefile.am, src/vm/jit/schedule/schedule.c,
+       src/vm/jit/schedule/schedule.h, src/vm/jit/show.c,
+       src/vm/jit/show.h, src/vm/jit/sparc64/Makefile.am,
+       src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/disass.c, src/vm/jit/sparc64/emit-arch.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/emit.h,
+       src/vm/jit/sparc64/linux/Makefile.am, src/vm/jit/sparc64/linux/md-
+       os.c, src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h,
+       src/vm/jit/sparc64/md-asm.h, src/vm/jit/sparc64/md.c,
+       src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/sparc64/solaris/Makefile.am, src/vm/jit/sparc64/solaris
+       /md-os.c, src/vm/jit/stack.c, src/vm/jit/stack.h,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h,
+       src/vm/jit/trace.c, src/vm/jit/trace.h,
+       src/vm/jit/verify/Makefile.am, src/vm/jit/verify/generate.pl,
+       src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-builtins.inc,
+       src/vm/jit/verify/typecheck-common.c, src/vm/jit/verify/typecheck-
+       common.h, src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/verify
+       /typecheck-invoke.inc, src/vm/jit/verify/typecheck-
+       multianewarray.inc, src/vm/jit/verify/typecheck-stackbased.c,
+       src/vm/jit/verify/typecheck-typeinferer.c, src/vm/jit/verify
+       /typecheck-typeinferer.h, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typecheck.h, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/verify/typeinfo.h, src/vm/jit/x86_64/Makefile.am,
+       src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h,
+       src/vm/jit/x86_64/disass.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/emit.h, src/vm/jit/x86_64/freebsd/Makefile.am,
+       src/vm/jit/x86_64/freebsd/md-os.c,
+       src/vm/jit/x86_64/linux/Makefile.am, src/vm/jit/x86_64/linux/md-
+       os.c, src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/md-abi.h,
+       src/vm/jit/x86_64/md-asm.h, src/vm/jit/x86_64/md.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/jit_interface.h,
+       src/vm/primitive.c, src/vm/primitive.h, src/vm/properties.c,
+       src/vm/properties.h, src/vm/resolve.c, src/vm/resolve.h,
+       src/vm/signal.c, src/vm/signallocal.h, src/vm/string.c,
+       src/vm/stringlocal.h, src/vm/types.h, src/vm/vm.c, src/vm/vm.h,
+       src/vmcore/Makefile.am, src/vmcore/annotation.c, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/classcache.c,
+       src/vmcore/classcache.h, src/vmcore/descriptor.c,
+       src/vmcore/descriptor.h, src/vmcore/field.c, src/vmcore/field.h,
+       src/vmcore/linker.c, src/vmcore/linker.h, src/vmcore/loader.c,
+       src/vmcore/loader.h, src/vmcore/method.c, src/vmcore/method.h,
+       src/vmcore/options.c, src/vmcore/options.h,
+       src/vmcore/primitivecore.c, src/vmcore/references.h, src/vmcore/rt-
+       timing.c, src/vmcore/rt-timing.h, src/vmcore/stackmap.c,
+       src/vmcore/stackmap.h, src/vmcore/statistics.c,
+       src/vmcore/statistics.h, src/vmcore/suck.c, src/vmcore/suck.h,
+       src/vmcore/utf8.c, src/vmcore/utf8.h, src/vmcore/zip.c,
+       src/vmcore/zip.h, tests/Makefile.am, tests/regression/Makefile.am,
+       tests/regression/MinimalClassReflection.java,
+       tests/regression/TestAnnotations.java,
+       tests/regression/codepatching/Makefile.am,
+       tests/regression/fptest.java, tests/regression/jasmin/Makefile.am,
+       tests/regression/jasmin/runtest, tests/regression/jasmin/show,
+       tests/regression/jctest.java, tests/regression/native/Makefile.am,
+       tests/regression/native/checkjni.c,
+       tests/regression/native/checkjni.java,
+       tests/regression/native/test.c, tests/regression/native/test.java,
+       tests/regression/native/testarguments.c,
+       tests/regression/native/testarguments.java,
+       tests/regression/native/testgetobjectclass0.c,
+       tests/regression/native/testgetobjectclass0.java,
+       tests/regression/resolving/Makefile.am,
+       tests/regression/resolving/classes1/Makefile.am,
+       tests/regression/resolving/classes2/Makefile.am,
+       tests/regression/resolving/classes3/Makefile.am:
+       * Removed all Id tags.
+       [777633d18b4c]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_printconfig): Better and correct output.
+       [660822b1af20]
+
+       * .hgignore:
+       * Added *~.
+       [c8678806a55c]
+
+2007-08-25  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * .hgignore:
+       * .hgignore: New file.
+       [42382aa1e7b5]
+
+2007-08-22  twisti  <twisti>
+
+       * src/vm/vm.c, src/vmcore/suck.c:
+       * src/vm/vm.c (vm_create) [ENABLE_JAVASE]: Removed #ifdef for
+       setting sun.boot.class.path and java.boot.class.path.
+       * src/vmcore/suck.c (suck_add_from_property): Likewise.
+       [69da96539daa]
+
+       * src/vm/properties.c, src/vm/vm.c, src/vmcore/suck.c:
+       * src/vm/vm.c (vm_create): Free properties after they have been
+       replaced.
+       * src/vmcore/suck.c (suck_add_from_property): Likewise.
+
+       * src/vm/properties.c (properties_set): Smaller changes.
+       [c92f5716cba2]
+
+       * src/threads/native/threads.c, src/vm/properties.c:
+       * src/vm/properties.c (properties_set): Fixed build for CLDC-1.1,
+       removed getenv of JAVA_HOME.
+
+       * src/threads/native/threads.c (threads_detach_thread): Fixed build
+       for CLDC-1.1.
+       [b8e9f732a292]
+
+       * src/native/vm/nativevm.c, src/vm/properties.c, src/vm/vm.c:
+       * src/vm/vm.c [WITH_JRE_LAYOUT] (libgen.h, unistd.h): Removed.
+
+       * src/vm/properties.c (errno.h): Added. [WITH_JRE_LAYOUT]
+       (libgen.h): Likewise. (properties_set) [WITH_CLASSPATH_SUN]: Set
+       sun.boot.library.path property.
+
+       * src/native/vm/nativevm.c (vm/properties.h): Added.
+       (nativevm_preinit) [WITH_CLASSPATH_SUN]: Use properties_get to get
+       sun.boot.library.path.
+       [a764c454c91c]
+
+2007-08-22  pm  <pm>
+
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c:
+       * src/vm/jit/s390/codegen.h: Cleanup.
+       * src/vm/jit/s390/codegen.c (codegen_emit): Tryed to improove ACONST.
+       * src/vm/jit/s390/emit.c (emit_copy): Use MVC (memcpy instruction) for
+       memory to memory copy.
+       [870ff292761c]
+
+2007-08-22  twisti  <twisti>
+
+       * src/vm/properties.c, src/vm/properties.h, src/vm/vm.c, src/vm/vm.h,
+       src/vmcore/suck.c:
+       * src/vm/properties.c (list_properties_entry): Renamed to
+       list_properties_entry_t. (properties_init): Only initialize the
+       list. (properties_set): New function to set default properties
+       (don't use JAVA_HOME to set java.home).
+
+       * src/vm/properties.h (vm/types.h): Removed. (stdint.h): Added.
+       (properties_init): Changed signature. (properties_set): New
+       function.
+
+       * src/vm/vm.c (cacao_prefix): Removed. (cacao_libjvm): Likewise.
+       (classpath_libdir): Likewise. (_Jv_bootclasspath): Likewise.
+       (_Jv_classpath): Likewise. (_Jv_java_library_path): Likewise.
+       (specificmethodname): Likewise. (specificsignature): Likewise.
+       (startit): Likewise. (vm_printconfig): Use properties_get to get
+       properties. (vm_create): Moved properties stuff into properties_set.
+
+       * src/vm/vm.h (cacao_prefix): Removed. (cacao_libjvm): Likewise.
+       (classpath_libdir): Likewise. (_Jv_bootclasspath): Likewise.
+       (_Jv_classpath): Likewise. (_Jv_java_library_path): Likewise.
+
+       * src/vmcore/suck.c (suck_add_from_property): Use properties_get to
+       manipulate bootclasspath.
+       [b0bc14174f72]
+
+       * m4/classpath.m4:
+       * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Fixed typo.
+       [232c19c34670]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (native/include/java_lang_Byte.h,
+       native/include/java_lang_Character.h,
+       native/include/java_lang_Short.h,
+       native/include/java_lang_Integer.h,
+       native/include/java_lang_Boolean.h, native/include/java_lang_Long.h,
+       native/include/java_lang_Float.h,
+       native/include/java_lang_Double.h): Removed.
+       [aab3d93b5630]
+
+       * configure.ac:
+       * configure.ac (AC_CHECK_HEADERS): Added libgen.h. (AC_CHECK_FUNCS):
+       Added dirname, readlink.
+       [0cbbe3bcc3cd]
+
+2007-08-22  panzi  <panzi>
+
+       * src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c,
+       src/vmcore/class.c, src/vmcore/class.h:
+       * src/vmcore/class.h (class_get_annotations): Added. This function
+       encapsulates the access to the annotations field of the classinfo
+       struct. It is defined even if ENABLE_ANNOTATIONS is not, but just
+       returns NULL in that case.
+
+       * src/vmcore/class.c (class_get_annotations): Added.
+
+       * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getDeclaredAnnotations): Now uses
+       class_get_annotations().
+
+       * src/native/vm/sun/jvm.c (JVM_GetClassAnnotations): Now uses
+       class_get_annotations().
+       [ae07ae0272eb]
+
+       * m4/annotations.m4:
+       * m4/annotations.m4: Fixed comment.
+       [38e9d135d38d]
+
+       * src/lib/gnu/java/lang/reflect/Constructor.java,
+       src/lib/gnu/java/lang/reflect/Field.java,
+       src/lib/gnu/java/lang/reflect/Method.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/reflect.c, src/native/vm/sun/jvm.c,
+       src/vmcore/annotation.h, src/vmcore/class.h:
+       * src/lib/gnu/java/lang/reflect/Method.java (declaredAnnotations):
+       Added generic type parameters to Class.
+
+       * src/lib/gnu/java/lang/reflect/Field.java (declaredAnnotations):
+       Added generic type parameters to Class.
+
+       * src/lib/gnu/java/lang/reflect/Constructor.java
+       (declaredAnnotations): Added generic type parameters to Class.
+
+       * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java: Fixed
+       formatting.
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c
+       (Java_sun_reflect_ConstantPool_getMemberRefInfoAt0): Fixed
+       formatting of log output.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c
+       (Java_java_lang_reflect_Method_getDefaultValue),
+       (Java_java_lang_reflect_Method_declaredAnnotations),
+       (Java_java_lang_reflect_Method_getParameterAnnotations): Use
+       LLNI_class_get macro.
+
+       * src/native/vm/gnu/java_lang_reflect_Field.c
+       (Java_java_lang_reflect_Method_declaredAnnotations): Use
+       LLNI_class_get macro.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (Java_java_lang_reflect_Method_declaredAnnotations),
+       (Java_java_lang_reflect_Method_getParameterAnnotations): Use
+       LLNI_class_get macro.
+
+       * src/native/vm/sun/jvm.c (JVM_GetClassConstantPool): Fixed
+       formatting of log output.
+
+       * src/native/vm/reflect.c (reflect_get_declaredannotatios): Fixed
+       comment.
+
+       * src/vmcore/class.h (classinfo): Added comments for annottation
+       fields.
+
+       * src/vmcore/annotation.h (annotation_t), (element_value_t): Removed
+       unused structs.
+       [81a831b87f1b]
+
+2007-08-21  michi  <michi>
+
+       * src/mm/cacao-gc/gc.c:
+       * src/mm/cacao-gc/gc.c (gc_init) [ENABLE_HANDLES]: Added offset
+       check for global reference entries.
+       [759632de7c01]
+
+       * src/native/jni.c, src/native/localref.c, src/native/localref.h:
+       * src/native/jni.c (_Jv_JNI_DeleteLocalRef): Moved code to
+       localref_del.
+
+       * src/native/localref.c (localref_add): Minor code cleanup.
+       (localref_del): Moved from jni.c and adapted to work with handles.
+
+       * src/native/localref.h (localref_del): Minor signature change.
+       [356dbd0bd1d9]
+
+       * src/native/jni.c:
+       * src/native/jni.c: Used LLNI_classinfo_wrap to return classes.
+       (_Jv_JNI_IsSameObject): Fixed implementation for handles.
+       (_Jv_JNI_NewLocalRef): Likewise. (_Jv_JNI_SetObjectArrayElement):
+       Use builtin_canstore correctly. (_Jv_JNI_NewGlobalRef): Correct
+       implementation for handles. (_Jv_JNI_DeleteGlobalRef): Likewise.
+       [5efc6830b6ab]
+
+2007-08-21  twisti  <twisti>
+
+       * src/vm/properties.c:
+       * src/vm/properties.c (properties_init): Moved setting java.home
+       into WITH_CLASSPATH_GNU, otherwise it's done twice for
+       WITH_CLASSPATH_SUN.
+       [46d825b9cb5f]
+
+2007-08-21  michi  <michi>
+
+       * src/native/jni.c, src/vm/access.c:
+       * src/native/jni.c: Fixed LLNI macro usage.
+       [1293d58652ab]
+
+2007-08-21  twisti  <twisti>
+
+       * src/native/jni.c, src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c,
+       src/vmcore/class.c, src/vmcore/class.h:
+       * src/vmcore/class.c (class_define): Added protection domain to
+       signature. (class_resolve_superclass): Some changes (not yet
+       correct). (class_issubclass): Added assert to see if super is
+       resolved.
+
+       * src/vmcore/class.h (classinfo) [ENABLE_JAVASE &&
+       WITH_CLASSPATH_SUN]: Added protectiondomain.
+
+       * src/native/jni.c (_Jv_JNI_DefineClass): Pass protection domain to
+       class_define.
+       * src/native/vm/java_lang_ClassLoader.c (defineClass): Likewise.
+
+       * src/native/vm/sun_misc_Unsafe.c (unistd.h): Added. (vm/builtin.h):
+       Likewise. (putShort__Ljava_lang_Object_2JS): Implemented.
+       (putFloat__Ljava_lang_Object_2JF): Likewise (putInt__JI): Likewise
+       (pageSize): Likewise (allocateInstance): Likewise (getLongVolatile):
+       Likewise (defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoade
+       r_2Ljava_security_ProtectionDomain_2): Pass protection domain to
+       class_define.
+
+       * src/native/vm/sun/jvm.c (threads/threads-common.h): Added.
+       (vm/signallocal.h): Likewise. (PRINTJVMWARNINGS): New macro (not
+       enabled yet). (JVM_MaxMemory): Implemented. (JVM_EnableCompiler):
+       Likewise. (JVM_DisableCompiler): Likewise. (JVM_ResolveClass):
+       Likewise. (JVM_GetClassSignature): Likewise. (JVM_Yield): Likewise.
+       (JVM_GetThreadStateValues): Likewise. (JVM_GetThreadStateNames):
+       Likewise. (JVM_RegisterSignal): Likewise. (JVM_FindSignal):
+       Likewise. (JVM_DefineClassWithSource): Pass protection domain to
+       class_define. (JVM_DesiredAssertionStatus): Return false for now.
+       (JVM_Available): Only ioctl is a correct implementation.
+       [2f9138ad6203]
+
+       * src/vm/access.c:
+       * src/vm/access.c (access_is_accessible_class) [WITH_CLASSPATH_SUN]:
+       Check for referer, not cls. (access_is_accessible_member)
+       [WITH_CLASSPATH_SUN]: Check for referer, not declarer.
+       [ea54fff4a82a]
+
+       * src/native/vm/java_lang_Object.c:
+       * src/native/vm/java_lang_Object.c (wait): Check for ms < 0.
+       [e1591b347c35]
+
+2007-08-21  panzi  <panzi>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_GetArrayLength): Now using function
+       array_length_get(). (JVM_GetArrayElement): Now using function
+       array_element_get(). (JVM_SetArrayElement): Implemented by using
+       function array_element_set().
+       [debb26635ceb]
+
+2007-08-21  twisti  <twisti>
+
+       * src/vm/array.c, src/vm/array.h:
+       * src/vm/array.c (vm/exceptions.h): Added. (vm/primitive.h):
+       Likewise. (array_element_get): New function. (array_element_set):
+       Likewise. (array_element_primitive_get): Cast to specific array-
+       type. (array_element_primitive_set): New function.
+       (ARRAY_TYPEARRAY_ELEMENT_GET): Added NPE and AIOOBE checks.
+       (ARRAY_TYPEARRAY_ELEMENT_SET): New macro. (array_length_get): New
+       function.
+
+       * src/vm/array.h (array_element_get): New function.
+       (array_element_set): Likewise. (array_booleanarray_element_get,
+       array_bytearray_element_get, array_chararray_element_get,
+       array_shortarray_element_get, array_intarray_element_get,
+       array_longarray_element_get, array_floatarray_element_get,
+       array_doublearray_element_get, array_objectarray_element_get):
+       Changed signature. (array_booleanarray_element_set,
+       array_bytearray_element_set, array_chararray_element_set,
+       array_shortarray_element_set, array_intarray_element_set,
+       array_longarray_element_set, array_floatarray_element_set,
+       array_doublearray_element_set, array_objectarray_element_set): New
+       function. (array_length_get): Likewise.
+       [49c86ae5ddb0]
+
+       * src/vm/properties.c:
+       * src/vm/properties.c (properties_init) [WITH_CLASSPATH_SUN]:
+       Removed debug output.
+       [e229dd128d49]
+
+       * configure.ac, src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/vm/properties.c:
+       * configure.ac (AC_CHECK_FUNCS): Added access.
+       * src/vm/properties.c (unistd.h): Added. (properties_init)
+       [WITH_CLASSPATH_SUN]: Find correct java.home.
+       [927d02909913]
+
+2007-08-21  michi  <michi>
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_Thread.c, src/vm/primitive.c,
+       src/vm/properties.c:
+       * src/vm/properties.c (properties_system_add): Use LLNI macros.
+       (properties_system_add_all): Likewise.
+
+       * src/vm/primitive.c (primitive_unbox): Likewise.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c: Fixed
+       assertion.
+
+       * src/native/vm/java_lang_Thread.c: Fixed LLNI macro usage.
+       [11f7b49dda5d]
+
+2007-08-21  panzi  <panzi>
+
+       * THIRDPARTY:
+       * THIRDPARTY (src/lib/gnu/sun/reflect/ConstantPool.java),
+       (src/lib/gnu/sun/reflect/annotation/AnnotationParser.java),
+       (src/lib/gnu/sun/reflect/annotation/AnnotationType.java), (src/lib/g
+       nu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java)
+       , (src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.j
+       ava): These files are licensed by sun under the GPLv2.
+       [8073f3ac70ea]
+
+2007-08-21  twisti  <twisti>
+
+       * src/native/vm/nativevm.c:
+       * src/native/vm/nativevm.c [WITH_CLASSPATH_SUN] (string.h): Added.
+       [WITH_CLASSPATH_SUN] (mm/memory.h): Likewise. (nativevm_preinit)
+       [WITH_CLASSPATH_SUN]: Use classpath_libdir variable instead of
+       CLASSPATH_LIBDIR. This is correct for WITH_JRE_LAYOUT.
+       [44950c9ac1f3]
+
+2007-08-21  michi  <michi>
+
+       * m4/classpath.m4, src/cacaoh/headers.c:
+       * src/cacaoh/headers.c (HEAP_PREFIX): Added define. (printtype):
+       Added arguments prefix and infix. (printfields): Pass correct prefix
+       for reference types. (printmethod): Pass correct infix for array
+       types. (headerfile_generate): Print correct prefix for heap object.
+       (headerfile_generate) [ENABLE_HANDLES]: Also create struct typedef
+       for handle.
+       [1cde84324121]
+
+2007-08-21  twisti  <twisti>
+
+       * m4/classpath.m4:
+       * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_LIBDIR): Set
+       CLASSPATH_LIBDIR correctly for OpenJDK.
+       [f59871a923da]
+
+       * configure.ac, m4/staticvm.m4:
+       * configure.ac (AC_CHECK_ENABLE_STATICVM): Added.
+       * m4/staticvm.m4: New file.
+       [575b17df5444]
+
+2007-08-21  michi  <michi>
+
+       * src/cacaoh/dummy.c, src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h,
+       src/mm/cacao-gc/rootset.c, src/mm/cacao-gc/rootset.h, src/mm/gc-
+       common.h, src/native/jni.c, src/threads/native/threads.c,
+       src/threads/threads-common.c, src/vmcore/loader.c:
+       * src/mm/cacao-gc/gc.h (list_gcref_entry_t): Renamed type to
+       reftype. [!ENABLE_HANDLES]: Added development break.
+
+       * src/mm/cacao-gc/gc.c (gc_reference_register): Added reftype to
+       arguments.
+
+       * src/mm/gc-common.h: Added reftype defines.
+       * src/mm/cacao-gc/rootset.h: Removed reftype defines.
+
+       * src/mm/cacao-gc/rootset.c: Adapted to changes.
+
+       * src/vmcore/loader.c (loader_hashtable_classloader_add): Pass
+       reftype to GC.
+       * src/native/jni.c (_Jv_JNI_NewGlobalRef): Likewise.
+       * src/threads/native/threads.c (threads_init): Likewise.
+       * src/threads/threads-common.c (threads_thread_new): Likewise.
+       (threads_thread_print_info) [WITH_CLASSPATH_GNU]: Fixed thread name
+       printing.
+
+       * src/cacaoh/dummy.c (gc_reference_register): Adapted dummy function
+       to new sig.
+       [3c38a2ccdc4f]
+
+2007-08-20  twisti  <twisti>
+
+       * m4/jre-layout.m4:
+       * m4/jre-layout.m4: Set Id keyword.
+       [187bc2030109]
+
+       * configure.ac, m4/jre-layout.m4:
+       * configure.ac (AC_CHECK_WITH_JRE_LAYOUT): Added.
+       * m4/jre-layout.m4: New file.
+       [29b158e22fc7]
+
+2007-08-20  michi  <michi>
+
+       * src/mm/boehm.c, src/vm/jit/replace.h:
+       * src/mm/boehm.c (heap_alloc_uncollectable): Fixed typo.
+       * src/vm/jit/replace.h [!ENABLE_REPLACEMENT]: Added missing defines.
+       [95bd9c1f25ad]
+
+2007-08-20  twisti  <twisti>
+
+       * src/native/llni.h, src/vm/signal.c:
+       * src/vm/signal.c (signal_thread): Removed debug output.
+       (signal_thread_handler): Likewise.
+       [1cb05b99b528]
+
+2007-08-20  michi  <michi>
+
+       * src/vmcore/loader.c:
+       * src/vmcore/loader.c: Fixed typos, LLNI_direct is called
+       LLNI_DIRECT.
+       [0def6a684fde]
+
+       * src/cacaoh/dummy.c, src/native/Makefile.am, src/native/llni.c,
+       src/native/llni.h, src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/native/Makefile.am: Added llni.c.
+
+       * src/native/llni.c: Added new file. (llni_critical_start,
+       llni_critical_end): Implemented.
+
+       * src/native/llni.h: Major cleanup of LLNI macros
+       (LLNI_CRITICAL_START, LLNI_CRITICAL_END): Added.
+
+       * src/cacaoh/dummy.c (llni_critical_start, llni_critical_end): Added
+       dummies.
+       [af75957ea4fa]
+
+2007-08-20  twisti  <twisti>
+
+       * src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/vmcore/utf8.c (utf_uncaughtException): Added.
+       (utf_java_lang_Thread_java_lang_Throwable__V): Likewise.
+       (utf8_init): Initialize new variables.
+       * src/vmcore/utf8.h: Likewise.
+       [3ab11f4e0235]
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_init) [WITH_CLASSPATH_SUN]:
+       Added code to initialize the thread. (threads_startup_thread):
+       Ignore the return value of threads_detach_thread.
+       (threads_detach_thread) [ENABLE_JAVASE]: Implemented
+       UncaughtExceptionHandler stuff.
+       [65df7c9c179f]
+
+2007-08-20  michi  <michi>
+
+       * src/native/localref.c:
+       * src/native/localref.c (localref_add): Disabled debug output.
+       [97af6afc71f6]
+
+       * src/native/jni.c, src/native/localref.c, src/native/localref.h:
+       * src/native/localref.c (localref_add): Implemented (moved parts
+       from jni.c). [!NDEBUG] (localref_dump): Improved debug output.
+
+       * src/native/localref.h: Added prototypes.
+
+       * src/native/jni.c (_Jv_JNI_NewLocalRef): Now uses localref_add.
+       [e792a0c22d3d]
+
+       * src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/java_lang_Class.c:
+       * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getClassLoader) [ENABLE_HANDLES]: Fixed
+       implementation.
+
+       * src/native/vm/gnu/java_lang_VMSystem.c
+       (Java_java_lang_VMSystem_identityHashCode) [ENABLE_GC_CACAO]:
+       Likewise.
+       [3d0ca306dc19]
+
+       * src/native/jni.c, src/native/localref.c, src/native/localref.h,
+       src/vm/vm.c:
+       * src/native/localref.c (localref_table_destroy): Added (moved from
+       jni.c). Improved documentation.
+
+       * src/native/localref.h: Likewise.
+
+       * src/native/jni.c (jni_free_localref_table): Removed.
+
+       * src/vm/vm.c (vm_createjvm): Added comment about localreftable.
+       [329d0c1a2734]
+
+       * src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_builtin): Fixed bug
+       in stackframesize calculation.
+       [d759d431071b]
+
+       * src/cacaoh/dummy.c, src/mm/cacao-gc/heap.h,
+       src/threads/native/threads.c, src/threads/threads-common.c,
+       src/vm/builtin.c, src/vm/builtin.h, src/vm/signal.c:
+       * src/vm/signal.c (signal_init): Use signal_register_signal to
+       register SIGUSR1.
+
+       * src/vm/builtin.c: Adapted to changes on trunk.
+       * src/vm/builtin.h: Likewise.
+       * src/mm/cacao-gc/heap.h: Likewise.
+       * src/threads/threads-common.c: Likewise.
+       * src/threads/native/threads.c: Likewise.
+       * src/cacaoh/dummy.c: Likewise.
+       [173e158ebcbc]
+
+       * configure.ac, src/mm/cacao-gc/gc.c, src/vm/global.h,
+       src/vmcore/loader.c:
+       * configure.ac: Checks for --enable-handles and sets define
+       accordingly.
+
+       * src/vm/global.h (java_handle_t): Changed ifdef to use
+       ENABLE_HANDLES.
+
+       * src/vmcore/loader.c (load_class_from_classloader): Likewise
+
+       * src/mm/cacao-gc/gc.c (gc_init) [ENABLE_HANDLES]: Ifdefed offset
+       check of indirection cells.
+       [78bdf2b86dea]
+
+       * configure.ac, src/Makefile.am, src/lib/Makefile.am,
+       src/native/include/Makefile.am,
+       src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/java_lang_String.c, src/native/vm/java_lang_String.h,
+       src/threads/threads-common.h, src/vm/builtin.c,
+       src/vm/builtintable.inc, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, src/vm/jit/trace.c,
+       src/vm/jit/trace.h, src/vm/properties.c, src/vm/stringlocal.h,
+       src/vmcore/zip.c:
+       * src/vm/builtin.c (builtintable_init): Create builtin stubs for
+       builtintable_function as well.
+
+       * src/vm/builtintable.inc (builtintable_function): Create stubs for
+       arraycopy.
+       [2120e8901106]
+
+2007-08-19  twisti  <twisti>
+
+       * src/native/vm/Makefile.am, src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_String.c,
+       src/native/vm/java_lang_String.h, src/native/vm/reflect.c,
+       src/native/vm/sun/jvm.c, src/vm/string.c, src/vm/stringlocal.h:
+       * src/vm/string.c (javastring_intern): New function.
+       (javastring_print): Likewise.
+       * src/vm/stringlocal.h
+
+       * src/native/vm/java_lang_String.c: Removed.
+       * src/native/vm/java_lang_String.h: Likewise.
+
+       * src/native/vm/cldc1.1/java_lang_String.c (intern): Use
+       javastring_intern.
+
+       * src/native/vm/java_lang_Class.c (native/vm/java_lang_String.h):
+       Removed.
+
+       * src/native/vm/gnu/java_lang_VMString.c
+       (native/vm/java_lang_String.h): Removed. (intern): Use
+       javastring_intern.
+
+       * src/native/vm/sun/jvm.c (native/vm/java_lang_String.h): Removed.
+       (JVM_GetSystemPackage): Added debug output.
+
+       * src/native/vm/reflect.c (native/vm/java_lang_String.h): Removed.
+       (reflect_field_new): Use javastring_intern. (reflect_method_new):
+       Likewise.
+
+       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Removed
+       java_lang_String.[ch].
+       [92115007d820]
+
+       * src/threads/threads-common.h:
+       * src/threads/threads-common.h (THREAD_STATE_*): Changed to be
+       compatible with OpenJDK (range 1-6).
+       [c0232448e92f]
+
+       * src/vm/signal.c, src/vm/signallocal.h:
+       * src/vm/signal.c (signal_init) [!WITH_CLASSPATH_SUN]: Only block
+       SIGINT for non-Sun configurations. (signal_thread): Use
+       signal_thread_handler. (signal_thread_handler): New function.
+
+       * src/vm/signallocal.h (signal_thread_handler): New function.
+       [35c1b5347341]
+
+       * src/vm/primitive.c:
+       * src/vm/primitive.c (primitive_box): Handle PRIMITIVETYPE_VOID
+       type. (primitive_unbox): Likewise.
+       [076fc6bc3012]
+
+2007-08-19  pm  <pm>
+
+       * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/emit.c:
+       * src/vm/jit/s390/asmpart.S: Made all function calls PIC (see bug
+       41), general cleanup.
+       * src/vm/jit/s390/emit.c (emit_verbosecall_enter): Save and restore
+       temporary registers for leaf methods.
+       [0ab89839950f]
+
+2007-08-19  twisti  <twisti>
+
+       * configure.ac, src/vm/properties.c, src/vm/vm.c:
+       * configure.ac (JAVA_ARCH): Added.
+
+       * src/vm/vm.c (opts): Added Xverify:none (should be handled better).
+       (vm_create) [WITH_JRE_LAYOUT && WITH_CLASSPATH_SUN]: Implemented.
+
+       * src/vm/properties.c (properties_init) [WITH_CLASSPATH_GNU]: Use
+       JAVA_ARCH.
+       [1e132391622d]
+
+       * src/vmcore/linker.c:
+       * src/vmcore/linker.c (link_class): Check for CLASS_LINKING.
+       (link_class_intern): Removed CLASS_LINKED check, but added an
+       assert.
+       [986a66aea815]
+
+2007-08-19  panzi  <panzi>
+
+       * src/native/vm/sun/jvm.c, tests/regression/Makefile.am,
+       tests/regression/TestAnnotations.java,
+       tests/regression/TestAnnotations.output:
+       * src/native/vm/sun/jvm.c (JVM_GetArrayElement): Using
+       array_xxxarray_element_get functions now.
+
+       * tests/regression/TestAnnotations.output: Added.
+
+       * tests/regression/Makefile.am (SOURCE_FILES): Added
+       TestAnnotations.java. (EXTRA_DIST): Added TestAnnotations.output.
+       (OUTPUT_JAVA_TESTS): Added TestAnnotations.
+
+       * tests/regression/TestAnnotations.java: Added detailed test cases
+       for annotations support.
+       [23f039edde88]
+
+2007-08-19  pm  <pm>
+
+       * src/vm/builtin.c, src/vm/jit/s390/md.c, src/vm/jit/trace.c,
+       src/vm/jit/trace.h:
+       * vm/builtin.c (builtin_trace_exception) [__s390__]: Decrement
+       TRACEJAVACALLINDENT instead of methodindent.
+       * vm/jit/trace.h: Adapted file to coding conventions.
+       * vm/jit/trace.c: Likewise.
+       * vm/jit/s390/md.c (md_dump_context) Fixed printing of java method at
+       failing address, (md_signal_handler_sigsegv) added missing default
+       branch to switch.
+       [512e17a366d4]
+
+2007-08-18  twisti  <twisti>
+
+       * src/Makefile.am, src/lib/Makefile.am,
+       src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java,
+       src/native/include/Makefile.am,
+       src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_System.c, src/vmcore/zip.c,
+       src/vmcore/zip.h:
+       * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c
+       (zip_read_resource, file_read_resource,
+       Java_com_sun_cldc_io_ResourceInputStream_open,
+       Java_com_sun_cldc_io_ResourceInputStream_bytesRemain,
+       Java_com_sun_cldc_io_ResourceInputStream_readByte,
+       Java_com_sun_cldc_io_ResourceInputStream_readBytes,
+       Java_com_sun_cldc_io_ResourceInputStream_clone): Used LLNI macros,
+       implemented missing methods
+
+       * src/native/vm/cldc1.1/java_lang_Object.c (native/llni.h): Added
+       * src/native/vm/cldc1.1/java_lang_Class.c: Likewise
+
+       * src/native/vm/cldc1.1/java_lang_String.c
+       (Java_java_lang_String_hashCode, Java_java_lang_String_indexOf__I,
+       Java_java_lang_String_indexOf__II,
+       Java_java_lang_String_lastIndexOf__I
+       Java_java_lang_String_lastIndexOf__II, Java_java_lang_String_equals,
+       Java_java_lang_String_intern): Used LLNI macros
+       * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c
+       (Java_com_sun_cldc_io_j2me_socket_Protocol_open0,
+       Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf,
+       Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf): Likewise
+
+       * src/native/vm/cldc1.1/java_lang_System.c
+       (Java_java_lang_System_arraycopy): Replaced java_arrayheader by
+       java_handle_t.
+
+       * src/vmcore/zip.c: Moved LFH struct to zip.h.
+       * src/vmcore/zip.h: Likewise.
+
+       * src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java: New file.
+
+       * src/lib/Makefile.am: Changed to build vm.zip for cldc1.1.
+       * src/native/include/Makefile.am: Likewise.
+       * src/Makefile.am: Likewise.
+       [2fc98ecf203f]
+
+2007-08-17  twisti  <twisti>
+
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c:
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c: Added Id keyword.
+       [3d57b610af51]
+
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c:
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c (native/llni.h):
+       Added. (boilerplate): Likewise.
+       [71fc7522fbbd]
+
+       * src/native/llni.h, src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/reflect.c, src/native/vm/sun/jvm.c,
+       src/vm/Makefile.am, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/string.c, src/vmcore/class.h,
+       src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.h,
+       src/vmcore/method.c, src/vmcore/method.h,
+       tests/regression/Makefile.am:
+       * src/vmcore/class.h (classinfo): Removed ENABLE_JAVASE for
+       enclosingclass and enclosingmethod. I don't think we can save that
+       much memory for CLDC configurations and it keeps the codebase
+       cleaner.
+       [6845be9d4d5c]
+
+2007-08-17  michi  <michi>
+
+       * NEWS, src/native/jni.c, src/native/llni.h,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/reflect.c,
+       src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c,
+       src/vm/Makefile.am, src/vm/array.c, src/vm/array.h,
+       src/vm/builtin.c, src/vm/global.h, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/verify/typecheck-
+       stackbased.c, src/vm/jit/verify/typecheck-typeinferer.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/primitive.c, src/vm/primitive.h, src/vm/string.c,
+       src/vm/vm.c, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.c,
+       src/vmcore/linker.h, src/vmcore/loader.c, src/vmcore/method.c,
+       src/vmcore/method.h, tests/regression/Makefile.am,
+       tests/regression/MinimalClassReflection.java,
+       tests/regression/MinimalClassReflection.output:
+       Merged revisions 8321-8342 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r8322 | twisti | 2007-08-16 17:54:38 +0200 (Thu, 16 Aug
+       2007) | 16 lines
+
+        * src/vmcore/method.c (method_get_annotations): Always enable the
+       method, but return NULL for !ENABLE_ANNOTATIONS. This keeps code
+       calling this function simpler. (method_get_parameterannotations):
+       Likewise. (method_get_annotationdefault): Likewise.
+
+        * src/vmcore/method.h (method_get_annotations): Removed
+       ENABLE_ANNOTATIONS. (method_get_parameterannotations): Likewise.
+       (method_get_annotationdefault): Likewise.
+
+        * src/native/vm/reflect.c (reflect_constructor_new): Always call
+       method-annotations functions. (reflect_field_new): Likewise.
+       (reflect_method_new): Likewise. ........ r8323 | twisti |
+       2007-08-16 18:01:05 +0200 (Thu, 16 Aug 2007) | 3 lines
+
+        * src/native/vm/sun/jvm.c (JVM_FindPrimitiveClass): Use
+       TRACEJVMCALLS and a better implementation. ........ r8325 |
+       twisti | 2007-08-16 19:25:47 +0200 (Thu, 16 Aug 2007) | 7 lines
+
+        * src/vmcore/field.c (field_get_annotations): Always enable the
+       method, but return NULL for !ENABLE_ANNOTATIONS. This keeps code
+       calling this function simpler.
+
+        * src/vmcore/field.h (field_get_annotations): Removed
+       ENABLE_ANNOTATIONS. ........ r8326 | twisti | 2007-08-16 19:45:49
+       +0200 (Thu, 16 Aug 2007) | 12 lines
+
+        * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (declaredAnnotations): Use byte-array handle. Don't check for this
+       == NULL , this cannot happen. (getParameterAnnotations):
+       Likewise.
+
+        * src/native/vm/gnu/java_lang_reflect_Field.c
+       (declaredAnnotations): Likewise.
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c
+       (declaredAnnotations): Likewise. (getParameterAnnotations):
+       Likewise. ........ r8327 | twisti | 2007-08-16 19:52:48 +0200
+       (Thu, 16 Aug 2007) | 8 lines
+
+        * src/vm/primitive.c (primitive_type_get_by_wrapperclass): New
+       function. (primitive_unbox): Changed signature.
+         * src/vm/primitive.h: Likewise.
+
+        * src/vm/vm.c (vm_array_from_objectarray): Rewritten to use
+       primitive-unbox function. ........ r8328 | twisti | 2007-08-16
+       19:56:19 +0200 (Thu, 16 Aug 2007) | 3 lines
+
+        * src/vm/vm.c (vm_array_from_objectarray): Use
+       primitive_type_get_by_wrapperclass (typo). Removed debug output.
+       ........ r8329 | twisti | 2007-08-16 19:57:27 +0200 (Thu, 16 Aug
+       2007) | 3 lines
+
+        * src/vm/vm.c (XXusage): Commented. We don't use it anymore but
+       we keep it to know which switches still need to be converted.
+       ........ r8330 | twisti | 2007-08-16 20:15:51 +0200 (Thu, 16 Aug
+       2007) | 25 lines
+
+        * src/vm/array.c: New file.
+         * src/vm/array.h: Likewise.
+
+        * src/vm/Makefile.am (libvm_la_SOURCES): Added array.[ch].
+
+        * src/vm/builtin.c, src/vm/string.c, src/vm/jit/verify
+       /typecheck-typeinferer.c, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typecheck-stackbased.c,
+       src/vm/jit/verify/typeinfo.c, src/vmcore/linker.c (vm/array.h):
+       Added.
+
+        * src/vm/primitive.h (ARRAYTYPE_*): Moved to vm/array.h
+
+        * src/vmcore/class.c (class_get_componenttype): New function.
+         * src/vmcore/class.h: Likewise.
+
+        * src/native/vm/java_lang_Class.c (getComponentType): Removed.
+         * src/native/vm/java_lang_Class.h: Likewise.
+
+        * src/native/vm/gnu/java_lang_VMClass.c (getComponentType): Call
+       class_get_componenttype.
+         * src/native/vm/sun/jvm.c (JVM_GetComponentType): Likewise. ........
+       r8331 | panzi | 2007-08-16 21:21:39 +0200 (Thu, 16 Aug 2007) | 16
+       lines
+
+        * src/native/vm/sun/jvm.c (vm/array.h): Added include.
+       (vm/global.h): Added include. (JVM_FindPrimitiveClass): Parameter
+       name shadowed type utf. (JVM_GetComponentType): Missing variable
+       classinfo* c. (JVM_GetClassAnnotations): java_bytearray ->
+       java_handle_bytearray_t. (JVM_GetFieldAnnotations): java_bytearray
+       -> java_handle_bytearray_t. (JVM_GetMethodAnnotations):
+       java_bytearray -> java_handle_bytearray_t.
+       (JVM_GetMethodDefaultAnnotationValue): java_bytearray ->
+       java_handle_bytearray_t. (JVM_GetMethodParameterAnnotations):
+       java_bytearray -> java_handle_bytearray_t. (JVM_GetArrayLength):
+       java_arrayheader -> java_array_t. (JVM_GetArrayElement): Updated
+       types, renamed wrong named variable.
+
+        * src/vmcore/linker.h: (_vftbl): Fixed formatting of comment.
+       ........ r8332 | panzi | 2007-08-16 21:29:42 +0200 (Thu, 16 Aug
+       2007) | 5 lines
+
+        * src/native/vm/sun/jvm.c (JVM_GetArrayElement): Used
+       exceptions_new_arrayindexoutofboundsexception where
+       exceptions_throw_arrayindexoutofboundsexception should have been
+       used. ........ r8333 | pm | 2007-08-16 23:46:32 +0200 (Thu, 16 Aug
+       2007) | 2 lines
+
+        * src/native/vm/sun/jvm.c (JVM_GetProtectionDomain): Return NULL
+       as default. ........ r8334 | ajordan | 2007-08-17 00:10:43 +0200
+       (Fri, 17 Aug 2007) | 5 lines
+
+        * src/vm/jit/sparc64/codegen.h: Improved overflow checking.
+
+        * src/vm/jit/sparc64/codegen.c (check_13bit_imm): Likewise.
+       (codegen_emit): Fixed ICDM_TABLESWITCH for large negative values.
+       ........ r8338 | panzi | 2007-08-17 22:03:06 +0200 (Fri, 17 Aug
+       2007) | 10 lines
+
+        * tests/regression/MinimalClassReflection.output: New file.
+         * tests/regression/MinimalClassReflection.java: New file. This adds
+       tests for some reflection methods like
+       java.lang.Class.isLocal/.isMember/.isAnonymous/.getDeclaringClass
+       etc.
+
+        * tests/regression/Makefile.am (SOURCE_FILES): Added
+       MinimalClassReflection.java. (EXTRA_DIST): Added
+       MinimalClassReflection.output. (OUTPUT_JAVA_TESTS): Added
+       MinimalClassReflection. ........ r8339 | twisti | 2007-08-17
+       23:21:51 +0200 (Fri, 17 Aug 2007) | 37 lines
+
+        * src/vm/global.h (ACC_CLASS_MEMBER): New define.
+       (ACC_CLASS_ANONYMOUS): Likewise.
+
+        * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getEnclosingClass): Removed.
+       (_Jv_java_lang_Class_getEnclosingMethod_intern): Use
+       class_get_enclosingclass.
+
+        * src/native/vm/java_lang_Class.h
+       (_Jv_java_lang_Class_getEnclosingClass): Removed.
+
+        * src/native/vm/gnu/java_lang_VMClass.c (stdint.h): Added.
+       (vmcore/class.h): Likewise. (methods): Enabled isAnonymousClass,
+       isLocalClass and isMemberClass.
+       (Java_java_lang_VMClass_getEnclosingClass): Use
+       class_get_enclosingclass. (isAnonymousClass): Implemented.
+       (isLocalClass): Likewise. (isMemberClass): Likewise.
+
+        * src/vmcore/class.c (class_load_attributes): Set ACC_CLASS_MEMBER
+       and ACC_CLASS_ANONYMOUS flags. (class_is_anonymousclass): New
+       function. (class_is_localclass): Likewise.
+       (class_is_memberclass): Likewise. (class_get_declaredclasses):
+       Check if outer is NULL. (class_get_declaringclass): Rewritten to
+       use c->declaringclass. (class_get_enclosingclass): New function.
+
+        * src/vmcore/class.h (classinfo): Added declaringclass.(
+       (class_is_anonymousclass): New function. (class_is_localclass):
+       Likewise. (class_is_memberclass): Likewise.
+       (class_get_enclosingclass): Likewise.
+
+        * NEWS: Added news. ........ r8340 | twisti | 2007-08-17
+       23:28:29 +0200 (Fri, 17 Aug 2007) | 2 lines
+
+        * src/native/vm/gnu/java_lang_VMClass.c (getEnclosingClass): Typo.
+       ........ r8341 | michi | 2007-08-17 23:32:01 +0200 (Fri, 17 Aug
+       2007) | 21 lines
+
+        * src/native/llni.h (LLNI_classinfo_wrap, LLNI_classinfo_unwrap):
+       Added new macros.
+
+        Used above two LLNI macros throughout the codebase:
+         * src/native/jni.c
+         * src/native/vm/java_lang_ClassLoader.c
+         * src/native/vm/cldc1.1/java_lang_Class.c
+         * src/native/vm/cldc1.1/java_lang_Object.c
+         * src/native/vm/java_lang_Class.c
+         * src/native/vm/java_lang_Object.c
+         * src/native/vm/gnu/java_lang_VMClassLoader.c
+         * src/native/vm/gnu/java_lang_VMClass.c
+         * src/native/vm/gnu/sun_reflect_ConstantPool.c
+         * src/native/vm/gnu/java_lang_reflect_Method.c
+         * src/native/vm/gnu/java_lang_reflect_Field.c
+         * src/native/vm/gnu/java_lang_VMThrowable.c
+         * src/native/vm/sun_misc_Unsafe.c
+         * src/native/vm/sun/jvm.c
+         * src/native/vm/reflect.c
+         * src/vmcore/loader.c ........
+       [240844a0096e]
+
+       * src/mm/cacao-gc/heap.c, src/mm/cacao-gc/heap.h, src/mm/cacao-
+       gc/mark.c, src/native/llni.h,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       tests/regression/Makefile.am:
+       * src/mm/cacao-gc/heap.c: Adapted to changes on trunk.
+       * src/mm/cacao-gc/heap.h: Likewise.
+       * src/mm/cacao-gc/mark.c: Likewise.
+       [494586254561]
+
+       * src/native/jni.c, src/native/llni.h,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/reflect.c,
+       src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c,
+       src/vmcore/loader.c:
+       * src/native/llni.h (LLNI_classinfo_wrap, LLNI_classinfo_unwrap):
+       Added new macros.
+
+       Used above two LLNI macros throughout the codebase:
+       * src/native/jni.c
+       * src/native/vm/java_lang_ClassLoader.c
+       * src/native/vm/cldc1.1/java_lang_Class.c
+       * src/native/vm/cldc1.1/java_lang_Object.c
+       * src/native/vm/java_lang_Class.c
+       * src/native/vm/java_lang_Object.c
+       * src/native/vm/gnu/java_lang_VMClassLoader.c
+       * src/native/vm/gnu/java_lang_VMClass.c
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c
+       * src/native/vm/gnu/java_lang_reflect_Method.c
+       * src/native/vm/gnu/java_lang_reflect_Field.c
+       * src/native/vm/gnu/java_lang_VMThrowable.c
+       * src/native/vm/sun_misc_Unsafe.c
+       * src/native/vm/sun/jvm.c
+       * src/native/vm/reflect.c
+       * src/vmcore/loader.c
+       [4ad817520fb4]
+
+2007-08-17  twisti  <twisti>
+
+       * src/native/vm/gnu/java_lang_VMClass.c:
+       * src/native/vm/gnu/java_lang_VMClass.c (getEnclosingClass): Typo.
+       [2ef182095ae1]
+
+       * NEWS, src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/vm/global.h, src/vmcore/class.c, src/vmcore/class.h:
+       * src/vm/global.h (ACC_CLASS_MEMBER): New define.
+       (ACC_CLASS_ANONYMOUS): Likewise.
+
+       * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getEnclosingClass): Removed.
+       (_Jv_java_lang_Class_getEnclosingMethod_intern): Use
+       class_get_enclosingclass.
+
+       * src/native/vm/java_lang_Class.h
+       (_Jv_java_lang_Class_getEnclosingClass): Removed.
+
+       * src/native/vm/gnu/java_lang_VMClass.c (stdint.h): Added.
+       (vmcore/class.h): Likewise. (methods): Enabled isAnonymousClass,
+       isLocalClass and isMemberClass.
+       (Java_java_lang_VMClass_getEnclosingClass): Use
+       class_get_enclosingclass. (isAnonymousClass): Implemented.
+       (isLocalClass): Likewise. (isMemberClass): Likewise.
+
+       * src/vmcore/class.c (class_load_attributes): Set ACC_CLASS_MEMBER
+       and ACC_CLASS_ANONYMOUS flags. (class_is_anonymousclass): New
+       function. (class_is_localclass): Likewise. (class_is_memberclass):
+       Likewise. (class_get_declaredclasses): Check if outer is NULL.
+       (class_get_declaringclass): Rewritten to use c->declaringclass.
+       (class_get_enclosingclass): New function.
+
+       * src/vmcore/class.h (classinfo): Added declaringclass.(
+       (class_is_anonymousclass): New function. (class_is_localclass):
+       Likewise. (class_is_memberclass): Likewise.
+       (class_get_enclosingclass): Likewise.
+
+       * NEWS: Added news.
+       [182b913bd9cf]
+
+2007-08-17  panzi  <panzi>
+
+       * tests/regression/Makefile.am,
+       tests/regression/MinimalClassReflection.java,
+       tests/regression/MinimalClassReflection.output:
+       * tests/regression/MinimalClassReflection.output: New file.
+       * tests/regression/MinimalClassReflection.java: New file. This adds
+       tests for some reflection methods like
+       java.lang.Class.isLocal/.isMember/.isAnonymous/.getDeclaringClass
+       etc.
+
+       * tests/regression/Makefile.am (SOURCE_FILES): Added
+       MinimalClassReflection.java. (EXTRA_DIST): Added
+       MinimalClassReflection.output. (OUTPUT_JAVA_TESTS): Added
+       MinimalClassReflection.
+       [1aaec4ee70e9]
+
+2007-08-17  michi  <michi>
+
+       * src/native/native.c, src/native/native.h:
+       * src/native/native.h (hashtable_library_loader_entry): Classloader
+       is represented by the classloader typedef.
+
+       * src/native/native.c (native_library_add, native_library_find):
+       Classloader does not need to be registered again.
+       [ee38e3ef5c76]
+
+       * src/vmcore/class.h:
+       * src/vmcore/class.h (classinfo): Added missing endif.
+       [f4bf74880e4f]
+
+       * src/native/jni.c, src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/sun_misc_Unsafe.c, src/vm/Makefile.am,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/primitive.c, src/vm/primitive.h, src/vm/string.c,
+       src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.h,
+       src/vmcore/loader.c:
+       * src/vmcore/loader.c (load_class_from_classloader)
+       [!ENABLE_GC_CACAO]: Pass object instead of classloader entry to
+       function.
+
+       * src/native/jni.c (_Jv_JNI_DefineClass): Register classloader.
+
+       * src/native/vm/gnu/java_lang_VMRuntime.c
+       (Java_java_lang_VMRuntime_nativeLoad): Likewise.
+
+       * src/native/vm/sun_misc_Unsafe.c
+       (Java_sun_misc_Unsafe_defineClass): Likewise.
+
+       * src/native/vm/gnu/java_lang_VMClassLoader.c
+       (Java_java_lang_VMClassLoader_findLoadedClass): Search for
+       classloader instead of adding a new one.
+
+       * src/native/vm/java_lang_Class.c: Fixed compiler warning.
+
+       * src/native/vm/java_lang_ClassLoader.c: Likewise.
+       [7e8c5c18b712]
+
+2007-08-16  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h:
+       * src/vm/jit/sparc64/codegen.h: Improved overflow checking.
+
+       * src/vm/jit/sparc64/codegen.c (check_13bit_imm): Likewise.
+       (codegen_emit): Fixed ICDM_TABLESWITCH for large negative values.
+       [8036df17dadb]
+
+2007-08-16  pm  <pm>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_GetProtectionDomain): Return NULL as
+       default.
+       [db907e41086f]
+
+2007-08-16  panzi  <panzi>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_GetArrayElement): Used
+       exceptions_new_arrayindexoutofboundsexception where
+       exceptions_throw_arrayindexoutofboundsexception should have been
+       used.
+       [33a38fdcba8e]
+
+       * src/native/vm/sun/jvm.c, src/vmcore/linker.h:
+       * src/native/vm/sun/jvm.c (vm/array.h): Added include.
+       (vm/global.h): Added include. (JVM_FindPrimitiveClass): Parameter
+       name shadowed type utf. (JVM_GetComponentType): Missing variable
+       classinfo* c. (JVM_GetClassAnnotations): java_bytearray ->
+       java_handle_bytearray_t. (JVM_GetFieldAnnotations): java_bytearray
+       -> java_handle_bytearray_t. (JVM_GetMethodAnnotations):
+       java_bytearray -> java_handle_bytearray_t.
+       (JVM_GetMethodDefaultAnnotationValue): java_bytearray ->
+       java_handle_bytearray_t. (JVM_GetMethodParameterAnnotations):
+       java_bytearray -> java_handle_bytearray_t. (JVM_GetArrayLength):
+       java_arrayheader -> java_array_t. (JVM_GetArrayElement): Updated
+       types, renamed wrong named variable.
+
+       * src/vmcore/linker.h: (_vftbl): Fixed formatting of comment.
+       [e13b6e6c0d15]
+
+2007-08-16  twisti  <twisti>
+
+       * src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/sun/jvm.c, src/vm/Makefile.am, src/vm/array.c,
+       src/vm/array.h, src/vm/builtin.c, src/vm/jit/verify/typecheck-
+       stackbased.c, src/vm/jit/verify/typecheck-typeinferer.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/primitive.h, src/vm/string.c, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/linker.c:
+       * src/vm/array.c: New file.
+       * src/vm/array.h: Likewise.
+
+       * src/vm/Makefile.am (libvm_la_SOURCES): Added array.[ch].
+
+       * src/vm/builtin.c, src/vm/string.c, src/vm/jit/verify/typecheck-
+       typeinferer.c, src/vm/jit/verify/typecheck.c, src/vm/jit/verify
+       /typecheck-stackbased.c, src/vm/jit/verify/typeinfo.c,
+       src/vmcore/linker.c (vm/array.h): Added.
+
+       * src/vm/primitive.h (ARRAYTYPE_*): Moved to vm/array.h
+
+       * src/vmcore/class.c (class_get_componenttype): New function.
+       * src/vmcore/class.h: Likewise.
+
+       * src/native/vm/java_lang_Class.c (getComponentType): Removed.
+       * src/native/vm/java_lang_Class.h: Likewise.
+
+       * src/native/vm/gnu/java_lang_VMClass.c (getComponentType): Call
+       class_get_componenttype.
+       * src/native/vm/sun/jvm.c (JVM_GetComponentType): Likewise.
+       [1f7cf6d1342f]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (XXusage): Commented. We don't use it anymore but we
+       keep it to know which switches still need to be converted.
+       [0a022dbb5571]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_array_from_objectarray): Use
+       primitive_type_get_by_wrapperclass (typo). Removed debug output.
+       [7c74a6c74478]
+
+       * src/vm/primitive.c, src/vm/primitive.h, src/vm/vm.c:
+       * src/vm/primitive.c (primitive_type_get_by_wrapperclass): New
+       function. (primitive_unbox): Changed signature.
+       * src/vm/primitive.h: Likewise.
+
+       * src/vm/vm.c (vm_array_from_objectarray): Rewritten to use
+       primitive-unbox function.
+       [d1bb1464fa01]
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c:
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (declaredAnnotations): Use byte-array handle. Don't check for this
+       == NULL , this cannot happen. (getParameterAnnotations): Likewise.
+
+       * src/native/vm/gnu/java_lang_reflect_Field.c (declaredAnnotations):
+       Likewise.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c
+       (declaredAnnotations): Likewise. (getParameterAnnotations):
+       Likewise.
+       [a671d0338b15]
+
+       * src/vmcore/field.c, src/vmcore/field.h:
+       * src/vmcore/field.c (field_get_annotations): Always enable the
+       method, but return NULL for !ENABLE_ANNOTATIONS. This keeps code
+       calling this function simpler.
+
+       * src/vmcore/field.h (field_get_annotations): Removed
+       ENABLE_ANNOTATIONS.
+       [43879e6b20c2]
+
+2007-08-16  michi  <michi>
+
+       * src/mm/cacao-gc/gc.c, src/native/vm/reflect.c,
+       src/native/vm/sun/jvm.c, src/vm/global.h, src/vmcore/loader.c,
+       src/vmcore/loader.h, src/vmcore/method.c, src/vmcore/method.h:
+       * src/vm/global.h [ENABLE_GC_CACAO] (java_handle_t): Made the handle
+       an its array pendants real indirection cells.
+
+       * src/mm/cacao-gc/gc.c (gc_init): Check the offset of the
+       indirection cells.
+
+       * src/vmcore/loader.h (hashtable_classloader_entry): Added attention
+       notice about the entry used as indirection cell.
+
+       * src/vmcore/loader.c (loader_hashtable_classloader_add): Used LLNI
+       critical sections to search and register classloader objects.
+       (loader_hashtable_classloader_find): Likewise.
+       [6d7c2d0e5a6d]
+
+2007-08-16  twisti  <twisti>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_FindPrimitiveClass): Use
+       TRACEJVMCALLS and a better implementation.
+       [53db5a1b83ed]
+
+       * src/native/vm/reflect.c, src/vmcore/method.c, src/vmcore/method.h:
+       * src/vmcore/method.c (method_get_annotations): Always enable the
+       method, but return NULL for !ENABLE_ANNOTATIONS. This keeps code
+       calling this function simpler. (method_get_parameterannotations):
+       Likewise. (method_get_annotationdefault): Likewise.
+
+       * src/vmcore/method.h (method_get_annotations): Removed
+       ENABLE_ANNOTATIONS. (method_get_parameterannotations): Likewise.
+       (method_get_annotationdefault): Likewise.
+
+       * src/native/vm/reflect.c (reflect_constructor_new): Always call
+       method-annotations functions. (reflect_field_new): Likewise.
+       (reflect_method_new): Likewise.
+       [dd8e95b3b98a]
+
+2007-08-16  michi  <michi>
+
+       * configure.ac, src/cacaoh/dummy.c, src/cacaoh/headers.c,
+       src/cacaoh/headers.h, src/native/jni.c, src/native/jni.h,
+       src/native/localref.c,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/java_security_VMAccessController.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_ClassLoader.h,
+       src/native/vm/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_reflect_Method.h,
+       src/native/vm/sun_misc_Unsafe.c, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/none/threads.h,
+       src/vm/access.c, src/vm/builtin.c, src/vm/builtin.h,
+       src/vm/exceptions.c, src/vm/global.h, src/vm/jit/Makefile.am,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/emit.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/stacktrace.h, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/emit.c, src/vm/signal.c, src/vm/signallocal.h,
+       src/vm/string.c, src/vm/stringlocal.h, src/vm/vm.c, src/vm/vm.h,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/field.c,
+       src/vmcore/field.h, src/vmcore/linker.c, src/vmcore/method.c,
+       src/vmcore/method.h:
+       Merged revisions 8299-8320 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r8300 | michi | 2007-08-13 12:23:20 +0200 (Mon, 13 Aug
+       2007) | 2 lines
+
+        * src/native/localref.c (localref_table_remove): Fixed assertion.
+       ........ r8301 | twisti | 2007-08-13 15:34:12 +0200 (Mon, 13 Aug
+       2007) | 5 lines
+
+        * configure.ac (dl): Check for dl before all other stuff.
+       (AC_CHECK_ENABLE_LIBJVM): Added.
+
+        * m4/libjvm.m4: New file. ........ r8303 | twisti | 2007-08-13
+       21:01:52 +0200 (Mon, 13 Aug 2007) | 2 lines
+
+        * src/vm/exceptions.c (exceptions_print_exception): Fixed typo.
+       ........ r8304 | pm | 2007-08-14 21:57:20 +0200 (Tue, 14 Aug 2007)
+       | 9 lines
+
+        * src/threads/none/threads.h [!defined(NDEBUG)]
+       (_no_threads_tracejavacallindent, _no_threads_tracejavacallcount,
+       TRACEJAVACALLINDENT, TRACEJAVACALLCOUNT): added.
+         * src/threads/native/threads.h [!defined(NDEBUG)] (threadinfo): Added
+       tracejavacallindent, tracejavacallcount members.
+       (TRACEJAVACALLINDENT, TRACEJAVACALLCOUNT): added.
+         * src/threads/native/threads.c: Likewise.
+         * src/vm/jit/trace.h New file.
+         * src/vm/jit/trace.c: Likewise.
+         * src/vm/jit/Makefile.am (libjit_la_SOURCES): added trace.h and
+       trace.c.
+         * src/vm/jit/s390/emit.c (emit_verbosecall_enter): adpated to use
+       trace_java_call_enter, (emit_verbosecall_exit): adapted to use
+       trace_java_call_exit. ........ r8305 | panzi | 2007-08-15 15:49:26
+       +0200 (Wed, 15 Aug 2007) | 34 lines
+
+        * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getDeclaredAnnotations): Use LLNI_* macro.
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c
+       (Java_java_lang_reflect_Method_getDefaultValue): Use LLNI_* macros.
+       (Java_java_lang_reflect_Method_declaredAnnotations): Use LLNI_*
+       macros. (Java_java_lang_reflect_Method_getParameterAnnotations):
+       Use LLNI_* macros.
+
+        * src/native/vm/gnu/java_lang_reflect_Field.c
+       (Java_java_lang_reflect_Field_declaredAnnotations): Use LLNI_*
+       macros.
+
+        * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (Java_java_lang_reflect_Constructor_declaredAnnotations): Use LLNI_*
+       macros.
+       (Java_java_lang_reflect_Constructor_getParameterAnnotations): Use
+       LLNI_* macros.
+
+        * src/native/vm/sun/jvm.c (native/llni.h): Added include.
+       (JVM_GetFieldAnnotations): Use LLNI_* macros.
+       (JVM_GetMethodAnnotations): Use LLNI_* macros.
+       (JVM_GetMethodDefaultAnnotationValue): Use LLNI_* macros.
+       (JVM_GetMethodParameterAnnotations): Use LLNI_* macros.
+       (JVM_GetClassConstantPool): Use LLNI_* macros.
+
+        * src/native/vm/reflect.c (reflect_constructor_new): Forgot to
+       set annotations and parameterAnnotations attributes for GNU
+       Classpath. (reflect_get_declaredannotatios): Use LLNI_* macros.
+       (reflect_get_parameterannotations): Use LLNI_* macros.
+
+        * src/native/vm/reflect.h (reflect_get_declaredannotatios): Now
+       the caller has to set the declaredAnnotations attribute of the
+       according object itself, because the LLNI_* macros can't get the
+       address of an field. ........ r8306 | twisti | 2007-08-15 16:47:11
+       +0200 (Wed, 15 Aug 2007) | 5 lines
+
+        * src/vm/signal.c (signal_init): Cast to functionptr to fix
+       warnings. (signal_register_signal): Changed signature.
+
+        * src/vm/signallocal.h (signal_register_signal): Likewise.
+       ........ r8307 | twisti | 2007-08-15 17:20:47 +0200 (Wed, 15 Aug
+       2007) | 7 lines
+
+        * src/vmcore/class.c (class_get_interfaces): New function.
+         * src/vmcore/class.h (class_get_interfaces): Likewise.
+
+        * src/native/vm/java_lang_Class.c (getSuperclass): Cast return
+       value. (getInterfaces): Use class_get_interfaces.
+         * src/native/vm/sun/jvm.c (JVM_GetClassInterfaces): Likewise. ........
+       r8308 | pm | 2007-08-15 18:03:28 +0200 (Wed, 15 Aug 2007) | 2 lines
+
+        * src/native/vm/sun/jvm.c (JVM_Available) [FIONREAD]: Argument to
+       ioctl is int *. ........ r8309 | twisti | 2007-08-15 18:42:52
+       +0200 (Wed, 15 Aug 2007) | 10 lines
+
+        * src/vmcore/class.c (vm/builtin.h): Added.
+       (class_get_declaredclasses): New function.
+
+        * src/vmcore/class.h (class_get_declaredclasses): Likewise.
+
+        * src/native/vm/java_lang_Class.c (getDeclaredClasses): Use
+       class_get_declaredclasses.
+
+        * src/native/vm/sun/jvm.c (JVM_GetDeclaredClasses): Likewise.
+       ........ r8310 | twisti | 2007-08-15 18:49:03 +0200 (Wed, 15 Aug
+       2007) | 3 lines
+
+        * src/native/vm/sun/jvm.c (JVM_GetClassInterfaces): Bugfix, forgot
+       to set c. ........ r8311 | panzi | 2007-08-15 19:03:40 +0200
+       (Wed, 15 Aug 2007) | 20 lines
+
+        * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (vm/vm.h): Added include.
+
+        * src/native/vm/gnu/sun_reflect_ConstantPool.c
+       (vm/stringlocal.h): Added include.
+       (Java_sun_reflect_ConstantPool_getClassAtIfLoaded0): Removed wrong
+       call of the macro TRACEJVMCALLS.
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c
+       (Java_java_lang_reflect_Method_getDefaultValue): Added proper casts
+       so gcc don't give me warnings.
+
+        * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       [ENABLE_ANNOTATIONS] (vm/exceptions.h): Added include.
+
+        * src/native/vm/sun/jvm.c (JVM_ConstantPoolGetStringAt):
+       Corrected cast. (JVM_ConstantPoolGetUTF8At): Corrected cast.
+       (JVM_GetArrayElement): Using primitive_box_* functions. ........
+       r8312 | twisti | 2007-08-16 00:10:22 +0200 (Thu, 16 Aug 2007) | 2
+       lines
+
+        * src/native/jni.c (native/localref.h): Added. ........ r8313 |
+       twisti | 2007-08-16 00:11:35 +0200 (Thu, 16 Aug 2007) | 4 lines
+
+        * src/native/localref.c: Added Id keyword.
+         * src/native/localref.h: Likewise.
+         * src/native/llni.h: Likewise. ........ r8314 | twisti | 2007-08-16
+       00:18:44 +0200 (Thu, 16 Aug 2007) | 2 lines
+
+        * src/vm/jit/codegen-common.c (native/localref.h): Added. ........
+       r8315 | panzi | 2007-08-16 00:49:20 +0200 (Thu, 16 Aug 2007) | 28
+       lines
+
+        * src/native/vm/reflect.c (reflect_constructor_new): Allocation
+       of the java_bytearray is now done in the method_get_* functions.
+       (reflect_field_new): Allocation of the java_bytearray is now done in
+       the field_get_* functions. (reflect_method_new): Allocation of
+       the java_bytearray is now done in the method_get_* functions.
+       Added use of LLNI_field_* macros.
+
+        * src/vmcore/method.c (method_get_annotations): Do allocation of
+       the java_bytearray here. (method_get_parameterannotations): Do
+       allocation of the java_bytearray here.
+       (method_get_annotationdefault): Do allocation of the java_bytearray
+       here.
+
+        * src/vmcore/method.h (method_get_annotations): This function
+       now returns java_bytearray*. (method_get_parameterannotations):
+       This function now returns java_bytearray*.
+       (method_get_annotationdefault): This function now returns
+       java_bytearray*.
+
+        * src/vmcore/field.c (vm/builtin.h): Added include.
+       (field_get_annotations): Do allocation of the java_bytearray here.
+
+        * src/vmcore/field.h (field_get_annotations): This function now
+       returns java_bytearray*.
+
+        * src/cacaoh/dummy.c (builtin_newarray_byte): Added. ........
+       r8316 | ajordan | 2007-08-16 01:32:57 +0200 (Thu, 16 Aug 2007) | 6
+       lines
+
+        * src/vm/jit/sparc64/codegen.h: Added M_SAVE_REG and 13-bit
+       overflow checking.
+
+        * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed stack
+       increasing for large stackframe sizes. (check_13bit_imm): Added
+       for overflow checking. ........ r8317 | pm | 2007-08-16 08:53:26
+       +0200 (Thu, 16 Aug 2007) | 2 lines
+
+        * src/vm/jit/trace (_array_load_param) [SIZEOF_VOID_P == 8]:
+       Bugfix, forgotten obsolete stack_offset. ........ r8318 | michi |
+       2007-08-16 12:05:34 +0200 (Thu, 16 Aug 2007) | 70 lines
+
+        * src/native/llni.h: Added macros for array handling.
+
+        * src/vm/global.h: Added typedefs for array handles. Renamed array
+       types.
+
+        Use LLNI macros for array access and adapted to above changes:
+         * src/vm/access.c
+         * src/vm/jit/arm/emit.c
+         * src/vm/jit/arm/codegen.c
+         * src/vm/jit/powerpc/emit.c
+         * src/vm/jit/powerpc/codegen.c
+         * src/vm/jit/sparc64/emit.c
+         * src/vm/jit/sparc64/codegen.c
+         * src/vm/jit/alpha/emit.c
+         * src/vm/jit/alpha/codegen.c
+         * src/vm/jit/s390/emit.c
+         * src/vm/jit/s390/codegen.c
+         * src/vm/jit/mips/emit.c
+         * src/vm/jit/mips/codegen.c
+         * src/vm/jit/m68k/emit.c
+         * src/vm/jit/m68k/codegen.c
+         * src/vm/jit/powerpc64/emit.c
+         * src/vm/jit/powerpc64/codegen.c
+         * src/vm/jit/i386/emit.c
+         * src/vm/jit/i386/codegen.c
+         * src/vm/jit/x86_64/emit.c
+         * src/vm/jit/x86_64/codegen.c
+         * src/vm/jit/stacktrace.c
+         * src/vm/jit/stacktrace.h
+         * src/vm/builtin.c
+         * src/vm/string.c
+         * src/vm/builtin.h
+         * src/vm/exceptions.c
+         * src/vm/vm.c
+         * src/vm/stringlocal.h
+         * src/vm/vm.h
+         * src/native/jni.c
+         * src/native/vm/java_lang_ClassLoader.c
+         * src/native/vm/java_lang_reflect_Constructor.h
+         * src/native/vm/java_lang_ClassLoader.h
+         * src/native/vm/java_lang_Class.c
+         * src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c
+         * src/native/vm/gnu/java_security_VMAccessController.c
+         * src/native/vm/gnu/java_lang_VMClassLoader.c
+         * src/native/vm/gnu/java_lang_management_VMManagementFactory.c
+         * src/native/vm/gnu/java_lang_VMClass.c
+         * src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
+         * src/native/vm/gnu/sun_reflect_ConstantPool.c
+         * src/native/vm/gnu/java_lang_reflect_Method.c
+         * src/native/vm/gnu/gnu_classpath_VMStackWalker.c
+         * src/native/vm/gnu/java_lang_VMSystem.c
+         * src/native/vm/gnu/java_lang_reflect_Constructor.c
+         * src/native/vm/gnu/java_lang_VMThrowable.c
+         * src/native/vm/java_lang_Class.h
+         * src/native/vm/sun_misc_Unsafe.c
+         * src/native/vm/sun/jvm.c
+         * src/native/vm/reflect.c
+         * src/native/vm/java_lang_reflect_Method.c
+         * src/native/vm/reflect.h
+         * src/native/vm/java_lang_reflect_Constructor.c
+         * src/native/vm/java_lang_reflect_Method.h
+         * src/native/jni.h
+         * src/vmcore/class.c
+         * src/vmcore/class.h
+         * src/vmcore/method.c
+         * src/vmcore/method.h
+         * src/vmcore/linker.c
+         * src/cacaoh/headers.h
+         * src/cacaoh/dummy.c
+         * src/cacaoh/headers.c ........ r8319 | michi | 2007-08-16 12:43:43
+       +0200 (Thu, 16 Aug 2007) | 5 lines
+
+        * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getDeclaredFields): Fixed postincrement of
+       array index. (_Jv_java_lang_Class_getDeclaredMethods): Likewise.
+       (_Jv_java_lang_Class_getDeclaredConstructors): Likewise. ........
+       r8320 | michi | 2007-08-16 13:35:14 +0200 (Thu, 16 Aug 2007) | 4
+       lines
+
+        * src/vm/jit/allocator/simplereg.c (simplereg_free): Index into
+       memcopycount is divided by SIZE_OF_STACKSLOT now.
+       (simplereg_allocate_temporaries): Likewise. ........
+       [e7e3dbee216f]
+
+       * src/vm/jit/allocator/simplereg.c:
+       * src/vm/jit/allocator/simplereg.c (simplereg_free): Index into
+       memcopycount is divided by SIZE_OF_STACKSLOT now.
+       (simplereg_allocate_temporaries): Likewise.
+       [f7cbb35f5009]
+
+       * src/native/vm/java_lang_Class.c:
+       * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getDeclaredFields): Fixed postincrement of
+       array index. (_Jv_java_lang_Class_getDeclaredMethods): Likewise.
+       (_Jv_java_lang_Class_getDeclaredConstructors): Likewise.
+       [5319d51e8c06]
+
+       * src/cacaoh/dummy.c, src/cacaoh/headers.c, src/cacaoh/headers.h,
+       src/native/jni.c, src/native/jni.h, src/native/llni.h,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/java_security_VMAccessController.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_ClassLoader.h,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.h,
+       src/native/vm/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_reflect_Method.h, src/native/vm/reflect.c,
+       src/native/vm/reflect.h, src/native/vm/sun/jvm.c,
+       src/native/vm/sun_misc_Unsafe.c, src/vm/access.c, src/vm/builtin.c,
+       src/vm/builtin.h, src/vm/exceptions.c, src/vm/global.h,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/string.c, src/vm/stringlocal.h, src/vm/vm.c, src/vm/vm.h,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c,
+       src/vmcore/method.c, src/vmcore/method.h:
+       * src/native/llni.h: Added macros for array handling.
+
+       * src/vm/global.h: Added typedefs for array handles. Renamed array
+       types.
+
+       Use LLNI macros for array access and adapted to above changes:
+       * src/vm/access.c
+       * src/vm/jit/arm/emit.c
+       * src/vm/jit/arm/codegen.c
+       * src/vm/jit/powerpc/emit.c
+       * src/vm/jit/powerpc/codegen.c
+       * src/vm/jit/sparc64/emit.c
+       * src/vm/jit/sparc64/codegen.c
+       * src/vm/jit/alpha/emit.c
+       * src/vm/jit/alpha/codegen.c
+       * src/vm/jit/s390/emit.c
+       * src/vm/jit/s390/codegen.c
+       * src/vm/jit/mips/emit.c
+       * src/vm/jit/mips/codegen.c
+       * src/vm/jit/m68k/emit.c
+       * src/vm/jit/m68k/codegen.c
+       * src/vm/jit/powerpc64/emit.c
+       * src/vm/jit/powerpc64/codegen.c
+       * src/vm/jit/i386/emit.c
+       * src/vm/jit/i386/codegen.c
+       * src/vm/jit/x86_64/emit.c
+       * src/vm/jit/x86_64/codegen.c
+       * src/vm/jit/stacktrace.c
+       * src/vm/jit/stacktrace.h
+       * src/vm/builtin.c
+       * src/vm/string.c
+       * src/vm/builtin.h
+       * src/vm/exceptions.c
+       * src/vm/vm.c
+       * src/vm/stringlocal.h
+       * src/vm/vm.h
+       * src/native/jni.c
+       * src/native/vm/java_lang_ClassLoader.c
+       * src/native/vm/java_lang_reflect_Constructor.h
+       * src/native/vm/java_lang_ClassLoader.h
+       * src/native/vm/java_lang_Class.c
+       * src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c
+       * src/native/vm/gnu/java_security_VMAccessController.c
+       * src/native/vm/gnu/java_lang_VMClassLoader.c
+       * src/native/vm/gnu/java_lang_management_VMManagementFactory.c
+       * src/native/vm/gnu/java_lang_VMClass.c
+       * src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c
+       * src/native/vm/gnu/java_lang_reflect_Method.c
+       * src/native/vm/gnu/gnu_classpath_VMStackWalker.c
+       * src/native/vm/gnu/java_lang_VMSystem.c
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       * src/native/vm/gnu/java_lang_VMThrowable.c
+       * src/native/vm/java_lang_Class.h
+       * src/native/vm/sun_misc_Unsafe.c
+       * src/native/vm/sun/jvm.c
+       * src/native/vm/reflect.c
+       * src/native/vm/java_lang_reflect_Method.c
+       * src/native/vm/reflect.h
+       * src/native/vm/java_lang_reflect_Constructor.c
+       * src/native/vm/java_lang_reflect_Method.h
+       * src/native/jni.h
+       * src/vmcore/class.c
+       * src/vmcore/class.h
+       * src/vmcore/method.c
+       * src/vmcore/method.h
+       * src/vmcore/linker.c
+       * src/cacaoh/headers.h
+       * src/cacaoh/dummy.c
+       * src/cacaoh/headers.c
+       [63b0fd7cb5fe]
+
+2007-08-16  pm  <pm>
+
+       * src/vm/jit/trace.c:
+       * src/vm/jit/trace (_array_load_param) [SIZEOF_VOID_P == 8]: Bugfix,
+       forgotten obsolete stack_offset.
+       [8cc3e076fe29]
+
+2007-08-15  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h:
+       * src/vm/jit/sparc64/codegen.h: Added M_SAVE_REG and 13-bit overflow
+       checking.
+
+       * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed stack
+       increasing for large stackframe sizes. (check_13bit_imm): Added for
+       overflow checking.
+       [13ba271dab74]
+
+2007-08-15  panzi  <panzi>
+
+       * src/cacaoh/dummy.c, src/native/vm/reflect.c, src/vmcore/field.c,
+       src/vmcore/field.h, src/vmcore/method.c, src/vmcore/method.h:
+       * src/native/vm/reflect.c (reflect_constructor_new): Allocation of
+       the java_bytearray is now done in the method_get_* functions.
+       (reflect_field_new): Allocation of the java_bytearray is now done in
+       the field_get_* functions. (reflect_method_new): Allocation of the
+       java_bytearray is now done in the method_get_* functions. Added use
+       of LLNI_field_* macros.
+
+       * src/vmcore/method.c (method_get_annotations): Do allocation of the
+       java_bytearray here. (method_get_parameterannotations): Do
+       allocation of the java_bytearray here.
+       (method_get_annotationdefault): Do allocation of the java_bytearray
+       here.
+
+       * src/vmcore/method.h (method_get_annotations): This function now
+       returns java_bytearray*. (method_get_parameterannotations): This
+       function now returns java_bytearray*.
+       (method_get_annotationdefault): This function now returns
+       java_bytearray*.
+
+       * src/vmcore/field.c (vm/builtin.h): Added include.
+       (field_get_annotations): Do allocation of the java_bytearray here.
+
+       * src/vmcore/field.h (field_get_annotations): This function now
+       returns java_bytearray*.
+
+       * src/cacaoh/dummy.c (builtin_newarray_byte): Added.
+       [3b41bdd55de9]
+
+2007-08-15  twisti  <twisti>
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (native/localref.h): Added.
+       [0ca38e055cda]
+
+       * src/native/llni.h, src/native/localref.c, src/native/localref.h:
+       * src/native/localref.c: Added Id keyword.
+       * src/native/localref.h: Likewise.
+       * src/native/llni.h: Likewise.
+       [e3fab8d4159d]
+
+       * src/native/jni.c:
+       * src/native/jni.c (native/localref.h): Added.
+       [b605fe201191]
+
+2007-08-15  panzi  <panzi>
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c:
+       * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (vm/vm.h): Added include.
+
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c (vm/stringlocal.h):
+       Added include. (Java_sun_reflect_ConstantPool_getClassAtIfLoaded0):
+       Removed wrong call of the macro TRACEJVMCALLS.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c
+       (Java_java_lang_reflect_Method_getDefaultValue): Added proper casts
+       so gcc don't give me warnings.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       [ENABLE_ANNOTATIONS] (vm/exceptions.h): Added include.
+
+       * src/native/vm/sun/jvm.c (JVM_ConstantPoolGetStringAt): Corrected
+       cast. (JVM_ConstantPoolGetUTF8At): Corrected cast.
+       (JVM_GetArrayElement): Using primitive_box_* functions.
+       [8cfa30fdde8a]
+
+2007-08-15  twisti  <twisti>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_GetClassInterfaces): Bugfix, forgot
+       to set c.
+       [aed11214ae7d]
+
+       * src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c,
+       src/vmcore/class.c, src/vmcore/class.h:
+       * src/vmcore/class.c (vm/builtin.h): Added.
+       (class_get_declaredclasses): New function.
+
+       * src/vmcore/class.h (class_get_declaredclasses): Likewise.
+
+       * src/native/vm/java_lang_Class.c (getDeclaredClasses): Use
+       class_get_declaredclasses.
+
+       * src/native/vm/sun/jvm.c (JVM_GetDeclaredClasses): Likewise.
+       [3d3963d5c803]
+
+2007-08-15  pm  <pm>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_Available) [FIONREAD]: Argument to
+       ioctl is int *.
+       [235e3ac93356]
+
+2007-08-15  twisti  <twisti>
+
+       * src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c,
+       src/vmcore/class.c, src/vmcore/class.h:
+       * src/vmcore/class.c (class_get_interfaces): New function.
+       * src/vmcore/class.h (class_get_interfaces): Likewise.
+
+       * src/native/vm/java_lang_Class.c (getSuperclass): Cast return
+       value. (getInterfaces): Use class_get_interfaces.
+       * src/native/vm/sun/jvm.c (JVM_GetClassInterfaces): Likewise.
+       [94c9ff4847c9]
+
+       * src/vm/signal.c, src/vm/signallocal.h:
+       * src/vm/signal.c (signal_init): Cast to functionptr to fix
+       warnings. (signal_register_signal): Changed signature.
+
+       * src/vm/signallocal.h (signal_register_signal): Likewise.
+       [17e72f4ecf1e]
+
+2007-08-15  panzi  <panzi>
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/reflect.c,
+       src/native/vm/reflect.h, src/native/vm/sun/jvm.c:
+       * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getDeclaredAnnotations): Use LLNI_* macro.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c
+       (Java_java_lang_reflect_Method_getDefaultValue): Use LLNI_* macros.
+       (Java_java_lang_reflect_Method_declaredAnnotations): Use LLNI_*
+       macros. (Java_java_lang_reflect_Method_getParameterAnnotations): Use
+       LLNI_* macros.
+
+       * src/native/vm/gnu/java_lang_reflect_Field.c
+       (Java_java_lang_reflect_Field_declaredAnnotations): Use LLNI_*
+       macros.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (Java_java_lang_reflect_Constructor_declaredAnnotations): Use LLNI_*
+       macros.
+       (Java_java_lang_reflect_Constructor_getParameterAnnotations): Use
+       LLNI_* macros.
+
+       * src/native/vm/sun/jvm.c (native/llni.h): Added include.
+       (JVM_GetFieldAnnotations): Use LLNI_* macros.
+       (JVM_GetMethodAnnotations): Use LLNI_* macros.
+       (JVM_GetMethodDefaultAnnotationValue): Use LLNI_* macros.
+       (JVM_GetMethodParameterAnnotations): Use LLNI_* macros.
+       (JVM_GetClassConstantPool): Use LLNI_* macros.
+
+       * src/native/vm/reflect.c (reflect_constructor_new): Forgot to set
+       annotations and parameterAnnotations attributes for GNU Classpath.
+       (reflect_get_declaredannotatios): Use LLNI_* macros.
+       (reflect_get_parameterannotations): Use LLNI_* macros.
+
+       * src/native/vm/reflect.h (reflect_get_declaredannotatios): Now the
+       caller has to set the declaredAnnotations attribute of the according
+       object itself, because the LLNI_* macros can't get the address of an
+       field.
+       [3b8fc6b76377]
+
+2007-08-14  pm  <pm>
+
+       * src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/none/threads.h, src/vm/jit/Makefile.am,
+       src/vm/jit/s390/emit.c, src/vm/jit/trace.c, src/vm/jit/trace.h:
+       * src/threads/none/threads.h [!defined(NDEBUG)]
+       (_no_threads_tracejavacallindent, _no_threads_tracejavacallcount,
+       TRACEJAVACALLINDENT, TRACEJAVACALLCOUNT): added.
+       * src/threads/native/threads.h [!defined(NDEBUG)] (threadinfo): Added
+       tracejavacallindent, tracejavacallcount members.
+       (TRACEJAVACALLINDENT, TRACEJAVACALLCOUNT): added.
+       * src/threads/native/threads.c: Likewise.
+       * src/vm/jit/trace.h New file.
+       * src/vm/jit/trace.c: Likewise.
+       * src/vm/jit/Makefile.am (libjit_la_SOURCES): added trace.h and
+       trace.c.
+       * src/vm/jit/s390/emit.c (emit_verbosecall_enter): adpated to use
+       trace_java_call_enter, (emit_verbosecall_exit): adapted to use
+       trace_java_call_exit.
+       [e821a274bf95]
+
+2007-08-13  twisti  <twisti>
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_print_exception): Fixed typo.
+       [bbb18ba6a16a]
+
+2007-08-13  michi  <michi>
+
+       * configure.ac, src/mm/cacao-gc/compact.c, src/mm/cacao-gc/copy.c,
+       src/mm/cacao-gc/final.c, src/mm/cacao-gc/final.h, src/mm/cacao-
+       gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao-
+       gc/heap.h, src/mm/cacao-gc/mark.c, src/mm/cacao-gc/region.c, src/mm
+       /cacao-gc/region.h, src/mm/cacao-gc/rootset.c, src/mm/cacao-
+       gc/rootset.h, src/mm/gc-common.h:
+       * src/mm/gc-common.h,
+       * src/mm/cacao-gc/gc.h,
+       * src/mm/cacao-gc/final.h,
+       * src/mm/cacao-gc/rootset.c,
+       * src/mm/cacao-gc/rootset.h,
+       * src/mm/cacao-gc/copy.c,
+       * src/mm/cacao-gc/heap.c,
+       * src/mm/cacao-gc/heap.h,
+       * src/mm/cacao-gc/region.c,
+       * src/mm/cacao-gc/compact.c,
+       * src/mm/cacao-gc/region.h,
+       * src/mm/cacao-gc/gc.c,
+       * src/mm/cacao-gc/final.c,
+       * src/mm/cacao-gc/mark.c: Adapted to changes on trunk.
+       [18edffcb5990]
+
+2007-08-13  twisti  <twisti>
+
+       * configure.ac, m4/libjvm.m4:
+       * configure.ac (dl): Check for dl before all other stuff.
+       (AC_CHECK_ENABLE_LIBJVM): Added.
+
+       * m4/libjvm.m4: New file.
+       [cdad3888d438]
+
+2007-08-13  michi  <michi>
+
+       * src/native/localref.c:
+       * src/native/localref.c (localref_table_remove): Fixed assertion.
+       [25f64eca9e36]
+
+       * NEWS, configure.ac, m4/ac_prog_javac.m4, m4/classpath.m4,
+       src/cacaoh/dummy.c, src/cacaoh/headers.c, src/cacaoh/headers.h,
+       src/lib/Makefile.am, src/mm/memory.c, src/native/Makefile.am,
+       src/native/include/Makefile.am, src/native/jni.c, src/native/jni.h,
+       src/native/localref.c, src/native/native.c, src/native/native.h,
+       src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_System.c,
+       src/native/vm/cldc1.1/java_lang_Throwable.c,
+       src/native/vm/gnu/Makefile.am,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Runtime.c,
+       src/native/vm/java_lang_Runtime.h, src/native/vm/java_lang_Thread.c,
+       src/native/vm/java_lang_reflect_Method.c, src/native/vm/nativevm.c,
+       src/native/vm/nativevm.h, src/native/vm/sun_misc_Unsafe.c,
+       src/threads/critical.c, src/threads/native/lock.c,
+       src/threads/native/lock.h, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/none/threads.h,
+       src/threads/threads-common.c, src/toolbox/avl.c, src/toolbox/avl.h,
+       src/toolbox/hashtable.c, src/toolbox/hashtable.h,
+       src/toolbox/list.h, src/toolbox/util.c, src/vm/Makefile.am,
+       src/vm/builtin.c, src/vm/builtin.h, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/finalizer.c, src/vm/global.h,
+       src/vm/initialize.c, src/vm/jit/Makefile.am,
+       src/vm/jit/alpha/Makefile.am, src/vm/jit/alpha/arch.h,
+       src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/alpha/md.c, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/Makefile.am, src/vm/jit/arm/arch.h,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/arm/patcher.c, src/vm/jit/asmpart.h, src/vm/jit/codegen-
+       common.c, src/vm/jit/codegen-common.h, src/vm/jit/dseg.c, src/vm/jit
+       /emit-common.c, src/vm/jit/emit-common.h,
+       src/vm/jit/i386/Makefile.am, src/vm/jit/i386/arch.h,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md.c,
+       src/vm/jit/i386/patcher.c, src/vm/jit/jit.h,
+       src/vm/jit/m68k/Makefile.am, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/mips/Makefile.am, src/vm/jit/mips/arch.h,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/patcher.h,
+       src/vm/jit/powerpc/Makefile.am, src/vm/jit/powerpc/arch.h,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md-
+       asm.h, src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/Makefile.am, src/vm/jit/powerpc64/arch.h,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/replace.c, src/vm/jit/replace.h,
+       src/vm/jit/s390/Makefile.am, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390
+       /md-abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390/md-asm.h,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, src/vm/jit/show.c,
+       src/vm/jit/sparc64/Makefile.am, src/vm/jit/sparc64/arch.h,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c,
+       src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/sparc64/patcher.c, src/vm/jit/sparc64/solaris/md-os.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h,
+       src/vm/jit/tools/Makefile.am, src/vm/jit/tools/genoffsets.c,
+       src/vm/jit/verify/typecheck-stackbased.c, src/vm/jit/verify
+       /typecheck-typeinferer.c, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/Makefile.am,
+       src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/linux/md-os.c, src/vm/jit/x86_64/md.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/properties.c,
+       src/vm/properties.h, src/vm/resolve.c, src/vm/signal.c,
+       src/vm/signallocal.h, src/vm/string.c, src/vm/stringlocal.h,
+       src/vm/vm.c, src/vm/vm.h, src/vmcore/Makefile.am,
+       src/vmcore/annotation.c, src/vmcore/annotation.h,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/classcache.c,
+       src/vmcore/descriptor.c, src/vmcore/field.c, src/vmcore/field.h,
+       src/vmcore/linker.c, src/vmcore/linker.h, src/vmcore/loader.c,
+       src/vmcore/method.c, src/vmcore/method.h, src/vmcore/primitive.c,
+       src/vmcore/primitive.h, src/vmcore/suck.h, src/vmcore/utf8.c,
+       src/vmcore/utf8.h, tests/rtIn/at/dms/kjc/Main, tests/rtMissedIn0:
+       Merged revisions 8245-8298 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r8246 | michi | 2007-07-31 13:36:03 +0200 (Tue, 31 Jul
+       2007) | 2 lines
+
+        * src/vm/jit/sparc64/md.c: Fixed file header. ........ r8247 |
+       michi | 2007-07-31 14:06:44 +0200 (Tue, 31 Jul 2007) | 10 lines
+
+        * src/vm/jit/arm/arch.h, src/vm/jit/powerpc/arch.h,
+       src/vm/jit/sparc64/arch.h, src/vm/jit/alpha/arch.h,
+       src/vm/jit/s390/arch.h, src/vm/jit/mips/arch.h,
+       src/vm/jit/powerpc64/arch.h, src/vm/jit/i386/arch.h,
+       src/vm/jit/x86_64/arch.h (REPLACEMENT_STUB_SIZE): Removed obsolete
+       define.
+
+        * src/vm/jit/powerpc/md.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/alpha/md.c, src/vm/jit/mips/md.c,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/i386/md.c,
+       src/vm/jit/x86_64/md.c (md_patch_replacement_point): We have to
+       use trap instructions here. ........ r8248 | twisti | 2007-07-31
+       14:47:11 +0200 (Tue, 31 Jul 2007) | 6 lines
+
+        * configure.ac: Only check AC_PROG_JAVAC and AC_PROG_JAR for
+       CLDC-1.1 and GNU.
+
+        * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Changed
+       default value for different configurations.. ........ r8249 |
+       panzi | 2007-07-31 14:59:03 +0200 (Tue, 31 Jul 2007) | 257 lines
+
+        * src/lib/gnu/java/lang/reflect/Method.java (annotations):
+       Added. (parameterAnnotations): Added. (annotationDefault):
+       Added.
+
+        * src/lib/gnu/java/lang/reflect/Field.java (annotations): Added.
+
+        * src/lib/gnu/sun/reflect: New directory.
+         * src/lib/gnu/sun/reflect/generics: New directory.
+         * src/lib/gnu/sun/reflect/generics/parser: New directory.
+         * src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java:
+       New file.
+
+        * src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java:
+       New file. This class parses type signatures and returns the acording
+       type as a java.lang.Class instance.
+
+        * src/lib/gnu/sun/reflect/ConstantPool.java [WITH_CLASSPATH_GNU]:
+       New file.
+
+        * src/lib/gnu/sun/reflect/annotation: New directory.
+         * src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionPr
+       oxy.java [WITH_CLASSPATH_GNU]: Copied file from OpenJDK.
+
+        *
+       src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
+       [WITH_CLASSPATH_GNU]: Copied file from OpenJDK.
+
+        * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java
+       [WITH_CLASSPATH_GNU]: Copied file from OpenJDK and changed a bit so
+       it can be used with GNU Classpath. [WITH_CLASSPATH_GNU]
+       (parseAnnotationsIntoArray): Added for convenience.
+       [WITH_CLASSPATH_GNU] (parseAnnotationDefault): Added for
+       convenience.
+
+        * src/lib/gnu/sun/reflect/annotation/AnnotationType.java
+       [WITH_CLASSPATH_GNU]: Copied file from OpenJDK and changed a bit so
+       it can be used with GNU Classpath. [WITH_CLASSPATH_GNU]
+       (annotationTypes): Added to emulate
+       sun.misc.SharedSecrets.getJavaLangAccess().getAnnotationType() and
+       sun.misc.SharedSecrets.getJavaLangAccess().setAnnotationType().
+
+        * src/lib/Makefile.am [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]:
+       Added classes needed by annotations support.
+
+        * src/native/vm/nativevm.h [ENABLE_ANNOTATIONS]
+       (_Jv_sun_reflect_ConstantPool_init): Added.
+
+        * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (vmcore/annotation.h): Include added.
+       [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (native/include/sun_reflect_ConstantPool.h): Include added.
+       [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (_Jv_java_lang_Class_getDeclaredAnnotations): Implemented.
+
+        * src/native/vm/gnu/java_lang_VMClass.c [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_VMClass_getDeclaredAnnotations): Implemented.
+
+        * src/native/vm/gnu/sun_reflect_ConstantPool.c
+       [ENABLE_ANNOTATIONS]: Added implementation of
+       sun.reflect.ConstantPool class. This is an copy of the according
+       functions from src/native/vm/sun/jvm.c for I don't know how to
+       unify it better (needs to be discussed).
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c
+       [ENABLE_ANNOTATIONS] (vm/vm.h): Added include.
+       [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h):
+       Added include. [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Method_getDefaultValue): Implemented.
+
+        * src/native/vm/gnu/Makefile.am [ENABLE_ANNOTATIONS]
+       (SUN_REFLECT_SOURCES): Added sun_reflect_ConstantPool.c
+
+        * src/native/vm/java_lang_Class.h [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (_Jv_java_lang_Class_getDeclaredAnnotations):
+       Added.
+
+        * src/native/vm/sun/jvm.c (assert.h): Added include.
+       (native/include/java_lang_Integer.h): Added include.
+       (native/include/java_lang_Long.h): Added include.
+       (native/include/java_lang_Short.h): Added include.
+       (native/include/java_lang_Byte.h): Added include.
+       (native/include/java_lang_Character.h): Added include.
+       (native/include/java_lang_Boolean.h): Added include.
+       (native/include/java_lang_Float.h): Added include.
+       (native/include/java_lang_Double.h): Added include.
+       [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h):
+       Added include. (JVM_GetDeclaringClass): Implemented.
+       (JVM_GetClassAnnotations) [ENABLE_ANNOTATIONS]: Implemented.
+       (JVM_GetFieldAnnotations): Implemented.
+       (JVM_GetMethodAnnotations): Implemented.
+       (JVM_GetMethodDefaultAnnotationValue): Implemented.
+       (JVM_GetMethodParameterAnnotations): Implemented.
+       [ENABLE_ANNOTATIONS] (JVM_GetClassConstantPool): Implemented.
+       (JVM_ConstantPoolGetSize): Implemented.
+       (JVM_ConstantPoolGetClassAt): Implemented.
+       (JVM_ConstantPoolGetClassAtIfLoaded): Implemented.
+       (JVM_ConstantPoolGetMethodAt): Implemented.
+       (JVM_ConstantPoolGetMethodAtIfLoaded): Implemented.
+       (JVM_ConstantPoolGetFieldAt): Implemented.
+       (JVM_ConstantPoolGetFieldAtIfLoaded): Implemented.
+       (JVM_ConstantPoolGetIntAt): Implemented.
+       (JVM_ConstantPoolGetLongAt): Implemented.
+       (JVM_ConstantPoolGetFloatAt): Implemented.
+       (JVM_ConstantPoolGetDoubleAt): Implemented.
+       (JVM_ConstantPoolGetStringAt): Implemented.
+       (JVM_ConstantPoolGetUTF8At): Implemented. (JVM_GetArrayElement):
+       Quickly implemented (will be rewritten by twisti). I needed this
+       function in a testcase and not directly for annotations support.
+
+        * src/native/vm/reflect.c [ENABLE_ANNOTATIONS] (mm/memmory.h):
+       Added include. (reflect_constructor_new) [ENABLE_ANNOTATIONS]:
+       Load annotations and parameter annotations. (reflect_field_new)
+       [ENABLE_ANNOTATIONS]: Load annotations. (reflect_method_new)
+       [ENABLE_ANNOTATIONS]: Load annotations, parameter annotations and
+       annotation default value.
+
+        * src/native/vm/nativevm.c [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (_Jv_sun_reflect_ConstantPool_init): Added
+       call.
+
+        * src/native/include/Makefile.am [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (JAVASE_HEADER_FILES): Added
+       sun_reflect_ConstantPool.h
+
+        * src/vmcore/class.c [ENABLE_ANNOTATIONS]
+       (class_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS]
+       (class_sun_reflect_annotation_AnnotationParser): Added.
+       (class_load_attributes) [ENABLE_ANNOTATIONS]: Load annotations.
+       (class_free) [ENABLE_ANNOTATIONS]: Free annotations.
+
+        * src/vmcore/loader.c (loader_init) [ENABLE_ANNOTATIONS]: Load
+       class_sun_reflect_ConstantPool. (loader_init) [ENABLE_ANNOTATIONS]
+       [WITH_CLASSPATH_GNU]: Load
+       class_sun_reflect_annotation_AnnotationParser.
+
+        * src/vmcore/annotation.c [!ENABLE_ANNOTATIONS]: Error: annotation
+       support has to be enabled when compling this file. (assert.h):
+       Added include. (toolbox/logging.h): Added include.
+       (annotation_bytearray_new): Added. (annotation_bytearray_free):
+       Added. (annotation_bytearrays_new): Added.
+       (annotation_bytearrays_resize): Added.
+       (annotation_bytearrays_insert): Added.
+       (annotation_bytearrays_free): Added.
+       (annotation_load_attribute_body): Added. Maybe this function should
+       be called loader_load_attribute_body and located in
+       vmcore/loader.c?
+       (annotation_load_method_attribute_annotationdefault): Added. (anno
+       tation_load_method_attribute_runtimevisibleparameterannotations):
+       Added. (annotation_load_method_attribute_runtimeinvisibleparameter
+       annotations): Added.
+       (annotation_load_class_attribute_runtimevisibleannotations): Added.
+       (annotation_load_class_attribute_runtimeinvisibleannotations):
+       Added.
+       (annotation_load_method_attribute_runtimevisibleannotations): Added.
+       (annotation_load_method_attribute_runtimeinvisibleannotations):
+       Added.
+       (annotation_load_field_attribute_runtimevisibleannotations): Added.
+       (annotation_load_field_attribute_runtimeinvisibleannotations):
+       Added.
+
+        * src/vmcore/class.h [ENABLE_ANNOTATIONS]
+       (runtimevisibleannotationscount): Removed. [ENABLE_ANNOTATIONS]
+       (runtimevisibleannotations): Removed. [ENABLE_ANNOTATIONS]
+       (annotations): Added. Bytearray of the unparsed annotations or
+       NULL if none. [ENABLE_ANNOTATIONS] (method_annotations): Added.
+       Array of bytearrays of method annotations. This Array is only as
+       big as needed or NULL if there are no method annotations at all.
+       [ENABLE_ANNOTATIONS] (method_parameterannotations): Added. Array of
+       bytearrays of method parameter annotations. This Array is only as
+       big as needed or NULL if there are no method parameter annotations
+       at all. [ENABLE_ANNOTATIONS] (method_annotationdefaults): Added.
+       Array of bytearrays of method annotation default values. This
+       Array is only as big as needed or NULL if there are no method
+       annotation default values at all. [ENABLE_ANNOTATIONS]
+       (field_annotations): Added. Array of bytearrays of field
+       annotations. This Array is only as big as needed or NULL if there
+       are no field annotations at all. [ENABLE_ANNOTATIONS]
+       (class_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS]
+       [WITH_CLASSPATH_GNU]
+       (class_sun_reflect_annotation_AnnotationParser): Added.
+
+        * src/vmcore/annotation.h (annotation_bytearray_t): Added. Used
+       to store unparsed (parameter-) annotations or unparsed annotation
+       default values in. (annotation_bytearrays_t): Added. Array of
+       bytearrays. (annotation_bytearray_new): Added.
+       (annotation_bytearray_free): Added. (annotation_bytearrays_new):
+       Added. (annotation_bytearrays_resize): Added.
+       (annotation_bytearrays_insert): Added.
+       (annotation_bytearrays_free): Added.
+       (annotation_load_class_attribute_runtimeinvisibleannotations):
+       Added.
+       (annotation_load_method_attribute_runtimevisibleannotations): Added.
+       (annotation_load_method_attribute_runtimeinvisibleannotations):
+       Added.
+       (annotation_load_field_attribute_runtimevisibleannotations): Added.
+       (annotation_load_field_attribute_runtimeinvisibleannotations):
+       Added. (annotation_load_method_attribute_annotationdefault):
+       Added. (annotation_load_method_attribute_runtimevisibleparameteran
+       notations): Added. (annotation_load_method_attribute_runtimeinvi
+       sibleparameterannotations): Added.
+
+        * src/vmcore/method.c (method_load) [ENABLE_ANNOTATIONS]: Load
+       annotations, parameter annotations and annotation default values.
+       [ENABLE_ANNOTATIONS] (method_get_annotations): Added.
+       [ENABLE_ANNOTATIONS] (method_get_parameterannotations): Added.
+       [ENABLE_ANNOTATIONS] (method_get_annotationdefault): Added.
+
+        * src/vmcore/method.h [ENABLE_ANNOTATIONS]
+       (method_get_annotations): Added. [ENABLE_ANNOTATIONS]
+       (method_get_parameterannotations): Added. [ENABLE_ANNOTATIONS]
+       (method_get_annotationdefault): Added.
+
+        * src/vmcore/field.c (mm/memory.h): Added include.
+       (vmcore/annotations.h): Added include. (field_load)
+       [ENABLE_ANNOTATIONS]: Laod annotations. [ENABLE_ANNOTATIONS]
+       (field_get_annotations): Added.
+
+        * src/vmcore/utf8.c [ENABLE_ANNOTATIONS]
+       (utf_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS]
+       (utf_RuntimeInvisibleAnnotations): Added. [ENABLE_ANNOTATIONS]
+       (utf_RuntimeVisibleParameterAnnotations): Added.
+       [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleParameterAnnotations):
+       Added. [ENABLE_ANNOTATIONS] (utf_AnnotationDefault): Added.
+       [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU]
+       (utf_sun_reflect_annotation_AnnotationParser): Added.
+
+        * src/vmcore/field.h [ENABLE_ANNOTATIONS]
+       (field_get_annotations): Added.
+
+        * src/vmcore/Makefile.am [ENABLE_ANNOTATIONS]
+       (ANNOTATION_SOURCES): Only compile annotations sources when
+       annotations are enabled.
+
+        * src/vmcore/utf8.h [ENABLE_ANNOTATIONS]
+       (utf_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS]
+       (utf_RuntimeInvisibleAnnotations): Added. [ENABLE_ANNOTATIONS]
+       (utf_RuntimeVisibleParameterAnnotations): Added.
+       [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleParameterAnnotations):
+       Added. [ENABLE_ANNOTATIONS] (utf_AnnotationDefault): Added.
+       [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU]
+       (utf_sun_reflect_annotation_AnnotationParser): Added.
+
+        * configure.ac (ENABLE_ANNOTATIONS): Added configure option
+       --enable-annotations. ........ r8250 | twisti | 2007-07-31
+       15:16:43 +0200 (Tue, 31 Jul 2007) | 3 lines
+
+        * m4/annotations.m4: New file.
+         * configure.ac: Use AC_CHECK_ENABLE_ANNOTATIONS. ........ r8251 | pm
+       | 2007-08-01 17:26:59 +0200 (Wed, 01 Aug 2007) | 9 lines
+
+        * jit/patcher.h: Added #error if included on s390.
+         * jit/patcher-common.h: Made declarations visible on s390.
+         * jit/s390/asmpart.S (asm_patcher_wrapper): removed.
+         * jit/s390/emit.c (emit_patcher_stubs): removed, (emit_patcher_traps):
+       added.
+         * jit/s390/codegen.h (PATCHER_LONGBRANCHES_NOPS_SKIP,
+       PATCHER_LONGBRANCHES_NOPS): removed, (PATCHER_CALL_SIZE,
+       PATCHER_NOPS, PATCHER_NOPS_SKIP) adapted to patching via signals.
+         * jit/s390/codegen.c (codegen_emit, codegen_emit_stub_native): Adapted
+       to paching via signals.
+         * jit/s390/md.c (md_signal_handler_sigill, md_signal_handler_sigsegv):
+       added support for exceptions_new_hardware_exception returning NULL.
+         * jit/s390/patcher.c: Adapted to paching via signals. ........ r8252
+       | twisti | 2007-08-02 00:47:17 +0200 (Thu, 02 Aug 2007) | 5 lines
+
+        * m4/ac_prog_javac.m4 (AC_PROG_JAVAC): Removed -1.5 from ecj.
+
+        * src/lib/Makefile.am (vm.zip): Added -source 1.5 -target 1.5.
+       Thanks to Mark Wielaard. ........ r8253 | twisti | 2007-08-02
+       16:46:00 +0200 (Thu, 02 Aug 2007) | 2 lines
+
+        * src/native/vm/sun/jvm.c (JVM_RaiseSignal): New function.
+       ........ r8254 | pm | 2007-08-03 20:43:30 +0200 (Fri, 03 Aug 2007)
+       | 3 lines
+
+        * src/vm/jit/patcher-common.c (patcher_handler): Call
+       LOCK_MONITOR_EXIT instead of LOCK_MONITOR_ENTER in double-patching
+       handler code. ........ r8255 | michi | 2007-08-03 21:06:37 +0200
+       (Fri, 03 Aug 2007) | 7 lines
+
+        * src/vm/jit/patcher-common.c (patcher_list_reset): Added.
+       (patcher_add_patch_ref) [!NDEBUG]: Added sanity check.
+
+        * src/vm/jit/patcher-common.h (patcher_list_reset): Added.
+
+        * src/vm/jit/codegen-common.c (codegen_reset): Resets the patcher
+       list. ........ r8256 | twisti | 2007-08-05 12:58:21 +0200 (Sun, 05
+       Aug 2007) | 3 lines
+
+        * src/native/vm/sun/jvm.c (JVM_Available) [FIONREAD]: Use
+       HotSpot-compatible code. ........ r8257 | twisti | 2007-08-05
+       13:04:21 +0200 (Sun, 05 Aug 2007) | 4 lines
+
+        * src/vm/jit/patcher-common.c (stdint.h): Added.
+       (patcher_list_free): Removed unused variable pr.
+       (patcher_add_patch_ref): Fixed warning. ........ r8258 | edwin |
+       2007-08-05 22:15:27 +0200 (Sun, 05 Aug 2007) | 2 lines
+
+        * src/vm/jit/replace.c (replace_new_sourceframe): Fixed
+       documentation. ........ r8259 | edwin | 2007-08-05 22:41:25 +0200
+       (Sun, 05 Aug 2007) | 3 lines
+
+        * src/vm/jit/replace.c (replace_read_executionstate): Improved
+       comments. (replace_write_executionstate): Likewise. ........
+       r8260 | michi | 2007-08-06 14:19:01 +0200 (Mon, 06 Aug 2007) | 13
+       lines
+
+        * src/vm/jit/emit-common.c (emit_patcher_traps): Added.
+
+        * src/vm/jit/emit-common.h (emit_trap): Added prototype.
+
+        * src/vm/jit/alpha/emit.c (emit_patcher_traps): Removed (moved to
+       emit-common). (emit_trap): Implemented.
+
+        * src/vm/jit/arm/emit.c: Likewise.
+
+        * src/vm/jit/powerpc/emit.c: Likewise.
+
+        * src/vm/jit/s390/emit.c: Likewise. ........ r8261 | michi |
+       2007-08-06 14:42:31 +0200 (Mon, 06 Aug 2007) | 3 lines
+
+        * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Removed
+       obsolete code about PATCHER_LONGBRANCHES_NOPS. ........ r8262 |
+       panzi | 2007-08-06 14:44:01 +0200 (Mon, 06 Aug 2007) | 97 lines
+
+        * src/lib/gnu/java/lang/reflect/Method.java
+       (java.lang.annotation.Annotation): Added import. (java.util.Map):
+       Added import. (sun.refelct.annotation.AnnotationParser): Added
+       import. (declaredAnnotations): Added field (inspired by OpenJDK).
+       (getAnnotation): Added method. (getDeclaredAnnotations): Added
+       method. (declaredAnnotations): Added method (inspired by OpenJDK).
+       (getParameterAnnotations): Added method.
+
+        * src/lib/gnu/java/lang/reflect/Field.java
+       (java.lang.annotation.Annotation): Added import. (java.util.Map):
+       Added import. (sun.refelct.annotation.AnnotationParser): Added
+       import. (declaredAnnotations): Added field (inspired by OpenJDK).
+       (getAnnotation): Added method. (getDeclaredAnnotations): Added
+       method. (declaredAnnotations): Added method (inspired by OpenJDK).
+
+        * src/lib/gnu/java/lang/reflect/Constructor.java: Copied file
+       from GNU Classpath. (java.lang.annotation.Annotation): Added
+       import. (java.util.Map): Added import.
+       (sun.refelct.annotation.AnnotationParser): Added import.
+       (declaredAnnotations): Added field (inspired by OpenJDK).
+       (getAnnotation): Added method. (getDeclaredAnnotations): Added
+       method. (declaredAnnotations): Added method (inspired by OpenJDK).
+       (getParameterAnnotations): Added method.
+
+        *
+       src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java:
+       Removed.
+
+        * src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java:
+       Removed. I figured out which class of GNU Classpath to use to
+       replace this self written class.
+
+        * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java:
+       Added a few comments.
+       (sun.reflect.generics.parser.SignatureParser): Removed import.
+       (sun.reflect.generics.parser.SignatureFormatError): Removed import.
+       (gnu.java.lang.reflect.FieldSignatureParser): Added import.
+       (parseParameterAnnotations): Added method. (parseSig): Changed
+       method so it uses GNU Classpaths FieldSignatureParser.
+
+        * src/lib/Makefile.am (VM_JAVA_FILES): Added
+       $(top_srcdir)/src/lib/gnu/java/lang/reflect/Constructor.java
+       (VM_CLASS_FILES): Added classes/java/lang/reflect/Constructor.class
+
+        * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (_Jv_java_lang_Class_getDeclaredAnnotations):
+       Cache methodinfo for
+       sun.reflect.annotation.AnnotationParser.parseAnnotationsIntoArray.
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c
+       [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added include.
+       [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method.
+       [ENABLE_ANNOTATIONS] (getParameterAnnotations): Added method.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Method_getDefaultValue): Cache methodinfo
+       for sun.reflect.annotation.AnnotationParser.parseDefaultValue.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Method_declaredAnnotations): Added.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Method_getParameterAnnotations): Added.
+
+        * src/native/vm/gnu/java_lang_reflect_Field.c
+       [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h):
+       Added include. [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added
+       include. [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Field_declaredAnnotations): Added.
+
+        * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       [ENABLE_ANNOTATIONS] (vm/vm.h): Added include.
+       [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h):
+       Added include. [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added
+       include. [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method.
+       [ENABLE_ANNOTATIONS] (getParameterAnnotations): Added method.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Constructor_declaredAnnotations): Added.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Constructor_getParameterAnnotations): Added.
+
+        * src/native/vm/reflect.c [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (vm/vm.h): Added include.
+       [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (native/include/sun_reflect_ConstantPool.h): Added include.
+       [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (reflect_get_declaredannotatios): Added. [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (reflect_get_parameterannotations): Added.
+
+        * src/native/vm/reflect.h [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (reflect_get_declaredannotatios): Added.
+       [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (reflect_get_parameterannotations): Added.
+
+        * src/native/vm/sun/jvm.c (JVM_GetDeclaredClasses): Implemented
+       (needed by a testcase of mine).
+
+        * src/vmcore/method.c (method_get_parametercount): Added. This
+       function gets the parameter count of a method (not counting the
+       this pointer of non-static methods). Returns -1 in case of an error.
+
+        * src/vmcore/method.h (method_get_parametercount): Added. ........
+       r8263 | twisti | 2007-08-06 16:41:05 +0200 (Mon, 06 Aug 2007) | 3
+       lines
+
+        * src/vm/jit/mips/arch.h (SUPPORT_PASS_FLOATARGS_IN_INTREGS):
+       Removed duplicate define. ........ r8264 | twisti | 2007-08-06
+       18:02:28 +0200 (Mon, 06 Aug 2007) | 33 lines
+
+        * src/vm/jit/patcher-common.h: Added __MIPS__ for new patcher
+       functions.
+
+        * src/vm/jit/patcher.h: Added __MIPS__ to include-check.
+
+        * src/vm/jit/mips/emit.c (vm/jit/patcher-common.h): Added.
+       (emit_patcher_stubs): Removed. (emit_trap): Added.
+
+        * src/vm/jit/mips/codegen.c (vm/jit/patcher.h): Removed. (vm/jit
+       /patcher-common.h): Added. (codegen_emit): Replaced
+       codegen_add_patch_ref with patcher_add_patch_ref, and
+       emit_patcher_stubs with emit_patcher_traps.
+       (codegen_emit_stub_native): Likewise.
+
+        * src/vm/jit/mips/codegen.h (PATCHER_CALL_INSTRUCTIONS): Changed
+       to 1. (PATCHER_CALL_SIZE): Changed to 1*4. (PATCHER_NOPS): Emit
+       only one NOP.
+
+        * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Check
+       for exception, set PC in trap-case.
+
+        * src/vm/jit/mips/irix/md-os.c (md_signal_handler_sigsegv): Check
+       for exception.
+
+        * src/vm/jit/mips/patcher.c: Renamed function to new patcher
+       functions, and use patcher references. (vm/jit/patcher.h):
+       Removed. (vm/jit/patcher-common.h): Added (patcher_wrapper):
+       Removed.
+
+        * src/vm/jit/mips/asmpart.S (asm_patcher_wrapper): Removed.
+       ........ r8265 | twisti | 2007-08-06 18:10:42 +0200 (Mon, 06 Aug
+       2007) | 3 lines
+
+        * src/vm/jit/emit-common.c: Set Id keyword.
+         * src/vm/jit/emit-common.h: Likewise. ........ r8266 | twisti |
+       2007-08-07 10:26:38 +0200 (Tue, 07 Aug 2007) | 3 lines
+
+        * src/threads/threads-common.c (threads_preinit): Fixed compiler
+       warning. ........ r8267 | twisti | 2007-08-07 13:07:48 +0200 (Tue,
+       07 Aug 2007) | 4 lines
+
+        * src/vm/jit/i386/emit.c (emit_trap): New function.
+         * src/vm/jit/powerpc64/emit.c: Likewise.
+         * src/vm/jit/x86_64/emit.c: Likewise. ........ r8268 | twisti |
+       2007-08-07 15:24:43 +0200 (Tue, 07 Aug 2007) | 34 lines
+
+        * src/vmcore/field.c (mm/memory.h): Added. (vm/global.h):
+       Likewise. (field_load): Allocate value memory only for static and
+       final fields.
+
+        * src/vmcore/field.h (fieldinfo): Made value a pointer.
+
+        * src/vmcore/loader.c (load_class_from_classbuffer): Allocate
+       fieldinfo's on the C heap.
+
+        * src/native/jni.c: fieldinfo->value is now a pointer.
+         * src/native/vm/sun_misc_Unsafe.c: Likewise.
+         * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise.
+
+        * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/patcher.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/patcher.c:
+       Likewise. ........ r8269 | twisti | 2007-08-07 21:21:33 +0200
+       (Tue, 07 Aug 2007) | 3 lines
+
+        * tests/rtMissedIn0: Removed.
+         * tests/rtIn: Likewise. ........ r8270 | twisti | 2007-08-08
+       15:57:12 +0200 (Wed, 08 Aug 2007) | 49 lines
+
+        * src/vm/vm.c (vm_array_store_flt): Handle __POWERPC__ correctly.
+       (vm_vmargs_from_valist): Removed. (vm_vmargs_from_jvalue):
+       Likewise. (vm_vmargs_from_objectarray): Likewise.
+       (vm_call_method_vmarg): Likewise. (vm_call_method_int_vmarg):
+       Likewise. (vm_call_method_int_valist): Likewise.
+       (vm_call_method_int_jvalue): Likewise.
+       (vm_call_method_long_vmarg): Likewise.
+       (vm_call_method_long_valist): Likewise.
+       (vm_call_method_long_jvalue): Likewise.
+       (vm_call_method_float_vmarg): Likewise.
+       (vm_call_method_float_valist): Likewise.
+       (vm_call_method_float_jvalue): Likewise.
+       (vm_call_method_double_vmarg): Likewise.
+       (vm_call_method_double_valist): Likewise.
+       (vm_call_method_double_jvalue): Likewise. (vm_call_method_valist):
+       Removed old implementation. (vm_call_method_jvalue): Likewise.
+
+        * src/vm/vm.h: Removed old prototypes.
+         * src/vm/jit/asmpart.h: Likewise.
+
+        * src/vm/exceptions.c (exceptions_handle_exception) [__POWERPC__]:
+       Get monitor object correctly (talk to Michi because of ARM).
+
+        * src/native/jni.c (_Jv_jni_invokeNative): Removed old
+       implementation.
+
+        * src/vm/jit/powerpc/linux/md-abi.c (md_param_alloc): Use 8-byte
+       stackslots. (md_param_alloc_native): Implemented native ABI.
+
+        * src/vm/jit/powerpc/emit.c (emit_load): Merged TYPE_FLT and
+       TYPE_DBL. (emit_store): Likewise
+         * src/vm/jit/powerpc/darwin/md-abi.c: Likewise.
+
+        * src/vm/jit/powerpc/arch.h (HAS_4BYTE_STACKSLOT): Removed.
+       (ALIGN_LONGS_IN_MEMORY): Likewise. (ALIGN_DOUBLES_IN_MEMORY):
+       Likewise.
+
+        * src/vm/jit/powerpc/codegen.c: Implemented 8-byte stackslots,
+       always load and store float-values as double (PowerPC's internal
+       register representation is the same).
+
+        * src/vm/jit/powerpc/asmpart.S (asm_vm_call_method): Use new
+       argument array. (asm_handle_exception): Restore callee-saved
+       registers from the correct location. ........ r8271 | twisti |
+       2007-08-08 16:07:56 +0200 (Wed, 08 Aug 2007) | 7 lines
+
+        * src/vm/vm.h (vm_arg): Removed.
+
+        * src/vm/jit/tools/genoffsets.c (main): Removed sizevmarg,
+       offvmargtype and offvmargdata.
+
+        * src/vm/jit/m68k/md.c (md_init): Removed some obsolete checks.
+       ........ r8272 | twisti | 2007-08-08 16:55:00 +0200 (Wed, 08 Aug
+       2007) | 7 lines
+
+        * src/threads/threads-common.c (stdint.h): Added.
+       (threads_thread_free): Also save and restore the thread state (this
+       is required for CLDC1.1, but is generally a good idea).
+
+        * src/native/vm/java_lang_Thread.c (isAlive)
+       [WITH_CLASSPATH_CLDC1_1]: Check for NULL. ........ r8273 |
+       twisti | 2007-08-08 17:33:15 +0200 (Wed, 08 Aug 2007) | 8 lines
+
+        * src/vmcore/class.c (class_isanysubclass): Don't use
+       ASM_GETCLASSVALUES_ATOMIC anymore, we will change that to use the
+       class-renumbering lock.
+
+        * src/vm/builtin.c (builtin_canstore): Likewise.
+       (builtin_canstore_onedim): Likewise.
+       (builtin_canstore_onedim_class): Likewise. ........ r8274 | twisti
+       | 2007-08-08 17:58:17 +0200 (Wed, 08 Aug 2007) | 45 lines
+
+        * src/vm/jit/tools: Removed.
+
+        * configure.ac (AC_CONFIG_FILES): Removed
+       src/vm/jit/tools/Makefile.
+         * src/vm/jit/Makefile.am (DIST_SUBDIRS): Removed tools. (SUBDIRS):
+       Likewise.
+
+        * src/threads/critical.c (stdint.h): Added. (vm/jit/asmpart.h):
+       Removed. (critical_init): Don't call
+       critical_register_asm_critical_sections.
+       (critical_register_asm_critical_sections): Removed.
+
+        * src/vm/jit/asmpart.h (ASM_GETCLASSVALUES_ATOMIC): Removed.
+       (asm_criticalsections): Likewise. (asm_getclassvalues_atomic):
+       Likewise. (intrp_asm_getclassvalues_atomic): Likewise.
+
+        * src/vm/jit/alpha/Makefile.am, src/vm/jit/arm/Makefile.am,
+       src/vm/jit/i386/Makefile.am, src/vm/jit/m68k/Makefile.am,
+       src/vm/jit/mips/Makefile.am, src/vm/jit/powerpc/Makefile.am,
+       src/vm/jit/powerpc64/Makefile.am, src/vm/jit/s390/Makefile.am,
+       src/vm/jit/sparc64/Makefile.am, src/vm/jit/x86_64/Makefile.am
+       (BUILT_SOURCES): Removed (CLEANFILES): Likewise. (offsets.h):
+       Likewise.
+
+        * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S
+       (offsets.h): Removed. (asm_getclassvalues_atomic): Likewise.
+       (asm_criticalsections): Likewise.
+
+        * src/vm/jit/powerpc/darwin/md-asm.h (asm_criticalsections):
+       Removed. (asm_getclassvalues_atomic): Likewise. ........ r8275 |
+       twisti | 2007-08-08 18:05:40 +0200 (Wed, 08 Aug 2007) | 12 lines
+
+        * src/vm/jit/alpha, src/vm/jit/arm, src/vm/jit/i386,
+       src/vm/jit/m68k, src/vm/jit/mips, src/vm/jit/parisc,
+       src/vm/jit/powerpc, src/vm/jit/powerpc64, src/vm/jit/s390,
+       src/vm/jit/sparc64, src/vm/jit/x86_64 (svn:ignore): Removed
+       offsets.h. ........ r8276 | twisti | 2007-08-08 18:09:14 +0200
+       (Wed, 08 Aug 2007) | 2 lines
+
+        * src/vm/jit/arm/asmpart.S (offsets.h): Removed. ........ r8277
+       | michi | 2007-08-08 18:42:11 +0200 (Wed, 08 Aug 2007) | 9 lines
+
+        * src/vmcore/linker.c (linker_compute_subclasses): Added attention
+       notice about the locking mechanism.
+
+        * src/vmcore/class.c (class_isanysubclass): Uses
+       linker_classrenumber_lock now.
+
+        * src/vm/builtin.c (builtin_canstore): Likewise.
+       (builtin_canstore_onedim): Likewise.
+       (builtin_canstore_onedim_class): Likewise. ........ r8278 | michi
+       | 2007-08-08 19:10:18 +0200 (Wed, 08 Aug 2007) | 5 lines
+
+        * src/vm/jit/s390/emit.c (emit_replacement_stubs): Removed
+       obsolete function.
+         * src/vm/jit/s390/codegen.c (codegen_emit): Do not create replacement
+       stubs.
+         * src/vm/jit/replace.c (replace_me): No longer call
+       asm_replacement_in.
+         * src/vm/jit/asmpart.h [ENABLE_REPLACEMENT]: Removed obsolete
+       prototypes. ........ r8279 | michi | 2007-08-09 11:36:57 +0200
+       (Thu, 09 Aug 2007) | 7 lines
+
+        * src/vm/jit/alpha/linux/md-os.c [ENABLE_REPLACEMENT]
+       (md_replace_executionstate_read): Implemented.
+       [ENABLE_REPLACEMENT] (md_replace_executionstate_write): Likewise.
+
+        * src/vm/jit/alpha/asmpart.S (asm_replacement_out): Removed.
+       (asm_replacement_in): Likewise. ........ r8280 | twisti |
+       2007-08-09 13:28:51 +0200 (Thu, 09 Aug 2007) | 2 lines
+
+        * NEWS: Added 0.99 release and some news. ........ r8281 |
+       twisti | 2007-08-09 14:09:17 +0200 (Thu, 09 Aug 2007) | 2 lines
+
+        * NEWS: Added news. ........ r8282 | twisti | 2007-08-09
+       14:18:47 +0200 (Thu, 09 Aug 2007) | 7 lines
+
+        * src/vm/signal.c (vm/types.h): Removed. (signal_init): Use
+       signal_register_signal. (signal_register_signal): New function.
+
+        * src/vm/signallocal.h (vm/types.h): Removed.
+       (signal_register_signal): New function. ........ r8283 | twisti |
+       2007-08-09 17:10:05 +0200 (Thu, 09 Aug 2007) | 30 lines
+
+        * src/vm/exceptions.c (toolbox/logging.h): Removed.
+       (vm/jit/disass.h): Likewise. (exceptions_new_hardware_exception):
+       Likewise.
+
+        * src/vm/exceptions.h (exceptions_new_hardware_exception):
+       Likewise.
+
+        * src/vm/signal.c (stdint.h): Added. (toolbox/logging.h):
+       Likewise. (vm/jit/codegen-common.h): Likewise.
+       (vm/jit/disass.h): Likewise. (vm/jit/patcher-common.h): Likewise.
+       (signal_handle): New function.
+
+        * src/vm/signallocal.h (signal_handle): Likewise.
+
+        * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/m68k/linux/md-os.c, src/vm/jit/mips/irix/md-os.c,
+       src/vm/jit/mips/linux/md-os.c, src/vm/jit/powerpc/darwin/md-os.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc64/linux/md-
+       os.c, src/vm/jit/s390/md.c, src/vm/jit/sparc64/linux/md-os.c,
+       src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/x86_64/linux/md-
+       os.c: Use new signal_handle function. ........ r8284 | michi |
+       2007-08-10 10:58:39 +0200 (Fri, 10 Aug 2007) | 26 lines
+
+        * src/native/llni.h: Added LLNI (low level native interface).
+
+        Use LLNI macros throughout the whole codebase:
+         * src/vm/jit/stacktrace.c
+         * src/vm/string.c
+         * src/vm/builtin.c
+         * src/vm/exceptions.c
+         * src/vm/vm.c
+         * src/native/jni.c
+         * src/native/vm/java_lang_ClassLoader.c
+         * src/native/vm/java_lang_Class.c
+         * src/native/vm/java_lang_String.c
+         * src/native/vm/java_lang_Object.c
+         * src/native/vm/gnu/java_lang_VMThread.c
+         * src/native/vm/gnu/java_lang_reflect_Method.c
+         * src/native/vm/gnu/java_lang_reflect_Field.c
+         * src/native/vm/gnu/java_lang_reflect_Constructor.c
+         * src/native/vm/gnu/java_lang_VMThrowable.c
+         * src/native/vm/java_lang_Thread.c
+         * src/native/vm/sun_misc_Unsafe.c
+         * src/native/vm/reflect.c
+         * src/native/vm/java_lang_reflect_Method.c
+         * src/native/vm/java_lang_reflect_Constructor.c
+         * src/threads/threads-common.c
+         * src/threads/native/threads.c ........ r8285 | michi | 2007-08-10
+       11:20:04 +0200 (Fri, 10 Aug 2007) | 5 lines
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c: Fixed merge
+       problem in previous revision 8284.
+
+        * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise.
+       ........ r8286 | michi | 2007-08-10 12:46:17 +0200 (Fri, 10 Aug
+       2007) | 9 lines
+
+        * src/vm/jit/powerpc/patcher.c (patcher_get_putfield): Fixed
+       severe bug for unalligned long field offsets.
+
+        * src/vmcore/linker.c [__POWERPC__ && __DARWIN__]: Long fields are
+       4-byte alligned in structs.
+
+        * src/vm/jit/patcher-common.c [TRACE_PATCHER]: Left patcher trace
+       code hanging around, might come handy again. ........ r8287 |
+       twisti | 2007-08-10 17:10:29 +0200 (Fri, 10 Aug 2007) | 2 lines
+
+        * src/native/jni.c (_Jv_JNI_FromReflectedField): Added missing ;.
+       ........ r8288 | twisti | 2007-08-10 17:12:00 +0200 (Fri, 10 Aug
+       2007) | 34 lines
+
+        * src/vmcore/primitive.c: Removed.
+         * src/vmcore/primitive.h: Likewise.
+
+        * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Removed
+       primitive.[ch].
+
+        * src/vmcore/primitivecore.c: New file.
+         * src/vm/primitive.c: Likwise.
+         * src/vm/primitive.h: Likewise.
+
+        * src/vm/Makefile.am (libvm_la_SOURCES): Added primitive.[ch].
+
+        * src/cacaoh/dummy.c (vm/primitive.h): Added.
+       (primitive_class_get_by_type): New function.
+       (primitive_class_get_by_char): Likewise.
+
+        * src/native/jni.c, src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c,
+       src/vm/builtin.c, src/vm/jit/verify/typecheck-stackbased.c,
+       src/vm/jit/verify/typecheck-typeinferer.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/resolve.c, src/vm/string.c, src/vm/vm.c,
+       src/vmcore/descriptor.c, src/vmcore/field.c,
+       src/vmcore/linker.c, src/vmcore/loader.c: Changed primitive.h
+       include. ........ r8289 | twisti | 2007-08-10 17:18:05 +0200 (Fri,
+       10 Aug 2007) | 3 lines
+
+        * src/native/vm/reflect.c (reflect_field_new): Fixed compilation.
+       (reflect_method_new): Likewise. ........ r8290 | twisti |
+       2007-08-11 12:25:40 +0200 (Sat, 11 Aug 2007) | 6 lines
+
+        * src/native/vm/sun/jvm.c (JVM_GC): Call GC-call directly, use
+       TRACEJVMCALLS. (JVM_TotalMemory): Likewise. (JVM_FreeMemory):
+       Likewise. (JVM_NewArray): Use TRACEJVMCALLS. ........ r8291 |
+       twisti | 2007-08-11 12:43:45 +0200 (Sat, 11 Aug 2007) | 41 lines
+
+        * src/vm/primitive.c (native/jni.h): Added. (native/llni.h):
+       Likewise. (native/include/java_lang_Boolean.h,
+       native/include/java_lang_Byte.h, native/include/java_lang_Short.h,
+       native/include/java_lang_Character.h,
+       native/include/java_lang_Integer.h,
+       native/include/java_lang_Long.h, native/include/java_lang_Float.h,
+       native/include/java_lang_Double.h): Likewise. (vm/builtin.h):
+       Likewise. (vm/vm.h): Likewise. (primitive_box): New function.
+       (primitive_unbox): Likewise. (PRIMITIVE_BOX_TYPE): New macro for
+       primitive_box_xxx functions. (PRIMITIVE_UNBOX_TYPE): New macro for
+       primitive_unbox_xxx functions.
+
+        * src/vm/primitive.h (primitive_box): Added. (primitive_unbox):
+       Likewise. (primitive_box_boolean, primitive_box_byte,
+       primitive_box_char, primitive_box_short, primitive_box_int,
+       primitive_box_long, primitive_box_float, primitive_box_double):
+       Likewise. (primitive_unbox_boolean, primitive_unbox_byte,
+       primitive_unbox_char, primitive_unbox_short,
+       primitive_unbox_int, primitive_unbox_long,
+       primitive_unbox_float, primitive_unbox_double): Likewise.
+
+        * src/native/jni.c (_Jv_jni_invokeNative): Use primitive-box
+       functions.
+
+        * src/native/vm/gnu/java_lang_reflect_Field.c (get): Likewise.
+       ........ r8292 | twisti | 2007-08-11 14:39:28 +0200 (Sat, 11 Aug
+       2007) | 13 lines
+
+        * src/vm/vm.c (VM_CALL_METHOD): New macro.
+       (VM_CALL_METHOD_VALIST): Likewise. (VM_CALL_METHOD_JVALUE):
+       Likewise. (VM_CALL_ARRAY): Likewise.
+
+        * src/vm/vm.h (vm_call_method_int): Changed return type to
+       stdint-type. (vm_call_method_int_valist): Likewise.
+       (vm_call_method_int_jvalue): Likewise. (vm_call_method_long):
+       Likewise. (vm_call_method_long_valist): Likewise.
+       (vm_call_method_long_jvalue): Likewise. ........ r8293 | twisti |
+       2007-08-11 14:40:22 +0200 (Sat, 11 Aug 2007) | 2 lines
+
+        * src/vm/vm.h: Set Id keyword. ........ r8294 | ajordan |
+       2007-08-11 15:42:25 +0200 (Sat, 11 Aug 2007) | 6 lines
+
+        * src/vm/jit/sparc64/md-abi.c (md_param_alloc_native): Fixed
+       pending issue from regoff change.
+         * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Likewise.
+
+        * src/vm/jit/sparc64/emit.c (emit_trap): Added. ........ r8295 |
+       michi | 2007-08-11 19:57:24 +0200 (Sat, 11 Aug 2007) | 106 lines
+
+        * src/vm/global.h (java_handle_t): Added typedef.
+       (java_object_t): New name for what was formerly known as
+       java_objectheader.
+
+        Adapted to above changes and decided where to use handles:
+         * src/vm/initialize.c
+         * src/vm/properties.h
+         * src/vm/jit/arm/codegen.c
+         * src/vm/jit/powerpc/codegen.c
+         * src/vm/jit/codegen-common.h
+         * src/vm/jit/sparc64/codegen.c
+         * src/vm/jit/sparc64/patcher.c
+         * src/vm/jit/alpha/codegen.c
+         * src/vm/jit/optimizing/recompile.c
+         * src/vm/jit/patcher-common.c
+         * src/vm/jit/s390/codegen.c
+         * src/vm/jit/show.c
+         * src/vm/jit/patcher-common.h
+         * src/vm/jit/mips/codegen.c
+         * src/vm/jit/patcher.h
+         * src/vm/jit/m68k/codegen.c
+         * src/vm/jit/powerpc64/codegen.c
+         * src/vm/jit/i386/codegen.c
+         * src/vm/jit/i386/patcher.c
+         * src/vm/jit/replace.c
+         * src/vm/jit/asmpart.h
+         * src/vm/jit/x86_64/codegen.c
+         * src/vm/jit/x86_64/patcher.c
+         * src/vm/jit/replace.h
+         * src/vm/jit/stacktrace.c
+         * src/vm/jit/stacktrace.h
+         * src/vm/jit/codegen-common.c
+         * src/vm/jit/jit.h
+         * src/vm/builtin.c
+         * src/vm/string.c
+         * src/vm/primitive.c
+         * src/vm/builtin.h
+         * src/vm/signal.c
+         * src/vm/primitive.h
+         * src/vm/exceptions.c
+         * src/vm/vm.c
+         * src/vm/finalizer.c
+         * src/vm/exceptions.h
+         * src/vm/stringlocal.h
+         * src/vm/vm.h
+         * src/vm/properties.c
+         * src/native/jni.c
+         * src/native/vm/java_lang_ClassLoader.c
+         * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c
+         * src/native/vm/cldc1.1/java_lang_Class.c
+         * src/native/vm/cldc1.1/java_lang_String.c
+         * src/native/vm/cldc1.1/java_lang_Object.c
+         * src/native/vm/cldc1.1/java_lang_System.c
+         * src/native/vm/cldc1.1/java_lang_Throwable.c
+         * src/native/vm/java_lang_Class.c
+         * src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c
+         * src/native/vm/gnu/java_lang_VMClassLoader.c
+         * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c
+         * src/native/vm/gnu/java_lang_reflect_Method.c
+         * src/native/vm/gnu/java_lang_VMRuntime.c
+         * src/native/vm/gnu/gnu_classpath_VMStackWalker.c
+         * src/native/vm/gnu/java_lang_reflect_Field.c
+         * src/native/vm/gnu/java_lang_reflect_Constructor.c
+         * src/native/vm/gnu/java_lang_VMThrowable.c
+         * src/native/vm/java_lang_Object.c
+         * src/native/vm/java_lang_String.c
+         * src/native/vm/java_lang_Thread.c
+         * src/native/vm/sun_misc_Unsafe.c
+         * src/native/vm/sun/jvm.c
+         * src/native/vm/reflect.c
+         * src/native/vm/java_lang_Runtime.c
+         * src/native/vm/java_lang_reflect_Method.c
+         * src/native/vm/reflect.h
+         * src/native/vm/java_lang_Runtime.h
+         * src/native/vm/java_lang_reflect_Constructor.c
+         * src/native/jni.h
+         * src/native/native.c
+         * src/native/native.h
+         * src/toolbox/hashtable.h
+         * src/toolbox/util.c
+         * src/toolbox/list.h
+         * src/toolbox/avl.c
+         * src/toolbox/avl.h
+         * src/toolbox/hashtable.c
+         * src/mm/memory.c
+         * src/threads/none/threads.h
+         * src/threads/threads-common.c
+         * src/threads/lock-common.h
+         * src/threads/native/threads.h
+         * src/threads/native/lock.c
+         * src/threads/native/threads.c
+         * src/threads/native/lock.h
+         * src/vmcore/class.c
+         * src/vmcore/loader.c
+         * src/vmcore/suck.h
+         * src/vmcore/class.h
+         * src/vmcore/loader.h
+         * src/vmcore/method.c
+         * src/vmcore/method.h
+         * src/vmcore/classcache.c
+         * src/vmcore/classcache.h
+         * src/vmcore/linker.c
+         * src/vmcore/linker.h
+         * src/cacaoh/headers.h
+         * src/cacaoh/dummy.c
+         * src/cacaoh/headers.c ........ r8296 | pm | 2007-08-12 00:38:38
+       +0200 (Sun, 12 Aug 2007) | 11 lines
+
+        * src/vm/exceptions.c (exceptions_handle_exception) [__S390__]:
+       Synchronization object is at SP - IsSync - 8.
+          * src/vm/vm.c (vm_array_store_flt) [__S390__]: Float value is in bytes
+       4-7 of uint64_t.
+          * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/md-abi.c, src/vm/jit/s390
+       /md-asm.h: Changed a lot for 8 byte stackslots. ........ r8297 |
+       michi | 2007-08-12 02:02:48 +0200 (Sun, 12 Aug 2007) | 35 lines
+
+        * src/native/localref.c: Added new file.
+         * src/native/localref.h: Likewise.
+
+        * src/native/Makefile.am: Added above two files.
+
+        * src/vm/jit/codegen-common.c (codegen_start_native_call)
+       (codegen_finish_native_call): Use separate function to deal with
+       localrefs.
+
+        * src/native/jni.h: Moved localref stuff to own file.
+         * src/native/jni.c: Likewise. (JNI_CALL_VIRTUAL_METHOD): Added new
+       macro. (JNI_CALL_NONVIRTUAL_METHOD): Likewise. (JNI_GET_FIELD):
+       Likewise. (JNI_SET_FIELD): Likewise. (JNI_CALL_STATIC_METHOD):
+       Likewise. (JNI_GET_STATIC_FIELD): Likewise.
+       (JNI_SET_STATIC_FIELD): Likewise. (JNI_NEW_ARRAY): Likewise.
+       (JNI_GET_ARRAY_ELEMENTS): Likewise. (JNI_RELEASE_ARRAY_ELEMENTS):
+       Likewise. (JNI_GET_ARRAY_REGION): Likewise.
+       (JNI_SET_ARRAY_REGION): Likewise.
+
+        * src/threads/native/threads.h,
+         * src/vm/jit/arm/codegen.c,
+         * src/vm/jit/powerpc/codegen.c,
+         * src/vm/jit/sparc64/codegen.c,
+         * src/vm/jit/alpha/codegen.c,
+         * src/vm/jit/s390/codegen.c,
+         * src/vm/jit/mips/codegen.c,
+         * src/vm/jit/m68k/codegen.c,
+         * src/vm/jit/powerpc64/codegen.c,
+         * src/vm/jit/i386/codegen.c,
+         * src/vm/jit/x86_64/codegen.c: Added missing include. ........ r8298
+       | pm | 2007-08-12 20:49:16 +0200 (Sun, 12 Aug 2007) | 7 lines
+
+        * src/vm/jit/dseg.c (dseg_get_linenumber_from_pc) [__S390__]:
+       Clear most significant bit of passed pc parameter.
+         * src/vm/jit/s390/asmpart.S (asm_handle_exception): Rewritten to be
+       wrapper for md_handle_exception.
+         * src/vm/jit/s390/md.c (md_handle_exception): New function.
+         * src/vm/jit/s390/md-abi.h (FLT_SAV_CNT): 2, (FLT_RES_CNT): 0.
+         * src/vm/jit/s390/md-abi.c (abi_registers_float_saved): Added f4 and
+       f6, (nregdescfloat): Made f4 and f6 saved registers. ........
+       [f2f83a695e10]
+
+2007-08-12  pm  <pm>
+
+       * src/vm/jit/dseg.c, src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md-
+       abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390/md.c:
+       * src/vm/jit/dseg.c (dseg_get_linenumber_from_pc) [__S390__]: Clear
+       most significant bit of passed pc parameter.
+       * src/vm/jit/s390/asmpart.S (asm_handle_exception): Rewritten to be
+       wrapper for md_handle_exception.
+       * src/vm/jit/s390/md.c (md_handle_exception): New function.
+       * src/vm/jit/s390/md-abi.h (FLT_SAV_CNT): 2, (FLT_RES_CNT): 0.
+       * src/vm/jit/s390/md-abi.c (abi_registers_float_saved): Added f4 and
+       f6, (nregdescfloat): Made f4 and f6 saved registers.
+       [9a2ce00b716e]
+
+2007-08-12  michi  <michi>
+
+       * src/native/Makefile.am, src/native/jni.c, src/native/jni.h,
+       src/native/localref.c, src/native/localref.h,
+       src/threads/native/threads.h, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c,
+       src/vm/vm.c:
+       * src/native/localref.c: Added new file.
+       * src/native/localref.h: Likewise.
+
+       * src/native/Makefile.am: Added above two files.
+
+       * src/vm/jit/codegen-common.c (codegen_start_native_call)
+       (codegen_finish_native_call): Use separate function to deal with
+       localrefs.
+
+       * src/native/jni.h: Moved localref stuff to own file.
+       * src/native/jni.c: Likewise. (JNI_CALL_VIRTUAL_METHOD): Added new
+       macro. (JNI_CALL_NONVIRTUAL_METHOD): Likewise. (JNI_GET_FIELD):
+       Likewise. (JNI_SET_FIELD): Likewise. (JNI_CALL_STATIC_METHOD):
+       Likewise. (JNI_GET_STATIC_FIELD): Likewise. (JNI_SET_STATIC_FIELD):
+       Likewise. (JNI_NEW_ARRAY): Likewise. (JNI_GET_ARRAY_ELEMENTS):
+       Likewise. (JNI_RELEASE_ARRAY_ELEMENTS): Likewise.
+       (JNI_GET_ARRAY_REGION): Likewise. (JNI_SET_ARRAY_REGION): Likewise.
+
+       * src/threads/native/threads.h,
+       * src/vm/jit/arm/codegen.c,
+       * src/vm/jit/powerpc/codegen.c,
+       * src/vm/jit/sparc64/codegen.c,
+       * src/vm/jit/alpha/codegen.c,
+       * src/vm/jit/s390/codegen.c,
+       * src/vm/jit/mips/codegen.c,
+       * src/vm/jit/m68k/codegen.c,
+       * src/vm/jit/powerpc64/codegen.c,
+       * src/vm/jit/i386/codegen.c,
+       * src/vm/jit/x86_64/codegen.c: Added missing include.
+       [144c435f4cfb]
+
+2007-08-11  pm  <pm>
+
+       * src/vm/exceptions.c, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.c, src/vm/jit/s390
+       /md-asm.h, src/vm/jit/s390/md.c, src/vm/vm.c:
+       * src/vm/exceptions.c (exceptions_handle_exception) [__S390__]:
+       Synchronization object is at SP - IsSync - 8.
+        * src/vm/vm.c (vm_array_store_flt) [__S390__]: Float value is in bytes
+       4-7 of uint64_t.
+        * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md-
+       asm.h: Changed a lot for 8 byte stackslots.
+       [a9830fedc342]
+
+2007-08-11  michi  <michi>
+
+       * src/cacaoh/dummy.c, src/cacaoh/headers.c, src/cacaoh/headers.h,
+       src/mm/memory.c, src/native/jni.c, src/native/jni.h,
+       src/native/native.c, src/native/native.h,
+       src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_System.c,
+       src/native/vm/cldc1.1/java_lang_Throwable.c,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Runtime.c,
+       src/native/vm/java_lang_Runtime.h, src/native/vm/java_lang_String.c,
+       src/native/vm/java_lang_Thread.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Method.c, src/native/vm/reflect.c,
+       src/native/vm/reflect.h, src/native/vm/sun/jvm.c,
+       src/native/vm/sun_misc_Unsafe.c, src/threads/lock-common.h,
+       src/threads/native/lock.c, src/threads/native/lock.h,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/none/threads.h, src/threads/threads-common.c,
+       src/toolbox/avl.c, src/toolbox/avl.h, src/toolbox/hashtable.c,
+       src/toolbox/hashtable.h, src/toolbox/list.h, src/toolbox/util.c,
+       src/vm/builtin.c, src/vm/builtin.h, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/finalizer.c, src/vm/global.h,
+       src/vm/initialize.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/asmpart.h, src/vm/jit/codegen-
+       common.c, src/vm/jit/codegen-common.h, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/patcher.c, src/vm/jit/jit.h,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/patcher-common.c,
+       src/vm/jit/patcher-common.h, src/vm/jit/patcher.h,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/replace.c, src/vm/jit/replace.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/show.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/patcher.c,
+       src/vm/primitive.c, src/vm/primitive.h, src/vm/properties.c,
+       src/vm/properties.h, src/vm/signal.c, src/vm/string.c,
+       src/vm/stringlocal.h, src/vm/vm.c, src/vm/vm.h, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/classcache.c,
+       src/vmcore/classcache.h, src/vmcore/linker.c, src/vmcore/linker.h,
+       src/vmcore/loader.c, src/vmcore/loader.h, src/vmcore/method.c,
+       src/vmcore/method.h, src/vmcore/suck.h:
+       * src/vm/global.h (java_handle_t): Added typedef. (java_object_t):
+       New name for what was formerly known as java_objectheader.
+
+       Adapted to above changes and decided where to use handles:
+       * src/vm/initialize.c
+       * src/vm/properties.h
+       * src/vm/jit/arm/codegen.c
+       * src/vm/jit/powerpc/codegen.c
+       * src/vm/jit/codegen-common.h
+       * src/vm/jit/sparc64/codegen.c
+       * src/vm/jit/sparc64/patcher.c
+       * src/vm/jit/alpha/codegen.c
+       * src/vm/jit/optimizing/recompile.c
+       * src/vm/jit/patcher-common.c
+       * src/vm/jit/s390/codegen.c
+       * src/vm/jit/show.c
+       * src/vm/jit/patcher-common.h
+       * src/vm/jit/mips/codegen.c
+       * src/vm/jit/patcher.h
+       * src/vm/jit/m68k/codegen.c
+       * src/vm/jit/powerpc64/codegen.c
+       * src/vm/jit/i386/codegen.c
+       * src/vm/jit/i386/patcher.c
+       * src/vm/jit/replace.c
+       * src/vm/jit/asmpart.h
+       * src/vm/jit/x86_64/codegen.c
+       * src/vm/jit/x86_64/patcher.c
+       * src/vm/jit/replace.h
+       * src/vm/jit/stacktrace.c
+       * src/vm/jit/stacktrace.h
+       * src/vm/jit/codegen-common.c
+       * src/vm/jit/jit.h
+       * src/vm/builtin.c
+       * src/vm/string.c
+       * src/vm/primitive.c
+       * src/vm/builtin.h
+       * src/vm/signal.c
+       * src/vm/primitive.h
+       * src/vm/exceptions.c
+       * src/vm/vm.c
+       * src/vm/finalizer.c
+       * src/vm/exceptions.h
+       * src/vm/stringlocal.h
+       * src/vm/vm.h
+       * src/vm/properties.c
+       * src/native/jni.c
+       * src/native/vm/java_lang_ClassLoader.c
+       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c
+       * src/native/vm/cldc1.1/java_lang_Class.c
+       * src/native/vm/cldc1.1/java_lang_String.c
+       * src/native/vm/cldc1.1/java_lang_Object.c
+       * src/native/vm/cldc1.1/java_lang_System.c
+       * src/native/vm/cldc1.1/java_lang_Throwable.c
+       * src/native/vm/java_lang_Class.c
+       * src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c
+       * src/native/vm/gnu/java_lang_VMClassLoader.c
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c
+       * src/native/vm/gnu/java_lang_reflect_Method.c
+       * src/native/vm/gnu/java_lang_VMRuntime.c
+       * src/native/vm/gnu/gnu_classpath_VMStackWalker.c
+       * src/native/vm/gnu/java_lang_reflect_Field.c
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       * src/native/vm/gnu/java_lang_VMThrowable.c
+       * src/native/vm/java_lang_Object.c
+       * src/native/vm/java_lang_String.c
+       * src/native/vm/java_lang_Thread.c
+       * src/native/vm/sun_misc_Unsafe.c
+       * src/native/vm/sun/jvm.c
+       * src/native/vm/reflect.c
+       * src/native/vm/java_lang_Runtime.c
+       * src/native/vm/java_lang_reflect_Method.c
+       * src/native/vm/reflect.h
+       * src/native/vm/java_lang_Runtime.h
+       * src/native/vm/java_lang_reflect_Constructor.c
+       * src/native/jni.h
+       * src/native/native.c
+       * src/native/native.h
+       * src/toolbox/hashtable.h
+       * src/toolbox/util.c
+       * src/toolbox/list.h
+       * src/toolbox/avl.c
+       * src/toolbox/avl.h
+       * src/toolbox/hashtable.c
+       * src/mm/memory.c
+       * src/threads/none/threads.h
+       * src/threads/threads-common.c
+       * src/threads/lock-common.h
+       * src/threads/native/threads.h
+       * src/threads/native/lock.c
+       * src/threads/native/threads.c
+       * src/threads/native/lock.h
+       * src/vmcore/class.c
+       * src/vmcore/loader.c
+       * src/vmcore/suck.h
+       * src/vmcore/class.h
+       * src/vmcore/loader.h
+       * src/vmcore/method.c
+       * src/vmcore/method.h
+       * src/vmcore/classcache.c
+       * src/vmcore/classcache.h
+       * src/vmcore/linker.c
+       * src/vmcore/linker.h
+       * src/cacaoh/headers.h
+       * src/cacaoh/dummy.c
+       * src/cacaoh/headers.c
+       [be809e5a11d0]
+
+2007-08-11  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/md-abi.c:
+       * src/vm/jit/sparc64/md-abi.c (md_param_alloc_native): Fixed pending
+       issue from regoff change.
+       * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Likewise.
+
+       * src/vm/jit/sparc64/emit.c (emit_trap): Added.
+       [9ca4d7cfc72d]
+
+2007-08-11  twisti  <twisti>
+
+       * src/vm/vm.h:
+       * src/vm/vm.h: Set Id keyword.
+       [be91580c1d11]
+
+       * src/vm/vm.c, src/vm/vm.h:
+       * src/vm/vm.c (VM_CALL_METHOD): New macro. (VM_CALL_METHOD_VALIST):
+       Likewise. (VM_CALL_METHOD_JVALUE): Likewise. (VM_CALL_ARRAY):
+       Likewise.
+
+       * src/vm/vm.h (vm_call_method_int): Changed return type to stdint-
+       type. (vm_call_method_int_valist): Likewise.
+       (vm_call_method_int_jvalue): Likewise. (vm_call_method_long):
+       Likewise. (vm_call_method_long_valist): Likewise.
+       (vm_call_method_long_jvalue): Likewise.
+       [bf3f6683be8c]
+
+       * src/native/jni.c, src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/vm/primitive.c, src/vm/primitive.h:
+       * src/vm/primitive.c (native/jni.h): Added. (native/llni.h):
+       Likewise. (native/include/java_lang_Boolean.h,
+       native/include/java_lang_Byte.h, native/include/java_lang_Short.h,
+       native/include/java_lang_Character.h,
+       native/include/java_lang_Integer.h, native/include/java_lang_Long.h,
+       native/include/java_lang_Float.h,
+       native/include/java_lang_Double.h): Likewise. (vm/builtin.h):
+       Likewise. (vm/vm.h): Likewise. (primitive_box): New function.
+       (primitive_unbox): Likewise. (PRIMITIVE_BOX_TYPE): New macro for
+       primitive_box_xxx functions. (PRIMITIVE_UNBOX_TYPE): New macro for
+       primitive_unbox_xxx functions.
+
+       * src/vm/primitive.h (primitive_box): Added. (primitive_unbox):
+       Likewise. (primitive_box_boolean, primitive_box_byte,
+       primitive_box_char, primitive_box_short, primitive_box_int,
+       primitive_box_long, primitive_box_float, primitive_box_double):
+       Likewise. (primitive_unbox_boolean, primitive_unbox_byte,
+       primitive_unbox_char, primitive_unbox_short, primitive_unbox_int,
+       primitive_unbox_long, primitive_unbox_float,
+       primitive_unbox_double): Likewise.
+
+       * src/native/jni.c (_Jv_jni_invokeNative): Use primitive-box
+       functions.
+
+       * src/native/vm/gnu/java_lang_reflect_Field.c (get): Likewise.
+       [23a46bc80fdd]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_GC): Call GC-call directly, use
+       TRACEJVMCALLS. (JVM_TotalMemory): Likewise. (JVM_FreeMemory):
+       Likewise. (JVM_NewArray): Use TRACEJVMCALLS.
+       [537eb6a207c4]
+
+2007-08-10  twisti  <twisti>
+
+       * src/native/vm/reflect.c:
+       * src/native/vm/reflect.c (reflect_field_new): Fixed compilation.
+       (reflect_method_new): Likewise.
+       [27deec01d70f]
+
+       * src/cacaoh/dummy.c, src/native/jni.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c,
+       src/vm/Makefile.am, src/vm/builtin.c, src/vm/jit/verify/typecheck-
+       stackbased.c, src/vm/jit/verify/typecheck-typeinferer.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/primitive.c, src/vm/primitive.h, src/vm/resolve.c,
+       src/vm/string.c, src/vm/vm.c, src/vmcore/Makefile.am,
+       src/vmcore/descriptor.c, src/vmcore/field.c, src/vmcore/linker.c,
+       src/vmcore/loader.c, src/vmcore/primitive.c, src/vmcore/primitive.h,
+       src/vmcore/primitivecore.c:
+       * src/vmcore/primitive.c: Removed.
+       * src/vmcore/primitive.h: Likewise.
+
+       * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Removed
+       primitive.[ch].
+
+       * src/vmcore/primitivecore.c: New file.
+       * src/vm/primitive.c: Likwise.
+       * src/vm/primitive.h: Likewise.
+
+       * src/vm/Makefile.am (libvm_la_SOURCES): Added primitive.[ch].
+
+       * src/cacaoh/dummy.c (vm/primitive.h): Added.
+       (primitive_class_get_by_type): New function.
+       (primitive_class_get_by_char): Likewise.
+
+       * src/native/jni.c, src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c,
+       src/vm/builtin.c, src/vm/jit/verify/typecheck-stackbased.c,
+       src/vm/jit/verify/typecheck-typeinferer.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/resolve.c, src/vm/string.c, src/vm/vm.c,
+       src/vmcore/descriptor.c, src/vmcore/field.c, src/vmcore/linker.c,
+       src/vmcore/loader.c: Changed primitive.h include.
+       [42d1724d0ac8]
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_FromReflectedField): Added missing ;.
+       [650582ff466a]
+
+2007-08-10  michi  <michi>
+
+       * src/vm/jit/patcher-common.c, src/vm/jit/powerpc/patcher.c,
+       src/vmcore/linker.c:
+       * src/vm/jit/powerpc/patcher.c (patcher_get_putfield): Fixed severe
+       bug for unalligned long field offsets.
+
+       * src/vmcore/linker.c [__POWERPC__ && __DARWIN__]: Long fields are
+       4-byte alligned in structs.
+
+       * src/vm/jit/patcher-common.c [TRACE_PATCHER]: Left patcher trace
+       code hanging around, might come handy again.
+       [40bd4faac269]
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c:
+       * src/native/vm/gnu/java_lang_reflect_Method.c: Fixed merge problem
+       in previous revision 8284.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise.
+       [26177c366515]
+
+       * src/native/jni.c, src/native/llni.h,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_String.c,
+       src/native/vm/java_lang_Thread.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Method.c, src/native/vm/reflect.c,
+       src/native/vm/sun_misc_Unsafe.c, src/threads/native/threads.c,
+       src/threads/threads-common.c, src/vm/builtin.c, src/vm/exceptions.c,
+       src/vm/jit/stacktrace.c, src/vm/string.c, src/vm/vm.c:
+       * src/native/llni.h: Added LLNI (low level native interface).
+
+       Use LLNI macros throughout the whole codebase:
+       * src/vm/jit/stacktrace.c
+       * src/vm/string.c
+       * src/vm/builtin.c
+       * src/vm/exceptions.c
+       * src/vm/vm.c
+       * src/native/jni.c
+       * src/native/vm/java_lang_ClassLoader.c
+       * src/native/vm/java_lang_Class.c
+       * src/native/vm/java_lang_String.c
+       * src/native/vm/java_lang_Object.c
+       * src/native/vm/gnu/java_lang_VMThread.c
+       * src/native/vm/gnu/java_lang_reflect_Method.c
+       * src/native/vm/gnu/java_lang_reflect_Field.c
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       * src/native/vm/gnu/java_lang_VMThrowable.c
+       * src/native/vm/java_lang_Thread.c
+       * src/native/vm/sun_misc_Unsafe.c
+       * src/native/vm/reflect.c
+       * src/native/vm/java_lang_reflect_Method.c
+       * src/native/vm/java_lang_reflect_Constructor.c
+       * src/threads/threads-common.c
+       * src/threads/native/threads.c
+       [7abb5f785e04]
+
+2007-08-09  twisti  <twisti>
+
+       * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/alpha/linux/md-
+       os.c, src/vm/jit/arm/linux/md-os.c, src/vm/jit/i386/darwin/md-os.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/md.c,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/solaris/md-
+       os.c, src/vm/jit/x86_64/linux/md-os.c, src/vm/signal.c,
+       src/vm/signallocal.h:
+       * src/vm/exceptions.c (toolbox/logging.h): Removed.
+       (vm/jit/disass.h): Likewise. (exceptions_new_hardware_exception):
+       Likewise.
+
+       * src/vm/exceptions.h (exceptions_new_hardware_exception): Likewise.
+
+       * src/vm/signal.c (stdint.h): Added. (toolbox/logging.h): Likewise.
+       (vm/jit/codegen-common.h): Likewise. (vm/jit/disass.h): Likewise.
+       (vm/jit/patcher-common.h): Likewise. (signal_handle): New function.
+
+       * src/vm/signallocal.h (signal_handle): Likewise.
+
+       * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/m68k/linux/md-os.c, src/vm/jit/mips/irix/md-os.c,
+       src/vm/jit/mips/linux/md-os.c, src/vm/jit/powerpc/darwin/md-os.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc64/linux/md-
+       os.c, src/vm/jit/s390/md.c, src/vm/jit/sparc64/linux/md-os.c,
+       src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/x86_64/linux/md-os.c:
+       Use new signal_handle function.
+       [782800380bb8]
+
+       * src/vm/signal.c, src/vm/signallocal.h:
+       * src/vm/signal.c (vm/types.h): Removed. (signal_init): Use
+       signal_register_signal. (signal_register_signal): New function.
+
+       * src/vm/signallocal.h (vm/types.h): Removed.
+       (signal_register_signal): New function.
+       [55ce6c52817b]
+
+       * NEWS:
+       * NEWS: Added news.
+       [d615712a54cb]
+
+       * NEWS:
+       * NEWS: Added 0.99 release and some news.
+       [bb055927a1b4]
+
+2007-08-09  michi  <michi>
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/linux/md-os.c:
+       * src/vm/jit/alpha/linux/md-os.c [ENABLE_REPLACEMENT]
+       (md_replace_executionstate_read): Implemented. [ENABLE_REPLACEMENT]
+       (md_replace_executionstate_write): Likewise.
+
+       * src/vm/jit/alpha/asmpart.S (asm_replacement_out): Removed.
+       (asm_replacement_in): Likewise.
+       [0e6fe86aa40d]
+
+2007-08-08  michi  <michi>
+
+       * src/vm/jit/asmpart.h, src/vm/jit/replace.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c:
+       * src/vm/jit/s390/emit.c (emit_replacement_stubs): Removed obsolete
+       function.
+       * src/vm/jit/s390/codegen.c (codegen_emit): Do not create replacement
+       stubs.
+       * src/vm/jit/replace.c (replace_me): No longer call
+       asm_replacement_in.
+       * src/vm/jit/asmpart.h [ENABLE_REPLACEMENT]: Removed obsolete
+       prototypes.
+       [a336a3194fe3]
+
+       * src/vm/builtin.c, src/vmcore/class.c, src/vmcore/linker.c:
+       * src/vmcore/linker.c (linker_compute_subclasses): Added attention
+       notice about the locking mechanism.
+
+       * src/vmcore/class.c (class_isanysubclass): Uses
+       linker_classrenumber_lock now.
+
+       * src/vm/builtin.c (builtin_canstore): Likewise.
+       (builtin_canstore_onedim): Likewise.
+       (builtin_canstore_onedim_class): Likewise.
+       [2173a4b92ae4]
+
+2007-08-08  twisti  <twisti>
+
+       * src/vm/jit/arm/asmpart.S:
+       * src/vm/jit/arm/asmpart.S (offsets.h): Removed.
+       [7864c8165337]
+
+       * configure.ac, src/threads/critical.c, src/vm/jit/Makefile.am,
+       src/vm/jit/alpha/Makefile.am, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/arm/Makefile.am, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/asmpart.h, src/vm/jit/i386/Makefile.am,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/Makefile.am,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/mips/Makefile.am,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/Makefile.am,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/darwin/md-asm.h,
+       src/vm/jit/powerpc64/Makefile.am, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/s390/Makefile.am, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/sparc64/Makefile.am, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/tools/Makefile.am, src/vm/jit/tools/genoffsets.c,
+       src/vm/jit/x86_64/Makefile.am, src/vm/jit/x86_64/asmpart.S:
+       * src/vm/jit/tools: Removed.
+
+       * configure.ac (AC_CONFIG_FILES): Removed src/vm/jit/tools/Makefile.
+       * src/vm/jit/Makefile.am (DIST_SUBDIRS): Removed tools. (SUBDIRS):
+       Likewise.
+
+       * src/threads/critical.c (stdint.h): Added. (vm/jit/asmpart.h):
+       Removed. (critical_init): Don't call
+       critical_register_asm_critical_sections.
+       (critical_register_asm_critical_sections): Removed.
+
+       * src/vm/jit/asmpart.h (ASM_GETCLASSVALUES_ATOMIC): Removed.
+       (asm_criticalsections): Likewise. (asm_getclassvalues_atomic):
+       Likewise. (intrp_asm_getclassvalues_atomic): Likewise.
+
+       * src/vm/jit/alpha/Makefile.am, src/vm/jit/arm/Makefile.am,
+       src/vm/jit/i386/Makefile.am, src/vm/jit/m68k/Makefile.am,
+       src/vm/jit/mips/Makefile.am, src/vm/jit/powerpc/Makefile.am,
+       src/vm/jit/powerpc64/Makefile.am, src/vm/jit/s390/Makefile.am,
+       src/vm/jit/sparc64/Makefile.am, src/vm/jit/x86_64/Makefile.am
+       (BUILT_SOURCES): Removed (CLEANFILES): Likewise. (offsets.h):
+       Likewise.
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S
+       (offsets.h): Removed. (asm_getclassvalues_atomic): Likewise.
+       (asm_criticalsections): Likewise.
+
+       * src/vm/jit/powerpc/darwin/md-asm.h (asm_criticalsections):
+       Removed. (asm_getclassvalues_atomic): Likewise.
+       [62317689105b]
+
+       * src/vm/builtin.c, src/vmcore/class.c:
+       * src/vmcore/class.c (class_isanysubclass): Don't use
+       ASM_GETCLASSVALUES_ATOMIC anymore, we will change that to use the
+       class-renumbering lock.
+
+       * src/vm/builtin.c (builtin_canstore): Likewise.
+       (builtin_canstore_onedim): Likewise.
+       (builtin_canstore_onedim_class): Likewise.
+       [60640d7b8794]
+
+       * src/native/vm/java_lang_Thread.c, src/threads/threads-common.c:
+       * src/threads/threads-common.c (stdint.h): Added.
+       (threads_thread_free): Also save and restore the thread state (this
+       is required for CLDC1.1, but is generally a good idea).
+
+       * src/native/vm/java_lang_Thread.c (isAlive)
+       [WITH_CLASSPATH_CLDC1_1]: Check for NULL.
+       [4478b69824a6]
+
+       * src/vm/jit/m68k/md.c, src/vm/jit/tools/genoffsets.c, src/vm/vm.h:
+       * src/vm/vm.h (vm_arg): Removed.
+
+       * src/vm/jit/tools/genoffsets.c (main): Removed sizevmarg,
+       offvmargtype and offvmargdata.
+
+       * src/vm/jit/m68k/md.c (md_init): Removed some obsolete checks.
+       [90eedc2247c7]
+
+       * src/native/jni.c, src/vm/exceptions.c, src/vm/jit/asmpart.h,
+       src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/md-abi.c,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c,
+       src/vm/vm.c, src/vm/vm.h:
+       * src/vm/vm.c (vm_array_store_flt): Handle __POWERPC__ correctly.
+       (vm_vmargs_from_valist): Removed. (vm_vmargs_from_jvalue): Likewise.
+       (vm_vmargs_from_objectarray): Likewise. (vm_call_method_vmarg):
+       Likewise. (vm_call_method_int_vmarg): Likewise.
+       (vm_call_method_int_valist): Likewise. (vm_call_method_int_jvalue):
+       Likewise. (vm_call_method_long_vmarg): Likewise.
+       (vm_call_method_long_valist): Likewise.
+       (vm_call_method_long_jvalue): Likewise.
+       (vm_call_method_float_vmarg): Likewise.
+       (vm_call_method_float_valist): Likewise.
+       (vm_call_method_float_jvalue): Likewise.
+       (vm_call_method_double_vmarg): Likewise.
+       (vm_call_method_double_valist): Likewise.
+       (vm_call_method_double_jvalue): Likewise. (vm_call_method_valist):
+       Removed old implementation. (vm_call_method_jvalue): Likewise.
+
+       * src/vm/vm.h: Removed old prototypes.
+       * src/vm/jit/asmpart.h: Likewise.
+
+       * src/vm/exceptions.c (exceptions_handle_exception) [__POWERPC__]:
+       Get monitor object correctly (talk to Michi because of ARM).
+
+       * src/native/jni.c (_Jv_jni_invokeNative): Removed old
+       implementation.
+
+       * src/vm/jit/powerpc/linux/md-abi.c (md_param_alloc): Use 8-byte
+       stackslots. (md_param_alloc_native): Implemented native ABI.
+
+       * src/vm/jit/powerpc/emit.c (emit_load): Merged TYPE_FLT and
+       TYPE_DBL. (emit_store): Likewise
+       * src/vm/jit/powerpc/darwin/md-abi.c: Likewise.
+
+       * src/vm/jit/powerpc/arch.h (HAS_4BYTE_STACKSLOT): Removed.
+       (ALIGN_LONGS_IN_MEMORY): Likewise. (ALIGN_DOUBLES_IN_MEMORY):
+       Likewise.
+
+       * src/vm/jit/powerpc/codegen.c: Implemented 8-byte stackslots,
+       always load and store float-values as double (PowerPC's internal
+       register representation is the same).
+
+       * src/vm/jit/powerpc/asmpart.S (asm_vm_call_method): Use new
+       argument array. (asm_handle_exception): Restore callee-saved
+       registers from the correct location.
+       [ebe852e9b203]
+
+2007-08-07  twisti  <twisti>
+
+       * tests/rtIn/at/dms/kjc/Main, tests/rtMissedIn0:
+       * tests/rtMissedIn0: Removed.
+       * tests/rtIn: Likewise.
+       [f86792ac8455]
+
+       * src/native/jni.c, src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/sun_misc_Unsafe.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/patcher.c, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/patcher.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/patcher.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/patcher.c, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/patcher.c, src/vmcore/field.c, src/vmcore/field.h,
+       src/vmcore/loader.c:
+       * src/vmcore/field.c (mm/memory.h): Added. (vm/global.h): Likewise.
+       (field_load): Allocate value memory only for static and final
+       fields.
+
+       * src/vmcore/field.h (fieldinfo): Made value a pointer.
+
+       * src/vmcore/loader.c (load_class_from_classbuffer): Allocate
+       fieldinfo's on the C heap.
+
+       * src/native/jni.c: fieldinfo->value is now a pointer.
+       * src/native/vm/sun_misc_Unsafe.c: Likewise.
+       * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise.
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/patcher.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/patcher.c: Likewise.
+       [49bab45fbf51]
+
+       * src/vm/jit/i386/emit.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/i386/emit.c (emit_trap): New function.
+       * src/vm/jit/powerpc64/emit.c: Likewise.
+       * src/vm/jit/x86_64/emit.c: Likewise.
+       [d544fbdb5d62]
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_preinit): Fixed compiler
+       warning.
+       [d070b6565b63]
+
+2007-08-06  twisti  <twisti>
+
+       * src/vm/jit/emit-common.c, src/vm/jit/emit-common.h:
+       * src/vm/jit/emit-common.c: Set Id keyword.
+       * src/vm/jit/emit-common.h: Likewise.
+       [1b592a73a3b0]
+
+       * src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/patcher-common.h,
+       src/vm/jit/patcher.h:
+       * src/vm/jit/patcher-common.h: Added __MIPS__ for new patcher
+       functions.
+
+       * src/vm/jit/patcher.h: Added __MIPS__ to include-check.
+
+       * src/vm/jit/mips/emit.c (vm/jit/patcher-common.h): Added.
+       (emit_patcher_stubs): Removed. (emit_trap): Added.
+
+       * src/vm/jit/mips/codegen.c (vm/jit/patcher.h): Removed. (vm/jit
+       /patcher-common.h): Added. (codegen_emit): Replaced
+       codegen_add_patch_ref with patcher_add_patch_ref, and
+       emit_patcher_stubs with emit_patcher_traps.
+       (codegen_emit_stub_native): Likewise.
+
+       * src/vm/jit/mips/codegen.h (PATCHER_CALL_INSTRUCTIONS): Changed to
+       1. (PATCHER_CALL_SIZE): Changed to 1*4. (PATCHER_NOPS): Emit only
+       one NOP.
+
+       * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Check
+       for exception, set PC in trap-case.
+
+       * src/vm/jit/mips/irix/md-os.c (md_signal_handler_sigsegv): Check
+       for exception.
+
+       * src/vm/jit/mips/patcher.c: Renamed function to new patcher
+       functions, and use patcher references. (vm/jit/patcher.h): Removed.
+       (vm/jit/patcher-common.h): Added (patcher_wrapper): Removed.
+
+       * src/vm/jit/mips/asmpart.S (asm_patcher_wrapper): Removed.
+       [3927f23b8cb3]
+
+       * src/vm/jit/mips/arch.h:
+       * src/vm/jit/mips/arch.h (SUPPORT_PASS_FLOATARGS_IN_INTREGS):
+       Removed duplicate define.
+       [db0217c3ef05]
+
+2007-08-06  panzi  <panzi>
+
+       * src/lib/Makefile.am, src/lib/gnu/java/lang/reflect/Constructor.java,
+       src/lib/gnu/java/lang/reflect/Field.java,
+       src/lib/gnu/java/lang/reflect/Method.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java,
+       src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/reflect.c,
+       src/native/vm/reflect.h, src/native/vm/sun/jvm.c,
+       src/vmcore/annotation.c, src/vmcore/method.c, src/vmcore/method.h:
+       * src/lib/gnu/java/lang/reflect/Method.java
+       (java.lang.annotation.Annotation): Added import. (java.util.Map):
+       Added import. (sun.refelct.annotation.AnnotationParser): Added
+       import. (declaredAnnotations): Added field (inspired by OpenJDK).
+       (getAnnotation): Added method. (getDeclaredAnnotations): Added
+       method. (declaredAnnotations): Added method (inspired by OpenJDK).
+       (getParameterAnnotations): Added method.
+
+       * src/lib/gnu/java/lang/reflect/Field.java
+       (java.lang.annotation.Annotation): Added import. (java.util.Map):
+       Added import. (sun.refelct.annotation.AnnotationParser): Added
+       import. (declaredAnnotations): Added field (inspired by OpenJDK).
+       (getAnnotation): Added method. (getDeclaredAnnotations): Added
+       method. (declaredAnnotations): Added method (inspired by OpenJDK).
+
+       * src/lib/gnu/java/lang/reflect/Constructor.java: Copied file from
+       GNU Classpath. (java.lang.annotation.Annotation): Added import.
+       (java.util.Map): Added import.
+       (sun.refelct.annotation.AnnotationParser): Added import.
+       (declaredAnnotations): Added field (inspired by OpenJDK).
+       (getAnnotation): Added method. (getDeclaredAnnotations): Added
+       method. (declaredAnnotations): Added method (inspired by OpenJDK).
+       (getParameterAnnotations): Added method.
+
+       * src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java:
+       Removed.
+
+       * src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java:
+       Removed. I figured out which class of GNU Classpath to use to
+       replace this self written class.
+
+       * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java: Added a
+       few comments. (sun.reflect.generics.parser.SignatureParser): Removed
+       import. (sun.reflect.generics.parser.SignatureFormatError): Removed
+       import. (gnu.java.lang.reflect.FieldSignatureParser): Added import.
+       (parseParameterAnnotations): Added method. (parseSig): Changed
+       method so it uses GNU Classpaths FieldSignatureParser.
+
+       * src/lib/Makefile.am (VM_JAVA_FILES): Added
+       $(top_srcdir)/src/lib/gnu/java/lang/reflect/Constructor.java
+       (VM_CLASS_FILES): Added classes/java/lang/reflect/Constructor.class
+
+       * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (_Jv_java_lang_Class_getDeclaredAnnotations):
+       Cache methodinfo for
+       sun.reflect.annotation.AnnotationParser.parseAnnotationsIntoArray.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c [ENABLE_ANNOTATIONS]
+       (native/vm/reflect.h): Added include. [ENABLE_ANNOTATIONS]
+       (declaredAnnotations): Added method. [ENABLE_ANNOTATIONS]
+       (getParameterAnnotations): Added method. [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Method_getDefaultValue): Cache methodinfo
+       for sun.reflect.annotation.AnnotationParser.parseDefaultValue.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Method_declaredAnnotations): Added.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Method_getParameterAnnotations): Added.
+
+       * src/native/vm/gnu/java_lang_reflect_Field.c [ENABLE_ANNOTATIONS]
+       (native/include/sun_reflect_ConstantPool.h): Added include.
+       [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added include.
+       [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Field_declaredAnnotations): Added.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       [ENABLE_ANNOTATIONS] (vm/vm.h): Added include. [ENABLE_ANNOTATIONS]
+       (native/include/sun_reflect_ConstantPool.h): Added include.
+       [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added include.
+       [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method.
+       [ENABLE_ANNOTATIONS] (getParameterAnnotations): Added method.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Constructor_declaredAnnotations): Added.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Constructor_getParameterAnnotations): Added.
+
+       * src/native/vm/reflect.c [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (vm/vm.h): Added include. [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (native/include/sun_reflect_ConstantPool.h): Added include.
+       [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (reflect_get_declaredannotatios): Added. [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (reflect_get_parameterannotations): Added.
+
+       * src/native/vm/reflect.h [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (reflect_get_declaredannotatios): Added. [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (reflect_get_parameterannotations): Added.
+
+       * src/native/vm/sun/jvm.c (JVM_GetDeclaredClasses): Implemented
+       (needed by a testcase of mine).
+
+       * src/vmcore/method.c (method_get_parametercount): Added. This
+       function gets the parameter count of a method (not counting the this
+       pointer of non-static methods). Returns -1 in case of an error.
+
+       * src/vmcore/method.h (method_get_parametercount): Added.
+       [f5cb5fb3404e]
+
+2007-08-06  michi  <michi>
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Removed
+       obsolete code about PATCHER_LONGBRANCHES_NOPS.
+       [1bc6a2ee1f2d]
+
+       * src/vm/jit/alpha/emit.c, src/vm/jit/arm/emit.c, src/vm/jit/emit-
+       common.c, src/vm/jit/emit-common.h, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/s390/emit.c:
+       * src/vm/jit/emit-common.c (emit_patcher_traps): Added.
+
+       * src/vm/jit/emit-common.h (emit_trap): Added prototype.
+
+       * src/vm/jit/alpha/emit.c (emit_patcher_traps): Removed (moved to
+       emit-common). (emit_trap): Implemented.
+
+       * src/vm/jit/arm/emit.c: Likewise.
+
+       * src/vm/jit/powerpc/emit.c: Likewise.
+
+       * src/vm/jit/s390/emit.c: Likewise.
+       [346f9ec5827a]
+
+2007-08-05  edwin  <edwin>
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_read_executionstate): Improved
+       comments. (replace_write_executionstate): Likewise.
+       [6aec81ae2149]
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_new_sourceframe): Fixed
+       documentation.
+       [77f8bf7f70b4]
+
+2007-08-05  twisti  <twisti>
+
+       * src/vm/jit/patcher-common.c:
+       * src/vm/jit/patcher-common.c (stdint.h): Added.
+       (patcher_list_free): Removed unused variable pr.
+       (patcher_add_patch_ref): Fixed warning.
+       [e43253cb24fb]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_Available) [FIONREAD]: Use HotSpot-
+       compatible code.
+       [5142a17c3bc0]
+
+2007-08-03  michi  <michi>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/patcher-common.c, src/vm/jit
+       /patcher-common.h:
+       * src/vm/jit/patcher-common.c (patcher_list_reset): Added.
+       (patcher_add_patch_ref) [!NDEBUG]: Added sanity check.
+
+       * src/vm/jit/patcher-common.h (patcher_list_reset): Added.
+
+       * src/vm/jit/codegen-common.c (codegen_reset): Resets the patcher
+       list.
+       [26187f44fa78]
+
+2007-08-03  pm  <pm>
+
+       * src/vm/jit/patcher-common.c:
+       * src/vm/jit/patcher-common.c (patcher_handler): Call
+       LOCK_MONITOR_EXIT instead of LOCK_MONITOR_ENTER in double-patching
+       handler code.
+       [df81594b92d3]
+
+2007-08-02  twisti  <twisti>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_RaiseSignal): New function.
+       [bfad8af45e64]
+
+2007-08-01  twisti  <twisti>
+
+       * m4/ac_prog_javac.m4, src/lib/Makefile.am:
+       * m4/ac_prog_javac.m4 (AC_PROG_JAVAC): Removed -1.5 from ecj.
+
+       * src/lib/Makefile.am (vm.zip): Added -source 1.5 -target 1.5.
+       Thanks to Mark Wielaard.
+       [a38b1afb2c67]
+
+2007-08-01  pm  <pm>
+
+       * src/vm/jit/patcher-common.h, src/vm/jit/patcher.h,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c:
+       * jit/patcher.h: Added #error if included on s390.
+       * jit/patcher-common.h: Made declarations visible on s390.
+       * jit/s390/asmpart.S (asm_patcher_wrapper): removed.
+       * jit/s390/emit.c (emit_patcher_stubs): removed, (emit_patcher_traps):
+       added.
+       * jit/s390/codegen.h (PATCHER_LONGBRANCHES_NOPS_SKIP,
+       PATCHER_LONGBRANCHES_NOPS): removed, (PATCHER_CALL_SIZE,
+       PATCHER_NOPS, PATCHER_NOPS_SKIP) adapted to patching via signals.
+       * jit/s390/codegen.c (codegen_emit, codegen_emit_stub_native): Adapted
+       to paching via signals.
+       * jit/s390/md.c (md_signal_handler_sigill, md_signal_handler_sigsegv):
+       added support for exceptions_new_hardware_exception returning NULL.
+       * jit/s390/patcher.c: Adapted to paching via signals.
+       [d5451a151292]
+
+2007-07-31  twisti  <twisti>
+
+       * configure.ac, m4/annotations.m4:
+       * m4/annotations.m4: New file.
+       * configure.ac: Use AC_CHECK_ENABLE_ANNOTATIONS.
+       [cf7daf180ded]
+
+2007-07-31  panzi  <panzi>
+
+       * configure.ac, src/lib/Makefile.am,
+       src/lib/gnu/java/lang/reflect/Field.java,
+       src/lib/gnu/java/lang/reflect/Method.java,
+       src/lib/gnu/sun/reflect/ConstantPool.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationParser.java,
+       src/lib/gnu/sun/reflect/annotation/AnnotationType.java, src/lib/gnu/
+       sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, sr
+       c/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java,
+       src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java,
+       src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java,
+       src/native/include/Makefile.am, src/native/vm/gnu/Makefile.am,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/sun_reflect_ConstantPool.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/nativevm.c, src/native/vm/nativevm.h,
+       src/native/vm/reflect.c, src/native/vm/sun/jvm.c,
+       src/vmcore/Makefile.am, src/vmcore/annotation.c,
+       src/vmcore/annotation.h, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/field.c, src/vmcore/field.h, src/vmcore/loader.c,
+       src/vmcore/method.c, src/vmcore/method.h, src/vmcore/utf8.c,
+       src/vmcore/utf8.h:
+       * src/lib/gnu/java/lang/reflect/Method.java (annotations): Added.
+       (parameterAnnotations): Added. (annotationDefault): Added.
+
+       * src/lib/gnu/java/lang/reflect/Field.java (annotations): Added.
+
+       * src/lib/gnu/sun/reflect: New directory.
+       * src/lib/gnu/sun/reflect/generics: New directory.
+       * src/lib/gnu/sun/reflect/generics/parser: New directory.
+       * src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java:
+       New file.
+
+       * src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java: New
+       file. This class parses type signatures and returns the acording
+       type as a java.lang.Class instance.
+
+       * src/lib/gnu/sun/reflect/ConstantPool.java [WITH_CLASSPATH_GNU]:
+       New file.
+
+       * src/lib/gnu/sun/reflect/annotation: New directory.
+       * src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionPr
+       oxy.java [WITH_CLASSPATH_GNU]: Copied file from OpenJDK.
+
+       *
+       src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
+       [WITH_CLASSPATH_GNU]: Copied file from OpenJDK.
+
+       * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java
+       [WITH_CLASSPATH_GNU]: Copied file from OpenJDK and changed a bit so
+       it can be used with GNU Classpath. [WITH_CLASSPATH_GNU]
+       (parseAnnotationsIntoArray): Added for convenience.
+       [WITH_CLASSPATH_GNU] (parseAnnotationDefault): Added for
+       convenience.
+
+       * src/lib/gnu/sun/reflect/annotation/AnnotationType.java
+       [WITH_CLASSPATH_GNU]: Copied file from OpenJDK and changed a bit so
+       it can be used with GNU Classpath. [WITH_CLASSPATH_GNU]
+       (annotationTypes): Added to emulate
+       sun.misc.SharedSecrets.getJavaLangAccess().getAnnotationType() and
+       sun.misc.SharedSecrets.getJavaLangAccess().setAnnotationType().
+
+       * src/lib/Makefile.am [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]:
+       Added classes needed by annotations support.
+
+       * src/native/vm/nativevm.h [ENABLE_ANNOTATIONS]
+       (_Jv_sun_reflect_ConstantPool_init): Added.
+
+       * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (vmcore/annotation.h): Include added.
+       [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (native/include/sun_reflect_ConstantPool.h): Include added.
+       [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (_Jv_java_lang_Class_getDeclaredAnnotations): Implemented.
+
+       * src/native/vm/gnu/java_lang_VMClass.c [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_VMClass_getDeclaredAnnotations): Implemented.
+
+       * src/native/vm/gnu/sun_reflect_ConstantPool.c [ENABLE_ANNOTATIONS]:
+       Added implementation of sun.reflect.ConstantPool class. This is an
+       copy of the according functions from src/native/vm/sun/jvm.c for I
+       don't know how to unify it better (needs to be discussed).
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c [ENABLE_ANNOTATIONS]
+       (vm/vm.h): Added include. [ENABLE_ANNOTATIONS]
+       (native/include/sun_reflect_ConstantPool.h): Added include.
+       [ENABLE_ANNOTATIONS]
+       (Java_java_lang_reflect_Method_getDefaultValue): Implemented.
+
+       * src/native/vm/gnu/Makefile.am [ENABLE_ANNOTATIONS]
+       (SUN_REFLECT_SOURCES): Added sun_reflect_ConstantPool.c
+
+       * src/native/vm/java_lang_Class.h [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (_Jv_java_lang_Class_getDeclaredAnnotations):
+       Added.
+
+       * src/native/vm/sun/jvm.c (assert.h): Added include.
+       (native/include/java_lang_Integer.h): Added include.
+       (native/include/java_lang_Long.h): Added include.
+       (native/include/java_lang_Short.h): Added include.
+       (native/include/java_lang_Byte.h): Added include.
+       (native/include/java_lang_Character.h): Added include.
+       (native/include/java_lang_Boolean.h): Added include.
+       (native/include/java_lang_Float.h): Added include.
+       (native/include/java_lang_Double.h): Added include.
+       [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h):
+       Added include. (JVM_GetDeclaringClass): Implemented.
+       (JVM_GetClassAnnotations) [ENABLE_ANNOTATIONS]: Implemented.
+       (JVM_GetFieldAnnotations): Implemented. (JVM_GetMethodAnnotations):
+       Implemented. (JVM_GetMethodDefaultAnnotationValue): Implemented.
+       (JVM_GetMethodParameterAnnotations): Implemented.
+       [ENABLE_ANNOTATIONS] (JVM_GetClassConstantPool): Implemented.
+       (JVM_ConstantPoolGetSize): Implemented.
+       (JVM_ConstantPoolGetClassAt): Implemented.
+       (JVM_ConstantPoolGetClassAtIfLoaded): Implemented.
+       (JVM_ConstantPoolGetMethodAt): Implemented.
+       (JVM_ConstantPoolGetMethodAtIfLoaded): Implemented.
+       (JVM_ConstantPoolGetFieldAt): Implemented.
+       (JVM_ConstantPoolGetFieldAtIfLoaded): Implemented.
+       (JVM_ConstantPoolGetIntAt): Implemented.
+       (JVM_ConstantPoolGetLongAt): Implemented.
+       (JVM_ConstantPoolGetFloatAt): Implemented.
+       (JVM_ConstantPoolGetDoubleAt): Implemented.
+       (JVM_ConstantPoolGetStringAt): Implemented.
+       (JVM_ConstantPoolGetUTF8At): Implemented. (JVM_GetArrayElement):
+       Quickly implemented (will be rewritten by twisti). I needed this
+       function in a testcase and not directly for annotations support.
+
+       * src/native/vm/reflect.c [ENABLE_ANNOTATIONS] (mm/memmory.h): Added
+       include. (reflect_constructor_new) [ENABLE_ANNOTATIONS]: Load
+       annotations and parameter annotations. (reflect_field_new)
+       [ENABLE_ANNOTATIONS]: Load annotations. (reflect_method_new)
+       [ENABLE_ANNOTATIONS]: Load annotations, parameter annotations and
+       annotation default value.
+
+       * src/native/vm/nativevm.c [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]
+       (_Jv_sun_reflect_ConstantPool_init): Added call.
+
+       * src/native/include/Makefile.am [WITH_CLASSPATH_GNU]
+       [ENABLE_ANNOTATIONS] (JAVASE_HEADER_FILES): Added
+       sun_reflect_ConstantPool.h
+
+       * src/vmcore/class.c [ENABLE_ANNOTATIONS]
+       (class_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS]
+       (class_sun_reflect_annotation_AnnotationParser): Added.
+       (class_load_attributes) [ENABLE_ANNOTATIONS]: Load annotations.
+       (class_free) [ENABLE_ANNOTATIONS]: Free annotations.
+
+       * src/vmcore/loader.c (loader_init) [ENABLE_ANNOTATIONS]: Load
+       class_sun_reflect_ConstantPool. (loader_init) [ENABLE_ANNOTATIONS]
+       [WITH_CLASSPATH_GNU]: Load
+       class_sun_reflect_annotation_AnnotationParser.
+
+       * src/vmcore/annotation.c [!ENABLE_ANNOTATIONS]: Error: annotation
+       support has to be enabled when compling this file. (assert.h): Added
+       include. (toolbox/logging.h): Added include.
+       (annotation_bytearray_new): Added. (annotation_bytearray_free):
+       Added. (annotation_bytearrays_new): Added.
+       (annotation_bytearrays_resize): Added.
+       (annotation_bytearrays_insert): Added. (annotation_bytearrays_free):
+       Added. (annotation_load_attribute_body): Added. Maybe this function
+       should be called loader_load_attribute_body and located in
+       vmcore/loader.c?
+       (annotation_load_method_attribute_annotationdefault): Added. (annota
+       tion_load_method_attribute_runtimevisibleparameterannotations):
+       Added. (annotation_load_method_attribute_runtimeinvisibleparameteran
+       notations): Added.
+       (annotation_load_class_attribute_runtimevisibleannotations): Added.
+       (annotation_load_class_attribute_runtimeinvisibleannotations):
+       Added. (annotation_load_method_attribute_runtimevisibleannotations):
+       Added.
+       (annotation_load_method_attribute_runtimeinvisibleannotations):
+       Added. (annotation_load_field_attribute_runtimevisibleannotations):
+       Added.
+       (annotation_load_field_attribute_runtimeinvisibleannotations):
+       Added.
+
+       * src/vmcore/class.h [ENABLE_ANNOTATIONS]
+       (runtimevisibleannotationscount): Removed. [ENABLE_ANNOTATIONS]
+       (runtimevisibleannotations): Removed. [ENABLE_ANNOTATIONS]
+       (annotations): Added. Bytearray of the unparsed annotations or NULL
+       if none. [ENABLE_ANNOTATIONS] (method_annotations): Added. Array of
+       bytearrays of method annotations. This Array is only as big as
+       needed or NULL if there are no method annotations at all.
+       [ENABLE_ANNOTATIONS] (method_parameterannotations): Added. Array of
+       bytearrays of method parameter annotations. This Array is only as
+       big as needed or NULL if there are no method parameter annotations
+       at all. [ENABLE_ANNOTATIONS] (method_annotationdefaults): Added.
+       Array of bytearrays of method annotation default values. This Array
+       is only as big as needed or NULL if there are no method annotation
+       default values at all. [ENABLE_ANNOTATIONS] (field_annotations):
+       Added. Array of bytearrays of field annotations. This Array is only
+       as big as needed or NULL if there are no field annotations at all.
+       [ENABLE_ANNOTATIONS] (class_sun_reflect_ConstantPool): Added.
+       [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU]
+       (class_sun_reflect_annotation_AnnotationParser): Added.
+
+       * src/vmcore/annotation.h (annotation_bytearray_t): Added. Used to
+       store unparsed (parameter-) annotations or unparsed annotation
+       default values in. (annotation_bytearrays_t): Added. Array of
+       bytearrays. (annotation_bytearray_new): Added.
+       (annotation_bytearray_free): Added. (annotation_bytearrays_new):
+       Added. (annotation_bytearrays_resize): Added.
+       (annotation_bytearrays_insert): Added. (annotation_bytearrays_free):
+       Added.
+       (annotation_load_class_attribute_runtimeinvisibleannotations):
+       Added. (annotation_load_method_attribute_runtimevisibleannotations):
+       Added.
+       (annotation_load_method_attribute_runtimeinvisibleannotations):
+       Added. (annotation_load_field_attribute_runtimevisibleannotations):
+       Added.
+       (annotation_load_field_attribute_runtimeinvisibleannotations):
+       Added. (annotation_load_method_attribute_annotationdefault): Added. (
+       annotation_load_method_attribute_runtimevisibleparameterannotations)
+       : Added. (annotation_load_method_attribute_runtimeinvisibleparameter
+       annotations): Added.
+
+       * src/vmcore/method.c (method_load) [ENABLE_ANNOTATIONS]: Load
+       annotations, parameter annotations and annotation default values.
+       [ENABLE_ANNOTATIONS] (method_get_annotations): Added.
+       [ENABLE_ANNOTATIONS] (method_get_parameterannotations): Added.
+       [ENABLE_ANNOTATIONS] (method_get_annotationdefault): Added.
+
+       * src/vmcore/method.h [ENABLE_ANNOTATIONS] (method_get_annotations):
+       Added. [ENABLE_ANNOTATIONS] (method_get_parameterannotations):
+       Added. [ENABLE_ANNOTATIONS] (method_get_annotationdefault): Added.
+
+       * src/vmcore/field.c (mm/memory.h): Added include.
+       (vmcore/annotations.h): Added include. (field_load)
+       [ENABLE_ANNOTATIONS]: Laod annotations. [ENABLE_ANNOTATIONS]
+       (field_get_annotations): Added.
+
+       * src/vmcore/utf8.c [ENABLE_ANNOTATIONS]
+       (utf_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS]
+       (utf_RuntimeInvisibleAnnotations): Added. [ENABLE_ANNOTATIONS]
+       (utf_RuntimeVisibleParameterAnnotations): Added.
+       [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleParameterAnnotations):
+       Added. [ENABLE_ANNOTATIONS] (utf_AnnotationDefault): Added.
+       [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU]
+       (utf_sun_reflect_annotation_AnnotationParser): Added.
+
+       * src/vmcore/field.h [ENABLE_ANNOTATIONS] (field_get_annotations):
+       Added.
+
+       * src/vmcore/Makefile.am [ENABLE_ANNOTATIONS] (ANNOTATION_SOURCES):
+       Only compile annotations sources when annotations are enabled.
+
+       * src/vmcore/utf8.h [ENABLE_ANNOTATIONS]
+       (utf_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS]
+       (utf_RuntimeInvisibleAnnotations): Added. [ENABLE_ANNOTATIONS]
+       (utf_RuntimeVisibleParameterAnnotations): Added.
+       [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleParameterAnnotations):
+       Added. [ENABLE_ANNOTATIONS] (utf_AnnotationDefault): Added.
+       [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU]
+       (utf_sun_reflect_annotation_AnnotationParser): Added.
+
+       * configure.ac (ENABLE_ANNOTATIONS): Added configure option
+       --enable-annotations.
+       [ab4f34149780]
+
+2007-07-31  twisti  <twisti>
+
+       * configure.ac, m4/classpath.m4:
+       * configure.ac: Only check AC_PROG_JAVAC and AC_PROG_JAR for
+       CLDC-1.1 and GNU.
+
+       * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Changed default
+       value for different configurations..
+       [d7d167268026]
+
+2007-07-31  michi  <michi>
+
+       * src/vm/jit/alpha/arch.h, src/vm/jit/alpha/md.c,
+       src/vm/jit/arm/arch.h, src/vm/jit/i386/arch.h, src/vm/jit/i386/md.c,
+       src/vm/jit/mips/arch.h, src/vm/jit/mips/md.c,
+       src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/md.c,
+       src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/s390/arch.h, src/vm/jit/sparc64/arch.h,
+       src/vm/jit/sparc64/md.c, src/vm/jit/x86_64/arch.h,
+       src/vm/jit/x86_64/md.c:
+       * src/vm/jit/arm/arch.h, src/vm/jit/powerpc/arch.h,
+       src/vm/jit/sparc64/arch.h, src/vm/jit/alpha/arch.h,
+       src/vm/jit/s390/arch.h, src/vm/jit/mips/arch.h,
+       src/vm/jit/powerpc64/arch.h, src/vm/jit/i386/arch.h,
+       src/vm/jit/x86_64/arch.h (REPLACEMENT_STUB_SIZE): Removed obsolete
+       define.
+
+       * src/vm/jit/powerpc/md.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/alpha/md.c, src/vm/jit/mips/md.c,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/i386/md.c,
+       src/vm/jit/x86_64/md.c (md_patch_replacement_point): We have to use
+       trap instructions here.
+       [ae987e4ea783]
+
+       * src/vm/jit/sparc64/md.c:
+       * src/vm/jit/sparc64/md.c: Fixed file header.
+       [97bdf942d526]
+
+       * THIRDPARTY, m4/ac_prog_javac.m4, src/cacaoh/dummy.c, src/mm/boehm.c,
+       src/native/include/Makefile.am, src/native/jni.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/sun_misc_Unsafe.c, src/threads/native/threads.h,
+       src/threads/threads-common.h, src/vm/access.c, src/vm/builtin.c,
+       src/vm/builtintable.inc, src/vm/exceptions.c, src/vm/exceptions.h,
+       src/vm/global.h, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/asmpart.h, src/vm/jit/code.h, src/vm/jit/codegen-
+       common.c, src/vm/jit/emit-common.h, src/vm/jit/i386/arch.h,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md-abi.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/md.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/irix/md-os.c,
+       src/vm/jit/mips/linux/md-os.c, src/vm/jit/patcher.h,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/darwin/md-abi.h, src/vm/jit/powerpc/darwin/md-
+       os.c, src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c,
+       src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c,
+       src/vm/jit/replace.c, src/vm/jit/replace.h, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c,
+       src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/linux/md-os.c, src/vm/jit_interface.h,
+       src/vm/properties.c, src/vm/properties.h, src/vm/string.c,
+       src/vm/vm.c, src/vm/vm.h, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/descriptor.c, src/vmcore/descriptor.h,
+       src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.c,
+       src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h,
+       src/vmcore/options.c, src/vmcore/options.h, src/vmcore/primitive.c,
+       src/vmcore/primitive.h, src/vmcore/statistics.c,
+       src/vmcore/statistics.h, src/vmcore/suck.c:
+       Merged revisions 8187-8244 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r8189 | ajordan | 2007-07-07 14:03:38 +0200 (Sat, 07 Jul
+       2007) | 2 lines
+
+        * src/vm/jit/sparc64/solaris/md-os.c: Implemented hardware
+       exception handling. ........ r8190 | twisti | 2007-07-08 15:42:06
+       +0200 (Sun, 08 Jul 2007) | 4 lines
+
+        * src/vm/jit/powerpc/linux/md-abi.c (vm/types.h): Removed.
+       (stdint.h): Added and use stdint-types in this file. (_ALIGN):
+       Removed and use ALIGN_2 in this file. ........ r8191 | twisti |
+       2007-07-08 17:15:53 +0200 (Sun, 08 Jul 2007) | 8 lines
+
+        * src/vm/jit/powerpc/emit.c (stdint.h): Added
+       (emit_verbosecall_enter): Reimplemented (this implementation is much
+       simpler and maybe should be extended to trace also arguments on the
+       stack). Darwin support is still missing.
+
+        * src/vm/jit/powerpc/darwin/md-abi.h (TRACE_ARGS_NUM): Changed to
+       4.
+         * src/vm/jit/powerpc/linux/md-abi.h (TRACE_ARGS_NUM): Likewise.
+       ........ r8192 | twisti | 2007-07-09 13:18:48 +0200 (Mon, 09 Jul
+       2007) | 3 lines
+
+        * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv):
+       Fixed typo. ........ r8193 | twisti | 2007-07-09 16:37:49 +0200
+       (Mon, 09 Jul 2007) | 2 lines
+
+        * src/vm/global.h (ALIGN_2): Use logical arithmetic. ........
+       r8194 | twisti | 2007-07-10 15:44:37 +0200 (Tue, 10 Jul 2007) | 9
+       lines
+
+        * src/vmcore/options.c (opt_TraceJavaCalls): Added.
+       (options_XX): Added opt_TraceJavaCalls. (options_xx): Likewise.
+
+        * src/vmcore/options.h (opt_TraceJavaCalls): Added.
+
+        * src/vm/vm.c (XXusage): Removed -verbose:call. (vm_create):
+       Likewise. ........ r8195 | pm | 2007-07-11 13:27:55 +0200 (Wed, 11
+       Jul 2007) | 3 lines
+
+        * src/vm/jit/s390/codegen.c (codegen_emit): Extended maximal
+       interface table offset from 12 bit to 16 bit in
+       ICMD_INVOKEINTERFACE.
+         * src/vm/jit/s390/patcher.c (patcher_invokeinterface): Likewise.
+       ........ r8196 | twisti | 2007-07-11 15:54:21 +0200 (Wed, 11 Jul
+       2007) | 5 lines
+
+        * src/vm/jit/powerpc/codegen.c (codegen_emit): Fixed bug when
+       taking out double arguments. (codegen_emit_stub_native): Use
+       switch-case for saving and restoring argument registers. ........
+       r8197 | twisti | 2007-07-11 21:17:04 +0200 (Wed, 11 Jul 2007) | 3
+       lines
+
+        * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method): Fixed stack
+       alignment. ........ r8198 | twisti | 2007-07-12 09:16:24 +0200
+       (Thu, 12 Jul 2007) | 10 lines
+
+        * src/vm/jit/alpha/asmpart.S (asm_vm_call_method): Rewritten for
+       new argument passing.
+
+        * src/vm/jit/alpha/md-abi.c (md_param_alloc): Set pd->index.
+
+        * src/native/jni.c: Added __ALPHA__ ifdef.
+         * src/vm/vm.c: Likewise.
+         * src/vm/vm.h: Likewise.
+         * src/vm/jit/asmpart.h: Likewise. ........ r8199 | michi |
+       2007-07-13 02:39:49 +0200 (Fri, 13 Jul 2007) | 7 lines
+
+        * src/vmcore/statistics.h (size_patchref): Added.
+         * src/vmcore/statistics.c (size_patchref): Added.
+       (statistics_print_memory_usage): Print size of patcher references.
+
+        * src/vm/jit/patcher-common.c (patcher_add_patch_ref,
+       patcher_list_free) [ENABLE_STATISTICS] Set size of patcher
+       references accordingly. ........ r8200 | twisti | 2007-07-15
+       11:47:21 +0200 (Sun, 15 Jul 2007) | 2 lines
+
+        * src/vm/vm.c: Build fix. ........ r8201 | twisti | 2007-07-15
+       12:37:50 +0200 (Sun, 15 Jul 2007) | 9 lines
+
+        * src/vmcore/primitive.c (stdint.h): Added.
+       (primitive_arrayclass_get_by_name): New function.
+
+        * src/vmcore/primitive.h (stdint.h): Added.
+       (primitive_arrayclass_get_by_name): Likewise.
+
+        * src/native/vm/sun/jvm.c (JVM_NewArray): Implemented handling for
+       primitive arrays. ........ r8202 | twisti | 2007-07-15 14:08:18
+       +0200 (Sun, 15 Jul 2007) | 3 lines
+
+        * src/native/include/Makefile.am [WITH_CLASSPATH_SUN]
+       (JAVASE_HEADER_FILES): Added sun_reflect_ConstantPool.h. ........
+       r8203 | twisti | 2007-07-15 14:30:04 +0200 (Sun, 15 Jul 2007) | 16
+       lines
+
+        * src/vmcore/primitive.c (primitive_class_is_primitive): Removed.
+         * src/vmcore/primitive.h: Likewise.
+
+        * src/vmcore/class.c (class_is_primitive): New function.
+       (class_isanysubclass): Use class_is_primitive.
+         * src/vmcore/class.h: Likewise.
+
+        * src/native/vm/java_lang_Class.c (isPrimitive): Use
+       class_is_primitive. (getDeclaringClass): Likewise.
+       (getDeclaredClasses): Likewise.
+
+        * src/native/vm/sun/jvm.c (JVM_GetProtectionDomain): Likewise.
+       (JVM_IsPrimitiveClass): Likewise. (JVM_NewArray): Likewise.
+       ........ r8204 | twisti | 2007-07-15 14:44:22 +0200 (Sun, 15 Jul
+       2007) | 4 lines
+
+        * src/native/vm/sun/jvm.c (JVM_ArrayCopy): Fixed warnings.
+       (JVM_GetStackTraceElement): Likewise. (JVM_FindLoadedClass):
+       Likewise. ........ r8205 | twisti | 2007-07-15 14:45:40 +0200
+       (Sun, 15 Jul 2007) | 2 lines
+
+        * src/native/vm/sun/jvm.c: Set Id keyword. ........ r8206 |
+       twisti | 2007-07-15 16:26:33 +0200 (Sun, 15 Jul 2007) | 7 lines
+
+        * src/vmcore/options.c (opt_TraceJVMCalls): Added.
+         * src/vmcore/options.h: Likewise.
+
+        * src/native/vm/sun/jvm.c (vmcore/options.h): Added.
+       (DEBUG_JVM): Renamed to TRACEJVMCALLS. (JVM_GetArrayLength):
+       Implemented. ........ r8207 | twisti | 2007-07-16 17:18:32 +0200
+       (Mon, 16 Jul 2007) | 6 lines
+
+        * src/vmcore/class.c (class_get_declaringclass): New function.
+         * src/vmcore/class.h: Likewise.
+
+        * src/native/vm/java_lang_Class.c (getDeclaringClass): Use
+       class_get_declaringclass. ........ r8208 | twisti | 2007-07-17
+       11:06:22 +0200 (Tue, 17 Jul 2007) | 3 lines
+
+        * src/native/jni.c (TRACEJNICALLS): Added but still unused.
+       (JNI_GetCreatedJavaVMs): Implemented. ........ r8209 | twisti |
+       2007-07-17 22:13:23 +0200 (Tue, 17 Jul 2007) | 9 lines
+
+        * src/vmcore/class.c (vm/resolve.h): Added. (class_define):
+       Changed signature.
+         * src/vmcore/class.h (class_define): Likewise.
+
+        * src/native/jni.c (_Jv_JNI_DefineClass): Bug fix, use
+       class_define.
+
+        * src/native/vm/java_lang_ClassLoader.c (defineClass): Use
+       class_define. ........ r8210 | twisti | 2007-07-18 14:51:00 +0200
+       (Wed, 18 Jul 2007) | 50 lines
+
+        * src/vm/jit/allocator/simplereg.c: Replaced HAS_4BYTE_STACKSLOT
+       with SIZEOF_VOID_P == 4.
+
+        * src/vm/jit/i386/emit.c (vm/jit/abi.h): Added.
+       (emit_verbosecall_enter): Changed to 8-byte stackslots.
+
+        * src/vm/jit/i386/codegen.c (codegen_emit): Changed to 8-byte
+       stackslots. (codegen_emit_stub_native): Likewise.
+
+        * src/vm/jit/i386/arch.h (HAS_4BYTE_STACKSLOT): Removed.
+       (ALIGN_LONGS_IN_MEMORY): Likewise. (ALIGN_DOUBLES_IN_MEMORY):
+       Likewise.
+
+        * src/vm/jit/i386/asmpart.S (asm_vm_call_method): Rewritten for
+       new argument passing. (asm_handle_exception): Use 8-byte
+       stackslots.
+
+        * src/vm/jit/i386/md-abi.c (md_param_alloc): Use 8-byte stackslots
+       and set pd->index. (md_param_alloc_native): New function.
+
+        * src/vm/global.h (ALIGN_EVEN): New macro. (ALIGN_ODD):
+       Likewise. (ALIGN_2): Defined to ALIGN_EVEN.
+
+        * src/vm/builtintable.inc (builtintable_function): Removed #ifdef
+       for java.lang.VMSystem.arraycopy, this works now correctly.
+
+        * src/vm/builtin.c (builtintable_init): Set ACC_METHOD_BUILTIN
+       when parsing the decriptor.
+
+        * src/vm/jit_interface.h (md_param_alloc_native): Added.
+
+        * src/vm/exceptions.c (exceptions_handle_exception): Temporarily
+       added __I386__ to get the monitor object correctly.
+
+        * src/vmcore/descriptor.c
+       (descriptor_pool_parse_method_descriptor): Check for
+       ACC_METHOD_BUILTIN flag. (descriptor_params_from_paramtypes):
+       Likewise.
+
+        * src/cacaoh/dummy.c (md_param_alloc_native): Added.
+
+        * src/vm/jit/asmpart.h: Added __I386__ ifdef.
+         * src/vm/vm.c: Likewise.
+         * src/vm/vm.h: Likewise.
+         * src/native/jni.c: Likewise. (_Jv_jni_invokeNative): Check for
+       exception too when vm_array_from_objectarray returns. ........
+       r8211 | michi | 2007-07-18 21:52:23 +0200 (Wed, 18 Jul 2007) | 25
+       lines
+
+        * src/vm/jit/replace.h (REPLACEMENT_EMIT_STUBS): Removed macro.
+
+        * src/vm/jit/emit-common.h (emit_replacement_stubs): Removed.
+
+        * src/vm/jit/arm/emit.c,
+         * src/vm/jit/arm/codegen.c,
+         * src/vm/jit/powerpc/emit.c,
+         * src/vm/jit/powerpc/codegen.c,
+         * src/vm/jit/sparc64/emit.c,
+         * src/vm/jit/sparc64/codegen.c,
+         * src/vm/jit/alpha/emit.c,
+         * src/vm/jit/alpha/codegen.c,
+         * src/vm/jit/s390/emit.c,
+         * src/vm/jit/mips/emit.c,
+         * src/vm/jit/mips/codegen.c,
+         * src/vm/jit/m68k/codegen.c,
+         * src/vm/jit/powerpc64/emit.c,
+         * src/vm/jit/powerpc64/codegen.c,
+         * src/vm/jit/i386/emit.c,
+         * src/vm/jit/i386/codegen.c,
+         * src/vm/jit/x86_64/emit.c,
+         * src/vm/jit/x86_64/codegen.c (emit_replacement_stubs): Removed.
+       (codegen_emit): Do not create replacement stubs anymore. ........
+       r8212 | twisti | 2007-07-18 21:59:32 +0200 (Wed, 18 Jul 2007) | 14
+       lines
+
+        * src/vm/vm.c (opts): Added -XX. (usage): Small text change.
+
+        * src/vmcore/options.c (opt_DebugStackFrameInfo): Added.
+       (opt_DebugStackTrace): Likewise. (options_XX): Added type and some
+       documentation. (options_xxusage): New function. (options_xx): Do
+       more error checking.
+
+        * src/vmcore/options.h (option_t): Added type and renamed option
+       to value. (opt_DebugStackFrameInfo): Added.
+       (opt_DebugStackTrace): Likewise. ........ r8213 | michi |
+       2007-07-18 22:08:26 +0200 (Wed, 18 Jul 2007) | 5 lines
+
+        * src/vmcore/options.h (opt_replace_verbose): Removed.
+         * src/vmcore/options.c (opt_replace_verbose): Removed.
+         * src/vm/vm.c [ENABLE_INLINING]: Removed options -ir and -iR, this is
+       now called -XX:TraceReplacement. ........ r8214 | michi |
+       2007-07-18 22:27:12 +0200 (Wed, 18 Jul 2007) | 2 lines
+
+        * src/vmcore/options.c (options_XX): Fixed -XX:TraceReplacement.
+       ........ r8215 | michi | 2007-07-18 22:31:21 +0200 (Wed, 18 Jul
+       2007) | 6 lines
+
+        * src/vm/jit/code.h (codeinfo) [ENABLE_REPLACEMENT]: Removed
+       obsolet pointer to replacementstubs.
+
+        * src/vm/jit/codegen-common.c (codegen_finish)
+       [ENABLE_REPLACEMENT]: Do not resolve pointer to replacementstubs.
+       ........ r8216 | michi | 2007-07-19 15:51:21 +0200 (Thu, 19 Jul
+       2007) | 20 lines
+
+        * src/vm/jit/powerpc/emit.c (emit_patcher_traps): Formerly known
+       as emit_patcher_stubs, now emits traps instead of stubs.
+
+        * src/vm/jit/powerpc/codegen.c (codegen_emit,
+       codegen_emit_stub_native): Call the new patcher functions and
+       adapted to above change.
+
+        * src/vm/jit/powerpc/patcher.c: Adapted patchers to new signature
+       for traps. (patcher_wrapper): Removed, this is obsolete.
+
+        * src/vm/jit/powerpc/asmpart.S (asm_patcher_wrapper): Removed,
+       this is obsolete.
+
+        * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv):
+       Only calls the exception handling if exception object present.
+
+        * src/vm/jit/powerpc/darwin/md-os.c (md_signal_handler_sigsegv):
+       Likewise.
+
+        * src/vm/jit/patcher-common.h [__POWERPC__]: Enabled new patcher
+       stuff.
+
+        * src/vm/jit/patcher.h [__POWERPC__]: Defined away old patcher
+       stuff. ........ r8217 | michi | 2007-07-19 17:44:41 +0200 (Thu, 19
+       Jul 2007) | 3 lines
+
+        * src/vm/jit/arm/md-os.c (md_signal_handler_sigsegv): Added
+       additional debug output. ........ r8218 | michi | 2007-07-19
+       18:33:19 +0200 (Thu, 19 Jul 2007) | 5 lines
+
+        * src/vm/jit/s390/md.c (md_get_method_patch_address): Fixed
+       cornercase for replacement.
+
+        * src/vm/jit/m68k/md.c (md_get_method_patch_address): Likewise.
+       ........ r8219 | twisti | 2007-07-20 18:52:11 +0200 (Fri, 20 Jul
+       2007) | 6 lines
+
+        * src/vmcore/class.c (class_get_superclass): New function.
+         * src/vmcore/class.h: Likewise.
+
+        * src/native/jni.c (_Jv_JNI_GetSuperclass): Use
+       class_get_superclass.
+         * src/native/vm/java_lang_Class.c (getSuperclass): Likewise. ........
+       r8220 | twisti | 2007-07-22 17:37:52 +0200 (Sun, 22 Jul 2007) | 8
+       lines
+
+        * src/vmcore/options.c (opt_TraceJNICalls): Added.
+         * src/vmcore/options.h: Likewise.
+
+        * src/native/jni.c (TRACEJNICALLS): Enabled.
+       (_Jv_JNI_GetStringLength): Added TRACEJNICALLS.
+       (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFLength):
+       Likewise. ........ r8221 | twisti | 2007-07-22 21:31:41 +0200
+       (Sun, 22 Jul 2007) | 3 lines
+
+        * src/native/jni.c (_Jv_JNI_GetSuperclass): Fixed TRACEJNICALLS.
+       (_Jv_JNI_GetStringUTFRegion): Bugfix, start at offset to copy data.
+       ........ r8222 | twisti | 2007-07-22 22:07:55 +0200 (Sun, 22 Jul
+       2007) | 3 lines
+
+        * src/threads/native/threads.h (threads_yield): Removed.
+         * src/threads/threads-common.h (threads_yield): Added. ........
+       r8223 | twisti | 2007-07-22 22:43:05 +0200 (Sun, 22 Jul 2007) | 3
+       lines
+
+        * src/vmcore/class.c (class_get_signature): New function.
+         * src/vmcore/class.h: Likewise. ........ r8224 | twisti | 2007-07-23
+       21:07:48 +0200 (Mon, 23 Jul 2007) | 2 lines
+
+        * src/vmcore/class.h (classinfo): Removed unused listnode.
+       ........ r8225 | twisti | 2007-07-23 23:33:16 +0200 (Mon, 23 Jul
+       2007) | 5 lines
+
+        * src/native/vm/sun_misc_Unsafe.c (vm/stringlocal.h): Added.
+       (putInt): New function. (getObject): Likewise. (defineClass):
+       Likewise. ........ r8226 | twisti | 2007-07-24 10:21:23 +0200
+       (Tue, 24 Jul 2007) | 4 lines
+
+        * src/native/vm/sun_misc_Unsafe.c [WITH_CLASSPATH_SUN]
+       (native/include/java_security_ProtectionDomain.h): Removed #ifdef.
+       (defineClass) [WITH_CLASSPATH_GNU]: Renamed pd to protectionDomain.
+       ........ r8227 | twisti | 2007-07-24 13:55:07 +0200 (Tue, 24 Jul
+       2007) | 16 lines
+
+        * src/vmcore/loader.c (vmcore/field.h): Added. (load_field):
+       Removed. (load_class_from_classbuffer): Call field_load.
+
+        * src/vmcore/field.c (stdint.h): Added. (vm/exceptions.h):
+       Likewise. (vm/stringlocal.h): Likewise. (vm/vm.h): Likewise.
+       (vmcore/descriptor.h): Likewise. (vmcore/loader.h): Likewise.
+       (vmcore/options.h): Likewise. (vmcore/suck.h): Likewise.
+       (field_load): New function.
+
+        * src/vmcore/field.h (field_load): Added. ........ r8228 |
+       twisti | 2007-07-24 14:37:25 +0200 (Tue, 24 Jul 2007) | 12 lines
+
+        * src/vmcore/loader.c (vmcore/method.h): Added.
+       (loader_load_method): Removed. (load_class_from_classbuffer): Call
+       method_load.
+
+        * src/vmcore/method.c (stdint.h): Added. (threads/lock-common):
+       Likewise. (vm/exceptions.h): Likewise. (vmcore/suck.h):
+       Likewise. (method_load): New function.
+
+        * src/vmcore/method.h (method_load): Added. ........ r8229 |
+       twisti | 2007-07-24 20:42:44 +0200 (Tue, 24 Jul 2007) | 2 lines
+
+        * src/vmcore/field.h (vmcore/loader.h): Added. ........ r8230 |
+       twisti | 2007-07-25 10:23:10 +0200 (Wed, 25 Jul 2007) | 9 lines
+
+        * src/vm/string.c, src/vm/vm.c, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/loader.c, src/vmcore/options.c,
+       src/vmcore/options.h: Removed eager-loading stuff (as it was broken
+       anyways). ........ r8231 | twisti | 2007-07-25 16:21:24 +0200
+       (Wed, 25 Jul 2007) | 6 lines
+
+        * src/vmcore/class.c [ENABLE_JAVASE] (class_get_signature): Only
+       for JavaSE.
+         * src/vmcore/class.h: Likewise.
+
+        * src/vmcore/method.h (vmcore/loader.h): Added. ........ r8232 |
+       twisti | 2007-07-25 16:51:40 +0200 (Wed, 25 Jul 2007) | 4 lines
+
+        * src/vmcore/descriptor.c (vm/vm.h): Added.
+       (descriptor_to_basic_type): Code cleanup. (descriptor_typesize):
+       Likewise. ........ r8233 | twisti | 2007-07-25 17:11:20 +0200
+       (Wed, 25 Jul 2007) | 5 lines
+
+        * src/vmcore/descriptor.c (descriptor_to_basic_type): Changed
+       return type to int. (descriptor_typesize): Likewise.
+         * src/vmcore/descriptor.h: Likewise. ........ r8234 | twisti |
+       2007-07-26 10:21:25 +0200 (Thu, 26 Jul 2007) | 4 lines
+
+        * src/vmcore/linker.c (dummy_alignment_long_t): New structure.
+       (dummy_alignment_double_t): Likewise. (linker_init): Added
+       long/double alignment check. ........ r8235 | twisti | 2007-07-26
+       10:29:24 +0200 (Thu, 26 Jul 2007) | 3 lines
+
+        * THIRDPARTY: Fixed classes path, added contrib/mapfile-vers-
+       product, src/lib/gnu/sun/misc/Unsafe.java ........ r8236 |
+       twisti | 2007-07-27 12:18:17 +0200 (Fri, 27 Jul 2007) | 22 lines
+
+        * src/vm/vm.c (version): Removed configuration output.
+       (vm_printconfig): New function. (vm_create): Set bootclasspath and
+       classpath whenever changed and don't call properties_postinit.
+       This fixes a bug with
+         -Djava.class.path.
+         * src/vm/vm.h (vm_printconfig): Added.
+
+        * src/vm/properties.c (properties_init): Set java.vm.info for all
+       JavaSE configurations. (properties_postinit): Removed.
+         * src/vm/properties.h (properties_postinit): Likewise.
+
+        * src/vmcore/options.c (opt_PrintConfig): Added. (options_xx):
+       Likewise.
+         * src/vmcore/options.h (opt_PrintConfig): Likewise.
+
+        * src/vmcore/suck.c (suck_add_from_property): Reset the
+       bootclasspath after it changed.
+
+        * src/cacaoh/dummy.c (properties_add): New dummy.
+       (vm_printconfig): Likewise. ........ r8237 | twisti | 2007-07-27
+       18:15:29 +0200 (Fri, 27 Jul 2007) | 16 lines
+
+        * src/vmcore/class.c (class_sun_reflect_MagicAccessorImpl): Added.
+       (class_issubclass): Don't get super-class directly, it can be
+       unresolved. Use class_get_superclass.
+
+        * src/vmcore/class.h (class_sun_reflect_MagicAccessorImpl): Added.
+
+        * src/vmcore/loader.c (loader_init): Load
+       class_sun_reflect_MagicAccessorImpl.
+
+        * src/vmcore/linker.c (linker_init): Link
+       class_sun_reflect_MagicAccessorImpl.
+
+        * src/vm/access.c (access_is_accessible_class)
+       [WITH_CLASSPATH_SUN]: Added sun/reflect/MagicAccessorImpl check.
+       (access_is_accessible_member): Likewise. ........ r8238 | twisti |
+       2007-07-27 20:41:53 +0200 (Fri, 27 Jul 2007) | 4 lines
+
+        * src/vmcore/class.c (class_resolve_superclass): New function.
+       (class_issubclass): Use class_resolve_superclass.
+       (class_get_superclass): Likewise. ........ r8239 | twisti |
+       2007-07-29 21:21:18 +0200 (Sun, 29 Jul 2007) | 3 lines
+
+        * src/vm/vm.c (vm_create) [WITH_CLASSPATH_SUN]: Set bootclasspath
+       as HotSpot does. ........ r8240 | pm | 2007-07-29 22:36:47 +0200
+       (Sun, 29 Jul 2007) | 7 lines
+
+        * src/vm/jit/replace.c: Enaled replacement on s390.
+         * src/vm/jit/s390/arch.h, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md.c: Changed a lot: implemented profiling, fixed
+       bugs found by mauve, begun work on replacament. ........ r8241 |
+       twisti | 2007-07-30 11:26:31 +0200 (Mon, 30 Jul 2007) | 4 lines
+
+        * m4/ac_prog_javac.m4 (AC_PROG_JAVAC): Try javac as first
+       compiler. Left jikes in there so configure can finish on machines
+       where we don't have a javac or ecj. ........ r8242 | twisti |
+       2007-07-31 10:45:35 +0200 (Tue, 31 Jul 2007) | 4 lines
+
+        * src/mm/boehm.c (heap_allocate): Call
+       GC_REGISTER_FINALIZER_NO_ORDER instead of GC_REGISTER_FINALIZER.
+       This fixes the GC heap memory leak seen with e.g. Jetty. ........
+       r8243 | michi | 2007-07-31 10:57:54 +0200 (Tue, 31 Jul 2007) | 21
+       lines
+
+        * src/vm/exceptions.c (exceptions_new_hardware_exception): Do not
+       create sfi.
+         * src/vm/exceptions.h (exceptions_new_hardware_exception): Changed
+       signature.
+
+        * src/vm/jit/arm/linux/md-os.c
+         * src/vm/jit/powerpc/linux/md-os.c
+         * src/vm/jit/powerpc/darwin/md-os.c
+         * src/vm/jit/sparc64/linux/md-os.c
+         * src/vm/jit/sparc64/solaris/md-os.c
+         * src/vm/jit/alpha/linux/md-os.c
+         * src/vm/jit/s390/md.c
+         * src/vm/jit/mips/linux/md-os.c
+         * src/vm/jit/mips/irix/md-os.c
+         * src/vm/jit/m68k/linux/md-os.c
+         * src/vm/jit/powerpc64/linux/md-os.c
+         * src/vm/jit/i386/darwin/md-os.c
+         * src/vm/jit/i386/linux/md-os.c
+         * src/vm/jit/x86_64/linux/md-os.c: Signal handlers create the sfi
+       now. Adapted to above changes. Exception object variable is now
+       called "e" on all archs. ........ r8244 | michi | 2007-07-31
+       11:30:28 +0200 (Tue, 31 Jul 2007) | 4 lines
+
+        * src/vm/jit/replace.c (replace_me_wrapper): Added.
+         * src/vm/jit/replace.h (replace_me_wrapper): Added.
+         * src/vm/exceptions.c (exceptions_new_hardware_exception): Call above
+       function. ........
+       [ec6d259e4518]
+
+       * src/vm/exceptions.c, src/vm/jit/replace.c, src/vm/jit/replace.h:
+       * src/vm/jit/replace.c (replace_me_wrapper): Added.
+       * src/vm/jit/replace.h (replace_me_wrapper): Added.
+       * src/vm/exceptions.c (exceptions_new_hardware_exception): Call above
+       function.
+       [dd4bd5f7600f]
+
+       * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/alpha/linux/md-
+       os.c, src/vm/jit/arm/linux/md-os.c, src/vm/jit/i386/darwin/md-os.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/md.c,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/solaris/md-
+       os.c, src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/exceptions.c (exceptions_new_hardware_exception): Do not
+       create sfi.
+       * src/vm/exceptions.h (exceptions_new_hardware_exception): Changed
+       signature.
+
+       * src/vm/jit/arm/linux/md-os.c
+       * src/vm/jit/powerpc/linux/md-os.c
+       * src/vm/jit/powerpc/darwin/md-os.c
+       * src/vm/jit/sparc64/linux/md-os.c
+       * src/vm/jit/sparc64/solaris/md-os.c
+       * src/vm/jit/alpha/linux/md-os.c
+       * src/vm/jit/s390/md.c
+       * src/vm/jit/mips/linux/md-os.c
+       * src/vm/jit/mips/irix/md-os.c
+       * src/vm/jit/m68k/linux/md-os.c
+       * src/vm/jit/powerpc64/linux/md-os.c
+       * src/vm/jit/i386/darwin/md-os.c
+       * src/vm/jit/i386/linux/md-os.c
+       * src/vm/jit/x86_64/linux/md-os.c: Signal handlers create the sfi now.
+       Adapted to above changes. Exception object variable is now called
+       "e" on all archs.
+       [02a065687d24]
+
+2007-07-31  twisti  <twisti>
+
+       * src/mm/boehm.c:
+       * src/mm/boehm.c (heap_allocate): Call
+       GC_REGISTER_FINALIZER_NO_ORDER instead of GC_REGISTER_FINALIZER.
+       This fixes the GC heap memory leak seen with e.g. Jetty.
+       [1dfe39d5388f]
+
+2007-07-30  twisti  <twisti>
+
+       * m4/ac_prog_javac.m4:
+       * m4/ac_prog_javac.m4 (AC_PROG_JAVAC): Try javac as first compiler.
+       Left jikes in there so configure can finish on machines where we
+       don't have a javac or ecj.
+       [03f3342458a9]
+
+2007-07-29  pm  <pm>
+
+       * src/vm/jit/replace.c, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c:
+       * src/vm/jit/replace.c: Enaled replacement on s390.
+       * src/vm/jit/s390/arch.h, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md.c: Changed a lot: implemented profiling, fixed
+       bugs found by mauve, begun work on replacament.
+       [e58b898d27e9]
+
+2007-07-29  twisti  <twisti>
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_create) [WITH_CLASSPATH_SUN]: Set bootclasspath as
+       HotSpot does.
+       [931286015662]
+
+2007-07-27  twisti  <twisti>
+
+       * src/vmcore/class.c:
+       * src/vmcore/class.c (class_resolve_superclass): New function.
+       (class_issubclass): Use class_resolve_superclass.
+       (class_get_superclass): Likewise.
+       [f523912ffb36]
+
+       * src/vm/access.c, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/linker.c, src/vmcore/loader.c:
+       * src/vmcore/class.c (class_sun_reflect_MagicAccessorImpl): Added.
+       (class_issubclass): Don't get super-class directly, it can be
+       unresolved. Use class_get_superclass.
+
+       * src/vmcore/class.h (class_sun_reflect_MagicAccessorImpl): Added.
+
+       * src/vmcore/loader.c (loader_init): Load
+       class_sun_reflect_MagicAccessorImpl.
+
+       * src/vmcore/linker.c (linker_init): Link
+       class_sun_reflect_MagicAccessorImpl.
+
+       * src/vm/access.c (access_is_accessible_class) [WITH_CLASSPATH_SUN]:
+       Added sun/reflect/MagicAccessorImpl check.
+       (access_is_accessible_member): Likewise.
+       [f8cb3cfe7a30]
+
+       * src/cacaoh/dummy.c, src/vm/properties.c, src/vm/properties.h,
+       src/vm/vm.c, src/vm/vm.h, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/suck.c:
+       * src/vm/vm.c (version): Removed configuration output.
+       (vm_printconfig): New function. (vm_create): Set bootclasspath and
+       classpath whenever changed and don't call properties_postinit. This
+       fixes a bug with
+       -Djava.class.path.
+       * src/vm/vm.h (vm_printconfig): Added.
+
+       * src/vm/properties.c (properties_init): Set java.vm.info for all
+       JavaSE configurations. (properties_postinit): Removed.
+       * src/vm/properties.h (properties_postinit): Likewise.
+
+       * src/vmcore/options.c (opt_PrintConfig): Added. (options_xx):
+       Likewise.
+       * src/vmcore/options.h (opt_PrintConfig): Likewise.
+
+       * src/vmcore/suck.c (suck_add_from_property): Reset the
+       bootclasspath after it changed.
+
+       * src/cacaoh/dummy.c (properties_add): New dummy. (vm_printconfig):
+       Likewise.
+       [e0faa4cf75a1]
+
+2007-07-26  twisti  <twisti>
+
+       * THIRDPARTY:
+       * THIRDPARTY: Fixed classes path, added contrib/mapfile-vers-
+       product, src/lib/gnu/sun/misc/Unsafe.java
+       [b36b7d0fe3ef]
+
+       * src/vmcore/linker.c:
+       * src/vmcore/linker.c (dummy_alignment_long_t): New structure.
+       (dummy_alignment_double_t): Likewise. (linker_init): Added
+       long/double alignment check.
+       [8122b21bcc2c]
+
+2007-07-25  twisti  <twisti>
+
+       * src/vmcore/descriptor.c, src/vmcore/descriptor.h:
+       * src/vmcore/descriptor.c (descriptor_to_basic_type): Changed return
+       type to int. (descriptor_typesize): Likewise.
+       * src/vmcore/descriptor.h: Likewise.
+       [7cb8e297edcf]
+
+       * src/vmcore/descriptor.c:
+       * src/vmcore/descriptor.c (vm/vm.h): Added.
+       (descriptor_to_basic_type): Code cleanup. (descriptor_typesize):
+       Likewise.
+       [60fed621bcbf]
+
+       * src/vmcore/class.c, src/vmcore/class.h, src/vmcore/method.h:
+       * src/vmcore/class.c [ENABLE_JAVASE] (class_get_signature): Only for
+       JavaSE.
+       * src/vmcore/class.h: Likewise.
+
+       * src/vmcore/method.h (vmcore/loader.h): Added.
+       [c1489229706f]
+
+       * src/vm/string.c, src/vm/vm.c, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/loader.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/vm/string.c, src/vm/vm.c, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/loader.c, src/vmcore/options.c,
+       src/vmcore/options.h: Removed eager-loading stuff (as it was broken
+       anyways).
+       [5867a4482f05]
+
+2007-07-24  twisti  <twisti>
+
+       * src/vmcore/field.h:
+       * src/vmcore/field.h (vmcore/loader.h): Added.
+       [cfdc335e6834]
+
+       * src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h:
+       * src/vmcore/loader.c (vmcore/method.h): Added.
+       (loader_load_method): Removed. (load_class_from_classbuffer): Call
+       method_load.
+
+       * src/vmcore/method.c (stdint.h): Added. (threads/lock-common):
+       Likewise. (vm/exceptions.h): Likewise. (vmcore/suck.h): Likewise.
+       (method_load): New function.
+
+       * src/vmcore/method.h (method_load): Added.
+       [3b822b675cae]
+
+       * src/vmcore/field.c, src/vmcore/field.h, src/vmcore/loader.c:
+       * src/vmcore/loader.c (vmcore/field.h): Added. (load_field):
+       Removed. (load_class_from_classbuffer): Call field_load.
+
+       * src/vmcore/field.c (stdint.h): Added. (vm/exceptions.h): Likewise.
+       (vm/stringlocal.h): Likewise. (vm/vm.h): Likewise.
+       (vmcore/descriptor.h): Likewise. (vmcore/loader.h): Likewise.
+       (vmcore/options.h): Likewise. (vmcore/suck.h): Likewise.
+       (field_load): New function.
+
+       * src/vmcore/field.h (field_load): Added.
+       [251b0a971fed]
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c [WITH_CLASSPATH_SUN]
+       (native/include/java_security_ProtectionDomain.h): Removed #ifdef.
+       (defineClass) [WITH_CLASSPATH_GNU]: Renamed pd to protectionDomain.
+       [ea135360488b]
+
+2007-07-23  twisti  <twisti>
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (vm/stringlocal.h): Added.
+       (putInt): New function. (getObject): Likewise. (defineClass):
+       Likewise.
+       [7203affa0097]
+
+       * src/vmcore/class.h:
+       * src/vmcore/class.h (classinfo): Removed unused listnode.
+       [3ff1aad8b73c]
+
+2007-07-22  twisti  <twisti>
+
+       * src/vmcore/class.c, src/vmcore/class.h:
+       * src/vmcore/class.c (class_get_signature): New function.
+       * src/vmcore/class.h: Likewise.
+       [880cb019c874]
+
+       * src/threads/native/threads.h, src/threads/threads-common.h:
+       * src/threads/native/threads.h (threads_yield): Removed.
+       * src/threads/threads-common.h (threads_yield): Added.
+       [12761839a9fd]
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_GetSuperclass): Fixed TRACEJNICALLS.
+       (_Jv_JNI_GetStringUTFRegion): Bugfix, start at offset to copy data.
+       [d3a41ccae208]
+
+       * src/native/jni.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.c (opt_TraceJNICalls): Added.
+       * src/vmcore/options.h: Likewise.
+
+       * src/native/jni.c (TRACEJNICALLS): Enabled.
+       (_Jv_JNI_GetStringLength): Added TRACEJNICALLS.
+       (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFLength):
+       Likewise.
+       [352b9420e7ec]
+
+2007-07-20  twisti  <twisti>
+
+       * src/native/jni.c, src/native/vm/java_lang_Class.c,
+       src/vmcore/class.c, src/vmcore/class.h:
+       * src/vmcore/class.c (class_get_superclass): New function.
+       * src/vmcore/class.h: Likewise.
+
+       * src/native/jni.c (_Jv_JNI_GetSuperclass): Use
+       class_get_superclass.
+       * src/native/vm/java_lang_Class.c (getSuperclass): Likewise.
+       [0e51eac71071]
+
+2007-07-19  michi  <michi>
+
+       * src/vm/jit/m68k/md.c, src/vm/jit/s390/md.c:
+       * src/vm/jit/s390/md.c (md_get_method_patch_address): Fixed
+       cornercase for replacement.
+
+       * src/vm/jit/m68k/md.c (md_get_method_patch_address): Likewise.
+       [669f79995095]
+
+       * src/vm/jit/arm/linux/md-os.c:
+       * src/vm/jit/arm/md-os.c (md_signal_handler_sigsegv): Added
+       additional debug output.
+       [0ca11e0b148b]
+
+       * src/vm/jit/patcher-common.h, src/vm/jit/patcher.h,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc/patcher.c:
+       * src/vm/jit/powerpc/emit.c (emit_patcher_traps): Formerly known as
+       emit_patcher_stubs, now emits traps instead of stubs.
+
+       * src/vm/jit/powerpc/codegen.c (codegen_emit,
+       codegen_emit_stub_native): Call the new patcher functions and
+       adapted to above change.
+
+       * src/vm/jit/powerpc/patcher.c: Adapted patchers to new signature
+       for traps. (patcher_wrapper): Removed, this is obsolete.
+
+       * src/vm/jit/powerpc/asmpart.S (asm_patcher_wrapper): Removed, this
+       is obsolete.
+
+       * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): Only
+       calls the exception handling if exception object present.
+
+       * src/vm/jit/powerpc/darwin/md-os.c (md_signal_handler_sigsegv):
+       Likewise.
+
+       * src/vm/jit/patcher-common.h [__POWERPC__]: Enabled new patcher
+       stuff.
+
+       * src/vm/jit/patcher.h [__POWERPC__]: Defined away old patcher
+       stuff.
+       [5feca9dd36ee]
+
+2007-07-18  michi  <michi>
+
+       * src/vm/jit/code.h, src/vm/jit/codegen-common.c:
+       * src/vm/jit/code.h (codeinfo) [ENABLE_REPLACEMENT]: Removed obsolet
+       pointer to replacementstubs.
+
+       * src/vm/jit/codegen-common.c (codegen_finish) [ENABLE_REPLACEMENT]:
+       Do not resolve pointer to replacementstubs.
+       [6a3a569589cb]
+
+       * src/vmcore/options.c:
+       * src/vmcore/options.c (options_XX): Fixed -XX:TraceReplacement.
+       [6ca74617e290]
+
+       * src/vm/vm.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.h (opt_replace_verbose): Removed.
+       * src/vmcore/options.c (opt_replace_verbose): Removed.
+       * src/vm/vm.c [ENABLE_INLINING]: Removed options -ir and -iR, this is
+       now called -XX:TraceReplacement.
+       [503ca78a9980]
+
+2007-07-18  twisti  <twisti>
+
+       * src/vm/vm.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/vm.c (opts): Added -XX. (usage): Small text change.
+
+       * src/vmcore/options.c (opt_DebugStackFrameInfo): Added.
+       (opt_DebugStackTrace): Likewise. (options_XX): Added type and some
+       documentation. (options_xxusage): New function. (options_xx): Do
+       more error checking.
+
+       * src/vmcore/options.h (option_t): Added type and renamed option to
+       value. (opt_DebugStackFrameInfo): Added. (opt_DebugStackTrace):
+       Likewise.
+       [90b1f890ec50]
+
+2007-07-18  michi  <michi>
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/emit-
+       common.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/emit.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/emit.c, src/vm/jit/replace.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/replace.h (REPLACEMENT_EMIT_STUBS): Removed macro.
+
+       * src/vm/jit/emit-common.h (emit_replacement_stubs): Removed.
+
+       * src/vm/jit/arm/emit.c,
+       * src/vm/jit/arm/codegen.c,
+       * src/vm/jit/powerpc/emit.c,
+       * src/vm/jit/powerpc/codegen.c,
+       * src/vm/jit/sparc64/emit.c,
+       * src/vm/jit/sparc64/codegen.c,
+       * src/vm/jit/alpha/emit.c,
+       * src/vm/jit/alpha/codegen.c,
+       * src/vm/jit/s390/emit.c,
+       * src/vm/jit/mips/emit.c,
+       * src/vm/jit/mips/codegen.c,
+       * src/vm/jit/m68k/codegen.c,
+       * src/vm/jit/powerpc64/emit.c,
+       * src/vm/jit/powerpc64/codegen.c,
+       * src/vm/jit/i386/emit.c,
+       * src/vm/jit/i386/codegen.c,
+       * src/vm/jit/x86_64/emit.c,
+       * src/vm/jit/x86_64/codegen.c (emit_replacement_stubs): Removed.
+       (codegen_emit): Do not create replacement stubs anymore.
+       [4b35cbd82eab]
+
+2007-07-18  twisti  <twisti>
+
+       * src/cacaoh/dummy.c, src/native/jni.c, src/vm/builtin.c,
+       src/vm/builtintable.inc, src/vm/exceptions.c, src/vm/global.h,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/asmpart.h,
+       src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, src/vm/jit/i386
+       /md-abi.c, src/vm/jit_interface.h, src/vm/vm.c, src/vm/vm.h,
+       src/vmcore/descriptor.c:
+       * src/vm/jit/allocator/simplereg.c: Replaced HAS_4BYTE_STACKSLOT
+       with SIZEOF_VOID_P == 4.
+
+       * src/vm/jit/i386/emit.c (vm/jit/abi.h): Added.
+       (emit_verbosecall_enter): Changed to 8-byte stackslots.
+
+       * src/vm/jit/i386/codegen.c (codegen_emit): Changed to 8-byte
+       stackslots. (codegen_emit_stub_native): Likewise.
+
+       * src/vm/jit/i386/arch.h (HAS_4BYTE_STACKSLOT): Removed.
+       (ALIGN_LONGS_IN_MEMORY): Likewise. (ALIGN_DOUBLES_IN_MEMORY):
+       Likewise.
+
+       * src/vm/jit/i386/asmpart.S (asm_vm_call_method): Rewritten for new
+       argument passing. (asm_handle_exception): Use 8-byte stackslots.
+
+       * src/vm/jit/i386/md-abi.c (md_param_alloc): Use 8-byte stackslots
+       and set pd->index. (md_param_alloc_native): New function.
+
+       * src/vm/global.h (ALIGN_EVEN): New macro. (ALIGN_ODD): Likewise.
+       (ALIGN_2): Defined to ALIGN_EVEN.
+
+       * src/vm/builtintable.inc (builtintable_function): Removed #ifdef
+       for java.lang.VMSystem.arraycopy, this works now correctly.
+
+       * src/vm/builtin.c (builtintable_init): Set ACC_METHOD_BUILTIN when
+       parsing the decriptor.
+
+       * src/vm/jit_interface.h (md_param_alloc_native): Added.
+
+       * src/vm/exceptions.c (exceptions_handle_exception): Temporarily
+       added __I386__ to get the monitor object correctly.
+
+       * src/vmcore/descriptor.c (descriptor_pool_parse_method_descriptor):
+       Check for ACC_METHOD_BUILTIN flag.
+       (descriptor_params_from_paramtypes): Likewise.
+
+       * src/cacaoh/dummy.c (md_param_alloc_native): Added.
+
+       * src/vm/jit/asmpart.h: Added __I386__ ifdef.
+       * src/vm/vm.c: Likewise.
+       * src/vm/vm.h: Likewise.
+       * src/native/jni.c: Likewise. (_Jv_jni_invokeNative): Check for
+       exception too when vm_array_from_objectarray returns.
+       [d8c3d6cb993f]
+
+2007-07-17  twisti  <twisti>
+
+       * src/native/jni.c, src/native/vm/java_lang_ClassLoader.c,
+       src/vmcore/class.c, src/vmcore/class.h:
+       * src/vmcore/class.c (vm/resolve.h): Added. (class_define): Changed
+       signature.
+       * src/vmcore/class.h (class_define): Likewise.
+
+       * src/native/jni.c (_Jv_JNI_DefineClass): Bug fix, use class_define.
+
+       * src/native/vm/java_lang_ClassLoader.c (defineClass): Use
+       class_define.
+       [e181022e65d4]
+
+       * src/native/jni.c:
+       * src/native/jni.c (TRACEJNICALLS): Added but still unused.
+       (JNI_GetCreatedJavaVMs): Implemented.
+       [704d5895a3e2]
+
+2007-07-16  twisti  <twisti>
+
+       * src/native/vm/java_lang_Class.c, src/vmcore/class.c,
+       src/vmcore/class.h:
+       * src/vmcore/class.c (class_get_declaringclass): New function.
+       * src/vmcore/class.h: Likewise.
+
+       * src/native/vm/java_lang_Class.c (getDeclaringClass): Use
+       class_get_declaringclass.
+       [1d90dbbeee2b]
+
+2007-07-15  twisti  <twisti>
+
+       * src/native/vm/sun/jvm.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.c (opt_TraceJVMCalls): Added.
+       * src/vmcore/options.h: Likewise.
+
+       * src/native/vm/sun/jvm.c (vmcore/options.h): Added. (DEBUG_JVM):
+       Renamed to TRACEJVMCALLS. (JVM_GetArrayLength): Implemented.
+       [e98518f9a80f]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c: Set Id keyword.
+       [62b76fb297f1]
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_ArrayCopy): Fixed warnings.
+       (JVM_GetStackTraceElement): Likewise. (JVM_FindLoadedClass):
+       Likewise.
+       [61524839b386]
+
+       * src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/primitive.c,
+       src/vmcore/primitive.h:
+       * src/vmcore/primitive.c (primitive_class_is_primitive): Removed.
+       * src/vmcore/primitive.h: Likewise.
+
+       * src/vmcore/class.c (class_is_primitive): New function.
+       (class_isanysubclass): Use class_is_primitive.
+       * src/vmcore/class.h: Likewise.
+
+       * src/native/vm/java_lang_Class.c (isPrimitive): Use
+       class_is_primitive. (getDeclaringClass): Likewise.
+       (getDeclaredClasses): Likewise.
+
+       * src/native/vm/sun/jvm.c (JVM_GetProtectionDomain): Likewise.
+       (JVM_IsPrimitiveClass): Likewise. (JVM_NewArray): Likewise.
+       [512da3c719eb]
+
+       * src/native/include/Makefile.am:
+       * src/native/include/Makefile.am [WITH_CLASSPATH_SUN]
+       (JAVASE_HEADER_FILES): Added sun_reflect_ConstantPool.h.
+       [2594b1bb74d6]
+
+       * src/native/vm/sun/jvm.c, src/vmcore/primitive.c,
+       src/vmcore/primitive.h:
+       * src/vmcore/primitive.c (stdint.h): Added.
+       (primitive_arrayclass_get_by_name): New function.
+
+       * src/vmcore/primitive.h (stdint.h): Added.
+       (primitive_arrayclass_get_by_name): Likewise.
+
+       * src/native/vm/sun/jvm.c (JVM_NewArray): Implemented handling for
+       primitive arrays.
+       [9d632e7741a1]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c: Build fix.
+       [a0bab80178fe]
+
+2007-07-13  michi  <michi>
+
+       * src/vm/jit/patcher-common.c, src/vmcore/statistics.c,
+       src/vmcore/statistics.h:
+       * src/vmcore/statistics.h (size_patchref): Added.
+       * src/vmcore/statistics.c (size_patchref): Added.
+       (statistics_print_memory_usage): Print size of patcher references.
+
+       * src/vm/jit/patcher-common.c (patcher_add_patch_ref,
+       patcher_list_free) [ENABLE_STATISTICS] Set size of patcher
+       references accordingly.
+       [a08b6b8ca02b]
+
+2007-07-12  twisti  <twisti>
+
+       * src/native/jni.c, src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/md-
+       abi.c, src/vm/jit/asmpart.h, src/vm/vm.c, src/vm/vm.h:
+       * src/vm/jit/alpha/asmpart.S (asm_vm_call_method): Rewritten for new
+       argument passing.
+
+       * src/vm/jit/alpha/md-abi.c (md_param_alloc): Set pd->index.
+
+       * src/native/jni.c: Added __ALPHA__ ifdef.
+       * src/vm/vm.c: Likewise.
+       * src/vm/vm.h: Likewise.
+       * src/vm/jit/asmpart.h: Likewise.
+       [e797b7ba8cef]
+
+2007-07-11  twisti  <twisti>
+
+       * src/vm/jit/x86_64/asmpart.S:
+       * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method): Fixed stack
+       alignment.
+       [83e9597727e8]
+
+       * src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): Fixed bug when taking
+       out double arguments. (codegen_emit_stub_native): Use switch-case
+       for saving and restoring argument registers.
+       [c1098e0c7614]
+
+2007-07-11  pm  <pm>
+
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c:
+       * src/vm/jit/s390/codegen.c (codegen_emit): Extended maximal
+       interface table offset from 12 bit to 16 bit in
+       ICMD_INVOKEINTERFACE.
+       * src/vm/jit/s390/patcher.c (patcher_invokeinterface): Likewise.
+       [f6bf38c6c8ef]
+
+2007-07-10  twisti  <twisti>
+
+       * src/vm/vm.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.c (opt_TraceJavaCalls): Added. (options_XX):
+       Added opt_TraceJavaCalls. (options_xx): Likewise.
+
+       * src/vmcore/options.h (opt_TraceJavaCalls): Added.
+
+       * src/vm/vm.c (XXusage): Removed -verbose:call. (vm_create):
+       Likewise.
+       [9d27af991ee3]
+
+2007-07-09  twisti  <twisti>
+
+       * src/vm/global.h:
+       * src/vm/global.h (ALIGN_2): Use logical arithmetic.
+       [95411b1de43b]
+
+       * src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): Fixed
+       typo.
+       [81577d9b7a70]
+
+2007-07-08  twisti  <twisti>
+
+       * src/vm/jit/powerpc/darwin/md-abi.h, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-abi.h:
+       * src/vm/jit/powerpc/emit.c (stdint.h): Added
+       (emit_verbosecall_enter): Reimplemented (this implementation is much
+       simpler and maybe should be extended to trace also arguments on the
+       stack). Darwin support is still missing.
+
+       * src/vm/jit/powerpc/darwin/md-abi.h (TRACE_ARGS_NUM): Changed to 4.
+       * src/vm/jit/powerpc/linux/md-abi.h (TRACE_ARGS_NUM): Likewise.
+       [76e8134d9547]
+
+       * src/vm/jit/powerpc/linux/md-abi.c:
+       * src/vm/jit/powerpc/linux/md-abi.c (vm/types.h): Removed.
+       (stdint.h): Added and use stdint-types in this file. (_ALIGN):
+       Removed and use ALIGN_2 in this file.
+       [2f63d1dad075]
+
+2007-07-07  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/solaris/md-os.c:
+       * src/vm/jit/sparc64/solaris/md-os.c: Implemented hardware exception
+       handling.
+       [f8def35f35a7]
+
+2007-07-06  michi  <michi>
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/linux/md-os.c:
+       * src/vm/jit/alpha/codegen.c (codegen_emit): ICMD_BUILTIN now calls
+       stubs. (codegen_emit_stub_builtin): Implemented.
+
+       * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigusr1):
+       Implemented.
+       [8e1026b0065a]
+
+2007-07-05  michi  <michi>
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/arm/md.c, src/vm/jit/code.c,
+       src/vm/jit/code.h, src/vm/jit/patcher.h, src/vm/jit/replace.c:
+       Merged revisions 8183-8186 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r8184 | michi | 2007-07-05 23:11:01 +0200 (Thu, 05 Jul
+       2007) | 5 lines
+
+        * src/vm/jit/code.c (code_get_stack_frame_size): Removed.
+         * src/vm/jit/code.h: Likewise.
+
+        * src/vm/jit/replace.c: Use code->stackframesize instead of above
+       function. ........ r8185 | michi | 2007-07-05 23:34:47 +0200 (Thu,
+       05 Jul 2007) | 3 lines
+
+        * src/vm/jit/arm/md.c (md_get_method_patch_address): Added the
+       replacement magic about mptr being NULL sometimes. ........
+       r8186 | michi | 2007-07-06 01:48:16 +0200 (Fri, 06 Jul 2007) | 18
+       lines
+
+        * src/vm/jit/alpha/emit.c (emit_patcher_traps): Formerly known
+       as emit_patcher_stubs, now emits traps instead of stubs.
+
+        * src/vm/jit/alpha/codegen.c (codegen_emit,
+       codegen_emit_stub_native): Call the new patcher functions and
+       adapted to above change.
+
+        * src/vm/jit/alpha/patcher.c: Adapted patchers to new signature
+       for traps. (patcher_wrapper): Removed, this is obsolete.
+
+        * src/vm/jit/alpha/asmpart.S (asm_patcher_wrapper): Removed, this
+       is obsolete.
+
+        * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Only
+       calls the exception handling if exception object present.
+
+        * src/vm/jit/patcher-common.h [__ALPHA__]: Enabled new patcher
+       stuff.
+
+        * src/vm/jit/patcher.h [__ALPHA__]: Defined away old patcher
+       stuff. ........
+       [a3741372872e]
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/patcher-common.h,
+       src/vm/jit/patcher.h:
+       * src/vm/jit/alpha/emit.c (emit_patcher_traps): Formerly known as
+       emit_patcher_stubs, now emits traps instead of stubs.
+
+       * src/vm/jit/alpha/codegen.c (codegen_emit,
+       codegen_emit_stub_native): Call the new patcher functions and
+       adapted to above change.
+
+       * src/vm/jit/alpha/patcher.c: Adapted patchers to new signature for
+       traps. (patcher_wrapper): Removed, this is obsolete.
+
+       * src/vm/jit/alpha/asmpart.S (asm_patcher_wrapper): Removed, this is
+       obsolete.
+
+       * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Only
+       calls the exception handling if exception object present.
+
+       * src/vm/jit/patcher-common.h [__ALPHA__]: Enabled new patcher
+       stuff.
+
+       * src/vm/jit/patcher.h [__ALPHA__]: Defined away old patcher stuff.
+       [a1c06d17e926]
+
+       * src/vm/jit/arm/md.c:
+       * src/vm/jit/arm/md.c (md_get_method_patch_address): Added the
+       replacement magic about mptr being NULL sometimes.
+       [141abc4a7bad]
+
+       * src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/replace.c:
+       * src/vm/jit/code.c (code_get_stack_frame_size): Removed.
+       * src/vm/jit/code.h: Likewise.
+
+       * src/vm/jit/replace.c: Use code->stackframesize instead of above
+       function.
+       [2a910eb769bf]
+
+       * src/vm/jit/arm/codegen.c:
+       Merged revisions 8179-8182 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r8182 | michi | 2007-07-05 22:36:16 +0200 (Thu, 05 Jul
+       2007) | 2 lines
+
+        * src/vm/jit/arm/codegen.c (codegen_emit): Replacement points are
+       created. ........
+       [7d9eb0c5b094]
+
+       * src/vm/jit/arm/codegen.c:
+       * src/vm/jit/arm/codegen.c (codegen_emit): Replacement points are
+       created.
+       [668663c17f9d]
+
+       * src/mm/cacao-gc/gc.h, src/threads/native/threads.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/linux/md-os.c:
+       * src/threads/native/threads.c: Fixed bogus ifdef.
+
+       * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigusr1):
+       Implemented.
+
+       * src/vm/jit/arm/codegen.c (codegen_emit): ICMD_BUILTIN now calls
+       stubs. (codegen_emit_stub_builtin): Implemented.
+       (codegen_emit_stub_native) [ENABLE_GC_CACAO]: Saved registers are
+       stored in sfi.
+
+       * src/mm/cacao-gc/gc.h: Added ARM to ported architecture list.
+       [70c7e9fae365]
+
+       * src/mm/cacao-gc/gc.c:
+       * src/mm/cacao-gc/gc.c (gc_reference_register): Fixed problem with
+       threads_init.
+       [1f0a1f599bf5]
+
+       * configure.ac, src/mm/boehm.c, src/mm/nogc.c, src/native/jni.c,
+       src/native/native.c, src/native/native.h, src/native/vm/Makefile.am,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/java_lang_Runtime.c, src/native/vm/sun_misc_Unsafe.c,
+       src/vm/builtin.c, src/vm/exceptions.c, src/vm/exceptions.h,
+       src/vm/global.h, src/vm/jit/Makefile.am, src/vm/jit/alpha/linux/md-
+       os.c, src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c,
+       src/vm/jit/arm/linux/md-os.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/codegen-common.c,
+       src/vm/jit/emit-common.h, src/vm/jit/i386/darwin/Makefile.am,
+       src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/i386/patcher.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/parse.c, src/vm/jit/patcher.h, src/vm/jit/powerpc/darwin
+       /md-os.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/tests/dacapo.status,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c,
+       src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h,
+       src/vm/jit/sparc64/patcher.c, src/vm/jit/sparc64/solaris/md-os.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/verify/typecheck-typeinferer.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/vm.c, src/vm/vm.h, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/linker.c, src/vmcore/options.c:
+       Merged revisions 8137-8178 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r8139 | twisti | 2007-06-24 12:12:27 +0200 (Sun, 24 Jun
+       2007) | 3 lines
+
+        * src/vm/jit/stacktrace.c (stacktrace_print_trace): Handle
+       WITH_CLASSPATH_SUN properly. ........ r8142 | pm | 2007-06-25
+       20:58:11 +0200 (Mon, 25 Jun 2007) | 3 lines
+
+        * src/vm/jit/s390/tests/jasmin.status: Added. ........ r8143 |
+       twisti | 2007-06-26 17:47:43 +0200 (Tue, 26 Jun 2007) | 3 lines
+
+        * src/vm/jit/i386/patcher.c (patcher_builtin_multianewarray):
+       Dont' patch function address. ........ r8144 | pm | 2007-06-26
+       23:16:35 +0200 (Tue, 26 Jun 2007) | 3 lines
+
+        * src/vm/jit/s390/tests/dacapo.status: Added more dacapo eclipse
+       results. ........ r8145 | michi | 2007-06-27 10:54:10 +0200 (Wed,
+       27 Jun 2007) | 16 lines
+
+        * src/vm/jit/patcher-common.h: Added.
+         * src/vm/jit/patcher-common.t: Added.
+         * src/vm/jit/Makefile.am: Added above two files.
+
+        * src/vm/jit/code.h (codeinfo): Added patcher list.
+         * src/vm/jit/code.c (code_codeinfo_new, code_codeinfo_free): Patcher
+       list is created and freed together with codeinfo.
+
+        * src/vm/jit/codegen-common.c (codegen_finish): Absolute PCs for
+       patchers are resolved.
+
+        * src/vm/jit/emit-common.h (emit_patcher_traps): Added prototype.
+
+        * src/vm/exception.c (exceptions_new_hardware_exception): Patcher
+       handler is called if needed. ........ r8146 | michi | 2007-06-27
+       11:04:17 +0200 (Wed, 27 Jun 2007) | 3 lines
+
+        * src/vm/exceptions.h: Added EXCEPTION_HARDWARE_COMPILER.
+         * src/vm/exceptions.c (exceptions_init): Made check clearer. ........
+       r8147 | twisti | 2007-06-27 11:23:24 +0200 (Wed, 27 Jun 2007) | 2
+       lines
+
+        * src/native/vm/gnu/java_lang_VMRuntime.c (unistd.h): Added.
+       ........ r8149 | twisti | 2007-06-27 15:26:49 +0200 (Wed, 27 Jun
+       2007) | 3 lines
+
+        * src/native/vm/sun_misc_Unsafe.c (putObject): New function.
+       (park): New function, but not implemented. ........ r8150 | twisti
+       | 2007-06-27 20:35:40 +0200 (Wed, 27 Jun 2007) | 6 lines
+
+        * src/mm/boehm.c (gc_init): Set GC_all_interior_pointers to 0 and
+       call GC_INIT very late.
+
+        * src/vm/vm.c (vm_create): Initialze the GC before all other
+       subsystems. ........ r8151 | pm | 2007-06-27 22:08:30 +0200 (Wed,
+       27 Jun 2007) | 2 lines
+
+        * src/vm/jit/s390/codegen.c (codegen_emit): Replace some
+       load/stores by a mvc. ........ r8152 | pm | 2007-06-27 22:37:45
+       +0200 (Wed, 27 Jun 2007) | 2 lines
+
+        * src/vm/jit/s390/codegen.c (codegen_emit): Fix profiling code.
+       ........ r8153 | ajordan | 2007-06-27 22:56:03 +0200 (Wed, 27 Jun
+       2007) | 12 lines
+
+        * src/vm/jit/sparc64/md-abi.h: Removed faulty register offset
+       multiplication from REG_WINDOW_TRANSPOSE.
+
+        * src/vm/jit/sparc64/asmpart.S: fixed offsets.h include.
+
+        * src/vm/jit/sparc64/solaris/macro_rename.h: Added include,
+       which renames the REG_SP defined from Solaris sys headers to
+       REG_SP_SOLARIS and defines mine.
+         * src/vm/jit/sparc64/emit.c: Used here.
+         * src/vm/jit/sparc64/codegen.c: Used here.
+         * src/vm/jit/sparc64/patcher.c: Used here. ........ r8154 | ajordan
+       | 2007-06-27 22:56:57 +0200 (Wed, 27 Jun 2007) | 2 lines
+
+        * configure.ac: Added librt for SPARC/Solaris. ........ r8155 |
+       ajordan | 2007-06-27 23:53:44 +0200 (Wed, 27 Jun 2007) | 6 lines
+
+        * src/vm/builtin.c (builtin_f2l): Added for DISABLE_GC.
+       (builtin_d2l): Likewise.
+
+        * src/native/jni.c (_Jv_jni_invokeNative): Added SPARC to defines,
+       corrected bitwise & for ARM. ........ r8156 | ajordan |
+       2007-06-28 00:07:28 +0200 (Thu, 28 Jun 2007) | 2 lines
+
+        * configure.ac: Check for librt should only be done on Solaris.
+       ........ r8157 | michi | 2007-06-28 00:12:32 +0200 (Thu, 28 Jun
+       2007) | 3 lines
+
+        * src/vm/vm.c: Fixed messed up ifdefs introduced with M68K.
+         * src/vm/vm.h: Likewise. ........ r8158 | ajordan | 2007-06-28
+       02:01:34 +0200 (Thu, 28 Jun 2007) | 6 lines
+
+        * src/vm/jit/sparc64/md-abi.c (md_param_alloc): Added absolute
+       offsets for native arguments (reguse * 8).
+
+        * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Adapted
+       to change above. ........ r8159 | michi | 2007-06-28 02:31:31
+       +0200 (Thu, 28 Jun 2007) | 5 lines
+
+        * src/vm/jit/verify/typecheck-typeinferer.c: Removed patcher.h
+       include.
+         * src/vm/jit/verify/typecheck.c: Likewise.
+         * src/vm/jit/parse.c: Likewise.
+         * src/vm/builtin.c: Likewise. ........ r8160 | michi | 2007-06-28
+       03:52:19 +0200 (Thu, 28 Jun 2007) | 26 lines
+
+        * src/vm/jit/arm/emit.c (emit_patcher_traps): Formerly known as
+       emit_patcher_stubs, now emits traps instead of stubs.
+
+        * src/vm/jit/arm/codegen.c (codegen_emit,
+       codegen_emit_stub_native): Call the new patcher functions and
+       adapted to above change.
+
+        * src/vm/jit/arm/patcher.c: Adapted patchers to new signature for
+       traps. (patcher_get_putfield): Fixed severe bug for long values.
+       (patcher_wrapper): Removed, this is obsolete.
+
+        * src/vm/jit/arm/codegen.h (M_TRAP): Added.
+
+        * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Removed, this is
+       obsolete.
+
+        * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill): Only
+       calls the exception handling if exception object present.
+
+        * src/vm/jit/patcher-common.c: Fixed includes.
+
+        * src/vm/jit/patcher-common.h [__ARM__]: Added prototypes for
+       patcher functions. (patchref_t): Added datap.
+
+        * src/vm/jit/patcher.h [__ARM__]: Defined away old patcher stuff.
+
+        * src/vm/jit/codegen-common.c (codegen_finish): Resolves pr->datap
+       as well. ........ r8161 | twisti | 2007-06-28 12:30:08 +0200 (Thu,
+       28 Jun 2007) | 11 lines
+
+        * src/vm/global.h (ACC_CLASS_REFERENCE_MASK): Added.
+       (ACC_CLASS_SOFT_REFERENCE): Renamed to ACC_CLASS_REFERENCE_SOFT.
+       (ACC_CLASS_WEAK_REFERENCE): Renamed to ACC_CLASS_REFERENCE_WEAK.
+       (ACC_CLASS_PHANTOM_REFERENCE): Renamed to
+       ACC_CLASS_REFERENCE_PHANTOM.
+
+        * src/vmcore/class.c (class_create_classinfo): Flag
+       soft/weak/phantom reference classes.
+
+        * src/vmcore/linker.c (link_class_intern): Inherit the reference
+       flags. ........ r8162 | twisti | 2007-06-28 15:40:37 +0200 (Thu,
+       28 Jun 2007) | 2 lines
+
+        * src/native/vm/sun/jvm.c: Added copyright header. ........
+       r8163 | twisti | 2007-06-29 20:53:55 +0200 (Fri, 29 Jun 2007) | 16
+       lines
+
+        * configure.ac (AC_CHECK_HEADERS): Added netdb.h, ucontext.h.
+       (AC_CHECK_FUNCS): Added gethostbyname, htons, malloc, recv, send.
+       (AC_CHECK_ENABLE_ZLIB): Moved code to function.
+       (AC_CHECK_ENABLE_LTDL): Likewise.
+
+        * m4/zlib.m4: New file.
+         * m4/ltdl.m4: Likewise.
+
+        * src/native/native.c [ENABLE_LTDL && HAVE_LTDL_H] (ltdl.h): Added
+       #ifdef. [ENABLE_LTDL] (hashtable_library): Likewise.
+       (native_init) [ENABLE_LTDL]: Likewise. [ENABLE_LTDL]
+       (native_library_open): Likewise. [ENABLE_LTDL]
+       (native_library_add): Likewise. [ENABLE_LTLD]
+       (native_library_find): Likewise. ........ r8164 | twisti |
+       2007-06-29 20:56:08 +0200 (Fri, 29 Jun 2007) | 2 lines
+
+        * src/native/native.c (native_library_find): Typo. ........
+       r8165 | twisti | 2007-06-29 21:02:08 +0200 (Fri, 29 Jun 2007) | 4
+       lines
+
+        * src/native/vm/java_lang_Runtime.c [ENABLE_LTDL && HAVE_LTDL_H]
+       (ltdl.h): Added #ifdef. (loadLibrary) [ENABLE_LTDL]: Likewise.
+       ........ r8166 | twisti | 2007-06-29 21:45:17 +0200 (Fri, 29 Jun
+       2007) | 9 lines
+
+        * src/native/native.c: Removed wrong comment.
+
+        * src/native/native.h [ENABLE_LTDL && HAVE_LTDL_H] (ltdl.h): Added
+       #ifdef. [ENABLE_LTDL] (hashtable_library_loader_entry): Likewise.
+       [ENABLE_LTDL] (hashtable_library_name_entry): Likewise.
+       [ENABLE_LTDL] (native_library_open, native_library_add)
+       (native_library_find): Likewise. ........ r8167 | twisti |
+       2007-06-29 22:27:41 +0200 (Fri, 29 Jun 2007) | 3 lines
+
+        * src/native/native.h (hashtable_library_name_entry): Moved up,
+       build fix. ........ r8168 | twisti | 2007-06-30 14:20:48 +0200
+       (Sat, 30 Jun 2007) | 2 lines
+
+        * src/mm/nogc.c (vm/vm.h): Added. ........ r8169 | twisti |
+       2007-06-30 14:33:50 +0200 (Sat, 30 Jun 2007) | 18 lines
+
+        * src/vmcore/class.c (class_is_array): New function.
+       (class_is_interface): Likewise.
+         * src/vmcore/class.h: Likewise.
+
+        * src/native/vm/java_lang_Class.c (stdint.h): Added.
+       (isInterface): Made JNI function, use class_is_interface.
+       (isArray): Made JNI function, use class_is_array.
+         * src/native/vm/java_lang_Class.h: Likewise.
+
+        * src/native/vm/cldc1.1/java_lang_Class.c (methods): Register
+       common methods for isInterface and isArray. (isInterface):
+       Removed. (isArray): Likewise.
+
+        * src/native/vm/gnu/java_lang_VMClass.c (isInterface): Changed to
+       JNI call. (isArray): Likewise. ........ r8170 | twisti |
+       2007-06-30 16:03:18 +0200 (Sat, 30 Jun 2007) | 23 lines
+
+        * src/native/jni.c [ENABLE_JAVASE] (native/vm/reflect.h): Added.
+       (_Jv_JNI_ToReflectedMethod): Implemented.
+
+        * src/native/vm/java_lang_Class.c [ENABLE_JAVASE]
+       (native/vm/reflect.h): Added. (getDeclaredFields): Use
+       reflect_field_new. (getDeclaredMethods): Use reflect_method_new.
+       (getDeclaredConstructors): Use reflect_constructor_new.
+       (getEnclosingConstructor): Use reflect_constructor_new.
+       (getEnclosingMethod): Use reflect_method_new.
+
+        * src/native/vm/sun/jvm.c (jio_vsnprintf): Added count check.
+       (jio_snprintf): Implemented. (JVM_IsInterface): Use
+       class_is_interface. (JVM_IsArrayClass): Use class_is_array.
+       (JVM_InvokeMethod): Disabled debug output.
+
+        * src/native/vm/reflect.c: New file.
+         * src/native/vm/reflect.h: Likewise.
+
+        * src/native/vm/Makefile.am [ENABLE_JAVASE] (REFLECT_SOURCES):
+       Added. (libnativevm_la_SOURCES): Added REFLECT_SOURCES. ........
+       r8171 | twisti | 2007-06-30 16:13:58 +0200 (Sat, 30 Jun 2007) | 2
+       lines
+
+        * src/native/vm/reflect.c: Fixed includes. ........ r8172 |
+       twisti | 2007-06-30 16:14:52 +0200 (Sat, 30 Jun 2007) | 3 lines
+
+        * src/native/vm/reflect.c: Added Id keyword.
+         * src/native/vm/reflect.h: Likewise. ........ r8173 | twisti |
+       2007-06-30 19:40:09 +0200 (Sat, 30 Jun 2007) | 3 lines
+
+        * src/native/vm/sun/jvm.c (JVM_Available): Fixed return value
+       (seems it's a boolean value, 1 is OK, 0 is error). ........
+       r8174 | twisti | 2007-07-01 19:49:25 +0200 (Sun, 01 Jul 2007) | 2
+       lines
+
+        * src/vmcore/options.c (options_xx): Fixed warnings. ........
+       r8175 | twisti | 2007-07-02 16:07:24 +0200 (Mon, 02 Jul 2007) | 3
+       lines
+
+        * src/vm/exceptions.c (exceptions_init) [!(__ARM__ && __LINUX__)]:
+       Don't mmap page 0x0 on arm-linux. ........ r8176 | twisti |
+       2007-07-03 17:43:14 +0200 (Tue, 03 Jul 2007) | 3 lines
+
+        * src/vm/jit/i386/darwin/Makefile.am (AM_CPPFLAGS): Added
+         -I$(top_builddir)/src. ........ r8177 | twisti | 2007-07-03
+       18:05:27 +0200 (Tue, 03 Jul 2007) | 3 lines
+
+        * src/native/vm/sun_misc_Unsafe.c (methods): Added unpark.
+       (unpark): New function, but unimplemented. ........ r8178 | michi
+       | 2007-07-05 13:13:20 +0200 (Thu, 05 Jul 2007) | 22 lines
+
+        * src/vm/exceptions.c (exceptions_new_hardware_exception):
+       Stackframeinfo block is now on the stack of the signal handler
+       function.
+
+        * src/vm/exceptions.h (exceptions_new_hardware_exception): Changed
+       signature.
+
+        * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Passes
+       sfi to exceptions function.
+
+        * src/vm/jit/powerpc/linux/md-os.c: Likewise.
+         * src/vm/jit/powerpc/darwin/md-os.c: Likewise.
+         * src/vm/jit/sparc64/linux/md-os.c: Likewise.
+         * src/vm/jit/sparc64/solaris/md-os.c: Likewise.
+         * src/vm/jit/alpha/linux/md-os.c: Likewise.
+         * src/vm/jit/s390/md.c: Likewise.
+         * src/vm/jit/mips/linux/md-os.c: Likewise.
+         * src/vm/jit/mips/irix/md-os.c: Likewise.
+         * src/vm/jit/m68k/linux/md-os.c: Likewise.
+         * src/vm/jit/powerpc64/linux/md-os.c: Likewise.
+         * src/vm/jit/i386/darwin/md-os.c: Likewise.
+         * src/vm/jit/i386/linux/md-os.c: Likewise.
+         * src/vm/jit/x86_64/linux/md-os.c: Likewise. ........
+       [45996bcfca93]
+
+       * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/alpha/linux/md-
+       os.c, src/vm/jit/arm/linux/md-os.c, src/vm/jit/i386/darwin/md-os.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/md.c,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/solaris/md-
+       os.c, src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/exceptions.c (exceptions_new_hardware_exception):
+       Stackframeinfo block is now on the stack of the signal handler
+       function.
+
+       * src/vm/exceptions.h (exceptions_new_hardware_exception): Changed
+       signature.
+
+       * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Passes
+       sfi to exceptions function.
+
+       * src/vm/jit/powerpc/linux/md-os.c: Likewise.
+       * src/vm/jit/powerpc/darwin/md-os.c: Likewise.
+       * src/vm/jit/sparc64/linux/md-os.c: Likewise.
+       * src/vm/jit/sparc64/solaris/md-os.c: Likewise.
+       * src/vm/jit/alpha/linux/md-os.c: Likewise.
+       * src/vm/jit/s390/md.c: Likewise.
+       * src/vm/jit/mips/linux/md-os.c: Likewise.
+       * src/vm/jit/mips/irix/md-os.c: Likewise.
+       * src/vm/jit/m68k/linux/md-os.c: Likewise.
+       * src/vm/jit/powerpc64/linux/md-os.c: Likewise.
+       * src/vm/jit/i386/darwin/md-os.c: Likewise.
+       * src/vm/jit/i386/linux/md-os.c: Likewise.
+       * src/vm/jit/x86_64/linux/md-os.c: Likewise.
+       [ed15bb556f62]
+
+2007-07-03  twisti  <twisti>
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (methods): Added unpark. (unpark):
+       New function, but unimplemented.
+       [5c5f4a6dbe96]
+
+       * src/vm/jit/i386/darwin/Makefile.am:
+       * src/vm/jit/i386/darwin/Makefile.am (AM_CPPFLAGS): Added
+       -I$(top_builddir)/src.
+       [d090c160bd9d]
+
+2007-07-02  twisti  <twisti>
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_init) [!(__ARM__ && __LINUX__)]:
+       Don't mmap page 0x0 on arm-linux.
+       [00c88ae777e6]
+
+2007-07-01  twisti  <twisti>
+
+       * src/vmcore/options.c:
+       * src/vmcore/options.c (options_xx): Fixed warnings.
+       [eb45b5e3c073]
+
+2007-06-30  twisti  <twisti>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c (JVM_Available): Fixed return value (seems
+       it's a boolean value, 1 is OK, 0 is error).
+       [4432ee1ce926]
+
+       * src/native/vm/reflect.c, src/native/vm/reflect.h:
+       * src/native/vm/reflect.c: Added Id keyword.
+       * src/native/vm/reflect.h: Likewise.
+       [046c821f97fd]
+
+       * src/native/vm/reflect.c:
+       * src/native/vm/reflect.c: Fixed includes.
+       [f0af119deb56]
+
+       * src/native/jni.c, src/native/vm/Makefile.am,
+       src/native/vm/java_lang_Class.c, src/native/vm/reflect.c,
+       src/native/vm/reflect.h, src/native/vm/sun/jvm.c:
+       * src/native/jni.c [ENABLE_JAVASE] (native/vm/reflect.h): Added.
+       (_Jv_JNI_ToReflectedMethod): Implemented.
+
+       * src/native/vm/java_lang_Class.c [ENABLE_JAVASE]
+       (native/vm/reflect.h): Added. (getDeclaredFields): Use
+       reflect_field_new. (getDeclaredMethods): Use reflect_method_new.
+       (getDeclaredConstructors): Use reflect_constructor_new.
+       (getEnclosingConstructor): Use reflect_constructor_new.
+       (getEnclosingMethod): Use reflect_method_new.
+
+       * src/native/vm/sun/jvm.c (jio_vsnprintf): Added count check.
+       (jio_snprintf): Implemented. (JVM_IsInterface): Use
+       class_is_interface. (JVM_IsArrayClass): Use class_is_array.
+       (JVM_InvokeMethod): Disabled debug output.
+
+       * src/native/vm/reflect.c: New file.
+       * src/native/vm/reflect.h: Likewise.
+
+       * src/native/vm/Makefile.am [ENABLE_JAVASE] (REFLECT_SOURCES):
+       Added. (libnativevm_la_SOURCES): Added REFLECT_SOURCES.
+       [79479048da5d]
+
+       * src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/vmcore/class.c, src/vmcore/class.h:
+       * src/vmcore/class.c (class_is_array): New function.
+       (class_is_interface): Likewise.
+       * src/vmcore/class.h: Likewise.
+
+       * src/native/vm/java_lang_Class.c (stdint.h): Added. (isInterface):
+       Made JNI function, use class_is_interface. (isArray): Made JNI
+       function, use class_is_array.
+       * src/native/vm/java_lang_Class.h: Likewise.
+
+       * src/native/vm/cldc1.1/java_lang_Class.c (methods): Register common
+       methods for isInterface and isArray. (isInterface): Removed.
+       (isArray): Likewise.
+
+       * src/native/vm/gnu/java_lang_VMClass.c (isInterface): Changed to
+       JNI call. (isArray): Likewise.
+       [acb7df19a892]
+
+       * src/mm/nogc.c:
+       * src/mm/nogc.c (vm/vm.h): Added.
+       [63946b83b797]
+
+2007-06-29  twisti  <twisti>
+
+       * src/native/native.h:
+       * src/native/native.h (hashtable_library_name_entry): Moved up,
+       build fix.
+       [d52db4d05f7f]
+
+       * src/native/native.c, src/native/native.h:
+       * src/native/native.c: Removed wrong comment.
+
+       * src/native/native.h [ENABLE_LTDL && HAVE_LTDL_H] (ltdl.h): Added
+       #ifdef. [ENABLE_LTDL] (hashtable_library_loader_entry): Likewise.
+       [ENABLE_LTDL] (hashtable_library_name_entry): Likewise.
+       [ENABLE_LTDL] (native_library_open, native_library_add)
+       (native_library_find): Likewise.
+       [37f54ade6767]
+
+       * src/native/vm/java_lang_Runtime.c:
+       * src/native/vm/java_lang_Runtime.c [ENABLE_LTDL && HAVE_LTDL_H]
+       (ltdl.h): Added #ifdef. (loadLibrary) [ENABLE_LTDL]: Likewise.
+       [d4bf1a094f8c]
+
+       * src/native/native.c:
+       * src/native/native.c (native_library_find): Typo.
+       [bab9a7c581a5]
+
+       * configure.ac, m4/ltdl.m4, m4/zlib.m4, src/native/native.c:
+       * configure.ac (AC_CHECK_HEADERS): Added netdb.h, ucontext.h.
+       (AC_CHECK_FUNCS): Added gethostbyname, htons, malloc, recv, send.
+       (AC_CHECK_ENABLE_ZLIB): Moved code to function.
+       (AC_CHECK_ENABLE_LTDL): Likewise.
+
+       * m4/zlib.m4: New file.
+       * m4/ltdl.m4: Likewise.
+
+       * src/native/native.c [ENABLE_LTDL && HAVE_LTDL_H] (ltdl.h): Added
+       #ifdef. [ENABLE_LTDL] (hashtable_library): Likewise. (native_init)
+       [ENABLE_LTDL]: Likewise. [ENABLE_LTDL] (native_library_open):
+       Likewise. [ENABLE_LTDL] (native_library_add): Likewise.
+       [ENABLE_LTLD] (native_library_find): Likewise.
+       [89167cd086a1]
+
+2007-06-28  twisti  <twisti>
+
+       * src/native/vm/sun/jvm.c:
+       * src/native/vm/sun/jvm.c: Added copyright header.
+       [e28a66594929]
+
+       * src/vm/global.h, src/vmcore/class.c, src/vmcore/linker.c:
+       * src/vm/global.h (ACC_CLASS_REFERENCE_MASK): Added.
+       (ACC_CLASS_SOFT_REFERENCE): Renamed to ACC_CLASS_REFERENCE_SOFT.
+       (ACC_CLASS_WEAK_REFERENCE): Renamed to ACC_CLASS_REFERENCE_WEAK.
+       (ACC_CLASS_PHANTOM_REFERENCE): Renamed to
+       ACC_CLASS_REFERENCE_PHANTOM.
+
+       * src/vmcore/class.c (class_create_classinfo): Flag
+       soft/weak/phantom reference classes.
+
+       * src/vmcore/linker.c (link_class_intern): Inherit the reference
+       flags.
+       [a26a9d65db4f]
+
+2007-06-28  michi  <michi>
+
+       * src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c,
+       src/vm/jit/arm/linux/md-os.c, src/vm/jit/arm/patcher.c, src/vm/jit
+       /codegen-common.c, src/vm/jit/patcher-common.c, src/vm/jit/patcher-
+       common.h, src/vm/jit/patcher.h:
+       * src/vm/jit/arm/emit.c (emit_patcher_traps): Formerly known as
+       emit_patcher_stubs, now emits traps instead of stubs.
+
+       * src/vm/jit/arm/codegen.c (codegen_emit, codegen_emit_stub_native):
+       Call the new patcher functions and adapted to above change.
+
+       * src/vm/jit/arm/patcher.c: Adapted patchers to new signature for
+       traps. (patcher_get_putfield): Fixed severe bug for long values.
+       (patcher_wrapper): Removed, this is obsolete.
+
+       * src/vm/jit/arm/codegen.h (M_TRAP): Added.
+
+       * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Removed, this is
+       obsolete.
+
+       * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill): Only
+       calls the exception handling if exception object present.
+
+       * src/vm/jit/patcher-common.c: Fixed includes.
+
+       * src/vm/jit/patcher-common.h [__ARM__]: Added prototypes for
+       patcher functions. (patchref_t): Added datap.
+
+       * src/vm/jit/patcher.h [__ARM__]: Defined away old patcher stuff.
+
+       * src/vm/jit/codegen-common.c (codegen_finish): Resolves pr->datap
+       as well.
+       [dd42a4fb91a1]
+
+       * src/vm/builtin.c, src/vm/jit/parse.c, src/vm/jit/verify/typecheck-
+       typeinferer.c, src/vm/jit/verify/typecheck.c:
+       * src/vm/jit/verify/typecheck-typeinferer.c: Removed patcher.h
+       include.
+       * src/vm/jit/verify/typecheck.c: Likewise.
+       * src/vm/jit/parse.c: Likewise.
+       * src/vm/builtin.c: Likewise.
+       [a728115da0ec]
+
+2007-06-28  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/md-abi.c:
+       * src/vm/jit/sparc64/md-abi.c (md_param_alloc): Added absolute
+       offsets for native arguments (reguse * 8).
+
+       * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Adapted
+       to change above.
+       [9cfebf36e941]
+
+2007-06-27  michi  <michi>
+
+       * src/vm/vm.c, src/vm/vm.h:
+       * src/vm/vm.c: Fixed messed up ifdefs introduced with M68K.
+       * src/vm/vm.h: Likewise.
+       [8eadc67728d1]
+
+2007-06-27  ajordan  <ajordan>
+
+       * configure.ac:
+       * configure.ac: Check for librt should only be done on Solaris.
+       [aaba5c87ffb0]
+
+       * src/native/jni.c, src/vm/builtin.c:
+       * src/vm/builtin.c (builtin_f2l): Added for DISABLE_GC.
+       (builtin_d2l): Likewise.
+
+       * src/native/jni.c (_Jv_jni_invokeNative): Added SPARC to defines,
+       corrected bitwise & for ARM.
+       [bddcdeb22dc9]
+
+       * configure.ac:
+       * configure.ac: Added librt for SPARC/Solaris.
+       [923534fb6691]
+
+       * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md-abi.h,
+       src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/sparc64/solaris/macro_rename.h:
+       * src/vm/jit/sparc64/md-abi.h: Removed faulty register offset
+       multiplication from REG_WINDOW_TRANSPOSE.
+
+       * src/vm/jit/sparc64/asmpart.S: fixed offsets.h include.
+
+       * src/vm/jit/sparc64/solaris/macro_rename.h: Added include, which
+       renames the REG_SP defined from Solaris sys headers to
+       REG_SP_SOLARIS and defines mine.
+       * src/vm/jit/sparc64/emit.c: Used here.
+       * src/vm/jit/sparc64/codegen.c: Used here.
+       * src/vm/jit/sparc64/patcher.c: Used here.
+       [2f8525b7b726]
+
+2007-06-27  pm  <pm>
+
+       * src/vm/jit/s390/codegen.c:
+       * src/vm/jit/s390/codegen.c (codegen_emit): Fix profiling code.
+       [692df92fc20d]
+
+       * src/vm/jit/s390/codegen.c:
+       * src/vm/jit/s390/codegen.c (codegen_emit): Replace some load/stores
+       by a mvc.
+       [ae968da74f36]
+
+2007-06-27  twisti  <twisti>
+
+       * src/mm/boehm.c, src/vm/vm.c:
+       * src/mm/boehm.c (gc_init): Set GC_all_interior_pointers to 0 and
+       call GC_INIT very late.
+
+       * src/vm/vm.c (vm_create): Initialze the GC before all other
+       subsystems.
+       [7e6bf309d25b]
+
+       * src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/sun_misc_Unsafe.c (putObject): New function. (park):
+       New function, but not implemented.
+       [3a5a36091d6b]
+
+       * src/native/vm/gnu/java_lang_VMRuntime.c:
+       * src/native/vm/gnu/java_lang_VMRuntime.c (unistd.h): Added.
+       [748708276827]
+
+2007-06-27  michi  <michi>
+
+       * src/vm/exceptions.c, src/vm/exceptions.h:
+       * src/vm/exceptions.h: Added EXCEPTION_HARDWARE_COMPILER.
+       * src/vm/exceptions.c (exceptions_init): Made check clearer.
+       [943f3069095d]
+
+       * src/vm/exceptions.c, src/vm/jit/Makefile.am, src/vm/jit/code.c,
+       src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/emit-
+       common.h, src/vm/jit/patcher-common.c, src/vm/jit/patcher-common.h:
+       * src/vm/jit/patcher-common.h: Added.
+       * src/vm/jit/patcher-common.t: Added.
+       * src/vm/jit/Makefile.am: Added above two files.
+
+       * src/vm/jit/code.h (codeinfo): Added patcher list.
+       * src/vm/jit/code.c (code_codeinfo_new, code_codeinfo_free): Patcher
+       list is created and freed together with codeinfo.
+
+       * src/vm/jit/codegen-common.c (codegen_finish): Absolute PCs for
+       patchers are resolved.
+
+       * src/vm/jit/emit-common.h (emit_patcher_traps): Added prototype.
+
+       * src/vm/exception.c (exceptions_new_hardware_exception): Patcher
+       handler is called if needed.
+       [e4ced3dc9153]
+
+2007-06-26  pm  <pm>
+
+       * src/vm/jit/s390/tests/dacapo.status:
+       * src/vm/jit/s390/tests/dacapo.status: Added more dacapo eclipse
+       results.
+       [4ceab82084f8]
+
+2007-06-26  twisti  <twisti>
+
+       * src/vm/jit/i386/patcher.c:
+       * src/vm/jit/i386/patcher.c (patcher_builtin_multianewarray): Dont'
+       patch function address.
+       [1a440facfdcb]
+
+2007-06-25  pm  <pm>
+
+       * src/vm/jit/s390/tests/jasmin.status:
+       * src/vm/jit/s390/tests/jasmin.status: Added.
+       [ea95a0a32e67]
+
+2007-06-25  michi  <michi>
+
+       * src/native/vm/gnu/java_lang_VMClassLoader.c:
+       * src/native/vm/gnu/java_lang_VMClassLoader.c
+       (Java_java_lang_VMClassLoader_findLoadedClass): Fixed bug with
+       classloader entry not being registered.
+       [f7a82b765b39]
+
+       * src/vm/jit/stacktrace.c, src/vmcore/class.c, src/vmcore/class.h:
+       * src/vmcore/class.c (class_define, class_array_of): Fixed compiler
+       warnings.
+       * src/vmcore/class.h: Likewise.
+       [a14a956dfda2]
+
+2007-06-24  twisti  <twisti>
+
+       * src/vm/jit/stacktrace.c:
+       * src/vm/jit/stacktrace.c (stacktrace_print_trace): Handle
+       WITH_CLASSPATH_SUN properly.
+       [6d8488b06f3f]
+
+2007-06-22  michi  <michi>
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c:
+       * src/vm/jit/i386/codegen.c (codegen_emit_stub_builtin): Adapted to
+       multiplied regoff value.
+
+       * src/vm/jit/m68k/codegen.c (codegen_emit_stub_builtin): Likewise.
+       [e4de9c874bd6]
+
+       * configure.ac, m4/classpath.m4, src/cacao/Makefile.am,
+       src/lib/Makefile.am, src/native/include/Makefile.am,
+       src/native/jni.c, src/native/jni.h, src/native/native.c,
+       src/native/native.h, src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Object.h,
+       src/native/vm/java_lang_Thread.c,
+       src/native/vm/java_lang_reflect_Method.c, src/native/vm/nativevm.c,
+       src/native/vm/nativevm.h, src/native/vm/sun_misc_Unsafe.c,
+       src/threads/native/threads.c, src/threads/threads-common.c,
+       src/vm/jit/arm/arch.h, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/asmpart.h, src/vm/jit/m68k/arch.h,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c,
+       src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/replace.c,
+       src/vm/properties.c, src/vm/vm.c, src/vm/vm.h, src/vmcore/class.h,
+       src/vmcore/field.c, src/vmcore/field.h, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/utf8.c, src/vmcore/utf8.h:
+       Merged revisions 8123-8136 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r8125 | twisti | 2007-06-21 12:02:14 +0200 (Thu, 21 Jun
+       2007) | 4 lines
+
+        * configure.ac (AC_CHECK_HEADERS): Added sys/socket.h.
+       (AC_CHECK_FUNCS): Added accept, close, connect, getsockname, listen,
+       setsockopt, shutdown, socket. ........ r8126 | twisti | 2007-06-21
+       12:42:35 +0200 (Thu, 21 Jun 2007) | 2 lines
+
+        * configure.ac (AC_CHECK_FUNCS): Added gethostname. ........
+       r8127 | michi | 2007-06-21 13:55:56 +0200 (Thu, 21 Jun 2007) | 19
+       lines
+
+        * src/vm/jit/arm/arch.h: Removed HAS_4BYTE_STACKSLOT,
+       ALIGN_LONGS_IN_MEMORY and ALIGN_DOUBLES_IN_MEMORY.
+
+        * src/vm/jit/arm/md-abi.c (md_param_alloc): Changed to 8-byte
+       stackslots and set pd->index correctly.
+
+        * src/vm/jit/arm/codegen.c: Changed to 8-byte stackslots (spilled
+       regs and arguments only).
+
+        * src/vm/jit/arm/asmpart.S (asm_vm_call_method): Reimplemented to
+       fit new argument passing. Changed to 8-byte stackslots.
+
+        * src/vm/vm.c (vm_array_store_flt, vm_array_store_dbl)
+       [SUPPORT_PASS_FLOATARGS_IN_INTREGS]: Fixed.
+
+        * src/vm/vm.c: Added ARM ifdefs.
+         * src/vm/vm.h: Added ARM ifdefs.
+         * src/native/jni.c: Added ARM ifdefs. ........ r8128 | tbfg |
+       2007-06-21 18:29:53 +0200 (Thu, 21 Jun 2007) | 11 lines
+
+        * src/vm/jit/m68k/linux/md-abi.h: Prepared 8 byte stackslots.
+         * src/vm/jit/m68k/linux/md-abi.c: Likewise.
+         * src/vm/jit/m68k/emit.c: Likewise.
+         * src/vm/jit/m68k/arch.h: Likewise.
+         * src/vm/jit/m68k/codegen.c: Likewise.
+         * src/vm/jit/m68k/asmpart.S: Likewise.
+         * src/vm/jit/asmpart.h: Likewise.
+         * src/vm/vm.c: Likewise.
+         * src/vm/vm.h: Likewise.
+         * src/native/jni.c: Likewise. ........ r8130 | twisti | 2007-06-22
+       10:50:37 +0200 (Fri, 22 Jun 2007) | 5 lines
+
+        * src/vmcore/options.c (opt_ThreadStackSize): Added.
+       (options_xx): Option and values are seperated by '=', not by ':'
+       (let's keep compatible to Sun).
+         * src/vmcore/options.h (opt_ThreadStackSize): Added. ........ r8131
+       | tbfg | 2007-06-22 11:37:00 +0200 (Fri, 22 Jun 2007) | 3 lines
+
+        * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Fixed for 8
+       byte stack slots.
+         * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Fixed location of
+       method address. ........ r8132 | twisti | 2007-06-22 13:15:47
+       +0200 (Fri, 22 Jun 2007) | 44 lines
+
+        * configure.ac, contrib/mapfile-vers-product, m4/classpath.m4,
+       src/cacao/Makefile.am, src/lib/Makefile.am,
+       src/lib/gnu/java/lang/reflect,
+       src/lib/gnu/java/lang/reflect/Field.java,
+       src/lib/gnu/java/lang/reflect/Method.java, src/lib/gnu/sun,
+       src/lib/gnu/sun/misc, src/lib/gnu/sun/misc/Unsafe.java,
+       src/native/include/Makefile.am, src/native/jni.c,
+       src/native/jni.h, src/native/native.c, src/native/native.h,
+       src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Object.c,
+       src/native/vm/java_lang_Object.h,
+       src/native/vm/java_lang_Thread.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Method.c,
+       src/native/vm/nativevm.c, src/native/vm/nativevm.h,
+       src/native/vm/sun, src/native/vm/sun/Makefile.am,
+       src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c,
+       src/threads/native/threads.c, src/threads/threads-common.c,
+       src/vm/properties.c, src/vm/vm.c, src/vm/vm.h,
+       src/vmcore/class.h, src/vmcore/field.c, src/vmcore/field.h,
+       src/vmcore/utf8.c, src/vmcore/utf8.h: Initial support for using
+       OpenJDK libraries as Java core libraries. ........ r8133 |
+       twisti | 2007-06-22 15:29:38 +0200 (Fri, 22 Jun 2007) | 2 lines
+
+        * m4/classpath.m4: Added Id keyword. ........ r8134 | twisti |
+       2007-06-22 16:49:10 +0200 (Fri, 22 Jun 2007) | 8 lines
+
+        * src/vmcore/options.c (opt_MaxPermSize): Added. (opt_PermSize):
+       Likewise. (options_xx): Check for +/- for boolean options (still
+       some work left).
+
+        * src/vmcore/options.h (opt_MaxPermSize): Added. (opt_PermSize):
+       Likewise. ........ r8135 | twisti | 2007-06-22 17:31:05 +0200
+       (Fri, 22 Jun 2007) | 6 lines
+
+        * src/lib/gnu/sun/misc/Unsafe.java: Updated to openjdk rev239.
+
+        * src/native/vm/sun_misc_Unsafe.c (arrayBaseOffset): Implemented.
+       (arrayIndexScale): Likewise. (addressSize): Likewise. ........
+       r8136 | michi | 2007-06-22 18:33:40 +0200 (Fri, 22 Jun 2007) | 2
+       lines
+
+        * src/vm/jit/replace.c: Adapted to multiplied regoff value.
+       ........
+       [ee178e550972]
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c: Adapted to multiplied regoff value.
+       [373d83e92ed6]
+
+2007-06-22  twisti  <twisti>
+
+       * src/lib/gnu/sun/misc/Unsafe.java, src/native/vm/sun_misc_Unsafe.c:
+       * src/lib/gnu/sun/misc/Unsafe.java: Updated to openjdk rev239.
+
+       * src/native/vm/sun_misc_Unsafe.c (arrayBaseOffset): Implemented.
+       (arrayIndexScale): Likewise. (addressSize): Likewise.
+       [c5b2654c4c94]
+
+       * src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.c (opt_MaxPermSize): Added. (opt_PermSize):
+       Likewise. (options_xx): Check for +/- for boolean options (still
+       some work left).
+
+       * src/vmcore/options.h (opt_MaxPermSize): Added. (opt_PermSize):
+       Likewise.
+       [53a39efe485c]
+
+       * m4/classpath.m4:
+       * m4/classpath.m4: Added Id keyword.
+       [fa591512630b]
+
+       * configure.ac, contrib/mapfile-vers-product, m4/classpath.m4,
+       src/cacao/Makefile.am, src/lib/Makefile.am,
+       src/lib/gnu/java/lang/reflect/Field.java,
+       src/lib/gnu/java/lang/reflect/Method.java,
+       src/lib/gnu/sun/misc/Unsafe.java, src/native/include/Makefile.am,
+       src/native/jni.c, src/native/jni.h, src/native/native.c,
+       src/native/native.h, src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Object.h,
+       src/native/vm/java_lang_Thread.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Method.c, src/native/vm/nativevm.c,
+       src/native/vm/nativevm.h, src/native/vm/sun/Makefile.am,
+       src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c,
+       src/threads/native/threads.c, src/threads/threads-common.c,
+       src/vm/properties.c, src/vm/vm.c, src/vm/vm.h, src/vmcore/class.h,
+       src/vmcore/field.c, src/vmcore/field.h, src/vmcore/utf8.c,
+       src/vmcore/utf8.h:
+       * configure.ac, contrib/mapfile-vers-product, m4/classpath.m4,
+       src/cacao/Makefile.am, src/lib/Makefile.am,
+       src/lib/gnu/java/lang/reflect,
+       src/lib/gnu/java/lang/reflect/Field.java,
+       src/lib/gnu/java/lang/reflect/Method.java, src/lib/gnu/sun,
+       src/lib/gnu/sun/misc, src/lib/gnu/sun/misc/Unsafe.java,
+       src/native/include/Makefile.am, src/native/jni.c, src/native/jni.h,
+       src/native/native.c, src/native/native.h, src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Object.h,
+       src/native/vm/java_lang_Thread.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Method.c, src/native/vm/nativevm.c,
+       src/native/vm/nativevm.h, src/native/vm/sun,
+       src/native/vm/sun/Makefile.am, src/native/vm/sun/jvm.c,
+       src/native/vm/sun_misc_Unsafe.c, src/threads/native/threads.c,
+       src/threads/threads-common.c, src/vm/properties.c, src/vm/vm.c,
+       src/vm/vm.h, src/vmcore/class.h, src/vmcore/field.c,
+       src/vmcore/field.h, src/vmcore/utf8.c, src/vmcore/utf8.h: Initial
+       support for using OpenJDK libraries as Java core libraries.
+       [5c68a9a5b5d5]
+
+2007-06-22  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/emit.c:
+       * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Fixed for 8 byte
+       stack slots.
+       * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Fixed location of
+       method address.
+       [cb59a39154b8]
+
+2007-06-22  twisti  <twisti>
+
+       * src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.c (opt_ThreadStackSize): Added. (options_xx):
+       Option and values are seperated by '=', not by ':' (let's keep
+       compatible to Sun).
+       * src/vmcore/options.h (opt_ThreadStackSize): Added.
+       [246c9137b7c3]
+
+2007-06-22  ajordan  <ajordan>
+
+       * src/mm/cacao-gc/gc.h, src/vm/jit/arm/arch.h,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/m68k/linux/md-abi.h,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/patcher.c:
+       * src/mm/cacao-gc/gc.h: Added SPARC64 to the architectures that
+       support exactGC
+
+       * src/vm/jit/sparc64/emit.c (emit_replacement_stubs): Added stub-
+       like implementation only non-trappable GC points will work.
+
+       * src/vm/jit/sparc64/codegen.c (codegen_emit): Added replacement
+       points. (codegen_emit_stub_builtin): Implemented.
+
+       * src/vm/jit/sparc64/patcher.c (patcher_wrapper): Temp debug print,
+       to see when extern sfi is created.
+       [d1caef8d8461]
+
+2007-06-21  tbfg  <tbfg>
+
+       * src/native/jni.c, src/vm/jit/asmpart.h, src/vm/jit/m68k/arch.h,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c,
+       src/vm/jit/m68k/linux/md-abi.h, src/vm/vm.c, src/vm/vm.h:
+       * src/vm/jit/m68k/linux/md-abi.h: Prepared 8 byte stackslots.
+       * src/vm/jit/m68k/linux/md-abi.c: Likewise.
+       * src/vm/jit/m68k/emit.c: Likewise.
+       * src/vm/jit/m68k/arch.h: Likewise.
+       * src/vm/jit/m68k/codegen.c: Likewise.
+       * src/vm/jit/m68k/asmpart.S: Likewise.
+       * src/vm/jit/asmpart.h: Likewise.
+       * src/vm/vm.c: Likewise.
+       * src/vm/vm.h: Likewise.
+       * src/native/jni.c: Likewise.
+       [92d6c9308a31]
+
+2007-06-21  michi  <michi>
+
+       * src/native/jni.c, src/vm/jit/arm/arch.h, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c, src/vm/vm.c,
+       src/vm/vm.h:
+       * src/vm/jit/arm/arch.h: Removed HAS_4BYTE_STACKSLOT,
+       ALIGN_LONGS_IN_MEMORY and ALIGN_DOUBLES_IN_MEMORY.
+
+       * src/vm/jit/arm/md-abi.c (md_param_alloc): Changed to 8-byte
+       stackslots and set pd->index correctly.
+
+       * src/vm/jit/arm/codegen.c: Changed to 8-byte stackslots (spilled
+       regs and arguments only).
+
+       * src/vm/jit/arm/asmpart.S (asm_vm_call_method): Reimplemented to
+       fit new argument passing. Changed to 8-byte stackslots.
+
+       * src/vm/vm.c (vm_array_store_flt, vm_array_store_dbl)
+       [SUPPORT_PASS_FLOATARGS_IN_INTREGS]: Fixed.
+
+       * src/vm/vm.c: Added ARM ifdefs.
+       * src/vm/vm.h: Added ARM ifdefs.
+       * src/native/jni.c: Added ARM ifdefs.
+       [039c70e75777]
+
+2007-06-21  twisti  <twisti>
+
+       * configure.ac:
+       * configure.ac (AC_CHECK_FUNCS): Added gethostname.
+       [c4fdd1a8ed28]
+
+       * configure.ac, src/cacaoh/cacaoh.c, src/cacaoh/headers.c,
+       src/native/include/Makefile.am, src/native/vm/gnu/Makefile.am,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/asmpart.h, src/vm/jit/i386/emit.c, src/vm/jit/i386/md-
+       abi.c, src/vm/jit/jit.h, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/md-abi.c,
+       src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-abi.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390
+       /md-abi.c, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/tools/genoffsets.c, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c,
+       src/vm/resolve.c, src/vm/string.c, src/vmcore/descriptor.c,
+       src/vmcore/descriptor.h, src/vmcore/linker.h, src/vmcore/method.c,
+       src/vmcore/method.h, src/vmcore/options.c, src/vmcore/options.h,
+       src/vmcore/statistics.c, src/vmcore/statistics.h, src/vmcore/utf8.c,
+       src/vmcore/utf8.h, tests/regression/native/testarguments.c,
+       tests/regression/native/testarguments.java:
+       * configure.ac (AC_CHECK_HEADERS): Added sys/socket.h.
+       (AC_CHECK_FUNCS): Added accept, close, connect, getsockname, listen,
+       setsockopt, shutdown, socket.
+       [80f35ffa2a7b]
+
+2007-06-21  michi  <michi>
+
+       * src/mm/cacao-gc/heap.h:
+       * src/mm/cacao-gc/heap.h: Fixed includes.
+       [52beee5c1394]
+
+2007-06-20  michi  <michi>
+
+       * configure.ac, src/cacaoh/cacaoh.c, src/cacaoh/dummy.c,
+       src/cacaoh/headers.c, src/mm/memory.c,
+       src/native/include/Makefile.am, src/native/jni.c,
+       src/native/native.c, src/native/native.h, src/native/vm/Makefile.am,
+       src/native/vm/gnu/Makefile.am, src/native/vm/gnu/gnu_java_lang_manag
+       ement_VMClassLoadingMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_reflect_Method.h,
+       src/native/vm/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/java_util_concurrent_atomic_AtomicLong.h,
+       src/native/vm/nativevm.c, src/native/vm/nativevm.h,
+       src/native/vm/sun_misc_Unsafe.c, src/threads/native/threads.c,
+       src/threads/threads-common.c, src/vm/builtin.c, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/global.h,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/arm/md-
+       abi.c, src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c, src/vm/jit
+       /emit-common.c, src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/md-abi.c, src/vm/jit/jit.h,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/disass.c,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c,
+       src/vm/jit/m68k/md.c, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, src/vm/jit/mips
+       /md-abi.c, src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin
+       /md-abi.c, src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-
+       abi.c, src/vm/jit/powerpc/netbsd/md-abi.c,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-abi.c,
+       src/vm/jit/replace.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/tests/dacapo.status, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md-abi.c,
+       src/vm/jit/sparc64/md-abi.h, src/vm/jit/tools/genoffsets.c,
+       src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/verify
+       /typecheck-stackbased.c, src/vm/jit/verify/typecheck-typeinferer.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c,
+       src/vm/resolve.c, src/vm/string.c, src/vm/vm.c, src/vm/vm.h,
+       src/vmcore/Makefile.am, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/descriptor.c, src/vmcore/descriptor.h,
+       src/vmcore/linker.c, src/vmcore/linker.h, src/vmcore/loader.c,
+       src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/primitive.c,
+       src/vmcore/primitive.h, src/vmcore/statistics.c,
+       src/vmcore/statistics.h, src/vmcore/utf8.c, src/vmcore/utf8.h,
+       tests/regression/native/testarguments.c,
+       tests/regression/native/testarguments.java,
+       tests/regression/native/testarguments.output:
+       Merged revisions 8056-8122 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r8058 | twisti | 2007-06-10 21:30:25 +0200 (Sun, 10 Jun
+       2007) | 2 lines
+
+        * src/native/jni.c (_Jv_jni_vmargs_from_objectarray): Indent.
+       ........ r8059 | twisti | 2007-06-10 21:31:28 +0200 (Sun, 10 Jun
+       2007) | 4 lines
+
+        * src/vm/vm.c (vm_vmargs_from_valist): Use TYPE_-defines instead
+       of PRIMITIVETYPE_ ones. (vm_vmargs_from_jvalue): Likewise.
+       ........ r8060 | twisti | 2007-06-10 22:00:40 +0200 (Sun, 10 Jun
+       2007) | 48 lines
+
+        * src/vm/global.h (PRIMITIVETYPE_*): Removed. (ARRAYTYPE_*):
+       Likewise.
+
+        * src/vm/jit/verify/typecheck-typeinferer.c (vmcore/primitive.h):
+       Added.
+         * src/vm/jit/verify/typecheck.c: Likewise.
+         * src/vm/jit/verify/typecheck-stackbased.c: Likewise.
+         * src/vm/jit/verify/typeinfo.c: Likewise.
+         * src/vm/builtin.c: Likewise.
+         * src/native/jni.c: Likewise.
+         * src/native/vm/gnu/java_lang_VMClassLoader.c: Likewise.
+         * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise.
+         * src/vmcore/descriptor.c: Likewise.
+
+        * src/vm/string.c (vmcore/primitive.h): Added.
+       (stringtable_update): Use new primitive functions.
+
+        * src/vm/resolve.c: Likewise. (resolve_class_from_typedesc): Use
+       new primitive functions.
+
+        * src/vm/vm.c (vmcore/primitive.h): Added. (vm_create): Call
+       primitive_init.
+
+        * src/native/vm/java_lang_Class.c (vmcore/primitive.h): Added.
+       (isPrimitive): Use primitive_class_is_primitive.
+       (getDeclaringClass): Likewise. (getDeclaredClasses): Likewise.
+       (getComponentType): Use primitive_class_get_by_type.
+
+        * src/vmcore/class.c (class_is_primitive): Removed.
+       (class_primitive_get): Removed.
+         * src/vmcore/class.c: Likewise.
+
+        * src/vmcore/primitive.c: New file.
+         * src/vmcore/primitive.h: Likewise.
+
+        * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Added
+       primitive.[ch].
+
+        * src/vmcore/linker.c (vmcore/primitive.h): Added.
+       (primitivetype_table): Removed. (linker_init): Removed
+       link_primitivetype_table call. (link_primitivetype_table):
+       Removed.
+
+        * src/vmcore/linker.h (primitivetypeinfo): Removed.
+       (primitivetype_table): Removed.
+
+        * src/vm/jit/verify/typecheck-builtins.inc: Removed Contact,
+       Authors from header. ........ r8061 | twisti | 2007-06-11
+       09:59:36 +0200 (Mon, 11 Jun 2007) | 3 lines
+
+        * src/vmcore/primitive.c (primitive_class_get_by_char): New
+       function.
+         * src/vmcore/primitive.h (primitive_class_get_by_char): Added.
+       ........ r8062 | twisti | 2007-06-11 10:12:14 +0200 (Mon, 11 Jun
+       2007) | 59 lines
+
+        * src/vm/resolve.c (resolve_class_from_name): Call
+       exceptions_classnotfoundexception_to_noclassdeffounderror in
+       exception case.
+
+        * src/vm/exceptions.c (vmcore/method.h): Added.
+       (exceptions_throw_utf_throwable): Added object-initialize code.
+       (exceptions_throw_utf_exception): Likewise.
+       (exceptions_throw_noclassdeffounderror_cause): New function.
+       (classnotfoundexception_to_noclassdeffounderror): Renamed to
+       exceptions_classnotfoundexception_to_noclassdeffounderror.
+       (exceptions_print_stacktrace): Don't use exceptionptr directly.
+
+        * src/vm/exceptions.h
+       (exceptions_throw_noclassdeffounderror_cause): Added.
+       (classnotfoundexception_to_noclassdeffounderror): Renamed to
+       exceptions_classnotfoundexception_to_noclassdeffounderror.
+
+        * src/vm/vm.c (opts): Added XX:. (vm_create): Likewise.
+       (vm_run): Call exceptions_throw_noclassdeffounderror_cause when
+       main-class is not found.
+
+        * src/native/vm/java_lang_Class.c (forName): Don't convert
+       exception.
+
+        * src/native/vm/gnu/java_lang_VMClassLoader.c (getPrimitiveClass):
+       Use primitive_class_get_by_char. (loadClass): Don't convert
+       exception.
+
+        * src/native/native.c (native_new_and_init_string): Use
+       class_findmethod instead of class_resolveclassmethod.
+       (native_new_and_init_throwable): Removed.
+       (native_new_and_init_exception): Likewise.
+
+        * src/native/native.h (native_new_and_init_throwable): Removed.
+       (native_new_and_init_exception): Likewise.
+
+        * src/vmcore/class.c (class_array_of): Smaller code changes.
+
+        * src/vmcore/loader.c (vmcore/primitive.h): Added.
+       (load_class_from_classloader): Don't convert exception.
+       (load_class_bootstrap): Throw ClassNotFoundException instead of
+       NoClassDefFoundError. (load_newly_created_array): Likewise, check
+       if primitive-array type is valid.
+
+        * src/vmcore/utf8.c (utf_initCause): Added.
+       (utf_java_lang_Throwable__java_lang_Throwable): Likewise.
+       (utf8_init): Initialize new variables.
+
+        * src/vmcore/utf8.h (utf_initCause): Added.
+       (utf_java_lang_Throwable__java_lang_Throwable): Likewise.
+
+        * src/cacaoh/dummy.c (exceptions_throw_classnotfoundexception):
+       New function. (classnotfoundexception_to_noclassdeffounderror):
+       Removed.
+
+        * src/vmcore/options.c (options_xx): New function.
+         * src/vmcore/options.h (options_xx): Added. ........ r8063 | twisti
+       | 2007-06-11 16:44:58 +0200 (Mon, 11 Jun 2007) | 6 lines
+
+        * src/vmcore/method.c (method_returntype_get): New function.
+         * src/vmcore/method.h (method_returntype_get): Added.
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c (getReturnType):
+       Use method_returntype_get. ........ r8064 | twisti | 2007-06-11
+       17:11:01 +0200 (Mon, 11 Jun 2007) | 11 lines
+
+        * src/native/vm/java_lang_reflect_Method.c: New file.
+         * src/native/vm/java_lang_reflect_Method.h: Likewise.
+
+        * src/native/vm/Makefile.am [ENABLE_JAVASE]
+       (JAVA_LANG_REFLECT_METHOD_SOURCES): Added
+       (libnativevm_la_SOURCES): Added JAVA_LANG_REFLECT_METHOD_SOURCES.
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c
+       (native/vm/java_lang_reflect_Method.h): Added. (invokeNative): Use
+       _Jv_java_lang_reflect_Method_invoke. ........ r8065 | pm |
+       2007-06-11 17:22:09 +0200 (Mon, 11 Jun 2007) | 3 lines
+
+        * src/vm/jit/s390/emit.c (emit_load_s1_notzero,
+       emit_load_s2_notzero, emit_load_s1_but, emit_load_s2_but): Correctly
+       handle float regissters.
+         * src/vm/jit/s390/tests/dacapo.status: Include dacapo lusearch
+       results. ........ r8066 | twisti | 2007-06-12 11:08:12 +0200 (Tue,
+       12 Jun 2007) | 4 lines
+
+        * src/vm/vm.c (opts): Added OPT_EA, OPT_DA. (usage): Print help
+       for OPT_EA, OPT_DA. (vm_create): Ignore OPT_EA, OPT_DA. ........
+       r8067 | twisti | 2007-06-12 14:32:18 +0200 (Tue, 12 Jun 2007) | 4
+       lines
+
+        * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (constructNative): Added asserts for declaringClass and slot.
+         * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative):
+       Likewise. ........ r8068 | pm | 2007-06-12 17:50:35 +0200 (Tue, 12
+       Jun 2007) | 5 lines
+
+        * src/vm/jits/390/codegen.h (N_BRC_BACK_PATCH, N_LTEBR, N_LTDBR,
+       N_LTXBR, DD_0, ..., DD_3): added, (M_CVTFI, M_CVTDI) changed to
+       round to nearest.
+         * src/vm/jits/390/codegen.c (codegen_emit): In ICMD_F2I and ICMD_D2I
+       correct handling of corner cases, ICMD_LALOAD fix.
+         * src/vm/jit/s390/md.c (md_dump_context): Include information on java
+       method in dump.
+         * src/vm/jits/390/tests/dacapo.status: Noted dacapo eclipse results.
+       ........ r8069 | twisti | 2007-06-13 16:08:24 +0200 (Wed, 13 Jun
+       2007) | 4 lines
+
+        * src/native/jni.c (stdint.h): Added.
+       (_Jv_jni_vmargs_from_objectarray): Use stdint-types, use global
+       class variables. ........ r8070 | twisti | 2007-06-13 16:26:41
+       +0200 (Wed, 13 Jun 2007) | 16 lines
+
+        * src/native/jni.c (_Jv_jni_vmargs_from_objectarray): Removed.
+       (_Jv_jni_invokeNative): Use vm_vmargs_from_objectarray.
+
+        * src/vm/vm.c (stdint.h): Added.
+       (native/include/java_lang_Byte.h)
+       (native/include/java_lang_Character.h)
+       (native/include/java_lang_Short.h)
+       (native/include/java_lang_Integer.h)
+       (native/include/java_lang_Boolean.h)
+       (native/include/java_lang_Long.h)
+       (native/include/java_lang_Float.h)
+       (native/include/java_lang_Double.h): Likewise.
+       (vm_vmargs_from_objectarray): New function.
+
+        * src/vm/vm.h (vm_vmargs_from_objectarray): Added. ........
+       r8071 | twisti | 2007-06-13 19:37:55 +0200 (Wed, 13 Jun 2007) | 3
+       lines
+
+        * src/vm/jit/tools/genoffsets.c (main): Removed some obsolete
+       stuff.
+         * src/vm/jit/m68k/md.c (md_init): Removed offobjvftbl check. ........
+       r8072 | twisti | 2007-06-13 20:31:19 +0200 (Wed, 13 Jun 2007) | 4
+       lines
+
+        * tests/regression/native/testarguments.java,
+       tests/regression/native/testarguments.c,
+       tests/regression/native/testarguments.output: Added address test.
+       ........ r8073 | twisti | 2007-06-13 23:54:27 +0200 (Wed, 13 Jun
+       2007) | 4 lines
+
+        * src/vm/jit/tools/genoffsets.c (vmcore/class.h): Removed.
+       (vmcore/linker.h): Likewise. (vmcore/method.h): Likewise. ........
+       r8074 | twisti | 2007-06-14 00:27:17 +0200 (Thu, 14 Jun 2007) | 43
+       lines
+
+        * src/vm/jit/mips/asmpart.S (asm_vm_call_method): Rewritten for
+       new argument passing.
+
+        * src/vm/jit/mips/md-abi.c (stdarg.h): Added. (mm/memory.h):
+       Likewise. (md_param_alloc): Set pd->index.
+
+        * src/vm/jit/asmpart.h (stdint.h): Added new function prototypes.
+
+        * src/vm/vm.c (md-abi.h): Added. (vm_array_store_int): New
+       function. (vm_array_store_lng): Likewise. (vm_array_store_flt):
+       Likewise. (vm_array_store_dbl): Likewise. (vm_array_store_adr):
+       Likewise. (vm_array_from_valist): Likewise.
+       (vm_array_from_jvalue): Likewise. (vm_array_from_objectarray):
+       Likewise. (vm_call_method_valist): New version added.
+       (vm_call_method_jvalue): Likewise. (vm_call_array): New function.
+       (vm_call_int_array): Likewise. (vm_call_method_int_valist): New
+       version added. (vm_call_method_int_jvalue): Likewise.
+       (vm_call_method_long_valist): Likewise.
+       (vm_call_method_long_jvalue): Likewise. (vm_call_long_array): New
+       function. (vm_call_method_float_vmarg): Added vm_abort.
+       (vm_call_method_double_vmarg): Likwise.
+
+        * src/vm/vm.h (stdarg.h): Added. (vmcore/class.h): Likewise.
+       (vmcore/method.h): Likewise. (vm_array_from_objectarray):
+       Likewise. (vm_call_array): Likewise. (vm_call_int_array):
+       Likewise. (vm_call_long_array): Likewise.
+
+        * src/native/jni.c (_Jv_jni_invokeNative): Added new version.
+
+        * src/vmcore/descriptor.h (stdint.h): Added. (paramdesc): Added
+       index field (this is temporarily). ........ r8075 | twisti |
+       2007-06-14 02:38:53 +0200 (Thu, 14 Jun 2007) | 3 lines
+
+        * src/vm/jit/mips/asmpart.S (asm_vm_call_method)
+       [!WORDS_BIGENDIAN]: Fixed bug (use lw instead of ld), better code
+       in the stack copy loop. ........ r8076 | twisti | 2007-06-14
+       11:35:31 +0200 (Thu, 14 Jun 2007) | 2 lines
+
+        * src/vm/vm.c: Fixed typos. ........ r8077 | twisti | 2007-06-14
+       11:44:12 +0200 (Thu, 14 Jun 2007) | 8 lines
+
+        * src/vm/vm.c (arch.h): Added. (vm/jit/abi-asm.h): Likewise.
+       (vm_array_store_int): Use ARG_CNT define. (vm_array_store_dbl):
+       Likewise. (vm_array_store_flt): Likewise. (vm_array_store_dbl):
+       Likewise. (vm_array_store_adr) [HAS_ADDRESS_REGISTER_FILE]:
+       Changed offset. ........ r8078 | twisti | 2007-06-14 12:20:02
+       +0200 (Thu, 14 Jun 2007) | 2 lines
+
+        * src/vm/vm.c (vm_call_method_long_vmarg): Removed vm_abort.
+       ........ r8079 | twisti | 2007-06-14 13:06:48 +0200 (Thu, 14 Jun
+       2007) | 3 lines
+
+        * src/vm/vm.c (vm_array_from_objectarray): For TYPE_ADR param can
+       be NULL, that's ok (jboss is a testcase for that). ........
+       r8080 | twisti | 2007-06-14 13:12:11 +0200 (Thu, 14 Jun 2007) | 10
+       lines
+
+        * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method): Rewritten for
+       new argument passing.
+
+        * src/vm/jit/x86_64/md-abi.c (md_param_alloc): Set pd->index.
+
+        * src/vm/vm.c: Added __X86_64__ ifdef.
+         * src/vm/vm.h: Likewise.
+         * src/native/jni.c: Likewise.
+         * src/vm/jit/asmpart.h: Likewise. ........ r8081 | tbfg | 2007-06-14
+       14:07:03 +0200 (Thu, 14 Jun 2007) | 4 lines
+
+        src/vm/jit/m68k/disass.c: Changed bfd_mach_mcf_isa_b_float_emac to
+       bfd_mach_mcfv4e as needed for newer binutils. ........ r8082 |
+       tbfg | 2007-06-14 14:10:49 +0200 (Thu, 14 Jun 2007) | 6 lines
+
+        * src/vm/jit/emit-common.c: Added emit_branch statistics.
+         * src/vmcore/statistics.c: Likewise.
+         * src/vmcore/statistics.h: Added count_emit_branch,
+       count_emit_branch_8bit, count_emit_branch_16bit,
+       count_emit_branch_32bit, count_emit_branch_64bit. ........ r8085 |
+       tbfg | 2007-06-14 17:12:54 +0200 (Thu, 14 Jun 2007) | 2 lines
+
+        * src/vm/jit/emit-common.c: Fixed warning related to STATISTICS.
+       ........ r8086 | twisti | 2007-06-14 17:31:54 +0200 (Thu, 14 Jun
+       2007) | 3 lines
+
+        * src/vmcore/loader.c: Removed commented
+       exceptions_throw_noclassdeffounderror calls. ........ r8087 |
+       twisti | 2007-06-14 18:01:12 +0200 (Thu, 14 Jun 2007) | 6 lines
+
+        * src/vm/exceptions.c (exceptions_get_exception)
+       (exceptions_set_exception, exceptions_clear_exception)
+       (exceptions_get_and_clear_exception): Moved these low leve function
+       to the top of the file.
+         * src/vm/exceptions.h: Likewise. ........ r8088 | twisti |
+       2007-06-14 18:05:42 +0200 (Thu, 14 Jun 2007) | 2 lines
+
+        * src/native/vm/java_lang_Class.c (forName): Removed unused
+       variables. ........ r8089 | twisti | 2007-06-14 18:06:31 +0200
+       (Thu, 14 Jun 2007) | 2 lines
+
+        * src/native/vm/java_lang_Class.c: Added Id keyword. ........
+       r8090 | twisti | 2007-06-14 18:07:37 +0200 (Thu, 14 Jun 2007) | 3
+       lines
+
+        * src/vm/exceptions.c: Don't use exceptionptr directly anymore,
+       access it only with functions. ........ r8091 | twisti |
+       2007-06-14 18:10:33 +0200 (Thu, 14 Jun 2007) | 3 lines
+
+        * src/threads/native/threads.c: Don't use exceptionptr directly
+       anymore. ........ r8092 | twisti | 2007-06-14 18:12:35 +0200 (Thu,
+       14 Jun 2007) | 3 lines
+
+        * src/native/native.c (native_findfunction): Use
+       exceptions_throw_unsatisfiedlinkerror. ........ r8093 | twisti |
+       2007-06-14 18:51:44 +0200 (Thu, 14 Jun 2007) | 5 lines
+
+        * src/vm/jit/emit-common.c (emit_bccz) [STATISTICS]: Is called
+       ENABLE_STATISTICS. (emit_label_bccz): Likewise. (emit_label):
+       Likewise. ........ r8094 | ajordan | 2007-06-16 03:15:41 +0200
+       (Sat, 16 Jun 2007) | 15 lines
+
+        * src/vmcore/statistics.h: Added more fine grained spill
+       statistics.
+         * src/vmcore/statistics.c: Likewise.
+
+        * src/vm/jit/jit.h: New defines for spill statistics. Old ones are
+       deprecated, won't increase the counters.
+
+        * src/vm/jit/codegen-common.c (codegen_increase): Defined SPARC64
+       for 2-instr-patcher-stub-call workaround.
+       (codegen_add_patch_ref): Likewise. (codegen_reg_of_var): Removed
+       obsolete spill counting.
+
+        * src/vm/jit/sparc64/emit.c: Changed for new spill statistics.
+         * src/vm/jit/sparc64/linux/md-os.c (md_critical_section_restart):
+       Fixed. ........ r8095 | ajordan | 2007-06-16 21:56:19 +0200 (Sat,
+       16 Jun 2007) | 6 lines
+
+        * src/vm/jit/sparc64/codegen.c (codegen_emit): Improved integer
+       argument passing by swapping variable allocation instead of
+       copying.
+
+        * src/vm/jit/sparc64/md-abi.h: Turned %i0 into saved reg.
+         * src/vm/jit/sparc64/md-abi.c: Likewise. ........ r8096 | pm |
+       2007-06-17 15:45:58 +0200 (Sun, 17 Jun 2007) | 8 lines
+
+        * src/vm/jit/s390/asmpart.S src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/tests/dacapo.status: Optimized loads from data
+       segment: the procedure vector now always points 4092 bytes before
+       the data segment, so a lot of loads have a positive displacement.
+       Removed dead code. ........ r8097 | pm | 2007-06-17 16:50:16 +0200
+       (Sun, 17 Jun 2007) | 3 lines
+
+        * src/vm/jit/s390/codegen.c (codegen_emit): More data segment load
+       optimalisations.
+         * src/vm/jit/s390/md.c (md_get_method_patch_address): Adapt to changes
+       in codegen_emit. ........ r8099 | tbfg | 2007-06-18 20:26:58 +0200
+       (Mon, 18 Jun 2007) | 20 lines
+
+        * src/vm/jit/powerpc64/linux/md-abi.c (md_param_alloc): Set index.
+
+        * src/vm/jit/powerpc64/asmpart.S (asm_vm_call_method): New
+       parameter format, do not call asm_jit_compile any more.
+
+        * src/vm/jit/asmpart.h: Enable new parameter format function
+       prototypes.
+
+        * src/vm/vm.h: Likewise.
+
+        * src/vm/vm.c (vm_array_store_int): Although ppc64 is big endian
+       do not big endianize the new parameter format.
+       (vm_array_store_flt): Likewise. (vm_array_store_adr): Likewise.
+       (vm_vmargs_from_valist): ppc64 like alpha uses doubles everywhere.
+       (vm_vmargs_from_jvalue): When HAS_ADDRESS_REGISTER_FILE is defined
+       address register arguments are between float and memuse.
+
+        * src/native/jni.c: Enable new parameter function calling.
+       ........ r8100 | twisti | 2007-06-18 22:18:14 +0200 (Mon, 18 Jun
+       2007) | 7 lines
+
+        * src/vm/exceptions.c (exceptions_throw_utf_throwable): Call
+       (Ljava/lang/Throwable;)V initializer and resolve the method with
+       class_resolveclassmethod to get possible exceptions.
+       (exceptions_throw_utf_cause): New function.
+       (exceptions_throw_noclassdeffounderror_cause): Use
+       exceptions_throw_utf_cause. ........ r8101 | twisti | 2007-06-19
+       20:07:59 +0200 (Tue, 19 Jun 2007) | 4 lines
+
+        * src/cacaoh/dummy.c [ENABLE_THREADS] (pthread.h): Removed.
+       (threads/threads-common.h): Added. [ENABLE_THREADS]
+       (threads_current_threadobject_key): Added #ifdef. ........ r8102 |
+       twisti | 2007-06-19 20:09:16 +0200 (Tue, 19 Jun 2007) | 2 lines
+
+        * src/cacaoh/dummy.c: Added Id keyword. ........ r8103 | twisti
+       | 2007-06-19 21:43:00 +0200 (Tue, 19 Jun 2007) | 21 lines
+
+        * src/native/vm/nativevm.c (nativevm_init) [ENABLE_JAVASE &&
+       WITH_CLASSPATH_GNU]: Call
+       _Jv_java_util_concurrent_atomic_AtomicLong_init.
+
+        * src/native/vm/Makefile.am [ENABLE_JAVASE]
+       (JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES): Added.
+       (libnativevm_la_SOURCES): Added
+       JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES.
+
+        * src/native/vm/java_util_concurrent_atomic_AtomicLong.c: New
+       file.
+         * src/native/vm/java_util_concurrent_atomic_AtomicLong.h: Likewise.
+
+        * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES):
+       Added java_util_concurrent_atomic_AtomicLong.c.
+
+        * src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c: New
+       file.
+
+        * src/native/include/Makefile.am (JAVASE_HEADER_FILES): Added
+       java_util_concurrent_atomic_AtomicLong.h. ........ r8104 | twisti
+       | 2007-06-19 23:15:00 +0200 (Tue, 19 Jun 2007) | 5 lines
+
+        * src/cacaoh/dummy.c (stdint.h): Added. (vm/types.h): Removed
+       and replaced all old types with stdint ones. (threads/threads-
+       common.h): Removed. [ENABLE_THREADS]
+       (threads_current_threadobject_key): Removed. ........ r8105 |
+       twisti | 2007-06-19 23:47:51 +0200 (Tue, 19 Jun 2007) | 3 lines
+
+        * src/cacaoh/headers.c (stdint.h): Added and use stdint-types.
+       (vm/types.h): Removed. ........ r8106 | twisti | 2007-06-20
+       00:50:17 +0200 (Wed, 20 Jun 2007) | 11 lines
+
+        * src/vm/vm.c (vm_call_float_array): New function.
+       (vm_call_method_float_valist): Likewise.
+       (vm_call_method_float_jvalue): Likewise. (vm_call_double_array):
+       Likewise. (vm_call_method_double_valist): Likewise.
+       (vm_call_method_double_jvalue): Likewise.
+
+        * src/vm/vm.h: Defined new functions.
+         * src/vm/jit/asmpart.h: Likewise.
+         * src/native/jni.c: Use new functions. ........ r8107 | twisti |
+       2007-06-20 13:11:59 +0200 (Wed, 20 Jun 2007) | 3 lines
+
+        * src/vm/vm.c (vm_array_store_int) [SIZEOF_VOID_P == 4]: Only do
+       the integer shift on 32-bit architectures. ........ r8108 |
+       ajordan | 2007-06-20 14:05:26 +0200 (Wed, 20 Jun 2007) | 11 lines
+
+        * src/vm/jit/sparc64/md-abi.c (md_param_alloc): Added pd->index
+       setting.
+
+        * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method): Get
+       parameters from new array.
+
+        * src/vm/jit/asmpart.h: Enable new parameter passing for SPARC64.
+         * src/vm/vm.h: Likewise.
+         * src/vm/vm.c: Likewise. (vm_array_store_flt): For SPARC, shift
+       float arguments on stack to low word too. ........ r8109 | twisti
+       | 2007-06-20 14:22:56 +0200 (Wed, 20 Jun 2007) | 3 lines
+
+        * src/native/vm/nativevm.h [ENABLE_JAVASE && WITH_CLASSPATH_GNU]:
+       Added _Jv_java_util_concurrent_atomic_AtomicLong_init. ........
+       r8110 | twisti | 2007-06-20 14:24:32 +0200 (Wed, 20 Jun 2007) | 3
+       lines
+
+        * src/cacaoh/cacaoh.c (HEAP_MAXSIZE, HEAP_STARTSIZE): Removed.
+       (main): Removed heapmaxsize, heapstartsize. ........ r8111 |
+       twisti | 2007-06-20 15:51:38 +0200 (Wed, 20 Jun 2007) | 10 lines
+
+        * src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanI
+       mpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/sun_misc_Unsafe.c: Use stdint-types because of
+       conflicts with generated header files. ........ r8112 | twisti |
+       2007-06-20 19:54:36 +0200 (Wed, 20 Jun 2007) | 28 lines
+
+        * src/vm/vm.c (XXusage): Removed -verbose:memory. (vm_create):
+       Likewise.
+
+        * src/mm/memory.c (memory_thread): Rewritten to use new variables.
+
+        * src/vmcore/options.c (errno.h): Added. (stdint.h): Likewise
+       (stdio.h): Likewise. (stdlib.h): Likewise. (opt_verbosememory):
+       Removed. (opt_ProfileGCMemoryUsage): Added.
+       (opt_ProfileMemoryUsage): Likewise.
+       (opt_ProfileMemoryUsageGNUPlot): Likewise. (options_XX): Likewise.
+       (options_xx): Implemented.
+
+        * src/vmcore/options.h (stdint.h): Added. (option_t): Likewise.
+       (opt_ProfileGCMemoryUsage): Likewise. (opt_ProfileMemoryUsage):
+       Likewise. (opt_ProfileMemoryUsageGNUPlot): Likewise.
+       (options_xx): Changed signature.
+
+        * src/vmcore/statistics.c (statistics_print_gc_memory_usage):
+       Rewritten to use new variables and GNU Plot output.
+
+        * configure.ac (AC_CHECK_FUNCS): Added atoi, atol, strchr,
+       strncmp. ........ r8113 | twisti | 2007-06-20 20:05:39 +0200 (Wed,
+       20 Jun 2007) | 5 lines
+
+        * src/vmcore/statistics.c (statistics_print_gc_memory_usage): Call
+       fflush.
+
+        * configure.ac (AC_CHECK_FUNCS): Added fflush, fopen, fprintf.
+       ........ r8114 | twisti | 2007-06-20 20:57:41 +0200 (Wed, 20 Jun
+       2007) | 3 lines
+
+        * src/threads/threads-common.c (threads_preinit): Added another
+       linuxthreads check. ........ r8115 | michi | 2007-06-20 21:14:05
+       +0200 (Wed, 20 Jun 2007) | 41 lines
+
+        * src/vm/vm.c (vm_array_store_int, vm_array_store_adr,
+       vm_array_store_lng, vm_array_store_flt, vm_array_store_dbl): Uses
+       pd->index for inmemory arguments.
+
+        * src/vm/jit/allocator/simplereg.c: The regoff value is a real
+       offset (multiplied by the stackslot size) for inmemory variables
+       now.
+
+        * src/vm/jit/arm/md-abi.c (md_param_alloc): Set pd->regoff as
+       described above.
+         * src/vm/jit/arm/emit.c: Adapted to above changes.
+         * src/vm/jit/arm/codegen.c: Adapted to above changes.
+
+        * src/vm/jit/powerpc/linux/md-abi.c,
+         * src/vm/jit/powerpc/netbsd/md-abi.c,
+         * src/vm/jit/powerpc/emit.c,
+         * src/vm/jit/powerpc/darwin/md-abi.c,
+         * src/vm/jit/powerpc/codegen.c,
+         * src/vm/jit/sparc64/emit.c,
+         * src/vm/jit/sparc64/md-abi.h,
+         * src/vm/jit/sparc64/codegen.c,
+         * src/vm/jit/sparc64/md-abi.c,
+         * src/vm/jit/alpha/emit.c,
+         * src/vm/jit/alpha/codegen.c,
+         * src/vm/jit/alpha/md-abi.c,
+         * src/vm/jit/s390/emit.c,
+         * src/vm/jit/s390/codegen.c,
+         * src/vm/jit/s390/md-abi.c,
+         * src/vm/jit/mips/emit.c,
+         * src/vm/jit/mips/codegen.c,
+         * src/vm/jit/mips/md-abi.c,
+         * src/vm/jit/m68k/emit.c,
+         * src/vm/jit/m68k/linux/md-abi.c,
+         * src/vm/jit/m68k/codegen.c,
+         * src/vm/jit/powerpc64/linux/md-abi.c,
+         * src/vm/jit/powerpc64/emit.c,
+         * src/vm/jit/powerpc64/codegen.c,
+         * src/vm/jit/i386/emit.c,
+         * src/vm/jit/i386/codegen.c,
+         * src/vm/jit/i386/md-abi.c,
+         * src/vm/jit/x86_64/emit.c,
+         * src/vm/jit/x86_64/codegen.c,
+         * src/vm/jit/x86_64/md-abi.c: Likewise. ........ r8116 | michi |
+       2007-06-20 22:30:56 +0200 (Wed, 20 Jun 2007) | 5 lines
+
+        * src/vm/jit/arm/codegen.c (codegen_emit,
+       codegen_emit_stub_native): Changed cd->stackframesize from
+       wordcount to bytecount.
+
+        * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Adapted to above
+       change. ........ r8117 | pm | 2007-06-20 23:20:53 +0200 (Wed, 20
+       Jun 2007) | 3 lines
+
+        * src/vm/jit/s390/codegen.h, src/vm/jit/s390/codegen.c
+       (codegen_emit): Support another hercules bug in F2D. ........
+       r8119 | twisti | 2007-06-21 00:05:10 +0200 (Thu, 21 Jun 2007) | 3
+       lines
+
+        * src/vmcore/statistics.c (statistics_print_gc_memory_usage):
+       Different print-format for different pointer-sizes. ........ r8120
+       | twisti | 2007-06-21 00:11:24 +0200 (Thu, 21 Jun 2007) | 13 lines
+
+        * src/vmcore/options.c (opt_verboseexception): Removed.
+       (opt_TraceExceptions): Added. (options_xx): Handle
+       OPT_TraceExceptions.
+
+        * src/vmcore/options.h (opt_verboseexception): Removed.
+       (opt_TraceExceptions): Added.
+
+        * src/vm/exceptions.c (exceptions_handle_exception): Replaced
+       opt_verboseexception with opt_TraceExceptions.
+
+        * src/vm/vm.c (XXusage): Removed opt_verboseexception.
+       (vm_create): Likewise. ........ r8121 | michi | 2007-06-21
+       01:32:34 +0200 (Thu, 21 Jun 2007) | 7 lines
+
+        * src/vmcore/options.c [ENABLE_REPLACEMENT]
+       (opt_TraceReplacement): Added. (options_xx) [ENABLE_REPLACEMENT]:
+       Handle OPT_TraceReplacement.
+
+        * src/vmcore/options.h [ENABLE_REPLACEMENT]
+       (opt_TraceReplacement): Added.
+
+        * src/vm/jit/replace.c: Use opt_TraceReplacement mentioned above.
+       ........
+       [5a4d93ab7f2c]
+
+       * tests/gc/ClassInit.java:
+       * tests/gc/ClassInit.java: Changed trigger for static initializer
+       from method call to field access.
+       [5d0cef9e0809]
+
+       * src/vm/jit/replace.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.c [ENABLE_REPLACEMENT] (opt_TraceReplacement):
+       Added. (options_xx) [ENABLE_REPLACEMENT]: Handle
+       OPT_TraceReplacement.
+
+       * src/vmcore/options.h [ENABLE_REPLACEMENT] (opt_TraceReplacement):
+       Added.
+
+       * src/vm/jit/replace.c: Use opt_TraceReplacement mentioned above.
+       [0574b7bc889f]
+
+2007-06-20  twisti  <twisti>
+
+       * src/vm/exceptions.c, src/vm/vm.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/vmcore/options.c (opt_verboseexception): Removed.
+       (opt_TraceExceptions): Added. (options_xx): Handle
+       OPT_TraceExceptions.
+
+       * src/vmcore/options.h (opt_verboseexception): Removed.
+       (opt_TraceExceptions): Added.
+
+       * src/vm/exceptions.c (exceptions_handle_exception): Replaced
+       opt_verboseexception with opt_TraceExceptions.
+
+       * src/vm/vm.c (XXusage): Removed opt_verboseexception. (vm_create):
+       Likewise.
+       [3f0c7cb2010b]
+
+       * src/vmcore/statistics.c:
+       * src/vmcore/statistics.c (statistics_print_gc_memory_usage):
+       Different print-format for different pointer-sizes.
+       [141899315be7]
+
+2007-06-20  michi  <michi>
+
+       * src/cacaoh/headers.c, src/mm/cacao-gc/gc.c,
+       src/native/include/Makefile.am, src/native/vm/gnu/Makefile.am,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/nativevm.c,
+       src/native/vm/nativevm.h, src/native/vm/sun_misc_Unsafe.c,
+       src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/codegen.c, src/vm/jit/arm
+       /md-abi.c, src/vm/jit/i386/emit.c, src/vm/jit/i386/md-abi.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/darwin/md-abi.c,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md-abi.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/x86_64/emit.c:
+       * src/mm/cacao-gc/gc.c (gc_reference_unregister): Added.
+       [7d6280a0a94a]
+
+2007-06-20  pm  <pm>
+
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h:
+       * src/vm/jit/s390/codegen.h, src/vm/jit/s390/codegen.c
+       (codegen_emit): Support another hercules bug in F2D.
+       [ffd633a37b0f]
+
+2007-06-20  michi  <michi>
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c:
+       * src/vm/jit/arm/codegen.c (codegen_emit, codegen_emit_stub_native):
+       Changed cd->stackframesize from wordcount to bytecount.
+
+       * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Adapted to above
+       change.
+       [8456c270e754]
+
+       * src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/arm/md-
+       abi.c, src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/md-abi.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, src/vm/jit/mips
+       /md-abi.c, src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin
+       /md-abi.c, src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-
+       abi.c, src/vm/jit/powerpc/netbsd/md-abi.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.c, src/vm/vm.c:
+       * src/vm/vm.c (vm_array_store_int, vm_array_store_adr,
+       vm_array_store_lng, vm_array_store_flt, vm_array_store_dbl): Uses
+       pd->index for inmemory arguments.
+
+       * src/vm/jit/allocator/simplereg.c: The regoff value is a real
+       offset (multiplied by the stackslot size) for inmemory variables
+       now.
+
+       * src/vm/jit/arm/md-abi.c (md_param_alloc): Set pd->regoff as
+       described above.
+       * src/vm/jit/arm/emit.c: Adapted to above changes.
+       * src/vm/jit/arm/codegen.c: Adapted to above changes.
+
+       * src/vm/jit/powerpc/linux/md-abi.c,
+       * src/vm/jit/powerpc/netbsd/md-abi.c,
+       * src/vm/jit/powerpc/emit.c,
+       * src/vm/jit/powerpc/darwin/md-abi.c,
+       * src/vm/jit/powerpc/codegen.c,
+       * src/vm/jit/sparc64/emit.c,
+       * src/vm/jit/sparc64/md-abi.h,
+       * src/vm/jit/sparc64/codegen.c,
+       * src/vm/jit/sparc64/md-abi.c,
+       * src/vm/jit/alpha/emit.c,
+       * src/vm/jit/alpha/codegen.c,
+       * src/vm/jit/alpha/md-abi.c,
+       * src/vm/jit/s390/emit.c,
+       * src/vm/jit/s390/codegen.c,
+       * src/vm/jit/s390/md-abi.c,
+       * src/vm/jit/mips/emit.c,
+       * src/vm/jit/mips/codegen.c,
+       * src/vm/jit/mips/md-abi.c,
+       * src/vm/jit/m68k/emit.c,
+       * src/vm/jit/m68k/linux/md-abi.c,
+       * src/vm/jit/m68k/codegen.c,
+       * src/vm/jit/powerpc64/linux/md-abi.c,
+       * src/vm/jit/powerpc64/emit.c,
+       * src/vm/jit/powerpc64/codegen.c,
+       * src/vm/jit/i386/emit.c,
+       * src/vm/jit/i386/codegen.c,
+       * src/vm/jit/i386/md-abi.c,
+       * src/vm/jit/x86_64/emit.c,
+       * src/vm/jit/x86_64/codegen.c,
+       * src/vm/jit/x86_64/md-abi.c: Likewise.
+       [41d0774d6ee9]
+
+2007-06-20  twisti  <twisti>
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_preinit): Added another
+       linuxthreads check.
+       [a183143f5c1a]
+
+       * configure.ac, src/vmcore/statistics.c:
+       * src/vmcore/statistics.c (statistics_print_gc_memory_usage): Call
+       fflush.
+
+       * configure.ac (AC_CHECK_FUNCS): Added fflush, fopen, fprintf.
+       [73c72b5efd77]
+
+       * configure.ac, src/mm/memory.c, src/vm/vm.c, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/statistics.c:
+       * src/vm/vm.c (XXusage): Removed -verbose:memory. (vm_create):
+       Likewise.
+
+       * src/mm/memory.c (memory_thread): Rewritten to use new variables.
+
+       * src/vmcore/options.c (errno.h): Added. (stdint.h): Likewise
+       (stdio.h): Likewise. (stdlib.h): Likewise. (opt_verbosememory):
+       Removed. (opt_ProfileGCMemoryUsage): Added.
+       (opt_ProfileMemoryUsage): Likewise. (opt_ProfileMemoryUsageGNUPlot):
+       Likewise. (options_XX): Likewise. (options_xx): Implemented.
+
+       * src/vmcore/options.h (stdint.h): Added. (option_t): Likewise.
+       (opt_ProfileGCMemoryUsage): Likewise. (opt_ProfileMemoryUsage):
+       Likewise. (opt_ProfileMemoryUsageGNUPlot): Likewise. (options_xx):
+       Changed signature.
+
+       * src/vmcore/statistics.c (statistics_print_gc_memory_usage):
+       Rewritten to use new variables and GNU Plot output.
+
+       * configure.ac (AC_CHECK_FUNCS): Added atoi, atol, strchr, strncmp.
+       [8aa5208d23bd]
+
+       * src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.
+       c, src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImp
+       l.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/sun_misc_Unsafe.c: Use stdint-types because of
+       conflicts with generated header files.
+       [d0c0f1a0f680]
+
+       * src/cacaoh/cacaoh.c:
+       * src/cacaoh/cacaoh.c (HEAP_MAXSIZE, HEAP_STARTSIZE): Removed.
+       (main): Removed heapmaxsize, heapstartsize.
+       [c8bedeb53fee]
+
+       * src/native/vm/nativevm.h:
+       * src/native/vm/nativevm.h [ENABLE_JAVASE && WITH_CLASSPATH_GNU]:
+       Added _Jv_java_util_concurrent_atomic_AtomicLong_init.
+       [7bf2b70fdd20]
+
+2007-06-20  ajordan  <ajordan>
+
+       * src/vm/jit/asmpart.h, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/sparc64/md-abi.c, src/vm/vm.c, src/vm/vm.h:
+       * src/vm/jit/sparc64/md-abi.c (md_param_alloc): Added pd->index
+       setting.
+
+       * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method): Get parameters
+       from new array.
+
+       * src/vm/jit/asmpart.h: Enable new parameter passing for SPARC64.
+       * src/vm/vm.h: Likewise.
+       * src/vm/vm.c: Likewise. (vm_array_store_flt): For SPARC, shift float
+       arguments on stack to low word too.
+       [cad4c8459a15]
+
+2007-06-20  twisti  <twisti>
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_array_store_int) [SIZEOF_VOID_P == 4]: Only do the
+       integer shift on 32-bit architectures.
+       [ec7d71eb14ce]
+
+2007-06-19  twisti  <twisti>
+
+       * src/native/jni.c, src/vm/jit/asmpart.h, src/vm/vm.c, src/vm/vm.h:
+       * src/vm/vm.c (vm_call_float_array): New function.
+       (vm_call_method_float_valist): Likewise.
+       (vm_call_method_float_jvalue): Likewise. (vm_call_double_array):
+       Likewise. (vm_call_method_double_valist): Likewise.
+       (vm_call_method_double_jvalue): Likewise.
+
+       * src/vm/vm.h: Defined new functions.
+       * src/vm/jit/asmpart.h: Likewise.
+       * src/native/jni.c: Use new functions.
+       [cd1486e9e61f]
+
+       * src/cacaoh/headers.c:
+       * src/cacaoh/headers.c (stdint.h): Added and use stdint-types.
+       (vm/types.h): Removed.
+       [0961a76da1a7]
+
+       * src/cacaoh/dummy.c:
+       * src/cacaoh/dummy.c (stdint.h): Added. (vm/types.h): Removed and
+       replaced all old types with stdint ones. (threads/threads-common.h):
+       Removed. [ENABLE_THREADS] (threads_current_threadobject_key):
+       Removed.
+       [30a74a4f0cf4]
+
+       * src/native/include/Makefile.am, src/native/vm/Makefile.am,
+       src/native/vm/gnu/Makefile.am,
+       src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/java_util_concurrent_atomic_AtomicLong.c,
+       src/native/vm/java_util_concurrent_atomic_AtomicLong.h,
+       src/native/vm/nativevm.c:
+       * src/native/vm/nativevm.c (nativevm_init) [ENABLE_JAVASE &&
+       WITH_CLASSPATH_GNU]: Call
+       _Jv_java_util_concurrent_atomic_AtomicLong_init.
+
+       * src/native/vm/Makefile.am [ENABLE_JAVASE]
+       (JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES): Added.
+       (libnativevm_la_SOURCES): Added
+       JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES.
+
+       * src/native/vm/java_util_concurrent_atomic_AtomicLong.c: New file.
+       * src/native/vm/java_util_concurrent_atomic_AtomicLong.h: Likewise.
+
+       * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES): Added
+       java_util_concurrent_atomic_AtomicLong.c.
+
+       * src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c: New
+       file.
+
+       * src/native/include/Makefile.am (JAVASE_HEADER_FILES): Added
+       java_util_concurrent_atomic_AtomicLong.h.
+       [8c4969ee5afa]
+
+       * src/cacaoh/dummy.c:
+       * src/cacaoh/dummy.c: Added Id keyword.
+       [958a5b301f5f]
+
+       * src/cacaoh/dummy.c:
+       * src/cacaoh/dummy.c [ENABLE_THREADS] (pthread.h): Removed. (threads
+       /threads-common.h): Added. [ENABLE_THREADS]
+       (threads_current_threadobject_key): Added #ifdef.
+       [1fc81716c8fb]
+
+2007-06-18  twisti  <twisti>
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_throw_utf_throwable): Call
+       (Ljava/lang/Throwable;)V initializer and resolve the method with
+       class_resolveclassmethod to get possible exceptions.
+       (exceptions_throw_utf_cause): New function.
+       (exceptions_throw_noclassdeffounderror_cause): Use
+       exceptions_throw_utf_cause.
+       [57608e101f88]
+
+2007-06-18  tbfg  <tbfg>
+
+       * src/native/jni.c, src/vm/jit/asmpart.h,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/linux/md-abi.c,
+       src/vm/vm.c, src/vm/vm.h:
+       * src/vm/jit/powerpc64/linux/md-abi.c (md_param_alloc): Set index.
+
+       * src/vm/jit/powerpc64/asmpart.S (asm_vm_call_method): New parameter
+       format, do not call asm_jit_compile any more.
+
+       * src/vm/jit/asmpart.h: Enable new parameter format function
+       prototypes.
+
+       * src/vm/vm.h: Likewise.
+
+       * src/vm/vm.c (vm_array_store_int): Although ppc64 is big endian do
+       not big endianize the new parameter format. (vm_array_store_flt):
+       Likewise. (vm_array_store_adr): Likewise. (vm_vmargs_from_valist):
+       ppc64 like alpha uses doubles everywhere. (vm_vmargs_from_jvalue):
+       When HAS_ADDRESS_REGISTER_FILE is defined address register arguments
+       are between float and memuse.
+
+       * src/native/jni.c: Enable new parameter function calling.
+       [4f8863624904]
+
+2007-06-17  pm  <pm>
+
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/md.c:
+       * src/vm/jit/s390/codegen.c (codegen_emit): More data segment load
+       optimalisations.
+       * src/vm/jit/s390/md.c (md_get_method_patch_address): Adapt to changes
+       in codegen_emit.
+       [49542d2724ed]
+
+       * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/tests/dacapo.status:
+       * src/vm/jit/s390/asmpart.S src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/tests/dacapo.status: Optimized loads from data
+       segment: the procedure vector now always points 4092 bytes before
+       the data segment, so a lot of loads have a positive displacement.
+       Removed dead code.
+       [4fb65c7793af]
+
+2007-06-16  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/md-abi.c,
+       src/vm/jit/sparc64/md-abi.h:
+       * src/vm/jit/sparc64/codegen.c (codegen_emit): Improved integer
+       argument passing by swapping variable allocation instead of copying.
+
+       * src/vm/jit/sparc64/md-abi.h: Turned %i0 into saved reg.
+       * src/vm/jit/sparc64/md-abi.c: Likewise.
+       [c57b32bcb804]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/jit.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c,
+       src/vmcore/statistics.c, src/vmcore/statistics.h:
+       * src/vmcore/statistics.h: Added more fine grained spill statistics.
+       * src/vmcore/statistics.c: Likewise.
+
+       * src/vm/jit/jit.h: New defines for spill statistics. Old ones are
+       deprecated, won't increase the counters.
+
+       * src/vm/jit/codegen-common.c (codegen_increase): Defined SPARC64
+       for 2-instr-patcher-stub-call workaround. (codegen_add_patch_ref):
+       Likewise. (codegen_reg_of_var): Removed obsolete spill counting.
+
+       * src/vm/jit/sparc64/emit.c: Changed for new spill statistics.
+       * src/vm/jit/sparc64/linux/md-os.c (md_critical_section_restart):
+       Fixed.
+       [c3a6554d62ff]
+
+2007-06-14  twisti  <twisti>
+
+       * src/vm/jit/emit-common.c:
+       * src/vm/jit/emit-common.c (emit_bccz) [STATISTICS]: Is called
+       ENABLE_STATISTICS. (emit_label_bccz): Likewise. (emit_label):
+       Likewise.
+       [196f9b2253bc]
+
+       * src/native/native.c:
+       * src/native/native.c (native_findfunction): Use
+       exceptions_throw_unsatisfiedlinkerror.
+       [f45e4f47064e]
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c: Don't use exceptionptr directly
+       anymore.
+       [95acc7abb942]
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c: Don't use exceptionptr directly anymore,
+       access it only with functions.
+       [ad9435047576]
+
+       * src/native/vm/java_lang_Class.c:
+       * src/native/vm/java_lang_Class.c: Added Id keyword.
+       [4f5335e1c9b5]
+
+       * src/native/vm/java_lang_Class.c:
+       * src/native/vm/java_lang_Class.c (forName): Removed unused
+       variables.
+       [e4fb080b640a]
+
+       * src/vm/exceptions.c, src/vm/exceptions.h:
+       * src/vm/exceptions.c (exceptions_get_exception)
+       (exceptions_set_exception, exceptions_clear_exception)
+       (exceptions_get_and_clear_exception): Moved these low leve function
+       to the top of the file.
+       * src/vm/exceptions.h: Likewise.
+       [9687cfa0b8da]
+
+       * src/vmcore/loader.c:
+       * src/vmcore/loader.c: Removed commented
+       exceptions_throw_noclassdeffounderror calls.
+       [33ad7340e017]
+
+2007-06-14  tbfg  <tbfg>
+
+       * src/vm/jit/emit-common.c:
+       * src/vm/jit/emit-common.c: Fixed warning related to STATISTICS.
+       [5851e39c5e3b]
+
+2007-06-14  michi  <michi>
+
+       * src/mm/cacao-gc/rootset.c, src/mm/cacao-gc/rootset.h:
+       * src/mm/cacao-gc/rootset.h (rootset_t): Removed ss and es from
+       rootset.
+       * src/mm/cacao-gc/rootset.c: Adapted to above changes.
+       [44759f6a2609]
+
+       * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/copy.c, src/mm/cacao-
+       gc/heap.c, src/mm/cacao-gc/mark.c, src/mm/cacao-gc/rootset.c, src/mm
+       /cacao-gc/rootset.h,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/jit/asmpart.h,
+       src/vm/jit/m68k/disass.c, src/vm/jit/mips/asmpart.S, src/vm/jit/mips
+       /md-abi.c, src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/tests/dacapo.status,
+       src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/md-abi.c,
+       src/vm/resolve.c, src/vm/string.c, src/vmcore/descriptor.c,
+       src/vmcore/descriptor.h, src/vmcore/method.c, src/vmcore/method.h,
+       src/vmcore/options.c, src/vmcore/options.h, src/vmcore/statistics.c,
+       src/vmcore/statistics.h:
+       * src/mm/cacao-gc/rootset.h (rootset_entry_t) Added. Rootsets can be
+       resized.
+       * src/mm/cacao-gc/rootset.c (rootset_resize) Added.
+
+       * src/mm/cacao-gc/copy.c: Adapted to above changes.
+       * src/mm/cacao-gc/heap.c: Likewise.
+       * src/mm/cacao-gc/compact.c: Likewise.
+       * src/mm/cacao-gc/mark.c: Likewise.
+       [3669240563a0]
+
+2007-06-14  tbfg  <tbfg>
+
+       * src/vm/jit/emit-common.c, src/vmcore/statistics.c,
+       src/vmcore/statistics.h:
+       * src/vm/jit/emit-common.c: Added emit_branch statistics.
+       * src/vmcore/statistics.c: Likewise.
+       * src/vmcore/statistics.h: Added count_emit_branch,
+       count_emit_branch_8bit, count_emit_branch_16bit,
+       count_emit_branch_32bit, count_emit_branch_64bit.
+       [e83bd9ae9d95]
+
+       * src/vm/jit/m68k/disass.c:
+       src/vm/jit/m68k/disass.c: Changed bfd_mach_mcf_isa_b_float_emac to
+       bfd_mach_mcfv4e as needed for newer binutils.
+       [f5e047be233b]
+
+2007-06-14  twisti  <twisti>
+
+       * src/native/jni.c, src/vm/jit/asmpart.h, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/md-abi.c, src/vm/vm.c, src/vm/vm.h:
+       * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method): Rewritten for
+       new argument passing.
+
+       * src/vm/jit/x86_64/md-abi.c (md_param_alloc): Set pd->index.
+
+       * src/vm/vm.c: Added __X86_64__ ifdef.
+       * src/vm/vm.h: Likewise.
+       * src/native/jni.c: Likewise.
+       * src/vm/jit/asmpart.h: Likewise.
+       [72c74af0daa4]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_array_from_objectarray): For TYPE_ADR param can be
+       NULL, that's ok (jboss is a testcase for that).
+       [326564bdb23d]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_call_method_long_vmarg): Removed vm_abort.
+       [744695dcd490]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (arch.h): Added. (vm/jit/abi-asm.h): Likewise.
+       (vm_array_store_int): Use ARG_CNT define. (vm_array_store_dbl):
+       Likewise. (vm_array_store_flt): Likewise. (vm_array_store_dbl):
+       Likewise. (vm_array_store_adr) [HAS_ADDRESS_REGISTER_FILE]: Changed
+       offset.
+       [5d8d0edf973d]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c: Fixed typos.
+       [b5c9d3729e96]
+
+       * src/vm/jit/mips/asmpart.S:
+       * src/vm/jit/mips/asmpart.S (asm_vm_call_method) [!WORDS_BIGENDIAN]:
+       Fixed bug (use lw instead of ld), better code in the stack copy
+       loop.
+       [c47fed9cc15c]
+
+2007-06-13  twisti  <twisti>
+
+       * src/native/jni.c, src/vm/jit/asmpart.h, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/md-abi.c, src/vm/vm.c, src/vm/vm.h,
+       src/vmcore/descriptor.h:
+       * src/vm/jit/mips/asmpart.S (asm_vm_call_method): Rewritten for new
+       argument passing.
+
+       * src/vm/jit/mips/md-abi.c (stdarg.h): Added. (mm/memory.h):
+       Likewise. (md_param_alloc): Set pd->index.
+
+       * src/vm/jit/asmpart.h (stdint.h): Added new function prototypes.
+
+       * src/vm/vm.c (md-abi.h): Added. (vm_array_store_int): New function.
+       (vm_array_store_lng): Likewise. (vm_array_store_flt): Likewise.
+       (vm_array_store_dbl): Likewise. (vm_array_store_adr): Likewise.
+       (vm_array_from_valist): Likewise. (vm_array_from_jvalue): Likewise.
+       (vm_array_from_objectarray): Likewise. (vm_call_method_valist): New
+       version added. (vm_call_method_jvalue): Likewise. (vm_call_array):
+       New function. (vm_call_int_array): Likewise.
+       (vm_call_method_int_valist): New version added.
+       (vm_call_method_int_jvalue): Likewise. (vm_call_method_long_valist):
+       Likewise. (vm_call_method_long_jvalue): Likewise.
+       (vm_call_long_array): New function. (vm_call_method_float_vmarg):
+       Added vm_abort. (vm_call_method_double_vmarg): Likwise.
+
+       * src/vm/vm.h (stdarg.h): Added. (vmcore/class.h): Likewise.
+       (vmcore/method.h): Likewise. (vm_array_from_objectarray): Likewise.
+       (vm_call_array): Likewise. (vm_call_int_array): Likewise.
+       (vm_call_long_array): Likewise.
+
+       * src/native/jni.c (_Jv_jni_invokeNative): Added new version.
+
+       * src/vmcore/descriptor.h (stdint.h): Added. (paramdesc): Added
+       index field (this is temporarily).
+       [e69592257712]
+
+       * src/vm/jit/tools/genoffsets.c:
+       * src/vm/jit/tools/genoffsets.c (vmcore/class.h): Removed.
+       (vmcore/linker.h): Likewise. (vmcore/method.h): Likewise.
+       [044505816e1d]
+
+       * tests/regression/native/testarguments.c,
+       tests/regression/native/testarguments.java,
+       tests/regression/native/testarguments.output:
+       * tests/regression/native/testarguments.java,
+       tests/regression/native/testarguments.c,
+       tests/regression/native/testarguments.output: Added address test.
+       [328942132afd]
+
+       * src/vm/jit/m68k/md.c, src/vm/jit/tools/genoffsets.c:
+       * src/vm/jit/tools/genoffsets.c (main): Removed some obsolete stuff.
+       * src/vm/jit/m68k/md.c (md_init): Removed offobjvftbl check.
+       [3a5d14dca2b6]
+
+       * src/native/jni.c, src/vm/vm.c, src/vm/vm.h:
+       * src/native/jni.c (_Jv_jni_vmargs_from_objectarray): Removed.
+       (_Jv_jni_invokeNative): Use vm_vmargs_from_objectarray.
+
+       * src/vm/vm.c (stdint.h): Added. (native/include/java_lang_Byte.h)
+       (native/include/java_lang_Character.h)
+       (native/include/java_lang_Short.h)
+       (native/include/java_lang_Integer.h)
+       (native/include/java_lang_Boolean.h)
+       (native/include/java_lang_Long.h) (native/include/java_lang_Float.h)
+       (native/include/java_lang_Double.h): Likewise.
+       (vm_vmargs_from_objectarray): New function.
+
+       * src/vm/vm.h (vm_vmargs_from_objectarray): Added.
+       [80db4c9bf082]
+
+       * src/native/jni.c:
+       * src/native/jni.c (stdint.h): Added.
+       (_Jv_jni_vmargs_from_objectarray): Use stdint-types, use global
+       class variables.
+       [27afbf410bf3]
+
+2007-06-12  pm  <pm>
+
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/tests/dacapo.status:
+       * src/vm/jits/390/codegen.h (N_BRC_BACK_PATCH, N_LTEBR, N_LTDBR,
+       N_LTXBR, DD_0, ..., DD_3): added, (M_CVTFI, M_CVTDI) changed to
+       round to nearest.
+       * src/vm/jits/390/codegen.c (codegen_emit): In ICMD_F2I and ICMD_D2I
+       correct handling of corner cases, ICMD_LALOAD fix.
+       * src/vm/jit/s390/md.c (md_dump_context): Include information on java
+       method in dump.
+       * src/vm/jits/390/tests/dacapo.status: Noted dacapo eclipse results.
+       [9e9ea1b2157d]
+
+2007-06-12  twisti  <twisti>
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c:
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (constructNative): Added asserts for declaringClass and slot.
+       * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative):
+       Likewise.
+       [0ac5a66c2fe9]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (opts): Added OPT_EA, OPT_DA. (usage): Print help for
+       OPT_EA, OPT_DA. (vm_create): Ignore OPT_EA, OPT_DA.
+       [f9e8cfb36fa9]
+
+2007-06-11  pm  <pm>
+
+       * src/vm/jit/s390/emit.c, src/vm/jit/s390/tests/dacapo.status:
+       * src/vm/jit/s390/emit.c (emit_load_s1_notzero,
+       emit_load_s2_notzero, emit_load_s1_but, emit_load_s2_but): Correctly
+       handle float regissters.
+       * src/vm/jit/s390/tests/dacapo.status: Include dacapo lusearch
+       results.
+       [1db7e718b606]
+
+2007-06-11  twisti  <twisti>
+
+       * src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_reflect_Method.h:
+       * src/native/vm/java_lang_reflect_Method.c: New file.
+       * src/native/vm/java_lang_reflect_Method.h: Likewise.
+
+       * src/native/vm/Makefile.am [ENABLE_JAVASE]
+       (JAVA_LANG_REFLECT_METHOD_SOURCES): Added (libnativevm_la_SOURCES):
+       Added JAVA_LANG_REFLECT_METHOD_SOURCES.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c
+       (native/vm/java_lang_reflect_Method.h): Added. (invokeNative): Use
+       _Jv_java_lang_reflect_Method_invoke.
+       [789e9c2528f9]
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c, src/vmcore/method.c,
+       src/vmcore/method.h:
+       * src/vmcore/method.c (method_returntype_get): New function.
+       * src/vmcore/method.h (method_returntype_get): Added.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c (getReturnType): Use
+       method_returntype_get.
+       [58a2095b54fd]
+
+       * src/cacaoh/dummy.c, src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/java_lang_Class.c, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/resolve.c, src/vm/vm.c,
+       src/vmcore/class.c, src/vmcore/loader.c, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/vm/resolve.c (resolve_class_from_name): Call
+       exceptions_classnotfoundexception_to_noclassdeffounderror in
+       exception case.
+
+       * src/vm/exceptions.c (vmcore/method.h): Added.
+       (exceptions_throw_utf_throwable): Added object-initialize code.
+       (exceptions_throw_utf_exception): Likewise.
+       (exceptions_throw_noclassdeffounderror_cause): New function.
+       (classnotfoundexception_to_noclassdeffounderror): Renamed to
+       exceptions_classnotfoundexception_to_noclassdeffounderror.
+       (exceptions_print_stacktrace): Don't use exceptionptr directly.
+
+       * src/vm/exceptions.h (exceptions_throw_noclassdeffounderror_cause):
+       Added. (classnotfoundexception_to_noclassdeffounderror): Renamed to
+       exceptions_classnotfoundexception_to_noclassdeffounderror.
+
+       * src/vm/vm.c (opts): Added XX:. (vm_create): Likewise. (vm_run):
+       Call exceptions_throw_noclassdeffounderror_cause when main-class is
+       not found.
+
+       * src/native/vm/java_lang_Class.c (forName): Don't convert
+       exception.
+
+       * src/native/vm/gnu/java_lang_VMClassLoader.c (getPrimitiveClass):
+       Use primitive_class_get_by_char. (loadClass): Don't convert
+       exception.
+
+       * src/native/native.c (native_new_and_init_string): Use
+       class_findmethod instead of class_resolveclassmethod.
+       (native_new_and_init_throwable): Removed.
+       (native_new_and_init_exception): Likewise.
+
+       * src/native/native.h (native_new_and_init_throwable): Removed.
+       (native_new_and_init_exception): Likewise.
+
+       * src/vmcore/class.c (class_array_of): Smaller code changes.
+
+       * src/vmcore/loader.c (vmcore/primitive.h): Added.
+       (load_class_from_classloader): Don't convert exception.
+       (load_class_bootstrap): Throw ClassNotFoundException instead of
+       NoClassDefFoundError. (load_newly_created_array): Likewise, check if
+       primitive-array type is valid.
+
+       * src/vmcore/utf8.c (utf_initCause): Added.
+       (utf_java_lang_Throwable__java_lang_Throwable): Likewise.
+       (utf8_init): Initialize new variables.
+
+       * src/vmcore/utf8.h (utf_initCause): Added.
+       (utf_java_lang_Throwable__java_lang_Throwable): Likewise.
+
+       * src/cacaoh/dummy.c (exceptions_throw_classnotfoundexception): New
+       function. (classnotfoundexception_to_noclassdeffounderror): Removed.
+
+       * src/vmcore/options.c (options_xx): New function.
+       * src/vmcore/options.h (options_xx): Added.
+       [116a6286baf0]
+
+       * src/vmcore/primitive.c, src/vmcore/primitive.h:
+       * src/vmcore/primitive.c (primitive_class_get_by_char): New
+       function.
+       * src/vmcore/primitive.h (primitive_class_get_by_char): Added.
+       [1c2e447571f7]
+
+2007-06-10  twisti  <twisti>
+
+       * src/native/jni.c, src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/java_lang_Class.c, src/vm/builtin.c, src/vm/global.h,
+       src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/verify
+       /typecheck-stackbased.c, src/vm/jit/verify/typecheck-typeinferer.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/resolve.c, src/vm/string.c, src/vm/vm.c,
+       src/vmcore/Makefile.am, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/descriptor.c, src/vmcore/linker.c, src/vmcore/linker.h,
+       src/vmcore/primitive.c, src/vmcore/primitive.h:
+       * src/vm/global.h (PRIMITIVETYPE_*): Removed. (ARRAYTYPE_*):
+       Likewise.
+
+       * src/vm/jit/verify/typecheck-typeinferer.c (vmcore/primitive.h):
+       Added.
+       * src/vm/jit/verify/typecheck.c: Likewise.
+       * src/vm/jit/verify/typecheck-stackbased.c: Likewise.
+       * src/vm/jit/verify/typeinfo.c: Likewise.
+       * src/vm/builtin.c: Likewise.
+       * src/native/jni.c: Likewise.
+       * src/native/vm/gnu/java_lang_VMClassLoader.c: Likewise.
+       * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise.
+       * src/vmcore/descriptor.c: Likewise.
+
+       * src/vm/string.c (vmcore/primitive.h): Added. (stringtable_update):
+       Use new primitive functions.
+
+       * src/vm/resolve.c: Likewise. (resolve_class_from_typedesc): Use new
+       primitive functions.
+
+       * src/vm/vm.c (vmcore/primitive.h): Added. (vm_create): Call
+       primitive_init.
+
+       * src/native/vm/java_lang_Class.c (vmcore/primitive.h): Added.
+       (isPrimitive): Use primitive_class_is_primitive.
+       (getDeclaringClass): Likewise. (getDeclaredClasses): Likewise.
+       (getComponentType): Use primitive_class_get_by_type.
+
+       * src/vmcore/class.c (class_is_primitive): Removed.
+       (class_primitive_get): Removed.
+       * src/vmcore/class.c: Likewise.
+
+       * src/vmcore/primitive.c: New file.
+       * src/vmcore/primitive.h: Likewise.
+
+       * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Added
+       primitive.[ch].
+
+       * src/vmcore/linker.c (vmcore/primitive.h): Added.
+       (primitivetype_table): Removed. (linker_init): Removed
+       link_primitivetype_table call. (link_primitivetype_table): Removed.
+
+       * src/vmcore/linker.h (primitivetypeinfo): Removed.
+       (primitivetype_table): Removed.
+
+       * src/vm/jit/verify/typecheck-builtins.inc: Removed Contact, Authors
+       from header.
+       [b966330e73b9]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_vmargs_from_valist): Use TYPE_-defines instead of
+       PRIMITIVETYPE_ ones. (vm_vmargs_from_jvalue): Likewise.
+       [6b6e8f657076]
+
+       * configure.ac, src/native/jni.c, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/jit/s390/emit.c, src/vmcore/linker.h,
+       src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/native/jni.c (_Jv_jni_vmargs_from_objectarray): Indent.
+       [9a477c778729]
+
+2007-06-10  michi  <michi>
+
+       * tests/gc/ClassInit.java:
+       * tests/gc/ClassInit: Testcase for static class initializers works
+       correct now.
+       [81ab1163d960]
+
+       * configure.ac, m4/classpath.m4, src/native/jni.c,
+       src/native/native.c, src/native/native.h,
+       src/native/vm/java_lang_ClassLoader.c, src/vm/builtin.c,
+       src/vm/builtin.h, src/vm/exceptions.c, src/vm/exceptions.h,
+       src/vm/jit/s390/emit.c, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/linker.c, src/vmcore/linker.h, src/vmcore/utf8.c,
+       src/vmcore/utf8.h:
+       Merged revisions 8034-8055 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r8041 | twisti | 2007-06-07 18:21:11 +0200 (Thu, 07 Jun
+       2007) | 4 lines
+
+        * configure.ac (AC_CHECK_HEADERS): Check for sys/select.h,
+       sys/stat.h, sys/types.h. (AC_CHECK_FUNCS): Check for fstat,
+       ioctl, select. ........ r8042 | twisti | 2007-06-07 19:43:29 +0200
+       (Thu, 07 Jun 2007) | 9 lines
+
+        * src/vmcore/class.c (class_primitive_get): New function.
+         * src/vmcore/class.h (class_primitive_get): Added.
+
+        * src/vmcore/linker.c (primitivetype_table): Changed layout.
+       (link_primitivetype_table): Store UTF-8 name in table.
+
+        * src/vmcore/linker.h (primitivetypeinfo): Changed layout, added
+       cname, changed name to UTF-8. ........ r8043 | twisti | 2007-06-07
+       21:22:31 +0200 (Thu, 07 Jun 2007) | 2 lines
+
+        * configure.ac (AC_CHECK_FUNCS): Added open, strerror. ........
+       r8044 | twisti | 2007-06-07 21:24:35 +0200 (Thu, 07 Jun 2007) | 5
+       lines
+
+        * src/vm/builtin.c (builtin_nanotime): New function.
+       (builtin_currenttimemillis): Use builtin_nanotime.
+
+        * src/vm/builtin.h (builtin_nanotime): Added. ........ r8045 |
+       twisti | 2007-06-07 23:52:21 +0200 (Thu, 07 Jun 2007) | 2 lines
+
+        * src/native/jni.c (_Jv_JNI_FatalError): Changed error message.
+       ........ r8046 | pm | 2007-06-08 00:02:16 +0200 (Fri, 08 Jun 2007)
+       | 4 lines
+
+        * src/vm/jit/s390/emit.c (emit_verbosecall_enter): Fix passing of
+       float argument 2 to builtin_verbosecall_enter.
+         * src/vm/builtin.c (builtin_print_argument): Fix malfunctioning
+       conversion from s8 to float on s390. ........ r8047 | twisti |
+       2007-06-08 00:20:37 +0200 (Fri, 08 Jun 2007) | 13 lines
+
+        * src/vmcore/utf8.c (utf_java_security_PrivilegedActionException):
+       Added. (utf8_init): Initialize
+       utf_java_security_PrivilegedActionException.
+
+        * src/vmcore/utf8.h (utf_java_security_PrivilegedActionException):
+       Added.
+
+        * src/vm/exceptions.c
+       (exceptions_throw_privilegedactionexception): New function.
+
+        * src/vm/exceptions.h
+       (exceptions_throw_privilegedactionexception): Added. ........
+       r8048 | twisti | 2007-06-08 00:41:54 +0200 (Fri, 08 Jun 2007) | 11
+       lines
+
+        * src/vmcore/utf8.c (utf_java_lang_Exception__V): Added.
+       (utf8_init): Initialize utf_java_lang_Exception__V.
+         * src/vmcore/utf8.h (utf_java_lang_Exception__V): Added.
+
+        * src/vm/exceptions.c (exceptions_throw_utf_exception): New
+       function. (exceptions_throw_privilegedactionexception): Use
+       exceptions_throw_utf_exception.
+
+        * src/native/native.c (native_new_and_init_exception): New
+       function.
+         * src/native/native.h (native_new_and_init_exception): Added. ........
+       r8049 | twisti | 2007-06-08 01:30:45 +0200 (Fri, 08 Jun 2007) | 6
+       lines
+
+        * src/vmcore/class.c (class_define): New function.
+         * src/vmcore/class.h (class_define): Added.
+
+        * src/native/vm/java_lang_ClassLoader.c (defineClass): Use
+       class_define. ........ r8050 | twisti | 2007-06-08 22:04:34 +0200
+       (Fri, 08 Jun 2007) | 2 lines
+
+        * configure.ac (AC_CHECK_FUNCS): Added lseek. ........ r8051 |
+       twisti | 2007-06-08 22:42:54 +0200 (Fri, 08 Jun 2007) | 3 lines
+
+        * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_INCLUDEDIR): Check for
+       jni_md.h too. ........
+       [6563526e7ae9]
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/heap.c, src/mm/cacao-
+       gc/region.c:
+       * src/mm/cacao-gc/heap.c (heap_update_references,
+       heap_increase_size): Added.
+       * src/mm/cacao-gc/region.c (region_resize): Added.
+       * src/mm/cacao-gc/gc.c (gc_collect): Heap gets resized if it's too
+       small.
+
+       * src/mm/cacao-gc/gc.c (gc_reference_register): Can be called
+       without gc_init.
+       [761f70b4c073]
+
+       * src/mm/cacao-gc/rootset.c:
+       * src/mm/cacao-gc/rootset.c (rootset_from_thread): Fixed typo.
+       [06e3c947f614]
+
+       * src/native/vm/java_lang_Class.c:
+       * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getClassLoader): Handle indirection cell of
+       bootstrap classloader properly.
+       [ec40a38a4415]
+
+       * configure.ac, m4/classpath.m4, src/threads/native/threads.c,
+       src/threads/threads-common.c, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/jit/s390/emit.c, src/vmcore/linker.h,
+       src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/threads/threads-common.c [ENABLE_GC_CACAO]: References to
+       java.lang.Thread now get registered uppon threadobject creation.
+
+       * src/threads/native/threads.c (threads_init) [ENABLE_GC_CACAO]:
+       Register mainthreadobject with the GC as well.
+       [f27ccfc9cef4]
+
+2007-06-08  twisti  <twisti>
+
+       * m4/classpath.m4:
+       * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_INCLUDEDIR): Check for
+       jni_md.h too.
+       [a7ff8e5056a1]
+
+       * configure.ac:
+       * configure.ac (AC_CHECK_FUNCS): Added lseek.
+       [2570912c4f23]
+
+2007-06-07  twisti  <twisti>
+
+       * src/native/vm/java_lang_ClassLoader.c, src/vmcore/class.c,
+       src/vmcore/class.h:
+       * src/vmcore/class.c (class_define): New function.
+       * src/vmcore/class.h (class_define): Added.
+
+       * src/native/vm/java_lang_ClassLoader.c (defineClass): Use
+       class_define.
+       [d07d76fc4127]
+
+       * src/native/native.c, src/native/native.h, src/vm/exceptions.c,
+       src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/vmcore/utf8.c (utf_java_lang_Exception__V): Added.
+       (utf8_init): Initialize utf_java_lang_Exception__V.
+       * src/vmcore/utf8.h (utf_java_lang_Exception__V): Added.
+
+       * src/vm/exceptions.c (exceptions_throw_utf_exception): New
+       function. (exceptions_throw_privilegedactionexception): Use
+       exceptions_throw_utf_exception.
+
+       * src/native/native.c (native_new_and_init_exception): New function.
+       * src/native/native.h (native_new_and_init_exception): Added.
+       [51375f51d27f]
+
+       * src/vm/exceptions.c, src/vm/exceptions.h, src/vmcore/utf8.c,
+       src/vmcore/utf8.h:
+       * src/vmcore/utf8.c (utf_java_security_PrivilegedActionException):
+       Added. (utf8_init): Initialize
+       utf_java_security_PrivilegedActionException.
+
+       * src/vmcore/utf8.h (utf_java_security_PrivilegedActionException):
+       Added.
+
+       * src/vm/exceptions.c (exceptions_throw_privilegedactionexception):
+       New function.
+
+       * src/vm/exceptions.h (exceptions_throw_privilegedactionexception):
+       Added.
+       [91d976c76ab3]
+
+2007-06-07  pm  <pm>
+
+       * src/vm/builtin.c, src/vm/jit/s390/emit.c:
+       * src/vm/jit/s390/emit.c (emit_verbosecall_enter): Fix passing of
+       float argument 2 to builtin_verbosecall_enter.
+       * src/vm/builtin.c (builtin_print_argument): Fix malfunctioning
+       conversion from s8 to float on s390.
+       [519598ee5f7c]
+
+2007-06-07  twisti  <twisti>
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_FatalError): Changed error message.
+       [55e700ed2709]
+
+       * src/vm/builtin.c, src/vm/builtin.h:
+       * src/vm/builtin.c (builtin_nanotime): New function.
+       (builtin_currenttimemillis): Use builtin_nanotime.
+
+       * src/vm/builtin.h (builtin_nanotime): Added.
+       [401776117493]
+
+       * configure.ac:
+       * configure.ac (AC_CHECK_FUNCS): Added open, strerror.
+       [ca72c4495369]
+
+       * src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c,
+       src/vmcore/linker.h:
+       * src/vmcore/class.c (class_primitive_get): New function.
+       * src/vmcore/class.h (class_primitive_get): Added.
+
+       * src/vmcore/linker.c (primitivetype_table): Changed layout.
+       (link_primitivetype_table): Store UTF-8 name in table.
+
+       * src/vmcore/linker.h (primitivetypeinfo): Changed layout, added
+       cname, changed name to UTF-8.
+       [2b7b6493b36c]
+
+       * configure.ac:
+       * configure.ac (AC_CHECK_HEADERS): Check for sys/select.h,
+       sys/stat.h, sys/types.h. (AC_CHECK_FUNCS): Check for fstat, ioctl,
+       select.
+       [b6e5f1303df2]
+
+2007-06-07  michi  <michi>
+
+       * src/mm/cacao-gc/rootset.c:
+       * src/mm/cacao-gc/rootset.c (rootset_from_thread): Add syncslots to
+       the rootset.
+       [c98b52b5c6d7]
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/m68k/codegen.c (codegen_emit): Enabled rplpoints for
+       ICMD_BUILTIN.
+       * src/vm/jit/i386/codegen.c: Likewise.
+       * src/vm/jit/x86_64/codegen.c: Likewise.
+       [e61e24193720]
+
+       * src/vm/jit/replace.c, src/vm/jit/replace.h:
+       * src/vm/jit/replace.c (replace_create_replacement_points)
+       [ENABLE_GC_CACAO]: Create replacement points for builtin invokations
+       as well.
+
+       * src/vm/jit/replace.h: Added REPLACEMENT_POINT_FORGC_BUILTIN and
+       REPLACEMENT_POINT_FORGC_BUILTIN_RETURN.
+       [b8cd6ed9311c]
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/rootset.c:
+       * src/mm/cacao-gc/rootset.c: Fixed some compiler wanings and verbose
+       output.
+       * src/mm/cacao-gc/gc.c: Likewise.
+       [95f567f2e31b]
+
+       * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao-
+       gc/rootset.c:
+       * src/mm/cacao-gc/rootset.c (rootset_from_classes): Fixed alignment
+       problem.
+       [5e61c8496d97]
+
+       * src/mm/cacao-gc/rootset.c:
+       * src/mm/cacao-gc/rootset.c (rootset_from_thread): Fixed verbose
+       output.
+       [45b51e706e2e]
+
+       * src/vm/jit/m68k/linux/md-abi.c:
+       Merged revisions 8027-8033 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r8032 | tbfg | 2007-06-07 13:23:52 +0200 (Thu, 07 Jun
+       2007) | 2 lines
+
+        * src/vm/jit/m68k/linux/md-abi.c: Additional defines for address
+       registers. ........
+       [10960ea13d78]
+
+       * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_find_replacement_point): Fixed
+       assertion.
+       * src/mm/cacao-gc/gc.h [__M68K__]: Added this architecture.
+       * src/mm/cacao-gc/heap.c (heap_alloc_intern): Removed debug code.
+       [bdb055d25777]
+
+2007-06-07  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/linux/md-abi.c:
+       * src/vm/jit/m68k/linux/md-abi.c: Additional defines for address
+       registers.
+       [807254ee68f7]
+
+       * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/md.c:
+       * linux/md-os.c (md_signal_handler_sigusr1): Implemented.
+       * emit.c (emit_replacement_stubs): Partially implemented.
+       * md.c (md_init): Disabled santiy checks.
+       * arch.h (REPLACEMENT_PATCH_SIZE): Defined to 0 for now.
+       * codegen.c (codegen_emit_stub_builtin): Implemented.
+       [a1f4488c6d64]
+
+2007-06-07  michi  <michi>
+
+       * src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigusr1):
+       Implemented.
+       [aa3f16d05963]
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_pop_native_frame,
+       replace_push_native_frame) [HAS_ADDRESS_REGISTER_FILE]: Adapted to
+       restore saved address registers as well.
+       [987c8ac0539f]
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/rootset.c:
+       * src/mm/cacao-gc/rootset.c (rootset_readout): Use thread list
+       instead of table.
+       * src/mm/cacao-gc/gc.c (gc_collect): Fixed deadlock with threads_dump.
+       [7fb4b86acc7a]
+
+       * ChangeLog, NEWS, configure.ac, src/mm/boehm-gc/pthread_stop_world.c,
+       src/native/native.c, src/native/native.h, src/native/vm/Makefile.am,
+       src/native/vm/gnu/Makefile.am,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/sun_misc_Unsafe.c,
+       src/native/vm/java_lang_Class.c, src/threads/critical.c,
+       src/threads/native/lock.c, src/threads/native/lock.h,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/none/threads.h, src/threads/threads-common.c,
+       src/threads/threads-common.h, src/vm/access.c, src/vm/access.h,
+       src/vm/builtin.c, src/vm/exceptions.c, src/vm/exceptions.h,
+       src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/emit-
+       common.h, src/vm/jit/i386/linux/md-os.c, src/vm/jit/jit.c,
+       src/vm/jit/mips/Makefile.am, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/irix/md-os.c,
+       src/vm/jit/mips/md-abi.c, src/vm/jit/optimizing/ifconv.c,
+       src/vm/jit/optimizing/profile.c, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md-
+       abi.h, src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux
+       /md-os.c, src/vm/jit/powerpc/md.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/replace.c,
+       src/vm/jit/replace.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, src/vm/jit/show.c,
+       src/vm/jit/show.h, src/vm/jit/sparc64/Makefile.am,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/machine-instr.h,
+       src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-asm.h,
+       src/vm/jit/sparc64/md.c, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/jit/x86_64/md.c, src/vm/resolve.c, src/vm/signal.c,
+       src/vm/signallocal.h, src/vm/string.c, src/vm/stringlocal.h,
+       src/vm/vm.c, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/linker.c, src/vmcore/method.h, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/statistics.c,
+       src/vmcore/statistics.h, src/vmcore/utf8.c, src/vmcore/utf8.h:
+       Merged revisions 7940-8026 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7941 | twisti | 2007-05-23 13:59:51 +0200 (Wed, 23 May
+       2007) | 6 lines
+
+        * src/vm/exceptions.c (new_exception_int): Removed.
+         * src/vm/exceptions.h (new_exception_int): Likewise.
+
+        * src/native/native.c (native_new_and_init_int): Likewise.
+         * src/native/native.h (native_new_and_init_int): Likewise. ........
+       r7942 | twisti | 2007-05-23 14:40:31 +0200 (Wed, 23 May 2007) | 24
+       lines
+
+        * src/vm/exceptions.c (threads/lock-common.h): Added.
+       [ENABLE_THREADS] (threads/native/threads.h): Removed.
+       [!ENABLE_THREADS] (threads/none/threads.h): Likewise. (threads
+       /threads-common.h): Added. (new_exception_message): Removed.
+       (exceptions_throw_classcircularityerror): Use
+       exceptions_throw_utf_utf. (exceptions_throw_classformaterror):
+       Likewise. (classnotfoundexception_to_noclassdeffounderror): Fixed
+       warning. (exceptions_throw_incompatibleclasschangeerror): Use
+       exceptions_throw_utf_utf. (exceptions_throw_internalerror):
+       Likewise. (exceptions_throw_unsupportedclassversionerror):
+       Likewise. (exceptions_throw_verifyerror): Likewise.
+       (exceptions_throw_verifyerror_for_stack): Likewise.
+       (exceptions_new_arithmeticexception): Likewise.
+       (exceptions_new_classcastexception): Use exceptions_new_class_utf.
+       (exceptions_print_exception): Fixed warnings.
+
+        * src/vmcore/utf8.c (utf_division_by_zero): Added. (utf8_init):
+       Likewise.
+
+        * src/vmcore/utf8.h (utf_division_by_zero): Likewise. ........
+       r7943 | twisti | 2007-05-23 15:09:28 +0200 (Wed, 23 May 2007) | 4
+       lines
+
+        * src/vmcore/linker.c (linker_compute_subclasses): We don't ship
+       the critical-section stuff with this release, since it's broken on
+       some architectures because of boehm. ........ r7944 | tbfg |
+       2007-05-23 16:15:00 +0200 (Wed, 23 May 2007) | 3 lines
+
+        * src/vm/jit/powerpc64/emit.c (MCODECHECK): Increase values to fix
+       canary corruption.
+         * src/vm/jit/powerpc64/codegen.c (MCODECHECK): Increase values to fix
+       canary corruption. ........ r7945 | twisti | 2007-05-23 17:25:18
+       +0200 (Wed, 23 May 2007) | 5 lines
+
+        * src/vm/jit/powerpc64/codegen.c (codegen_emit): ICMD_INSTANCEOF:
+       Removed unused supervftbl.
+
+        * src/vm/jit/emit-common.h [__POWERPC64__] (emit_bnan): Enabled.
+       ........ r7946 | twisti | 2007-05-23 17:43:53 +0200 (Wed, 23 May
+       2007) | 2 lines
+
+        * configure.ac (OPT_CFLAGS): Changed to -O2. ........ r7947 |
+       twisti | 2007-05-23 17:57:41 +0200 (Wed, 23 May 2007) | 4 lines
+
+        * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Fixed
+       warning.
+         * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv):
+       Likewise. ........ r7948 | twisti | 2007-05-23 18:00:13 +0200
+       (Wed, 23 May 2007) | 3 lines
+
+        * src/vm/exceptions.c (exceptions_new_hardware_exception): Fixed
+       warning. ........ r7949 | twisti | 2007-05-23 19:46:27 +0200 (Wed,
+       23 May 2007) | 2 lines
+
+        * src/vm/jit/jit.c (jit_compile_intern): Fixed typo. ........
+       r7950 | twisti | 2007-05-23 19:51:04 +0200 (Wed, 23 May 2007) | 2
+       lines
+
+        * src/vm/vm.c (vm_create): Use vm_abort for profile_start_thread.
+       ........ r7951 | twisti | 2007-05-23 19:51:43 +0200 (Wed, 23 May
+       2007) | 3 lines
+
+        * src/vm/jit/optimizing/profile.c (profile_thread): Replaced
+       table- with list-functions. ........ r7952 | twisti | 2007-05-23
+       19:53:13 +0200 (Wed, 23 May 2007) | 2 lines
+
+        * src/vm/jit/optimizing/profile.c: Set Id keyword. ........
+       r7953 | twisti | 2007-05-23 19:56:59 +0200 (Wed, 23 May 2007) | 3
+       lines
+
+        * src/native/vm/gnu/java_lang_VMClassLoader.c (getPrimitiveClass):
+       Return NULL in error case. ........ r7954 | twisti | 2007-05-23
+       19:58:18 +0200 (Wed, 23 May 2007) | 3 lines
+
+        * src/threads/native/lock.c: Set Id keyword.
+         * src/threads/native/lock.h: Likewise. ........ r7955 | twisti |
+       2007-05-23 20:05:26 +0200 (Wed, 23 May 2007) | 8 lines
+
+        * src/vm/jit/arm/linux/md-os.c, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/x86_64/linux/md-
+       os.c (md_critical_section_restart): Removed debug output. ........
+       r7956 | twisti | 2007-05-23 20:08:42 +0200 (Wed, 23 May 2007) | 3
+       lines
+
+        * src/vmcore/statistics.c (statistics_print_memory_usage): Smaller
+       output changes. ........ r7957 | twisti | 2007-05-23 20:28:01
+       +0200 (Wed, 23 May 2007) | 2 lines
+
+        * src/vm/jit/mips/Makefile.am (DIST_SUBDIRS): Added uclinux.
+       ........ r7958 | twisti | 2007-05-23 21:11:10 +0200 (Wed, 23 May
+       2007) | 3 lines
+
+        * src/vm/jit/powerpc64/linux/md-os.c
+       (md_critical_section_restart): Fixed typo. ........ r7959 |
+       twisti | 2007-05-23 21:37:26 +0200 (Wed, 23 May 2007) | 5 lines
+
+        * src/threads/threads-common.h (THREAD_STATE_NEW)
+       (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING)
+       (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Start states
+       with 1, so we can catch unset states. ........ r7960 | twisti |
+       2007-05-24 00:04:49 +0200 (Thu, 24 May 2007) | 2 lines
+
+        * configure.ac (AM_INIT_AUTOMAKE): Added dist-bzip2. ........
+       r7961 | ajordan | 2007-05-24 00:54:38 +0200 (Thu, 24 May 2007) | 4
+       lines
+
+        * src/vm/jit/sparc64/Makefile.am: md-asm.h was not properly
+       added to noinst_HEADERS. ........ r7962 | ajordan | 2007-05-24
+       01:56:59 +0200 (Thu, 24 May 2007) | 3 lines
+
+        * src/vm/jit/sparc64/Makefile.am: Added missing emit.h. ........
+       r7963 | twisti | 2007-05-24 12:21:16 +0200 (Thu, 24 May 2007) | 42
+       lines
+
+        * src/threads/threads-common.c (mm/memory.h): Added.
+       (toolbox/list.h): Likewise. (threads_table): Removed.
+       (list_threads, list_threads_free): Added. (threads_preinit):
+       Initialize lists. (threads_table_init): Removed.
+       (threads_table_add): Likewise. (threads_table_remove): Likewise.
+       (threads_table_get): Likewise. (threads_table_get_threads):
+       Likewise. (threads_table_get_non_daemons): Likewise.
+       (threads_table_first): Likewise. (threads_table_next): Likewise.
+       (threads_table_dump): Likewise. (threads_list_first): New
+       function. (threads_list_next): Likewise.
+       (threads_list_get_non_daemons): Likewise. (threads_thread_new):
+       Likewise. (threads_thread_free): Likewise.
+       (threads_thread_print_info): Added state-assert, print thread index.
+       (threads_thread_state_runnable): New function.
+       (threads_thread_state_waiting): Likewise.
+       (threads_thread_state_timed_waiting): Likewise.
+       (threads_thread_state_terminated): Likewise. (threads_dump): Use
+       threads-list functions.
+
+        * src/threads/threads-common.h: Likewise.
+       (threads_table_entry_t): Removed. (threads_table_t): Likewise.
+
+        * src/threads/native/threads.c (mutex_threads_table): Renamed to
+       mutex_threads_list. (threads_cast_sendsignals): Use threads-list
+       functions. (threads_table_lock): Renamed to threads_list_lock.
+       (threads_table_unlock): Renamed to threads_list_unlock.
+       (threads_startup_thread): Use threads-state functions.
+       (threads_detach_thread): Likewise. (threads_wait_with_timeout):
+       Likewise. (threads_join_all_threads): Use threads-list functions.
+
+        * src/threads/native/threads.h (threadobject): Added linkage.
+       ........ r7964 | twisti | 2007-05-24 12:23:42 +0200 (Thu, 24 May
+       2007) | 3 lines
+
+        * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv): Fixed
+       warning. ........ r7965 | michi | 2007-05-24 15:25:41 +0200 (Thu,
+       24 May 2007) | 3 lines
+
+        * src/vmcore/linker.c (link_class_intern) [__ARM_EABI__]: Fixed
+       field alignment bug. Double and Long fields are 8-byte aligned
+       with EABI. ........ r7966 | pm | 2007-05-25 14:41:03 +0200 (Fri,
+       25 May 2007) | 24 lines
+
+        * src/vm/jit/show.h (show_filters_init, show_filters_apply,
+       show_filters_test_verbosecall_enter,
+       show_filters_test_verbosecall_exit): Added.
+         * src/vm/jit/show.c: Likewise.
+         * src/vm/jit/jit.c (jit_compile_intern): Honour filters.
+         * src/vm/jit/codegen-common.c (codegen_add_patch_ref,
+       codegen_generate_stub_native): Honour PATCHER_LONGBRANCHES_NOPS if
+       defined, honour filters.
+         * src/vm/builtin.c (builtin_trace_exception,
+       builtin_verbosecall_enter, builtin_verbosecall_exit): Honour
+       filters.
+         * src/vm/signal.c (signal_init): Register SIGILL handler on s390.
+         * src/vm/vm.c: Handle -XXfi, -XXfe, -XXfm commandline options.
+         * src/vm/signallocal.h (md_signal_handler_sigill): Forward declare on
+       s390.
+         * src/threads/none/threads.h (_no_threads_filterverbosecallctr,
+       FILTERVERBOSECALLCTR): Added.
+         * src/threads/native/threads.h (struct threadobject): Added
+       filterverbosecallctr.
+         * src/threads/native/threads.c (threads_impl_thread_new): Initialize
+       filterverbosecallctr.
+         * src/threads/critical.c (critical_comparator): On s390, clear bit 32
+       of pointer when comparing.
+         * src/vmcore/options.h (opt_filter_verbosecall_include,
+       opt_filter_verbosecall_exclude, opt_filter_show_method): Added.
+         * src/vmcore/options.c: Likewise.
+         * src/vmcore/method.h (struct methodinfo): Added filtermatches.
+         * configure.ac: If no NDEBUG and regex.h header is present, define
+       ENABLE_DEBUG_FILTER.
+         * src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/tests/dacapo.status, src/vm/jit/s390/patcher.c:
+       Changed a lot. ........ r7967 | twisti | 2007-05-25 17:03:46 +0200
+       (Fri, 25 May 2007) | 3 lines
+
+        * src/vm/string.c (javastring_new_from_utf_buffer): Made static.
+         * src/vm/stringlocal.h (javastring_new_from_utf_buffer): Removed.
+       ........ r7968 | twisti | 2007-05-25 17:05:04 +0200 (Fri, 25 May
+       2007) | 3 lines
+
+        * src/vm/jit/powerpc/md.c (md_get_method_patch_address): Fixed
+       warning, use vm_abort. ........ r7969 | twisti | 2007-05-25
+       17:05:57 +0200 (Fri, 25 May 2007) | 3 lines
+
+        * src/vm/jit/optimizing/ifconv.c (vm/vm.h): Added.
+       (ifconv_static): Fixed warning, use vm_abort. ........ r7970 |
+       twisti | 2007-05-25 17:23:56 +0200 (Fri, 25 May 2007) | 5 lines
+
+        * src/threads/threads-common.c (threads_thread_start_internal)
+       [WITH_CLASSPATH_CLDC1_1]: Set name to NULL, but this needs a fix.
+       (threads_thread_print_info) [ENABLE_JAVAME_CLDC1_1]: Set name to
+       utf_null. ........ r7971 | pm | 2007-05-26 17:26:06 +0200 (Sat, 26
+       May 2007) | 2 lines
+
+        * contrib/vmlog/vmlog.c: Use autoconf define WORDS_BIGENDIAN to
+       determine endianess. ........ r7972 | ajordan | 2007-05-28
+       02:05:04 +0200 (Mon, 28 May 2007) | 11 lines
+
+        * src/vm/jit/sparc64/codegen.h: Removed asserts for stores with
+       sethi.
+
+        * src/vm/jit/sparc64/codegen.c: Added code to fill with nops when
+       a patcher is right at the end of a basic block.
+
+        * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method_end): Returning
+       0 when an exception occurs.
+
+        * src/vm/jit/sparc64/md.c (md_get_method_patch_address): Improved
+       handling of mptr loads when a sethi is involved. ........ r7973
+       | twisti | 2007-05-29 11:03:56 +0200 (Tue, 29 May 2007) | 10 lines
+
+        * src/vm/exceptions.c (exceptions_throw_illegalaccessexception):
+       Changed signature.
+         * src/vm/exceptions.h: Likewise.
+
+        * src/vm/resolve.c (resolve_class_from_name): Make utf8-string out
+       of exception message. (resolve_subtype_check): Likewise.
+       (resolve_field_verifier_checks): Likewise.
+       (resolve_method_verifier_checks): Likewise. ........ r7974 |
+       twisti | 2007-05-29 13:30:20 +0200 (Tue, 29 May 2007) | 3 lines
+
+        * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed warnings,
+       some indent. ........ r7975 | pm | 2007-05-29 13:44:02 +0200
+       (Tue, 29 May 2007) | 3 lines
+
+        * src/vm/jit/show.c (vm/vm.h) add missing include,
+       (_no_threads_filterverbosecallctr) fix type: u2 instead of u4
+       ........ r7976 | twisti | 2007-05-29 14:22:55 +0200 (Tue, 29 May
+       2007) | 24 lines
+
+        * src/vm/access.c (string.h): Added. (mm/memory.h): Likewise.
+       (vmcore/field.h): Likewise. (vmcore/method.h): Likewise.
+       (access_check_member): Removed. (access_check_field): New
+       function. (access_check_method): Likewise.
+
+        * src/vm/access.h (vmcore/field.h): Added. (vmcore/method.h):
+       Likewise. (access_check_member): Removed. (access_check_field):
+       New function. (access_check_method): Likewise.
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative):
+       Call access_check_method instead of access_check_member.
+
+        * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (constructNative): Likewise.
+
+        * src/native/vm/gnu/java_lang_reflect_Field.c
+       (cacao_get_field_address): Call access_check_field instead of
+       access_check_member. ........ r7977 | twisti | 2007-05-29 14:34:20
+       +0200 (Tue, 29 May 2007) | 6 lines
+
+        * src/vm/signal.c (signal_init): Changed signature.
+         * src/vm/signallocal.h (signal_init): Likewise.
+
+        * src/vm/vm.c (vm_create): Call signal_init right after gc_init
+       and check return value. ........ r7978 | twisti | 2007-05-30
+       16:09:10 +0200 (Wed, 30 May 2007) | 7 lines
+
+        * src/vm/signal.c (mm/boehm-gc/include/gc.h): Added.
+       (GC_suspend_handler): Defined. (GC_restart_handler): Likewise.
+       (signal_thread): Add the Boehm-GC signals to the mask and call the
+       appropriate Boehm-function. This is a workaround for the Boehm-
+       LinuxThreads bug. ........ r7979 | twisti | 2007-05-30 17:52:00
+       +0200 (Wed, 30 May 2007) | 3 lines
+
+        * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed --disable-
+       debug build. ........ r7980 | twisti | 2007-05-30 18:01:09 +0200
+       (Wed, 30 May 2007) | 4 lines
+
+        * src/vm/jit/powerpc64/md.c (md_get_method_patch_address): Use
+       vm_abort and fixed warning. (md_codegen_get_pv_from_pc): Likewise.
+       ........ r7981 | twisti | 2007-05-30 21:43:36 +0200 (Wed, 30 May
+       2007) | 9 lines
+
+        * src/mm/boehm-gc/pthread_stop_world.c (cacao_suspendhandler):
+       Commented. (GC_suspend_handler): Commented cacao_suspendhandler
+       call. (GC_signum1, GC_signum2): Define for all configurations
+       (hope that works).
+
+        * src/threads/native/threads.c: Commented all critical-sections
+       code, as it does not work anyway and it does not compile
+       everywhere. ........ r7982 | twisti | 2007-05-30 22:01:49 +0200
+       (Wed, 30 May 2007) | 6 lines
+
+        * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native): Fixed
+       typo.
+
+        * src/vm/jit/powerpc64/emit.c [!NDEBUG] (emit_verbosecall_enter)
+       (emit_verbosecall_exit): Only compile conditionally. ........
+       r7983 | twisti | 2007-05-30 22:04:42 +0200 (Wed, 30 May 2007) | 3
+       lines
+
+        * src/vm/resolve.c (resolve_subtype_check): Don't free the memory
+       before it's used. ........ r7984 | twisti | 2007-05-30 22:30:00
+       +0200 (Wed, 30 May 2007) | 7 lines
+
+        * src/threads/native/threads.c (threads_impl_preinit): Initialize
+       mutex_threads_list. (threads_impl_table_init): Removed.
+       (threads_impl_table_init, threads_list_unlock): Fixed debug message.
+
+        * src/threads/threads-common.h (threads_impl_table_init): Removed.
+       ........ r7985 | twisti | 2007-05-30 22:40:23 +0200 (Wed, 30 May
+       2007) | 3 lines
+
+        * src/mm/boehm-gc/pthread_stop_world.c (GC_signum1, GC_signum2):
+       No it did not work, reverted rev7981. ........ r7986 | twisti |
+       2007-05-30 22:45:43 +0200 (Wed, 30 May 2007) | 3 lines
+
+        * src/vm/builtin.c (math.h): Removed because we don't need it as
+       we include fdlibm.h and it does not work on some OSs, like Darwin.
+       ........ r7987 | twisti | 2007-05-30 22:51:50 +0200 (Wed, 30 May
+       2007) | 4 lines
+
+        * src/vm/signal.c (signal_thread) [!__DARWIN__]: Don't do the
+       GC_signum stuff on Darwin (should also be done on Solaris, but let's
+       wait how the exact-GC is doing). ........ r7988 | twisti |
+       2007-05-30 22:53:56 +0200 (Wed, 30 May 2007) | 4 lines
+
+        * src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin
+       /md-abi.h: Removed Contact, Authors, Changes from header. ........
+       r7989 | twisti | 2007-05-30 23:04:42 +0200 (Wed, 30 May 2007) | 4
+       lines
+
+        * src/vm/jit/powerpc/asmpart.S [ENABLE_REPLACEMENT] (L_replace_me)
+       (L_replace_build_execution_state, L_replace_free_safestack): Only if
+       replacement is enabled, otherwise we get a linker error. ........
+       r7990 | twisti | 2007-05-30 23:05:20 +0200 (Wed, 30 May 2007) | 3
+       lines
+
+        * src/vm/jit/powerpc/darwin/md-os.c
+       (thread_restartcriticalsection): Renamed to
+       md_critical_section_restart. ........ r7991 | twisti | 2007-05-30
+       23:59:29 +0200 (Wed, 30 May 2007) | 3 lines
+
+        * ChangeLog: Updated.
+         * ChangeLog-2006: New file. ........ r7992 | twisti | 2007-05-31
+       00:01:38 +0200 (Thu, 31 May 2007) | 2 lines
+
+        * NEWS: Added some 0.98 release notes. ........ r7993 | twisti |
+       2007-05-31 00:32:43 +0200 (Thu, 31 May 2007) | 2 lines
+
+        * src/vm/jit/powerpc64/emit.c (emit_branch): Removed debug output.
+       ........ r7994 | twisti | 2007-05-31 18:10:58 +0200 (Thu, 31 May
+       2007) | 2 lines
+
+        * src/vm/vm.c (vm_create): Added comment. ........ r7995 |
+       twisti | 2007-06-01 00:45:19 +0200 (Fri, 01 Jun 2007) | 2 lines
+
+        * src/vm/signal.c: Reverted rev7978. ........ r7996 | twisti |
+       2007-06-01 01:05:51 +0200 (Fri, 01 Jun 2007) | 15 lines
+
+        * m4/ac_pthreads_implementation.m4: New file.
+
+        * m4/threads.m4 (AC_CHECK_ENABLE_THREADS): Call
+       AC_CHECK_PTHREADS_IMPLEMENTATION for posix and linux.
+
+        * configure.ac (AC_CHECK_HEADERS): Added stdlib.h.
+       (AC_CHECK_FUNCS): Added confstr, strstr.
+
+        * src/vm/signal.c (signal_init) [!PTHREADS_IS_LINUXTHREADS]: Only
+       block the signals if we are not on LinuxThreads. (signal_thread):
+       Set state accordingly.
+
+        * src/vm/vm.c (vm_create) [!PTHREADS_IS_LINUXTHREADS]: Only start
+       signal-thread if we are not on LinuxThreads. ........ r7997 |
+       twisti | 2007-06-01 01:26:23 +0200 (Fri, 01 Jun 2007) | 5 lines
+
+        * src/vm/jit/mips/irix/md-os.c (vm/jit/mips/codegen.h): Added.
+       (md_signal_handler_sigsegv): Updated to new exception-handling.
+       (thread_restartcriticalsection): Renamed to
+       md_critical_section_restart. ........ r7998 | twisti | 2007-06-01
+       02:29:51 +0200 (Fri, 01 Jun 2007) | 16 lines
+
+        * m4/ac_pthreads_implementation.m4: Reverted rev7996.
+         * m4/threads.m4: Likewise.
+
+        * src/threads/threads-common.c [__LINUX__]
+       (threads_pthreads_implementation_nptl): Added. (threads_preinit)
+       [__LINUX__]: Check which thread-implementation we are using.
+
+        * src/threads/threads-common.h [__LINUX__]
+       (threads_pthreads_implementation_nptl): Added.
+
+        * src/vm/signal.c (signal_init) [__LINUX__]: Check for
+       threads_pthreads_implementation_nptl.
+
+        * src/vm/vm.c (vm_create) [__LINUX__]: Likewise. ........ r7999
+       | ajordan | 2007-06-01 02:45:04 +0200 (Fri, 01 Jun 2007) | 12 lines
+
+        * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed
+       the way float arguments are preserved over
+       codegen_start_native_call.
+         * src/vm/jit/sparc64/md-abi.c (codegen_start_native_call): Likewise.
+
+        * src/vm/jit/sparc64/machine-instr.h (compare_and_swap): Changed
+       inline assembly, so it survives gcc optimization.
+
+        * src/vm/jit/sparc64/asmpart.S (asm_patcher_wrapper): Saving and
+       restoring float return register.
+         * src/vm/jit/sparc64/md-asm.h: Likewise. ........ r8000 | ajordan |
+       2007-06-01 21:34:56 +0200 (Fri, 01 Jun 2007) | 2 lines
+
+        * src/vm/signal.c: Added ifdefs to fix compiling with disabled
+       threads. ........ r8001 | pm | 2007-06-02 19:47:30 +0200 (Sat, 02
+       Jun 2007) | 9 lines
+
+        * contrib/vmlog/vmlogfilter.c: Added a tool that filters a vmlog
+       log file the same way as -XXfi and -XXfx do.
+
+        * contrib/vmlog/vmlog.c, contrib/vmlog/vmlog.h
+       (vmlog_thread_log_append): Made not-static.
+
+        * contrib/vmlog/Makefile.am, configure.ac: Conditional building
+       of vmlogfilter if ENABLE_VMLOG is set and regex.h present. ........
+       r8002 | pm | 2007-06-03 20:24:44 +0200 (Sun, 03 Jun 2007) | 2 lines
+
+        * configure.ac: Fix broken regex.h test. ........ r8003 | twisti
+       | 2007-06-03 20:42:09 +0200 (Sun, 03 Jun 2007) | 16 lines
+
+        * src/threads/threads-common.c (threads_thread_start_internal):
+       Changed order of initialization stuff, so we can leave the join-
+       mutex very early. (threads_thread_start): Likewise.
+
+        * src/threads/native/threads.c (threads_mutex_join_lock): New
+       function. (threads_mutex_join_unlock): Likewise.
+       (threads_attach_current_thread): Changed order of initialization
+       stuff, so we can leave the join-mutex very early.
+       (threads_detach_thread): Send the signal inside the join-mutex.
+       (threads_join_all_threads): Use join-mutex functions.
+
+        * src/threads/threads-common.h (threads_mutex_join_lock): Added.
+       (threads_mutex_join_unlock): Likewise. ........ r8004 | twisti |
+       2007-06-04 14:59:04 +0200 (Mon, 04 Jun 2007) | 3 lines
+
+        * src/vm/signal.c (signal_init): Use if-vm_abort instead of
+       assert.
+         * src/vm/exceptions.h: Changed hardware-exception comment accordingly.
+       ........ r8005 | twisti | 2007-06-04 15:12:56 +0200 (Mon, 04 Jun
+       2007) | 9 lines
+
+        * src/vm/signal.c (unistd.h): Removed. (sys/mman.h): Likewise.
+       (signal_init): Moved mmap of page 0x0 and the hardware-exceptions
+       check into exceptions_init.
+
+        * src/vm/exceptions.c (unistd.h): Added. (sys/mman.h): Likewise.
+       (exceptions_init): See above. ........ r8006 | twisti | 2007-06-05
+       09:40:49 +0200 (Tue, 05 Jun 2007) | 20 lines
+
+        * src/vmcore/statistics.c (count_calls_java_to_native): Added.
+       (count_calls_native_to_java): Likewise.
+       (count_native_function_calls): Removed. (nativeinvokation):
+       Likewise. (print_stats): Print new variables.
+
+        * src/vmcore/statistics.h (count_calls_java_to_native): Added.
+       (count_calls_native_to_java): Likewise. (nativeinvokation):
+       Removed.
+
+        * src/vm/jit/codegen-common.c (codegen_start_native_call)
+       [ENABLE_STATISTICS]: Increase count_calls_java_to_native.
+
+        * src/vm/vm.c (vm_call_method_vmarg) [ENABLE_STATISTICS]: Increase
+       count_calls_native_to_java. (vm_call_method_int_vmarg): Likewise.
+       (vm_call_method_long_vmarg): Likewise.
+       (vm_call_method_float_vmarg): Likewise.
+       (vm_call_method_double_vmarg): Likewise. ........ r8007 | twisti |
+       2007-06-05 09:42:57 +0200 (Tue, 05 Jun 2007) | 2 lines
+
+        * src/vm/vm.c (vmcore/statistics.h): Added. ........ r8008 |
+       twisti | 2007-06-05 09:44:38 +0200 (Tue, 05 Jun 2007) | 2 lines
+
+        * src/vm/vm.c: Set Id keyword. ........ r8009 | twisti |
+       2007-06-05 09:56:35 +0200 (Tue, 05 Jun 2007) | 2 lines
+
+        * src/vm/jit/mips/codegen.c (codegen_emit): Small code-layout
+       change. ........ r8010 | twisti | 2007-06-05 11:00:30 +0200 (Tue,
+       05 Jun 2007) | 3 lines
+
+        * src/vm/jit/mips/codegen.c (codegen_emit): Use FLTMOVE and
+       DBLMOVE to save some moves. ........ r8011 | twisti | 2007-06-05
+       12:06:18 +0200 (Tue, 05 Jun 2007) | 12 lines
+
+        * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 4]:
+       Use internally a different calling convention. It's the same as on
+       n64 with register skipping and, but with long alignment (as on
+       ARM). (md_param_alloc_native) [SIZEOF_VOID_P == 4]: Use the o32
+       ABI.
+
+        * src/vm/jit/mips/codegen.c (codegen_emit) [SIZEOF_VOID_P == 4]:
+       Changes for new internal calling conventions.
+       (codegen_emit_stub_native) [SIZEOF_VOID_P == 4]: Likewise.
+
+        * src/vm/jit/mips/asmpart.S (asm_vm_call_method) [SIZEOF_VOID_P ==
+       4]: Adjusted reserved stack-space to 4*4. ........ r8012 |
+       twisti | 2007-06-05 12:14:29 +0200 (Tue, 05 Jun 2007) | 3 lines
+
+        * src/vm/jit/mips/md-abi.c (md_param_alloc_native)
+       [SIZEOF_VOID_P == 8]: Fixed compilation. ........ r8013 | twisti |
+       2007-06-05 12:19:09 +0200 (Tue, 05 Jun 2007) | 3 lines
+
+        * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 8]:
+       Use reguse instead of i. ........ r8014 | twisti | 2007-06-05
+       14:53:30 +0200 (Tue, 05 Jun 2007) | 3 lines
+
+        * src/vm/jit/codegen-common.c [__ARM__] (md-abi.h): Removed.
+       (codegen_reg_of_var) [__ARM__]: Removed split-code. ........ r8015
+       | twisti | 2007-06-05 22:58:11 +0200 (Tue, 05 Jun 2007) | 10 lines
+
+        * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES):
+       Removed sun_misc_Unsafe.c.
+
+        * src/native/vm/Makefile.am [ENABLE_JAVASE]
+       (SUN_MISC_UNSAFE_SOURCES): Added. (libnativevm_la_SOURCES):
+       Added SUN_MISC_UNSAFE_SOURCES.
+
+        * src/native/vm/gnu/sun_misc_Unsafe.c: Removed.
+         * src/native/vm/sun_misc_Unsafe.c: Added. ........ r8016 | twisti |
+       2007-06-06 00:11:12 +0200 (Wed, 06 Jun 2007) | 5 lines
+
+        * src/native/native.c (native_init): Check nativevm_init return
+       value.
+
+        * src/native/vm/nativevm.c (nativevm_init): Changed signature.
+         * src/native/vm/nativevm.h (nativevm_init): Likewise. ........ r8017
+       | twisti | 2007-06-06 01:46:59 +0200 (Wed, 06 Jun 2007) | 10 lines
+
+        * src/native/vm/gnu/java_lang_VMString.c
+       (native/vm/java_lang_String.h): Added. (intern): Call
+       _Jv_java_lang_String_intern.
+
+        * src/native/vm/java_lang_String.c: New file.
+         * src/native/vm/java_lang_String.h: Likewise.
+
+        * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
+       java_lang_String.[ch]. ........ r8018 | twisti | 2007-06-06
+       11:24:22 +0200 (Wed, 06 Jun 2007) | 2 lines
+
+        * configure.ac (AC_INIT): Changed version to 0.98. ........
+       r8019 | twisti | 2007-06-06 11:26:00 +0200 (Wed, 06 Jun 2007) | 2
+       lines
+
+        * ChangeLog: Updated. ........ r8022 | twisti | 2007-06-06
+       13:31:28 +0200 (Wed, 06 Jun 2007) | 3 lines
+
+        * configure.ac (AC_INIT): Changed version to 0.98+svn.
+       (OPT_CFLAGS): Changed to -O0. ........ r8023 | twisti | 2007-06-06
+       19:19:17 +0200 (Wed, 06 Jun 2007) | 2 lines
+
+        * NEWS: Fixed 0.98 release date. ........ r8024 | twisti |
+       2007-06-06 19:23:42 +0200 (Wed, 06 Jun 2007) | 8 lines
+
+        * src/vmcore/class.c (class_is_primitive): New function.
+         * src/vmcore/class.h (class_is_primitive): Added.
+
+        * src/native/vm/java_lang_Class.c (isPrimitive): Use
+       class_is_primitive. (getDeclaringClass): Likewise.
+       (getDeclaredClasses): Likewise. ........ r8025 | michi |
+       2007-06-07 10:51:54 +0200 (Thu, 07 Jun 2007) | 8 lines
+
+        * src/vm/jit/code.h (codeinfo) [ENABLE_REPLACEMENT,
+       HAS_ADDRESS_REGISTER_FILE]: Added savedadrcount.
+
+        * src/vm/jit/replace.c [HAS_ADDRESS_REGISTER_FILE]: Added support
+       for address registers.
+
+        * src/vm/jit/replace.h [HAS_ADDRESS_REGISTER_FILE]: Likewise.
+       ........ r8026 | twisti | 2007-06-07 11:04:51 +0200 (Thu, 07 Jun
+       2007) | 15 lines
+
+        * src/native/vm/gnu/java_lang_reflect_Constructor.c (methods):
+       Install _Jv_- functions directly. (getModifiersInternal):
+       Removed. (getParameterTypes): Likewise. (getExceptionTypes):
+       Likewise. (constructNative): Call
+       _Jv_java_lang_reflect_Constructor_newInstance. (getSignature):
+       Removed.
+
+        * src/native/vm/Makefile.am [ENABLE_JAVASE]
+       (JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES): Added.
+       (libnativevm_la_SOURCES): Added
+       JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES.
+
+        * src/native/vm/java_lang_reflect_Constructor.c: New file.
+         * src/native/vm/java_lang_reflect_Constructor.h: Likewise. ........
+       [f14d326b56fe]
+
+2007-06-07  twisti  <twisti>
+
+       * src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.c,
+       src/native/vm/java_lang_reflect_Constructor.h:
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c (methods):
+       Install _Jv_- functions directly. (getModifiersInternal): Removed.
+       (getParameterTypes): Likewise. (getExceptionTypes): Likewise.
+       (constructNative): Call
+       _Jv_java_lang_reflect_Constructor_newInstance. (getSignature):
+       Removed.
+
+       * src/native/vm/Makefile.am [ENABLE_JAVASE]
+       (JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES): Added.
+       (libnativevm_la_SOURCES): Added
+       JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES.
+
+       * src/native/vm/java_lang_reflect_Constructor.c: New file.
+       * src/native/vm/java_lang_reflect_Constructor.h: Likewise.
+       [6960350b0edd]
+
+2007-06-07  michi  <michi>
+
+       * src/vm/jit/code.h, src/vm/jit/replace.c, src/vm/jit/replace.h:
+       * src/vm/jit/code.h (codeinfo) [ENABLE_REPLACEMENT,
+       HAS_ADDRESS_REGISTER_FILE]: Added savedadrcount.
+
+       * src/vm/jit/replace.c [HAS_ADDRESS_REGISTER_FILE]: Added support
+       for address registers.
+
+       * src/vm/jit/replace.h [HAS_ADDRESS_REGISTER_FILE]: Likewise.
+       [4a6ecb69f8b5]
+
+2007-06-06  twisti  <twisti>
+
+       * src/native/vm/java_lang_Class.c, src/vmcore/class.c,
+       src/vmcore/class.h:
+       * src/vmcore/class.c (class_is_primitive): New function.
+       * src/vmcore/class.h (class_is_primitive): Added.
+
+       * src/native/vm/java_lang_Class.c (isPrimitive): Use
+       class_is_primitive. (getDeclaringClass): Likewise.
+       (getDeclaredClasses): Likewise.
+       [7a59a4145783]
+
+       * NEWS:
+       * NEWS: Fixed 0.98 release date.
+       [eef3556c431c]
+
+       * configure.ac:
+       * configure.ac (AC_INIT): Changed version to 0.98+svn. (OPT_CFLAGS):
+       Changed to -O0.
+       [98ba45471b0c]
+
+       * ChangeLog:
+       * ChangeLog: Updated.
+       [430cdebdf7d1] [cacao-0.98]
+
+       * configure.ac:
+       * configure.ac (AC_INIT): Changed version to 0.98.
+       [55dc961e7162]
+
+2007-06-05  twisti  <twisti>
+
+       * src/native/vm/Makefile.am, src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/java_lang_String.c, src/native/vm/java_lang_String.h:
+       * src/native/vm/gnu/java_lang_VMString.c
+       (native/vm/java_lang_String.h): Added. (intern): Call
+       _Jv_java_lang_String_intern.
+
+       * src/native/vm/java_lang_String.c: New file.
+       * src/native/vm/java_lang_String.h: Likewise.
+
+       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
+       java_lang_String.[ch].
+       [5d0584628b96]
+
+       * src/native/native.c, src/native/vm/nativevm.c,
+       src/native/vm/nativevm.h:
+       * src/native/native.c (native_init): Check nativevm_init return
+       value.
+
+       * src/native/vm/nativevm.c (nativevm_init): Changed signature.
+       * src/native/vm/nativevm.h (nativevm_init): Likewise.
+       [757bca0bff3a]
+
+       * src/native/vm/Makefile.am, src/native/vm/gnu/Makefile.am,
+       src/native/vm/gnu/sun_misc_Unsafe.c,
+       src/native/vm/sun_misc_Unsafe.c:
+       * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES):
+       Removed sun_misc_Unsafe.c.
+
+       * src/native/vm/Makefile.am [ENABLE_JAVASE]
+       (SUN_MISC_UNSAFE_SOURCES): Added. (libnativevm_la_SOURCES): Added
+       SUN_MISC_UNSAFE_SOURCES.
+
+       * src/native/vm/gnu/sun_misc_Unsafe.c: Removed.
+       * src/native/vm/sun_misc_Unsafe.c: Added.
+       [95d583480799]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c [__ARM__] (md-abi.h): Removed.
+       (codegen_reg_of_var) [__ARM__]: Removed split-code.
+       [3ab646d8b0e1]
+
+       * src/vm/jit/mips/md-abi.c:
+       * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 8]:
+       Use reguse instead of i.
+       [643220e47422]
+
+       * src/vm/jit/mips/md-abi.c:
+       * src/vm/jit/mips/md-abi.c (md_param_alloc_native) [SIZEOF_VOID_P ==
+       8]: Fixed compilation.
+       [5f2d418385a3]
+
+       * src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/md-abi.c:
+       * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 4]:
+       Use internally a different calling convention. It's the same as on
+       n64 with register skipping and, but with long alignment (as on ARM).
+       (md_param_alloc_native) [SIZEOF_VOID_P == 4]: Use the o32 ABI.
+
+       * src/vm/jit/mips/codegen.c (codegen_emit) [SIZEOF_VOID_P == 4]:
+       Changes for new internal calling conventions.
+       (codegen_emit_stub_native) [SIZEOF_VOID_P == 4]: Likewise.
+
+       * src/vm/jit/mips/asmpart.S (asm_vm_call_method) [SIZEOF_VOID_P ==
+       4]: Adjusted reserved stack-space to 4*4.
+       [f3dfa2fb1f08]
+
+       * src/vm/jit/mips/codegen.c:
+       * src/vm/jit/mips/codegen.c (codegen_emit): Use FLTMOVE and DBLMOVE
+       to save some moves.
+       [6e02854739d1]
+
+       * src/vm/jit/mips/codegen.c:
+       * src/vm/jit/mips/codegen.c (codegen_emit): Small code-layout
+       change.
+       [397770a510c4]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c: Set Id keyword.
+       [d1945a7fc00f]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vmcore/statistics.h): Added.
+       [a834dcae9a0b]
+
+       * src/vm/jit/codegen-common.c, src/vm/vm.c, src/vmcore/statistics.c,
+       src/vmcore/statistics.h:
+       * src/vmcore/statistics.c (count_calls_java_to_native): Added.
+       (count_calls_native_to_java): Likewise.
+       (count_native_function_calls): Removed. (nativeinvokation):
+       Likewise. (print_stats): Print new variables.
+
+       * src/vmcore/statistics.h (count_calls_java_to_native): Added.
+       (count_calls_native_to_java): Likewise. (nativeinvokation): Removed.
+
+       * src/vm/jit/codegen-common.c (codegen_start_native_call)
+       [ENABLE_STATISTICS]: Increase count_calls_java_to_native.
+
+       * src/vm/vm.c (vm_call_method_vmarg) [ENABLE_STATISTICS]: Increase
+       count_calls_native_to_java. (vm_call_method_int_vmarg): Likewise.
+       (vm_call_method_long_vmarg): Likewise. (vm_call_method_float_vmarg):
+       Likewise. (vm_call_method_double_vmarg): Likewise.
+       [cbcd525d01cc]
+
+2007-06-04  twisti  <twisti>
+
+       * src/vm/exceptions.c, src/vm/signal.c:
+       * src/vm/signal.c (unistd.h): Removed. (sys/mman.h): Likewise.
+       (signal_init): Moved mmap of page 0x0 and the hardware-exceptions
+       check into exceptions_init.
+
+       * src/vm/exceptions.c (unistd.h): Added. (sys/mman.h): Likewise.
+       (exceptions_init): See above.
+       [ef8a5cde695e]
+
+       * src/vm/exceptions.h, src/vm/signal.c:
+       * src/vm/signal.c (signal_init): Use if-vm_abort instead of assert.
+       * src/vm/exceptions.h: Changed hardware-exception comment accordingly.
+       [d6d44453fb52]
+
+2007-06-03  twisti  <twisti>
+
+       * src/threads/native/threads.c, src/threads/threads-common.c,
+       src/threads/threads-common.h:
+       * src/threads/threads-common.c (threads_thread_start_internal):
+       Changed order of initialization stuff, so we can leave the join-
+       mutex very early. (threads_thread_start): Likewise.
+
+       * src/threads/native/threads.c (threads_mutex_join_lock): New
+       function. (threads_mutex_join_unlock): Likewise.
+       (threads_attach_current_thread): Changed order of initialization
+       stuff, so we can leave the join-mutex very early.
+       (threads_detach_thread): Send the signal inside the join-mutex.
+       (threads_join_all_threads): Use join-mutex functions.
+
+       * src/threads/threads-common.h (threads_mutex_join_lock): Added.
+       (threads_mutex_join_unlock): Likewise.
+       [31785a69c5f9]
+
+2007-06-03  pm  <pm>
+
+       * configure.ac:
+       * configure.ac: Fix broken regex.h test.
+       [5f7300fa2cb5]
+
+2007-06-02  pm  <pm>
+
+       * configure.ac, contrib/vmlog/Makefile.am, contrib/vmlog/vmlog.c,
+       contrib/vmlog/vmlog.h, contrib/vmlog/vmlogfilter.c:
+       * contrib/vmlog/vmlogfilter.c: Added a tool that filters a vmlog log
+       file the same way as -XXfi and -XXfx do.
+
+       * contrib/vmlog/vmlog.c, contrib/vmlog/vmlog.h
+       (vmlog_thread_log_append): Made not-static.
+
+       * contrib/vmlog/Makefile.am, configure.ac: Conditional building of
+       vmlogfilter if ENABLE_VMLOG is set and regex.h present.
+       [2903e00a87aa]
+
+2007-06-01  ajordan  <ajordan>
+
+       * src/vm/signal.c:
+       * src/vm/signal.c: Added ifdefs to fix compiling with disabled
+       threads.
+       [fa34a45c2d1e]
+
+       * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/machine-instr.h, src/vm/jit/sparc64/md-abi.c,
+       src/vm/jit/sparc64/md-asm.h:
+       * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed the
+       way float arguments are preserved over codegen_start_native_call.
+       * src/vm/jit/sparc64/md-abi.c (codegen_start_native_call): Likewise.
+
+       * src/vm/jit/sparc64/machine-instr.h (compare_and_swap): Changed
+       inline assembly, so it survives gcc optimization.
+
+       * src/vm/jit/sparc64/asmpart.S (asm_patcher_wrapper): Saving and
+       restoring float return register.
+       * src/vm/jit/sparc64/md-asm.h: Likewise.
+       [02b890228951]
+
+2007-06-01  twisti  <twisti>
+
+       * m4/ac_pthreads_implementation.m4, m4/threads.m4, src/threads
+       /threads-common.c, src/threads/threads-common.h, src/vm/signal.c,
+       src/vm/vm.c:
+       * m4/ac_pthreads_implementation.m4: Reverted rev7996.
+       * m4/threads.m4: Likewise.
+
+       * src/threads/threads-common.c [__LINUX__]
+       (threads_pthreads_implementation_nptl): Added. (threads_preinit)
+       [__LINUX__]: Check which thread-implementation we are using.
+
+       * src/threads/threads-common.h [__LINUX__]
+       (threads_pthreads_implementation_nptl): Added.
+
+       * src/vm/signal.c (signal_init) [__LINUX__]: Check for
+       threads_pthreads_implementation_nptl.
+
+       * src/vm/vm.c (vm_create) [__LINUX__]: Likewise.
+       [87faa8691e61]
+
+2007-05-31  twisti  <twisti>
+
+       * src/vm/jit/mips/irix/md-os.c:
+       * src/vm/jit/mips/irix/md-os.c (vm/jit/mips/codegen.h): Added.
+       (md_signal_handler_sigsegv): Updated to new exception-handling.
+       (thread_restartcriticalsection): Renamed to
+       md_critical_section_restart.
+       [2a7547f40594]
+
+       * configure.ac, m4/ac_pthreads_implementation.m4, m4/threads.m4,
+       src/vm/signal.c, src/vm/vm.c:
+       * m4/ac_pthreads_implementation.m4: New file.
+
+       * m4/threads.m4 (AC_CHECK_ENABLE_THREADS): Call
+       AC_CHECK_PTHREADS_IMPLEMENTATION for posix and linux.
+
+       * configure.ac (AC_CHECK_HEADERS): Added stdlib.h. (AC_CHECK_FUNCS):
+       Added confstr, strstr.
+
+       * src/vm/signal.c (signal_init) [!PTHREADS_IS_LINUXTHREADS]: Only
+       block the signals if we are not on LinuxThreads. (signal_thread):
+       Set state accordingly.
+
+       * src/vm/vm.c (vm_create) [!PTHREADS_IS_LINUXTHREADS]: Only start
+       signal-thread if we are not on LinuxThreads.
+       [80c6b89148d7]
+
+       * src/vm/signal.c:
+       * src/vm/signal.c: Reverted rev7978.
+       [6e1ee16a0ebd]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_create): Added comment.
+       [3860a183b0cb]
+
+2007-05-30  twisti  <twisti>
+
+       * src/vm/jit/powerpc64/emit.c:
+       * src/vm/jit/powerpc64/emit.c (emit_branch): Removed debug output.
+       [a2b2fb137c74]
+
+       * NEWS:
+       * NEWS: Added some 0.98 release notes.
+       [c990ac936f72]
+
+       * ChangeLog, ChangeLog-2006:
+       * ChangeLog: Updated.
+       * ChangeLog-2006: New file.
+       [2eed586043b9]
+
+       * src/vm/jit/powerpc/darwin/md-os.c:
+       * src/vm/jit/powerpc/darwin/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart.
+       [948ea5d4594b]
+
+       * src/vm/jit/powerpc/asmpart.S:
+       * src/vm/jit/powerpc/asmpart.S [ENABLE_REPLACEMENT] (L_replace_me)
+       (L_replace_build_execution_state, L_replace_free_safestack): Only if
+       replacement is enabled, otherwise we get a linker error.
+       [01bba61ca238]
+
+       * src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md-
+       abi.h:
+       * src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md-
+       abi.h: Removed Contact, Authors, Changes from header.
+       [bf03068d9128]
+
+       * src/vm/signal.c:
+       * src/vm/signal.c (signal_thread) [!__DARWIN__]: Don't do the
+       GC_signum stuff on Darwin (should also be done on Solaris, but let's
+       wait how the exact-GC is doing).
+       [84f89c49bbb4]
+
+       * src/vm/builtin.c:
+       * src/vm/builtin.c (math.h): Removed because we don't need it as we
+       include fdlibm.h and it does not work on some OSs, like Darwin.
+       [bd9c55a421a3]
+
+       * src/mm/boehm-gc/pthread_stop_world.c:
+       * src/mm/boehm-gc/pthread_stop_world.c (GC_signum1, GC_signum2): No
+       it did not work, reverted rev7981.
+       [1a4919b18fd5]
+
+       * src/threads/native/threads.c, src/threads/threads-common.h:
+       * src/threads/native/threads.c (threads_impl_preinit): Initialize
+       mutex_threads_list. (threads_impl_table_init): Removed.
+       (threads_impl_table_init, threads_list_unlock): Fixed debug message.
+
+       * src/threads/threads-common.h (threads_impl_table_init): Removed.
+       [e361eaf3e9ab]
+
+       * src/vm/resolve.c:
+       * src/vm/resolve.c (resolve_subtype_check): Don't free the memory
+       before it's used.
+       [52dbef0b9bb3]
+
+       * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c:
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native): Fixed
+       typo.
+
+       * src/vm/jit/powerpc64/emit.c [!NDEBUG] (emit_verbosecall_enter)
+       (emit_verbosecall_exit): Only compile conditionally.
+       [5c9b9bf65ba8]
+
+       * src/mm/boehm-gc/pthread_stop_world.c, src/threads/native/threads.c:
+       * src/mm/boehm-gc/pthread_stop_world.c (cacao_suspendhandler):
+       Commented. (GC_suspend_handler): Commented cacao_suspendhandler
+       call. (GC_signum1, GC_signum2): Define for all configurations (hope
+       that works).
+
+       * src/threads/native/threads.c: Commented all critical-sections
+       code, as it does not work anyway and it does not compile everywhere.
+       [77e8f7fc7c33]
+
+       * src/vm/jit/powerpc64/md.c:
+       * src/vm/jit/powerpc64/md.c (md_get_method_patch_address): Use
+       vm_abort and fixed warning. (md_codegen_get_pv_from_pc): Likewise.
+       [01f38d93be79]
+
+       * src/vm/jit/powerpc64/codegen.c:
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed --disable-
+       debug build.
+       [c4fa7f33ae53]
+
+       * src/vm/signal.c:
+       * src/vm/signal.c (mm/boehm-gc/include/gc.h): Added.
+       (GC_suspend_handler): Defined. (GC_restart_handler): Likewise.
+       (signal_thread): Add the Boehm-GC signals to the mask and call the
+       appropriate Boehm-function. This is a workaround for the Boehm-
+       LinuxThreads bug.
+       [40593e6fd1fc]
+
+2007-05-29  twisti  <twisti>
+
+       * src/vm/signal.c, src/vm/signallocal.h, src/vm/vm.c:
+       * src/vm/signal.c (signal_init): Changed signature.
+       * src/vm/signallocal.h (signal_init): Likewise.
+
+       * src/vm/vm.c (vm_create): Call signal_init right after gc_init and
+       check return value.
+       [ad80c85a863f]
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/access.c,
+       src/vm/access.h:
+       * src/vm/access.c (string.h): Added. (mm/memory.h): Likewise.
+       (vmcore/field.h): Likewise. (vmcore/method.h): Likewise.
+       (access_check_member): Removed. (access_check_field): New function.
+       (access_check_method): Likewise.
+
+       * src/vm/access.h (vmcore/field.h): Added. (vmcore/method.h):
+       Likewise. (access_check_member): Removed. (access_check_field): New
+       function. (access_check_method): Likewise.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): Call
+       access_check_method instead of access_check_member.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (constructNative): Likewise.
+
+       * src/native/vm/gnu/java_lang_reflect_Field.c
+       (cacao_get_field_address): Call access_check_field instead of
+       access_check_member.
+       [bb462c48ac9e]
+
+2007-05-29  pm  <pm>
+
+       * src/vm/jit/show.c:
+       * src/vm/jit/show.c (vm/vm.h) add missing include,
+       (_no_threads_filterverbosecallctr) fix type: u2 instead of u4
+       [e78f2ffacfe6]
+
+2007-05-29  twisti  <twisti>
+
+       * src/vm/jit/powerpc64/codegen.c:
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed warnings,
+       some indent.
+       [d1845bf4f0b3]
+
+       * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/resolve.c:
+       * src/vm/exceptions.c (exceptions_throw_illegalaccessexception):
+       Changed signature.
+       * src/vm/exceptions.h: Likewise.
+
+       * src/vm/resolve.c (resolve_class_from_name): Make utf8-string out
+       of exception message. (resolve_subtype_check): Likewise.
+       (resolve_field_verifier_checks): Likewise.
+       (resolve_method_verifier_checks): Likewise.
+       [7972804c2663]
+
+2007-05-28  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/md.c:
+       * src/vm/jit/sparc64/codegen.h: Removed asserts for stores with
+       sethi.
+
+       * src/vm/jit/sparc64/codegen.c: Added code to fill with nops when a
+       patcher is right at the end of a basic block.
+
+       * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method_end): Returning 0
+       when an exception occurs.
+
+       * src/vm/jit/sparc64/md.c (md_get_method_patch_address): Improved
+       handling of mptr loads when a sethi is involved.
+       [d069ba5f06d5]
+
+2007-05-26  pm  <pm>
+
+       * contrib/vmlog/vmlog.c:
+       * contrib/vmlog/vmlog.c: Use autoconf define WORDS_BIGENDIAN to
+       determine endianess.
+       [3e68881c72bf]
+
+2007-05-25  twisti  <twisti>
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_thread_start_internal)
+       [WITH_CLASSPATH_CLDC1_1]: Set name to NULL, but this needs a fix.
+       (threads_thread_print_info) [ENABLE_JAVAME_CLDC1_1]: Set name to
+       utf_null.
+       [2dd12a05fb5c]
+
+       * src/vm/jit/optimizing/ifconv.c:
+       * src/vm/jit/optimizing/ifconv.c (vm/vm.h): Added. (ifconv_static):
+       Fixed warning, use vm_abort.
+       [bb500a776fbe]
+
+       * src/vm/jit/powerpc/md.c:
+       * src/vm/jit/powerpc/md.c (md_get_method_patch_address): Fixed
+       warning, use vm_abort.
+       [74ab9b837f4c]
+
+       * src/vm/string.c, src/vm/stringlocal.h:
+       * src/vm/string.c (javastring_new_from_utf_buffer): Made static.
+       * src/vm/stringlocal.h (javastring_new_from_utf_buffer): Removed.
+       [c65dcab97e76]
+
+2007-05-25  pm  <pm>
+
+       * configure.ac, src/threads/critical.c, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/none/threads.h,
+       src/vm/builtin.c, src/vm/jit/codegen-common.c, src/vm/jit/jit.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/s390/tests/dacapo.status,
+       src/vm/jit/show.c, src/vm/jit/show.h, src/vm/signal.c,
+       src/vm/signallocal.h, src/vm/vm.c, src/vmcore/method.h,
+       src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/jit/show.h (show_filters_init, show_filters_apply,
+       show_filters_test_verbosecall_enter,
+       show_filters_test_verbosecall_exit): Added.
+       * src/vm/jit/show.c: Likewise.
+       * src/vm/jit/jit.c (jit_compile_intern): Honour filters.
+       * src/vm/jit/codegen-common.c (codegen_add_patch_ref,
+       codegen_generate_stub_native): Honour PATCHER_LONGBRANCHES_NOPS if
+       defined, honour filters.
+       * src/vm/builtin.c (builtin_trace_exception,
+       builtin_verbosecall_enter, builtin_verbosecall_exit): Honour
+       filters.
+       * src/vm/signal.c (signal_init): Register SIGILL handler on s390.
+       * src/vm/vm.c: Handle -XXfi, -XXfe, -XXfm commandline options.
+       * src/vm/signallocal.h (md_signal_handler_sigill): Forward declare on
+       s390.
+       * src/threads/none/threads.h (_no_threads_filterverbosecallctr,
+       FILTERVERBOSECALLCTR): Added.
+       * src/threads/native/threads.h (struct threadobject): Added
+       filterverbosecallctr.
+       * src/threads/native/threads.c (threads_impl_thread_new): Initialize
+       filterverbosecallctr.
+       * src/threads/critical.c (critical_comparator): On s390, clear bit 32
+       of pointer when comparing.
+       * src/vmcore/options.h (opt_filter_verbosecall_include,
+       opt_filter_verbosecall_exclude, opt_filter_show_method): Added.
+       * src/vmcore/options.c: Likewise.
+       * src/vmcore/method.h (struct methodinfo): Added filtermatches.
+       * configure.ac: If no NDEBUG and regex.h header is present, define
+       ENABLE_DEBUG_FILTER.
+       * src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/tests/dacapo.status, src/vm/jit/s390/patcher.c:
+       Changed a lot.
+       [606e1b6afbeb]
+
+2007-05-24  michi  <michi>
+
+       * src/vmcore/linker.c:
+       * src/vmcore/linker.c (link_class_intern) [__ARM_EABI__]: Fixed
+       field alignment bug. Double and Long fields are 8-byte aligned with
+       EABI.
+       [c57105969efc]
+
+2007-05-24  twisti  <twisti>
+
+       * src/vm/jit/i386/linux/md-os.c:
+       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv): Fixed
+       warning.
+       [9841538af60f]
+
+       * src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/threads-common.c (mm/memory.h): Added.
+       (toolbox/list.h): Likewise. (threads_table): Removed. (list_threads,
+       list_threads_free): Added. (threads_preinit): Initialize lists.
+       (threads_table_init): Removed. (threads_table_add): Likewise.
+       (threads_table_remove): Likewise. (threads_table_get): Likewise.
+       (threads_table_get_threads): Likewise.
+       (threads_table_get_non_daemons): Likewise. (threads_table_first):
+       Likewise. (threads_table_next): Likewise. (threads_table_dump):
+       Likewise. (threads_list_first): New function. (threads_list_next):
+       Likewise. (threads_list_get_non_daemons): Likewise.
+       (threads_thread_new): Likewise. (threads_thread_free): Likewise.
+       (threads_thread_print_info): Added state-assert, print thread index.
+       (threads_thread_state_runnable): New function.
+       (threads_thread_state_waiting): Likewise.
+       (threads_thread_state_timed_waiting): Likewise.
+       (threads_thread_state_terminated): Likewise. (threads_dump): Use
+       threads-list functions.
+
+       * src/threads/threads-common.h: Likewise. (threads_table_entry_t):
+       Removed. (threads_table_t): Likewise.
+
+       * src/threads/native/threads.c (mutex_threads_table): Renamed to
+       mutex_threads_list. (threads_cast_sendsignals): Use threads-list
+       functions. (threads_table_lock): Renamed to threads_list_lock.
+       (threads_table_unlock): Renamed to threads_list_unlock.
+       (threads_startup_thread): Use threads-state functions.
+       (threads_detach_thread): Likewise. (threads_wait_with_timeout):
+       Likewise. (threads_join_all_threads): Use threads-list functions.
+
+       * src/threads/native/threads.h (threadobject): Added linkage.
+       [7119004b7671]
+
+2007-05-23  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/Makefile.am:
+       * src/vm/jit/sparc64/Makefile.am: Added missing emit.h.
+       [d043608db272]
+
+       * src/vm/jit/sparc64/Makefile.am:
+       * src/vm/jit/sparc64/Makefile.am: md-asm.h was not properly added to
+       noinst_HEADERS.
+       [a888e4ae3e58]
+
+2007-05-23  twisti  <twisti>
+
+       * configure.ac:
+       * configure.ac (AM_INIT_AUTOMAKE): Added dist-bzip2.
+       [b4f4c4d4a840]
+
+       * src/threads/threads-common.h:
+       * src/threads/threads-common.h (THREAD_STATE_NEW)
+       (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING)
+       (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Start states
+       with 1, so we can catch unset states.
+       [a1aa7edd50d1]
+
+       * src/vm/jit/powerpc64/linux/md-os.c:
+       * src/vm/jit/powerpc64/linux/md-os.c (md_critical_section_restart):
+       Fixed typo.
+       [5e15a6dbd074]
+
+       * src/vm/jit/mips/Makefile.am:
+       * src/vm/jit/mips/Makefile.am (DIST_SUBDIRS): Added uclinux.
+       [4dc3d033c6ec]
+
+       * src/vmcore/statistics.c:
+       * src/vmcore/statistics.c (statistics_print_memory_usage): Smaller
+       output changes.
+       [8f1740856eee]
+
+       * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/jit/arm/linux/md-os.c, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/x86_64/linux/md-os.c
+       (md_critical_section_restart): Removed debug output.
+       [ad67481e544b]
+
+       * src/threads/native/lock.c, src/threads/native/lock.h:
+       * src/threads/native/lock.c: Set Id keyword.
+       * src/threads/native/lock.h: Likewise.
+       [88a0496626f3]
+
+       * src/native/vm/gnu/java_lang_VMClassLoader.c:
+       * src/native/vm/gnu/java_lang_VMClassLoader.c (getPrimitiveClass):
+       Return NULL in error case.
+       [fbb5d46a541f]
+
+       * src/vm/jit/optimizing/profile.c:
+       * src/vm/jit/optimizing/profile.c: Set Id keyword.
+       [11900f141992]
+
+       * src/vm/jit/optimizing/profile.c:
+       * src/vm/jit/optimizing/profile.c (profile_thread): Replaced table-
+       with list-functions.
+       [ede8f3f4cb22]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_create): Use vm_abort for profile_start_thread.
+       [ed4f1df2d4de]
+
+       * src/vm/jit/jit.c:
+       * src/vm/jit/jit.c (jit_compile_intern): Fixed typo.
+       [73e13518e0df]
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_new_hardware_exception): Fixed
+       warning.
+       [679f3b09928b]
+
+       * src/vm/jit/x86_64/linux/md-os.c, src/vm/jit/x86_64/md.c:
+       * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Fixed
+       warning.
+       * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv):
+       Likewise.
+       [215c17677a9c]
+
+       * configure.ac:
+       * configure.ac (OPT_CFLAGS): Changed to -O2.
+       [a6ea45496841]
+
+       * src/vm/jit/emit-common.h, src/vm/jit/powerpc64/codegen.c:
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit): ICMD_INSTANCEOF:
+       Removed unused supervftbl.
+
+       * src/vm/jit/emit-common.h [__POWERPC64__] (emit_bnan): Enabled.
+       [8db39c7b9644]
+
+2007-05-23  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c:
+       * src/vm/jit/powerpc64/emit.c (MCODECHECK): Increase values to fix
+       canary corruption.
+       * src/vm/jit/powerpc64/codegen.c (MCODECHECK): Increase values to fix
+       canary corruption.
+       [595305514350]
+
+2007-05-23  twisti  <twisti>
+
+       * src/vmcore/linker.c:
+       * src/vmcore/linker.c (linker_compute_subclasses): We don't ship the
+       critical-section stuff with this release, since it's broken on some
+       architectures because of boehm.
+       [e817500e30d3]
+
+       * src/vm/exceptions.c, src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/vm/exceptions.c (threads/lock-common.h): Added.
+       [ENABLE_THREADS] (threads/native/threads.h): Removed.
+       [!ENABLE_THREADS] (threads/none/threads.h): Likewise. (threads
+       /threads-common.h): Added. (new_exception_message): Removed.
+       (exceptions_throw_classcircularityerror): Use
+       exceptions_throw_utf_utf. (exceptions_throw_classformaterror):
+       Likewise. (classnotfoundexception_to_noclassdeffounderror): Fixed
+       warning. (exceptions_throw_incompatibleclasschangeerror): Use
+       exceptions_throw_utf_utf. (exceptions_throw_internalerror):
+       Likewise. (exceptions_throw_unsupportedclassversionerror): Likewise.
+       (exceptions_throw_verifyerror): Likewise.
+       (exceptions_throw_verifyerror_for_stack): Likewise.
+       (exceptions_new_arithmeticexception): Likewise.
+       (exceptions_new_classcastexception): Use exceptions_new_class_utf.
+       (exceptions_print_exception): Fixed warnings.
+
+       * src/vmcore/utf8.c (utf_division_by_zero): Added. (utf8_init):
+       Likewise.
+
+       * src/vmcore/utf8.h (utf_division_by_zero): Likewise.
+       [b52c2cca5b7d]
+
+       * src/native/native.c, src/native/native.h, src/vm/exceptions.c,
+       src/vm/exceptions.h:
+       * src/vm/exceptions.c (new_exception_int): Removed.
+       * src/vm/exceptions.h (new_exception_int): Likewise.
+
+       * src/native/native.c (native_new_and_init_int): Likewise.
+       * src/native/native.h (native_new_and_init_int): Likewise.
+       [6992a69c370d]
+
+2007-05-23  michi  <michi>
+
+       * src/native/include/Makefile.am, src/native/jni.c, src/vm/global.h,
+       src/vm/jit/abi.h, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/arm/patcher.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/m68k/patcher.c, src/vm/jit/x86_64/md.c:
+       Merged revisions 7918-7939 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7926 | twisti | 2007-05-21 10:27:06 +0200 (Mon, 21 May
+       2007) | 12 lines
+
+        * src/native/jni.c (_Jv_jni_CallLongMethodA): New function.
+       (_Jv_jni_CallFloatMethodA): Likewise. (_Jv_jni_CallDoubleMethodA):
+       Likewise. (_Jv_JNI_CallStaticBooleanMethodA): Implemented.
+       (_Jv_JNI_CallStaticByteMethodA): Likewise.
+       (_Jv_JNI_CallStaticCharMethodA): Likewise.
+       (_Jv_JNI_CallStaticShortMethodA): Likewise.
+       (_Jv_JNI_CallStaticIntMethodA): Likewise.
+       (_Jv_JNI_CallStaticLongMethodA): Likewise.
+       (_Jv_JNI_CallStaticFloatMethodA): Likewise.
+       (_Jv_JNI_CallStaticDoubleMethodA): Likewise. ........ r7927 |
+       twisti | 2007-05-21 10:48:46 +0200 (Mon, 21 May 2007) | 3 lines
+
+        * src/native/include/Makefile.am (CLEANFILES): Simply clean an *.h
+       files. ........ r7929 | michi | 2007-05-21 13:45:31 +0200 (Mon, 21
+       May 2007) | 8 lines
+
+        * src/vm/jit/arm/codegen.h (M_EORLE): Added.
+
+        * src/vm/jit/arm/codegen.c (codegen_emit): Fixed superindex
+       overflow for ICMD_INSTANCEOF and ICMD_CHECKCAST.
+
+        * src/vm/jit/arm/patcher.c
+       (patcher_checkcast_instanceof_interface): Adapted patcher to above
+       changes. ........ r7930 | twisti | 2007-05-21 16:40:32 +0200 (Mon,
+       21 May 2007) | 2 lines
+
+        * src/vm/global.h (ALIGN_2): Added. ........ r7931 | twisti |
+       2007-05-21 16:42:28 +0200 (Mon, 21 May 2007) | 6 lines
+
+        * src/vm/jit/arm/md-abi.c (md_param_alloc): Use EABI internally.
+       (ALIGN_2): Removed.
+
+        * src/vm/jit/arm/codegen.c (codegen_emit): Removed SPLIT-stuff.
+         * src/vm/jit/arm/emit.c (emit_store): Likewise. ........ r7932 |
+       michi | 2007-05-22 09:00:57 +0200 (Tue, 22 May 2007) | 3 lines
+
+        * src/vm/jit/arm/md-abi.c (md_param_alloc): Align stack arguments
+       as well.
+         * src/vm/jit/arm/asmpart.S (asm_vm_call_method): Use EABI internally.
+       ........ r7933 | michi | 2007-05-22 09:21:08 +0200 (Tue, 22 May
+       2007) | 2 lines
+
+        * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Removed obsolete
+       SPLIT-stuff. ........ r7934 | michi | 2007-05-22 12:07:21 +0200
+       (Tue, 22 May 2007) | 2 lines
+
+        * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Removed
+       obsolete SPLIT-stuff. ........ r7935 | twisti | 2007-05-22
+       13:18:15 +0200 (Tue, 22 May 2007) | 3 lines
+
+        * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Replaced
+       assert with vm_abort. ........ r7938 | tbfg | 2007-05-23 11:37:37
+       +0200 (Wed, 23 May 2007) | 5 lines
+
+        * src/vm/jit/abi.h (abi_registers_address_name): Added.
+       (abi_registers_address_argument): Likewise.
+       (abi_registers_address_saved): Likewise.
+       (abi_registers_address_temporary): Likewise. ........ r7939 | tbfg
+       | 2007-05-23 11:40:05 +0200 (Wed, 23 May 2007) | 13 lines
+
+        * src/vm/jit/m68k/codegen.c (codegen_emit): Remove NOP after each
+       ICMD. Add NOP generation at end of basci block when patcher is
+       longer than instruction to be patched.
+
+        * src/vm/jit/m68k/patcher.c (patcher_get_putfield): Implemented.
+
+        * src/vm/jit/m68k/codegen.h (COMPILERSTUB_CODESIZE): Correct
+       value.
+
+        * src/vm/jit/codegen-common.c (codegen_increase): Enable NOP after
+       patcher generation at end of basic block. ........
+       [5e9239c03966]
+
+2007-05-23  tbfg  <tbfg>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/patcher.c:
+       * src/vm/jit/m68k/codegen.c (codegen_emit): Remove NOP after each
+       ICMD. Add NOP generation at end of basci block when patcher is
+       longer than instruction to be patched.
+
+       * src/vm/jit/m68k/patcher.c (patcher_get_putfield): Implemented.
+
+       * src/vm/jit/m68k/codegen.h (COMPILERSTUB_CODESIZE): Correct value.
+
+       * src/vm/jit/codegen-common.c (codegen_increase): Enable NOP after
+       patcher generation at end of basic block.
+       [c06959f336b9]
+
+       * src/vm/jit/abi.h:
+       * src/vm/jit/abi.h (abi_registers_address_name): Added.
+       (abi_registers_address_argument): Likewise.
+       (abi_registers_address_saved): Likewise.
+       (abi_registers_address_temporary): Likewise.
+       [3c252b5dfa38]
+
+2007-05-23  michi  <michi>
+
+       * src/vm/jit/stacktrace.h:
+       * src/vm/jit/stacktrace.h (stackframeinfo) [ENABLE_GC_CACAO]: Added
+       adrregs for HAS_ADDRESS_REGISTER_FILE architectures.
+       [30fcc084af90]
+
+2007-05-22  michi  <michi>
+
+       * src/vm/builtintable.inc, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/arm/patcher.c, src/vm/jit/x86_64/md.c:
+       * src/vm/builtintable.inc (builtintable_internal): Enabled builtin
+       stubs for ICMD_NEWARRAY and ICMD_ANEWARRAY.
+       [4f994b75bad7]
+
+2007-05-22  twisti  <twisti>
+
+       * src/vm/jit/x86_64/md.c:
+       * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Replaced
+       assert with vm_abort.
+       [1753c1c0dfb9]
+
+2007-05-22  michi  <michi>
+
+       * src/vm/jit/arm/codegen.c:
+       * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Removed
+       obsolete SPLIT-stuff.
+       [cbbe265fb1ac]
+
+       * src/vm/jit/arm/emit.c:
+       * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Removed obsolete
+       SPLIT-stuff.
+       [d78bb0141f66]
+
+       * src/vm/jit/arm/asmpart.S, src/vm/jit/arm/md-abi.c:
+       * src/vm/jit/arm/md-abi.c (md_param_alloc): Align stack arguments as
+       well.
+       * src/vm/jit/arm/asmpart.S (asm_vm_call_method): Use EABI internally.
+       [3942d11bd5a8]
+
+2007-05-21  twisti  <twisti>
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/arm/md-
+       abi.c:
+       * src/vm/jit/arm/md-abi.c (md_param_alloc): Use EABI internally.
+       (ALIGN_2): Removed.
+
+       * src/vm/jit/arm/codegen.c (codegen_emit): Removed SPLIT-stuff.
+       * src/vm/jit/arm/emit.c (emit_store): Likewise.
+       [9a3a5bb37f48]
+
+       * src/vm/global.h:
+       * src/vm/global.h (ALIGN_2): Added.
+       [63d9afde94b7]
+
+2007-05-21  michi  <michi>
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h,
+       src/vm/jit/arm/patcher.c:
+       * src/vm/jit/arm/codegen.h (M_EORLE): Added.
+
+       * src/vm/jit/arm/codegen.c (codegen_emit): Fixed superindex overflow
+       for ICMD_INSTANCEOF and ICMD_CHECKCAST.
+
+       * src/vm/jit/arm/patcher.c (patcher_checkcast_instanceof_interface):
+       Adapted patcher to above changes.
+       [9d9deb8bb043]
+
+       * src/mm/cacao-gc/mark.c, src/native/include/Makefile.am:
+       * src/mm/cacao-gc/mark.c (mark_me): Ifdefed statistics assertion.
+       [5c577e7dc152]
+
+2007-05-21  twisti  <twisti>
+
+       * src/native/include/Makefile.am:
+       * src/native/include/Makefile.am (CLEANFILES): Simply clean an *.h
+       files.
+       [5a05843da368]
+
+       * src/native/jni.c, src/native/jni.h:
+       * src/native/jni.c (_Jv_jni_CallLongMethodA): New function.
+       (_Jv_jni_CallFloatMethodA): Likewise. (_Jv_jni_CallDoubleMethodA):
+       Likewise. (_Jv_JNI_CallStaticBooleanMethodA): Implemented.
+       (_Jv_JNI_CallStaticByteMethodA): Likewise.
+       (_Jv_JNI_CallStaticCharMethodA): Likewise.
+       (_Jv_JNI_CallStaticShortMethodA): Likewise.
+       (_Jv_JNI_CallStaticIntMethodA): Likewise.
+       (_Jv_JNI_CallStaticLongMethodA): Likewise.
+       (_Jv_JNI_CallStaticFloatMethodA): Likewise.
+       (_Jv_JNI_CallStaticDoubleMethodA): Likewise.
+       [2d2693b5fc01]
+
+2007-05-21  michi  <michi>
+
+       * src/vm/jit/i386/linux/md-os.c:
+       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigusr1): This
+       function is no longer GC-specific, removed assertion.
+       [06b76ff22ce6]
+
+       * src/mm/cacao-gc/heap.c, src/mm/cacao-gc/mark.c, src/mm/cacao-
+       gc/rootset.c, src/mm/cacao-gc/rootset.h:
+       * src/mm/cacao-gc/rootset.c (rootset_from_globals): Uses registered
+       references instead of Cacao-internal structures now.
+       (rootset_readout) [ENABLE_THREADS]: Adapted to new threads table.
+
+       * src/mm/cacao-gc/rootset.h: Minor changes.
+       * src/mm/cacao-gc/heap.c: Likewise.
+       * src/mm/cacao-gc/mark.c: Likewise.
+       [efe66624fb2e]
+
+2007-05-20  michi  <michi>
+
+       * src/cacaoh/dummy.c, src/threads/threads-common.c,
+       src/vmcore/linker.c:
+       * src/threads/threads-common.c (threads_thread_new)
+       [ENABLE_GC_CACAO]: Initialize GC-specific field.
+       (threads_thread_start_internal): Register reference with the GC.
+       (threads_thread_start): Likewise.
+
+       * src/vmcore/linker.c: Functions are now called threads_stopworld
+       and threads_startworld.
+
+       * src/cacaoh/dummy.c: Likewise.
+       [c75b79edb8ef]
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c: Major fix after messed up merge from
+       trunk, sorry for not beeing more precise here.
+       [946bdd0b169e]
+
+       * src/cacaoh/dummy.c, src/native/jni.c, src/native/jni.h,
+       src/vmcore/loader.c, src/vmcore/loader.h:
+       * src/cacaoh/dummy.c (gc_reference_register): Added.
+
+       * src/vmcore/loader.c (hashtable_classloader): Made it static again.
+       (loader_hashtable_classloader_add) [ENABLE_GC_CACAO]: Registers
+       reference with the GC.
+
+       * src/native/jni.c (hashtable_global_ref): Made it static again.
+       (_Jv_JNI_NewGlobalRef) [ENABLE_GC_CACAO]: Registers reference with
+       the GC. (_Jv_JNI_DeleteGlobalRef) [ENABLE_GC_CACAO]: Unregisters
+       above reference.
+       [7ea5ce46fe14]
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/gc-common.h:
+       * src/mm/gc-common.h (gc_reference_register,
+       gc_reference_unregister): Added prototypes.
+
+       * src/mm/cacao-gc/gc.h (list_gcref_entry_t): Added.
+
+       * src/mm/cacao-gc/gc.c (gc_reflist): Added. (gc_reference_register):
+       Implemented.
+       [8bc119ebad52]
+
+       * src/mm/cacao-gc/final.c, src/mm/cacao-gc/final.h:
+       * src/mm/cacao-gc/final.h: Renamed final_entry to
+       list_final_entry_t.
+       * src/mm/cacao-gc/final.c: Likewise.
+       [33e5ba33c62c]
+
+       * .cvsignore, configure.ac, contrib/.cvsignore,
+       contrib/check_dangerous_printf.pl, doc/.cvsignore,
+       doc/handbook/.cvsignore, man/.cvsignore, src/.cvsignore,
+       src/cacao/.cvsignore, src/cacaoh/.cvsignore, src/cacaoh/dummy.c,
+       src/fdlibm/.cvsignore, src/lib/.cvsignore, src/lib/Makefile.am,
+       src/lib/vm/reference/gnu/classpath/VMStackWalker.java,
+       src/lib/vm/reference/gnu/classpath/VMSystemProperties.java, src/lib/
+       vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java, src/l
+       ib/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/lib/vm/reference/java/lang/VMClassLoader.java,
+       src/lib/vm/reference/java/lang/VMString.java,
+       src/lib/vm/reference/java/lang/VMThread.java,
+       src/lib/vm/reference/java/lang/VMThrowable.java,
+       src/lib/vm/reference/java/security/VMAccessController.java,
+       src/mm/.cvsignore, src/mm/boehm-gc/.cvsignore, src/mm/boehm-
+       gc/doc/.cvsignore, src/mm/boehm-gc/include/.cvsignore, src/mm/boehm-
+       gc/include/gc.h, src/mm/cacao-gc/.cvsignore, src/mm/memory.c,
+       src/mm/memory.h, src/native/.cvsignore,
+       src/native/include/.cvsignore, src/native/jni.c,
+       src/native/jvmti/.cvsignore, src/native/native.c,
+       src/native/native.h, src/native/tools/.cvsignore,
+       src/native/vm/.cvsignore, src/native/vm/Makefile.am,
+       src/native/vm/cldc1.1/.cvsignore,
+       src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
+       src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Double.c,
+       src/native/vm/cldc1.1/java_lang_Float.c,
+       src/native/vm/cldc1.1/java_lang_Math.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_Runtime.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_System.c,
+       src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/cldc1.1/java_lang_Throwable.c,
+       src/native/vm/gnu/.cvsignore,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, src/native/vm/
+       gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/java_lang_reflect_VMProxy.c,
+       src/native/vm/gnu/java_security_VMAccessController.c,
+       src/native/vm/gnu/sun_misc_Unsafe.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Runtime.c,
+       src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h,
+       src/scripts/.cvsignore, src/threads/.cvsignore,
+       src/threads/Makefile.am, src/threads/critical.c,
+       src/threads/critical.h, src/threads/native/.cvsignore,
+       src/threads/native/lock.c, src/threads/native/lock.h,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/none/.cvsignore, src/threads/none/lock.h, src/threads
+       /threads-common.c, src/threads/threads-common.h,
+       src/toolbox/.cvsignore, src/toolbox/avl.c, src/toolbox/avl.h,
+       src/toolbox/hashtable.c, src/toolbox/list.c, src/toolbox/list.h,
+       src/toolbox/worklist.c, src/toolbox/worklist.h, src/vm/.cvsignore,
+       src/vm/Makefile.am, src/vm/builtin.c, src/vm/finalizer.c,
+       src/vm/initialize.c, src/vm/jit/.cvsignore,
+       src/vm/jit/allocator/.cvsignore, src/vm/jit/alpha/.cvsignore,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/alpha/freebsd/.cvsignore,
+       src/vm/jit/alpha/linux/.cvsignore, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/arm/.cvsignore, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/.cvsignore,
+       src/vm/jit/arm/linux/md-os.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/codegen-common.h, src/vm/jit/dseg.h, src/vm/jit/emit-
+       common.h, src/vm/jit/i386/.cvsignore, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/darwin/.cvsignore, src/vm/jit/i386/darwin/md-os.c,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/freebsd/.cvsignore,
+       src/vm/jit/i386/linux/.cvsignore, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/inline/.cvsignore, src/vm/jit/inline/Makefile.am,
+       src/vm/jit/inline/inline.c, src/vm/jit/inline/inline.h,
+       src/vm/jit/intrp/.cvsignore, src/vm/jit/jit.c,
+       src/vm/jit/loop/.cvsignore, src/vm/jit/m68k/arch.h,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/linux/md-os.h, src/vm/jit/m68k/machine-instr.h,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/mips/.cvsignore, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/irix/.cvsignore,
+       src/vm/jit/mips/linux/.cvsignore, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/optimizing/.cvsignore,
+       src/vm/jit/optimizing/dominators.c, src/vm/jit/optimizing/graph.c,
+       src/vm/jit/optimizing/graph.h, src/vm/jit/optimizing/lifetimes.c,
+       src/vm/jit/optimizing/lifetimes.h, src/vm/jit/optimizing/lsra.c,
+       src/vm/jit/optimizing/lsra.h, src/vm/jit/optimizing/profile.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/optimizing/ssa.c,
+       src/vm/jit/optimizing/ssa.h, src/vm/jit/parisc/.cvsignore,
+       src/vm/jit/parisc/linux/.cvsignore, src/vm/jit/parse.c,
+       src/vm/jit/patcher.h, src/vm/jit/powerpc/.cvsignore,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/.cvsignore,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/.cvsignore,
+       src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc/netbsd/.cvsignore,
+       src/vm/jit/powerpc64/.cvsignore, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/linux/.cvsignore, src/vm/jit/powerpc64/linux
+       /md-os.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/.cvsignore, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/disass.c,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390
+       /machine-instr.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md-
+       abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/schedule/.cvsignore,
+       src/vm/jit/show.c, src/vm/jit/sparc64/.cvsignore,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/linux/.cvsignore, src/vm/jit/sparc64/linux/md-
+       os.c, src/vm/jit/sparc64/machine-instr.h, src/vm/jit/sparc64/md-
+       abi.c, src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md-asm.h,
+       src/vm/jit/sparc64/solaris/.cvsignore, src/vm/jit/sparc64/solaris
+       /md-os.c, src/vm/jit/stack.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/tools/.cvsignore, src/vm/jit/verify/.cvsignore,
+       src/vm/jit/x86_64/.cvsignore, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/freebsd/.cvsignore,
+       src/vm/jit/x86_64/linux/.cvsignore, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/signal.c, src/vm/string.c, src/vm/vm.c,
+       src/vmcore/.cvsignore, src/vmcore/class.c, src/vmcore/classcache.c,
+       src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/statistics.c,
+       src/vmcore/statistics.h, src/vmcore/suck.c, src/vmcore/utf8.c,
+       tests/.cvsignore, tests/Makefile.am, tests/regression/.cvsignore,
+       tests/regression/codepatching/.cvsignore,
+       tests/regression/native/.cvsignore, tests/stack/.cvsignore:
+       Merged revisions 7797-7917 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7799 | twisti | 2007-04-24 01:03:31 +0200 (Tue, 24 Apr
+       2007) | 4 lines
+
+        * configure.ac: Removed --enable-threads checks and call instead
+       AC_CHECK_ENABLE_THREADS.
+         * m4/threads.m4: New file. ........ r7800 | twisti | 2007-04-24
+       01:39:11 +0200 (Tue, 24 Apr 2007) | 2 lines
+
+        * .cvsignore: Removed. ........ r7801 | twisti | 2007-04-24
+       01:51:37 +0200 (Tue, 24 Apr 2007) | 74 lines
+
+        * contrib/.cvsignore, doc/.cvsignore, doc/handbook/.cvsignore,
+       man/.cvsignore, src/.cvsignore, src/cacao/.cvsignore,
+       src/cacaoh/.cvsignore, src/fdlibm/.cvsignore,
+       src/lib/.cvsignore, src/mm/.cvsignore, src/mm/boehm-
+       gc/.cvsignore, src/mm/boehm-gc/doc/.cvsignore, src/mm/boehm-
+       gc/include/.cvsignore, src/mm/cacao-gc/.cvsignore,
+       src/native/.cvsignore, src/native/include/.cvsignore,
+       src/native/jvmti/.cvsignore, src/native/tools/.cvsignore,
+       src/native/vm/.cvsignore, src/native/vm/cldc1.1/.cvsignore,
+       src/native/vm/gnu/.cvsignore, src/scripts/.cvsignore,
+       src/threads/.cvsignore, src/threads/none/.cvsignore,
+       src/threads/posix/.cvsignore, src/toolbox/.cvsignore,
+       src/vm/.cvsignore, src/vm/jit/.cvsignore,
+       src/vm/jit/allocator/.cvsignore, src/vm/jit/alpha/.cvsignore,
+       src/vm/jit/alpha/freebsd/.cvsignore,
+       src/vm/jit/alpha/linux/.cvsignore, src/vm/jit/arm/.cvsignore,
+       src/vm/jit/arm/linux/.cvsignore, src/vm/jit/i386/.cvsignore,
+       src/vm/jit/i386/cygwin/.cvsignore,
+       src/vm/jit/i386/darwin/.cvsignore,
+       src/vm/jit/i386/freebsd/.cvsignore,
+       src/vm/jit/i386/linux/.cvsignore, src/vm/jit/inline/.cvsignore,
+       src/vm/jit/intrp/.cvsignore, src/vm/jit/loop/.cvsignore,
+       src/vm/jit/m68k/.cvsignore, src/vm/jit/m68k/linux/.cvsignore,
+       src/vm/jit/mips/.cvsignore, src/vm/jit/mips/irix/.cvsignore,
+       src/vm/jit/mips/linux/.cvsignore,
+       src/vm/jit/optimizing/.cvsignore, src/vm/jit/parisc/.cvsignore,
+       src/vm/jit/parisc/linux/.cvsignore, src/vm/jit/powerpc/.cvsignore,
+       src/vm/jit/powerpc/darwin/.cvsignore,
+       src/vm/jit/powerpc/linux/.cvsignore,
+       src/vm/jit/powerpc/netbsd/.cvsignore,
+       src/vm/jit/powerpc64/.cvsignore,
+       src/vm/jit/powerpc64/linux/.cvsignore, src/vm/jit/s390/.cvsignore,
+       src/vm/jit/schedule/.cvsignore, src/vm/jit/sparc64/.cvsignore,
+       src/vm/jit/sparc64/linux/.cvsignore,
+       src/vm/jit/sparc64/solaris/.cvsignore,
+       src/vm/jit/tools/.cvsignore, src/vm/jit/verify/.cvsignore,
+       src/vm/jit/x86_64/.cvsignore,
+       src/vm/jit/x86_64/freebsd/.cvsignore,
+       src/vm/jit/x86_64/linux/.cvsignore, src/vmcore/.cvsignore,
+       tests/.cvsignore, tests/regression/.cvsignore,
+       tests/regression/codepatching/.cvsignore,
+       tests/regression/jasmin/.cvsignore,
+       tests/regression/native/.cvsignore, tests/stack/.cvsignore:
+       Removed. ........ r7802 | tbfg | 2007-04-24 12:20:05 +0200 (Tue,
+       24 Apr 2007) | 2 lines
+
+        * threads.m4: Fixed a typo ........ r7803 | twisti | 2007-04-24
+       16:23:40 +0200 (Tue, 24 Apr 2007) | 3 lines
+
+        * src/threads/threads-common.c (threads_dump): Also print integer
+       thread id, so it's easier to compare with the ones from gdb.
+       ........ r7804 | twisti | 2007-04-24 16:29:20 +0200 (Tue, 24 Apr
+       2007) | 3 lines
+
+        * src/threads/threads-common.c: Set Id keyword.
+         * src/threads/threads-common.h: Likewise. ........ r7805 | twisti |
+       2007-04-25 13:47:15 +0200 (Wed, 25 Apr 2007) | 12 lines
+
+        * src/threads/threads-common.c (threads_create_thread)
+       [ENABLE_GC_BOEHM]: Use GCNEW_UNCOLLECTABLE.
+       (threads_start_javathread) [ENABLE_GC_BOEHM]: Likewise.
+
+        * src/threads/native/threads.c (threads_preinit)
+       [ENABLE_GC_BOEHM]: Likewise. (threads_init): Removed resizing-
+       of-threadobject code, we don't need it anymore.
+       (threads_attach_current_thread) [ENABLE_GC_BOEHM]: Use
+       GCNEW_UNCOLLECTABLE. (threads_detach_thread) [ENABLE_GC_BOEHM]:
+       Use GCFREE. ........ r7806 | twisti | 2007-04-25 13:54:32 +0200
+       (Wed, 25 Apr 2007) | 3 lines
+
+        * src/threads/native/threads.c (threads_init): Use variable t
+       instead of mainthreadobj->object, makes code simpler. ........
+       r7807 | twisti | 2007-04-25 16:24:18 +0200 (Wed, 25 Apr 2007) | 3
+       lines
+
+        * contrib: Ignore TAGS.
+         * contrib/vmlog: Likewise. ........ r7808 | twisti | 2007-04-25
+       17:12:20 +0200 (Wed, 25 Apr 2007) | 6 lines
+
+        * src/native/native.c (native/include/java_lang_Object.h): Include
+       always. [ENABLE_JAVAME_CLDC1_1]
+       (native/include/com_sun_cldc_io_ResourceInputStream.h)
+       (native/include/com_sun_cldc_io_j2me_socket_Protocol.h): Added.
+       ........ r7809 | twisti | 2007-04-25 17:14:34 +0200 (Wed, 25 Apr
+       2007) | 3 lines
+
+        * src/threads/native/threads.c (threads_preinit): We always need
+       variable t. ........ r7810 | stefan | 2007-04-25 18:39:03 +0200
+       (Wed, 25 Apr 2007) | 2 lines
+
+        * src/vmcore/linker.c (linker_init): added missing
+       lock_init_object_lock. ........ r7811 | twisti | 2007-04-25
+       20:33:30 +0200 (Wed, 25 Apr 2007) | 23 lines
+
+        * src/threads/threads-common.c (threads_create_thread): Renamed to
+       threads_thread_create_internal and a new function.
+       (threads_start_javathread): Use threads_create_thread.
+
+        * src/threads/threads-common.h (threads_create_thread): Changed
+       signature. (threads_thread_create_internal): Added.
+
+        * src/threads/native/threads.c (threads_set_current_threadobject):
+       Made non-static. (threads_init_threadobject): Likewise, use
+       threads_create_thread. (threads_init): Cleanup.
+       (threads_startup_thread): Likewise.
+       (threads_attach_current_thread): Use threads_create_thread.
+
+        * src/vm/jit/optimizing/profile.c (profile_start_thread): Replaced
+       threads_create_thread with threads_thread_create_internal.
+         * src/vm/jit/optimizing/recompile.c (recompile_start_thread):
+       Likewise.
+         * src/vm/signal.c (signal_start_thread): Likewise.
+         * src/vm/finalizer.c (finalizer_start_thread): Likewise.
+         * src/mm/memory.c (memory_start_thread): Likewise. ........ r7812 |
+       twisti | 2007-04-25 20:51:03 +0200 (Wed, 25 Apr 2007) | 2 lines
+
+        * src/mm/memory.h: Updated copyright header. ........ r7813 |
+       twisti | 2007-04-25 21:20:13 +0200 (Wed, 25 Apr 2007) | 35 lines
+
+        * src/threads/lock-common.h: New file.
+
+        * src/threads/native/lock.h: Removed function prototypes.
+         * src/threads/none/lock.h (LOCK_INIT_OBJECT_LOCK): Added.
+
+        * src/mm/memory.c, src/native/jni.c, src/native/native.c,
+       src/native/vm/java_lang_Object.c,
+       src/native/vm/java_lang_Thread.c, src/threads/Makefile.am,
+       src/threads/native/threads.c, src/threads/threads-common.c,
+       src/toolbox/avl.c, src/toolbox/hashtable.c, src/toolbox/list.c,
+       src/vm/builtin.c, src/vm/finalizer.c, src/vm/initialize.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/jit.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c,
+       src/vm/jit/patcher.h, src/vm/jit/show.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/string.c, src/vmcore/class.c, src/vmcore/classcache.c,
+       src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/suck.c,
+       src/vmcore/utf8.c: Updated headers. ........ r7814 | twisti |
+       2007-04-25 21:36:15 +0200 (Wed, 25 Apr 2007) | 3 lines
+
+        * src/vm/jit/powerpc/linux/md-abi.c
+       (abi_registers_float_temporary): Fixed number of registers.
+       ........ r7815 | twisti | 2007-04-25 21:37:11 +0200 (Wed, 25 Apr
+       2007) | 3 lines
+
+        * src/vm/jit/powerpc/codegen.c: Fixed lock include.
+         * src/vm/jit/powerpc/emit.c: Likewise. ........ r7816 | twisti |
+       2007-04-25 21:38:46 +0200 (Wed, 25 Apr 2007) | 2 lines
+
+        * src/vm/jit/powerpc/emit.c: Set Id keyword. ........ r7817 |
+       twisti | 2007-04-25 21:42:50 +0200 (Wed, 25 Apr 2007) | 3 lines
+
+        * src/vm/jit/powerpc64/codegen.c: Changed lock includes.
+         * src/vm/jit/powerpc64/emit.c: Likewise. ........ r7818 | twisti |
+       2007-04-25 21:47:50 +0200 (Wed, 25 Apr 2007) | 3 lines
+
+        * src/vm/jit/i386/codegen.c: Changed lock include.
+         * src/vm/jit/i386/emit.c: Likewise. ........ r7819 | twisti |
+       2007-04-25 21:54:01 +0200 (Wed, 25 Apr 2007) | 3 lines
+
+        * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Use
+       md->params to save and restore argument registers. ........ r7820
+       | twisti | 2007-04-25 21:55:34 +0200 (Wed, 25 Apr 2007) | 3 lines
+
+        * src/vm/jit/alpha/codegen.c: Changed lock include.
+         * src/vm/jit/alpha/emit.c: Likewise. ........ r7821 | twisti |
+       2007-04-25 21:56:30 +0200 (Wed, 25 Apr 2007) | 2 lines
+
+        * src/vm/jit/alpha/emit.c: Set Id keyword. ........ r7822 |
+       twisti | 2007-04-25 22:02:14 +0200 (Wed, 25 Apr 2007) | 5 lines
+
+        * src/vm/jit/arm/emit.c (emit_load): Use switch-case instead of
+       if-else contruct. (emit_store): Likewise. (emit_copy): Likewise.
+       ........ r7823 | twisti | 2007-04-25 22:03:04 +0200 (Wed, 25 Apr
+       2007) | 3 lines
+
+        * src/vm/jit/arm/codegen.c: Changed lock include.
+         * src/vm/jit/arm/emit.c: Likewise. ........ r7824 | twisti |
+       2007-04-25 22:07:37 +0200 (Wed, 25 Apr 2007) | 3 lines
+
+        * src/vm/jit/mips/codegen.c: Changed lock includes.
+         * src/vm/jit/mips/emit.c: Likewise. ........ r7825 | twisti |
+       2007-04-25 22:31:57 +0200 (Wed, 25 Apr 2007) | 11 lines
+
+        * src/threads/threads-common.c (threads_start_javathread): Changed
+       signature.
+
+        * src/threads/lock-common.h (threads/threads-common.h): Added.
+       [ENABLE_THREADS]: Only define functions when threads are enabled.
+
+        * src/threads/threads-common.h
+       (native/include/java_lang_Thread.h): Removed. [ENABLE_THREADS]:
+       Only define functions when threads are enabled.
+       (threads_start_javathread): Changed signature. ........ r7826 |
+       twisti | 2007-04-25 22:56:16 +0200 (Wed, 25 Apr 2007) | 3 lines
+
+        * src/threads/threads-common.c (threads_dump) [!SIZEOF_VOID_P ==
+       8]: Fixed warning. ........ r7827 | twisti | 2007-04-25 23:03:44
+       +0200 (Wed, 25 Apr 2007) | 6 lines
+
+        * src/threads/lock-common.h (threads/threads-common.h): Removed
+       that header again and added a comment about not including thread
+       headers.
+
+        * src/threads/threads-common.c (threads_start_javathread):
+       Reverted.
+         * src/threads/threads-common.h (threads_start_javathread): Likewise.
+       ........ r7828 | stefan | 2007-04-25 23:23:57 +0200 (Wed, 25 Apr
+       2007) | 3 lines
+
+        * src/vm/jit/i386/darwin/md-os.c: attempt at porting the exception
+       changes (see r7596 & r7648). ........ r7829 | stefan |
+       2007-04-25 23:47:00 +0200 (Wed, 25 Apr 2007) | 3 lines
+
+        * src/vm/jit/i386/darwin/md-os.c: added threads/threads-common.h,
+       removed vm/jit/i386/md-abi.h ........ r7830 | twisti | 2007-04-26
+       13:14:39 +0200 (Thu, 26 Apr 2007) | 28 lines
+
+        * src/threads/threads-common.c (threads/critical.h): Added.
+       (threads/native/threads.h): Removed. (threads_table): Added.
+       (threads_preinit): New function. (threads_table_init): Moved from
+       implementation file. (threads_table_add): Likewise.
+       (threads_table_remove): Likewise. (threads_table_dump): Likewise.
+
+        * src/threads/threads-common.h (threads_table_entry_t)
+       (threads_table_t): Added. (threads_preinit): Likewise.
+       (threads_table_add): Likewise. (threads_table_remove): Likewise.
+       (threads_impl_preinit): Likewise. (threads_init_threadobject):
+       Likewise.
+
+        * src/threads/native/threads.c (threads_table): Removed.
+       (threads_preinit): Renamed to threads_impl_preinit.
+       (threads_table_init): Removed. (threads_table_add): Likewise.
+       (threads_table_remove): Likewise. (threads_table_dump): Likewise.
+
+        * src/threads/native/threads.h (threads_table_entry_t)
+       (threads_table_t): Removed. (threads_preinit): Likewise. ........
+       r7831 | twisti | 2007-04-26 14:48:16 +0200 (Thu, 26 Apr 2007) | 23
+       lines
+
+        * src/threads/threads-common.c (threads_thread_create_internal):
+       Renamed to threads_thread_start_internal and start the thread.
+       (threads_start_javathread): Renamed to threads_thread_start.
+         * src/threads/threads-common.h: Likewise.
+
+        * src/threads/native/threads.c (threads_start_thread): Renamed to
+       threads_impl_thread_start.
+
+        * src/mm/memory.c (thread_memory): Removed.
+       (memory_start_thread): Call threads_thread_start_internal.
+
+        * src/vm/finalizer.c (thread_finalizer): Removed.
+       (finalizer_start_thread): Call threads_thread_start_internal.
+
+        * src/vm/signal.c (thread_signal): Removed.
+       (signal_start_thread): Call threads_thread_start_internal.
+
+        * src/vm/jit/optimizing/profile.c (thread_profile): Removed.
+       (profile_start_thread): Call threads_thread_start_internal.
+
+        * src/vm/jit/optimizing/recompile.c (thread_recompile): Removed.
+       (recompile_start_thread): Call threads_thread_start_internal.
+       ........ r7832 | twisti | 2007-04-26 15:06:16 +0200 (Thu, 26 Apr
+       2007) | 3 lines
+
+        * src/native/vm/java_lang_Thread.c (start): Renamed
+       threads_start_javathread to threads_thread_start. ........ r7833 |
+       twisti | 2007-04-26 15:07:05 +0200 (Thu, 26 Apr 2007) | 2 lines
+
+        * src/native/vm/java_lang_Thread.c: Set Id keyword. ........
+       r7834 | twisti | 2007-04-26 15:32:08 +0200 (Thu, 26 Apr 2007) | 3
+       lines
+
+        * src/vm/vm.c [ENABLE_THREADS] (threads/native/threads.h):
+       Removed. (threads/threads-common.h): Added. ........ r7835 |
+       twisti | 2007-04-26 15:43:08 +0200 (Thu, 26 Apr 2007) | 7 lines
+
+        * src/vm/jit/inline/inline.h (config.h): Added. (inline_inline):
+       Likewise.
+
+        * src/vm/jit/jit.c (threads/threads-common.h): Added.
+       [ENABLE_INLINING] (vm/jit/inline/inline.h): Likewise.
+       [ENABLE_THREADS] (threads/native/threads.h): Removed. ........
+       r7836 | ajordan | 2007-04-27 03:37:06 +0200 (Fri, 27 Apr 2007) | 9
+       lines
+
+        * src/vm/jit/sparc64/emit.c: Keeping stack 16-byte aligned when
+       calling C/native functions from the stack. (Solaris requires this)
+         * src/vm/jit/sparc64/codegen.c: Likewise.
+         * src/vm/jit/sparc64/codegen.h: Likewise.
+
+        * src/vm/jit/sparc64/md-abi.c: Removed zero sized abi_register_*
+       arrays. (not allowed in ISO C)
+
+        * src/vm/jit/sparc64/solaris/md-os.c: Preliminary hardware
+       exception handling. (untested) ........ r7837 | tbfg | 2007-04-27
+       10:43:06 +0200 (Fri, 27 Apr 2007) | 27 lines
+
+        * src/vm/jit/m68k/emit.c (emit_arrayindexoutofbounds_check):
+       Fixed.
+         * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill): AIOOB
+       fixed. Editor boiler plate added.
+
+        * src/vm/jit/m68k/linux/md-os.h: Editor boiler plate.
+
+        * src/vm/jit/m68k/linux/md-abi.c: Likewise.
+
+        * src/vm/jit/m68k/md.c: Likewise.
+
+        * src/vm/jit/m68k/machine-instr.h: Likewise.
+
+        * src/vm/jit/m68k/patcher.c: Editor boiler plate.
+       (patcher_invokeinterface): Implemented. (patcher_get_putfield):
+       Implemented. (patcher_resolve_class): Implemented.
+       (patcher_get_putstatic): Implemented.
+
+        * src/vm/jit/m68k/codegen.c: Editor boiler plate.
+       (ICMD_GETSTATIC): Added patcher. (ICMD_AASTORE): Fixed.
+
+        * src/vm/jit/m68k/asmpart.S: Editor boiler plate.
+       (asm_vm_call_method_exception_handler): Fixed used register.
+       Return values in %d0 and %a0 as gcc sometimes expects pointers in
+       %a0. ........ r7838 | ajordan | 2007-04-28 14:59:58 +0200 (Sat, 28
+       Apr 2007) | 3 lines
+
+        * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Fixed
+       stack alignement in first save. ........ r7839 | pm | 2007-04-30
+       00:46:56 +0200 (Mon, 30 Apr 2007) | 15 lines
+
+        * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/emit.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/machine-instr.h,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/md-asm.h, src/vm/jit/s390/disass.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/md-abi.c: Adapted S390 port to changes from
+       branches/twisti (hardware exceptions, emit_branch, abi_registers_*),
+       jctest works again. Cleaned up almost all dead x86_64 code. ........
+       r7840 | tbfg | 2007-04-30 12:53:13 +0200 (Mon, 30 Apr 2007) | 31
+       lines
+
+        * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Fixed.
+       (emit_arithmetic_check): Implemented.
+
+        * src/vm/jit/m68k/md.c (md_get_method_patch_address): Changed
+       invoking register. (md_stacktrace_get_returnaddress): Fix for
+       linking words on stack.
+
+        * src/vm/jit/m68k/codegen.c (IUSHRCONST): Fix. (ICMD_IOR):
+       Implemented. (ICMD_IORCONST): Likewise. (ICMD_IXOR): Likewise.
+       (ICMD_IXORCONST): Likewise. (ICMD_INVOKEVIRTUAL): Changed invoking
+       register. (ICMD_INVOKEINTERFACE): Likewise.
+
+        * src/vm/jit/m68k/patcher.c (patcher_invokevirtual): Changed
+       invoking register.
+
+        * src/vm/jit/m68k/asmpart.S
+       (asm_vm_call_method_exception_handler): Proper stack restauration.
+       (L_asm_call_jit_compiler_exception): Implemented.
+       (asm_patcher_wrapper): Fixses. (L_asm_patcher_wrapper_exception):
+       Implemented.
+
+        * src/vm/jit/m68k/codegen.h (M_IXOR): Added. (M_IOR_IMM): Added.
+       (M_IXOR_IMM): Added.
+
+        * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe):
+       Comment and further m68k stuff. ........ r7841 | twisti |
+       2007-04-30 13:58:57 +0200 (Mon, 30 Apr 2007) | 3 lines
+
+        * src/vm/jit/inline/Makefile.am (AM_CPPFLAGS): Added
+         -I$(top_builddir)/src. ........ r7842 | tbfg | 2007-04-30 14:44:47
+       +0200 (Mon, 30 Apr 2007) | 3 lines
+
+        * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Restore
+       registers correctly. ........ r7843 | tbfg | 2007-05-01 15:00:12
+       +0200 (Tue, 01 May 2007) | 22 lines
+
+        * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill):
+       Support EXCEPTION_HARDWARE_ARITHMETIC.
+
+        * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Use corret opcode for
+       word forms.
+
+        * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Implemented.
+       (ICMD_IREMPOW2): Implemented. (ICMD_ISHLCONST): Fixed.
+       (ICMD_ISHRCONST): Fixed. (ICMD_IUSHRCONST): Fixed.
+       (ICMD_SALOAD): Signextension fix. (ICMD_LALOAD): Implemented.
+       (ICMD_LASTORE): Fixed. (ICMD_IASTORE): Fixed.
+       (ICMD_MULITANEWARRAY): Fixed.
+
+        * src/vm/jit/m68k/codegen.h (M_IADDX): Added. (M_IXOR): Fixed.
+       (M_BCS): Fixed. ........ r7844 | pm | 2007-05-01 17:46:22 +0200
+       (Tue, 01 May 2007) | 3 lines
+
+        * src/vm/jit/emit-common.h (BRANCH_LABEL_6): Added. ........
+       r7845 | pm | 2007-05-01 18:05:07 +0200 (Tue, 01 May 2007) | 3 lines
+
+        * src/vm/jit/s390/codegen.c (codegen_emit): Use new emit_label and
+       emit_label_* functions.
+         * src/vm/jit/s390/disass.c (disass_pseudo_instr): Nicer formatting for
+       ill pseudo instruction. ........ r7846 | pm | 2007-05-01 18:14:00
+       +0200 (Tue, 01 May 2007) | 2 lines
+
+        * src/vm/jit/s390/codegen.h (gen_bound_check,
+       gen_nullptr_check_intern, gen_bound_check, N_LONG_0): Remove because
+       obsolete. ........ r7847 | ajordan | 2007-05-01 19:35:55 +0200
+       (Tue, 01 May 2007) | 6 lines
+
+        * src/vm/jit/sparc64/codegen.h: Removed unused var_to_reg_int
+       define.
+
+        * src/vm/jit/sparc64/codegen.c: Fixed JIT float argument passing
+       via stack.
+
+        * src/vm/jit/sparc64/asmpart.S (asm_vm_call): Fixed integer
+       argument passing via stack args. ........ r7848 | pm | 2007-05-01
+       23:40:26 +0200 (Tue, 01 May 2007) | 8 lines
+
+        * src/vm/jit/s390/md.c (md_dump_context): Added. Fatal signals now
+       print the context and a stacktrace.
+         * src/vm/jit/s390/emit.h (emit_restore_pv): Added. Fixes bug where
+       REG_PV recalculation uses dseg value to recalculate REG_PV.
+         * src/vm/jit/s390/emit.c: Likewise.
+         * src/vm/jit/s390/codegen.h (N_RI, N_RI2): Test immediate operand for
+       correct signedness.
+         * src/vm/jit/s390/codegen.c (codegen_emit): Use emit_restore_pv for
+       REG_PV recalculation/
+         * src/vm/jit/s390/disass.c (disass_pseudo_instr): Fix formating.
+         * src/vm/jit/s390/tests/dacapo.status: Added. ........ r7849 |
+       twisti | 2007-05-02 11:57:22 +0200 (Wed, 02 May 2007) | 6 lines
+
+        * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv):
+       Added uClibc support. (md_signal_handler_sigtrap): Likewise.
+       (md_signal_handler_sigusr2): Likewise.
+       (thread_restartcriticalsection): Likewise. ........ r7850 | twisti
+       | 2007-05-02 18:21:12 +0200 (Wed, 02 May 2007) | 37 lines
+
+        * src/threads/threads-common.c (threads_preinit): Create and
+       initialize the main-thread. (threads_table_init): Changed
+       signature, insert main-thread and maintain a used list too.
+       (threads_table_add): Use locking and maintain used list.
+       (threads_table_remove): Likewise. (threads_table_get): New
+       function. (threads_table_get_non_daemons): Likewise.
+       (threads_table_first): Likewise. (threads_table_next): Likewise.
+       [!NDEBUG] (threads_table_dump): Use log_* functions.
+       (threads_dump): Use threads-table and functions.
+
+        * src/threads/threads-common.h (threads_table_entry_t): Made a
+       struct and renamed nextfree to next. (threads_table_get): Added
+       (threads_table_get_non_daemons): Likewise. (threads_table_first):
+       Likewise. (threads_table_next): Likewise. [!NDEBUG]
+       (threads_table_dump): Likewise. (threads_impl_table_init):
+       Likewise. (threads_table_lock): Likewise.
+       (threads_table_unlock): Likewise.
+       (threads_set_current_threadobject): Likewise.
+
+        * src/threads/native/threads.c (threadlistlock): Removed.
+       (threads_impl_preinit): Removed main-thread initialization code.
+       (threads_impl_table_init): New function. (threads_table_lock): New
+       function. (threads_table_unlock): Likewise. (threads_init): Get
+       main-thread from threads-table and removed thread-list code.
+       (threads_attach_current_thread): Likewise.
+       (threads_detach_thread): Removed thread-list code.
+       (threads_find_non_daemon_thread): Removed.
+       (threads_join_all_threads): Use threads_table_get_non_daemons.
+       ........ r7851 | twisti | 2007-05-02 21:57:07 +0200 (Wed, 02 May
+       2007) | 3 lines
+
+        * src/vmcore/class.c (class_load_attributes): Disable annotation
+       loading for the release. ........ r7852 | tbfg | 2007-05-02
+       22:36:07 +0200 (Wed, 02 May 2007) | 3 lines
+
+        * java_lang_Double.c (Java_java_lang_Double_doubleToLongBits):
+       Added missing JNIEnv* argument to signature. ........ r7853 |
+       twisti | 2007-05-02 22:40:11 +0200 (Wed, 02 May 2007) | 8 lines
+
+        * src/threads/threads-common.c (threads_table_get_threads): New
+       function.
+
+        * src/threads/threads-common.h (threads_table_get_threads): Added.
+
+        * src/threads/native/threads.c (threads_cast_sendsignals):
+       Rewritten. (threads_cast_stopworld): Likewise. ........ r7854 |
+       twisti | 2007-05-02 22:44:59 +0200 (Wed, 02 May 2007) | 4 lines
+
+        * src/native/vm/cldc1.1/java_lang_Double.c
+       (native/include/java_lang_Double.h): Added. (longBitsToDouble):
+       Fixed return type. ........ r7855 | twisti | 2007-05-02 22:46:56
+       +0200 (Wed, 02 May 2007) | 3 lines
+
+        * src/native/vm/cldc1.1/java_lang_Float.c (native/native.h):
+       Removed. (native/include/java_lang_Float.h): Added. ........
+       r7856 | tbfg | 2007-05-03 00:28:04 +0200 (Thu, 03 May 2007) | 7
+       lines
+
+        * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Fixed. (ICMD_IREM):
+       Fixed. (ICMD_LASTORE): Use M_LST. (ICMD_DASTORE): Use M_LST.
+       (ICMD_LALOAD): Use M_LLD. (ICMD_DALOAD): Use M_LLD. ........
+       r7857 | tbfg | 2007-05-03 02:33:48 +0200 (Thu, 03 May 2007) | 6
+       lines
+
+        * src/vm/jit/m68k/codegen.c (ICMD_CALOAD): Fixed.
+
+        * src/vm/jit/m68k/patcher.c (*): Removed patching back of old
+       opcodes from patcher_wrapper, moved into each patcher.
+       (patcher_patch_back): Added. ........ r7858 | twisti | 2007-05-03
+       10:16:14 +0200 (Thu, 03 May 2007) | 3 lines
+
+        * contrib/check_dangerous_printf.pl: Removed this file in favor of
+       pscan. ........ r7859 | twisti | 2007-05-03 10:29:16 +0200 (Thu,
+       03 May 2007) | 7 lines
+
+        * src/toolbox/avl.h (avl_tree): Renamed to avl_tree_t.
+       (avl_node): Renamed to avl_node_t.
+
+        * src/toolbox/avl.c: Likewise.
+         * src/threads/critical.c: Likewise.
+         * src/vm/jit/codegen-common.c: Likewise. ........ r7860 | twisti |
+       2007-05-03 14:30:05 +0200 (Thu, 03 May 2007) | 9 lines
+
+        * src/toolbox/avl.c (avl_insert_intern): Changed order of
+       comparator-arguments. (avl_find): Likewise.
+
+        * src/toolbox/avl.h (avl_comparator): Renamed arguments, to
+       reflect the change.
+
+        * src/vm/jit/codegen-common.c (methodtree_comparator): Likewise.
+       ........ r7861 | twisti | 2007-05-03 15:49:35 +0200 (Thu, 03 May
+       2007) | 4 lines
+
+        * src/vm/jit/codegen-common.c (codegen_start_native_call)
+       [ENABLE_JAVASE]: This has to be ENABLE_JNI.
+       (codegen_finish_native_call): Likewise. ........ r7862 | twisti |
+       2007-05-03 16:53:39 +0200 (Thu, 03 May 2007) | 7 lines
+
+        * src/toolbox/avl.c (toolbox/logging.h): Added. (vm/global.h):
+       Likewise. (vm/vm.h): Likewise. (avl_insert_intern): Use vm_abort
+       instead of assert. (avl_insert): Removed debug code. (avl_dump):
+       Use logging functions. ........ r7863 | twisti | 2007-05-03
+       22:58:54 +0200 (Thu, 03 May 2007) | 3 lines
+
+        * src/mm/boehm-gc/include/gc.h (GC_HAVE_BUILTIN_BACKTRACE):
+       Commented, we don't need it and uClibc doesn't have it. ........
+       r7864 | twisti | 2007-05-03 23:17:26 +0200 (Thu, 03 May 2007) | 47
+       lines
+
+        * src/threads/critical.c (critical_compare): Renamed to
+       critical_comparator. (critical_find): Removed.
+       (critical_register_critical_section): Renamed to
+       critical_section_register. (critical_find_restart_point): Call
+       avl_find. (critical_register_asm_critical_sections): Call
+       critical_section_register.
+
+        * src/threads/critical.h (critical_section_node_t): Renamed
+       members. (thread_restartcriticalsection): Renamed to
+       md_critical_section_restart.
+
+        * src/threads/native/threads.c (threads_cast_darwinstop): Call
+       md_critical_section_restart. (threads_sigsuspend_handler):
+       Likewise.
+
+        * src/vmcore/linker.c (linker_compute_subclasses): Call
+       threads_cast_{start,stop}world, removed LOCK_MONITOR_{ENTER,EXIT}.
+
+        * src/cacaoh/dummy.c (threads_cast_stopworld): Added.
+       (threads_cast_startworld): Likewise.
+
+        * src/vm/jit/codegen-common.c (codegen_setup): Setup listcritical.
+       (codegen_reset): Likewise. (codegen_critical_section_new): New
+       function. (codegen_critical_section_start): Likewise.
+       (codegen_critical_section_end): Likwise.
+       (codegen_critical_section_finish): Likewise. (codegen_finish):
+       Call codegen_critical_section_finish. (codegen_threadcritrestart):
+       Removed. (codegen_threadcritstart): Likewise.
+       (codegen_threadcritstop): Likewise.
+
+        * src/vm/jit/codegen-common.h (codegen_critical_section_t):
+       Renamed to critical_section_ref_t. (codegendata): Added
+       listcritical, removed threadcrit, threadcritcurrent and
+       threadcritcount. (CODEGEN_CRITICAL_SECTION_NEW,
+       CODEGEN_CRITICAL_SECTION_START) (CODEGEN_CRITICAL_SECTION_END):
+       Defined.
+
+        * src/vm/jit/powerpc/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+        * src/vm/jit/powerpc/linux/md-os.c
+       (thread_restartcriticalsection): Renamed to
+       md_critical_section_restart. ........ r7865 | twisti | 2007-05-03
+       23:29:40 +0200 (Thu, 03 May 2007) | 6 lines
+
+        * src/vm/jit/i386/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+        * src/vm/jit/i386/linux/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart. ........ r7866 | twisti |
+       2007-05-04 00:32:11 +0200 (Fri, 04 May 2007) | 6 lines
+
+        * src/vm/jit/x86_64/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+        * src/vm/jit/x86_64/linux/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart. ........ r7867 | tbfg |
+       2007-05-04 01:31:01 +0200 (Fri, 04 May 2007) | 7 lines
+
+        * src/vm/jit/m68k/md.c (md_stacktrace_get_returnaddress): Removed
+       braindead address check and fixed the real bug.
+
+        * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Added float
+       argument handling. (asm_call_jit_compiler): Fixed stack offset
+       bug. ........ r7868 | tbfg | 2007-05-04 12:13:20 +0200 (Fri, 04
+       May 2007) | 4 lines
+
+        * linker.c (linker_compute_subclasses): Only call
+       threads_cast_[start|stop]world when ENABLE_THREADS. ........ r7869
+       | pm | 2007-05-05 10:08:49 +0200 (Sat, 05 May 2007) | 3 lines
+
+        * contrib/vmlog/Makefile.am (AM_CPPFLAGS): Add include
+       directories for vmlog.
+          * src/vm/Makefile.am: Likewise. ........ r7870 | tbfg | 2007-05-05
+       15:46:11 +0200 (Sat, 05 May 2007) | 3 lines
+
+        * linker.c (linker_compute_subclasses):
+       threads_cast_[start|stop]world only available when using GC.
+       ........ r7871 | tbfg | 2007-05-05 15:48:39 +0200 (Sat, 05 May
+       2007) | 8 lines
+
+        * src/vm/jit/m68k/emit.c (emit_patcher_stubs): Add thread
+       support. (emit_exception_check_areg): Removed dead code.
+
+        * src/vm/jit/m68k/codegen.c (codegen_emit): Add thread support.
+
+        * src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Likewise.
+       ........ r7872 | ajordan | 2007-05-06 15:32:49 +0200 (Sun, 06 May
+       2007) | 5 lines
+
+        * src/vm/jit/sparc64/codegen.c: Implemented threads support.
+         * src/vm/jit/sparc64/machine-instr.h: Likewise.
+         * src/vm/jit/sparc64/linux/md-os.c: Likewise. ........ r7873 | tbfg
+       | 2007-05-07 00:20:13 +0200 (Mon, 07 May 2007) | 16 lines
+
+        * src/vm/jit/m68k/codegen.c (codegen_emit): Allocate 2 additional
+       words in stackframe for long to double conversion.
+
+        * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Copy exception
+       object into correct register.
+
+        * src/vm/jit/m68k/codegen.h (M_FLD): Implemented. (M_DLD):
+       Likewise. (M_FST): Likewise. (M_DST): Likewise. (M_FLTMOVE):
+       Likewise. (M_INT2FLTMOVE): Likewise. (M_DBLMOVE): Likewise.
+       (FCONST): Likewise. ........ r7874 | ajordan | 2007-05-07 03:44:47
+       +0200 (Mon, 07 May 2007) | 7 lines
+
+        * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed
+       fp arg passing.
+         * src/vm/jit/sparc64/md-abi.h: Likewise.
+
+        * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method): Likewise, but
+       the other way around.
+         * src/vm/jit/sparc64/md-asm.h: Likewise. ........ r7875 | twisti |
+       2007-05-07 13:35:30 +0200 (Mon, 07 May 2007) | 10 lines
+
+        * src/threads/threads-common.c (threads_table_get): Made static
+       and removed table lock. (threads_dump): Lock threads table.
+
+        * src/threads/threads-common.h (threads_table_get): Removed.
+
+        * src/threads/native/threads.c (threads_cast_stopworld): Lock
+       threads table. (threads_cast_startworld): Likewise. ........
+       r7876 | twisti | 2007-05-07 13:37:00 +0200 (Mon, 07 May 2007) | 2
+       lines
+
+        * src/threads/threads-common.c (threads_dump): Typo. ........
+       r7877 | tbfg | 2007-05-07 15:02:55 +0200 (Mon, 07 May 2007) | 38
+       lines
+
+        * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Enabled.
+       (SUPPORT_FLOAT_CMP): Enabled. (SUPPORT_DOUBLE): Enabled.
+       (SUPPORT_DOUBLE_CMP): Enabled.
+
+        * src/vm/jit/m68k/codegen.c (ICMD_FCMPL): Implemented.
+       (ICMD_DCMPL): Likewise. (ICMD_FCMPG): Likewise. (ICMD_DCMPG):
+       Likewise. (ICMD_FMUL): Likewise. (ICMD_DMUL): Likewise.
+       (ICMD_FDIV): Likewise. (ICMD_DDIV): Likewise. (ICMD_FADD):
+       Likewise. (ICMD_DADD): Likewise. (ICMD_FSUB): Likewise.
+       (ICMD_DSUB): Likewise. (ICMD_F2D): Likewise. (ICMD_D2F):
+       Likewise. (ICMD_BUILTIN): Handle float return values.
+       (codegen_emit_stub_native): Handle float values.
+
+        * src/vm/jit/m68k/codegen.h (M_FCMP): Added. (M_BFEQ): Added.
+       (M_BFLT): Added. (M_BFGT): Added. (M_BFUN): Added. (M_FADD):
+       Added. (M_DADD): Added. (M_FSUB): Added. (M_DSUB): Added.
+       (M_FMUL): Added. (M_DMUL): Added. (M_FDIV): Added. (M_DDIV):
+       Added. (M_D2F): Added. (M_F2D): Added. ........ r7878 | twisti
+       | 2007-05-07 15:31:18 +0200 (Mon, 07 May 2007) | 3 lines
+
+        * src/native/vm/java_lang_Thread.h (threads/native/threads.h):
+       Removed. ........ r7879 | twisti | 2007-05-07 15:45:19 +0200 (Mon,
+       07 May 2007) | 8 lines
+
+        * configure.ac (AC_CHECK_HEADERS): Added sys/mman.h,
+       sys/resource.h. (AC_CHECK_FUNCS): Added getrusage, mprotect.
+
+        * src/vmcore/statistics.c [HAVE_SYS_TIME_H] (sys/time.h): Include
+       conditionally. [HAVE_SYS_RESOURCE_H] (sys/resource.h): Likewise.
+       (getcputime) [!HAVE_GETRUSAGE]: Return 0. ........ r7880 | twisti
+       | 2007-05-07 16:13:45 +0200 (Mon, 07 May 2007) | 6 lines
+
+        * src/vm/jit/mips/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+        * src/vm/jit/mips/linux/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart. ........ r7881 | twisti |
+       2007-05-07 16:16:54 +0200 (Mon, 07 May 2007) | 7 lines
+
+        * configure.ac (AC_CONFIG_FILES): Added
+       src/vm/jit/mips/uclinux/Makefile.
+
+        * src/vm/jit/mips/uclinux: New directory.
+         * src/vm/jit/mips/uclinux/md-os.c: New file.
+         * src/vm/jit/mips/uclinux/Makefile.am: Likewise. ........ r7882 |
+       tbfg | 2007-05-07 16:23:32 +0200 (Mon, 07 May 2007) | 8 lines
+
+        * tests/exception_restore_registers.java: New test, tests if
+       variables get restored in case of exceptions.
+
+        * tests/exception_restore_registers.output: New file, expected
+       output.
+
+        * tests/Makefile.am: Added exception_restore_registers target.
+       ........ r7883 | tbfg | 2007-05-07 16:26:41 +0200 (Mon, 07 May
+       2007) | 11 lines
+
+        * src/vm/jit/m68k/codegen.c (ICMD_FNEG): Implemented.
+       (ICMD_DNEG): Implemented.
+
+        * src/vm/jit/m68k/asmpart.S (asm_call_jit_compiler): Store
+       volatile floatregisters. (asm_patcher_wrapper): Likewise.
+       (asm_handle_exception): Restore float registers.
+
+        * src/vm/jit/m68k/codegen.h (M_FNEG): Added. (M_DNEG): Added.
+       ........ r7884 | ajordan | 2007-05-07 17:07:03 +0200 (Mon, 07 May
+       2007) | 4 lines
+
+        * src/vm/jit/sparc64/codegen.c (codegen_emit): Adapted to critical
+       section renames.
+         * src/vm/jit/sparc64/linux/md-os.c: Likewise. ........ r7885 |
+       twisti | 2007-05-07 23:29:55 +0200 (Mon, 07 May 2007) | 7 lines
+
+        * src/threads/native/threads.c (mainthreadobj): Removed.
+         * src/threads/native/threads.h (mainthreadobj): Likewise.
+
+        * src/vm/jit/optimizing/profile.c (threads/native/threads.h):
+       Likewise. (profile_thread): Rewritten thread iteration. ........
+       r7886 | twisti | 2007-05-07 23:34:01 +0200 (Mon, 07 May 2007) | 6
+       lines
+
+        * src/vm/jit/alpha/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+        * src/vm/jit/alpha/linux/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart. ........ r7887 | twisti |
+       2007-05-08 15:03:07 +0200 (Tue, 08 May 2007) | 6 lines
+
+        * src/configure.ac (AC_CHECK_HEADERS): Added string.h.
+       (AC_CHECK_FUNCS): Added strdup.
+
+        * src/src/vmcore/options.c [HAVE_STRING_H] (string.h): Added
+       #ifdef. (options_get) HAVE_STRDUP]: Added. ........ r7888 | tbfg
+       | 2007-05-09 10:36:16 +0200 (Wed, 09 May 2007) | 7 lines
+
+        * src/vm/jit/powerpc64/linux/md-os.c
+       (thread_restartcriticalsection): Renamed to
+       md_critical_section_restart.
+
+        * src/vm/jit/powerpc64/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros. ........ r7889 | tbfg |
+       2007-05-09 10:52:11 +0200 (Wed, 09 May 2007) | 36 lines
+
+        * src/vm/jit/m68k/linux/md-abi.h (LA_SIZE_IN_POINTERS): Defined 0.
+       (PA_SIZE_IN_POINTERS): Removed. (PA_SIZE): Removed.
+       (LA_LR_OFFSET): Removed. (LA_SIZE_ALIGNED): Removed.
+
+        * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Removed
+       linking instructions, save only used registers.
+
+        (emit_verbosecall_exit): Likewise.
+
+        * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Depends on configure
+       option ENABLE_SOFTFLOAT.
+
+        * src/vm/jit/m68k/codegen.c (codegen_emit): Use M_FSTORE/M_FLOAT
+       to save/restore float registers without converting any values.
+       Fixed offset of IsSync.
+
+        (codegen_emit_stub_native): Move floating point return values
+       into floating point registers.
+
+        * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Save/restore
+       floating point registers.
+
+        (asm_call_jit_compiler): Save/restore volatile floating point
+       registers.
+
+        (asm_patcher_wrapper): Likewise.
+
+        (asm_handle_exception): Use fmovemd instructions to restore
+       floatng point registers without converting.
+
+        * src/vm/jit/m68k/codegen.h (M_FSTORE): Added. (M_FLOAT): Added.
+       ........ r7890 | twisti | 2007-05-09 18:05:58 +0200 (Wed, 09 May
+       2007) | 7 lines
+
+        * src/lib/Makefile.am (VM_JAVA_FILES): Renamed vm/reference/ to
+       gnu/.
+
+        * src/lib/vm: Removed.
+         * src/lib/gnu: Added.
+         * src/lib/gnu/java: Likewise.
+         * src/lib/gnu/gnu: Likewise. ........ r7891 | tbfg | 2007-05-09
+       18:37:20 +0200 (Wed, 09 May 2007) | 5 lines
+
+        * src/vm/jit/powerpc64/codegen.c (ICMD_CHECKCAST): Use
+       branch_label_* instead of harcoded jump offsets.
+
+        (ICMD_INSTANCEOF): Likewise. ........ r7892 | tbfg | 2007-05-10
+       14:50:45 +0200 (Thu, 10 May 2007) | 3 lines
+
+        * src/vm/jit/powerpc64/patcher.c (patcher_checkcast_interface):
+       Fixed not flushing all bytes written. ........ r7893 | twisti |
+       2007-05-10 15:27:29 +0200 (Thu, 10 May 2007) | 7 lines
+
+        * src/threads/threads-common.c (threads_thread_start_internal):
+       Set thread-flags. (threads_thread_start): Likewise.
+
+        * src/threads/native/threads.c (threads_startup_thread): Don't set
+       thread-flags. ........ r7894 | twisti | 2007-05-10 16:04:05 +0200
+       (Thu, 10 May 2007) | 19 lines
+
+        * src/vmcore/options.c (opt_verbosethreads): Added.
+         * src/vmcore/options.h (opt_verbosethreads): Likewise.
+
+        * src/vm/vm.c (XXusage): Added -verbose:threads. (vm_create):
+       Likewise.
+
+        * src/threads/threads-common.c (threads_create_thread): Renamed
+       variable thread to t. (threads_thread_print_info): New function.
+       (threads_dump): Use threads_thread_print_info.
+
+        * src/threads/threads-common.h (threads_thread_print_info): Added.
+
+        * src/threads/native/threads.c (threads_init) [!NDEBUG]: Added
+         -verbose:threads debug-output. (threads_startup_thread): Likewise.
+       (threads_attach_current_thread): Likewise.
+       (threads_detach_thread): Likewise. ........ r7895 | tbfg |
+       2007-05-10 16:34:05 +0200 (Thu, 10 May 2007) | 9 lines
+
+        * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Make SOFTFLOAT
+       clean. (emit_verbosecall_exit): Likewise.
+
+        * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Mark comment
+       about gcc abi wiredness.
+
+        * src/vm/jit/m68k/codegen.h (M_D2F): Fixed. (M_F2D): Fixed.
+       ........ r7896 | tbfg | 2007-05-11 19:15:08 +0200 (Fri, 11 May
+       2007) | 9 lines
+
+        * src/vm/jit/m68k/codegen.c (codegen_emit): Fix stackframesize
+       allocation in not synchronized methods which call a builtin
+       returning a double. Merged with ENABLE_THREADS case. Added code
+       to copy interface registers.
+
+        * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Save
+       temporary registers, dunno if really needed, but its a slow path
+       anyways. ........ r7897 | twisti | 2007-05-11 20:23:27 +0200 (Fri,
+       11 May 2007) | 2 lines
+
+        * src/threads/native/threads.h (threadobject): Removed next and
+       prev. ........ r7898 | tbfg | 2007-05-11 20:58:24 +0200 (Fri, 11
+       May 2007) | 12 lines
+
+        * src/vm/jit/m68k/linux/md-abi.h (ADR_SAV_CNT): Increased by one
+       (%fp). (ADR_RES_CNT): Decreased by one (%fp).
+
+        * src/vm/jit/m68k/linux/md-abi.c (nregdescadr): Declared %fp a
+       REG_SAV.
+
+        * src/vm/jit/m68k/arch.h (SUPPORT_DIVISION): Defined.
+
+
+         * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Additional logic
+       to restore %fp when unwinding the stack. ........ r7899 | twisti |
+       2007-05-11 21:31:04 +0200 (Fri, 11 May 2007) | 37 lines
+
+        * src/threads/threads-common.c (threads_create_thread): Removed
+       lock_init_execution_env.
+
+        * src/threads/lock-common.h (lock_init_execution_env): Removed.
+       (lock_record_free_pools): Likewise.
+
+        * src/threads/native/threads.h (threadobject): Removed ee.
+
+        * src/threads/native/lock.c (vm/finalizer.h): Added.
+       [ENABLE_GC_BOEHM] (mm/boehm-gc/include/gc.h): Likewise.
+       (lock_global_pool): Removed. (lock_global_pool_lock): Likewise.
+       (lock_init): Don't initialize lock_global_pool_lock.
+       (lock_record_init): Removed. (lock_init_execution_env): Likewise.
+       (lock_record_alloc_new_pool): Likewise. (lock_record_alloc_pool):
+       Likewise. (lock_record_free_pools): Likewise.
+       (lock_record_alloc): Likewise. (lock_record_recycle): Likewise.
+       (lock_hashtable_get_lock_record): Renamed to lock_hashtable_get.
+       (lock_record_new): New function. (lock_record_free): Likewise.
+       (lock_hashtable_remove): Likewise. [ENABLE_GC_BOEHM]
+       (lock_record_finalizer): Likewise.
+
+        * src/threads/native/lock.h (lock_execution_env_t): Removed.
+       (lock_record_pool_header_t): Likewise. (lock_record_pool_t):
+       Likewise. (lock_record_t): Renamed obj to object, removed
+       nextfree. [ENABLE_JVMTI] (lock_global_pool_lock,
+       lock_global_pool): Removed.
+
+        * src/vmcore/statistics.c (size_lock_record_pool): Renamed to
+       size_lock_record. (statistics_print_memory_usage): Likewise.
+         * src/vmcore/statistics.h: Likewise. ........ r7900 | twisti |
+       2007-05-11 22:35:16 +0200 (Fri, 11 May 2007) | 6 lines
+
+        * src/vm/jit/arm/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+        * src/vm/jit/arm/linux/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart. ........ r7901 | twisti |
+       2007-05-11 23:18:51 +0200 (Fri, 11 May 2007) | 3 lines
+
+        * src/vmcore/statistics.c (statistics_print_memory_usage): Use
+       log_println instead of printf. ........ r7902 | twisti |
+       2007-05-12 00:33:15 +0200 (Sat, 12 May 2007) | 10 lines
+
+        * configure.ac (AC_CHECK_HEADERS): Added time.h.
+       (AC_CHECK_FUNCS): Added localtime, localtime_r, time.
+
+        * src/vmcore/statistics.c [HAVE_TIME_H] (time.h): Added.
+       (statistics_print_date): New function.
+         * src/vmcore/statistics.h (statistics_print_date): Added.
+
+        * src/mm/memory.c (memory_thread) [ENABLE_STATISTICS]: Call
+       statistics_print_date. ........ r7903 | tbfg | 2007-05-14 13:15:33
+       +0200 (Mon, 14 May 2007) | 15 lines
+
+        * src/vm/jit/dseg.h (dseg_adddata): Removed warning due to typo.
+
+        * src/vm/jit/m68k/arch.h (SUPPORT_LONG) Defined.
+       (SUPPORT_LONG_ADD): Defined. (SUPPORT_CONST_LOGICAL): Defined.
+
+        * src/vm/jit/m68k/codegen.c (ICMD_LADD): Implemented.
+       (ICMD_LADDCONST): Implemented. (ICMD_LSUB): Implemented.
+       (ICMD_LSUBCONST): Implemented. (ICMD_LNEG): Implemented.
+
+        * src/vm/jit/m68k/codegen.h (M_ISUBX): Added. (M_INEGX): Added.
+       ........ r7904 | twisti | 2007-05-14 15:29:32 +0200 (Mon, 14 May
+       2007) | 26 lines
+
+        * src/threads/threads-common.c (threads_create_thread): Renamed to
+       threads_thread_new. (threads_thread_free): New function.
+       (threads_preinit): Renamed threads_create_thread to
+       threads_thread_new. (threads_thread_start_internal): Likewise.
+       (threads_thread_start): Likewise.
+
+        * src/threads/threads-common.h (threads_create_thread): Renamed to
+       threads_thread_new. (threads_thread_free): Added.
+       (threads_init_threadobject): Renamed to threads_impl_thread_new.
+       (threads_impl_thread_free): Added.
+
+        * src/threads/native/threads.c (toolbox/avl.h): Removed.
+       (threadattr): Likewise. (threads_init_threadobject): Renamed to
+       threads_impl_thread_new. (threads_impl_thread_free): New function.
+       (threads_init): Use local pthread_attr_t.
+       (threads_impl_thread_start): Use pthread_attr_setdetachstate (fixes
+       memory leak), check more return values of pthread-calls.
+       (threads_attach_current_thread): Renamed threads_create_thread to
+       threads_thread_new. (threads_detach_thread): Removed lock-record
+       pools comment, call threads_thread_free. ........ r7905 | twisti
+       | 2007-05-14 16:11:33 +0200 (Mon, 14 May 2007) | 4 lines
+
+        * src/toolbox/list.c (list_add_first): Call
+       list_add_first_unsynced. (list_add_first_unsynced): New function.
+         * src/toolbox/list.h (list_add_first_unsynced): Added. ........
+       r7906 | twisti | 2007-05-14 19:25:33 +0200 (Mon, 14 May 2007) | 2
+       lines
+
+        * src/native/native.c (native_class_getdeclaredannotations):
+       Removed. ........ r7907 | tbfg | 2007-05-15 11:25:27 +0200 (Tue,
+       15 May 2007) | 2 lines
+
+        * builtin.c (builtin_ldiv): Needed when DISABLE_GC. ........
+       r7908 | christian | 2007-05-15 11:55:17 +0200 (Tue, 15 May 2007) |
+       37 lines
+
+        * src/vm/jit/codegen-common.c: (codegen_emit_phi_moves): Added.
+       (Former codegen_insert_phi_moves from codegen.c)
+
+        * src/vm/jit/codegen-common.h: Function prototype for
+       codegen_emit_phi_moves added.
+
+        * src/vm/jit/optimizing/lsra.c: Adapted to new instruction format
+       and unified variables.
+
+        * src/vm/jit/optimizing/lsra.h: Likewise.
+
+        * src/vm/jit/optimizing/ssa.c: Likewise.
+
+        * src/vm/jit/optimizing/ssa.h: Likewise.
+
+        * src/vm/jit/optimizing/graph.c: Likewise.
+
+        * src/vm/jit/optimizing/graph.h: Likewise.
+
+        * src/vm/jit/optimizing/dominators.c: Likewise.
+
+        * src/vm/jit/optimizing/lifetimes.c: Likewise and changed lifetime
+       anaylsis to a worklist algorithmus.
+
+        * src/vm/jit/optimizing/lifetimes.h: Likewise.
+
+        * src/vm/jit/i386/codegen.c: (codegen_insert_phi_moves): Moved to
+       src/vm/jit/codegen-common.c codegen_emit_phi_moves (codegen_emit):
+       Necessary Adaptions for SSA.
+
+        * src/toolbox/worklist.c: (wl_reset): Added.
+
+        * src/toolbox/worklist.h: Function Prototype for wl_reset added.
+
+        * src/vm/jit/stack.c: Removed old SSA specific code. ........
+       r7909 | tbfg | 2007-05-15 12:32:16 +0200 (Tue, 15 May 2007) | 12
+       lines
+
+        * src/vm/jit/powerpc64/patcher.c
+       (patcher_resolve_classref_to_classinfo): Patch back original code.
+
+        (patcher_resolve_classref_to_vftbl): Likewise.
+       (patcher_resolve_classref_to_flags): Likewise.
+
+        * src/vm/jit/powerpc64/asmpart.S (DARWIN): Removed all darwin
+       ifdefed code for readability. Needs to be ported carefully anyways.
+
+        (asm_vm_call_method): When handling arguments treat address type
+       as long. ........ r7910 | twisti | 2007-05-16 10:02:52 +0200
+       (Wed, 16 May 2007) | 59 lines
+
+        * src/native/native.c: Removed all native-includes.
+       (dummynativetable): Removed. (mainhandle): Likewise.
+       (native_init): Don't dlopen libjvm, initialize the native-methods
+       tree. (native_tree_native_methods_comparator): New function.
+       (native_method_symbol): Likewise. (native_method_find): Likewise.
+       (native_resolve_function): Use native-methods tree for internal
+       native methods.
+
+        * src/native/native.h (native/jni.h): Added.
+       (NATIVE_METHODS_COUNT): Defined. (native_methods_node_t): New
+       structure. (native_method_register): Added.
+
+        * src/native/vm/nativevm.c: New file.
+         * src/native/vm/nativevm.h: Likewise.
+
+        * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
+       nativevm.[ch].
+
+        * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
+       src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Double.c,
+       src/native/vm/cldc1.1/java_lang_Float.c,
+       src/native/vm/cldc1.1/java_lang_Math.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_Runtime.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_System.c,
+       src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/cldc1.1/java_lang_Throwable.c,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, src/native/v
+       m/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/java_lang_reflect_VMProxy.c,
+       src/native/vm/gnu/java_security_VMAccessController.c,
+       src/native/vm/gnu/sun_misc_Unsafe.c: Added methods table and init
+       function to register the native methods. ........ r7911 | twisti |
+       2007-05-16 11:01:10 +0200 (Wed, 16 May 2007) | 8 lines
+
+        * src/native/native.c (native_library_open): New function.
+       (native_hashtable_library_add): Renamed to native_library_add.
+       (native_hashtable_library_find): Renamed to native_library_find.
+         * src/native/native.h: Likewise.
+
+        * src/native/vm/java_lang_Runtime.c (loadLibrary): Use
+       native_library_open. ........ r7912 | twisti | 2007-05-18 15:12:09
+       +0200 (Fri, 18 May 2007) | 14 lines
+
+        * src/native/native.c (native_tree_native_methods_comparator):
+       Compare classname, name and descriptor.
+       (native_method_register): Set all structure members.
+       (native_method_find): Changed argument-type to methodinfo.
+       (native_resolve_function): Likewise.
+
+        * src/native/native.h (native_methods_node_t): Added classname and
+       descriptor, renamed method to function.
+
+        * src/native/vm/gnu/java_lang_VMClass.c: Updated wrong signatures.
+         * src/native/vm/gnu/java_lang_VMObject.c: Likewise.
+         * src/native/vm/gnu/java_lang_VMThread.c: Likewise.
+         * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise.
+       ........ r7913 | twisti | 2007-05-18 15:45:54 +0200 (Fri, 18 May
+       2007) | 6 lines
+
+        * src/native/vm/cldc1.1/java_lang_String.c (methods): Removed
+       quick-hack.
+
+        * src/native/vm/cldc1.1/java_lang_Throwable.c (fillInStackTrace):
+       Fixed signature. ........ r7914 | twisti | 2007-05-18 16:17:34
+       +0200 (Fri, 18 May 2007) | 4 lines
+
+        * src/threads/threads-common.c (threads_thread_get_state): Fixed
+       compiler warning. (threads_thread_is_alive): Likewise. ........
+       r7915 | twisti | 2007-05-18 16:22:19 +0200 (Fri, 18 May 2007) | 2
+       lines
+
+        * src/toolbox/list.c (list_create): Use LOCK_INIT_OBJECT_LOCK-
+       macro. ........ r7916 | twisti | 2007-05-18 16:24:21 +0200 (Fri,
+       18 May 2007) | 10 lines
+
+        * src/vmcore/statistics.c (count_nstub_len): Renamed to
+       size_stub_native. (statistics_print_memory_usage): Likewise.
+
+        * src/vmcore/statistics.h: Likewise.
+
+        * src/vm/jit/codegen-common.c (codegen_generate_stub_native):
+       Likewise, moved statistics-calculation after codegen_finish(), so
+       actually something is counted. ........ r7917 | twisti |
+       2007-05-18 17:05:32 +0200 (Fri, 18 May 2007) | 3 lines
+
+        * src/native/vm/cldc1.1/java_lang_Object.c (getClass): Fixed
+       signature. ........
+       [4af05b527810]
+
+2007-05-18  twisti  <twisti>
+
+       * src/native/vm/cldc1.1/java_lang_Object.c:
+       * src/native/vm/cldc1.1/java_lang_Object.c (getClass): Fixed
+       signature.
+       [54484f15560e]
+
+       * src/vm/jit/codegen-common.c, src/vmcore/statistics.c,
+       src/vmcore/statistics.h:
+       * src/vmcore/statistics.c (count_nstub_len): Renamed to
+       size_stub_native. (statistics_print_memory_usage): Likewise.
+
+       * src/vmcore/statistics.h: Likewise.
+
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_native):
+       Likewise, moved statistics-calculation after codegen_finish(), so
+       actually something is counted.
+       [63567965122d]
+
+       * src/toolbox/list.c:
+       * src/toolbox/list.c (list_create): Use LOCK_INIT_OBJECT_LOCK-macro.
+       [8de6c89e9bf9]
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_thread_get_state): Fixed
+       compiler warning. (threads_thread_is_alive): Likewise.
+       [8d74bfb4fb5c]
+
+       * src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_Throwable.c:
+       * src/native/vm/cldc1.1/java_lang_String.c (methods): Removed quick-
+       hack.
+
+       * src/native/vm/cldc1.1/java_lang_Throwable.c (fillInStackTrace):
+       Fixed signature.
+       [322b8d3496f1]
+
+       * src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c:
+       * src/native/native.c (native_tree_native_methods_comparator):
+       Compare classname, name and descriptor. (native_method_register):
+       Set all structure members. (native_method_find): Changed argument-
+       type to methodinfo. (native_resolve_function): Likewise.
+
+       * src/native/native.h (native_methods_node_t): Added classname and
+       descriptor, renamed method to function.
+
+       * src/native/vm/gnu/java_lang_VMClass.c: Updated wrong signatures.
+       * src/native/vm/gnu/java_lang_VMObject.c: Likewise.
+       * src/native/vm/gnu/java_lang_VMThread.c: Likewise.
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise.
+       [f36dae832c9a]
+
+2007-05-16  twisti  <twisti>
+
+       * src/native/native.c, src/native/native.h,
+       src/native/vm/java_lang_Runtime.c:
+       * src/native/native.c (native_library_open): New function.
+       (native_hashtable_library_add): Renamed to native_library_add.
+       (native_hashtable_library_find): Renamed to native_library_find.
+       * src/native/native.h: Likewise.
+
+       * src/native/vm/java_lang_Runtime.c (loadLibrary): Use
+       native_library_open.
+       [187f8d8411ff]
+
+       * src/native/native.c, src/native/native.h, src/native/vm/Makefile.am,
+       src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
+       src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Double.c,
+       src/native/vm/cldc1.1/java_lang_Float.c,
+       src/native/vm/cldc1.1/java_lang_Math.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_Runtime.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_System.c,
+       src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/cldc1.1/java_lang_Throwable.c,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, src/native/vm/
+       gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/java_lang_reflect_VMProxy.c,
+       src/native/vm/gnu/java_security_VMAccessController.c,
+       src/native/vm/gnu/sun_misc_Unsafe.c, src/native/vm/nativevm.c,
+       src/native/vm/nativevm.h:
+       * src/native/native.c: Removed all native-includes.
+       (dummynativetable): Removed. (mainhandle): Likewise. (native_init):
+       Don't dlopen libjvm, initialize the native-methods tree.
+       (native_tree_native_methods_comparator): New function.
+       (native_method_symbol): Likewise. (native_method_find): Likewise.
+       (native_resolve_function): Use native-methods tree for internal
+       native methods.
+
+       * src/native/native.h (native/jni.h): Added. (NATIVE_METHODS_COUNT):
+       Defined. (native_methods_node_t): New structure.
+       (native_method_register): Added.
+
+       * src/native/vm/nativevm.c: New file.
+       * src/native/vm/nativevm.h: Likewise.
+
+       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
+       nativevm.[ch].
+
+       * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
+       src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Double.c,
+       src/native/vm/cldc1.1/java_lang_Float.c,
+       src/native/vm/cldc1.1/java_lang_Math.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_Runtime.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_System.c,
+       src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/cldc1.1/java_lang_Throwable.c,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, src/native/vm/
+       gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMObject.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMString.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/java_lang_reflect_VMProxy.c,
+       src/native/vm/gnu/java_security_VMAccessController.c,
+       src/native/vm/gnu/sun_misc_Unsafe.c: Added methods table and init
+       function to register the native methods.
+       [64c69300da3b]
+
+2007-05-15  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/patcher.c:
+       * src/vm/jit/powerpc64/patcher.c
+       (patcher_resolve_classref_to_classinfo): Patch back original code.
+
+       (patcher_resolve_classref_to_vftbl): Likewise.
+       (patcher_resolve_classref_to_flags): Likewise.
+
+       * src/vm/jit/powerpc64/asmpart.S (DARWIN): Removed all darwin
+       ifdefed code for readability. Needs to be ported carefully anyways.
+
+       (asm_vm_call_method): When handling arguments treat address type as
+       long.
+       [8b2523c8fe2b]
+
+2007-05-15  christian  <christian>
+
+       * src/toolbox/worklist.c, src/toolbox/worklist.h, src/vm/jit/codegen-
+       common.c, src/vm/jit/codegen-common.h, src/vm/jit/i386/codegen.c,
+       src/vm/jit/optimizing/dominators.c, src/vm/jit/optimizing/graph.c,
+       src/vm/jit/optimizing/graph.h, src/vm/jit/optimizing/lifetimes.c,
+       src/vm/jit/optimizing/lifetimes.h, src/vm/jit/optimizing/lsra.c,
+       src/vm/jit/optimizing/lsra.h, src/vm/jit/optimizing/ssa.c,
+       src/vm/jit/optimizing/ssa.h, src/vm/jit/stack.c:
+       * src/vm/jit/codegen-common.c: (codegen_emit_phi_moves): Added.
+       (Former codegen_insert_phi_moves from codegen.c)
+
+       * src/vm/jit/codegen-common.h: Function prototype for
+       codegen_emit_phi_moves added.
+
+       * src/vm/jit/optimizing/lsra.c: Adapted to new instruction format
+       and unified variables.
+
+       * src/vm/jit/optimizing/lsra.h: Likewise.
+
+       * src/vm/jit/optimizing/ssa.c: Likewise.
+
+       * src/vm/jit/optimizing/ssa.h: Likewise.
+
+       * src/vm/jit/optimizing/graph.c: Likewise.
+
+       * src/vm/jit/optimizing/graph.h: Likewise.
+
+       * src/vm/jit/optimizing/dominators.c: Likewise.
+
+       * src/vm/jit/optimizing/lifetimes.c: Likewise and changed lifetime
+       anaylsis to a worklist algorithmus.
+
+       * src/vm/jit/optimizing/lifetimes.h: Likewise.
+
+       * src/vm/jit/i386/codegen.c: (codegen_insert_phi_moves): Moved to
+       src/vm/jit/codegen-common.c codegen_emit_phi_moves (codegen_emit):
+       Necessary Adaptions for SSA.
+
+       * src/toolbox/worklist.c: (wl_reset): Added.
+
+       * src/toolbox/worklist.h: Function Prototype for wl_reset added.
+
+       * src/vm/jit/stack.c: Removed old SSA specific code.
+       [6270ebe435fa]
+
+2007-05-15  tbfg  <tbfg>
+
+       * src/vm/builtin.c:
+       * builtin.c (builtin_ldiv): Needed when DISABLE_GC.
+       [cec8c00d844a]
+
+2007-05-14  twisti  <twisti>
+
+       * src/native/native.c:
+       * src/native/native.c (native_class_getdeclaredannotations):
+       Removed.
+       [1fcaff874000]
+
+       * src/toolbox/list.c, src/toolbox/list.h:
+       * src/toolbox/list.c (list_add_first): Call list_add_first_unsynced.
+       (list_add_first_unsynced): New function.
+       * src/toolbox/list.h (list_add_first_unsynced): Added.
+       [c982fd6285f2]
+
+       * src/threads/native/threads.c, src/threads/threads-common.c,
+       src/threads/threads-common.h:
+       * src/threads/threads-common.c (threads_create_thread): Renamed to
+       threads_thread_new. (threads_thread_free): New function.
+       (threads_preinit): Renamed threads_create_thread to
+       threads_thread_new. (threads_thread_start_internal): Likewise.
+       (threads_thread_start): Likewise.
+
+       * src/threads/threads-common.h (threads_create_thread): Renamed to
+       threads_thread_new. (threads_thread_free): Added.
+       (threads_init_threadobject): Renamed to threads_impl_thread_new.
+       (threads_impl_thread_free): Added.
+
+       * src/threads/native/threads.c (toolbox/avl.h): Removed.
+       (threadattr): Likewise. (threads_init_threadobject): Renamed to
+       threads_impl_thread_new. (threads_impl_thread_free): New function.
+       (threads_init): Use local pthread_attr_t.
+       (threads_impl_thread_start): Use pthread_attr_setdetachstate (fixes
+       memory leak), check more return values of pthread-calls.
+       (threads_attach_current_thread): Renamed threads_create_thread to
+       threads_thread_new. (threads_detach_thread): Removed lock-record
+       pools comment, call threads_thread_free.
+       [f922505053e3]
+
+2007-05-14  tbfg  <tbfg>
+
+       * src/vm/jit/dseg.h, src/vm/jit/m68k/arch.h,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h:
+       * src/vm/jit/dseg.h (dseg_adddata): Removed warning due to typo.
+
+       * src/vm/jit/m68k/arch.h (SUPPORT_LONG) Defined. (SUPPORT_LONG_ADD):
+       Defined. (SUPPORT_CONST_LOGICAL): Defined.
+
+       * src/vm/jit/m68k/codegen.c (ICMD_LADD): Implemented.
+       (ICMD_LADDCONST): Implemented. (ICMD_LSUB): Implemented.
+       (ICMD_LSUBCONST): Implemented. (ICMD_LNEG): Implemented.
+
+       * src/vm/jit/m68k/codegen.h (M_ISUBX): Added. (M_INEGX): Added.
+       [09becbd98429]
+
+2007-05-11  twisti  <twisti>
+
+       * configure.ac, src/mm/memory.c, src/vmcore/statistics.c,
+       src/vmcore/statistics.h:
+       * configure.ac (AC_CHECK_HEADERS): Added time.h. (AC_CHECK_FUNCS):
+       Added localtime, localtime_r, time.
+
+       * src/vmcore/statistics.c [HAVE_TIME_H] (time.h): Added.
+       (statistics_print_date): New function.
+       * src/vmcore/statistics.h (statistics_print_date): Added.
+
+       * src/mm/memory.c (memory_thread) [ENABLE_STATISTICS]: Call
+       statistics_print_date.
+       [25ead7bd5f52]
+
+       * src/vmcore/statistics.c:
+       * src/vmcore/statistics.c (statistics_print_memory_usage): Use
+       log_println instead of printf.
+       [061cff927754]
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/linux/md-os.c:
+       * src/vm/jit/arm/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+       * src/vm/jit/arm/linux/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart.
+       [d18fe002c94f]
+
+       * src/threads/lock-common.h, src/threads/native/lock.c,
+       src/threads/native/lock.h, src/threads/native/threads.h, src/threads
+       /threads-common.c, src/vmcore/statistics.c, src/vmcore/statistics.h:
+       * src/threads/threads-common.c (threads_create_thread): Removed
+       lock_init_execution_env.
+
+       * src/threads/lock-common.h (lock_init_execution_env): Removed.
+       (lock_record_free_pools): Likewise.
+
+       * src/threads/native/threads.h (threadobject): Removed ee.
+
+       * src/threads/native/lock.c (vm/finalizer.h): Added.
+       [ENABLE_GC_BOEHM] (mm/boehm-gc/include/gc.h): Likewise.
+       (lock_global_pool): Removed. (lock_global_pool_lock): Likewise.
+       (lock_init): Don't initialize lock_global_pool_lock.
+       (lock_record_init): Removed. (lock_init_execution_env): Likewise.
+       (lock_record_alloc_new_pool): Likewise. (lock_record_alloc_pool):
+       Likewise. (lock_record_free_pools): Likewise. (lock_record_alloc):
+       Likewise. (lock_record_recycle): Likewise.
+       (lock_hashtable_get_lock_record): Renamed to lock_hashtable_get.
+       (lock_record_new): New function. (lock_record_free): Likewise.
+       (lock_hashtable_remove): Likewise. [ENABLE_GC_BOEHM]
+       (lock_record_finalizer): Likewise.
+
+       * src/threads/native/lock.h (lock_execution_env_t): Removed.
+       (lock_record_pool_header_t): Likewise. (lock_record_pool_t):
+       Likewise. (lock_record_t): Renamed obj to object, removed nextfree.
+       [ENABLE_JVMTI] (lock_global_pool_lock, lock_global_pool): Removed.
+
+       * src/vmcore/statistics.c (size_lock_record_pool): Renamed to
+       size_lock_record. (statistics_print_memory_usage): Likewise.
+       * src/vmcore/statistics.h: Likewise.
+       [6c9eb67b735c]
+
+2007-05-11  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h:
+       * src/vm/jit/m68k/linux/md-abi.h (ADR_SAV_CNT): Increased by one
+       (%fp). (ADR_RES_CNT): Decreased by one (%fp).
+
+       * src/vm/jit/m68k/linux/md-abi.c (nregdescadr): Declared %fp a
+       REG_SAV.
+
+       * src/vm/jit/m68k/arch.h (SUPPORT_DIVISION): Defined.
+
+
+       * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Additional logic
+       to restore %fp when unwinding the stack.
+       [2c693aa2e5a2]
+
+2007-05-11  twisti  <twisti>
+
+       * src/threads/native/threads.h:
+       * src/threads/native/threads.h (threadobject): Removed next and
+       prev.
+       [f855349a44d5]
+
+2007-05-11  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c:
+       * src/vm/jit/m68k/codegen.c (codegen_emit): Fix stackframesize
+       allocation in not synchronized methods which call a builtin
+       returning a double. Merged with ENABLE_THREADS case. Added code to
+       copy interface registers.
+
+       * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Save temporary
+       registers, dunno if really needed, but its a slow path anyways.
+       [90d247b28159]
+
+2007-05-10  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/m68k/emit.c:
+       * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Make SOFTFLOAT
+       clean. (emit_verbosecall_exit): Likewise.
+
+       * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Mark comment about
+       gcc abi wiredness.
+
+       * src/vm/jit/m68k/codegen.h (M_D2F): Fixed. (M_F2D): Fixed.
+       [1fce7d6e6eed]
+
+2007-05-10  twisti  <twisti>
+
+       * src/threads/native/threads.c, src/threads/threads-common.c,
+       src/threads/threads-common.h, src/vm/vm.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/vmcore/options.c (opt_verbosethreads): Added.
+       * src/vmcore/options.h (opt_verbosethreads): Likewise.
+
+       * src/vm/vm.c (XXusage): Added -verbose:threads. (vm_create):
+       Likewise.
+
+       * src/threads/threads-common.c (threads_create_thread): Renamed
+       variable thread to t. (threads_thread_print_info): New function.
+       (threads_dump): Use threads_thread_print_info.
+
+       * src/threads/threads-common.h (threads_thread_print_info): Added.
+
+       * src/threads/native/threads.c (threads_init) [!NDEBUG]: Added
+       -verbose:threads debug-output. (threads_startup_thread): Likewise.
+       (threads_attach_current_thread): Likewise. (threads_detach_thread):
+       Likewise.
+       [837d882ff4d7]
+
+       * src/threads/native/threads.c, src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_thread_start_internal): Set
+       thread-flags. (threads_thread_start): Likewise.
+
+       * src/threads/native/threads.c (threads_startup_thread): Don't set
+       thread-flags.
+       [473c74e3b3f8]
+
+2007-05-10  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/patcher.c:
+       * src/vm/jit/powerpc64/patcher.c (patcher_checkcast_interface):
+       Fixed not flushing all bytes written.
+       [c68a841961bd]
+
+2007-05-09  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/codegen.c:
+       * src/vm/jit/powerpc64/codegen.c (ICMD_CHECKCAST): Use
+       branch_label_* instead of harcoded jump offsets.
+
+       (ICMD_INSTANCEOF): Likewise.
+       [42c458c7fbeb]
+
+2007-05-09  twisti  <twisti>
+
+       * src/lib/Makefile.am, src/lib/gnu/gnu/classpath/VMStackWalker.java,
+       src/lib/gnu/gnu/classpath/VMSystemProperties.java,
+       src/lib/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java,
+       src/lib/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/lib/gnu/java/lang/VMClassLoader.java,
+       src/lib/gnu/java/lang/VMString.java,
+       src/lib/gnu/java/lang/VMThread.java,
+       src/lib/gnu/java/lang/VMThrowable.java,
+       src/lib/gnu/java/security/VMAccessController.java,
+       src/lib/vm/reference/gnu/classpath/VMStackWalker.java,
+       src/lib/vm/reference/gnu/classpath/VMSystemProperties.java, src/lib/
+       vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java, src/l
+       ib/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+       src/lib/vm/reference/java/lang/VMClassLoader.java,
+       src/lib/vm/reference/java/lang/VMString.java,
+       src/lib/vm/reference/java/lang/VMThread.java,
+       src/lib/vm/reference/java/lang/VMThrowable.java,
+       src/lib/vm/reference/java/security/VMAccessController.java:
+       * src/lib/Makefile.am (VM_JAVA_FILES): Renamed vm/reference/ to
+       gnu/.
+
+       * src/lib/vm: Removed.
+       * src/lib/gnu: Added.
+       * src/lib/gnu/java: Likewise.
+       * src/lib/gnu/gnu: Likewise.
+       [b01c51c68bf2]
+
+2007-05-09  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.h:
+       * src/vm/jit/m68k/linux/md-abi.h (LA_SIZE_IN_POINTERS): Defined 0.
+       (PA_SIZE_IN_POINTERS): Removed. (PA_SIZE): Removed. (LA_LR_OFFSET):
+       Removed. (LA_SIZE_ALIGNED): Removed.
+
+       * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Removed linking
+       instructions, save only used registers.
+
+       (emit_verbosecall_exit): Likewise.
+
+       * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Depends on configure
+       option ENABLE_SOFTFLOAT.
+
+       * src/vm/jit/m68k/codegen.c (codegen_emit): Use M_FSTORE/M_FLOAT to
+       save/restore float registers without converting any values. Fixed
+       offset of IsSync.
+
+       (codegen_emit_stub_native): Move floating point return values into
+       floating point registers.
+
+       * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Save/restore
+       floating point registers.
+
+       (asm_call_jit_compiler): Save/restore volatile floating point
+       registers.
+
+       (asm_patcher_wrapper): Likewise.
+
+       (asm_handle_exception): Use fmovemd instructions to restore floatng
+       point registers without converting.
+
+       * src/vm/jit/m68k/codegen.h (M_FSTORE): Added. (M_FLOAT): Added.
+       [223653956636]
+
+       * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-os.c:
+       * src/vm/jit/powerpc64/linux/md-os.c
+       (thread_restartcriticalsection): Renamed to
+       md_critical_section_restart.
+
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+       [7e17b57deda1]
+
+2007-05-08  twisti  <twisti>
+
+       * configure.ac, src/vmcore/options.c:
+       * src/configure.ac (AC_CHECK_HEADERS): Added string.h.
+       (AC_CHECK_FUNCS): Added strdup.
+
+       * src/src/vmcore/options.c [HAVE_STRING_H] (string.h): Added #ifdef.
+       (options_get) HAVE_STRDUP]: Added.
+       [ecf613150ffd]
+
+2007-05-07  twisti  <twisti>
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/linux/md-os.c:
+       * src/vm/jit/alpha/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+       * src/vm/jit/alpha/linux/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart.
+       [8bb1aeffa059]
+
+       * src/threads/native/threads.c, src/threads/native/threads.h,
+       src/vm/jit/optimizing/profile.c:
+       * src/threads/native/threads.c (mainthreadobj): Removed.
+       * src/threads/native/threads.h (mainthreadobj): Likewise.
+
+       * src/vm/jit/optimizing/profile.c (threads/native/threads.h):
+       Likewise. (profile_thread): Rewritten thread iteration.
+       [ae773419190f]
+
+2007-05-07  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/linux/md-os.c:
+       * src/vm/jit/sparc64/codegen.c (codegen_emit): Adapted to critical
+       section renames.
+       * src/vm/jit/sparc64/linux/md-os.c: Likewise.
+       [7440f5ffe4e0]
+
+2007-05-07  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h:
+       * src/vm/jit/m68k/codegen.c (ICMD_FNEG): Implemented. (ICMD_DNEG):
+       Implemented.
+
+       * src/vm/jit/m68k/asmpart.S (asm_call_jit_compiler): Store volatile
+       floatregisters. (asm_patcher_wrapper): Likewise.
+       (asm_handle_exception): Restore float registers.
+
+       * src/vm/jit/m68k/codegen.h (M_FNEG): Added. (M_DNEG): Added.
+       [3c46ebb18bc6]
+
+       * tests/Makefile.am, tests/exception_restore_registers.java,
+       tests/exception_restore_registers.output:
+       * tests/exception_restore_registers.java: New test, tests if
+       variables get restored in case of exceptions.
+
+       * tests/exception_restore_registers.output: New file, expected
+       output.
+
+       * tests/Makefile.am: Added exception_restore_registers target.
+       [4903c88ec794]
+
+2007-05-07  twisti  <twisti>
+
+       * configure.ac, src/vm/jit/mips/uclinux/Makefile.am,
+       src/vm/jit/mips/uclinux/md-os.c:
+       * configure.ac (AC_CONFIG_FILES): Added
+       src/vm/jit/mips/uclinux/Makefile.
+
+       * src/vm/jit/mips/uclinux: New directory.
+       * src/vm/jit/mips/uclinux/md-os.c: New file.
+       * src/vm/jit/mips/uclinux/Makefile.am: Likewise.
+       [a2f9e9b4c127]
+
+       * src/vm/jit/mips/codegen.c, src/vm/jit/mips/linux/md-os.c:
+       * src/vm/jit/mips/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+       * src/vm/jit/mips/linux/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart.
+       [98af0627c6d6]
+
+       * configure.ac, src/vmcore/statistics.c:
+       * configure.ac (AC_CHECK_HEADERS): Added sys/mman.h, sys/resource.h.
+       (AC_CHECK_FUNCS): Added getrusage, mprotect.
+
+       * src/vmcore/statistics.c [HAVE_SYS_TIME_H] (sys/time.h): Include
+       conditionally. [HAVE_SYS_RESOURCE_H] (sys/resource.h): Likewise.
+       (getcputime) [!HAVE_GETRUSAGE]: Return 0.
+       [eb6879201b23]
+
+       * src/native/vm/java_lang_Thread.h:
+       * src/native/vm/java_lang_Thread.h (threads/native/threads.h):
+       Removed.
+       [81608585fa81]
+
+2007-05-07  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h:
+       * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Enabled.
+       (SUPPORT_FLOAT_CMP): Enabled. (SUPPORT_DOUBLE): Enabled.
+       (SUPPORT_DOUBLE_CMP): Enabled.
+
+       * src/vm/jit/m68k/codegen.c (ICMD_FCMPL): Implemented. (ICMD_DCMPL):
+       Likewise. (ICMD_FCMPG): Likewise. (ICMD_DCMPG): Likewise.
+       (ICMD_FMUL): Likewise. (ICMD_DMUL): Likewise. (ICMD_FDIV): Likewise.
+       (ICMD_DDIV): Likewise. (ICMD_FADD): Likewise. (ICMD_DADD): Likewise.
+       (ICMD_FSUB): Likewise. (ICMD_DSUB): Likewise. (ICMD_F2D): Likewise.
+       (ICMD_D2F): Likewise. (ICMD_BUILTIN): Handle float return values.
+       (codegen_emit_stub_native): Handle float values.
+
+       * src/vm/jit/m68k/codegen.h (M_FCMP): Added. (M_BFEQ): Added.
+       (M_BFLT): Added. (M_BFGT): Added. (M_BFUN): Added. (M_FADD): Added.
+       (M_DADD): Added. (M_FSUB): Added. (M_DSUB): Added. (M_FMUL): Added.
+       (M_DMUL): Added. (M_FDIV): Added. (M_DDIV): Added. (M_D2F): Added.
+       (M_F2D): Added.
+       [b351752b3490]
+
+2007-05-07  twisti  <twisti>
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_dump): Typo.
+       [3bc0b63b21b8]
+
+       * src/threads/native/threads.c, src/threads/threads-common.c,
+       src/threads/threads-common.h:
+       * src/threads/threads-common.c (threads_table_get): Made static and
+       removed table lock. (threads_dump): Lock threads table.
+
+       * src/threads/threads-common.h (threads_table_get): Removed.
+
+       * src/threads/native/threads.c (threads_cast_stopworld): Lock
+       threads table. (threads_cast_startworld): Likewise.
+       [0087aafbce90]
+
+2007-05-07  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md-asm.h:
+       * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed fp
+       arg passing.
+       * src/vm/jit/sparc64/md-abi.h: Likewise.
+
+       * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method): Likewise, but
+       the other way around.
+       * src/vm/jit/sparc64/md-asm.h: Likewise.
+       [fd7ab22fe3d1]
+
+2007-05-06  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c:
+       * src/vm/jit/m68k/codegen.c (codegen_emit): Allocate 2 additional
+       words in stackframe for long to double conversion.
+
+       * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Copy exception
+       object into correct register.
+
+       * src/vm/jit/m68k/codegen.h (M_FLD): Implemented. (M_DLD): Likewise.
+       (M_FST): Likewise. (M_DST): Likewise. (M_FLTMOVE): Likewise.
+       (M_INT2FLTMOVE): Likewise. (M_DBLMOVE): Likewise. (FCONST):
+       Likewise.
+       [0a407cecd8df]
+
+2007-05-06  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/linux/md-os.c,
+       src/vm/jit/sparc64/machine-instr.h:
+       * src/vm/jit/sparc64/codegen.c: Implemented threads support.
+       * src/vm/jit/sparc64/machine-instr.h: Likewise.
+       * src/vm/jit/sparc64/linux/md-os.c: Likewise.
+       [962f3ac2f269]
+
+2007-05-05  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/emit.c:
+       * src/vm/jit/m68k/emit.c (emit_patcher_stubs): Add thread support.
+       (emit_exception_check_areg): Removed dead code.
+
+       * src/vm/jit/m68k/codegen.c (codegen_emit): Add thread support.
+
+       * src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Likewise.
+       [2f26a013bf14]
+
+       * src/vmcore/linker.c:
+       * linker.c (linker_compute_subclasses):
+       threads_cast_[start|stop]world only available when using GC.
+       [ddaa473162cc]
+
+2007-05-05  pm  <pm>
+
+       * contrib/vmlog/Makefile.am, src/vm/Makefile.am:
+       * contrib/vmlog/Makefile.am (AM_CPPFLAGS): Add include directories
+       for vmlog.
+        * src/vm/Makefile.am: Likewise.
+       [0200182415ca]
+
+2007-05-04  tbfg  <tbfg>
+
+       * src/vmcore/linker.c:
+       * linker.c (linker_compute_subclasses): Only call
+       threads_cast_[start|stop]world when ENABLE_THREADS.
+       [8a12809e3939]
+
+2007-05-03  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/md.c:
+       * src/vm/jit/m68k/md.c (md_stacktrace_get_returnaddress): Removed
+       braindead address check and fixed the real bug.
+
+       * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Added float
+       argument handling. (asm_call_jit_compiler): Fixed stack offset bug.
+       [4d450bf43726]
+
+2007-05-03  twisti  <twisti>
+
+       * src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/jit/x86_64/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+       * src/vm/jit/x86_64/linux/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart.
+       [58f763abf182]
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/i386/linux/md-os.c:
+       * src/vm/jit/i386/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+       * src/vm/jit/i386/linux/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart.
+       [1ea512b3aa7e]
+
+       * src/cacaoh/dummy.c, src/threads/critical.c, src/threads/critical.h,
+       src/threads/native/threads.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/codegen-common.h, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vmcore/linker.c:
+       * src/threads/critical.c (critical_compare): Renamed to
+       critical_comparator. (critical_find): Removed.
+       (critical_register_critical_section): Renamed to
+       critical_section_register. (critical_find_restart_point): Call
+       avl_find. (critical_register_asm_critical_sections): Call
+       critical_section_register.
+
+       * src/threads/critical.h (critical_section_node_t): Renamed members.
+       (thread_restartcriticalsection): Renamed to
+       md_critical_section_restart.
+
+       * src/threads/native/threads.c (threads_cast_darwinstop): Call
+       md_critical_section_restart. (threads_sigsuspend_handler): Likewise.
+
+       * src/vmcore/linker.c (linker_compute_subclasses): Call
+       threads_cast_{start,stop}world, removed LOCK_MONITOR_{ENTER,EXIT}.
+
+       * src/cacaoh/dummy.c (threads_cast_stopworld): Added.
+       (threads_cast_startworld): Likewise.
+
+       * src/vm/jit/codegen-common.c (codegen_setup): Setup listcritical.
+       (codegen_reset): Likewise. (codegen_critical_section_new): New
+       function. (codegen_critical_section_start): Likewise.
+       (codegen_critical_section_end): Likwise.
+       (codegen_critical_section_finish): Likewise. (codegen_finish): Call
+       codegen_critical_section_finish. (codegen_threadcritrestart):
+       Removed. (codegen_threadcritstart): Likewise.
+       (codegen_threadcritstop): Likewise.
+
+       * src/vm/jit/codegen-common.h (codegen_critical_section_t): Renamed
+       to critical_section_ref_t. (codegendata): Added listcritical,
+       removed threadcrit, threadcritcurrent and threadcritcount.
+       (CODEGEN_CRITICAL_SECTION_NEW, CODEGEN_CRITICAL_SECTION_START)
+       (CODEGEN_CRITICAL_SECTION_END): Defined.
+
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): Use
+       CODEGEN_CRITICAL_SECTION_* macros.
+
+       * src/vm/jit/powerpc/linux/md-os.c (thread_restartcriticalsection):
+       Renamed to md_critical_section_restart.
+       [7f54f774046b]
+
+       * src/mm/boehm-gc/include/gc.h:
+       * src/mm/boehm-gc/include/gc.h (GC_HAVE_BUILTIN_BACKTRACE):
+       Commented, we don't need it and uClibc doesn't have it.
+       [52f7bbb43963]
+
+       * src/toolbox/avl.c:
+       * src/toolbox/avl.c (toolbox/logging.h): Added. (vm/global.h):
+       Likewise. (vm/vm.h): Likewise. (avl_insert_intern): Use vm_abort
+       instead of assert. (avl_insert): Removed debug code. (avl_dump): Use
+       logging functions.
+       [6c16dd030e43]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_start_native_call)
+       [ENABLE_JAVASE]: This has to be ENABLE_JNI.
+       (codegen_finish_native_call): Likewise.
+       [3953e7c5db17]
+
+       * src/toolbox/avl.c, src/toolbox/avl.h, src/vm/jit/codegen-common.c:
+       * src/toolbox/avl.c (avl_insert_intern): Changed order of
+       comparator-arguments. (avl_find): Likewise.
+
+       * src/toolbox/avl.h (avl_comparator): Renamed arguments, to reflect
+       the change.
+
+       * src/vm/jit/codegen-common.c (methodtree_comparator): Likewise.
+       [d7c021bc6103]
+
+       * src/threads/critical.c, src/toolbox/avl.c, src/toolbox/avl.h,
+       src/vm/jit/codegen-common.c:
+       * src/toolbox/avl.h (avl_tree): Renamed to avl_tree_t. (avl_node):
+       Renamed to avl_node_t.
+
+       * src/toolbox/avl.c: Likewise.
+       * src/threads/critical.c: Likewise.
+       * src/vm/jit/codegen-common.c: Likewise.
+       [78a3161d59f0]
+
+       * contrib/check_dangerous_printf.pl:
+       * contrib/check_dangerous_printf.pl: Removed this file in favor of
+       pscan.
+       [01c3063dac5a]
+
+2007-05-03  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c:
+       * src/vm/jit/m68k/codegen.c (ICMD_CALOAD): Fixed.
+
+       * src/vm/jit/m68k/patcher.c (*): Removed patching back of old
+       opcodes from patcher_wrapper, moved into each patcher.
+       (patcher_patch_back): Added.
+       [b5bd8907ff04]
+
+2007-05-02  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/codegen.c:
+       * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Fixed. (ICMD_IREM):
+       Fixed. (ICMD_LASTORE): Use M_LST. (ICMD_DASTORE): Use M_LST.
+       (ICMD_LALOAD): Use M_LLD. (ICMD_DALOAD): Use M_LLD.
+       [e53aa985f343]
+
+2007-05-02  twisti  <twisti>
+
+       * src/native/vm/cldc1.1/java_lang_Float.c:
+       * src/native/vm/cldc1.1/java_lang_Float.c (native/native.h):
+       Removed. (native/include/java_lang_Float.h): Added.
+       [54ab8fef4a97]
+
+       * src/native/vm/cldc1.1/java_lang_Double.c:
+       * src/native/vm/cldc1.1/java_lang_Double.c
+       (native/include/java_lang_Double.h): Added. (longBitsToDouble):
+       Fixed return type.
+       [c178e4019030]
+
+       * src/threads/native/threads.c, src/threads/threads-common.c,
+       src/threads/threads-common.h:
+       * src/threads/threads-common.c (threads_table_get_threads): New
+       function.
+
+       * src/threads/threads-common.h (threads_table_get_threads): Added.
+
+       * src/threads/native/threads.c (threads_cast_sendsignals):
+       Rewritten. (threads_cast_stopworld): Likewise.
+       [eb798e490771]
+
+2007-05-02  tbfg  <tbfg>
+
+       * src/native/vm/cldc1.1/java_lang_Double.c:
+       * java_lang_Double.c (Java_java_lang_Double_doubleToLongBits): Added
+       missing JNIEnv* argument to signature.
+       [f3210d71cb99]
+
+2007-05-02  twisti  <twisti>
+
+       * src/vmcore/class.c:
+       * src/vmcore/class.c (class_load_attributes): Disable annotation
+       loading for the release.
+       [0af4700c23ad]
+
+       * src/threads/native/threads.c, src/threads/threads-common.c,
+       src/threads/threads-common.h:
+       * src/threads/threads-common.c (threads_preinit): Create and
+       initialize the main-thread. (threads_table_init): Changed signature,
+       insert main-thread and maintain a used list too.
+       (threads_table_add): Use locking and maintain used list.
+       (threads_table_remove): Likewise. (threads_table_get): New function.
+       (threads_table_get_non_daemons): Likewise. (threads_table_first):
+       Likewise. (threads_table_next): Likewise. [!NDEBUG]
+       (threads_table_dump): Use log_* functions. (threads_dump): Use
+       threads-table and functions.
+
+       * src/threads/threads-common.h (threads_table_entry_t): Made a
+       struct and renamed nextfree to next. (threads_table_get): Added
+       (threads_table_get_non_daemons): Likewise. (threads_table_first):
+       Likewise. (threads_table_next): Likewise. [!NDEBUG]
+       (threads_table_dump): Likewise. (threads_impl_table_init): Likewise.
+       (threads_table_lock): Likewise. (threads_table_unlock): Likewise.
+       (threads_set_current_threadobject): Likewise.
+
+       * src/threads/native/threads.c (threadlistlock): Removed.
+       (threads_impl_preinit): Removed main-thread initialization code.
+       (threads_impl_table_init): New function. (threads_table_lock): New
+       function. (threads_table_unlock): Likewise. (threads_init): Get
+       main-thread from threads-table and removed thread-list code.
+       (threads_attach_current_thread): Likewise. (threads_detach_thread):
+       Removed thread-list code. (threads_find_non_daemon_thread): Removed.
+       (threads_join_all_threads): Use threads_table_get_non_daemons.
+       [0700dff8d4c1]
+
+       * src/vm/jit/powerpc/linux/md-os.c:
+       * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv):
+       Added uClibc support. (md_signal_handler_sigtrap): Likewise.
+       (md_signal_handler_sigusr2): Likewise.
+       (thread_restartcriticalsection): Likewise.
+       [059aa5d19855]
+
+2007-05-01  pm  <pm>
+
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/disass.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/tests/dacapo.status:
+       * src/vm/jit/s390/md.c (md_dump_context): Added. Fatal signals now
+       print the context and a stacktrace.
+       * src/vm/jit/s390/emit.h (emit_restore_pv): Added. Fixes bug where
+       REG_PV recalculation uses dseg value to recalculate REG_PV.
+       * src/vm/jit/s390/emit.c: Likewise.
+       * src/vm/jit/s390/codegen.h (N_RI, N_RI2): Test immediate operand for
+       correct signedness.
+       * src/vm/jit/s390/codegen.c (codegen_emit): Use emit_restore_pv for
+       REG_PV recalculation/
+       * src/vm/jit/s390/disass.c (disass_pseudo_instr): Fix formating.
+       * src/vm/jit/s390/tests/dacapo.status: Added.
+       [ff3277613b53]
+
+2007-05-01  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h:
+       * src/vm/jit/sparc64/codegen.h: Removed unused var_to_reg_int
+       define.
+
+       * src/vm/jit/sparc64/codegen.c: Fixed JIT float argument passing via
+       stack.
+
+       * src/vm/jit/sparc64/asmpart.S (asm_vm_call): Fixed integer argument
+       passing via stack args.
+       [e33c45b78466]
+
+2007-05-01  pm  <pm>
+
+       * src/vm/jit/s390/codegen.h:
+       * src/vm/jit/s390/codegen.h (gen_bound_check,
+       gen_nullptr_check_intern, gen_bound_check, N_LONG_0): Remove because
+       obsolete.
+       [d859db890556]
+
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/disass.c:
+       * src/vm/jit/s390/codegen.c (codegen_emit): Use new emit_label and
+       emit_label_* functions.
+       * src/vm/jit/s390/disass.c (disass_pseudo_instr): Nicer formatting for
+       ill pseudo instruction.
+       [cc1ac3e37507]
+
+       * src/vm/jit/emit-common.h:
+       * src/vm/jit/emit-common.h (BRANCH_LABEL_6): Added.
+       [b90fe58b8782]
+
+2007-05-01  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-os.c:
+       * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill): Support
+       EXCEPTION_HARDWARE_ARITHMETIC.
+
+       * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Use corret opcode for
+       word forms.
+
+       * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Implemented.
+       (ICMD_IREMPOW2): Implemented. (ICMD_ISHLCONST): Fixed.
+       (ICMD_ISHRCONST): Fixed. (ICMD_IUSHRCONST): Fixed. (ICMD_SALOAD):
+       Signextension fix. (ICMD_LALOAD): Implemented. (ICMD_LASTORE):
+       Fixed. (ICMD_IASTORE): Fixed. (ICMD_MULITANEWARRAY): Fixed.
+
+       * src/vm/jit/m68k/codegen.h (M_IADDX): Added. (M_IXOR): Fixed.
+       (M_BCS): Fixed.
+       [89edfe323c24]
+
+2007-04-30  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S:
+       * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Restore
+       registers correctly.
+       [967120c3cdb9]
+
+2007-04-30  twisti  <twisti>
+
+       * src/vm/jit/inline/Makefile.am:
+       * src/vm/jit/inline/Makefile.am (AM_CPPFLAGS): Added
+       -I$(top_builddir)/src.
+       [e8368e38b6ec]
+
+2007-04-30  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/stacktrace.c:
+       * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Fixed.
+       (emit_arithmetic_check): Implemented.
+
+       * src/vm/jit/m68k/md.c (md_get_method_patch_address): Changed
+       invoking register. (md_stacktrace_get_returnaddress): Fix for
+       linking words on stack.
+
+       * src/vm/jit/m68k/codegen.c (IUSHRCONST): Fix. (ICMD_IOR):
+       Implemented. (ICMD_IORCONST): Likewise. (ICMD_IXOR): Likewise.
+       (ICMD_IXORCONST): Likewise. (ICMD_INVOKEVIRTUAL): Changed invoking
+       register. (ICMD_INVOKEINTERFACE): Likewise.
+
+       * src/vm/jit/m68k/patcher.c (patcher_invokevirtual): Changed
+       invoking register.
+
+       * src/vm/jit/m68k/asmpart.S (asm_vm_call_method_exception_handler):
+       Proper stack restauration. (L_asm_call_jit_compiler_exception):
+       Implemented. (asm_patcher_wrapper): Fixses.
+       (L_asm_patcher_wrapper_exception): Implemented.
+
+       * src/vm/jit/m68k/codegen.h (M_IXOR): Added. (M_IOR_IMM): Added.
+       (M_IXOR_IMM): Added.
+
+       * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe):
+       Comment and further m68k stuff.
+       [2ac9ff4e6c4d]
+
+2007-04-29  pm  <pm>
+
+       * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/disass.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/machine-instr.h,
+       src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390
+       /md-asm.h, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c:
+       * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/emit.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/machine-instr.h,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/arch.h, src/vm/jit/s390
+       /md-asm.h, src/vm/jit/s390/disass.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md-abi.c: Adapted S390
+       port to changes from branches/twisti (hardware exceptions,
+       emit_branch, abi_registers_*), jctest works again. Cleaned up almost
+       all dead x86_64 code.
+       [2ec074267d97]
+
+2007-04-28  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/asmpart.S:
+       * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Fixed stack
+       alignement in first save.
+       [65770b01fe81]
+
+2007-04-27  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c,
+       src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/linux/md-os.h,
+       src/vm/jit/m68k/machine-instr.h, src/vm/jit/m68k/md.c,
+       src/vm/jit/m68k/patcher.c:
+       * src/vm/jit/m68k/emit.c (emit_arrayindexoutofbounds_check): Fixed.
+       * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill): AIOOB
+       fixed. Editor boiler plate added.
+
+       * src/vm/jit/m68k/linux/md-os.h: Editor boiler plate.
+
+       * src/vm/jit/m68k/linux/md-abi.c: Likewise.
+
+       * src/vm/jit/m68k/md.c: Likewise.
+
+       * src/vm/jit/m68k/machine-instr.h: Likewise.
+
+       * src/vm/jit/m68k/patcher.c: Editor boiler plate.
+       (patcher_invokeinterface): Implemented. (patcher_get_putfield):
+       Implemented. (patcher_resolve_class): Implemented.
+       (patcher_get_putstatic): Implemented.
+
+       * src/vm/jit/m68k/codegen.c: Editor boiler plate. (ICMD_GETSTATIC):
+       Added patcher. (ICMD_AASTORE): Fixed.
+
+       * src/vm/jit/m68k/asmpart.S: Editor boiler plate.
+       (asm_vm_call_method_exception_handler): Fixed used register. Return
+       values in %d0 and %a0 as gcc sometimes expects pointers in %a0.
+       [5b6400d328af]
+
+2007-04-27  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md-abi.c,
+       src/vm/jit/sparc64/solaris/md-os.c:
+       * src/vm/jit/sparc64/emit.c: Keeping stack 16-byte aligned when
+       calling C/native functions from the stack. (Solaris requires this)
+       * src/vm/jit/sparc64/codegen.c: Likewise.
+       * src/vm/jit/sparc64/codegen.h: Likewise.
+
+       * src/vm/jit/sparc64/md-abi.c: Removed zero sized abi_register_*
+       arrays. (not allowed in ISO C)
+
+       * src/vm/jit/sparc64/solaris/md-os.c: Preliminary hardware exception
+       handling. (untested)
+       [e70daa591465]
+
+2007-04-26  twisti  <twisti>
+
+       * src/vm/jit/inline/inline.h, src/vm/jit/jit.c:
+       * src/vm/jit/inline/inline.h (config.h): Added. (inline_inline):
+       Likewise.
+
+       * src/vm/jit/jit.c (threads/threads-common.h): Added.
+       [ENABLE_INLINING] (vm/jit/inline/inline.h): Likewise.
+       [ENABLE_THREADS] (threads/native/threads.h): Removed.
+       [9544b7246cc7]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c [ENABLE_THREADS] (threads/native/threads.h): Removed.
+       (threads/threads-common.h): Added.
+       [13c16140a43d]
+
+       * src/native/vm/java_lang_Thread.c:
+       * src/native/vm/java_lang_Thread.c: Set Id keyword.
+       [a0083a667694]
+
+       * src/native/vm/java_lang_Thread.c:
+       * src/native/vm/java_lang_Thread.c (start): Renamed
+       threads_start_javathread to threads_thread_start.
+       [e25c3f63b5f1]
+
+       * src/mm/memory.c, src/threads/native/threads.c, src/threads/threads-
+       common.c, src/threads/threads-common.h, src/vm/finalizer.c,
+       src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c,
+       src/vm/signal.c:
+       * src/threads/threads-common.c (threads_thread_create_internal):
+       Renamed to threads_thread_start_internal and start the thread.
+       (threads_start_javathread): Renamed to threads_thread_start.
+       * src/threads/threads-common.h: Likewise.
+
+       * src/threads/native/threads.c (threads_start_thread): Renamed to
+       threads_impl_thread_start.
+
+       * src/mm/memory.c (thread_memory): Removed. (memory_start_thread):
+       Call threads_thread_start_internal.
+
+       * src/vm/finalizer.c (thread_finalizer): Removed.
+       (finalizer_start_thread): Call threads_thread_start_internal.
+
+       * src/vm/signal.c (thread_signal): Removed. (signal_start_thread):
+       Call threads_thread_start_internal.
+
+       * src/vm/jit/optimizing/profile.c (thread_profile): Removed.
+       (profile_start_thread): Call threads_thread_start_internal.
+
+       * src/vm/jit/optimizing/recompile.c (thread_recompile): Removed.
+       (recompile_start_thread): Call threads_thread_start_internal.
+       [cf0ec721a423]
+
+       * src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/threads-common.c (threads/critical.h): Added.
+       (threads/native/threads.h): Removed. (threads_table): Added.
+       (threads_preinit): New function. (threads_table_init): Moved from
+       implementation file. (threads_table_add): Likewise.
+       (threads_table_remove): Likewise. (threads_table_dump): Likewise.
+
+       * src/threads/threads-common.h (threads_table_entry_t)
+       (threads_table_t): Added. (threads_preinit): Likewise.
+       (threads_table_add): Likewise. (threads_table_remove): Likewise.
+       (threads_impl_preinit): Likewise. (threads_init_threadobject):
+       Likewise.
+
+       * src/threads/native/threads.c (threads_table): Removed.
+       (threads_preinit): Renamed to threads_impl_preinit.
+       (threads_table_init): Removed. (threads_table_add): Likewise.
+       (threads_table_remove): Likewise. (threads_table_dump): Likewise.
+
+       * src/threads/native/threads.h (threads_table_entry_t)
+       (threads_table_t): Removed. (threads_preinit): Likewise.
+       [98b0208c933b]
+
+2007-04-25  stefan  <stefan>
+
+       * src/vm/jit/i386/darwin/md-os.c:
+       * src/vm/jit/i386/darwin/md-os.c: added threads/threads-common.h,
+       removed vm/jit/i386/md-abi.h
+       [b40b6e3adec2]
+
+       * src/vm/jit/i386/darwin/md-os.c:
+       * src/vm/jit/i386/darwin/md-os.c: attempt at porting the exception
+       changes (see r7596 & r7648).
+       [e46dd5485bb0]
+
+2007-04-25  twisti  <twisti>
+
+       * src/threads/lock-common.h, src/threads/threads-common.c, src/threads
+       /threads-common.h:
+       * src/threads/lock-common.h (threads/threads-common.h): Removed that
+       header again and added a comment about not including thread headers.
+
+       * src/threads/threads-common.c (threads_start_javathread): Reverted.
+       * src/threads/threads-common.h (threads_start_javathread): Likewise.
+       [823fb8fdda16]
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_dump) [!SIZEOF_VOID_P == 8]:
+       Fixed warning.
+       [b96d90a7e7d5]
+
+       * src/threads/lock-common.h, src/threads/threads-common.c, src/threads
+       /threads-common.h:
+       * src/threads/threads-common.c (threads_start_javathread): Changed
+       signature.
+
+       * src/threads/lock-common.h (threads/threads-common.h): Added.
+       [ENABLE_THREADS]: Only define functions when threads are enabled.
+
+       * src/threads/threads-common.h (native/include/java_lang_Thread.h):
+       Removed. [ENABLE_THREADS]: Only define functions when threads are
+       enabled. (threads_start_javathread): Changed signature.
+       [744b5d438408]
+
+       * src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c:
+       * src/vm/jit/mips/codegen.c: Changed lock includes.
+       * src/vm/jit/mips/emit.c: Likewise.
+       [901b6ff89903]
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c:
+       * src/vm/jit/arm/codegen.c: Changed lock include.
+       * src/vm/jit/arm/emit.c: Likewise.
+       [9fc8e573ad28]
+
+       * src/vm/jit/arm/emit.c:
+       * src/vm/jit/arm/emit.c (emit_load): Use switch-case instead of if-
+       else contruct. (emit_store): Likewise. (emit_copy): Likewise.
+       [a191766f4557]
+
+       * src/vm/jit/alpha/emit.c:
+       * src/vm/jit/alpha/emit.c: Set Id keyword.
+       [b4b601dd0a67]
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c:
+       * src/vm/jit/alpha/codegen.c: Changed lock include.
+       * src/vm/jit/alpha/emit.c: Likewise.
+       [06bc88907312]
+
+       * src/vm/jit/alpha/codegen.c:
+       * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Use
+       md->params to save and restore argument registers.
+       [1cf56ebf1324]
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c:
+       * src/vm/jit/i386/codegen.c: Changed lock include.
+       * src/vm/jit/i386/emit.c: Likewise.
+       [3d8268805f33]
+
+       * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c:
+       * src/vm/jit/powerpc64/codegen.c: Changed lock includes.
+       * src/vm/jit/powerpc64/emit.c: Likewise.
+       [829ba893ab30]
+
+       * src/vm/jit/powerpc/emit.c:
+       * src/vm/jit/powerpc/emit.c: Set Id keyword.
+       [3970210193ef]
+
+       * src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c:
+       * src/vm/jit/powerpc/codegen.c: Fixed lock include.
+       * src/vm/jit/powerpc/emit.c: Likewise.
+       [6d8fd28976c5]
+
+       * src/vm/jit/powerpc/linux/md-abi.c:
+       * src/vm/jit/powerpc/linux/md-abi.c (abi_registers_float_temporary):
+       Fixed number of registers.
+       [43002ce63f4b]
+
+       * src/mm/memory.c, src/native/jni.c, src/native/native.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Thread.c,
+       src/threads/Makefile.am, src/threads/lock-common.h,
+       src/threads/native/lock.h, src/threads/native/threads.c,
+       src/threads/none/lock.h, src/threads/threads-common.c,
+       src/toolbox/avl.c, src/toolbox/hashtable.c, src/toolbox/list.c,
+       src/vm/builtin.c, src/vm/finalizer.c, src/vm/initialize.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/jit.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c,
+       src/vm/jit/patcher.h, src/vm/jit/show.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/string.c, src/vmcore/class.c, src/vmcore/classcache.c,
+       src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/suck.c,
+       src/vmcore/utf8.c:
+       * src/threads/lock-common.h: New file.
+
+       * src/threads/native/lock.h: Removed function prototypes.
+       * src/threads/none/lock.h (LOCK_INIT_OBJECT_LOCK): Added.
+
+       * src/mm/memory.c, src/native/jni.c, src/native/native.c,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Thread.c,
+       src/threads/Makefile.am, src/threads/native/threads.c, src/threads
+       /threads-common.c, src/toolbox/avl.c, src/toolbox/hashtable.c,
+       src/toolbox/list.c, src/vm/builtin.c, src/vm/finalizer.c,
+       src/vm/initialize.c, src/vm/jit/inline/inline.c, src/vm/jit/jit.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c,
+       src/vm/jit/patcher.h, src/vm/jit/show.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/string.c, src/vmcore/class.c, src/vmcore/classcache.c,
+       src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/suck.c,
+       src/vmcore/utf8.c: Updated headers.
+       [70b6420148e2]
+
+       * src/mm/memory.h:
+       * src/mm/memory.h: Updated copyright header.
+       [c16a6646ceb2]
+
+       * src/mm/memory.c, src/threads/native/threads.c, src/threads/threads-
+       common.c, src/threads/threads-common.h, src/vm/finalizer.c,
+       src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c,
+       src/vm/signal.c:
+       * src/threads/threads-common.c (threads_create_thread): Renamed to
+       threads_thread_create_internal and a new function.
+       (threads_start_javathread): Use threads_create_thread.
+
+       * src/threads/threads-common.h (threads_create_thread): Changed
+       signature. (threads_thread_create_internal): Added.
+
+       * src/threads/native/threads.c (threads_set_current_threadobject):
+       Made non-static. (threads_init_threadobject): Likewise, use
+       threads_create_thread. (threads_init): Cleanup.
+       (threads_startup_thread): Likewise. (threads_attach_current_thread):
+       Use threads_create_thread.
+
+       * src/vm/jit/optimizing/profile.c (profile_start_thread): Replaced
+       threads_create_thread with threads_thread_create_internal.
+       * src/vm/jit/optimizing/recompile.c (recompile_start_thread):
+       Likewise.
+       * src/vm/signal.c (signal_start_thread): Likewise.
+       * src/vm/finalizer.c (finalizer_start_thread): Likewise.
+       * src/mm/memory.c (memory_start_thread): Likewise.
+       [052522c1db52]
+
+2007-04-25  stefan  <stefan>
+
+       * src/vmcore/linker.c:
+       * src/vmcore/linker.c (linker_init): added missing
+       lock_init_object_lock.
+       [191964287e88]
+
+2007-04-25  twisti  <twisti>
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_preinit): We always need
+       variable t.
+       [b88c5990edf2]
+
+       * src/native/native.c:
+       * src/native/native.c (native/include/java_lang_Object.h): Include
+       always. [ENABLE_JAVAME_CLDC1_1]
+       (native/include/com_sun_cldc_io_ResourceInputStream.h)
+       (native/include/com_sun_cldc_io_j2me_socket_Protocol.h): Added.
+       [f994e6222404]
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_init): Use variable t
+       instead of mainthreadobj->object, makes code simpler.
+       [a0a835dd24fe]
+
+       * src/threads/native/threads.c, src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_create_thread)
+       [ENABLE_GC_BOEHM]: Use GCNEW_UNCOLLECTABLE.
+       (threads_start_javathread) [ENABLE_GC_BOEHM]: Likewise.
+
+       * src/threads/native/threads.c (threads_preinit) [ENABLE_GC_BOEHM]:
+       Likewise. (threads_init): Removed resizing-of-threadobject code, we
+       don't need it anymore. (threads_attach_current_thread)
+       [ENABLE_GC_BOEHM]: Use GCNEW_UNCOLLECTABLE. (threads_detach_thread)
+       [ENABLE_GC_BOEHM]: Use GCFREE.
+       [af7e5b77a250]
+
+2007-04-24  twisti  <twisti>
+
+       * src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/threads-common.c: Set Id keyword.
+       * src/threads/threads-common.h: Likewise.
+       [ae9e95a7b28d]
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_dump): Also print integer
+       thread id, so it's easier to compare with the ones from gdb.
+       [249c326e0a4b]
+
+2007-04-24  tbfg  <tbfg>
+
+       * m4/threads.m4:
+       * threads.m4: Fixed a typo
+       [7a9720e29965]
+
+2007-04-23  twisti  <twisti>
+
+       * contrib/.cvsignore, doc/.cvsignore, doc/handbook/.cvsignore,
+       man/.cvsignore, src/.cvsignore, src/cacao/.cvsignore,
+       src/cacaoh/.cvsignore, src/fdlibm/.cvsignore, src/lib/.cvsignore,
+       src/mm/.cvsignore, src/mm/boehm-gc/.cvsignore, src/mm/boehm-
+       gc/doc/.cvsignore, src/mm/boehm-gc/include/.cvsignore, src/mm/cacao-
+       gc/.cvsignore, src/native/.cvsignore, src/native/include/.cvsignore,
+       src/native/jvmti/.cvsignore, src/native/tools/.cvsignore,
+       src/native/vm/.cvsignore, src/native/vm/cldc1.1/.cvsignore,
+       src/native/vm/gnu/.cvsignore, src/scripts/.cvsignore,
+       src/threads/.cvsignore, src/threads/native/.cvsignore,
+       src/threads/none/.cvsignore, src/toolbox/.cvsignore,
+       src/vm/.cvsignore, src/vm/jit/.cvsignore,
+       src/vm/jit/allocator/.cvsignore, src/vm/jit/alpha/.cvsignore,
+       src/vm/jit/alpha/freebsd/.cvsignore,
+       src/vm/jit/alpha/linux/.cvsignore, src/vm/jit/arm/.cvsignore,
+       src/vm/jit/arm/linux/.cvsignore, src/vm/jit/i386/.cvsignore,
+       src/vm/jit/i386/darwin/.cvsignore,
+       src/vm/jit/i386/freebsd/.cvsignore,
+       src/vm/jit/i386/linux/.cvsignore, src/vm/jit/inline/.cvsignore,
+       src/vm/jit/intrp/.cvsignore, src/vm/jit/loop/.cvsignore,
+       src/vm/jit/m68k/.cvsignore, src/vm/jit/m68k/linux/.cvsignore,
+       src/vm/jit/mips/.cvsignore, src/vm/jit/mips/irix/.cvsignore,
+       src/vm/jit/mips/linux/.cvsignore, src/vm/jit/optimizing/.cvsignore,
+       src/vm/jit/parisc/.cvsignore, src/vm/jit/parisc/linux/.cvsignore,
+       src/vm/jit/powerpc/.cvsignore, src/vm/jit/powerpc/darwin/.cvsignore,
+       src/vm/jit/powerpc/linux/.cvsignore,
+       src/vm/jit/powerpc/netbsd/.cvsignore,
+       src/vm/jit/powerpc64/.cvsignore,
+       src/vm/jit/powerpc64/linux/.cvsignore, src/vm/jit/s390/.cvsignore,
+       src/vm/jit/schedule/.cvsignore, src/vm/jit/sparc64/.cvsignore,
+       src/vm/jit/sparc64/linux/.cvsignore,
+       src/vm/jit/sparc64/solaris/.cvsignore, src/vm/jit/tools/.cvsignore,
+       src/vm/jit/verify/.cvsignore, src/vm/jit/x86_64/.cvsignore,
+       src/vm/jit/x86_64/freebsd/.cvsignore,
+       src/vm/jit/x86_64/linux/.cvsignore, src/vmcore/.cvsignore,
+       tests/.cvsignore, tests/regression/.cvsignore,
+       tests/regression/codepatching/.cvsignore,
+       tests/regression/native/.cvsignore, tests/stack/.cvsignore:
+       * contrib/.cvsignore, doc/.cvsignore, doc/handbook/.cvsignore,
+       man/.cvsignore, src/.cvsignore, src/cacao/.cvsignore,
+       src/cacaoh/.cvsignore, src/fdlibm/.cvsignore, src/lib/.cvsignore,
+       src/mm/.cvsignore, src/mm/boehm-gc/.cvsignore, src/mm/boehm-
+       gc/doc/.cvsignore, src/mm/boehm-gc/include/.cvsignore, src/mm/cacao-
+       gc/.cvsignore, src/native/.cvsignore, src/native/include/.cvsignore,
+       src/native/jvmti/.cvsignore, src/native/tools/.cvsignore,
+       src/native/vm/.cvsignore, src/native/vm/cldc1.1/.cvsignore,
+       src/native/vm/gnu/.cvsignore, src/scripts/.cvsignore,
+       src/threads/.cvsignore, src/threads/none/.cvsignore,
+       src/threads/posix/.cvsignore, src/toolbox/.cvsignore,
+       src/vm/.cvsignore, src/vm/jit/.cvsignore,
+       src/vm/jit/allocator/.cvsignore, src/vm/jit/alpha/.cvsignore,
+       src/vm/jit/alpha/freebsd/.cvsignore,
+       src/vm/jit/alpha/linux/.cvsignore, src/vm/jit/arm/.cvsignore,
+       src/vm/jit/arm/linux/.cvsignore, src/vm/jit/i386/.cvsignore,
+       src/vm/jit/i386/cygwin/.cvsignore,
+       src/vm/jit/i386/darwin/.cvsignore,
+       src/vm/jit/i386/freebsd/.cvsignore,
+       src/vm/jit/i386/linux/.cvsignore, src/vm/jit/inline/.cvsignore,
+       src/vm/jit/intrp/.cvsignore, src/vm/jit/loop/.cvsignore,
+       src/vm/jit/m68k/.cvsignore, src/vm/jit/m68k/linux/.cvsignore,
+       src/vm/jit/mips/.cvsignore, src/vm/jit/mips/irix/.cvsignore,
+       src/vm/jit/mips/linux/.cvsignore, src/vm/jit/optimizing/.cvsignore,
+       src/vm/jit/parisc/.cvsignore, src/vm/jit/parisc/linux/.cvsignore,
+       src/vm/jit/powerpc/.cvsignore, src/vm/jit/powerpc/darwin/.cvsignore,
+       src/vm/jit/powerpc/linux/.cvsignore,
+       src/vm/jit/powerpc/netbsd/.cvsignore,
+       src/vm/jit/powerpc64/.cvsignore,
+       src/vm/jit/powerpc64/linux/.cvsignore, src/vm/jit/s390/.cvsignore,
+       src/vm/jit/schedule/.cvsignore, src/vm/jit/sparc64/.cvsignore,
+       src/vm/jit/sparc64/linux/.cvsignore,
+       src/vm/jit/sparc64/solaris/.cvsignore, src/vm/jit/tools/.cvsignore,
+       src/vm/jit/verify/.cvsignore, src/vm/jit/x86_64/.cvsignore,
+       src/vm/jit/x86_64/freebsd/.cvsignore,
+       src/vm/jit/x86_64/linux/.cvsignore, src/vmcore/.cvsignore,
+       tests/.cvsignore, tests/regression/.cvsignore,
+       tests/regression/codepatching/.cvsignore,
+       tests/regression/jasmin/.cvsignore,
+       tests/regression/native/.cvsignore, tests/stack/.cvsignore: Removed.
+       [9cfa2b402d78]
+
+       * .cvsignore:
+       * .cvsignore: Removed.
+       [de2254a5a0f4]
+
+       * configure.ac, m4/threads.m4:
+       * configure.ac: Removed --enable-threads checks and call instead
+       AC_CHECK_ENABLE_THREADS.
+       * m4/threads.m4: New file.
+       [fd1ace174105]
+
+2007-04-23  michi  <michi>
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_find_replacement_point_for_pc):
+       Added assertion. (replace_recover_source_state) [ENABLE_GC_CACAO]:
+       Now recovers native frames.
+       [353654378d75]
+
+       * configure.ac, contrib/Makefile.am, contrib/vmlog/Makefile,
+       contrib/vmlog/README, contrib/vmlog/vmlog_cacao.patch,
+       src/cacaoh/dummy.c, src/mm/cacao-gc/final.c, src/mm/cacao-
+       gc/final.h, src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/cldc1.1/java_lang_System.c,
+       src/threads/native/Makefile.am, src/threads/native/lock.c,
+       src/threads/threads-common.h, src/toolbox/list.c,
+       src/toolbox/list.h, src/vm/Makefile.am, src/vm/builtin.c,
+       src/vm/builtin.h, src/vm/exceptions.c, src/vm/exceptions.h,
+       src/vm/jit/Makefile.am, src/vm/jit/codegen-common.c, src/vm/jit
+       /codegen-common.h, src/vm/jit/emit-common.c,
+       src/vm/jit/intrp/asmpart.c, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c,
+       src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/linux/md-os.h,
+       src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c,
+       src/vm/jit/optimizing/recompile.h, src/vm/jit/powerpc/darwin/md-
+       abi.c, src/vm/jit/powerpc/darwin/md-abi.h, src/vm/jit/powerpc/darwin
+       /md-os.c, src/vm/jit/replace.c, src/vm/jit/sparc64/arch.h,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/md.c, src/vm/jit/stacktrace.c,
+       src/vm/properties.c, src/vm/signal.c, src/vm/vm.c,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/suck.c,
+       src/vmcore/suck.h, tests/regression/resolving/Makefile.am:
+       Merged revisions 7766-7796 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7769 | tbfg | 2007-04-19 17:01:49 +0200 (Thu, 19 Apr
+       2007) | 16 lines
+
+        * src/vm/jit/m68k/linux/md-abi.c (abi_registers_integer_saved):
+       Fixed. (abi_registers_float_saved): Fixed.
+
+        * src/vm/jit/m68k/emit.c (emit_classcast_check): Fixed.
+
+        * src/vm/jit/m68k/codegen.c (codegen_emit): Temporary hacked a
+       field for saved adr registers until real patch will be done.
+       (ICMD_INSTANCEOF): Fixed. (ICMD_CHECKCAST): Fixed.
+       (codegen_emit_stub_compiler): Removed useless code.
+
+        * src/vm/jit/m68k/asmpart.S (L_asm_handle_exception_not_catched):
+       Implemented.
+
+        * src/vm/jit/m68k/codegen.h (M_BLS): Added. ........ r7770 |
+       twisti | 2007-04-19 21:39:06 +0200 (Thu, 19 Apr 2007) | 20 lines
+
+        * src/vm/jit/powerpc/darwin/md-abi.h (REG_FA0, REG_FA1): Added.
+       (REG_A0_A1_PACKED, REG_A2_A3_PACKED): Likewise.
+
+        * src/vm/jit/powerpc/darwin/md-os.c [ENABLE_THREADS]
+       (threads/native/threads.h): Added. (md_signal_handler_sigsegv):
+       Changed for hardware-exceptions. (md_signal_handler_sigtrap): New
+       function.
+
+        * src/vm/jit/powerpc/darwin/md-abi.c (vm/descriptor.h): Changed to
+       vmcore/descriptor.h. (regs): Renamed to
+       abi_registers_integer_name. (abi_registers_integer_argument):
+       Added. (abi_registers_integer_saved): Likewise.
+       (abi_registers_integer_temporary): Likewise.
+       (abi_registers_float_argument): Likewise.
+       (abi_registers_float_saved): Likewise.
+       (abi_registers_float_temporary): Likewise. (md_param_alloc): Use
+       new register arrays. (md_param_alloc_native): New function.
+       ........ r7771 | twisti | 2007-04-19 21:41:08 +0200 (Thu, 19 Apr
+       2007) | 5 lines
+
+        * src/cacaoh/dummy.c (exceptions_print_current_exception): Added
+       abort. (exceptions_throw_outofmemoryerror): Removed.
+       (exceptions_throw_illegalaccessexception): Likewise. ........
+       r7772 | twisti | 2007-04-19 21:43:39 +0200 (Thu, 19 Apr 2007) | 5
+       lines
+
+        * src/vm/signal.c (assert.h): Added. (vm/exceptions.h):
+       Likewise. [ENABLE_STATISTICS] (vmcore/statistics.h): Likewise.
+       (signal_init): Added hardware-exception assert. ........ r7773 |
+       twisti | 2007-04-19 21:44:54 +0200 (Thu, 19 Apr 2007) | 3 lines
+
+        * src/vm/exceptions.h: Added a comment about the hardware-
+       exception assert in signal_init. ........ r7774 | twisti |
+       2007-04-19 21:58:08 +0200 (Thu, 19 Apr 2007) | 2 lines
+
+        * configure.ac (AC_INIT): Changed version to 0.98rc. ........
+       r7775 | twisti | 2007-04-19 21:59:17 +0200 (Thu, 19 Apr 2007) | 3
+       lines
+
+        * tests/regression/resolving/Makefile.am (check): Added missing
+       JAVAFLAGS. ........ r7776 | twisti | 2007-04-19 23:31:47 +0200
+       (Thu, 19 Apr 2007) | 3 lines
+
+        * src/vm/signal.c (signal_thread): Check return value of sig*
+       functions. ........ r7777 | twisti | 2007-04-20 13:21:38 +0200
+       (Fri, 20 Apr 2007) | 2 lines
+
+        * src/threads/threads-common.h (native/jni.h): Added. ........
+       r7778 | twisti | 2007-04-20 14:40:05 +0200 (Fri, 20 Apr 2007) | 3
+       lines
+
+        * src/vm/jit/codegen-common.c (codegen_finish_native_call): #ifdef
+       lrt and plrt. Don't set lrt, we don't need it. ........ r7779 |
+       twisti | 2007-04-20 14:48:55 +0200 (Fri, 20 Apr 2007) | 2 lines
+
+        * src/vm/vm.c (vm_create): Print unknown -verbose option. ........
+       r7780 | twisti | 2007-04-20 14:53:45 +0200 (Fri, 20 Apr 2007) | 2
+       lines
+
+        * src/vm/vm.c (version): Print libjvm.so path. ........ r7781 |
+       twisti | 2007-04-20 15:06:45 +0200 (Fri, 20 Apr 2007) | 4 lines
+
+        * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c (loadLibrary):
+       Fixed string-internal warnings.
+         * src/native/vm/cldc1.1/java_lang_System.c (getProperty0): Likewise.
+       ........ r7782 | twisti | 2007-04-20 15:09:36 +0200 (Fri, 20 Apr
+       2007) | 2 lines
+
+        * src/vm/vm.c: Changed header order to prevent a warning. ........
+       r7783 | twisti | 2007-04-20 15:28:27 +0200 (Fri, 20 Apr 2007) | 16
+       lines
+
+        * src/toolbox/list.h (listnode): Renamed to listnode_t. (list):
+       Renamed to list_t.
+
+        * src/toolbox/list.c, src/vm/jit/codegen-common.c, src/vm/jit
+       /codegen-common.h, src/vm/jit/emit-common.c,
+       src/vm/jit/optimizing/profile.c,
+       src/vm/jit/optimizing/recompile.c,
+       src/vm/jit/optimizing/recompile.h, src/vm/properties.c,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/suck.c,
+       src/vmcore/suck.h: Likewise. ........ r7784 | twisti | 2007-04-20
+       15:51:41 +0200 (Fri, 20 Apr 2007) | 9 lines
+
+        * src/toolbox/list.h (list_t): Added size.
+
+        * src/toolbox/list.c (list_create): Initialize size.
+       (list_create_dump): Likewise. (list_add_first): Increase size.
+       (list_add_last_unsynced): Likewise. (list_add_before): Likewise.
+       (list_remove_unsynced): Decrease size. ........ r7785 | edwin |
+       2007-04-21 12:55:30 +0200 (Sat, 21 Apr 2007) | 6 lines
+
+        * src/vm/jit/replace.c, src/vm/jit/intrp/asmpart.c, src/vm/jit
+       /codegen-common.c, src/vm/builtin.c, src/vm/exceptions.c,
+       src/vm/vm.c, src/threads/native/lock.c (ENABLE_VMLOG): Applied the
+       vmlog patch and wrapped all inserted code with #if
+       defined(ENABLE_VMLOG). ........ r7786 | edwin | 2007-04-21
+       14:37:47 +0200 (Sat, 21 Apr 2007) | 6 lines
+
+        * configure.ac (--enable-vmlog): New configure option.
+
+        * src/vm/jit/Makefile.am, src/vm/Makefile.am,
+       src/threads/native/Makefile.am (AM_CPPFLAGS): Added -I for vmlog
+       includes. ........ r7787 | edwin | 2007-04-21 14:48:14 +0200 (Sat,
+       21 Apr 2007) | 3 lines
+
+        * contrib/vmlog/vmlog_cacao.patch: Removed. It is no longer
+       needed.
+         * contrib/vmlog/README: Updated for CACAO's --enable-vmlog. ........
+       r7788 | edwin | 2007-04-21 18:26:34 +0200 (Sat, 21 Apr 2007) | 2
+       lines
+
+        * contrib/vmlog/Makefile: Renamed to maintain.mk. ........ r7789
+       | edwin | 2007-04-21 18:42:52 +0200 (Sat, 21 Apr 2007) | 4 lines
+
+        * configure.ac: Generate vmlog Makefiles.
+         * contrib/Makefile.am: Added vmlog to SUBDIRS.
+         * contrib/vmlog/Makefile.am, contrib/vmlog/t/Makefile.am: New files.
+       ........ r7790 | edwin | 2007-04-21 20:56:43 +0200 (Sat, 21 Apr
+       2007) | 3 lines
+
+        * tests/regression/resolving/Makefile.am: Added "-classpath ." to
+       javac options so the tests work with ecj out-of-the-box. ........
+       r7791 | ajordan | 2007-04-22 17:55:51 +0200 (Sun, 22 Apr 2007) | 13
+       lines
+
+        * src/vm/jit/sparc64/arch.h: Properly activated all FP features
+       SPARC64 supports in hardware.
+
+        * src/vm/jit/sparc64/asmpart.S: Added functions to read/write the
+       FP state register.
+         * src/vm/jit/sparc64/md.c: Added prototypes here.
+
+        * src/vm/jit/sparc64/codegen.h: Added 'branch on FP condition
+       codes' macros.
+
+        * src/vm/jit/sparc64/emit.c (emit_verbosecall_enter): Fixed FP
+       argument passing.
+
+        * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed FP conversion
+       functions to (a) use unique slots in the data segment (doh!), (b)
+       catch the case where NaN is converted to an integer value. (JVMS and
+       SPARC do not inherently agree here). ........ r7792 | tbfg |
+       2007-04-22 22:02:05 +0200 (Sun, 22 Apr 2007) | 31 lines
+
+        * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigsegv):
+       Implemented. (md_signal_handler_sigill): More exceptions handled.
+       Some fixes.
+
+        * src/vm/jit/m68k/linux/md-os.h
+       (M68K_EXCEPTION_HARDWARE_NULLPOINTER): Used instead of
+       EXCEPTION_HARDWARE_NULLPOINTER, because a trap with value #0 will
+       not be taken.
+
+        * src/vm/jit/m68k/emit.c (emit_load_[low|high]): Fixed assertion.
+       (emit_arrayindexoutofbounds_check): Implemented.
+       (emit_nullpointer_check): Implemented.
+       (emit_exception_check_ireg): Renamed emit_exception_check.
+       (emit_exception_check_areg): Disabled code.
+       (emit_exception_check): Implemented.
+
+        * src/vm/jit/m68k/codegen.c (ICMD_LALOAD): Implemented.
+       (ICMD_FALOAD): Implemented. (ICMD_DALOAD): Implemented.
+       (ICMD_LASTORE): Implemented. (ICMD_FASTORE): Implemented.
+       (ICMD_DASTORE): Implemented. (ICMD_BUILTIN): Exception check
+       enabled. (ICMD_MULTIANEWARRAY): Implemented.
+       (codegen_emit_stub_native): Exception check implemented.
+
+        * src/vm/jit/m68k/asmpart.S (asm_handle_nat_exception): Symbol
+       exported and implemented.
+
+        * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe):
+       More m68k fixes. ........ r7793 | twisti | 2007-04-23 16:29:48
+       +0200 (Mon, 23 Apr 2007) | 3 lines
+
+        * src/vm/signal.c (signal_thread): Don't check for an error on
+       sigwait (revisit this patch with the exact-GC). ........ r7795 |
+       twisti | 2007-04-23 22:03:38 +0200 (Mon, 23 Apr 2007) | 2 lines
+
+        * src/vm/builtin.h (md-abi.h): Added. ........ r7796 | twisti |
+       2007-04-23 22:04:44 +0200 (Mon, 23 Apr 2007) | 4 lines
+
+        * configure.ac: Removed all classpath related checks and made
+       functions for them.
+         * m4/classpath.m4: New file. ........
+       [260c33906953]
+
+2007-04-23  twisti  <twisti>
+
+       * configure.ac, m4/classpath.m4:
+       * configure.ac: Removed all classpath related checks and made
+       functions for them.
+       * m4/classpath.m4: New file.
+       [a6ecb4be61c9]
+
+       * src/vm/builtin.h:
+       * src/vm/builtin.h (md-abi.h): Added.
+       [27f5944a2194]
+
+2007-04-23  michi  <michi>
+
+       * configure.ac, contrib/vmlog/Makefile, contrib/vmlog/README,
+       contrib/vmlog/vmlog_cacao.patch, src/toolbox/list.c,
+       src/toolbox/list.h, src/vm/Makefile.am, src/vm/exceptions.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/intrp/asmpart.c,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/linux/md-os.h, src/vm/jit/powerpc/darwin/md-os.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/x86_64/codegen.c (codegen_emit): Builtin stubs are
+       called for ICMD_BUILTIN if available.
+
+       * src/vm/jit/i386/codegen.c (codegen_emit): Likewise.
+       (codegen_emit_stub_builtin): Adapted to new signature and a bugfix.
+       [f8c80a7d7861]
+
+2007-04-23  twisti  <twisti>
+
+       * src/vm/signal.c:
+       * src/vm/signal.c (signal_thread): Don't check for an error on
+       sigwait (revisit this patch with the exact-GC).
+       [316672080a9f]
+
+2007-04-22  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/linux/md-os.h,
+       src/vm/jit/stacktrace.c:
+       * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigsegv):
+       Implemented. (md_signal_handler_sigill): More exceptions handled.
+       Some fixes.
+
+       * src/vm/jit/m68k/linux/md-os.h
+       (M68K_EXCEPTION_HARDWARE_NULLPOINTER): Used instead of
+       EXCEPTION_HARDWARE_NULLPOINTER, because a trap with value #0 will
+       not be taken.
+
+       * src/vm/jit/m68k/emit.c (emit_load_[low|high]): Fixed assertion.
+       (emit_arrayindexoutofbounds_check): Implemented.
+       (emit_nullpointer_check): Implemented. (emit_exception_check_ireg):
+       Renamed emit_exception_check. (emit_exception_check_areg): Disabled
+       code. (emit_exception_check): Implemented.
+
+       * src/vm/jit/m68k/codegen.c (ICMD_LALOAD): Implemented.
+       (ICMD_FALOAD): Implemented. (ICMD_DALOAD): Implemented.
+       (ICMD_LASTORE): Implemented. (ICMD_FASTORE): Implemented.
+       (ICMD_DASTORE): Implemented. (ICMD_BUILTIN): Exception check
+       enabled. (ICMD_MULTIANEWARRAY): Implemented.
+       (codegen_emit_stub_native): Exception check implemented.
+
+       * src/vm/jit/m68k/asmpart.S (asm_handle_nat_exception): Symbol
+       exported and implemented.
+
+       * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe):
+       More m68k fixes.
+       [f5b35b44de35]
+
+2007-04-22  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md.c:
+       * src/vm/jit/sparc64/arch.h: Properly activated all FP features
+       SPARC64 supports in hardware.
+
+       * src/vm/jit/sparc64/asmpart.S: Added functions to read/write the FP
+       state register.
+       * src/vm/jit/sparc64/md.c: Added prototypes here.
+
+       * src/vm/jit/sparc64/codegen.h: Added 'branch on FP condition codes'
+       macros.
+
+       * src/vm/jit/sparc64/emit.c (emit_verbosecall_enter): Fixed FP
+       argument passing.
+
+       * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed FP conversion
+       functions to (a) use unique slots in the data segment (doh!), (b)
+       catch the case where NaN is converted to an integer value. (JVMS and
+       SPARC do not inherently agree here).
+       [2871672fa702]
+
+2007-04-21  edwin  <edwin>
+
+       * tests/regression/resolving/Makefile.am:
+       * tests/regression/resolving/Makefile.am: Added "-classpath ." to
+       javac options so the tests work with ecj out-of-the-box.
+       [7854d14c2197]
+
+       * configure.ac, contrib/Makefile.am, contrib/vmlog/Makefile.am,
+       contrib/vmlog/t/Makefile.am:
+       * configure.ac: Generate vmlog Makefiles.
+       * contrib/Makefile.am: Added vmlog to SUBDIRS.
+       * contrib/vmlog/Makefile.am, contrib/vmlog/t/Makefile.am: New files.
+       [c695e40c9ca0]
+
+       * contrib/vmlog/Makefile, contrib/vmlog/maintain.mk:
+       * contrib/vmlog/Makefile: Renamed to maintain.mk.
+       [cf73c926d5a8]
+
+       * contrib/vmlog/README, contrib/vmlog/vmlog_cacao.patch:
+       * contrib/vmlog/vmlog_cacao.patch: Removed. It is no longer needed.
+       * contrib/vmlog/README: Updated for CACAO's --enable-vmlog.
+       [550f98d25763]
+
+       * configure.ac, src/threads/native/Makefile.am, src/vm/Makefile.am,
+       src/vm/jit/Makefile.am:
+       * configure.ac (--enable-vmlog): New configure option.
+
+       * src/vm/jit/Makefile.am, src/vm/Makefile.am,
+       src/threads/native/Makefile.am (AM_CPPFLAGS): Added -I for vmlog
+       includes.
+       [686e27b2c775]
+
+       * src/threads/native/lock.c, src/vm/builtin.c, src/vm/exceptions.c,
+       src/vm/jit/codegen-common.c, src/vm/jit/intrp/asmpart.c,
+       src/vm/jit/replace.c, src/vm/vm.c:
+       * src/vm/jit/replace.c, src/vm/jit/intrp/asmpart.c, src/vm/jit
+       /codegen-common.c, src/vm/builtin.c, src/vm/exceptions.c,
+       src/vm/vm.c, src/threads/native/lock.c (ENABLE_VMLOG): Applied the
+       vmlog patch and wrapped all inserted code with #if
+       defined(ENABLE_VMLOG).
+       [79cd1ec1bdfe]
+
+2007-04-20  twisti  <twisti>
+
+       * src/toolbox/list.c, src/toolbox/list.h:
+       * src/toolbox/list.h (list_t): Added size.
+
+       * src/toolbox/list.c (list_create): Initialize size.
+       (list_create_dump): Likewise. (list_add_first): Increase size.
+       (list_add_last_unsynced): Likewise. (list_add_before): Likewise.
+       (list_remove_unsynced): Decrease size.
+       [a3b9de93ae36]
+
+       * src/toolbox/list.c, src/toolbox/list.h, src/vm/jit/codegen-common.c,
+       src/vm/jit/codegen-common.h, src/vm/jit/emit-common.c,
+       src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c,
+       src/vm/jit/optimizing/recompile.h, src/vm/properties.c,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/suck.c,
+       src/vmcore/suck.h:
+       * src/toolbox/list.h (listnode): Renamed to listnode_t. (list):
+       Renamed to list_t.
+
+       * src/toolbox/list.c, src/vm/jit/codegen-common.c, src/vm/jit
+       /codegen-common.h, src/vm/jit/emit-common.c,
+       src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c,
+       src/vm/jit/optimizing/recompile.h, src/vm/properties.c,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/suck.c,
+       src/vmcore/suck.h: Likewise.
+       [d364c8e90caf]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c: Changed header order to prevent a warning.
+       [e2130afe6ce2]
+
+       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/cldc1.1/java_lang_System.c:
+       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c (loadLibrary):
+       Fixed string-internal warnings.
+       * src/native/vm/cldc1.1/java_lang_System.c (getProperty0): Likewise.
+       [3392e29dc096]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (version): Print libjvm.so path.
+       [cf8bfa7aacd0]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_create): Print unknown -verbose option.
+       [1e0587f7990c]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_finish_native_call): #ifdef
+       lrt and plrt. Don't set lrt, we don't need it.
+       [4adb6a2ff2e2]
+
+       * src/threads/threads-common.h:
+       * src/threads/threads-common.h (native/jni.h): Added.
+       [46a14c79e619]
+
+2007-04-19  twisti  <twisti>
+
+       * src/vm/signal.c:
+       * src/vm/signal.c (signal_thread): Check return value of sig*
+       functions.
+       [c9b703e40679]
+
+       * tests/regression/resolving/Makefile.am:
+       * tests/regression/resolving/Makefile.am (check): Added missing
+       JAVAFLAGS.
+       [ef74f05c14af]
+
+       * configure.ac:
+       * configure.ac (AC_INIT): Changed version to 0.98rc.
+       [54cbdd59db94]
+
+       * src/vm/exceptions.h:
+       * src/vm/exceptions.h: Added a comment about the hardware-exception
+       assert in signal_init.
+       [577088fbe91e]
+
+       * src/vm/signal.c:
+       * src/vm/signal.c (assert.h): Added. (vm/exceptions.h): Likewise.
+       [ENABLE_STATISTICS] (vmcore/statistics.h): Likewise. (signal_init):
+       Added hardware-exception assert.
+       [f7ec08f8ba16]
+
+       * src/cacaoh/dummy.c:
+       * src/cacaoh/dummy.c (exceptions_print_current_exception): Added
+       abort. (exceptions_throw_outofmemoryerror): Removed.
+       (exceptions_throw_illegalaccessexception): Likewise.
+       [975230caffb6]
+
+       * src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md-
+       abi.h, src/vm/jit/powerpc/darwin/md-os.c:
+       * src/vm/jit/powerpc/darwin/md-abi.h (REG_FA0, REG_FA1): Added.
+       (REG_A0_A1_PACKED, REG_A2_A3_PACKED): Likewise.
+
+       * src/vm/jit/powerpc/darwin/md-os.c [ENABLE_THREADS]
+       (threads/native/threads.h): Added. (md_signal_handler_sigsegv):
+       Changed for hardware-exceptions. (md_signal_handler_sigtrap): New
+       function.
+
+       * src/vm/jit/powerpc/darwin/md-abi.c (vm/descriptor.h): Changed to
+       vmcore/descriptor.h. (regs): Renamed to abi_registers_integer_name.
+       (abi_registers_integer_argument): Added.
+       (abi_registers_integer_saved): Likewise.
+       (abi_registers_integer_temporary): Likewise.
+       (abi_registers_float_argument): Likewise.
+       (abi_registers_float_saved): Likewise.
+       (abi_registers_float_temporary): Likewise. (md_param_alloc): Use new
+       register arrays. (md_param_alloc_native): New function.
+       [c7ade92ec34b]
+
+2007-04-19  tbfg  <tbfg>
+
+       * src/vm/jit/allocator/simplereg.c, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/jit.h,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/parse.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/linux/Makefile.am, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/emit.c, src/vm/jit/stack.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/m68k/linux/md-abi.c (abi_registers_integer_saved):
+       Fixed. (abi_registers_float_saved): Fixed.
+
+       * src/vm/jit/m68k/emit.c (emit_classcast_check): Fixed.
+
+       * src/vm/jit/m68k/codegen.c (codegen_emit): Temporary hacked a field
+       for saved adr registers until real patch will be done.
+       (ICMD_INSTANCEOF): Fixed. (ICMD_CHECKCAST): Fixed.
+       (codegen_emit_stub_compiler): Removed useless code.
+
+       * src/vm/jit/m68k/asmpart.S (L_asm_handle_exception_not_catched):
+       Implemented.
+
+       * src/vm/jit/m68k/codegen.h (M_BLS): Added.
+       [84e697c2d473]
+
+2007-04-19  michi  <michi>
+
+       * src/mm/cacao-gc/final.c, src/mm/cacao-gc/gc.c, src/mm/cacao-
+       gc/mark.c:
+       * src/mm/cacao-gc/final.c: Cleaned up debug code.
+       * src/mm/cacao-gc/gc.c: Likewise.
+       * src/mm/cacao-gc/mark.c: Likewise.
+       [9f8ef49fa79b]
+
+       * src/mm/cacao-gc/heap.c, src/mm/cacao-gc/heap.h:
+       * src/mm/cacao-gc/heap.h: Removed finalizer header flag.
+
+       * src/mm/cacao-gc/heap.c (heap_alloc): Adapted to above changes.
+       (heap_print_object): Handle invalid heap references correctly.
+       [f2937900eaac]
+
+       * src/native/vm/java_lang_ClassLoader.c, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/threads-common.c,
+       src/threads/threads-common.h, src/vm/builtintable.inc,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/codegen-
+       common.c, src/vm/jit/emit-common.h, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/emit.c, src/vm/jit/inline/inline.c,
+       src/vm/jit/jit.h, src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/parse.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/Makefile.am,
+       src/vm/jit/replace.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/emit.c, src/vm/jit/show.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/md-abi.c, src/vm/jit/stack.c, src/vm/jit/verify
+       /typecheck-common.c, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/emit.c, tests/regression/jasmin/Makefile.am,
+       tests/regression/resolving/Makefile.am:
+       Merged revisions 7732-7765 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7733 | twisti | 2007-04-17 00:56:37 +0200 (Tue, 17 Apr
+       2007) | 3 lines
+
+        * src/vm/jit/x86_64/codegen.c (codegen_emit): Made argument
+       passing cleaner. ........ r7734 | twisti | 2007-04-17 13:15:15
+       +0200 (Tue, 17 Apr 2007) | 3 lines
+
+        * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Use
+       simpler code to save and restore argument registers. ........
+       r7735 | edwin | 2007-04-17 20:47:50 +0200 (Tue, 17 Apr 2007) | 3
+       lines
+
+        * src/vm/jit/parse.c (parse): Small cleanup of local variable
+       renaming. (No code changes.) ........ r7736 | edwin | 2007-04-17
+       21:24:05 +0200 (Tue, 17 Apr 2007) | 5 lines
+
+        * src/vm/jit/stack.c (stack_analyse): The javalocals array can
+       have negative values != UNUSED (these values < UNUSED represent
+       returnAddresses of local subroutines). Thus >= 0 must be used to
+       check for normal indices. ........ r7737 | edwin | 2007-04-17
+       21:57:55 +0200 (Tue, 17 Apr 2007) | 2 lines
+
+        * src/vm/jit/stack.c (stack_javalocals_store): Added an assert.
+       ........ r7738 | edwin | 2007-04-17 22:06:44 +0200 (Tue, 17 Apr
+       2007) | 2 lines
+
+        * src/vm/jit/jit.h (jitdata): Cleaned up comments for local_map.
+       ........ r7739 | twisti | 2007-04-17 22:17:01 +0200 (Tue, 17 Apr
+       2007) | 10 lines
+
+        * src/threads/threads-common.c (threads_print_stacktrace): Renamed
+       to threads_thread_print_stacktrace. (threads_print_stacktrace):
+       New function. (threads_dump): Use threads_thread_print_stacktrace.
+
+        * src/threads/threads-common.h: Likewise.
+
+        * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Use new
+       threads_print_stacktrace. ........ r7740 | twisti | 2007-04-17
+       22:25:55 +0200 (Tue, 17 Apr 2007) | 4 lines
+
+        * src/threads/native/threads.c (threads_init): Fixed string-
+       internal warnings. (threads_attach_current_thread): Likewise.
+       ........ r7741 | edwin | 2007-04-17 22:30:09 +0200 (Tue, 17 Apr
+       2007) | 4 lines
+
+        * src/vm/jit/jit.h (basicblock): Document the javalocal array.
+       (JAVALOCAL_FROM_RETADDR): New macro. (RETADDR_FROM_JAVALOCAL):
+       Likewise. ........ r7742 | edwin | 2007-04-17 22:37:36 +0200 (Tue,
+       17 Apr 2007) | 4 lines
+
+        * src/vm/jit/stack.c, src/vm/jit/show.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/replace.c,
+       src/vm/jit/jit.h: Fix and use the new macros for calculating
+       javalocals values representing returnAddresses. ........ r7743 |
+       edwin | 2007-04-17 22:53:41 +0200 (Tue, 17 Apr 2007) | 6 lines
+
+        * src/vm/jit/stack.c, src/vm/jit/verify/typecheck-common.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/jit/inline/inline.c,
+       src/vm/jit/allocator/simplereg.c: Clarification: Renamed variables
+       that are indices into jd->var to "varindex". Renamed variables that
+       are bytecode variable indices to "javaindex". ........ r7744 |
+       twisti | 2007-04-17 22:54:04 +0200 (Tue, 17 Apr 2007) | 2 lines
+
+        * tests/regression/jasmin/Makefile.am (check): Set
+       LD_LIBRARY_PATH. ........ r7745 | twisti | 2007-04-17 22:59:52
+       +0200 (Tue, 17 Apr 2007) | 3 lines
+
+        * src/vm/builtintable.inc (builtintable_function) [ENABLE_JIT]: We
+       need the entries only for JIT. ........ r7746 | edwin | 2007-04-17
+       23:01:15 +0200 (Tue, 17 Apr 2007) | 2 lines
+
+        * src/vm/jit/verify/typecheck.c: More variable renaming for
+       clarity. ........ r7747 | edwin | 2007-04-17 23:11:20 +0200 (Tue,
+       17 Apr 2007) | 3 lines
+
+        * src/vm/jit/stack.c (stack_reanalyse_block, stack_analyse):
+       Renamed variable "j" to a more obvious "varindex". ........
+       r7748 | edwin | 2007-04-17 23:25:55 +0200 (Tue, 17 Apr 2007) | 3
+       lines
+
+        * src/vm/jit/stack.c (stack_analyse): Do not abuse poor "i" for
+       types, use a separate variable for that. ........ r7749 | edwin
+       | 2007-04-17 23:30:20 +0200 (Tue, 17 Apr 2007) | 4 lines
+
+        * src/vm/jit/stack.c (stack_init_javalocals): Use "type" as
+       variable for the type. (stack_analyse): Likewise. ........
+       r7750 | twisti | 2007-04-17 23:37:12 +0200 (Tue, 17 Apr 2007) | 3
+       lines
+
+        * tests/regression/resolving/Makefile.am (check): Use
+       LD_LIBRARY_PATH for JAVA. ........ r7751 | twisti | 2007-04-18
+       00:06:01 +0200 (Wed, 18 Apr 2007) | 3 lines
+
+        * src/vm/jit/alpha/codegen.c (codegen_emit): Fixed bug in float-
+       argument passing. ........ r7752 | twisti | 2007-04-18 00:50:49
+       +0200 (Wed, 18 Apr 2007) | 2 lines
+
+        * src/vm/jit/m68k/codegen.c: Boilerplate added. ........ r7753 |
+       twisti | 2007-04-18 00:55:21 +0200 (Wed, 18 Apr 2007) | 2 lines
+
+        * src/vm/jit/m68k/emit.c: boilerplate added. ........ r7754 |
+       twisti | 2007-04-18 01:18:15 +0200 (Wed, 18 Apr 2007) | 23 lines
+
+        * src/vm/jit/emit-common.h (emit_copy): Changed signature.
+
+        * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c: Likewise.
+       ........ r7755 | twisti | 2007-04-18 11:59:58 +0200 (Wed, 18 Apr
+       2007) | 3 lines
+
+        * src/native/vm/java_lang_ClassLoader.c [ENABLE_STATISTICS]
+       (vmcore/statistics.h): Added. ........ r7756 | twisti | 2007-04-18
+       16:11:56 +0200 (Wed, 18 Apr 2007) | 12 lines
+
+        * src/threads/native/threads.c (mutex_join, cond_join): Added.
+       (threads_init_threadobject): Don't initalize join-mutex and cond.
+       (threads_preinit): Initialize mutex_join and cond_join.
+       (threads_startup_thread): Added vm_abort. (threads_detach_thread):
+       Don't reset thread id and use global mutex and condition.
+       (threads_find_non_daemon_thread): Lock thread list.
+       (threads_join_all_threads): Use global mutex and condition.
+
+        * src/threads/native/threads.h (threadobject): Removed joinmutex
+       and joincond. ........ r7757 | tbfg | 2007-04-18 16:49:18 +0200
+       (Wed, 18 Apr 2007) | 6 lines
+
+        * src/vm/jit/powerpc64/codegen.c (sign_ext): Removed from
+       ICMD_INEG, ICMD_IDIV, ICMD_IREM, ICMD_IMUL, ICMD_IAND and ICMD_IOR
+       to save the if runtime costs.
+
+        (ICMD_IUSHR): Needs sign extension for 0 bit shift case. ........
+       r7758 | michi | 2007-04-18 17:31:07 +0200 (Wed, 18 Apr 2007) | 3
+       lines
+
+        * src/vm/jit/powerpc64/linux/Makefile.am (AM_CPPFLAGS): Added
+         -I$(top_builddir)/src. ........ r7759 | ajordan | 2007-04-18
+       23:04:01 +0200 (Wed, 18 Apr 2007) | 5 lines
+
+        * src/vm/jit/sparc64/emit.c: Migrated to
+       abi_registers_{integer,float}_argument.
+         * src/vm/jit/sparc64/codegen.c: Likewise.
+         * src/vm/jit/sparc64/md-abi.c: Likewise. ........ r7761 | twisti |
+       2007-04-19 11:18:20 +0200 (Thu, 19 Apr 2007) | 13 lines
+
+        * src/threads/native/threads.c (threads_start_javathread):
+       Removed. (threads_detach_thread): Added some comments.
+
+        * src/threads/native/threads.h (threads_start_javathread):
+       Removed.
+
+        * src/threads/threads-common.c (assert.h): Added.
+       [ENABLE_STATISTICS] (vmcore/options.h, vmcore/statistics.h): Added.
+       (threads_start_javathread): Added.
+
+        * src/threads/threads-common.h (vm/global.h): Added.
+       (native/include/java_lang_Thread.h): Likewise.
+       (threads_start_javathread): Likewise. ........ r7762 | twisti |
+       2007-04-19 11:19:33 +0200 (Thu, 19 Apr 2007) | 3 lines
+
+        * src/threads/threads-common.c (threads_start_javathread)
+       [ENABLE_JAVASE]: Check for daemon thread and set the flag. ........
+       r7763 | michi | 2007-04-19 14:19:19 +0200 (Thu, 19 Apr 2007) | 4
+       lines
+
+        * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Use long branch
+       construct for exception handling here. This fixes a crash in the
+       following jasmin regression testcase:
+       jasmin/test_verify_fail_areturn_wrong_reftype. ........
+       [d1f4bb13f44d]
+
+2007-04-19  twisti  <twisti>
+
+       * src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_builtin): Changed
+       signature and use register number directly to save registers.
+       [5e24d4db20dd]
+
+       * src/vm/builtin.c, src/vm/jit/arm/asmpart.S, src/vm/jit/codegen-
+       common.c, src/vm/jit/codegen-common.h:
+       * src/vm/jit/codegen-common.c (vm/builtin.h): Added.
+       (codegen_generate_stub_builtin): New function.
+       (codegen_generate_stub_native): Moved codegen_finish before
+       statistics generation, otherwise the numbers are wrong.
+       (codegen_stub_builtin_enter): New function.
+       (codegen_stub_builtin_exit): Likewise.
+
+       * src/vm/jit/codegen-common.h (vm/builtin.h): Added.
+       (codegen_generate_stub_builtin): Likewise.
+       (codegen_emit_stub_builtin): Likewise. (codegen_stub_builtin_enter):
+       Likewise. (codegen_stub_builtin_exit): Likewise.
+
+       * src/vm/builtin.c (builtintable_init): Call
+       codegen_generate_stub_builtin when required.
+       [117933a6743e]
+
+2007-04-19  michi  <michi>
+
+       * src/vm/jit/arm/asmpart.S:
+       * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Use long branch
+       construct for exception handling here. This fixes a crash in the
+       following jasmin regression testcase:
+       jasmin/test_verify_fail_areturn_wrong_reftype.
+       [8aa425921124]
+
+2007-04-19  twisti  <twisti>
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_start_javathread)
+       [ENABLE_JAVASE]: Check for daemon thread and set the flag.
+       [8306a271a6c1]
+
+       * src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/native/threads.c (threads_start_javathread): Removed.
+       (threads_detach_thread): Added some comments.
+
+       * src/threads/native/threads.h (threads_start_javathread): Removed.
+
+       * src/threads/threads-common.c (assert.h): Added.
+       [ENABLE_STATISTICS] (vmcore/options.h, vmcore/statistics.h): Added.
+       (threads_start_javathread): Added.
+
+       * src/threads/threads-common.h (vm/global.h): Added.
+       (native/include/java_lang_Thread.h): Likewise.
+       (threads_start_javathread): Likewise.
+       [c4a3107b7978]
+
+2007-04-19  michi  <michi>
+
+       * src/mm/cacao-gc/rootset.c, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/jit.h,
+       src/vm/jit/mips/codegen.c, src/vm/jit/parse.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/stack.c, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/emit.c:
+       * src/mm/cacao-gc/rootset.c (rootset_from_thread): Add javastack
+       references to the rootset as well.
+       [baaa57d14785]
+
+2007-04-18  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/md-abi.c:
+       * src/vm/jit/sparc64/emit.c: Migrated to
+       abi_registers_{integer,float}_argument.
+       * src/vm/jit/sparc64/codegen.c: Likewise.
+       * src/vm/jit/sparc64/md-abi.c: Likewise.
+       [d958a61d6165]
+
+2007-04-18  michi  <michi>
+
+       * src/vm/jit/powerpc64/linux/Makefile.am:
+       * src/vm/jit/powerpc64/linux/Makefile.am (AM_CPPFLAGS): Added
+       -I$(top_builddir)/src.
+       [16714b42b207]
+
+2007-04-18  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/codegen.c:
+       * src/vm/jit/powerpc64/codegen.c (sign_ext): Removed from ICMD_INEG,
+       ICMD_IDIV, ICMD_IREM, ICMD_IMUL, ICMD_IAND and ICMD_IOR to save the
+       if runtime costs.
+
+       (ICMD_IUSHR): Needs sign extension for 0 bit shift case.
+       [14d9b6039acb]
+
+2007-04-18  twisti  <twisti>
+
+       * src/threads/native/threads.c, src/threads/native/threads.h:
+       * src/threads/native/threads.c (mutex_join, cond_join): Added.
+       (threads_init_threadobject): Don't initalize join-mutex and cond.
+       (threads_preinit): Initialize mutex_join and cond_join.
+       (threads_startup_thread): Added vm_abort. (threads_detach_thread):
+       Don't reset thread id and use global mutex and condition.
+       (threads_find_non_daemon_thread): Lock thread list.
+       (threads_join_all_threads): Use global mutex and condition.
+
+       * src/threads/native/threads.h (threadobject): Removed joinmutex and
+       joincond.
+       [9ebf23aa7207]
+
+       * src/native/vm/java_lang_ClassLoader.c:
+       * src/native/vm/java_lang_ClassLoader.c [ENABLE_STATISTICS]
+       (vmcore/statistics.h): Added.
+       [a79842fdacee]
+
+2007-04-17  twisti  <twisti>
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/emit-
+       common.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/emit-common.h (emit_copy): Changed signature.
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c: Likewise.
+       [76e94dbd7a3a]
+
+       * src/vm/jit/m68k/emit.c:
+       * src/vm/jit/m68k/emit.c: boilerplate added.
+       [1ff409db43be]
+
+       * src/vm/jit/m68k/codegen.c:
+       * src/vm/jit/m68k/codegen.c: Boilerplate added.
+       [760d14d37bcb]
+
+       * src/vm/jit/alpha/codegen.c:
+       * src/vm/jit/alpha/codegen.c (codegen_emit): Fixed bug in float-
+       argument passing.
+       [b29395e453c9]
+
+       * tests/regression/resolving/Makefile.am:
+       * tests/regression/resolving/Makefile.am (check): Use
+       LD_LIBRARY_PATH for JAVA.
+       [3d01fe59eafc]
+
+2007-04-17  edwin  <edwin>
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_init_javalocals): Use "type" as variable
+       for the type. (stack_analyse): Likewise.
+       [d41dd80098e8]
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_analyse): Do not abuse poor "i" for
+       types, use a separate variable for that.
+       [159f24ccdc9c]
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_reanalyse_block, stack_analyse): Renamed
+       variable "j" to a more obvious "varindex".
+       [27c7f7048652]
+
+       * src/vm/jit/verify/typecheck.c:
+       * src/vm/jit/verify/typecheck.c: More variable renaming for clarity.
+       [3ed0eebead11]
+
+2007-04-17  twisti  <twisti>
+
+       * src/vm/builtintable.inc:
+       * src/vm/builtintable.inc (builtintable_function) [ENABLE_JIT]: We
+       need the entries only for JIT.
+       [720be9b2f3e9]
+
+       * tests/regression/jasmin/Makefile.am:
+       * tests/regression/jasmin/Makefile.am (check): Set LD_LIBRARY_PATH.
+       [0f69c60c1908]
+
+2007-04-17  edwin  <edwin>
+
+       * src/vm/jit/allocator/simplereg.c, src/vm/jit/inline/inline.c,
+       src/vm/jit/stack.c, src/vm/jit/verify/typecheck-common.c,
+       src/vm/jit/verify/typeinfo.c:
+       * src/vm/jit/stack.c, src/vm/jit/verify/typecheck-common.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/jit/inline/inline.c,
+       src/vm/jit/allocator/simplereg.c: Clarification: Renamed variables
+       that are indices into jd->var to "varindex". Renamed variables that
+       are bytecode variable indices to "javaindex".
+       [620f945a729d]
+
+       * src/vm/jit/inline/inline.c, src/vm/jit/jit.h, src/vm/jit/replace.c,
+       src/vm/jit/show.c, src/vm/jit/stack.c:
+       * src/vm/jit/stack.c, src/vm/jit/show.c, src/vm/jit/inline/inline.c,
+       src/vm/jit/replace.c, src/vm/jit/jit.h: Fix and use the new macros
+       for calculating javalocals values representing returnAddresses.
+       [1c7d8fa48924]
+
+       * src/vm/jit/jit.h:
+       * src/vm/jit/jit.h (basicblock): Document the javalocal array.
+       (JAVALOCAL_FROM_RETADDR): New macro. (RETADDR_FROM_JAVALOCAL):
+       Likewise.
+       [75abe41b937a]
+
+2007-04-17  twisti  <twisti>
+
+       * src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_init): Fixed string-internal
+       warnings. (threads_attach_current_thread): Likewise.
+       [e043ec7c3f97]
+
+       * src/threads/threads-common.c, src/threads/threads-common.h,
+       src/vm/jit/codegen-common.c:
+       * src/threads/threads-common.c (threads_print_stacktrace): Renamed
+       to threads_thread_print_stacktrace. (threads_print_stacktrace): New
+       function. (threads_dump): Use threads_thread_print_stacktrace.
+
+       * src/threads/threads-common.h: Likewise.
+
+       * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Use new
+       threads_print_stacktrace.
+       [c3afb76242b9]
+
+2007-04-17  edwin  <edwin>
+
+       * src/vm/jit/jit.h:
+       * src/vm/jit/jit.h (jitdata): Cleaned up comments for local_map.
+       [4a6ac5bcba92]
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_javalocals_store): Added an assert.
+       [447e21183701]
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_analyse): The javalocals array can have
+       negative values != UNUSED (these values < UNUSED represent
+       returnAddresses of local subroutines). Thus >= 0 must be used to
+       check for normal indices.
+       [7ac59dbc963c]
+
+       * src/vm/jit/parse.c:
+       * src/vm/jit/parse.c (parse): Small cleanup of local variable
+       renaming. (No code changes.)
+       [bcddd3d2a4e6]
+
+2007-04-17  twisti  <twisti>
+
+       * src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Use
+       simpler code to save and restore argument registers.
+       [7d8cd9be641b]
+
+2007-04-16  twisti  <twisti>
+
+       * src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/x86_64/codegen.c (codegen_emit): Made argument passing
+       cleaner.
+       [7943e3406a26]
+
+2007-04-16  michi  <michi>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h,
+       src/vm/jit/inline/inline.c:
+       Merged revisions 7727-7731 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7731 | twisti | 2007-04-17 00:24:30 +0200 (Tue, 17 Apr
+       2007) | 7 lines
+
+        * src/vm/jit/codegen-common.c (codegen_setup): Removed maxstack
+       stuff.
+         * src/vm/jit/codegen-common.h (codegendata): Likewise.
+
+        * src/vm/jit/inline/inline.c: Fixed includes.
+       (inline_jit_compile): Removed maxstack stuff. (inline_transform):
+       Removed basicblockindex. ........
+       [33abc694205d]
+
+2007-04-16  twisti  <twisti>
+
+       * src/vm/jit/Makefile.am, src/vm/jit/codegen-common.c, src/vm/jit
+       /codegen-common.h, src/vm/jit/inline/inline.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-abi.c:
+       * src/vm/jit/codegen-common.c (codegen_setup): Removed maxstack
+       stuff.
+       * src/vm/jit/codegen-common.h (codegendata): Likewise.
+
+       * src/vm/jit/inline/inline.c: Fixed includes. (inline_jit_compile):
+       Removed maxstack stuff. (inline_transform): Removed basicblockindex.
+       [e472140655af]
+
+2007-04-16  michi  <michi>
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h:
+       * src/mm/cacao-gc/gc.h [!ENABLE_STATISTICS]: Added dummy defines.
+
+       * src/mm/cacao-gc/gc.c [ENABLE_STATISTICS]: Added gcstat_collections
+       and gcstat_collections_forced.
+       [ad29c1300cb4]
+
+2007-04-16  twisti  <twisti>
+
+       * src/mm/cacao-gc/Makefile.am:
+       * src/mm/cacao-gc/Makefile.am (AM_CPPFLAGS): Added
+       -I$(top_builddir)/src.
+       [669b0ff5327d]
+
+2007-04-16  michi  <michi>
+
+       * src/mm/cacao-gc/compact.c:
+       * src/mm/cacao-gc/compact.c (compact_move): Fixed ifdef.
+       [466da41ce969]
+
+       * src/mm/cacao-gc/Makefile.am, src/vm/jit/Makefile.am,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/linux/md-abi.c:
+       Merged revisions 7723-7726 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7724 | twisti | 2007-04-16 23:07:10 +0200 (Mon, 16 Apr
+       2007) | 5 lines
+
+        * src/vm/jit/powerpc64/linux/md-abi.c: Argument register changes
+       ported (rev7713).
+         * src/vm/jit/powerpc64/emit.c: Likewise.
+         * src/vm/jit/powerpc64/codegen.c: Likewise. ........ r7725 | twisti
+       | 2007-04-16 23:09:39 +0200 (Mon, 16 Apr 2007) | 3 lines
+
+        * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added m68k.
+         * src/mm/cacao-gc/Makefile.am (libgc_la_SOURCES): Removed heap.c.
+       ........
+       [0f5d540918d1]
+
+       * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-abi.c,
+       tests/gc/ClassInit.java:
+       * tests/gc/ClassInit.java: Added testcase (static initializer
+       calling gc).
+       [3a0594ed3067]
+
+2007-04-16  twisti  <twisti>
+
+       * src/mm/cacao-gc/Makefile.am, src/vm/jit/Makefile.am:
+       * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added m68k.
+       * src/mm/cacao-gc/Makefile.am (libgc_la_SOURCES): Removed heap.c.
+       [daa4ed3c8940]
+
+       * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/linux/md-abi.c:
+       * src/vm/jit/powerpc64/linux/md-abi.c: Argument register changes
+       ported (rev7713).
+       * src/vm/jit/powerpc64/emit.c: Likewise.
+       * src/vm/jit/powerpc64/codegen.c: Likewise.
+       [e454c133c9aa]
+
+2007-04-16  michi  <michi>
+
+       * src/native/jni.c, src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Runtime.c, src/threads/threads-common.c,
+       src/vm/builtin.c, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.c, src/vm/jit/arm/md-
+       abi.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/md-abi.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, src/vm/jit/mips
+       /md-abi.c, src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md-
+       abi.h, src/vm/jit/reg.c, src/vm/jit/reg.h, src/vm/jit/stack.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.c, src/vmcore/utf8.c:
+       Merged revisions 7707-7722 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7712 | twisti | 2007-04-15 23:13:03 +0200 (Sun, 15 Apr
+       2007) | 4 lines
+
+        * src/vm/jit/mips/emit.c (emit_load): Bugfix: Added missing float
+       instruction. (emit_store): Likewise. ........ r7713 | twisti |
+       2007-04-15 23:49:48 +0200 (Sun, 15 Apr 2007) | 29 lines
+
+        * src/vm/jit/reg.c (reg_setup): Removed arg{int,flt}regs stuff.
+         * src/vm/jit/reg.h (registerdata): Removed arg{int,flt}regs.
+
+        * src/vm/jit/stack.c (stack_analyse): regoff now contains the
+       register number instead of an offset.
+
+        * src/vm/jit/allocator/simplereg.c: Use
+       abi_registers_{integer,float}_argument instead of arg{int,flt}regs.
+
+        * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.c, src/vm/jit/arm
+       /md-abi.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/md-abi.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/md-abi.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c,
+       src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c: A lot of
+       changes like the ones above. ........ r7714 | twisti | 2007-04-16
+       16:11:14 +0200 (Mon, 16 Apr 2007) | 4 lines
+
+        * src/vm/builtin.c (builtin_print_argument): Removed
+       java_lang_String until we know what we do with strings internally
+       (more patches to come). ........ r7715 | twisti | 2007-04-16
+       16:28:30 +0200 (Mon, 16 Apr 2007) | 5 lines
+
+        * src/threads/threads-common.c
+       (native/include/java_lang_String.h): Added.
+       (threads_create_thread): Fixed string-internal warnings.
+       (threads_dump): Likewise. ........ r7716 | twisti | 2007-04-16
+       16:29:53 +0200 (Mon, 16 Apr 2007) | 2 lines
+
+        * src/vmcore/utf8.c (utf_get_number_of_u2s): Return 0 instead of
+       NULL. ........ r7717 | twisti | 2007-04-16 17:23:32 +0200 (Mon, 16
+       Apr 2007) | 5 lines
+
+        * src/native/vm/gnu/java_lang_VMClassLoader.c (loadClass): Fixed
+       string-internal warnings. (nativeGetResources): Likewise.
+       (findLoadedClass): Likewise. ........ r7718 | twisti | 2007-04-16
+       17:26:01 +0200 (Mon, 16 Apr 2007) | 3 lines
+
+        * src/native/vm/gnu/java_lang_VMRuntime.c (mapLibraryName): Fixed
+       string-internal warnings. ........ r7719 | twisti | 2007-04-16
+       17:29:29 +0200 (Mon, 16 Apr 2007) | 3 lines
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c (getSignature):
+       Fixed string-internal warnings. ........ r7720 | twisti |
+       2007-04-16 17:49:09 +0200 (Mon, 16 Apr 2007) | 13 lines
+
+        * src/native/vm/java_lang_ClassLoader.c (defineClass): Fixed
+       string-internal warnings.
+
+        * src/native/vm/java_lang_Runtime.c (loadLibrary): Likewise.
+
+        * src/native/vm/gnu/java_lang_reflect_Field.c (getSignature):
+       Likewise.
+
+        * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (getSignature): Likewise.
+
+        * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace):
+       Likewise. ........ r7721 | twisti | 2007-04-16 17:53:53 +0200
+       (Mon, 16 Apr 2007) | 7 lines
+
+        * src/native/vm/java_lang_Class.c (forName): Fixed string-internal
+       warnings. (getDeclaredFields): Likewise. (getDeclaredMethods):
+       Likewise. (getEnclosingMethod): Likewise. (getClassSignature):
+       Likewise. ........ r7722 | twisti | 2007-04-16 17:57:21 +0200
+       (Mon, 16 Apr 2007) | 5 lines
+
+        * src/native/jni.c (_Jv_JNI_DefineClass): Fixed string-internal
+       warnings. (_Jv_JNI_NewStringUTF): Likewise.
+       (_Jv_JNI_GetStringUTFChars): Likewise. ........
+       [24a7a762a076]
+
+2007-04-16  twisti  <twisti>
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_DefineClass): Fixed string-internal
+       warnings. (_Jv_JNI_NewStringUTF): Likewise.
+       (_Jv_JNI_GetStringUTFChars): Likewise.
+       [a37bf09a362e]
+
+       * src/native/vm/java_lang_Class.c:
+       * src/native/vm/java_lang_Class.c (forName): Fixed string-internal
+       warnings. (getDeclaredFields): Likewise. (getDeclaredMethods):
+       Likewise. (getEnclosingMethod): Likewise. (getClassSignature):
+       Likewise.
+       [07c0a68486d0]
+
+       * src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_Runtime.c:
+       * src/native/vm/java_lang_ClassLoader.c (defineClass): Fixed string-
+       internal warnings.
+
+       * src/native/vm/java_lang_Runtime.c (loadLibrary): Likewise.
+
+       * src/native/vm/gnu/java_lang_reflect_Field.c (getSignature):
+       Likewise.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c (getSignature):
+       Likewise.
+
+       * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace):
+       Likewise.
+       [c8536d3e324b]
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c:
+       * src/native/vm/gnu/java_lang_reflect_Method.c (getSignature): Fixed
+       string-internal warnings.
+       [5e143a12f2f0]
+
+       * src/native/vm/gnu/java_lang_VMRuntime.c:
+       * src/native/vm/gnu/java_lang_VMRuntime.c (mapLibraryName): Fixed
+       string-internal warnings.
+       [ce5133d6a085]
+
+       * src/native/vm/gnu/java_lang_VMClassLoader.c:
+       * src/native/vm/gnu/java_lang_VMClassLoader.c (loadClass): Fixed
+       string-internal warnings. (nativeGetResources): Likewise.
+       (findLoadedClass): Likewise.
+       [bf7462d48bc1]
+
+       * src/vmcore/utf8.c:
+       * src/vmcore/utf8.c (utf_get_number_of_u2s): Return 0 instead of
+       NULL.
+       [c6d33c63976b]
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (native/include/java_lang_String.h):
+       Added. (threads_create_thread): Fixed string-internal warnings.
+       (threads_dump): Likewise.
+       [9dffdfeeb62e]
+
+       * src/vm/builtin.c:
+       * src/vm/builtin.c (builtin_print_argument): Removed
+       java_lang_String until we know what we do with strings internally
+       (more patches to come).
+       [99f554aec90e]
+
+2007-04-15  twisti  <twisti>
+
+       * src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/arm/md-
+       abi.c, src/vm/jit/arm/md-abi.h, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/md-abi.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/md-abi.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md-
+       abi.h, src/vm/jit/reg.c, src/vm/jit/reg.h, src/vm/jit/stack.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.c:
+       * src/vm/jit/reg.c (reg_setup): Removed arg{int,flt}regs stuff.
+       * src/vm/jit/reg.h (registerdata): Removed arg{int,flt}regs.
+
+       * src/vm/jit/stack.c (stack_analyse): regoff now contains the
+       register number instead of an offset.
+
+       * src/vm/jit/allocator/simplereg.c: Use
+       abi_registers_{integer,float}_argument instead of arg{int,flt}regs.
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.c, src/vm/jit/arm/md-
+       abi.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/md-abi.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, src/vm/jit/mips
+       /md-abi.c, src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md-
+       abi.h, src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.c: A lot of changes like the ones above.
+       [a3fefe287703]
+
+       * src/vm/jit/mips/emit.c:
+       * src/vm/jit/mips/emit.c (emit_load): Bugfix: Added missing float
+       instruction. (emit_store): Likewise.
+       [9851f06e8ca3]
+
+2007-04-15  michi  <michi>
+
+       * src/vm/builtintable.inc:
+       * src/vm/builtintable.inc: Fixed flags for builtin_new and
+       builtin_fast_new.
+       [7308c5bf0f60]
+
+       * src/vm/builtin.h, src/vm/builtintable.inc:
+       * src/vm/builtin.h (builtintable_entry): Added stub pointer.
+       * src/vm/builtintable.inc: Adapted to above changes. Added vim boiler
+       plate.
+       [22c4d550cf29]
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/i386/codegen.c (codegen_emit_stub_builtin): Different
+       function signature. Fixed argument passing. Saving return value.
+
+       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_builtin): Different
+       function signature.
+       [1d72eeb5cb8e]
+
+       * src/vm/jit/i386/codegen.c:
+       * src/vm/jit/i386/codegen.c (codegen_emit_stub_builtin):
+       Implemented. (codegen_emit_stub_native): Now uses
+       abi_registers_integer_saved.
+       [66d503d68d4a]
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/i386/md-abi.c,
+       tests/regression/resolving/Makefile.am,
+       tests/regression/resolving/classes1/Makefile.am,
+       tests/regression/resolving/classes2/Makefile.am,
+       tests/regression/resolving/classes3/Makefile.am:
+       Merged revisions 7701-7706 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7703 | twisti | 2007-04-15 13:37:55 +0200 (Sun, 15 Apr
+       2007) | 6 lines
+
+        * tests/regression/resolving/Makefile.am: Added GNU header and
+       fixed srcdir != builddir.
+         * tests/regression/resolving/classes1/Makefile.am: Likewise.
+         * tests/regression/resolving/classes2/Makefile.am: Likewise.
+         * tests/regression/resolving/classes3/Makefile.am: Likewise. ........
+       r7704 | michi | 2007-04-15 13:55:25 +0200 (Sun, 15 Apr 2007) | 3
+       lines
+
+        * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Fixed
+       calculation of stackframesize. ........ r7705 | michi | 2007-04-15
+       14:15:01 +0200 (Sun, 15 Apr 2007) | 4 lines
+
+        * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument):
+       Added. (abi_registers_integer_saved): Likewise.
+       (abi_registers_integer_temporary): Likewise. ........ r7706 |
+       michi | 2007-04-15 14:17:02 +0200 (Sun, 15 Apr 2007) | 2 lines
+
+        * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument):
+       Fixed. ........
+       [84a0c74bbb13]
+
+       * src/vm/jit/i386/md-abi.c:
+       * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument): Fixed.
+       [7105b50d6de2]
+
+       * src/vm/jit/i386/md-abi.c:
+       * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument): Added.
+       (abi_registers_integer_saved): Likewise.
+       (abi_registers_integer_temporary): Likewise.
+       [fb1cc05ded0e]
+
+       * src/vm/jit/i386/codegen.c:
+       * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Fixed
+       calculation of stackframesize.
+       [ad58732e3821]
+
+2007-04-15  twisti  <twisti>
+
+       * tests/regression/resolving/Makefile.am,
+       tests/regression/resolving/classes1/Makefile.am,
+       tests/regression/resolving/classes2/Makefile.am,
+       tests/regression/resolving/classes3/Makefile.am:
+       * tests/regression/resolving/Makefile.am: Added GNU header and fixed
+       srcdir != builddir.
+       * tests/regression/resolving/classes1/Makefile.am: Likewise.
+       * tests/regression/resolving/classes2/Makefile.am: Likewise.
+       * tests/regression/resolving/classes3/Makefile.am: Likewise.
+       [9fa46231f8d7]
+
+2007-04-15  michi  <michi>
+
+       * src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_builtin): Removed
+       call of codegen_finish.
+       [e47ffd6fee4f]
+
+       * src/cacao/cacao.c, src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h,
+       src/vm/jit/i386/arch.h, src/vm/jit/m68k/arch.h,
+       src/vm/jit/mips/arch.h, src/vm/jit/mips/codegen.c, src/vm/jit/mips
+       /md-abi.c, src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc64/arch.h,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/arch.h,
+       src/vm/jit/sparc64/arch.h, src/vm/jit/stack.c,
+       src/vm/jit/x86_64/arch.h:
+       Merged revisions 7693-7700 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7694 | tbfg | 2007-04-12 17:35:13 +0200 (Thu, 12 Apr
+       2007) | 8 lines
+
+        * src/vm/jit/powerpc64/emit.c (emit_patcher_stubs): Removed dead
+       code.
+
+        * src/vm/jit/powerpc64/codegen.c (ICMD_ISUB): Fixed evil bug.
+       (ICMD_LSHR): Fixed a bug. (createnativestub): Use
+       emit_patcher_stub.
+
+        * src/vm/jit/powerpc64/patcher.c (patcher_resolve_native): Fixed.
+       ........ r7695 | twisti | 2007-04-12 21:49:34 +0200 (Thu, 12 Apr
+       2007) | 14 lines
+
+        * src/vm/jit/stack.c (stack_analyse): Removed USEBUILTINTABLE,
+       always check for automatic-builtins (compile this is not
+       affected).
+
+        * src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h,
+       src/vm/jit/i386/arch.h, src/vm/jit/m68k/arch.h,
+       src/vm/jit/mips/arch.h, src/vm/jit/powerpc/arch.h,
+       src/vm/jit/powerpc64/arch.h, src/vm/jit/s390/arch.h,
+       src/vm/jit/sparc64/arch.h, src/vm/jit/x86_64/arch.h
+       (USEBUILTINTABLE): Removed. ........ r7698 | twisti | 2007-04-13
+       12:12:04 +0200 (Fri, 13 Apr 2007) | 5 lines
+
+        * src/cacao/cacao.c (main): Save the error message of the first
+       lt_dlopenext and print it too when the second fails (thanks
+       Dalibor). Although there's still a problem, when the first fails
+       for some reason and the second picks up and old installed one
+       silently. ........ r7699 | twisti | 2007-04-13 12:42:05 +0200
+       (Fri, 13 Apr 2007) | 2 lines
+
+        * src/vm/jit/mips/md-abi.c (md_param_alloc): Code beautified.
+       ........ r7700 | twisti | 2007-04-13 13:48:48 +0200 (Fri, 13 Apr
+       2007) | 3 lines
+
+        * src/vm/jit/mips/codegen.c (codegen_emit): ICMD_LDIV, ICMD_LREM:
+       Use REG_Ax_Ax_PACKED defines. ........
+       [cdaa70dc40b0]
+
+2007-04-13  twisti  <twisti>
+
+       * src/vm/jit/mips/codegen.c:
+       * src/vm/jit/mips/codegen.c (codegen_emit): ICMD_LDIV, ICMD_LREM:
+       Use REG_Ax_Ax_PACKED defines.
+       [11e93792d728]
+
+       * src/vm/jit/mips/md-abi.c:
+       * src/vm/jit/mips/md-abi.c (md_param_alloc): Code beautified.
+       [63916a5952b0]
+
+       * src/cacao/cacao.c:
+       * src/cacao/cacao.c (main): Save the error message of the first
+       lt_dlopenext and print it too when the second fails (thanks
+       Dalibor). Although there's still a problem, when the first fails for
+       some reason and the second picks up and old installed one silently.
+       [7486bf60943a]
+
+2007-04-12  twisti  <twisti>
+
+       * src/vm/jit/x86_64/codegen.c:
+       * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_builtin): New
+       function.
+       [05a68242fab2]
+
+       * src/vm/builtin.c, src/vm/builtin.h, src/vm/builtintable.inc,
+       src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h,
+       src/vm/jit/i386/arch.h, src/vm/jit/mips/arch.h,
+       src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc64/arch.h,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/arch.h, src/vm/jit/stack.c,
+       src/vm/jit/x86_64/arch.h:
+       * src/vm/builtin.c (builtintable_replace_function): Replaced
+       checkexception with flags and check for exception flag.
+
+       * src/vm/builtin.h (builtintable_entry): Removed checkexception,
+       added flags. (BUILTINTABLE_FLAG_STUB): Defined.
+       (BUILTINTABLE_FLAG_EXCEPTION): Likewise.
+
+       * src/vm/builtintable.inc (builtintable_internal): Moved position of
+       flags. (builtintable_automatic): Likewise. (builtintable_function):
+       Likewise.
+       [b63c7f9b5333]
+
+       * src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h,
+       src/vm/jit/i386/arch.h, src/vm/jit/m68k/arch.h,
+       src/vm/jit/mips/arch.h, src/vm/jit/powerpc/arch.h,
+       src/vm/jit/powerpc64/arch.h, src/vm/jit/s390/arch.h,
+       src/vm/jit/sparc64/arch.h, src/vm/jit/stack.c,
+       src/vm/jit/x86_64/arch.h:
+       * src/vm/jit/stack.c (stack_analyse): Removed USEBUILTINTABLE,
+       always check for automatic-builtins (compile this is not affected).
+
+       * src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h,
+       src/vm/jit/i386/arch.h, src/vm/jit/m68k/arch.h,
+       src/vm/jit/mips/arch.h, src/vm/jit/powerpc/arch.h,
+       src/vm/jit/powerpc64/arch.h, src/vm/jit/s390/arch.h,
+       src/vm/jit/sparc64/arch.h, src/vm/jit/x86_64/arch.h
+       (USEBUILTINTABLE): Removed.
+       [9112dbd911db]
+
+2007-04-12  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/patcher.c:
+       * src/vm/jit/powerpc64/emit.c (emit_patcher_stubs): Removed dead
+       code.
+
+       * src/vm/jit/powerpc64/codegen.c (ICMD_ISUB): Fixed evil bug.
+       (ICMD_LSHR): Fixed a bug. (createnativestub): Use emit_patcher_stub.
+
+       * src/vm/jit/powerpc64/patcher.c (patcher_resolve_native): Fixed.
+       [2f53b0ece37e]
+
+2007-04-12  michi  <michi>
+
+       * src/cacaoh/dummy.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/codegen.h, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h, src/vm/jit/arm/linux/md-os.c, src/vm/jit
+       /codegen-common.c, src/vm/jit/codegen-common.h,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h,
+       src/vm/jit/jit.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/codegen.h, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/codegen.h, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/codegen.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/codegen.h, src/vm/jit_interface.h,
+       src/vmcore/linker.c, src/vmcore/loader.c:
+       Merged revisions 7688-7692 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7690 | twisti | 2007-04-12 13:56:05 +0200 (Thu, 12 Apr
+       2007) | 3 lines
+
+        * src/vm/jit/arm/linux/md-os.c (mm/memory.h): Removed.
+       [ENABLE_THREADS] (threads/native/threads.h): Added. ........ r7691
+       | twisti | 2007-04-12 14:45:10 +0200 (Thu, 12 Apr 2007) | 36 lines
+
+        * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler):
+       New function.
+
+        * src/vm/jit/codegen-common.h (createcompilerstub): Removed.
+       (codegen_generate_stub_compiler): Added.
+         * src/vm/jit_interface.h: Likewise.
+         * src/cacaoh/dummy.c: Likewise.
+
+        * src/vmcore/linker.c (link_class_intern): Replaced
+       createcompilerstub with codegen_generate_stub_compiler.
+
+        * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c
+       (COMPILERSTUB_DATASIZE) (COMPILERSTUB_SIZE): Removed.
+       (createcompilerstub): Renamed to codegen_emit_stub_compiler and
+       changed signature.
+
+        * src/vm/jit/alpha/codegen.h, src/vm/jit/arm/codegen.h,
+       src/vm/jit/i386/codegen.h, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/mips/codegen.h, src/vm/jit/powerpc/codegen.h,
+       src/vm/jit/powerpc64/codegen.h, src/vm/jit/s390/codegen.h,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/x86_64/codegen.h
+       (COMPILERSTUB_CODESIZE): Added. ........ r7692 | twisti |
+       2007-04-12 16:47:24 +0200 (Thu, 12 Apr 2007) | 26 lines
+
+        * src/vm/jit/codegen-common.c (codegen_createnativestub): Renamed
+       to codegen_generate_stub_native and call codegen_finish.
+
+        * src/vm/jit/codegen-common.h (codegen_createnativestub): Removed.
+       (codegen_generate_stub_native): Added.
+         * src/vm/jit_interface.h: Likewise.
+         * src/cacaoh/dummy.c: Likewise.
+
+        * src/vmcore/loader.c (load_newly_created_array): Renamed
+       codegen_createnativestub to codegen_generate_stub_native and changed
+       signature.
+         * src/vm/jit/jit.c (jit_compile_intern): Likewise.
+
+        * src/vm/jit/arm/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/x86_64/codegen.c
+       (createnativestub): Renamed to codegen_emit_stub_native and
+       changed signature, don't call codegen_finish. ........
+       [c9aa605344f9]
+
+2007-04-12  twisti  <twisti>
+
+       * src/cacaoh/dummy.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/codegen-common.c, src/vm/jit
+       /codegen-common.h, src/vm/jit/i386/codegen.c, src/vm/jit/jit.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit_interface.h,
+       src/vmcore/loader.c:
+       * src/vm/jit/codegen-common.c (codegen_createnativestub): Renamed to
+       codegen_generate_stub_native and call codegen_finish.
+
+       * src/vm/jit/codegen-common.h (codegen_createnativestub): Removed.
+       (codegen_generate_stub_native): Added.
+       * src/vm/jit_interface.h: Likewise.
+       * src/cacaoh/dummy.c: Likewise.
+
+       * src/vmcore/loader.c (load_newly_created_array): Renamed
+       codegen_createnativestub to codegen_generate_stub_native and changed
+       signature.
+       * src/vm/jit/jit.c (jit_compile_intern): Likewise.
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/x86_64/codegen.c
+       (createnativestub): Renamed to codegen_emit_stub_native and changed
+       signature, don't call codegen_finish.
+       [bdea958b9063]
+
+       * src/cacaoh/dummy.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/codegen.h, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h, src/vm/jit/codegen-common.c, src/vm/jit
+       /codegen-common.h, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/codegen.h, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/codegen.h, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/codegen.h, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/codegen.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/codegen.h, src/vm/jit_interface.h,
+       src/vmcore/linker.c:
+       * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler): New
+       function.
+
+       * src/vm/jit/codegen-common.h (createcompilerstub): Removed.
+       (codegen_generate_stub_compiler): Added.
+       * src/vm/jit_interface.h: Likewise.
+       * src/cacaoh/dummy.c: Likewise.
+
+       * src/vmcore/linker.c (link_class_intern): Replaced
+       createcompilerstub with codegen_generate_stub_compiler.
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c
+       (COMPILERSTUB_DATASIZE) (COMPILERSTUB_SIZE): Removed.
+       (createcompilerstub): Renamed to codegen_emit_stub_compiler and
+       changed signature.
+
+       * src/vm/jit/alpha/codegen.h, src/vm/jit/arm/codegen.h,
+       src/vm/jit/i386/codegen.h, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/mips/codegen.h, src/vm/jit/powerpc/codegen.h,
+       src/vm/jit/powerpc64/codegen.h, src/vm/jit/s390/codegen.h,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/x86_64/codegen.h
+       (COMPILERSTUB_CODESIZE): Added.
+       [604ac021c387]
+
+       * src/vm/jit/arm/linux/md-os.c:
+       * src/vm/jit/arm/linux/md-os.c (mm/memory.h): Removed.
+       [ENABLE_THREADS] (threads/native/threads.h): Added.
+       [d360d51a6405]
+
+2007-04-12  michi  <michi>
+
+       * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao-
+       gc/mark.c:
+       * src/mm/cacao-gc/gc.h (gc_collect): Added prototype.
+       * src/mm/cacao-gc/heap.c: Fixed includes.
+       * src/mm/cacao-gc/mark.c: Fixed includes.
+       [aad7ee5bcc5b]
+
+       * src/cacaoh/dummy.c, src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/threads/native/threads.c, src/toolbox/logging.c,
+       src/vm/global.h, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/alpha/emit.c, src/vm/jit/arm/asmpart.S, src/vm/jit
+       /codegen-common.c, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/intrp/asmpart.c, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/arch.h,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/codegen.h, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390
+       /md-abi.h, src/vm/jit/s390/tests/tests.java.pp,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S,
+       src/vmcore/linker.c, src/vmcore/linker.h:
+       Merged revisions 7674-7687 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7675 | michi | 2007-04-05 16:23:04 +0200 (Thu, 05 Apr
+       2007) | 10 lines
+
+        * src/vm/global.h (compiler_lock, compiler_unlock): Removed.
+         * src/cacaoh/dummy.c (compiler_lock, compiler_unlock): Removed.
+         * src/threads/native/threads.c (compiler_lock, compiler_unlock):
+       Removed.
+
+        * src/vmcore/linker.h (linker_classrenumber_lock): Added.
+         * src/vmcore/linker.c (linker_classrenumber_lock): Added.
+       (linker_compute_subclasses): Uses above lock object instead of
+       compiler_lock.
+
+        * src/vm/jit/intrp/asmpart.c (intrp_asm_getclassvalues_atomic):
+       Likewise. ........ r7676 | twisti | 2007-04-08 23:14:40 +0200
+       (Sun, 08 Apr 2007) | 3 lines
+
+        * src/native/vm/cldc1.1/java_lang_Object.c (notifyAll):
+       Implemented.
+         * src/native/vm/cldc1.1/java_lang_String.c (lastIndexOf__I): Likewise.
+       ........ r7677 | twisti | 2007-04-09 13:51:25 +0200 (Mon, 09 Apr
+       2007) | 8 lines
+
+        * src/vm/jit/mips/codegen.h (BRANCH_NOPS): Added long-branches
+       case.
+
+        * src/vm/jit/mips/emit.c (emit_load): Use switch-case instead of
+       if-else contruct. (emit_store): Likewise. (emit_copy): Likewise.
+       (emit_branch): Implemented conditional long-branches. ........
+       r7678 | twisti | 2007-04-09 19:23:55 +0200 (Mon, 09 Apr 2007) | 11
+       lines
+
+        * src/vm/jit/alpha/asmpart.S: Use % instead of @ for progbits as
+       ARM's assembler uses @ as comment character.
+         * src/vm/jit/arm/asmpart.S: Likewise.
+         * src/vm/jit/i386/asmpart.S: Likewise.
+         * src/vm/jit/mips/asmpart.S: Likewise.
+         * src/vm/jit/powerpc/asmpart.S: Likewise.
+         * src/vm/jit/powerpc64/asmpart.S: Likewise.
+         * src/vm/jit/s390/asmpart.S: Likewise.
+         * src/vm/jit/sparc64/asmpart.S: Likewise.
+         * src/vm/jit/x86_64/asmpart.S: Likewise. ........ r7679 | twisti |
+       2007-04-09 23:17:36 +0200 (Mon, 09 Apr 2007) | 2 lines
+
+        * src/vm/jit/alpha/emit.c (emit_copy): Check src-type, not dst-
+       type. ........ r7680 | pm | 2007-04-10 07:02:20 +0200 (Tue, 10 Apr
+       2007) | 8 lines
+
+        * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/tests/tests.java.pp: Changed very much. ........
+       r7681 | twisti | 2007-04-10 14:22:16 +0200 (Tue, 10 Apr 2007) | 3
+       lines
+
+        * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Set
+       val accordingly. ........ r7682 | twisti | 2007-04-10 23:24:14
+       +0200 (Tue, 10 Apr 2007) | 3 lines
+
+        * src/vm/jit/mips/codegen.c (codegen_emit): Fixed ICMD_IF_Lxx
+       instructions for 64-bit. ........ r7683 | twisti | 2007-04-10
+       23:37:03 +0200 (Tue, 10 Apr 2007) | 3 lines
+
+        * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): We
+       only need to check the cause for pre glibc-2.5. ........ r7684 |
+       twisti | 2007-04-11 10:11:49 +0200 (Wed, 11 Apr 2007) | 3 lines
+
+        * src/vm/jit/codegen-common.c (codegen_generate): Added re-
+       generating debug message. ........ r7685 | twisti | 2007-04-11
+       10:21:06 +0200 (Wed, 11 Apr 2007) | 2 lines
+
+        * src/toolbox/logging.c (log_finish): Also print a \n in the log-
+       file. ........ r7687 | tbfg | 2007-04-11 18:39:22 +0200 (Wed, 11
+       Apr 2007) | 19 lines
+
+        * src/vm/jit/powerpc64/arch.h (SUPPORT_LONG_SHIFT): Enabled.
+
+        * src/vm/jit/powerpc64/codegen.c (ICMD_LSHLCONST): Implemented.
+       (ICMD_LSHRCONST): Likewise. (ICMD_LUSHRCONST): Likewise.
+       (ICMD_LSHL): Likewise. (ICMD_LSHR): Likewise. (ICMD_LUSHR):
+       Likewise. (ICMD_IUSHR): Fixed. (ICMD_IUSHRCONST): Fixed.
+
+        * src/vm/jit/powerpc64/codegen.h (M_SRL): Use 64bit opcode.
+       (M_SRA): Likewise. (M_SRA_IMM): Likewise. (M_SRL_IMM): Likewise.
+       (M_SSL_IMM): Likewise. (M_SSL): Likewise. (M_CLR_HIGH): Added.
+       ........
+       [7a123c32db11]
+
+2007-04-11  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/codegen.h:
+       * src/vm/jit/powerpc64/arch.h (SUPPORT_LONG_SHIFT): Enabled.
+
+       * src/vm/jit/powerpc64/codegen.c (ICMD_LSHLCONST): Implemented.
+       (ICMD_LSHRCONST): Likewise. (ICMD_LUSHRCONST): Likewise.
+       (ICMD_LSHL): Likewise. (ICMD_LSHR): Likewise. (ICMD_LUSHR):
+       Likewise. (ICMD_IUSHR): Fixed. (ICMD_IUSHRCONST): Fixed.
+
+       * src/vm/jit/powerpc64/codegen.h (M_SRL): Use 64bit opcode. (M_SRA):
+       Likewise. (M_SRA_IMM): Likewise. (M_SRL_IMM): Likewise. (M_SSL_IMM):
+       Likewise. (M_SSL): Likewise. (M_CLR_HIGH): Added.
+       [8b91afea2648]
+
+2007-04-11  twisti  <twisti>
+
+       * src/vm/builtin.h, src/vm/builtintable.inc,
+       src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/tests/tests.java.pp,
+       src/vm/jit/x86_64/asmpart.S, src/vmcore/linker.c:
+       * src/vm/builtin.h (builtin_fast_new): Added. (BUILTIN_FAST_new):
+       Likewise.
+
+       * src/vm/builtintable.inc (builtintable_internal): Added
+       BUILTIN_FAST_new.
+       [2c1970a9e98f]
+
+       * src/toolbox/logging.c:
+       * src/toolbox/logging.c (log_finish): Also print a \n in the log-
+       file.
+       [45a5bb68dac8]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_generate): Added re-
+       generating debug message.
+       [5d40e61513e2]
+
+2007-04-10  twisti  <twisti>
+
+       * src/vm/jit/mips/linux/md-os.c:
+       * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): We only
+       need to check the cause for pre glibc-2.5.
+       [ba356d7fb5f0]
+
+       * src/vm/jit/mips/codegen.c:
+       * src/vm/jit/mips/codegen.c (codegen_emit): Fixed ICMD_IF_Lxx
+       instructions for 64-bit.
+       [c6d5b478aef0]
+
+       * src/vm/jit/mips/linux/md-os.c:
+       * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Set val
+       accordingly.
+       [3e43374d7974]
+
+2007-04-10  pm  <pm>
+
+       * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h,
+       src/vm/jit/s390/tests/tests.java.pp:
+       * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/tests/tests.java.pp: Changed very much.
+       [8991ec608963]
+
+2007-04-09  twisti  <twisti>
+
+       * src/vm/jit/alpha/emit.c:
+       * src/vm/jit/alpha/emit.c (emit_copy): Check src-type, not dst-type.
+       [1d86f11b4c3a]
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/x86_64/asmpart.S:
+       * src/vm/jit/alpha/asmpart.S: Use % instead of @ for progbits as
+       ARM's assembler uses @ as comment character.
+       * src/vm/jit/arm/asmpart.S: Likewise.
+       * src/vm/jit/i386/asmpart.S: Likewise.
+       * src/vm/jit/mips/asmpart.S: Likewise.
+       * src/vm/jit/powerpc/asmpart.S: Likewise.
+       * src/vm/jit/powerpc64/asmpart.S: Likewise.
+       * src/vm/jit/s390/asmpart.S: Likewise.
+       * src/vm/jit/sparc64/asmpart.S: Likewise.
+       * src/vm/jit/x86_64/asmpart.S: Likewise.
+       [8e4b092d8838]
+
+       * src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c:
+       * src/vm/jit/mips/codegen.h (BRANCH_NOPS): Added long-branches case.
+
+       * src/vm/jit/mips/emit.c (emit_load): Use switch-case instead of if-
+       else contruct. (emit_store): Likewise. (emit_copy): Likewise.
+       (emit_branch): Implemented conditional long-branches.
+       [2b31d3ab64e9]
+
+2007-04-08  twisti  <twisti>
+
+       * src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_String.c:
+       * src/native/vm/cldc1.1/java_lang_Object.c (notifyAll): Implemented.
+       * src/native/vm/cldc1.1/java_lang_String.c (lastIndexOf__I): Likewise.
+       [020417ffe9f4]
+
+2007-04-05  michi  <michi>
+
+       * src/cacaoh/dummy.c, src/threads/native/threads.c, src/vm/global.h,
+       src/vm/jit/intrp/asmpart.c, src/vmcore/linker.c,
+       src/vmcore/linker.h:
+       * src/vm/global.h (compiler_lock, compiler_unlock): Removed.
+       * src/cacaoh/dummy.c (compiler_lock, compiler_unlock): Removed.
+       * src/threads/native/threads.c (compiler_lock, compiler_unlock):
+       Removed.
+
+       * src/vmcore/linker.h (linker_classrenumber_lock): Added.
+       * src/vmcore/linker.c (linker_classrenumber_lock): Added.
+       (linker_compute_subclasses): Uses above lock object instead of
+       compiler_lock.
+
+       * src/vm/jit/intrp/asmpart.c (intrp_asm_getclassvalues_atomic):
+       Likewise.
+       [b6b122d1b5da]
+
+       * src/native/native.c, src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h,
+       src/vm/exceptions.c, src/vm/jit/codegen-common.c:
+       Merged revisions 7665-7673 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7666 | twisti | 2007-04-05 02:14:57 +0200 (Thu, 05 Apr
+       2007) | 4 lines
+
+        * src/threads/threads-common.c (threads_print_stacktrace): Removed
+       !ENABLE_THREADS code, since this file is only compiled with
+       ENABLE_THREADS. ........ r7669 | twisti | 2007-04-05 13:39:58
+       +0200 (Thu, 05 Apr 2007) | 27 lines
+
+        * src/native/vm/java_lang_Thread.c [ENABLE_THREADS]
+       (threads/native/threads.h): Removed. (threads/threads-common.h):
+       Added. (vm/stringlocal.h): Likewise. (vm/vm.h): Removed.
+       (getState): Implemented.
+
+        * src/threads/threads-common.c (vm/vm.h): Added.
+       (threads_get_state): New function. (threads_dump): Print thread
+       state.
+
+        * src/threads/threads-common.h (THREAD_STATE_NEW)
+       (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING)
+       (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Defined.
+       (threads_get_state): Added.
+
+        * src/threads/native/threads.c (threads_init): Set thread-state.
+       (threads_startup_thread): Likewise.
+       (threads_attach_current_thread): Likewise.
+       (threads_detach_thread): Likewise. (threads_wait_with_timeout):
+       Likewise.
+
+        * src/threads/native/threads.h (threadobject): Added state field.
+
+        * src/native/native.c (dummynativetable) [ENABLE_JAVASE]: Added
+       Java_java_lang_VMThread_getState. ........ r7670 | twisti |
+       2007-04-05 13:57:59 +0200 (Thu, 05 Apr 2007) | 13 lines
+
+        * src/threads/threads-common.c (threads_get_state): Renamed to
+       threads_thread_get_state. (threads_thread_is_alive): New function.
+
+        * src/threads/threads-common.h: Likewise.
+
+        * src/native/vm/java_lang_Thread.c (isAlive): New function.
+       (getState): Renamed threads_get_state to threads_thread_get_state.
+
+        * src/native/vm/java_lang_Thread.h (isAlive): Added.
+
+        * src/native/vm/cldc1.1/java_lang_Thread.c (isAlive): New
+       function. ........ r7671 | twisti | 2007-04-05 14:06:28 +0200
+       (Thu, 05 Apr 2007) | 3 lines
+
+        * src/vm/exceptions.c (exceptions_throw_nosuchmethoderror)
+       [!ENABLE_JAVASE]: Throw an error. ........ r7673 | michi |
+       2007-04-05 15:22:37 +0200 (Thu, 05 Apr 2007) | 3 lines
+
+        * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Inserted
+       ifdef to fix compiler error with disabled threads. ........
+       [c1e618e7a27b]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Inserted
+       ifdef to fix compiler error with disabled threads.
+       [bab8588a9998]
+
+       * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/gc.c, src/mm/cacao-
+       gc/heap.c, src/vm/exceptions.c:
+       * src/mm/cacao-gc/heap.c: Added include to fix compile warning.
+
+       * src/mm/cacao-gc/compact.c: Made most functions static.
+
+       * src/mm/cacao-gc/gc.c (gc_collect): Fixed debug output for current
+       stacktrace.
+       [f0c3b9c0ed44]
+
+2007-04-05  twisti  <twisti>
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_throw_nosuchmethoderror)
+       [!ENABLE_JAVASE]: Throw an error.
+       [bc502afcb318]
+
+       * src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h,
+       src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/threads/threads-common.c (threads_get_state): Renamed to
+       threads_thread_get_state. (threads_thread_is_alive): New function.
+
+       * src/threads/threads-common.h: Likewise.
+
+       * src/native/vm/java_lang_Thread.c (isAlive): New function.
+       (getState): Renamed threads_get_state to threads_thread_get_state.
+
+       * src/native/vm/java_lang_Thread.h (isAlive): Added.
+
+       * src/native/vm/cldc1.1/java_lang_Thread.c (isAlive): New function.
+       [60d709c07fc6]
+
+       * src/native/native.c, src/native/vm/java_lang_Thread.c,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h:
+       * src/native/vm/java_lang_Thread.c [ENABLE_THREADS]
+       (threads/native/threads.h): Removed. (threads/threads-common.h):
+       Added. (vm/stringlocal.h): Likewise. (vm/vm.h): Removed. (getState):
+       Implemented.
+
+       * src/threads/threads-common.c (vm/vm.h): Added.
+       (threads_get_state): New function. (threads_dump): Print thread
+       state.
+
+       * src/threads/threads-common.h (THREAD_STATE_NEW)
+       (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING)
+       (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Defined.
+       (threads_get_state): Added.
+
+       * src/threads/native/threads.c (threads_init): Set thread-state.
+       (threads_startup_thread): Likewise. (threads_attach_current_thread):
+       Likewise. (threads_detach_thread): Likewise.
+       (threads_wait_with_timeout): Likewise.
+
+       * src/threads/native/threads.h (threadobject): Added state field.
+
+       * src/native/native.c (dummynativetable) [ENABLE_JAVASE]: Added
+       Java_java_lang_VMThread_getState.
+       [2ef27aeb36c1]
+
+2007-04-05  michi  <michi>
+
+       * src/mm/cacao-gc/gc.c:
+       * src/mm/cacao-gc/gc.c (gc_collect) [!ENABLE_THREADS]: Temporarly
+       defined away printing of current stacktrace.
+       [7a3f09dfa9ab]
+
+       * configure.ac, src/mm/cacao-gc/gc.c, src/native/native.c,
+       src/native/vm/gnu/sun_misc_Unsafe.c, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/none/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h,
+       src/vm/exceptions.c, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/arm/md.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/jit.h, src/vm/jit/mips/asmpart.S, src/vm/jit/mips/md-
+       abi.h, src/vm/jit/parse.c, src/vm/jit/parse.h,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/replace.c, src/vm/jit/replace.h,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/show.c,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/stack.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h,
+       src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-stackbased-
+       gen.inc, src/vm/jit/verify/typecheck-stackbased.c,
+       src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/linux/md-os.c, src/vmcore/statistics.c:
+       Merged revisions 7642-7664 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7643 | twisti | 2007-04-03 13:35:40 +0200 (Tue, 03 Apr
+       2007) | 3 lines
+
+        * src/vmcore/statistics.c (statistics_print_memory_usage): Prevent
+       compiler warning on 64-bit machines. ........ r7644 | twisti |
+       2007-04-03 13:37:30 +0200 (Tue, 03 Apr 2007) | 3 lines
+
+        * src/vm/jit/x86_64/emit.c (emit_replacement_stubs): Removed
+       unused variable disp. ........ r7645 | twisti | 2007-04-03
+       13:46:50 +0200 (Tue, 03 Apr 2007) | 3 lines
+
+        * src/vm/jit/allocator/simplereg.c (simplereg_make_statistics):
+       Fixed compiler warning. ........ r7646 | twisti | 2007-04-03
+       13:56:21 +0200 (Tue, 03 Apr 2007) | 3 lines
+
+        * src/vm/jit/replace.c (native/include/java_lang_String.h):
+       Removed. (java_value_print): Don't cast to java_lang_String.
+       ........ r7647 | twisti | 2007-04-03 14:10:22 +0200 (Tue, 03 Apr
+       2007) | 2 lines
+
+        * src/vm/jit/jit.h: Includes alpha-sorted. ........ r7648 |
+       twisti | 2007-04-03 15:14:09 +0200 (Tue, 03 Apr 2007) | 3 lines
+
+        * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigfpe): Use
+       exceptions_new_hardware_exception. ........ r7649 | twisti |
+       2007-04-03 15:47:39 +0200 (Tue, 03 Apr 2007) | 4 lines
+
+        * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Use
+       exceptions_new_hardware_exception. [ENABLE_THREADS]
+       (md_signal_handler_sigusr2): New function. ........ r7650 | twisti
+       | 2007-04-03 15:48:10 +0200 (Tue, 03 Apr 2007) | 2 lines
+
+        * configure.ac: Added armv4 architecture. ........ r7651 |
+       twisti | 2007-04-03 16:00:32 +0200 (Tue, 03 Apr 2007) | 13 lines
+
+        * src/vm/jit/stacktrace.c
+       (stacktrace_create_inline_stackframeinfo): Removed.
+       (stacktrace_inline_arithmeticexception): Likewise.
+       (stacktrace_inline_arrayindexoutofboundsexception): Likewise.
+       (stacktrace_inline_arraystoreexception): Likewise.
+       (stacktrace_inline_classcastexception): Likewise.
+       (stacktrace_inline_nullpointerexception): Likewise.
+       (stacktrace_inline_fillInStackTrace): Likewise.
+       (stacktrace_hardware_arithmeticexception): Likewise.
+       (stacktrace_hardware_nullpointerexception): Likewise.
+
+        * src/vm/jit/stacktrace.h: Likewise. ........ r7652 | twisti |
+       2007-04-03 16:23:16 +0200 (Tue, 03 Apr 2007) | 15 lines
+
+        * src/threads/native/threads.h (STACKFRAMEINFO): Return
+       stackframeinfo instead of a pointer to it.
+         * src/threads/none/threads.h (STACKFRAMEINFO): Likewise.
+
+        * src/vm/jit/codegen-common.c (codegen_finish_native_call):
+       STACKFRAMEINFO changes.
+
+        * src/vm/jit/replace.c (replace_recover_source_state): Likewise.
+
+        * src/vm/jit/stacktrace.c (stacktrace_create_stackframeinfo):
+       Likewise. (stacktrace_create_extern_stackframeinfo): Likewise.
+       (stacktrace_create_native_stackframeinfo): Likewise.
+       (stacktrace_remove_stackframeinfo): Likewise. ........ r7653 |
+       twisti | 2007-04-03 16:34:23 +0200 (Tue, 03 Apr 2007) | 5 lines
+
+        * src/vm/jit/arm/emit.c (emit_exception_stubs): Removed.
+
+        * src/vm/jit/arm/md.c (md_codegen_patch_branch): Likewise.
+       (md_stacktrace_get_returnaddress): Removed debug code. ........
+       r7654 | twisti | 2007-04-03 17:22:21 +0200 (Tue, 03 Apr 2007) | 4
+       lines
+
+        * src/vm/exceptions.c (exceptions_fillinstacktrace)
+       [ENABLE_JAVAME_CLDC1_1]: fillInStackTrace has another signature in
+       CLDC-1.1. ........ r7655 | twisti | 2007-04-03 17:22:57 +0200
+       (Tue, 03 Apr 2007) | 3 lines
+
+        * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigfpe): Use
+       exceptions_new_hardware_exception. ........ r7656 | twisti |
+       2007-04-03 17:29:26 +0200 (Tue, 03 Apr 2007) | 5 lines
+
+        * src/vm/jit/replace.c (threads/threads-common.h): Added.
+
+        * src/vm/jit/replace.h: Moved empty defines to the top of the file
+       to see what's happening when !defined(ENABLE_REPLACEMENT).
+       ........ r7657 | twisti | 2007-04-03 17:51:52 +0200 (Tue, 03 Apr
+       2007) | 24 lines
+
+        * src/vm/jit/stacktrace.c (stacktrace_create): Changed signature.
+
+        (stacktrace_fillInStackTrace): Pass stackframeinfo to
+       stacktrace_create. (stacktrace_getClassContext): Likewise.
+       (stacktrace_getCurrentClass): Likewise. (stacktrace_getStack):
+       Likewise. (stacktrace_dump_trace): Removed.
+
+        * src/vm/jit/stacktrace.h (threads/native/threads.h)
+       (threads/none/threads.h): Removed. (stacktrace_create): Added.
+       (stacktrace_dump_trace): Removed.
+
+        * src/threads/native/threads.c (threads_dump): Removed.
+         * src/threads/native/threads.h (threads_dump): Likewise.
+
+        * src/threads/threads-common.c (vm/jit/stacktrace.h): Added.
+       (threads_dump): Added. (threads_print_stacktrace): Likewise.
+
+        * src/threads/threads-common.h (threads_dump): Added.
+       (threads_print_stacktrace): Likewise. ........ r7658 | twisti |
+       2007-04-03 18:06:30 +0200 (Tue, 03 Apr 2007) | 10 lines
+
+        * src/threads/threads-common.c (threads_print_stacktrace): Pass
+       stackframeinfo to stacktrace_create.
+
+        * src/vm/jit/codegen-common.c (threads/native/threads.h): Removed.
+       (threads/threads-common.h): Added. (codegen_get_pv_from_pc):
+       Replaced stacktrace_dump_trace with threads_print_stacktrace.
+
+        * src/vm/jit/stacktrace.h (stacktrace_print_trace_from_buffer):
+       Added. ........ r7659 | twisti | 2007-04-03 20:02:48 +0200 (Tue,
+       03 Apr 2007) | 2 lines
+
+        * src/vm/jit/mips/md-abi.h (REG_FA0, REG_FA1, REG_FA2): Defined.
+       ........ r7660 | twisti | 2007-04-03 23:30:13 +0200 (Tue, 03 Apr
+       2007) | 2 lines
+
+        * src/vm/jit/i386/linux/md-os.c (threads/threads-common.h): Added.
+       ........ r7661 | twisti | 2007-04-04 00:29:59 +0200 (Wed, 04 Apr
+       2007) | 11 lines
+
+        * src/vm/jit/alpha/asmpart.S: Replaced __GNU__ with __linux__ for
+       exec-stacks.
+         * src/vm/jit/arm/asmpart.S: Likewise.
+         * src/vm/jit/i386/asmpart.S: Likewise.
+         * src/vm/jit/mips/asmpart.S: Likewise.
+         * src/vm/jit/powerpc/asmpart.S: Likewise.
+         * src/vm/jit/powerpc64/asmpart.S: Likewise.
+         * src/vm/jit/s390/asmpart.S: Likewise.
+         * src/vm/jit/sparc64/asmpart.S: Likewise.
+         * src/vm/jit/x86_64/asmpart.S: Likewise. ........ r7662 | twisti |
+       2007-04-04 16:16:37 +0200 (Wed, 04 Apr 2007) | 8 lines
+
+        * src/native/vm/gnu/sun_misc_Unsafe.c: Header changes.
+
+        * src/native/native.c [ENABLE_JAVASE]
+       (native/include/sun_misc_Unsafe.h): Added. [ENABLE_JAVASE]
+       (dummynativetable): Added Java_sun_misc_Unsafe_objectFieldOffset
+       and Java_sun_misc_Unsafe_compareAndSwapInt. ........ r7663 |
+       twisti | 2007-04-05 00:14:42 +0200 (Thu, 05 Apr 2007) | 24 lines
+
+        * src/vm/jit/parse.c (BYTECODEINDEX_TO_BASICBLOCK): Added.
+       (parsedata_t): Removed instructionstart, added bytecodestart,
+       basicblockstart, bytecodemap, instructionmap. (parse_setup):
+       Allocate new arrays. (parse_bytecodeindex_to_basicblock): New
+       function. (parse_mark_exception_boundaries): Pass parsedata_t.
+       (parse_resolve_exception_table): Likewise. (parse): Completely
+       rewritten so we are able to have basic block boundaries on IR
+       instruction level. We now also resolve basic block pointers in
+       this pass.
+
+        * src/vm/jit/parse.h (MARK_BASICBLOCK): Pass parsedata_t.
+       (BLOCK_OF): Removed.
+
+        * src/vm/jit/jit.h (jitdata): Removed basicblockindex.
+
+        * src/vm/jit/show.c (SHOW_TARGET): Print block instead of
+       insindex. (show_icmd): Likewise.
+
+        * src/vm/jit/stack.c (BRANCH_TARGET): Directly use block.
+       (stack_analyse): Likewise.
+         * src/vm/jit/verify/icmds.c: Likewise.
+         * src/vm/jit/verify/typecheck-stackbased.c: Likewise. ........ r7664
+       | twisti | 2007-04-05 00:29:36 +0200 (Thu, 05 Apr 2007) | 4 lines
+
+        * src/vm/jit/verify/typecheck-stackbased.c: Use block directly
+       instead of insindex.
+         * src/vm/jit/verify/typecheck-stackbased-gen.inc: Newly generated.
+       ........
+       [9d86f2708920]
+
+2007-04-05  twisti  <twisti>
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_print_stacktrace): Removed
+       !ENABLE_THREADS code, since this file is only compiled with
+       ENABLE_THREADS.
+       [502ecbd2fba0]
+
+2007-04-05  michi  <michi>
+
+       * configure.ac, src/mm/cacao-gc/rootset.h, src/vm/exceptions.c,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/arm/md.c,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/jit.h,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/parse.c, src/vm/jit/parse.h,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/stack.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/emit.c, src/vmcore/statistics.c:
+       * src/mm/cacao-gc/rootset.h [!ENABLE_THREADS]: Added missing
+       include.
+       [604173540cca]
+
+2007-04-04  twisti  <twisti>
+
+       * src/vm/jit/verify/typecheck-stackbased-gen.inc, src/vm/jit/verify
+       /typecheck-stackbased.c:
+       * src/vm/jit/verify/typecheck-stackbased.c: Use block directly
+       instead of insindex.
+       * src/vm/jit/verify/typecheck-stackbased-gen.inc: Newly generated.
+       [9c43f6bf257b]
+
+       * src/vm/jit/jit.h, src/vm/jit/parse.c, src/vm/jit/parse.h,
+       src/vm/jit/show.c, src/vm/jit/stack.c, src/vm/jit/verify/icmds.c,
+       src/vm/jit/verify/typecheck-stackbased.c:
+       * src/vm/jit/parse.c (BYTECODEINDEX_TO_BASICBLOCK): Added.
+       (parsedata_t): Removed instructionstart, added bytecodestart,
+       basicblockstart, bytecodemap, instructionmap. (parse_setup):
+       Allocate new arrays. (parse_bytecodeindex_to_basicblock): New
+       function. (parse_mark_exception_boundaries): Pass parsedata_t.
+       (parse_resolve_exception_table): Likewise. (parse): Completely
+       rewritten so we are able to have basic block boundaries on IR
+       instruction level. We now also resolve basic block pointers in this
+       pass.
+
+       * src/vm/jit/parse.h (MARK_BASICBLOCK): Pass parsedata_t.
+       (BLOCK_OF): Removed.
+
+       * src/vm/jit/jit.h (jitdata): Removed basicblockindex.
+
+       * src/vm/jit/show.c (SHOW_TARGET): Print block instead of insindex.
+       (show_icmd): Likewise.
+
+       * src/vm/jit/stack.c (BRANCH_TARGET): Directly use block.
+       (stack_analyse): Likewise.
+       * src/vm/jit/verify/icmds.c: Likewise.
+       * src/vm/jit/verify/typecheck-stackbased.c: Likewise.
+       [1c98fd306ae9]
+
+       * src/native/native.c, src/native/vm/gnu/sun_misc_Unsafe.c:
+       * src/native/vm/gnu/sun_misc_Unsafe.c: Header changes.
+
+       * src/native/native.c [ENABLE_JAVASE]
+       (native/include/sun_misc_Unsafe.h): Added. [ENABLE_JAVASE]
+       (dummynativetable): Added Java_sun_misc_Unsafe_objectFieldOffset and
+       Java_sun_misc_Unsafe_compareAndSwapInt.
+       [567b543c09f0]
+
+2007-04-03  twisti  <twisti>
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/x86_64/asmpart.S:
+       * src/vm/jit/alpha/asmpart.S: Replaced __GNU__ with __linux__ for
+       exec-stacks.
+       * src/vm/jit/arm/asmpart.S: Likewise.
+       * src/vm/jit/i386/asmpart.S: Likewise.
+       * src/vm/jit/mips/asmpart.S: Likewise.
+       * src/vm/jit/powerpc/asmpart.S: Likewise.
+       * src/vm/jit/powerpc64/asmpart.S: Likewise.
+       * src/vm/jit/s390/asmpart.S: Likewise.
+       * src/vm/jit/sparc64/asmpart.S: Likewise.
+       * src/vm/jit/x86_64/asmpart.S: Likewise.
+       [444cc6a0252c]
+
+       * src/vm/jit/i386/linux/md-os.c:
+       * src/vm/jit/i386/linux/md-os.c (threads/threads-common.h): Added.
+       [eb056f855d16]
+
+       * src/vm/jit/mips/md-abi.h:
+       * src/vm/jit/mips/md-abi.h (REG_FA0, REG_FA1, REG_FA2): Defined.
+       [68805417d49c]
+
+       * src/threads/threads-common.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/stacktrace.h:
+       * src/threads/threads-common.c (threads_print_stacktrace): Pass
+       stackframeinfo to stacktrace_create.
+
+       * src/vm/jit/codegen-common.c (threads/native/threads.h): Removed.
+       (threads/threads-common.h): Added. (codegen_get_pv_from_pc):
+       Replaced stacktrace_dump_trace with threads_print_stacktrace.
+
+       * src/vm/jit/stacktrace.h (stacktrace_print_trace_from_buffer):
+       Added.
+       [92e3e05961c1]
+
+       * src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h:
+       * src/vm/jit/stacktrace.c (stacktrace_create): Changed signature.
+
+       (stacktrace_fillInStackTrace): Pass stackframeinfo to
+       stacktrace_create. (stacktrace_getClassContext): Likewise.
+       (stacktrace_getCurrentClass): Likewise. (stacktrace_getStack):
+       Likewise. (stacktrace_dump_trace): Removed.
+
+       * src/vm/jit/stacktrace.h (threads/native/threads.h)
+       (threads/none/threads.h): Removed. (stacktrace_create): Added.
+       (stacktrace_dump_trace): Removed.
+
+       * src/threads/native/threads.c (threads_dump): Removed.
+       * src/threads/native/threads.h (threads_dump): Likewise.
+
+       * src/threads/threads-common.c (vm/jit/stacktrace.h): Added.
+       (threads_dump): Added. (threads_print_stacktrace): Likewise.
+
+       * src/threads/threads-common.h (threads_dump): Added.
+       (threads_print_stacktrace): Likewise.
+       [63bf8943ed5b]
+
+       * src/vm/jit/replace.c, src/vm/jit/replace.h:
+       * src/vm/jit/replace.c (threads/threads-common.h): Added.
+
+       * src/vm/jit/replace.h: Moved empty defines to the top of the file
+       to see what's happening when !defined(ENABLE_REPLACEMENT).
+       [9bff9dceafb9]
+
+       * src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigfpe): Use
+       exceptions_new_hardware_exception.
+       [76a092e62a17]
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_fillinstacktrace)
+       [ENABLE_JAVAME_CLDC1_1]: fillInStackTrace has another signature in
+       CLDC-1.1.
+       [86cf630e9ed0]
+
+       * src/vm/jit/arm/emit.c, src/vm/jit/arm/md.c:
+       * src/vm/jit/arm/emit.c (emit_exception_stubs): Removed.
+
+       * src/vm/jit/arm/md.c (md_codegen_patch_branch): Likewise.
+       (md_stacktrace_get_returnaddress): Removed debug code.
+       [c10040663367]
+
+       * src/threads/native/threads.h, src/threads/none/threads.h, src/vm/jit
+       /codegen-common.c, src/vm/jit/replace.c, src/vm/jit/stacktrace.c:
+       * src/threads/native/threads.h (STACKFRAMEINFO): Return
+       stackframeinfo instead of a pointer to it.
+       * src/threads/none/threads.h (STACKFRAMEINFO): Likewise.
+
+       * src/vm/jit/codegen-common.c (codegen_finish_native_call):
+       STACKFRAMEINFO changes.
+
+       * src/vm/jit/replace.c (replace_recover_source_state): Likewise.
+
+       * src/vm/jit/stacktrace.c (stacktrace_create_stackframeinfo):
+       Likewise. (stacktrace_create_extern_stackframeinfo): Likewise.
+       (stacktrace_create_native_stackframeinfo): Likewise.
+       (stacktrace_remove_stackframeinfo): Likewise.
+       [a871084ee7e0]
+
+       * src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h:
+       * src/vm/jit/stacktrace.c (stacktrace_create_inline_stackframeinfo):
+       Removed. (stacktrace_inline_arithmeticexception): Likewise.
+       (stacktrace_inline_arrayindexoutofboundsexception): Likewise.
+       (stacktrace_inline_arraystoreexception): Likewise.
+       (stacktrace_inline_classcastexception): Likewise.
+       (stacktrace_inline_nullpointerexception): Likewise.
+       (stacktrace_inline_fillInStackTrace): Likewise.
+       (stacktrace_hardware_arithmeticexception): Likewise.
+       (stacktrace_hardware_nullpointerexception): Likewise.
+
+       * src/vm/jit/stacktrace.h: Likewise.
+       [af68330ce7c0]
+
+       * configure.ac:
+       * configure.ac: Added armv4 architecture.
+       [c937cb3cea57]
+
+       * src/vm/jit/arm/linux/md-os.c:
+       * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Use
+       exceptions_new_hardware_exception. [ENABLE_THREADS]
+       (md_signal_handler_sigusr2): New function.
+       [e9e777a56623]
+
+       * src/vm/jit/i386/linux/md-os.c:
+       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigfpe): Use
+       exceptions_new_hardware_exception.
+       [a97e8e6dc1e0]
+
+       * src/vm/jit/jit.h:
+       * src/vm/jit/jit.h: Includes alpha-sorted.
+       [3500fd328b80]
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (native/include/java_lang_String.h): Removed.
+       (java_value_print): Don't cast to java_lang_String.
+       [ad5d673f7d24]
+
+       * src/vm/jit/allocator/simplereg.c:
+       * src/vm/jit/allocator/simplereg.c (simplereg_make_statistics):
+       Fixed compiler warning.
+       [1055a2f64e7f]
+
+       * src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/x86_64/emit.c (emit_replacement_stubs): Removed unused
+       variable disp.
+       [2e50907d43f4]
+
+       * src/vmcore/statistics.c:
+       * src/vmcore/statistics.c (statistics_print_memory_usage): Prevent
+       compiler warning on 64-bit machines.
+       [ab67f899c788]
+
+2007-04-02  michi  <michi>
+
+       * src/vm/jit/replace.c:
+       Merged revisions 7639-7641 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7641 | michi | 2007-04-03 01:13:55 +0200 (Tue, 03 Apr
+       2007) | 2 lines
+
+        * src/vm/jit/replace.c: Added include to fix crash on x86_64.
+       ........
+       [4680535245f6]
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c: Added include to fix crash on x86_64.
+       [ebc64b980d76]
+
+2007-04-02  twisti  <twisti>
+
+       * src/mm/cacao-gc/gc.h, src/vm/jit/alpha/codegen.c:
+       * src/mm/cacao-gc/gc.h: Enable __ALPHA__.
+
+       * src/vm/jit/alpha/codegen.c (vm/jit/abi.h): Added.
+       (createnativestub) [ENABLE_GC_CACAO]: Save and restore callee saved
+       integer registers in the stackframe info for the GC.
+       [137d30680194]
+
+2007-04-02  michi  <michi>
+
+       * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/alpha/md-abi.c:
+       Merged revisions 7632-7638 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7637 | twisti | 2007-04-02 22:58:30 +0200 (Mon, 02 Apr
+       2007) | 4 lines
+
+        * src/vm/jit/alpha/md-abi.c (abi_registers_integer_argument):
+       Added. (abi_registers_integer_saved): Likewise.
+       (abi_registers_integer_temporary): Likewise. ........ r7638 |
+       twisti | 2007-04-02 23:24:59 +0200 (Mon, 02 Apr 2007) | 4 lines
+
+        * src/vm/jit/alpha/linux/md-os.c [ENABLE_THREADS]
+       (threads/native/threads.h): Added. [ENABLE_THREADS]
+       (md_signal_handler_sigusr2): Added #ifdef. ........
+       [cd78728131f5]
+
+2007-04-02  twisti  <twisti>
+
+       * src/vm/jit/alpha/linux/md-os.c:
+       * src/vm/jit/alpha/linux/md-os.c [ENABLE_THREADS]
+       (threads/native/threads.h): Added. [ENABLE_THREADS]
+       (md_signal_handler_sigusr2): Added #ifdef.
+       [cee6cdea0943]
+
+       * src/vm/jit/alpha/md-abi.c:
+       * src/vm/jit/alpha/md-abi.c (abi_registers_integer_argument): Added.
+       (abi_registers_integer_saved): Likewise.
+       (abi_registers_integer_temporary): Likewise.
+       [8acb739340f8]
+
+       * src/mm/cacao-gc/gc.h, src/vm/jit/x86_64/codegen.c:
+       * src/mm/cacao-gc/gc.h: Enable __X86_64__.
+
+       * src/vm/jit/x86_64/codegen.c (vm/jit/abi.h): Added.
+       (createnativestub) [ENABLE_GC_CACAO]: Save and restore callee saved
+       integer registers in the stackframe info for the GC.
+       [d62d435e5ddf]
+
+2007-04-02  michi  <michi>
+
+       * tests/gc/New.java:
+       * tests/gc/New.java: Added testcase.
+       [5ee8dcaa0074]
+
+2007-04-02  twisti  <twisti>
+
+       * src/mm/cacao-gc/gc.h, src/vm/jit/powerpc/codegen.c:
+       * src/mm/cacao-gc/gc.h: Enable __POWERPC__.
+
+       * src/vm/jit/powerpc/codegen.c (vm/jit/abi.h): Added.
+       (createnativestub) [ENABLE_GC_CACAO]: Save and restore callee saved
+       integer registers in the stackframe info for the GC.
+       [5a0de1a6ba64]
+
+2007-04-02  michi  <michi>
+
+       * src/mm/cacao-gc/heap.c:
+       * src/mm/cacao-gc/heap.c (heap_print_object): Fixed for 64 bit
+       architectures.
+       [1ed0f8681b94]
+
+       * src/vm/jit/parse.c, src/vm/jit/stacktrace.c, src/vm/jit/x86_64/md-
+       abi.c:
+       Merged revisions 7628-7631 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7629 | twisti | 2007-04-02 21:45:20 +0200 (Mon, 02 Apr
+       2007) | 3 lines
+
+        * src/vm/jit/parse.c (parse): JAVA_GOTO_W must be converted to a
+       ICMD_GOTO. ........ r7630 | twisti | 2007-04-02 21:56:14 +0200
+       (Mon, 02 Apr 2007) | 4 lines
+
+        * src/vm/jit/x86_64/md-abi.c (abi_registers_integer_argument):
+       Added. (abi_registers_integer_saved): Likewise.
+       (abi_registers_integer_temporary): Likewise. ........ r7631 |
+       michi | 2007-04-02 22:04:22 +0200 (Mon, 02 Apr 2007) | 3 lines
+
+        * src/vm/jit/stacktrace.c (stacktrace_create): Returns NULL if
+       there is no stacktrace available for the given thread. Fixed
+       comments. ........
+       [1e29fb9df8ce]
+
+       * src/vm/jit/stacktrace.c:
+       * src/vm/jit/stacktrace.c (stacktrace_create): Returns NULL if there
+       is no stacktrace available for the given thread. Fixed comments.
+       [63577053a131]
+
+2007-04-02  twisti  <twisti>
+
+       * src/vm/jit/x86_64/md-abi.c:
+       * src/vm/jit/x86_64/md-abi.c (abi_registers_integer_argument):
+       Added. (abi_registers_integer_saved): Likewise.
+       (abi_registers_integer_temporary): Likewise.
+       [3da24dcecde5]
+
+       * src/vm/jit/parse.c:
+       * src/vm/jit/parse.c (parse): JAVA_GOTO_W must be converted to a
+       ICMD_GOTO.
+       [6261bb84b822]
+
+2007-04-02  michi  <michi>
+
+       * THIRDPARTY, src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/jit.h,
+       src/vm/jit/parse.c, src/vm/jit/parse.h, src/vm/jit/powerpc/darwin
+       /md-asm.h, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/stack.c:
+       Merged revisions 7616-7627 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7617 | twisti | 2007-03-30 01:22:07 +0200 (Fri, 30 Mar
+       2007) | 3 lines
+
+        * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv):
+       Fixed address check (thanks Michi). ........ r7619 | twisti |
+       2007-03-30 13:41:27 +0200 (Fri, 30 Mar 2007) | 9 lines
+
+        * src/vm/jit/parse.c (parse_realloc_instructions): Renamed ipc to
+       icount. (parse): Renamed ipc to icount, set method variables at
+       the very end and use local variables before.
+
+        * src/vm/jit/parse.h (INSTRUCTIONS_CHECK): Renamed ipc to icount.
+       (PINC): Likewise. (OP_PREPARE_FLAGS): Likewise. ........ r7620 |
+       edwin | 2007-04-01 12:50:39 +0200 (Sun, 01 Apr 2007) | 3 lines
+
+        * contrib/vmlog: Committed vmlog 0.0.5.
+         * THIRDPARTY: Added copyright notice for vmlog. ........ r7621 |
+       stefan | 2007-04-01 18:18:16 +0200 (Sun, 01 Apr 2007) | 3 lines
+
+        * src/vm/jit/powerpc/darwin/md-asm.h, src/vm/jit/i386/darwin/md-
+       asm.h: added missing symbol asm_vm_call_method_end. ........ r7622
+       | ajordan | 2007-04-02 00:53:59 +0200 (Mon, 02 Apr 2007) | 3 lines
+
+        * src/vm/jit/sparc64/codegen.c: Implemented float argument passing
+       for builtin calls.
+         * src/vm/jit/sparc64/codegen.h: Likewise. ........ r7623 | twisti |
+       2007-04-02 15:45:30 +0200 (Mon, 02 Apr 2007) | 5 lines
+
+        * src/vm/jit/stack.c (stack_mark_reached): Added assert on b.
+       (stack_mark_reached_from_outvars): Likewise.
+       (stack_reach_next_block): Use NULL instead of !. (stack_analyse):
+       Indent. ........ r7624 | twisti | 2007-04-02 18:09:44 +0200 (Mon,
+       02 Apr 2007) | 3 lines
+
+        * src/vm/jit/stack.c (stack_reach_next_block): Reformatted
+       comments. (stack_analyse): Likewise. ........ r7627 | twisti |
+       2007-04-02 20:56:59 +0200 (Mon, 02 Apr 2007) | 8 lines
+
+        * src/vm/jit/jit.h (INS_FLAG_BASICBLOCK): Defined.
+       (INS_FLAG_ID_SHIFT): Changed to 5.
+       (INSTRUCTION_STARTS_BASICBLOCK): Added.
+
+        * src/vm/jit/parse.c (parse): Changed basic block determination.
+       Now basic blocks can start at IR instruction level. This is
+       required for slow-fast path builtins. ........
+       [f9d0a4f6327b]
+
+2007-04-02  twisti  <twisti>
+
+       * src/vm/jit/jit.h, src/vm/jit/parse.c:
+       * src/vm/jit/jit.h (INS_FLAG_BASICBLOCK): Defined.
+       (INS_FLAG_ID_SHIFT): Changed to 5. (INSTRUCTION_STARTS_BASICBLOCK):
+       Added.
+
+       * src/vm/jit/parse.c (parse): Changed basic block determination. Now
+       basic blocks can start at IR instruction level. This is required for
+       slow-fast path builtins.
+       [ef50941ead84]
+
+2007-04-02  michi  <michi>
+
+       * tests/gc/ThreadJava.java, tests/gc/ThreadSleep.java:
+       * tests/gc/ThreadJava.java: Added testcase.
+       * tests/gc/ThreadSleep.java: Added testcase.
+       [0a205fe910b4]
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/mark.c, src/vm/jit/parse.c,
+       src/vm/jit/parse.h, src/vm/jit/stack.c:
+       * src/mm/cacao-gc/gc.c (gc_collect): Moved notification of finalizer
+       thread.
+       * src/mm/cacao-gc/mark.c (mark_me): Cleaned up and ifdefed finalizer
+       code.
+       [0eb8853e9bf6]
+
+2007-04-02  twisti  <twisti>
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_reach_next_block): Reformatted comments.
+       (stack_analyse): Likewise.
+       [3e3bfb01e253]
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_mark_reached): Added assert on b.
+       (stack_mark_reached_from_outvars): Likewise.
+       (stack_reach_next_block): Use NULL instead of !. (stack_analyse):
+       Indent.
+       [72e9bd12289b]
+
+2007-04-01  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h:
+       * src/vm/jit/sparc64/codegen.c: Implemented float argument passing
+       for builtin calls.
+       * src/vm/jit/sparc64/codegen.h: Likewise.
+       [90c476ea0a77]
+
+2007-04-01  stefan  <stefan>
+
+       * src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/powerpc/darwin/md-asm.h:
+       * src/vm/jit/powerpc/darwin/md-asm.h, src/vm/jit/i386/darwin/md-
+       asm.h: added missing symbol asm_vm_call_method_end.
+       [81dbc8f328aa]
+
+2007-04-01  edwin  <edwin>
+
+       * THIRDPARTY, contrib/vmlog/COPYING, contrib/vmlog/Makefile,
+       contrib/vmlog/README, contrib/vmlog/t/concat.c,
+       contrib/vmlog/t/file.c, contrib/vmlog/t/hash.c,
+       contrib/vmlog/t/log.c, contrib/vmlog/t/memdup.c,
+       contrib/vmlog/t/opt.c, contrib/vmlog/t/prolog.h,
+       contrib/vmlog/t/ring.c, contrib/vmlog/t/string.c,
+       contrib/vmlog/t/tags.c, contrib/vmlog/t/threadhash.c,
+       contrib/vmlog/vmlog.c, contrib/vmlog/vmlog.h,
+       contrib/vmlog/vmlog_cacao.c, contrib/vmlog/vmlog_cacao.h,
+       contrib/vmlog/vmlog_cacao.patch, contrib/vmlog/vmlog_jamvm.c,
+       contrib/vmlog/vmlog_jamvm.h, contrib/vmlog/vmlog_jamvm.patch,
+       contrib/vmlog/vmlogdiff.c, contrib/vmlog/vmlogdump.c,
+       contrib/vmlog/vmlogindex.c:
+       * contrib/vmlog: Committed vmlog 0.0.5.
+       * THIRDPARTY: Added copyright notice for vmlog.
+       [13140b8f0f3d]
+
+2007-03-30  twisti  <twisti>
+
+       * src/vm/jit/parse.c, src/vm/jit/parse.h:
+       * src/vm/jit/parse.c (parse_realloc_instructions): Renamed ipc to
+       icount. (parse): Renamed ipc to icount, set method variables at the
+       very end and use local variables before.
+
+       * src/vm/jit/parse.h (INSTRUCTIONS_CHECK): Renamed ipc to icount.
+       (PINC): Likewise. (OP_PREPARE_FLAGS): Likewise.
+       [5f89b928fab8]
+
+2007-03-30  michi  <michi>
+
+       * tests/gc/Makefile, tests/gc/NativeGlobalRef.java, tests/gc/native.c:
+       * tests/gc/NativeGlobalRef.java: Added testcase for global
+       references.
+       * tests/gc/native.c: Added native library for all testcases.
+       * tests/gc/Makefile: Added for easy handling of native testcases.
+       [cad98d81e6c1]
+
+2007-03-29  twisti  <twisti>
+
+       * src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md-
+       abi.h:
+       * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv):
+       Fixed address check (thanks Michi).
+       [5d97b9265241]
+
+2007-03-29  michi  <michi>
+
+       * src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md-
+       abi.h, src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/md.c:
+       Merged revisions 7599,7601-7615 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7604 | pm | 2007-03-29 08:52:15 +0200 (Thu, 29 Mar 2007)
+       | 7 lines
+
+        * src/vm/jit/s390/md-abi.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/arch.h: Changed a lot.
+       ........ r7605 | twisti | 2007-03-29 13:04:25 +0200 (Thu, 29 Mar
+       2007) | 3 lines
+
+        * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv):
+       Check for addr == NULL in NPE case. ........ r7611 | ajordan |
+       2007-03-29 23:37:40 +0200 (Thu, 29 Mar 2007) | 6 lines
+
+        * src/vm/jit/sparc64/md.c (md_get_pv_from_pc): Implemented sethi
+       hanlding.
+
+        * src/vm/jit/sparc64/codegen.c (createnativestub): Fixed
+       window/stack handling in case of exception.
+         * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Likewise.
+       ........ r7612 | michi | 2007-03-29 23:56:35 +0200 (Thu, 29 Mar
+       2007) | 2 lines
+
+        * src/mm/nogc.c: Fixed merging conflict which was commited to that
+       file. ........ r7614 | ajordan | 2007-03-30 01:01:58 +0200 (Fri,
+       30 Mar 2007) | 5 lines
+
+        * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed
+       ICMD_IREMPOW2. Added ICMD_L2F and ICMD_L2D. Fixed constant
+       creation in IF_L* compares. ........
+       [5fa9158bb902]
+
+       * src/mm/boehm.c, src/mm/cacao-gc/copy.c, src/mm/cacao-gc/heap.c,
+       src/mm/gc-common.h, src/mm/memory.h, src/mm/nogc.c,
+       src/vm/builtin.c, src/vm/jit/mips/irix/md-os.c,
+       src/vm/jit/mips/linux/md-os.c, src/vmcore/class.c:
+       * src/vm/builtin.c (builtin_fast_new): Added.
+
+       * src/mm/memory.h: Defined away GC macros for cacao gc.
+
+       * src/vm/jit/mips/linux/md-os.c (md_init): Better use macro here.
+       * src/vm/jit/mips/irix/md-os.c (md_init): See above.
+
+       * src/vmcore/class.c (class_create_classinfo): Do not use GC macro.
+
+       * src/mm/gc-common.h (heap_alloc): Changed signature of old
+       heap_allocate.
+
+       * src/mm/nogc.c (heap_alloc): Adapted to above changes.
+       * src/mm/boehm.c (heap_alloc): See above.
+       * src/mm/cacao-gc/heap.c (heap_alloc): See above.
+
+       * src/mm/cacao-gc/copy.c: Removed wrongly placed comment.
+       [53d07e4ed5dc]
+
+2007-03-29  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c:
+       * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed ICMD_IREMPOW2.
+       Added ICMD_L2F and ICMD_L2D. Fixed constant creation in IF_L*
+       compares.
+       [67e44799d296]
+
+2007-03-29  michi  <michi>
+
+       * src/mm/cacao-gc/final.c, src/mm/cacao-gc/final.h, src/mm/cacao-
+       gc/gc.c, src/mm/nogc.c:
+       * src/mm/cacao-gc/gc.c (gc_finalizer_all): Implemented
+       * src/mm/cacao-gc/final.c (final_set_all_reclaimable): Added.
+       * src/mm/cacao-gc/final.h (final_set_all_reclaimable): Added
+       prototype.
+       [46e450965b78]
+
+       * src/mm/nogc.c:
+       * src/mm/nogc.c: Fixed merging conflict which was commited to that
+       file.
+       [c0c73c75fa54]
+
+2007-03-29  ajordan  <ajordan>
+
+       * src/vm/exceptions.h, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/md.c:
+       * src/vm/jit/sparc64/md.c (md_get_pv_from_pc): Implemented sethi
+       hanlding.
+
+       * src/vm/jit/sparc64/codegen.c (createnativestub): Fixed
+       window/stack handling in case of exception.
+       * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Likewise.
+       [ab2fb8fcf377]
+
+2007-03-29  michi  <michi>
+
+       * src/mm/cacao-gc/final.c, tests/gc/Final.java,
+       tests/gc/FinalExit.java, tests/gc/FinalForce.java:
+       * src/mm/cacao-gc/final.c (final_register): Uses list_add_first
+       instead of list_add_last to be more Sun-like.
+
+       * tests/gc/Final.java: Added testcase for finalization testing.
+       * tests/gc/FinalExit.java: See above.
+       * tests/gc/FinalForce.java: See above.
+       [9d2bb56faa1c]
+
+       * src/vm/exceptions.h:
+       Merged revisions 7600 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7600 | twisti | 2007-03-29 00:59:52 +0200 (Thu, 29 Mar
+       2007) | 3 lines
+
+        * src/vm/exceptions.h (exceptionptr): Removed.
+       (_no_threads_exceptionptr): Likewise. ........
+       [099d13dd30cc]
+
+       * src/mm/cacao-gc/gc.c:
+       * src/mm/cacao-gc/gc.c (gc_collect): Added a global gc lock.
+       [07040b7c00cc]
+
+       * tests/gc/ThreadStress.java:
+       * tests/gc/ThreadStress.java: Added stress test for threads.
+       [1bae1bedc255]
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/heap.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/replace.c,
+       src/vm/jit/s390/arch.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.h:
+       * src/mm/cacao-gc/heap.c (heap_increase_size): Uses vm_abort on
+       error now.
+       * src/mm/cacao-gc/gc.c (gc_finalize_all): Added.
+       * src/vm/jit/replace.c (replace_me) [ENABLE_GC_CACAO]: Fixed ifdef
+       here.
+       [2bfff1dfed66]
+
+2007-03-29  twisti  <twisti>
+
+       * src/vm/jit/powerpc/linux/md-os.c:
+       * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv):
+       Check for addr == NULL in NPE case.
+       [be47a420f840]
+
+2007-03-29  pm  <pm>
+
+       * src/vm/jit/s390/arch.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.h:
+       * src/vm/jit/s390/md-abi.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/arch.h: Changed a lot.
+       [3c5a76b228f4]
+
+2007-03-28  michi  <michi>
+
+       * tests/gc/Chain.java, tests/gc/Hashcode.java, tests/gc/Simple.java:
+       * test/gc: Added directory to contain Garbage Collector testcases.
+
+       * test/gc/Chain.java: Added.
+       * tests/gc/Simple.java: Added.
+       * tests/gc/Hashcode.java: Added.
+       [53b6c706a55f]
+
+       * src/mm/cacao-gc/Makefile.am, src/mm/cacao-gc/compact.c, src/mm
+       /cacao-gc/compact.h, src/mm/cacao-gc/copy.c, src/mm/cacao-gc/copy.h,
+       src/mm/cacao-gc/final.c, src/mm/cacao-gc/final.h, src/mm/cacao-
+       gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao-
+       gc/heap.h, src/mm/cacao-gc/mark.c, src/mm/cacao-gc/mark.h, src/mm
+       /cacao-gc/region.c, src/mm/cacao-gc/region.h, src/mm/cacao-
+       gc/rootset.c, src/mm/cacao-gc/rootset.h:
+       Removed author and contact from header, sorry for not listing every
+       file here.
+       [3791f0859589]
+
+       * AUTHORS, configure.ac, src/Makefile.am, src/cacaoh/dummy.c, src/mm
+       /boehm-gc/include/private/gc_locks.h, src/mm/nogc.c,
+       src/native/include/Makefile.am, src/native/jni.c,
+       src/native/native.c, src/native/native.h,
+       src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c, src/threads/native/lock.c,
+       src/threads/native/threads.c, src/toolbox/list.c,
+       src/toolbox/list.h, src/vm/access.c, src/vm/builtin.c,
+       src/vm/builtin.h, src/vm/exceptions.c, src/vm/exceptions.h,
+       src/vm/global.h, src/vm/jit/abi.h, src/vm/jit/alpha/arch.h,
+       src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/codegen.h, src/vm/jit/alpha/emit.c,
+       src/vm/jit/alpha/linux/md-os.c, src/vm/jit/alpha/md.c,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/arm/arch.h,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c,
+       src/vm/jit/arm/linux/Makefile.am, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/arm/md.c, src/vm/jit/asmpart.h, src/vm/jit/code.c,
+       src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/codegen-
+       common.h, src/vm/jit/disass-common.c, src/vm/jit/disass.h,
+       src/vm/jit/dseg.c, src/vm/jit/dseg.h, src/vm/jit/emit-common.c,
+       src/vm/jit/emit-common.h, src/vm/jit/i386/arch.h,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/codegen.h, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md.c,
+       src/vm/jit/i386/patcher.c, src/vm/jit/jit.c, src/vm/jit/jit.h,
+       src/vm/jit/m68k/Makefile.am, src/vm/jit/m68k/arch.h,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, src/vm/jit/m68k
+       /machine-instr.h, src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/m68k/uclinux/Makefile.am, src/vm/jit/m68k/uclinux/md-
+       abi.c, src/vm/jit/m68k/uclinux/md-abi.h, src/vm/jit/m68k/uclinux/md-
+       asm.h, src/vm/jit/m68k/uclinux/md-os.c, src/vm/jit/mips/arch.h,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/md.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/parse.c,
+       src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/codegen.h,
+       src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc/md.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/arch.h,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/codegen.h, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/linux/md-
+       abi.h, src/vm/jit/powerpc64/linux/md-os.c,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/reg.c, src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md-
+       abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/sparc64/arch.h,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md-abi.c,
+       src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/verify/typecheck-invoke.inc,
+       src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/emit.h,
+       src/vm/jit/x86_64/linux/md-os.c, src/vm/jit/x86_64/md.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/signal.c, src/vm/signallocal.h,
+       src/vm/string.c, src/vm/vm.c, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/classcache.c,
+       src/vmcore/descriptor.h, src/vmcore/linker.c, src/vmcore/loader.c,
+       src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/statistics.c,
+       src/vmcore/statistics.h, src/vmcore/zip.c,
+       tests/regression/native/Makefile.am:
+       Merged revisions 7501-7598 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7503 | twisti | 2007-03-12 11:11:33 +0100 (Mon, 12 Mar
+       2007) | 11 lines
+
+        * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c
+       (vm/vm.h): Added. (open): Call vm_abort.
+
+        * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c
+       (unistd.h): Added. (readByte): New function. (writeBuf):
+       Likewise. (available0): Likewise. (close0): Likewise. ........
+       r7504 | twisti | 2007-03-12 14:17:07 +0100 (Mon, 12 Mar 2007) | 2
+       lines
+
+        * src/vm/jit/arm/md.c (vm/jit/codegen-common.h): Added. ........
+       r7505 | twisti | 2007-03-12 14:34:37 +0100 (Mon, 12 Mar 2007) | 8
+       lines
+
+        * src/vm/jit/codegen.c (codegen): Change the operand direction of
+       some macros. Started to implement long-compares differently.
+
+        * src/vm/jit/codegen.h (M_AND, M_ORR, M_EOR, M_AND_IMM, M_MOVEQ)
+       (M_MOVVS_IMM, M_MOVNE_IMM, M_MOVLT_IMM, M_MOVLS_IMM): Changed
+       operand direction. (M_ORR_S, M_CMPEQ, M_CMPLE): New macro.
+       ........ r7510 | michi | 2007-03-13 14:19:07 +0100 (Tue, 13 Mar
+       2007) | 2 lines
+
+        * src/vm/jit/arm/linux/Makefile.am: Fixed include path to care
+       about builddir. ........ r7511 | michi | 2007-03-13 17:32:56 +0100
+       (Tue, 13 Mar 2007) | 6 lines
+
+        * src/vm/jit/arm/codegen.c (codegen): Long branches are
+       implemented differently now.
+
+        * src/vm/jit/arm/codegen.h (M_COMPARE): Easier macros without
+       overjumps. (M_MOVEQ_IMM, M_MOVGT_IMM, M_ADDHI_IMM, M_SUBLO_IMM,
+       M_CMPEQ_IMM): New macro. ........ r7513 | twisti | 2007-03-13
+       21:31:23 +0100 (Tue, 13 Mar 2007) | 2 lines
+
+        * src/vm/jit/i386/codegen.c (codegen): Fixed compiler warning.
+       ........ r7514 | twisti | 2007-03-13 21:31:51 +0100 (Tue, 13 Mar
+       2007) | 5 lines
+
+        * src/vm/jit/i386/emit.c (emit_load): Use switch-case instead of
+       if-else contruct. (emit_store): Likewise. (emit_copy): Likewise.
+       ........ r7516 | michi | 2007-03-14 13:00:07 +0100 (Wed, 14 Mar
+       2007) | 2 lines
+
+        * src/mm/nogc.c: Fixed includes and exceptions. ........ r7518 |
+       michi | 2007-03-14 17:44:05 +0100 (Wed, 14 Mar 2007) | 3 lines
+
+        * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Fixed bug with
+       inmemory arguments, which caused some crashes with verbose-calls.
+       ........ r7519 | michi | 2007-03-14 18:31:05 +0100 (Wed, 14 Mar
+       2007) | 3 lines
+
+        * src/vm/jit/arm/codegen.c (codegen): All the long compares have a
+       different implementation now. ........ r7520 | twisti |
+       2007-03-14 22:16:04 +0100 (Wed, 14 Mar 2007) | 2 lines
+
+        * src/vm/jit/alpha/md.c (vm/jit/codegen-common.h): Added
+       temporarily. ........ r7521 | twisti | 2007-03-14 22:18:00 +0100
+       (Wed, 14 Mar 2007) | 5 lines
+
+        * src/vm/jit/alpha/emit.c (emit_load): Use switch-case instead of
+       if-else contruct. (emit_store): Likewise. (emit_copy): Likewise.
+       ........ r7522 | twisti | 2007-03-14 22:54:49 +0100 (Wed, 14 Mar
+       2007) | 7 lines
+
+        * src/vmcore/statistics.c (size_string): Added.
+       (statistics_print_memory_usage): Likewise.
+         * src/vmcore/statistics.h (size_string): Likewise.
+
+        * src/vm/string.c (vmcore/statistics.h): Added.
+       (literalstring_u2): Added statistics. ........ r7524 | pm |
+       2007-03-15 08:07:51 +0100 (Thu, 15 Mar 2007) | 7 lines
+
+        * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h: Changed
+       a lot.
+         * src/vm/jit/s390/tests, src/vm/jit/s390/tests/tests.java.pp,
+       src/vm/jit/s390/tests/Makefile: Added opcode tests in java. ........
+       r7525 | pm | 2007-03-15 09:23:19 +0100 (Thu, 15 Mar 2007) | 2 lines
+
+        * src/vm/jit/s390/tests/tests.java.pp: added INT2CHAR test testing
+       negative values. ........ r7526 | twisti | 2007-03-15 10:28:56
+       +0100 (Thu, 15 Mar 2007) | 3 lines
+
+        * src/native/jni.c (_Jv_jni_invokeNative): Release memory in
+       exception case. ........ r7534 | pm | 2007-03-17 00:00:18 +0100
+       (Sat, 17 Mar 2007) | 11 lines
+
+        * src/vm/exceptions.c (exceptions_handle_exception): 31 bit
+       address comparison for S390. These address comparison macros need to
+       be moved to some header.
+         * src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/arch.h, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/md-abi.c, src/vm/jit/s390/tests/tests.java.pp,
+       src/vm/jit/s390/tests/Makefile: Changed a lot. ........ r7535 |
+       twisti | 2007-03-17 13:57:32 +0100 (Sat, 17 Mar 2007) | 2 lines
+
+        * src/vm/builtin.c (builtin_isanysubclass): Cleanup and comments.
+       ........ r7536 | twisti | 2007-03-17 14:10:04 +0100 (Sat, 17 Mar
+       2007) | 2 lines
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c (vm/resolve.h):
+       Added. ........ r7537 | twisti | 2007-03-17 14:11:11 +0100 (Sat,
+       17 Mar 2007) | 3 lines
+
+        * src/vm/builtin.c (builtin_isanysubclass): Code cleanup.
+       (builtin_isanysubclass_vftbl): Likewise. ........ r7538 | twisti |
+       2007-03-17 14:12:00 +0100 (Sat, 17 Mar 2007) | 3 lines
+
+        * src/vm/builtin.h (builtin_isanysubclass_vftbl): Removed, made
+       static. ........ r7543 | ajordan | 2007-03-20 01:25:19 +0100 (Tue,
+       20 Mar 2007) | 3 lines
+
+        * src/vm/jit/sparc64/md-abi.c (md_param_alloc_native): using this
+       for native param allocation. No need for my own version of this
+       anymore.
+         * src/vm/jit/sparc64/codegen.c: Likewise. ........ r7547 | twisti |
+       2007-03-21 14:18:20 +0100 (Wed, 21 Mar 2007) | 4 lines
+
+        * src/vmcore/linker.c (link_primitivetype_table): Set super class
+       explicitly to NULL. (linker_compute_subclasses): Indent. ........
+       r7548 | twisti | 2007-03-21 14:19:44 +0100 (Wed, 21 Mar 2007) | 3
+       lines
+
+        * src/vmcore/zip.c (zip_get): Don't assign in if-statement, this
+       makes debugging a bit easier. ........ r7549 | twisti |
+       2007-03-21 14:27:14 +0100 (Wed, 21 Mar 2007) | 22 lines
+
+        * src/vmcore/statistics.c (size_threadobject, size_lock_hashtable)
+       (size_lock_waiter): Added. (statistics_print_memory_usage): Print
+       new variables.
+
+        * src/vmcore/statistics.h (size_threadobject, size_lock_hashtable)
+       (size_lock_waiter): Added.
+
+        * src/threads/native/lock.c (vmcore/options.h): Added.
+       [ENABLE_STATISTICS] (vmcore/statistics.h): Added.
+       (lock_hashtable_init): Added statistics. (lock_hashtable_grow):
+       Likewise. (lock_record_add_waiter): Likewise.
+       (lock_record_remove_waiter): Likewise.
+
+        * src/threads/native/threads.c [ENABLE_STATISTICS]
+       (vmcore/statistics.h): Added. (threads_preinit): Added statistics.
+       (threads_init): Likewise. (threads_start_javathread): Likewise.
+       (threads_attach_current_thread): Likewise.
+       (threads_detach_thread): Likewise. ........ r7551 | twisti |
+       2007-03-21 15:26:09 +0100 (Wed, 21 Mar 2007) | 8 lines
+
+        * src/vmcore/statistics.c (size_lock_record_pool): Added.
+       (statistics_print_memory_usage): Print new variable.
+
+        * src/vmcore/statistics.h (size_lock_record_pool): Added.
+
+        * src/threads/native/lock.c (lock_record_alloc_new_pool): Added
+       statistics. ........ r7554 | michi | 2007-03-22 14:55:44 +0100
+       (Thu, 22 Mar 2007) | 3 lines
+
+        * src/vm/jit/arm/codegen.c (codegen) [!ENABLE_SOFTFLOAT]: Fixed
+       position of soft null pointer checks in PUTFIELD and GETFIELD.
+       ........ r7559 | twisti | 2007-03-23 12:56:31 +0100 (Fri, 23 Mar
+       2007) | 5 lines
+
+        * src/vm/jit/powerpc/emit.c (emit_load): Use switch-case instead
+       of if-else contruct. (emit_store): Likewise. (emit_copy):
+       Likewise. ........ r7560 | twisti | 2007-03-23 19:51:41 +0100
+       (Fri, 23 Mar 2007) | 4 lines
+
+        * src/vmcore/classcache.c (classcache_add_constraint)
+       [CLASSCACHE_VERBOSE]: Started to use log-functions.
+       (classcache_debug_dump): Likewise. ........ r7561 | twisti |
+       2007-03-23 20:10:35 +0100 (Fri, 23 Mar 2007) | 7 lines
+
+        * src/vm/global.h (ACC_CLASS_PRIMITIVE): Defined.
+
+        * src/vm/builtin.c (builtin_isanysubclass): Check for primitive
+       classes.
+
+        * src/vmcore/linker.c (link_primitivetype_table): Set primitive
+       flag. ........ r7562 | twisti | 2007-03-23 21:38:14 +0100 (Fri, 23
+       Mar 2007) | 4 lines
+
+        * src/vm/builtin.c (builtin_isanysubclass_vftbl): Removed.
+       (builtin_descriptorscompatible): Use builtin_isanysubclass instead
+       of builtin_isanysubclass_vftbl. ........ r7563 | twisti |
+       2007-03-23 22:33:53 +0100 (Fri, 23 Mar 2007) | 22 lines
+
+        * src/vm/builtin.c (builtin_isanysubclass): Removed.
+       (builtin_instanceof): Replaced builtin_isanysubclass with
+       class_isanysubclass. (builtin_descriptorscompatible): Likewise.
+
+        * src/vm/builtin.h (builtin_isanysubclass): Removed.
+
+        * src/vm/access.c (access_is_accessible_member): Replaced
+       builtin_isanysubclass with class_isanysubclass.
+         * src/native/vm/java_lang_Class.c (isAssignableFrom): Likewise.
+
+        * src/vm/jit/asmpart.h (castinfo): Removed.
+
+        * src/vmcore/class.c (vm/jit/asmpart.h): Added.
+       (class_isanysubclass): New function.
+
+        * src/vmcore/class.h (castinfo): Added. (class_isanysubclass):
+       Likewise.
+
+        * src/cacaoh/dummy.c (asm_getclassvalues_atomic): New function.
+       (intrp_asm_getclassvalues_atomic): Likewise. ........ r7573 |
+       twisti | 2007-03-25 20:55:02 +0200 (Sun, 25 Mar 2007) | 21 lines
+
+        * src/native/native.c (native_get_parametertypes): Removed.
+       (native_get_exceptiontypes): Likewise.
+         * src/native/native.h: Likewise.
+
+        * src/vmcore/method.c (vm/builtin.h): Added. (vm/resolve.h):
+       Likewise. (method_get_parametertypearray): New function.
+       (method_get_exceptionarray): Likewise.
+         * src/vmcore/method.h (method_get_parametertypearray): Added.
+       (method_get_exceptionarray): Likewise.
+
+        * src/cacaoh/dummy.c (builtin_anewarray): Added.
+       (resolve_class_from_typedesc): Likewise.
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c
+       (getParameterTypes): Use method function. (getExceptionTypes):
+       Likewise.
+         * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (getParameterTypes): Likewise. (getExceptionTypes): Likewise.
+       ........ r7575 | twisti | 2007-03-25 22:30:50 +0200 (Sun, 25 Mar
+       2007) | 9 lines
+
+        Reverted patch 7268.
+
+        * src/vm/jit/code.c: Reverted.
+         * src/vm/jit/code.h: Likewise.
+         * src/vm/jit/jit.c: Likewise.
+         * src/vm/jit/jit.h: Likewise.
+         * src/vmcore/loader.c: Likewise.
+         * src/vmcore/method.h: Likewise. ........ r7581 | pm | 2007-03-26
+       09:23:16 +0200 (Mon, 26 Mar 2007) | 10 lines
+
+        * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/emit.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/tests/tests.java.pp, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/md-abi.c: Chaned a lot. ........ r7587 | twisti |
+       2007-03-28 15:29:09 +0200 (Wed, 28 Mar 2007) | 19 lines
+
+        * src/vm/exceptions.c (throw_exception_exit_intern): Removed.
+       (throw_exception): Likewise. (throw_exception_exit): Likewise.
+       (throw_main_exception): Likewise. (throw_main_exception_exit):
+       Likewise. (throw_cacao_exception_exit): Likewise.
+       (exceptions_print_stacktrace): New function.
+         * src/vm/exceptions.h: Likewise.
+
+        * src/vm/vm.c (vm_create): Use vm_abort or
+       exceptions_print_stacktrace instead of throw_main_exception_exit.
+       (vm_run): Likewise. (vm_exit): Likewise.
+       (vm_get_mainclass_from_jar): Likewise.
+
+        * src/threads/native/threads.c (threads_init): Use return instead
+       of throw_exception_exit. (threads_startup_thread): Use vm_abort.
+       ........ r7593 | twisti | 2007-03-28 22:22:13 +0200 (Wed, 28 Mar
+       2007) | 3 lines
+
+        Initialized merge tracking via "svnmerge" with revisions "1-7592"
+       from svn+ssh://c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/bran
+       ches/twisti ........ r7594 | twisti | 2007-03-28 22:28:37 +0200
+       (Wed, 28 Mar 2007) | 3 lines
+
+        Initialized merge tracking via "svnmerge" with revisions "1-6086"
+       from svn+ssh://c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/bran
+       ches/twisti ........ r7595 | twisti | 2007-03-28 22:50:34 +0200
+       (Wed, 28 Mar 2007) | 3 lines
+
+        Initialized merge tracking via "svnmerge" with revisions "1-6085"
+       from file:///ahome/cacao/svn/cacao/branches/twisti ........
+       r7596 | twisti | 2007-03-28 23:05:53 +0200 (Wed, 28 Mar 2007) | 2
+       lines
+
+        * Merged in twisti-branch. ........ r7597 | michi | 2007-03-29
+       00:25:44 +0200 (Thu, 29 Mar 2007) | 2 lines
+
+        * AUTHORS: Added myself to the list of authors (finally). ........
+       r7598 | twisti | 2007-03-29 00:32:13 +0200 (Thu, 29 Mar 2007) | 2
+       lines
+
+        * svnmerge uninit. ........
+       [2ba675aeac92]
+
+2007-03-28  twisti  <twisti>
+
+       * m4/cacaoh.m4, src/native/include/Makefile.am, src/native/jni.c,
+       src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c, src/toolbox/list.c,
+       src/toolbox/list.h, src/vm/access.c, src/vm/builtin.c,
+       src/vm/builtin.h, src/vm/exceptions.h, src/vm/global.h,
+       src/vm/jit/abi.h, src/vm/jit/alpha/arch.h,
+       src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/codegen.h, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/alpha/md.c, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/arch.h, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h,
+       src/vm/jit/arm/md.c, src/vm/jit/asmpart.h, src/vm/jit/codegen-
+       common.c, src/vm/jit/codegen-common.h, src/vm/jit/disass-common.c,
+       src/vm/jit/disass.h, src/vm/jit/dseg.c, src/vm/jit/dseg.h,
+       src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/i386/md.c, src/vm/jit/i386/patcher.c, src/vm/jit/jit.c,
+       src/vm/jit/jit.h, src/vm/jit/m68k/.cvsignore,
+       src/vm/jit/m68k/disass.c, src/vm/jit/m68k/emit.h,
+       src/vm/jit/m68k/linux/.cvsignore, src/vm/jit/m68k/linux/Makefile.am,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h,
+       src/vm/jit/m68k/linux/md-asm.h, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/linux/md-os.h, src/vm/jit/mips/arch.h,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/codegen.h, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c, src/vm/jit/parse.c,
+       src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/codegen.h,
+       src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/codegen.h,
+       src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/linux/md-
+       abi.h, src/vm/jit/powerpc64/linux/md-os.c,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/reg.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/sparc64/emit.h, src/vm/jit/stacktrace.c,
+       src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/emit.h,
+       src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c,
+       src/vm/signal.c, src/vm/signallocal.h, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/classcache.c,
+       src/vmcore/descriptor.h, src/vmcore/linker.c, src/vmcore/loader.c,
+       src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c,
+       src/vmcore/options.h, tests/regression/native/Makefile.am:
+       * src/vm/exceptions.h (exceptionptr): Removed.
+       (_no_threads_exceptionptr): Likewise.
+       [444d6d50b065]
+
+2007-03-28  michi  <michi>
+
+       * configure.ac, src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm
+       /cacao-gc/rootset.c, src/vm/builtin.c, src/vm/builtin.h,
+       src/vm/jit/alpha/md.c, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/patcher.c, src/vm/jit/jit.c,
+       src/vm/jit/jit.h, src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c,
+       src/vm/jit/parse.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/replace.c,
+       src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md-
+       abi.h, src/vm/jit/s390/patcher.c, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/emit.h,
+       src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c,
+       src/vmcore/classcache.c, src/vmcore/linker.c, src/vmcore/method.c,
+       src/vmcore/method.h, src/vmcore/options.c, src/vmcore/options.h,
+       src/vmcore/statistics.c:
+       * src/mm/cacao-gc/gc.h: Added GC_EXECUTIONSTATE and GC_SOURCESTATE
+       defines.
+       * src/mm/cacao-gc/gc.c [!ENABLE_THREADS]: Added _no_threads variables
+       for above defines.
+
+       * src/mm/cacao-gc/rootset.c: Now uses above defines.
+       * src/vm/jit/replace.c (replace_me, replace_gc_from_native): Same.
+       [f6b1620d87fe]
+
+       * AUTHORS:
+       * AUTHORS: Added myself to the list of authors (finally).
+       [0b44275eac74]
+
+2007-03-28  twisti  <twisti>
+
+       * AUTHORS, configure.ac, src/Makefile.am, src/cacaoh/dummy.c, src/mm
+       /boehm-gc/include/private/gc_locks.h, src/mm/nogc.c,
+       src/native/include/Makefile.am, src/native/jni.c,
+       src/toolbox/list.c, src/toolbox/list.h, src/vm/builtin.c,
+       src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/abi.h,
+       src/vm/jit/alpha/arch.h, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/codegen.h,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/alpha/md.c, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/arch.h, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/arm/md.c, src/vm/jit/asmpart.h, src/vm/jit/codegen-
+       common.c, src/vm/jit/codegen-common.h, src/vm/jit/disass-common.c,
+       src/vm/jit/disass.h, src/vm/jit/dseg.c, src/vm/jit/dseg.h,
+       src/vm/jit/emit-common.c, src/vm/jit/emit-common.h,
+       src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/i386/md.c, src/vm/jit/i386/patcher.c, src/vm/jit/jit.c,
+       src/vm/jit/jit.h, src/vm/jit/m68k/Makefile.am,
+       src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/machine-instr.h,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/m68k/uclinux/Makefile.am, src/vm/jit/m68k/uclinux/md-
+       abi.c, src/vm/jit/m68k/uclinux/md-abi.h, src/vm/jit/m68k/uclinux/md-
+       asm.h, src/vm/jit/m68k/uclinux/md-os.c, src/vm/jit/mips/arch.h,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/md.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/parse.c,
+       src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/codegen.h,
+       src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc/md.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/arch.h,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/codegen.h, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/linux/md-
+       abi.h, src/vm/jit/powerpc64/linux/md-os.c,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/reg.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/emit-arch.h, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/sparc64/patcher.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/verify/typecheck-invoke.inc, src/vm/jit/x86_64/arch.h,
+       src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/emit.h, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c,
+       src/vm/signal.c, src/vm/signallocal.h, src/vm/vm.c,
+       src/vmcore/descriptor.h, src/vmcore/loader.c, src/vmcore/options.c,
+       src/vmcore/options.h, tests/regression/native/Makefile.am:
+       * Merged in twisti-branch.
+       [584c104cdec1]
+
+       * src/vm/jit/powerpc/codegen.h, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-os.c, src/vm/signal.c,
+       src/vm/signallocal.h:
+       * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigtrap): New
+       function.
+
+       * src/vm/jit/powerpc/emit.c (emit_arrayindexoutofbounds_check): Use
+       trap instruction.
+
+       * src/vm/jit/powerpc/codegen.h (M_OP3_GET_A, M_OP3_GET_B): New
+       macros. (M_TRAPGEU): Likewise.
+
+       * src/vm/signal.c [__POWERPC__] (signal_init): Install SIGTRAP
+       handler.
+
+       * src/vm/signallocal.h [__POWERPC__] (md_signal_handler_sigtrap):
+       Added.
+       [db686946cce5]
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c,
+       src/vm/jit/arm/linux/md-os.c:
+       * src/vm/jit/arm/emit.c (emit_branch): Replaced BRANCH_A with
+       BRANCH_UGT. (emit_arithmetic_check): Use new hardware-exception
+       defines. (emit_nullpointer_check): Likewise.
+       (emit_nullpointer_check_force): Likewise.
+       (emit_arrayindexoutofbounds_check): Likewise.
+       (emit_classcast_check): Likewise. (emit_exception_check): Likewise.
+
+       * src/vm/jit/arm/codegen.c (codegen_emit): Generate correct NPE-
+       check, smaller branch changes.
+
+       * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill):
+       Restructured to be more like the other architectures.
+       [b1866e6f3a4e]
+
+       * src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/emit.h, src/vm/jit/x86_64/linux/md-os.c,
+       src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c:
+       * src/vm/jit/x86_64/emit.c (vm/exceptions.h): Added. (emit_branch):
+       New function. (emit_arithmetic_check,
+       emit_arrayindexoutofbounds_check) (emit_classcast_check,
+       emit_nullpointer_check, emit_exception_check): Use hardware-
+       exception instruction. (emit_exception_stubs): Removed.
+       (emit_mov_mem_reg): New function. (emit_alul_imm32_reg): Likewise.
+       * src/vm/jit/x86_64/emit.h: Likewise.
+
+       * src/vm/jit/x86_64/md.c (md_codegen_patch_branch): Removed.
+
+
+       * src/vm/jit/x86_64/codegen.c (codegen): Renamed to codegen_emit and a
+       zillion changes.
+
+       * src/vm/jit/x86_64/codegen.h (CALCOFFSETBYTES, CALCIMMEDIATEBYTES):
+       Removed. (ALIGNCODENOP): Implemented correctly.
+       (BRANCH_UNCONDITIONAL_SIZE, BRANCH_CONDITIONAL_SIZE): Added.
+       (BRANCH_NOPS): Added one nop. (M_ALD_MEM, M_ALD_MEM_GET_OPC,
+       M_ALD_MEM_GET_MOD, M_ALD_MEM_GET_REG) (M_ALD_MEM_GET_RM,
+       M_ALD_MEM_GET_DISP): New macro. (M_ISUB_IMM32): Likewise.
+       (M_ICMP_IMM32): Likewise. (M_BAE): Renamed to M_BUGE. (M_BA):
+       Renamed to M_BUGT. (M_BULT, M_BULE): New macros. (M_CMOVEQ_MEMBASE,
+       M_CMOVNE_MEMBASE, M_CMOVLT_MEMBASE) (M_CMOVLE_MEMBASE,
+       M_CMOVGE_MEMBASE, M_CMOVGT_MEMBASE): Removed. (M_CMOVB): Renamed to
+       M_CMOVULT. (M_CMOVA): Renamed to M_CMOVUGT.
+
+       * src/vm/jit/x86_64/linux/md-os.c (vm/types.h): Added.
+       (vm/jit/x86_64/codegen.h): Likewise. (vm/exceptions.h): Likewise.
+       (md_signal_handler_sigsegv): Rewritten for hardware-exceptions.
+
+       * src/vm/jit/x86_64/arch.h
+       (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER)
+       (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER)
+       (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS)
+       (SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS): Defined.
+
+       * src/vm/jit/x86_64/patcher.c
+       (patcher_checkcast_instanceof_interface): Renamed to
+       patcher_checkcast_interface. (patcher_instanceof_interface): New
+       function.
+       [9cbaee9cb174]
+
+       * AUTHORS:
+       * AUTHORS: Keep it alpha-sorted.
+       [c261d9c6b664]
+
+       * src/threads/native/threads.c, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390
+       /md-abi.h, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/tests/tests.java.pp, src/vm/vm.c:
+       * Merged with trunk.
+       [b65b5373c1e3]
+
+       * src/threads/native/threads.c, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/vm.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/vm/exceptions.c (throw_exception_exit_intern): Removed.
+       (throw_exception): Likewise. (throw_exception_exit): Likewise.
+       (throw_main_exception): Likewise. (throw_main_exception_exit):
+       Likewise. (throw_cacao_exception_exit): Likewise.
+       (exceptions_print_stacktrace): New function.
+       * src/vm/exceptions.h: Likewise.
+
+       * src/vm/vm.c (vm_create): Use vm_abort or
+       exceptions_print_stacktrace instead of throw_main_exception_exit.
+       (vm_run): Likewise. (vm_exit): Likewise.
+       (vm_get_mainclass_from_jar): Likewise.
+
+       * src/threads/native/threads.c (threads_init): Use return instead of
+       throw_exception_exit. (threads_startup_thread): Use vm_abort.
+       [093dd11f1414]
+
+2007-03-28  tbfg  <tbfg>
+
+       * AUTHORS, src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/m68k/disass.c, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/emit.h, src/vm/jit/m68k/linux/md-abi.c,
+       src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/linux/md-os.h,
+       src/vm/jit/m68k/machine-instr.h, src/vm/jit/m68k/md.c,
+       src/vm/jit/m68k/patcher.c:
+       * AUTHORS: Added Roland Lezuo.
+
+       * src/vm/jit/m68k/linux/md-os.c: Added GPL license header.
+       * src/vm/jit/m68k/linux/md-os.h: Likewise.
+       * src/vm/jit/m68k/linux/md-abi.c: Likewise.
+       * src/vm/jit/m68k/emit.c: Likewise.
+       * src/vm/jit/m68k/md.c: Likewise.
+       * src/vm/jit/m68k/emit.h: Likewise.
+       * src/vm/jit/m68k/codegen.c: Likewise.
+       * src/vm/jit/m68k/disass.c: Likewise.
+       * src/vm/jit/m68k/machine-instr.h: Likewise.
+       * src/vm/jit/m68k/patcher.c: Likewise.
+       * src/vm/jit/m68k/codegen.h: Likewise.
+       [2f5a7fa77fd0]
+
+2007-03-28  twisti  <twisti>
+
+       * src/vm/vm.c, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vmcore/options.c (checknull): Removed.
+       * src/vmcore/options.h: Likewise.
+
+       * src/vm/vm.c (opts): Removed softnull. (vm_create): Likewise.
+       [67aae9ed164f]
+
+2007-03-27  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.h,
+       src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/md.c,
+       src/vm/jit/m68k/patcher.c, src/vm/jit/stacktrace.c:
+       * m68k/linux/md-abi.h (REG_ITMP1_XPTR): Renamed REG_ATMP1_XPTR.
+       (REG_ITMP2_XPC): Renamed REG_ATMP2_XPC.
+
+       * m68k/linux/md-os.c (md_signal_handler_sigill): Use REG_ATMP1_XPTR
+       and REG_ATMP2_XPC.
+
+       * m68k/md.c (md_stacktrace_get_returnaddress): Removed frame linking
+       code, adpat offset.
+
+       * m68k/codegen.c (codegen_emit): Removed frame linking code.
+       (ICMD_ATHROW): Fixed. (createnativestub): Removed frame linking
+       code.
+
+       * m68k/asmpart.S (asm_vm_call_method_long): Removed frame linking
+       code. (asm_vm_call_method_exception_handler): Implemented.
+       (asm_call_jit_compiler): Removed frame linking code.
+       (asm_patcher_wrapper): Simpler code. (asm_handle_exception): Partial
+       implementation.
+
+       * stacktrace.c (stacktrace_create): M68k has a return word on stack.
+       [1df61ce55fe6]
+
+       * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/linux/Makefile.am, src/vm/jit/m68k/linux/md-os.c,
+       src/vm/jit/m68k/linux/md-os.h, src/vm/jit/m68k/md.c,
+       src/vm/jit/m68k/patcher.c:
+       * linux/md-os.h (md_init_linux): Prototyp.
+       (md_signal_handler_sigill): Likewise.
+
+       * linux/md-os.c (actual_ucontext_t): Correct defines for ucontext_t.
+       (md_init_linux): New function. (md_signal_handler_sigill):
+       Implemented.
+
+       * linux/Makefile.am (libmd_la_SOURCES): Added md-os.h. to
+       dependencies.
+
+       * emit.c (emit_load_low): Implemented. (emit_load_high):
+       Implemented. (emit_classcast_check): Implemented. (emit_branch):
+       BRANCH_UGT added.
+
+       * md.c (md_init): Call md_init_linux if on linux.
+
+       * arch.h (HAS_4BYTE_STACKSLOT): Defined true.
+       (SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS): Likewise.
+
+       * codegen.c: Various fixes. (ICMD_INEG): Implemented. (ICMD_IDIV):
+       Implemented. (ICMD_IREM): Implemented. (ICMD_LDIV): Implemented.
+       (ICMD_LREM): Implemented. (ICMD_ISHL): Implemented.
+       (ICMD_ISHLCONST): Implemented. (ICMD_ISHR): Implemented.
+       (ICMD_ISHRCONST): Implemented. (ICMD_IUSHR): Implemented.
+       (ICMD_IUSHRCONST): Implemented. (ICMD_IAND): Implemented.
+       (ICMD_IANDCONST): Implemented. (ICMD_AASTORE): Implemented.
+       (ICMD_INVOKEINTERFACE): Implemented. (ICMD_TABLESWITCH):
+       Implemented. (ICMD_LOOKUPSWITCH): Implemented.
+
+       * patcher.c (patcher_instanceof_interface): Implemented.
+       (patcher_checkcast_interface): Implemented.
+       (patcher_invokeinterface): Added.
+
+       * codegen.h (ENABLE_SOFTFLOAT): Some ifdefs fors floats. (M_LLD):
+       Implemented. (M_LST): Implemented. (M_ISUB_IMM): Added. (M_IMUL):
+       Added. (M_IDIV): Added. (M_ISSL): Added. (M_ISSR): Added. (M_IUSR):
+       Added. (M_IAND): Added. (M_IOR): Added. (M_IREM): Added. (M_INEG):
+       Added. (OPWORD_ASSERT): Added. (M_ICMPI): Renamed M_ICMP_IMM.
+       (M_BLE): Fixed. (M_BHI, M_BHI16, M_BHI32): Added. (M_ASUBINT):
+       Added. (M_ISSL_IMM): Added (M_ISRL_IMM): Added. (M_IUSR_IMM): Added.
+       (M_TRAP_SETREGISTER): Added. (M_TRAP): Added.
+       [b6f5f3f696f2]
+
+2007-03-26  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390
+       /md-abi.c, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/tests/tests.java.pp:
+       * src/vm/jit/powerpc64/linux/md-os.c (md_signal_handler_sigsegv):
+       Use new exceptions_new_hardware_exception.
+
+       * src/vm/jit/powerpc64/emit.c: Use new hardwareexception defines.
+
+       * src/vm/jit/powerpc64/codegen.c: Likewise.
+       [826c4444d17a]
+
+2007-03-26  pm  <pm>
+
+       * src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/access.c,
+       src/vm/builtin.h, src/vm/global.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390
+       /md-abi.h, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/tests/tests.java.pp, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/classcache.c, src/vmcore/linker.c,
+       src/vmcore/method.c, src/vmcore/method.h:
+       * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/emit.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/tests/tests.java.pp, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/md-abi.c: Chaned a lot.
+       [41183fe2f8bb]
+
+2007-03-25  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c:
+       * src/vm/jit/sparc64/emit.c: Adapted to changed BRANCH_U defines.
+       * src/vm/jit/sparc64/codegen.c: Likewise.
+       [9179df5f161b]
+
+2007-03-25  twisti  <twisti>
+
+       * src/vm/jit/codegen-common.h, src/vm/jit/emit-common.c, src/vm/jit
+       /emit-common.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c:
+       * src/vm/jit/codegen-common.h (BRANCH_LTU): Renamed to BRANCH_ULT,
+       to be consistent with Alpha compare instructions. (BRANCH_LEU):
+       Renamed to BRANCH_ULE. (BRANCH_GEU): Renamed to BRANCH_UGE.
+       (BRANCH_GTU): Renamed to BRANCH_UGT.
+
+       * src/vm/jit/emit-common.c (emit_bltu): Renamed to emit_bult.
+       (emit_bleu): Renamed to emit_bule. (emit_bgeu): Renamed to
+       emit_buge. (emit_bgtu): Renamed to emit_bugt.
+       * src/vm/jit/emit-common.h: Likewise.
+
+       * src/vm/jit/i386/emit.c (emit_branch): Use new function names.
+       * src/vm/jit/i386/codegen.c (codegen_emit): Likewise.
+       [6f04f5dea964]
+
+2007-03-25  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit-arch.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/emit.h:
+       * src/vm/jit/sparc64/emit-arch.h: Renamed to emit.h.
+       * src/vm/jit/sparc64/emit.c: Updated include name.
+       * src/vm/jit/sparc64/codegen.c: Likewise.
+       [b52ac55e15ff]
+
+2007-03-25  twisti  <twisti>
+
+       * src/cacaoh/dummy.c, src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_Class.c, src/vm/access.c, src/vm/builtin.c,
+       src/vm/builtin.h, src/vm/global.h, src/vm/jit/asmpart.h,
+       src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/jit.c,
+       src/vm/jit/jit.h, src/vm/jit/powerpc/emit.c, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/classcache.c, src/vmcore/linker.c,
+       src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h:
+       * Merged with trunk.
+       [95bff0b38745]
+
+2007-03-25  ajordan  <ajordan>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h, src/vm/jit
+       /emit-common.c, src/vm/jit/emit-common.h,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/emit-arch.h, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/patcher.c:
+       * src/vm/jit/codegen-common.h (codegen_add_branch_ref): Options
+       added to branchrefs. (codegen_branch_label_add): Likewise.
+       * src/vm/jit/codegen-common.c: Likewise.
+       * src/vm/jit/emit-common.h (emit_label_bccz): Added options.
+       (emit_label_bcc): Likewise.
+       * src/vm/jit/emit-common.c (emit_label_*): Adapted to options.
+
+       * src/vm/jit/sparc64/emit-arch.h: Added for SPARC specific branch
+       otpions and emit_b* wrappers.
+
+       * src/vm/jit/sparc64/emit.c: Adapted to outside changes.
+       * src/vm/jit/sparc64/linux/md-os.c: Likewise.
+
+       * src/vm/jit/sparc64/patcher.c: Fixed classcast_interface patcher.
+
+       * src/vm/jit/sparc64/codegen.h: Fixed M_SHFT macro.
+       * src/vm/jit/sparc64/codegen.c: Fixed 32-bit shifts and various other
+       bugs.
+       [5b5ff31f30a0]
+
+2007-03-25  twisti  <twisti>
+
+       * src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/jit.c,
+       src/vm/jit/jit.h, src/vmcore/loader.c, src/vmcore/method.h:
+       Reverted patch 7268.
+
+       * src/vm/jit/code.c: Reverted.
+       * src/vm/jit/code.h: Likewise.
+       * src/vm/jit/jit.c: Likewise.
+       * src/vm/jit/jit.h: Likewise.
+       * src/vmcore/loader.c: Likewise.
+       * src/vmcore/method.h: Likewise.
+       [2080e200a6d6]
+
+       * src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/jit/codegen-
+       common.h, src/vm/jit/emit-common.c, src/vm/jit/emit-common.h,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c:
+       * src/vm/jit/codegen-common.h (BRANCH_B): Renamed to BRANCH_LTU.
+       (BRANCH_BE): Renamed to BRANCH_LEU. (BRANCH_AE): Renamed to
+       BRANCH_GEU. (BRANCH_A): Renamed to BRANCH_GTU.
+
+       * src/vm/jit/emit-common.c (emit_bb): Renamed to emit_bltu.
+       (emit_bbe): Renamed to emit_bleu. (emit_bae): Renamed to emit_bgeu.
+       (emit_ba): Renamed to emit_bgtu.
+       * src/vm/jit/emit-common.h: Likewise.
+
+       * src/vm/jit/i386/emit.c (emit_branch): Use new unsigned-branch
+       defines.
+       * src/vm/jit/i386/codegen.c (codegen_emit): Use new unsigned-branch
+       functions.
+       [0389cd4d3375]
+
+       * src/cacaoh/dummy.c, src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/vm/jit/i386/patcher.c, src/vmcore/method.c, src/vmcore/method.h:
+       * src/native/native.c (native_get_parametertypes): Removed.
+       (native_get_exceptiontypes): Likewise.
+       * src/native/native.h: Likewise.
+
+       * src/vmcore/method.c (vm/builtin.h): Added. (vm/resolve.h):
+       Likewise. (method_get_parametertypearray): New function.
+       (method_get_exceptionarray): Likewise.
+       * src/vmcore/method.h (method_get_parametertypearray): Added.
+       (method_get_exceptionarray): Likewise.
+
+       * src/cacaoh/dummy.c (builtin_anewarray): Added.
+       (resolve_class_from_typedesc): Likewise.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c (getParameterTypes):
+       Use method function. (getExceptionTypes): Likewise.
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (getParameterTypes): Likewise. (getExceptionTypes): Likewise.
+       [491366802e0d]
+
+2007-03-25  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c:
+       * src/vm/jit/sparc64/codegen.c (emit_codegen): Fixed incoming
+       argument handling, 'stack arg -> spilled' case. Fixed compares in
+       ICMD_IF_XX (integer ones) by removing branch on reg optimization
+       when val == 0. Doesn't work when there is junk in the upper 32-bits.
+       Fixed lookupswitch.
+       [7a9636db4b25]
+
+2007-03-24  twisti  <twisti>
+
+       * src/vm/jit/i386/arch.h, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/codegen.h, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md.c,
+       src/vm/jit/i386/patcher.c:
+       * src/vm/jit/i386/emit.c (vm/exceptions.h): Added. (emit_branch):
+       New function. (emit_arithmetic_check,
+       emit_arrayindexoutofbounds_check) (emit_classcast_check,
+       emit_nullpointer_check, emit_exception_check): Use hardware-
+       exception instructions. (emit_exception_stubs): Removed.
+
+       * src/vm/jit/i386/md.c (md_codegen_patch_branch): Removed.
+
+       * src/vm/jit/i386/codegen.c (codegen): Renamed to codegen_emit and a
+       zillion changes.
+
+       * src/vm/jit/i386/codegen.h (M_ALD_MEM): Added. (M_ALD_MEM_GET_OPC,
+       M_ALD_MEM_GET_MOD, M_ALD_MEM_GET_REG) (M_ALD_MEM_GET_RM,
+       M_ALD_MEM_GET_DISP): Likewise.
+
+       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv):
+       Rewritten for hardware-exceptions.
+
+       * src/vm/jit/i386/arch.h
+       (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER)
+       (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER)
+       (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS)
+       (SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS): Defined.
+
+       * src/vm/jit/i386/patcher.c
+       (patcher_checkcast_instanceof_interface): Renamed to
+       patcher_checkcast_interface. (patcher_instanceof_interface): New
+       function.
+       [0d1bc9f817e7]
+
+       * src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/linux/md-os.c:
+       * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Use new
+       exceptions_new_hardware_exception.
+
+       * src/vm/jit/powerpc/emit.c (emit_arithmetic_check)
+       (emit_arrayindexoutofbounds_check, emit_classcast_check)
+       (emit_nullpointer_check, emit_exception_check): Use new hardware-
+       exception defines.
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): Likewise.
+       [421de52e290f]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h:
+       * src/vm/jit/codegen-common.c (codegen_setup): Don't set
+       exceptionrefs. (codegen_reset): Likewise.
+       (codegen_add_exception_ref): Removed.
+       (codegen_add_arithmeticexception_ref): Likewise.
+       (codegen_add_arrayindexoutofboundsexception_ref): Likewise.
+       (codegen_add_arraystoreexception_ref): Likewise.
+       (codegen_add_classcastexception_ref): Likewise.
+       (codegen_add_nullpointerexception_ref): Likewise.
+       (codegen_add_fillinstacktrace_ref): Likewise.
+
+       * src/vm/jit/codegen-common.h (codegendata): Removed exceptionrefs.
+       (exceptionref): Removed. (codegen_add_arithmeticexception_ref):
+       Likewise. (codegen_add_arrayindexoutofboundsexception_ref):
+       Likewise. (codegen_add_arraystoreexception_ref): Likewise.
+       (codegen_add_classcastexception_ref): Likewise.
+       (codegen_add_nullpointerexception_ref): Likewise.
+       (codegen_add_fillinstacktrace_ref): Likewise.
+       [fd308cb27a30]
+
+2007-03-24  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/patcher.c:
+       This is the hello world runs commit.
+
+       * emit.c (emit_branch): Fixed.
+
+       * codegen.c (ICMD_*ASTORE): Fixed. (ICMD_*ALOAD): Fixed.
+
+       * patcher.c (patcher_resolve_classref_to_flags): Implemented.
+       (patcher_resolve_classref_to_vftbl): Implemented.
+
+       * asmpart.S (asm_patcher_wrapper): Store scratch registers.
+       (asm_getclassvalues_atomic): Implemented.
+
+       * codegen.h (M_IMOV_IMM32): Added, for use with patchers.
+       [ad44ea32e5dc]
+
+2007-03-23  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h,
+       src/vm/jit/m68k/patcher.c:
+       * linux/md-abi.h (ENABLE_SOFTFLOAT): Ifdefed stuff.
+
+       * linux/md-abi.c (ENABLE_SOFTFLOAT): Ifdefed stuff.
+
+       * emit.c (ENABLE_SOFTFLOAT): Ifdefed stuff.
+       (emit_nullpointer_check): Added.
+
+       * arch.h (SUPPORT_CONST_MUL): Yes.
+
+       * codegen.c (codegen_emit): ENABLE_SOFTFLOAT stuff. (ICMD_*CONST):
+       Added. (ICMD_INT2*): Added. (ICMD_IMUL*): Added. (ICMD_IADD,
+       ICMD_ISUB): Fixes.
+
+       * patcher.c (patcher_invokevirtual): Implemented.
+
+       * codegen.h: Lots of new opcodes implemented.
+       [bc42d1195a58]
+
+2007-03-23  twisti  <twisti>
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/alpha/linux/md-os.c:
+       * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Use
+       new exceptions_new_hardware_exception.
+
+       * src/vm/jit/alpha/emit.c (emit_arithmetic_check)
+       (emit_arrayindexoutofbounds_check, emit_classcast_check)
+       (emit_nullpointer_check, emit_exception_check): Use new hardware-
+       exception defines.
+       * src/vm/jit/alpha/codegen.c (codegen_emit): Likewise.
+       [2cd307710e39]
+
+       * src/vm/jit/alpha/md.c:
+       * src/vm/jit/alpha/md.c (vm/jit/codegen-common.h): Removed.
+       (md_codegen_patch_branch): Likewise.
+       [6d2d08670841]
+
+       * src/vm/access.c, src/vm/builtin.h, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/global.h, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-os.c,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c:
+       * src/vm/exceptions.c (exceptions_new_hardware_exception): Changed
+       signature and rewritten.
+
+       * src/vm/exceptions.h (EXCEPTION_LOAD_DISP_*): Renamed to
+       EXCEPTION_HARDWARE_*. (exceptions_new_hardware_exception): Changed
+       signature.
+
+       * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): Use
+       new exceptions_new_hardware_exception.
+
+       * src/vm/jit/powerpc/emit.c (emit_arithmetic_check)
+       (emit_arrayindexoutofbounds_check, emit_classcast_check)
+       (emit_nullpointer_check, emit_exception_check): Use new defines.
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): Likewise.
+       [e891bd9a01e9]
+
+       * src/cacaoh/dummy.c, src/native/vm/java_lang_Class.c,
+       src/vm/access.c, src/vm/builtin.c, src/vm/builtin.h,
+       src/vm/jit/asmpart.h, src/vmcore/class.c, src/vmcore/class.h:
+       * src/vm/builtin.c (builtin_isanysubclass): Removed.
+       (builtin_instanceof): Replaced builtin_isanysubclass with
+       class_isanysubclass. (builtin_descriptorscompatible): Likewise.
+
+       * src/vm/builtin.h (builtin_isanysubclass): Removed.
+
+       * src/vm/access.c (access_is_accessible_member): Replaced
+       builtin_isanysubclass with class_isanysubclass.
+       * src/native/vm/java_lang_Class.c (isAssignableFrom): Likewise.
+
+       * src/vm/jit/asmpart.h (castinfo): Removed.
+
+       * src/vmcore/class.c (vm/jit/asmpart.h): Added.
+       (class_isanysubclass): New function.
+
+       * src/vmcore/class.h (castinfo): Added. (class_isanysubclass):
+       Likewise.
+
+       * src/cacaoh/dummy.c (asm_getclassvalues_atomic): New function.
+       (intrp_asm_getclassvalues_atomic): Likewise.
+       [f259f2de6309]
+
+       * src/vm/builtin.c:
+       * src/vm/builtin.c (builtin_isanysubclass_vftbl): Removed.
+       (builtin_descriptorscompatible): Use builtin_isanysubclass instead
+       of builtin_isanysubclass_vftbl.
+       [86da5e869cbf]
+
+       * src/vm/builtin.c, src/vm/global.h, src/vmcore/linker.c:
+       * src/vm/global.h (ACC_CLASS_PRIMITIVE): Defined.
+
+       * src/vm/builtin.c (builtin_isanysubclass): Check for primitive
+       classes.
+
+       * src/vmcore/linker.c (link_primitivetype_table): Set primitive
+       flag.
+       [0ff0eb43786d]
+
+       * src/vmcore/classcache.c:
+       * src/vmcore/classcache.c (classcache_add_constraint)
+       [CLASSCACHE_VERBOSE]: Started to use log-functions.
+       (classcache_debug_dump): Likewise.
+       [9b93f8cd8dc9]
+
+       * src/vm/jit/powerpc/emit.c:
+       * src/vm/jit/powerpc/emit.c (emit_load): Use switch-case instead of
+       if-else contruct. (emit_store): Likewise. (emit_copy): Likewise.
+       [e24ec626da8a]
+
+2007-03-23  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/emit.c:
+       * src/vm/jit/m68k/emit.c (emit_verbosecall_exit): Fixed.
+
+       * src/vm/jit/m68k/codegen.c (ICMD_IRETURN): Fixed.
+       (createnativestub): Fixed.
+
+       * src/vm/jit/m68k/asmpart.S (L_asm_vm_call_method_copy_done):
+       Removed assertion.
+       [9fbd34c11819]
+
+2007-03-22  michi  <michi>
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h,
+       src/vm/jit/arm/emit.c:
+       * src/vm/jit/arm/emit.c (emit_nullpointer_check_force): Added.
+       * src/vm/jit/arm/codegen.h (gen_nullptr_check_intern): Removed.
+       * src/vm/jit/arm/codegen.c (codegen_emit): Adapted to above changes.
+       [6c0669c61b9c]
+
+2007-03-22  tbfg  <tbfg>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h,
+       src/vm/jit/dseg.c, src/vm/jit/dseg.h, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/patcher.c:
+       * src/vm/jit/codegen-common.h (datareferences): Enabled for m68k.
+
+       * src/vm/jit/dseg.c (dseg_adddata): Enabled for m68k.
+       (dseg_resolve_datareferences): Enalbed for m68k.
+
+       * src/vm/jit/dseg.h: Likewise.
+
+       * src/vm/jit/m68k/linux/md-abi.h (REG_D0): Added. (REG_D1, REG_A0,
+       REG_A1, REG_F0, REG_F1): Added.
+
+
+       * src/vm/jit/m68k/emit.c (emit_patcher_stubs): Fixed.
+
+       * src/vm/jit/m68k/codegen.c (createnativestub): Implemented.
+
+       * src/vm/jit/m68k/patcher.c (patcher_resolve_native_function):
+       Added.
+
+       * src/vm/jit/m68k/codegen.h (M_AMOV): Fixed. (M_AADD_IMM): Fixed.
+       (M_IADD_IMM): Fixed.
+
+       * src/vm/jit/codegen-common.c (codegen_setup): Datareferences
+       enabled for m68k.
+       [de445ee3cb19]
+
+2007-03-22  twisti  <twisti>
+
+       * src/vm/jit/arm/codegen.c:
+       * Merged with trunk.
+       [e13a0efc99c5]
+
+2007-03-22  michi  <michi>
+
+       * src/vm/jit/arm/codegen.c:
+       * src/vm/jit/arm/codegen.c (codegen) [!ENABLE_SOFTFLOAT]: Fixed
+       position of soft null pointer checks in PUTFIELD and GETFIELD.
+       [0241cda4051a]
+
+2007-03-21  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/emit.h, src/vm/jit/m68k/linux/md-abi.c,
+       src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/md.c,
+       src/vm/jit/m68k/patcher.c:
+       * src/vm/jit/m68k/linux/md-abi.h (REG_FRESULT2): Removed, all float
+       registers are 64bit. (REG_A0_A1_PACKED): Removed, no argument
+       registers.
+
+       * src/vm/jit/m68k/linux/md-abi.c (md_return_alloc): Implemented, we
+       can alway precolor the result register as no argument registers are
+       used.
+
+       * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Fixed. (emit_branch):
+       Implemented. (emit_classcast_check): Implemented.
+       (emit_arrayindexoutofbounds_check): Implemented.
+
+       * src/vm/jit/m68k/md.c (md_get_method_patch_address): Implemented
+       invokevirtual case. (md_return_alloc): Moved to linux/md-abi.c.
+
+       * src/vm/jit/m68k/emit.h (emit_jsr): Removed. (emit_jmp): Removed.
+
+       * src/vm/jit/m68k/codegen.c (codegen_emit): Added branch resolving.
+       (ICMD_IADD): Implemented. (ICMD_IINC): Implemented.
+       (ICMD_IADDCONST): Implemented. (ICMD_ASTORE): Implemented.
+       (ICMD_IF*): Implemented. (ICMD_IF_ICMP*): Implemented.
+       (ICMD_IF_ACMP*): Implemented. (ICMD_ARRAYLENGTH): Implemented.
+       (ICMD_*LOAD): Implemented, but not long, float and double.
+       (ICMD_*STORE): Likewise. (ICMD_INVOKEVIRTUAL): Fixed.
+       (ICMD_INSTANCEOF): Partially implemented. (ICMD_CHECKCAST):
+       Likewise.
+
+       * src/vm/jit/m68k/patcher.c (patcher_resolve_classref_to_flags):
+       Added. (patcher_resolve_classref_to_vftbl): Added.
+       (patcher_instanceof_interface): Added.
+       (patcher_checkcast_interface): Added.
+
+       * src/vm/jit/m68k/asmpart.S (asm_call_jit_compiler): Fixed mptr.
+
+       * src/vm/jit/m68k/codegen.h (BRANCH_NOPS): Implemented. (M_MOV_IMM):
+       Renamed M_IMOV_IMM. (M_IMOV): Added. (M_AMOV): Added. (M_ICLR):
+       Added. (M_PUSH): Renamed M_IPUSH. (M_POP): Renamed M_IPOP.
+       (M_PUSH_IMM): Renamed M_IPUSH_IMM. (M_IADD_IMM): Added. (M_ISUB):
+       Added. (M_IADD): Added. (M_TST): Renamed M_ITST. (M_ICMPI): Added.
+       (M_ACMPI): Added. (M_ICMP): Added. (M_ACMP): Added. (M_IAND_IMM):
+       Added. (M_B[R|EQ|NE|LT|GE|GT|LE|NAN]_[16|32]): Added. (M_LBZX):
+       Added. (M_LHZX): Added. (M_LWZX): Added. (M_LAX): Added. (M_STBX):
+       Added. (M_STHX): Added. (M_STWX): Added. (M_STAX): Added. (M_BSEXT):
+       Added. (M_HSEXT): Added. (M_AADDINT): Added. (M_ISSL_IMM): Added.
+       [c577767cfb92]
+
+2007-03-21  twisti  <twisti>
+
+       * src/threads/native/lock.c, src/vmcore/statistics.c:
+       * Merged with trunk.
+       [66e2171855c4]
+
+       * src/threads/native/lock.c, src/vmcore/statistics.c,
+       src/vmcore/statistics.h:
+       * src/vmcore/statistics.c (size_lock_record_pool): Added.
+       (statistics_print_memory_usage): Print new variable.
+
+       * src/vmcore/statistics.h (size_lock_record_pool): Added.
+
+       * src/threads/native/lock.c (lock_record_alloc_new_pool): Added
+       statistics.
+       [de5df327235c]
+
+       * src/native/jni.c, src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/threads/native/lock.c, src/threads/native/threads.c,
+       src/vm/builtin.c, src/vm/builtin.h, src/vm/exceptions.c,
+       src/vm/jit/s390/arch.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390
+       /md-abi.c, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/md-abi.c,
+       src/vmcore/linker.c, src/vmcore/statistics.c:
+       * Merged with trunk.
+       [044d295cad35]
+
+       * src/threads/native/lock.c, src/threads/native/threads.c,
+       src/vmcore/statistics.c, src/vmcore/statistics.h:
+       * src/vmcore/statistics.c (size_threadobject, size_lock_hashtable)
+       (size_lock_waiter): Added. (statistics_print_memory_usage): Print
+       new variables.
+
+       * src/vmcore/statistics.h (size_threadobject, size_lock_hashtable)
+       (size_lock_waiter): Added.
+
+       * src/threads/native/lock.c (vmcore/options.h): Added.
+       [ENABLE_STATISTICS] (vmcore/statistics.h): Added.
+       (lock_hashtable_init): Added statistics. (lock_hashtable_grow):
+       Likewise. (lock_record_add_waiter): Likewise.
+       (lock_record_remove_waiter): Likewise.
+
+       * src/threads/native/threads.c [ENABLE_STATISTICS]
+       (vmcore/statistics.h): Added. (threads_preinit): Added statistics.
+       (threads_init): Likewise. (threads_start_javathread): Likewise.
+       (threads_attach_current_thread): Likewise. (threads_detach_thread):
+       Likewise.
+       [0e6bc4048dbd]
+
+       * src/vmcore/zip.c:
+       * src/vmcore/zip.c (zip_get): Don't assign in if-statement, this
+       makes debugging a bit easier.
+       [9f9318ee0bec]
+
+       * src/vmcore/linker.c:
+       * src/vmcore/linker.c (link_primitivetype_table): Set super class
+       explicitly to NULL. (linker_compute_subclasses): Indent.
+       [0179eeef5747]
+
+2007-03-21  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/m68k/disass.c, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c:
+       * src/vm/jit/m68k/linux/md-abi.h (ADR_RES_CNT): Increased, as %fp
+       should not be used. (TRACE_ARGS_NUM): Removed.
+
+       * src/vm/jit/m68k/linux/md-abi.c (nregdescadr): Reserved %fp.
+
+       * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Generated moveql for
+       short immideates. (emit_load): Implemented.
+       (emit_verbosecall_enter): Implemented. (emit_verbosecall_exit):
+       Implemented.
+
+       * src/vm/jit/m68k/md.c (md_codegen_get_pv_from_pc): Comment fixed.
+       (md_get_method_patch_address): Fixed. (cacheflush): Method defintion
+       added. (md_cacheflush): Implemented. (md_dcacheflush): Implemented.
+       (md_icacheflush): Implemented. (comment): Kernel patch for
+       sys_cacheflush to work added.
+
+       * src/vm/jit/m68k/arch.h
+       (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER): Defined.
+       (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER): Undefined.
+       (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Undefined.
+
+       * src/vm/jit/m68k/codegen.c (codegen_emit): Used callee saved
+       registers are stored. Arguments copied into local map. Function
+       calls properly linked. Stack freed, calle saved register restored.
+       (createcompilerstub): Fixed. (ICMD_ICONST): Implemented.
+       (ICMD_ATHROW): Likewise. (ICMD_GOTO): Likewise. (ICMD_RET):
+       Likewise. (ICMD_JSR): Likewise. (ICMD_IFNULL): Likewise.
+       (ICMD_IFNONNULL): Likewise. (ICMD_GETFIELD): Likewise.
+       (ICMD_PUTFIELD): Likewise. (ICMD_BUILTIN): Fixed argument handling.
+       (ICMD_IRETURN): Fixed address return type issue.
+
+       * src/vm/jit/m68k/disass.c (disassinstr): Even prettier output.
+
+       * src/vm/jit/m68k/patcher.c (patcher_wrapper): Fixed.
+       (patcher_get_putfield): Implemented.
+
+       * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Symbol added.
+       (asm_vm_call_method): Fixed argument passing.
+       (asm_call_jit_compiler): Removes stackframe. Invoked jitcode without
+       linking.
+
+       * src/vm/jit/m68k/codegen.h (M_NOP): Added. (ALIGNCODENOP): Added.
+       (M_BSR): Renamed M_BSR_IMM. (M_JSR_PCREL): Added. (M_PUSHALL):
+       Likewise. (M_POPALL): Likewise. (M_AADD_IMM): Likewise.
+       (M_INT2ADRMOVE): Likewise. (M_ADR2INTMOVE): Likewise. (M_TST):
+       Likewise. (M_ATST): Likewise.
+       [d0b36959ff46]
+
+2007-03-20  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/linux/md-os.c,
+       src/vm/jit/sparc64/md.c:
+       * src/vm/jit/sparc64/codegen.h: Fixed load/stores with large
+       displacements (SETHI).
+
+       * src/vm/jit/sparc64/codegen.c: Implemented hardware exceptions.
+       * src/vm/jit/sparc64/md.c: Likwise.
+       * src/vm/jit/sparc64/linux/md-os.c: Likewise.
+       * src/vm/jit/sparc64/arch.h: Likewise.
+       [63e0d09e3f85]
+
+2007-03-20  michi  <michi>
+
+       * src/vm/exceptions.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c,
+       src/vm/jit/arm/linux/md-os.c, src/vm/signal.c, src/vm/signallocal.h:
+       * src/vm/jit/arm/codegen.c (codegen_emit): No longer emit exception
+       stubs.
+
+       * src/vm/jit/arm/codegen.h: Trap instructions added.
+
+       * src/vm/jit/arm/emit.c: (emit_arithmetic_check): Use hardware-
+       exception instructions. (emit_arrayindexoutofbounds_check):
+       Likewise. (emit_classcast_check): Likewise.
+       (emit_nullpointer_check): Likewise. (emit_exception_check):
+       Likewise.
+
+       * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill): Added.
+
+       * src/vm/signal.c (signal_init) [__ARM__]: Catch SIGILL for
+       hardware-exceptions.
+
+       * src/vm/signallocal.h [__ARM__]: Added prototype for
+       md_signal_handler_sigill.
+
+       * src/vm/exceptions.c (exceptions_new_hardware_exception) [__ARM__]:
+       Adapted to ARM since there is no REG_ZERO on this arch.
+       [2627837d967b]
+
+2007-03-20  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/md-abi.c:
+       * src/vm/jit/sparc64/md-abi.c (md_param_alloc_native): using this
+       for native param allocation. No need for my own version of this
+       anymore.
+       * src/vm/jit/sparc64/codegen.c: Likewise.
+       [a9e82fd0d81d]
+
+2007-03-20  michi  <michi>
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_new_hardware_exception): Added
+       comment and assertion for ARM, since there is no REG_ZERO there.
+       [066bff2c61cd]
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h,
+       src/vm/jit/arm/emit.c:
+       Lots of the stuff in this commit was done by twisti, I only
+       completed his work.
+
+       * src/vm/jit/arm/emit.c (emit_branch, emit_arithmetic_check)
+       (emit_classcast_check, emit_exception_check): Added.
+       (emit_exception_stubs): Fixed.
+
+       * src/vm/jit/arm/codegen.h (load_var_to_reg, store_reg_to_var_lng):
+       Removed. (gen_resolvebranch, gen_nullptr_check, gen_div_check,
+       gen_bound_check): Removed.
+
+       * src/vm/jit/arm/codegen.c (codegen): Renamed to codegen_emit.
+       Changed to use emit-branch and emit-check functions.
+       [cf7ed6d495a5]
+
+       * src/vm/jit/arm/arch.h, src/vm/jit/arm/md.c:
+       * src/vm/jit/arm/arch.h
+       (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER)
+       (SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS)
+       (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER)
+       (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Added.
+
+       * src/vm/jit/arm/md.c (md_codegen_patch_branch): Added assertion.
+       [6e95c5f34111]
+
+2007-03-17  ajordan  <ajordan>
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, src/vm/jit
+       /codegen-common.c, src/vm/jit/codegen-common.h, src/vm/jit/emit-
+       common.c, src/vm/jit/emit-common.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md.c,
+       src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md.c:
+       * src/vm/jit/emit-common.h: Functions which branch on unsigned
+       conditions can be enabled by defining
+       SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS to 1 in arch.h.
+       (emit_branch): Added option argument to machine dependent branch
+       emitting function, to accomodate special flags some architectures
+       might allow to set in the branch. (eg. selecting condition codes,
+       setting prediction) (emit_bccz): Added option argument. (emit_bcc):
+       Likewise.
+       * src/vm/jit/codegen-common.h: Added define for empty branch options
+       argument.
+       * src/vm/jit/emit-common.c: All branch emitting functions changed to
+       pass an empty options argument.
+
+       * src/vm/jit/codegen-common.c (codegen_resolve_branchrefs): Call to
+       emit_b* adapted to new brach emitting signature.
+       * src/vm/jit/powerpc/emit.c (emit_branch): Likewise.
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): Likewise.
+       * src/vm/jit/alpha/emit.c (emit_branch): Likewise.
+       * src/vm/jit/alpha/codegen.c (codegen_emit): Likewise.
+       * src/vm/jit/mips/emit.c (emit_branch): Likewise.
+       * src/vm/jit/mips/codegen.c (codegen_emit): Likewise.
+       * src/vm/jit/m68k/emit.c (emit_branch): Likewise.
+       * src/vm/jit/powerpc64/emit.c (emit_branch): Likewise.
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit): Likewise.
+
+       * src/vm/jit/sparc64/*: Ported code to work with branch and
+       exception changes.
+       [082d27818cb9]
+
+2007-03-17  twisti  <twisti>
+
+       * src/vm/builtin.h:
+       * src/vm/builtin.h (builtin_isanysubclass_vftbl): Removed, made
+       static.
+       [40dbf088ff86]
+
+       * src/vm/builtin.c:
+       * src/vm/builtin.c (builtin_isanysubclass): Code cleanup.
+       (builtin_isanysubclass_vftbl): Likewise.
+       [35e3a6da581a]
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c:
+       * src/native/vm/gnu/java_lang_reflect_Method.c (vm/resolve.h):
+       Added.
+       [e18a539bc7ef]
+
+       * src/vm/builtin.c:
+       * src/vm/builtin.c (builtin_isanysubclass): Cleanup and comments.
+       [da83167dc0e7]
+
+2007-03-16  pm  <pm>
+
+       * src/vm/exceptions.c, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/tests/Makefile, src/vm/jit/s390/tests/tests.java.pp:
+       * src/vm/exceptions.c (exceptions_handle_exception): 31 bit address
+       comparison for S390. These address comparison macros need to be
+       moved to some header.
+       * src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/arch.h, src/vm/jit/s390/patcher.c, src/vm/jit/s390
+       /md-abi.c, src/vm/jit/s390/tests/tests.java.pp,
+       src/vm/jit/s390/tests/Makefile: Changed a lot.
+       [b5435a3d596b]
+
+2007-03-16  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/asmpart.S:
+       * src/vm/jit/powerpc64/asmpart.S (libjvm): Fix libjvm build.
+       [f84ce133c86f]
+
+       * src/vm/jit/emit-common.c, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c:
+       * powerpc64/emit.c (emit_branch): Removed superflous vm_abort.
+
+       * powerpc64/codegen.c (codegen_emit): Adopt ppc change.
+
+       * powerpc64/asmpart.S (__ASSEMBLY__): Define needed for newer libc.
+       (global): Fixed things for static build.
+
+       * emit-common.c (emit_bnan): Enabled for __POWERPC64__.
+       [773024452f4e]
+
+2007-03-16  twisti  <twisti>
+
+       * src/cacaoh/dummy.c, src/vm/exceptions.c, src/vm/exceptions.h,
+       src/vmcore/loader.c:
+       * src/vm/exceptions.c
+       (exceptions_throw_noclassdeffounderror_wrong_name): New function.
+       (exceptions_new_hardware_exception): Distinguish pointer-size.
+
+       * src/vm/exceptions.h
+       (exceptions_throw_noclassdeffounderror_wrong_name): Added.
+       * src/cacaoh/dummy.c: Likewise.
+
+       * src/vmcore/loader.c (load_class_from_classbuffer): Use
+       exceptions_throw_noclassdeffounderror_wrong_name.
+       [10d06f982050]
+
+       * src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/powerpc/codegen.c (codegen_emit): Use label-branches
+       instead of hardcoded ones (maybe there are some left).
+       [af55245327e3]
+
+       * src/vm/jit/emit-common.c, src/vm/jit/emit-common.h:
+       * src/vm/jit/emit-common.c (emit_label_bne, emit_label_blt)
+       (emit_label_bge, emit_label_bgt, emit_label_ble): New function.
+       * src/vm/jit/emit-common.h: Likewise.
+       [edc6c51ac2df]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/emit.c:
+       * src/vm/jit/codegen-common.c (codegen_generate): Removed debug
+       code.
+       * src/vm/jit/powerpc/emit.c (emit_branch): Likewise.
+       [532c70a3d6b6]
+
+2007-03-15  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c:
+       * codegen.c (ICMD_CALOAD): Do not use sign extending load for char.
+       Dacapo antlr now passes. (opt_showdisassemble): Removed from various
+       places.
+
+       * patcher.c (opt_showdisassemble): Replaced by opt_shownops. cacao
+       -so works again.
+       [e31fbfe92629]
+
+2007-03-15  twisti  <twisti>
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_jni_invokeNative): Release memory in
+       exception case.
+       [8caf33a3260a]
+
+2007-03-15  pm  <pm>
+
+       * src/vm/jit/s390/tests/tests.java.pp:
+       * src/vm/jit/s390/tests/tests.java.pp: added INT2CHAR test testing
+       negative values.
+       [aa554a26fc64]
+
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/tests/Makefile, src/vm/jit/s390/tests/tests.java.pp:
+       * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h: Changed a
+       lot.
+       * src/vm/jit/s390/tests, src/vm/jit/s390/tests/tests.java.pp,
+       src/vm/jit/s390/tests/Makefile: Added opcode tests in java.
+       [7cf85b556eef]
+
+2007-03-14  twisti  <twisti>
+
+       * src/mm/nogc.c, src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, src/vm/string.c,
+       src/vmcore/statistics.c:
+       * Merged with trunk.
+       [8305ef91befc]
+
+       * src/vm/string.c, src/vmcore/statistics.c, src/vmcore/statistics.h:
+       * src/vmcore/statistics.c (size_string): Added.
+       (statistics_print_memory_usage): Likewise.
+       * src/vmcore/statistics.h (size_string): Likewise.
+
+       * src/vm/string.c (vmcore/statistics.h): Added. (literalstring_u2):
+       Added statistics.
+       [4848e755769f]
+
+       * src/vm/jit/alpha/emit.c:
+       * src/vm/jit/alpha/emit.c (emit_load): Use switch-case instead of
+       if-else contruct. (emit_store): Likewise. (emit_copy): Likewise.
+       [1eb3f98f544d]
+
+       * src/vm/jit/alpha/md.c:
+       * src/vm/jit/alpha/md.c (vm/jit/codegen-common.h): Added
+       temporarily.
+       [ce089b68b9b5]
+
+2007-03-14  michi  <michi>
+
+       * src/vm/jit/arm/codegen.c:
+       * src/vm/jit/arm/codegen.c (codegen): All the long compares have a
+       different implementation now.
+       [7da8dcbce235]
+
+       * src/vm/jit/arm/emit.c:
+       * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Fixed bug with
+       inmemory arguments, which caused some crashes with verbose-calls.
+       [1564b2409e4a]
+
+2007-03-14  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/asmpart.S:
+       * asmpart.S (asm_cacheflush): Create correct ppc64 alf abi function
+       descriptor for gcc-4.1. gcc-3.4 works too.
+
+       (asm_getclassvalues_atomic): Likewise.
+       [b16c7b5c46c9]
+
+2007-03-14  michi  <michi>
+
+       * src/mm/nogc.c:
+       * src/mm/nogc.c: Fixed includes and exceptions.
+       [17f4c0aa0bb1]
+
+2007-03-13  twisti  <twisti>
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/linux/md-abi.h:
+       * src/vm/jit/powerpc64/linux/md-abi.h (REG_A3, REG_FA0, REG_FA1):
+       Added.
+
+       * src/vm/jit/powerpc64/emit.c (emit_verbosecall_exit): Adopted
+       signature change of builtin_verbosecall_exit.
+       [5b5201b65647]
+
+       * src/vm/jit/i386/emit.c:
+       * src/vm/jit/i386/emit.c (emit_load): Use switch-case instead of if-
+       else contruct. (emit_store): Likewise. (emit_copy): Likewise.
+       [bdbfe4ab81d9]
+
+       * src/vm/jit/i386/codegen.c:
+       * src/vm/jit/i386/codegen.c (codegen): Fixed compiler warning.
+       [d04aaed44b74]
+
+       * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h,
+       src/vm/jit/arm/md.c:
+       * Merged with trunk.
+       [e65251d81071]
+
+2007-03-13  michi  <michi>
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h:
+       * src/vm/jit/arm/codegen.c (codegen): Long branches are implemented
+       differently now.
+
+       * src/vm/jit/arm/codegen.h (M_COMPARE): Easier macros without
+       overjumps. (M_MOVEQ_IMM, M_MOVGT_IMM, M_ADDHI_IMM, M_SUBLO_IMM,
+       M_CMPEQ_IMM): New macro.
+       [baa7f5e2d7d7]
+
+       * src/vm/jit/arm/linux/Makefile.am:
+       * src/vm/jit/arm/linux/Makefile.am: Fixed include path to care about
+       builddir.
+       [25fb1683004a]
+
+2007-03-12  twisti  <twisti>
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Removed
+       ifdef.
+       [1b260c15209b]
+
+       * src/vm/jit/codegen-common.h:
+       * src/vm/jit/codegen-common.h (BRANCH_B, BRANCH_BE, BRANCH_AE)
+       (BRANCH_A, BRANCH_NAN): Defined.
+       [d6a77d9ac5f6]
+
+       * src/vm/jit/emit-common.c, src/vm/jit/emit-common.h:
+       * src/vm/jit/emit-common.c [__I386__ || __X86_64__] (emit_bb): New
+       function. (emit_bbe): Likewise. (emit_bae): Likewise. (emit_ba):
+       Likewise. [__POWERPC__] (emit_bnan): #ifdef'ed.
+       * src/vm/jit/emit-common.h: Likewise.
+       [f7a65ebf9dd9]
+
+2007-03-12  tbfg  <tbfg>
+
+       * src/mm/boehm.c, src/mm/gc-common.h, src/mm/memory.c,
+       src/mm/memory.h, src/native/jni.h, src/native/native.c,
+       src/native/native.h,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/vm/global.h, src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h,
+       src/vm/jit/arm/md.c, src/vm/jit/i386/codegen.c,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/stacktrace.h, src/vm/signal.c, src/vm/signallocal.h,
+       src/vmcore/class.c, src/vmcore/class.h, src/vmcore/loader.c:
+       * md.c (md_codegen_get_pv_from_pc): Fixed comment.
+       (md_get_method_patch_address): Added case for invokespecial and
+       invokestatic.
+
+       * codegen.c (codegen_emit): Fixed invokespecial/static.
+       (createcompilerstub): Invoke without linking.
+       * patcher.c (patcher_invokevirtual): Implemented.
+
+       * asmpart.S (asm_call_jit_compiler): Save correct registers.
+       [90b6edd36d00]
+
+2007-03-12  twisti  <twisti>
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h:
+       * src/vm/jit/codegen.c (codegen): Change the operand direction of
+       some macros. Started to implement long-compares differently.
+
+       * src/vm/jit/codegen.h (M_AND, M_ORR, M_EOR, M_AND_IMM, M_MOVEQ)
+       (M_MOVVS_IMM, M_MOVNE_IMM, M_MOVLT_IMM, M_MOVLS_IMM): Changed
+       operand direction. (M_ORR_S, M_CMPEQ, M_CMPLE): New macro.
+       [2509f70f8505]
+
+       * src/vm/jit/arm/md.c:
+       * src/vm/jit/arm/md.c (vm/jit/codegen-common.h): Added.
+       [d11d179c49bd]
+
+       * src/mm/boehm.c, src/mm/gc-common.h, src/mm/memory.c,
+       src/mm/memory.h, src/native/jni.h, src/native/native.c,
+       src/native/native.h,
+       src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/vm/global.h, src/vm/jit/i386/codegen.c, src/vm/jit/stacktrace.h,
+       src/vm/signal.c, src/vm/signallocal.h, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/loader.c:
+       * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c
+       (vm/vm.h): Added. (open): Call vm_abort.
+
+       * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c
+       (unistd.h): Added. (readByte): New function. (writeBuf): Likewise.
+       (available0): Likewise. (close0): Likewise.
+       [00bc809f0d2a]
+
+2007-03-12  michi  <michi>
+
+       * src/mm/cacao-gc/heap.c:
+       * src/mm/cacao-gc/heap.c: Fixed includes.
+       [575b62e7001e]
+
+       * src/mm/cacao-gc/gc.c:
+       * src/mm/cacao-gc/gc.c (gc_suspend): Implemented. (gc_collect): Now
+       properly suspends threads before collecting.
+       [2c58bad749e7]
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c [ENABLE_GC_CACAO] (replace_gc_from_native):
+       Added. (replace_me) [ENABLE_GC_CACAO]: Different execution path for
+       the exact GC. (replace_map_source_state_identity): Added.
+       [d881dd686fb0]
+
+       * src/mm/cacao-gc/rootset.c:
+       * src/mm/cacao-gc/rootset.c (rootset_from_thread): Local references
+       are added.
+       [6749b3d61efa]
+
+       * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/mark.c:
+       * src/mm/cacao-gc/compact.c: Class fields are no longer threaded
+       directly.
+       * src/mm/cacao-gc/mark.c: Class fields are no longer marked directly.
+       [3b706ddc3bfd]
+
+       * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/rootset.c,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/vm/jit/i386/linux/md-os.c:
+       * src/threads/native/threads.h (threadobject): Struct now contains
+       es and ss.
+       * src/threads/native/threads.c (threads_suspend_ack): Informs GC about
+       suspend.
+       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigusr1): Pass SP
+       as well.
+       * src/mm/cacao-gc/gc.h (gc_suspend): Adapted prototype.
+       * src/mm/cacao-gc/rootset.c (rootset_from_thread): Uses ss of
+       threadobject.
+       [132ecadd6b9b]
+
+2007-03-11  michi  <michi>
+
+       * src/vm/jit/code.c, src/vm/jit/code.h:
+       * src/vm/jit/code.c (code_find_codeinfo_for_pc_nocheck): Added.
+       * src/vm/jit/code.h (code_find_codeinfo_for_pc_nocheck): Added
+       prototype.
+       [39fc2c9ba668]
+
+       * configure.ac, src/mm/cacao-gc/heap.c, src/mm/cacao-gc/region.c,
+       src/mm/cacao-gc/region.h, src/vm/builtin.c,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/jit.c, src/vm/jit/jit.h,
+       src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c, src/vm/jit/parse.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/x86_64/asmpart.S:
+       * src/mm/cacao-gc/region.h (regioninfo_t): Added object header for
+       locking.
+       * src/mm/cacao-gc/region.c (region_create): Header mentioned above is
+       initiated.
+       * src/mm/cacao-gc/heap.c (heap_alloc_intern): Lock regions while
+       allocating.
+       [afd084a060d6]
+
+2007-03-09  twisti  <twisti>
+
+       * src/cacaoh/headers.c, src/mm/boehm.c, src/mm/gc-common.h,
+       src/mm/memory.c, src/mm/memory.h, src/native/jni.h,
+       src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/vm/Makefile.am, src/vm/builtin.h, src/vm/global.h,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/patcher.c, src/vm/jit/inline/inline.c,
+       src/vm/jit/intrp/intrp.h, src/vm/jit/intrp/patcher.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md-
+       abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/patcher.c,
+       src/vm/jit/stack.c, src/vm/jit/stacktrace.h,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c,
+       src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c,
+       src/vm/jit_interface.h, src/vm/resolve.c, src/vm/resolve.h,
+       src/vm/signal.c, src/vm/signallocal.h, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/classcache.c,
+       src/vmcore/descriptor.c, src/vmcore/linker.c, src/vmcore/loader.c,
+       src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/statistics.c,
+       tests/regression/Makefile.am:
+       * tests/regression/resolving (svn:ignore): Added.
+       * tests/regression/resolving/classes1: Likewise.
+       * tests/regression/resolving/classes2: Likewise.
+       * tests/regression/resolving/classes3: Likewise.
+       [644c9406eb42]
+
+2007-03-09  tbfg  <tbfg>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/emit.h,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c:
+       * src/vm/jit/m68k/emit.c (emit_copy): Implemented. (emit_load):
+       Implemented. (emit_patcher_stubs): Using bsrl instrad of jsr to
+       easily spot patchers ind assembler output.
+
+       * src/vm/jit/m68k/md.c (md_dcacheflush): Added.
+
+       * src/vm/jit/m68k/codegen.c (ICMD_*LOAD): Implemented.
+       (ICMD_PUTSTATIC): Implemented. (ICMD_BUILTIN): Implemented.
+
+       * src/vm/jit/m68k/patcher.c (patcher_wrapper): Correctyl patching
+       back original code. (patcher_invokestatic_special): Implemented.
+       (patcher_resolve_classref_to_classinfo): Implemented.
+       (patcher_get_putstatic): Implemented.
+
+       * src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Return to jit
+       code.
+
+       * src/vm/jit/m68k/codegen.h (M_AMOV_IMM): Fixed. (M_JMP_IMM): Added.
+       (M_BSR): Added. (OPWORD_COND): Added for M_*MOVE opcodes. (M_*MOVE):
+       Added.
+
+       * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Show
+       opt_shownops for m68k enabled.
+       [e2ec759779d3]
+
+2007-03-08  michi  <michi>
+
+       * src/threads/native/threads.c, src/threads/native/threads.h,
+       src/vm/jit/i386/linux/md-os.c:
+       Added support for thread suspension!
+
+       * src/threads/native/threads.h (threadobject): Needed fields added.
+       * src/threads/native/threads.c (threads_stopworld,
+       threads_startworld): Improved. (threads_suspend_thread,
+       threads_resume_thread, threads_suspend_ack): Added.
+
+       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigusr1): Adapted
+       to changes.
+       [4c8c428f0906]
+
+       * src/mm/cacao-gc/rootset.c, src/vm/jit/replace.c:
+       * src/vm/jit/replace.c (replace_me): Loads sfi of current thread.
+       (replace_recover_source_state): No longer bound to current thread.
+
+       * src/mm/cacao-gc/rootset.c (rootset_from_thread): Loads sfi from
+       passed thread.
+       [71ccc40f0313]
+
+       * src/cacaoh/headers.c, src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/vm/Makefile.am, src/vm/builtin.h,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/codegen-common.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/patcher.c, src/vm/jit/inline/inline.c,
+       src/vm/jit/intrp/intrp.h, src/vm/jit/intrp/patcher.c,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md-
+       abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/patcher.c,
+       src/vm/jit/stack.c, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/md.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/jit_interface.h,
+       src/vm/resolve.c, src/vm/resolve.h, src/vm/vm.c,
+       src/vmcore/classcache.c, src/vmcore/descriptor.c,
+       src/vmcore/linker.c, src/vmcore/method.c, src/vmcore/method.h,
+       src/vmcore/options.c, src/vmcore/options.h, src/vmcore/statistics.c,
+       tests/regression/Makefile.am:
+       * src/threads/native/threads.h: Added THREAD_FLAG_IN_NATIVE and
+       gc_critical.
+       * src/threads/native/threads.c: Init and dump the above flags.
+
+       * src/vm/vm.c: Change the THREAD_IN_NATIVE_FLAG accordingly.
+       * src/vm/jit/codegen-common.c: Same as above.
+       [32d0b0323e17]
+
+2007-03-08  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/md.c,
+       src/vm/jit/m68k/patcher.c:
+       * src/vm/jit/m68k/linux/md-abi.h (REG_FP): Added. (REG_METHODPTR):
+       Added. (REG_ITMP12_PACKED): Added. (REG_ITMP23_PACKED): Added.
+
+       * src/vm/jit/m68k/emit.c (emit_jsr): Removed. (emit_jmp): Removed.
+       (emit_store): Implemented. (emit_patcher_stubs): Implemented.
+
+
+       * src/vm/jit/m68k/md.c (md_init): Asserting the offsets generated in
+       build process.
+
+       * src/vm/jit/m68k/codegen.c (INVOKE_VIRTUAL): Generate method
+       header. (ICMD_*RETURN): Implemented.
+
+       * src/vm/jit/m68k/patcher.c (patcher_wrapper): Implemented.
+       (patcher_initialize_class): Implemented. (patcher_invokevirtual):
+       Implemented. (patcher_resolve_class): Implemented.
+
+       * src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Implemented.
+
+       * src/vm/jit/m68k/codegen.h (MCODECHECK): Implemented.
+       (OPWORD_IMM16): Added. (OPWORD_IMM32): Added. (PATCHER_CALL_SIZE):
+       Defined. (M_TPF):Added. (M_TPFW): Added. (M_TPFL): Added. (M_JMP):
+       Added. (M_JSR): Added. (M_JSR_IMM): Added. (M_RET): Added. (M_LINK):
+       Added. (M_UNLK): Added. (M_PUSH_IMM): Added. (M_ILD): Added.
+       (M_ALD): Added. (M_IST): Added. (M_AST): Added. (M_INTMOVE): Added.
+       (M_ADRMOVE): Added.
+       [083ace5e9428]
+
+2007-03-08  twisti  <twisti>
+
+       * src/vm/jit/mips/codegen.c:
+       * src/vm/jit/mips/codegen.c (codegen_emit): Use label-branches.
+       [f2f8fcaa5e5e]
+
+       * configure.ac, src/cacaoh/dummy.c, src/cacaoh/headers.c,
+       src/native/jni.c, src/native/native.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Thread.c,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/vm/Makefile.am, src/vm/builtin.c,
+       src/vm/builtin.h, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/intrp/intrp.h,
+       src/vm/jit/intrp/patcher.c, src/vm/jit/jit.c, src/vm/jit/jit.h,
+       src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/replace.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md-
+       abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/patcher.c,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h,
+       src/vm/jit/sparc64/md-asm.h, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/stack.c, src/vm/jit/verify/typecheck-typeinferer.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/md.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/jit_interface.h,
+       src/vm/resolve.c, src/vm/resolve.h, src/vm/signal.c, src/vm/vm.c,
+       src/vmcore/Makefile.am, src/vmcore/class.c, src/vmcore/classcache.c,
+       src/vmcore/descriptor.c, src/vmcore/linker.c, src/vmcore/loader.c,
+       src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/resolve.c, src/vmcore/resolve.h,
+       src/vmcore/statistics.c, tests/regression/Makefile.am,
+       tests/regression/resolving/Makefile.am,
+       tests/regression/resolving/TestController.java,
+       tests/regression/resolving/TestLoader.java,
+       tests/regression/resolving/classes1/BarPassFoo.java,
+       tests/regression/resolving/classes1/BarUseFoo.java,
+       tests/regression/resolving/classes1/Foo.java,
+       tests/regression/resolving/classes1/Makefile.am,
+       tests/regression/resolving/classes2/BarPassFoo.java,
+       tests/regression/resolving/classes2/BarUseFoo.java,
+       tests/regression/resolving/classes2/DerivedFoo.java,
+       tests/regression/resolving/classes2/Foo.java,
+       tests/regression/resolving/classes2/Makefile.am,
+       tests/regression/resolving/classes3/BarPassFoo.java,
+       tests/regression/resolving/classes3/BarUseFoo.java,
+       tests/regression/resolving/classes3/DerivedFoo.java,
+       tests/regression/resolving/classes3/Foo.java,
+       tests/regression/resolving/classes3/Makefile.am,
+       tests/regression/resolving/test_instance_subtype_violated.java, test
+       s/regression/resolving/test_param_loading_constraint_violated.java, t
+       ests/regression/resolving/test_param_loading_constraint_violated_der
+       ived.java,
+       tests/regression/resolving/test_param_subtype_violated.java,
+       tests/regression/resolving/test_return_subtype_ok.java,
+       tests/regression/resolving/test_return_subtype_violated.java, tests/
+       regression/resolving/test_retval_loading_constraint_violated.java,
+       tests/regression/resolving/test_simple_lazy_load.java:
+       * Merged with trunk.
+       [ecc23547cf56]
+
+       * src/vm/jit/alpha/codegen.c:
+       * src/vm/jit/alpha/codegen.c (codegen_emit): Use label-branches.
+       [760b24bc4183]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h, src/vm/jit
+       /emit-common.c, src/vm/jit/emit-common.h:
+       * src/vm/jit/codegen-common.c (codegen_setup): Create brancheslabel
+       list. (codegen_reset): Likewise. (codegen_branch_label_add): New
+       function.
+
+       * src/vm/jit/codegen-common.h (codegendata): Added brancheslabel.
+       (branch_label_ref_t): New structure. (codegen_branch_label_add):
+       Added.
+
+       * src/vm/jit/emit-common.c (emit_label_bccz): New function.
+       (emit_label): Likewise. (emit_label_bcc): Likewise. (emit_label_br):
+       Likewise. (emit_label_beqz): Likewise. (emit_label_beq): Likewise.
+
+       * src/vm/jit/emit-common.h (BRANCH_LABEL_1, BRANCH_LABEL_2)
+       (BRANCH_LABEL_3, BRANCH_LABEL_4, BRANCH_LABEL_5): Defined.
+       (emit_label_bccz): Added. (emit_label): Likewise. (emit_label_bcc):
+       Likewise. (emit_label_br): Likewise. (emit_label_beqz): Likewise.
+       (emit_label_beq): Likewise.
+       [8a343a0e70e3]
+
+2007-03-08  michi  <michi>
+
+       * src/cacaoh/dummy.c, src/cacaoh/headers.c, src/mm/cacao-gc/rootset.c,
+       src/native/jni.c, src/native/native.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Thread.c,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/threads-common.c, src/vm/Makefile.am, src/vm/builtin.c,
+       src/vm/builtin.h, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/intrp/intrp.h,
+       src/vm/jit/intrp/patcher.c, src/vm/jit/jit.c, src/vm/jit/jit.h,
+       src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/replace.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md-
+       abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/patcher.c,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h,
+       src/vm/jit/sparc64/md-asm.h, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/stack.c, src/vm/jit/stacktrace.h, src/vm/jit/verify
+       /typecheck-typeinferer.c, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c,
+       src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c,
+       src/vm/jit_interface.h, src/vm/resolve.c, src/vm/resolve.h,
+       src/vm/signal.c, src/vm/vm.c, src/vmcore/Makefile.am,
+       src/vmcore/class.c, src/vmcore/descriptor.c, src/vmcore/linker.c,
+       src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h,
+       src/vmcore/options.c, src/vmcore/options.h, src/vmcore/resolve.c,
+       src/vmcore/resolve.h, src/vmcore/statistics.c,
+       tests/regression/resolving/Makefile.am,
+       tests/regression/resolving/classes2/BarPassFoo.java,
+       tests/regression/resolving/test_return_subtype_ok.java,
+       tests/regression/resolving/test_return_subtype_violated.java:
+       Merged revisions 7441-7480 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7442 | pm | 2007-03-03 00:28:37 +0100 (Sat, 03 Mar 2007)
+       | 8 lines
+
+        * src/vm/jit/s390/emit.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-asm.h,
+       src/vm/jit/s390/patcher.c, src/vm/jit/s390/asmpart.S: Changed a
+       lot in S390 codegen. ........ r7444 | edwin | 2007-03-04 13:28:37
+       +0100 (Sun, 04 Mar 2007) | 5 lines
+
+        * tests/regression/resolving/test_return_subtype_violated.java:
+       New test.
+
+        * tests/regression/resolving/Makefile.am: Added new test. ........
+       r7445 | edwin | 2007-03-04 13:32:59 +0100 (Sun, 04 Mar 2007) | 4
+       lines
+
+        * tests/regression/resolving/test_return_subtype_ok.java: New
+       test.
+
+        * tests/regression/resolving/Makefile.am: Added new test. ........
+       r7446 | edwin | 2007-03-04 15:02:49 +0100 (Sun, 04 Mar 2007) | 2
+       lines
+
+        * src/vm/jit/inline/inline.c: Committed breadth-first inlining
+       code. ........ r7447 | edwin | 2007-03-04 15:22:42 +0100 (Sun, 04
+       Mar 2007) | 6 lines
+
+        * src/vmcore/method.h (methodinfo): Added hitcountdown field.
+       (Only if ENABLE_REPLACEMENT).
+
+        * src/vmcore/loader.c (loader_load_method): Initialize
+       hitcountdown field. ........ r7448 | edwin | 2007-03-04 15:46:21
+       +0100 (Sun, 04 Mar 2007) | 5 lines
+
+        * src/vm/jit/i386/codegen.c (codegen): Emit code for countdown
+       traps.
+
+        * src/vm/jit/i386/emit.c (emit_replacement_stubs): Add jump
+       reference for countdown traps. ........ r7449 | twisti |
+       2007-03-04 19:07:55 +0100 (Sun, 04 Mar 2007) | 5 lines
+
+        * src/vm/jit/x86_64/emit.c (emit_load): Use switch-case instead of
+       if-else contruct. (emit_store): Likewise. (emit_copy): Likewise.
+       ........ r7450 | edwin | 2007-03-04 20:13:29 +0100 (Sun, 04 Mar
+       2007) | 8 lines
+
+        * src/vmcore/options.h, src/vmcore/options.c, src/vmcore/method.c,
+       src/vmcore/linker.c: Replayed lost parts of commit 7228.
+
+        * src/vm/jit/intrp/intrp.h: Added missing #include to make it
+       compile.
+
+        * src/vm/jit/inline/inline.c: Fixed names of vmcore/ #include
+       files. ........ r7451 | edwin | 2007-03-04 21:10:18 +0100 (Sun, 04
+       Mar 2007) | 7 lines
+
+        * src/vm/jit/replace.c: Handle countdown traps. Request
+       optimization of hot methods and their callers.
+
+        * src/vm/jit/jit.c (jit_compile): Set JITDATA_FLAG_COUNTDOWN for
+       inlining. (jit_recompile): Set JITDATA_FLAG_INLINE for inlining.
+       ........ r7453 | pm | 2007-03-05 09:38:29 +0100 (Mon, 05 Mar 2007)
+       | 8 lines
+
+        * src/vm/jit/s390/md-abi.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/patcher.c: Changed a
+       lot. ........ r7457 | edwin | 2007-03-05 17:53:45 +0100 (Mon, 05
+       Mar 2007) | 3 lines
+
+        * src/vmcore/resolve.h, src/vmcore/resolve.c
+       (resolve_classref_or_classinfo_eager): New function. ........
+       r7458 | edwin | 2007-03-05 18:32:38 +0100 (Mon, 05 Mar 2007) | 2
+       lines
+
+        * src/vm/jit/code.c (code_get_methodinfo_from_pv): New function.
+       ........ r7459 | edwin | 2007-03-05 18:34:43 +0100 (Mon, 05 Mar
+       2007) | 4 lines
+
+        * src/vm/builtin.h (builtintable_replace_function): Don't use
+       instruction * to avoid bootstrapping problems.
+         * src/vm/builtin.c (builtintable_replace_function): Likewise. ........
+       r7460 | edwin | 2007-03-05 18:44:20 +0100 (Mon, 05 Mar 2007) | 5
+       lines
+
+        * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getSuperclass),
+       (_Jv_java_lang_Class_getDeclaringClass)
+       (_Jv_java_lang_Class_getDeclaredClasses): Use
+       resolve_classref_or_classinfo_eager. ........ r7461 | edwin |
+       2007-03-06 00:50:33 +0100 (Tue, 06 Mar 2007) | 3 lines
+
+        * src/native/native.c (native_get_exceptiontypes): Use
+       resolve_classref_or_classinfo_eager. ........ r7462 | edwin |
+       2007-03-06 00:56:41 +0100 (Tue, 06 Mar 2007) | 2 lines
+
+        * src/cacaoh/headers.c: Don't include asmpart.h. ........ r7463
+       | edwin | 2007-03-06 01:02:04 +0100 (Tue, 06 Mar 2007) | 3 lines
+
+        * src/vmcore/linker.c (link_class_intern): Use
+       resolve_classref_or_classinfo_eager. ........ r7464 | edwin |
+       2007-03-06 01:26:31 +0100 (Tue, 06 Mar 2007) | 30 lines
+
+        * src/vmcore/resolve.c: Moved back to src/vm/resolve.c.
+         * src/vmcore/resolve.h: Moved back to src/vm/resolve.h.
+         * src/vm/jit/code.h (codeinfo): Moved typedef to method.h.
+       (code_get_methodinfo_for_pv): Added prototype.
+         * src/vmcore/method.h (codeinfo): Moved typedef here.
+
+        * src/vm/jit_interface.h: New file.
+
+        * src/vm/Makefile.am: Added resolve.[ch] and jit_interface.h.
+         * src/vmcore/Makefile.am: Removed resolve.[ch].
+
+        * src/vmcore/class.c: Include "arch.h", but don't include
+       "resolve.h".
+
+        * src/vmcore/method.c (method_vftbl_lookup): Use
+       code_get_methodinfo_for_pv.
+
+        * src/vmcore/linker.c (resolve_classref_or_classinfo_eager): Added
+       copy of prototype to avoid bootstrapping issues.
+
+        * src/cacaoh/dummy.c (code_get_methodinfo_for_pv): New dummy.
+       (resolve_classref_or_classinfo_eager): Simple implementation that
+       does not use resolve.c code. (typeinfo_init_class): Removed
+       dummy. (typeinfo_init_classinfo): Likewise.
+       (typeinfo_is_assignable_to_class): Likewise. (typeinfo_print):
+       Likewise.
+
+        * many other files: Changed #include "vmcore/resolve.h" to
+       "vm/resolve.h". ........ r7465 | edwin | 2007-03-06 01:27:12 +0100
+       (Tue, 06 Mar 2007) | 2 lines
+
+        * src/vm/jit_interface.h: Added Id keyword. ........ r7468 |
+       twisti | 2007-03-06 12:12:03 +0100 (Tue, 06 Mar 2007) | 11 lines
+
+        * src/vmcore/statistics.c (vm/jit/code.h): Added for codeinfo.
+       (vmcore/class.h): Added. (vmcore/field.h): Likewise.
+       (vmcore/method.h): Likewise.
+
+        * src/vm/jit/optimizing/recompile.c (vm/jit/code.h): Likewise.
+       (vm/jit/jit.h): Likewise.
+
+        * src/vm/jit/x86_64/md.c (vm/jit/codegen-common.h): Likewise.
+         * src/vm/jit/x86_64/md-abi.c (vm/jit/jit.h): Likewise. ........
+       r7470 | twisti | 2007-03-06 18:01:19 +0100 (Tue, 06 Mar 2007) | 6
+       lines
+
+        * src/vm/vm.c (vm_create): Reenabled signal-thread. This only
+       works on NPTL-threads and NOT with linuxthreads!
+
+        * src/vm/signal.c (signal_init): Reenabled blocking for SIGINT and
+       SIGQUIT. ........ r7471 | twisti | 2007-03-06 18:01:49 +0100 (Tue,
+       06 Mar 2007) | 2 lines
+
+        * src/vm/signal.c (arch.h): Added. ........ r7472 | ajordan |
+       2007-03-06 19:55:12 +0100 (Tue, 06 Mar 2007) | 10 lines
+
+        * src/vm/jit/sparc64/emit.c: emit_{load,store,copy} changed to
+       switch/case for handling different types.
+
+        * src/vm/jit/sparc64/codegen.h: fixed f2d and d2f conversion.
+
+        * src/vm/jit/sparc64/md-abi.c: removed md_native_reg_setup(), not
+       needed any longer.
+
+        * src/vm/jit/sparc64/codegen.c: implemented ICMD_MULTIANEWARRAY.
+       fixed FRETURN, DRETURN. repaired native float arg passing.
+       ........ r7473 | ajordan | 2007-03-07 01:32:35 +0100 (Wed, 07 Mar
+       2007) | 6 lines
+
+        * src/vm/jit/sparc64/md-abi.h: increased number of JIT float
+       argument registers to 5.
+         * src/vm/jit/sparc64/md-asm.h: likewise.
+         * src/vm/jit/sparc64/md-abi.c: likewise.
+
+        * src/vm/jit/sparc64/asmpart.S: added floating point argument
+       handling in asm_vm_call. ........ r7474 | michi | 2007-03-07
+       12:47:45 +0100 (Wed, 07 Mar 2007) | 9 lines
+
+        * src/threads/native/threads.h (threadobject): This structure is
+       no longer an instance of java.lang.Thread, but contains a
+       reference to it.
+
+        * src/threads/native/threads.c (threads_start_javathread): Added.
+
+        * src/threads/threads-common.c: Adapted to above changes.
+         * src/threads/native/threads.c: See above.
+         * src/native/vm/java_lang_Thread.c: See above. ........ r7475 |
+       twisti | 2007-03-07 13:37:34 +0100 (Wed, 07 Mar 2007) | 3 lines
+
+        * src/vm/jit/x86_64/asmpart.S (asm_compare_and_swap): New
+       function. (asm_memory_barrier): Likewise. ........ r7476 |
+       twisti | 2007-03-07 14:12:01 +0100 (Wed, 07 Mar 2007) | 2 lines
+
+        * src/vm/jit/x86_64/emit.c (emit_call_reg): Call emit_rex with
+       size 0. ........ r7477 | twisti | 2007-03-07 15:05:04 +0100 (Wed,
+       07 Mar 2007) | 2 lines
+
+        * src/vm/jit/mips/md.c (vm/jit/codegen-common.h): Temporarily
+       added. ........ r7478 | michi | 2007-03-08 03:59:31 +0100 (Thu, 08
+       Mar 2007) | 5 lines
+
+        * src/threads/native/threads.c (threads_init) [!ENABLE_GC_CACAO]:
+       Fixed bug for lost java.lang.Thread object of mainthread with
+       BoehmGC.
+
+        * src/native/vm/java_lang_Thread.c: Fixed includes to prevend
+       compiler warnings. ........
+       [d775c359cb66]
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/vm/jit/i386/linux
+       /md-os.c:
+       * src/vm/jit/i386/linux/md-os.c: Cleaned up.
+       * src/mm/cacao-gc/gc.h: Fixed includes.
+       * src/mm/cacao-gc/gc.c (gc_pending): Added global variable.
+       [c1f89c958f8d]
+
+2007-03-08  twisti  <twisti>
+
+       * src/mm/boehm.c, src/mm/cacao-gc/compact.c, src/mm/gc-common.h,
+       src/mm/memory.c, src/mm/memory.h, src/native/jni.h,
+       src/native/native.h,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/java_lang_ClassLoader.c, src/toolbox/list.c,
+       src/toolbox/list.h, src/vm/global.h, src/vm/jit/stacktrace.h,
+       src/vm/signallocal.h, src/vmcore/class.h, src/vmcore/classcache.h,
+       src/vmcore/loader.h, src/vmcore/rt-timing.c, src/vmcore/rt-timing.h:
+       * src/toolbox/list.c (list_remove): Call list_remove_unsynced.
+       (list_remove_unsynced): New function.
+
+       * src/toolbox/list.h (list_remove_unsynced): Added.
+       [b65a6efba3aa]
+
+2007-03-08  michi  <michi>
+
+       * configure.ac, src/cacaoh/headers.c, src/mm/cacao-gc/gc.h,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/vm/Makefile.am, src/vm/builtin.h,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/linux/md-os.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/intrp/intrp.h,
+       src/vm/jit/intrp/patcher.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390
+       /md-abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/stack.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c,
+       src/vm/jit/x86_64/md.c, src/vm/signal.c, src/vm/signallocal.h,
+       src/vmcore/classcache.c, src/vmcore/descriptor.c,
+       src/vmcore/options.c, src/vmcore/options.h, src/vmcore/statistics.c,
+       tests/regression/Makefile.am:
+       * src/mm/cacao-gc/gc.h (gc_suspend): Added prototype.
+
+       * src/vm/signale.c (signale_init) [ENABLE_GC_CACAO]: Handler for
+       SIGUSR1.
+       * src/vm/signallocal.h: Added prototype for SIGUSR1 handler.
+
+       * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigusr1): Added.
+       [186d485732de]
+
+2007-03-08  twisti  <twisti>
+
+       * src/native/vm/java_lang_Thread.c, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/vm/jit/alpha/arch.h,
+       src/vm/jit/alpha/codegen.h, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/emit-common.c, src/vm/jit/emit-common.h, src/vm/signal.c:
+       * src/vm/jit/alpha/codegen.h (M_INSTR_MEM_A): Renamed to
+       M_MEM_GET_A. (M_INSTR_MEM_B): Renamed to M_MEM_GET_B.
+       (M_INSTR_MEM_DISP): Renamed to M_MEM_GET_DISP.
+
+       * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv):
+       Likewise.
+
+       * src/vm/jit/alpha/arch.h
+       (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER): Defined.
+       (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER): Likewise.
+       (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Likewise.
+
+       * src/vm/jit/emit-common.c (arch.h): Added.
+       * src/vm/jit/emit-common.h (arch.h): Likewise.
+       [872d8003e23f]
+
+2007-03-08  michi  <michi>
+
+       * src/native/vm/java_lang_Thread.c, src/threads/native/threads.c:
+       * src/threads/native/threads.c (threads_init) [!ENABLE_GC_CACAO]:
+       Fixed bug for lost java.lang.Thread object of mainthread with
+       BoehmGC.
+
+       * src/native/vm/java_lang_Thread.c: Fixed includes to prevend
+       compiler warnings.
+       [41366642f3af]
+
+2007-03-07  twisti  <twisti>
+
+       * src/vm/jit/mips/md.c:
+       * src/vm/jit/mips/md.c (vm/jit/codegen-common.h): Temporarily added.
+       [58f73c63ef03]
+
+       * src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/x86_64/emit.c (emit_call_reg): Call emit_rex with size
+       0.
+       [f1b6321c7bea]
+
+       * src/vm/jit/x86_64/asmpart.S:
+       * src/vm/jit/x86_64/asmpart.S (asm_compare_and_swap): New function.
+       (asm_memory_barrier): Likewise.
+       [eab404e7f39b]
+
+2007-03-07  michi  <michi>
+
+       * src/native/vm/java_lang_Thread.c, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/threads-common.c:
+       * src/threads/native/threads.h (threadobject): This structure is no
+       longer an instance of java.lang.Thread, but contains a reference to
+       it.
+
+       * src/threads/native/threads.c (threads_start_javathread): Added.
+
+       * src/threads/threads-common.c: Adapted to above changes.
+       * src/threads/native/threads.c: See above.
+       * src/native/vm/java_lang_Thread.c: See above.
+       [e0154f388f07]
+
+2007-03-07  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/md-abi.c,
+       src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md-asm.h:
+       * src/vm/jit/sparc64/md-abi.h: increased number of JIT float
+       argument registers to 5.
+       * src/vm/jit/sparc64/md-asm.h: likewise.
+       * src/vm/jit/sparc64/md-abi.c: likewise.
+
+       * src/vm/jit/sparc64/asmpart.S: added floating point argument
+       handling in asm_vm_call.
+       [2ead47c5f866]
+
+2007-03-06  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md-abi.c:
+       * src/vm/jit/sparc64/emit.c: emit_{load,store,copy} changed to
+       switch/case for handling different types.
+
+       * src/vm/jit/sparc64/codegen.h: fixed f2d and d2f conversion.
+
+       * src/vm/jit/sparc64/md-abi.c: removed md_native_reg_setup(), not
+       needed any longer.
+
+       * src/vm/jit/sparc64/codegen.c: implemented ICMD_MULTIANEWARRAY.
+       fixed FRETURN, DRETURN. repaired native float arg passing.
+       [9980961f1055]
+
+2007-03-06  twisti  <twisti>
+
+       * src/vm/signal.c:
+       * src/vm/signal.c (arch.h): Added.
+       [3d116d2fe39a]
+
+       * src/vm/signal.c, src/vm/vm.c:
+       * src/vm/vm.c (vm_create): Reenabled signal-thread. This only works
+       on NPTL-threads and NOT with linuxthreads!
+
+       * src/vm/signal.c (signal_init): Reenabled blocking for SIGINT and
+       SIGQUIT.
+       [be5ff32af719]
+
+2007-03-06  tbfg  <tbfg>
+
+       * src/cacaoh/headers.c, src/native/native.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c, src/vm/Makefile.am,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/intrp/patcher.c,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/md.c, src/vm/jit/stack.c, src/vm/jit/verify
+       /typecheck-typeinferer.c, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/md-abi.c,
+       src/vm/jit/x86_64/md.c, src/vmcore/Makefile.am, src/vmcore/class.c,
+       src/vmcore/descriptor.c, src/vmcore/statistics.c:
+       * src/vm/jit/m68k/md.c (md_get_method_patch_address): Implemented.
+
+       * src/vm/jit/m68k/asmpart.S (call_jit_dummy): Dummy memory slot to
+       fake jit like invocation of asm_call_jit_compiler.
+
+       (asm_vm_call_method): Invoke jit compiler like from jitted code.
+       (asm_call_jit_compiler): Invoke compiled method.
+       [5cd56b546f0e]
+
+2007-03-06  twisti  <twisti>
+
+       * src/vm/jit/optimizing/recompile.c, src/vm/jit/x86_64/md-abi.c,
+       src/vm/jit/x86_64/md.c, src/vmcore/statistics.c:
+       * src/vmcore/statistics.c (vm/jit/code.h): Added for codeinfo.
+       (vmcore/class.h): Added. (vmcore/field.h): Likewise.
+       (vmcore/method.h): Likewise.
+
+       * src/vm/jit/optimizing/recompile.c (vm/jit/code.h): Likewise.
+       (vm/jit/jit.h): Likewise.
+
+       * src/vm/jit/x86_64/md.c (vm/jit/codegen-common.h): Likewise.
+       * src/vm/jit/x86_64/md-abi.c (vm/jit/jit.h): Likewise.
+       [846bb32a87d2]
+
+2007-03-06  michi  <michi>
+
+       * src/mm/cacao-gc/Makefile.am, src/mm/cacao-gc/copy.c, src/mm/cacao-
+       gc/copy.h, src/mm/cacao-gc/gc.c, src/mm/cacao-gc/heap.c:
+       * src/mm/cacao-gc/copy.c: Added file.
+       * src/mm/cacao-gc/copy.h: Added file.
+       * src/mm/cacao-gc/Makefile.am: See above.
+
+       * src/mm/cacao-gc/heap.c: Moved copy specific stuff to own file.
+
+       * src/mm/cacao-gc/gc.c: Now tests copy collections.
+       [57611210cc37]
+
+       * configure.ac, src/mm/cacao-gc/rootset.c, src/mm/cacao-gc/rootset.h,
+       src/vm/builtin.h, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/i386/emit.c,
+       src/vm/jit/x86_64/emit.c, src/vmcore/classcache.c,
+       tests/regression/Makefile.am:
+       Static class references are now explicitly added to the rootset.
+
+       * src/mm/cacao-gc/rootset.c (rootset_from_classes): Added.
+       * src/mm/cacao-gc/rootset.h (REFTYPE_CLASSREF): Added.
+       [2eb5b5cfca2f]
+
+2007-03-06  edwin  <edwin>
+
+       * src/vm/jit_interface.h:
+       * src/vm/jit_interface.h: Added Id keyword.
+       [920caf1ce50d]
+
+       * src/cacaoh/dummy.c, src/native/jni.c, src/native/native.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/java_lang_Class.c, src/vm/Makefile.am,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/patcher.c, src/vm/jit/code.h,
+       src/vm/jit/i386/patcher.c, src/vm/jit/intrp/intrp.h,
+       src/vm/jit/intrp/patcher.c, src/vm/jit/jit.h,
+       src/vm/jit/mips/patcher.c, src/vm/jit/parse.c,
+       src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/stack.c, src/vm/jit/verify/typecheck-typeinferer.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/jit_interface.h,
+       src/vm/resolve.c, src/vm/resolve.h, src/vmcore/Makefile.am,
+       src/vmcore/class.c, src/vmcore/descriptor.c, src/vmcore/linker.c,
+       src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h,
+       src/vmcore/resolve.c, src/vmcore/resolve.h:
+       * src/vmcore/resolve.c: Moved back to src/vm/resolve.c.
+       * src/vmcore/resolve.h: Moved back to src/vm/resolve.h.
+       * src/vm/jit/code.h (codeinfo): Moved typedef to method.h.
+       (code_get_methodinfo_for_pv): Added prototype.
+       * src/vmcore/method.h (codeinfo): Moved typedef here.
+
+       * src/vm/jit_interface.h: New file.
+
+       * src/vm/Makefile.am: Added resolve.[ch] and jit_interface.h.
+       * src/vmcore/Makefile.am: Removed resolve.[ch].
+
+       * src/vmcore/class.c: Include "arch.h", but don't include
+       "resolve.h".
+
+       * src/vmcore/method.c (method_vftbl_lookup): Use
+       code_get_methodinfo_for_pv.
+
+       * src/vmcore/linker.c (resolve_classref_or_classinfo_eager): Added
+       copy of prototype to avoid bootstrapping issues.
+
+       * src/cacaoh/dummy.c (code_get_methodinfo_for_pv): New dummy.
+       (resolve_classref_or_classinfo_eager): Simple implementation that
+       does not use resolve.c code. (typeinfo_init_class): Removed dummy.
+       (typeinfo_init_classinfo): Likewise.
+       (typeinfo_is_assignable_to_class): Likewise. (typeinfo_print):
+       Likewise.
+
+       * many other files: Changed #include "vmcore/resolve.h" to
+       "vm/resolve.h".
+       [a6ae28360f65]
+
+       * src/vmcore/linker.c:
+       * src/vmcore/linker.c (link_class_intern): Use
+       resolve_classref_or_classinfo_eager.
+       [8b56688900be]
+
+2007-03-05  edwin  <edwin>
+
+       * src/cacaoh/headers.c:
+       * src/cacaoh/headers.c: Don't include asmpart.h.
+       [899764f7a0ce]
+
+       * src/native/native.c:
+       * src/native/native.c (native_get_exceptiontypes): Use
+       resolve_classref_or_classinfo_eager.
+       [f5aff9934af5]
+
+       * src/native/vm/java_lang_Class.c:
+       * src/native/vm/java_lang_Class.c
+       (_Jv_java_lang_Class_getSuperclass),
+       (_Jv_java_lang_Class_getDeclaringClass)
+       (_Jv_java_lang_Class_getDeclaredClasses): Use
+       resolve_classref_or_classinfo_eager.
+       [1390ab8b3bd2]
+
+       * src/vm/builtin.c, src/vm/builtin.h:
+       * src/vm/builtin.h (builtintable_replace_function): Don't use
+       instruction * to avoid bootstrapping problems.
+       * src/vm/builtin.c (builtintable_replace_function): Likewise.
+       [19a54ed5e016]
+
+       * src/vm/jit/code.c:
+       * src/vm/jit/code.c (code_get_methodinfo_from_pv): New function.
+       [e6e6f9540e1e]
+
+       * src/vm/jit/i386/asmpart.S, src/vmcore/resolve.c,
+       src/vmcore/resolve.h:
+       * src/vmcore/resolve.h, src/vmcore/resolve.c
+       (resolve_classref_or_classinfo_eager): New function.
+       [3ead6ad73d97]
+
+2007-03-05  tbfg  <tbfg>
+
+       * src/vm/jit/abi.h, src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h,
+       src/vm/jit/m68k/md.c, src/vm/jit/reg.c, src/vmcore/descriptor.h:
+       * src/vm/jit/abi.h (HAS_ADDRESS_REGISTER_FILE): Include arch.h
+       (nregdescadr): Declare extern when HAS_ADDRESS_REGISTER_FILE.
+
+       * src/vm/jit/m68k/linux/md-abi.h (REF_FP): Added.
+
+       * src/vm/jit/m69k/linux/md-abi.c (nregdescadr): Fixed typo.
+       (md_param_alloc): Implemented.
+
+       * src/vm/jit/m68k/md.c (md_codegen_get_pv_from_pc): Implemented.
+       (md_stacktrace_get_returnaddress): Implemented.
+
+       * src/vm/jit/m68k/arch.h (HAS_ADDRESS_REGISTER_FILE): Defined.
+
+       * src/vm/jit/m68k/asmpart.S (asm_vm_call_method_end): Added.
+       (asm_call_jit_compiler): Implemented.
+
+       * src/vm/jit/reg.c (reg_setup): rd->adrreg_argnum is missing.
+
+       * src/vmcore/descriptor.h (arch.h): Included as needed for
+       HAS_ADDRESS_REGISTER_FILE.
+       [629a0a1b6da3]
+
+       * src/vm/jit/mips/asmpart.S, src/vm/jit/x86_64/asmpart.S:
+       * src/vm/jit/mips/asmpart.S (asm_vm_call_method_end): Added.
+       * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method_end): Added.
+       [781fb227cc5e]
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.h,
+       src/vm/jit/sparc64/asmpart.S:
+       * asmpart.h (asm_vm_call_method_end): Dummy method to readable mark
+       end of the asm_vm_call_method which is needed to insert it into avl
+       tree.
+
+       * codegen-common.c (codegen_init): Use asm_vm_call_method_end.
+
+       * arm/asmpart.S (asm_vm_call_method_end): Added.
+       * powerpc/asmpart.S (asm_vm_call_method_end): Added.
+       * sparc64/asmpart.S (asm_vm_call_method_end): Added.
+       * alpha/asmpart.S (asm_vm_call_method_end): Added.
+       * s390/asmpart.S (asm_vm_call_method_end): Added.
+       * powerpc64/asmpart.S (asm_vm_call_method_end): Added.
+       * i386/asmpart.S (asm_vm_call_method_end): Added.
+       [aa13999923b1]
+
+2007-03-05  pm  <pm>
+
+       * configure.ac, src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c,
+       src/vm/jit/codegen-common.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.h,
+       src/vm/jit/s390/patcher.c, src/vm/jit/x86_64/patcher.c,
+       src/vmcore/classcache.c, src/vmcore/resolve.c, src/vmcore/resolve.h,
+       tests/regression/Makefile.am:
+       * src/vm/jit/s390/md-abi.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/emit.h, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/patcher.c: Changed a lot.
+       [cb92a55875c8]
+
+2007-03-04  twisti  <twisti>
+
+       * src/mm/boehm.c, src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/vm/access.c, src/vm/access.h, src/vm/jit/i386/codegen.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/intrp/intrp.h,
+       src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/md-asm.h, src/vm/jit/stack.c,
+       src/vm/jit/verify/typecheck.c, src/vmcore/linker.c,
+       src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h,
+       src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/jit/powerpc64/linux/md-abi.c (regs): Renamed to
+       abi_registers_integer_name. (md_param_alloc_native): New function.
+
+       * src/vm/jit/powerpc64/emit.c (emit_verbosecall_enter): Replaced
+       builtin_trace_args with builtin_verbosecall_enter.
+       (emit_verbosecall_exit): Replaced builtin_displaymethodstop with
+       builtin_verbosecall_exit
+
+       * src/vm/jit/powerpc64/arch.h
+       (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER): Defined.
+       (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER): Likewise.
+       (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Likewise.
+       [8b515435fe56]
+
+2007-03-04  edwin  <edwin>
+
+       * src/vm/jit/jit.c, src/vm/jit/replace.c:
+       * src/vm/jit/replace.c: Handle countdown traps. Request optimization
+       of hot methods and their callers.
+
+       * src/vm/jit/jit.c (jit_compile): Set JITDATA_FLAG_COUNTDOWN for
+       inlining. (jit_recompile): Set JITDATA_FLAG_INLINE for inlining.
+       [25d019f7504b]
+
+       * src/vm/jit/inline/inline.c, src/vm/jit/intrp/intrp.h,
+       src/vmcore/linker.c, src/vmcore/method.c, src/vmcore/options.c,
+       src/vmcore/options.h:
+       * src/vmcore/options.h, src/vmcore/options.c, src/vmcore/method.c,
+       src/vmcore/linker.c: Replayed lost parts of commit 7228.
+
+       * src/vm/jit/intrp/intrp.h: Added missing #include to make it
+       compile.
+
+       * src/vm/jit/inline/inline.c: Fixed names of vmcore/ #include files.
+       [b12f334a12da]
+
+2007-03-04  twisti  <twisti>
+
+       * src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/x86_64/emit.c (emit_load): Use switch-case instead of
+       if-else contruct. (emit_store): Likewise. (emit_copy): Likewise.
+       [262f592df737]
+
+2007-03-04  edwin  <edwin>
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c:
+       * src/vm/jit/i386/codegen.c (codegen): Emit code for countdown
+       traps.
+
+       * src/vm/jit/i386/emit.c (emit_replacement_stubs): Add jump
+       reference for countdown traps.
+       [5fd5b2811199]
+
+       * src/vmcore/loader.c, src/vmcore/method.h:
+       * src/vmcore/method.h (methodinfo): Added hitcountdown field. (Only
+       if ENABLE_REPLACEMENT).
+
+       * src/vmcore/loader.c (loader_load_method): Initialize hitcountdown
+       field.
+       [efeadd853ac8]
+
+       * src/vm/jit/inline/inline.c:
+       * src/vm/jit/inline/inline.c: Committed breadth-first inlining code.
+       [38ec32d5f074]
+
+       * tests/regression/resolving/Makefile.am,
+       tests/regression/resolving/test_return_subtype_ok.java:
+       * tests/regression/resolving/test_return_subtype_ok.java: New test.
+
+       * tests/regression/resolving/Makefile.am: Added new test.
+       [7644200c297b]
+
+       * src/mm/boehm.c, tests/regression/resolving/Makefile.am,
+       tests/regression/resolving/classes2/BarPassFoo.java,
+       tests/regression/resolving/test_return_subtype_violated.java:
+       * tests/regression/resolving/test_return_subtype_violated.java: New
+       test.
+
+       * tests/regression/resolving/Makefile.am: Added new test.
+       [498b290fa85e]
+
+2007-03-03  michi  <michi>
+
+       * src/mm/boehm.c, src/mm/cacao-gc/heap.c, src/vm/jit/s390/emit.c,
+       src/vmcore/rt-timing.c, src/vmcore/rt-timing.h:
+       * src/vmcore/rt-timing.c: Added rt-timing for heap allocation time.
+       * src/vmcore/rt-timing.h: See above.
+
+       * src/mm/boehm.c (heap_allocate): Heap allocation time is measured.
+
+       * src/mm/cacao-gc/heap.c (heap_allocate): Heap allocation time is
+       measured.
+       [01335840ae08]
+
+2007-03-02  pm  <pm>
+
+       * configure.ac, src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/access.c,
+       src/vm/access.h, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/patcher.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md-asm.h,
+       src/vm/jit/s390/patcher.c, src/vm/jit/stack.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/x86_64/patcher.c,
+       src/vmcore/classcache.c, src/vmcore/resolve.c, src/vmcore/resolve.h,
+       tests/regression/Makefile.am:
+       * src/vm/jit/s390/emit.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-asm.h,
+       src/vm/jit/s390/patcher.c, src/vm/jit/s390/asmpart.S: Changed a lot
+       in S390 codegen.
+       [b5859fd89dd5]
+
+2007-03-02  michi  <michi>
+
+       * configure.ac, src/cacaoh/dummy.c, src/native/jni.c,
+       src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_ClassLoader.h, src/vm/access.c,
+       src/vm/access.h, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/arm/patcher.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/stack.c,
+       src/vm/jit/stacktrace.h, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/vm.c, src/vmcore/classcache.c,
+       src/vmcore/resolve.c, src/vmcore/resolve.h,
+       tests/regression/Makefile.am, tests/regression/jasmin/Makefile.am, t
+       ests/regression/jasmin/test_verify_ok_local_as_retaddr_and_reference
+       .j, tests/regression/resolving/Makefile.am,
+       tests/regression/resolving/TestController.java,
+       tests/regression/resolving/TestLoader.java,
+       tests/regression/resolving/classes1/BarPassFoo.java,
+       tests/regression/resolving/classes1/BarUseFoo.java,
+       tests/regression/resolving/classes1/Foo.java,
+       tests/regression/resolving/classes1/Makefile.am,
+       tests/regression/resolving/classes2/BarPassFoo.java,
+       tests/regression/resolving/classes2/BarUseFoo.java,
+       tests/regression/resolving/classes2/DerivedFoo.java,
+       tests/regression/resolving/classes2/Foo.java,
+       tests/regression/resolving/classes2/Makefile.am,
+       tests/regression/resolving/classes3/BarPassFoo.java,
+       tests/regression/resolving/classes3/BarUseFoo.java,
+       tests/regression/resolving/classes3/DerivedFoo.java,
+       tests/regression/resolving/classes3/Foo.java,
+       tests/regression/resolving/classes3/Makefile.am,
+       tests/regression/resolving/test_instance_subtype_violated.java, test
+       s/regression/resolving/test_param_loading_constraint_violated.java, t
+       ests/regression/resolving/test_param_loading_constraint_violated_der
+       ived.java,
+       tests/regression/resolving/test_param_subtype_violated.java, tests/r
+       egression/resolving/test_retval_loading_constraint_violated.java,
+       tests/regression/resolving/test_simple_lazy_load.java:
+       Merged revisions 7407-7440 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7408 | twisti | 2007-02-26 23:11:38 +0100 (Mon, 26 Feb
+       2007) | 15 lines
+
+        * src/native/vm/java_lang_ClassLoader.c: New file.
+         * src/native/vm/java_lang_ClassLoader.h: Likewise.
+
+        * src/native/vm/gnu/java_lang_VMClassLoader.c
+       (native/vm/java_lang_ClassLoader.h): Added. (defineClass): Removed
+       code and call _Jv_java_lang_ClassLoader_defineClass.
+
+        * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
+       java_lang_ClassLoader.[ch].
+
+        * src/native/jni.c [ENABLE_JAVASE]
+       (native/vm/java_lang_ClassLoader.h): Added. (_Jv_JNI_DefineClass):
+       Removed env and NULL arguments. ........ r7409 | ajordan |
+       2007-02-27 03:07:00 +0100 (Tue, 27 Feb 2007) | 8 lines
+
+        * configure.ac: added solaris specific stuff: arch defines,
+       libintl dependency and solaris subdir makefile.
+
+        * src/vm/jit/stacktrace.h: declared SPARC specific functions.
+
+        * src/vm/jit/sparc64/emit.c: fixed call to
+       builtin_verbosecall_exit.
+
+        * src/vm/jit/sparc64/solaris/md-os.c: signal handling disabled,
+       can't test right now. ........ r7412 | twisti | 2007-02-27
+       22:13:26 +0100 (Tue, 27 Feb 2007) | 2 lines
+
+        * src/vm/jit/sparc64/solaris: Set ignore-properties. ........
+       r7414 | pm | 2007-02-28 08:22:04 +0100 (Wed, 28 Feb 2007) | 5 lines
+
+        * src/vm/jit/s390/codegen.c (codegen): Added ICMD_AASTORE.
+         * src/vm/jit/s390/asmpart.S (asm_patcher_wrapper): Added exception
+       handler.
+         * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Likewise.
+       ........ r7415 | twisti | 2007-02-28 14:23:54 +0100 (Wed, 28 Feb
+       2007) | 3 lines
+
+        * src/native/vm/java_lang_ClassLoader.c (defineClass): Added
+       loader-variable for convenience. ........ r7416 | twisti |
+       2007-02-28 14:25:56 +0100 (Wed, 28 Feb 2007) | 2 lines
+
+        * src/native/vm/java_lang_ClassLoader.c (vm/stringlocal.h): Added.
+       ........ r7418 | twisti | 2007-02-28 21:07:06 +0100 (Wed, 28 Feb
+       2007) | 13 lines
+
+        * src/vm/access.c (access_check_caller): Renamed to
+       access_check_member. Don't call access_is_accessible_class, this is
+       wrong.
+
+        * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (constructNative): Use access_check_member.
+
+        * src/native/vm/gnu/java_lang_reflect_Field.c (CHECKFIELDACCESS):
+       Removed. (cacao_get_field_address): Use access_check_member.
+
+        * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative):
+       Likewise. ........ r7419 | twisti | 2007-02-28 23:00:50 +0100
+       (Wed, 28 Feb 2007) | 3 lines
+
+        * src/vm/access.h (access_check_caller): Renamed to
+       access_check_member. ........ r7420 | edwin | 2007-02-28 23:30:31
+       +0100 (Wed, 28 Feb 2007) | 3 lines
+
+        * src/vm/jit/stack.c (stack_analyse): Fix: reset TYPE_VOID to
+       TYPE_ADR at the end of stack_analyse. ........ r7421 | twisti |
+       2007-02-28 23:31:50 +0100 (Wed, 28 Feb 2007) | 4 lines
+
+        * src/vm/vm.c (vm_create): Changed initialization order. Call
+       properties_postinit later, since it puts a pointer to
+       _Jv_bootclasspath into the properties list. ........ r7422 | edwin
+       | 2007-02-28 23:50:28 +0100 (Wed, 28 Feb 2007) | 4 lines
+
+        * tests/regression/jasmin/test_verify_ok_local_as_retaddr_and_refe
+       rence.j: New test.
+         * tests/regression/jasmin/Makefile.am: Added new test. ........
+       r7423 | edwin | 2007-03-01 00:20:58 +0100 (Thu, 01 Mar 2007) | 2
+       lines
+
+        * src/vm/jit/stack.c (stack_analyse): Minor STACK_VERBOSE
+       improvements. ........ r7424 | edwin | 2007-03-01 00:27:15 +0100
+       (Thu, 01 Mar 2007) | 3 lines
+
+        * src/vm/jit/verify/typecheck.c (handle_basic_block): Move the
+       printing of the block to a point where jd->var is already valid.
+       ........ r7425 | twisti | 2007-03-01 00:39:48 +0100 (Thu, 01 Mar
+       2007) | 2 lines
+
+        * src/cacaoh/dummy.c (typeinfo_print): Added. ........ r7426 |
+       twisti | 2007-03-01 00:57:39 +0100 (Thu, 01 Mar 2007) | 5 lines
+
+        * src/vmcore/classcache.c (toolbox/logging.h): Added.
+       (classcache_merge_class_entries): Replace log_text with log_println.
+       (classcache_store): Likewise. (classcache_store_defined):
+       Likewise. ........ r7427 | edwin | 2007-03-01 13:32:10 +0100 (Thu,
+       01 Mar 2007) | 3 lines
+
+        * src/vmcore/resolve.c (resolve_classref_or_classinfo): Always use
+       refmethod->class as the referring class, if it is available.
+       ........ r7428 | twisti | 2007-03-01 13:39:45 +0100 (Thu, 01 Mar
+       2007) | 6 lines
+
+        * src/native/vm/Makefile.am [ENABLE_JAVASE] (CLASSLOADER_SOURCES):
+       Added. (libnativevm_la_SOURCES): Use CLASSLOADER_SOURCES.
+
+        * src/native/vm/java_lang_ClassLoader.c (native/jni.h): Added.
+       ........ r7431 | edwin | 2007-03-01 14:49:14 +0100 (Thu, 01 Mar
+       2007) | 14 lines
+
+        * src/vmcore/resolve.h, src/vmcore/resolve.c
+       (resolve_class_eager_no_access_check): New function.
+
+        * src/vm/jit/powerpc/patcher.c: Use
+       resolve_class_eager_no_access_check.
+         * src/vm/jit/arm/patcher.c: Likewise.
+         * src/vm/jit/sparc64/patcher.c: Likewise.
+         * src/vm/jit/alpha/patcher.c: Likewise.
+         * src/vm/jit/s390/patcher.c: Likewise.
+         * src/vm/jit/mips/patcher.c: Likewise.
+         * src/vm/jit/powerpc64/patcher.c: Likewise.
+         * src/vm/jit/i386/patcher.c: Likewise.
+         * src/vm/jit/x86_64/patcher.c: Likewise. ........ r7433 | edwin |
+       2007-03-02 20:42:13 +0100 (Fri, 02 Mar 2007) | 3 lines
+
+        * tests/regression/resolving: Added resolving test suite. These
+       tests check lazy loading, classloader handling, loading & subtype
+       constraints. ........ r7434 | edwin | 2007-03-02 20:44:53 +0100
+       (Fri, 02 Mar 2007) | 2 lines
+
+        * configure.ac: Added Makefiles of resolving test suite. ........
+       r7435 | edwin | 2007-03-02 20:45:42 +0100 (Fri, 02 Mar 2007) | 2
+       lines
+
+        * src/vmcore/classcache.c: Print debug messages to stdout.
+       ........
+       [16cce40a0a12]
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/heap.h, src/vmcore/rt-
+       timing.c, src/vmcore/rt-timing.h:
+       * src/vmcore/rt-timing.h: Added gc rt-timing defines.
+       * src/vmcore/rt-timing.c [ENABLE_GC_CACAO]: Added gc rt-timing
+       entries.
+       * src/mm/cacao-gc/gc.c: Added realtime-timing.
+
+       * src/mm/cacao-gc/heap.h: Removed unused global variables.
+       [3f7144c5e402]
+
+       * src/native/jni.c, src/native/jni.h:
+       * src/native/jni.h (hashtable_global_ref): Added.
+       * src/native/jni.c (hashtable_global_ref): Made non-static for the
+       exact gc.
+       [369806a4aae8]
+
+       * src/mm/cacao-gc/rootset.c:
+       * src/mm/cacao-gc/rootset.c [!ENABLE_THREADS]: Now compiles again.
+       [d942f1db75bc]
+
+       * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/gc.h, src/mm/cacao-
+       gc/heap.c, src/mm/cacao-gc/mark.c, src/vm/global.h,
+       src/vm/jit/arm/patcher.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/x86_64/patcher.c,
+       tests/regression/Makefile.am:
+       * src/vm/global.h (HDRFLAG_REFERENCING): Added.
+
+       * src/mm/cacao-gc/heap.c: Sets above header flag now.
+       * src/mm/cacao-gc/compact.c: Check for above header flag now.
+       * src/mm/cacao-gc/mark.c: See above.
+
+       * src/mm/cacao-gc/gc.h: Added configuration define for the above
+       behavior.
+       [080b239a5aaa]
+
+2007-03-02  tbfg  <tbfg>
+
+       * configure.ac, src/vm/jit/arm/patcher.c, src/vm/jit/disass-common.c,
+       src/vm/jit/disass.h, src/vm/jit/i386/patcher.c,
+       src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/disass.c,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/emit.h,
+       src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/x86_64/patcher.c, src/vmcore/classcache.c,
+       src/vmcore/resolve.c, src/vmcore/resolve.h,
+       tests/regression/Makefile.am:
+       * src/vm/jit/disass-common.c(disass_buf): Enabled for m68k.
+
+       * src/vm/jit/disass.h(disass_buf): Likewise.
+
+       * src/vm/jit/m68k/linux/md-abi.c(nregdescaddr): Added.
+
+       * src/vm/jit/m68k/emit.c(emit_jsr): Added. (emit_jmp): Added.
+       (emit_store): Added. (emit_load): Added. (emit_load_low): Added.
+       (emit_load_high): Added. (emit_branch): Added.
+       (emit_verbosecall_enter): Added. (emit_verbosecall_exit): Added.
+
+       * src/vm/jit/m68k/emit.h: Like emit.c
+
+       * src/vm/jit/m68k/codegen.c(codegen_emit): Some dummy code added.
+       (createnativestub): Likewise.
+
+       * src/vm/jit/m68k/disass.c(disassinstr): Implemented and tested.
+
+       * src/vm/jit/m68k/asmpart.S(asm_vm_call_method): Implemented
+       argument passing.
+
+       * src/vm/jit/m68k/codegen.h(M_ILLEGAL): Added. (M_PUSH): Likewise.
+       (M_APUSH): Likewise. (M_POP): Likewise. (M_APOP): Likewise. (M_JMP):
+       Likewise. (M_JSR): Likewise.
+
+       * configure.ac (ENABLE_DISASSEMBLER): Enabled for m68k.
+       [bac4f948b59c]
+
+2007-03-02  edwin  <edwin>
+
+       * src/vmcore/classcache.c:
+       * src/vmcore/classcache.c: Print debug messages to stdout.
+       [ba6016da118e]
+
+       * configure.ac:
+       * configure.ac: Added Makefiles of resolving test suite.
+       [4313663128f6]
+
+       * tests/regression/Makefile.am,
+       tests/regression/resolving/Makefile.am,
+       tests/regression/resolving/TestController.java,
+       tests/regression/resolving/TestLoader.java,
+       tests/regression/resolving/classes1/BarPassFoo.java,
+       tests/regression/resolving/classes1/BarUseFoo.java,
+       tests/regression/resolving/classes1/Foo.java,
+       tests/regression/resolving/classes1/Makefile.am,
+       tests/regression/resolving/classes2/BarPassFoo.java,
+       tests/regression/resolving/classes2/BarUseFoo.java,
+       tests/regression/resolving/classes2/DerivedFoo.java,
+       tests/regression/resolving/classes2/Foo.java,
+       tests/regression/resolving/classes2/Makefile.am,
+       tests/regression/resolving/classes3/BarPassFoo.java,
+       tests/regression/resolving/classes3/BarUseFoo.java,
+       tests/regression/resolving/classes3/DerivedFoo.java,
+       tests/regression/resolving/classes3/Foo.java,
+       tests/regression/resolving/classes3/Makefile.am,
+       tests/regression/resolving/test_instance_subtype_violated.java, test
+       s/regression/resolving/test_param_loading_constraint_violated.java, t
+       ests/regression/resolving/test_param_loading_constraint_violated_der
+       ived.java,
+       tests/regression/resolving/test_param_subtype_violated.java, tests/r
+       egression/resolving/test_retval_loading_constraint_violated.java,
+       tests/regression/resolving/test_simple_lazy_load.java:
+       * tests/regression/resolving: Added resolving test suite. These
+       tests check lazy loading, classloader handling, loading & subtype
+       constraints.
+       [cdc72aade335]
+
+2007-03-02  michi  <michi>
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/rootset.c, src/mm/cacao-
+       gc/rootset.h:
+       * src/mm/cacao-gc/gc.c (gc_collect): Moved rootset creation to
+       rootset_readout.
+       * src/mm/cacao-gc/rootset.c (rootset_readout): Added
+
+       * src/mm/cacao-gc/rootset.c (rootset_from_globals): Now adds
+       threadobjects and global references.
+
+       * src/mm/cacao-gc/rootset.h: Added refs_type field to rootset.
+       [ad0c808325c4]
+
+2007-03-01  edwin  <edwin>
+
+       * src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c, src/vm/jit
+       /codegen-common.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/sparc64/patcher.c, src/vm/jit/x86_64/patcher.c,
+       src/vmcore/resolve.c, src/vmcore/resolve.h:
+       * src/vmcore/resolve.h, src/vmcore/resolve.c
+       (resolve_class_eager_no_access_check): New function.
+
+       * src/vm/jit/powerpc/patcher.c: Use
+       resolve_class_eager_no_access_check.
+       * src/vm/jit/arm/patcher.c: Likewise.
+       * src/vm/jit/sparc64/patcher.c: Likewise.
+       * src/vm/jit/alpha/patcher.c: Likewise.
+       * src/vm/jit/s390/patcher.c: Likewise.
+       * src/vm/jit/mips/patcher.c: Likewise.
+       * src/vm/jit/powerpc64/patcher.c: Likewise.
+       * src/vm/jit/i386/patcher.c: Likewise.
+       * src/vm/jit/x86_64/patcher.c: Likewise.
+       [188ce45e94a5]
+
+2007-03-01  michi  <michi>
+
+       * src/mm/cacao-gc/mark.c, src/vm/jit/codegen-common.c:
+       * src/mm/cacao-gc/mark.c (mark_me): Fixed a bug for "outside
+       pointers".
+       [00cb4e70477b]
+
+2007-03-01  twisti  <twisti>
+
+       * src/cacaoh/dummy.c, src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/access.c,
+       src/vm/access.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/stack.c,
+       src/vm/jit/verify/typecheck.c, src/vm/vm.c,
+       tests/regression/jasmin/Makefile.am:
+       * Merged with trunk.
+       [39040c757ae6]
+
+       * src/native/vm/Makefile.am, src/native/vm/java_lang_ClassLoader.c:
+       * src/native/vm/Makefile.am [ENABLE_JAVASE] (CLASSLOADER_SOURCES):
+       Added. (libnativevm_la_SOURCES): Use CLASSLOADER_SOURCES.
+
+       * src/native/vm/java_lang_ClassLoader.c (native/jni.h): Added.
+       [020ca26f54f1]
+
+2007-03-01  edwin  <edwin>
+
+       * src/vmcore/resolve.c:
+       * src/vmcore/resolve.c (resolve_classref_or_classinfo): Always use
+       refmethod->class as the referring class, if it is available.
+       [a671bb862433]
+
+2007-02-28  twisti  <twisti>
+
+       * src/vmcore/classcache.c:
+       * src/vmcore/classcache.c (toolbox/logging.h): Added.
+       (classcache_merge_class_entries): Replace log_text with log_println.
+       (classcache_store): Likewise. (classcache_store_defined): Likewise.
+       [5c13c1877eaf]
+
+       * src/cacaoh/dummy.c:
+       * src/cacaoh/dummy.c (typeinfo_print): Added.
+       [269225303ad5]
+
+2007-02-28  edwin  <edwin>
+
+       * src/vm/jit/verify/typecheck.c:
+       * src/vm/jit/verify/typecheck.c (handle_basic_block): Move the
+       printing of the block to a point where jd->var is already valid.
+       [23c03d745eca]
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_analyse): Minor STACK_VERBOSE
+       improvements.
+       [1c941917218d]
+
+       * tests/regression/jasmin/Makefile.am, tests/regression/jasmin/test_ve
+       rify_ok_local_as_retaddr_and_reference.j:
+       * tests/regression/jasmin/test_verify_ok_local_as_retaddr_and_refere
+       nce.j: New test.
+       * tests/regression/jasmin/Makefile.am: Added new test.
+       [fe03a2bb9cf6]
+
+2007-02-28  twisti  <twisti>
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_create): Changed initialization order. Call
+       properties_postinit later, since it puts a pointer to
+       _Jv_bootclasspath into the properties list.
+       [61e332c57634]
+
+2007-02-28  edwin  <edwin>
+
+       * src/vm/jit/stack.c:
+       * src/vm/jit/stack.c (stack_analyse): Fix: reset TYPE_VOID to
+       TYPE_ADR at the end of stack_analyse.
+       [5042bb6ae3af]
+
+2007-02-28  twisti  <twisti>
+
+       * src/vm/access.h:
+       * src/vm/access.h (access_check_caller): Renamed to
+       access_check_member.
+       [96cd6de1d0b8]
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/access.c:
+       * src/vm/access.c (access_check_caller): Renamed to
+       access_check_member. Don't call access_is_accessible_class, this is
+       wrong.
+
+       * src/native/vm/gnu/java_lang_reflect_Constructor.c
+       (constructNative): Use access_check_member.
+
+       * src/native/vm/gnu/java_lang_reflect_Field.c (CHECKFIELDACCESS):
+       Removed. (cacao_get_field_address): Use access_check_member.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative):
+       Likewise.
+       [a0b49cb1bccc]
+
+2007-02-28  michi  <michi>
+
+       * src/mm/cacao-gc/mark.c, src/vm/jit/codegen-common.c:
+       * src/mm/cacao-gc/mark.c: Added MARK() as helper macro.
+       [2994cd00c958]
+
+2007-02-28  twisti  <twisti>
+
+       * src/native/vm/java_lang_ClassLoader.c:
+       * src/native/vm/java_lang_ClassLoader.c (vm/stringlocal.h): Added.
+       [3c44ad680b4b]
+
+       * src/native/vm/java_lang_ClassLoader.c:
+       * src/native/vm/java_lang_ClassLoader.c (defineClass): Added loader-
+       variable for convenience.
+       [de55c5da2485]
+
+2007-02-28  pm  <pm>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c:
+       * src/vm/jit/s390/codegen.c (codegen): Added ICMD_AASTORE.
+       * src/vm/jit/s390/asmpart.S (asm_patcher_wrapper): Added exception
+       handler.
+       * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Likewise.
+       [6e6fd1de31b1]
+
+2007-02-27  twisti  <twisti>
+
+       * configure.ac, src/native/Makefile.am, src/native/jni.c,
+       src/native/vm/Makefile.am, src/vm/exceptions.c, src/vm/global.h,
+       src/vm/jit/codegen-common.c, src/vm/jit/replace.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-asm.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/solaris/md-os.c,
+       src/vm/jit/stacktrace.h, src/vm/vm.c, src/vmcore/class.h:
+       * Merged with trunk.
+       [8277a27cd172]
+
+       * * src/vm/jit/sparc64/solaris: Set ignore-properties.
+       [89b8897dd615]
+
+2007-02-27  michi  <michi>
+
+       * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/gc.h:
+       * src/mm/cacao-gc/gc.h: Fixed typo in POINTS_INTO.
+       * src/mm/cacao-gc/compact.c (compact_move): Fixed typo.
+       [f17d8ca4a302]
+
+       * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h:
+       * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/gc.c: Added define
+       (GCCONF_FINALIZER) to disable finalization.
+       [e15792241f6f]
+
+2007-02-27  ajordan  <ajordan>
+
+       * configure.ac, src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/solaris
+       /md-os.c, src/vm/jit/stacktrace.h:
+       * configure.ac: added solaris specific stuff: arch defines, libintl
+       dependency and solaris subdir makefile.
+
+       * src/vm/jit/stacktrace.h: declared SPARC specific functions.
+
+       * src/vm/jit/sparc64/emit.c: fixed call to builtin_verbosecall_exit.
+
+       * src/vm/jit/sparc64/solaris/md-os.c: signal handling disabled,
+       can't test right now.
+       [9ae2ff45937d]
+
+2007-02-26  twisti  <twisti>
+
+       * src/native/jni.c, src/native/vm/Makefile.am,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/java_lang_ClassLoader.c,
+       src/native/vm/java_lang_ClassLoader.h, src/vm/jit/codegen-common.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390
+       /md-asm.h, src/vmcore/zip.c:
+       * src/native/vm/java_lang_ClassLoader.c: New file.
+       * src/native/vm/java_lang_ClassLoader.h: Likewise.
+
+       * src/native/vm/gnu/java_lang_VMClassLoader.c
+       (native/vm/java_lang_ClassLoader.h): Added. (defineClass): Removed
+       code and call _Jv_java_lang_ClassLoader_defineClass.
+
+       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
+       java_lang_ClassLoader.[ch].
+
+       * src/native/jni.c [ENABLE_JAVASE]
+       (native/vm/java_lang_ClassLoader.h): Added. (_Jv_JNI_DefineClass):
+       Removed env and NULL arguments.
+       [f4e073f67460]
+
+2007-02-26  michi  <michi>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md-asm.h,
+       src/vmcore/zip.c:
+       Merged revisions 7390-7406 via svnmerge from
+       svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk
+
+       ........ r7395 | michi | 2007-02-23 23:57:53 +0100 (Fri, 23 Feb
+       2007) | 2 lines
+
+        * src/vm/jit/replace.c: Renamed regs to
+       abi_registers_integer_name. ........ r7402 | twisti | 2007-02-24
+       15:47:12 +0100 (Sat, 24 Feb 2007) | 4 lines
+
+        * src/vmcore/zip.c (errno.h): Added. (vm/vm.h): Likewise.
+       (zip_get): Replaced asserts with vm_abort. ........ r7403 | pm |
+       2007-02-25 22:31:58 +0100 (Sun, 25 Feb 2007) | 6 lines
+
+        * src/vm/jit/codegen-common.c (methodtree_comparator): Fixed S390
+       related comment.
+         * src/vm/jit/s390/codegen.h: Fixed M_JSR macro, did not store RA.
+         * src/vm/jit/s390/md-asm.h: Added (LOAD|STORE)_TEMPORARY_REGISTERS and
+       (LOAD|STORE)_ARGUMENT_REGISTERS macros.
+         * src/vm/jit/s390/asmpart.S: Implemented asm_handle_exception and
+       asm_vm_call_method_exception_handler.
+         * src/vm/jit/s390/md-abi.c (abi_registers_integer_temporary): did not
+       contain %r0, added. ........ r7404 | pm | 2007-02-25 23:02:16
+       +0100 (Sun, 25 Feb 2007) | 2 lines
+
+        * src/vm/jit/s390/asmpart.S (asm_getclassvalues_atomic,
+       asm_criticalsections): Added. ........ r7405 | pm | 2007-02-25
+       23:34:27 +0100 (Sun, 25 Feb 2007) | 3 lines
+
+        * src/vm/jit/s390/codegen.c (codegen): Fixed ICMD_IF_ACMPNE
+         * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Handling NULL
+       return value of jit_asm_compile. ........
+       [1b285f944716]
+
+       * src/mm/cacao-gc/Makefile.am, src/mm/cacao-gc/compact.c, src/mm
+       /cacao-gc/final.c, src/mm/cacao-gc/final.h, src/mm/cacao-gc/gc.c,
+       src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao-
+       gc/heap.h, src/mm/cacao-gc/mark.c, src/mm/cacao-gc/mark.h, src/mm
+       /cacao-gc/rootset.c, src/mm/cacao-gc/rootset.h, src/vm/jit/s390/md-
+       asm.h:
+       * src/mm/cacao-gc/final.h, src/mm/cacao-gc/final.c, src/mm/cacao-
+       gc/rootset.h, src/mm/cacao-gc/rootset.c: Added.
+       * src/mm/cacao-gc/Makefile.am: See above.
+
+       * src/mm/cacao-gc/gc.h (gc_notify_finalizer): Added.
+       * src/mm/cacao-gc/gc.c: Added finalization support.
+       * src/mm/cacao-gc/mark.c: Same as above. Rootset can contain "non-
+       marking" references now.
+
+       * src/mm/cacao-gc/heap.h, src/mm/cacao-gc/heap.c: Severe code
+       cleanup, this applies to almost all files.
+       [1fcc2ed6373c]
+
+2007-02-25  pm  <pm>
+
+       * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c:
+       * src/vm/jit/s390/codegen.c (codegen): Fixed ICMD_IF_ACMPNE
+       * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Handling NULL
+       return value of jit_asm_compile.
+       [4d4b8ff67e86]
+
+       * src/vm/jit/s390/asmpart.S:
+       * src/vm/jit/s390/asmpart.S (asm_getclassvalues_atomic,
+       asm_criticalsections): Added.
+       [081c95d4a439]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390
+       /md-asm.h:
+       * src/vm/jit/codegen-common.c (methodtree_comparator): Fixed S390
+       related comment.
+       * src/vm/jit/s390/codegen.h: Fixed M_JSR macro, did not store RA.
+       * src/vm/jit/s390/md-asm.h: Added (LOAD|STORE)_TEMPORARY_REGISTERS and
+       (LOAD|STORE)_ARGUMENT_REGISTERS macros.
+       * src/vm/jit/s390/asmpart.S: Implemented asm_handle_exception and
+       asm_vm_call_method_exception_handler.
+       * src/vm/jit/s390/md-abi.c (abi_registers_integer_temporary): did not
+       contain %r0, added.
+       [ac2af54a65da]
+
+2007-02-24  twisti  <twisti>
+
+       * src/vmcore/class.h, src/vmcore/zip.c:
+       * src/vmcore/zip.c (errno.h): Added. (vm/vm.h): Likewise. (zip_get):
+       Replaced asserts with vm_abort.
+       [4921b203cfdc]
+
+2007-02-24  michi  <michi>
+
+       * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/gc.c, src/mm/cacao-
+       gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao-gc/mark.c, src/mm
+       /cacao-gc/region.h:
+       * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/compact.c, src/mm/cacao-
+       gc/region.h, src/mm/cacao-gc/gc.c, src/mm/cacao-gc/mark.c, src/mm
+       /cacao-gc/heap.c: Severe code cleanup.
+       [a8c4d7afe6d8]
+
+       * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/heap.c, src/mm/cacao-
+       gc/heap.h, src/vm/global.h:
+       * src/vm/global.h: Added defines HDRFLAG_HASH_TAKEN and
+       HDRFLAG_HASH_ATTACHED.
+
+       * src/mm/cacao-gc/compact.c (compact_move): Hashcode gets attached
+       to objects while moving if previously taken.
+
+       * src/mm/cacao-gc/heap.c (get_object_size): Attached hashcode might
+       increase object size.
+       [c436d5e47cfa]
+
+2007-02-23  michi  <michi>
+
+       * src/native/native.c,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMSystem.c,
+       src/native/vm/java_lang_Class.c, src/vm/vm.c, src/vmcore/class.c,
+       src/vmcore/class.h, src/vmcore/classcache.h, src/vmcore/loader.c,
+       src/vmcore/loader.h:
+       * src/vm/vm.c [ENABLE_GC_CACAO]: Added assertion for JVMTI.
+
+       * src/vmcore/loader.h (classloader): Added this typedef, use it to
+       represent the indirection cell for a classloader.
+
+       * src/vmcore/class.h (classinfo): Classloaders are now represendet
+       as indirection cells.
+
+       * src/vmcore/loader.c, src/vmcore/class.c, src/vmcore/classcache.h,
+       src/native/native.c, src/native/vm/java_lang_Class.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/java_lang_VMSystem.c: Adapted to above changes.
+       [de2f4c3ac2f3]
+
+       * src/mm/cacao-gc/Makefile.am, src/mm/cacao-gc/compact.c, src/mm
+       /cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm
+       /cacao-gc/heap.h, src/mm/cacao-gc/mark.c, src/mm/cacao-gc/mark.h,
+       src/mm/cacao-gc/region.c, src/mm/cacao-gc/region.h:
+       * src/mm/cacao-gc/mark.h, src/mm/cacao-gc/heap.h, src/mm/cacao-
+       gc/heap.c, src/mm/cacao-gc/region.h, src/mm/cacao-gc/region.c:
+       Added.
+
+       * src/mm/cacao-gc/Makefile.am: See above.
+
+       * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/gc.c: Moved development
+       breaks. (gc_collect): Added.
+
+       * src/mm/cacao-gc/compact.c: Classloaders are threaded in now.
+       (compact_move): Fixed a severe typo.
+       [749fb93803aa]
+
+       * src/vm/global.h:
+       * src/vm/global.h: Added defines for HDRFLAG_MARK1, HDRFLAG_MARK2
+       and HDRFLAG_UNCOLLECTABLE.
+       [3f9744e458be]
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/replace.c,
+       src/vm/jit/stacktrace.h:
+       * src/vm/jit/i386/codegen.c (createnativestub) [ENABLE_GC_CACAO]:
+       Saved registers are now stored/recovered into/from the
+       stackframeinfo struct.
+
+       * src/vm/jit/replace.c (replace_pop_native_frame,
+       replace_push_native_frame) [ENABLE_GC_CACAO]: Handle saved registers
+       in the stackframeinfo struct now.
+
+       * src/vm/jit/stacktrace.h [ENABLE_GC_CACAO]: Modified stackframeinfo
+       struct accordingly.
+       [4ab276d7b9bb]
+
+       * src/vm/jit/replace.c:
+       * src/vm/jit/replace.c: Renamed regs to abi_registers_integer_name.
+       [6fe203d50ca4]
+
+       * src/mm/memory.c, src/mm/memory.h:
+       * src/mm/memory.c, src/mm/memory.h: Moved defines for memcheck into
+       header file.
+       [0d3eb975b96c]
+
+       * src/cacaoh/dummy.c, src/native/native.c, src/native/native.h,
+       src/vmcore/loader.c, src/vmcore/loader.h:
+       * src/native/native.h (hashtable_library_loader_entry): Uses
+       indirection cells.
+       * src/native/native.c (native_hashtable_library_add): Uses indirection
+       cells. (native_hashtable_library_find): Uses indirection cells.
+
+       * src/vmcore/loader.h (hashtable_classloader_entry): Added to
+       represent indirection cells.
+       * src/vmcore/loader.c (hashtable_classloader): Added to hold
+       indirection cells. (loader_hashtable_classloader_add,
+       loader_hashtable_classloader_find): Added.
+
+       * src/cacaoh/dummy.c (heap_get_hashcode): Added.
+       [3ed9616c49da]
+
+       * src/native/jni.c:
+       * src/native/jni.c (jni_free_localref_table): Added.
+       * src/native/jni.c [ENABLE_GC_CACAO]: The localref_table is no longer
+       put onto the heap, but managed explicitly.
+       [e4b9c076da31]
+
+       * src/mm/gc-common.h, src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/gnu/java_lang_VMSystem.c:
+       * src/mm/gc-common.h [ENABLE_GC_CACAO]: Added prototype for
+       heap_get_hashcode().
+       * src/native/vm/gnu/java_lang_VMSystem.c [ENABLE_GC_CACAO]: Uses new
+       method to get hashcodes for objects.
+       * src/native/vm/cldc1.1/java_lang_Object.c [ENABLE_GC_CACAO]: Don't
+       know if we can use this here.
+       [d82b09b9957d]
+
+2007-02-21  twisti  <twisti>
+
+       * src/vm/global.h, src/vmcore/class.c, src/vmcore/loader.c,
+       src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/vm/global.h (ACC_CLASS_SOFT_REFERENCE,
+       ACC_CLASS_WEAK_REFERENCE) (ACC_CLASS_PHANTOM_REFERENCE): Added.
+
+       * src/vmcore/class.c (class_create_classinfo) [ENABLE_JAVASE]: Check
+       if the class is a reference class and flag it.
+
+       * src/vmcore/loader.c (load_class_from_classbuffer): OR the flags
+       loaded.
+
+       * src/vmcore/utf8.c (utf_java_lang_ref_SoftReference)
+       (utf_java_lang_ref_WeakReference,
+       utf_java_lang_ref_PhantomReference): Added. (utf8_init): Initialize
+       added variables.
+       * src/vmcore/utf8.h: Likewise.
+       [417471e88036]
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_throw_noclassdeffounderror): Abort
+       when VM is initializing.
+       [b40a83ba8073]
+
+2007-02-21  pm  <pm>
+
+       * src/vm/jit/s390/codegen.c:
+       * src/vm/jit/s390/codegen.c (codegen): allocate register save area
+       required by C abi for builtin calls
+       * src/vm/jit/s390/codegen.c (createnativestub): fix errornous code
+       generated for return, fix datasp argument to
+       codegen_finish_native_call
+       [9f5b283b0aac]
+
+2007-02-21  twisti  <twisti>
+
+       * m4/jni.m4, src/native/Makefile.am, src/native/jni.c, src/vm/vm.c:
+       * m4/jni.m4: Added ENABLE_JNI AM_CONDITIONAL.
+
+       * src/vm/vm.c (vm_createjvm): Replaced some ENABLE_JAVASE with
+       ENABLE_JNI. (vm_create): Likewise.
+
+       * src/native/Makefile.am: Likewise.
+
+       * src/native/jni.c (jni_init) [ENABLE_JAVASE]: ifdef'ed Java SE
+       stuff. (_Jv_JNI_DefineClass) [!ENABLE_JAVASE]: Abort.
+       (_Jv_JNI_FindClass): Likewise. (_Jv_JNI_FromReflectedMethod):
+       Likewise. (_Jv_JNI_FromReflectedField): Likewise.
+       (_Jv_JNI_NewDirectByteBuffer): Likewise.
+       (_Jv_JNI_GetDirectBufferAddress): Likewise.
+       (_Jv_JNI_GetDirectBufferCapacity): Likewise.
+       (_Jv_JNI_IsAssignableFrom): Call
+       _Jv_java_lang_Class_isAssignableFrom. (_Jv_JNI_IsInstanceOf): Call
+       _Jv_java_lang_Class_isInstance. (_Jv_JNI_EnsureLocalCapacity):
+       Removed debug output.
+       [6a87404455be]
+
+       * configure.ac, src/native/include/Makefile.am,
+       src/native/vm/cldc1.1/Makefile.am,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/java_lang_Runtime.c,
+       src/native/vm/java_lang_Runtime.h, src/vm/jit/Makefile.am,
+       src/vm/jit/abi-asm.h, src/vm/jit/disass-common.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/patcher.c,
+       src/vm/jit/x86_64/md-abi.c:
+       * Merged with trunk.
+       [0f801edae0f9]
+
+       * src/vm/jit/Makefile.am, src/vm/jit/disass-common.c:
+       * src/vm/jit/Makefile.am [!WITH_BINUTILS_DISASSEMBLER]
+       (DISASS_SOURCES): Removed.
+
+       * src/vm/jit/disass-common.c: Removed WITH_BINUTILS_DISASSEMBLER
+       ifdefs, since it's compiled conditionally.
+       [68009c60134a]
+
+       * src/vm/jit/x86_64/md-abi.c:
+       * src/vm/jit/x86_64/md-abi.c (regs): Renamed to
+       abi_registers_integer_name. (md_param_alloc): Made code more clear.
+       (md_param_alloc_native): New function.
+       [cebe1d53aed3]
+
+       * src/vm/jit/abi-asm.h:
+       * src/vm/jit/abi-asm.h: Cosmetic changes.
+       [8abf46e074a3]
+
+2007-02-20  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c,
+       src/vm/jit/m68k/emit.h, src/vm/jit/m68k/linux/md-abi.c,
+       src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/machine-instr.h,
+       src/vm/jit/m68k/md.c:
+       * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): New function.
+       (emit_mov_imm_areg): Likewise.
+
+       * src/vm/jit/m68k/linux/md-abi.h: Lots of defines.
+
+       * src/vm/jit/m68k/linux/md-abi.c: Register allocator data structure
+       created, some stubs added.
+
+       * src/vm/jit/m68k/md.c (md_param_alloc): Removed.
+       * src/vm/jit/m68k/arch.h (REG_ZERO): Added a dummy REG_ZERO, needs to
+       be resolved.
+
+       * src/vm/jit/m68k/emit.h: New file.
+
+       * src/vm/jit/m68k/codegen.c (createcompilerstub): Implemented.
+
+       * src/vm/jit/m68k/machine-instr.h (*BARRIER*): Implemented.
+       (compare_and_swap): Implemented, but not atomically, there is no way
+       to do soo on coldfire.
+
+       * src/vm/jit/m68k/codegen.h (M_MOV_IMM): Added. (M_AMOV_IMM): Added.
+       (M_JMP): Added. (OPWORD): Added.
+       [2e818486fcf6]
+
+       * src/cacao/Makefile.am, src/mm/memory.h, src/mm/nogc.c,
+       src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/threads/native/Makefile.am, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/toolbox/logging.c,
+       src/vm/finalizer.c, src/vm/jit/abi.h, src/vm/jit/alpha/disass.c,
+       src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/disass.c, src/vm/jit/arm
+       /md-abi.c, src/vm/jit/asmpart.h, src/vm/jit/disass.h,
+       src/vm/jit/i386/md-abi.c, src/vm/jit/mips/disass.c, src/vm/jit/mips
+       /md-abi.c, src/vm/jit/mips/md-abi.h, src/vm/jit/powerpc/linux/md-
+       abi.c, src/vm/jit/s390/asmpart.S, src/vm/jit/s390/patcher.c,
+       src/vm/jit/stacktrace.c, src/vm/signal.c, src/vmcore/descriptor.c,
+       src/vmcore/descriptor.h, src/vmcore/options.c, src/vmcore/options.h:
+       * src/mm/nogc.c (heap_allocate): Renamed
+       exceptions_throw_outofmemory_exit to
+       exceptions_throw_outofmemoryerror. (gc_init): Liekwise.
+
+       * src/vmcore/descriptor.h (methoddesc): Added argaddrreguse when
+       HAS_ADDRESS_REGISTER_FILE.
+       [4bc1020616ed]
+
+2007-02-20  twisti  <twisti>
+
+       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c:
+       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c (vm/exceptions.h):
+       Added. (vm/stringlocal.h): Likewise. (loadLibrary): Throw error in
+       case.
+       [f5960974827d]
+
+       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/java_lang_Runtime.c,
+       src/native/vm/java_lang_Runtime.h:
+       * src/native/vm/java_lang_Runtime.c (loadLibrary): Different
+       signature for _Jv_java_lang_Runtime_loadLibrary depending on
+       ENABLE_JNI.
+       * src/native/vm/java_lang_Runtime.h: Likewise.
+       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c: Likewise.
+       * src/native/vm/gnu/java_lang_VMRuntime.c: Likewise.
+       [89ae09836c68]
+
+       * configure.ac, m4/java.m4, m4/jit.m4, m4/jni.m4:
+       * configure.ac (AC_CHECK_ENABLE_JAVA): Added. (AC_CHECK_ENABLE_JIT):
+       Likewise. (AC_CHECK_ENABLE_JNI): Likewise.
+
+       * m4/jni.m4: New file.
+       * m4/java.m4: Likewise.
+       * m4/jit.m4: Likewise.
+       [1c39fd610b52]
+
+2007-02-19  twisti  <twisti>
+
+       * src/native/include/Makefile.am, src/native/vm/cldc1.1/Makefile.am,
+       src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/java_lang_Runtime.c,
+       src/native/vm/java_lang_Runtime.h:
+       * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c: New file.
+
+       * src/native/vm/cldc1.1/Makefile.am (libnativevmcore_la_SOURCES):
+       Added com_sun_cldchi_jvm_JVM.c.
+
+       * src/native/vm/java_lang_Runtime.c [!WITH_STATIC_CLASSPATH]
+       (ltdl.h): Added. (native/jni.h): Likewise. (native/native.h):
+       Likewise. (native/include/java_lang_String.h): Likewise.
+       (toolbox/logging.h): Likewise. (vm/exceptions.h): Likewise.
+       (vm/stringlocal.h): Likewise. (vmcore/options.h): Likewise.
+       (loadLibrary): New function.
+
+       * src/native/vm/java_lang_Runtime.h (native/jni.h): Added.
+       (native/include/java_lang_String.h): Likewise.
+
+       * src/native/vm/gnu/java_lang_VMRuntime.c [!WITH_STATIC_CLASSPATH]
+       (ltdl.h): Removed. (native/native.h): Likewise. (toolbox/logging.h):
+       Likewise. (vmcore/options.h): Likewise. (nativeLoad): Call
+       _Jv_java_lang_Runtime_loadLibrary.
+
+       * src/native/include/Makefile.am (JAVAME_CLDC1_1_HEADER_FILES):
+       Added com_sun_cldchi_jvm_JVM.h.
+       [f1fc106c9495]
+
+2007-02-18  pm  <pm>
+
+       * src/cacao/Makefile.am, src/mm/memory.h, src/native/native.c,
+       src/native/native.h, src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/threads/native/Makefile.am, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/toolbox/logging.c,
+       src/vm/finalizer.c, src/vm/jit/abi.h, src/vm/jit/alpha/disass.c,
+       src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/disass.c, src/vm/jit/arm
+       /md-abi.c, src/vm/jit/asmpart.h, src/vm/jit/disass.h,
+       src/vm/jit/i386/md-abi.c, src/vm/jit/mips/disass.c, src/vm/jit/mips
+       /md-abi.c, src/vm/jit/mips/md-abi.h, src/vm/jit/powerpc/linux/md-
+       abi.c, src/vm/jit/s390/asmpart.S, src/vm/jit/s390/patcher.c,
+       src/vm/jit/stacktrace.c, src/vm/signal.c, src/vmcore/descriptor.c,
+       src/vmcore/descriptor.h, src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/jit/s390/patcher.c (patcher_wrapper): Formatting changes.
+       * src/vm/jit/s390/asmpart.S (asm_patcher_wrapper): Did not remove
+       stack frame created by patcher stubs.
+       [02d0605e27d4]
+
+2007-02-18  michi  <michi>
+
+       * src/mm/cacao-gc/compact.c:
+       * src/mm/cacao-gc/compact.c: Fixed a typo in compact_move().
+       Classloaders are now threaded in compact_thread_classes() as well.
+       [d5545512c055]
+
+       * src/cacaoh/Makefile.am, src/mm/boehm.c, src/native/native.c,
+       src/native/native.h, src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/vm/builtin.h, src/vm/jit/Makefile.am,
+       src/vm/jit/alpha/freebsd/Makefile.am,
+       src/vm/jit/alpha/linux/Makefile.am, src/vm/jit/alpha/md-abi.h,
+       src/vm/jit/alpha/md.c, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/freebsd/Makefile.am,
+       src/vm/jit/i386/linux/Makefile.am, src/vm/jit/mips/irix/Makefile.am,
+       src/vm/jit/mips/linux/Makefile.am,
+       src/vm/jit/powerpc/darwin/Makefile.am,
+       src/vm/jit/powerpc/linux/Makefile.am, src/vm/jit/powerpc/linux/md-
+       abi.h, src/vm/jit/s390/arch.h, src/vm/jit/s390/emit.c,
+       src/vm/jit/s390/md-asm.h, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.h, src/vmcore/class.h:
+       * src/native/native.c, src/native/native.h: The hashtable_library
+       now uses the hashcode of the classloader instead of its memory
+       address.
+       [333581df59af]
+
+2007-02-16  twisti  <twisti>
+
+       * src/cacaoh/dummy.c, src/mm/memory.c:
+       * Merged with trunk.
+       [80d87d7ebe2c]
+
+       * src/cacaoh/dummy.c, src/mm/memory.c, src/vmcore/statistics.c,
+       src/vmcore/statistics.h:
+       * src/vmcore/statistics.c (mm/gc-common.h): Added.
+       (statistics_print_gc_memory_usage): New function.
+       * src/vmcore/statistics.h (statistics_print_gc_memory_usage):
+       Likewise.
+
+       * src/cacaoh/dummy.c (gc_get_heap_size): New stub.
+       (gc_get_free_bytes): Likewise. (gc_get_total_bytes): Likewise.
+       (gc_get_max_heap_size): Likewise.
+
+       * src/mm/memory.c (memory_thread): Call
+       statistics_print_gc_memory_usage.
+       [1a5524ae4db5]
+
+       * src/Makefile.am, src/cacaoh/dummy.c, src/threads/Makefile.am,
+       src/threads/threads-common.c, src/vm/jit/intrp/asmpart.c,
+       src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/dynamic-super.c,
+       src/vm/jit/intrp/engine.c, src/vm/jit/intrp/intrp.h,
+       src/vm/jit/intrp/java.vmg, src/vm/jit/intrp/patcher.c,
+       src/vm/jit/intrp/peephole.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c:
+       * Merged with trunk.
+       [1e3bbf505d88]
+
+2007-02-16  pm  <pm>
+
+       * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-abi.c,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c:
+       * src/vm/jit/s390/md.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md-abi.c: Changed a lot.
+       Mostly adapted to changes in the tree.
+       [7e252ec103cb]
+
+2007-02-15  twisti  <twisti>
+
+       * src/cacaoh/dummy.c, src/vm/jit/intrp/dynamic-super.c,
+       src/vm/jit/intrp/engine.c:
+       * src/cacaoh/dummy.c (intrp_asm_abstractmethoderror): New stub.
+       (print_dynamic_super_statistics): Likewise.
+
+       * src/vm/jit/intrp/engine.c (mm/memory.h): Added.
+       * src/vm/jit/intrp/dynamic-super.c [!ENABLE_THREADS]
+       (threads/none/lock.h): Likewise.
+       [aeb00f812c30]
+
+       * src/Makefile.am, src/threads/Makefile.am, src/threads/threads-
+       common.c:
+       * src/Makefile.am [ENABLE_THREADS] (THREADS_DIR): Added. (SUBDIRS):
+       Added THREADS_DIR.
+
+       * src/threads/Makefile.am (SUBDIRS): Set always to native.
+
+       * src/threads/threads-common.c (threads/none/threads.h): Removed.
+       [ENABLE_THREADS] (threads_create_thread): Removed ifdef.
+       (threads_get_current_tid) [ENABLE_THREADS]: Removed.
+       [9cc012c8781c]
+
+       * src/vm/jit/powerpc/arch.h:
+       * src/vm/jit/powerpc/arch.h
+       (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER)
+       (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER)
+       (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Defined.
+       [1fa126b89842]
+
+       * src/vm/jit/emit-common.c, src/vm/jit/emit-common.h,
+       src/vm/jit/mips/arch.h, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/md.c,
+       src/vm/jit/mips/patcher.c:
+       * src/vm/jit/emit-common.c
+       [SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER] (emit_beqz)
+       (emit_bnez, emit_bltz, emit_bgez, emit_bgtz, emit_blez): #ifdef'ed.
+       [SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS] (emit_beq)
+       (emit_bne): New functions.
+       [SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER] (emit_beq, emit_bne)
+       (emit_blt, emit_bge, emit_bgt, emit_ble): #ifdef'ed.
+       * src/vm/jit/emit-common.h: Likewise.
+
+       * src/vm/jit/mips/emit.c (emit_branch): Fixed.
+       (emit_arithmetic_check): Use hardware-exception instructions.
+       (emit_arrayindexoutofbounds_check): Likewise.
+       (emit_classcast_check): Likewise. (emit_nullpointer_check):
+       Likewise. (emit_exception_check): Likewise. (emit_arraystore_check):
+       Removed. (emit_exception_stubs): Likewise.
+
+       * src/vm/jit/mips/md.c (md_codegen_patch_branch): Removed.
+
+       * src/vm/jit/mips/codegen.c (codegen): Renamed to codegen_emit and
+       changed to use emit-branch functions.
+
+       * src/vm/jit/mips/codegen.h (M_ITYPE_GET_RS, M_ITYPE_GET_RT)
+       (M_ITYPE_GET_IMM): Added.
+
+       * src/vm/jit/mips/linux/md-os.c (vm/jit/mips/codegen.h): Added.
+       (md_signal_handler_sigsegv): Use exceptions_new_hardware_exception.
+
+       * src/vm/jit/mips/arch.h
+       (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER)
+       (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER)
+       (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Defined.
+
+       * src/vm/jit/mips/patcher.c (patcher_checkcast_interface): Fixed
+       patching offsets.
+       [fad4133a1392]
+
+2007-02-15  pm  <pm>
+
+       * src/cacaoh/Makefile.am, src/native/include/Makefile.am, src/threads
+       /threads-common.c:
+       * src/threads/threads-common.c (threads_get_current_tid): Return 0
+       if compiled with --enable-threads=none
+       [c76426752793]
+
+2007-02-14  twisti  <twisti>
+
+       * configure.ac, m4/cacaoh.m4, src/Makefile.am,
+       src/native/include/Makefile.am:
+       * configure.ac (--with-cacaoh): Removed code and call
+       AC_CHECK_WITH_CACAOH.
+       * m4/cacaoh.m4: New file.
+       * src/Makefile.am [ENABLE_CACAOH] (CACAOH_DIR): Added. (SUBDIRS):
+       Added CACAOH_DIR.
+       * src/native/include/Makefile.am (CACAOH): Don't set it, configure
+       does that.
+       [0310673feb39]
+
+2007-02-14  tbfg  <tbfg>
+
+       * src/Makefile.am, src/cacaoh/Makefile.am,
+       tests/regression/native/Makefile.am:
+       * src/Makefile.am: Do not recurse into cacaoh when not enabled.
+       * src/cacaoh/Makefile.am: Removed conditional builds.
+       * tests/regression/native/Makefile.am: Used hardcoded cacaoh.
+       [f4ae950cc199]
+
+       * configure.ac, src/cacaoh/Makefile.am,
+       src/native/include/Makefile.am:
+       * configure.ac (--with-cacaoh): Added --with-cacaoh for easier
+       crossbuilds.
+
+       * src/cacaoh/Makefile.am: Use configure provided cacaoh.
+
+       * src/native/include/Makefile.am: Only build cacaoh when no
+       --with-cacaoh given.
+       [d3ac14a1eef5]
+
+2007-02-14  twisti  <twisti>
+
+       * src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/intrp.h,
+       src/vm/jit/mips/emit.c:
+       * src/vm/jit/mips/emit.c (emit_branch): New function.
+       [b9f3457e62b7]
+
+       * src/cacao/Makefile.am, src/mm/boehm.c, src/mm/memory.c,
+       src/mm/memory.h, src/native/include/Makefile.am,
+       src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/threads/Makefile.am, src/threads/native/Makefile.am,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/toolbox/logging.c, src/vm/builtin.h, src/vm/finalizer.c,
+       src/vm/jit/abi.h, src/vm/jit/alpha/disass.c,
+       src/vm/jit/alpha/freebsd/Makefile.am,
+       src/vm/jit/alpha/linux/Makefile.am, src/vm/jit/alpha/md-abi.c,
+       src/vm/jit/alpha/md-abi.h, src/vm/jit/alpha/md.c,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/disass.c, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/asmpart.h, src/vm/jit/disass.h,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/freebsd/Makefile.am,
+       src/vm/jit/i386/linux/Makefile.am, src/vm/jit/i386/md-abi.c,
+       src/vm/jit/intrp/asmpart.c, src/vm/jit/intrp/codegen.c,
+       src/vm/jit/intrp/dynamic-super.c, src/vm/jit/intrp/engine.c,
+       src/vm/jit/intrp/intrp.h, src/vm/jit/intrp/java.vmg,
+       src/vm/jit/intrp/patcher.c, src/vm/jit/intrp/peephole.c,
+       src/vm/jit/mips/disass.c, src/vm/jit/mips/irix/Makefile.am,
+       src/vm/jit/mips/linux/Makefile.am, src/vm/jit/mips/md-abi.c,
+       src/vm/jit/mips/md-abi.h, src/vm/jit/powerpc/darwin/Makefile.am,
+       src/vm/jit/powerpc/linux/Makefile.am, src/vm/jit/powerpc/linux/md-
+       abi.c, src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390
+       /md-asm.h, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64
+       /md-abi.h, src/vm/signal.c, src/vmcore/class.h,
+       src/vmcore/descriptor.c, src/vmcore/descriptor.h,
+       src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/jit/intrp/peephole.c: Updated to current codebase.
+       * src/vm/jit/intrp/intrp.h: Likewise.
+       * src/vm/jit/intrp/codegen.c: Likewise.
+       * src/vm/jit/intrp/engine.c: Likewise.
+       * src/vm/jit/intrp/asmpart.c: Likewise.
+       * src/vm/jit/intrp/dynamic-super.c: Likewise.
+       * src/vm/jit/intrp/patcher.c: Likewise.
+       * src/vm/jit/intrp/java.vmg: Likewise.
+       [cc5c117f777d]
+
+       * configure.ac, src/cacao/Makefile.am, src/cacaoh/dummy.c,
+       src/mm/memory.c, src/mm/memory.h, src/native/jni.c,
+       src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/threads/.cvsignore, src/threads/Makefile.am,
+       src/threads/critical.c, src/threads/critical.h,
+       src/threads/native/Makefile.am, src/threads/native/critical.c,
+       src/threads/native/critical.h, src/threads/native/lock.c,
+       src/threads/native/lock.h, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/none/threads.h,
+       src/threads/threads-common.c, src/threads/threads-common.h,
+       src/toolbox/logging.c, src/vm/builtin.c, src/vm/builtin.h,
+       src/vm/exceptions.c, src/vm/finalizer.c, src/vm/jit/abi.h,
+       src/vm/jit/alpha/disass.c, src/vm/jit/alpha/emit.c, src/vm/jit/alpha
+       /md-abi.c, src/vm/jit/alpha/md-abi.h, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/disass.c,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c,
+       src/vm/jit/disass.h, src/vm/jit/emit-common.h,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/md-abi.c,
+       src/vm/jit/mips/disass.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/irix/Makefile.am, src/vm/jit/mips/linux/Makefile.am,
+       src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md-abi.h,
+       src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c,
+       src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/replace.c,
+       src/vm/jit/replace.h, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/patcher.c, src/vm/jit/show.c,
+       src/vm/jit/sparc64/Makefile.am, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md-abi.c,
+       src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md.c,
+       src/vm/jit/sparc64/patcher.c, src/vm/jit/sparc64/solaris/.cvsignore,
+       src/vm/jit/sparc64/solaris/Makefile.am, src/vm/jit/sparc64/solaris
+       /md-os.c, src/vm/jit/stacktrace.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.h, src/vm/signal.c, src/vm/vm.c,
+       src/vmcore/annotation.c, src/vmcore/descriptor.c,
+       src/vmcore/descriptor.h, src/vmcore/options.c, src/vmcore/options.h:
+       * Merged with trunk.
+       [7b6a202c6bfd]
+
+       * src/mm/boehm.c, src/native/include/Makefile.am, src/native/native.c,
+       src/native/vm/Makefile.am, src/native/vm/cldc1.1/Makefile.am,
+       src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_Runtime.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/java_lang_Object.h, src/native/vm/java_lang_Runtime.c,
+       src/native/vm/java_lang_Runtime.h, src/vm/exceptions.c,
+       src/vm/jit/alpha/freebsd/Makefile.am,
+       src/vm/jit/alpha/linux/Makefile.am, src/vm/jit/alpha/md.c,
+       src/vm/jit/codegen-common.c, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/i386/cygwin/Makefile.am, src/vm/jit/i386/cygwin/md-asm.h,
+       src/vm/jit/i386/cygwin/md-os.c, src/vm/jit/i386/cygwin/ucontext.c,
+       src/vm/jit/i386/cygwin/ucontext.h,
+       src/vm/jit/i386/freebsd/Makefile.am,
+       src/vm/jit/i386/linux/Makefile.am,
+       src/vm/jit/powerpc/darwin/Makefile.am,
+       src/vm/jit/powerpc/linux/Makefile.am,
+       src/vm/jit/powerpc/netbsd/Makefile.am,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-abi.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md-asm.h,
+       src/vm/jit/s390/patcher.c, src/vm/vm.c, src/vmcore/class.h:
+       * Merged with trunk.
+       [e39f030e886d]
+
+2007-02-14  tbfg  <tbfg>
+
+       * src/cacao/Makefile.am, src/cacaoh/dummy.c, src/mm/memory.c,
+       src/mm/memory.h, src/native/native.h,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/threads/native/Makefile.am, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/toolbox/logging.c,
+       src/vm/finalizer.c, src/vm/jit/Makefile.am, src/vm/jit/abi.h,
+       src/vm/jit/alpha/disass.c, src/vm/jit/alpha/md-abi.c,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/disass.c, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c,
+       src/vm/jit/disass.h, src/vm/jit/i386/md-abi.c,
+       src/vm/jit/m68k/disass.c, src/vm/jit/mips/disass.c, src/vm/jit/mips
+       /md-abi.c, src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/s390/md.c,
+       src/vm/jit/stacktrace.c, src/vm/signal.c, src/vmcore/annotation.c,
+       src/vmcore/descriptor.c, src/vmcore/descriptor.h,
+       src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/jit/m68k/disass.c: New file.
+       * src/vm/jit/codegen-common.c: Include vmcore/statistics.h
+       unconditionally.
+       [2e1c214eadcf]
+
+2007-02-13  twisti  <twisti>
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c:
+       * src/vm/jit/arm/codegen.c (createnativestub) [!__ARM_EABI__]:
+       #ifdef'ed split-stuff.
+       * src/vm/jit/arm/md-abi.c (md_param_alloc_native) [!__ARM_EABI__]:
+       Added GNU EABI stuff.
+       [af78bca75913]
+
+2007-02-13  ajordan  <ajordan>
+
+       * configure.ac, src/vm/jit/sparc64/Makefile.am,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/solaris/.cvsignore,
+       src/vm/jit/sparc64/solaris/Makefile.am, src/vm/jit/sparc64/solaris
+       /md-os.c:
+       * configure.ac: Added support for compiling on Solaris.
+
+       * src/vm/jit/sparc64/*: Added os subdir, changes for compiling on
+       Solaris.
+       [157ae470d534]
+
+2007-02-13  twisti  <twisti>
+
+       * src/vm/jit/mips/disass.c, src/vm/jit/mips/md-abi.c:
+       * src/vm/jit/mips/md-abi.c (regs): Renamed to
+       abi_registers_integer_name. (md_param_alloc_native): New function.
+       * src/vm/jit/mips/disass.c (disassinstr): Replaced regs with
+       abi_registers_integer_name.
+       [3db406d10cfa]
+
+       * src/vm/jit/mips/emit.c, src/vm/jit/mips/md-abi.h:
+       * src/vm/jit/mips/emit.c (emit_verbosecall_exit): Fixed argument
+       passing, but I think there's still something left to fix.
+       * src/vm/jit/mips/md-abi.h (REG_A2_A3_PACKED): Added.
+       [f55f5d4d9ef6]
+
+       * src/threads/native/lock.c, src/threads/native/lock.h:
+       * src/threads/native/lock.c (vm/vm.h): Added.
+       (lock_record_add_waiter): New function. (lock_record_remove_waiter):
+       Free the waiter data structure. (lock_record_wait): Use
+       lock_record_add_waiter.
+       * src/threads/native/lock.h: Cosmetic changes.
+       [d1d527064209]
+
+       * src/cacaoh/dummy.c:
+       * src/cacaoh/dummy.c (mem_alloc): Arghhhh, fixed arguments.
+       [a9db026b311f]
+
+       * src/cacaoh/dummy.c:
+       * src/cacaoh/dummy.c (mem_alloc): Use calloc instead of malloc.
+       [6faeec3ab2c6]
+
+       * src/threads/threads-common.c:
+       * src/threads/threads-common.c (threads_get_current_tid): Check if
+       thread is NULL and return 0.
+       [8f9daba23327]
+
+       * src/cacaoh/dummy.c, src/threads/threads-common.c, src/threads
+       /threads-common.h, src/toolbox/logging.c:
+       * src/threads/threads-common.c (threads_get_current_tid): New
+       function.
+       * src/threads/threads-common.h (threads_get_current_tid): Added.
+
+       * src/toolbox/logging.c (log_start): Use threads_get_current_tid.
+
+       * src/cacaoh/dummy.c (threads_get_current_threadobject): Removed.
+       (threads_get_current_tid): Added.
+       [3a124f6f4c56]
+
+2007-02-13  ajordan  <ajordan>
+
+       * src/vm/jit/Makefile.am, src/vm/signal.c:
+       * src/vm/jit/Makefile.am: Reverted duplicate changes.
+
+       * src/vm/signal.c: Reverted one duplicate header include.
+       [2fbdec7bf486]
+
+       * src/native/jni.c, src/threads/critical.c,
+       src/threads/none/threads.h, src/threads/threads-common.c,
+       src/vm/exceptions.c, src/vm/finalizer.c, src/vm/jit/Makefile.am,
+       src/vm/jit/codegen-common.c, src/vm/jit/stacktrace.c,
+       src/vm/signal.c:
+       * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframeinfo):
+       SPARC specific retrieval of the PV. (stacktrace_create): SPARC
+       specific stack walking.
+
+       * src/vm/jit/Makefile.am: Not compiling verifier source when
+       disabled.
+
+       * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Included
+       __SPARC_64__ in ifdef to add patcher NOPs from here.
+
+       * src/vm/signal.c: Added include statements and/or ifdefs to fix
+       compiling without threads.
+       * src/vm/exceptions.c: Likewise.
+       * src/vm/finalizer.c: Likewise.
+       * src/native/jni.c: Likewise.
+       * src/threads/none/threads.h: Likewise.
+       * src/threads/threads-common.c: Likewise.
+       * src/threads/critical.c: Likewise.
+       [c51c053fbfbf]
+
+       * src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md-abi.c,
+       src/vm/jit/sparc64/md-abi.h:
+       * src/vm/jit/sparc64/md-abi.h: set TRACE_ARGS_NUM to 6.
+       * src/vm/jit/sparc64/emit.c: using the 6 available integer argument
+       regs for call tracing.
+
+       * src/vm/jit/sparc64/md-abi.c: added abi register names. Added
+       md_param_alloc_native(), but still using the existing workaround.
+       [9a19cd374635]
+
+2007-02-13  twisti  <twisti>
+
+       * src/mm/memory.c:
+       * src/mm/memory.c (memory_thread) [ENABLE_STATISTICS]: #ifdef'ed
+       statistics_print_memory_usage call.
+       [cd26a2966c4b]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_create) [ENABLE_STATISTICS]: #ifdef opt_stat.
+       [08f3909ddc6a]
+
+       * src/mm/memory.c, src/vm/vm.c:
+       * src/vm/vm.c (vm_create): Set opt_stat also true for
+       -verbose:memory.
+       * src/mm/memory.c [ENABLE_THREADS] (threads/threads-common.h): Added.
+       (memory_thread): Call statistics_print_memory_usage.
+       [b512ae21162a]
+
+       * src/cacao/Makefile.am, src/mm/memory.c, src/mm/memory.h,
+       src/threads/.cvsignore, src/threads/Makefile.am,
+       src/threads/critical.c, src/threads/critical.h,
+       src/threads/native/Makefile.am, src/threads/native/critical.c,
+       src/threads/native/critical.h, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/threads-common.c,
+       src/threads/threads-common.h, src/vm/finalizer.c,
+       src/vm/jit/asmpart.h, src/vm/jit/optimizing/profile.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/signal.c, src/vm/vm.c,
+       src/vmcore/options.c, src/vmcore/options.h:
+       * src/vm/jit/optimizing/profile.c (native/jni.h): Removed.
+       (native/include/java_lang_Thread.h): Likewise.
+       (native/include/java_lang_VMThread.h): Likewise. (threads/threads-
+       common.h): Added. (thread_profile): Changed type to threadobject.
+       (profile_start_thread): Use threads_create_thread.
+       * src/vm/jit/optimizing/recompile.c: Likewise.
+       * src/vm/signal.c: Likewise.
+       * src/vm/finalizer.c: Likewise.
+
+       * src/vm/jit/asmpart.h (threads/native/critical.h): Removed.
+       (threads/critical.h): Added.
+
+       * src/vmcore/options.c (opt_verbosememory): Added.
+       * src/vmcore/options.h: Likewise.
+
+       * src/vm/vm.c (XXusage): Added -verbose:memory. (vm_create):
+       Likewise. Start memory thread.
+
+       * src/cacao/Makefile.am (THREAD_LIB): Changed to
+       $(top_builddir)/src/threads/libthreads.la.
+
+       * src/mm/memory.c [ENABLE_THREADS] (thread_memory): Added.
+       [ENABLE_THREADS] (memory_thread): New function. [ENABLE_THREADS]
+       (memory_start_thread): Likewise.
+       * src/mm/memory.h [ENABLE_THREADS] (memory_start_thread): Added.
+
+       * src/threads/native/critical.c: Removed.
+       * src/threads/native/critical.h: Likewise.
+       * src/threads/critical.c: Added.
+       * src/threads/critical.h: Likewise.
+
+       * src/threads/threads-common.c: New file.
+       * src/threads/threads-common.h: Likewise.
+       * src/threads/Makefile.am (AM_CPPFLAGS): Added. (LIB): Likewise.
+       [ENABLE_THREADS] (THREAD_LIB): Likewise. (noinst_LTLIBRARIES):
+       Likewise. (libthreads_la_SOURCES): Likewise. (libthreads_la_LIBADD):
+       Likewise.
+
+       * src/threads/.cvsignore: New file.
+
+       * src/threads/native/threads.c (include "threads/threads-common.h):
+       Added.
+       * src/threads/native/threads.h (MIN_PRIORITY, NORM_PRIORITY)
+       (MAX_PRIORITY): Removed.
+
+       * src/threads/native/Makefile.am (noinst_LTLIBRARIES): Changed to
+       libthreadsposix.la.
+       [57682a5aba23]
+
+       * src/vmcore/annotation.c:
+       * src/vmcore/annotation.c
+       (annotation_load_attribute_runtimevisibleannotations): Renamed aa to
+       annotations.
+       [1c792673fcbd]
+
+2007-02-12  twisti  <twisti>
+
+       * src/vm/jit/emit-common.h:
+       * src/vm/jit/emit-common.h (_EMIT_H): Renamed to _EMIT_COMMON_H.
+       (config.h): Added. (vm/jit/codegen-common.h): Likewise.
+       [SIZEOF_VOID_P == 4] (IS_IMM16): Added.
+       [b19814ba89ab]
+
+       * src/vm/jit/alpha/disass.c, src/vm/jit/alpha/md-abi.c:
+       * src/vm/jit/alpha/md-abi.c (regs): Renamed to
+       abi_registers_integer_name. (md_param_alloc_native): New function.
+
+       * src/vm/jit/alpha/disass.c (vm/jit/abi.h): Added. (disassinstr):
+       Replaced regs with abi_registers_integer_name.
+       [23febdef7237]
+
+       * src/vm/jit/i386/md-abi.c:
+       * src/vm/jit/i386/md-abi.c (regs): Renamed to
+       abi_registers_integer_name. (md_param_alloc_native): New function.
+       [cc5eeff0cb09]
+
+2007-02-11  twisti  <twisti>
+
+       * src/vm/jit/arm/disass.c, src/vm/jit/arm/md-abi.c:
+       * src/vm/jit/arm/disass.c (stdio.h): Added. (regs): Removed.
+       * src/vm/jit/arm/md-abi.c (abi_registers_integer_name): Added.
+       (md_param_alloc_native): Likewise.
+       [29ed076c2ed8]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (vm/jit/abi.h): Added.
+       [3edfd0bfe9e7]
+
+       * src/vm/jit/disass.h, src/vm/jit/show.c:
+       * src/vm/jit/disass.h (regs): Removed.
+
+       * src/vm/jit/show.c (vm/jit/abi.h): Added. (show_allocation):
+       Renamed regs to abi_registers_integer_name.
+       [f0edc37030d7]
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/linux/md-abi.c:
+       * src/vm/jit/codegen-common.c (codegen_createnativestub): Call
+       md_param_alloc_native instead of md_param_alloc.
+
+       * src/vm/jit/powerpc/linux/md-abi.c (assert.h): Added. (regs):
+       Renamed to abi_registers_integer_name.
+       (abi_registers_integer_argument, abi_registers_integer_saved)
+       (abi_registers_integer_temporary, abi_registers_float_name)
+       (abi_registers_float_argument, abi_registers_float_saved)
+       (abi_registers_float_temporary): Added. (md_param_alloc):
+       Reformatted. (md_param_alloc_native): New function.
+       [4736770b86de]
+
+       * src/vm/jit/abi.h, src/vmcore/descriptor.c, src/vmcore/descriptor.h:
+       * src/vmcore/descriptor.c (vm/jit/abi.h): Added.
+       * src/vmcore/descriptor.h (md_param_alloc): Removed.
+
+       * src/vm/jit/abi.h (abi_registers_integer_name)
+       (abi_registers_integer_argument, abi_registers_integer_saved)
+       (abi_registers_integer_temporary, abi_registers_float_name)
+       (abi_registers_float_argument, abi_registers_float_saved)
+       (abi_registers_float_temporary): Added. (md_param_alloc): Likewise.
+       (md_param_alloc_native): Likewise.
+       [a16f365547ee]
+
+       * src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/java_lang_reflect_Method.c:
+       * src/native/native.c (native_get_returntype): Removed.
+       * src/native/native.h: Likewise.
+
+       * src/native/vm/gnu/java_lang_reflect_Method.c (getReturnType):
+       Moved code from native_get_returntype.
+       [63cc7b056dbb]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (vm/jit/md.h): Added.
+       [d03242be27f2]
+
+2007-02-11  michi  <michi>
+
+       * src/mm/cacao-gc/region.c, src/mm/cacao-gc/region.h, src/mm/memory.c,
+       src/mm/memory.h:
+       * src/mm/cacao-gc/region.h, src/mm/cacao-gc/region.c: Added.
+       * src/mm/memory.c, src/mm/memory.h: Moved defines for memcheck into
+       header file.
+       [12fda0ee1c7c]
+
+2007-02-11  twisti  <twisti>
+
+       * src/vm/jit/arm/asmpart.S, src/vm/jit/arm/emit.c:
+       * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Keep stack 8-byte
+       aligned. (emit_verbosecall_exit): Added comment.
+       * src/vm/jit/arm/asmpart.S (asm_call_jit_compiler): Keep stack 8-byte
+       aligned.
+       [d97c9610df75]
+
+2007-02-11  michi  <michi>
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/stacktrace.h:
+       * src/vm/jit/i386/codegen.c (createnativestub): Saved registers are
+       now stored/recovered into/from the stackframeinfo structure.
+       * src/vm/jit/stacktrace.h: Modified stackframeinfo structure
+       accordingly.
+       [663e32714291]
+
+2007-02-11  pm  <pm>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/stacktrace.c:
+       * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframeinfo):
+       On s390 get return address from stack also in leaf methods.
+       * src/vm/jit/codegen-common.c (methodtree_comparator): On s390 compare
+       addresses as 31 bit integers.
+       * src/vm/jit/s390/md.c, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/asmpart.S: Changed a lot, working on s390 port.
+       [c749d9c3aaf1]
+
+2007-02-11  tbfg  <tbfg>
+
+       * src/vm/builtin.h, src/vm/jit/arm/emit.c, src/vm/jit/i386/emit.c,
+       src/vm/jit/mips/md-abi.h, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/x86_64/emit.c:
+       * src/vm/jit/powerpc64/codegen.c (CHECKCAST): Longbranches are only
+       an issue when using SOFTEX.
+
+       * src/vm/jit/powerpc64/patcher.c
+       (patcher_resolve_classref_to_classinfo): Added.
+       (patcher_resolve_classref_to_classinfo): Added.
+       (patcher_resolve_classref_to_vftbl): Added.
+       (patcher_resolve_classref_to_flags): Added.
+       [448a35abd40f]
+
+2007-02-11  michi  <michi>
+
+       * src/vm/jit/replace.c, src/vm/jit/replace.h:
+       * src/vm/jit/replace.c: Fixed includes for options.h and
+       classcache.h headers.
+       * src/vm/jit/replace.h: Added forward typedef for rplalloc.
+       [666823923812]
+
+       * src/vm/jit/replace.h:
+       * src/vm/jit/replace.h: Fixed include for method.h header.
+       [0ed77d0cbca4]
+
+       * src/mm/gc-common.h, src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/gnu/java_lang_VMSystem.c:
+       * src/mm/gc-common.h [ENABLE_GC_CACAO]: Added prototype for
+       heap_get_hashcode().
+       * src/native/vm/gnu/java_lang_VMSystem.c [ENABLE_GC_CACAO]: Uses new
+       method to get hashcodes for objects.
+       * src/native/vm/cldc1.1/java_lang_Object.c [ENABLE_GC_CACAO]: Don't
+       know if we can use this here.
+       [985cf627996d]
+
+2007-02-11  twisti  <twisti>
+
+       * src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.h:
+       * src/vm/jit/x86_64/emit.c (emit_verbosecall_enter): Renamed
+       builtin_trace_args to builtin_verbosecall_enter.
+       (builtin_verbosecall_exit): Renamed builtin_displaymethodstop to
+       builtin_verbosecall_exit and changed signature.
+
+       * src/vm/jit/x86_64/md-abi.h (REG_FA0, REG_FA1): Added.
+       [c6b6afe62556]
+
+2007-02-10  twisti  <twisti>
+
+       * src/vm/builtin.c, src/vm/builtin.h, src/vm/jit/alpha/emit.c,
+       src/vm/jit/alpha/md-abi.h, src/vm/jit/arm/emit.c,
+       src/vm/jit/i386/emit.c, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/irix/Makefile.am, src/vm/jit/mips/linux/Makefile.am,
+       src/vm/jit/mips/md-abi.h, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/linux/md-abi.h:
+       * src/vm/builtin.c (builtin_trace_args): Renamed to
+       builtin_verbosecall_enter. (builtin_trace_args): Renamed to
+       builtin_verbosecall_enter. (builtin_displaymethodstop): Renamed to
+       builtin_verbosecall_exit and changed signature.
+       * src/vm/builtin.h: Likewise.
+
+       * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Likewise.
+       (builtin_verbosecall_exit): Likewise.
+       * src/vm/jit/alpha/emit.c: Likewise.
+       * src/vm/jit/i386/emit.c: Likewise.
+       * src/vm/jit/mips/emit.c: Likewise.
+       * src/vm/jit/powerpc/emit.c: Likewise.
+
+       * src/vm/jit/alpha/md-abi.h (REG_FA0, REG_FA1, REG_FA2): Added.
+       * src/vm/jit/mips/md-abi.h: Removed multiple defines.
+       * src/vm/jit/powerpc/linux/md-abi.h (REG_FA0, REG_FA1): Added.
+       (REG_A0_A1_PACKED): Likewise.
+
+       * src/vm/jit/mips/linux/Makefile.am (AM_CPPFLAGS): Added
+       -I$(top_builddir)/src.
+       * src/vm/jit/mips/irix/Makefile.am: Likewise.
+       [07b4af4a23e6]
+
+2007-02-10  tbfg  <tbfg>
+
+       * src/mm/boehm.c, src/native/include/Makefile.am, src/native/native.c,
+       src/native/vm/cldc1.1/Makefile.am,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_Runtime.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/java_lang_Object.h, src/vm/exceptions.c,
+       src/vm/jit/alpha/md.c, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/arch.h,
+       src/vmcore/class.h:
+       * src/vm/jit/powerpc64/linux/md-abi.c: Adopt changes include files.
+
+       * src/vm/jit/powerpc64/emit.c: Likewise.
+
+       * src/vm/jit/powerpc64/md.c: Likewise.
+
+       * src/vm/jit/powerpc64/codegen.c: Likewise. Moved block closing
+       bracket.
+
+       * src/vm/jit/powerpc64/patcher.c: Likewise.
+
+       * src/vm/exceptions.c: new_arithmeticexception and
+       new_arrayindexoutofboundsexception prefixed by exceptions_.
+       [1cdc902a5ccf]
+
+2007-02-10  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md-abi.c,
+       src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/patcher.c:
+       * src/vm/jit/sparc64/codegen.c (createnativestub): Fixed stack
+       argument passing.
+
+       * src/vm/jit/sparc64/*: Adapted includes to new cacao structure.
+       [39f035e16f77]
+
+2007-02-10  pm  <pm>
+
+       * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h:
+       * s390/codegen.c: fix: ICMD_FCMPL generated wrong branch offset
+       * s390/codegen.h: likewise
+       * s390/asmpart.S: fix: asm_call_jit_compiler did not remove stack
+       frame
+       [3937893d7ada]
+
+       * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/patcher.c:
+       Continued work on S390 codegen. Affected files:
+
+       * s390/codegen.c
+       * s390/codegen.h
+       * s390/arch.h
+       * s390/patcher.c
+       * s390/asmpart.S
+       [baf322e0ebc6]
+
+2007-02-09  twisti  <twisti>
+
+       * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-abi.c,
+       src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/powerpc64/patcher.c:
+       * src/vm/jit/powerpc64/linux/md-os.c: Fixed includes.
+       * src/vm/jit/powerpc64/linux/md-abi.c: Likewise.
+       * src/vm/jit/powerpc64/md.c: Likewise.
+       * src/vm/jit/powerpc64/codegen.c: Likewise.
+       * src/vm/jit/powerpc64/patcher.c: Likewise.
+       [66efde2212b2]
+
+       * src/vm/jit/i386/asmpart.S:
+       * src/vm/jit/i386/asmpart.S (asm_compare_and_swap): Added ; after
+       lock, Darwin's assembler requires that. (asm_compare_and_swap):
+       Likewise.
+       [29838e9abba1]
+
+       * src/mm/boehm.c:
+       * src/mm/boehm.c [ENABLE_THREADS] (threads/native/threads.h):
+       Removed.
+       [7d3d2244cd52]
+
+       * src/vm/jit/powerpc/darwin/Makefile.am,
+       src/vm/jit/powerpc/linux/Makefile.am,
+       src/vm/jit/powerpc/netbsd/Makefile.am:
+       * src/vm/jit/powerpc/linux/Makefile.am (AM_CPPFLAGS): Added
+       -I$(top_builddir)/src.
+       * src/vm/jit/powerpc/darwin/Makefile.am: Likewise.
+       * src/vm/jit/powerpc/netbsd/Makefile.am: Likewise.
+       [27b01b1e3b7e]
+
+       * src/vm/vm.c, src/vmcore/class.h:
+       * src/vmcore/class.h (dummy_java_lang_Class): Added. (classinfo):
+       Use dummy_java_lang_Class.
+       * src/vm/vm.c (vm_create): Check dummy_java_lang_Class size.
+       [646f1b3bd20a]
+
+       * src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/java_lang_Runtime.c,
+       src/native/vm/java_lang_Runtime.h:
+       * src/native/vm/java_lang_Runtime.c [ENABLE_JAVASE]
+       (runFinalizersOnExit): Added.
+       * src/native/vm/java_lang_Runtime.h: Likewise.
+
+       * src/native/vm/gnu/java_lang_VMRuntime.c (exit): Renamed argument
+       par1 to status. (runFinalizersOnExit): Call
+       _Jv_java_lang_Runtime_runFinalizersOnExit.
+       [f35f918c49c4]
+
+       * src/native/include/Makefile.am, src/native/native.c,
+       src/native/vm/Makefile.am, src/native/vm/cldc1.1/Makefile.am,
+       src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
+       src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_Runtime.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h,
+       src/native/vm/java_lang_Object.h, src/native/vm/java_lang_Runtime.c,
+       src/native/vm/java_lang_Runtime.h, src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_throw_unsatisfiedlinkerror)
+       [!ENABLE_JAVASE]: Generate a java.lang.Error.
+
+       * src/native/vm/cldc1.1/java_lang_Class.c (isInstance): Added.
+       (isAssignableFrom): Likewise. (isInterface): Likewise. (isArray):
+       Likewise.
+
+       * src/native/vm/cldc1.1/java_lang_Object.c (hashCode): Likewise.
+       (notify): Likewise. (wait): Likewise.
+
+       * src/native/vm/cldc1.1/java_lang_String.c (hashCode): Smaller
+       implementation changes. (indexOf__II): Likewise. (lastIndexOf__II):
+       Likewise. (indexOf__I): Added.
+
+       * src/native/vm/cldc1.1/java_lang_Thread.c: Header updated.
+
+       * src/native/vm/cldc1.1/java_lang_Runtime.c (exitInternal): Fixed
+       signature. (freeMemory): Added. (totalMemory): Likewise. (gc):
+       Likewise.
+
+       * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c: New
+       file.
+       * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c:
+       Likewise.
+       * src/native/vm/cldc1.1/Makefile.am (libnativevmcore_la_SOURCES):
+       Added com_sun_cldc_io_ResourceInputStream.c and
+       com_sun_cldc_io_j2me_socket_Protocol.c.
+
+       * src/native/vm/java_lang_Runtime.c: New file.
+       * src/native/vm/java_lang_Runtime.h: Likewise.
+       * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
+       java_lang_Runtime.c and java_lang_Runtime.h.
+
+
+       * src/native/vm/java_lang_Class.c: Un-ifdef some functions for CLDC.
+       * src/native/vm/java_lang_Class.h: Likewise.
+
+       * src/native/vm/gnu/java_lang_VMRuntime.c
+       (native/vm/java_lang_Runtime.h): Added. (exit): Call
+       _Jv_java_lang_Runtime function. (freeMemory): Likewise.
+       (totalMemory): Likewise. (gc): Likewise.
+
+       * src/native/vm/java_lang_Object.h [ENABLE_JAVASE]
+       (native/include/java_lang_Cloneable.h): Only available for JavaSE
+       configurations.
+
+       * src/native/include/Makefile.am (JAVAME_CLDC1_1_HEADER_FILES):
+       Added com_sun_cldc_io_ResourceInputStream.h and
+       com_sun_cldc_io_j2me_socket_Protocol.h.
+
+       * src/native/native.c (dummynativetable) [ENABLE_JAVAME_CLDC1_1]:
+       Added new functions.
+       [fbdb38a96c9f]
+
+       * src/vm/jit/alpha/freebsd/Makefile.am,
+       src/vm/jit/alpha/linux/Makefile.am, src/vm/jit/alpha/md.c:
+       * src/vm/jit/alpha/md.c (vm/options.h): Changed to vmcore/options.h.
+
+       * src/vm/jit/alpha/linux/Makefile.am (AM_CPPFLAGS): Added
+       -I$(top_builddir)/src.
+       * src/vm/jit/alpha/freebsd/Makefile.am: Likewise.
+       [693b7e76e960]
+
+2007-02-08  tbfg  <tbfg>
+
+       * src/vm/jit/i386/cygwin/Makefile.am, src/vm/jit/i386/cygwin/md-asm.h,
+       src/vm/jit/i386/cygwin/md-os.c, src/vm/jit/i386/cygwin/ucontext.c,
+       src/vm/jit/i386/cygwin/ucontext.h, src/vm/jit/m68k/.cvsignore,
+       src/vm/jit/m68k/linux/.cvsignore, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md-asm.h,
+       src/vm/jit/s390/patcher.c:
+       * m68k/linux/.cvsignore: Added.
+       * m68k/.cvsignore: Added.
+       [cdf1b5289488]
+
+2007-02-08  michi  <michi>
+
+       * src/vm/jit/i386/cygwin/Makefile.am, src/vm/jit/i386/cygwin/md-asm.h,
+       src/vm/jit/i386/cygwin/md-os.c, src/vm/jit/i386/cygwin/ucontext.c,
+       src/vm/jit/i386/cygwin/ucontext.h:
+       * src/vm/jit/i386/cygwin/Makefile.am: Changed to unix fileformat.
+       * src/vm/jit/i386/cygwin/ucontext.h,
+       src/vm/jit/i386/cygwin/ucontext.c, src/vm/jit/i386/cygwin/md-os.c,
+       src/vm/jit/i386/cygwin/md-asm.h: Likewise.
+       [45fafa8afbb4]
+
+2007-02-08  twisti  <twisti>
+
+       * src/vm/jit/i386/cygwin/Makefile.am,
+       src/vm/jit/i386/freebsd/Makefile.am,
+       src/vm/jit/i386/linux/Makefile.am:
+       * src/vm/jit/i386/linux/Makefile.am (AM_CPPFLAGS) Added
+       -I$(top_builddir)/src.
+       * src/vm/jit/i386/cygwin/Makefile.am: Likewise.
+       * src/vm/jit/i386/freebsd/Makefile.am: Likewise.
+       [466a8912874b]
+
+2007-02-07  pm  <pm>
+
+       * src/vm/jit/codegen-common.c, src/vm/jit/s390/asmpart.S,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/md-asm.h,
+       src/vm/jit/s390/patcher.c:
+       Continued work on S390 port.
+       java.lang.ClassLoader.getSystemClassLoader is now compiled, patched,
+       called and the patcher trigger compilation of another method.
+
+       * jit/s390/emit.c: Likiwise.
+       * jit/s390/codegen.c: Likewise.
+       * jit/s390/codegen.h: Likewise.
+       * jit/s390/md-asm.h: Likewise.
+       * jit/s390/patcher.c: Likewise.
+       * jit/s390/asmpart.S: Likewise.
+       * jit/codegen-common.c: Likewise.
+       [592440195369]
+
+2007-02-07  tbfg  <tbfg>
+
+       * src/vm/jit/m68k/Makefile.am:
+       * src/vm/jit/m68k/Makefile.am (DIST_SUBDIRS): Removed uclinux, added
+       linux.
+       [f967fb516920]
+
+       * configure.ac, src/mm/boehm-gc/include/private/gc_locks.h,
+       src/vm/jit/m68k/linux/Makefile.am, src/vm/jit/m68k/linux/md-abi.c,
+       src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/linux/md-asm.h,
+       src/vm/jit/m68k/linux/md-os.c:
+       * src/vm/jit/m68k/linux/md-abi.c: Added.
+       * src/vm/jit/m68k/uclinux: Removed.
+       * src/mm/boehm-gc/include/private/gc_locks.h (GC_test_and_set):
+       Disabled, assembly does not work on coldfire.
+       * configure.ac: Enabled m68k builds.
+       [76b92aaedb38]
+
+2007-02-07  twisti  <twisti>
+
+       * configure.ac, src/Makefile.am, src/cacao/Makefile.am,
+       src/cacao/cacao.c, src/cacaoh/Makefile.am, src/cacaoh/cacaoh.c,
+       src/cacaoh/headers.c, src/cacaoh/headers.h, src/lib/Makefile.am,
+       src/mm/Makefile.am, src/mm/boehm.c, src/mm/gc-common.h,
+       src/mm/memory.c, src/native/include/.cvsignore,
+       src/native/include/Makefile.am,
+       src/native/include/java_lang_Class.h,
+       src/native/include/java_lang_ClassLoader.h,
+       src/native/include/java_lang_Cloneable.h,
+       src/native/include/java_lang_Object.h,
+       src/native/include/java_lang_String.h,
+       src/native/include/java_lang_Thread.h,
+       src/native/include/java_lang_ThreadGroup.h,
+       src/native/include/java_lang_Throwable.h,
+       src/native/include/java_lang_VMThread.h,
+       src/native/include/java_lang_VMThrowable.h,
+       src/native/include/java_util_Properties.h, src/native/jni.c,
+       src/native/jni.h, src/native/native.c, src/native/native.h,
+       src/native/vm/Makefile.am, src/threads/native/Makefile.am,
+       src/threads/native/lock.c, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/threads/none/lock.h,
+       src/threads/none/threads.h, src/toolbox/Makefile.am,
+       src/toolbox/avl.c, src/toolbox/list.c, src/toolbox/logging.c,
+       src/toolbox/logging.h, src/vm/Makefile.am, src/vm/access.c,
+       src/vm/access.h, src/vm/annotation.c, src/vm/annotation.h,
+       src/vm/builtin.c, src/vm/builtin.h, src/vm/builtintable.inc,
+       src/vm/class.c, src/vm/class.h, src/vm/classcache.c,
+       src/vm/classcache.h, src/vm/descriptor.c, src/vm/descriptor.h,
+       src/vm/exceptions.c, src/vm/exceptions.h, src/vm/field.c,
+       src/vm/field.h, src/vm/finalizer.c, src/vm/hashtable.c,
+       src/vm/hashtable.h, src/vm/initialize.c, src/vm/initialize.h,
+       src/vm/jit/Makefile.am, src/vm/jit/abi.h,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/arch.h,
+       src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c,
+       src/vm/jit/alpha/md-abi.c, src/vm/jit/alpha/patcher.c,
+       src/vm/jit/asmpart.h, src/vm/jit/code.c, src/vm/jit/code.h,
+       src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h,
+       src/vm/jit/dseg.c, src/vm/jit/dseg.h, src/vm/jit/emit-common.c,
+       src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, src/vm/jit/i386
+       /md-abi.c, src/vm/jit/i386/md.c, src/vm/jit/i386/patcher.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/jit.c, src/vm/jit/jit.h,
+       src/vm/jit/loop/graph.h, src/vm/jit/loop/loop.h,
+       src/vm/jit/mips/arch.h, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/disass.c,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md-asm.h,
+       src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c,
+       src/vm/jit/optimizing/Makefile.am, src/vm/jit/optimizing/ifconv.c,
+       src/vm/jit/optimizing/ifconv.h, src/vm/jit/optimizing/profile.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/parisc/arch.h,
+       src/vm/jit/parse.c, src/vm/jit/powerpc/arch.h,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c,
+       src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/powerpc64/arch.h, src/vm/jit/show.c,
+       src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/sparc64/patcher.c, src/vm/jit/stack.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h,
+       src/vm/jit/tools/Makefile.am, src/vm/jit/tools/genoffsets.c,
+       src/vm/jit/verify/typecheck-stackbased.c,
+       src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/verify/typeinfo.h, src/vm/jit/x86_64/Makefile.am,
+       src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/codegen.c,
+       src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/md.c,
+       src/vm/jit/x86_64/patcher.c, src/vm/linker.c, src/vm/linker.h,
+       src/vm/loader.c, src/vm/loader.h, src/vm/method.c, src/vm/method.h,
+       src/vm/options.c, src/vm/options.h, src/vm/properties.c,
+       src/vm/properties.h, src/vm/references.h, src/vm/resolve.c,
+       src/vm/resolve.h, src/vm/rt-timing.c, src/vm/rt-timing.h,
+       src/vm/signal.c, src/vm/signallocal.h, src/vm/statistics.c,
+       src/vm/statistics.h, src/vm/string.c, src/vm/stringlocal.h,
+       src/vm/suck.c, src/vm/suck.h, src/vm/utf8.c, src/vm/utf8.h,
+       src/vm/vm.c, src/vm/zip.c, src/vm/zip.h:
+       * Merged with trunk.
+       [e840d73af6a9]
+
+2007-02-06  twisti  <twisti>
+
+       * src/native/vm/cldc1.1/Makefile.am:
+       * src/native/vm/cldc1.1/Makefile.am: Updated header.
+       [ab6eb7c14e9b]
+
+       * src/native/vm/cldc1.1/java_lang_String.c:
+       * src/native/vm/cldc1.1/java_lang_String.c (hashCode): Implemented.
+       (indexOf__II): Likewise. (lastIndexOf__II): Likewise.
+       [b527bef0a2f2]
+
+       * src/threads/native/Makefile.am, src/vm/jit/x86_64/Makefile.am,
+       src/vm/jit/x86_64/freebsd/Makefile.am,
+       src/vm/jit/x86_64/linux/Makefile.am:
+       * src/threads/native/Makefile.am (AM_CPPFLAGS): Added
+       -I$(top_builddir)/src.
+       * src/vm/jit/x86_64/Makefile.am: Likewise.
+       * src/vm/jit/x86_64/linux/Makefile.am: Likewise.
+       * src/vm/jit/x86_64/freebsd/Makefile.am: Likewise.
+       [e93ab8483e6b]
+
+       * src/vm/jit/powerpc/codegen.c:
+       * src/vm/jit/powerpc/codegen.c (codegen) [ENABLE_PROFILING]: #ifdef
+       profiling code.
+       [3f09fe8f17ae]
+
+       * src/native/vm/Makefile.am:
+       * src/native/vm/Makefile.am (DIST_SUBDIRS): Added missing \.
+       [f9a03ea56104]
+
+       * src/vm/jit/tools/genoffsets.c:
+       * src/vm/jit/tools/genoffsets.c (vm/jit/stacktrace.h): Not required,
+       removed.
+       [4c950490c9bb]
+
+       * src/vm/jit/tools/Makefile.am:
+       * src/vm/jit/tools/Makefile.am: Cosmetic changes.
+       [28ac1f93fda5]
+
+       * src/mm/Makefile.am, src/vm/Makefile.am, src/vm/jit/Makefile.am,
+       src/vm/jit/optimizing/Makefile.am:
+       * src/vm/jit/optimizing/Makefile.am (AM_CPPFLAGS): Added
+       -I$(top_builddir)/src.
+       * src/vm/jit/Makefile.am: Likewise.
+       * src/vm/Makefile.am: Likewise.
+       * src/mm/Makefile.am: Likewise.
+       [b769e2013034]
+
+       * src/vm/jit/x86_64/freebsd/md-os.c, src/vm/jit/x86_64/linux/md-os.c:
+       * src/vm/jit/linux/md-os.c (thread_restartcriticalsection): Added
+       missing cast and pass pc to critical_find_restart_point.
+       * src/vm/jit/freebsd/md-os.c (thread_restartcriticalsection):
+       Likewise.
+       [304f206f98a4]
+
+2007-02-05  twisti  <twisti>
+
+       * src/cacaoh/dummy.c:
+       * src/cacaoh/dummy.c (builtin_clone, builtin_isanysubclass)
+       (builtin_new): Keep compiler happy and return a value.
+       [7b6ed76f17e1]
+
+       * src/vm/signallocal.h:
+       * src/vm/signallocal.h (vm/types.h): Added. (vm/global.h): Likewise.
+       [284179c96249]
+
+       * configure.ac, src/vm/jit/x86_64/Makefile.am,
+       src/vm/jit/x86_64/freebsd/.cvsignore,
+       src/vm/jit/x86_64/freebsd/Makefile.am, src/vm/jit/x86_64/freebsd/md-
+       os.c:
+       * configure.ac (AC_CONFIG_FILES): Added
+       src/vm/jit/x86_64/freebsd/Makefile.
+
+       * src/vm/jit/x86_64/Makefile.am (DIST_SUBDIRS): Added freebsd.
+
+       * src/vm/jit/x86_64/freebsd/md-os.c: New file.
+       * src/vm/jit/x86_64/freebsd/Makefile.am: Likewise.
+       * src/vm/jit/x86_64/freebsd/.cvsignore: Likewise.
+       [f06962a27a47]
+
+       * configure.ac, src/vm/jit/x86_64/Makefile.am,
+       src/vm/jit/x86_64/linux/.cvsignore,
+       src/vm/jit/x86_64/linux/Makefile.am, src/vm/jit/x86_64/linux/md-
+       os.c, src/vm/jit/x86_64/md.c:
+       * configure.ac (AC_CONFIG_FILES): Added
+       src/vm/jit/x86_64/linux/Makefile.
+
+       * src/vm/jit/x86_64/Makefile.am (DIST_SUBDIRS): Added. (SUBDIRS):
+       Likewise. (libarch_la_LIBADD): Likewise.
+
+       * src/vm/jit/x86_64/md.c (md_signal_handler_sigsegv)
+       (md_signal_handler_sigfpe, md_signal_handler_sigusr2)
+       (thread_restartcriticalsection): Removed.
+
+       * src/vm/jit/x86_64/linux/md-os.c: New file.
+       * src/vm/jit/x86_64/linux/Makefile.am: Likewise.
+       * src/vm/jit/x86_64/linux/.cvsignore: Likewise.
+       [50fd3baf26ce]
+
+2007-02-04  pm  <pm>
+
+       * src/vm/jit/codegen-common.h, src/vm/jit/dseg.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390
+       /md-abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390/md-asm.h,
+       src/vm/jit/s390/md.c:
+       * jit/codegen-common.h: Enabled dseg_adddata for s390.
+       * jit/dseg.c: Likewise.
+       * jit/s390/md-abi.h: Continued work on s390 port.
+       * jit/s390/emit.c: Likewise.
+       * jit/s390/md.c: Likewise.
+       * jit/s390/codegen.c: Likewise.
+       * jit/s390/codegen.h: Likewise.
+       * jit/s390/md-asm.h: Likewise.
+       * jit/s390/asmpart.S: Likewise.
+       * jit/s390/md-abi.c: Likewise.
+       [39030922ab4c]
+
+2007-02-04  twisti  <twisti>
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_ExceptionDescribe): Fixed typo.
+       [ad6e18d9a2c9]
+
+2007-02-03  twisti  <twisti>
+
+       * src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h:
+       * src/vm/jit/x86_64/codegen.c (codegen) [ENABLE_PROFILING]: #ifdef
+       instrumentation code. (createnativestub) [ENABLE_PROFILING]:
+       Likewise.
+
+       * src/vm/jit/x86_64/codegen.h [ENABLE_PROFILING]
+       (PROFILE_CYCLE_START) (PROFILE_CYCLE_STOP): Added #ifdef.
+       [222c9620051f]
+
+       * src/native/jni.c, src/vm/builtin.c, src/vm/finalizer.c,
+       src/vm/signal.c:
+       * src/vm/builtin.c [ENABLE_THREADS] (threads/native/threads.h):
+       Removed. [ENABLE_THREADS] (threads/native/lock.h): Added.
+       (builtin_throw_exception): Use exceptions_set_exception.
+
+       * src/vm/finalizer.c (finalizer_run): Likewise.
+
+       * src/vm/signal.c (signal_start_thread): Use #warning instead of
+       #error (temporarily).
+
+       * src/native/jni.c (_Jv_jni_invokeNative): Use
+       exceptions_get_exception, and exceptions_clear_exception.
+       (_Jv_JNI_ExceptionDescribe): Likewise. (_Jv_JNI_IsAssignableFrom):
+       Use exceptions_set_exception. (_Jv_JNI_ExceptionOccurred): Use
+       exceptions_get_exception. (_Jv_JNI_ExceptionCheck): Likewise.
+       (_Jv_JNI_ExceptionClear): Use exceptions_clear_exception.
+       [fed9851c2331]
+
+2007-02-02  twisti  <twisti>
+
+       * src/vm/jit/i386/codegen.c:
+       * src/vm/jit/i386/codegen.c (codegen) [ENABLE_PROFILING]: Profiling
+       code. (createnativestub): Likewise.
+       [7a50687ad4fa]
+
+       * src/native/vm/java_lang_Object.c:
+       * src/native/vm/java_lang_Object.c [ENABLE_JAVAME_CLDC1_1]
+       (native/include/java_lang_String.h): Added.
+       [fd01a1f6bbed]
+
+       * src/native/vm/java_lang_Class.h:
+       * src/native/vm/java_lang_Class.h
+       (native/include/java_lang_String.h): Required by java_lang_Class.h
+       for Java ME.
+       [f4ce4816ce07]
+
+2007-02-02  michi  <michi>
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.h:
+       * src/vm/jit/arm/md-abi.h: Renamed REG_IP to REG_PV (special favor
+       for twisti).
+       * src/vm/jit/arm/emit.c, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h: Adapted to the above change.
+       [09cb587627a5]
+
+2007-02-02  twisti  <twisti>
+
+       * src/vm/jit/jit.c:
+       * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_PROFILING]: Call
+       reorder only when profiling.
+       [b82b4ffef10b]
+
+       * src/vm/jit/code.h, src/vm/jit/jit.c:
+       * src/vm/jit/code.h (codeinfo) [ENABLE_PROFILING]: Made frequency,
+       bbfrequency, and cycles conditional.
+
+       * src/vm/jit/jit.c (jit_compile) [ENABLE_PROFILING]: Likewise.
+       (jit_compile_intern) [ENABLE_PROFILING]: Likewise.
+       [aefa55d03b45]
+
+       * src/vm/jit/optimizing/Makefile.am:
+       * src/vm/jit/optimizing/Makefile.am [ENABLE_PROFILING]
+       (REORDER_SOURCES): Moved here till we have something better.
+       [0d4c94194c02]
+
+2007-02-01  twisti  <twisti>
+
+       * src/vmcore/suck.c:
+       * src/vmcore/suck.c (assert.h): Added. (suck_float): Use assert
+       instead of an exception. (suck_double): Likewise.
+       [307597c08f3e]
+
+       * src/vmcore/linker.c:
+       * src/vmcore/linker.c (link_class_intern): Also align double and s8
+       fields to 4-bytes for ARM.
+       [bd695dd70df6]
+
+       * src/vm/exceptions.c, src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/vmcore/utf8.c (utf_java_lang_InvocationTargetException): Is
+       actually called utf_java_lang_reflect_InvocationTargetException.
+       (utf8_init): Likewise.
+
+       * src/vmcore/utf8.h (utf_java_lang_InvocationTargetException):
+       Likewise.
+
+       * src/vm/exceptions.c (exceptions_throw_invocationtargetexception):
+       Likewise.
+       [27db8a25b0c5]
+
+       * src/vm/jit/code.c:
+       * src/vm/jit/code.c [ENABLE_THREADS] (threads/native/lock.h): Added.
+       [5c7f3502d8dc]
+
+       * src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/jit.c,
+       src/vm/jit/jit.h, src/vmcore/loader.c, src/vmcore/method.h:
+       * src/vmcore/method.h (methodinfo): Removed member object.
+       * src/vm/jit/code.h (codeinfo): Added member object.
+
+       * src/vmcore/loader.c (loader_load_method): Removed
+       lock_init_object_lock. (load_newly_created_array): Likewise.
+       * src/vm/jit/code.c (code_codeinfo_new): Added lock_init_object_lock.
+
+       * src/vm/jit/jit.c (jit_jitdata_new): Changed signature.
+       (jit_compile): Use codeinfo lock object instead of methodinfo.
+       (jit_recompile): Changed signature.
+       * src/vm/jit/jit.h (jit_jitdata_new): Likewise.
+       [b10236223add]
+
+2007-01-31  twisti  <twisti>
+
+       * src/cacaoh/dummy.c:
+       * src/cacaoh/dummy.c (pthread.h): Added.
+       [9e9bd911a22a]
+
+       * src/cacaoh/dummy.c, src/toolbox/logging.c:
+       * src/toolbox/logging.c (log_start): Uncommented thread pointer
+       stuff.
+       * src/cacaoh/dummy.c (threads_get_current_threadobject): Added.
+       [edfa159dd432]
+
+       * src/native/jni.c:
+       * src/native/jni.c (_Jv_JNI_ThrowNew): Fixed warnings.
+       [2e98f9533278]
+
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c:
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c: Updated
+       year.
+       [5972b844a2f3]
+
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c:
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (string.h):
+       Added. (mm/memory.h): Likewise.
+       [932a77fd8583]
+
+       * src/vmcore/loader.c:
+       * src/vmcore/loader.c (load_newly_created_array) [ENABLE_JAVASE]:
+       Fixed interfacescount.
+       [2e8984fe366c]
+
+       * src/vm/exceptions.c, src/vm/exceptions.h:
+       * src/vm/exceptions.c [ENABLE_JAVAME_CLDC1_1](exceptions_new_error):
+       New function. (exceptions_asm_new_abstractmethoderror)
+       [!ENABLE_JAVASE]: Use exceptions_new_error.
+       (exceptions_throw_virtualmachineerror): Removed.
+       * src/vm/exceptions.h (exceptions_throw_virtualmachineerror):
+       Likewise.
+       [5b39ee72f613]
+
+       * src/vm/jit/Makefile.am:
+       * src/vm/jit/Makefile.am: Fixed !ENABLE_VERIFER build.
+       [f7b45962f8d0]
+
+2007-01-30  twisti  <twisti>
+
+       * src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c, src/vm/jit/arm/md-
+       abi.c, src/vm/jit/arm/md-abi.h, src/vm/jit/arm/md.c,
+       src/vm/jit/arm/patcher.c:
+       * src/vm/jit/arm/emit.c (mm/memory.h): Added. (vm/global.h):
+       Likewise. (emit_patcher_stubs): Align stack to 8-byte.
+       (emit_verbosecall_exit): Smaller optimizations.
+
+       * src/vm/jit/arm/md-abi.h (config.h): Added. (REG_A1_A2_PACKED):
+       Defined.
+
+       * src/vm/jit/arm/md.c: Fixed includes. (md_codegen_get_pv_from_pc):
+       Use vm_abort.
+
+       * src/vm/jit/arm/codegen.c: Fixed includes. (codegen): Align stack
+       to 8-byte. (createnativestub): Likewise.
+
+       * src/vm/jit/arm/codegen.h (M_ADD_IMM_EXT_MUL4): Added do-while.
+       (M_SUB_IMM_EXT_MUL4): Likewise.
+
+       * src/vm/jit/arm/patcher.c: Fixed includes. (patcher_wrapper): Align
+       stack to 8-byte.
+       * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Likewise.
+
+       * src/vm/jit/arm/md-abi.c: Fixed includes.
+       [0a30c3d70337]
+
+       * src/vm/signal.c, src/vm/vm.c:
+       * src/vm/signal.c (signal_init): Disable signal-thread handling
+       temporarily.
+       * src/vm/vm.c (vm_create): Likewise.
+       [7f75f5c44e54]
+
+2007-01-29  twisti  <twisti>
+
+       * src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Runtime.c,
+       src/native/vm/java_lang_Class.c, src/vm/properties.c,
+       src/vm/string.c, src/vmcore/class.c, src/vmcore/resolve.c,
+       src/vmcore/utf8.c, src/vmcore/utf8.h:
+       * src/vm/string.c (native/jni.h): Added.
+       * src/vm/properties.c (native/jni.h): Likewise.
+
+       * src/native/vm/cldc1.1/java_lang_Runtime.c: Includes fixed for
+       cacaoh-changes.
+       * src/native/vm/cldc1.1/java_lang_Class.c: Likewise.
+
+       * src/native/vm/java_lang_Class.c [ENABLE_JAVAME_CLDC1_1]
+       (native/include/java_lang_String.h): Added. (forName): #ifdef'd
+       loader variable.
+
+       * src/vmcore/class.c (class_resolveclassmethod): Removed Java ME
+       exception handling, we do that in the exception function itself.
+       (class_resolveinterfacemethod): Likewise.
+       * src/vmcore/resolve.c (resolve_method_invokespecial): Likewise.
+
+       * src/vmcore/utf8.c [ENABLE_JAVASE]
+       (utf_java_lang_AbstractMethodError, utf_java_lang_NoSuchFieldError)
+       (utf_java_lang_NoSuchMethodError): Removed ifdef.
+       * src/vmcore/utf8.h: Likewise.
+       [882a47a8b48a]
+
+2007-01-29  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/patcher.c:
+       * src/vm/jit/sparc64/codegen.h: Fixed double register number packing
+       and fp compare instruction macros.
+       * src/vm/jit/sparc64/codegen.c: Fixed fp compares. Fixed INT2CHAR.
+       Fixed fp argument saving in createnativestub().
+
+       * src/vm/jit/sparc64/patcher.c: Implemented get/put field patcher.
+
+       * src/vm/jit/sparc64/md.c: Removed printf.
+       [402167948fee]
+
+2007-01-29  twisti  <twisti>
+
+       * src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, src/vm/jit/i386
+       /md-abi.c, src/vm/jit/i386/md.c, src/vm/jit/i386/patcher.c:
+       * src/vm/jit/i386/emit.c: Includes fixed for cacaoh-changes.
+       * src/vm/jit/i386/md.c: Likewise.
+       * src/vm/jit/i386/codegen.c: Likewise.
+       * src/vm/jit/i386/patcher.c: Likewise.
+       * src/vm/jit/i386/md-abi.c: Likewise.
+       [0b43a2caf86d]
+
+       * src/vm/jit/i386/asmpart.S:
+       * src/vm/jit/i386/asmpart.S (asm_compare_and_swap): New function.
+       (asm_memory_barrier): Likewise.
+       [4baa01211589]
+
+       * src/vm/jit/alpha/asmpart.S:
+       * src/vm/jit/alpha/asmpart.S (asm_compare_and_swap): Changed
+       comment.
+       [edf7afa4a623]
+
+       * src/vm/jit/mips/codegen.c, src/vm/jit/mips/disass.c,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md.c,
+       src/vm/jit/mips/patcher.c:
+       * src/vm/jit/mips/emit.c: Include fixes for cacaoh-changes.
+       * src/vm/jit/mips/md.c: Likewise.
+       * src/vm/jit/mips/codegen.c: Likewise
+       * src/vm/jit/mips/linux/md-os.c: Likewise
+       * src/vm/jit/mips/disass.c: Likewise
+       * src/vm/jit/mips/patcher.c: Likewise
+       * src/vm/jit/mips/md-abi.c: Likewise
+       [5075d26aabb8]
+
+       * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c,
+       src/vm/jit/alpha/linux/md-os.c, src/vm/jit/alpha/md-abi.c,
+       src/vm/jit/alpha/patcher.c:
+       * src/vm/jit/alpha/emit.c: Fixed includes for cacaoh-changes.
+       * src/vm/jit/alpha/codegen.c: Likewise.
+       * src/vm/jit/alpha/linux/md-os.c: Likewise.
+       * src/vm/jit/alpha/patcher.c: Likewise.
+       * src/vm/jit/alpha/md-abi.c: Likewise.
+       [65984e7b13d1]
+
+       * src/native/include/.cvsignore:
+       * src/native/include/.cvsignore: Ignore all *.h files.
+       [afcbe578518b]
+
+       * src/vm/jit/x86_64/md.c:
+       * src/vm/jit/x86_64/md.c: Fixed includes for cacaoh-changes.
+       [900dc7622fe5]
+
+       * src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/patcher.c:
+       * src/vm/jit/x86_64/emit.c: Fixed includes for cacaoh-changes.
+       * src/vm/jit/x86_64/codegen.c: Likewise.
+       * src/vm/jit/x86_64/patcher.c: Likewise.
+       * src/vm/jit/x86_64/md-abi.c: Likewise.
+       [16d9eafe63cc]
+
+       * src/vm/jit/emit-common.c, src/vm/jit/jit.c, src/vmcore/stackmap.c:
+       * src/vmcore/stackmap.c [ENABLE_STATISTICS] (vmcore/statistics.h):
+       Removed ifdef.
+       * src/vm/jit/jit.c: Likewise.
+       * src/vm/jit/emit-common.c: Likewise.
+       [d184eba61575]
+
+       * configure.ac, src/Makefile.am, src/cacao/Makefile.am,
+       src/cacaoh/Makefile.am, src/cacaoh/cacaoh.c, src/cacaoh/dummy.c,
+       src/cacaoh/headers.c, src/cacaoh/headers.h, src/mm/Makefile.am,
+       src/mm/boehm.c, src/mm/gc-common.h, src/mm/memory.c,
+       src/native/include/Makefile.am,
+       src/native/include/java_lang_Class.h,
+       src/native/include/java_lang_ClassLoader.h,
+       src/native/include/java_lang_Cloneable.h,
+       src/native/include/java_lang_Object.h,
+       src/native/include/java_lang_String.h,
+       src/native/include/java_lang_Thread.h,
+       src/native/include/java_lang_ThreadGroup.h,
+       src/native/include/java_lang_Throwable.h,
+       src/native/include/java_lang_VMThread.h,
+       src/native/include/java_lang_VMThrowable.h,
+       src/native/include/java_util_Properties.h, src/native/jni.c,
+       src/native/jni.h, src/native/native.c, src/native/native.h,
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, src/native/vm/
+       gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
+       src/native/vm/gnu/java_lang_VMClass.c,
+       src/native/vm/gnu/java_lang_VMClassLoader.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMThrowable.c,
+       src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
+       src/native/vm/gnu/java_lang_reflect_Constructor.c,
+       src/native/vm/gnu/java_lang_reflect_Field.c,
+       src/native/vm/gnu/java_lang_reflect_Method.c,
+       src/native/vm/gnu/java_security_VMAccessController.c,
+       src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Object.c,
+       src/native/vm/java_lang_Thread.c, src/threads/native/lock.c,
+       src/threads/native/threads.c, src/threads/native/threads.h,
+       src/threads/none/lock.h, src/threads/none/threads.h,
+       src/toolbox/Makefile.am, src/toolbox/avl.c, src/toolbox/hashtable.c,
+       src/toolbox/hashtable.h, src/toolbox/list.c, src/toolbox/logging.c,
+       src/toolbox/logging.h, src/vm/Makefile.am, src/vm/access.c,
+       src/vm/access.h, src/vm/annotation.c, src/vm/annotation.h,
+       src/vm/builtin.c, src/vm/builtin.h, src/vm/class.c, src/vm/class.h,
+       src/vm/classcache.c, src/vm/classcache.h, src/vm/descriptor.c,
+       src/vm/descriptor.h, src/vm/exceptions.c, src/vm/exceptions.h,
+       src/vm/field.c, src/vm/field.h, src/vm/finalizer.c,
+       src/vm/hashtable.c, src/vm/hashtable.h, src/vm/initialize.c,
+       src/vm/initialize.h, src/vm/jit/abi.h,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/asmpart.h,
+       src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/codegen-common.c,
+       src/vm/jit/codegen-common.h, src/vm/jit/dseg.c, src/vm/jit/dseg.h,
+       src/vm/jit/emit-common.c, src/vm/jit/jit.c, src/vm/jit/jit.h,
+       src/vm/jit/loop/graph.h, src/vm/jit/loop/loop.h,
+       src/vm/jit/optimizing/ifconv.c, src/vm/jit/optimizing/ifconv.h,
+       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/emit.c, src/vm/jit/powerpc/linux/md-abi.c,
+       src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/patcher.c,
+       src/vm/jit/show.c, src/vm/jit/stack.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/stacktrace.h, src/vm/jit/tools/genoffsets.c,
+       src/vm/jit/verify/typecheck-stackbased.c, src/vm/jit/verify
+       /typecheck-typeinferer.c, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typeinfo.c, src/vm/jit/verify/typeinfo.h,
+       src/vm/linker.c, src/vm/linker.h, src/vm/loader.c, src/vm/loader.h,
+       src/vm/method.c, src/vm/method.h, src/vm/options.c,
+       src/vm/options.h, src/vm/properties.c, src/vm/properties.h,
+       src/vm/references.h, src/vm/resolve.c, src/vm/resolve.h, src/vm/rt-
+       timing.c, src/vm/rt-timing.h, src/vm/signal.c, src/vm/signallocal.h,
+       src/vm/stackmap.c, src/vm/stackmap.h, src/vm/statistics.c,
+       src/vm/statistics.h, src/vm/string.c, src/vm/stringlocal.h,
+       src/vm/suck.c, src/vm/suck.h, src/vm/utf8.c, src/vm/utf8.h,
+       src/vm/vm.c, src/vm/zip.c, src/vm/zip.h, src/vmcore/.cvsignore,
+       src/vmcore/Makefile.am, src/vmcore/annotation.c,
+       src/vmcore/annotation.h, src/vmcore/class.c, src/vmcore/class.h,
+       src/vmcore/classcache.c, src/vmcore/classcache.h,
+       src/vmcore/descriptor.c, src/vmcore/descriptor.h,
+       src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.c,
+       src/vmcore/linker.h, src/vmcore/loader.c, src/vmcore/loader.h,
+       src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c,
+       src/vmcore/options.h, src/vmcore/references.h, src/vmcore/resolve.c,
+       src/vmcore/resolve.h, src/vmcore/rt-timing.c, src/vmcore/rt-
+       timing.h, src/vmcore/stackmap.c, src/vmcore/stackmap.h,
+       src/vmcore/statistics.c, src/vmcore/statistics.h, src/vmcore/suck.c,
+       src/vmcore/suck.h, src/vmcore/utf8.c, src/vmcore/utf8.h,
+       src/vmcore/zip.c, src/vmcore/zip.h:
+       * This is a rather huge commit, which changes the build order of
+       various parts to be able to bootstrap cacaoh without any
+       dependencies on a generated header file. I include the file list
+       from SVN, so we can see what happened to the files.
+
+       Here we go (D-files were mostly moved to src/vmcore):
+
+       D src/vm/hashtable.h D src/vm/options.h M
+       src/vm/properties.h D src/vm/zip.c D src/vm/class.c D
+       src/vm/suck.c D src/vm/loader.c M src/vm/builtin.c M
+       src/vm/string.c D src/vm/zip.h D src/vm/class.h D src/vm
+       /rt-timing.c D src/vm/suck.h D src/vm/annotation.c M
+       src/vm/builtin.h D src/vm/loader.h D src/vm/descriptor.c D
+       src/vm/annotation.h D src/vm/rt-timing.h D src/vm/resolve.c D
+       src/vm/method.c D src/vm/descriptor.h M src/vm/finalizer.c D
+       src/vm/resolve.h D src/vm/method.h D src/vm/references.h D
+       src/vm/classcache.c D src/vm/statistics.c D
+       src/vm/classcache.h D src/vm/statistics.h M
+       src/vm/initialize.c M src/vm/access.c D src/vm/stackmap.c M
+       src/vm/jit/powerpc/linux/md-abi.c M src/vm/jit/powerpc/emit.c M
+       src/vm/jit/powerpc/md.c M src/vm/jit/powerpc/codegen.c M
+       src/vm/jit/powerpc/patcher.c M src/vm/jit/codegen-common.h M
+       src/vm/jit/abi.h M src/vm/jit/stack.c M
+       src/vm/jit/optimizing/profile.c M
+       src/vm/jit/optimizing/recompile.c M
+       src/vm/jit/optimizing/ifconv.c M src/vm/jit/optimizing/ifconv.h M
+       src/vm/jit/code.c M src/vm/jit/tools/genoffsets.c M
+       src/vm/jit/code.h M src/vm/jit/show.c M src/vm/jit/dseg.c M
+       src/vm/jit/verify/typeinfo.h M src/vm/jit/verify/typecheck-
+       typeinferer.c M src/vm/jit/verify/typecheck.c M
+       src/vm/jit/verify/typecheck-stackbased.c M
+       src/vm/jit/verify/typeinfo.c M src/vm/jit/dseg.h M
+       src/vm/jit/loop/loop.h M src/vm/jit/loop/graph.h M
+       src/vm/jit/allocator/simplereg.c M src/vm/jit/parse.c M
+       src/vm/jit/asmpart.h M src/vm/jit/stacktrace.c M src/vm/jit
+       /emit-common.c M src/vm/jit/jit.c M src/vm/jit/stacktrace.h M
+       src/vm/jit/codegen-common.c M src/vm/jit/jit.h M
+       src/vm/initialize.h M src/vm/access.h D src/vm/stackmap.h M
+       src/vm/signal.c M src/vm/exceptions.c M src/vm/vm.c D
+       src/vm/field.c D src/vm/linker.c M src/vm/exceptions.h M
+       src/vm/stringlocal.h D src/vm/utf8.c D src/vm/field.h M
+       src/vm/Makefile.am D src/vm/linker.h D src/vm/hashtable.c D
+       src/vm/options.c D src/vm/utf8.h M src/vm/properties.c M
+       src/vm/signallocal.h M src/cacao/Makefile.am M
+       src/native/jni.c M src/native/vm/java_lang_Class.c M
+       src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c M
+       src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c M
+       src/native/vm/gnu/java_security_VMAccessController.c M
+       src/native/vm/gnu/java_lang_VMClassLoader.c M
+       src/native/vm/gnu/java_lang_management_VMManagementFactory.c M
+       src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c M
+       src/native/vm/gnu/java_lang_VMClass.c M
+       src/native/vm/gnu/java_lang_VMThread.c M
+       src/native/vm/gnu/gnu_classpath_VMSystemProperties.c M
+       src/native/vm/gnu/java_lang_reflect_Method.c M
+       src/native/vm/gnu/java_lang_VMRuntime.c M
+       src/native/vm/gnu/java_lang_reflect_Field.c M
+       src/native/vm/gnu/gnu_classpath_VMStackWalker.c M src/native/vm/g
+       nu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c M
+       src/native/vm/gnu/java_lang_reflect_Constructor.c M
+       src/native/vm/gnu/java_lang_VMThrowable.c M
+       src/native/vm/java_lang_Object.c M
+       src/native/vm/java_lang_Thread.c D
+       src/native/include/java_lang_Thread.h D
+       src/native/include/java_lang_Throwable.h D
+       src/native/include/java_util_Properties.h D
+       src/native/include/java_lang_VMThread.h D
+       src/native/include/java_lang_VMThrowable.h D
+       src/native/include/java_lang_ClassLoader.h M
+       src/native/include/Makefile.am D
+       src/native/include/java_lang_Cloneable.h D
+       src/native/include/java_lang_ThreadGroup.h D
+       src/native/include/java_lang_Class.h D
+       src/native/include/java_lang_Object.h D
+       src/native/include/java_lang_String.h M src/native/jni.h M
+       src/native/native.c M src/native/native.h A
+       src/toolbox/hashtable.h M src/toolbox/list.c M
+       src/toolbox/avl.c M src/toolbox/logging.c M
+       src/toolbox/Makefile.am M src/toolbox/logging.h A
+       src/toolbox/hashtable.c M src/mm/gc-common.h M
+       src/mm/Makefile.am M src/mm/memory.c M src/mm/boehm.c M
+       src/Makefile.am M src/threads/none/threads.h M
+       src/threads/none/lock.h M src/threads/native/threads.h M
+       src/threads/native/lock.c M src/threads/native/threads.c AM
+       src/vmcore A src/vmcore/options.h A src/vmcore/zip.c A
+       src/vmcore/suck.c A src/vmcore/class.c A src/vmcore/loader.c A
+       src/vmcore/zip.h A src/vmcore/annotation.c A src/vmcore/suck.h
+       A src/vmcore/class.h A src/vmcore/rt-timing.c A
+       src/vmcore/loader.h A src/vmcore/descriptor.c A
+       src/vmcore/resolve.c A src/vmcore/annotation.h A src/vmcore
+       /rt-timing.h A src/vmcore/method.c A src/vmcore/descriptor.h A
+       src/vmcore/resolve.h A src/vmcore/method.h A
+       src/vmcore/references.h A src/vmcore/classcache.c A
+       src/vmcore/statistics.c A src/vmcore/.cvsignore A
+       src/vmcore/classcache.h A src/vmcore/statistics.h A
+       src/vmcore/stackmap.c A src/vmcore/stackmap.h A
+       src/vmcore/field.c A src/vmcore/linker.c A src/vmcore/utf8.c A
+       src/vmcore/field.h A src/vmcore/Makefile.am A
+       src/vmcore/linker.h A src/vmcore/options.c A src/vmcore/utf8.h
+       M src/cacaoh/cacaoh.c M src/cacaoh/headers.h M
+       src/cacaoh/Makefile.am M src/cacaoh/headers.c A
+       src/cacaoh/dummy.c M configure.ac
+       [0fc2b6dcc07b]
+
+       * src/vm/jit/arm/emit.c:
+       * src/vm/jit/arm/emit.c [ENABLE_SOFTFLOAT] (emit_load): Implemented.
+       (emit_store): Changed implementation to be more clear. (emit_copy):
+       Likewise.
+       [fe8afee04ad9]
+
+       * src/vm/jit/arm/codegen.c:
+       * src/vm/jit/arm/codegen.c (codegen): ICMD_DASTORE: bugfix for
+       softfloat.
+       [91314a82783b]
+
+2007-01-28  twisti  <twisti>
+
+       * src/vm/jit/mips/codegen.c:
+       * src/vm/jit/mips/codegen.c (createcompilerstub): Don't generate a
+       codeinfo.
+       [2fde0f1e0334]
+
+       * src/vm/jit/arm/codegen.c:
+       * src/vm/jit/arm/codegen.c (createcompilerstub): Don't generate a
+       codeinfo.
+       [e3b34887588a]
+
+2007-01-27  twisti  <twisti>
+
+       * configure.ac, m4/soft.m4, src/vm/builtin.c, src/vm/builtintable.inc,
+       src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h,
+       src/vm/jit/i386/arch.h, src/vm/jit/m68k/arch.h,
+       src/vm/jit/mips/arch.h, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/patcher.c, src/vm/jit/parisc/arch.h,
+       src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc64/arch.h,
+       src/vm/jit/s390/arch.h, src/vm/jit/sparc64/arch.h,
+       src/vm/jit/x86_64/arch.h:
+       * configure.ac: Use AC_CHECK_SOFTFLOAT, AC_CHECK_SOFT_FLOAT_CMP and
+       AC_CHECK_SOFT_DOUBLE_CMP.
+       * m4/soft.m4: New file.
+
+       * src/vm/builtin.c [!SUPPORT_FLOAT_CMP] (builtin_fcmpl): Added
+       conditional. [!SUPPORT_DOUBLE_CMP] (builtin_dcmpl): Likewise.
+
+       * src/vm/builtintable.inc (builtintable_automatic):
+       [!SUPPORT_FLOAT_CMP] (BUILTIN_fcmpl): Added. [!SUPPORT_DOUBLE_CMP]
+       (BUILTIN_dcmpl): Likewise. (builtintable_function): [__MIPS__ &&
+       SIZEOF_VOID_P != 4] (BUILTIN_arraycopy): Added.
+
+       * src/vm/jit/mips/codegen.c (codegen): Added SUPPORT_FLOAT_CMP for
+       ICMD_FCMPx, and SUPPORT_DOUBLE_CMP for ICMD_DCMPx.
+
+       * src/vm/jit/arm/arch.h (SUPPORT_FLOAT_CMP, SUPPORT_DOUBLE_CMP):
+       Added.
+       * src/vm/jit/powerpc/arch.h: Likewise.
+       * src/vm/jit/sparc64/arch.h: Likewise.
+       * src/vm/jit/alpha/arch.h: Likewise.
+       * src/vm/jit/s390/arch.h: Likewise.
+       * src/vm/jit/mips/arch.h: Likewise.
+       * src/vm/jit/parisc/arch.h: Likewise.
+       * src/vm/jit/m68k/arch.h: Likewise.
+       * src/vm/jit/i386/arch.h: Likewise.
+       * src/vm/jit/powerpc64/arch.h: Likewise.
+       * src/vm/jit/x86_64/arch.h: Likewise.
+
+       * src/vm/jit/mips/patcher.c (vm/jit/md.h): Added.
+       [0030ae40a5f0]
+
+       * src/vm/loader.c:
+       * src/vm/loader.c (load_newly_created_array): c->interfacescount was
+       always set to 0, fixed.
+       [c583dcb762a3]
+
+2007-01-27  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c,
+       src/vm/jit/sparc64/md.c:
+       * src/vm/jit/sparc64/emit.c: Moved exception check generation to
+       emit functions.
+       * src/vm/jit/sparc64/codegen.h: Likewise.
+       * src/vm/jit/sparc64/codegen.c: Likewise.
+
+       * src/vm/jit/sparc64/md.c: Added SPARC specific functions for
+       getting JIT information from the stack frame.
+
+       * src/vm/jit/sparc64/linux/md-os.c: Fixed icache flushing when start
+       address is not doubleword aligned.
+       [2bd4d44bd3c0]
+
+2007-01-23  twisti  <twisti>
+
+       * src/vm/jit/mips/emit.c:
+       * src/vm/jit/mips/emit.c (emit_patcher_stubs): Use
+       dseg_add_functionptr instead of dseg_add_address.
+       [0d1711cc34aa]
+
+2007-01-22  twisti  <twisti>
+
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c:
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (postInit):
+       Added missing file://.
+       [cd2249587a11]
+
+       * src/cacao/cacao.c:
+       * src/cacao/cacao.c (main): Fixed typo.
+       [543a7a5860cb]
+
+       * src/lib/Makefile.am,
+       src/lib/vm/reference/gnu/classpath/VMSystemProperties.java,
+       src/native/include/Makefile.am:
+       * src/lib/vm/reference/gnu/classpath/VMSystemProperties.java: New
+       file.
+
+       * src/lib/Makefile.am (VM_JAVA_FILES): Added
+       gnu/classpath/VMSystemProperties.java. (VM_CLASS_FILES): Likewise.
+
+       * src/native/include/Makefile.am (VM_ZIP): Added. (DO_HEADER_FILES):
+       Depend on VM_ZIP.
+       [cd1a96682531]
+
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c,
+       src/vm/properties.c, src/vm/properties.h:
+       * src/vm/properties.c (properties_get): Search list forward, as we
+       don't have duplicate entries anymore. (properties_system_add): New
+       function.
+       * src/vm/properties.h (properties_system_add): Added.
+
+       * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (postInit):
+       New function.
+       [67978ad263eb]
+
+       * src/vm/jit/mips/md.c:
+       * src/vm/jit/mips/md.c (md_get_method_patch_address): Fixed compiler
+       warning.
+       [3091559d5e74]
+
+       * src/cacao/cacao.c:
+       * src/cacao/cacao.c (main): Fixed compiler warning.
+       [d5e2cb977df7]
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c:
+       * src/vm/jit/arm/codegen.c (vm/jit/md.h): Added.
+       * src/vm/jit/arm/patcher.c (vm/jit/md.h): Likewise.
+       [0b8f6c2eab9d]
+
+2007-01-22  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h:
+       * src/vm/jit/sparc64/codegen.h: Fixed big disp handling.
+       * src/vm/jit/sparc64/codegen.c: Likewise.
+       [a635998681c3]
+
+2007-01-22  twisti  <twisti>
+
+       * src/vm/jit/Makefile.am, src/vm/jit/codegen-common.c,
+       src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/md.h, src/vm/vm.c:
+       * src/vm/jit/jit.h (md_init, md_get_method_patch_address,)
+       (md_cacheflush, md_icacheflush, md_dcacheflush, intrp_md_init):
+       Removed.
+
+       * src/vm/jit/md.h: New file.
+       * src/vm/jit/Makefile.am (noinst_HEADERS): Added md.h.
+
+       * src/vm/jit/jit.c (vm/jit/md.h): Added.
+       * src/vm/jit/codegen-common.c (vm/jit/md.h): Likewise.
+       * src/vm/vm.c (vm/jit/md.h): Likewise.
+       [d390734ef98c]
+
+2007-01-19  edwin  <edwin>
+
+       * configure.ac, src/cacaoh/headers.c, src/vm/exceptions.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/jit.c, src/vm/linker.c,
+       src/vm/method.c, src/vm/options.c, src/vm/options.h, src/vm/vm.c:
+       * src/vm/options.h, src/vm/method.c, src/vm/jit/inline/inline.c,
+       src/vm/jit/jit.c, src/vm/vm.c, src/vm/linker.c, src/vm/options.c,
+       src/cacaoh/headers.c: Cleaned up inlining options.
+
+       * src/vm/exceptions.c: Removed a left-over use of "useinlining".
+
+       * configure.ac: New configure flag --enable-inlining-debug.
+       [566f6e517a77]
+
+2007-01-18  twisti  <twisti>
+
+       * src/vm/jit/arm/asmpart.S, src/vm/jit/arm/md-asm.h:
+       * src/vm/jit/arm/md-asm.h: Renamed argument defines to start with 0.
+       * src/vm/jit/arm/asmpart.S: Likewise.
+       [2b341e5bb601]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (usage): Removed CACAO options. (XXusage): New
+       function. (vm_create): Handle OPT_XX.
+       [28b7b97ae806]
+
+       * src/vm/jit/powerpc/asmpart.S:
+       * src/vm/jit/powerpc/asmpart.S (asm_compare_and_swap): New function.
+       (asm_memory_barrier): Likewise.
+       [50cb34084654]
+
+       * src/vm/jit/mips/asmpart.S, src/vm/jit/mips/md-asm.h:
+       * src/vm/jit/mips/md-asm.h (RESTORE_ARGUMENT_REGISTERS)
+       (RESTORE_ARGUMENT_REGISTERS, SAVE_TEMPORARY_REGISTERS)
+       (RESTORE_TEMPORARY_REGISTERS): Added missing float registers.
+
+       * src/vm/jit/mips/asmpart.S (asm_patcher_wrapper): Changed stack
+       size for float registers.
+       [a5ec1ec75994]
+
+2007-01-17  tbfg  <tbfg>
+
+       * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c,
+       src/vm/jit/powerpc64/linux/md-abi.h:
+       * src/vm/jit/powerpc64/linux/md-abi.h (REG_ZERO): Added.
+
+       * src/vm/jit/powerpc64/emit.c (emit_replacement_stubs):
+       Conditionally compiled on ENABLE_REPLACEMENT.
+
+       * src/vm/jit/powerpc64/codegen.c (codegen_emit): Replaced
+       emit_replacement_stubs with REPLACEMENT_EMIT_STUBS.
+       [e6ee875d25a7]
+
+2007-01-17  twisti  <twisti>
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (md-abi.h): Added.
+       [4bec4df1aab1]
+
+       * src/vm/jit/codegen-common.c:
+       * src/vm/jit/codegen-common.c (codegen_reset): #ifdef replacement
+       stuff.
+       [1ecfc6ea6c0e]
+
+       * configure.ac, src/cacaoh/headers.c, src/vm/jit/Makefile.am,
+       src/vm/jit/alpha/asmpart.S, src/vm/jit/asmpart.h, src/vm/jit/disass-
+       common.c, src/vm/jit/disass.h, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/x86_64/asmpart.S:
+       Merged with trunk rev7219.
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/disass-common.c,
+       src/vm/jit/s390, src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h,
+       src/vm/jit/s390/md.c, src/vm/jit/s390/emit.h,
+       src/vm/jit/s390/codegen.c, src/vm/jit/s390/machine-instr.h,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/arch.h, src/vm/jit/s390
+       /md-asm.h, src/vm/jit/s390/disass.c, src/vm/jit/s390/patcher.c,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/Makefile.am,
+       src/vm/jit/s390/md-abi.c, src/vm/jit/s390/.cvsignore,
+       src/vm/jit/disass.h, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/asmpart.h, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/Makefile.am, src/cacaoh/headers.c, configure.ac: Merged.
+       [15381fe4a67f]
+
+2007-01-16  pm  <pm>
+
+       * configure.ac, src/vm/jit/Makefile.am, src/vm/jit/disass-common.c,
+       src/vm/jit/disass.h, src/vm/jit/s390/.cvsignore,
+       src/vm/jit/s390/Makefile.am, src/vm/jit/s390/arch.h,
+       src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c,
+       src/vm/jit/s390/codegen.h, src/vm/jit/s390/disass.c,
+       src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390
+       /machine-instr.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md-
+       abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/md.c,
+       src/vm/jit/s390/patcher.c:
+       Initial import of s390 codegen, codebase is copyed from x86_64.
+       [c5d44fda5516]
+
+2007-01-16  twisti  <twisti>
+
+       * src/cacaoh/headers.c:
+       * src/cacaoh/headers.c (asm_compare_and_swap): Added.
+       (asm_memory_barrier): Likewise.
+       [ced478ee11d0]
+
+       * src/vm/jit/x86_64/asmpart.S:
+       * src/vm/jit/x86_64/asmpart.S (asm_patcher_wrapper): Removed unused
+       sizestackframeinfo.
+       [6aaa22b2b309]
+
+       * src/vm/jit/alpha/asmpart.S, src/vm/jit/asmpart.h:
+       * src/vm/jit/asmpart.h (asm_compare_and_swap): Added.
+       (asm_memory_barrier): Likewise.
+
+       * src/vm/jit/alpha/asmpart.S (asm_compare_and_swap): New function.
+       (asm_memory_barrier): Likewise.
+       [8a11edfc6695]
+
+2007-01-15  twisti  <twisti>
+
+       * src/vm/jit/powerpc64/codegen.c:
+       * src/vm/jit/powerpc64/codegen.c (codegen): Ported replacement.
+       [1b31182b8fdf]
+
+       * configure.ac, src/cacaoh/cacaoh.c, src/cacaoh/headers.c,
+       src/mm/boehm.c, src/mm/memory.c, src/native/native.c,
+       src/vm/builtin.c, src/vm/classcache.c, src/vm/descriptor.c,
+       src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/Makefile.am,
+       src/vm/jit/allocator/liveness.c, src/vm/jit/allocator/lsra.c,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/inline/inline.c,
+       src/vm/jit/inline/inline_debug.inc, src/vm/jit/intrp/codegen.c,
+       src/vm/jit/jit.c, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c,
+       src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md-abi.h,
+       src/vm/jit/mips/md.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md-abi.h,
+       src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/stack.c, src/vm/jit/tools/genoffsets.c,
+       src/vm/jit/verify/generate.pl, src/vm/jit/verify/typecheck-
+       builtins.inc, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/loader.c, src/vm/rt-timing.c,
+       src/vm/rt-timing.h, src/vm/suck.c, src/vm/utf8.c, src/vm/vm.c:
+       Merged with trunk rev7206.
+
+       * src/vm/suck.c, src/vm/loader.c, src/vm/builtin.c, src/vm/rt-
+       timing.c, src/vm/descriptor.c, src/vm/rt-timing.h,
+       src/vm/classcache.c, src/vm/jit/powerpc/codegen.c, src/vm/jit/arm,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.h, src/vm/jit/arm/md.c,
+       src/vm/jit/arm/codegen.c, src/vm/jit/arm/machine-instr.h,
+       src/vm/jit/arm/codegen.h src/vm/jit/arm/linux, src/vm/jit/arm/linux
+       /md-os.c, src/vm/jit/arm/linux/Makefile.am,
+       src/vm/jit/arm/linux/.cvsignore, src/vm/jit/arm/arch.h,
+       src/vm/jit/arm/md-asm.h, src/vm/jit/arm/disass.c,
+       src/vm/jit/arm/patcher.c, src/vm/jit/arm/asmpart.S,
+       src/vm/jit/arm/Makefile.am, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/arm/.cvsignore, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/patcher.c, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/stack.c,
+       src/vm/jit/tools/genoffsets.c, src/vm/jit/verify/typecheck-
+       typeinferer-gen.inc, src/vm/jit/verify/typecheck-typeinferer.c,
+       src/vm/jit/verify/generate.pl, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/mips/md-abi.h,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/md.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h,
+       src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/md-abi.c, src/vm/jit/inline/inline.c,
+       src/vm/jit/inline/inline_debug.inc, src/vm/jit/allocator/lsra.c,
+       src/vm/jit/allocator/simplereg.c, src/vm/jit/allocator/liveness.c,
+       src/vm/jit/parisc/linux/Makefile.am, src/vm/jit/m68k,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/md.c,
+       src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c, src/vm/jit/m68k
+       /machine-instr.h, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/m68k/uclinux, src/vm/jit/m68k/uclinux/md-abi.h,
+       src/vm/jit/m68k/uclinux/md-os.c, src/vm/jit/m68k/uclinux/md-asm.h,
+       src/vm/jit/m68k/uclinux/Makefile.am, src/vm/jit/m68k/uclinux/md-
+       abi.c, src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/Makefile.am,
+       src/vm/jit/m68k/codegen.h, src/vm/jit/powerpc64/codegen.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/intrp/codegen.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/jit/jit.c,
+       src/vm/jit/Makefile.am, src/vm/exceptions.c, src/vm/vm.c,
+       src/vm/exceptions.h, src/vm/utf8.c, src/native/native.c,
+       src/mm/memory.c, src/mm/boehm.c, src/cacaoh/cacaoh.c,
+       src/cacaoh/headers.c, configure.ac: Merged.
+       [263e061c0f8d]
+
+2007-01-13  edwin  <edwin>
+
+       * src/vm/jit/verify/typecheck-typeinferer.c:
+       * src/vm/jit/verify/typecheck-typeinferer.c: Check basic types in
+       debug mode.
+       [bc6ac49a2576]
+
+       * src/vm/jit/verify/generate.pl, src/vm/jit/verify/typecheck-
+       typeinferer-gen.inc:
+       * src/vm/jit/verify/generate.pl: Further changes for the type
+       inferer.
+
+       * src/vm/jit/verify/typecheck-typeinferer-gen.inc: Regenerated.
+       [58d274e03303]
+
+       * src/vm/rt-timing.c, src/vm/rt-timing.h:
+       * src/vm/rt-timing.h: Fixed position of #include "config.h".
+       (rt_timing_diff_usec): Export.
+
+       * src/vm/rt-timing.c (rt_timing_diff_usec): Export.
+       [17a57a236451]
+
+       * src/vm/jit/jit.c:
+       * src/vm/jit/jit.c (jit_compile_intern): Removed unused code and
+       fixed instrumentation.
+       [d32067dc461e]
+
+       * src/vm/jit/inline/inline.c, src/vm/jit/inline/inline_debug.inc:
+       * src/vm/jit/inline/inline.c: Better inlining decisions. Implemented
+       knapsack heuristics. More statistics. Refactoring and fixes.
+
+       * src/vm/jit/inline/inline_debug.inc: Fixed to make it compile.
+       [2675b8465cc8]
+
+2007-01-13  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md.c,
+       src/vm/jit/sparc64/patcher.c:
+       * src/vm/jit/sparc64/md-abi.h: The JIT stackframes now also includes
+       the 6 parameter slots required when doing a ABI compliant C call.
+       * src/vm/jit/sparc64/emit.c: Likewise.
+       * src/vm/jit/sparc64/codegen.c: Likewise.
+       * src/vm/jit/sparc64/patcher.c: Likewise.
+       * src/vm/jit/sparc64/asmpart.S: Likewise.
+
+       * src/vm/jit/sparc64/codegen.h: Added include.
+
+       * src/vm/jit/sparc64/md.c: Added method, to get framepointer from
+       saved register window. (for temporary fix in JIT stack walking)
+       [8723d252337d]
+
+2007-01-12  twisti  <twisti>
+
+       * src/vm/jit/arm/linux/md-os.c:
+       * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Use
+       codegen_get_pv_from_pc.
+       [b14675eb67a8]
+
+2007-01-11  twisti  <twisti>
+
+       * src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/md-abi.c,
+       src/vm/jit/mips/md-abi.h:
+       * src/vm/jit/mips/md-abi.h: Merged MIPS32 code.
+       * src/vm/jit/mips/emit.c: Likewise.
+       * src/vm/jit/mips/codegen.c: Likewise.
+       * src/vm/jit/mips/codegen.h: Likewise.
+       * src/vm/jit/mips/linux/md-os.c: Likewise.
+       * src/vm/jit/mips/asmpart.S: Likewise.
+       * src/vm/jit/mips/md-abi.c: Likewise.
+       [87baf39e945a]
+
+       * src/mm/memory.c, src/vm/jit/m68k/Makefile.am,
+       src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S,
+       src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h,
+       src/vm/jit/m68k/emit.c, src/vm/jit/m68k/machine-instr.h,
+       src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c,
+       src/vm/jit/m68k/uclinux/Makefile.am, src/vm/jit/m68k/uclinux/md-
+       abi.c, src/vm/jit/m68k/uclinux/md-abi.h, src/vm/jit/m68k/uclinux/md-
+       asm.h, src/vm/jit/m68k/uclinux/md-os.c:
+       * src/mm/memory.c (mem_realloc): Fixed compiler warning.
+       [2758baba10d2]
+
+       * src/vm/exceptions.c:
+       * src/vm/exceptions.c (exceptions_throw_internalerror): Don't return
+       a value. (exceptions_throw_outofmemoryerror): Likewise.
+       [bd9464eafaa4]
+
+       * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h,
+       src/vm/jit/arm/emit.c:
+       * src/vm/jit/arm/emit.c (emit_exception_stubs): Renamed eref to er,
+       use md_codegen_patch_branch.
+
+       * src/vm/jit/arm/codegen.c (codegen): Use
+       codegen_resolve_branchrefs, use exceptions_throw_internalerror.
+
+       * src/vm/jit/arm/codegen.h (M_STACK_LOAD_FLT_TYPED): Removed.
+       (M_STACK_STORE_FLT_TYPED): Likewise.
+       [6b1b1aad7475]
+
+       * configure.ac, src/vm/jit/Makefile.am, src/vm/jit/arm/.cvsignore,
+       src/vm/jit/arm/Makefile.am, src/vm/jit/arm/arch.h,
+       src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c,
+       src/vm/jit/arm/codegen.h, src/vm/jit/arm/disass.c,
+       src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/.cvsignore,
+       src/vm/jit/arm/linux/Makefile.am, src/vm/jit/arm/linux/md-os.c,
+       src/vm/jit/arm/machine-instr.h, src/vm/jit/arm/md-abi.c,
+       src/vm/jit/arm/md-abi.h, src/vm/jit/arm/md-asm.h,
+       src/vm/jit/arm/md.c, src/vm/jit/arm/patcher.c:
+       * configure.ac [ENABLE_STATICVM] (AC_CHECK_LIB(dl)): Only perform
+       the check if we want a static VM. (AC_CONFIG_FILES): Added
+       src/vm/jit/arm/Makefile and src/vm/jit/arm/linux/Makefile.
+       * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added arm.
+       [93c25d89aa7a]
+
+2007-01-10  twisti  <twisti>
+
+       * src/vm/builtin.c:
+       * src/vm/builtin.c (builtin_newarray): Removed debug output.
+       [ca1161ec4cc1]
+
+       * src/cacaoh/cacaoh.c, src/cacaoh/headers.c, src/mm/boehm.c,
+       src/mm/memory.c, src/native/native.c, src/vm/builtin.c,
+       src/vm/classcache.c, src/vm/descriptor.c, src/vm/exceptions.c,
+       src/vm/exceptions.h, src/vm/jit/allocator/liveness.c,
+       src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/simplereg.c,
+       src/vm/jit/alpha/codegen.c, src/vm/jit/i386/codegen.c,
+       src/vm/jit/intrp/codegen.c, src/vm/jit/mips/codegen.c,
+       src/vm/jit/mips/md.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/powerpc64/codegen.c, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/stack.c,
+       src/vm/jit/tools/genoffsets.c, src/vm/jit/verify/typecheck-
+       builtins.inc, src/vm/jit/verify/typeinfo.c,
+       src/vm/jit/x86_64/codegen.c, src/vm/loader.c, src/vm/suck.c,
+       src/vm/utf8.c, src/vm/vm.c:
+       * src/vm/suck.c (suck_add): Use vm_abort instead of
+       throw_cacao_exception_exit. (suck_float, suck_double): Use
+       exceptions_throw_internalerror.
+
+       * src/vm/loader.c (load_class_bootstrap): Use vm_abort instead of
+       throw_cacao_exception_exit.
+       * src/vm/jit/sparc64/emit.c (emit_patcher_stubs): Likewise.
+       * src/vm/jit/mips/md.c (md_patch_replacement_point): Likewise.
+       * src/vm/vm.c (vm_create): Likewise.
+
+       * src/vm/builtin.c (builtin_newarray): Use
+       exceptions_throw_outofmemoryerror.
+
+       * src/vm/descriptor.c (descriptor_pool_lookup_classref): Use
+       exceptions_throw_internalerror.
+       * src/vm/classcache.c (classcache_store_unique): Likewise.
+       * src/vm/jit/powerpc/codegen.c (codegen): Likewise.
+       * src/vm/jit/sparc64/codegen.c (codegen): Likewise.
+       * src/vm/jit/alpha/codegen.c (codegen): Likewise.
+       * src/vm/jit/mips/codegen.c (codegen): Likewise.
+       * src/vm/jit/i386/codegen.c (codegen): Likewise.
+       * src/vm/jit/powerpc64/codegen.c (codegen): Likewise.
+       * src/vm/jit/intrp/codegen.c (codegen): Likewise.
+       * src/vm/jit/x86_64/codegen.c (codegen): Likewise.
+       * src/vm/jit/stack.c (stack_reanalyse_block): Likewise.
+       (stack_analyse): Likewise.
+       * src/vm/jit/verify/typeinfo.c (typeinfos_init_from_methoddesc):
+       Likewise. (typeinfo_init_component): Likewise.
+       * src/vm/jit/verify/typecheck-builtins.inc: Likewise.
+       * src/vm/jit/allocator/lsra.c (lsra_scan_registers_canditates):
+       Likewise.
+       * src/vm/jit/allocator/simplereg.c (simplereg_allocate_temporaries):
+       Likewise.
+       * src/vm/jit/allocator/liveness.c
+       (liveness_scan_registers_canditates): Likewise.
+
+       * src/vm/exceptions.c (exceptions_throw_outofmemory_exit): Removed.
+       (new_internalerror): Removed. (exceptions_throw_internalerror):
+       Rewritten. (exceptions_throw_outofmemoryerror): Added.
+
+       * src/vm/exceptions.h: Likewise.
+
+       * src/vm/utf8.c (utf_get_number_of_u2s): Use
+       exceptions_throw_internalerror instead of
+       throw_cacao_exception_exit.
+
+       * src/native/native.c (native_init): Changed debug output.
+
+       * src/mm/memory.c (memory_checked_alloc): Use vm_abort instead of
+       exceptions_throw_outofmemory_exit. (mem_realloc): Changed debug
+       output.
+       * src/mm/boehm.c (gc_out_of_memory): Use vm_abort and
+       exceptions_throw_outofmemoryerror.
+
+       * src/cacaoh/cacaoh.c (cacaoh_abort): Added. (main): Use
+       cacaoh_abort.
+
+       * src/cacaoh/headers.c (throw_cacao_exception_exit): Removed.
+       (exceptions_throw_outofmemory_exit): Likewise. (new_internalerror):
+       Renamed to exceptions_throw_internalerror.
+       (exceptions_throw_outofmemoryerror): Added.
+
+       * src/vm/jit/tools/genoffsets.c (main): Don't print
+       sizestackframeinfo.
+       [eaa7c4b43388]
+
+       * src/vm/jit/parisc/linux/Makefile.am:
+       * src/vm/jit/parisc/linux/Makefile.am (libmd_la_SOURCES): Commented.
+       [b51cf064818d]
+
+2007-01-08  twisti  <twisti>
+
+       * configure.ac, src/cacao/cacao.c, src/mm/memory.c, src/vm/jit/emit-
+       common.h, src/vm/jit/inline/inline.c, src/vm/jit/jit.c,
+       src/vm/jit/mips/codegen.c, src/vm/jit/parisc/Makefile.am,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/sparc64/patcher.c, src/vm/jit/verify/Makefile.am,
+       src/vm/jit/verify/generate.pl, src/vm/jit/verify/icmds.c,
+       src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/verify
+       /typecheck-common.c, src/vm/jit/verify/typecheck-common.h,
+       src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/verify/typecheck-
+       invoke.inc, src/vm/jit/verify/typecheck-stackbased-gen.inc,
+       src/vm/jit/verify/typecheck-variablesbased-gen.inc,
+       src/vm/jit/verify/typecheck.c, src/vm/method.c, src/vm/method.h,
+       src/vm/vm.c:
+       Merged with trunk rev6283.
+
+       * src/vm/method.c, src/vm/method.h, src/vm/jit/sparc64/md.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/patcher.c,
+       src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-invoke.inc,
+       src/vm/jit/verify/typecheck-common.c, src/vm/jit/verify/typecheck-
+       typeinferer-gen.inc, src/vm/jit/verify/typecheck-multianewarray.inc,
+       src/vm/jit/verify/typecheck-typeinferer.c, src/vm/jit/verify
+       /typecheck-common.h, src/vm/jit/verify/typecheck-fields.inc,
+       src/vm/jit/verify/typecheck-typeinferer.h, src/vm/jit/verify
+       /typecheck-stackbased-gen.inc, src/vm/jit/verify/typecheck.c,
+       src/vm/jit/verify/typecheck-variablesbased-gen.inc,
+       src/vm/jit/verify/generate.pl, src/vm/jit/verify/Makefile.am,
+       src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/mips/codegen.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/parisc/linux/Makefile.am,
+       src/vm/jit/parisc/Makefile.am, src/vm/jit/jit.c, src/vm/jit/emit-
+       common.h, src/vm/vm.c, src/cacao/cacao.c, src/mm/memory.c,
+       configure.ac: Merged.
+       [8e237a4d5523]
+
+       * configure.ac:
+       * configure.ac: Added GPL header.
+       [c3f5ae9d7eb2]
+
+       * src/vm/vm.c:
+       * src/vm/vm.c (vm_create): Fixed off-by-one bug.
+       [f5e5e63ff2db]
+
+2007-01-08  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c:
+       * src/vm/jit/sparc64/codegen.c: Fixed argument passing via the stack
+       (for JIT methods).
+       [77115a8e9e95]
+
+2007-01-07  ajordan  <ajordan>
+
+       * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h,
+       src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/sparc64/patcher.c:
+       * src/vm/jit/sparc64/codegen.c: Implemented INSTANCEOF and CHECKCAST
+       ICMDs
+       * src/vm/jit/sparc64/patcher.c: and their respective patchers.
+
+       * src/vm/jit/sparc64/codegen.h: Added comparison instructions.
+
+       * src/vm/jit/sparc64/linux/md-os.c: Implemented instruction cache
+       flush for linux.
+       * src/vm/jit/sparc64/md.c: Likewise.
+       [2d476dbfb2c2]
+
+2007-01-06  twisti  <twisti>
+
+       * configure.ac:
+       * configure.ac: Check for libdl.
+       [6decb9c44f6f]
+
+       * src/cacao/cacao.c:
+       * src/cacao/cacao.c (main): Print function name in error output.
+       [941930b2845d]
+
+2007-01-06  edwin  <edwin>
+
+       * src/vm/jit/inline/inline.c:
+       * src/vm/jit/inline/inline.c: Many refactorings and comments.
+       [a4fdb4ceef75]
+
+2007-01-04  twisti  <twisti>
+
+       * src/mm/memory.c:
+       * src/mm/memory.c (mem_realloc): Use vm_abort.
+       [e6f0eee2c2cf]
+
+2007-01-03  edwin  <edwin>
+
+       * src/vm/jit/verify/Makefile.am, src/vm/jit/verify/icmds.c,
+       src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/verify
+       /typecheck-common.c, src/vm/jit/verify/typecheck-common.h,
+       src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/verify/typecheck-
+       invoke.inc, src/vm/jit/verify/typecheck-multianewarray.inc,
+       src/vm/jit/verify/typecheck-stackbased-gen.inc, src/vm/jit/verify
+       /typecheck-typeinferer-gen.inc, src/vm/jit/verify/typecheck-
+       typeinferer.c, src/vm/jit/verify/typecheck-typeinferer.h,
+       src/vm/jit/verify/typecheck-variablesbased-gen.inc,
+       src/vm/jit/verify/typecheck.c:
+       * src/vm/jit/verify/typecheck-typeinferer.c: New type inference
+       pass.
+       * src/vm/jit/verify/typecheck-typeinferer.h: Likewise.
+
+       * src/vm/jit/verify/typecheck-common.c: Moved code from typecheck.c
+       that can be shared between the variables-based verifier and the type
+       inference pass to this file.
+       * src/vm/jit/verify/typecheck-common.h: Likewise.
+
+       * src/vm/jit/verify/typecheck-multianewarray.inc: Moved code for
+       type checking/infering MULTIANEWARRAY to this file.
+
+       * src/vm/jit/verify/icmds.c: Adapted for generating the type
+       infererence pass.
+       * src/vm/jit/verify/typecheck-invoke.inc: Likewise.
+       * src/vm/jit/verify/typecheck-fields.inc: Likewise.
+       * src/vm/jit/verify/typecheck.c: Likewise.
+       * src/vm/jit/verify/Makefile.am: Likewise.
+       * src/vm/jit/verify/typecheck-builtins.inc: Likewise.
+
+       * src/vm/jit/verify/typecheck-typeinferer-gen.inc: Generated.
+
+       * src/vm/jit/verify/typecheck-stackbased-gen.inc: Regenerated.
+       * src/vm/jit/verify/typecheck-variablesbased-gen.inc: Regenerated.
+       [6d875bc53835]
+
+       * src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-stackbased-
+       gen.inc, src/vm/jit/verify/typecheck-variablesbased-gen.inc:
+       * src/vm/jit/verify/icmds.c: Added comments.
+
+       * src/vm/jit/verify/typecheck-stackbased-gen.inc, src/vm/jit/verify
+       /typecheck-variablesbased-gen.inc: Regenerated.
+       [81dcffbbd1b3]
+
+       * src/vm/method.c, src/vm/method.h:
+       * src/vm/method.c, src/vm/method.h (method_count_implementations):
+       New function.
+       [58228f481c93]
+
+       * src/vm/jit/verify/generate.pl:
+       * src/vm/jit/verify/generate.pl: Added options --typeinferer and
+       --debug. Prepared for generating the type inference pass.
+       [07e04a8efbb4]
+
+2007-01-02  twisti  <twisti>
+
+       * configure.ac, src/vm/jit/parisc/Makefile.am,
+       src/vm/jit/parisc/linux/Makefile.am:
+       * configure.ac (AC_CONFIG_FILES): Added
+       src/vm/jit/parisc/linux/Makefile.
+       * src/vm/jit/parisc/Makefile.am (SUBDIRS): Set to $(OS_DIR).
+       * src/vm/jit/parisc/linux/Makefile.am: New file.
+       [d193cb85b31c]
+
+2007-01-02  edwin  <edwin>
+
+       * src/vm/jit/emit-common.h:
+       * src/vm/jit/emit-common.h (emit_replacement_stubs): Only declare
+       prototype if ENABLE_REPLACEMENT.
+       [60115f167ec8]
+
+       * src/vm/jit/mips/codegen.c:
+       * src/vm/jit/mips/codegen.c (codegen): Use REPLACEMENT_ macros.
+       [5e4385a84e1e]
+
+2007-01-02  twisti  <twisti>
+
+       * configure.ac, src/native/include/.cvsignore,
+       src/native/include/Makefile.am,
+       src/native/include/java_lang_VMObject.h, src/vm/jit/Makefile.am,
+       src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/disass.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.c,
+       src/vm/jit/alpha/md.c, src/vm/jit/asmpart.h, src/vm/jit/code.c,
+       src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/codegen-
+       common.h, src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c,
+       src/vm/jit/i386/disass.c, src/vm/jit/i386/emit.c, src/vm/jit/i386
+       /md-abi.c, src/vm/jit/i386/md.c, src/vm/jit/inline/inline.c,
+       src/vm/jit/jit.h, src/vm/jit/mips/asmpart.S, src/vm/jit/mips/emit.c,
+       src/vm/jit/mips/md.c, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/md.c,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/replace.h, src/vm/jit/show.c, src/vm/jit/sparc64/emit.c,
+       src/vm/jit/sparc64/md.c, src/vm/jit/tools/genoffsets.c,
+       src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/disass.c,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c,
+       src/vm/jit/x86_64/md.c, tests/regression/jctest.java,
+       tests/regression/jctest.output:
+       Merged with trunk rev6266.
+
+       * src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/md.c,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/codegen-common.h,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md.c,
+       src/vm/jit/alpha/disass.c, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/alpha/md-abi.c, src/vm/jit/code.c,
+       src/vm/jit/tools/genoffsets.c, src/vm/jit/code.h, src/vm/jit/show.c,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/md.c,
+       src/vm/jit/mips/asmpart.S, src/vm/jit/inline/inline.c,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/i386/emit.c, src/vm/jit/i386/md.c,
+       src/vm/jit/i386/codegen.c, src/vm/jit/i386/disass.c,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/i386/md-abi.c,
+       src/vm/jit/asmpart.h, src/vm/jit/x86_64/emit.c,
+       src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/disass.c,
+       src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/md-abi.c,
+       src/vm/jit/replace.h, src/vm/jit/Makefile.am, src/vm/jit/codegen-
+       common.c, src/vm/jit/jit.h, src/native/include,
+       src/native/include/java_lang_VMObject.h,
+       src/native/include/Makefile.am, src/native/include/.cvsignore,
+       tests/regression/jctest.output, tests/regression/jctest.java,
+       configure.ac: Merged.
+       [191085398868]
+
+2007-01-02  edwin  <edwin>
+
+       * src/vm/jit/jit.c:
+       * src/vm/jit/jit.c (jit_invalidate_code): Require
+       ENABLE_REPLACEMENT.
+       [66966741fd27]
+
+2007-01-02  twisti  <twisti>
+
+       * configure.ac, contrib/setenvinstalled.in, contrib/setenvsource.in,
+       m4/ac_prog_javac.m4, src/Makefile.am, src/cacaoh/cacaoh.c,
+       src/cacaoh/headers.c, src/fdlibm/Makefile.am, src/fdlibm/e_fmod.c,
+       src/fdlibm/fdlibm.h, src/fdlibm/ieeefp.h, src/fdlibm/mprec.h,
+       src/fdlibm/s_copysign.c, src/fdlibm/s_finite.c, src/fdlibm/w_fmod.c,
+       src/lib/vm/reference/java/lang/VMThread.java, src/mm/memory.c,
+       src/native/Makefile.am, src/native/include/.cvsignore,
+       src/native/include/Makefile.am,
+       src/native/include/java_lang_Thread.h,
+       src/native/include/java_lang_VMThread.h, src/native/jni.c,
+       src/native/native.c, src/native/native.h, src/native/vm/Makefile.am,
+       src/threads/native/lock.c, src/threads/native/threads.c,
+       src/threads/native/threads.h, src/vm/annotation.c, src/vm/class.c,
+       src/vm/class.h, src/vm/exceptions.c, src/vm/exceptions.h,
+       src/vm/finalizer.c, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/alpha/md.c, src/vm/jit/asmpart.h, src/vm/jit/codegen-
+       common.c, src/vm/jit/i386/asmpart.S, src/vm/jit/i386/md.c,
+       src/vm/jit/inline/inline.c, src/vm/jit/mips/md.c,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/powerpc/asmpart.S,
+       src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/md.c,
+       src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c,
+       src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h,
+       src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/md.c,
+       src/vm/linker.c, src/vm/loader.c, src/vm/properties.c,
+       src/vm/properties.h, src/vm/resolve.c, src/vm/resolve.h,
+       src/vm/signal.c, src/vm/utf8.c, src/vm/utf8.h, src/vm/vm.c,
+       tests/regression/Makefile.am,
+       tests/regression/codepatching/Makefile.am,
+       tests/regression/jasmin/Makefile.am,
+       tests/regression/native/Makefile.am:
+       Merged with trunk rev6223.
+
+       * m4/ac_prog_javac.m4, src/vm/properties.h, src/vm/class.c,
+       src/vm/loader.c, src/vm/annotation.c, src/vm/class.h,
+       src/vm/resolve.c, src/vm/finalizer.c, src/vm/resolve.h,
+       src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/codegen.c,
+       src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/asmpart.S,
+       src/vm/jit/optimizing/recompile.c, src/vm/jit/stacktrace.c,
+       src/vm/jit/stacktrace.h, src/vm/jit/codegen-common.c,
+       src/vm/signal.c, src/vm/exceptions.c, src/vm/vm.c, src/vm/linker.c,
+       src/vm/exceptions.h, src/vm/utf8.c, src/vm/utf8.h,
+       src/vm/properties.c, src/lib/vm/reference/java/lang/VMThread.java,
+       src/native/jni.c, src/native/vm/java_lang_Thread.h,
+       src/native/vm/cldc1.1,
+       src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c,
+       src/native/vm/cldc1.1/java_lang_Runtime.c,
+       src/native/vm/cldc1.1/java_lang_System.c,
+       src/native/vm/cldc1.1/java_lang_Class.c,
+       src/native/vm/cldc1.1/java_lang_Float.c,
+       src/native/vm/cldc1.1/Makefile.am,
+       src/native/vm/cldc1.1/java_lang_Object.c,
+       src/native/vm/cldc1.1/java_lang_String.c,
+       src/native/vm/cldc1.1/java_lang_Thread.c,
+       src/native/vm/cldc1.1/java_lang_Throwable.c,
+       src/native/vm/cldc1.1/java_lang_Math.c,
+       src/native/vm/cldc1.1/.cvsignore,
+       src/native/vm/cldc1.1/java_lang_Double.c,
+       src/native/vm/java_lang_Class.c,
+       src/native/vm/gnu/java_lang_VMThread.c,
+       src/native/vm/gnu/java_lang_VMRuntime.c,
+       src/native/vm/gnu/Makefile.am, src/native/vm/Makefile.am,
+       src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Thread.c,
+       src/native/vm/java_lang_Class.h, src/native/vm/java_lang_Object.h,
+       src/native/include, src/native/include/java_lang_Thread.h,
+       src/native/include/java_lang_VMThread.h,
+       src/native/include/Makefile.am, src/native/include/.cvsignore,
+       src/native/native.c, src/native/Makefile.am, src/native/native.h,
+       src/mm/memory.c, src/Makefile.am, src/threads/native/threads.h,
+       src/threads/native/lock.c, src/threads/native/threads.c,
+       src/fdlibm/k_cos.c, src/fdlibm/s_ceil.c, src/fdlibm/s_finite.c,
+       src/fdlibm/ieeefp.h, src/fdlibm/fdlibm.h, src/fdlibm/s_floor.c,
+       src/fdlibm/k_sin.c, src/fdlibm/s_tan.c, src/fdlibm/s_cos.c,
+       src/fdlibm/w_fmod.c, src/fdlibm/mprec.h, src/fdlibm/s_sin.c,
+       src/fdlibm/s_copysign.c, src/fdlibm/w_sqrt.c,
+       src/fdlibm/e_rem_pio2.c, src/fdlibm/k_rem_pio2.c,
+       src/fdlibm/Makefile.am, src/fdlibm/e_fmod.c, src/fdlibm/k_tan.c,
+       src/fdlibm/e_sqrt.c, src/cacaoh/cacaoh.c, src/cacaoh/headers.c,
+       contrib/setenvinstalled.in, contrib/setenvsource.in,
+       tests/regression/jasmin/Makefile.am,
+       tests/regression/native/Makefile.am,
+       tests/regression/codepatching/Makefile.am,
+       tests/regression/Makefile.am, configure.ac: Merged.
+       [693ea6b397f5]
+
+2007-01-02  edwin  <edwin>
+
+       * configure.ac, src/vm/jit/Makefile.am, src/vm/jit/alpha/asmpart.S,
+       src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md.c,
+       src/vm/jit/asmpart.h, src/vm/jit/code.c, src/vm/jit/code.h,
+       src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h,
+       src/vm/jit/i386/asmpart.S, src/vm/jit/i386/emit.c,
+       src/vm/jit/i386/md.c, src/vm/jit/jit.h, src/vm/jit/mips/asmpart.S,
+       src/vm/jit/mips/emit.c, src/vm/jit/mips/md.c,
+       src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/emit.c,
+       src/vm/jit/powerpc/md.c, src/vm/jit/powerpc64/asmpart.S,
+       src/vm/jit/powerpc64/md.c, src/vm/jit/replace.h, src/vm/jit/show.c,
+       src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md.c,
+       src/vm/jit/tools/genoffsets.c, src/vm/jit/x86_64/asmpart.S,
+       src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md.c:
+       * configure.ac: Added option --enable-replacement.
+
+       * src/vm/jit/Makefile.am: Compile replace.c only for
+       ENABLE_REPLACEMENT.
+
+       * src/vm/jit/replace.h: Define empty macros unless
+       ENABLE_REPLACEMENT.
+
+       * src/vm/jit/powerpc/emit.c: Enclosed replacement-specific code in
+       #if ENABLE_REPLACEMENT.
+       * src/vm/jit/powerpc/md.c: Likewise.
+       * src/vm/jit/powerpc/asmpart.S: Likewise.
+       * src/vm/jit/codegen-common.h: Likewise.
+       * src/vm/jit/sparc64/emit.c: Likewise.
+       * src/vm/jit/sparc64/md.c: Likewise.
+       * src/vm/jit/alpha/emit.c: Likewise.
+       * src/vm/jit/alpha/md.c: Likewise.
+       * src/vm/jit/alpha/asmpart.S: Likewise.
+       * src/vm/jit/code.c: Likewise.
+       * src/vm/jit/code.h: Likewise.
+       * src/vm/jit/tools/genoffsets.c: Likewise.
+       * src/vm/jit/show.c: Likewise.
+       * src/vm/jit/mips/emit.c: Likewise.
+       * src/vm/jit/mips/md.c: Likewise.
+       * src/vm/jit/mips/asmpart.S: Likewise.
+       * src/vm/jit/powerpc64/md.c: Likewise.
+       * src/vm/jit/powerpc64/asmpart.S: Likewise.
+       * src/vm/jit/i386/emit.c: Likewise.
+       * src/vm/jit/i386/md.c: Likewise.
+       * src/vm/jit/i386/asmpart.S: Likewise.
+       * src/vm/jit/asmpart.h: Likewise.
+       * src/vm/jit/x86_64/emit.c: Likewise.
+       * src/vm/jit/x86_64/md.c: Likewise.
+       * src/vm/jit/x86_64/asmpart.S: Likewise.
+       * src/vm/jit/codegen-common.c: Likewise.
+       * src/vm/jit/jit.h: Likewise.
+       [d57bc9b264e8]
+
+       * src/vm/jit/i386/codegen.c:
+       * src/vm/jit/i386/codegen.c (codegen): Cleaned up to use
+       REPLACEMENT_ macros.
+       [262f09f41eaf]
+
+2007-01-02  twisti  <twisti>
+
+       * tests/regression/jctest.java, tests/regression/jctest.output:
+       * tests/regression/jctest.java: Print hex numbers too.
+       * tests/regression/jctest.output: Updated.
+       [bead5d6be07a]
+
diff --git a/INSTALL b/INSTALL
index f3869a941abc66166ca5ac152b1c526998c696cf..d3c5b40a94091285c27361905f591af64c1f7b21 100644 (file)
--- a/INSTALL
+++ b/INSTALL
-Quick start instructions
-========================
+Installation Instructions
+*************************
 
-You can check the configure options via `./configure --help'. But the
-default settings should be ok. For building the package type:
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007 Free Software Foundation, Inc.
 
-   $ ./configure
-   $ make
-   $ make install
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
 
-The default installation prefix is `/usr/local/cacao'. You can change
-this destination by providing the `--prefix=PATH' option to configure.
+Basic Installation
+==================
 
-This version of cacao only supports the `--prefix' option, even if
-configure processes the other options (`--bindir', `--libdir', etc.),
-it will screw up your installation since CACAO tries to setup a
-directory tree like the JVMs from Sun or IBM do.
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
 
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
 
-Requirements:
--------------
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+  6. Often, you can also type `make uninstall' to remove the installed
+     files again.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
 
-In order to compile the Java classes from GNU classpath, you need a
-Java compiler supported by GNU classpath. To get a working classpath
-in an appropriate time, we recommend IBM jikes 1.18 or newer. For
-further instructions concerning GNU classpath, please refer to
-`src/classpath/INSTALL'.
index e451bb5a5888a841377bb2dbcfd5c6fb3d460bbb..069cd4fe1196f180db2fe4ff65cc1ed96980fa5d 100644 (file)
@@ -25,7 +25,12 @@ ACLOCAL_AMFLAGS = -I m4
 
 MAINTAINERCLEANFILES = Makefile.in configure
 
-SUBDIRS = contrib doc man src tests
+SUBDIRS = \
+       contrib \
+       doc \
+       man \
+       src \
+       tests
 
 EXTRA_DIST = \
        ChangeLog-1998 \
@@ -36,6 +41,8 @@ EXTRA_DIST = \
        ChangeLog-2003 \
        ChangeLog-2004 \
        ChangeLog-2005 \
+       ChangeLog-2006 \
+       ChangeLog-2007 \
        THIRDPARTY
 
 
diff --git a/NEWS b/NEWS
index 973a7bd67f277fc43049111cbb335101a82995e0..e2ce1c6aba6200b66e39de2f9e2853c8a7efa587 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,20 @@
-New in release 0.99 (March x, 2008)
+New in release 0.99.1 (June 17, 2008)
+
+  * Fixed compilation of OpenJDK code (libltdl related).
+  * Imported new gnu/java/lang/CPStringBuilder.java to fix OOMEs.
+  * Fixed abort with OpenJDK's java binary when exiting.
+
+New in release 0.99 (June 14, 2008)
 
   * Initial support to use OpenJDK as Java core library.
   * Fixed memory leak in Boehm-GC.
+  * Boehm-GC updated to version 7.1.
+  * Removed libltdl dependency.
+  * Renamed --with-classpath configure options to
+    --with-java-runtime-library.
+  * Renamed --with-jre-layout to --enable-layout.
+  * Replaced --with-classpath-includedir with --with-jni_h and
+    --with-jni_md_h to better support OpenJDK/IcedTea builds.
   * Use 8-byte stack-slots on all architectures.
   * Faster C-to-Java calls.
   * Removed genoffsets, cross-compilation is now much easier.
@@ -11,8 +24,6 @@ New in release 0.99 (March x, 2008)
   * Assertion support.
   * Linenumber table code rewritten.
   * Exception table code rewritten.
-  * Replaced --with-classpath-includedir with --with-jni_h and
-    --with-jni_md_h to better support OpenJDK/IcedTea build.s
 
 
 New in release 0.98 (June 6, 2007)
index ec1766123ade024727c646a8dc99d8377ba5f2e5..24002d4bbc24ec4430e40614fed4f8428dc113c4 100644 (file)
@@ -70,7 +70,7 @@ The upstream for fdlibm is libgcj (http://gcc.gnu.org/java/), they sync
 again with the 'real' upstream (http://www.netlib.org/fdlibm/readme).
 
 
-* src/lib/gnu/*
+* src/classes/gnuclasspath/*
 
 GNU Classpath is licensed under the terms of the GNU General Public 
 License  with the following clarification and special exception:
@@ -108,7 +108,7 @@ that contains a configuration script generated by Autoconf, under
 the same distribution terms as the rest of that program.
 
 
-* m4/{ac_prog_javac.m4,ac_prog_javac_works.m4}
+* m4/{ac_prog_jar.m4,ac_prog_javac.m4,ac_prog_javac_works.m4,ax_compiler_vendor.m4}
 
 The http://ac-archive.sourceforge.net/ website states this about the
 copyright:
@@ -169,36 +169,6 @@ are permitted in any medium without royalty provided the copyright
 notice and this notice are preserved.
 
 
-* contrib/svn2cl.xsl
-
-   Copyright (C) 2004, 2005, 2006 Arthur de Jong.
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions
-   are met:
-   1. Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-   2. Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-   3. The name of the author may not be used to endorse or promote
-      products derived from this software without specific prior
-      written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-   ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-   IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
 * contrib/vmlog
 
 Copyright (C) 2006 Edwin Steiner <edwin.steiner@gmx.net>
@@ -212,14 +182,14 @@ See contrib/vmlog/COPYING for the full text of the license.
 
 
 * contrib/mapfile-vers-product,
-  src/lib/gnu/sun/misc/Unsafe.java,
-  src/lib/gnu/sun/reflect/ConstantPool.java,
-  src/lib/gnu/sun/reflect/annotation/AnnotationParser.java,
-  src/lib/gnu/sun/reflect/annotation/AnnotationType.java,
-  src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java,
-  src/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java,
-  src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java,
-  src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
+  src/classes/gnuclasspath/sun/misc/Unsafe.java,
+  src/classes/gnuclasspath/sun/reflect/ConstantPool.java,
+  src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java,
+  src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java,
+  src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java,
+  src/classes/gnuclasspath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java,
+  src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java,
+  src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
 
 Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
index 1c6c633c87997a93f81cd87d36be0ff21aa67ddc..5b41f04c3b038b04bf935a4aa42644421a55ad18 100755 (executable)
 #!/bin/sh
 
-# test for a libtoolize
+# Test for a autoconf commands.
 
-CACAO_HAVE_LIBTOOLIZE=false
+# Test for a autoconf.
 
-for CACAO_LIBTOOLIZE in libtoolize libtoolize15 glibtoolize; do
-    if ${CACAO_LIBTOOLIZE} --version > /dev/null 2>&1; then
-        CACAO_LIBTOOLIZE_VERSION=`${CACAO_LIBTOOLIZE} --version | sed 's/^.*[^0-9.]\([0-9]\{1,\}\.[0-9.]\{1,\}\).*/\1/'`
-#        echo ${CACAO_LIBTOOLIZE_VERSION}
-        case ${CACAO_LIBTOOLIZE_VERSION} in
-            1.5* | 2.* )
-                CACAO_HAVE_LIBTOOLIZE=true
+HAVE_AUTOCONF=false
+
+for AUTOCONF in autoconf autoconf259; do
+    if ${AUTOCONF} --version > /dev/null 2>&1; then
+        AUTOCONF_VERSION=`${AUTOCONF} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
+#        echo ${AUTOCONF_VERSION}
+        case ${AUTOCONF_VERSION} in
+            2.59* | 2.6[0-9]* )
+                HAVE_AUTOCONF=true
                 break;
                 ;;
         esac
     fi
 done
 
-if test ${CACAO_HAVE_LIBTOOLIZE} = false; then
-    echo "No proper libtoolize was found."
-    echo "You must have libtool 1.5 or later installed."
-    exit 1
-fi
+# Test for a autoheader.
 
+HAVE_AUTOHEADER=false
 
-# test for a aclocal
-
-CACAO_HAVE_ACLOCAL=false
-
-for CACAO_ACLOCAL in aclocal aclocal-1.9 aclocal19; do
-    if ${CACAO_ACLOCAL} --version > /dev/null 2>&1; then
-        CACAO_ACLOCAL_VERSION=`${CACAO_ACLOCAL} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
-#        echo ${CACAO_ACLOCAL_VERSION}
-        case ${CACAO_ACLOCAL_VERSION} in
-            1.9* | 1.1[0-9]* )
-                CACAO_HAVE_ACLOCAL=true
+for AUTOHEADER in autoheader autoheader259; do
+    if ${AUTOHEADER} --version > /dev/null 2>&1; then
+        AUTOHEADER_VERSION=`${AUTOHEADER} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
+#        echo ${AUTOHEADER_VERSION}
+        case ${AUTOHEADER_VERSION} in
+            2.59* | 2.6[0-9]* )
+                HAVE_AUTOHEADER=true
                 break;
                 ;;
         esac
     fi
 done
 
-if test ${CACAO_HAVE_ACLOCAL} = false; then
-    echo "No proper aclocal was found."
-    echo "You must have automake 1.9 or later installed."
-    exit 1
-fi
-
+# Test for a autoreconf.
 
-# test for a autoheader
+HAVE_AUTORECONF=false
 
-CACAO_HAVE_AUTOHEADER=false
-
-for CACAO_AUTOHEADER in autoheader autoheader259; do
-    if ${CACAO_AUTOHEADER} --version > /dev/null 2>&1; then
-        CACAO_AUTOHEADER_VERSION=`${CACAO_AUTOHEADER} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
-#        echo ${CACAO_AUTOHEADER_VERSION}
-        case ${CACAO_AUTOHEADER_VERSION} in
+for AUTORECONF in autoreconf; do
+    if ${AUTORECONF} --version > /dev/null 2>&1; then
+        AUTORECONF_VERSION=`${AUTORECONF} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
+#        echo ${AUTORECONF_VERSION}
+        case ${AUTORECONF_VERSION} in
             2.59* | 2.6[0-9]* )
-                CACAO_HAVE_AUTOHEADER=true
+                HAVE_AUTORECONF=true
                 break;
                 ;;
         esac
     fi
 done
 
-if test ${CACAO_HAVE_AUTOHEADER} = false; then
+if test ${HAVE_AUTOCONF} = false; then
+    echo "No proper autoconf was found."
+    echo "You must have autoconf 2.59 or later installed."
+    exit 1
+fi
+
+if test ${HAVE_AUTOHEADER} = false; then
     echo "No proper autoheader was found."
     echo "You must have autoconf 2.59 or later installed."
     exit 1
 fi
 
+if test ${HAVE_AUTORECONF} = false; then
+    echo "No proper autoreconf was found."
+    echo "You must have autoconf 2.59 or later installed."
+    exit 1
+fi
 
-# test for a automake
 
-CACAO_HAVE_AUTOMAKE=false
+# Test for a automake commands.
 
-for CACAO_AUTOMAKE in automake automake-1.9 automake19; do
-    if ${CACAO_AUTOMAKE} --version > /dev/null 2>&1; then
-        CACAO_AUTOMAKE_VERSION=`${CACAO_AUTOMAKE} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
-#        echo ${CACAO_AUTOMAKE_VERSION}
-        case ${CACAO_AUTOMAKE_VERSION} in
+# Test for a aclocal.
+
+HAVE_ACLOCAL=false
+
+for ACLOCAL in aclocal aclocal-1.10 aclocal-1.9 aclocal19; do
+    if ${ACLOCAL} --version > /dev/null 2>&1; then
+        ACLOCAL_VERSION=`${ACLOCAL} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
+#        echo ${ACLOCAL_VERSION}
+        case ${ACLOCAL_VERSION} in
+            1.9* | 1.1[0-9]* )
+                HAVE_ACLOCAL=true
+                break;
+                ;;
+        esac
+    fi
+done
+
+# Test for a automake.
+
+HAVE_AUTOMAKE=false
+
+for AUTOMAKE in automake automake-1.10 automake-1.9 automake19; do
+    if ${AUTOMAKE} --version > /dev/null 2>&1; then
+        AUTOMAKE_VERSION=`${AUTOMAKE} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
+#        echo ${AUTOMAKE_VERSION}
+        case ${AUTOMAKE_VERSION} in
             1.9* | 1.1[0-9]* )
-                CACAO_HAVE_AUTOMAKE=true
+                HAVE_AUTOMAKE=true
                 break;
                 ;;
         esac
     fi
 done
 
-if test ${CACAO_HAVE_AUTOMAKE} = false; then
+if test ${HAVE_ACLOCAL} = false; then
+    echo "No proper aclocal was found."
+    echo "You must have automake 1.9 or later installed."
+    exit 1
+fi
+
+if test ${HAVE_AUTOMAKE} = false; then
     echo "No proper automake was found."
     echo "You must have automake 1.9 or later installed."
     exit 1
 fi
 
 
-# test for a autoconf
+# Test for a libtoolize.
 
-CACAO_HAVE_AUTOCONF=false
+HAVE_LIBTOOLIZE=false
 
-for CACAO_AUTOCONF in autoconf autoconf259; do
-    if ${CACAO_AUTOCONF} --version > /dev/null 2>&1; then
-        CACAO_AUTOCONF_VERSION=`${CACAO_AUTOCONF} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
-#        echo ${CACAO_AUTOCONF_VERSION}
-        case ${CACAO_AUTOCONF_VERSION} in
-            2.59* | 2.6[0-9]* )
-                CACAO_HAVE_AUTOCONF=true
+for LIBTOOLIZE in libtoolize libtoolize15 glibtoolize; do
+    if ${LIBTOOLIZE} --version > /dev/null 2>&1; then
+        LIBTOOLIZE_VERSION=`${LIBTOOLIZE} --version | sed 's/^.*[^0-9.]\([0-9]\{1,\}\.[0-9.]\{1,\}\).*/\1/'`
+#        echo ${LIBTOOLIZE_VERSION}
+        case ${LIBTOOLIZE_VERSION} in
+            1.5* | 2.* )
+                HAVE_LIBTOOLIZE=true
                 break;
                 ;;
         esac
     fi
 done
 
-if test ${CACAO_HAVE_AUTOCONF} = false; then
-    echo "No proper autoconf was found."
-    echo "You must have autoconf 2.59 or later installed."
+if test ${HAVE_LIBTOOLIZE} = false; then
+    echo "No proper libtoolize was found."
+    echo "You must have libtool 1.5 or later installed."
     exit 1
 fi
 
 
-${CACAO_LIBTOOLIZE} --automake
-if test `uname` = 'FreeBSD'; then
-    ${CACAO_ACLOCAL} -I m4 -I /usr/local/share/aclocal -I /usr/local/share/aclocal19
-else
-    ${CACAO_ACLOCAL} -I m4
-fi
-${CACAO_AUTOHEADER}
-${CACAO_AUTOMAKE} --add-missing
-${CACAO_AUTOCONF}
-
-export CACAO_LIBTOOLIZE
-export CACAO_ACLOCAL
-export CACAO_AUTOHEADER
-export CACAO_AUTOMAKE
-export CACAO_AUTOCONF
+export ACLOCAL AUTOCONF AUTOHEADER AUTOMAKE LIBTOOLIZE
 
-cd src/mm/boehm-gc && ./autogen.sh && cd ../..
+${AUTORECONF} --force --install
index f4269984191652bb532c79376f54f59c80adc4d2..9312ab4e99ee8d68aba26d7d9d9e85bcd8e1dda0 100644 (file)
@@ -23,11 +23,11 @@ dnl 02110-1301, USA.
 dnl Process this file with autoconf to produce a configure script.
 
 
-AC_INIT(cacao, 0.99rc6, cacao@cacaojvm.org)
-AC_CONFIG_SRCDIR(src/cacao/cacao.c)
+AC_INIT(cacao, 1.1.0pre, cacao@cacaojvm.org)
+AC_CONFIG_SRCDIR(src/cacao/cacao.cpp)
 AC_CANONICAL_HOST
 AC_PREREQ(2.59)
-AM_INIT_AUTOMAKE([1.9.0 dist-bzip2])
+AM_INIT_AUTOMAKE([1.9.0 dist-bzip2 tar-ustar])
 AM_MAINTAINER_MODE
 
 AM_CONFIG_HEADER([config.h])
@@ -35,162 +35,210 @@ AM_CONFIG_HEADER([config.h])
 AC_PREFIX_DEFAULT(/usr/local/cacao)
 
 
-dnl set optimization and debugging for all architectures and systems
-if test x"$CFLAGS" = "x"; then
-    OPT_CFLAGS="-O0 -g3"
-else
-    OPT_CFLAGS=$CFLAGS
-fi
-
-dnl system type
+dnl Host CPU type.
 case "$host_cpu" in
 alpha | alphaev56 | alphapca56 )
     ARCH_DIR="alpha"
-    ARCH_CFLAGS="-mieee -D__ALPHA__"
+    ARCH_FLAGS="-mieee -D__ALPHA__"
     JAVA_ARCH="alpha"
     ;;
 
-arm | armv4 | armv4tl | armv5b | armv5l )
+arm | armv4 | armv4tl | armv5b | armv5l | armv5tel | armv5tejl )
     ARCH_DIR="arm"
-    ARCH_CFLAGS="-D__ARM__"
+    ARCH_FLAGS="-D__ARM__"
     JAVA_ARCH="arm"
     ;;
 
 hppa2.0 )
     ARCH_DIR="parisc"
-    ARCH_CFLAGS="-D__PARISC__"
+    ARCH_FLAGS="-D__PARISC__"
     JAVA_ARCH="hppa"
     ;;
 
 i386 | i486 | i586 | i686 )
     ARCH_DIR="i386"
-    ARCH_CFLAGS="-D__I386__"
+    ARCH_FLAGS="-m32 -D__I386__"
     JAVA_ARCH="i386"
     ;;
 
 m68k )
     ARCH_DIR="m68k"
-    ARCH_CFLAGS="-D__M68K__"
+    ARCH_FLAGS="-D__M68K__"
     JAVA_ARCH="m68k"
     ;;
 
-mips | mipsel )
+mips )
     ARCH_DIR="mips"
-    ARCH_CFLAGS="-D__MIPS__"
-    dnl Is this correct for mipsel?
+    ARCH_FLAGS="-D__MIPS__"
     JAVA_ARCH="mips"
     ;;
 
+mipsel )
+    ARCH_DIR="mips"
+    ARCH_FLAGS="-D__MIPS__"
+    JAVA_ARCH="mipsel"
+    ;;
+
 powerpc )
     ARCH_DIR="powerpc"
-    ARCH_CFLAGS="-D__POWERPC__"
+    ARCH_FLAGS="-m32 -D__POWERPC__"
     JAVA_ARCH="ppc"
     ;;
 
 powerpc64 )
     ARCH_DIR="powerpc64"
-    ARCH_CFLAGS="-D__POWERPC64__"
+    ARCH_FLAGS="-m64 -D__POWERPC64__"
     JAVA_ARCH="ppc64"
     ;;
 
 s390 )
     ARCH_DIR="s390"
-    ARCH_CFLAGS="-D__S390__"
+    ARCH_FLAGS="-D__S390__"
     JAVA_ARCH="s390"
     ;;
 
 sparc | sparc64 )
     ARCH_DIR="sparc64"
-    ARCH_CFLAGS="-mcpu=v9 -m64 -D__SPARC_64__"
+    ARCH_FLAGS="-mcpu=v9 -m64 -D__SPARC_64__"
     dnl Is this correct for 64-bits?
     JAVA_ARCH="sparc"
     ;;
 
 x86_64 )
     ARCH_DIR="x86_64"
-    ARCH_CFLAGS="-D__X86_64__"
+    ARCH_FLAGS="-m64 -D__X86_64__"
     JAVA_ARCH="amd64"
     ;;
 
 xdspcore )
     ARCH_DIR="xdspcore"
     ENABLE_STATICVM="yes"
-    ARCH_CFLAGS="-D__XDSPCORE__"
+    ARCH_FLAGS="-D__XDSPCORE__"
     USE_SCHEDULER="1"
     ;;
 
 * )
-    AC_MSG_ERROR($host_cpu systems are not supported at this time)
+    AC_MSG_ERROR([$host_cpu systems are currently not supported.])
     ;;
 esac
 
-dnl host type
+
+dnl Host operating system type.
 case "$host_os" in
 *cygwin* )
     OS_DIR="cygwin"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -Wall -Wno-long-long"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -ansi -pedantic -Wall -Wno-long-long"
+    OS_FLAGS="-D__WINDOWS__ -D__CYGWIN__"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *darwin* )
     OS_DIR="darwin"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -Wall -Wno-long-long"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -ansi -pedantic -Wall -Wno-long-long"
+    OS_FLAGS="-D__DARWIN__"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
+    ;;
+
+dnl Must be BEFORE *freebsd*.
+*kfreebsd*-gnu)
+    OS_DIR="freebsd"
+    OS_FLAGS="-D__FREEBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *freebsd* )
     OS_DIR="freebsd"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -ansi -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED"
+    OS_FLAGS="-D__FREEBSD__ -D_XOPEN_SOURCE_EXTENDED"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *irix* )
     OS_DIR="irix"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__IRIX__"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__IRIX__"
-    ;;
-
-*kfreebsd*-gnu)
-    OS_DIR="freebsd"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    OS_FLAGS="-D__IRIX__"
+    INTRP_CFLAGS="$ARCH_FLAGS $OS_FLAGS"
     ;;
 
-dnl must be before *linux*
+dnl Must be BEFORE *linux*.
 *uclinux | *elf )
     OS_DIR="uclinux"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *linux* | *Linux* )
     OS_DIR="linux"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *netbsd* )
     OS_DIR="netbsd"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    OS_FLAGS="-D__NETBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *solaris* )
     OS_DIR="solaris"
-       dnl on solaris the architecture defines 'sparc','sun','unix' are not set when cpp is called with -ansi
-       dnl therefore we add them here
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__SOLARIS__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ -D_BSD_SOURCE -Dsparc -Dsun -Dunix"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__SOLARIS__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ -D_BSD_SOURCE -Dsparc -Dsun -Dunix"
+    dnl On solaris the architecture defines 'sparc', 'sun', 'unix' are
+    dnl not set when cpp is called with -std=c99, therefore we add them
+    dnl here.
+    OS_FLAGS="-D__SOLARIS__ -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_BSD_SOURCE"
+    CC_FLAGS="-D_XOPEN_SOURCE=600"
+    CXX_FLAGS="-D_XOPEN_SOURCE=500"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 * )
+    AC_MSG_ERROR([$host_os operating systems are currently not supported.])
     ;;
 esac
 
 
-dnl temporary set the CFLAGS for configure tests (e.g. inline keyword)
-dnl we set it properly at the end of this file
-CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
+dnl Set optimization and debugging for all architectures and systems.
+dnl NOTE: Setting the CFLAGS/CXXFLAGS only works before calling AC_PROG_CC/AC_PROG_CXX.
+if test x"$CFLAGS" = "x"; then
+    OPT_CFLAGS="-g -O0"
+else
+    OPT_CFLAGS=$CFLAGS
+fi
+
+if test x"$CXXFLAGS" = "x"; then
+    OPT_CXXFLAGS="-g -O0"
+else
+    OPT_CXXFLAGS=$CXXFLAGS
+fi
+
+dnl Check for compiler.
+AC_PROG_CC
+AC_PROG_CXX
+
+dnl Check compiler vendor.
+AX_COMPILER_VENDOR
+
+dnl Set compiler flags depending on the compiler vendor.
+case "$ax_cv_c_compiler_vendor" in
+gnu )
+    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long $CC_FLAGS"
+    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long $CXX_FLAGS"
+    ;;
+
+sgi )
+    CC_FLAGS="-c99 $CC_FLAGS"
+    CXX_FLAGS="$CXX_FLAGS"
+    ;;
+
+sun )
+    CC_FLAGS="-xc99 $CC_FLAGS"
+    CXX_FLAGS="$CXX_FLAGS"
+    ;;
+
+* )    
+    AC_MSG_ERROR([$ax_cv_c_compiler_vendor compilers are currently not supported.])
+    ;;
+esac
+
+dnl Temporary set the CFLAGS for configure tests (e.g. inline keyword)
+dnl we set it properly at the end of this file.
+CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS"
+CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS"
 
 dnl set interpreter flags
 AC_SUBST(INTRP_CFLAGS)
@@ -199,30 +247,37 @@ dnl define and substitute some architecture specific variables
 AC_DEFINE_UNQUOTED([ARCH_DIR], "${ARCH_DIR}", [architecture directory])
 AC_DEFINE_UNQUOTED([JAVA_ARCH], "${JAVA_ARCH}", [Java architecture name])
 AC_SUBST(ARCH_DIR)
+AC_SUBST(JAVA_ARCH)
 AC_SUBST(OS_DIR)
 AC_SUBST(USE_SCHEDULER)
 
-
 dnl Checks for programs.
-AC_PROG_CC
 AM_PROG_AS
 AC_PROG_LD
 AC_PROG_LD_GNU
-AC_PROG_RANLIB
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AM_PROG_MKDIR_P
 
+AM_CONDITIONAL([WITH_GNU_LD], [test x"$with_gnu_ld" = "xyes"])
+
 dnl Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 
+dnl Crucial header files.
+AC_CHECK_HEADERS([stdbool.h],, [AC_MSG_ERROR(cannot find stdbool.h)])
+AC_CHECK_HEADERS([stdint.h],, [AC_MSG_ERROR(cannot find stdint.h)])
+
 dnl keep them alpha-sorted!
 AC_CHECK_HEADERS([assert.h])
 AC_CHECK_HEADERS([errno.h])
+AC_CHECK_HEADERS([execinfo.h])
 AC_CHECK_HEADERS([fcntl.h])
 AC_CHECK_HEADERS([libgen.h])
 AC_CHECK_HEADERS([netdb.h])
+AC_CHECK_HEADERS([signal.h])
+AC_CHECK_HEADERS([stdarg.h])
 AC_CHECK_HEADERS([stdint.h])
 AC_CHECK_HEADERS([stdio.h])
 AC_CHECK_HEADERS([stdlib.h])
@@ -239,15 +294,6 @@ AC_CHECK_HEADERS([sys/stat.h])
 AC_CHECK_HEADERS([sys/time.h])
 AC_CHECK_HEADERS([sys/types.h])
 
-dnl this is for fdlibm
-AC_CHECK_HEADERS([inttypes.h])
-AC_CHECK_HEADERS([sys/config.h])
-AC_CHECK_HEADERS([sys/types.h])
-AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t]))
-AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t]))
-AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, [Define to 1 if you have BSD u_int32_t]))
-AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, [Define to 1 if you have BSD u_int32_t]))
-
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_INLINE
@@ -259,7 +305,11 @@ AC_STRUCT_TM
 
 dnl Checks for libraries (NOTE: Should be done before function checks,
 dnl as some functions may be in libraries we check for).
-AC_CHECK_LIB(dl, dlopen,,)
+case "${OS_DIR}" in
+    solaris )
+         AC_CHECK_LIB([socket], [gethostname],, [AC_MSG_ERROR(cannot find libsocket)])
+         ;;
+esac
 
 dnl Checks for library functions.
 AC_PROG_GCC_TRADITIONAL
@@ -273,6 +323,8 @@ AC_CHECK_FUNCS([accept])
 AC_CHECK_FUNCS([access])
 AC_CHECK_FUNCS([atoi])
 AC_CHECK_FUNCS([atol])
+AC_CHECK_FUNCS([backtrace])
+AC_CHECK_FUNCS([backtrace_symbols])
 AC_CHECK_FUNCS([calloc])
 AC_CHECK_FUNCS([close])
 AC_CHECK_FUNCS([confstr])
@@ -288,6 +340,7 @@ AC_CHECK_FUNCS([fstat])
 AC_CHECK_FUNCS([fsync])
 AC_CHECK_FUNCS([ftruncate])
 AC_CHECK_FUNCS([getcwd])
+AC_CHECK_FUNCS([getenv])
 AC_CHECK_FUNCS([gethostbyname])
 AC_CHECK_FUNCS([gethostname])
 AC_CHECK_FUNCS([getpagesize])
@@ -308,6 +361,7 @@ AC_CHECK_FUNCS([memset])
 AC_CHECK_FUNCS([mmap])
 AC_CHECK_FUNCS([mprotect])
 AC_CHECK_FUNCS([open])
+AC_CHECK_FUNCS([printf])
 AC_CHECK_FUNCS([read])
 AC_CHECK_FUNCS([readlink])
 AC_CHECK_FUNCS([realloc])
@@ -319,9 +373,11 @@ AC_CHECK_FUNCS([setsockopt])
 AC_CHECK_FUNCS([shutdown])
 AC_CHECK_FUNCS([socket])
 AC_CHECK_FUNCS([stat])
+AC_CHECK_FUNCS([str2sig])
 AC_CHECK_FUNCS([strcat])
 AC_CHECK_FUNCS([strchr])
 AC_CHECK_FUNCS([strcpy])
+AC_CHECK_FUNCS([strcmp])
 AC_CHECK_FUNCS([strdup])
 AC_CHECK_FUNCS([strerror])
 AC_CHECK_FUNCS([strlen])
@@ -359,8 +415,7 @@ AC_DEFINE_UNQUOTED([CACAO_LIBDIR], "${CACAO_LIBDIR}", [library installation pref
 AC_SUBST(CACAO_LIBDIR)
 
 
-AC_CHECK_ENABLE_LTDL
-
+AC_CHECK_ENABLE_DL
 AC_CHECK_ENABLE_JAVA
 
 AC_CHECK_ENABLE_JIT
@@ -377,266 +432,20 @@ AC_CHECK_SOFT_DOUBLE_CMP
 AC_CHECK_ENABLE_GC
 AC_CHECK_ENABLE_DEBUG
 AC_CHECK_ENABLE_DUMP
-
-
-dnl check for memcheck support
-AC_MSG_CHECKING(whether debugging memory checks should be enabled)
-AC_ARG_ENABLE([memcheck],
-              [AS_HELP_STRING(--enable-memcheck,enable debugging memory checks [[default=no]])],
-              [case "${enableval}" in
-                   yes) ENABLE_MEMCHECK=yes;;
-                   *) ENABLE_MEMCHECK=no;;
-               esac],
-              [ENABLE_MEMCHECK=no])
-AC_MSG_RESULT(${ENABLE_MEMCHECK})
-AM_CONDITIONAL([ENABLE_MEMCHECK], test x"${ENABLE_MEMCHECK}" = "xyes")
-
-if test x"${ENABLE_MEMCHECK}" = "xyes"; then
-    AC_DEFINE([ENABLE_MEMCHECK], 1, [perform debugging memory checks])
-fi
-
-
-dnl check for handles (indirection cells) support
-AC_MSG_CHECKING(whether handles (indirection cells) should be enabled)
-AC_ARG_ENABLE([handles],
-              [AS_HELP_STRING(--enable-handles,enable handles (indirection cells) [[default=no]])],
-              [case "${enableval}" in
-                   yes) ENABLE_HANDLES=yes;;
-                   *) ENABLE_HANDLES=no;;
-               esac],
-              [ENABLE_HANDLES=no])
-AC_MSG_RESULT(${ENABLE_HANDLES})
-AM_CONDITIONAL([ENABLE_HANDLES], test x"${ENABLE_HANDLES}" = "xyes")
-
-if test x"${ENABLE_HANDLES}" = "xyes"; then
-    AC_DEFINE([ENABLE_HANDLES], 1, [enable handles (indirection cells)])
-fi
-
-
-dnl check for vmlog support
-AC_MSG_CHECKING(whether vmlog tracing should be enabled)
-AC_ARG_ENABLE([vmlog],
-              [AS_HELP_STRING(--enable-vmlog,enable vmlog tracing [[default=no]])],
-              [case "${enableval}" in
-                   yes) ENABLE_VMLOG=yes;;
-                   *) ENABLE_VMLOG=no;;
-               esac],
-              [ENABLE_VMLOG=no])
-AC_MSG_RESULT(${ENABLE_VMLOG})
-AM_CONDITIONAL([ENABLE_VMLOG], test x"${ENABLE_VMLOG}" = "xyes")
-
-if test x"${ENABLE_VMLOG}" = "xyes"; then
-    AC_DEFINE([ENABLE_VMLOG], 1, [enable vmlog tracing code])
-fi
-
-
-dnl check for disassembler support
-AC_MSG_CHECKING(whether disassembler should be enabled)
-AC_ARG_ENABLE([disassembler],
-              [AS_HELP_STRING(--enable-disassembler,enable disassembler [[default=no]])],
-              [case "${enableval}" in
-                   yes) ENABLE_DISASSEMBLER=yes;;
-                   *) ENABLE_DISASSEMBLER=no;;
-               esac],
-              [ENABLE_DISASSEMBLER=no])
-AC_MSG_RESULT(${ENABLE_DISASSEMBLER})
-AM_CONDITIONAL([ENABLE_DISASSEMBLER], test x"${ENABLE_DISASSEMBLER}" = "xyes")
-
-if test x"${ENABLE_DISASSEMBLER}" = "xyes"; then
-    AC_DEFINE([ENABLE_DISASSEMBLER], 1, [enable disassembler])
-
-    dnl check for binutils headers and libraries on some architectures for the
-    dnl disassembler
-    case "${ARCH_DIR}" in
-        arm | i386 | powerpc | x86_64 | sparc64 | powerpc64 | s390 | m68k)
-            AC_CHECK_HEADER([ansidecl.h],, [AC_MSG_ERROR(cannot find ansidecl.h)])
-            AC_CHECK_HEADER([symcat.h],, [AC_MSG_ERROR(cannot find symcat.h)])
-            AC_CHECK_HEADER([bfd.h],, [AC_MSG_ERROR(cannot find bfd.h)])
-            AC_CHECK_HEADER([dis-asm.h],, [AC_MSG_ERROR(cannot find dis-asm.h)])
-
-            case "${OS_DIR}" in
-                cygwin | darwin | netbsd | solaris)
-                     AC_CHECK_LIB(intl, dcgettext,, [AC_MSG_ERROR(cannot find libintl (from binutils))])
-                     ;;
-            esac
-
-            case "${OS_DIR}" in
-                solaris)
-                                        AC_CHECK_LIB(rt, sem_init,, [AC_MSG_ERROR(cannot find librt)])
-                     ;;
-            esac
-
-
-            AC_CHECK_LIB(iberty, xstrerror,, [AC_MSG_ERROR(cannot find libiberty (from binutils))])
-            AC_CHECK_LIB(bfd, bfd_get_arch,, [AC_MSG_ERROR(cannot find libbfd (from binutils))])
-            AC_CHECK_LIB(opcodes, disassembler,, [AC_MSG_ERROR(cannot find libopcodes (from binutils))])
-            AC_DEFINE([WITH_BINUTILS_DISASSEMBLER], 1, [use binutils disassembler])
-            AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [true])
-            ;;
-        * )
-            AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
-            ;;
-    esac
-else
-    AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
-fi
-
-
-dnl check for statistics
-AC_MSG_CHECKING(whether statistics generation should be enabled)
-AC_ARG_ENABLE([statistics],
-              [AS_HELP_STRING(--enable-statistics,enable statistics generation [[default=no]])],
-              [case "${enableval}" in
-                   yes) ENABLE_STATISTICS=yes;;
-                   *) ENABLE_STATISTICS=no;;
-               esac],
-              [ENABLE_STATISTICS=no])
-AC_MSG_RESULT(${ENABLE_STATISTICS})
-AM_CONDITIONAL([ENABLE_STATISTICS], test x"${ENABLE_STATISTICS}" = "xyes")
-
-if test x"${ENABLE_STATISTICS}" = "xyes"; then
-    AC_DEFINE([ENABLE_STATISTICS], 1, [enable statistics])
-fi
-
-
-dnl check for verifier
-AC_MSG_CHECKING(whether classfile verification should be enabled)
-AC_ARG_ENABLE([verifier],
-              [AS_HELP_STRING(--disable-verifier,disable classfile verification [[default=enabled]])],
-              [case "${enableval}" in
-                   no) ENABLE_VERIFIER=no;;
-                   *) ENABLE_VERIFIER=yes;;
-               esac],
-              [ENABLE_VERIFIER=yes])
-AC_MSG_RESULT(${ENABLE_VERIFIER})
-AM_CONDITIONAL([ENABLE_VERIFIER], test x"${ENABLE_VERIFIER}" = "xyes")
-
-if test x"${ENABLE_VERIFIER}" = "xyes"; then
-    AC_DEFINE([ENABLE_VERIFIER], 1, [enable classfile verification])
-fi
-
-
-dnl check for compiler timing
-AC_MSG_CHECKING(whether real-time timing should be enabled)
-AC_ARG_ENABLE([rt-timing],
-              [AS_HELP_STRING(--enable-rt-timing,enable real-time timing [[default=no]])],
-              [case "${enableval}" in
-                   yes) ENABLE_RT_TIMING=yes;;
-                   *) ENABLE_RT_TIMING=no;;
-               esac],
-              [ENABLE_RT_TIMING=no])
-AC_MSG_RESULT(${ENABLE_RT_TIMING})
-AM_CONDITIONAL([ENABLE_RT_TIMING], test x"${ENABLE_RT_TIMING}" = "xyes")
-
-if test x"${ENABLE_RT_TIMING}" = "xyes"; then
-    AC_DEFINE([ENABLE_RT_TIMING], 1, [enable real-time timing])
-fi
-
-
-dnl check for cycle count statistics
-AC_MSG_CHECKING(whether cycle count statistics should be enabled)
-AC_ARG_ENABLE([cycles-stats],
-              [AS_HELP_STRING(--enable-cycles-stats,enable cycle count statistics [[default=no]])],
-              [case "${enableval}" in
-                   yes) ENABLE_CYCLES_STATS=yes;;
-                   *) ENABLE_CYCLES_STATS=no;;
-               esac],
-              [ENABLE_CYCLES_STATS=no])
-AC_MSG_RESULT(${ENABLE_CYCLES_STATS})
-AM_CONDITIONAL([ENABLE_CYCLES_STATS], test x"${ENABLE_CYCLES_STATS}" = "xyes")
-
-if test x"${ENABLE_CYCLES_STATS}" = "xyes"; then
-    AC_DEFINE([ENABLE_CYCLES_STATS], 1, [enable cycle count statistics])
-fi
-
-
-dnl check for JVMTI
-AC_MSG_CHECKING(whether to compile JVMTI support)
-AC_ARG_ENABLE([jvmti],
-              [AS_HELP_STRING(--enable-jvmti,enable JVMTI [[default=no]])],
-              [case "${enableval}" in
-                   yes) ENABLE_JVMTI=yes;;
-                   *) ENABLE_JVMTI=no;;
-               esac],
-              [ENABLE_JVMTI=no])
-AC_MSG_RESULT(${ENABLE_JVMTI})
-AM_CONDITIONAL([ENABLE_JVMTI], test x"${ENABLE_JVMTI}" = "xyes")
-
-if test x"${ENABLE_JVMTI}" = "xyes"; then
-    AC_DEFINE([ENABLE_JVMTI], 1, [use JVMTI])
-fi
-
-
+AC_CHECK_ENABLE_MEMCHECK
+AC_CHECK_ENABLE_HANDLES
+AC_CHECK_ENABLE_VMLOG
+AC_CHECK_ENABLE_DISASSEMBLER
+AC_CHECK_ENABLE_STATISTICS
+AC_CHECK_ENABLE_VERIFIER
+AC_CHECK_ENABLE_RT_TIMING
+AC_CHECK_ENABLE_CYCLE_STATS
+AC_CHECK_ENABLE_JVMTI
 AC_CHECK_ENABLE_THREADS
-
-
-dnl check if if-conversion should be supported
-AC_MSG_CHECKING(whether if-conversion should be supported)
-AC_ARG_ENABLE([ifconv],
-              [AS_HELP_STRING(--disable-ifconv,disable if-conversion [[default=enabled]])],
-              [case "${enableval}" in
-                   no) ENABLE_IFCONV=no;;
-                   *) ENABLE_IFCONV=yes;;
-               esac],
-              [ENABLE_IFCONV=yes])
-AC_MSG_RESULT(${ENABLE_IFCONV})
-AM_CONDITIONAL([ENABLE_IFCONV], test x"${ENABLE_IFCONV}" = "xyes")
-   
-if test x"${ENABLE_IFCONV}" = "xyes"; then
-    AC_DEFINE([ENABLE_IFCONV], 1, [enable if-conversion])
-fi
-
-
-dnl check for inlining
-AC_MSG_CHECKING(whether method inlining should be supported)
-AC_ARG_ENABLE([inlining],
-              [AS_HELP_STRING(--enable-inlining,enable method inlining [[default=no]])],
-              [case "${enableval}" in
-                   yes) ENABLE_INLINING=yes;;
-                   *) ENABLE_INLINING=no;;
-               esac],
-              [ENABLE_INLINING=no])
-AC_MSG_RESULT(${ENABLE_INLINING})
-AM_CONDITIONAL([ENABLE_INLINING], test x"${ENABLE_INLINING}" = "xyes")
-
-if test x"${ENABLE_INLINING}" = "xyes"; then
-    AC_DEFINE([ENABLE_INLINING], 1, [use method inlining])
-fi
-
-
-dnl check for inlining debug options
-AC_MSG_CHECKING(whether method inlining debug options should be enabled)
-AC_ARG_ENABLE([inlining-debug],
-              [AS_HELP_STRING(--enable-inlining-debug,enable method inlining debug options [[default=no]])],
-              [case "${enableval}" in
-                   yes) ENABLE_INLINING_DEBUG=yes;;
-                   *) ENABLE_INLINING_DEBUG=no;;
-               esac],
-              [ENABLE_INLINING_DEBUG=no])
-AC_MSG_RESULT(${ENABLE_INLINING_DEBUG})
-AM_CONDITIONAL([ENABLE_INLINING_DEBUG], test x"${ENABLE_INLINING_DEBUG}" = "xyes")
-
-if test x"${ENABLE_INLINING_DEBUG}" = "xyes"; then
-    AC_DEFINE([ENABLE_INLINING_DEBUG], 1, [enable method inlining debug options])
-fi
-
-
-dnl check for replacement
-AC_MSG_CHECKING(whether on-stack replacement should be supported)
-AC_ARG_ENABLE([replacement],
-              [AS_HELP_STRING(--enable-replacement,enable on-stack replacement [[default=no]])],
-              [case "${enableval}" in
-                   yes) ENABLE_REPLACEMENT=yes;;
-                   *) ENABLE_REPLACEMENT=no;;
-               esac],
-              [ENABLE_REPLACEMENT=no])
-AC_MSG_RESULT(${ENABLE_REPLACEMENT})
-AM_CONDITIONAL([ENABLE_REPLACEMENT], test x"${ENABLE_REPLACEMENT}" = "xyes")
-
-if test x"${ENABLE_REPLACEMENT}" = "xyes"; then
-    AC_DEFINE([ENABLE_REPLACEMENT], 1, [use on-stack replacement])
-fi
-
+AC_CHECK_ENABLE_IFCONV
+AC_CHECK_ENABLE_INLINING
+AC_CHECK_ENABLE_INLINING_DEBUG
+AC_CHECK_ENABLE_REPLACEMENT
 
 dnl check for loop optimization
 AC_MSG_CHECKING(whether loop optimization should be supported)
@@ -668,11 +477,13 @@ AC_MSG_RESULT(${ENABLE_SSA})
 AM_CONDITIONAL([ENABLE_SSA], test x"${ENABLE_SSA}" = "xyes")
 AM_CONDITIONAL([ENABLE_ESCAPE], test x"${ENABLE_SSA}" = "xyes")
 AM_CONDITIONAL([ENABLE_ESCAPE_CHECK], test x"${ENABLE_SSA}" = "xyes")
+AM_CONDITIONAL([ENABLE_TLH], test x"${ENABLE_SSA}" = "xyes")
 
 if test x"${ENABLE_SSA}" = "xyes"; then
     AC_DEFINE([ENABLE_SSA], 1, [enable lsra with ssa])
     AC_DEFINE([ENABLE_ESCAPE], 1, [enable escape analysis with ssa])
     AC_DEFINE([ENABLE_ESCAPE_CHECK], 1, [enable generating code to validate escape analysis results])
+    AC_DEFINE([ENABLE_TLH], 1, [enable thread local heap])
     ENABLE_LSRA="no"
 fi
 
@@ -737,6 +548,7 @@ else
        AM_CONDITIONAL([USE_SCHEDULER], [false])
 fi
 
+AC_CHECK_ENABLE_OPAGENT
 
 AC_CHECK_ENABLE_ZLIB
 
@@ -754,19 +566,9 @@ AC_CHECK_ENABLE_STATICVM
 AC_CHECK_ENABLE_ANNOTATIONS
 AC_CHECK_ENABLE_ASSERTION
 
+dnl This one depends on AC_CHECK_ENABLE_ZLIB.
+AC_CHECK_WITH_VM_ZIP
 
-dnl where is CACAO's vm.zip
-AC_MSG_CHECKING(where CACAO's vm.zip is installed)
-AC_ARG_WITH([vm-zip],
-            [AS_HELP_STRING(--with-vm-zip=<path>,path to CACAO's vm.zip (includes the name of the file and may be flat) [[default=/usr/local/cacao/share/cacao/vm.zip]])],
-            [CACAO_VM_ZIP=${withval}],
-            [CACAO_VM_ZIP=${CACAO_PREFIX}/share/cacao/vm.zip])
-AC_MSG_RESULT(${CACAO_VM_ZIP})
-AC_DEFINE_UNQUOTED([CACAO_VM_ZIP], "${CACAO_VM_ZIP}", [CACAO's vm.zip])
-AC_SUBST(CACAO_VM_ZIP)
-
-
-AC_CHECK_WITH_CACAOH
 AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY
 
 dnl Now we check for jre-layout so we can skip some checks that are
@@ -775,6 +577,7 @@ AC_CHECK_ENABLE_JRE_LAYOUT
 
 AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_PREFIX
 AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_CLASSES
+AC_CHECK_WITH_BUILD_JAVA_RUNTIME_LIBRARY_CLASSES
 
 if test x"${ENABLE_JRE_LAYOUT}" = "xno"; then
    AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_LIBDIR
@@ -784,11 +587,14 @@ dnl The check for jni_md.h must be before jni.h.
 AC_CHECK_WITH_JNI_MD_H
 AC_CHECK_WITH_JNI_H
 
-dnl HPI is only required for OpenJDK
+dnl JVM, HPI, and JMM is only required for OpenJDK.
 case "${WITH_JAVA_RUNTIME_LIBRARY}" in
     openjdk)
+        AC_CHECK_WITH_JVM_MD_H
+        AC_CHECK_WITH_JVM_H
         AC_CHECK_WITH_HPI_MD_H
         AC_CHECK_WITH_HPI_H
+        AC_CHECK_WITH_JMM_H
         ;;
     *)
         ;;
@@ -808,6 +614,8 @@ case "${WITH_JAVA_RUNTIME_LIBRARY}" in
         ;;
 esac
 
+AC_CHECK_WITH_JASMIN_JAR
+AC_CHECK_WITH_JUNIT_JAR
 
 AC_CHECK_HEADERS(
        [regex.h], 
@@ -837,14 +645,21 @@ AZ_PYTHON_LSPEC
 dnl define some stuff required for --fullversion
 AC_DEFINE_UNQUOTED(VERSION_CONFIGURE_ARGS, "$ac_configure_args", [configure arguments])
 AC_DEFINE_UNQUOTED(VERSION_CC, "$CC", [CC used])
-AC_DEFINE_UNQUOTED(VERSION_CFLAGS, "$OPT_CFLAGS $ARCH_CFLAGS $CPPFLAGS", [CFLAGS used])
+AC_DEFINE_UNQUOTED(VERSION_CXX, "$CXX", [CXX used])
+AC_DEFINE_UNQUOTED(VERSION_CFLAGS, "$OPT_CFLAGS $ARCH_CFLAGS $CC_FLAGS $CPPFLAGS", [CFLAGS used])
+AC_DEFINE_UNQUOTED(VERSION_CXXFLAGS, "$OPT_CXXFLAGS $ARCH_CXXFLAGS $CXX_FLAGS $CPPFLAGS", [CXXFLAGS used])
 
 
-dnl finally pass CFLAGS to Makefiles via AM_CFLAGS
+dnl Finally pass flags to Makefiles.
 CFLAGS="$OPT_CFLAGS"
-AM_CFLAGS=$ARCH_CFLAGS
+CXXFLAGS="$OPT_CXXFLAGS"
+
+AM_CFLAGS="$CC_FLAGS $ARCH_FLAGS $OS_FLAGS"
+AM_CXXFLAGS="$CXX_FLAGS $ARCH_FLAGS $OS_FLAGS"
 AM_CPPFLAGS="$CPPFLAGS"
+
 AC_SUBST(AM_CFLAGS)
+AC_SUBST(AM_CXXFLAGS)
 AC_SUBST(AM_CPPFLAGS)
 
 
@@ -860,7 +675,6 @@ AC_CONFIG_FILES([Makefile]
                [man/Makefile]
                [src/Makefile]
                [src/cacao/Makefile]
-               [src/cacaoh/Makefile]
                [src/classes/Makefile]
                [src/fdlibm/Makefile]
                [src/mm/Makefile]
@@ -891,6 +705,7 @@ AC_CONFIG_FILES([Makefile]
                [src/vm/jit/i386/darwin/Makefile]
                [src/vm/jit/i386/freebsd/Makefile]
                [src/vm/jit/i386/linux/Makefile]
+               [src/vm/jit/i386/solaris/Makefile]
                [src/vm/jit/intrp/Makefile]
                [src/vm/jit/inline/Makefile]
                [src/vm/jit/ir/Makefile]
@@ -919,13 +734,13 @@ AC_CONFIG_FILES([Makefile]
                [src/vm/jit/x86_64/Makefile]
                [src/vm/jit/x86_64/freebsd/Makefile]
                [src/vm/jit/x86_64/linux/Makefile]
-               [src/vmcore/Makefile]
+               [src/vm/jit/x86_64/solaris/Makefile]
                [tests/Makefile]
                [tests/regression/Makefile]
-               [tests/regression/bugzilla/Makefile]
                [tests/regression/assertion/Makefile]
+               [tests/regression/base/Makefile]
+               [tests/regression/bugzilla/Makefile]
                [tests/regression/jasmin/Makefile]
-               [tests/regression/junit/Makefile]
                [tests/regression/native/Makefile]
                [tests/regression/resolving/Makefile]
                [tests/regression/resolving/classes1/Makefile]
@@ -934,11 +749,8 @@ AC_CONFIG_FILES([Makefile]
 )
 
 
-dnl now configure subpackages with OPT_CFLAGS and ARCH_CFLAGS
-export OPT_CFLAGS
-export ARCH_CFLAGS
 dnl We only build the shared library objects but we use it as
-dnl noinst_LTLIBRARIES
+dnl noinst_LTLIBRARIES.
 ac_configure_args="$ac_configure_args --disable-static"
 AC_CONFIG_SUBDIRS(src/mm/boehm-gc)
 
index 57803bd3abcf54f218d30329498d71a3eb02d316..a37279b651d7a06351f3db8d912e661c09c15d03 100644 (file)
@@ -23,6 +23,9 @@
 
 SUBDIRS = vmlog
 
+EXTRA_DIST = \
+       mapfile-vers-product
+
 noinst_DATA = \
        setenvinstalled.in \
        setenvsource.in
index 5d23dfa6a39cba8819fd75f90dd348ccdc155aa0..d414e6358b2b86d451b08c7ba0f85215136f7dda 100644 (file)
@@ -31,7 +31,7 @@
 SUNWprivate_1.1 {
         global:
                 # CACAO
-                vm_createjvm;
+                VM_create;
                 vm_run;
 
                 # JNI
diff --git a/contrib/svn2cl.xsl b/contrib/svn2cl.xsl
deleted file mode 100644 (file)
index 1333b94..0000000
+++ /dev/null
@@ -1,348 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-
-   svn2cl.xsl - xslt stylesheet for converting svn log to a normal
-                changelog
-
-   Usage (replace ++ with two minus signs which aren't allowed
-   inside xml comments):
-     svn ++verbose ++xml log | \
-       xsltproc ++stringparam strip-prefix `basename $(pwd)` \
-                ++stringparam linelen 75 \
-                ++stringparam groupbyday yes \
-                ++stringparam include-rev yes \
-                ++stringparam breakbeforemsg yes \
-                ++stringparam authorsfile FILE \
-                svn2cl.xsl - > ChangeLog
-
-   This file is based on several implementations of this conversion
-   that I was not completely happy with and some other common
-   xslt constructs found on the web.
-
-   Copyright (C) 2004, 2005, 2006 Arthur de Jong.
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions
-   are met:
-   1. Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-   2. Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-   3. The name of the author may not be used to endorse or promote
-      products derived from this software without specific prior
-      written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-   ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-   IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--->
-
-<!DOCTYPE stylesheet [
- <!ENTITY tab "&#9;">
- <!ENTITY newl "&#10;">
- <!ENTITY space "&#32;">
-]>
-
-<xsl:stylesheet
-  version="1.0"
-  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
- <xsl:output
-   method="text"
-   encoding="utf-8"
-   media-type="text/plain"
-   omit-xml-declaration="yes"
-   standalone="yes"
-   indent="no" />
-
- <xsl:strip-space elements="*" />
-
- <!-- the prefix of pathnames to strip -->
- <xsl:param name="strip-prefix" select="'/'" />
-
- <!-- the length of a line to wrap messages at -->
- <xsl:param name="linelen" select="80" />
- <!-- whether entries should be grouped by day -->
- <xsl:param name="groupbyday" select="'no'" />
-
- <!-- whether a revision number should be included -->
- <xsl:param name="include-rev" select="'no'" />
-
- <!-- whether the log message should start on a new line -->
- <xsl:param name="breakbeforemsg" select="'no'" />
-
- <!-- location of authors file if any -->
- <xsl:param name="authorsfile" select="''" />
-
- <!-- add newlines at the end of the changelog -->
- <xsl:template match="log">
-  <xsl:apply-templates/>
-  <xsl:text>&newl;</xsl:text>
- </xsl:template>
-
- <!-- format one entry from the log -->
- <xsl:template match="logentry">
-  <!-- save log entry number -->
-  <xsl:variable name="pos" select="position()" />
-  <!-- fetch previous entry's date -->
-  <xsl:variable name="prevdate">
-   <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/date" />
-  </xsl:variable>
-  <!-- fetch previous entry's author -->
-  <xsl:variable name="prevauthor">
-   <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/author" />
-  </xsl:variable>
-  <!-- fetch this entry's date -->
-  <xsl:variable name="date">
-   <xsl:apply-templates select="date" />
-  </xsl:variable>
-  <!-- fetch this entry's author -->
-  <xsl:variable name="author">
-   <xsl:apply-templates select="author" />
-  </xsl:variable>
-  <!-- check if header is changed -->
-  <xsl:if test="($prevdate!=$date) or ($prevauthor!=$author)">
-   <!-- add newline -->
-   <xsl:if test="not(position()=1)">
-     <xsl:text>&newl;</xsl:text>
-   </xsl:if>
-   <!-- date -->
-   <xsl:apply-templates select="date" />
-   <!-- two spaces -->
-   <xsl:text>&space;&space;</xsl:text>
-   <!-- author's name -->
-   <xsl:apply-templates select="author" />
-   <!-- two newlines -->
-   <xsl:text>&newl;&newl;</xsl:text>
-  </xsl:if>
-  <!-- get paths string -->
-  <xsl:variable name="paths">
-   <xsl:apply-templates select="paths" />
-   <xsl:text>:&space;</xsl:text>
-  </xsl:variable>
-  <!-- get revision number -->
-  <xsl:variable name="rev">
-   <xsl:if test="$include-rev='yes'">
-    <xsl:text>[r</xsl:text>
-    <xsl:value-of select="@revision" />
-    <xsl:text>]&space;</xsl:text>
-   </xsl:if>
-  </xsl:variable>
-  <!-- trim trailing newlines -->
-  <xsl:variable name="msg">
-   <!-- add a line break before the log message -->
-   <xsl:if test="$breakbeforemsg='yes'">
-    <xsl:text>&newl;</xsl:text>
-   </xsl:if>
-   <xsl:call-template name="trim-newln">
-    <xsl:with-param name="txt" select="msg" />
-   </xsl:call-template>
-  </xsl:variable>
-  <!-- first line is indented (other indents are done in wrap template) -->
-  <xsl:text>&tab;</xsl:text>
-  <!-- print the paths and message nicely wrapped -->
-  <xsl:call-template name="wrap">
-   <xsl:with-param name="txt" select="concat($rev,$msg)" />
-  </xsl:call-template>
- </xsl:template>
-
- <!-- format date -->
- <xsl:template match="date">
-  <xsl:variable name="date" select="normalize-space(.)" />
-  <!-- output date part -->
-  <xsl:value-of select="substring($date,1,10)" />
-  <!-- output time part -->
-  <xsl:if test="$groupbyday!='yes'">
-   <xsl:text>&space;</xsl:text>
-   <xsl:value-of select="substring($date,12,5)" />
-  </xsl:if>
- </xsl:template>
-
- <!-- format author -->
- <xsl:template match="author">
-  <xsl:variable name="author" select="normalize-space(.)" />
-  <xsl:choose>
-   <!-- try to look up the author in the authorsfile -->
-   <xsl:when test="$authorsfile!='' and document($authorsfile)//author[@uid=$author]">
-    <xsl:value-of select="normalize-space(document($authorsfile)//author[@uid=$author])" />
-   </xsl:when>
-   <!-- just use the author name as given by svn -->
-   <xsl:otherwise>
-    <xsl:value-of select="$author" />
-   </xsl:otherwise>
-  </xsl:choose>
- </xsl:template>
-
- <!-- present a list of paths names -->
- <xsl:template match="paths">
-  <xsl:for-each select="path">
-   <xsl:sort select="normalize-space(.)" data-type="text" />
-   <!-- unless we are the first entry, add a comma -->
-   <xsl:if test="not(position()=1)">
-    <xsl:text>,&space;</xsl:text>
-   </xsl:if>
-   <!-- print the path name -->
-   <xsl:apply-templates select="." />
-  </xsl:for-each>
- </xsl:template>
-
- <!-- transform path to something printable -->
- <xsl:template match="path">
-  <!-- fetch the pathname -->
-  <xsl:variable name="p1" select="normalize-space(.)" />
-  <!-- strip leading slash -->
-  <xsl:variable name="p2">
-   <xsl:choose>
-    <xsl:when test="starts-with($p1,'/')">
-     <xsl:value-of select="substring($p1,2)" />
-    </xsl:when>
-    <xsl:otherwise>
-     <xsl:value-of select="$p1" />
-    </xsl:otherwise>
-   </xsl:choose>
-  </xsl:variable>
-  <!-- strip trailing slash from strip-prefix -->
-  <xsl:variable name="sp">
-   <xsl:choose>
-    <xsl:when test="substring($strip-prefix,string-length($strip-prefix),1)='/'">
-     <xsl:value-of select="substring($strip-prefix,1,string-length($strip-prefix)-1)" />
-    </xsl:when>
-    <xsl:otherwise>
-     <xsl:value-of select="$strip-prefix" />
-    </xsl:otherwise>
-   </xsl:choose>
-  </xsl:variable>
-  <!-- strip strip-prefix -->
-  <xsl:variable name="p3">
-   <xsl:choose>
-    <xsl:when test="starts-with($p2,$sp)">
-     <xsl:value-of select="substring($p2,1+string-length($sp))" />
-    </xsl:when>
-    <xsl:otherwise>
-     <!-- TODO: do not print strings that do not begin with strip-prefix -->
-     <xsl:value-of select="$p2" />
-    </xsl:otherwise>
-   </xsl:choose>
-  </xsl:variable>
-  <!-- strip another slash -->
-  <xsl:variable name="p4">
-   <xsl:choose>
-    <xsl:when test="starts-with($p3,'/')">
-     <xsl:value-of select="substring($p3,2)" />
-    </xsl:when>
-    <xsl:otherwise>
-     <xsl:value-of select="$p3" />
-    </xsl:otherwise>
-   </xsl:choose>
-  </xsl:variable>
-  <!-- translate empty string to dot -->
-  <xsl:choose>
-   <xsl:when test="$p4 = ''">
-    <xsl:text>.</xsl:text>
-   </xsl:when>
-   <xsl:otherwise>
-    <xsl:value-of select="$p4" />
-   </xsl:otherwise>
-  </xsl:choose>
- </xsl:template>
-
- <!-- string-wrapping template -->
- <xsl:template name="wrap">
-  <xsl:param name="txt" />
-  <xsl:choose>
-   <xsl:when test="contains($txt,'&newl;')">
-     <!-- text contains newlines, do the first line -->
-     <xsl:call-template name="wrap">
-      <xsl:with-param name="txt" select="substring-before($txt,'&newl;')" />
-     </xsl:call-template>
-     <!-- print tab -->
-     <xsl:text>&tab;</xsl:text>
-     <!-- wrap the rest of the text -->
-     <xsl:call-template name="wrap">
-      <xsl:with-param name="txt" select="substring-after($txt,'&newl;')" />
-     </xsl:call-template>
-   </xsl:when>
-   <xsl:when test="(string-length($txt) &lt; (($linelen)-9)) or not(contains($txt,' '))">
-    <!-- this is easy, nothing to do -->
-    <xsl:value-of select="normalize-space($txt)" />
-    <!-- add newline -->
-    <xsl:text>&newl;</xsl:text>
-   </xsl:when>
-   <xsl:otherwise>
-    <!-- find the first line -->
-    <xsl:variable name="tmp" select="substring($txt,1,(($linelen)-10))" />
-    <xsl:variable name="line">
-     <xsl:choose>
-      <xsl:when test="contains($tmp,' ')">
-       <xsl:call-template name="find-line">
-        <xsl:with-param name="txt" select="$tmp" />
-       </xsl:call-template>
-      </xsl:when>
-      <xsl:otherwise>
-       <xsl:value-of select="normalize-space(substring-before($txt,' '))" />
-      </xsl:otherwise>
-     </xsl:choose>
-    </xsl:variable>
-    <!-- print newline and tab -->
-    <xsl:value-of select="normalize-space($line)" />
-    <xsl:text>&newl;&tab;</xsl:text>
-    <!-- wrap the rest of the text -->
-    <xsl:call-template name="wrap">
-     <xsl:with-param name="txt" select="substring($txt,string-length($line)+1)" />
-    </xsl:call-template>
-   </xsl:otherwise>
-  </xsl:choose>
- </xsl:template>
-
- <!-- template to trim line to contain space as last char -->
- <xsl:template name="find-line">
-  <xsl:param name="txt" />
-  <xsl:choose>
-   <xsl:when test="substring($txt,string-length($txt),1) = ' '">
-    <xsl:value-of select="$txt" />
-   </xsl:when>
-   <xsl:otherwise>
-    <xsl:call-template name="find-line">
-     <xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" />
-    </xsl:call-template>
-   </xsl:otherwise>
-  </xsl:choose>
- </xsl:template>
-
- <!-- template to trim trailing and starting newlines -->
- <xsl:template name="trim-newln">
-  <xsl:param name="txt" />
-  <xsl:choose>
-   <!-- find starting newlines -->
-   <xsl:when test="substring($txt,1,1) = '&newl;'">
-    <xsl:call-template name="trim-newln">
-     <xsl:with-param name="txt" select="substring($txt,2)" />
-    </xsl:call-template>
-   </xsl:when>
-   <!-- find trailing newlines -->
-   <xsl:when test="substring($txt,string-length($txt),1) = '&newl;'">
-    <xsl:call-template name="trim-newln">
-     <xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" />
-    </xsl:call-template>
-   </xsl:when>
-   <!-- no newlines found, we're done -->
-   <xsl:otherwise>
-    <xsl:value-of select="$txt" />
-   </xsl:otherwise>
-  </xsl:choose>
- </xsl:template>
-
-</xsl:stylesheet>
index c75bf12b80ac0e9c4d49358b8311bdc21b5abb74..2ea19e9a5b7e36ae405a0d07be49a56cceec9b5b 100644 (file)
@@ -25,7 +25,7 @@ dist_noinst_DATA = \
        Doxyfile
 
 doxygen:
-       doxygen
+       doxygen $(srcdir)/Doxyfile
 
 clean-local:
        -rm -rf html latex
diff --git a/m4/ax_compiler_vendor.m4 b/m4/ax_compiler_vendor.m4
new file mode 100644 (file)
index 0000000..a1da61e
--- /dev/null
@@ -0,0 +1,33 @@
+dnl Taken from http://ac-archive.sourceforge.net/
+
+dnl @synopsis AX_COMPILER_VENDOR
+dnl
+dnl @summary find the vendor (gnu, intel, etc.) of the C/C++ compiler
+dnl
+dnl Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm,
+dnl sun, hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi,
+dnl microsoft, watcom, etc. The vendor is returned in the cache
+dnl variable $ax_cv_c_compiler_vendor for C and
+dnl $ax_cv_cxx_compiler_vendor for C++.
+dnl
+dnl @category C
+dnl @category Cxx
+dnl @author Steven G. Johnson <stevenj@alum.mit.edu> with Matteo Frigo
+dnl @version 2005-05-30
+dnl @license GPLWithACException
+
+AC_DEFUN([AX_COMPILER_VENDOR],
+[
+AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
+ [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
+  # note: don't check for gcc first since some other compilers define __GNUC__
+  for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
+    vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
+#if !($vencpp)
+      thisisanerror;
+#endif
+])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
+  done
+ ])
+])
diff --git a/m4/cacaoh.m4 b/m4/cacaoh.m4
deleted file mode 100644 (file)
index 1c19667..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-dnl m4/cacaoh.m4
-dnl
-dnl Copyright (C) 2007, 2008
-dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-dnl 
-dnl This file is part of CACAO.
-dnl 
-dnl This program is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU General Public License as
-dnl published by the Free Software Foundation; either version 2, or (at
-dnl your option) any later version.
-dnl 
-dnl This program is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-dnl General Public License for more details.
-dnl 
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-dnl 02110-1301, USA.
-
-
-dnl check which cacaoh to use
-
-AC_DEFUN([AC_CHECK_WITH_CACAOH],[
-AC_MSG_CHECKING(which cacaoh to use (for crosscompilation))
-AC_ARG_WITH([cacaoh],
-            [AS_HELP_STRING(--with-cacaoh,which cacaoh to use [[default=$(top_builddir)/src/cacaoh/cacaoh]])],
-            [CACAOH="${withval}"],
-            [CACAOH=["\$(top_builddir)/src/cacaoh/cacaoh"]])
-AC_MSG_RESULT(${CACAOH})
-AC_SUBST(CACAOH)
-])
diff --git a/m4/cycle-stats.m4 b/m4/cycle-stats.m4
new file mode 100644 (file)
index 0000000..c474adc
--- /dev/null
@@ -0,0 +1,41 @@
+dnl m4/cycle-stats.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for cycle count statistics
+
+AC_DEFUN([AC_CHECK_ENABLE_CYCLE_STATS],[
+AC_MSG_CHECKING(whether cycle count statistics should be enabled)
+AC_ARG_ENABLE([cycles-stats],
+              [AS_HELP_STRING(--enable-cycles-stats,enable cycle count statistics [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_CYCLES_STATS=yes;;
+                   *) ENABLE_CYCLES_STATS=no;;
+               esac],
+              [ENABLE_CYCLES_STATS=no])
+AC_MSG_RESULT(${ENABLE_CYCLES_STATS})
+AM_CONDITIONAL([ENABLE_CYCLES_STATS], test x"${ENABLE_CYCLES_STATS}" = "xyes")
+
+if test x"${ENABLE_CYCLES_STATS}" = "xyes"; then
+    AC_DEFINE([ENABLE_CYCLES_STATS], 1, [enable cycle count statistics])
+fi
+])
diff --git a/m4/disassembler.m4 b/m4/disassembler.m4
new file mode 100644 (file)
index 0000000..b45333c
--- /dev/null
@@ -0,0 +1,76 @@
+dnl m4/disassembler.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for disassembler support
+
+AC_DEFUN([AC_CHECK_ENABLE_DISASSEMBLER],[
+AC_MSG_CHECKING(whether disassembler should be enabled)
+AC_ARG_ENABLE([disassembler],
+              [AS_HELP_STRING(--enable-disassembler,enable disassembler [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_DISASSEMBLER=yes;;
+                   *) ENABLE_DISASSEMBLER=no;;
+               esac],
+              [ENABLE_DISASSEMBLER=no])
+AC_MSG_RESULT(${ENABLE_DISASSEMBLER})
+AM_CONDITIONAL([ENABLE_DISASSEMBLER], test x"${ENABLE_DISASSEMBLER}" = "xyes")
+
+if test x"${ENABLE_DISASSEMBLER}" = "xyes"; then
+    AC_DEFINE([ENABLE_DISASSEMBLER], 1, [enable disassembler])
+
+    dnl check for binutils headers and libraries on some architectures for the
+    dnl disassembler
+    case "${ARCH_DIR}" in
+        arm | i386 | powerpc | x86_64 | sparc64 | powerpc64 | s390 | m68k)
+            AC_CHECK_HEADER([ansidecl.h],, [AC_MSG_ERROR(cannot find ansidecl.h)])
+            AC_CHECK_HEADER([symcat.h],, [AC_MSG_ERROR(cannot find symcat.h)])
+            AC_CHECK_HEADER([bfd.h],, [AC_MSG_ERROR(cannot find bfd.h)])
+            AC_CHECK_HEADER([dis-asm.h],, [AC_MSG_ERROR(cannot find dis-asm.h)])
+
+            case "${OS_DIR}" in
+                cygwin | darwin | netbsd | solaris)
+                     AC_CHECK_LIB(intl, dcgettext,, [AC_MSG_ERROR(cannot find libintl (from binutils))])
+                     ;;
+            esac
+
+            case "${OS_DIR}" in
+                solaris)
+                                        AC_CHECK_LIB(rt, sem_init,, [AC_MSG_ERROR(cannot find librt)])
+                     ;;
+            esac
+
+
+            AC_CHECK_LIB(iberty, xstrerror,, [AC_MSG_ERROR(cannot find libiberty (from binutils))])
+            AC_CHECK_LIB(bfd, bfd_get_arch,, [AC_MSG_ERROR(cannot find libbfd (from binutils))])
+            AC_CHECK_LIB(opcodes, disassembler,, [AC_MSG_ERROR(cannot find libopcodes (from binutils))])
+            AC_DEFINE([WITH_BINUTILS_DISASSEMBLER], 1, [use binutils disassembler])
+            AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [true])
+            ;;
+        * )
+            AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
+            ;;
+    esac
+else
+    AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
+fi
+])
diff --git a/m4/dl.m4 b/m4/dl.m4
new file mode 100644 (file)
index 0000000..5b05b1d
--- /dev/null
+++ b/m4/dl.m4
@@ -0,0 +1,55 @@
+dnl m4/dl.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check if dynamic library loading should be used
+
+AC_DEFUN([AC_CHECK_ENABLE_DL],[
+AC_MSG_CHECKING(whether to support dynamic library loading)
+AC_ARG_ENABLE([dl],
+              [AS_HELP_STRING(--disable-dl,disable dynamic library loading (needs libdl) [[default=enabled]])],
+              [case "${enableval}" in
+                  no) ENABLE_DL=no;;
+                  *) ENABLE_DL=yes;;
+               esac],
+              [ENABLE_DL=yes])
+AC_MSG_RESULT(${ENABLE_DL})
+
+if test x"${ENABLE_DL}" = "xyes"; then
+    AC_CHECK_HEADERS([dlfcn.h],, [AC_MSG_ERROR(cannot find dlfcn.h)])
+
+    case "${OS_DIR}" in
+        freebsd | netbsd )
+            dnl There is no libdl on FreeBSD, and NetBSD (see PR96).
+            ;;
+        *)
+            AC_CHECK_LIB([dl], [dlopen],, [AC_MSG_ERROR(cannot find libdl)])
+            ;;
+    esac
+    
+    AC_CHECK_FUNCS([dlclose])
+    AC_CHECK_FUNCS([dlerror])
+    AC_CHECK_FUNCS([dlopen])
+    AC_CHECK_FUNCS([dlsym])
+    AC_DEFINE([ENABLE_DL], 1, [Enable dynamic library loading.])
+fi
+])
diff --git a/m4/handles.m4 b/m4/handles.m4
new file mode 100644 (file)
index 0000000..3e1fae1
--- /dev/null
@@ -0,0 +1,41 @@
+dnl m4/handles.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for handles (indirection cells) support
+
+AC_DEFUN([AC_CHECK_ENABLE_HANDLES],[
+AC_MSG_CHECKING(whether handles (indirection cells) should be enabled)
+AC_ARG_ENABLE([handles],
+              [AS_HELP_STRING(--enable-handles,enable handles (indirection cells) [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_HANDLES=yes;;
+                   *) ENABLE_HANDLES=no;;
+               esac],
+              [ENABLE_HANDLES=no])
+AC_MSG_RESULT(${ENABLE_HANDLES})
+AM_CONDITIONAL([ENABLE_HANDLES], test x"${ENABLE_HANDLES}" = "xyes")
+
+if test x"${ENABLE_HANDLES}" = "xyes"; then
+    AC_DEFINE([ENABLE_HANDLES], 1, [enable handles (indirection cells)])
+fi
+])
diff --git a/m4/ifconv.m4 b/m4/ifconv.m4
new file mode 100644 (file)
index 0000000..78bcb4f
--- /dev/null
@@ -0,0 +1,41 @@
+dnl m4/ifconv.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check if if-conversion should be supported
+
+AC_DEFUN([AC_CHECK_ENABLE_IFCONV],[
+AC_MSG_CHECKING(whether if-conversion should be supported)
+AC_ARG_ENABLE([ifconv],
+              [AS_HELP_STRING(--disable-ifconv,disable if-conversion [[default=enabled]])],
+              [case "${enableval}" in
+                   no) ENABLE_IFCONV=no;;
+                   *) ENABLE_IFCONV=yes;;
+               esac],
+              [ENABLE_IFCONV=yes])
+AC_MSG_RESULT(${ENABLE_IFCONV})
+AM_CONDITIONAL([ENABLE_IFCONV], test x"${ENABLE_IFCONV}" = "xyes")
+   
+if test x"${ENABLE_IFCONV}" = "xyes"; then
+    AC_DEFINE([ENABLE_IFCONV], 1, [enable if-conversion])
+fi
+])
diff --git a/m4/inlining.m4 b/m4/inlining.m4
new file mode 100644 (file)
index 0000000..00a8c16
--- /dev/null
@@ -0,0 +1,61 @@
+dnl m4/inlining.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for inlining
+
+AC_DEFUN([AC_CHECK_ENABLE_INLINING],[
+AC_MSG_CHECKING(whether method inlining should be supported)
+AC_ARG_ENABLE([inlining],
+              [AS_HELP_STRING(--enable-inlining,enable method inlining [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_INLINING=yes;;
+                   *) ENABLE_INLINING=no;;
+               esac],
+              [ENABLE_INLINING=no])
+AC_MSG_RESULT(${ENABLE_INLINING})
+AM_CONDITIONAL([ENABLE_INLINING], test x"${ENABLE_INLINING}" = "xyes")
+
+if test x"${ENABLE_INLINING}" = "xyes"; then
+    AC_DEFINE([ENABLE_INLINING], 1, [use method inlining])
+fi
+])
+
+
+dnl check for inlining debug options
+
+AC_DEFUN([AC_CHECK_ENABLE_INLINING_DEBUG],[
+AC_MSG_CHECKING(whether method inlining debug options should be enabled)
+AC_ARG_ENABLE([inlining-debug],
+              [AS_HELP_STRING(--enable-inlining-debug,enable method inlining debug options [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_INLINING_DEBUG=yes;;
+                   *) ENABLE_INLINING_DEBUG=no;;
+               esac],
+              [ENABLE_INLINING_DEBUG=no])
+AC_MSG_RESULT(${ENABLE_INLINING_DEBUG})
+AM_CONDITIONAL([ENABLE_INLINING_DEBUG], test x"${ENABLE_INLINING_DEBUG}" = "xyes")
+
+if test x"${ENABLE_INLINING_DEBUG}" = "xyes"; then
+    AC_DEFINE([ENABLE_INLINING_DEBUG], 1, [enable method inlining debug options])
+fi
+])
diff --git a/m4/jasmin.m4 b/m4/jasmin.m4
new file mode 100644 (file)
index 0000000..14e0cde
--- /dev/null
@@ -0,0 +1,34 @@
+dnl m4/jasmin.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl Check location of Jasmin jar file.
+
+AC_DEFUN([AC_CHECK_WITH_JASMIN_JAR],[
+AC_MSG_CHECKING(location of Jasmin jar)
+AC_ARG_WITH([jasmin-jar],
+            [AS_HELP_STRING(--with-jasmin-jar=<path>,location of Jasmin jar file [[default=/usr/share/java/cup.jar:/usr/share/java/jasmin-sable.jar]])],
+            [JASMIN_JAR="${withval}"],
+            [JASMIN_JAR="/usr/share/java/cup.jar:/usr/share/java/jasmin-sable.jar"])
+AC_MSG_RESULT(${JASMIN_JAR})
+AC_SUBST(JASMIN_JAR)
+])
index d69cf7e07e3a5343a13994089da20bec65b341fa..587ddfaf954d4e804ce4514d7182ee5b2a6adb3a 100644 (file)
@@ -92,14 +92,28 @@ AC_ARG_WITH([java-runtime-library-classes],
 AC_MSG_RESULT(${JAVA_RUNTIME_LIBRARY_CLASSES})
 AC_DEFINE_UNQUOTED([JAVA_RUNTIME_LIBRARY_CLASSES], "${JAVA_RUNTIME_LIBRARY_CLASSES}", [Java runtime library classes])
 AC_SUBST(JAVA_RUNTIME_LIBRARY_CLASSES)
+])
+
+
+dnl where are Java core library classes located at compilation time
+
+AC_DEFUN([AC_CHECK_WITH_BUILD_JAVA_RUNTIME_LIBRARY_CLASSES],[
+AC_MSG_CHECKING(where Java core library classes are located at compile time)
+AC_ARG_WITH([build-java-runtime-library-classes],
+            [AS_HELP_STRING(--with-build-java-runtime-library-classes=<path>,path to Java core library classes (includes the name of the file and may be flat) [[default=${JAVA_RUNTIME_LIBRARY_CLASSES}]])],
+            [BUILD_JAVA_RUNTIME_LIBRARY_CLASSES=${withval}],
+            [BUILD_JAVA_RUNTIME_LIBRARY_CLASSES=${JAVA_RUNTIME_LIBRARY_CLASSES}])
+AC_MSG_RESULT(${BUILD_JAVA_RUNTIME_LIBRARY_CLASSES})
+AC_DEFINE_UNQUOTED([BUILD_JAVA_RUNTIME_LIBRARY_CLASSES], "${BUILD_JAVA_RUNTIME_LIBRARY_CLASSES}", [Java core library classes at compile time])
+AC_SUBST(BUILD_JAVA_RUNTIME_LIBRARY_CLASSES)
 
 dnl define BOOTCLASSPATH for Makefiles
 case "${WITH_JAVA_RUNTIME_LIBRARY}" in
     cldc1.1 | gnuclasspath)
-        BOOTCLASSPATH="\$(top_builddir)/src/classes/classes:\$(JAVA_RUNTIME_LIBRARY_CLASSES)"
+        BOOTCLASSPATH="\$(top_builddir)/src/classes/classes:${BUILD_JAVA_RUNTIME_LIBRARY_CLASSES}"
         ;;
     *)
-        BOOTCLASSPATH="\$(JAVA_RUNTIME_LIBRARY_CLASSES)"
+        BOOTCLASSPATH="${BUILD_JAVA_RUNTIME_LIBRARY_CLASSES}"
         ;;
 esac
 AC_SUBST(BOOTCLASSPATH)
diff --git a/m4/jitcache.m4 b/m4/jitcache.m4
new file mode 100644 (file)
index 0000000..d873f30
--- /dev/null
@@ -0,0 +1,40 @@
+dnl m4/jitcache.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for jitcache support
+AC_DEFUN([AC_CHECK_ENABLE_JITCACHE],[
+AC_MSG_CHECKING(whether JIT compiler output caching should be enabled)
+AC_ARG_ENABLE([jitcache],
+              [AS_HELP_STRING(--enable-jitcache,enable caching of JIT compiler output [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_JITCACHE=yes;;
+                   *) ENABLE_JITCACHE=no;;
+               esac],
+              [ENABLE_JITCACHE=no])
+AC_MSG_RESULT(${ENABLE_JITCACHE})
+AM_CONDITIONAL([ENABLE_JITCACHE], test x"${ENABLE_JITCACHE}" = "xyes")
+
+if test x"${ENABLE_JITCACHE}" = "xyes"; then
+    AC_DEFINE([ENABLE_JITCACHE], 1, [store and load JIT compiler output])
+fi
+])
diff --git a/m4/jmm.m4 b/m4/jmm.m4
new file mode 100644 (file)
index 0000000..37c86ed
--- /dev/null
+++ b/m4/jmm.m4
@@ -0,0 +1,42 @@
+dnl m4/jmm.m4
+dnl
+dnl Copyright (C) 2008 Theobroma Systems Ltd.
+dnl
+dnl This file is part of CACAO.
+dnl
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl Check for jmm.h
+
+AC_DEFUN([AC_CHECK_WITH_JMM_H],[
+AC_MSG_CHECKING(where jmm.h is installed)
+AC_ARG_WITH([jmm_h],
+            [AS_HELP_STRING(--with-jmm_h=<dir>,path to jmm.h (only with --with-java-runtime-library=openjdk) [[default=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/share/javavm/export]])],
+            [WITH_JMM_H=${withval}],
+            [case "${WITH_JAVA_RUNTIME_LIBRARY}" in
+                 openjdk)
+                     WITH_JMM_H=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/share/javavm/export
+                     ;;
+                 *)
+                     ;;
+            esac])
+AC_MSG_RESULT(${WITH_JMM_H})
+
+AC_CHECK_HEADER([${WITH_JMM_H}/jmm.h],
+                [AC_DEFINE_UNQUOTED([INCLUDE_JMM_H], "${WITH_JMM_H}/jmm.h", [Java runtime library jmm.h header])],
+                [AC_MSG_ERROR(cannot find jmm.h)])
+])
diff --git a/m4/junit.m4 b/m4/junit.m4
new file mode 100644 (file)
index 0000000..1df6db5
--- /dev/null
@@ -0,0 +1,34 @@
+dnl m4/junit.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl Check location of JUnit jar file.
+
+AC_DEFUN([AC_CHECK_WITH_JUNIT_JAR],[
+AC_MSG_CHECKING(location of JUnit jar)
+AC_ARG_WITH([junit-jar],
+            [AS_HELP_STRING(--with-junit-jar=<path>,location of JUnit jar file [[default=/usr/share/java/junit4.jar]])],
+            [JUNIT_JAR="${withval}"],
+            [JUNIT_JAR="/usr/share/java/junit4.jar"])
+AC_MSG_RESULT(${JUNIT_JAR})
+AC_SUBST(JUNIT_JAR)
+])
diff --git a/m4/jvm.m4 b/m4/jvm.m4
new file mode 100644 (file)
index 0000000..b431497
--- /dev/null
+++ b/m4/jvm.m4
@@ -0,0 +1,67 @@
+dnl m4/jvm.m4
+dnl
+dnl Copyright (C) 2008 Theobroma Systems Ltd.
+dnl
+dnl This file is part of CACAO.
+dnl
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl Check for jvm_md.h
+
+AC_DEFUN([AC_CHECK_WITH_JVM_MD_H],[
+AC_MSG_CHECKING(where jvm_md.h is installed)
+AC_ARG_WITH([jvm_md_h],
+            [AS_HELP_STRING(--with-jvm_md_h=<dir>,path to jvm_md.h (only with --with-java-runtime-library=openjdk) [[default=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/solaris/javavm/export]])],
+            [WITH_JVM_MD_H=${withval}],
+            [case "${WITH_JAVA_RUNTIME_LIBRARY}" in
+                 openjdk)
+                     WITH_JVM_MD_H=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/solaris/javavm/export
+                     ;;
+                 *)
+                     ;;
+            esac])
+AC_MSG_RESULT(${WITH_JVM_MD_H})
+
+AC_CHECK_HEADER([${WITH_JVM_MD_H}/jvm_md.h],
+                [AC_DEFINE_UNQUOTED([INCLUDE_JVM_MD_H], "${WITH_JVM_MD_H}/jvm_md.h", [Java runtime library jvm_md.h header])],
+                [AC_MSG_ERROR(cannot find jvm_md.h)])
+
+dnl Add the path to jvm_md.h to the CPPFLAGS so jvm.h can find it.
+CPPFLAGS="${CPPFLAGS} -I${WITH_JVM_MD_H}"
+])
+
+
+dnl Check for jvm.h
+
+AC_DEFUN([AC_CHECK_WITH_JVM_H],[
+AC_MSG_CHECKING(where jvm.h is installed)
+AC_ARG_WITH([jvm_h],
+            [AS_HELP_STRING(--with-jvm_h=<dir>,path to jvm.h (only with --with-java-runtime-library=openjdk) [[default=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/share/javavm/export]])],
+            [WITH_JVM_H=${withval}],
+            [case "${WITH_JAVA_RUNTIME_LIBRARY}" in
+                 openjdk)
+                     WITH_JVM_H=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/share/javavm/export
+                     ;;
+                 *)
+                     ;;
+            esac])
+AC_MSG_RESULT(${WITH_JVM_H})
+
+AC_CHECK_HEADER([${WITH_JVM_H}/jvm.h],
+                [AC_DEFINE_UNQUOTED([INCLUDE_JVM_H], "${WITH_JVM_H}/jvm.h", [Java runtime library jvm.h header])],
+                [AC_MSG_ERROR(cannot find jvm.h)])
+])
diff --git a/m4/jvmti.m4 b/m4/jvmti.m4
new file mode 100644 (file)
index 0000000..7ee27ad
--- /dev/null
@@ -0,0 +1,41 @@
+dnl m4/jvmti.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for JVMTI
+
+AC_DEFUN([AC_CHECK_ENABLE_JVMTI],[
+AC_MSG_CHECKING(whether to compile JVMTI support)
+AC_ARG_ENABLE([jvmti],
+              [AS_HELP_STRING(--enable-jvmti,enable JVMTI [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_JVMTI=yes;;
+                   *) ENABLE_JVMTI=no;;
+               esac],
+              [ENABLE_JVMTI=no])
+AC_MSG_RESULT(${ENABLE_JVMTI})
+AM_CONDITIONAL([ENABLE_JVMTI], test x"${ENABLE_JVMTI}" = "xyes")
+
+if test x"${ENABLE_JVMTI}" = "xyes"; then
+    AC_DEFINE([ENABLE_JVMTI], 1, [use JVMTI])
+fi
+])
diff --git a/m4/ltdl.m4 b/m4/ltdl.m4
deleted file mode 100644 (file)
index 6a7b174..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-dnl m4/ltdl.m4
-dnl
-dnl Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
-dnl C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-dnl E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-dnl J. Wenninger, Institut f. Computersprachen - TU Wien
-dnl 
-dnl This file is part of CACAO.
-dnl 
-dnl This program is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU General Public License as
-dnl published by the Free Software Foundation; either version 2, or (at
-dnl your option) any later version.
-dnl 
-dnl This program is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-dnl General Public License for more details.
-dnl 
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-dnl 02110-1301, USA.
-
-
-dnl check if ltdl should be used
-
-AC_DEFUN([AC_CHECK_ENABLE_LTDL],[
-AC_MSG_CHECKING(whether ltdl should be used)
-AC_ARG_ENABLE([ltdl],
-              [AS_HELP_STRING(--disable-ltdl,disable ltdl support [[default=enabled]])],
-              [case "${enableval}" in
-                  no)
-                      ENABLE_LTDL=no
-                      ;;
-                  *)
-                      ENABLE_LTDL=yes
-                      ;;
-               esac],
-              [ENABLE_LTDL=yes])
-AC_MSG_RESULT(${ENABLE_LTDL})
-
-if test x"${ENABLE_LTDL}" = "xyes"; then
-    dnl we need this check for --enable-staticvm, otherwise ltdl can't find dlopen
-    if test x"${ENABLE_STATICVM}" = "xyes"; then
-        AC_CHECK_LIB(dl, dlopen,, [AC_MSG_ERROR(cannot find libdl)])
-    fi
-
-    AC_CHECK_HEADERS([ltdl.h],, [AC_MSG_ERROR(cannot find ltdl.h)])
-    AC_CHECK_LIB(ltdl, lt_dlopen,, [AC_MSG_ERROR(cannot find libltdl)])
-    AC_DEFINE([ENABLE_LTDL], 1, [use ltdl])
-fi
-
-AM_CONDITIONAL([ENABLE_LTDL], test x"${ENABLE_LTDL}" = "xyes")
-])
diff --git a/m4/memcheck.m4 b/m4/memcheck.m4
new file mode 100644 (file)
index 0000000..008990f
--- /dev/null
@@ -0,0 +1,41 @@
+dnl m4/memcheck.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for memcheck support
+
+AC_DEFUN([AC_CHECK_ENABLE_MEMCHECK],[
+AC_MSG_CHECKING(whether debugging memory checks should be enabled)
+AC_ARG_ENABLE([memcheck],
+              [AS_HELP_STRING(--enable-memcheck,enable debugging memory checks [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_MEMCHECK=yes;;
+                   *) ENABLE_MEMCHECK=no;;
+               esac],
+              [ENABLE_MEMCHECK=no])
+AC_MSG_RESULT(${ENABLE_MEMCHECK})
+AM_CONDITIONAL([ENABLE_MEMCHECK], test x"${ENABLE_MEMCHECK}" = "xyes")
+
+if test x"${ENABLE_MEMCHECK}" = "xyes"; then
+    AC_DEFINE([ENABLE_MEMCHECK], 1, [perform debugging memory checks])
+fi
+])
diff --git a/m4/opagent.m4 b/m4/opagent.m4
new file mode 100644 (file)
index 0000000..5b55961
--- /dev/null
@@ -0,0 +1,58 @@
+dnl m4/opagent.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+dnl check if opagent library should be used
+
+AC_DEFUN([AC_CHECK_ENABLE_OPAGENT],[
+AC_ARG_WITH([opagent-includedir],
+            [AS_HELP_STRING(--with-opagent-includedir=<path>,location of opagent header files [[default=/usr/include]])],
+            [OPAGENT_CFLAGS=-I"${withval}"],
+            [])
+AC_SUBST(OPAGENT_CFLAGS)
+
+AC_ARG_WITH([opagent-libdir],
+            [AS_HELP_STRING(--with-opagent-libdir=<path>,location of opagent library [[default=/usr/lib/oprofile]])],
+            [OPAGENT_LDFLAGS=-L"${withval}"],
+            [OPAGENT_LDFLAGS=-L/usr/lib/oprofile])
+AC_SUBST(OPAGENT_LDFLAGS)
+
+AC_MSG_CHECKING(whether Oprofile opagent support code should be compiled)
+AC_ARG_ENABLE([opagent],
+              [AS_HELP_STRING(--enable-opagent,enable opagent library support [[default=disabled]])],
+              [case "${enableval}" in
+                  yes) ENABLE_OPAGENT=yes;;
+                  *) ENABLE_OPAGENT=no;;
+               esac],
+              [ENABLE_OPAGENT=no])
+AC_MSG_RESULT(${ENABLE_OPAGENT})
+
+if test x"${ENABLE_OPAGENT}" = "xyes"; then
+    CFLAGS="$CFLAGS $OPAGENT_CFLAGS"
+    CPPFLAGS="$CPPFLAGS $OPAGENT_CFLAGS"
+    LDFLAGS="$LDFLAGS $OPAGENT_LDFLAGS"
+    AC_CHECK_HEADERS([opagent.h],, [AC_MSG_ERROR(cannot find opagent.h)])
+    AC_CHECK_LIB(opagent, op_open_agent,, [AC_MSG_ERROR(cannot find libopagent)])
+    AC_DEFINE([ENABLE_OPAGENT], 1, [use opagent])
+fi
+AM_CONDITIONAL([ENABLE_OPAGENT], [test x"${ENABLE_OPAGENT}" = "xyes"])
+])
+
diff --git a/m4/replacement.m4 b/m4/replacement.m4
new file mode 100644 (file)
index 0000000..0a891be
--- /dev/null
@@ -0,0 +1,41 @@
+dnl m4/replacement.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for replacement
+
+AC_DEFUN([AC_CHECK_ENABLE_REPLACEMENT],[
+AC_MSG_CHECKING(whether on-stack replacement should be supported)
+AC_ARG_ENABLE([replacement],
+              [AS_HELP_STRING(--enable-replacement,enable on-stack replacement [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_REPLACEMENT=yes;;
+                   *) ENABLE_REPLACEMENT=no;;
+               esac],
+              [ENABLE_REPLACEMENT=no])
+AC_MSG_RESULT(${ENABLE_REPLACEMENT})
+AM_CONDITIONAL([ENABLE_REPLACEMENT], test x"${ENABLE_REPLACEMENT}" = "xyes")
+
+if test x"${ENABLE_REPLACEMENT}" = "xyes"; then
+    AC_DEFINE([ENABLE_REPLACEMENT], 1, [use on-stack replacement])
+fi
+])
diff --git a/m4/rt-timing.m4 b/m4/rt-timing.m4
new file mode 100644 (file)
index 0000000..c2e85f8
--- /dev/null
@@ -0,0 +1,41 @@
+dnl m4/rt-timing.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for compiler timing
+
+AC_DEFUN([AC_CHECK_ENABLE_RT_TIMING],[
+AC_MSG_CHECKING(whether real-time timing should be enabled)
+AC_ARG_ENABLE([rt-timing],
+              [AS_HELP_STRING(--enable-rt-timing,enable real-time timing [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_RT_TIMING=yes;;
+                   *) ENABLE_RT_TIMING=no;;
+               esac],
+              [ENABLE_RT_TIMING=no])
+AC_MSG_RESULT(${ENABLE_RT_TIMING})
+AM_CONDITIONAL([ENABLE_RT_TIMING], test x"${ENABLE_RT_TIMING}" = "xyes")
+
+if test x"${ENABLE_RT_TIMING}" = "xyes"; then
+    AC_DEFINE([ENABLE_RT_TIMING], 1, [enable real-time timing])
+fi
+])
diff --git a/m4/statistics.m4 b/m4/statistics.m4
new file mode 100644 (file)
index 0000000..2ee82c0
--- /dev/null
@@ -0,0 +1,41 @@
+dnl m4/statistics.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for statistics
+
+AC_DEFUN([AC_CHECK_ENABLE_STATISTICS],[
+AC_MSG_CHECKING(whether statistics generation should be enabled)
+AC_ARG_ENABLE([statistics],
+              [AS_HELP_STRING(--enable-statistics,enable statistics generation [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_STATISTICS=yes;;
+                   *) ENABLE_STATISTICS=no;;
+               esac],
+              [ENABLE_STATISTICS=no])
+AC_MSG_RESULT(${ENABLE_STATISTICS})
+AM_CONDITIONAL([ENABLE_STATISTICS], test x"${ENABLE_STATISTICS}" = "xyes")
+
+if test x"${ENABLE_STATISTICS}" = "xyes"; then
+    AC_DEFINE([ENABLE_STATISTICS], 1, [enable statistics])
+fi
+])
index 08cc6f8ed9df0c801c38c1112987af74b7cf7a78..c1acf9baebd91fde444220ee39c0af1c8b8ee380 100644 (file)
@@ -57,10 +57,11 @@ case "${ENABLE_THREADS}" in
         AC_DEFINE([ENABLE_THREADS], 1, [enable threads])
         AC_CHECK_LIB(pthread, main)
 
-        ARCH_CFLAGS="$ARCH_CFLAGS -D_REENTRANT"
+        OS_FLAGS="$OS_FLAGS -D_REENTRANT"
 
-        dnl we changed ARCH_CFLAGS, set CFLAGS again
-        CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
+        dnl We changed OS_FLAGS, set CFLAGS again.
+        CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS"
+        CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS"
 
         dnl tell boehm to support threads as well
         ac_configure_args="$ac_configure_args --enable-boehm-threads=posix"
diff --git a/m4/verifier.m4 b/m4/verifier.m4
new file mode 100644 (file)
index 0000000..96141e0
--- /dev/null
@@ -0,0 +1,41 @@
+dnl m4/verifier.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for verifier
+
+AC_DEFUN([AC_CHECK_ENABLE_VERIFIER],[
+AC_MSG_CHECKING(whether classfile verification should be enabled)
+AC_ARG_ENABLE([verifier],
+              [AS_HELP_STRING(--disable-verifier,disable classfile verification [[default=enabled]])],
+              [case "${enableval}" in
+                   no) ENABLE_VERIFIER=no;;
+                   *) ENABLE_VERIFIER=yes;;
+               esac],
+              [ENABLE_VERIFIER=yes])
+AC_MSG_RESULT(${ENABLE_VERIFIER})
+AM_CONDITIONAL([ENABLE_VERIFIER], test x"${ENABLE_VERIFIER}" = "xyes")
+
+if test x"${ENABLE_VERIFIER}" = "xyes"; then
+    AC_DEFINE([ENABLE_VERIFIER], 1, [enable classfile verification])
+fi
+])
diff --git a/m4/vm-zip.m4 b/m4/vm-zip.m4
new file mode 100644 (file)
index 0000000..85f2548
--- /dev/null
@@ -0,0 +1,43 @@
+dnl m4/vm-zip.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl where is CACAO's vm.zip
+
+AC_DEFUN([AC_CHECK_WITH_VM_ZIP],[
+AC_MSG_CHECKING(where CACAO's vm.zip is installed)
+AC_ARG_WITH([vm-zip],
+            [AS_HELP_STRING(--with-vm-zip=<path>,path to CACAO's vm.zip (includes the name of the file and may be flat) [[default=(--enable-zlib:${CACAO_PREFIX}/share/cacao/vm.zip,--disable-zlib:${CACAO_PREFIX}/share/cacao/classes)]])],
+            [CACAO_VM_ZIP=${withval}],
+            [case "${ENABLE_ZLIB}" in
+                 no)
+                     CACAO_VM_ZIP=${CACAO_PREFIX}/share/cacao/classes
+                     ;;
+                 *)
+                     CACAO_VM_ZIP=${CACAO_PREFIX}/share/cacao/vm.zip
+                     ;;
+             esac
+            ])
+AC_MSG_RESULT(${CACAO_VM_ZIP})
+AC_DEFINE_UNQUOTED([CACAO_VM_ZIP], "${CACAO_VM_ZIP}", [CACAO's vm.zip])
+AC_SUBST(CACAO_VM_ZIP)
+])
diff --git a/m4/vmlog.m4 b/m4/vmlog.m4
new file mode 100644 (file)
index 0000000..17d98a2
--- /dev/null
@@ -0,0 +1,41 @@
+dnl m4/vmlog.m4
+dnl
+dnl Copyright (C) 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl 
+dnl This file is part of CACAO.
+dnl 
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl check for vmlog support
+
+AC_DEFUN([AC_CHECK_ENABLE_VMLOG],[
+AC_MSG_CHECKING(whether vmlog tracing should be enabled)
+AC_ARG_ENABLE([vmlog],
+              [AS_HELP_STRING(--enable-vmlog,enable vmlog tracing [[default=no]])],
+              [case "${enableval}" in
+                   yes) ENABLE_VMLOG=yes;;
+                   *) ENABLE_VMLOG=no;;
+               esac],
+              [ENABLE_VMLOG=no])
+AC_MSG_RESULT(${ENABLE_VMLOG})
+AM_CONDITIONAL([ENABLE_VMLOG], test x"${ENABLE_VMLOG}" = "xyes")
+
+if test x"${ENABLE_VMLOG}" = "xyes"; then
+    AC_DEFINE([ENABLE_VMLOG], 1, [enable vmlog tracing code])
+fi
+])
index b2cb8bf2aec61d7f8be3544a1bc6438da5a63e88..b1bf2b10609d14a455453926493e4c9dd795cd6b 100644 (file)
@@ -23,7 +23,6 @@
 
 DIST_SUBDIRS = \
        cacao \
-       cacaoh \
        classes \
        fdlibm \
        mm \
@@ -31,21 +30,18 @@ DIST_SUBDIRS = \
        scripts \
        threads \
        toolbox \
-       vm \
-       vmcore
+       vm
 
 # DON'T CHANGE THIS ORDER!!!
 
 SUBDIRS = \
-       toolbox \
-       vmcore \
-       cacaoh \
        classes \
-       native \
        fdlibm \
+       toolbox \
        mm \
-       threads \
        vm \
+       threads \
+       native \
        cacao \
        scripts
 
index 2a5247afd4a716069e0ad0873e79e608858173be..0f59f3228b95e4d90472c359f992b8cae152cd2a 100644 (file)
@@ -35,11 +35,17 @@ lib_LTLIBRARIES = \
        libjvm.la
 
 libjvm_la_LDFLAGS = \
-       -version-info 1:0:0
+       -avoid-version
 
 if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
+if WITH_GNU_LD
 libjvm_la_LDFLAGS += \
        -Xlinker --version-script=$(top_srcdir)/contrib/mapfile-vers-product
+else
+# This is for the Solaris LD.
+libjvm_la_LDFLAGS += \
+       -Xlinker -M$(top_srcdir)/contrib/mapfile-vers-product
+endif
 endif
 
 cacao_LDFLAGS += \
@@ -68,6 +74,11 @@ endif
 
 libjvm_la_SOURCES =
 
+# Dummy C++ source to cause C++ linking.
+# http://www.gnu.org/software/automake/manual/automake.html#Libtool-Convenience-Libraries
+nodist_EXTRA_libjvm_la_SOURCES = \
+       dummy.cxx
+
 libjvm_la_LIBADD = \
        $(top_builddir)/src/fdlibm/libfdlibm.la \
        $(top_builddir)/src/mm/libmm.la \
@@ -75,14 +86,13 @@ libjvm_la_LIBADD = \
        $(top_builddir)/src/threads/libthreads.la \
        $(top_builddir)/src/toolbox/libtoolbox.la \
        $(top_builddir)/src/vm/libvm.la \
-       $(top_builddir)/src/vmcore/libvmcore.la \
        $(GC_LIB)
 
 bin_PROGRAMS = \
        cacao
 
 cacao_SOURCES = \
-       cacao.c
+       cacao.cpp
 
 cacao_LDADD = \
        $(CACAO_LIBS)
@@ -91,6 +101,20 @@ cacao_DEPENDENCIES = \
        $(cacao_LDADD)
 
 
+if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
+install-data-local:
+       $(mkdir_p) $(prefix)/jre/lib/$(JAVA_ARCH)/server
+       $(LN_S) -f $(libdir)/libjvm.so $(prefix)/jre/lib/$(JAVA_ARCH)/server
+       $(ECHO) $(ECHO_N) > $(prefix)/jre/lib/$(JAVA_ARCH)/server/Xusage.txt
+       $(ECHO) $(ECHO_N) > $(prefix)/jre/lib/$(JAVA_ARCH)/server/libjsig.so
+
+uninstall-local:
+       rm -f $(prefix)/jre/lib/$(JAVA_ARCH)/server/libjvm.so
+       rm -f $(prefix)/jre/lib/$(JAVA_ARCH)/server/Xusage.txt
+       rm -f $(prefix)/jre/lib/$(JAVA_ARCH)/server/libjsig.so
+endif
+
+
 ## Local variables:
 ## mode: Makefile
 ## indent-tabs-mode: t
diff --git a/src/cacao/cacao.c b/src/cacao/cacao.c
deleted file mode 100644 (file)
index 1f19362..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/* src/cacao/cacao.c - contains main() of cacao
-
-   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>
-
-#if defined(ENABLE_LIBJVM)
-# include <ltdl.h>
-#endif
-
-#if defined(ENABLE_JRE_LAYOUT)
-# include <errno.h>
-# include <libgen.h>
-# include <unistd.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-
-#if defined(ENABLE_JVMTI)
-# include "native/jvmti/jvmti.h"
-# include "native/jvmti/cacaodbg.h"
-# include "threads/mutex.h"
-#endif
-
-#include "vm/vm.h"
-
-
-/* forward declarations *******************************************************/
-
-static JavaVMInitArgs *cacao_options_prepare(int argc, char **argv);
-
-
-/* main ************************************************************************
-
-   The main program.
-   
-*******************************************************************************/
-
-int main(int argc, char **argv)
-{
-#if defined(ENABLE_LIBJVM)
-       char           *path;
-#endif
-
-#if defined(ENABLE_LIBJVM)     
-       /* Variables for JNI_CreateJavaVM dlopen call. */
-       lt_dlhandle     libjvm_handle;
-       lt_ptr          libjvm_vm_createjvm;
-       lt_ptr          libjvm_vm_run;
-       const char     *lterror;
-
-       bool (*vm_createjvm)(JavaVM **, void **, void *);
-       void (*vm_run)(JavaVM *, JavaVMInitArgs *);
-#endif
-
-       JavaVM         *vm;                 /* denotes a Java VM                  */
-       JNIEnv         *env;
-       JavaVMInitArgs *vm_args;
-
-       /* prepare the options */
-
-       vm_args = cacao_options_prepare(argc, argv);
-       
-       /* load and initialize a Java VM, return a JNI interface pointer in env */
-
-#if defined(ENABLE_LIBJVM)
-# if defined(ENABLE_JRE_LAYOUT)
-       /* SUN also uses a buffer of 4096-bytes (strace is your friend). */
-
-       path = malloc(sizeof(char) * 4096);
-
-       if (readlink("/proc/self/exe", path, 4095) == -1) {
-               fprintf(stderr, "main: readlink failed: %s\n", strerror(errno));
-               abort();
-       }
-
-       /* get the path of the current executable */
-
-       path = dirname(path);
-
-       if ((strlen(path) + strlen("/../lib/libjvm") + strlen("0")) > 4096) {
-               fprintf(stderr, "main: libjvm name to long for buffer\n");
-               abort();
-       }
-
-       /* concatinate the library name */
-
-       strcat(path, "/../lib/libjvm");
-# else
-       path = CACAO_LIBDIR"/libjvm";
-# endif
-
-       if (lt_dlinit()) {
-               fprintf(stderr, "main: lt_dlinit failed: %s\n", lt_dlerror());
-               abort();
-       }
-
-       /* First try to open where dlopen searches, e.g. LD_LIBRARY_PATH.
-          If not found, try the absolute path. */
-
-       if (!(libjvm_handle = lt_dlopenext("libjvm"))) {
-               /* save the error message */
-
-               lterror = strdup(lt_dlerror());
-
-               if (!(libjvm_handle = lt_dlopenext(path))) {
-                       /* print the first error message too */
-
-                       fprintf(stderr, "main: lt_dlopenext failed: %s\n", lterror);
-
-                       /* and now the current one */
-
-                       fprintf(stderr, "main: lt_dlopenext failed: %s\n", lt_dlerror());
-                       abort();
-               }
-
-               /* free the error string */
-
-               free((void *) lterror);
-       }
-
-       if (!(libjvm_vm_createjvm = lt_dlsym(libjvm_handle, "vm_createjvm"))) {
-               fprintf(stderr, "main: lt_dlsym failed: %s\n", lt_dlerror());
-               abort();
-       }
-
-       vm_createjvm =
-               (bool (*)(JavaVM **, void **, void *)) (ptrint) libjvm_vm_createjvm;
-#endif
-
-       /* create the Java VM */
-
-       (void) vm_createjvm(&vm, (void *) &env, vm_args);
-
-#if defined(ENABLE_JVMTI)
-       mutex_init(&dbgcomlock);
-       if (jvmti) jvmti_set_phase(JVMTI_PHASE_START);
-#endif
-
-#if defined(ENABLE_LIBJVM)
-       if (!(libjvm_vm_run = lt_dlsym(libjvm_handle, "vm_run"))) {
-               fprintf(stderr, "lt_dlsym failed: %s\n", lt_dlerror());
-               abort();
-       }
-
-       vm_run = (void (*)(JavaVM *, JavaVMInitArgs *)) (ptrint) libjvm_vm_run;
-#endif
-
-       /* run the VM */
-
-       vm_run(vm, vm_args);
-
-       /* keep compiler happy */
-
-       return 0;
-}
-
-
-/* cacao_options_prepare *******************************************************
-
-   Prepare the JavaVMInitArgs.
-
-*******************************************************************************/
-
-static JavaVMInitArgs *cacao_options_prepare(int argc, char **argv)
-{
-       JavaVMInitArgs *vm_args;
-       s4              i;
-
-       vm_args = malloc(sizeof(JavaVMInitArgs));
-
-       vm_args->version            = JNI_VERSION_1_2;
-       vm_args->nOptions           = argc - 1;
-       vm_args->options            = malloc(sizeof(JavaVMOption) * argc);
-       vm_args->ignoreUnrecognized = JNI_FALSE;
-
-       for (i = 1; i < argc; i++)
-               vm_args->options[i - 1].optionString = argv[i];
-
-       return vm_args;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/cacao/cacao.cpp b/src/cacao/cacao.cpp
new file mode 100644 (file)
index 0000000..9bf7c05
--- /dev/null
@@ -0,0 +1,220 @@
+/* src/cacao/cacao.cpp - contains main() of cacao
+
+   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"
+
+#if defined(ENABLE_JRE_LAYOUT)
+# include <errno.h>
+# include <libgen.h>
+# include <unistd.h>
+#endif
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JVMTI)
+# include "native/jvmti/jvmti.h"
+# include "native/jvmti/cacaodbg.h"
+#endif
+
+#include "vm/os.hpp"
+#include "vm/vm.hpp"
+
+
+/* Defines. *******************************************************************/
+
+#define LIBJVM_NAME    NATIVE_LIBRARY_PREFIX"jvm"NATIVE_LIBRARY_SUFFIX
+
+
+/* forward declarations *******************************************************/
+
+static JavaVMInitArgs* prepare_options(int argc, char** argv);
+
+
+/* main ************************************************************************
+
+   The main program.
+   
+*******************************************************************************/
+
+int main(int argc, char **argv)
+{
+#if defined(ENABLE_LIBJVM)
+       char* path;
+
+# if defined(ENABLE_JRE_LAYOUT)
+       int         len;
+# endif
+#endif
+
+#if defined(ENABLE_LIBJVM)     
+       /* Variables for JNI_CreateJavaVM dlopen call. */
+       void*       libjvm_handle;
+       void*       libjvm_VM_create;
+       void*       libjvm_vm_run;
+       const char* lterror;
+
+       bool (*VM_create)(JavaVM**, void**, void*);
+       void (*vm_run)(JavaVM*, JavaVMInitArgs*);
+#endif
+
+       // Prepare the options.
+       JavaVMInitArgs* vm_args = prepare_options(argc, argv);
+       
+       /* load and initialize a Java VM, return a JNI interface pointer in env */
+
+#if defined(ENABLE_LIBJVM)
+# if defined(ENABLE_JRE_LAYOUT)
+       /* SUN also uses a buffer of 4096-bytes (strace is your friend). */
+
+       path = (char*) os::malloc(sizeof(char) * 4096);
+
+       if (readlink("/proc/self/exe", path, 4095) == -1) {
+               fprintf(stderr, "main: readlink failed: %s\n", strerror(errno));
+               os::abort();
+       }
+
+       /* get the path of the current executable */
+
+       path = os::dirname(path);
+       len  = os::strlen(path) + os::strlen("/../lib/"LIBJVM_NAME) + os::strlen("0");
+
+       if (len > 4096) {
+               fprintf(stderr, "main: libjvm name to long for buffer\n");
+               os::abort();
+       }
+
+       /* concatenate the library name */
+
+       strcat(path, "/../lib/"LIBJVM_NAME);
+# else
+       path = (char*) CACAO_LIBDIR"/"LIBJVM_NAME;
+# endif
+
+       /* First try to open where dlopen searches, e.g. LD_LIBRARY_PATH.
+          If not found, try the absolute path. */
+
+       libjvm_handle = os::dlopen(LIBJVM_NAME, RTLD_NOW);
+
+       if (libjvm_handle == NULL) {
+               /* save the error message */
+
+               lterror = strdup(os::dlerror());
+
+               libjvm_handle = os::dlopen(path, RTLD_NOW);
+
+               if (libjvm_handle == NULL) {
+                       /* print the first error message too */
+
+                       fprintf(stderr, "main: os::dlopen failed: %s\n", lterror);
+
+                       /* and now the current one */
+
+                       fprintf(stderr, "main: os::dlopen failed: %s\n", os::dlerror());
+                       os::abort();
+               }
+
+               // Free the error string.
+               os::free((void*) lterror);
+       }
+
+       libjvm_VM_create = os::dlsym(libjvm_handle, "VM_create");
+
+       if (libjvm_VM_create == NULL) {
+               fprintf(stderr, "main: lt_dlsym failed: %s\n", os::dlerror());
+               os::abort();
+       }
+
+       VM_create = (bool (*)(JavaVM**, void**, void*)) (uintptr_t) libjvm_VM_create;
+#endif
+
+       // Create the Java VM.
+       JavaVM* vm;
+       void*   env; // We use a void* instead of a JNIEnv* here to prevent a compiler warning.
+
+       (void) VM_create(&vm, &env, vm_args);
+
+#if defined(ENABLE_JVMTI)
+# error This should be a JVMTI function.
+       Mutex_init(&dbgcomlock);
+       if (jvmti) jvmti_set_phase(JVMTI_PHASE_START);
+#endif
+
+#if defined(ENABLE_LIBJVM)
+       libjvm_vm_run = os::dlsym(libjvm_handle, "vm_run");
+
+       if (libjvm_vm_run == NULL) {
+               fprintf(stderr, "main: os::dlsym failed: %s\n", os::dlerror());
+               os::abort();
+       }
+
+       vm_run = (void (*)(JavaVM*, JavaVMInitArgs*)) (uintptr_t) libjvm_vm_run;
+#endif
+
+       // Run the VM.
+       vm_run(vm, vm_args);
+
+       // Keep compiler happy.
+       return 0;
+}
+
+
+/**
+ * Prepare the JavaVMInitArgs structure.
+ */
+static JavaVMInitArgs* prepare_options(int argc, char** argv)
+{
+       JavaVMInitArgs* vm_args;
+
+       vm_args = (JavaVMInitArgs*) malloc(sizeof(JavaVMInitArgs));
+
+       vm_args->version            = JNI_VERSION_1_2;
+       vm_args->nOptions           = argc - 1;
+       vm_args->options            = (JavaVMOption*) malloc(sizeof(JavaVMOption) * argc);
+       vm_args->ignoreUnrecognized = JNI_FALSE;
+
+       for (int i = 1; i < argc; i++)
+               vm_args->options[i - 1].optionString = argv[i];
+
+       return vm_args;
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/cacaoh/Makefile.am b/src/cacaoh/Makefile.am
deleted file mode 100644 (file)
index 7ab1d64..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-## src/cacaoh/Makefile.am
-##
-## 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.
-
-
-AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR)
-
-if ENABLE_RT_TIMING
-cacaoh_LDFLAGS = -lrt
-endif
-
-noinst_LTLIBRARIES = \
-       libcacaoh.la
-
-libcacaoh_la_SOURCES = \
-       dummy.c \
-       headers.c \
-       headers.h
-
-libcacaoh_la_LIBADD = \
-       $(top_builddir)/src/toolbox/libtoolbox.la \
-       $(top_builddir)/src/vmcore/libvmcore.la
-
-noinst_PROGRAMS = \
-       cacaoh
-
-cacaoh_SOURCES = \
-       cacaoh.c
-
-cacaoh_LDADD = \
-       libcacaoh.la
-
-cacaoh_DEPENDENCIES = \
-       $(cacaoh_LDADD)
-
-
-## Local variables:
-## mode: Makefile
-## indent-tabs-mode: t
-## c-basic-offset: 4
-## tab-width: 8
-## compile-command: "automake --add-missing"
-## End:
diff --git a/src/cacaoh/cacaoh.c b/src/cacaoh/cacaoh.c
deleted file mode 100644 (file)
index 0f1e8ed..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
-/* src/cacaoh/cacaoh.c - main for header generation (cacaoh)
-
-   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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "cacaoh/headers.h"
-
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-
-#include "toolbox/hashtable.h"
-#include "toolbox/logging.h"
-
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vmcore/classcache.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-#include "vmcore/suck.h"
-
-
-/* define cacaoh options ******************************************************/
-
-enum {
-       OPT_HELP,
-       OPT_VERSION,
-       OPT_VERBOSE,
-       OPT_DIRECTORY,
-       OPT_CLASSPATH,
-       OPT_BOOTCLASSPATH,
-
-       DUMMY
-};
-
-
-opt_struct opts[] = {
-       { "help",             false, OPT_HELP          },
-       { "version",          false, OPT_VERSION       },
-       { "verbose",          false, OPT_VERBOSE       },
-       { "d",                true,  OPT_DIRECTORY     },
-       { "classpath",        true,  OPT_CLASSPATH     },
-       { "bootclasspath",    true,  OPT_BOOTCLASSPATH },
-       { NULL,               false, 0                 }
-};
-
-
-/* usage ***********************************************************************
-
-   Obviously prints usage information of cacaoh.
-
-*******************************************************************************/
-
-void usage(void)
-{
-       printf("Usage: cacaoh [options] <classes>\n"
-                  "\n"
-                  "Options:\n"
-                  "    -help                 Print this message\n"
-                  "    -classpath <path>     \n"
-                  "    -bootclasspath <path> \n"
-                  "    -d <dir>              Output directory\n"
-                  "    -version              Print version information\n"
-                  "    -verbose              Enable verbose output\n");
-
-       /* exit with error code */
-
-       exit(1);
-}
-
-
-/* version *********************************************************************
-
-   Prints cacaoh version information.
-
-*******************************************************************************/
-
-static void version(void)
-{
-       printf("cacaoh version "VERSION"\n");
-       printf("Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,\n");
-       printf("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,\n");
-       printf("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,\n");
-       printf("J. Wenninger, Institut f. Computersprachen - TU Wien\n\n");
-
-       printf("This program is free software; you can redistribute it and/or\n");
-       printf("modify it under the terms of the GNU General Public License as\n");
-       printf("published by the Free Software Foundation; either version 2, or (at\n");
-       printf("your option) any later version.\n\n");
-
-       printf("This program is distributed in the hope that it will be useful, but\n");
-       printf("WITHOUT ANY WARRANTY; without even the implied warranty of\n");
-       printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n");
-       printf("General Public License for more details.\n");
-
-       exit(0);
-}
-
-
-/* forward declarations *******************************************************/
-
-static JavaVMInitArgs *cacaoh_options_prepare(int argc, char **argv);
-
-
-/* main ************************************************************************
-
-   Main program.
-   
-*******************************************************************************/
-
-int main(int argc, char **argv)
-{
-       JavaVMInitArgs *vm_args;
-       s4 i, j;
-       s4 opt;
-       classinfo *c;
-       char *opt_directory;
-
-       /********** internal (only used by main) *****************************/
-   
-       char *bootclasspath;
-       char *classpath;
-       char *cp;
-       s4    cplen;
-
-       if (argc < 2)
-               usage();
-
-       /* set the bootclasspath */
-
-       cp = getenv("BOOTCLASSPATH");
-
-       if (cp) {
-               bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
-               strcpy(bootclasspath, cp);
-       }
-       else {
-               cplen =
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-                       strlen(CACAO_VM_ZIP) +
-                       strlen(":") +
-#endif
-                       strlen(JAVA_RUNTIME_LIBRARY_CLASSES) +
-                       strlen("0");
-
-               bootclasspath = MNEW(char, cplen);
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-               strcat(bootclasspath, CACAO_VM_ZIP);
-               strcat(bootclasspath, ":");
-#endif
-               strcat(bootclasspath, JAVA_RUNTIME_LIBRARY_CLASSES);
-       }
-
-
-       /* set the classpath */
-
-       cp = getenv("CLASSPATH");
-
-       if (cp != NULL) {
-               classpath = MNEW(char, strlen(cp) + strlen("0"));
-               strcat(classpath, cp);
-       }
-       else {
-               classpath = MNEW(char, strlen(".") + strlen("0"));
-               strcpy(classpath, ".");
-       }
-
-
-       /* initialize options with default values */
-
-       opt_verbose = false;
-       opt_directory = NULL;
-
-
-       /* parse the options ******************************************************/
-
-       vm_args = cacaoh_options_prepare(argc, argv);
-
-       while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
-               switch (opt) {
-               case OPT_IGNORE:
-                       break;
-
-               case OPT_HELP:
-                       usage();
-                       break;
-
-               case OPT_CLASSPATH:
-                       /* forget old classpath and set the argument as new classpath */
-                       MFREE(classpath, char, strlen(classpath));
-
-                       classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
-                       strcpy(classpath, opt_arg);
-                       break;
-
-               case OPT_BOOTCLASSPATH:
-                       /* Forget default bootclasspath and set the argument as
-                          new boot classpath. */
-                       MFREE(bootclasspath, char, strlen(bootclasspath));
-
-                       bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
-                       strcpy(bootclasspath, opt_arg);
-                       break;
-
-               case OPT_DIRECTORY:
-                       opt_directory = MNEW(char, strlen(opt_arg) + strlen("0"));
-                       strcpy(opt_directory, opt_arg);
-                       break;
-
-               case OPT_VERSION:
-                       version();
-                       break;
-
-               case OPT_VERBOSE:
-                       opt_verbose = true;
-                       loadverbose = true;
-                       break;
-
-               default:
-                       usage();
-               }
-       }
-                       
-       /**************************** Program start **************************/
-
-       if (opt_verbose) {
-               log_init(NULL);
-               log_println("Java - header-generator started"); 
-       }
-
-       utf8_init();
-
-       /* initialize the classcache hashtable stuff: lock, hashtable
-          (must be done _after_ threads_preinit) */
-
-       if (!classcache_init())
-               vm_abort("classcache_init failed\n");
-
-       /* initialize the loader with bootclasspath (must be done _after_
-          thread_preinit) */
-
-       if (!suck_init())
-               vm_abort("suck_init failed\n");
-
-       suck_add(bootclasspath);
-
-       /* Also add the normal classpath, so the bootstrap class loader
-          can find the files. */
-
-       suck_add(classpath);
-
-       /* AFTER: classcache_init */
-
-       loader_preinit();
-       loader_init();
-
-
-       /* load Java classes ******************************************************/
-       
-       for (i = opt_index; i < vm_args->nOptions; i++) {
-               cp = vm_args->options[i].optionString;
-
-               /* convert classname */
-
-               for (j = strlen(cp) - 1; j >= 0; j--) {
-                       switch (cp[j]) {
-                       case '.':
-                               cp[j] = '/';
-                               break;
-                       case '_':
-                               cp[j] = '$';
-                               break;
-                       }
-               }
-       
-               /* exceptions are catched with new_exception call */
-
-               if (!(c = load_class_bootstrap(utf_new_char(cp))))
-                       vm_abort("java.lang.NoClassDefFoundError: %s\n", cp);
-
-               if (!link_class(c))
-                       vm_abort("java.lang.LinkageError: %s\n", cp);
-
-               headerfile_generate(c, opt_directory);
-       }
-
-       /************************ Release all resources **********************/
-
-       loader_close();
-
-       if (opt_verbose) {
-               log_println("Java - header-generator stopped");
-#if defined(ENABLE_STATISTICS)
-               statistics_print_memory_usage();
-#endif
-       }
-       
-       return 0;
-}
-
-
-/* cacaoh_options_prepare ******************************************************
-
-   Prepare the JavaVMInitArgs.
-
-*******************************************************************************/
-
-static JavaVMInitArgs *cacaoh_options_prepare(int argc, char **argv)
-{
-       JavaVMInitArgs *vm_args;
-       s4              i;
-
-       vm_args = NEW(JavaVMInitArgs);
-
-       vm_args->nOptions = argc - 1;
-       vm_args->options  = MNEW(JavaVMOption, argc);
-
-       for (i = 1; i < argc; i++)
-               vm_args->options[i - 1].optionString = argv[i];
-
-       return vm_args;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/cacaoh/dummy.c b/src/cacaoh/dummy.c
deleted file mode 100644 (file)
index 6e10e39..0000000
+++ /dev/null
@@ -1,854 +0,0 @@
-/* src/cacaoh/dummy.c - dummy functions for cacaoh
-
-   Copyright (C) 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 <errno.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-
-#include "native/llni.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/primitive.h"
-#include "vm/vm.h"
-
-#include "vm/jit/code.h"
-
-#include "vmcore/class.h"
-#include "vmcore/classcache.h"
-#include "vmcore/field.h"
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-#include "vmcore/utf8.h"
-#include "vmcore/system.h"
-
-
-/* global variables ***********************************************************/
-
-bool  vm_initializing = true;
-char *_Jv_bootclasspath;
-
-
-java_handle_t *javastring_new_slash_to_dot(utf *u)
-{
-       vm_abort("javastring_new_slash_to_dot");
-
-       return NULL;
-}
-
-
-/* access *********************************************************************/
-
-bool access_is_accessible_class(classinfo *referer, classinfo *cls)
-{
-       return true;
-}
-
-bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
-                                                                int32_t memberflags)
-{
-       vm_abort("access_is_accessible_member");
-
-       return true;
-}
-
-
-/* array **********************************************************************/
-
-java_handle_t *array_objectarray_element_get(java_handle_objectarray_t *a, int32_t index)
-{
-       java_handle_t *value;
-       int32_t        size;
-
-       if (a == NULL) {
-               log_println("array_objectarray_element_get(a=%p, index=%d): NullPointerException", a, index);
-               return NULL;
-       }
-
-       size = LLNI_array_size(a);
-
-       if ((index < 0) || (index > size)) {
-               log_println("array_objectarray_element_get(a=%p, index=%d): ArrayIndexOutOfBoundsException", a, index);
-               return NULL;
-       }
-
-       value = LLNI_WRAP(LLNI_array_direct(a, index));
-
-       return value;
-}
-
-void array_objectarray_element_set(java_handle_objectarray_t *a, int32_t index, java_handle_t *value)
-{
-       int32_t size;
-
-       if (a == NULL) {
-               log_println("array_objectarray_element_set(a=%p, index=%d): NullPointerException", a, index);
-               return;
-       }
-
-       size = LLNI_array_size(a);
-
-       if ((index < 0) || (index > size)) {
-               log_println("array_objectarray_element_set(a=%p, index=%d): ArrayIndexOutOfBoundsException", a, index);
-               return;
-       }
-
-       LLNI_array_direct(a, index) = LLNI_UNWRAP(value);
-}
-
-int32_t array_length_get(java_handle_t *a)
-{
-       if (a == NULL) {
-               log_println("array_length_get(a=%p): NullPointerException", a);
-               return 0;
-       }
-
-       return LLNI_array_size(a);
-}
-
-
-/* asm ************************************************************************/
-
-void asm_abstractmethoderror(void)
-{
-       abort();
-}
-
-void intrp_asm_abstractmethoderror(void)
-{
-       abort();
-}
-
-
-/* builtin ********************************************************************/
-
-java_handle_t *builtin_clone(void *env, java_handle_t *o)
-{
-       vm_abort("builtin_clone: Not implemented.");
-       return NULL;
-}
-
-bool fast_subtype_check(struct _vftbl *s, struct _vftbl *t)
-{
-       vm_abort("fast_subtype_check: Not implemented.");
-       return 0;
-}
-
-bool builtin_isanysubclass(classinfo *sub, classinfo *super)
-{
-       vm_abort("builtin_isanysubclass: Not implemented.");
-       return 0;
-}
-
-bool builtin_instanceof(java_handle_t *o, classinfo *class)
-{
-       vm_abort("builtin_instanceof: Not implemented.");
-       return 0;
-}
-
-java_handle_t *builtin_new(classinfo *c)
-{
-       vm_abort("builtin_new: Not implemented.");
-       return NULL;
-}
-
-java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass)
-{
-       java_objectarray_t *oa = (java_objectarray_t*) mem_alloc(
-               sizeof(java_array_t) + size * sizeof(java_object_t*));
-       java_handle_objectarray_t *h = (java_handle_objectarray_t*) LLNI_WRAP(
-               (java_object_t*) oa);
-
-       if (h != NULL) {
-               LLNI_array_size(h) = size;
-       }
-
-       return h;
-}
-
-java_handle_bytearray_t *builtin_newarray_byte(int32_t size)
-{
-       java_bytearray_t *ba = (java_bytearray_t*) mem_alloc(
-               sizeof(java_array_t) + size * sizeof(int8_t));
-       java_handle_bytearray_t *h = (java_handle_bytearray_t*) LLNI_WRAP(
-               (java_object_t*) ba);
-
-       if (h != NULL) {
-               LLNI_array_size(h) = size;
-       }
-       
-       return h;
-}
-
-
-/* code ***********************************************************************/
-
-void code_free_code_of_method(methodinfo *m)
-{
-}
-
-
-methodinfo *code_get_methodinfo_for_pv(void *pv)
-{
-       return NULL;
-}
-
-
-/* codegen ********************************************************************/
-
-u1 *codegen_generate_stub_compiler(methodinfo *m)
-{
-       return NULL;
-}
-
-codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f)
-{
-       return NULL;
-}
-
-#if defined(ENABLE_INTRP)
-u1 *intrp_createcompilerstub(methodinfo *m)
-{
-       return NULL;
-}
-#endif
-
-void removecompilerstub(u1 *stub)
-{
-}
-
-void removenativestub(u1 *stub)
-{
-}
-
-
-/* exceptions *****************************************************************/
-
-void exceptions_clear_exception(void)
-{
-}
-
-void exceptions_print_current_exception(void)
-{
-       abort();
-}
-
-void exceptions_throw_abstractmethoderror(void)
-{
-       fprintf(stderr, "java.lang.AbstractMethodError\n");
-
-       abort();
-}
-
-void exceptions_throw_classcircularityerror(classinfo *c)
-{
-       fprintf(stderr, "java.lang.ClassCircularityError: ");
-
-       utf_display_printable_ascii(c->name);
-       fputc('\n', stderr);
-
-       abort();
-}
-
-void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
-{
-       va_list ap;
-
-       fprintf(stderr, "java.lang.ClassFormatError: ");
-
-       utf_display_printable_ascii(c->name);
-       fprintf(stderr, ": ");
-
-       va_start(ap, message);
-       vfprintf(stderr, message, ap);
-       va_end(ap);
-
-       fputc('\n', stderr);
-
-       abort();
-}
-
-void exceptions_throw_incompatibleclasschangeerror(classinfo *c, const char *message)
-{
-       fprintf(stderr, "java.lang.IncompatibleClassChangeError: ");
-
-       if (c != NULL)
-               utf_fprint_printable_ascii_classname(stderr, c->name);
-
-       fputc('\n', stderr);
-
-       abort();
-}
-
-void exceptions_throw_internalerror(const char *message, ...)
-{
-       va_list ap;
-
-       fprintf(stderr, "java.lang.InternalError: ");
-
-       va_start(ap, message);
-       vfprintf(stderr, message, ap);
-       va_end(ap);
-
-       abort();
-}
-
-void exceptions_throw_linkageerror(const char *message, classinfo *c)
-{
-       fprintf(stderr, "java.lang.LinkageError: %s", message);
-
-       if (c != NULL)
-               utf_fprint_printable_ascii_classname(stderr, c->name);
-
-       fputc('\n', stderr);
-
-       abort();
-}
-
-void exceptions_throw_noclassdeffounderror(utf *name)
-{
-       fprintf(stderr, "java.lang.NoClassDefFoundError: ");
-       utf_fprint_printable_ascii(stderr, name);
-       fputc('\n', stderr);
-
-       abort();
-}
-
-void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name)
-{
-       fprintf(stderr, "java.lang.NoClassDefFoundError: ");
-       utf_fprint_printable_ascii(stderr, c->name);
-       fprintf(stderr, " (wrong name: ");
-       utf_fprint_printable_ascii(stderr, name);
-       fprintf(stderr, ")\n");
-
-       abort();
-}
-
-void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...)
-{
-       fprintf(stderr, "java.lang.VerifyError: ");
-       utf_fprint_printable_ascii(stderr, m->name);
-       fprintf(stderr, ": %s", message);
-
-       abort();
-}
-
-void exceptions_throw_nosuchfielderror(classinfo *c, utf *name)
-{
-       fprintf(stderr, "java.lang.NoSuchFieldError: ");
-       utf_fprint_printable_ascii(stderr, c->name);
-       fprintf(stderr, ".");
-       utf_fprint_printable_ascii(stderr, name);
-       fputc('\n', stderr);
-
-       abort();
-}
-
-void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc)
-{
-       fprintf(stderr, "java.lang.NoSuchMethodError: ");
-       utf_fprint_printable_ascii(stderr, c->name);
-       fprintf(stderr, ".");
-       utf_fprint_printable_ascii(stderr, name);
-       utf_fprint_printable_ascii(stderr, desc);
-       fputc('\n', stderr);
-
-       abort();
-}
-
-void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi)
-{
-       fprintf(stderr, "java.lang.UnsupportedClassVersionError: " );
-       utf_display_printable_ascii(c->name);
-       fprintf(stderr, " (Unsupported major.minor version %d.%d)\n", ma, mi);
-
-       abort();
-}
-
-void exceptions_throw_classnotfoundexception(utf *name)
-{
-       fprintf(stderr, "java.lang.ClassNotFoundException: ");
-       utf_fprint_printable_ascii(stderr, name);
-       fputc('\n', stderr);
-
-       abort();
-}
-
-void exceptions_throw_nullpointerexception(void)
-{
-       fprintf(stderr, "java.lang.NullPointerException\n");
-
-       abort();
-}
-
-
-/* finalizer ******************************************************************/
-
-void finalizer_notify(void)
-{
-       vm_abort("finalizer_notify");
-}
-
-void finalizer_run(void *o, void *p)
-{
-       vm_abort("finalizer_run");
-}
-
-
-/* gc *************************************************************************/
-
-void gc_reference_register(java_object_t **ref, int32_t reftype)
-{
-       vm_abort("gc_reference_register");
-}
-
-int64_t gc_get_heap_size(void)
-{
-       return 0;
-}
-
-int64_t gc_get_free_bytes(void)
-{
-       return 0;
-}
-
-int64_t gc_get_total_bytes(void)
-{
-       return 0;
-}
-
-int64_t gc_get_max_heap_size(void)
-{
-       return 0;
-}
-
-
-/* heap ***********************************************************************/
-
-void *heap_alloc_uncollectable(size_t bytelength)
-{
-       return calloc(bytelength, 1);
-}
-
-s4 heap_get_hashcode(java_object_t *o)
-{
-       return 0;
-}
-
-
-/* jit ************************************************************************/
-
-void jit_invalidate_code(methodinfo *m)
-{
-       vm_abort("jit_invalidate_code");
-}
-
-
-/* llni ***********************************************************************/
-
-void llni_critical_start()
-{
-}
-
-void llni_critical_end()
-{
-}
-
-
-/* localref *******************************************************************/
-
-java_handle_t *localref_add(java_object_t *o)
-{
-#if defined(ENABLE_HANDLES)
-       java_handle_t *h = (java_handle_t*) mem_alloc(sizeof(java_handle_t));
-
-       h->heap_object = o;
-
-       return h;
-#else
-       return (java_handle_t*) o;
-#endif
-}
-
-
-/* lock ***********************************************************************/
-
-void lock_init_object_lock(java_object_t *o)
-{
-}
-
-bool lock_monitor_enter(java_handle_t *o)
-{
-       return true;
-}
-
-bool lock_monitor_exit(java_handle_t *o)
-{
-       return true;
-}
-
-
-/* md *************************************************************************/
-
-void md_param_alloc(methoddesc *md)
-{
-}
-
-void md_param_alloc_native(methoddesc *md)
-{
-}
-
-
-/* memory *********************************************************************/
-
-void *mem_alloc(int32_t size)
-{
-       /* real implementation in src/mm/memory.c clears memory */
-
-       return calloc(size, 1);
-}
-
-void *mem_realloc(void *src, int32_t len1, int32_t len2)
-{
-       return realloc(src, len2);
-}
-
-void mem_free(void *m, int32_t size)
-{
-       free(m);
-}
-
-void *dumpmemory_get(size_t size)
-{
-       return malloc(size);
-}
-
-int32_t dumpmemory_marker(void)
-{
-       return 0;
-}
-
-void dumpmemory_release(int32_t size)
-{
-}
-
-
-/* package ********************************************************************/
-
-/* void package_add(java_handle_t *packagename) */
-void package_add(utf *packagename)
-{
-       /* Do nothing. */
-}
-
-
-/* primitive ******************************************************************/
-
-classinfo *primitive_arrayclass_get_by_type(int type)
-{
-       return NULL;
-}
-
-classinfo *primitive_class_get_by_type(int type)
-{
-       abort();
-       return NULL;
-}
-
-classinfo *primitive_class_get_by_char(char ch)
-{
-       abort();
-       return NULL;
-}
-
-
-/* properties *****************************************************************/
-
-void properties_add(char *key, char *value)
-{
-}
-
-char *properties_get(char *key)
-{
-       return NULL;
-}
-
-
-/* reflect ********************************************************************/
-
-java_handle_t *reflect_constructor_new(fieldinfo *f)
-{
-       vm_abort("reflect_constructor_new: Not implemented.");
-       return NULL;
-}
-
-java_handle_t *reflect_field_new(fieldinfo *f)
-{
-       vm_abort("reflect_field_new: Not implemented.");
-       return NULL;
-}
-
-java_handle_t *reflect_method_new(methodinfo *m)
-{
-       vm_abort("reflect_method_new: Not implemented.");
-       return NULL;
-}
-
-
-/* resolve ********************************************************************/
-
-void resolve_handle_pending_exception(bool throwError)
-{
-       vm_abort("resolve_handle_pending_exception: Not implemented.");
-}
-
-bool resolve_class_from_typedesc(typedesc *d, bool checkaccess, bool link, classinfo **result)
-{
-       abort();
-
-       return false;
-}
-
-/* stupid resolving implementation used by resolve_classref_or_classinfo_eager */
-/* This function does eager resolving without any access checks.               */
-
-static classinfo * dummy_resolve_class_from_name(classinfo *referer,
-                                                 utf *classname,
-                                                 bool checkaccess)
-{
-       classinfo *cls = NULL;
-       char *utf_ptr;
-       int len;
-       
-       assert(referer);
-       assert(classname);
-       
-       /* lookup if this class has already been loaded */
-
-       cls = classcache_lookup(referer->classloader, classname);
-
-       if (!cls) {
-               /* resolve array types */
-
-               if (classname->text[0] == '[') {
-                       utf_ptr = classname->text + 1;
-                       len = classname->blength - 1;
-
-                       /* classname is an array type name */
-
-                       switch (*utf_ptr) {
-                               case 'L':
-                                       utf_ptr++;
-                                       len -= 2;
-                                       /* FALLTHROUGH */
-                               case '[':
-                                       /* the component type is a reference type */
-                                       /* resolve the component type */
-                                       if ((cls = dummy_resolve_class_from_name(referer,
-                                                                          utf_new(utf_ptr,len),
-                                                                          checkaccess)) == NULL)
-                                               return NULL; /* exception */
-
-                                       /* create the array class */
-                                       cls = class_array_of(cls,false);
-                                       if (!cls)
-                                               return NULL; /* exception */
-                       }
-               }
-
-               /* load the class */
-               if (!cls) {
-                       if (!(cls = load_class_from_classloader(classname,
-                                                                                                       referer->classloader)))
-                               return false; /* exception */
-               }
-       }
-
-       /* the class is now loaded */
-       assert(cls);
-       assert(cls->state & CLASS_LOADED);
-
-       return cls;
-}
-
-
-classinfo * resolve_classref_or_classinfo_eager(classref_or_classinfo cls,
-                                                                                               bool checkaccess)
-{
-       classinfo         *c;
-       
-       assert(cls.any);
-
-       if (IS_CLASSREF(cls)) {
-               /* we must resolve this reference */
-
-               if ((c = dummy_resolve_class_from_name(cls.ref->referer, cls.ref->name,
-                                                                                  checkaccess)) == NULL)
-                       return NULL;
-       }
-       else {
-               /* cls has already been resolved */
-               c = cls.cls;
-       }
-
-       assert(c);
-       assert(c->state & CLASS_LOADED);
-
-       /* succeeded */
-       return c;
-}
-
-
-/* stacktrace *****************************************************************/
-
-java_handle_objectarray_t *stacktrace_getClassContext()
-{
-       return NULL;
-}
-
-
-/* threads ********************************************************************/
-
-intptr_t threads_get_current_tid(void)
-{
-       return 0;
-}
-
-void threads_cast_stopworld(void)
-{
-}
-
-void threads_cast_startworld(void)
-{
-}
-
-
-/* vm *************************************************************************/
-
-void vm_printconfig(void)
-{
-}
-
-void vm_abort(const char *text, ...)
-{
-       va_list ap;
-
-       va_start(ap, text);
-       vfprintf(stderr, text, ap);
-       va_end(ap);
-
-       system_abort();
-}
-
-void vm_abort_errno(const char *text, ...)
-{
-       va_list ap;
-
-       va_start(ap, text);
-       vm_abort_errnum(errno, text, ap);
-       va_end(ap);
-}
-
-void vm_abort_errnum(int errnum, const char *text, ...)
-{
-       va_list ap;
-
-       log_start();
-
-       va_start(ap, text);
-       log_vprint(text, ap);
-       va_end(ap);
-
-       log_print(": %s", system_strerror(errnum));
-       log_finish();
-
-       system_abort();
-}
-
-java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...)
-{
-       return NULL;
-}
-
-
-/* XXX */
-
-void stringtable_update(void)
-{
-       log_println("stringtable_update: REMOVE ME!");
-}
-
-java_object_t *literalstring_new(utf *u)
-{
-       log_println("literalstring_new: REMOVE ME!");
-
-       return NULL;
-}
-
-
-void print_dynamic_super_statistics(void)
-{
-}
-
-
-#if defined(ENABLE_VMLOG)
-void vmlog_cacao_set_prefix(const char *arg)
-{
-}
-
-void vmlog_cacao_set_stringprefix(const char *arg)
-{
-}
-
-void vmlog_cacao_set_ignoreprefix(const char *arg)
-{
-}
-#endif
-
-
-/*
- * 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/cacaoh/headers.c b/src/cacaoh/headers.c
deleted file mode 100644 (file)
index 8d9c42f..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-/* src/cacaoh/headers.c - functions for header generation
-
-   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 <ctype.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if defined(ENABLE_THREADS)
-# if defined(__DARWIN__)
-#  include <signal.h>
-# endif
-# include <ucontext.h>
-#endif
-
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-
-#include "toolbox/chain.h"
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-#include "vm/global.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
-
-/************************ global variables **********************/
-
-#define ACC_NATIVELY_OVERLOADED    0x10000000
-
-#if defined(ENABLE_HANDLES)
-# define HEAP_PREFIX "heap_"
-#else
-# define HEAP_PREFIX ""
-#endif
-
-chain *ident_chain;     /* chain with method and field names in current class */
-FILE *file = NULL;
-static uint32_t outputsize;
-static bool dopadding;
-
-
-static void printIDpart(int c)
-{
-       if ((c >= 'a' && c <= 'z') ||
-               (c >= 'A' && c <= 'Z') ||
-               (c >= '0' && c <= '9') ||
-               (c == '_'))
-               putc(c, file);
-       else
-               putc('_', file);
-}
-
-
-void printID(utf *u)
-{
-       char *utf_ptr = u->text;
-       int i;
-
-       for (i = 0; i < utf_get_number_of_u2s(u); i++) 
-               printIDpart(utf_nextu2(&utf_ptr));
-}
-
-
-static void addoutputsize(int len)
-{
-       uint32_t newsize;
-       int32_t  i;
-
-       if (!dopadding)
-               return;
-
-       newsize = MEMORY_ALIGN(outputsize, len);
-       
-       for (i = outputsize; i < newsize; i++)
-               fprintf(file, "   uint8_t pad%d\n", (int) i);
-
-       outputsize = newsize;
-}
-
-
-void printOverloadPart(utf *desc)
-{
-       char *utf_ptr=desc->text;
-       uint16_t c;
-
-       fprintf(file, "__");
-
-       while ((c = utf_nextu2(&utf_ptr)) != ')') {
-               switch (c) {
-               case 'I':
-               case 'S':
-               case 'B':
-               case 'C':
-               case 'Z':
-               case 'J':
-               case 'F':
-               case 'D': 
-                       fprintf(file, "%c", (char) c);
-                       break;
-               case '[':
-                       fprintf(file, "_3");
-                       break;
-               case 'L':
-                       putc('L', file);
-                       while ((c = utf_nextu2(&utf_ptr)) != ';')
-                               printIDpart(c);
-                       fprintf(file, "_2");
-                       break;
-               case '(':
-                       break;
-               default: 
-                       log_text("invalid method descriptor");
-                       assert(0);
-               }
-       }
-}
-
-static char *printtype(char *utf_ptr, char *prefix, char *infix)
-{
-       uint16_t c;
-
-       switch (utf_nextu2(&utf_ptr)) {
-       case 'V':
-               fprintf(file, "void");
-               break;
-       case 'I':
-       case 'S':
-       case 'B':
-       case 'C':
-       case 'Z':
-               addoutputsize(4);
-               fprintf(file, "int32_t");
-               break;
-       case 'J':
-               addoutputsize(8);
-               fprintf(file, "int64_t");
-               break;
-       case 'F':
-               addoutputsize(4);
-               fprintf(file, "float");
-               break;
-       case 'D':
-               addoutputsize(8);
-               fprintf(file, "double");
-               break;
-       case '[':
-               addoutputsize ( sizeof(java_array_t*) ); 
-               switch (utf_nextu2(&utf_ptr)) {
-               case 'I':  fprintf (file, "java%s_intarray_t*", infix); break;
-               case 'J':  fprintf (file, "java%s_longarray_t*", infix); break;
-               case 'Z':  fprintf (file, "java%s_booleanarray_t*", infix); break;
-               case 'B':  fprintf (file, "java%s_bytearray_t*", infix); break;
-               case 'S':  fprintf (file, "java%s_shortarray_t*", infix); break;
-               case 'C':  fprintf (file, "java%s_chararray_t*", infix); break;
-               case 'F':  fprintf (file, "java%s_floatarray_t*", infix); break;
-               case 'D':  fprintf (file, "java%s_doublearray_t*", infix); break;
-                               
-               case '[': fprintf(file, "java%s_objectarray_t*", infix);
-                       while ((c = utf_nextu2(&utf_ptr)) == '[');
-                       if (c == 'L')
-                               while (utf_nextu2(&utf_ptr) != ';');
-                       break;
-                           
-               case 'L':  fprintf(file, "java%s_objectarray_t*", infix);
-                       while (utf_nextu2(&utf_ptr) != ';');
-                       break;
-               default:
-                       log_text("invalid type descriptor");
-                       assert(0);
-               }
-               break;
-               
-       case 'L': 
-               addoutputsize ( sizeof(java_object_t*));
-               fprintf (file, "struct %s", prefix);
-               while ( (c = utf_nextu2(&utf_ptr)) != ';' ) printIDpart (c);     
-               fprintf (file, "*");
-               break;
-                                       
-       default:
-               log_text("Unknown type in field descriptor");
-               assert(0);
-       }
-       
-       return utf_ptr;
-}
-
-
-/***** determine the number of entries of a utf string in the ident chain *****/
-
-static int searchidentchain_utf(utf *ident) 
-{
-       utf *u = chain_first(ident_chain);     /* first element of list */
-       int count = 0;
-
-       while (u) {
-               if (u==ident) count++;         /* string found */
-               u = chain_next(ident_chain);   /* next element in list */ 
-       }
-
-       return count;
-}
-
-
-/************** print structure for direct access to objects ******************/
-
-static void printfields(classinfo *c)
-{
-       int32_t i;
-       fieldinfo *f;
-       int ident_count;
-       
-       if (!c) {
-               addoutputsize(sizeof(java_object_t));
-               fprintf(file, "   java_object_t header;\n");
-               return;
-       }
-               
-       printfields(c->super);
-       
-       for (i = 0; i < c->fieldscount; i++) {
-               f = &(c->fields[i]);
-               
-               if (!(f->flags & ACC_STATIC)) {
-                       fprintf(file, "   ");
-                       printtype(f->descriptor->text, HEAP_PREFIX, "");
-                       fprintf(file, " ");
-                       utf_fprint_printable_ascii(file, f->name);
-
-                       /* rename multiple fieldnames */
-                       if ((ident_count = searchidentchain_utf(f->name)))
-                               fprintf(file, "%d", ident_count - 1);
-                       chain_addlast(ident_chain, f->name);    
-
-                       fprintf(file, ";\n");
-               }
-       }
-}
-
-
-/***************** store prototype for native method in file ******************/
-
-void printmethod(methodinfo *m)
-{
-       char *utf_ptr;
-       int32_t paramnum = 1;
-
-       /* search for return-type in descriptor */      
-       utf_ptr = m->descriptor->text;
-       while (utf_nextu2(&utf_ptr) != ')');
-
-       /* create remarks */
-       fprintf(file, "\n/*\n * Class:     ");
-       utf_fprint_printable_ascii(file, m->clazz->name);
-       fprintf(file, "\n * Method:    ");
-       utf_fprint_printable_ascii(file, m->name);
-       fprintf(file, "\n * Signature: ");
-       utf_fprint_printable_ascii(file, m->descriptor);
-       fprintf(file, "\n */\n");
-
-       /* create prototype */                  
-       fprintf(file, "JNIEXPORT ");
-       printtype(utf_ptr, "", "_handle");
-       fprintf(file, " JNICALL Java_");
-       printID(m->clazz->name);
-
-       chain_addlast(ident_chain, m->name);
-
-       fprintf(file, "_");
-       printID(m->name);
-
-       /* ATTENTION: We use a dummy flag here. */
-
-       if (m->flags & ACC_NATIVELY_OVERLOADED)
-               printOverloadPart(m->descriptor);
-
-       fprintf(file, "(JNIEnv *env");
-       
-       utf_ptr = m->descriptor->text + 1;
-                       
-       if (!(m->flags & ACC_STATIC)) {
-               fprintf(file, ", struct ");
-               printID(m->clazz->name);
-               fprintf(file, "* this");
-
-       } else {
-               fprintf(file, ", jclass clazz");
-       }
-
-       if ((*utf_ptr) != ')') fprintf(file, ", ");
-                       
-       while ((*utf_ptr) != ')') {
-               utf_ptr = printtype(utf_ptr, "", "_handle");
-               fprintf(file, " par%d", paramnum++);
-               if ((*utf_ptr)!=')') fprintf(file, ", ");
-       }
-                       
-       fprintf(file, ");\n\n");
-}
-
-
-/******* remove package-name in fully-qualified classname *********************/
-
-void gen_header_filename(char *buffer, utf *u)
-{
-       int32_t i;
-  
-       for (i = 0; i < utf_get_number_of_u2s(u); i++) {
-               if ((u->text[i] == '/') || (u->text[i] == '$')) {
-                       buffer[i] = '_';  /* convert '$' and '/' to '_' */
-
-               } else {
-                       buffer[i] = u->text[i];
-               }
-       }
-       buffer[utf_get_number_of_u2s(u)] = '\0';
-}
-
-
-/* create headerfile for classes and store native methods in chain ************/
-
-void headerfile_generate(classinfo *c, char *opt_directory)
-{
-       char header_filename[1024] = "";
-       char classname[1024]; 
-       char uclassname[1024];
-       int32_t i;
-       methodinfo *m;                  
-       int32_t j;
-       methodinfo *m2;
-       bool nativelyoverloaded;
-
-       /* prevent compiler warnings */
-
-       nativelyoverloaded = false;
-
-       /* open headerfile for class */
-       gen_header_filename(classname, c->name);
-
-       /* create chain for renaming fields */
-       ident_chain = chain_new();
-       
-       if (opt_directory) {
-               sprintf(header_filename, "%s/%s.h", opt_directory, classname);
-
-       } else {
-               sprintf(header_filename, "%s.h", classname);
-       }
-
-       file = fopen(header_filename, "w");
-       if (!file) {
-               log_text("Can not open file to store header information");
-               assert(0);
-       }
-
-       fprintf(file, "/* This file is machine generated, don't edit it! */\n\n");
-
-       /* convert to uppercase */
-       for (i = 0; classname[i]; i++) {
-               uclassname[i] = toupper(classname[i]);
-       }
-       uclassname[i] = '\0';
-
-       fprintf(file, "#ifndef _%s_H\n#define _%s_H\n\n", uclassname, uclassname);
-
-       /* create structure for direct access to objects */     
-       fprintf(file, "/* Structure information for class: ");
-       utf_fprint_printable_ascii(file, c->name);
-       fprintf(file, " */\n\n");
-       fprintf(file, "typedef struct %s", HEAP_PREFIX);
-       printID(c->name);
-       fprintf(file, " {\n");
-       outputsize = 0;
-       dopadding = true;
-
-       printfields(c);
-
-       fprintf(file, "} %s", HEAP_PREFIX);
-       printID(c->name);
-       fprintf(file, ";\n\n");
-
-#if defined(ENABLE_HANDLES)
-       /* create structure for indirection cell */
-       fprintf(file, "typedef struct ");
-       printID(c->name);
-       fprintf(file, " {\n");
-       fprintf(file, "   %s", HEAP_PREFIX);
-       printID(c->name);
-       fprintf(file, " *heap_object;\n");
-       fprintf(file, "} ");
-       printID(c->name);
-       fprintf(file, ";\n\n");
-#endif
-
-       /* create chain for renaming overloaded methods */
-       chain_free(ident_chain);
-       ident_chain = chain_new();
-
-       /* create method-prototypes */
-                               
-       /* find overloaded methods */
-
-       for (i = 0; i < c->methodscount; i++) {
-               m = &(c->methods[i]);
-
-               if (!(m->flags & ACC_NATIVE))
-                       continue;
-
-               /* We use a dummy flag here. */
-
-               if (!(m->flags & ACC_NATIVELY_OVERLOADED)) {
-                       nativelyoverloaded = false;
-
-                       for (j = i + 1; j < c->methodscount; j++) {
-                               m2 = &(c->methods[j]);
-
-                               if (!(m2->flags & ACC_NATIVE))
-                                       continue;
-
-                               if (m->name == m2->name) {
-                                       m2->flags          |= ACC_NATIVELY_OVERLOADED;
-                                       nativelyoverloaded  = true;
-                               }
-                       }
-               }
-
-               if (nativelyoverloaded == true)
-                       m->flags |= ACC_NATIVELY_OVERLOADED;
-       }
-
-       for (i = 0; i < c->methodscount; i++) {
-               m = &(c->methods[i]);
-
-               if (m->flags & ACC_NATIVE)
-                       printmethod(m);
-       }
-
-       chain_free(ident_chain);
-
-       fprintf(file, "#endif\n\n");
-
-       fclose(file);
-}
-
-
-/******** print classname, '$' used to seperate inner-class name ***********/
-
-void print_classname(classinfo *clazz)
-{
-       utf *u = clazz->name;
-    char *endpos  = u->text + u->blength;
-    char *utf_ptr = u->text; 
-       uint16_t c;
-
-    while (utf_ptr < endpos) {
-               if ((c = utf_nextu2(&utf_ptr)) == '_')
-                       putc('$', file);
-               else
-                       putc(c, file);
-       }
-} 
-
-
-/*
- * 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/cacaoh/headers.h b/src/cacaoh/headers.h
deleted file mode 100644 (file)
index de8ed71..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/* src/cacaoh/headers.h - export functions for header generation
-
-   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
-
-   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 _HEADERS_H
-#define _HEADERS_H
-
-#include "config.h"
-
-#include "toolbox/chain.h"
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/utf8.h"
-
-
-/* export variables ***********************************************************/
-
-extern chain *nativemethod_chain;
-extern chain *nativeclass_chain;
-extern chain *ident_chain;
-extern FILE *file;
-
-
-/* function prototypes ********************************************************/
-
-void printID(utf *u);
-void printOverloadPart(utf *desc);
-void printmethod(methodinfo *m);
-void gen_header_filename(char *buffer, utf *u);
-void headerfile_generate(classinfo *c, char *opt_directory);
-void print_classname(classinfo *clazz);
-
-#endif /* _HEADERS_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:
- */
index 9ddec49705cbcf2cbc404f6813ea5087afdc1507..507eb39d6505d023d41cc5d03f575d8cf03cb448 100644 (file)
@@ -77,7 +77,7 @@ endif
 if ENABLE_ZLIB
 pkgdata_DATA = vm.zip
 else
-pkgdata_DATA = nozip
+noinst_DATA = nozip
 endif
 endif
 
@@ -88,7 +88,7 @@ VM_JAVA_FILES = \
 if ENABLE_ZLIB
 pkgdata_DATA = vm.zip
 else
-pkgdata_DATA = nozip
+noinst_DATA = nozip
 endif
 endif
 
@@ -107,6 +107,14 @@ else
 nozip: $(VM_JAVA_FILES)
        $(mkdir_p) classes
        $(JAVAC) -bootclasspath $(BOOTCLASSPATH) -source 1.5 -target 1.5 -d classes $(VM_JAVA_FILES)
+
+install-data-local: nozip
+       $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)
+       cp -R classes $(DESTDIR)$(pkgdatadir)
+
+uninstall-local:
+       rm -rf $(DESTDIR)$(pkgdatadir)/classes
+
 endif
 
 clean-local:
index 688f36dbc886e8f60dfc7fdcf2c28931f7938757..27e7d2cc7f918c4f156af0f2a18a817b60c7ce2c 100644 (file)
@@ -204,8 +204,11 @@ public final class CPStringBuilder
     int valueLength = value.length;
 
     /* Always call ensureCapacity in order to preserve
-       copy-on-write semantics.  */
-    ensureCapacity(newLength);
+       copy-on-write semantics, except when the position
+       is simply being reset
+    */
+    if (newLength > 0)
+      ensureCapacity(newLength);
 
     if (newLength < valueLength)
       {
@@ -1036,18 +1039,24 @@ public final class CPStringBuilder
    * Increase the capacity of this <code>StringBuilder</code>. This will
    * ensure that an expensive growing operation will not occur until either
    * <code>minimumCapacity</code> is reached or the array has been allocated.
-   * The buffer is grown to the larger of <code>minimumCapacity</code> and
+   * The buffer is grown to either <code>minimumCapacity * 2</code>, if
+   * the array has been allocated or the larger of <code>minimumCapacity</code> and 
    * <code>capacity() * 2 + 2</code>, if it is not already large enough.
    *
    * @param minimumCapacity the new capacity
-   * @see #capacity()
+   * @see #length()
    */
   public void ensureCapacity(int minimumCapacity)
   {
     if (allocated || minimumCapacity > value.length)
       {
-        int max = value.length * 2 + 2;
-        minimumCapacity = (minimumCapacity < max ? max : minimumCapacity);
+       if (minimumCapacity > value.length)
+         {
+           int max = value.length * 2 + 2;
+           minimumCapacity = (minimumCapacity < max ? max : minimumCapacity);
+         }
+       else
+         minimumCapacity *= 2;
        allocateArray(minimumCapacity);
       }
   }
index a511f3cf05691c657a5f6c92d620df11df3e3bae..e4f2595d323353b90ff6f0220b2f7fe50b896c18 100644 (file)
@@ -376,41 +376,42 @@ final class VMThread
      * @throws InterruptedException if the Thread is (or was) interrupted;
      *         it's <i>interrupted status</i> will be cleared
      */
-    static void sleep(long ms, int ns) throws InterruptedException
-    {
-      // Note: JDK treats a zero length sleep is like Thread.yield(),
-      // without checking the interrupted status of the thread.
-      // It's unclear if this is a bug in the implementation or the spec.
-      // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203
-      if (ms == 0 && ns == 0)
-       {
-         if (Thread.interrupted())
-           throw new InterruptedException();
-         return;
-       }
+//     static void sleep(long ms, int ns) throws InterruptedException
+//     {
+//       // Note: JDK treats a zero length sleep is like Thread.yield(),
+//       // without checking the interrupted status of the thread.
+//       // It's unclear if this is a bug in the implementation or the spec.
+//       // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203
+//       if (ms == 0 && ns == 0)
+//     {
+//       if (Thread.interrupted())
+//         throw new InterruptedException();
+//       return;
+//     }
 
-      // Compute end time, but don't overflow
-      long now = System.currentTimeMillis();
-      long end = now + ms;
-      if (end < now)
-         end = Long.MAX_VALUE;
+//       // Compute end time, but don't overflow
+//       long now = System.currentTimeMillis();
+//       long end = now + ms;
+//       if (end < now)
+//       end = Long.MAX_VALUE;
 
-      // A VM is allowed to return from wait() without notify() having been
-      // called, so we loop to handle possible spurious wakeups.
-      VMThread vt = Thread.currentThread().vmThread;
-      synchronized (vt)
-       {
-         while (true)
-           {
-             vt.wait(ms, ns);
-             now = System.currentTimeMillis();
-             if (now >= end)
-               break;
-             ms = end - now;
-             ns = 0;
-           }
-       }
-    }
+//       // A VM is allowed to return from wait() without notify() having been
+//       // called, so we loop to handle possible spurious wakeups.
+//       VMThread vt = Thread.currentThread().vmThread;
+//       synchronized (vt)
+//     {
+//       while (true)
+//         {
+//           vt.wait(ms, ns);
+//           now = System.currentTimeMillis();
+//           if (now >= end)
+//             break;
+//           ms = end - now;
+//           ns = 0;
+//         }
+//     }
+//     }
+    static native void sleep(long ms, int ns) throws InterruptedException;
 
     /**
      * Determine whether the current Thread has been interrupted, and clear
index 8c5aca3652bfe2ec6717691bd6b26720e4e0d764..51ce4729e9bb2ecf480f137568d5d342fc7f6625 100644 (file)
@@ -47,7 +47,7 @@ public class AnnotationParser {
      * Parses the annotations described by the passed byte array,
      * but returns Annotation[] so I don't have to do this in C.
      *
-     * @author Mathias Panzenböck
+     * @author Mathias Panzenboeck
      * 
      * @param rawAnnotations are the unparsed annotations
      * @param constPool is the constant pool of the declaring class
@@ -67,7 +67,7 @@ public class AnnotationParser {
     /**
      * Parses parameter annotations.
      * 
-     * @author Mathias Panzenböck
+     * @author Mathias Panzenboeck
      * 
      * @param parameterAnnotations are the unparsed parameter annotations
      * @param constPool is the constant pool of the declaring class
@@ -99,7 +99,7 @@ public class AnnotationParser {
      * This method is basically copied from OpenJDKs
      * java.lang.reflect.Method.getAnnotationDefault()
      * 
-     * @author Mathias Panzenböck
+     * @author Mathias Panzenboeck
      *
      * @param method represents the method for which the annotation default value has to be parsed
      * @param annotationDefault is the unparsed annotation default value
index ea559bbb99178b947377edabb31abc81bb1c6881..f80fe7f98d493c8447c8ae5d0fe9538fbb064fb3 100644 (file)
@@ -45,7 +45,7 @@ public class AnnotationType {
      * sun.misc.SharedSecrets.getJavaLangAccess().setAnnotationType() so
      * this class can be used with gnu classpath.
      *
-     * @author Mathias Panzenböck
+     * @author Mathias Panzenboeck
      */
     private static Map<Class, AnnotationType> annotationTypes =
         new HashMap<Class, AnnotationType>();
index 17ff86bff138c51a4f343156b8addb0a306903dd..fa43132510992dfacfdd557699f20738216957b8 100644 (file)
@@ -75,7 +75,7 @@
 #define __IEEE_BIG_ENDIAN
 #endif
 
-#ifdef __i386__
+#if defined(__i386__) || defined(__i386)
 #define __IEEE_LITTLE_ENDIAN
 #endif
 
index 22c39cec2ed77c989a22004cbf4b07976c250b7f..78ba758a196f5adfac2e806460f21703cdb2482e 100644 (file)
@@ -31,7 +31,7 @@ DIST_SUBDIRS = \
 
 if DISABLE_GC
 GC_FILE = \
-       nogc.c
+       gc-none.cpp
 endif
 
 if ENABLE_GC_BOEHM
@@ -39,7 +39,7 @@ SUBDIRS = \
        boehm-gc
 
 GC_FILE = \
-       boehm.c
+       gc-boehm.cpp
 
 GC_LIB = \
        $(top_builddir)/src/mm/boehm-gc/libgc.la
@@ -59,16 +59,21 @@ noinst_LTLIBRARIES = \
 libmm_la_SOURCES = \
        codememory.c \
        codememory.h \
-       dumpmemory.c \
-       dumpmemory.h \
+       dumpmemory.cpp \
+       dumpmemory.hpp \
        $(GC_FILE) \
-       gc-common.h \
+       gc.hpp \
        memory.c \
        memory.h
 
 libmm_la_LIBADD = \
        $(GC_LIB)
 
+if ENABLE_TLH
+libmm_la_SOURCES += \
+       tlh.h \
+       tlh.c
+endif
 
 ## Local variables:
 ## mode: Makefile
index 57207d792593e2d3a5488196a9958376e7e62fe5..cf83b26147f3d9bd6d6adaefbd4f0098221b3566 100644 (file)
 
 ## Process this file with automake to produce Makefile.in.
 
+ACLOCAL_AMFLAGS = -I m4
+
+DISTCLEANFILES = \
+       atomic_ops.c \
+       atomic_ops_sysdeps.S \
+       libatomic_ops
+
 ## FIXME: `make distcheck' in this directory will not currently work.
 ##     This is most likely to the explicit flags passed to submakes.
 
@@ -35,14 +42,16 @@ SUBDIRS =
 # Initialize variables so that we can declare files locally.
 EXTRA_DIST = 
 noinst_LTLIBRARIES =
-include_HEADERS =
-pkginclude_HEADERS =
+# Don't install include/gc
+#include_HEADERS =
+#pkginclude_HEADERS =
 dist_noinst_HEADERS =
 check_PROGRAMS =
 TESTS =
 
-pkgconfigdir = $(libdir)/pkgconfig
-dist_pkgconfig_DATA = bdw-gc.pc
+# Don't install pkg-config data.
+#pkgconfigdir = $(libdir)/pkgconfig
+#dist_pkgconfig_DATA = bdw-gc.pc
 
 # C Library
 # ---------
@@ -74,7 +83,7 @@ endif
 if USE_INTERNAL_LIBATOMIC_OPS   
 nodist_libgc_la_SOURCES = ./atomic_ops.c        
 endif   
-        
+
 if NEED_ATOMIC_OPS_ASM          
 nodist_libgc_la_SOURCES = ./atomic_ops_sysdeps.S        
 endif
@@ -96,7 +105,7 @@ EXTRA_libgc_la_SOURCES = alpha_mach_dep.S \
 
 if CPLUSPLUS
 noinst_LTLIBRARIES += libgccpp.la
-pkginclude_HEADERS += include/gc_cpp.h include/gc_allocator.h
+#pkginclude_HEADERS += include/gc_cpp.h include/gc_allocator.h
 libgccpp_la_SOURCES = gc_cpp.cc
 libgccpp_la_LIBADD = ./libgc.la
 libgccpp_la_LDFLAGS = -version-info 1:3:0 -no-undefined
@@ -189,7 +198,7 @@ CONFIG_STATUS_DEPENDENCIES = $(srcdir)/configure.host
 
 # :FIXME: why do we distribute this one???
 #
-EXTRA_DIST += libtool.m4
+#EXTRA_DIST += libtool.m4
 
 #
 # :GOTCHA: GNU make rule for making .s out of .S is flawed, 
diff --git a/src/mm/boehm-gc/autogen.sh b/src/mm/boehm-gc/autogen.sh
deleted file mode 100755 (executable)
index fe66cc0..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-${CACAO_LIBTOOLIZE} --automake
-if test `uname` = 'FreeBSD'; then
-    ${CACAO_ACLOCAL} -I . -I /usr/local/share/aclocal -I /usr/local/share/aclocal19
-else
-    ${CACAO_ACLOCAL}
-fi
-${CACAO_AUTOHEADER}
-${CACAO_AUTOMAKE} --add-missing
-${CACAO_AUTOCONF}
-
-(cd libatomic_ops-1.2; ./autogen.sh)
index 7e5d530f71bfd9416d540a960037342d94694dd6..5ab3d30afd95b7824d35cb6f2aa52b091b504d45 100644 (file)
@@ -35,11 +35,6 @@ AC_SUBST(GC_VERSION)
 AM_PROG_CC_C_O
 AC_PROG_CXX
 
-dnl temporary set the CFLAGS for configure tests (e.g. inline keyword)
-dnl we set it properly later in this file
-CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
-AC_C_INLINE
-
 AM_PROG_AS
 ## FIXME: really needed? (AC_LIBTOOL already provides this)
 AC_CHECK_TOOL(AR, ar)
@@ -500,15 +495,6 @@ case "$host" in
  *) AC_MSG_RESULT(no) ;;
 esac
 
-dnl We need to override the top-level CFLAGS.  This is how we do it.
-dnl MY_CFLAGS="$CFLAGS"
-dnl AC_SUBST(MY_CFLAGS)
-
-dnl pass CFLAGS to Makefiles via AM_CFLAGS
-CFLAGS=$OPT_CFLAGS
-AM_CFLAGS=$ARCH_CFLAGS
-AC_SUBST(AM_CFLAGS)
-
 dnl Include defines that have become de facto standard.
 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
 AC_DEFINE([NO_EXECUTE_PERMISSION], 1, [no exceute permission])
index 1dab4c214cc789b75b4e80ade73ef2f56750f505..19a6571058bb76ca49207b366a4c324b2a3d4b9e 100644 (file)
@@ -242,11 +242,6 @@ GC_API unsigned long GC_time_limit;
  */
 GC_API void GC_init(void);
 
-/* Added for cacao */
-int GC_signum1();   
-int GC_signum2();   
-/* cacao END */
-
 /*
  * general purpose allocation routines, with roughly malloc calling conv.
  * The atomic versions promise that no relevant pointers are contained
index 991a07990ff756fa76ad26399e836de6ec439650..a27aab074987a9c62c342e521d9d551d5660e723 100644 (file)
@@ -55,6 +55,7 @@ dist_noinst_HEADERS += \
        include/javaxfc.h 
 
 # unprefixed header
-include_HEADERS += \
+#include_HEADERS += \
+dist_noinst_HEADERS += \
         include/extra/gc.h \
         include/extra/gc_cpp.h
index 8e77c48a860031ff15eb5433abaf04caa767e8e5..e1377ac088e223ea88e3ab0d3a26db54201b9902 100644 (file)
 #    define SEQUENT
 #    define mach_type_known
 # endif
-# if defined(sun) && (defined(i386) || defined(__i386__))
+# if (defined(sun) || defined(__sun)) && (defined(i386) || defined(__i386__))
 #    define I386
 #    define SOLARIS
 #    define mach_type_known
 # endif
-# if defined(sun) && defined(__amd64)
+# if (defined(sun) || defined(__sun)) && defined(__amd64)
 #    define X86_64
 #    define SOLARIS
 #    define mach_type_known
 #     define DYNAMIC_LOADING
       extern int _end[];
 #     define DATAEND (_end)
-      extern int __data_start[];
-#     define DATASTART ((ptr_t)(__data_start))
+#     define SEARCH_FOR_DATA_START
 #     define CPP_WORDSZ _MIPS_SZPTR
 #     define ALIGNMENT (_MIPS_SZPTR/8)
 #     if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
 #       define OS_TYPE "LINUX"
 #       define LINUX_STACKBOTTOM
 #       define DYNAMIC_LOADING
-       extern int __data_start[];
-#       define DATASTART ((ptr_t)(__data_start))
-    extern int _end[];
+#       define SEARCH_FOR_DATA_START
+        extern int _end[];
 #   define DATAEND (_end)
 #   define CACHE_LINE_SIZE 256
 #   define GETPAGESIZE() 4096
diff --git a/src/mm/boehm-gc/libatomic_ops-1.2/autogen.sh b/src/mm/boehm-gc/libatomic_ops-1.2/autogen.sh
deleted file mode 100755 (executable)
index 4b78526..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-if test `uname` = 'FreeBSD'; then
-    ${CACAO_ACLOCAL} -I . -I /usr/local/share/aclocal -I /usr/local/share/aclocal19
-else
-    ${CACAO_ACLOCAL}
-fi
-${CACAO_AUTOHEADER}
-${CACAO_AUTOMAKE} --add-missing
-${CACAO_AUTOCONF}
index ce212d08ae7fd5c5ed80312f9064be05175e1bcf..09756e71cd073be249a1944d5b70eacc03622050 100644 (file)
@@ -1,3 +1,4 @@
 # installed documentation
 #
-dist_pkgdata_DATA=COPYING LICENSING.txt README.txt COPYING README_stack.txt README_malloc.txt README_win32.txt
+#dist_pkgdata_DATA=COPYING LICENSING.txt README.txt COPYING README_stack.txt README_malloc.txt README_win32.txt
+dist_noinst_DATA=COPYING LICENSING.txt README.txt COPYING README_stack.txt README_malloc.txt README_win32.txt
diff --git a/src/mm/boehm-gc/libatomic_ops-1.2/mkinstalldirs b/src/mm/boehm-gc/libatomic_ops-1.2/mkinstalldirs
deleted file mode 100755 (executable)
index 259dbfc..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-#! /bin/sh
-# mkinstalldirs --- make directory hierarchy
-
-scriptversion=2005-06-29.22
-
-# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
-# Created: 1993-05-16
-# Public domain.
-#
-# This file is maintained in Automake, please report
-# bugs to <bug-automake@gnu.org> or send patches to
-# <automake-patches@gnu.org>.
-
-errstatus=0
-dirmode=
-
-usage="\
-Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
-
-Create each directory DIR (with mode MODE, if specified), including all
-leading file name components.
-
-Report bugs to <bug-automake@gnu.org>."
-
-# process command line arguments
-while test $# -gt 0 ; do
-  case $1 in
-    -h | --help | --h*)         # -h for help
-      echo "$usage"
-      exit $?
-      ;;
-    -m)                         # -m PERM arg
-      shift
-      test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
-      dirmode=$1
-      shift
-      ;;
-    --version)
-      echo "$0 $scriptversion"
-      exit $?
-      ;;
-    --)                         # stop option processing
-      shift
-      break
-      ;;
-    -*)                         # unknown option
-      echo "$usage" 1>&2
-      exit 1
-      ;;
-    *)                          # first non-opt arg
-      break
-      ;;
-  esac
-done
-
-for file
-do
-  if test -d "$file"; then
-    shift
-  else
-    break
-  fi
-done
-
-case $# in
-  0) exit 0 ;;
-esac
-
-# Solaris 8's mkdir -p isn't thread-safe.  If you mkdir -p a/b and
-# mkdir -p a/c at the same time, both will detect that a is missing,
-# one will create a, then the other will try to create a and die with
-# a "File exists" error.  This is a problem when calling mkinstalldirs
-# from a parallel make.  We use --version in the probe to restrict
-# ourselves to GNU mkdir, which is thread-safe.
-case $dirmode in
-  '')
-    if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
-      echo "mkdir -p -- $*"
-      exec mkdir -p -- "$@"
-    else
-      # On NextStep and OpenStep, the `mkdir' command does not
-      # recognize any option.  It will interpret all options as
-      # directories to create, and then abort because `.' already
-      # exists.
-      test -d ./-p && rmdir ./-p
-      test -d ./--version && rmdir ./--version
-    fi
-    ;;
-  *)
-    if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
-       test ! -d ./--version; then
-      echo "mkdir -m $dirmode -p -- $*"
-      exec mkdir -m "$dirmode" -p -- "$@"
-    else
-      # Clean up after NextStep and OpenStep mkdir.
-      for d in ./-m ./-p ./--version "./$dirmode";
-      do
-        test -d $d && rmdir $d
-      done
-    fi
-    ;;
-esac
-
-for file
-do
-  case $file in
-    /*) pathcomp=/ ;;
-    *)  pathcomp= ;;
-  esac
-  oIFS=$IFS
-  IFS=/
-  set fnord $file
-  shift
-  IFS=$oIFS
-
-  for d
-  do
-    test "x$d" = x && continue
-
-    pathcomp=$pathcomp$d
-    case $pathcomp in
-      -*) pathcomp=./$pathcomp ;;
-    esac
-
-    if test ! -d "$pathcomp"; then
-      echo "mkdir $pathcomp"
-
-      mkdir "$pathcomp" || lasterr=$?
-
-      if test ! -d "$pathcomp"; then
-       errstatus=$lasterr
-      else
-       if test ! -z "$dirmode"; then
-         echo "chmod $dirmode $pathcomp"
-         lasterr=
-         chmod "$dirmode" "$pathcomp" || lasterr=$?
-
-         if test ! -z "$lasterr"; then
-           errstatus=$lasterr
-         fi
-       fi
-      fi
-    fi
-
-    pathcomp=$pathcomp/
-  done
-done
-
-exit $errstatus
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
index 7ca41ff1161381dd4080a345d86ee9eaa1602d6e..be1adf9fe335778bca4dee3cc27bf8a5d62e100a 100644 (file)
@@ -2,8 +2,10 @@ SUBDIRS=atomic_ops
 
 AM_CFLAGS=@PICFLAG@
 
-include_HEADERS=atomic_ops.h atomic_ops_stack.h atomic_ops_malloc.h
-lib_LIBRARIES = libatomic_ops.a libatomic_ops_gpl.a
+#include_HEADERS=atomic_ops.h atomic_ops_stack.h atomic_ops_malloc.h
+noinst_HEADERS=atomic_ops.h atomic_ops_stack.h atomic_ops_malloc.h
+#lib_LIBRARIES = libatomic_ops.a libatomic_ops_gpl.a
+noinst_LIBRARIES = libatomic_ops.a libatomic_ops_gpl.a
 if NEED_ASM
 libatomic_ops_a_SOURCES = atomic_ops.c atomic_ops_sysdeps.S
 else
index 8000273f28610a9e1ffe90484b690fe96e4428eb..67148e79e82db1af433362e7ad243be372937635 100644 (file)
@@ -3,7 +3,8 @@ SUBDIRS=sysdeps
 EXTRA_DIST=generalize-small.template
 
 #Private Headers
-private_HEADERS=generalize.h generalize-small.h
+#private_HEADERS=generalize.h generalize-small.h
+noinst_HEADERS=generalize.h generalize-small.h
 privatedir=${includedir}/atomic_ops/
 
 generalize-small.h: generalize-small.template
index f47f8120c9025580c9b67cece4547e2765c06140..ceed063efefc73bf88f5461b9bcbbf7351a58d9f 100644 (file)
@@ -1,5 +1,6 @@
 #General sysdep utility headers, followed by the arch-specific ones
-nobase_sysdep_HEADERS= generic_pthread.h \
+#nobase_sysdep_HEADERS= generic_pthread.h \
+noinst_HEADERS= generic_pthread.h \
          atomic_load_store.h \
          aligned_atomic_load_store.h \
          acquire_release_volatile.h \
index bc280ebd2a176d59712eeb5d804e67985f8010a2..c9970ab3626951dd65a3a41b15c3438aec4c4b8f 100644 (file)
@@ -5,15 +5,6 @@
  * see doc/COPYING for details.
  */
 
-void test_atomic(void);
-void test_atomic_release(void);
-void test_atomic_acquire(void);
-void test_atomic_read(void);
-void test_atomic_write(void);
-void test_atomic_full(void);
-void test_atomic_release_write(void);
-void test_atomic_acquire_read(void);
-
 /* Some basic sanity tests.  These do not test the barrier semantics. */
 
 #undef TA_assert
diff --git a/src/mm/boehm-gc/libtool.m4 b/src/mm/boehm-gc/libtool.m4
deleted file mode 100644 (file)
index 0f53cb5..0000000
+++ /dev/null
@@ -1,6397 +0,0 @@
-# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
-## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
-## Free Software Foundation, Inc.
-## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
-##
-## This file is free software; the Free Software Foundation gives
-## unlimited permission to copy and/or distribute it, with or without
-## modifications, as long as this notice is preserved.
-
-# serial 48 AC_PROG_LIBTOOL
-
-
-# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
-# -----------------------------------------------------------
-# If this macro is not defined by Autoconf, define it here.
-m4_ifdef([AC_PROVIDE_IFELSE],
-         [],
-         [m4_define([AC_PROVIDE_IFELSE],
-                [m4_ifdef([AC_PROVIDE_$1],
-                          [$2], [$3])])])
-
-
-# AC_PROG_LIBTOOL
-# ---------------
-AC_DEFUN([AC_PROG_LIBTOOL],
-[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
-dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
-dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
-  AC_PROVIDE_IFELSE([AC_PROG_CXX],
-    [AC_LIBTOOL_CXX],
-    [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
-  ])])
-dnl And a similar setup for Fortran 77 support
-  AC_PROVIDE_IFELSE([AC_PROG_F77],
-    [AC_LIBTOOL_F77],
-    [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
-])])
-
-dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
-dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
-dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
-  AC_PROVIDE_IFELSE([AC_PROG_GCJ],
-    [AC_LIBTOOL_GCJ],
-    [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
-      [AC_LIBTOOL_GCJ],
-      [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
-       [AC_LIBTOOL_GCJ],
-      [ifdef([AC_PROG_GCJ],
-            [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
-       ifdef([A][M_PROG_GCJ],
-            [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
-       ifdef([LT_AC_PROG_GCJ],
-            [define([LT_AC_PROG_GCJ],
-               defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
-])])# AC_PROG_LIBTOOL
-
-
-# _AC_PROG_LIBTOOL
-# ----------------
-AC_DEFUN([_AC_PROG_LIBTOOL],
-[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
-
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
-
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-AC_SUBST(LIBTOOL)dnl
-
-# Prevent multiple expansion
-define([AC_PROG_LIBTOOL], [])
-])# _AC_PROG_LIBTOOL
-
-
-# AC_LIBTOOL_SETUP
-# ----------------
-AC_DEFUN([AC_LIBTOOL_SETUP],
-[AC_PREREQ(2.50)dnl
-AC_REQUIRE([AC_ENABLE_SHARED])dnl
-AC_REQUIRE([AC_ENABLE_STATIC])dnl
-AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_PROG_LD])dnl
-AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
-AC_REQUIRE([AC_PROG_NM])dnl
-
-AC_REQUIRE([AC_PROG_LN_S])dnl
-AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
-AC_REQUIRE([AC_OBJEXT])dnl
-AC_REQUIRE([AC_EXEEXT])dnl
-dnl
-
-AC_LIBTOOL_SYS_MAX_CMD_LEN
-AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-AC_LIBTOOL_OBJDIR
-
-AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-_LT_AC_PROG_ECHO_BACKSLASH
-
-case $host_os in
-aix3*)
-  # AIX sometimes has problems with the GCC collect2 program.  For some
-  # reason, if we set the COLLECT_NAMES environment variable, the problems
-  # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
-    COLLECT_NAMES=
-    export COLLECT_NAMES
-  fi
-  ;;
-esac
-
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
-[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
-
-# Same as above, but do not quote variable references.
-[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-
-# Constants:
-rm="rm -f"
-
-# Global variables:
-default_ofile=libtool
-can_build_shared=yes
-
-# All known linkers require a `.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
-ltmain="$ac_aux_dir/ltmain.sh"
-ofile="$default_ofile"
-with_gnu_ld="$lt_cv_prog_gnu_ld"
-
-AC_CHECK_TOOL(AR, ar, false)
-AC_CHECK_TOOL(RANLIB, ranlib, :)
-AC_CHECK_TOOL(STRIP, strip, :)
-
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
-
-# Set sane defaults for various variables
-test -z "$AR" && AR=ar
-test -z "$AR_FLAGS" && AR_FLAGS=cru
-test -z "$AS" && AS=as
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-test -z "$LD" && LD=ld
-test -z "$LN_S" && LN_S="ln -s"
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-test -z "$NM" && NM=nm
-test -z "$SED" && SED=sed
-test -z "$OBJDUMP" && OBJDUMP=objdump
-test -z "$RANLIB" && RANLIB=:
-test -z "$STRIP" && STRIP=:
-test -z "$ac_objext" && ac_objext=o
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-if test -n "$RANLIB"; then
-  case $host_os in
-  openbsd*)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
-    ;;
-  *)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
-    ;;
-  esac
-  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
-fi
-
-_LT_CC_BASENAME([$compiler])
-
-# Only perform the check for file, if the check method requires it
-case $deplibs_check_method in
-file_magic*)
-  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
-    AC_PATH_MAGIC
-  fi
-  ;;
-esac
-
-AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
-enable_win32_dll=yes, enable_win32_dll=no)
-
-AC_ARG_ENABLE([libtool-lock],
-    [AC_HELP_STRING([--disable-libtool-lock],
-       [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-AC_ARG_WITH([pic],
-    [AC_HELP_STRING([--with-pic],
-       [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
-    [pic_mode="$withval"],
-    [pic_mode=default])
-test -z "$pic_mode" && pic_mode=default
-
-# Use C for the default configuration in the libtool script
-tagname=
-AC_LIBTOOL_LANG_C_CONFIG
-_LT_AC_TAGCONFIG
-])# AC_LIBTOOL_SETUP
-
-
-# _LT_AC_SYS_COMPILER
-# -------------------
-AC_DEFUN([_LT_AC_SYS_COMPILER],
-[AC_REQUIRE([AC_PROG_CC])dnl
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-])# _LT_AC_SYS_COMPILER
-
-
-# _LT_CC_BASENAME(CC)
-# -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
-AC_DEFUN([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-])
-
-
-# _LT_COMPILER_BOILERPLATE
-# ------------------------
-# Check for compiler boilerplate output or warnings with
-# the simple compiler test code.
-AC_DEFUN([_LT_COMPILER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_COMPILER_BOILERPLATE
-
-
-# _LT_LINKER_BOILERPLATE
-# ----------------------
-# Check for linker boilerplate output or warnings with
-# the simple link test code.
-AC_DEFUN([_LT_LINKER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_LINKER_BOILERPLATE
-
-
-# _LT_AC_SYS_LIBPATH_AIX
-# ----------------------
-# Links a minimal program and checks the executable
-# for the system default hardcoded library path. In most cases,
-# this is /usr/lib:/lib, but when the MPI compilers are used
-# the location of the communication and MPI libs are included too.
-# If we don't find anything, use the default library path according
-# to the aix ld manual.
-AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
-[AC_LINK_IFELSE(AC_LANG_PROGRAM,[
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi],[])
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-])# _LT_AC_SYS_LIBPATH_AIX
-
-
-# _LT_AC_SHELL_INIT(ARG)
-# ----------------------
-AC_DEFUN([_LT_AC_SHELL_INIT],
-[ifdef([AC_DIVERSION_NOTICE],
-            [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
-        [AC_DIVERT_PUSH(NOTICE)])
-$1
-AC_DIVERT_POP
-])# _LT_AC_SHELL_INIT
-
-
-# _LT_AC_PROG_ECHO_BACKSLASH
-# --------------------------
-# Add some code to the start of the generated configure script which
-# will find an echo command which doesn't interpret backslashes.
-AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
-[_LT_AC_SHELL_INIT([
-# Check that we are running under the correct shell.
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-case X$ECHO in
-X*--fallback-echo)
-  # Remove one level of quotation (which was required for Make).
-  ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
-  ;;
-esac
-
-echo=${ECHO-echo}
-if test "X[$]1" = X--no-reexec; then
-  # Discard the --no-reexec flag, and continue.
-  shift
-elif test "X[$]1" = X--fallback-echo; then
-  # Avoid inline document here, it may be left over
-  :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
-  # Yippee, $echo works!
-  :
-else
-  # Restart under the correct shell.
-  exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
-fi
-
-if test "X[$]1" = X--fallback-echo; then
-  # used as fallback echo
-  shift
-  cat <<EOF
-[$]*
-EOF
-  exit 0
-fi
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test -z "$ECHO"; then
-if test "X${echo_test_string+set}" != Xset; then
-# find a string as large as possible, as long as the shell can cope with it
-  for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
-    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
-    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
-       echo_test_string=`eval $cmd` &&
-       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
-    then
-      break
-    fi
-  done
-fi
-
-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
-   echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
-   test "X$echo_testing_string" = "X$echo_test_string"; then
-  :
-else
-  # The Solaris, AIX, and Digital Unix default echo programs unquote
-  # backslashes.  This makes it impossible to quote backslashes using
-  #   echo "$something" | sed 's/\\/\\\\/g'
-  #
-  # So, first we look for a working echo in the user's PATH.
-
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for dir in $PATH /usr/ucb; do
-    IFS="$lt_save_ifs"
-    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
-       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
-       echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
-       test "X$echo_testing_string" = "X$echo_test_string"; then
-      echo="$dir/echo"
-      break
-    fi
-  done
-  IFS="$lt_save_ifs"
-
-  if test "X$echo" = Xecho; then
-    # We didn't find a better echo, so look for alternatives.
-    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
-       echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
-       test "X$echo_testing_string" = "X$echo_test_string"; then
-      # This shell has a builtin print -r that does the trick.
-      echo='print -r'
-    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
-        test "X$CONFIG_SHELL" != X/bin/ksh; then
-      # If we have ksh, try running configure again with it.
-      ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
-      export ORIGINAL_CONFIG_SHELL
-      CONFIG_SHELL=/bin/ksh
-      export CONFIG_SHELL
-      exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
-    else
-      # Try using printf.
-      echo='printf %s\n'
-      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
-        echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
-        test "X$echo_testing_string" = "X$echo_test_string"; then
-       # Cool, printf works
-       :
-      elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
-          test "X$echo_testing_string" = 'X\t' &&
-          echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
-          test "X$echo_testing_string" = "X$echo_test_string"; then
-       CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
-       export CONFIG_SHELL
-       SHELL="$CONFIG_SHELL"
-       export SHELL
-       echo="$CONFIG_SHELL [$]0 --fallback-echo"
-      elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
-          test "X$echo_testing_string" = 'X\t' &&
-          echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
-          test "X$echo_testing_string" = "X$echo_test_string"; then
-       echo="$CONFIG_SHELL [$]0 --fallback-echo"
-      else
-       # maybe with a smaller string...
-       prev=:
-
-       for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
-         if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
-         then
-           break
-         fi
-         prev="$cmd"
-       done
-
-       if test "$prev" != 'sed 50q "[$]0"'; then
-         echo_test_string=`eval $prev`
-         export echo_test_string
-         exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
-       else
-         # Oops.  We lost completely, so just stick with echo.
-         echo=echo
-       fi
-      fi
-    fi
-  fi
-fi
-fi
-
-# Copy echo and quote the copy suitably for passing to libtool from
-# the Makefile, instead of quoting the original, which is used later.
-ECHO=$echo
-if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
-   ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
-fi
-
-AC_SUBST(ECHO)
-])])# _LT_AC_PROG_ECHO_BACKSLASH
-
-
-# _LT_AC_LOCK
-# -----------
-AC_DEFUN([_LT_AC_LOCK],
-[AC_ARG_ENABLE([libtool-lock],
-    [AC_HELP_STRING([--disable-libtool-lock],
-       [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.$ac_objext` in
-    *ELF-32*)
-      HPUX_IA64_MODE="32"
-      ;;
-    *ELF-64*)
-      HPUX_IA64_MODE="64"
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-*-*-irix6*)
-  # Find out which ABI we are using.
-  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-   if test "$lt_cv_prog_gnu_ld" = yes; then
-    case `/usr/bin/file conftest.$ac_objext` in
-    *32-bit*)
-      LD="${LD-ld} -melf32bsmip"
-      ;;
-    *N32*)
-      LD="${LD-ld} -melf32bmipn32"
-      ;;
-    *64-bit*)
-      LD="${LD-ld} -melf64bmip"
-      ;;
-    esac
-   else
-    case `/usr/bin/file conftest.$ac_objext` in
-    *32-bit*)
-      LD="${LD-ld} -32"
-      ;;
-    *N32*)
-      LD="${LD-ld} -n32"
-      ;;
-    *64-bit*)
-      LD="${LD-ld} -64"
-      ;;
-    esac
-   fi
-  fi
-  rm -rf conftest*
-  ;;
-
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.o` in
-    *32-bit*)
-      case $host in
-        x86_64-*linux*)
-          LD="${LD-ld} -m elf_i386"
-          ;;
-        ppc64-*linux*|powerpc64-*linux*)
-          LD="${LD-ld} -m elf32ppclinux"
-          ;;
-        s390x-*linux*)
-          LD="${LD-ld} -m elf_s390"
-          ;;
-        sparc64-*linux*)
-          LD="${LD-ld} -m elf32_sparc"
-          ;;
-      esac
-      ;;
-    *64-bit*)
-      case $host in
-        x86_64-*linux*)
-          LD="${LD-ld} -m elf_x86_64"
-          ;;
-        ppc*-*linux*|powerpc*-*linux*)
-          LD="${LD-ld} -m elf64ppc"
-          ;;
-        s390*-*linux*)
-          LD="${LD-ld} -m elf64_s390"
-          ;;
-        sparc*-*linux*)
-          LD="${LD-ld} -m elf64_sparc"
-          ;;
-      esac
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-
-*-*-sco3.2v5*)
-  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -belf"
-  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
-    [AC_LANG_PUSH(C)
-     AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
-     AC_LANG_POP])
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
-    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
-  fi
-  ;;
-sparc*-*solaris*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.o` in
-    *64-bit*)
-      case $lt_cv_prog_gnu_ld in
-      yes*) LD="${LD-ld} -m elf64_sparc" ;;
-      *)    LD="${LD-ld} -64" ;;
-      esac
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-
-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
-[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
-  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
-  AC_CHECK_TOOL(AS, as, false)
-  AC_CHECK_TOOL(OBJDUMP, objdump, false)
-  ;;
-  ])
-esac
-
-need_locks="$enable_libtool_lock"
-
-])# _LT_AC_LOCK
-
-
-# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-#              [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
-# ----------------------------------------------------------------
-# Check whether the given compiler option works
-AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
-[AC_REQUIRE([LT_AC_PROG_SED])
-AC_CACHE_CHECK([$1], [$2],
-  [$2=no
-  ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$3"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&AS_MESSAGE_LOG_FD
-   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       $2=yes
-     fi
-   fi
-   $rm conftest*
-])
-
-if test x"[$]$2" = xyes; then
-    ifelse([$5], , :, [$5])
-else
-    ifelse([$6], , :, [$6])
-fi
-])# AC_LIBTOOL_COMPILER_OPTION
-
-
-# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-#                          [ACTION-SUCCESS], [ACTION-FAILURE])
-# ------------------------------------------------------------
-# Check whether the given compiler option works
-AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
-[AC_CACHE_CHECK([$1], [$2],
-  [$2=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $3"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&AS_MESSAGE_LOG_FD
-       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         $2=yes
-       fi
-     else
-       $2=yes
-     fi
-   fi
-   $rm conftest*
-   LDFLAGS="$save_LDFLAGS"
-])
-
-if test x"[$]$2" = xyes; then
-    ifelse([$4], , :, [$4])
-else
-    ifelse([$5], , :, [$5])
-fi
-])# AC_LIBTOOL_LINKER_OPTION
-
-
-# AC_LIBTOOL_SYS_MAX_CMD_LEN
-# --------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
-[# find the maximum length of command line arguments
-AC_MSG_CHECKING([the maximum length of command line arguments])
-AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
-  i=0
-  teststring="ABCD"
-
-  case $build_os in
-  msdosdjgpp*)
-    # On DJGPP, this test can blow up pretty badly due to problems in libc
-    # (any single argument exceeding 2000 bytes causes a buffer overrun
-    # during glob expansion).  Even if it were fixed, the result of this
-    # check would be larger than it should be.
-    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
-    ;;
-
-  gnu*)
-    # Under GNU Hurd, this test is not required because there is
-    # no limit to the length of command line arguments.
-    # Libtool will interpret -1 as no limit whatsoever
-    lt_cv_sys_max_cmd_len=-1;
-    ;;
-
-  cygwin* | mingw*)
-    # On Win9x/ME, this test blows up -- it succeeds, but takes
-    # about 5 minutes as the teststring grows exponentially.
-    # Worse, since 9x/ME are not pre-emptively multitasking,
-    # you end up with a "frozen" computer, even though with patience
-    # the test eventually succeeds (with a max line length of 256k).
-    # Instead, let's just punt: use the minimum linelength reported by
-    # all of the supported platforms: 8192 (on NT/2K/XP).
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
-
-  amigaos*)
-    # On AmigaOS with pdksh, this test takes hours, literally.
-    # So we just punt and use a minimum line length of 8192.
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
-
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
-    # This has been around since 386BSD, at least.  Likely further.
-    if test -x /sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
-    elif test -x /usr/sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
-    else
-      lt_cv_sys_max_cmd_len=65536      # usable default for all BSDs
-    fi
-    # And add a safety zone
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    ;;
-
-  interix*)
-    # We know the value 262144 and hardcode it with a safety zone (like BSD)
-    lt_cv_sys_max_cmd_len=196608
-    ;;
-
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    #
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  sco3.2v5*)
-    lt_cv_sys_max_cmd_len=102400
-    ;;
-  sysv5* | sco5v6* | sysv4.2uw2*)
-    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
-    if test -n "$kargmax"; then
-      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[       ]]//'`
-    else
-      lt_cv_sys_max_cmd_len=32768
-    fi
-    ;;
-  *)
-    # If test is not a shell built-in, we'll probably end up computing a
-    # maximum length that is only half of the actual maximum length, but
-    # we can't tell.
-    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-    while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
-              = "XX$teststring") >/dev/null 2>&1 &&
-           new_result=`expr "X$teststring" : ".*" 2>&1` &&
-           lt_cv_sys_max_cmd_len=$new_result &&
-           test $i != 17 # 1/2 MB should be enough
-    do
-      i=`expr $i + 1`
-      teststring=$teststring$teststring
-    done
-    teststring=
-    # Add a significant safety factor because C++ compilers can tack on massive
-    # amounts of additional arguments before passing them to the linker.
-    # It appears as though 1/2 is a usable value.
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
-    ;;
-  esac
-])
-if test -n $lt_cv_sys_max_cmd_len ; then
-  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
-else
-  AC_MSG_RESULT(none)
-fi
-])# AC_LIBTOOL_SYS_MAX_CMD_LEN
-
-
-# _LT_AC_CHECK_DLFCN
-# ------------------
-AC_DEFUN([_LT_AC_CHECK_DLFCN],
-[AC_CHECK_HEADERS(dlfcn.h)dnl
-])# _LT_AC_CHECK_DLFCN
-
-
-# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
-#                           ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
-# ---------------------------------------------------------------------
-AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
-  [$4]
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<EOF
-[#line __oline__ "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL          RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL                DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL                0
-#  endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW         DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW       RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW     DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW     0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
-
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
-      /* dlclose (self); */
-    }
-  else
-    puts (dlerror ());
-
-    exit (status);
-}]
-EOF
-  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
-    lt_status=$?
-    case x$lt_status in
-      x$lt_dlno_uscore) $1 ;;
-      x$lt_dlneed_uscore) $2 ;;
-      x$lt_dlunknown|x*) $3 ;;
-    esac
-  else :
-    # compilation failed
-    $3
-  fi
-fi
-rm -fr conftest*
-])# _LT_AC_TRY_DLOPEN_SELF
-
-
-# AC_LIBTOOL_DLOPEN_SELF
-# ----------------------
-AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
-  enable_dlopen=unknown
-  enable_dlopen_self=unknown
-  enable_dlopen_self_static=unknown
-else
-  lt_cv_dlopen=no
-  lt_cv_dlopen_libs=
-
-  case $host_os in
-  beos*)
-    lt_cv_dlopen="load_add_on"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-    ;;
-
-  mingw* | pw32*)
-    lt_cv_dlopen="LoadLibrary"
-    lt_cv_dlopen_libs=
-   ;;
-
-  cygwin*)
-    lt_cv_dlopen="dlopen"
-    lt_cv_dlopen_libs=
-   ;;
-
-  darwin*)
-  # if libdl is installed we need to link against it
-    AC_CHECK_LIB([dl], [dlopen],
-               [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
-    lt_cv_dlopen="dyld"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-    ])
-   ;;
-
-  *)
-    AC_CHECK_FUNC([shl_load],
-         [lt_cv_dlopen="shl_load"],
-      [AC_CHECK_LIB([dld], [shl_load],
-           [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
-       [AC_CHECK_FUNC([dlopen],
-             [lt_cv_dlopen="dlopen"],
-         [AC_CHECK_LIB([dl], [dlopen],
-               [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
-           [AC_CHECK_LIB([svld], [dlopen],
-                 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
-             [AC_CHECK_LIB([dld], [dld_link],
-                   [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
-             ])
-           ])
-         ])
-       ])
-      ])
-    ;;
-  esac
-
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
-    enable_dlopen=no
-  fi
-
-  case $lt_cv_dlopen in
-  dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
-    save_LDFLAGS="$LDFLAGS"
-    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
-    save_LIBS="$LIBS"
-    LIBS="$lt_cv_dlopen_libs $LIBS"
-
-    AC_CACHE_CHECK([whether a program can dlopen itself],
-         lt_cv_dlopen_self, [dnl
-         _LT_AC_TRY_DLOPEN_SELF(
-           lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
-           lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
-    ])
-
-    if test "x$lt_cv_dlopen_self" = xyes; then
-      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
-      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
-         lt_cv_dlopen_self_static, [dnl
-         _LT_AC_TRY_DLOPEN_SELF(
-           lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
-           lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
-      ])
-    fi
-
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
-    ;;
-  esac
-
-  case $lt_cv_dlopen_self in
-  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
-  *) enable_dlopen_self=unknown ;;
-  esac
-
-  case $lt_cv_dlopen_self_static in
-  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
-  *) enable_dlopen_self_static=unknown ;;
-  esac
-fi
-])# AC_LIBTOOL_DLOPEN_SELF
-
-
-# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
-# ---------------------------------
-# Check to see if options -c and -o are simultaneously supported by compiler
-AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
-  [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
-  [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
-   $rm -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&AS_MESSAGE_LOG_FD
-   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
-     fi
-   fi
-   chmod u+w . 2>&AS_MESSAGE_LOG_FD
-   $rm conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
-   $rm out/* && rmdir out
-   cd ..
-   rmdir conftest
-   $rm conftest*
-])
-])# AC_LIBTOOL_PROG_CC_C_O
-
-
-# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
-# -----------------------------------------
-# Check to see if we can do hard links to lock some files if needed
-AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
-[AC_REQUIRE([_LT_AC_LOCK])dnl
-
-hard_links="nottested"
-if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  AC_MSG_CHECKING([if we can lock with hard links])
-  hard_links=yes
-  $rm conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  AC_MSG_RESULT([$hard_links])
-  if test "$hard_links" = no; then
-    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
-])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
-
-
-# AC_LIBTOOL_OBJDIR
-# -----------------
-AC_DEFUN([AC_LIBTOOL_OBJDIR],
-[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
-[rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
-  lt_cv_objdir=.libs
-else
-  # MS-DOS does not allow filenames that begin with a dot.
-  lt_cv_objdir=_libs
-fi
-rmdir .libs 2>/dev/null])
-objdir=$lt_cv_objdir
-])# AC_LIBTOOL_OBJDIR
-
-
-# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
-# ----------------------------------------------
-# Check hardcoding attributes.
-AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
-[AC_MSG_CHECKING([how to hardcode library paths into programs])
-_LT_AC_TAGVAR(hardcode_action, $1)=
-if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
-   test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
-   test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
-
-  # We can hardcode non-existant directories.
-  if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
-     test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
-    # Linking always hardcodes the temporary library directory.
-    _LT_AC_TAGVAR(hardcode_action, $1)=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    _LT_AC_TAGVAR(hardcode_action, $1)=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
-fi
-AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
-
-if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
-])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
-
-
-# AC_LIBTOOL_SYS_LIB_STRIP
-# ------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
-[striplib=
-old_striplib=
-AC_MSG_CHECKING([whether stripping libraries is possible])
-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
-  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
-  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
-  AC_MSG_RESULT([yes])
-else
-# FIXME - insert some real tests, host_os isn't really good enough
-  case $host_os in
-   darwin*)
-       if test -n "$STRIP" ; then
-         striplib="$STRIP -x"
-         AC_MSG_RESULT([yes])
-       else
-  AC_MSG_RESULT([no])
-fi
-       ;;
-   *)
-  AC_MSG_RESULT([no])
-    ;;
-  esac
-fi
-])# AC_LIBTOOL_SYS_LIB_STRIP
-
-
-# AC_LIBTOOL_SYS_DYNAMIC_LINKER
-# -----------------------------
-# PORTME Fill in your ld.so characteristics
-AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
-[AC_MSG_CHECKING([dynamic linker characteristics])
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
-  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-  else
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-  fi
-else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
-
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
-
-aix4* | aix5*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[[01]] | aix4.[[01]].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-          echo ' yes '
-          echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
-       :
-      else
-       can_build_shared=no
-      fi
-      ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
-
-amigaos*)
-  library_names_spec='$libname.ixlibrary $libname.a'
-  # Create ${libname}_ixlibrary.a entries in /sys/libs.
-  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-  ;;
-
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
-
-bsdi[[45]]*)
-  version_type=linux
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
-
-cygwin* | mingw* | pw32*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
-
-  case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32*)
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $rm \$dlpath'
-    shlibpath_overrides_runpath=yes
-
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
-      ;;
-    mingw*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-      if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
-        # It is most probably a Windows format PATH printed by
-        # mingw gcc, but we are running on Cygwin. Gcc prints its search
-        # path with ; separators, and with drive letters. We can handle the
-        # drive letters (cygwin fileutils understands them), so leave them,
-        # especially as we might pass files found there to a mingw objdump,
-        # which wouldn't understand a cygwinified path. Ahh.
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-      fi
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    esac
-    ;;
-
-  *)
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    ;;
-  esac
-  dynamic_linker='Win32 ld.exe'
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
-
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
-  if test "$GCC" = yes; then
-    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
-  else
-    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
-  fi
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
-
-dgux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-freebsd1*)
-  dynamic_linker=no
-  ;;
-
-kfreebsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[[123]]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
-      ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
-      ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
-  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  freebsd*) # from 4.6 on
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
-
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  ;;
-
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-   hppa*64*)
-     shrext_cmds='.sl'
-     hardcode_into_libs=yes
-     dynamic_linker="$host_os dld.sl"
-     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-     soname_spec='${libname}${release}${shared_ext}$major'
-     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-     ;;
-   *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555.
-  postinstall_cmds='chmod 555 $lib'
-  ;;
-
-interix3*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-       if test "$lt_cv_prog_gnu_ld" = yes; then
-               version_type=linux
-       else
-               version_type=irix
-       fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
-
-# This must be Linux ELF.
-linux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
-
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,   ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
-  fi
-
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
-
-knetbsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
-
-newsos6)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
-
-nto-qnx*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
-
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[[89]] | openbsd2.[[89]].*)
-       shlibpath_overrides_runpath=no
-       ;;
-      *)
-       shlibpath_overrides_runpath=yes
-       ;;
-      esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
-  ;;
-
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
-
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
-
-solaris*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
-
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
-
-sysv4 | sysv4.3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      export_dynamic_flag_spec='${wl}-Blargedynsym'
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      ;;
-  esac
-  ;;
-
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-    shlibpath_overrides_runpath=no
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    shlibpath_overrides_runpath=yes
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-       ;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
-uts4*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-*)
-  dynamic_linker=no
-  ;;
-esac
-AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
-
-
-# _LT_AC_TAGCONFIG
-# ----------------
-AC_DEFUN([_LT_AC_TAGCONFIG],
-[AC_ARG_WITH([tags],
-    [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
-        [include additional configurations @<:@automatic@:>@])],
-    [tagnames="$withval"])
-
-if test -f "$ltmain" && test -n "$tagnames"; then
-  if test ! -f "${ofile}"; then
-    AC_MSG_WARN([output file `$ofile' does not exist])
-  fi
-
-  if test -z "$LTCC"; then
-    eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
-    if test -z "$LTCC"; then
-      AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
-    else
-      AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
-    fi
-  fi
-  if test -z "$LTCFLAGS"; then
-    eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
-  fi
-
-  # Extract list of available tagged configurations in $ofile.
-  # Note that this assumes the entire list is on one line.
-  available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
-
-  lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-  for tagname in $tagnames; do
-    IFS="$lt_save_ifs"
-    # Check whether tagname contains only valid characters
-    case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
-    "") ;;
-    *)  AC_MSG_ERROR([invalid tag name: $tagname])
-       ;;
-    esac
-
-    if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
-    then
-      AC_MSG_ERROR([tag name \"$tagname\" already exists])
-    fi
-
-    # Update the list of available tags.
-    if test -n "$tagname"; then
-      echo appending configuration tag \"$tagname\" to $ofile
-
-      case $tagname in
-      CXX)
-       if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-           ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-           (test "X$CXX" != "Xg++"))) ; then
-         AC_LIBTOOL_LANG_CXX_CONFIG
-       else
-         tagname=""
-       fi
-       ;;
-
-      F77)
-       if test -n "$F77" && test "X$F77" != "Xno"; then
-         AC_LIBTOOL_LANG_F77_CONFIG
-       else
-         tagname=""
-       fi
-       ;;
-
-      GCJ)
-       if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
-         AC_LIBTOOL_LANG_GCJ_CONFIG
-       else
-         tagname=""
-       fi
-       ;;
-
-      RC)
-       AC_LIBTOOL_LANG_RC_CONFIG
-       ;;
-
-      *)
-       AC_MSG_ERROR([Unsupported tag name: $tagname])
-       ;;
-      esac
-
-      # Append the new tag name to the list of available tags.
-      if test -n "$tagname" ; then
-      available_tags="$available_tags $tagname"
-    fi
-    fi
-  done
-  IFS="$lt_save_ifs"
-
-  # Now substitute the updated list of available tags.
-  if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
-    mv "${ofile}T" "$ofile"
-    chmod +x "$ofile"
-  else
-    rm -f "${ofile}T"
-    AC_MSG_ERROR([unable to update list of available tagged configurations.])
-  fi
-fi
-])# _LT_AC_TAGCONFIG
-
-
-# AC_LIBTOOL_DLOPEN
-# -----------------
-# enable checks for dlopen support
-AC_DEFUN([AC_LIBTOOL_DLOPEN],
- [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
-])# AC_LIBTOOL_DLOPEN
-
-
-# AC_LIBTOOL_WIN32_DLL
-# --------------------
-# declare package support for building win32 DLLs
-AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
-[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
-])# AC_LIBTOOL_WIN32_DLL
-
-
-# AC_ENABLE_SHARED([DEFAULT])
-# ---------------------------
-# implement the --enable-shared flag
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_SHARED],
-[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([shared],
-    [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
-       [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
-    [p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_shared=yes ;;
-    no) enable_shared=no ;;
-    *)
-      enable_shared=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-       IFS="$lt_save_ifs"
-       if test "X$pkg" = "X$p"; then
-         enable_shared=yes
-       fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac],
-    [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
-])# AC_ENABLE_SHARED
-
-
-# AC_DISABLE_SHARED
-# -----------------
-# set the default shared flag to --disable-shared
-AC_DEFUN([AC_DISABLE_SHARED],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_SHARED(no)
-])# AC_DISABLE_SHARED
-
-
-# AC_ENABLE_STATIC([DEFAULT])
-# ---------------------------
-# implement the --enable-static flag
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_STATIC],
-[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([static],
-    [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
-       [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
-    [p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_static=yes ;;
-    no) enable_static=no ;;
-    *)
-     enable_static=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-       IFS="$lt_save_ifs"
-       if test "X$pkg" = "X$p"; then
-         enable_static=yes
-       fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac],
-    [enable_static=]AC_ENABLE_STATIC_DEFAULT)
-])# AC_ENABLE_STATIC
-
-
-# AC_DISABLE_STATIC
-# -----------------
-# set the default static flag to --disable-static
-AC_DEFUN([AC_DISABLE_STATIC],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_STATIC(no)
-])# AC_DISABLE_STATIC
-
-
-# AC_ENABLE_FAST_INSTALL([DEFAULT])
-# ---------------------------------
-# implement the --enable-fast-install flag
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_FAST_INSTALL],
-[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([fast-install],
-    [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
-    [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
-    [p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_fast_install=yes ;;
-    no) enable_fast_install=no ;;
-    *)
-      enable_fast_install=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-       IFS="$lt_save_ifs"
-       if test "X$pkg" = "X$p"; then
-         enable_fast_install=yes
-       fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac],
-    [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
-])# AC_ENABLE_FAST_INSTALL
-
-
-# AC_DISABLE_FAST_INSTALL
-# -----------------------
-# set the default to --disable-fast-install
-AC_DEFUN([AC_DISABLE_FAST_INSTALL],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_FAST_INSTALL(no)
-])# AC_DISABLE_FAST_INSTALL
-
-
-# AC_LIBTOOL_PICMODE([MODE])
-# --------------------------
-# implement the --with-pic flag
-# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
-AC_DEFUN([AC_LIBTOOL_PICMODE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-pic_mode=ifelse($#,1,$1,default)
-])# AC_LIBTOOL_PICMODE
-
-
-# AC_PROG_EGREP
-# -------------
-# This is predefined starting with Autoconf 2.54, so this conditional
-# definition can be removed once we require Autoconf 2.54 or later.
-m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
-[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
-   [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
-    then ac_cv_prog_egrep='grep -E'
-    else ac_cv_prog_egrep='egrep'
-    fi])
- EGREP=$ac_cv_prog_egrep
- AC_SUBST([EGREP])
-])])
-
-
-# AC_PATH_TOOL_PREFIX
-# -------------------
-# find a file program which can recognise shared library
-AC_DEFUN([AC_PATH_TOOL_PREFIX],
-[AC_REQUIRE([AC_PROG_EGREP])dnl
-AC_MSG_CHECKING([for $1])
-AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
-[case $MAGIC_CMD in
-[[\\/*] |  ?:[\\/]*])
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
-  ;;
-*)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-dnl $ac_dummy forces splitting on constant user-supplied paths.
-dnl POSIX.2 word splitting is done only on the output of word expansions,
-dnl not every word.  This closes a longstanding sh security hole.
-  ac_dummy="ifelse([$2], , $PATH, [$2])"
-  for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$1; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
-      if test -n "$file_magic_test_file"; then
-       case $deplibs_check_method in
-       "file_magic "*)
-         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-           $EGREP "$file_magic_regex" > /dev/null; then
-           :
-         else
-           cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-EOF
-         fi ;;
-       esac
-      fi
-      break
-    fi
-  done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
-  ;;
-esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
-  AC_MSG_RESULT($MAGIC_CMD)
-else
-  AC_MSG_RESULT(no)
-fi
-])# AC_PATH_TOOL_PREFIX
-
-
-# AC_PATH_MAGIC
-# -------------
-# find a file program which can recognise a shared library
-AC_DEFUN([AC_PATH_MAGIC],
-[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
-if test -z "$lt_cv_path_MAGIC_CMD"; then
-  if test -n "$ac_tool_prefix"; then
-    AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
-  else
-    MAGIC_CMD=:
-  fi
-fi
-])# AC_PATH_MAGIC
-
-
-# AC_PROG_LD
-# ----------
-# find the pathname to the GNU or non-GNU linker
-AC_DEFUN([AC_PROG_LD],
-[AC_ARG_WITH([gnu-ld],
-    [AC_HELP_STRING([--with-gnu-ld],
-       [assume the C compiler uses GNU ld @<:@default=no@:>@])],
-    [test "$withval" = no || with_gnu_ld=yes],
-    [with_gnu_ld=no])
-AC_REQUIRE([LT_AC_PROG_SED])dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-ac_prog=ld
-if test "$GCC" = yes; then
-  # Check if gcc -print-prog-name=ld gives a path.
-  AC_MSG_CHECKING([for ld used by $CC])
-  case $host in
-  *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
-    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
-  *)
-    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
-  esac
-  case $ac_prog in
-    # Accept absolute paths.
-    [[\\/]]* | ?:[[\\/]]*)
-      re_direlt='/[[^/]][[^/]]*/\.\./'
-      # Canonicalize the pathname of ld
-      ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
-      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
-       ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
-      done
-      test -z "$LD" && LD="$ac_prog"
-      ;;
-  "")
-    # If it fails, then pretend we aren't using GCC.
-    ac_prog=ld
-    ;;
-  *)
-    # If it is relative, then search for the first ld in PATH.
-    with_gnu_ld=unknown
-    ;;
-  esac
-elif test "$with_gnu_ld" = yes; then
-  AC_MSG_CHECKING([for GNU ld])
-else
-  AC_MSG_CHECKING([for non-GNU ld])
-fi
-AC_CACHE_VAL(lt_cv_path_LD,
-[if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
-      # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
-      # Break only if it was the GNU/non-GNU ld that we prefer.
-      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
-      *GNU* | *'with BFD'*)
-       test "$with_gnu_ld" != no && break
-       ;;
-      *)
-       test "$with_gnu_ld" != yes && break
-       ;;
-      esac
-    fi
-  done
-  IFS="$lt_save_ifs"
-else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi])
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
-  AC_MSG_RESULT($LD)
-else
-  AC_MSG_RESULT(no)
-fi
-test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
-AC_PROG_LD_GNU
-])# AC_PROG_LD
-
-
-# AC_PROG_LD_GNU
-# --------------
-AC_DEFUN([AC_PROG_LD_GNU],
-[AC_REQUIRE([AC_PROG_EGREP])dnl
-AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
-  lt_cv_prog_gnu_ld=yes
-  ;;
-*)
-  lt_cv_prog_gnu_ld=no
-  ;;
-esac])
-with_gnu_ld=$lt_cv_prog_gnu_ld
-])# AC_PROG_LD_GNU
-
-
-# AC_PROG_LD_RELOAD_FLAG
-# ----------------------
-# find reload flag for linker
-#   -- PORTME Some linkers may need a different reload flag.
-AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
-[AC_CACHE_CHECK([for $LD option to reload object files],
-  lt_cv_ld_reload_flag,
-  [lt_cv_ld_reload_flag='-r'])
-reload_flag=$lt_cv_ld_reload_flag
-case $reload_flag in
-"" | " "*) ;;
-*) reload_flag=" $reload_flag" ;;
-esac
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
-  darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
-    else
-      reload_cmds='$LD$reload_flag -o $output$reload_objs'
-    fi
-    ;;
-esac
-])# AC_PROG_LD_RELOAD_FLAG
-
-
-# AC_DEPLIBS_CHECK_METHOD
-# -----------------------
-# how to check for library dependencies
-#  -- PORTME fill in with the dynamic library characteristics
-AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
-[AC_CACHE_CHECK([how to recognise dependent libraries],
-lt_cv_deplibs_check_method,
-[lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-
-case $host_os in
-aix4* | aix5*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-beos*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-bsdi[[45]]*)
-  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
-  lt_cv_file_magic_cmd='/usr/bin/file -L'
-  lt_cv_file_magic_test_file=/shlib/libc.so
-  ;;
-
-cygwin*)
-  # func_win32_libid is a shell function defined in ltmain.sh
-  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
-  lt_cv_file_magic_cmd='func_win32_libid'
-  ;;
-
-mingw* | pw32*)
-  # Base MSYS/MinGW do not provide the 'file' command needed by
-  # func_win32_libid shell function, so use a weaker test based on 'objdump'.
-  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
-  lt_cv_file_magic_cmd='$OBJDUMP -f'
-  ;;
-
-darwin* | rhapsody*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-freebsd* | kfreebsd*-gnu | dragonfly*)
-  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
-    case $host_cpu in
-    i*86 )
-      # Not sure whether the presence of OpenBSD here was a mistake.
-      # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
-      lt_cv_file_magic_cmd=/usr/bin/file
-      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
-      ;;
-    esac
-  else
-    lt_cv_deplibs_check_method=pass_all
-  fi
-  ;;
-
-gnu*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-hpux10.20* | hpux11*)
-  lt_cv_file_magic_cmd=/usr/bin/file
-  case $host_cpu in
-  ia64*)
-    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
-    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
-    ;;
-  hppa*64*)
-    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
-    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
-    ;;
-  *)
-    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
-    lt_cv_file_magic_test_file=/usr/lib/libc.sl
-    ;;
-  esac
-  ;;
-
-interix3*)
-  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
-  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
-  ;;
-
-irix5* | irix6* | nonstopux*)
-  case $LD in
-  *-32|*"-32 ") libmagic=32-bit;;
-  *-n32|*"-n32 ") libmagic=N32;;
-  *-64|*"-64 ") libmagic=64-bit;;
-  *) libmagic=never-match;;
-  esac
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-# This must be Linux ELF.
-linux*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-netbsd*)
-  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
-  fi
-  ;;
-
-newos6*)
-  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
-  lt_cv_file_magic_cmd=/usr/bin/file
-  lt_cv_file_magic_test_file=/usr/lib/libnls.so
-  ;;
-
-nto-qnx*)
-  lt_cv_deplibs_check_method=unknown
-  ;;
-
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
-  fi
-  ;;
-
-osf3* | osf4* | osf5*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-solaris*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-sysv4 | sysv4.3*)
-  case $host_vendor in
-  motorola)
-    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
-    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
-    ;;
-  ncr)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  sequent)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
-    ;;
-  sni)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
-    lt_cv_file_magic_test_file=/lib/libc.so
-    ;;
-  siemens)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  pc)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  esac
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-esac
-])
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-])# AC_DEPLIBS_CHECK_METHOD
-
-
-# AC_PROG_NM
-# ----------
-# find the pathname to a BSD-compatible name lister
-AC_DEFUN([AC_PROG_NM],
-[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
-[if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then 
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-       # Check to see if the nm accepts a BSD-compat flag.
-       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
-       #   nm: unknown option "B" ignored
-       # Tru64's nm complains that /dev/null is an invalid object file
-       case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-       */dev/null* | *'Invalid file or object type'*)
-         lt_cv_path_NM="$tmp_nm -B"
-         break
-         ;;
-       *)
-         case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-         */dev/null*)
-           lt_cv_path_NM="$tmp_nm -p"
-           break
-           ;;
-         *)
-           lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-           continue # so that we can try to find one that supports BSD flags
-           ;;
-         esac
-         ;;
-       esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
-fi])
-NM="$lt_cv_path_NM"
-])# AC_PROG_NM
-
-
-# AC_CHECK_LIBM
-# -------------
-# check for math library
-AC_DEFUN([AC_CHECK_LIBM],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-LIBM=
-case $host in
-*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
-  # These system don't have libm, or don't need it
-  ;;
-*-ncr-sysv4.3*)
-  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
-  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
-  ;;
-*)
-  AC_CHECK_LIB(m, cos, LIBM="-lm")
-  ;;
-esac
-])# AC_CHECK_LIBM
-
-
-# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
-# -----------------------------------
-# sets LIBLTDL to the link flags for the libltdl convenience library and
-# LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-convenience to the configure arguments.  Note that
-# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
-# it is assumed to be `libltdl'.  LIBLTDL will be prefixed with
-# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
-# (note the single quotes!).  If your package is not flat and you're not
-# using automake, define top_builddir and top_srcdir appropriately in
-# the Makefiles.
-AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-  case $enable_ltdl_convenience in
-  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
-  "") enable_ltdl_convenience=yes
-      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
-  esac
-  LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
-  LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
-  # For backwards non-gettext consistent compatibility...
-  INCLTDL="$LTDLINCL"
-])# AC_LIBLTDL_CONVENIENCE
-
-
-# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
-# -----------------------------------
-# sets LIBLTDL to the link flags for the libltdl installable library and
-# LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-install to the configure arguments.  Note that
-# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
-# and an installed libltdl is not found, it is assumed to be `libltdl'.
-# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
-# '${top_srcdir}/' (note the single quotes!).  If your package is not
-# flat and you're not using automake, define top_builddir and top_srcdir
-# appropriately in the Makefiles.
-# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
-AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-  AC_CHECK_LIB(ltdl, lt_dlinit,
-  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
-  [if test x"$enable_ltdl_install" = xno; then
-     AC_MSG_WARN([libltdl not installed, but installation disabled])
-   else
-     enable_ltdl_install=yes
-   fi
-  ])
-  if test x"$enable_ltdl_install" = x"yes"; then
-    ac_configure_args="$ac_configure_args --enable-ltdl-install"
-    LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
-    LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
-  else
-    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
-    LIBLTDL="-lltdl"
-    LTDLINCL=
-  fi
-  # For backwards non-gettext consistent compatibility...
-  INCLTDL="$LTDLINCL"
-])# AC_LIBLTDL_INSTALLABLE
-
-
-# AC_LIBTOOL_CXX
-# --------------
-# enable support for C++ libraries
-AC_DEFUN([AC_LIBTOOL_CXX],
-[AC_REQUIRE([_LT_AC_LANG_CXX])
-])# AC_LIBTOOL_CXX
-
-
-# _LT_AC_LANG_CXX
-# ---------------
-AC_DEFUN([_LT_AC_LANG_CXX],
-[AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
-])# _LT_AC_LANG_CXX
-
-# _LT_AC_PROG_CXXCPP
-# ------------------
-AC_DEFUN([_LT_AC_PROG_CXXCPP],
-[
-AC_REQUIRE([AC_PROG_CXX])
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
-  AC_PROG_CXXCPP
-fi
-])# _LT_AC_PROG_CXXCPP
-
-# AC_LIBTOOL_F77
-# --------------
-# enable support for Fortran 77 libraries
-AC_DEFUN([AC_LIBTOOL_F77],
-[AC_REQUIRE([_LT_AC_LANG_F77])
-])# AC_LIBTOOL_F77
-
-
-# _LT_AC_LANG_F77
-# ---------------
-AC_DEFUN([_LT_AC_LANG_F77],
-[AC_REQUIRE([AC_PROG_F77])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
-])# _LT_AC_LANG_F77
-
-
-# AC_LIBTOOL_GCJ
-# --------------
-# enable support for GCJ libraries
-AC_DEFUN([AC_LIBTOOL_GCJ],
-[AC_REQUIRE([_LT_AC_LANG_GCJ])
-])# AC_LIBTOOL_GCJ
-
-
-# _LT_AC_LANG_GCJ
-# ---------------
-AC_DEFUN([_LT_AC_LANG_GCJ],
-[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
-  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
-    [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
-      [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
-        [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
-          [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
-])# _LT_AC_LANG_GCJ
-
-
-# AC_LIBTOOL_RC
-# -------------
-# enable support for Windows resource files
-AC_DEFUN([AC_LIBTOOL_RC],
-[AC_REQUIRE([LT_AC_PROG_RC])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
-])# AC_LIBTOOL_RC
-
-
-# AC_LIBTOOL_LANG_C_CONFIG
-# ------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
-AC_DEFUN([_LT_AC_LANG_C_CONFIG],
-[lt_save_CC="$CC"
-AC_LANG_PUSH(C)
-
-# Source file extension for C test sources.
-ac_ext=c
-
-# Object file extension for compiled C test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}\n'
-
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-## CAVEAT EMPTOR:
-## There is no encapsulation within the following macros, do not change
-## the running order or otherwise move them around unless you know exactly
-## what you are doing...
-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-AC_LIBTOOL_SYS_LIB_STRIP
-AC_LIBTOOL_DLOPEN_SELF
-
-# Report which library types will actually be built
-AC_MSG_CHECKING([if libtool supports shared libraries])
-AC_MSG_RESULT([$can_build_shared])
-
-AC_MSG_CHECKING([whether to build shared libraries])
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
-  test "$enable_shared" = yes && enable_static=no
-  if test -n "$RANLIB"; then
-    archive_cmds="$archive_cmds~\$RANLIB \$lib"
-    postinstall_cmds='$RANLIB $lib'
-  fi
-  ;;
-
-aix4* | aix5*)
-  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-    test "$enable_shared" = yes && enable_static=no
-  fi
-    ;;
-esac
-AC_MSG_RESULT([$enable_shared])
-
-AC_MSG_CHECKING([whether to build static libraries])
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-AC_MSG_RESULT([$enable_static])
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_C_CONFIG
-
-
-# AC_LIBTOOL_LANG_CXX_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
-AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
-[AC_LANG_PUSH(C++)
-AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
-
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
-_LT_AC_TAGVAR(always_export_symbols, $1)=no
-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_direct, $1)=no
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
-_LT_AC_TAGVAR(module_cmds, $1)=
-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_AC_TAGVAR(no_undefined_flag, $1)=
-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-
-# Dependencies to place before and after the object being linked:
-_LT_AC_TAGVAR(predep_objects, $1)=
-_LT_AC_TAGVAR(postdep_objects, $1)=
-_LT_AC_TAGVAR(predeps, $1)=
-_LT_AC_TAGVAR(postdeps, $1)=
-_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
-
-# Source file extension for C++ test sources.
-ac_ext=cpp
-
-# Object file extension for compiled C++ test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_LD=$LD
-lt_save_GCC=$GCC
-GCC=$GXX
-lt_save_with_gnu_ld=$with_gnu_ld
-lt_save_path_LD=$lt_cv_path_LD
-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
-  lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
-else
-  $as_unset lt_cv_prog_gnu_ld
-fi
-if test -n "${lt_cv_path_LDCXX+set}"; then
-  lt_cv_path_LD=$lt_cv_path_LDCXX
-else
-  $as_unset lt_cv_path_LD
-fi
-test -z "${LDCXX+set}" || LD=$LDCXX
-CC=${CXX-"c++"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-# We don't want -fno-exception wen compiling C++ code, so set the
-# no_builtin_flag separately
-if test "$GXX" = yes; then
-  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
-else
-  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-fi
-
-if test "$GXX" = yes; then
-  # Set up default GNU C++ configuration
-
-  AC_PROG_LD
-
-  # Check if GNU C++ uses GNU ld as the underlying linker, since the
-  # archiving commands below assume that GNU ld is being used.
-  if test "$with_gnu_ld" = yes; then
-    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
-    #     investigate it a little bit more. (MM)
-    wlarc='${wl}'
-
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
-       grep 'no-whole-archive' > /dev/null; then
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    else
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-    fi
-  else
-    with_gnu_ld=no
-    wlarc=
-
-    # A generic and very simple default shared library creation
-    # command for GNU C++ for the case where it uses the native
-    # linker, instead of GNU ld.  If possible, this setting should
-    # overridden to take advantage of the native linker features on
-    # the platform it is being used on.
-    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-  fi
-
-  # Commands to make compiler produce verbose output that lists
-  # what "hidden" libraries, object files and flags are used when
-  # linking a shared library.
-  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-else
-  GXX=no
-  with_gnu_ld=no
-  wlarc=
-fi
-
-# PORTME: fill in a description of your system's C++ link characteristics
-AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-_LT_AC_TAGVAR(ld_shlibs, $1)=yes
-case $host_os in
-  aix3*)
-    # FIXME: insert proper C++ library support
-    _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    ;;
-  aix4* | aix5*)
-    if test "$host_cpu" = ia64; then
-      # On IA64, the linker does run time linking by default, so we don't
-      # have to do anything special.
-      aix_use_runtimelinking=no
-      exp_sym_flag='-Bexport'
-      no_entry_flag=""
-    else
-      aix_use_runtimelinking=no
-
-      # Test if we are trying to use run time linking or normal
-      # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-      # need to do runtime linking.
-      case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
-       for ld_flag in $LDFLAGS; do
-         case $ld_flag in
-         *-brtl*)
-           aix_use_runtimelinking=yes
-           break
-           ;;
-         esac
-       done
-       ;;
-      esac
-
-      exp_sym_flag='-bexport'
-      no_entry_flag='-bnoentry'
-    fi
-
-    # When large executables or shared objects are built, AIX ld can
-    # have problems creating the table of contents.  If linking a library
-    # or program results in "error TOC overflow" add -mminimal-toc to
-    # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-    # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
-    _LT_AC_TAGVAR(archive_cmds, $1)=''
-    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
-    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
-    if test "$GXX" = yes; then
-      case $host_os in aix4.[[012]]|aix4.[[012]].*)
-      # We only want to do this on AIX 4.2 and lower, the check
-      # below for broken collect2 doesn't work under 4.3+
-       collect2name=`${CC} -print-prog-name=collect2`
-       if test -f "$collect2name" && \
-          strings "$collect2name" | grep resolve_lib_name >/dev/null
-       then
-         # We have reworked collect2
-         _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-       else
-         # We have old collect2
-         _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
-         # It fails to find uninstalled libraries when the uninstalled
-         # path is not listed in the libpath.  Setting hardcode_minus_L
-         # to unsupported forces relinking
-         _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-       fi
-       ;;
-      esac
-      shared_flag='-shared'
-      if test "$aix_use_runtimelinking" = yes; then
-       shared_flag="$shared_flag "'${wl}-G'
-      fi
-    else
-      # not using gcc
-      if test "$host_cpu" = ia64; then
-       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-       # chokes on -Wl,-G. The following line is correct:
-       shared_flag='-G'
-      else
-       if test "$aix_use_runtimelinking" = yes; then
-         shared_flag='${wl}-G'
-       else
-         shared_flag='${wl}-bM:SRE'
-       fi
-      fi
-    fi
-
-    # It seems that -bexpall does not export symbols beginning with
-    # underscore (_), so it is better to generate a list of symbols to export.
-    _LT_AC_TAGVAR(always_export_symbols, $1)=yes
-    if test "$aix_use_runtimelinking" = yes; then
-      # Warning - without using the other runtime loading flags (-brtl),
-      # -berok will link without error, but may produce a broken library.
-      _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
-      # Determine the default libpath from the value encoded in an empty executable.
-      _LT_AC_SYS_LIBPATH_AIX
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-     else
-      if test "$host_cpu" = ia64; then
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
-       _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-      else
-       # Determine the default libpath from the value encoded in an empty executable.
-       _LT_AC_SYS_LIBPATH_AIX
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-       # Warning - without using the other run time loading flags,
-       # -berok will link without error, but may produce a broken library.
-       _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-       # Exported symbols can be pulled into shared objects from archives
-       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
-       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-       # This is similar to how AIX traditionally builds its shared libraries.
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-      fi
-    fi
-    ;;
-
-  beos*)
-    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
-      # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
-      # support --undefined.  This deserves some investigation.  FIXME
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-    else
-      _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    fi
-    ;;
-
-  chorus*)
-    case $cc_basename in
-      *)
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-    esac
-    ;;
-
-  cygwin* | mingw* | pw32*)
-    # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
-    # as there is no search path for DLLs.
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-    _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
-    _LT_AC_TAGVAR(always_export_symbols, $1)=no
-    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-
-    if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      # If the export-symbols file already is a .def file (1st line
-      # is EXPORTS), use it as is; otherwise, prepend...
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-       cp $export_symbols $output_objdir/$soname.def;
-      else
-       echo EXPORTS > $output_objdir/$soname.def;
-       cat $export_symbols >> $output_objdir/$soname.def;
-      fi~
-      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-    else
-      _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    fi
-  ;;
-      darwin* | rhapsody*)
-        case $host_os in
-        rhapsody* | darwin1.[[012]])
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[[012]])
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-        esac
-      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-      _LT_AC_TAGVAR(hardcode_direct, $1)=no
-      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
-      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
-    if test "$GXX" = yes ; then
-      lt_int_apple_cc_single_mod=no
-      output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
-       lt_int_apple_cc_single_mod=yes
-      fi
-      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      else
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-        fi
-        _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          else
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          fi
-            _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-          _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         _LT_AC_TAGVAR(ld_shlibs, $1)=no
-          ;;
-      esac
-      fi
-        ;;
-
-  dgux*)
-    case $cc_basename in
-      ec++*)
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-      ghcx*)
-       # Green Hills C++ Compiler
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-      *)
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-    esac
-    ;;
-  freebsd[[12]]*)
-    # C++ shared libraries reported to be fairly broken before switch to ELF
-    _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    ;;
-  freebsd-elf*)
-    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-    ;;
-  freebsd* | kfreebsd*-gnu | dragonfly*)
-    # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
-    # conventions
-    _LT_AC_TAGVAR(ld_shlibs, $1)=yes
-    ;;
-  gnu*)
-    ;;
-  hpux9*)
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-    _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
-                               # but as the default
-                               # location of the library.
-
-    case $cc_basename in
-    CC*)
-      # FIXME: insert proper C++ library support
-      _LT_AC_TAGVAR(ld_shlibs, $1)=no
-      ;;
-    aCC*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      # Commands to make compiler produce verbose output that lists
-      # what "hidden" libraries, object files and flags are used when
-      # linking a shared library.
-      #
-      # There doesn't appear to be a way to prevent this compiler from
-      # explicitly linking system object files so we need to strip them
-      # from the output so that they don't get included in the library
-      # dependencies.
-      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-      ;;
-    *)
-      if test "$GXX" = yes; then
-        _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-        # FIXME: insert proper C++ library support
-        _LT_AC_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-    esac
-    ;;
-  hpux10*|hpux11*)
-    if test $with_gnu_ld = no; then
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-      case $host_cpu in
-      hppa*64*|ia64*)
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
-        ;;
-      *)
-       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-        ;;
-      esac
-    fi
-    case $host_cpu in
-    hppa*64*|ia64*)
-      _LT_AC_TAGVAR(hardcode_direct, $1)=no
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-    *)
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
-                                             # but as the default
-                                             # location of the library.
-      ;;
-    esac
-
-    case $cc_basename in
-      CC*)
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-      aCC*)
-       case $host_cpu in
-       hppa*64*)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-         ;;
-       ia64*)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-         ;;
-       *)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-         ;;
-       esac
-       # Commands to make compiler produce verbose output that lists
-       # what "hidden" libraries, object files and flags are used when
-       # linking a shared library.
-       #
-       # There doesn't appear to be a way to prevent this compiler from
-       # explicitly linking system object files so we need to strip them
-       # from the output so that they don't get included in the library
-       # dependencies.
-       output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-       ;;
-      *)
-       if test "$GXX" = yes; then
-         if test $with_gnu_ld = no; then
-           case $host_cpu in
-           hppa*64*)
-             _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-             ;;
-           ia64*)
-             _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-             ;;
-           *)
-             _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-             ;;
-           esac
-         fi
-       else
-         # FIXME: insert proper C++ library support
-         _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       fi
-       ;;
-    esac
-    ;;
-  interix3*)
-    _LT_AC_TAGVAR(hardcode_direct, $1)=no
-    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-    # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-    # Instead, shared libraries are loaded at an image base (0x10000000 by
-    # default) and relocated if they conflict, which is a slow very memory
-    # consuming and fragmenting process.  To avoid this, we pick a random,
-    # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-    # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-    ;;
-  irix5* | irix6*)
-    case $cc_basename in
-      CC*)
-       # SGI C++
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
-       # Archives containing C++ object files must be created using
-       # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
-       # necessary to make sure instantiated templates are included
-       # in the archive.
-       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
-       ;;
-      *)
-       if test "$GXX" = yes; then
-         if test "$with_gnu_ld" = no; then
-           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-         else
-           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
-         fi
-       fi
-       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-       ;;
-    esac
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-    ;;
-  linux*)
-    case $cc_basename in
-      KCC*)
-       # Kuck and Associates, Inc. (KAI) C++ Compiler
-
-       # KCC will only create a shared library if the output file
-       # ends with ".so" (or ".sl" for HP-UX), so rename the library
-       # to its proper name (with version) after linking.
-       _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
-       # Commands to make compiler produce verbose output that lists
-       # what "hidden" libraries, object files and flags are used when
-       # linking a shared library.
-       #
-       # There doesn't appear to be a way to prevent this compiler from
-       # explicitly linking system object files so we need to strip them
-       # from the output so that they don't get included in the library
-       # dependencies.
-       output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
-       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-
-       # Archives containing C++ object files must be created using
-       # "CC -Bstatic", where "CC" is the KAI C++ compiler.
-       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
-       ;;
-      icpc*)
-       # Intel C++
-       with_gnu_ld=yes
-       # version 8.0 and above of icpc choke on multiply defined symbols
-       # if we add $predep_objects and $postdep_objects, however 7.1 and
-       # earlier do not add the objects themselves.
-       case `$CC -V 2>&1` in
-       *"Version 7."*)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-         ;;
-       *)  # Version 8.0 or newer
-         tmp_idyn=
-         case $host_cpu in
-           ia64*) tmp_idyn=' -i_dynamic';;
-         esac
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-         ;;
-       esac
-       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
-       ;;
-      pgCC*)
-        # Portland Group C++ compiler
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-        ;;
-      cxx*)
-       # Compaq C++
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
-
-       runpath_var=LD_RUN_PATH
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
-       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-       # Commands to make compiler produce verbose output that lists
-       # what "hidden" libraries, object files and flags are used when
-       # linking a shared library.
-       #
-       # There doesn't appear to be a way to prevent this compiler from
-       # explicitly linking system object files so we need to strip them
-       # from the output so that they don't get included in the library
-       # dependencies.
-       output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-       ;;
-    esac
-    ;;
-  lynxos*)
-    # FIXME: insert proper C++ library support
-    _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    ;;
-  m88k*)
-    # FIXME: insert proper C++ library support
-    _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    ;;
-  mvs*)
-    case $cc_basename in
-      cxx*)
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-      *)
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-    esac
-    ;;
-  netbsd*)
-    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
-      wlarc=
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    fi
-    # Workaround some broken pre-1.5 toolchains
-    output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
-    ;;
-  openbsd2*)
-    # C++ shared libraries are fairly broken
-    _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    ;;
-  openbsd*)
-    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    fi
-    output_verbose_link_cmd='echo'
-    ;;
-  osf3*)
-    case $cc_basename in
-      KCC*)
-       # Kuck and Associates, Inc. (KAI) C++ Compiler
-
-       # KCC will only create a shared library if the output file
-       # ends with ".so" (or ".sl" for HP-UX), so rename the library
-       # to its proper name (with version) after linking.
-       _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-       # Archives containing C++ object files must be created using
-       # "CC -Bstatic", where "CC" is the KAI C++ compiler.
-       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
-
-       ;;
-      RCC*)
-       # Rational C++ 2.4.1
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-      cxx*)
-       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-       # Commands to make compiler produce verbose output that lists
-       # what "hidden" libraries, object files and flags are used when
-       # linking a shared library.
-       #
-       # There doesn't appear to be a way to prevent this compiler from
-       # explicitly linking system object files so we need to strip them
-       # from the output so that they don't get included in the library
-       # dependencies.
-       output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-       ;;
-      *)
-       if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
-         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-         # Commands to make compiler produce verbose output that lists
-         # what "hidden" libraries, object files and flags are used when
-         # linking a shared library.
-         output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-       else
-         # FIXME: insert proper C++ library support
-         _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       fi
-       ;;
-    esac
-    ;;
-  osf4* | osf5*)
-    case $cc_basename in
-      KCC*)
-       # Kuck and Associates, Inc. (KAI) C++ Compiler
-
-       # KCC will only create a shared library if the output file
-       # ends with ".so" (or ".sl" for HP-UX), so rename the library
-       # to its proper name (with version) after linking.
-       _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-       # Archives containing C++ object files must be created using
-       # the KAI C++ compiler.
-       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
-       ;;
-      RCC*)
-       # Rational C++ 2.4.1
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-      cxx*)
-       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-         echo "-hidden">> $lib.exp~
-         $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
-         $rm $lib.exp'
-
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
-       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-       # Commands to make compiler produce verbose output that lists
-       # what "hidden" libraries, object files and flags are used when
-       # linking a shared library.
-       #
-       # There doesn't appear to be a way to prevent this compiler from
-       # explicitly linking system object files so we need to strip them
-       # from the output so that they don't get included in the library
-       # dependencies.
-       output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-       ;;
-      *)
-       if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
-         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-         # Commands to make compiler produce verbose output that lists
-         # what "hidden" libraries, object files and flags are used when
-         # linking a shared library.
-         output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-       else
-         # FIXME: insert proper C++ library support
-         _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       fi
-       ;;
-    esac
-    ;;
-  psos*)
-    # FIXME: insert proper C++ library support
-    _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    ;;
-  sunos4*)
-    case $cc_basename in
-      CC*)
-       # Sun C++ 4.x
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-      lcc*)
-       # Lucid
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-      *)
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-    esac
-    ;;
-  solaris*)
-    case $cc_basename in
-      CC*)
-       # Sun C++ 4.2, 5.x and Centerline C++
-        _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
-       _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-       $CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-       case $host_os in
-         solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
-         *)
-           # The C++ compiler is used as linker so we must use $wl
-           # flag to pass the commands to the underlying system
-           # linker. We must also pass each convience library through
-           # to the system linker between allextract/defaultextract.
-           # The C++ compiler will combine linker options so we
-           # cannot just pass the convience library names through
-           # without $wl.
-           # Supported since Solaris 2.6 (maybe 2.5.1?)
-           _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
-           ;;
-       esac
-       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
-       output_verbose_link_cmd='echo'
-
-       # Archives containing C++ object files must be created using
-       # "CC -xar", where "CC" is the Sun C++ compiler.  This is
-       # necessary to make sure instantiated templates are included
-       # in the archive.
-       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
-       ;;
-      gcx*)
-       # Green Hills C++ Compiler
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-
-       # The C++ compiler must be used to create the archive.
-       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
-       ;;
-      *)
-       # GNU C++ compiler with Solaris linker
-       if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-         _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
-         if $CC --version | grep -v '^2\.7' > /dev/null; then
-           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-           _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-               $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
-           # Commands to make compiler produce verbose output that lists
-           # what "hidden" libraries, object files and flags are used when
-           # linking a shared library.
-           output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
-         else
-           # g++ 2.7 appears to require `-G' NOT `-shared' on this
-           # platform.
-           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-           _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-               $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
-           # Commands to make compiler produce verbose output that lists
-           # what "hidden" libraries, object files and flags are used when
-           # linking a shared library.
-           output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
-         fi
-
-         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
-       fi
-       ;;
-    esac
-    ;;
-  sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    runpath_var='LD_RUN_PATH'
-
-    case $cc_basename in
-      CC*)
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-       ;;
-      *)
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-       ;;
-    esac
-    ;;
-  sysv5* | sco3.2v5* | sco5v6*)
-    # Note: We can NOT use -z defs as we might desire, because we do not
-    # link with -lc, and that would cause any symbols used from libc to
-    # always be unresolved, which means just about no library would
-    # ever link correctly.  If we're not using GNU ld we use -z text
-    # though, which does catch some bad symbols but isn't as heavy-handed
-    # as -z defs.
-    # For security reasons, it is highly recommended that you always
-    # use absolute paths for naming shared libraries, and exclude the
-    # DT_RUNPATH tag from executables and libraries.  But doing so
-    # requires that you compile everything twice, which is a pain.
-    # So that behaviour is only enabled if SCOABSPATH is set to a
-    # non-empty value in the environment.  Most likely only useful for
-    # creating official distributions of packages.
-    # This is a hack until libtool officially supports absolute path
-    # names for shared libraries.
-    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-    _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
-    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
-    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
-    runpath_var='LD_RUN_PATH'
-
-    case $cc_basename in
-      CC*)
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-       ;;
-      *)
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-       ;;
-    esac
-    ;;
-  tandem*)
-    case $cc_basename in
-      NCC*)
-       # NonStop-UX NCC 3.20
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-      *)
-       # FIXME: insert proper C++ library support
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       ;;
-    esac
-    ;;
-  vxworks*)
-    # FIXME: insert proper C++ library support
-    _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    ;;
-  *)
-    # FIXME: insert proper C++ library support
-    _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    ;;
-esac
-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-
-_LT_AC_TAGVAR(GCC, $1)="$GXX"
-_LT_AC_TAGVAR(LD, $1)="$LD"
-
-## CAVEAT EMPTOR:
-## There is no encapsulation within the following macros, do not change
-## the running order or otherwise move them around unless you know exactly
-## what you are doing...
-AC_LIBTOOL_POSTDEP_PREDEP($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC=$lt_save_CC
-LDCXX=$LD
-LD=$lt_save_LD
-GCC=$lt_save_GCC
-with_gnu_ldcxx=$with_gnu_ld
-with_gnu_ld=$lt_save_with_gnu_ld
-lt_cv_path_LDCXX=$lt_cv_path_LD
-lt_cv_path_LD=$lt_save_path_LD
-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-])# AC_LIBTOOL_LANG_CXX_CONFIG
-
-# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
-# ------------------------------------
-# Figure out "hidden" library dependencies from verbose
-# compiler output when linking a shared library.
-# Parse the compiler output and extract the necessary
-# objects, libraries and library flags.
-AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
-dnl we can't use the lt_simple_compile_test_code here,
-dnl because it contains code intended for an executable,
-dnl not a library.  It's possible we should let each
-dnl tag define a new lt_????_link_test_code variable,
-dnl but it's only used here...
-ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
-int a;
-void foo (void) { a = 0; }
-EOF
-],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
-class Foo
-{
-public:
-  Foo (void) { a = 0; }
-private:
-  int a;
-};
-EOF
-],[$1],[F77],[cat > conftest.$ac_ext <<EOF
-      subroutine foo
-      implicit none
-      integer*4 a
-      a=0
-      return
-      end
-EOF
-],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
-public class foo {
-  private int a;
-  public void bar (void) {
-    a = 0;
-  }
-};
-EOF
-])
-dnl Parse the compiler output and extract the necessary
-dnl objects, libraries and library flags.
-if AC_TRY_EVAL(ac_compile); then
-  # Parse the compiler output and extract the necessary
-  # objects, libraries and library flags.
-
-  # Sentinel used to keep track of whether or not we are before
-  # the conftest object file.
-  pre_test_object_deps_done=no
-
-  # The `*' in the case matches for architectures that use `case' in
-  # $output_verbose_cmd can trigger glob expansion during the loop
-  # eval without this substitution.
-  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
-
-  for p in `eval $output_verbose_link_cmd`; do
-    case $p in
-
-    -L* | -R* | -l*)
-       # Some compilers place space between "-{L,R}" and the path.
-       # Remove the space.
-       if test $p = "-L" \
-         || test $p = "-R"; then
-        prev=$p
-        continue
-       else
-        prev=
-       fi
-
-       if test "$pre_test_object_deps_done" = no; then
-        case $p in
-        -L* | -R*)
-          # Internal compiler library paths should come after those
-          # provided the user.  The postdeps already come after the
-          # user supplied libs so there is no need to process them.
-          if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
-            _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
-          else
-            _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
-          fi
-          ;;
-        # The "-l" case would never come before the object being
-        # linked, so don't bother handling this case.
-        esac
-       else
-        if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
-          _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
-        else
-          _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
-        fi
-       fi
-       ;;
-
-    *.$objext)
-       # This assumes that the test object file only shows up
-       # once in the compiler output.
-       if test "$p" = "conftest.$objext"; then
-        pre_test_object_deps_done=yes
-        continue
-       fi
-
-       if test "$pre_test_object_deps_done" = no; then
-        if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
-          _LT_AC_TAGVAR(predep_objects, $1)="$p"
-        else
-          _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
-        fi
-       else
-        if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
-          _LT_AC_TAGVAR(postdep_objects, $1)="$p"
-        else
-          _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
-        fi
-       fi
-       ;;
-
-    *) ;; # Ignore the rest.
-
-    esac
-  done
-
-  # Clean up.
-  rm -f a.out a.exe
-else
-  echo "libtool.m4: error: problem compiling $1 test program"
-fi
-
-$rm -f confest.$objext
-
-# PORTME: override above test on systems where it is broken
-ifelse([$1],[CXX],
-[case $host_os in
-interix3*)
-  # Interix 3.5 installs completely hosed .la files for C++, so rather than
-  # hack all around it, let's just trust "g++" to DTRT.
-  _LT_AC_TAGVAR(predep_objects,$1)=
-  _LT_AC_TAGVAR(postdep_objects,$1)=
-  _LT_AC_TAGVAR(postdeps,$1)=
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC*)
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
-    ;;
-  esac
-  ;;
-esac
-])
-
-case " $_LT_AC_TAGVAR(postdeps, $1) " in
-*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
-esac
-])# AC_LIBTOOL_POSTDEP_PREDEP
-
-# AC_LIBTOOL_LANG_F77_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
-AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
-[AC_REQUIRE([AC_PROG_F77])
-AC_LANG_PUSH(Fortran 77)
-
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
-_LT_AC_TAGVAR(always_export_symbols, $1)=no
-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_direct, $1)=no
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
-_LT_AC_TAGVAR(module_cmds, $1)=
-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_AC_TAGVAR(no_undefined_flag, $1)=
-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-
-# Source file extension for f77 test sources.
-ac_ext=f
-
-# Object file extension for compiled f77 test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="      subroutine t\n      return\n      end\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code="      program t\n      end\n"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${F77-"f77"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-AC_MSG_CHECKING([if libtool supports shared libraries])
-AC_MSG_RESULT([$can_build_shared])
-
-AC_MSG_CHECKING([whether to build shared libraries])
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
-  test "$enable_shared" = yes && enable_static=no
-  if test -n "$RANLIB"; then
-    archive_cmds="$archive_cmds~\$RANLIB \$lib"
-    postinstall_cmds='$RANLIB $lib'
-  fi
-  ;;
-aix4* | aix5*)
-  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-    test "$enable_shared" = yes && enable_static=no
-  fi
-  ;;
-esac
-AC_MSG_RESULT([$enable_shared])
-
-AC_MSG_CHECKING([whether to build static libraries])
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-AC_MSG_RESULT([$enable_static])
-
-_LT_AC_TAGVAR(GCC, $1)="$G77"
-_LT_AC_TAGVAR(LD, $1)="$LD"
-
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_F77_CONFIG
-
-
-# AC_LIBTOOL_LANG_GCJ_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
-AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
-[AC_LANG_SAVE
-
-# Source file extension for Java test sources.
-ac_ext=java
-
-# Object file extension for compiled Java test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${GCJ-"gcj"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-# GCJ did not exist at the time GCC didn't implicitly link libc in.
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-
-## CAVEAT EMPTOR:
-## There is no encapsulation within the following macros, do not change
-## the running order or otherwise move them around unless you know exactly
-## what you are doing...
-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_RESTORE
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_GCJ_CONFIG
-
-
-# AC_LIBTOOL_LANG_RC_CONFIG
-# -------------------------
-# Ensure that the configuration vars for the Windows resource compiler are
-# suitably defined.  Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
-AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
-[AC_LANG_SAVE
-
-# Source file extension for RC test sources.
-ac_ext=rc
-
-# Object file extension for compiled RC test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
-
-# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${RC-"windres"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_RESTORE
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_RC_CONFIG
-
-
-# AC_LIBTOOL_CONFIG([TAGNAME])
-# ----------------------------
-# If TAGNAME is not passed, then create an initial libtool script
-# with a default configuration from the untagged config vars.  Otherwise
-# add code to config.status for appending the configuration named by
-# TAGNAME from the matching tagged config vars.
-AC_DEFUN([AC_LIBTOOL_CONFIG],
-[# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
-  # See if we are running on zsh, and set the options which allow our commands through
-  # without removal of \ escapes.
-  if test -n "${ZSH_VERSION+set}" ; then
-    setopt NO_GLOB_SUBST
-  fi
-  # Now quote all the things that may contain metacharacters while being
-  # careful not to overquote the AC_SUBSTed values.  We take copies of the
-  # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
-    SED SHELL STRIP \
-    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
-    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
-    deplibs_check_method reload_flag reload_cmds need_locks \
-    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
-    lt_cv_sys_global_symbol_to_c_name_address \
-    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
-    old_postinstall_cmds old_postuninstall_cmds \
-    _LT_AC_TAGVAR(compiler, $1) \
-    _LT_AC_TAGVAR(CC, $1) \
-    _LT_AC_TAGVAR(LD, $1) \
-    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
-    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
-    _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
-    _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
-    _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
-    _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
-    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
-    _LT_AC_TAGVAR(old_archive_cmds, $1) \
-    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
-    _LT_AC_TAGVAR(predep_objects, $1) \
-    _LT_AC_TAGVAR(postdep_objects, $1) \
-    _LT_AC_TAGVAR(predeps, $1) \
-    _LT_AC_TAGVAR(postdeps, $1) \
-    _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
-    _LT_AC_TAGVAR(archive_cmds, $1) \
-    _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
-    _LT_AC_TAGVAR(postinstall_cmds, $1) \
-    _LT_AC_TAGVAR(postuninstall_cmds, $1) \
-    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
-    _LT_AC_TAGVAR(allow_undefined_flag, $1) \
-    _LT_AC_TAGVAR(no_undefined_flag, $1) \
-    _LT_AC_TAGVAR(export_symbols_cmds, $1) \
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
-    _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
-    _LT_AC_TAGVAR(hardcode_automatic, $1) \
-    _LT_AC_TAGVAR(module_cmds, $1) \
-    _LT_AC_TAGVAR(module_expsym_cmds, $1) \
-    _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
-    _LT_AC_TAGVAR(exclude_expsyms, $1) \
-    _LT_AC_TAGVAR(include_expsyms, $1); do
-
-    case $var in
-    _LT_AC_TAGVAR(old_archive_cmds, $1) | \
-    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
-    _LT_AC_TAGVAR(archive_cmds, $1) | \
-    _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
-    _LT_AC_TAGVAR(module_cmds, $1) | \
-    _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
-    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
-    _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
-    extract_expsyms_cmds | reload_cmds | finish_cmds | \
-    postinstall_cmds | postuninstall_cmds | \
-    old_postinstall_cmds | old_postuninstall_cmds | \
-    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
-      # Double-quote double-evaled strings.
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
-      ;;
-    *)
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
-      ;;
-    esac
-  done
-
-  case $lt_echo in
-  *'\[$]0 --fallback-echo"')
-    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
-    ;;
-  esac
-
-ifelse([$1], [],
-  [cfgfile="${ofile}T"
-  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
-  $rm -f "$cfgfile"
-  AC_MSG_NOTICE([creating $ofile])],
-  [cfgfile="$ofile"])
-
-  cat <<__EOF__ >> "$cfgfile"
-ifelse([$1], [],
-[#! $SHELL
-
-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
-#
-# This file is part of GNU Libtool:
-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
-#
-# 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 of the License, 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.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# A sed program that does not truncate output.
-SED=$lt_SED
-
-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-# The names of the tagged configurations supported by this script.
-available_tags=
-
-# ### BEGIN LIBTOOL CONFIG],
-[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
-
-# Is the compiler the GNU C compiler?
-with_gcc=$_LT_AC_TAGVAR(GCC, $1)
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names.  First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
-archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
-module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
-
-# Symbols that must always be exported.
-include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
-
-ifelse([$1],[],
-[# ### END LIBTOOL CONFIG],
-[# ### END LIBTOOL TAG CONFIG: $tagname])
-
-__EOF__
-
-ifelse([$1],[], [
-  case $host_os in
-  aix3*)
-    cat <<\EOF >> "$cfgfile"
-
-# AIX sometimes has problems with the GCC collect2 program.  For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
-  COLLECT_NAMES=
-  export COLLECT_NAMES
-fi
-EOF
-    ;;
-  esac
-
-  # We use sed instead of cat because bash on DJGPP gets confused if
-  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
-  # text mode, it properly converts lines to CR/LF.  This bash problem
-  # is reportedly fixed, but why not run on old versions too?
-  sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
-
-  mv -f "$cfgfile" "$ofile" || \
-    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
-  chmod +x "$ofile"
-])
-else
-  # If there is no Makefile yet, we rely on a make rule to execute
-  # `config.status --recheck' to rerun these tests and create the
-  # libtool script then.
-  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
-  if test -f "$ltmain_in"; then
-    test -f Makefile && make "$ltmain"
-  fi
-fi
-])# AC_LIBTOOL_CONFIG
-
-
-# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
-# -------------------------------------------
-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-
-_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-
-if test "$GCC" = yes; then
-  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
-
-  AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
-    lt_cv_prog_compiler_rtti_exceptions,
-    [-fno-rtti -fno-exceptions], [],
-    [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
-fi
-])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
-
-
-# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-# ---------------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
-[AC_REQUIRE([AC_CANONICAL_HOST])
-AC_REQUIRE([AC_PROG_NM])
-AC_REQUIRE([AC_OBJEXT])
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-AC_MSG_CHECKING([command to parse $NM output from $compiler object])
-AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
-[
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[[BCDEGRST]]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
-
-# Transform an extracted symbol line into a proper C declaration
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
-
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
-
-# Define system-specific variables.
-case $host_os in
-aix*)
-  symcode='[[BCDT]]'
-  ;;
-cygwin* | mingw* | pw32*)
-  symcode='[[ABCDGISTW]]'
-  ;;
-hpux*) # Its linker distinguishes data from code symbols
-  if test "$host_cpu" = ia64; then
-    symcode='[[ABCDEGRST]]'
-  fi
-  lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
-  lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
-  ;;
-linux*)
-  if test "$host_cpu" = ia64; then
-    symcode='[[ABCDGIRSTW]]'
-    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
-    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
-  fi
-  ;;
-irix* | nonstopux*)
-  symcode='[[BCDEGRST]]'
-  ;;
-osf*)
-  symcode='[[BCDEGQRST]]'
-  ;;
-solaris*)
-  symcode='[[BDRT]]'
-  ;;
-sco3.2v5*)
-  symcode='[[DT]]'
-  ;;
-sysv4.2uw2*)
-  symcode='[[DT]]'
-  ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
-  symcode='[[ABDT]]'
-  ;;
-sysv4)
-  symcode='[[DFNSTU]]'
-  ;;
-esac
-
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
-  opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
-  ;;
-esac
-
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
-  symcode='[[ABCDGIRSTW]]' ;;
-esac
-
-# Try without a prefix undercore, then with it.
-for ac_symprfx in "" "_"; do
-
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
-
-  # Write the raw and C identifiers.
-  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[     ]]\($symcode$symcode*\)[[       ]][[    ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
-
-  # Check to see that the pipe works correctly.
-  pipe_works=no
-
-  rm -f conftest*
-  cat > conftest.$ac_ext <<EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-EOF
-
-  if AC_TRY_EVAL(ac_compile); then
-    # Now try to grab the symbols.
-    nlist=conftest.nm
-    if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
-      # Try sorting and uniquifying the output.
-      if sort "$nlist" | uniq > "$nlist"T; then
-       mv -f "$nlist"T "$nlist"
-      else
-       rm -f "$nlist"T
-      fi
-
-      # Make sure that we snagged all the symbols we need.
-      if grep ' nm_test_var$' "$nlist" >/dev/null; then
-       if grep ' nm_test_func$' "$nlist" >/dev/null; then
-         cat <<EOF > conftest.$ac_ext
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-EOF
-         # Now generate the symbol file.
-         eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
-
-         cat <<EOF >> conftest.$ac_ext
-#if defined (__STDC__) && __STDC__
-# define lt_ptr_t void *
-#else
-# define lt_ptr_t char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-const struct {
-  const char *name;
-  lt_ptr_t address;
-}
-lt_preloaded_symbols[[]] =
-{
-EOF
-         $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
-         cat <<\EOF >> conftest.$ac_ext
-  {0, (lt_ptr_t) 0}
-};
-
-#ifdef __cplusplus
-}
-#endif
-EOF
-         # Now try linking the two files.
-         mv conftest.$ac_objext conftstm.$ac_objext
-         lt_save_LIBS="$LIBS"
-         lt_save_CFLAGS="$CFLAGS"
-         LIBS="conftstm.$ac_objext"
-         CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
-         if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
-           pipe_works=yes
-         fi
-         LIBS="$lt_save_LIBS"
-         CFLAGS="$lt_save_CFLAGS"
-       else
-         echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
-       fi
-      else
-       echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
-      fi
-    else
-      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
-    fi
-  else
-    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
-    cat conftest.$ac_ext >&5
-  fi
-  rm -f conftest* conftst*
-
-  # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
-    break
-  else
-    lt_cv_sys_global_symbol_pipe=
-  fi
-done
-])
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
-  lt_cv_sys_global_symbol_to_cdecl=
-fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
-  AC_MSG_RESULT(failed)
-else
-  AC_MSG_RESULT(ok)
-fi
-]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-
-
-# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
-# ---------------------------------------
-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
-[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
-_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
-_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
-
-AC_MSG_CHECKING([for $compiler option to produce PIC])
- ifelse([$1],[CXX],[
-  # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
-    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-
-    case $host_os in
-    aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-       # AIX 5 now supports IA64 processor
-       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      fi
-      ;;
-    amigaos*)
-      # FIXME: we need at least 68020 code to build shared libraries, but
-      # adding the `-m68020' flag to GCC prevents building anything better,
-      # like `-m68040'.
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
-      ;;
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
-    mingw* | os2* | pw32*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
-      ;;
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
-      ;;
-    *djgpp*)
-      # DJGPP does not support shared libraries at all
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
-      ;;
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-    sysv4*MP*)
-      if test -d /usr/nec; then
-       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
-      fi
-      ;;
-    hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-       ;;
-      *)
-       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-       ;;
-      esac
-      ;;
-    *)
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-      ;;
-    esac
-  else
-    case $host_os in
-      aix4* | aix5*)
-       # All AIX code is PIC.
-       if test "$host_cpu" = ia64; then
-         # AIX 5 now supports IA64 processor
-         _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-       else
-         _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
-       fi
-       ;;
-      chorus*)
-       case $cc_basename in
-       cxch68*)
-         # Green Hills C++ Compiler
-         # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
-         ;;
-       esac
-       ;;
-       darwin*)
-         # PIC is the default on this platform
-         # Common symbols not allowed in MH_DYLIB files
-         case $cc_basename in
-           xlc*)
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-           ;;
-         esac
-       ;;
-      dgux*)
-       case $cc_basename in
-         ec++*)
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-           ;;
-         ghcx*)
-           # Green Hills C++ Compiler
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
-           ;;
-         *)
-           ;;
-       esac
-       ;;
-      freebsd* | kfreebsd*-gnu | dragonfly*)
-       # FreeBSD uses GNU C++
-       ;;
-      hpux9* | hpux10* | hpux11*)
-       case $cc_basename in
-         CC*)
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-           if test "$host_cpu" != ia64; then
-             _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
-           fi
-           ;;
-         aCC*)
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-           case $host_cpu in
-           hppa*64*|ia64*)
-             # +Z the default
-             ;;
-           *)
-             _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
-             ;;
-           esac
-           ;;
-         *)
-           ;;
-       esac
-       ;;
-      interix*)
-       # This is c89, which is MS Visual C++ (no shared libs)
-       # Anyone wants to do a port?
-       ;;
-      irix5* | irix6* | nonstopux*)
-       case $cc_basename in
-         CC*)
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-           # CC pic flag -KPIC is the default.
-           ;;
-         *)
-           ;;
-       esac
-       ;;
-      linux*)
-       case $cc_basename in
-         KCC*)
-           # KAI C++ Compiler
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-           ;;
-         icpc* | ecpc*)
-           # Intel C++
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-           ;;
-         pgCC*)
-           # Portland Group C++ compiler.
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-           ;;
-         cxx*)
-           # Compaq C++
-           # Make sure the PIC flag is empty.  It appears that all Alpha
-           # Linux and Compaq Tru64 Unix objects are PIC.
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
-           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-           ;;
-         *)
-           ;;
-       esac
-       ;;
-      lynxos*)
-       ;;
-      m88k*)
-       ;;
-      mvs*)
-       case $cc_basename in
-         cxx*)
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
-           ;;
-         *)
-           ;;
-       esac
-       ;;
-      netbsd*)
-       ;;
-      osf3* | osf4* | osf5*)
-       case $cc_basename in
-         KCC*)
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
-           ;;
-         RCC*)
-           # Rational C++ 2.4.1
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
-           ;;
-         cxx*)
-           # Digital/Compaq C++
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-           # Make sure the PIC flag is empty.  It appears that all Alpha
-           # Linux and Compaq Tru64 Unix objects are PIC.
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
-           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-           ;;
-         *)
-           ;;
-       esac
-       ;;
-      psos*)
-       ;;
-      solaris*)
-       case $cc_basename in
-         CC*)
-           # Sun C++ 4.2, 5.x and Centerline C++
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
-           ;;
-         gcx*)
-           # Green Hills C++ Compiler
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
-           ;;
-         *)
-           ;;
-       esac
-       ;;
-      sunos4*)
-       case $cc_basename in
-         CC*)
-           # Sun C++ 4.x
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
-           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-           ;;
-         lcc*)
-           # Lucid
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
-           ;;
-         *)
-           ;;
-       esac
-       ;;
-      tandem*)
-       case $cc_basename in
-         NCC*)
-           # NonStop-UX NCC 3.20
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-           ;;
-         *)
-           ;;
-       esac
-       ;;
-      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-       case $cc_basename in
-         CC*)
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-           ;;
-       esac
-       ;;
-      vxworks*)
-       ;;
-      *)
-       _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
-       ;;
-    esac
-  fi
-],
-[
-  if test "$GCC" = yes; then
-    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-       # AIX 5 now supports IA64 processor
-       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      fi
-      ;;
-
-    amigaos*)
-      # FIXME: we need at least 68020 code to build shared libraries, but
-      # adding the `-m68020' flag to GCC prevents building anything better,
-      # like `-m68040'.
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
-      ;;
-
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
-
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
-      ;;
-
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
-      ;;
-
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
-      enable_shared=no
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
-      fi
-      ;;
-
-    hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-       # +Z the default
-       ;;
-      *)
-       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-       ;;
-      esac
-      ;;
-
-    *)
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-      ;;
-    esac
-  else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      if test "$host_cpu" = ia64; then
-       # AIX 5 now supports IA64 processor
-       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      else
-       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
-         _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-         ;;
-       esac
-       ;;
-
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
-      ;;
-
-    hpux9* | hpux10* | hpux11*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-       # +Z the default
-       ;;
-      *)
-       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
-       ;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      # PIC (with -KPIC) is the default.
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-      ;;
-
-    newsos6)
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      ;;
-
-    linux*)
-      case $cc_basename in
-      icc* | ecc*)
-       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-        ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-       # which looks to be a dead project)
-       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-        ;;
-      ccc*)
-        _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-        # All Alpha code is PIC.
-        _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-        ;;
-      esac
-      ;;
-
-    osf3* | osf4* | osf5*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      # All OSF/1 code is PIC.
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-      ;;
-
-    solaris*)
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
-      *)
-       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
-      esac
-      ;;
-
-    sunos4*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      ;;
-
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec ;then
-       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
-       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      fi
-      ;;
-
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      ;;
-
-    unicos*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
-      ;;
-
-    uts4*)
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      ;;
-
-    *)
-      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
-      ;;
-    esac
-  fi
-])
-AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
-  AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
-    _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
-    [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
-    [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
-     "" | " "*) ;;
-     *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
-     esac],
-    [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
-     _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
-fi
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
-    ;;
-  *)
-    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
-    ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
-AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
-  _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
-  $lt_tmp_static_flag,
-  [],
-  [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
-])
-
-
-# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
-# ------------------------------------
-# See if the linker supports building shared libraries.
-AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
-[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-ifelse([$1],[CXX],[
-  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  case $host_os in
-  aix4* | aix5*)
-    # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
-      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
-    else
-      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
-    fi
-    ;;
-  pw32*)
-    _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
-  ;;
-  cygwin* | mingw*)
-    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
-  ;;
-  *)
-    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  ;;
-  esac
-],[
-  runpath_var=
-  _LT_AC_TAGVAR(allow_undefined_flag, $1)=
-  _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-  _LT_AC_TAGVAR(archive_cmds, $1)=
-  _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-  _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
-  _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
-  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-  _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
-  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-  _LT_AC_TAGVAR(hardcode_direct, $1)=no
-  _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-  _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-  _LT_AC_TAGVAR(hardcode_automatic, $1)=no
-  _LT_AC_TAGVAR(module_cmds, $1)=
-  _LT_AC_TAGVAR(module_expsym_cmds, $1)=
-  _LT_AC_TAGVAR(always_export_symbols, $1)=no
-  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  _LT_AC_TAGVAR(include_expsyms, $1)=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
-  _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  _LT_CC_BASENAME([$compiler])
-  case $host_os in
-  cygwin* | mingw* | pw32*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test "$GCC" != yes; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd*)
-    with_gnu_ld=no
-    ;;
-  esac
-
-  _LT_AC_TAGVAR(ld_shlibs, $1)=yes
-  if test "$with_gnu_ld" = yes; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
-
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
-    # See if GNU ld supports shared libraries.
-    case $host_os in
-    aix3* | aix4* | aix5*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
-      fi
-      ;;
-
-    amigaos*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-
-      # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
-      # that the semantics of dynamic libraries on AmigaOS, at least up
-      # to version 4, is to share data among multiple programs linked
-      # with the same dynamic library.  Since this doesn't match the
-      # behavior of shared libraries on other platforms, we can't use
-      # them.
-      _LT_AC_TAGVAR(ld_shlibs, $1)=no
-      ;;
-
-    beos*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-       _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
-       # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
-       # support --undefined.  This deserves some investigation.  FIXME
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      else
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
-    cygwin* | mingw* | pw32*)
-      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
-      # as there is no search path for DLLs.
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_AC_TAGVAR(always_export_symbols, $1)=no
-      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
-
-      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-       # If the export-symbols file already is a .def file (1st line
-       # is EXPORTS), use it as is; otherwise, prepend...
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-         cp $export_symbols $output_objdir/$soname.def;
-       else
-         echo EXPORTS > $output_objdir/$soname.def;
-         cat $export_symbols >> $output_objdir/$soname.def;
-       fi~
-       $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
-    interix3*)
-      _LT_AC_TAGVAR(hardcode_direct, $1)=no
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
-
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-       tmp_addflag=
-       case $cc_basename,$host_cpu in
-       pgcc*)                          # Portland Group C compiler
-         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-         tmp_addflag=' $pic_flag'
-         ;;
-       pgf77* | pgf90* | pgf95*)       # Portland Group f77 and f90 compilers
-         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-         tmp_addflag=' $pic_flag -Mnomain' ;;
-       ecc*,ia64* | icc*,ia64*)                # Intel C compiler on ia64
-         tmp_addflag=' -i_dynamic' ;;
-       efc*,ia64* | ifort*,ia64*)      # Intel Fortran compiler on ia64
-         tmp_addflag=' -i_dynamic -nofor_main' ;;
-       ifc* | ifort*)                  # Intel Fortran compiler
-         tmp_addflag=' -nofor_main' ;;
-       esac
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-       if test $supports_anon_versioning = yes; then
-         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-         $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-       fi
-      else
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-       wlarc=
-      else
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
-      ;;
-
-    solaris*)
-      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
-      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) 
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-       cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
-       ;;
-       *)
-         if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-           _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
-           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
-           _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
-         else
-           _LT_AC_TAGVAR(ld_shlibs, $1)=no
-         fi
-       ;;
-      esac
-      ;;
-
-    sunos4*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    *)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-       _LT_AC_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-    esac
-
-    if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
-      runpath_var=
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-    fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_AC_TAGVAR(always_export_symbols, $1)=yes
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
-       # Neither direct hardcoding nor static linking is supported with a
-       # broken collect2.
-       _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
-      fi
-      ;;
-
-    aix4* | aix5*)
-      if test "$host_cpu" = ia64; then
-       # On IA64, the linker does run time linking by default, so we don't
-       # have to do anything special.
-       aix_use_runtimelinking=no
-       exp_sym_flag='-Bexport'
-       no_entry_flag=""
-      else
-       # If we're using GNU nm, then we don't want the "-C" option.
-       # -C means demangle to AIX nm, but means don't demangle with GNU nm
-       if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
-         _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
-       else
-         _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
-       fi
-       aix_use_runtimelinking=no
-
-       # Test if we are trying to use run time linking or normal
-       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-       # need to do runtime linking.
-       case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
-         for ld_flag in $LDFLAGS; do
-         if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
-           aix_use_runtimelinking=yes
-           break
-         fi
-         done
-         ;;
-       esac
-
-       exp_sym_flag='-bexport'
-       no_entry_flag='-bnoentry'
-      fi
-
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
-      _LT_AC_TAGVAR(archive_cmds, $1)=''
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
-      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
-      if test "$GCC" = yes; then
-       case $host_os in aix4.[[012]]|aix4.[[012]].*)
-       # We only want to do this on AIX 4.2 and lower, the check
-       # below for broken collect2 doesn't work under 4.3+
-         collect2name=`${CC} -print-prog-name=collect2`
-         if test -f "$collect2name" && \
-          strings "$collect2name" | grep resolve_lib_name >/dev/null
-         then
-         # We have reworked collect2
-         _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-         else
-         # We have old collect2
-         _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
-         # It fails to find uninstalled libraries when the uninstalled
-         # path is not listed in the libpath.  Setting hardcode_minus_L
-         # to unsupported forces relinking
-         _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-         fi
-         ;;
-       esac
-       shared_flag='-shared'
-       if test "$aix_use_runtimelinking" = yes; then
-         shared_flag="$shared_flag "'${wl}-G'
-       fi
-      else
-       # not using gcc
-       if test "$host_cpu" = ia64; then
-       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-       # chokes on -Wl,-G. The following line is correct:
-         shared_flag='-G'
-       else
-         if test "$aix_use_runtimelinking" = yes; then
-           shared_flag='${wl}-G'
-         else
-           shared_flag='${wl}-bM:SRE'
-         fi
-       fi
-      fi
-
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      _LT_AC_TAGVAR(always_export_symbols, $1)=yes
-      if test "$aix_use_runtimelinking" = yes; then
-       # Warning - without using the other runtime loading flags (-brtl),
-       # -berok will link without error, but may produce a broken library.
-       _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
-       # Determine the default libpath from the value encoded in an empty executable.
-       _LT_AC_SYS_LIBPATH_AIX
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-       else
-       if test "$host_cpu" = ia64; then
-         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-         _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-       else
-        # Determine the default libpath from the value encoded in an empty executable.
-        _LT_AC_SYS_LIBPATH_AIX
-        _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-         # Warning - without using the other run time loading flags,
-         # -berok will link without error, but may produce a broken library.
-         _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-         # Exported symbols can be pulled into shared objects from archives
-         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
-         _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-         # This is similar to how AIX traditionally builds its shared libraries.
-         _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-       fi
-      fi
-      ;;
-
-    amigaos*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-      # see comment about different semantics on the GNU ld section
-      _LT_AC_TAGVAR(ld_shlibs, $1)=no
-      ;;
-
-    bsdi[[45]]*)
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
-      ;;
-
-    cygwin* | mingw* | pw32*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
-      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
-      # Tell ltmain to make .lib files, not .a files.
-      libext=lib
-      # Tell ltmain to make .dll files, not .so files.
-      shrext_cmds=".dll"
-      # FIXME: Setting linknames here is a bad hack.
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
-      # The linker will automatically build a .lib file if we build a DLL.
-      _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
-      # FIXME: Should let the user specify the lib program.
-      _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
-      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-      ;;
-
-    darwin* | rhapsody*)
-      case $host_os in
-        rhapsody* | darwin1.[[012]])
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[[012]])
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-      esac
-      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-      _LT_AC_TAGVAR(hardcode_direct, $1)=no
-      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
-      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-    if test "$GCC" = yes ; then
-       output_verbose_link_cmd='echo'
-        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-    else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         _LT_AC_TAGVAR(ld_shlibs, $1)=no
-          ;;
-      esac
-    fi
-      ;;
-
-    dgux*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    freebsd1*)
-      _LT_AC_TAGVAR(ld_shlibs, $1)=no
-      ;;
-
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    hpux9*)
-      if test "$GCC" = yes; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-       _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      fi
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-      ;;
-
-    hpux10*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-       _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-
-       # hardcode_minus_L: Not really in the search PATH,
-       # but as the default location of the library.
-       _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-      fi
-      ;;
-
-    hpux11*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-       case $host_cpu in
-       hppa*64*)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-         ;;
-       ia64*)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-         ;;
-       *)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-         ;;
-       esac
-      else
-       case $host_cpu in
-       hppa*64*)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-         ;;
-       ia64*)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-         ;;
-       *)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-         ;;
-       esac
-      fi
-      if test "$with_gnu_ld" = no; then
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-       case $host_cpu in
-       hppa*64*|ia64*)
-         _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
-         _LT_AC_TAGVAR(hardcode_direct, $1)=no
-         _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-         ;;
-       *)
-         _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-         _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-
-         # hardcode_minus_L: Not really in the search PATH,
-         # but as the default location of the library.
-         _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-         ;;
-       esac
-      fi
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
-      fi
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-      ;;
-
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    newsos6)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    openbsd*)
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-      else
-       case $host_os in
-        openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
-          _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-          _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-          ;;
-        *)
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-          _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-          ;;
-       esac
-      fi
-      ;;
-
-    os2*)
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
-      ;;
-
-    osf3*)
-      if test "$GCC" = yes; then
-       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-      fi
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-      ;;
-
-    osf4* | osf5*)     # as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-      else
-       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-       $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
-       # Both c and cxx compiler support -rpath directly
-       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
-      fi
-      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-      ;;
-
-    solaris*)
-      _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
-      if test "$GCC" = yes; then
-       wlarc='${wl}'
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-         $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
-      else
-       wlarc=''
-       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-       $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
-      fi
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      case $host_os in
-      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
-      *)
-       # The compiler driver will combine linker options so we
-       # cannot just pass the convience library names through
-       # without $wl, iff we do not link with $LD.
-       # Luckily, gcc supports the same syntax we need for Sun Studio.
-       # Supported since Solaris 2.6 (maybe 2.5.1?)
-       case $wlarc in
-       '')
-         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
-       *)
-         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
-       esac ;;
-      esac
-      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-      ;;
-
-    sunos4*)
-      if test "x$host_vendor" = xsequent; then
-       # Use $CC to link under sequent, because it throws in some extra .o
-       # files that make .init and .fini sections work.
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    sysv4)
-      case $host_vendor in
-       sni)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-         _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
-       ;;
-       siemens)
-         ## LD is ld it makes a PLAMLIB
-         ## CC just makes a GrossModule.
-         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-         _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
-         _LT_AC_TAGVAR(hardcode_direct, $1)=no
-        ;;
-       motorola)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-         _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
-       ;;
-      esac
-      runpath_var='LD_RUN_PATH'
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    sysv4.3*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-       runpath_var=LD_RUN_PATH
-       hardcode_runpath_var=yes
-       _LT_AC_TAGVAR(ld_shlibs, $1)=yes
-      fi
-      ;;
-
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*)
-      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
-      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
-      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    uts4*)
-      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    *)
-      _LT_AC_TAGVAR(ld_shlibs, $1)=no
-      ;;
-    esac
-  fi
-])
-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
-x|xyes)
-  # Assume -lc should be added
-  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $_LT_AC_TAGVAR(archive_cmds, $1) in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      AC_MSG_CHECKING([whether -lc should be explicitly linked in])
-      $rm conftest*
-      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-      if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
-        soname=conftest
-        lib=conftest
-        libobjs=conftest.$ac_objext
-        deplibs=
-        wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
-       pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
-        compiler_flags=-v
-        linker_flags=-v
-        verstring=
-        output_objdir=.
-        libname=conftest
-        lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
-        _LT_AC_TAGVAR(allow_undefined_flag, $1)=
-        if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
-        then
-         _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-        else
-         _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-        fi
-        _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
-      else
-        cat conftest.err 1>&5
-      fi
-      $rm conftest*
-      AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
-      ;;
-    esac
-  fi
-  ;;
-esac
-])# AC_LIBTOOL_PROG_LD_SHLIBS
-
-
-# _LT_AC_FILE_LTDLL_C
-# -------------------
-# Be careful that the start marker always follows a newline.
-AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
-# /* ltdll.c starts here */
-# #define WIN32_LEAN_AND_MEAN
-# #include <windows.h>
-# #undef WIN32_LEAN_AND_MEAN
-# #include <stdio.h>
-#
-# #ifndef __CYGWIN__
-# #  ifdef __CYGWIN32__
-# #    define __CYGWIN__ __CYGWIN32__
-# #  endif
-# #endif
-#
-# #ifdef __cplusplus
-# extern "C" {
-# #endif
-# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
-# #ifdef __cplusplus
-# }
-# #endif
-#
-# #ifdef __CYGWIN__
-# #include <cygwin/cygwin_dll.h>
-# DECLARE_CYGWIN_DLL( DllMain );
-# #endif
-# HINSTANCE __hDllInstance_base;
-#
-# BOOL APIENTRY
-# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
-# {
-#   __hDllInstance_base = hInst;
-#   return TRUE;
-# }
-# /* ltdll.c ends here */
-])# _LT_AC_FILE_LTDLL_C
-
-
-# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
-# ---------------------------------
-AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
-
-
-# old names
-AC_DEFUN([AM_PROG_LIBTOOL],   [AC_PROG_LIBTOOL])
-AC_DEFUN([AM_ENABLE_SHARED],  [AC_ENABLE_SHARED($@)])
-AC_DEFUN([AM_ENABLE_STATIC],  [AC_ENABLE_STATIC($@)])
-AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
-AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
-AC_DEFUN([AM_PROG_LD],        [AC_PROG_LD])
-AC_DEFUN([AM_PROG_NM],        [AC_PROG_NM])
-
-# This is just to silence aclocal about the macro not being used
-ifelse([AC_DISABLE_FAST_INSTALL])
-
-AC_DEFUN([LT_AC_PROG_GCJ],
-[AC_CHECK_TOOL(GCJ, gcj, no)
-  test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
-  AC_SUBST(GCJFLAGS)
-])
-
-AC_DEFUN([LT_AC_PROG_RC],
-[AC_CHECK_TOOL(RC, windres, no)
-])
-
-############################################################
-# NOTE: This macro has been submitted for inclusion into   #
-#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
-#  a released version of Autoconf we should remove this    #
-#  macro and use it instead.                               #
-############################################################
-# LT_AC_PROG_SED
-# --------------
-# Check for a fully-functional sed program, that truncates
-# as few characters as possible.  Prefer GNU sed if found.
-AC_DEFUN([LT_AC_PROG_SED],
-[AC_MSG_CHECKING([for a sed that does not truncate output])
-AC_CACHE_VAL(lt_cv_path_SED,
-[# Loop through the user's path and test for sed and gsed.
-# Then use that list of sed's as ones to test for truncation.
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for lt_ac_prog in sed gsed; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
-        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
-      fi
-    done
-  done
-done
-lt_ac_max=0
-lt_ac_count=0
-# Add /usr/xpg4/bin/sed as it is typically found on Solaris
-# along with /bin/sed that truncates output.
-for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
-  cat /dev/null > conftest.in
-  lt_ac_count=0
-  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
-  # Check for GNU sed and select it if it is found.
-  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
-    lt_cv_path_SED=$lt_ac_sed
-    break
-  fi
-  while true; do
-    cat conftest.in conftest.in >conftest.tmp
-    mv conftest.tmp conftest.in
-    cp conftest.in conftest.nl
-    echo >>conftest.nl
-    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
-    cmp -s conftest.out conftest.nl || break
-    # 10000 chars as input seems more than enough
-    test $lt_ac_count -gt 10 && break
-    lt_ac_count=`expr $lt_ac_count + 1`
-    if test $lt_ac_count -gt $lt_ac_max; then
-      lt_ac_max=$lt_ac_count
-      lt_cv_path_SED=$lt_ac_sed
-    fi
-  done
-done
-])
-SED=$lt_cv_path_SED
-AC_MSG_RESULT([$SED])
-])
diff --git a/src/mm/boehm-gc/m4/dummy b/src/mm/boehm-gc/m4/dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/mm/boehm-gc/mkinstalldirs b/src/mm/boehm-gc/mkinstalldirs
deleted file mode 100755 (executable)
index 82a561f..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-#! /bin/sh
-# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman@prep.ai.mit.edu>
-# Created: 1993-05-16
-# Public domain
-
-# $Id: mkinstalldirs,v 1.1.1.1 2005/10/10 22:33:34 hboehm Exp $
-
-errstatus=0
-dirmode=""
-
-usage="\
-Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
-
-# process command line arguments
-while test $# -gt 0 ; do
-   case "${1}" in
-     -h | --help | --h* )                      # -h for help
-       echo "${usage}" 1>&2; exit 0 ;;
-     -m )                                      # -m PERM arg
-       shift
-       test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
-       dirmode="${1}"
-       shift ;;
-     -- ) shift; break ;;                      # stop option processing
-     -* ) echo "${usage}" 1>&2; exit 1 ;;      # unknown option
-     * )  break ;;                             # first non-opt arg
-   esac
-done
-
-for file
-do
-  if test -d "$file"; then
-    shift
-  else
-    break
-  fi
-done
-
-case $# in
-0) exit 0 ;;
-esac
-
-case $dirmode in
-'')
-  if mkdir -p -- . 2>/dev/null; then
-    echo "mkdir -p -- $*"
-    exec mkdir -p -- "$@"
-  fi ;;
-*)
-  if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
-    echo "mkdir -m $dirmode -p -- $*"
-    exec mkdir -m "$dirmode" -p -- "$@"
-  fi ;;
-esac
-
-for file
-do
-   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
-   shift
-
-   pathcomp=
-   for d
-   do
-     pathcomp="$pathcomp$d"
-     case "$pathcomp" in
-       -* ) pathcomp=./$pathcomp ;;
-     esac
-
-     if test ! -d "$pathcomp"; then
-       echo "mkdir $pathcomp"
-
-       mkdir "$pathcomp" || lasterr=$?
-
-       if test ! -d "$pathcomp"; then
-         errstatus=$lasterr
-       else
-         if test ! -z "$dirmode"; then
-            echo "chmod $dirmode $pathcomp"
-
-            lasterr=""
-            chmod "$dirmode" "$pathcomp" || lasterr=$?
-
-            if test ! -z "$lasterr"; then
-              errstatus=$lasterr
-            fi
-         fi
-       fi
-     fi
-
-     pathcomp="$pathcomp/"
-   done
-done
-
-exit $errstatus
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 3
-# End:
-# mkinstalldirs ends here
index 85fa531cb193f6b1f53d2bc0fa6a60792641d5d8..30ad9bef53ca8bad92d49fac06f3d7a965ef74aa 100644 (file)
@@ -372,9 +372,6 @@ int GC_suspend_all()
     return n_live_threads;
 }
 
-void lock_stopworld(int);
-void unlock_stopworld();
-
 void GC_stop_world()
 {
     int i;
@@ -561,16 +558,4 @@ void GC_stop_init() {
       }
 }
 
-/* Added for cacao */
-int GC_signum1()
-{
-    return SIG_SUSPEND;
-}
-
-int GC_signum2()
-{
-    return SIG_THR_RESTART;
-}
-/* cacao END */
-
 #endif
diff --git a/src/mm/boehm.c b/src/mm/boehm.c
deleted file mode 100644 (file)
index 411cb6c..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-/* src/mm/boehm.c - interface for boehm gc
-
-   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 <stdint.h>
-
-#if defined(ENABLE_THREADS) && defined(__LINUX__)
-#define GC_LINUX_THREADS
-#endif
-#if defined(ENABLE_THREADS) && defined(__IRIX__)
-#define GC_IRIX_THREADS
-#endif
-#if defined(ENABLE_THREADS) && defined(__DARWIN__)
-#define GC_DARWIN_THREADS
-#endif
-
-#include "boehm-gc/include/gc.h"
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/finalizer.h"
-#include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/rt-timing.h"
-
-
-/* global variables ***********************************************************/
-
-static bool in_gc_out_of_memory = false;    /* is GC out of memory?           */
-
-
-/* prototype static functions *************************************************/
-
-static void gc_ignore_warnings(char *msg, GC_word arg);
-
-
-/* gc_init *********************************************************************
-
-   Initializes the boehm garbage collector.
-
-*******************************************************************************/
-
-void gc_init(size_t heapmaxsize, size_t heapstartsize)
-{
-       size_t heapcurrentsize;
-
-       TRACESUBSYSTEMINITIALIZATION("gc_init");
-
-       /* just to be sure (should be set to 1 by JAVA_FINALIZATION macro) */
-
-       GC_java_finalization = 1;
-
-       /* Ignore pointers that do not point to the start of an object. */
-
-       GC_all_interior_pointers = 0;
-
-       /* suppress warnings */
-
-       GC_set_warn_proc(gc_ignore_warnings);
-
-       /* install a GC notifier */
-
-       GC_finalize_on_demand = 1;
-       GC_finalizer_notifier = finalizer_notify;
-
-       /* define OOM function */
-
-       GC_oom_fn = gc_out_of_memory;
-
-       GC_INIT();
-
-       /* set the maximal heap size */
-
-       GC_set_max_heap_size(heapmaxsize);
-
-       /* set the initial heap size */
-
-       heapcurrentsize = GC_get_heap_size();
-
-       if (heapstartsize > heapcurrentsize)
-               GC_expand_hp(heapstartsize - heapcurrentsize);
-}
-
-
-static void gc_ignore_warnings(char *msg, GC_word arg)
-{
-}
-
-
-void *heap_alloc_uncollectable(size_t size)
-{
-       void *p;
-
-       p = GC_MALLOC_UNCOLLECTABLE(size);
-
-       /* clear allocated memory region */
-
-       MSET(p, 0, uint8_t, size);
-
-       return p;
-}
-
-
-/* heap_alloc ******************************************************************
-
-   Allocates memory on the Java heap.
-
-*******************************************************************************/
-
-void *heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect)
-{
-       void *p;
-#if defined(ENABLE_RT_TIMING)
-       struct timespec time_start, time_end;
-#endif
-
-       RT_TIMING_GET_TIME(time_start);
-
-       /* We can't use a bool here for references, as it's passed as a
-          bitmask in builtin_new.  Thus we check for != 0. */
-
-       if (references != 0)
-               p = GC_MALLOC(size);
-       else
-               p = GC_MALLOC_ATOMIC(size);
-
-       if (p == NULL)
-               return NULL;
-
-       if (finalizer != NULL)
-               GC_REGISTER_FINALIZER_NO_ORDER(p, finalizer_run, 0, 0, 0);
-
-       /* clear allocated memory region */
-
-       MSET(p, 0, uint8_t, size);
-
-       RT_TIMING_GET_TIME(time_end);
-       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_GC_ALLOC);
-
-       return p;
-}
-
-
-void heap_free(void *p)
-{
-       GC_FREE(p);
-}
-
-void gc_call(void)
-{
-       if (opt_verbosegc)
-               dolog("Garbage Collection:  previous/now = %d / %d ",
-                         0, 0);
-
-       GC_gcollect();
-}
-
-
-int64_t gc_get_heap_size(void)
-{
-       return GC_get_heap_size();
-}
-
-
-int64_t gc_get_free_bytes(void)
-{
-       return GC_get_free_bytes();
-}
-
-
-/* gc_get_total_bytes **********************************************************
-
-   Returns the number of total bytes currently used on the Java heap.
-
-*******************************************************************************/
-
-int64_t gc_get_total_bytes(void)
-{
-       return GC_get_total_bytes();
-}
-
-
-int64_t gc_get_max_heap_size(void)
-{
-       return GC_get_max_heap_size();
-}
-
-
-void gc_invoke_finalizers(void)
-{
-       GC_invoke_finalizers();
-}
-
-
-void gc_finalize_all(void)
-{
-       GC_finalize_all();
-}
-
-
-/* gc_out_of_memory ************************************************************
-
-   This function is called when boehm detects that it is OOM.
-
-*******************************************************************************/
-
-void *gc_out_of_memory(size_t bytes_requested)
-{
-       /* if this happens, we are REALLY out of memory */
-
-       if (in_gc_out_of_memory) {
-               /* this is all we can do... */
-               vm_abort("gc_out_of_memory: out of memory");
-       }
-
-       in_gc_out_of_memory = true;
-
-       /* try to release some memory */
-
-       gc_call();
-
-       /* now instantiate the exception */
-
-       exceptions_throw_outofmemoryerror();
-
-       in_gc_out_of_memory = false;
-
-       return NULL;
-}
-
-
-/*
- * 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:
- */
index fb0d77342dcf9334513c1a576d05cb53dbed4306..b895797e4305c9ac5a9b6b854ae9b19b26c086eb 100644 (file)
@@ -1,9 +1,7 @@
 /* mm/cacao-gc/final.c - GC module for finalization and weak references
 
-   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.
 
index 8987073fe1a31e8cdfdbc966f6ec45b6fd994885..d6798b29a772bcf0390bcd22994a706db6250470 100644 (file)
@@ -1,9 +1,7 @@
 /* mm/cacao-gc/final.h - GC header for finalization and weak references
 
-   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.
 
 #ifndef _FINAL_H
 #define _FINAL_H
 
+#include "config.h"
 #include "vm/types.h"
 
-#include "toolbox/list.h"
-#include "vmcore/method.h"
+#include "toolbox/list.hpp"
+#include "vm/method.hpp"
 
 
 /* Global Variables ***********************************************************/
index 1f8f5db417ab966ca231be28a922a910a92e961e..e9fd6d50f66e34a5f5232eff0da07d1cb7bcaf71 100644 (file)
@@ -30,8 +30,8 @@
 
 #include "vm/types.h"
 
-#include "threads/lock-common.h"
-#include "threads/thread.h"
+#include "threads/lock.hpp"
+#include "threads/thread.hpp"
 
 #include "compact.h"
 #include "copy.h"
 #include "rootset.h"
 #include "mm/memory.h"
 #include "toolbox/logging.h"
+
 #include "vm/finalizer.h"
-#include "vm/vm.h"
-#include "vmcore/rt-timing.h"
+#include "vm/rt-timing.h"
+#include "vm/vm.hpp"
 
 
 /* Global Variables ***********************************************************/
index 31060381d73868057a9a8dcbfb33960a0ee6cf40..082d8083d6e225f263e92f29fe2a12fe67bd18a3 100644 (file)
 #include "config.h"
 #include "vm/types.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "toolbox/list.h"
-#include "vm/jit/replace.h"
+#include "toolbox/list.hpp"
+#include "vm/jit/replace.hpp"
 
 
 /* Configuration Switches *****************************************************/
@@ -54,7 +54,7 @@
 
 #if !defined(NDEBUG) && defined(GC_DEBUGGING)
 # include <assert.h>
-# include "vmcore/options.h"
+# include "vm/options.h"
 # define GC_LOG(code) if (opt_verbosegc) { code; }
 # define GC_ASSERT(assertion) assert(assertion)
 #else
index 425b0dfc38286eb353155446e7d76fcdbde2be9d..22ce0691738fe9c8f42399c8e1be3bd1964972dc 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.
 
@@ -28,7 +26,7 @@
 #include "config.h"
 #include "vm/types.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
 #include "gc.h"
 #include "final.h"
 #include "native/include/java_lang_String.h"
 #include "native/llni.h"
 #include "toolbox/logging.h"
+
 #include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-#include "vmcore/options.h"
-#include "vmcore/rt-timing.h"
+#include "vm/options.h"
+#include "vm/rt-timing.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
 
 
 /* Global Variables ***********************************************************/
index f53613a363098292e9a7702d3276b1b9004adf6b..7e76976c3ebf2ccab9403c5974df39dda4fa5952 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "gc.h"
 #include "region.h"
-#include "vm/array.h" /* needed for ARRAYTYPE_OBJECT */
+#include "vm/array.hpp" /* needed for ARRAYTYPE_OBJECT */
 
 
 #define GC_SIZE_DUMMY 0xff
index c2c8a5c9b71a4896bf5b2c9743b3c9b0e91830ae..fedfb9abb750990dd7b339b972510ad343280603 100644 (file)
 #include "rootset.h"
 #include "mm/memory.h"
 #include "toolbox/logging.h"
+
 #include "vm/global.h"
-#include "vm/vm.h"
-#include "vmcore/linker.h"
+#include "vm/linker.hpp"
+#include "vm/vm.hpp"
 
 
 /* Helper Macros **************************************************************/
index 89ac2c2018b6df521a8f32f70583ca6bb55db34d..7761fa8089b0050309df666fa9c841c577b7058a 100644 (file)
 #include "mm/memory.h"
 
 #include "threads/threadlist.h"
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
 #include "toolbox/logging.h"
 
 #include "vm/global.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
 
 
 rootset_t *rootset_create(void)
index e61315f555a6fae6bdd8955515b270bcd31c65fa..5c01e9828bd744ce4ca55cd177aed98655da8a50 100644 (file)
@@ -31,10 +31,11 @@ typedef struct rootset_t rootset_t;
 #include "config.h"
 #include "vm/types.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/jit/replace.h"
-#include "vmcore/method.h"
+#include "vm/method.hpp"
+
+#include "vm/jit/replace.hpp"
 
 
 /* Structures *****************************************************************/
index 7d2fd89c867dfbda7c993c547ed614af1043c8fa..b56179221b9333c55b51f6423befe5654043ae84 100644 (file)
 #include <stdlib.h>
 #include <sys/mman.h> /* REMOVEME */
 
-#include "threads/lock-common.h"
-#include "threads/thread.h"
+#include "threads/mutex.hpp"
+#include "threads/thread.hpp"
 
 #include "mm/codememory.h"
 #include "mm/memory.h"
 
-#include "vmcore/options.h"
+#include "vm/global.h"
+#include "vm/options.h"
+#include "vm/os.hpp"
 
 #if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
+# include "vm/statistics.h"
 #endif
 
-#include "vmcore/system.h"
-
-#include "vm/global.h"
-
 
 /* global code memory variables ***********************************************/
 
 #define DEFAULT_CODE_MEMORY_SIZE    128 * 1024 /* defaulting to 128kB         */
 
 #if defined(ENABLE_THREADS)
-static java_object_t *lock_code_memory = NULL;
+static Mutex *code_memory_mutex = NULL;
 #endif
-static void          *code_memory      = NULL;
-static int            code_memory_size = 0;
-static int            pagesize         = 0;
+static void  *code_memory       = NULL;
+static int    code_memory_size  = 0;
+static int    pagesize          = 0;
 
 
 /* codememory_init *************************************************************
@@ -69,16 +67,14 @@ void codememory_init(void)
        TRACESUBSYSTEMINITIALIZATION("codememory_init");
 
 #if defined(ENABLE_THREADS)
-       /* create lock for code memory */
-
-       lock_code_memory = NEW(java_object_t);
+       /* create mutex for code memory */
 
-       lock_init_object_lock(lock_code_memory);
+       code_memory_mutex = Mutex_new();
 #endif
 
        /* Get the pagesize of this architecture. */
 
-       pagesize = system_getpagesize();
+       pagesize = os_getpagesize();
 }
 
 
@@ -93,7 +89,7 @@ void *codememory_get(size_t size)
 {
        void *p;
 
-       LOCK_MONITOR_ENTER(lock_code_memory);
+       Mutex_lock(code_memory_mutex);
 
        size = MEMORY_ALIGN(size, ALIGNSIZE);
 
@@ -124,9 +120,9 @@ void *codememory_get(size_t size)
 
                /* allocate the memory */
 
-               p = system_mmap_anonymous(NULL, code_memory_size,
-                                                                 PROT_READ | PROT_WRITE | PROT_EXEC,
-                                                                 MAP_PRIVATE);
+               p = os_mmap_anonymous(NULL, code_memory_size,
+                                                         PROT_READ | PROT_WRITE | PROT_EXEC,
+                                                         MAP_PRIVATE);
 
                /* set global code memory pointer */
 
@@ -140,7 +136,7 @@ void *codememory_get(size_t size)
        code_memory       = (void *) ((ptrint) code_memory + size);
        code_memory_size -= size;
 
-       LOCK_MONITOR_EXIT(lock_code_memory);
+       Mutex_unlock(code_memory_mutex);
 
        return p;
 }
index c9dd38393dacffdf559f92d63326236a2c814e0a..3fe3a18cb209929e3699a0f233fa572382232d1a 100644 (file)
 #include "config.h"
 
 #include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <sys/types.h>
 
 
@@ -45,6 +50,10 @@ void  codememory_init(void);
 void *codememory_get(size_t size);
 void  codememory_release(void *p, size_t size);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _CODEMEMORY_H */
 
 
diff --git a/src/mm/dumpmemory.c b/src/mm/dumpmemory.c
deleted file mode 100644 (file)
index 0dc1915..0000000
+++ /dev/null
@@ -1,482 +0,0 @@
-/* src/mm/dumpmemory.c - dump memory management
-
-   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 <stdint.h>
-
-#include "mm/dumpmemory.h"
-#include "mm/memory.h"
-
-#include "threads/thread.h"
-
-#include "vmcore/options.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
-#include "vmcore/system.h"
-
-#include "vm/vm.h"
-
-
-/*******************************************************************************
-
-  This structure is used for dump memory allocation if cacao
-  runs without threads.
-
-*******************************************************************************/
-
-#if !defined(ENABLE_THREADS)
-static dumpinfo_t _no_threads_dumpinfo;
-#endif
-
-#if defined(ENABLE_THREADS)
-#define DUMPINFO    &((threadobject *) THREADOBJECT)->dumpinfo
-#else
-#define DUMPINFO    &_no_threads_dumpinfo
-#endif
-
-
-/* dump_check_canaries *********************************************************
-
-   Check canaries in dump memory.
-
-   IN:
-      di...........dumpinfo_t * of the dump area to check
-         bottomsize...dump size down to which the dump area should be checked
-                      (specify 0 to check the whole dump area)
-
-   ERROR HANDLING:
-      If any canary has been changed, this function aborts the VM with
-         an error message.
-
-*******************************************************************************/
-
-#if defined(ENABLE_MEMCHECK)
-static void dump_check_canaries(dumpinfo_t *di, s4 bottomsize)
-{
-       dump_allocation_t *da;
-       uint8_t           *pm;
-       int                i, j;
-
-       /* iterate over all dump memory allocations above bottomsize */
-
-       da = di->allocations;
-
-       while (da && da->used >= bottomsize) {
-               /* check canaries */
-
-               pm = ((uint8_t *) da->mem) - MEMORY_CANARY_SIZE;
-
-               for (i = 0; i < MEMORY_CANARY_SIZE; ++i) {
-                       if (pm[i] != i + MEMORY_CANARY_FIRST_BYTE) {
-                               fprintf(stderr, "canary bytes:");
-
-                               for (j = 0; j < MEMORY_CANARY_SIZE; ++j)
-                                       fprintf(stderr, " %02x", pm[j]);
-
-                               fprintf(stderr,"\n");
-
-                               vm_abort("error: dump memory bottom canary killed: "
-                                                "%p (%d bytes allocated at %p)\n",
-                                                pm + i, da->size, da->mem);
-                       }
-               }
-
-               pm = ((uint8_t *) da->mem) + da->size;
-
-               for (i = 0; i < MEMORY_CANARY_SIZE; ++i) {
-                       if (pm[i] != i + MEMORY_CANARY_FIRST_BYTE) {
-                               fprintf(stderr, "canary bytes:");
-
-                               for (j = 0; j < MEMORY_CANARY_SIZE; ++j)
-                                       fprintf(stderr, " %02x", pm[j]);
-
-                               fprintf(stderr, "\n");
-
-                               vm_abort("error: dump memory top canary killed: "
-                                                "%p (%d bytes allocated at %p)\n",
-                                                pm + i, da->size, da->mem);
-                       }
-               }
-
-               da = da->next;
-       }
-}
-#endif /* defined(ENABLE_MEMCHECK) */
-
-
-/* dumpmemory_alloc ************************************************************
-
-   ATTENTION: This function must only be called from dumpmemory_get!
-
-   Allocate a new dump memory block.
-
-   IN:
-      di ..... dumpinfo_t of the current thread
-      size ... required memory size
-
-*******************************************************************************/
-
-void dumpmemory_alloc(dumpinfo_t *di, size_t size)
-{
-       dumpblock_t *db;
-       size_t       newblocksize;
-
-       /* Allocate a new dumpblock_t structure. */
-
-       db = memory_checked_alloc(sizeof(dumpblock_t));
-
-       /* If requested size is greater than the default, make the new
-          dump block as big as the size requested. Else use the default
-          size. */
-
-       if (size > DUMPBLOCKSIZE) {
-               newblocksize = size;
-       }
-       else {
-               newblocksize = DUMPBLOCKSIZE;
-       }
-
-       /* allocate dumpblock memory */
-
-       db->dumpmem = memory_checked_alloc(newblocksize);
-
-       db->size  = newblocksize;
-       db->prev  = di->block;
-       di->block = db;
-
-       /* Used dump size is previously allocated dump size, because the
-          remaining free memory of the previous dump block cannot be
-          used. */
-
-       di->used = di->allocated;
-
-       /* Increase the allocated dump size by the size of the new dump
-          block. */
-
-       di->allocated += newblocksize;
-
-#if defined(ENABLE_STATISTICS)
-       /* The amount of globally allocated dump memory (thread save). */
-
-       if (opt_stat)
-               globalallocateddumpsize += newblocksize;
-#endif
-}
-
-
-/* dumpmemory_get **************************************************************
-
-   Allocate memory in the dump area.
-
-   IN:
-      size.........size of block to allocate, in bytes
-                                  may be zero, in which case NULL is returned
-
-   RETURN VALUE:
-      pointer to allocated memory, or
-         NULL iff `size` was zero
-
-   ERROR HANDLING:
-      XXX This function uses `memory_checked_alloc`, which *exits* if
-         no memory could be allocated.
-
-   THREADS:
-      dumpmemory_get is thread safe. Each thread has its own dump
-      memory area.
-
-   This function is a fast allocator suitable for scratch memory that
-   can be collectively freed when the current activity (eg. compiling)
-   is done.
-
-   You cannot selectively free dump memory. Before you start
-   allocating it, you remember the current size returned by
-   `dumpmemory_marker`. Later, when you no longer need the memory,
-   call `dumpmemory_release` with the remembered size and all dump
-   memory allocated since the call to `dumpmemory_marker` will be
-   freed.
-
-*******************************************************************************/
-
-void *dumpmemory_get(size_t size)
-{
-#if defined(DISABLE_DUMP)
-
-       /* use malloc memory for dump memory (for debugging only!) */
-
-       return mem_alloc(size);
-
-#else /* !defined(DISABLE_DUMP) */
-
-       void       *p;
-       dumpinfo_t *di;
-#if defined(ENABLE_MEMCHECK)
-       s4          origsize = size; /* needed for the canary system */
-#endif
-
-       di = DUMPINFO;
-
-       if (size == 0)
-               return NULL;
-
-#if defined(ENABLE_MEMCHECK)
-       size += 2 * MEMORY_CANARY_SIZE;
-#endif
-
-       size = MEMORY_ALIGN(size, ALIGNSIZE);
-
-       /* Check if we have enough memory in the current memory block. */
-
-       if (di->used + size > di->allocated) {
-               /* If not, allocate a new one. */
-
-               dumpmemory_alloc(di, size);
-       }
-
-       /* current dump block base address + the size of the current dump
-          block - the size of the unused memory = new start address  */
-
-       p = ((uint8_t *) di->block->dumpmem) + di->block->size -
-               (di->allocated - di->used);
-
-#if defined(ENABLE_MEMCHECK)
-       {
-               dump_allocation_t *da = NEW(dump_allocation_t);
-               uint8_t           *pm;
-               int                i;
-
-               /* add the allocation to our linked list of allocations */
-
-               da->next = di->allocations;
-               da->mem  = ((uint8_t *) p) + MEMORY_CANARY_SIZE;
-               da->size = origsize;
-               da->used = di->used;
-
-               di->allocations = da;
-
-               /* write the canaries */
-
-               pm = (uint8_t *) p;
-
-               for (i = 0; i < MEMORY_CANARY_SIZE; ++i)
-                       pm[i] = i + MEMORY_CANARY_FIRST_BYTE;
-
-               pm = ((uint8_t *) da->mem) + da->size;
-
-               for (i = 0; i < MEMORY_CANARY_SIZE; ++i)
-                       pm[i] = i + MEMORY_CANARY_FIRST_BYTE;
-
-               /* make m point after the bottom canary */
-
-               p = ((uint8_t *) p) + MEMORY_CANARY_SIZE;
-
-               /* clear the memory */
-
-               (void) system_memset(p, MEMORY_CLEAR_BYTE, da->size);
-       }
-#endif /* defined(ENABLE_MEMCHECK) */
-
-       /* Increase used dump size by the allocated memory size. */
-
-       di->used += size;
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               if (di->used > maxdumpsize)
-                       maxdumpsize = di->used;
-#endif
-
-       return p;
-
-#endif /* defined(DISABLE_DUMP) */
-}
-
-
-/* dumpmemory_realloc **********************************************************
-
-   Stupid realloc implementation for dump memory. Avoid, if possible.
-
-*******************************************************************************/
-
-void *dumpmemory_realloc(void *src, s4 len1, s4 len2)
-{
-#if defined(DISABLE_DUMP)
-       /* use malloc memory for dump memory (for debugging only!) */
-
-       return mem_realloc(src, len1, len2);
-#else
-       void *dst;
-
-       dst = dumpmemory_get(len2);
-
-       (void) system_memcpy(dst, src, len1);
-
-#if defined(ENABLE_MEMCHECK)
-       /* destroy the source */
-
-       (void) system_memset(src, MEMORY_CLEAR_BYTE, len1);
-#endif
-
-       return dst;
-#endif
-}
-
-
-/* dumpmemory_release **********************************************************
-
-   Release dump memory above the given size.
-
-   IN:
-       size........All dump memory above this mark will be freed. Usually
-                      `size` will be the return value of a `dumpmemory_marker`
-                                  call made earlier.
-
-       ERROR HANDLING:
-          XXX If the given size is invalid, this function *exits* with an
-              error message.
-                                  
-       See `dump_alloc`.
-
-*******************************************************************************/
-
-void dumpmemory_release(s4 size)
-{
-#if defined(DISABLE_DUMP)
-
-       /* use malloc memory for dump memory (for debugging only!) */
-
-       /* do nothing */
-
-#else /* !defined(DISABLE_DUMP) */
-
-       dumpinfo_t *di;
-
-       di = DUMPINFO;
-
-       if ((size < 0) || (size > di->used))
-               vm_abort("dump_release: Illegal dump release size: %d", size);
-
-#if defined(ENABLE_MEMCHECK)
-       {
-               dump_allocation_t *da, *next;
-
-               /* check canaries */
-
-               dump_check_canaries(di, size);
-
-               /* iterate over all dump memory allocations about to be released */
-
-               da = di->allocations;
-
-               while ((da != NULL) && (da->used >= size)) {
-                       next = da->next;
-
-                       /* invalidate the freed memory */
-
-                       (void) system_memset(da->mem, MEMORY_CLEAR_BYTE, da->size);
-
-                       FREE(da, dump_allocation_t);
-
-                       da = next;
-               }
-               di->allocations = da;
-       }
-#endif /* defined(ENABLE_MEMCHECK) */
-
-       /* Reset the used dump size to the size specified. */
-
-       di->used = size;
-
-       while ((di->block != NULL) && di->allocated - di->block->size >= di->used) {
-               dumpblock_t *tmp = di->block;
-
-               di->allocated -= tmp->size;
-               di->block      = tmp->prev;
-
-#if defined(ENABLE_STATISTICS)
-               /* the amount of globally allocated dump memory (thread save) */
-
-               if (opt_stat)
-                       globalallocateddumpsize -= tmp->size;
-#endif
-
-               /* Release the dump memory and the dumpinfo structure. */
-
-               system_free(tmp->dumpmem);
-               system_free(tmp);
-       }
-
-#endif /* defined(DISABLE_DUMP) */
-}
-
-
-/* dumpmemory_marker ***********************************************************
-
-   Returns a marker of the dump memory area.  This marker is actually
-   the used size of the dump memory area.
-
-   RETURN VALUE:
-       marker of the current dump memory status
-
-*******************************************************************************/
-
-int32_t dumpmemory_marker(void)
-{
-#if defined(DISABLE_DUMP)
-       /* use malloc memory for dump memory (for debugging only!) */
-
-       return 0;
-
-#else /* !defined(DISABLE_DUMP) */
-
-       dumpinfo_t *di;
-
-       di = DUMPINFO;
-
-       if (di == NULL)
-               return 0;
-
-       return di->used;
-
-#endif /* defined(DISABLE_DUMP) */
-}
-
-
-/*
- * 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/mm/dumpmemory.cpp b/src/mm/dumpmemory.cpp
new file mode 100644 (file)
index 0000000..4650d52
--- /dev/null
@@ -0,0 +1,318 @@
+/* src/mm/dumpmemory.cpp - dump memory management
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 <stdint.h>
+
+#include "mm/dumpmemory.hpp"
+#include "mm/memory.h"
+
+#include "threads/thread.hpp"
+
+#include "vm/options.h"
+#include "vm/os.hpp"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#include "vm/vm.hpp"
+
+
+/*******************************************************************************
+
+  This structure is used for dump memory allocation if cacao
+  runs without threads.
+
+*******************************************************************************/
+
+#if !defined(ENABLE_THREADS)
+static dumpinfo_t _no_threads_dumpinfo;
+#endif
+
+
+/**
+ * Allocate a new thread-local dump memory structure.
+ */
+DumpMemory::DumpMemory() : _size(0), _used(0)
+{
+}
+
+
+/**
+ * Stupid realloc implementation for dump memory.  Avoid, if possible.
+ */
+void* DumpMemory::reallocate(void* src, size_t len1, size_t len2)
+{
+       void* dst = allocate(len2);
+
+       (void) os::memcpy(dst, src, len1);
+
+#if defined(ENABLE_MEMCHECK)
+       // Destroy the source.
+       (void) os::memset(src, MEMORY_CLEAR_BYTE, len1);
+#endif
+
+       return dst;
+}
+
+
+/**
+ * Add the given dump area to the area list.
+ *
+ * @param dm Pointer to dump area.
+ */
+void DumpMemory::add_area(DumpMemoryArea* dma)
+{
+       _areas.push_back(dma);
+
+       // Increase the size count of the dump memory.
+       _size += dma->get_size();
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat) {
+               if (_size > (size_t) maxdumpsize)
+                       maxdumpsize = _size;
+       }
+#endif
+}
+
+
+/**
+ * Remove the given dump area from the area list.
+ *
+ * @param dm Pointer to dump area.
+ */
+void DumpMemory::remove_area(DumpMemoryArea* dma)
+{
+       // Sanity check.
+       assert(_areas.back() == dma);
+
+       // Remove the last area from the list.  The check above guarantees
+       // we are removing the correct area.
+       _areas.pop_back();
+
+       // Decrease the size and used count.
+       _size -= dma->get_size();
+       _used -= dma->get_used();
+}
+
+
+/**
+ * Allocate a new dump memory area.
+ *
+ * @ param size Required memory size.
+ */
+DumpMemoryArea::DumpMemoryArea(size_t size) : _size(0), _used(0)
+{
+       // Get the DumpMemory object of the current thread.
+       DumpMemory* dm = DumpMemory::get_current();
+
+       // Add this area to the areas list.
+       dm->add_area(this);
+}
+
+
+/**
+ * Release all dump memory blocks in the current dump area.
+ */
+DumpMemoryArea::~DumpMemoryArea()
+{
+       // Get the DumpMemory object of the current thread.
+       DumpMemory* dm = DumpMemory::get_current();
+
+#if defined(ENABLE_MEMCHECK)
+       // Check canaries.
+
+       check_canaries();
+
+       // Iterate over all dump memory allocations about to be released.
+
+       for (std::vector<DumpMemoryAllocation*>::iterator it = _allocs.begin(); it != _allocs.end(); it++) {
+               DumpMemoryAllocation* dma = *it;
+
+               // Invalidate the freed memory.
+               (void) os::memset(dma->get_mem(), MEMORY_CLEAR_BYTE, dma->get_size());
+
+               // Call the destructor of the current allocation.
+               delete dma;
+       }
+#endif /* defined(ENABLE_MEMCHECK) */
+
+       // Free all memory blocks.
+       for (std::vector<DumpMemoryBlock*>::iterator it = _blocks.begin(); it != _blocks.end(); it++) {
+               // Call the destructor of the current block.
+               delete *it;
+       }
+
+       // Remove this area for the area list.
+       dm->remove_area(this);
+}
+
+
+/**
+ * Allocate a dump memory block for the current dump memory area.
+ *
+ * @param size Required memory size.
+ *
+ * @return Pointer to the newly allocated block.
+ */
+DumpMemoryBlock* DumpMemoryArea::allocate_new_block(size_t size)
+{
+       DumpMemoryBlock* dmb = new DumpMemoryBlock(size);
+       _blocks.push_back(dmb);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat) {
+               DumpMemory* dm = DumpMemory::get_current();
+               dm->add_size(dmb->get_size());
+
+               if (dm->get_size() > (size_t) maxdumpsize)
+                       maxdumpsize = dm->get_size();
+       }
+#endif
+
+       return dmb;
+}
+
+
+/**
+ * Checks canaries in this dump memory area. If any canary has been changed,
+ * this function aborts the VM with an error message.
+ */
+#if defined(ENABLE_MEMCHECK)
+void DumpMemoryArea::check_canaries()
+{
+       uint8_t* pm;
+
+       // Iterate over all dump memory allocations.
+
+       for (std::vector<DumpMemoryAllocation*>::iterator it = _allocs.begin(); it != _allocs.end(); it++) {
+               DumpMemoryAllocation* dma = *it;
+
+               // Check canaries.
+
+               pm = ((uint8_t *) dma->get_mem()) - MEMORY_CANARY_SIZE;
+
+               for (int i = 0; i < MEMORY_CANARY_SIZE; ++i) {
+                       if (pm[i] != i + MEMORY_CANARY_FIRST_BYTE) {
+                               fprintf(stderr, "canary bytes:");
+
+                               for (int j = 0; j < MEMORY_CANARY_SIZE; ++j)
+                                       fprintf(stderr, " %02x", pm[j]);
+
+                               fprintf(stderr,"\n");
+
+                               vm_abort("error: dump memory bottom canary killed: "
+                                                "%p (%d bytes allocated at %p)\n",
+                                                pm + i, dma->get_size(), dma->get_mem());
+                       }
+               }
+
+               pm = ((uint8_t *) dma->get_mem()) + dma->get_size();
+
+               for (int i = 0; i < MEMORY_CANARY_SIZE; ++i) {
+                       if (pm[i] != i + MEMORY_CANARY_FIRST_BYTE) {
+                               fprintf(stderr, "canary bytes:");
+
+                               for (int j = 0; j < MEMORY_CANARY_SIZE; ++j)
+                                       fprintf(stderr, " %02x", pm[j]);
+
+                               fprintf(stderr, "\n");
+
+                               vm_abort("error: dump memory top canary killed: "
+                                                "%p (%d bytes allocated at %p)\n",
+                                                pm + i, dma->get_size(), dma->get_mem());
+                       }
+               }
+       }
+}
+#endif /* defined(ENABLE_MEMCHECK) */
+
+
+/**
+ * Allocate a memory block for the current dump memory block.
+ *
+ * @param size Required memory size.
+ */
+DumpMemoryBlock::DumpMemoryBlock(size_t size) : _size(0), _used(0), _block(0)
+{
+       // If requested size is greater than the default, make the new
+       // memory block as big as the requested size.  Otherwise use the
+       // default size.
+       _size = (size > DEFAULT_SIZE) ? size : DEFAULT_SIZE;
+
+       // Allocate a memory block.
+       _block = memory_checked_alloc(_size);
+
+#if defined(ENABLE_STATISTICS)
+       // The amount of globally allocated dump memory (thread safe).
+       if (opt_stat)
+               globalallocateddumpsize += _size;
+#endif
+}
+
+
+/**
+ * Release the memory block for the dump memory block.
+ *
+ * @param size Required memory size.
+ */
+DumpMemoryBlock::~DumpMemoryBlock()
+{
+       // Release the memory block.
+       mem_free(_block, /* XXX */ 1);
+
+#if defined(ENABLE_STATISTICS)
+       // The amount of globally allocated dump memory (thread safe).
+       if (opt_stat)
+               globalallocateddumpsize -= _size;
+#endif
+}
+
+
+// Legacy C interface.
+
+extern "C" {
+       void* DumpMemory_allocate(size_t size) { return DumpMemory::allocate(size); }
+       void* DumpMemory_reallocate(void* src, size_t len1, size_t len2) { return DumpMemory::reallocate(src, len1, len2); }
+}
+
+
+/*
+ * 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/mm/dumpmemory.h b/src/mm/dumpmemory.h
deleted file mode 100644 (file)
index f519777..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/* src/mm/dumpmemory.h - dump memory management
-
-   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 _DUMPMEMORY_H
-#define _DUMPMEMORY_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct dumpblock_t dumpblock_t;
-typedef struct dumpinfo_t  dumpinfo_t;
-
-#include "config.h"
-
-#include <stdint.h>
-#include <string.h>
-
-
-/* ATTENTION: We need to define dumpblock_t and dumpinfo_t before
-   internal includes, as we need dumpinfo_t as nested structure in
-   threadobject. */
-
-/* dumpblock ******************************************************************/
-
-#define DUMPBLOCKSIZE    2 << 13    /* 2 * 8192 bytes */
-#define ALIGNSIZE        8
-
-struct dumpblock_t {
-       dumpblock_t *prev;
-       void        *dumpmem;
-       int32_t      size;
-};
-
-
-/* dump_allocation *************************************************************
-
-   This struct is used to record dump memory allocations for ENABLE_MEMCHECK.
-
-*******************************************************************************/
-
-#if defined(ENABLE_MEMCHECK)
-typedef struct dump_allocation_t dump_allocation_t;
-
-struct dump_allocation_t {
-       dump_allocation_t *next;
-       void              *mem;
-       int32_t            used;
-       int32_t            size;
-};
-#endif
-
-
-/* dumpinfo *******************************************************************/
-
-struct dumpinfo_t {
-       dumpblock_t       *block;                   /* the current top-most block */
-       int32_t            allocated;             /* allocated bytes in this area */
-       int32_t            used;                  /* used bytes in this dump area */
-#if defined(ENABLE_MEMCHECK)
-       dump_allocation_t *allocations;       /* list of allocations in this area */
-#endif
-};
-
-
-/* convenience macros *********************************************************/
-
-#define DMARKER               dumpmarker = dumpmemory_marker()
-#define DRELEASE              dumpmemory_release(dumpmarker)
-
-#define DNEW(type)            ((type *) dumpmemory_get(sizeof(type)))
-#define DMNEW(type,num)       ((type *) dumpmemory_get(sizeof(type) * (num)))
-#define DMREALLOC(ptr,type,num1,num2) dumpmemory_realloc((ptr), sizeof(type) * (num1), \
-                                                          sizeof(type) * (num2))
-
-/* function prototypes ********************************************************/
-
-void    *dumpmemory_get(size_t size);
-void    *dumpmemory_realloc(void *src, int32_t len1, int32_t len2);
-int32_t  dumpmemory_marker(void);
-void     dumpmemory_release(int32_t size);
-
-#endif /* _DUMPMEMORY_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/mm/dumpmemory.hpp b/src/mm/dumpmemory.hpp
new file mode 100644 (file)
index 0000000..c871d3e
--- /dev/null
@@ -0,0 +1,383 @@
+/* src/mm/dumpmemory.hpp - dump memory management
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _DUMPMEMORY_HPP
+#define _DUMPMEMORY_HPP
+
+#include "config.h"
+
+#include <assert.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+
+#include <cstddef>
+#include <list>
+#include <vector>
+#include <stdio.h> // REMOVEME
+
+
+// Forward declaration.
+class DumpMemoryArea;
+class DumpMemoryBlock;
+#if defined(ENABLE_MEMCHECK)
+class DumpMemoryAllocation;
+#endif
+
+
+/**
+ * Thread-local dump memory structure.
+ */
+class DumpMemory {
+private:
+       size_t                     _size;  ///< Size of the dump areas in this dump memory.
+       size_t                     _used;  ///< Used memory in this dump memory.
+       std::list<DumpMemoryArea*> _areas; ///< Pointer to the current dump area.
+
+public:
+       DumpMemory();
+       ~DumpMemory();
+
+       static inline DumpMemory* get_current();
+       static inline void*       allocate(size_t size);
+
+       inline void   add_size(size_t size) { _size += size; }
+
+       inline size_t get_size() const { return _size; }
+       inline size_t get_used() const { return _used; }
+
+       inline DumpMemoryArea* get_current_area() const;
+
+       static void* reallocate(void* src, size_t len1, size_t len2);
+
+       void  add_area(DumpMemoryArea* dma);
+       void  remove_area(DumpMemoryArea* dma);
+};
+
+
+/**
+ * Dump memory area.
+ */
+class DumpMemoryArea {
+private:
+       size_t                        _size;   ///< Size of the current memory block.
+       size_t                        _used;   ///< Used memory in the current memory block.
+       std::vector<DumpMemoryBlock*> _blocks; ///< List of memory blocks in this area.
+#if defined(ENABLE_MEMCHECK)
+       std::vector<DumpMemoryAllocation*> _allocs; ///< List of allocations in this area.
+#endif
+
+public:
+       DumpMemoryArea(size_t size = 0);
+       ~DumpMemoryArea();
+
+       inline size_t get_size() const { return _size; }
+       inline size_t get_used() const { return _used; }
+
+       // Inline functions.
+       inline void*            allocate(size_t size);
+       inline DumpMemoryBlock* get_current_block() const;
+
+       DumpMemoryBlock* allocate_new_block(size_t size);
+
+#if defined(ENABLE_MEMCHECK)
+private:
+       void check_canaries();
+#endif
+};
+
+
+/**
+ * Dump memory block.
+ */
+class DumpMemoryBlock {
+private:
+       static const size_t DEFAULT_SIZE = 2 << 13; // 2 * 8192 bytes
+
+       size_t _size;  ///< Size of the current memory block.
+       size_t _used;  ///< Used memory in the current memory block.
+       void*  _block; ///< List of memory blocks in this area.
+
+public:
+       DumpMemoryBlock(size_t size = 0);
+       ~DumpMemoryBlock();
+
+       inline size_t get_size() const { return _size; }
+       inline size_t get_used() const { return _used; }
+       inline size_t get_free() const { return _size - _used; }
+
+       // Inline functions.
+       inline void* allocate(size_t size);
+};
+
+
+/**
+ * Allocator for the dump memory.
+ */
+template<class T> class DumpMemoryAllocator {
+public:
+       // Type definitions.
+       typedef T              value_type;
+       typedef T*             pointer;
+       typedef const T*       const_pointer;
+       typedef T&             reference;
+       typedef const T&       const_reference;
+       typedef std::size_t    size_type;
+       typedef std::ptrdiff_t difference_type;
+
+       // Rebind allocator to type U.
+       template <class U> struct rebind {
+               typedef DumpMemoryAllocator<U> other;
+       };
+
+       // Constructors and destructor, nothing to do because the
+       // allocator has no state.
+       DumpMemoryAllocator() throw() {}
+       DumpMemoryAllocator(const DumpMemoryAllocator&) throw() {}
+       template <class U> DumpMemoryAllocator(const DumpMemoryAllocator<U>&) throw() {}
+
+       ~DumpMemoryAllocator() throw() {}
+
+       pointer allocate(size_type n, void* = 0) {
+//             printf("allocate: n=%d * %d\n", n, sizeof(T));
+               return static_cast<pointer>(DumpMemory::allocate(n * sizeof(T)));
+       }
+
+       // Initialize elements of allocated storage p with value value.
+       void construct(pointer p, const T& value) {
+//             printf("construct: p=%p, value=%p\n", (void*) p, (void*) value);
+               // Initialize memory with placement new.
+               new ((void*) p) T(value);
+       }
+
+       // Destroy elements of initialized storage p.
+       void destroy(pointer p) {
+//             printf("destroy: p=%p\n", (void*) p);
+               // Destroy objects by calling their destructor.
+               p->~T();
+       }
+
+       void deallocate(pointer p, size_type n) {
+//             printf("deallocate: p=%p, n=%d\n", (void*) p, n);
+               // We don't need to deallocate on dump memory.
+       }
+};
+
+
+/**
+ * Dump memory allocation, used for for ENABLE_MEMCHECK.
+ */
+#if defined(ENABLE_MEMCHECK)
+class DumpMemoryAllocation {
+private:
+       size_t _size;
+       void*  _mem;
+
+public:
+       DumpMemoryAllocation() : _size(0), _mem(NULL) {}
+       DumpMemoryAllocation(size_t size, void* mem) : _size(size), _mem(mem) {}
+       ~DumpMemoryAllocation() {};
+
+       inline size_t get_size() const { return _size; }
+       inline void*  get_mem()  const { return _mem; }
+};
+#endif
+
+
+// Includes.
+#include "mm/memory.h"
+
+#include "threads/thread.hpp"
+
+#include "vm/options.h"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+
+// Inline functions.
+
+inline DumpMemory* DumpMemory::get_current()
+{
+       // Get the DumpMemory object of the current thread.
+       threadobject* t = thread_get_current();
+       DumpMemory* dm = t->_dumpmemory;
+       return dm;
+}
+
+inline DumpMemoryArea* DumpMemory::get_current_area() const
+{
+       return _areas.back();
+}
+
+inline void* DumpMemory::allocate(size_t size)
+{
+       DumpMemory* dm = get_current();
+       DumpMemoryArea* dma = dm->get_current_area();
+
+       size_t alignedsize = size;
+
+#if defined(ENABLE_MEMCHECK)
+       alignedsize += 2 * MEMORY_CANARY_SIZE;
+#endif
+
+       // Align the allocation size.
+       alignedsize = MEMORY_ALIGN(alignedsize, ALIGNSIZE);
+
+       void* p = dma->allocate(alignedsize);
+
+       // Increase the used count of the dump memory.
+       dm->_used += alignedsize;
+
+       return p;
+}
+
+inline DumpMemoryBlock* DumpMemoryArea::get_current_block() const
+{
+       return _blocks.empty() ? NULL : _blocks.back();
+}
+
+inline void* DumpMemoryArea::allocate(size_t size)
+{
+       DumpMemoryBlock* dmb = get_current_block();
+
+       // Check if we have a memory block or have enough memory in the
+       // current memory block.
+       if (dmb == NULL || size > dmb->get_free()) {
+               // No, allocate a new one.
+               dmb = allocate_new_block(size);
+
+               // Increase the size of the memory area.  We use get_size()
+               // here because the default size is very likely to be bigger
+               // than size.
+               _size += dmb->get_size();
+       }
+
+       void* p = dmb->allocate(size);
+
+#if defined(ENABLE_MEMCHECK)
+       uint8_t *pm;
+       size_t   origsize = size - 2 * MEMORY_CANARY_SIZE;
+
+       // Make p point after the bottom canary.
+
+       p = ((uint8_t *) p) + MEMORY_CANARY_SIZE;
+
+       // Add the allocation to our list of allocations
+
+       DumpMemoryAllocation* dma = new DumpMemoryAllocation(origsize, p);
+
+       _allocs.push_back(dma);
+
+       // Write the canaries.
+
+       pm = ((uint8_t *) p) - MEMORY_CANARY_SIZE;
+
+       for (int i = 0; i < MEMORY_CANARY_SIZE; ++i)
+               pm[i] = i + MEMORY_CANARY_FIRST_BYTE;
+
+       pm = ((uint8_t *) p) + dma->get_size();
+
+       for (int i = 0; i < MEMORY_CANARY_SIZE; ++i)
+               pm[i] = i + MEMORY_CANARY_FIRST_BYTE;
+
+       // Clear the memory.
+
+       (void) os::memset(p, MEMORY_CLEAR_BYTE, dma->get_size());
+#endif /* defined(ENABLE_MEMCHECK) */
+
+       // Increase the used size of the memory area.
+       _used += size;
+
+       return p;
+}
+
+/**
+ * Allocate memory in the current dump memory area.
+ *
+ * This function is a fast allocator suitable for scratch memory that
+ * can be collectively freed when the current activity (eg. compiling)
+ * is done.
+ *
+ * You cannot selectively free dump memory. Before you start
+ * allocating it, you remember the current size returned by
+ * `dumpmemory_marker`. Later, when you no longer need the memory,
+ * call `dumpmemory_release` with the remembered size and all dump
+ * memory allocated since the call to `dumpmemory_marker` will be
+ * freed.
+ *
+ * @parm size Size of block to allocate in bytes. May be zero, in which case NULL is returned
+ *
+ * @return Pointer to allocated memory, or NULL iff size was zero.
+ */
+void* DumpMemoryBlock::allocate(size_t size)
+{
+       if (size == 0)
+               return NULL;
+
+       // Sanity check.
+       assert(size <= (_size - _used));
+
+       // Calculate the memory address of the newly allocated memory.
+       void* p = (void*) (((uint8_t*) _block) + _used);
+
+       // Increase used memory block size by the allocated memory size.
+       _used += size;
+
+       return p;
+}
+
+#else
+
+// Legacy C interface.
+
+void* DumpMemory_allocate(size_t size);
+void* DumpMemory_reallocate(void* src, size_t len1, size_t len2);
+
+#define DNEW(type)                    ((type*) DumpMemory_allocate(sizeof(type)))
+#define DMNEW(type,num)               ((type*) DumpMemory_allocate(sizeof(type) * (num)))
+#define DMREALLOC(ptr,type,num1,num2) ((type*) DumpMemory_reallocate((ptr), sizeof(type) * (num1), sizeof(type) * (num2)))
+
+#endif
+
+#endif // _DUMPMEMORY_HPP
+
+
+/*
+ * 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/mm/gc-boehm.cpp b/src/mm/gc-boehm.cpp
new file mode 100644 (file)
index 0000000..bfd612b
--- /dev/null
@@ -0,0 +1,273 @@
+/* src/mm/gc-boehm.cpp - interface for boehm gc
+
+   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 <stdint.h>
+
+#if defined(ENABLE_THREADS) && defined(__LINUX__)
+#define GC_LINUX_THREADS
+#endif
+#if defined(ENABLE_THREADS) && defined(__IRIX__)
+#define GC_IRIX_THREADS
+#endif
+#if defined(ENABLE_THREADS) && defined(__DARWIN__)
+#define GC_DARWIN_THREADS
+#endif
+
+#include "boehm-gc/include/gc.h"
+#include "mm/gc.hpp"
+#include "mm/memory.h"
+
+#include "toolbox/logging.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/finalizer.h"
+#include "vm/global.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/rt-timing.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+
+/* global variables ***********************************************************/
+
+static bool in_gc_out_of_memory = false;    /* is GC out of memory?           */
+
+
+/* prototype static functions *************************************************/
+
+static void gc_ignore_warnings(char *msg, GC_word arg);
+
+
+/* gc_init *********************************************************************
+
+   Initializes the boehm garbage collector.
+
+*******************************************************************************/
+
+void gc_init(size_t heapmaxsize, size_t heapstartsize)
+{
+       size_t heapcurrentsize;
+
+       TRACESUBSYSTEMINITIALIZATION("gc_init");
+
+       /* just to be sure (should be set to 1 by JAVA_FINALIZATION macro) */
+
+       GC_java_finalization = 1;
+
+       /* Ignore pointers that do not point to the start of an object. */
+
+       GC_all_interior_pointers = 0;
+
+       /* suppress warnings */
+
+       GC_set_warn_proc(gc_ignore_warnings);
+
+       /* install a GC notifier */
+
+       GC_finalize_on_demand = 1;
+       GC_finalizer_notifier = finalizer_notify;
+
+       /* define OOM function */
+
+       GC_oom_fn = gc_out_of_memory;
+
+       GC_INIT();
+
+       /* set the maximal heap size */
+
+       GC_set_max_heap_size(heapmaxsize);
+
+       /* set the initial heap size */
+
+       heapcurrentsize = GC_get_heap_size();
+
+       if (heapstartsize > heapcurrentsize)
+               GC_expand_hp(heapstartsize - heapcurrentsize);
+}
+
+
+static void gc_ignore_warnings(char *msg, GC_word arg)
+{
+}
+
+
+void *heap_alloc_uncollectable(size_t size)
+{
+       void *p;
+
+       p = GC_MALLOC_UNCOLLECTABLE(size);
+
+       /* clear allocated memory region */
+
+       MSET(p, 0, uint8_t, size);
+
+       return p;
+}
+
+
+/* heap_alloc ******************************************************************
+
+   Allocates memory on the Java heap.
+
+*******************************************************************************/
+
+void *heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect)
+{
+       void *p;
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_end;
+#endif
+
+       RT_TIMING_GET_TIME(time_start);
+
+       /* We can't use a bool here for references, as it's passed as a
+          bitmask in builtin_new.  Thus we check for != 0. */
+
+       if (references != 0)
+               p = GC_MALLOC(size);
+       else
+               p = GC_MALLOC_ATOMIC(size);
+
+       if (p == NULL)
+               return NULL;
+
+       if (finalizer != NULL)
+               GC_REGISTER_FINALIZER_NO_ORDER(p, finalizer_run, 0, 0, 0);
+
+       /* clear allocated memory region */
+
+       MSET(p, 0, uint8_t, size);
+
+       RT_TIMING_GET_TIME(time_end);
+       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_GC_ALLOC);
+
+       return p;
+}
+
+
+void heap_free(void *p)
+{
+       GC_FREE(p);
+}
+
+void gc_call(void)
+{
+       if (opt_verbosegc)
+               dolog("Garbage Collection:  previous/now = %d / %d ",
+                         0, 0);
+
+       GC_gcollect();
+}
+
+
+int64_t gc_get_heap_size(void)
+{
+       return GC_get_heap_size();
+}
+
+
+int64_t gc_get_free_bytes(void)
+{
+       return GC_get_free_bytes();
+}
+
+
+/* gc_get_total_bytes **********************************************************
+
+   Returns the number of total bytes currently used on the Java heap.
+
+*******************************************************************************/
+
+int64_t gc_get_total_bytes(void)
+{
+       return GC_get_total_bytes();
+}
+
+
+int64_t gc_get_max_heap_size(void)
+{
+       return GC_get_max_heap_size();
+}
+
+
+void gc_invoke_finalizers(void)
+{
+       GC_invoke_finalizers();
+}
+
+
+void gc_finalize_all(void)
+{
+       GC_finalize_all();
+}
+
+
+/* gc_out_of_memory ************************************************************
+
+   This function is called when boehm detects that it is OOM.
+
+*******************************************************************************/
+
+void *gc_out_of_memory(size_t bytes_requested)
+{
+       /* if this happens, we are REALLY out of memory */
+
+       if (in_gc_out_of_memory) {
+               /* this is all we can do... */
+               os::abort("gc_out_of_memory: out of memory");
+       }
+
+       in_gc_out_of_memory = true;
+
+       /* try to release some memory */
+
+       gc_call();
+
+       /* now instantiate the exception */
+
+       exceptions_throw_outofmemoryerror();
+
+       in_gc_out_of_memory = false;
+
+       return NULL;
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/mm/gc-common.h b/src/mm/gc-common.h
deleted file mode 100644 (file)
index 12454e8..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/* src/mm/gc-common.h - gc independant interface for heap managment
-
-   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 _GC_COMMON_H
-#define _GC_COMMON_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/global.h"
-
-#include "vmcore/method.h"
-
-
-/* reference types ************************************************************/
-
-enum {
-       GC_REFTYPE_THREADOBJECT,
-       GC_REFTYPE_CLASSLOADER,
-       GC_REFTYPE_JNI_GLOBALREF,
-       GC_REFTYPE_FINALIZER,
-       GC_REFTYPE_LOCALREF,
-       GC_REFTYPE_STACK,
-       GC_REFTYPE_CLASSREF,
-       GC_REFTYPE_LOCKRECORD
-};
-
-
-/* function prototypes ********************************************************/
-
-void    gc_init(size_t heapmaxsize, size_t heapstartsize);
-
-void*   heap_alloc_uncollectable(size_t size);
-void*   heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect);
-void    heap_free(void *p);
-
-#if defined(ENABLE_GC_CACAO)
-void    heap_init_objectheader(java_object_t *o, uint32_t size);
-int32_t heap_get_hashcode(java_object_t *o);
-
-void    gc_reference_register(java_object_t **ref, int32_t reftype);
-void    gc_reference_unregister(java_object_t **ref);
-
-void    gc_weakreference_register(java_object_t **ref, int32_t reftype);
-void    gc_weakreference_unregister(java_object_t **ref);
-#endif
-
-void    gc_call(void);
-int64_t gc_get_heap_size(void);
-int64_t gc_get_free_bytes(void);
-int64_t gc_get_total_bytes(void);
-int64_t gc_get_max_heap_size(void);
-void    gc_invoke_finalizers(void);
-void    gc_finalize_all(void);
-void*   gc_out_of_memory(size_t bytes_requested);
-
-
-/* inlined functions **********************************************************/
-
-static inline int32_t heap_hashcode(java_object_t *obj)
-{
-#if defined(ENABLE_GC_CACAO)
-       return heap_get_hashcode(obj);
-#else
-       return (int32_t)(intptr_t) obj;
-#endif
-}
-
-#endif /* _GC_COMMON_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:
- */
diff --git a/src/mm/gc-none.cpp b/src/mm/gc-none.cpp
new file mode 100644 (file)
index 0000000..d0a488d
--- /dev/null
@@ -0,0 +1,178 @@
+/* src/mm/gc-none.cpp - allocates memory through malloc (no GC)
+
+   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 <stdlib.h>
+
+#if defined(HAVE_SYS_MMAN_H)
+# include <sys/mman.h>
+#endif
+
+#include "vm/types.h"
+
+#include "boehm-gc/include/gc.h"
+
+#include "mm/gc.hpp"
+#include "mm/memory.h"
+
+#include "toolbox/logging.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/global.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/vm.hpp"
+
+
+/* global stuff ***************************************************************/
+
+#define MMAP_HEAPADDRESS    0x10000000  /* try to map the heap to this addr.  */
+#define ALIGNSIZE           8
+
+static void *mmapptr = NULL;
+static int mmapsize = 0;
+static void *mmaptop = NULL;
+
+
+void* heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect)
+{
+       void *m;
+
+       mmapptr = (void *) MEMORY_ALIGN((ptrint) mmapptr, ALIGNSIZE);
+       
+       m = mmapptr;
+       mmapptr = (void *) ((ptrint) mmapptr + size);
+
+       if (mmapptr > mmaptop)
+               vm_abort("heap_alloc: out of memory");
+
+       MSET(m, 0, u1, size);
+
+       return m;
+}
+
+
+void* heap_alloc_uncollectable(size_t size)
+{
+       return heap_alloc(size, false, NULL, false);
+}
+
+
+void heap_free(void* p)
+{
+       /* nop */
+}
+
+
+
+void gc_init(size_t heapmaxsize, size_t heapstartsize)
+{
+       heapmaxsize = MEMORY_ALIGN(heapmaxsize, ALIGNSIZE);
+
+#if defined(HAVE_MMAP)
+       mmapptr = mmap((void *) MMAP_HEAPADDRESS,
+                                  (size_t) heapmaxsize,
+                                  PROT_READ | PROT_WRITE,
+                                  MAP_PRIVATE |
+# if defined(MAP_ANONYMOUS)
+                                  MAP_ANONYMOUS,
+# elif defined(MAP_ANON)
+                                  MAP_ANON,
+# else
+                                  0,
+# endif
+                                  -1,
+                                  (off_t) 0);
+
+       if (mmapptr == MAP_FAILED)
+               vm_abort("gc_init: out of memory");
+#else
+       mmapptr = malloc(heapmaxsize);
+
+       if (mmapptr == NULL)
+               vm_abort("gc_init: out of memory");
+#endif
+
+       mmapsize = heapmaxsize;
+       mmaptop = (void *) ((ptrint) mmapptr + mmapsize);
+}
+
+
+void gc_call(void)
+{
+       log_text("GC call: nothing done...");
+       /* nop */
+}
+
+
+s8 gc_get_heap_size(void)
+{
+       return 0;
+}
+
+
+s8 gc_get_free_bytes(void)
+{
+       return 0;
+}
+
+
+s8 gc_get_total_bytes(void)
+{
+       return 0;
+}
+
+
+s8 gc_get_max_heap_size(void)
+{
+       return 0;
+}
+
+
+void gc_invoke_finalizers(void)
+{
+       /* nop */
+}
+
+
+void gc_finalize_all(void)
+{
+       /* nop */
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/mm/gc.hpp b/src/mm/gc.hpp
new file mode 100644 (file)
index 0000000..0a07912
--- /dev/null
@@ -0,0 +1,199 @@
+/* src/mm/gc.hpp - gc independant interface for heap managment
+
+   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 _GC_HPP
+#define _GC_HPP
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+
+#ifdef __cplusplus
+
+class GC {
+public:
+};
+
+
+/**
+ * Critical section for the GC.
+ */
+class GCCriticalSection {
+public:
+       GCCriticalSection()  { enter(); }
+       ~GCCriticalSection() { leave(); }
+
+       inline static void enter ();
+       inline static void leave ();
+       inline static bool inside();
+};
+
+
+// Includes.
+#if defined(ENABLE_GC_CACAO)
+# include "threads/thread.hpp"
+#endif
+
+
+/**
+ * Enters a LLNI critical section which prevents the GC from moving
+ * objects around on the collected heap.
+ *
+ * There are no race conditions possible while entering such a critical
+ * section, because each thread only modifies its own thread local flag
+ * and the GC reads the flags while the world is stopped.
+ */
+void GCCriticalSection::enter()
+{
+#if defined(ENABLE_GC_CACAO)
+       threadobject* t = thread_get_current();
+
+       // Sanity check.
+       assert(t->gc_critical == false);
+
+       t->gc_critical = true;
+#endif
+}
+
+/**
+ * Leaves a LLNI critical section and allows the GC to move objects
+ * around on the collected heap again.
+ */
+void GCCriticalSection::leave()
+{
+#if defined(ENABLE_GC_CACAO)
+       threadobject* t = thread_get_current();
+
+       // Sanity check.
+       assert(t->gc_critical == true);
+
+       t->gc_critical = false;
+#endif
+}
+
+
+/**
+ * Checks if the calling thread is inside a GC critical section.
+ *
+ * @return true if inside, false otherwise.
+ */
+bool GCCriticalSection::inside()
+{
+#if defined(ENABLE_GC_CACAO)
+       threadobject* t = thread_get_current();
+       return t->gc_critical;
+#else
+       return true;
+#endif
+}
+
+#endif
+
+
+/* reference types ************************************************************/
+
+enum {
+       GC_REFTYPE_THREADOBJECT,
+       GC_REFTYPE_CLASSLOADER,
+       GC_REFTYPE_JNI_GLOBALREF,
+       GC_REFTYPE_FINALIZER,
+       GC_REFTYPE_LOCALREF,
+       GC_REFTYPE_STACK,
+       GC_REFTYPE_CLASSREF,
+       GC_REFTYPE_LOCKRECORD
+};
+
+
+// Includes.
+#include "vm/global.h"
+#include "vm/method.hpp"
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void    gc_init(size_t heapmaxsize, size_t heapstartsize);
+
+void*   heap_alloc_uncollectable(size_t size);
+void*   heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect);
+void    heap_free(void *p);
+
+#if defined(ENABLE_GC_CACAO)
+void    heap_init_objectheader(java_object_t *o, uint32_t size);
+int32_t heap_get_hashcode(java_object_t *o);
+
+void    gc_reference_register(java_object_t **ref, int32_t reftype);
+void    gc_reference_unregister(java_object_t **ref);
+
+void    gc_weakreference_register(java_object_t **ref, int32_t reftype);
+void    gc_weakreference_unregister(java_object_t **ref);
+#endif
+
+void    gc_call(void);
+int64_t gc_get_heap_size(void);
+int64_t gc_get_free_bytes(void);
+int64_t gc_get_total_bytes(void);
+int64_t gc_get_max_heap_size(void);
+void    gc_invoke_finalizers(void);
+void    gc_finalize_all(void);
+void*   gc_out_of_memory(size_t bytes_requested);
+
+
+/* inlined functions **********************************************************/
+
+static inline int32_t heap_hashcode(java_object_t* obj)
+{
+#if defined(ENABLE_GC_CACAO)
+       return heap_get_hashcode(obj);
+#else
+       return (int32_t)(intptr_t) obj;
+#endif
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _GC_HPP
+
+
+/*
+ * 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 0b74e53517e14d2a2fa788716ef834917addf308..0774aee016228547abfe7b8d919478d22a72dc4a 100644 (file)
 #include "config.h"
 
 #include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include <stdint.h>
 
 #if defined(__DARWIN__)
 /* If we compile with -ansi on darwin, <sys/types.h> is not
 
 #include "mm/memory.h"
 
-#include "native/native.h"
+#include "native/native.hpp"
 
-#include "threads/lock-common.h"
-#include "threads/thread.h"
+#include "threads/lock.hpp"
+#include "threads/thread.hpp"
 
 #include "toolbox/logging.h"
 
-#include "vm/exceptions.h"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
 
-#include "vmcore/options.h"
+#include "vm/options.h"
+#include "vm/os.hpp"
 
 #if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
+# include "vm/statistics.h"
 #endif
 
-#include "vmcore/system.h"
-
 
 /* memory_mprotect *************************************************************
 
@@ -74,9 +68,8 @@
 
 void memory_mprotect(void *addr, size_t len, int prot)
 {
-       if (system_mprotect(addr, len, prot) != 0)
-               vm_abort("memory_mprotect: system_mprotect failed: %s",
-                                strerror(errno));
+       if (os_mprotect(addr, len, prot) != 0)
+               vm_abort_errno("memory_mprotect: os_mprotect failed");
 }
 
 
@@ -93,7 +86,7 @@ void *memory_checked_alloc(size_t size)
 {
        /* always allocate memory zeroed out */
 
-       void *p = calloc(size, 1);
+       void *p = os_calloc(size, 1);
 
        if (p == NULL)
                vm_abort("memory_checked_alloc: calloc failed: out of memory");
@@ -149,7 +142,7 @@ void *mem_realloc(void *src, int32_t len1, int32_t len2)
 
 #if defined(ENABLE_MEMCHECK)
        if (len2 < len1)
-               memset((u1*)dst + len2, MEMORY_CLEAR_BYTE, len1 - len2);
+               os_memset((u1*)dst + len2, MEMORY_CLEAR_BYTE, len1 - len2);
 #endif
 
        dst = realloc(src, len2);
@@ -159,7 +152,7 @@ void *mem_realloc(void *src, int32_t len1, int32_t len2)
 
 #if defined(ENABLE_MEMCHECK)
        if (len2 > len1)
-               memset((u1*)dst + len1, MEMORY_CLEAR_BYTE, len2 - len1);
+               os_memset((u1*)dst + len1, MEMORY_CLEAR_BYTE, len2 - len1);
 #endif
 
        return dst;
@@ -183,10 +176,10 @@ void mem_free(void *m, int32_t size)
 
 #if defined(ENABLE_MEMCHECK)
        /* destroy the contents */
-       memset(m, MEMORY_CLEAR_BYTE, size);
+       os_memset(m, MEMORY_CLEAR_BYTE, size);
 #endif
 
-       free(m);
+       os_free(m);
 }
 
 
index 0d2c74b2957d2d84bc4d6f8a4e0e3cb5d153e53f..ec6393f19f8a4ac959748a64750ca26a7cae8c89 100644 (file)
 #ifndef _MEMORY_H
 #define _MEMORY_H
 
-
 #include "config.h"
 
-#include <string.h>
+#include <stdint.h>
 
-#include "vm/types.h"
 
-#include "mm/codememory.h"
-#include "mm/dumpmemory.h"
+// Align the size of memory allocations to this size.
+#define ALIGNSIZE 8
+#define MEMORY_ALIGN(pos,size) ((((pos) + (size) - 1) / (size)) * (size))
 
 
-/* constants for ENABLE_MEMCHECK **********************************************/
+// Constants for ENABLE_MEMCHECK.
 
 #if defined(ENABLE_MEMCHECK)
 #define MEMORY_CANARY_SIZE          16
 #define MEMORY_CANARY_FIRST_BYTE    0xca
 #define MEMORY_CLEAR_BYTE           0xa5
-#endif /* defined(ENABLE_MEMCHECK) */
-
+#endif
 
-/* internal includes **********************************************************/
 
-#include "mm/gc-common.h"
+// Includes.
+#include "mm/codememory.h"
+#include "mm/dumpmemory.hpp"
+#include "mm/gc.hpp"
 
 
 /* 
@@ -88,7 +88,6 @@ Some more macros:
 
 */
 
-#define MEMORY_ALIGN(pos,size) ((((pos) + (size) - 1) / (size)) * (size))
 #define PADDING(pos,size)     (MEMORY_ALIGN((pos),(size)) - (pos))
 #define OFFSET(s,el)          ((int32_t) ((ptrint) &(((s*) 0)->el)))
 
@@ -127,6 +126,10 @@ Some more macros:
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool  memory_init(void);
 
 void  memory_mprotect(void *addr, size_t len, int prot);
@@ -144,6 +147,10 @@ void *mem_realloc(void *src, int32_t len1, int32_t len2);
 bool  memory_start_thread(void);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _MEMORY_H */
 
 
diff --git a/src/mm/nogc.c b/src/mm/nogc.c
deleted file mode 100644 (file)
index c84deb4..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/* src/mm/nogc.c - allocates memory through malloc (no GC)
-
-   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
-
-   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 <stdlib.h>
-
-#if defined(HAVE_SYS_MMAN_H)
-# include <sys/mman.h>
-#endif
-
-#include "vm/types.h"
-
-#include "boehm-gc/include/gc.h"
-
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
-
-/* global stuff ***************************************************************/
-
-#define MMAP_HEAPADDRESS    0x10000000  /* try to map the heap to this addr.  */
-#define ALIGNSIZE           8
-
-static void *mmapptr = NULL;
-static int mmapsize = 0;
-static void *mmaptop = NULL;
-
-
-void *heap_alloc(u4 size, u4 references, methodinfo *finalizer, bool collect)
-{
-       void *m;
-
-       mmapptr = (void *) MEMORY_ALIGN((ptrint) mmapptr, ALIGNSIZE);
-       
-       m = mmapptr;
-       mmapptr = (void *) ((ptrint) mmapptr + size);
-
-       if (mmapptr > mmaptop)
-               vm_abort("heap_alloc: out of memory");
-
-       MSET(m, 0, u1, size);
-
-       return m;
-}
-
-
-void *heap_alloc_uncollectable(u4 size)
-{
-       return heap_alloc(size, false, NULL, false);
-}
-
-
-void heap_free(void *p)
-{
-       /* nop */
-}
-
-
-
-void gc_init(u4 heapmaxsize, u4 heapstartsize)
-{
-       heapmaxsize = MEMORY_ALIGN(heapmaxsize, ALIGNSIZE);
-
-#if defined(HAVE_MMAP)
-       mmapptr = mmap((void *) MMAP_HEAPADDRESS,
-                                  (size_t) heapmaxsize,
-                                  PROT_READ | PROT_WRITE,
-                                  MAP_PRIVATE |
-# if defined(MAP_ANONYMOUS)
-                                  MAP_ANONYMOUS,
-# elif defined(MAP_ANON)
-                                  MAP_ANON,
-# else
-                                  0,
-# endif
-                                  -1,
-                                  (off_t) 0);
-
-       if (mmapptr == MAP_FAILED)
-               vm_abort("gc_init: out of memory");
-#else
-       mmapptr = malloc(heapmaxsize);
-
-       if (mmapptr == NULL)
-               vm_abort("gc_init: out of memory");
-#endif
-
-       mmapsize = heapmaxsize;
-       mmaptop = (void *) ((ptrint) mmapptr + mmapsize);
-}
-
-
-void gc_call(void)
-{
-       log_text("GC call: nothing done...");
-       /* nop */
-}
-
-
-s8 gc_get_heap_size(void)
-{
-       return 0;
-}
-
-
-s8 gc_get_free_bytes(void)
-{
-       return 0;
-}
-
-
-s8 gc_get_total_bytes(void)
-{
-       return 0;
-}
-
-
-s8 gc_get_max_heap_size(void)
-{
-       return 0;
-}
-
-
-void gc_invoke_finalizers(void)
-{
-       /* nop */
-}
-
-
-void gc_finalize_all(void)
-{
-       /* nop */
-}
-
-
-/*
- * 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:
- */
diff --git a/src/mm/tlh.c b/src/mm/tlh.c
new file mode 100644 (file)
index 0000000..e46cf87
--- /dev/null
@@ -0,0 +1,128 @@
+/* src/mm/tlh.c
+
+   Copyright (C) 2008
+   CACAOVM - Verein zu Foerderung der freien virtuellen Machine 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 "mm/memory.h"
+#include "mm/tlh.h"
+
+#include "vm/global.h"
+
+#include <assert.h>
+#include <sys/mman.h>
+
+static const int TLH_MAX_SIZE = (20 * 1024 * 1024);
+
+static inline bool tlh_avail(tlh_t *tlh, unsigned n) {
+       /*
+    ---  --- --- ---
+                    ^ end
+            ^ top
+                    ^ top + 2
+       */
+       return (tlh->top + n) <= tlh->end;
+}
+
+void tlh_init(tlh_t *tlh) {
+
+       void *heap = mmap(
+               NULL, 
+               TLH_MAX_SIZE, 
+               PROT_READ|PROT_WRITE, 
+               MAP_ANONYMOUS|MAP_PRIVATE, 
+               -1, 
+               0
+       );
+       
+       if (heap == MAP_FAILED) {
+               /* The top pointer points to end, so all allocations will fail. */
+               tlh->start = NULL;
+               tlh->end = NULL;
+               tlh->top = NULL;
+               tlh->base = NULL;
+       } else {
+               tlh->start = (uint8_t *)heap;
+               tlh->top = tlh->start;
+               tlh->base = tlh->start;
+               tlh->end = tlh->start + TLH_MAX_SIZE;
+       }
+
+       tlh->overflows = 0;
+}
+
+void tlh_destroy(tlh_t *tlh) {
+       int res = munmap(tlh->start, TLH_MAX_SIZE);
+       if (res == -1) {
+               /* TODO */
+               assert(0);
+       }
+       tlh->start = NULL;
+       tlh->end = NULL;
+       tlh->top = NULL;
+       tlh->base = NULL;
+}
+
+void tlh_add_frame(tlh_t *tlh) {
+       if (tlh_avail(tlh, SIZEOF_VOID_P)) {
+               *(uint8_t **)tlh->top = tlh->base;
+               tlh->base = tlh->top;
+               tlh->top += SIZEOF_VOID_P;
+       } else {
+               tlh->overflows += 1;
+       }
+}
+
+void tlh_remove_frame(tlh_t *tlh) {
+       if (tlh->overflows > 0) {
+               tlh->overflows -= 1;
+       } else {
+               tlh->top = tlh->base;
+               tlh->base = *(uint8_t **)tlh->top;
+       }
+}
+
+void *tlh_alloc(tlh_t *tlh, size_t size) {
+       void *ret;
+       if (tlh_avail(tlh, size)) {
+               ret = tlh->top;
+               tlh->top += size;
+               MZERO(ret, char, size);
+       } else {
+               ret = NULL;
+       }
+       return ret;
+}
+
+/*
+ * 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/mm/tlh.h b/src/mm/tlh.h
new file mode 100644 (file)
index 0000000..6a6eab8
--- /dev/null
@@ -0,0 +1,74 @@
+/* src/mm/tlh.h
+
+   Copyright (C) 2008
+   CACAOVM - Verein zu Foerderung der freien virtuellen Machine 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 _MM_TLH_H
+#define _MM_TLH_H
+
+#include "config.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+typedef struct {
+       uint8_t *start;
+       uint8_t *end;
+       uint8_t *top;
+       uint8_t *base;
+       unsigned overflows;
+} tlh_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void tlh_init(tlh_t *tlh);
+
+void tlh_destroy(tlh_t *tlh);
+
+void tlh_add_frame(tlh_t *tlh);
+
+void tlh_remove_frame(tlh_t *tlh);
+
+void *tlh_alloc(tlh_t *tlh, size_t size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/*
+ * 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 8cb17b562df183739d54a40fd245c2e5e35fdb52..4806f11499a351bbd8eb16c9634bdac073eb4bfa 100644 (file)
@@ -1,9 +1,7 @@
 ## src/native/Makefile.am
 ##
-## 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.
 ##
@@ -28,7 +26,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top
 LIBS =
 
 SUBDIRS = \
-       include \
        vm
 
 if ENABLE_JVMTI
@@ -40,18 +37,18 @@ noinst_LTLIBRARIES = libnative.la
 
 if ENABLE_JNI
 JNI_SOURCES = \
-       jni.c \
-       jni.h \
-       localref.c \
-       localref.h
+       jni.cpp \
+       jni.hpp \
+       localref.cpp \
+       localref.hpp
 endif
 
 libnative_la_SOURCES = \
        $(JNI_SOURCES) \
        llni.c \
        llni.h \
-       native.c \
-       native.h
+       native.cpp \
+       native.hpp
 
 libnative_la_LIBADD = \
        vm/libnativevm.la \
index bdecd1eef2815c7ba5229abb617756eb74931e8c..28a29873cc7737d4326ee4b8c1c505112d882db6 100644 (file)
 ## 02110-1301, USA.
 
 
-JAVAH    = $(CACAOH)
-JAVAHCMD = $(JAVAH) -bootclasspath $(BOOTCLASSPATH)
+JAVAH    = javah
+JAVAHCMD = $(JAVAH) -jni -bootclasspath $(BOOTCLASSPATH)
 
-COMMON_HEADER_FILES = \
-       java_lang_Class.h \
-       java_lang_Object.h \
-       java_lang_String.h \
-       java_lang_Thread.h \
-       java_lang_Throwable.h \
-       \
-       java_io_InputStream.h \
-       java_io_PrintStream.h \
-       \
-       java_lang_Boolean.h \
-       java_lang_Byte.h \
-       java_lang_Character.h \
-       java_lang_Double.h \
-       java_lang_Float.h \
-       java_lang_Integer.h \
-       java_lang_Long.h \
-       java_lang_Short.h \
-       java_util_Vector.h
-
-JAVASE_HEADER_FILES = \
-       java_lang_ClassLoader.h \
-       java_lang_Cloneable.h \
-       java_lang_ThreadGroup.h \
-       java_util_Properties.h \
-       \
-       java_io_File.h \
-       java_lang_Process.h \
-       java_lang_StackTraceElement.h \
-       java_lang_reflect_Constructor.h \
-       java_lang_reflect_Field.h \
-       java_lang_reflect_Method.h \
-       java_nio_Buffer.h \
-       java_security_ProtectionDomain.h \
-       java_util_HashMap.h \
-       java_util_Map.h \
-       java_util_concurrent_atomic_AtomicLong.h \
-       sun_misc_Unsafe.h
-
-if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
-JAVASE_HEADER_FILES += \
-       java_lang_VMThread.h \
-       java_lang_VMThrowable.h \
-       \
-       gnu_classpath_Pointer.h \
-       gnu_classpath_Pointer32.h \
-       gnu_classpath_Pointer64.h \
-       gnu_java_lang_VMCPStringBuilder.h \
-       java_lang_VMObject.h \
-       java_lang_reflect_VMConstructor.h \
-       java_lang_reflect_VMField.h \
-       java_lang_reflect_VMMethod.h \
-       java_nio_DirectByteBufferImpl.h
-
-if ENABLE_ANNOTATIONS
-JAVASE_HEADER_FILES += \
-       sun_reflect_ConstantPool.h
-endif
-endif
-
-if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
-JAVASE_HEADER_FILES += \
-       java_lang_AssertionStatusDirectives.h \
-       java_nio_ByteBuffer.h \
-       sun_reflect_ConstantPool.h
-endif
-
-JAVAME_CLDC1_1_HEADER_FILES = \
+if WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
+IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
        com_sun_cldc_io_ResourceInputStream.h \
        com_sun_cldc_io_j2me_socket_Protocol.h \
        com_sun_cldchi_io_ConsoleOutputStream.h \
        com_sun_cldchi_jvm_FileDescriptor.h \
        com_sun_cldchi_jvm_JVM.h \
+       java_lang_Class.h \
        java_lang_Math.h \
        java_lang_Runtime.h \
        java_lang_System.h
-
-JVMTI_HEADER_FILES = \
-       gnu_classpath_jdwp_VMFrame.h \
-       gnu_classpath_jdwp_VMMethod.h \
-       gnu_classpath_jdwp_VMVirtualMachine.h \
-       gnu_classpath_jdwp_event_EventRequest.h \
-       gnu_classpath_jdwp_util_VariableTable.h
+endif
 
 if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
-ADDITIONAL_IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
+IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
        gnu_classpath_VMStackWalker.h \
        gnu_classpath_VMSystemProperties.h \
+       gnu_java_lang_VMCPStringBuilder.h \
        gnu_java_lang_management_VMClassLoadingMXBeanImpl.h \
        gnu_java_lang_management_VMMemoryMXBeanImpl.h \
        gnu_java_lang_management_VMRuntimeMXBeanImpl.h \
        gnu_java_lang_management_VMThreadMXBeanImpl.h \
        java_lang_VMClass.h \
        java_lang_VMClassLoader.h \
+       java_lang_VMObject.h \
        java_lang_VMRuntime.h \
        java_lang_VMString.h \
        java_lang_VMSystem.h \
-       java_lang_management_MemoryUsage.h \
-       java_lang_management_ThreadInfo.h \
+       java_lang_VMThread.h \
+       java_lang_VMThrowable.h \
        java_lang_management_VMManagementFactory.h \
+       java_lang_reflect_VMConstructor.h \
+       java_lang_reflect_VMField.h \
+       java_lang_reflect_VMMethod.h \
        java_lang_reflect_VMProxy.h \
-       java_security_VMAccessController.h
-endif
-
-CLEANFILES = \
-       *.h
-
-DO_HEADER_FILES = \
-       $(COMMON_HEADER_FILES)
+       java_security_VMAccessController.h \
+       java_util_concurrent_atomic_AtomicLong.h \
+       sun_misc_Unsafe.h
 
-if ENABLE_JAVASE
-DO_HEADER_FILES += \
-       $(JAVASE_HEADER_FILES) \
-       $(ADDITIONAL_IMPLEMENTED_VM_CLASSES_HEADER_FILES)
+if ENABLE_ANNOTATIONS
+IMPLEMENTED_VM_CLASSES_HEADER_FILES += \
+       sun_reflect_ConstantPool.h
+endif
 endif
 
-if ENABLE_JAVAME_CLDC1_1
-DO_HEADER_FILES += \
-       $(JAVAME_CLDC1_1_HEADER_FILES)
+if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
+IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
+       sun_misc_Unsafe.h
 endif
 
 if ENABLE_JVMTI
-DO_HEADER_FILES += \
-       $(GEN_JVMTI_HEADER_FILES)
+JVMTI_HEADER_FILES = \
+       gnu_classpath_jdwp_VMFrame.h \
+       gnu_classpath_jdwp_VMMethod.h \
+       gnu_classpath_jdwp_VMVirtualMachine.h \
+       gnu_classpath_jdwp_event_EventRequest.h \
+       gnu_classpath_jdwp_util_VariableTable.h
 endif
 
+CLEANFILES = \
+       *.h
+
+DO_HEADER_FILES = \
+       $(IMPLEMENTED_VM_CLASSES_HEADER_FILES)
+
 if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
+if ENABLE_ZLIB
 VM_ZIP = $(top_builddir)/src/classes/vm.zip
 endif
+endif
 
 if WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
+if ENABLE_ZLIB
 VM_ZIP = $(top_builddir)/src/classes/vm.zip
 endif
+endif
 
 noinst_DATA = $(DO_HEADER_FILES)
 
diff --git a/src/native/jni.c b/src/native/jni.c
deleted file mode 100644 (file)
index 392126e..0000000
+++ /dev/null
@@ -1,4390 +0,0 @@
-/* src/native/jni.c - implementation of the Java Native Interface 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 <stdint.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/localref.h"
-#include "native/native.h"
-
-#if defined(ENABLE_JAVASE)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-#  include "native/include/gnu_classpath_Pointer.h"
-
-#  if SIZEOF_VOID_P == 8
-#   include "native/include/gnu_classpath_Pointer64.h"
-#  else
-#   include "native/include/gnu_classpath_Pointer32.h"
-#  endif
-# endif
-#endif
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Throwable.h"
-
-#if defined(ENABLE_JAVASE)
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-#  include "native/include/java_nio_ByteBuffer.h"       /* required by j.l.CL */
-# endif
-
-/* java_lang_ClassLoader is used in java_lang_Class and vice versa, so
-   we pre-define it here to prevent a compiler warning for Sun
-   configurations. */
-
-struct java_lang_ClassLoader;
-
-# include "native/include/java_lang_Class.h"
-# include "native/include/java_lang_ClassLoader.h"
-
-# include "native/include/java_lang_reflect_Constructor.h"
-# include "native/include/java_lang_reflect_Field.h"
-# include "native/include/java_lang_reflect_Method.h"
-
-# include "native/include/java_nio_Buffer.h"
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-#  include "native/include/java_lang_reflect_VMConstructor.h"
-#  include "native/include/java_lang_reflect_VMField.h"
-#  include "native/include/java_lang_reflect_VMMethod.h"
-
-#  include "native/include/java_nio_DirectByteBufferImpl.h"
-# endif
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-# include "native/include/java_lang_Class.h"
-#endif
-
-#if defined(ENABLE_JVMTI)
-# include "native/jvmti/cacaodbg.h"
-#endif
-
-#if defined(ENABLE_JAVASE)
-# include "native/vm/reflect.h"
-#endif
-
-#include "threads/lock-common.h"
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/primitive.h"
-#include "vm/resolve.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/argument.h"
-#include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-
-
-/* debug **********************************************************************/
-
-#if !defined(NDEBUG)
-# define TRACEJNICALLS(text)                                   \
-    do {                                                                               \
-        if (opt_TraceJNICalls) {                               \
-            log_println text;                                  \
-        }                                                                              \
-    } while (0)
-#else
-# define TRACEJNICALLS(text)
-#endif
-
-
-/* global variables ***********************************************************/
-
-/* global reference table *****************************************************/
-
-/* hashsize must be power of 2 */
-
-#define HASHTABLE_GLOBAL_REF_SIZE    64 /* initial size of globalref-hash     */
-
-static hashtable *hashtable_global_ref; /* hashtable for globalrefs           */
-
-
-/* direct buffer stuff ********************************************************/
-
-#if defined(ENABLE_JAVASE)
-static classinfo *class_java_nio_Buffer;
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-static classinfo *class_java_nio_DirectByteBufferImpl;
-static classinfo *class_java_nio_DirectByteBufferImpl_ReadWrite;
-
-#  if SIZEOF_VOID_P == 8
-static classinfo *class_gnu_classpath_Pointer64;
-#  else
-static classinfo *class_gnu_classpath_Pointer32;
-#  endif
-
-static methodinfo *dbbirw_init;
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-static classinfo *class_sun_nio_ch_DirectBuffer;
-static classinfo *class_java_nio_DirectByteBuffer;
-
-static methodinfo *dbb_init;
-
-# endif
-#endif
-
-
-/* some forward declarations **************************************************/
-
-jobject jni_NewLocalRef(JNIEnv *env, jobject ref);
-
-
-/* jni_init ********************************************************************
-
-   Initialize the JNI subsystem.
-
-*******************************************************************************/
-
-bool jni_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("jni_init");
-
-       /* create global ref hashtable */
-
-       hashtable_global_ref = NEW(hashtable);
-
-       hashtable_create(hashtable_global_ref, HASHTABLE_GLOBAL_REF_SIZE);
-
-
-#if defined(ENABLE_JAVASE)
-       /* Direct buffer stuff. */
-
-       if (!(class_java_nio_Buffer =
-                 load_class_bootstrap(utf_new_char("java/nio/Buffer"))) ||
-               !link_class(class_java_nio_Buffer))
-               return false;
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       if (!(class_java_nio_DirectByteBufferImpl =
-                 load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl"))) ||
-               !link_class(class_java_nio_DirectByteBufferImpl))
-               return false;
-
-       if (!(class_java_nio_DirectByteBufferImpl_ReadWrite =
-                 load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl$ReadWrite"))) ||
-               !link_class(class_java_nio_DirectByteBufferImpl_ReadWrite))
-               return false;
-
-       if (!(dbbirw_init =
-               class_resolvemethod(class_java_nio_DirectByteBufferImpl_ReadWrite,
-                                                       utf_init,
-                                                       utf_new_char("(Ljava/lang/Object;Lgnu/classpath/Pointer;III)V"))))
-               return false;
-
-#  if SIZEOF_VOID_P == 8
-       if (!(class_gnu_classpath_Pointer64 =
-                 load_class_bootstrap(utf_new_char("gnu/classpath/Pointer64"))) ||
-               !link_class(class_gnu_classpath_Pointer64))
-               return false;
-#  else
-       if (!(class_gnu_classpath_Pointer32 =
-                 load_class_bootstrap(utf_new_char("gnu/classpath/Pointer32"))) ||
-               !link_class(class_gnu_classpath_Pointer32))
-               return false;
-#  endif
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       if (!(class_sun_nio_ch_DirectBuffer =
-                 load_class_bootstrap(utf_new_char("sun/nio/ch/DirectBuffer"))))
-               vm_abort("jni_init: loading sun/nio/ch/DirectBuffer failed");
-
-       if (!link_class(class_sun_nio_ch_DirectBuffer))
-               vm_abort("jni_init: linking sun/nio/ch/DirectBuffer failed");
-
-       if (!(class_java_nio_DirectByteBuffer =
-                 load_class_bootstrap(utf_new_char("java/nio/DirectByteBuffer"))))
-               vm_abort("jni_init: loading java/nio/DirectByteBuffer failed");
-
-       if (!link_class(class_java_nio_DirectByteBuffer))
-               vm_abort("jni_init: linking java/nio/DirectByteBuffer failed");
-
-       if (!(dbb_init =
-                 class_resolvemethod(class_java_nio_DirectByteBuffer,
-                                                         utf_init,
-                                                         utf_new_char("(JI)V"))))
-               vm_abort("jni_init: resolving java/nio/DirectByteBuffer.init(JI)V failed");
-
-# endif
-
-#endif /* defined(ENABLE_JAVASE) */
-
-       return true;
-}
-
-
-/* jni_version_check ***********************************************************
-
-   Check if the given JNI version is supported.
-
-   IN:
-       version....JNI version to check
-
-   RETURN VALUE:
-       true.......supported
-       false......not supported
-
-*******************************************************************************/
-
-bool jni_version_check(int version)
-{
-       switch (version) {
-       case JNI_VERSION_1_1:
-       case JNI_VERSION_1_2:
-       case JNI_VERSION_1_4:
-       case JNI_VERSION_1_6:
-               return true;
-       default:
-               return false;
-       }
-}
-
-
-/* _Jv_jni_CallObjectMethod ****************************************************
-
-   Internal function to call Java Object methods.
-
-*******************************************************************************/
-
-static java_handle_t *_Jv_jni_CallObjectMethod(java_handle_t *o,
-                                                                                          vftbl_t *vftbl,
-                                                                                          methodinfo *m, va_list ap)
-{
-       methodinfo    *resm;
-       java_handle_t *ro;
-
-       STATISTICS(jniinvokation());
-
-       if (m == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-
-       } else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       STATISTICS(jnicallXmethodnvokation());
-
-       ro = vm_call_method_valist(resm, o, ap);
-
-       return ro;
-}
-
-
-/* _Jv_jni_CallObjectMethodA ***************************************************
-
-   Internal function to call Java Object methods.
-
-*******************************************************************************/
-
-static java_handle_t *_Jv_jni_CallObjectMethodA(java_handle_t *o,
-                                                                                               vftbl_t *vftbl,
-                                                                                               methodinfo *m,
-                                                                                               const jvalue *args)
-{
-       methodinfo    *resm;
-       java_handle_t *ro;
-
-       STATISTICS(jniinvokation());
-
-       if (m == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-
-       } else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       STATISTICS(jnicallXmethodnvokation());
-
-       ro = vm_call_method_jvalue(resm, o, args);
-
-       return ro;
-}
-
-
-/* _Jv_jni_CallIntMethod *******************************************************
-
-   Internal function to call Java integer class methods (boolean,
-   byte, char, short, int).
-
-*******************************************************************************/
-
-static jint _Jv_jni_CallIntMethod(java_handle_t *o, vftbl_t *vftbl,
-                                                                 methodinfo *m, va_list ap)
-{
-       methodinfo *resm;
-       jint        i;
-
-       STATISTICS(jniinvokation());
-
-       if (m == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-        
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-
-       } else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       STATISTICS(jnicallXmethodnvokation());
-
-       i = vm_call_method_int_valist(resm, o, ap);
-
-       return i;
-}
-
-
-/* _Jv_jni_CallIntMethodA ******************************************************
-
-   Internal function to call Java integer class methods (boolean,
-   byte, char, short, int).
-
-*******************************************************************************/
-
-static jint _Jv_jni_CallIntMethodA(java_handle_t *o, vftbl_t *vftbl,
-                                                                  methodinfo *m, const jvalue *args)
-{
-       methodinfo *resm;
-       jint        i;
-
-       STATISTICS(jniinvokation());
-
-       if (m == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-        
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-
-       } else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       STATISTICS(jnicallXmethodnvokation());
-
-       i = vm_call_method_int_jvalue(resm, o, args);
-
-       return i;
-}
-
-
-/* _Jv_jni_CallLongMethod ******************************************************
-
-   Internal function to call Java long methods.
-
-*******************************************************************************/
-
-static jlong _Jv_jni_CallLongMethod(java_handle_t *o, vftbl_t *vftbl,
-                                                                       methodinfo *m, va_list ap)
-{
-       methodinfo *resm;
-       jlong       l;
-
-       STATISTICS(jniinvokation());
-
-       if (m == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-
-       } else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       STATISTICS(jnicallXmethodnvokation());
-
-       l = vm_call_method_long_valist(resm, o, ap);
-
-       return l;
-}
-
-
-/* _Jv_jni_CallLongMethodA *****************************************************
-
-   Internal function to call Java long methods.
-
-*******************************************************************************/
-
-static jlong _Jv_jni_CallLongMethodA(java_handle_t *o, vftbl_t *vftbl,
-                                                                        methodinfo *m, const jvalue *args)
-{
-       methodinfo *resm;
-       jlong       l;
-
-       STATISTICS(jniinvokation());
-
-       if (m == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-       }
-       else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       STATISTICS(jnicallXmethodnvokation());
-
-       l = vm_call_method_long_jvalue(resm, o, args);
-
-       return l;
-}
-
-
-/* _Jv_jni_CallFloatMethod *****************************************************
-
-   Internal function to call Java float methods.
-
-*******************************************************************************/
-
-static jfloat _Jv_jni_CallFloatMethod(java_handle_t *o, vftbl_t *vftbl,
-                                                                         methodinfo *m, va_list ap)
-{
-       methodinfo *resm;
-       jfloat      f;
-
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-
-       } else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       STATISTICS(jnicallXmethodnvokation());
-
-       f = vm_call_method_float_valist(resm, o, ap);
-
-       return f;
-}
-
-
-/* _Jv_jni_CallFloatMethodA ****************************************************
-
-   Internal function to call Java float methods.
-
-*******************************************************************************/
-
-static jfloat _Jv_jni_CallFloatMethodA(java_handle_t *o, vftbl_t *vftbl,
-                                                                          methodinfo *m, const jvalue *args)
-{
-       methodinfo *resm;
-       jfloat      f;
-
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-       }
-       else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       STATISTICS(jnicallXmethodnvokation());
-
-       f = vm_call_method_float_jvalue(resm, o, args);
-
-       return f;
-}
-
-
-/* _Jv_jni_CallDoubleMethod ****************************************************
-
-   Internal function to call Java double methods.
-
-*******************************************************************************/
-
-static jdouble _Jv_jni_CallDoubleMethod(java_handle_t *o, vftbl_t *vftbl,
-                                                                               methodinfo *m, va_list ap)
-{
-       methodinfo *resm;
-       jdouble     d;
-
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-
-       } else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       d = vm_call_method_double_valist(resm, o, ap);
-
-       return d;
-}
-
-
-/* _Jv_jni_CallDoubleMethodA ***************************************************
-
-   Internal function to call Java double methods.
-
-*******************************************************************************/
-
-static jdouble _Jv_jni_CallDoubleMethodA(java_handle_t *o, vftbl_t *vftbl,
-                                                                                methodinfo *m, const jvalue *args)
-{
-       methodinfo *resm;
-       jdouble     d;
-
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-       }
-       else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       d = vm_call_method_double_jvalue(resm, o, args);
-
-       return d;
-}
-
-
-/* _Jv_jni_CallVoidMethod ******************************************************
-
-   Internal function to call Java void methods.
-
-*******************************************************************************/
-
-static void _Jv_jni_CallVoidMethod(java_handle_t *o, vftbl_t *vftbl,
-                                                                  methodinfo *m, va_list ap)
-{      
-       methodinfo *resm;
-
-       if (m == NULL) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-
-       } else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       STATISTICS(jnicallXmethodnvokation());
-
-       (void) vm_call_method_valist(resm, o, ap);
-}
-
-
-/* _Jv_jni_CallVoidMethodA *****************************************************
-
-   Internal function to call Java void methods.
-
-*******************************************************************************/
-
-static void _Jv_jni_CallVoidMethodA(java_handle_t *o, vftbl_t *vftbl,
-                                                                       methodinfo *m, const jvalue *args)
-{      
-       methodinfo *resm;
-
-       if (m == NULL) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       /* Class initialization is done by the JIT compiler.  This is ok
-          since a static method always belongs to the declaring class. */
-
-       if (m->flags & ACC_STATIC) {
-               /* For static methods we reset the object. */
-
-               if (o != NULL)
-                       o = NULL;
-
-               /* for convenience */
-
-               resm = m;
-
-       } else {
-               /* For instance methods we make a virtual function table lookup. */
-
-               resm = method_vftbl_lookup(vftbl, m);
-       }
-
-       STATISTICS(jnicallXmethodnvokation());
-
-       (void) vm_call_method_jvalue(resm, o, args);
-}
-
-
-/* GetVersion ******************************************************************
-
-   Returns the major version number in the higher 16 bits and the
-   minor version number in the lower 16 bits.
-
-*******************************************************************************/
-
-jint _Jv_JNI_GetVersion(JNIEnv *env)
-{
-       TRACEJNICALLS(("_Jv_JNI_GetVersion(env=%p)", env));
-
-       /* We support JNI 1.6. */
-
-       return JNI_VERSION_1_6;
-}
-
-
-/* Class Operations ***********************************************************/
-
-/* DefineClass *****************************************************************
-
-   Loads a class from a buffer of raw class data. The buffer
-   containing the raw class data is not referenced by the VM after the
-   DefineClass call returns, and it may be discarded if desired.
-
-*******************************************************************************/
-
-jclass _Jv_JNI_DefineClass(JNIEnv *env, const char *name, jobject loader,
-                                                  const jbyte *buf, jsize bufLen)
-{
-#if defined(ENABLE_JAVASE)
-       utf             *u;
-       classloader_t   *cl;
-       classinfo       *c;
-       java_lang_Class *co;
-
-       TRACEJNICALLS(("_Jv_JNI_DefineClass(env=%p, name=%s, loader=%p, buf=%p, bufLen=%d)", env, name, loader, buf, bufLen));
-
-       u  = utf_new_char(name);
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       c = class_define(u, cl, bufLen, (uint8_t *) buf, NULL);
-
-       co = LLNI_classinfo_wrap(c);
-
-       return (jclass) jni_NewLocalRef(env, (jobject) co);
-#else
-       vm_abort("_Jv_JNI_DefineClass: not implemented in this configuration");
-
-       /* keep compiler happy */
-
-       return 0;
-#endif
-}
-
-
-/* FindClass *******************************************************************
-
-   This function loads a locally-defined class. It searches the
-   directories and zip files specified by the CLASSPATH environment
-   variable for the class with the specified name.
-
-*******************************************************************************/
-
-jclass jni_FindClass(JNIEnv *env, const char *name)
-{
-#if defined(ENABLE_JAVASE)
-
-       utf             *u;
-       classinfo       *cc;
-       classinfo       *c;
-       java_lang_Class *co;
-
-       TRACEJNICALLS(("jni_FindClass(env=%p, name=%s)", env, name));
-
-       /* FIXME If name is NULL we have a problem here. */
-
-       u = utf_new_char_classname((char *) name);
-
-       if ((u == NULL) /*|| (int)strlen(name) > symbolOopDesc::max_length() */) {
-               exceptions_throw_noclassdeffounderror(u);
-               return NULL;
-       }
-
-       /* Check stacktrace for classloader, if one found use it,
-          otherwise use the system classloader. */
-
-       /* Quote from the JNI documentation:
-        
-          In the Java 2 Platform, FindClass locates the class loader
-          associated with the current native method.  If the native code
-          belongs to a system class, no class loader will be
-          involved. Otherwise, the proper class loader will be invoked to
-          load and link the named class. When FindClass is called through
-          the Invocation Interface, there is no current native method or
-          its associated class loader. In that case, the result of
-          ClassLoader.getBaseClassLoader is used." */
-
-       cc = stacktrace_get_current_class();
-
-       if (cc == NULL)
-               c = load_class_from_sysloader(u);
-       else
-               c = load_class_from_classloader(u, cc->classloader);
-
-       if (c == NULL) {
-               resolve_handle_pending_exception(true);
-               return NULL;
-       }
-
-       if (!link_class(c))
-               return NULL;
-
-       co = LLNI_classinfo_wrap(c);
-
-       return (jclass) jni_NewLocalRef(env, (jobject) co);
-
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-
-       utf       *u;
-       classinfo *c;
-
-       TRACEJNICALLS(("jni_FindClass(env=%p, name=%s)", env, name));
-
-       u = utf_new_char_classname((char *) name);
-       c = load_class_bootstrap(u);
-
-       if (c == NULL) {
-               resolve_handle_pending_exception(true);
-               return NULL;
-       }
-
-       if (!link_class(c))
-               return NULL;
-
-       return (jclass) jni_NewLocalRef(env, (jobject) c);
-       
-#else
-       vm_abort("jni_FindClass: not implemented in this configuration");
-
-       /* keep compiler happy */
-
-       return NULL;
-#endif
-}
-  
-
-/* GetSuperclass ***************************************************************
-
-   If clazz represents any class other than the class Object, then
-   this function returns the object that represents the superclass of
-   the class specified by clazz.
-
-*******************************************************************************/
-jclass _Jv_JNI_GetSuperclass(JNIEnv *env, jclass sub)
-{
-       classinfo       *c;
-       classinfo       *super;
-       java_lang_Class *co;
-
-       TRACEJNICALLS(("_Jv_JNI_GetSuperclass(env=%p, sub=%p)", env, sub));
-
-       c = LLNI_classinfo_unwrap(sub);
-
-       if (c == NULL)
-               return NULL;
-
-       super = class_get_superclass(c);
-
-       co = LLNI_classinfo_wrap(super);
-
-       return (jclass) jni_NewLocalRef(env, (jobject) co);
-}
-  
-/* IsAssignableFrom ************************************************************
-
-   Determines whether an object of sub can be safely cast to sup.
-
-*******************************************************************************/
-
-jboolean _Jv_JNI_IsAssignableFrom(JNIEnv *env, jclass sub, jclass sup)
-{
-       classinfo *to;
-       classinfo *from;
-
-       TRACEJNICALLS(("_Jv_JNI_IsAssignableFrom(env=%p, sub=%p, sup=%p)", env, sub, sup));
-
-       to   = (classinfo *) sup;
-       from = (classinfo *) sub;
-
-       return class_is_assignable_from(to, from);
-}
-
-
-/* Throw ***********************************************************************
-
-   Causes a java.lang.Throwable object to be thrown.
-
-*******************************************************************************/
-
-jint _Jv_JNI_Throw(JNIEnv *env, jthrowable obj)
-{
-       java_handle_t *o;
-
-       STATISTICS(jniinvokation());
-
-       o = (java_handle_t *) obj;
-
-       exceptions_set_exception(o);
-
-       return JNI_OK;
-}
-
-
-/* ThrowNew ********************************************************************
-
-   Constructs an exception object from the specified class with the
-   message specified by message and causes that exception to be
-   thrown.
-
-*******************************************************************************/
-
-jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg) 
-{
-       classinfo     *c;
-       java_handle_t *o;
-       java_handle_t *s;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(clazz);
-       if (msg == NULL)
-               msg = "";
-       s = javastring_new_from_utf_string(msg);
-
-       /* instantiate exception object */
-
-       o = native_new_and_init_string(c, s);
-
-       if (o == NULL)
-               return -1;
-
-       exceptions_set_exception(o);
-
-       return 0;
-}
-
-
-/* ExceptionOccurred ***********************************************************
-
-   Determines if an exception is being thrown. The exception stays
-   being thrown until either the native code calls ExceptionClear(),
-   or the Java code handles the exception.
-
-*******************************************************************************/
-
-jthrowable _Jv_JNI_ExceptionOccurred(JNIEnv *env)
-{
-       java_handle_t *o;
-
-       TRACEJNICALLS(("_Jv_JNI_ExceptionOccurred(env=%p)", env));
-
-       o = exceptions_get_exception();
-
-       return jni_NewLocalRef(env, (jthrowable) o);
-}
-
-
-/* ExceptionDescribe ***********************************************************
-
-   Prints an exception and a backtrace of the stack to a system
-   error-reporting channel, such as stderr. This is a convenience
-   routine provided for debugging.
-
-*******************************************************************************/
-
-void jni_ExceptionDescribe(JNIEnv *env)
-{
-       TRACEJNICALLS(("jni_ExceptionDescribe(env=%p)", env));
-
-       exceptions_print_stacktrace();
-}
-
-
-/* ExceptionClear **************************************************************
-
-   Clears any exception that is currently being thrown. If no
-   exception is currently being thrown, this routine has no effect.
-
-*******************************************************************************/
-
-void jni_ExceptionClear(JNIEnv *env)
-{
-       TRACEJNICALLS(("jni_ExceptionClear(env=%p)", env));
-
-       exceptions_clear_exception();
-}
-
-
-/* FatalError ******************************************************************
-
-   Raises a fatal error and does not expect the VM to recover. This
-   function does not return.
-
-*******************************************************************************/
-
-void _Jv_JNI_FatalError(JNIEnv *env, const char *msg)
-{
-       STATISTICS(jniinvokation());
-
-       /* this seems to be the best way */
-
-       vm_abort("JNI Fatal error: %s", msg);
-}
-
-
-/* PushLocalFrame **************************************************************
-
-   Creates a new local reference frame, in which at least a given
-   number of local references can be created.
-
-*******************************************************************************/
-
-jint jni_PushLocalFrame(JNIEnv* env, jint capacity)
-{
-       TRACEJNICALLS(("jni_PushLocalFrame(env=%p, capacity=%d)", env, capacity));
-
-       if (capacity <= 0)
-               return -1;
-
-       /* add new local reference frame to current table */
-
-       if (!localref_frame_push(capacity))
-               return -1;
-
-       return 0;
-}
-
-
-/* PopLocalFrame ***************************************************************
-
-   Pops off the current local reference frame, frees all the local
-   references, and returns a local reference in the previous local
-   reference frame for the given result object.
-
-*******************************************************************************/
-
-jobject jni_PopLocalFrame(JNIEnv* env, jobject result)
-{
-       TRACEJNICALLS(("jni_PopLocalFrame(env=%p, result=%p)", env, result));
-
-       /* release all current local frames */
-
-       localref_frame_pop_all();
-
-       /* add local reference and return the value */
-
-       return jni_NewLocalRef(env, result);
-}
-
-
-/* DeleteLocalRef **************************************************************
-
-   Deletes the local reference pointed to by localRef.
-
-*******************************************************************************/
-
-void jni_DeleteLocalRef(JNIEnv *env, jobject localRef)
-{
-       java_handle_t *o;
-
-       TRACEJNICALLS(("jni_DeleteLocalRef(env=%p, ref=%p)", env, localRef));
-
-       o = (java_handle_t *) localRef;
-
-       if (o == NULL)
-               return;
-
-       /* delete the reference */
-
-       localref_del(o);
-}
-
-
-/* IsSameObject ****************************************************************
-
-   Tests whether two references refer to the same Java object.
-
-*******************************************************************************/
-
-jboolean _Jv_JNI_IsSameObject(JNIEnv *env, jobject ref1, jobject ref2)
-{
-       java_handle_t *o1;
-       java_handle_t *o2;
-       jboolean       result;
-
-       STATISTICS(jniinvokation());
-
-       o1 = (java_handle_t *) ref1;
-       o2 = (java_handle_t *) ref2;
-
-       LLNI_CRITICAL_START;
-
-       if (LLNI_UNWRAP(o1) == LLNI_UNWRAP(o2))
-               result = JNI_TRUE;
-       else
-               result = JNI_FALSE;
-
-       LLNI_CRITICAL_END;
-
-       return result;
-}
-
-
-/* NewLocalRef *****************************************************************
-
-   Creates a new local reference that refers to the same object as ref.
-
-*******************************************************************************/
-
-jobject jni_NewLocalRef(JNIEnv *env, jobject ref)
-{
-       java_handle_t *o;
-       java_handle_t *localref;
-
-       TRACEJNICALLS(("jni_NewLocalRef(env=%p, ref=%p)", env, ref));
-
-       o = (java_handle_t *) ref;
-
-       if (o == NULL)
-               return NULL;
-
-       /* insert the reference */
-
-       localref = localref_add(LLNI_DIRECT(o));
-
-       return (jobject) localref;
-}
-
-
-/* EnsureLocalCapacity *********************************************************
-
-   Ensures that at least a given number of local references can be
-   created in the current thread
-
-*******************************************************************************/
-
-jint jni_EnsureLocalCapacity(JNIEnv* env, jint capacity)
-{
-       localref_table *lrt;
-
-       TRACEJNICALLS(("jni_EnsureLocalCapacity(env=%p, capacity=%d)", env, capacity));
-
-       /* get local reference table (thread specific) */
-
-       lrt = LOCALREFTABLE;
-
-       /* check if capacity elements are available in the local references table */
-
-       if ((lrt->used + capacity) > lrt->capacity)
-               return jni_PushLocalFrame(env, capacity);
-
-       return 0;
-}
-
-
-/* AllocObject *****************************************************************
-
-   Allocates a new Java object without invoking any of the
-   constructors for the object. Returns a reference to the object.
-
-*******************************************************************************/
-
-jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz)
-{
-       classinfo     *c;
-       java_handle_t *o;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(clazz);
-
-       if ((c->flags & ACC_INTERFACE) || (c->flags & ACC_ABSTRACT)) {
-               exceptions_throw_instantiationexception(c);
-               return NULL;
-       }
-               
-       o = builtin_new(c);
-
-       return jni_NewLocalRef(env, (jobject) o);
-}
-
-
-/* NewObject *******************************************************************
-
-   Programmers place all arguments that are to be passed to the
-   constructor immediately following the methodID
-   argument. NewObject() accepts these arguments and passes them to
-   the Java method that the programmer wishes to invoke.
-
-*******************************************************************************/
-
-jobject _Jv_JNI_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
-{
-       java_handle_t *o;
-       classinfo     *c;
-       methodinfo    *m;
-       va_list        ap;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(clazz);
-       m = (methodinfo *) methodID;
-
-       /* create object */
-
-       o = builtin_new(c);
-       
-       if (o == NULL)
-               return NULL;
-
-       /* call constructor */
-
-       va_start(ap, methodID);
-       _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, ap);
-       va_end(ap);
-
-       return jni_NewLocalRef(env, (jobject) o);
-}
-
-
-/* NewObjectV ******************************************************************
-
-   Programmers place all arguments that are to be passed to the
-   constructor in an args argument of type va_list that immediately
-   follows the methodID argument. NewObjectV() accepts these
-   arguments, and, in turn, passes them to the Java method that the
-   programmer wishes to invoke.
-
-*******************************************************************************/
-
-jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID,
-                                                  va_list args)
-{
-       java_handle_t *o;
-       classinfo     *c;
-       methodinfo    *m;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(clazz);
-       m = (methodinfo *) methodID;
-
-       /* create object */
-
-       o = builtin_new(c);
-       
-       if (o == NULL)
-               return NULL;
-
-       /* call constructor */
-
-       _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, args);
-
-       return jni_NewLocalRef(env, (jobject) o);
-}
-
-
-/* NewObjectA ***************************************************************** 
-
-   Programmers place all arguments that are to be passed to the
-   constructor in an args array of jvalues that immediately follows
-   the methodID argument. NewObjectA() accepts the arguments in this
-   array, and, in turn, passes them to the Java method that the
-   programmer wishes to invoke.
-
-*******************************************************************************/
-
-jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID,
-                                                  const jvalue *args)
-{
-       java_handle_t *o;
-       classinfo     *c;
-       methodinfo    *m;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(clazz);
-       m = (methodinfo *) methodID;
-
-       /* create object */
-
-       o = builtin_new(c);
-       
-       if (o == NULL)
-               return NULL;
-
-       /* call constructor */
-
-       _Jv_jni_CallVoidMethodA(o, LLNI_vftbl_direct(o), m, args);
-
-       return jni_NewLocalRef(env, (jobject) o);
-}
-
-
-/* GetObjectClass **************************************************************
-
- Returns the class of an object.
-
-*******************************************************************************/
-
-jclass _Jv_JNI_GetObjectClass(JNIEnv *env, jobject obj)
-{
-       java_handle_t   *o;
-       classinfo       *c;
-       java_lang_Class *co;
-
-       STATISTICS(jniinvokation());
-
-       o = (java_handle_t *) obj;
-
-       if ((o == NULL) || (LLNI_vftbl_direct(o) == NULL))
-               return NULL;
-
-       LLNI_class_get(o, c);
-
-       co = LLNI_classinfo_wrap(c);
-
-       return (jclass) jni_NewLocalRef(env, (jobject) co);
-}
-
-
-/* IsInstanceOf ****************************************************************
-
-   Tests whether an object is an instance of a class.
-
-*******************************************************************************/
-
-jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)
-{
-       classinfo     *c;
-       java_handle_t *h;
-
-       TRACEJNICALLS(("_Jv_JNI_IsInstanceOf(env=%p, obj=%p, clazz=%p)", env, obj, clazz));
-
-       /* XXX Is this correct? */
-       c = LLNI_classinfo_unwrap(clazz);
-       h = (java_handle_t *) obj;
-
-       return class_is_instance(c, h);
-}
-
-
-/* Reflection Support *********************************************************/
-
-/* FromReflectedMethod *********************************************************
-
-   Converts java.lang.reflect.Method or java.lang.reflect.Constructor
-   object to a method ID.
-  
-*******************************************************************************/
-  
-jmethodID jni_FromReflectedMethod(JNIEnv *env, jobject method)
-{
-#if defined(ENABLE_JAVASE)
-       java_handle_t                   *o;
-       java_lang_reflect_Method        *rm;
-       java_lang_reflect_Constructor   *rc;
-       classinfo                       *c;
-       methodinfo                      *m;
-       int32_t                          slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_reflect_VMMethod      *rvmm;
-       java_lang_reflect_VMConstructor *rvmc;
-#endif
-
-       TRACEJNICALLS(("jni_FromReflectedMethod(env=%p, method=%p)", env, method));
-
-       o = (java_handle_t *) method;
-
-       if (o == NULL)
-               return NULL;
-
-       if (o->vftbl->clazz == class_java_lang_reflect_Constructor) {
-               rc = (java_lang_reflect_Constructor *) method;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-               LLNI_field_get_ref(rc,   cons , rvmc);
-               LLNI_field_get_cls(rvmc, clazz, c);
-               LLNI_field_get_val(rvmc, slot , slot);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-               LLNI_field_get_cls(rc, clazz, c);
-               LLNI_field_get_val(rc, slot , slot);
-
-#else
-# error unknown configuration
-#endif
-       }
-       else {
-               assert(o->vftbl->clazz == class_java_lang_reflect_Method);
-
-               rm = (java_lang_reflect_Method *) method;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-               LLNI_field_get_ref(rm,   m ,    rvmm);
-               LLNI_field_get_cls(rvmm, clazz, c);
-               LLNI_field_get_val(rvmm, slot , slot);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-               LLNI_field_get_cls(rm, clazz, c);
-               LLNI_field_get_val(rm, slot , slot);
-
-#else
-# error unknown configuration
-#endif
-       }
-
-       m = &(c->methods[slot]);
-
-       return (jmethodID) m;
-#else
-       vm_abort("jni_FromReflectedMethod: Not implemented in this configuration.");
-
-       /* Keep compiler happy. */
-
-       return NULL;
-#endif
-}
-
-
-/* FromReflectedField **********************************************************
-
-   Converts a java.lang.reflect.Field to a field ID.
-
-*******************************************************************************/
-jfieldID jni_FromReflectedField(JNIEnv* env, jobject field)
-{
-#if defined(ENABLE_JAVASE)
-       java_lang_reflect_Field   *rf;
-       classinfo                 *c;
-       fieldinfo                 *f;
-       int32_t                    slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_reflect_VMField *rvmf;
-#endif
-
-       TRACEJNICALLS(("jni_FromReflectedField(env=%p, field=%p)", env, field));
-
-       rf = (java_lang_reflect_Field *) field;
-
-       if (rf == NULL)
-               return NULL;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       LLNI_field_get_ref(rf,   f,     rvmf);
-       LLNI_field_get_cls(rvmf, clazz, c);
-       LLNI_field_get_val(rvmf, slot , slot);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       LLNI_field_get_cls(rf, clazz, c);
-       LLNI_field_get_val(rf, slot , slot);
-
-#else
-# error unknown configuration
-#endif
-
-       f = &(c->fields[slot]);
-
-       return (jfieldID) f;
-#else
-       vm_abort("jni_FromReflectedField: Not implemented in this configuration.");
-
-       /* Keep compiler happy. */
-
-       return NULL;
-#endif
-}
-
-
-/* ToReflectedMethod ***********************************************************
-
-   Converts a method ID derived from cls to an instance of the
-   java.lang.reflect.Method class or to an instance of the
-   java.lang.reflect.Constructor class.
-
-*******************************************************************************/
-
-jobject _Jv_JNI_ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID,
-                                                                 jboolean isStatic)
-{
-#if defined(ENABLE_JAVASE)
-       methodinfo                    *m;
-       java_lang_reflect_Constructor *rc;
-       java_lang_reflect_Method      *rm;
-
-       TRACEJNICALLS(("_Jv_JNI_ToReflectedMethod(env=%p, cls=%p, methodID=%p, isStatic=%d)", env, cls, methodID, isStatic));
-
-       m = (methodinfo *) methodID;
-
-       /* HotSpot does the same assert. */
-
-       assert(((m->flags & ACC_STATIC) != 0) == (isStatic != 0));
-
-       if (m->name == utf_init) {
-               rc = reflect_constructor_new(m);
-
-               return (jobject) rc;
-       }
-       else {
-               rm = reflect_method_new(m);
-
-               return (jobject) rm;
-       }
-#else
-       vm_abort("_Jv_JNI_ToReflectedMethod: not implemented in this configuration");
-
-       /* keep compiler happy */
-
-       return NULL;
-#endif
-}
-
-
-/* ToReflectedField ************************************************************
-
-   Converts a field ID derived from cls to an instance of the
-   java.lang.reflect.Field class.
-
-*******************************************************************************/
-
-jobject _Jv_JNI_ToReflectedField(JNIEnv* env, jclass cls, jfieldID fieldID,
-                                                                jboolean isStatic)
-{
-       STATISTICS(jniinvokation());
-
-       log_text("JNI-Call: ToReflectedField: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* Calling Instance Methods ***************************************************/
-
-/* GetMethodID *****************************************************************
-
-   Returns the method ID for an instance (nonstatic) method of a class
-   or interface. The method may be defined in one of the clazz's
-   superclasses and inherited by clazz. The method is determined by
-   its name and signature.
-
-   GetMethodID() causes an uninitialized class to be initialized.
-
-*******************************************************************************/
-
-jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name,
-                                                         const char *sig)
-{
-       classinfo  *c;
-       utf        *uname;
-       utf        *udesc;
-       methodinfo *m;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(clazz);
-
-       if (c == NULL)
-               return NULL;
-
-       if (!(c->state & CLASS_INITIALIZED))
-               if (!initialize_class(c))
-                       return NULL;
-
-       /* try to get the method of the class or one of it's superclasses */
-
-       uname = utf_new_char((char *) name);
-       udesc = utf_new_char((char *) sig);
-
-       m = class_resolvemethod(c, uname, udesc);
-
-       if ((m == NULL) || (m->flags & ACC_STATIC)) {
-               exceptions_throw_nosuchmethoderror(c, uname, udesc);
-
-               return NULL;
-       }
-
-       return (jmethodID) m;
-}
-
-
-/* JNI-functions for calling instance methods *********************************/
-
-#define JNI_CALL_VIRTUAL_METHOD(name, type, intern)         \
-type _Jv_JNI_Call##name##Method(JNIEnv *env, jobject obj,   \
-                                                               jmethodID methodID, ...)    \
-{                                                           \
-       java_handle_t *o;                                       \
-       methodinfo    *m;                                       \
-       va_list        ap;                                      \
-       type           ret;                                     \
-                                                            \
-       o = (java_handle_t *) obj;                              \
-       m = (methodinfo *) methodID;                            \
-                                                            \
-       va_start(ap, methodID);                                 \
-       ret = _Jv_jni_Call##intern##Method(o, LLNI_vftbl_direct(o), m, ap); \
-       va_end(ap);                                             \
-                                                            \
-       return ret;                                             \
-}
-
-JNI_CALL_VIRTUAL_METHOD(Boolean, jboolean, Int)
-JNI_CALL_VIRTUAL_METHOD(Byte,    jbyte,    Int)
-JNI_CALL_VIRTUAL_METHOD(Char,    jchar,    Int)
-JNI_CALL_VIRTUAL_METHOD(Short,   jshort,   Int)
-JNI_CALL_VIRTUAL_METHOD(Int,     jint,     Int)
-JNI_CALL_VIRTUAL_METHOD(Long,    jlong,    Long)
-JNI_CALL_VIRTUAL_METHOD(Float,   jfloat,   Float)
-JNI_CALL_VIRTUAL_METHOD(Double,  jdouble,  Double)
-
-
-#define JNI_CALL_VIRTUAL_METHOD_V(name, type, intern)              \
-type _Jv_JNI_Call##name##MethodV(JNIEnv *env, jobject obj,         \
-                                                                jmethodID methodID, va_list args) \
-{                                                                  \
-       java_handle_t *o;                                              \
-       methodinfo    *m;                                              \
-       type           ret;                                            \
-                                                                   \
-       o = (java_handle_t *) obj;                                     \
-       m = (methodinfo *) methodID;                                   \
-                                                                   \
-       ret = _Jv_jni_Call##intern##Method(o, LLNI_vftbl_direct(o), m, args);      \
-                                                                   \
-       return ret;                                                    \
-}
-
-JNI_CALL_VIRTUAL_METHOD_V(Boolean, jboolean, Int)
-JNI_CALL_VIRTUAL_METHOD_V(Byte,    jbyte,    Int)
-JNI_CALL_VIRTUAL_METHOD_V(Char,    jchar,    Int)
-JNI_CALL_VIRTUAL_METHOD_V(Short,   jshort,   Int)
-JNI_CALL_VIRTUAL_METHOD_V(Int,     jint,     Int)
-JNI_CALL_VIRTUAL_METHOD_V(Long,    jlong,    Long)
-JNI_CALL_VIRTUAL_METHOD_V(Float,   jfloat,   Float)
-JNI_CALL_VIRTUAL_METHOD_V(Double,  jdouble,  Double)
-
-
-#define JNI_CALL_VIRTUAL_METHOD_A(name, type, intern)          \
-type _Jv_JNI_Call##name##MethodA(JNIEnv *env, jobject obj,     \
-                                                                jmethodID methodID,           \
-                                                                const jvalue *args)           \
-{                                                              \
-       java_handle_t *o;                                          \
-       methodinfo    *m;                                          \
-       type           ret;                                        \
-                                                               \
-       o = (java_handle_t *) obj;                                 \
-       m = (methodinfo *) methodID;                               \
-                                                               \
-       ret = _Jv_jni_Call##intern##MethodA(o, LLNI_vftbl_direct(o), m, args); \
-                                                               \
-       return ret;                                                \
-}
-
-JNI_CALL_VIRTUAL_METHOD_A(Boolean, jboolean, Int)
-JNI_CALL_VIRTUAL_METHOD_A(Byte,    jbyte,    Int)
-JNI_CALL_VIRTUAL_METHOD_A(Char,    jchar,    Int)
-JNI_CALL_VIRTUAL_METHOD_A(Short,   jshort,   Int)
-JNI_CALL_VIRTUAL_METHOD_A(Int,     jint,     Int)
-JNI_CALL_VIRTUAL_METHOD_A(Long,    jlong,    Long)
-JNI_CALL_VIRTUAL_METHOD_A(Float,   jfloat,   Float)
-JNI_CALL_VIRTUAL_METHOD_A(Double,  jdouble,  Double)
-
-
-jobject _Jv_JNI_CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                                ...)
-{
-       java_handle_t *o;
-       methodinfo    *m;
-       java_handle_t *ret;
-       va_list        ap;
-
-       o = (java_handle_t *) obj;
-       m = (methodinfo *) methodID;
-
-       va_start(ap, methodID);
-       ret = _Jv_jni_CallObjectMethod(o, LLNI_vftbl_direct(o), m, ap);
-       va_end(ap);
-
-       return jni_NewLocalRef(env, (jobject) ret);
-}
-
-
-jobject _Jv_JNI_CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                                 va_list args)
-{
-       java_handle_t *o;
-       methodinfo    *m;
-       java_handle_t *ret;
-
-       o = (java_handle_t *) obj;
-       m = (methodinfo *) methodID;
-
-       ret = _Jv_jni_CallObjectMethod(o, LLNI_vftbl_direct(o), m, args);
-
-       return jni_NewLocalRef(env, (jobject) ret);
-}
-
-
-jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                                 const jvalue *args)
-{
-       java_handle_t *o;
-       methodinfo    *m;
-       java_handle_t *ret;
-
-       o = (java_handle_t *) obj;
-       m = (methodinfo *) methodID;
-
-       ret = _Jv_jni_CallObjectMethodA(o, LLNI_vftbl_direct(o), m, args);
-
-       return jni_NewLocalRef(env, (jobject) ret);
-}
-
-
-
-void _Jv_JNI_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
-{
-       java_handle_t *o;
-       methodinfo    *m;
-       va_list        ap;
-
-       o = (java_handle_t *) obj;
-       m = (methodinfo *) methodID;
-
-       va_start(ap, methodID);
-       _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, ap);
-       va_end(ap);
-}
-
-
-void _Jv_JNI_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                        va_list args)
-{
-       java_handle_t *o;
-       methodinfo    *m;
-
-       o = (java_handle_t *) obj;
-       m = (methodinfo *) methodID;
-
-       _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, args);
-}
-
-
-void _Jv_JNI_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                        const jvalue *args)
-{
-       java_handle_t *o;
-       methodinfo    *m;
-
-       o = (java_handle_t *) obj;
-       m = (methodinfo *) methodID;
-
-       _Jv_jni_CallVoidMethodA(o, LLNI_vftbl_direct(o), m, args);
-}
-
-
-
-#define JNI_CALL_NONVIRTUAL_METHOD(name, type, intern)                      \
-type _Jv_JNI_CallNonvirtual##name##Method(JNIEnv *env, jobject obj,         \
-                                                                                 jclass clazz, jmethodID methodID, \
-                                                                                 ...)                              \
-{                                                                           \
-       java_handle_t *o;                                                       \
-       classinfo     *c;                                                       \
-       methodinfo    *m;                                                       \
-       va_list        ap;                                                      \
-       type           ret;                                                     \
-                                                                            \
-       o = (java_handle_t *) obj;                                              \
-       c = LLNI_classinfo_unwrap(clazz);                                       \
-       m = (methodinfo *) methodID;                                            \
-                                                                            \
-       va_start(ap, methodID);                                                 \
-       ret = _Jv_jni_Call##intern##Method(o, c->vftbl, m, ap);                 \
-       va_end(ap);                                                             \
-                                                                            \
-       return ret;                                                             \
-}
-
-JNI_CALL_NONVIRTUAL_METHOD(Boolean, jboolean, Int)
-JNI_CALL_NONVIRTUAL_METHOD(Byte,    jbyte,    Int)
-JNI_CALL_NONVIRTUAL_METHOD(Char,    jchar,    Int)
-JNI_CALL_NONVIRTUAL_METHOD(Short,   jshort,   Int)
-JNI_CALL_NONVIRTUAL_METHOD(Int,     jint,     Int)
-JNI_CALL_NONVIRTUAL_METHOD(Long,    jlong,    Long)
-JNI_CALL_NONVIRTUAL_METHOD(Float,   jfloat,   Float)
-JNI_CALL_NONVIRTUAL_METHOD(Double,  jdouble,  Double)
-
-
-#define JNI_CALL_NONVIRTUAL_METHOD_V(name, type, intern)                     \
-type _Jv_JNI_CallNonvirtual##name##MethodV(JNIEnv *env, jobject obj,         \
-                                                                                  jclass clazz, jmethodID methodID, \
-                                                                                  va_list args)                     \
-{                                                                            \
-       java_handle_t *o;                                                        \
-       classinfo     *c;                                                        \
-       methodinfo    *m;                                                        \
-       type           ret;                                                      \
-                                                                             \
-       o = (java_handle_t *) obj;                                               \
-       c = LLNI_classinfo_unwrap(clazz);                                        \
-       m = (methodinfo *) methodID;                                             \
-                                                                             \
-       ret = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);                       \
-                                                                             \
-       return ret;                                                              \
-}
-
-JNI_CALL_NONVIRTUAL_METHOD_V(Boolean, jboolean, Int)
-JNI_CALL_NONVIRTUAL_METHOD_V(Byte,    jbyte,    Int)
-JNI_CALL_NONVIRTUAL_METHOD_V(Char,    jchar,    Int)
-JNI_CALL_NONVIRTUAL_METHOD_V(Short,   jshort,   Int)
-JNI_CALL_NONVIRTUAL_METHOD_V(Int,     jint,     Int)
-JNI_CALL_NONVIRTUAL_METHOD_V(Long,    jlong,    Long)
-JNI_CALL_NONVIRTUAL_METHOD_V(Float,   jfloat,   Float)
-JNI_CALL_NONVIRTUAL_METHOD_V(Double,  jdouble,  Double)
-
-
-#define JNI_CALL_NONVIRTUAL_METHOD_A(name, type, intern)                     \
-type _Jv_JNI_CallNonvirtual##name##MethodA(JNIEnv *env, jobject obj,         \
-                                                                                  jclass clazz, jmethodID methodID, \
-                                                                                  const jvalue *args)               \
-{                                                                            \
-       log_text("JNI-Call: CallNonvirtual##name##MethodA: IMPLEMENT ME!");      \
-                                                                             \
-       return 0;                                                                \
-}
-
-JNI_CALL_NONVIRTUAL_METHOD_A(Boolean, jboolean, Int)
-JNI_CALL_NONVIRTUAL_METHOD_A(Byte,    jbyte,    Int)
-JNI_CALL_NONVIRTUAL_METHOD_A(Char,    jchar,    Int)
-JNI_CALL_NONVIRTUAL_METHOD_A(Short,   jshort,   Int)
-JNI_CALL_NONVIRTUAL_METHOD_A(Int,     jint,     Int)
-JNI_CALL_NONVIRTUAL_METHOD_A(Long,    jlong,    Long)
-JNI_CALL_NONVIRTUAL_METHOD_A(Float,   jfloat,   Float)
-JNI_CALL_NONVIRTUAL_METHOD_A(Double,  jdouble,  Double)
-
-jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj,
-                                                                                  jclass clazz, jmethodID methodID,
-                                                                                  ...)
-{
-       java_handle_t *o;
-       classinfo     *c;
-       methodinfo    *m;
-       java_handle_t *r;
-       va_list        ap;
-
-       o = (java_handle_t *) obj;
-       c = LLNI_classinfo_unwrap(clazz);
-       m = (methodinfo *) methodID;
-
-       va_start(ap, methodID);
-       r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap);
-       va_end(ap);
-
-       return jni_NewLocalRef(env, (jobject) r);
-}
-
-
-jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj,
-                                                                                       jclass clazz, jmethodID methodID,
-                                                                                       va_list args)
-{
-       java_handle_t *o;
-       classinfo     *c;
-       methodinfo    *m;
-       java_handle_t *r;
-
-       o = (java_handle_t *) obj;
-       c = LLNI_classinfo_unwrap(clazz);
-       m = (methodinfo *) methodID;
-
-       r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args);
-
-       return jni_NewLocalRef(env, (jobject) r);
-}
-
-
-jobject _Jv_JNI_CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj,
-                                                                                       jclass clazz, jmethodID methodID,
-                                                                                       const jvalue *args)
-{
-       log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!");
-
-       return jni_NewLocalRef(env, NULL);
-}
-
-
-void _Jv_JNI_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz,
-                                                                         jmethodID methodID, ...)
-{
-       java_handle_t *o;
-       classinfo     *c;
-       methodinfo    *m;
-       va_list        ap;
-
-       o = (java_handle_t *) obj;
-       c = LLNI_classinfo_unwrap(clazz);
-       m = (methodinfo *) methodID;
-
-       va_start(ap, methodID);
-       _Jv_jni_CallVoidMethod(o, c->vftbl, m, ap);
-       va_end(ap);
-}
-
-
-void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz,
-                                                                          jmethodID methodID, va_list args)
-{
-       java_handle_t *o;
-       classinfo     *c;
-       methodinfo    *m;
-
-       o = (java_handle_t *) obj;
-       c = LLNI_classinfo_unwrap(clazz);
-       m = (methodinfo *) methodID;
-
-       _Jv_jni_CallVoidMethod(o, c->vftbl, m, args);
-}
-
-
-void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                                                          jmethodID methodID, const jvalue * args)
-{      
-       java_handle_t *o;
-       classinfo     *c;
-       methodinfo    *m;
-
-       o = (java_handle_t *) obj;
-       c = LLNI_classinfo_unwrap(clazz);
-       m = (methodinfo *) methodID;
-
-       _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args);
-}
-
-
-/* Accessing Fields of Objects ************************************************/
-
-/* GetFieldID ******************************************************************
-
-   Returns the field ID for an instance (nonstatic) field of a
-   class. The field is specified by its name and signature. The
-   Get<type>Field and Set<type>Field families of accessor functions
-   use field IDs to retrieve object fields.
-
-*******************************************************************************/
-
-jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name,
-                                                       const char *sig)
-{
-       classinfo *c;
-       fieldinfo *f;
-       utf       *uname;
-       utf       *udesc;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(clazz);
-
-       /* XXX NPE check? */
-
-       uname = utf_new_char((char *) name);
-       udesc = utf_new_char((char *) sig);
-
-       f = class_findfield(c, uname, udesc); 
-       
-       if (f == NULL)
-               exceptions_throw_nosuchfielderror(c, uname);  
-
-       return (jfieldID) f;
-}
-
-
-/* Get<type>Field Routines *****************************************************
-
-   This family of accessor routines returns the value of an instance
-   (nonstatic) field of an object. The field to access is specified by
-   a field ID obtained by calling GetFieldID().
-
-*******************************************************************************/
-
-#define GET_FIELD(o,type,f) \
-    *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset)))
-
-#define JNI_GET_FIELD(name, type, intern)                                 \
-type _Jv_JNI_Get##name##Field(JNIEnv *env, jobject obj, jfieldID fieldID) \
-{                                                                         \
-       intern ret;                                                           \
-                                                                          \
-       TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "Field(env=%p, obj=%p, fieldId=%p)", env, obj, fieldID)); \
-                                                                          \
-       LLNI_CRITICAL_START;                                                  \
-                                                                          \
-       ret = GET_FIELD(LLNI_DIRECT((java_handle_t *) obj), intern, fieldID); \
-                                                                          \
-       LLNI_CRITICAL_END;                                                    \
-                                                                          \
-       return (type) ret;                                                    \
-}
-
-JNI_GET_FIELD(Boolean, jboolean, s4)
-JNI_GET_FIELD(Byte,    jbyte,    s4)
-JNI_GET_FIELD(Char,    jchar,    s4)
-JNI_GET_FIELD(Short,   jshort,   s4)
-JNI_GET_FIELD(Int,     jint,     s4)
-JNI_GET_FIELD(Long,    jlong,    s8)
-JNI_GET_FIELD(Float,   jfloat,   float)
-JNI_GET_FIELD(Double,  jdouble,  double)
-
-
-jobject _Jv_JNI_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)
-{
-       java_handle_t *o;
-
-       TRACEJNICALLS(("_Jv_JNI_GetObjectField(env=%p, obj=%p, fieldId=%p)", env, obj, fieldID));
-
-       LLNI_CRITICAL_START;
-
-       o = LLNI_WRAP(GET_FIELD(LLNI_DIRECT((java_handle_t *) obj), java_object_t*, fieldID));
-
-       LLNI_CRITICAL_END;
-
-       return jni_NewLocalRef(env, (jobject) o);
-}
-
-
-/* Set<type>Field Routines *****************************************************
-
-   This family of accessor routines sets the value of an instance
-   (nonstatic) field of an object. The field to access is specified by
-   a field ID obtained by calling GetFieldID().
-
-*******************************************************************************/
-
-#define SET_FIELD(o,type,f,value) \
-    *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset))) = (type) (value)
-
-#define JNI_SET_FIELD(name, type, intern)                                  \
-void _Jv_JNI_Set##name##Field(JNIEnv *env, jobject obj, jfieldID fieldID,  \
-                                                         type value)                                  \
-{                                                                          \
-       TRACEJNICALLS(("_Jv_JNI_Set" STR(name) "Field(env=%p, obj=%p, fieldId=%p, value=%p)", env, obj, fieldID, value)); \
-                                                                           \
-       LLNI_CRITICAL_START;                                                   \
-                                                                           \
-       SET_FIELD(LLNI_DIRECT((java_handle_t *) obj), intern, fieldID, value); \
-                                                                              \
-       LLNI_CRITICAL_START;                                                   \
-}
-
-JNI_SET_FIELD(Boolean, jboolean, s4)
-JNI_SET_FIELD(Byte,    jbyte,    s4)
-JNI_SET_FIELD(Char,    jchar,    s4)
-JNI_SET_FIELD(Short,   jshort,   s4)
-JNI_SET_FIELD(Int,     jint,     s4)
-JNI_SET_FIELD(Long,    jlong,    s8)
-JNI_SET_FIELD(Float,   jfloat,   float)
-JNI_SET_FIELD(Double,  jdouble,  double)
-
-
-void _Jv_JNI_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID,
-                                                       jobject value)
-{
-       TRACEJNICALLS(("_Jv_JNI_SetObjectField(env=%p, obj=%p, fieldId=%p, value=%p)", env, obj, fieldID, value));
-
-       LLNI_CRITICAL_START;
-
-       SET_FIELD(obj, java_handle_t*, fieldID, LLNI_UNWRAP((java_handle_t*) value));
-
-       LLNI_CRITICAL_END;
-}
-
-
-/* Calling Static Methods *****************************************************/
-
-/* GetStaticMethodID ***********************************************************
-
-   Returns the method ID for a static method of a class. The method is
-   specified by its name and signature.
-
-   GetStaticMethodID() causes an uninitialized class to be
-   initialized.
-
-*******************************************************************************/
-
-jmethodID _Jv_JNI_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name,
-                                                                       const char *sig)
-{
-       classinfo  *c;
-       utf        *uname;
-       utf        *udesc;
-       methodinfo *m;
-
-       TRACEJNICALLS(("_Jv_JNI_GetStaticMethodID(env=%p, clazz=%p, name=%s, sig=%s)", env, clazz, name, sig));
-
-       c = LLNI_classinfo_unwrap(clazz);
-
-       if (c == NULL)
-               return NULL;
-
-       if (!(c->state & CLASS_INITIALIZED))
-               if (!initialize_class(c))
-                       return NULL;
-
-       /* try to get the static method of the class */
-
-       uname = utf_new_char((char *) name);
-       udesc = utf_new_char((char *) sig);
-
-       m = class_resolvemethod(c, uname, udesc);
-
-       if ((m == NULL) || !(m->flags & ACC_STATIC)) {
-               exceptions_throw_nosuchmethoderror(c, uname, udesc);
-
-               return NULL;
-       }
-
-       return (jmethodID) m;
-}
-
-
-#define JNI_CALL_STATIC_METHOD(name, type, intern)               \
-type _Jv_JNI_CallStatic##name##Method(JNIEnv *env, jclass clazz, \
-                                                                         jmethodID methodID, ...)   \
-{                                                                \
-       methodinfo *m;                                               \
-       va_list     ap;                                              \
-       type        res;                                             \
-                                                                 \
-       m = (methodinfo *) methodID;                                 \
-                                                                 \
-       va_start(ap, methodID);                                      \
-       res = _Jv_jni_Call##intern##Method(NULL, NULL, m, ap);       \
-       va_end(ap);                                                  \
-                                                                 \
-       return res;                                                  \
-}
-
-JNI_CALL_STATIC_METHOD(Boolean, jboolean, Int)
-JNI_CALL_STATIC_METHOD(Byte,    jbyte,    Int)
-JNI_CALL_STATIC_METHOD(Char,    jchar,    Int)
-JNI_CALL_STATIC_METHOD(Short,   jshort,   Int)
-JNI_CALL_STATIC_METHOD(Int,     jint,     Int)
-JNI_CALL_STATIC_METHOD(Long,    jlong,    Long)
-JNI_CALL_STATIC_METHOD(Float,   jfloat,   Float)
-JNI_CALL_STATIC_METHOD(Double,  jdouble,  Double)
-
-
-#define JNI_CALL_STATIC_METHOD_V(name, type, intern)                     \
-type _Jv_JNI_CallStatic##name##MethodV(JNIEnv *env, jclass clazz,        \
-                                                                          jmethodID methodID, va_list args) \
-{                                                                        \
-       methodinfo *m;                                                       \
-       type        res;                                                     \
-                                                                         \
-       m = (methodinfo *) methodID;                                         \
-                                                                         \
-       res = _Jv_jni_Call##intern##Method(NULL, NULL, m, args);             \
-                                                                         \
-       return res;                                                          \
-}
-
-JNI_CALL_STATIC_METHOD_V(Boolean, jboolean, Int)
-JNI_CALL_STATIC_METHOD_V(Byte,    jbyte,    Int)
-JNI_CALL_STATIC_METHOD_V(Char,    jchar,    Int)
-JNI_CALL_STATIC_METHOD_V(Short,   jshort,   Int)
-JNI_CALL_STATIC_METHOD_V(Int,     jint,     Int)
-JNI_CALL_STATIC_METHOD_V(Long,    jlong,    Long)
-JNI_CALL_STATIC_METHOD_V(Float,   jfloat,   Float)
-JNI_CALL_STATIC_METHOD_V(Double,  jdouble,  Double)
-
-
-#define JNI_CALL_STATIC_METHOD_A(name, type, intern)                           \
-type _Jv_JNI_CallStatic##name##MethodA(JNIEnv *env, jclass clazz,              \
-                                                                          jmethodID methodID, const jvalue *args) \
-{                                                                              \
-       methodinfo *m;                                                             \
-       type        res;                                                           \
-                                                                               \
-       m = (methodinfo *) methodID;                                               \
-                                                                               \
-       res = _Jv_jni_Call##intern##MethodA(NULL, NULL, m, args);                  \
-                                                                               \
-       return res;                                                                \
-}
-
-JNI_CALL_STATIC_METHOD_A(Boolean, jboolean, Int)
-JNI_CALL_STATIC_METHOD_A(Byte,    jbyte,    Int)
-JNI_CALL_STATIC_METHOD_A(Char,    jchar,    Int)
-JNI_CALL_STATIC_METHOD_A(Short,   jshort,   Int)
-JNI_CALL_STATIC_METHOD_A(Int,     jint,     Int)
-JNI_CALL_STATIC_METHOD_A(Long,    jlong,    Long)
-JNI_CALL_STATIC_METHOD_A(Float,   jfloat,   Float)
-JNI_CALL_STATIC_METHOD_A(Double,  jdouble,  Double)
-
-
-jobject _Jv_JNI_CallStaticObjectMethod(JNIEnv *env, jclass clazz,
-                                                                          jmethodID methodID, ...)
-{
-       methodinfo    *m;
-       java_handle_t *o;
-       va_list        ap;
-
-       TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethod(env=%p, clazz=%p, methodID=%p, ...)", env, clazz, methodID));
-
-       m = (methodinfo *) methodID;
-
-       va_start(ap, methodID);
-       o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap);
-       va_end(ap);
-
-       return jni_NewLocalRef(env, (jobject) o);
-}
-
-
-jobject _Jv_JNI_CallStaticObjectMethodV(JNIEnv *env, jclass clazz,
-                                                                               jmethodID methodID, va_list args)
-{
-       methodinfo    *m;
-       java_handle_t *o;
-
-       TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethodV(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args));
-
-       m = (methodinfo *) methodID;
-
-       o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args);
-
-       return jni_NewLocalRef(env, (jobject) o);
-}
-
-
-jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz,
-                                                                               jmethodID methodID, const jvalue *args)
-{
-       methodinfo    *m;
-       java_handle_t *o;
-
-       TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethodA(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args));
-
-       m = (methodinfo *) methodID;
-
-       o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args);
-
-       return jni_NewLocalRef(env, (jobject) o);
-}
-
-
-void _Jv_JNI_CallStaticVoidMethod(JNIEnv *env, jclass clazz,
-                                                                 jmethodID methodID, ...)
-{
-       methodinfo *m;
-       va_list     ap;
-
-       TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethod(env=%p, clazz=%p, methodID=%p, ...)", env, clazz, methodID));
-
-       m = (methodinfo *) methodID;
-
-       va_start(ap, methodID);
-       _Jv_jni_CallVoidMethod(NULL, NULL, m, ap);
-       va_end(ap);
-}
-
-
-void _Jv_JNI_CallStaticVoidMethodV(JNIEnv *env, jclass clazz,
-                                                                  jmethodID methodID, va_list args)
-{
-       methodinfo *m;
-
-       TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethodV(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args));
-
-       m = (methodinfo *) methodID;
-
-       _Jv_jni_CallVoidMethod(NULL, NULL, m, args);
-}
-
-
-void _Jv_JNI_CallStaticVoidMethodA(JNIEnv *env, jclass clazz,
-                                                                  jmethodID methodID, const jvalue * args)
-{
-       methodinfo *m;
-
-       TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethodA(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args));
-
-       m = (methodinfo *) methodID;
-
-       _Jv_jni_CallVoidMethodA(NULL, NULL, m, args);
-}
-
-
-/* Accessing Static Fields ****************************************************/
-
-/* GetStaticFieldID ************************************************************
-
-   Returns the field ID for a static field of a class. The field is
-   specified by its name and signature. The GetStatic<type>Field and
-   SetStatic<type>Field families of accessor functions use field IDs
-   to retrieve static fields.
-
-*******************************************************************************/
-
-jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name,
-                                                                 const char *sig)
-{
-       classinfo *c;
-       fieldinfo *f;
-       utf       *uname;
-       utf       *usig;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(clazz);
-
-       uname = utf_new_char((char *) name);
-       usig  = utf_new_char((char *) sig);
-
-       f = class_findfield(c, uname, usig);
-       
-       if (f == NULL)
-               exceptions_throw_nosuchfielderror(c, uname);
-
-       return (jfieldID) f;
-}
-
-
-/* GetStatic<type>Field ********************************************************
-
-   This family of accessor routines returns the value of a static
-   field of an object.
-
-*******************************************************************************/
-
-#define JNI_GET_STATIC_FIELD(name, type, field)                \
-type _Jv_JNI_GetStatic##name##Field(JNIEnv *env, jclass clazz, \
-                                                                       jfieldID fieldID)          \
-{                                                              \
-       classinfo *c;                                              \
-       fieldinfo *f;                                              \
-                                                               \
-       STATISTICS(jniinvokation());                               \
-                                                               \
-       c = LLNI_classinfo_unwrap(clazz);                          \
-       f = (fieldinfo *) fieldID;                                 \
-                                                               \
-       if (!(c->state & CLASS_INITIALIZED))                       \
-               if (!initialize_class(c))                              \
-                       return 0;                                          \
-                                                               \
-       return f->value->field;                                    \
-}
-
-JNI_GET_STATIC_FIELD(Boolean, jboolean, i)
-JNI_GET_STATIC_FIELD(Byte,    jbyte,    i)
-JNI_GET_STATIC_FIELD(Char,    jchar,    i)
-JNI_GET_STATIC_FIELD(Short,   jshort,   i)
-JNI_GET_STATIC_FIELD(Int,     jint,     i)
-JNI_GET_STATIC_FIELD(Long,    jlong,    l)
-JNI_GET_STATIC_FIELD(Float,   jfloat,   f)
-JNI_GET_STATIC_FIELD(Double,  jdouble,  d)
-
-
-jobject _Jv_JNI_GetStaticObjectField(JNIEnv *env, jclass clazz,
-                                                                        jfieldID fieldID)
-{
-       classinfo     *c;
-       fieldinfo     *f;
-       java_handle_t *h;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(clazz);
-       f = (fieldinfo *) fieldID;
-
-       if (!(c->state & CLASS_INITIALIZED))
-               if (!initialize_class(c))
-                       return NULL;
-
-       h = LLNI_WRAP(f->value->a);
-
-       return jni_NewLocalRef(env, (jobject) h);
-}
-
-
-/*  SetStatic<type>Field *******************************************************
-
-       This family of accessor routines sets the value of a static field
-       of an object.
-
-*******************************************************************************/
-
-#define JNI_SET_STATIC_FIELD(name, type, field)                \
-void _Jv_JNI_SetStatic##name##Field(JNIEnv *env, jclass clazz, \
-                                                                       jfieldID fieldID,          \
-                                                                       type value)                \
-{                                                              \
-       classinfo *c;                                              \
-       fieldinfo *f;                                              \
-                                                               \
-       STATISTICS(jniinvokation());                               \
-                                                               \
-       c = LLNI_classinfo_unwrap(clazz);                          \
-       f = (fieldinfo *) fieldID;                                 \
-                                                               \
-       if (!(c->state & CLASS_INITIALIZED))                       \
-               if (!initialize_class(c))                              \
-                       return;                                            \
-                                                               \
-       f->value->field = value;                                   \
-}
-
-JNI_SET_STATIC_FIELD(Boolean, jboolean, i)
-JNI_SET_STATIC_FIELD(Byte,    jbyte,    i)
-JNI_SET_STATIC_FIELD(Char,    jchar,    i)
-JNI_SET_STATIC_FIELD(Short,   jshort,   i)
-JNI_SET_STATIC_FIELD(Int,     jint,     i)
-JNI_SET_STATIC_FIELD(Long,    jlong,    l)
-JNI_SET_STATIC_FIELD(Float,   jfloat,   f)
-JNI_SET_STATIC_FIELD(Double,  jdouble,  d)
-
-
-void _Jv_JNI_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID,
-                                                                 jobject value)
-{
-       classinfo *c;
-       fieldinfo *f;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(clazz);
-       f = (fieldinfo *) fieldID;
-
-       if (!(c->state & CLASS_INITIALIZED))
-               if (!initialize_class(c))
-                       return;
-
-       f->value->a = LLNI_UNWRAP((java_handle_t *) value);
-}
-
-
-/* String Operations **********************************************************/
-
-/* NewString *******************************************************************
-
-   Create new java.lang.String object from an array of Unicode
-   characters.
-
-*******************************************************************************/
-
-jstring _Jv_JNI_NewString(JNIEnv *env, const jchar *buf, jsize len)
-{
-       java_lang_String        *s;
-       java_handle_chararray_t *a;
-       u4                       i;
-
-       STATISTICS(jniinvokation());
-       
-       s = (java_lang_String *) builtin_new(class_java_lang_String);
-       a = builtin_newarray_char(len);
-
-       /* javastring or characterarray could not be created */
-       if ((a == NULL) || (s == NULL))
-               return NULL;
-
-       /* copy text */
-       for (i = 0; i < len; i++)
-               LLNI_array_direct(a, i) = buf[i];
-
-       LLNI_field_set_ref(s, value , a);
-       LLNI_field_set_val(s, offset, 0);
-       LLNI_field_set_val(s, count , len);
-
-       return (jstring) jni_NewLocalRef(env, (jobject) s);
-}
-
-
-static jchar emptyStringJ[]={0,0};
-
-/* GetStringLength *************************************************************
-
-   Returns the length (the count of Unicode characters) of a Java
-   string.
-
-*******************************************************************************/
-
-jsize _Jv_JNI_GetStringLength(JNIEnv *env, jstring str)
-{
-       java_lang_String *s;
-       jsize             len;
-
-       TRACEJNICALLS(("_Jv_JNI_GetStringLength(env=%p, str=%p)", env, str));
-
-       s = (java_lang_String *) str;
-
-       LLNI_field_get_val(s, count, len);
-
-       return len;
-}
-
-
-/********************  convertes javastring to u2-array ****************************/
-       
-u2 *javastring_tou2(jstring so) 
-{
-       java_lang_String        *s;
-       java_handle_chararray_t *a;
-       u2                      *stringbuffer;
-       u4                       i;
-       int32_t                  count;
-       int32_t                  offset;
-
-       STATISTICS(jniinvokation());
-       
-       s = (java_lang_String *) so;
-
-       if (!s)
-               return NULL;
-
-       LLNI_field_get_ref(s, value, a);
-
-       if (!a)
-               return NULL;
-
-       LLNI_field_get_val(s, count, count);
-       LLNI_field_get_val(s, offset, offset);
-
-       /* allocate memory */
-
-       stringbuffer = MNEW(u2, count + 1);
-
-       /* copy text */
-
-       for (i = 0; i < count; i++)
-               stringbuffer[i] = LLNI_array_direct(a, offset + i);
-       
-       /* terminate string */
-
-       stringbuffer[i] = '\0';
-
-       return stringbuffer;
-}
-
-
-/* GetStringChars **************************************************************
-
-   Returns a pointer to the array of Unicode characters of the
-   string. This pointer is valid until ReleaseStringChars() is called.
-
-*******************************************************************************/
-
-const jchar *_Jv_JNI_GetStringChars(JNIEnv *env, jstring str, jboolean *isCopy)
-{      
-       jchar *jc;
-
-       STATISTICS(jniinvokation());
-
-       jc = javastring_tou2(str);
-
-       if (jc) {
-               if (isCopy)
-                       *isCopy = JNI_TRUE;
-
-               return jc;
-       }
-
-       if (isCopy)
-               *isCopy = JNI_TRUE;
-
-       return emptyStringJ;
-}
-
-
-/* ReleaseStringChars **********************************************************
-
-   Informs the VM that the native code no longer needs access to
-   chars. The chars argument is a pointer obtained from string using
-   GetStringChars().
-
-*******************************************************************************/
-
-void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)
-{
-       java_lang_String *s;
-
-       STATISTICS(jniinvokation());
-
-       if (chars == emptyStringJ)
-               return;
-
-       s = (java_lang_String *) str;
-
-       MFREE(((jchar *) chars), jchar, LLNI_field_direct(s, count) + 1);
-}
-
-
-/* NewStringUTF ****************************************************************
-
-   Constructs a new java.lang.String object from an array of UTF-8
-   characters.
-
-*******************************************************************************/
-
-jstring _Jv_JNI_NewStringUTF(JNIEnv *env, const char *bytes)
-{
-       java_lang_String *s;
-
-       TRACEJNICALLS(("_Jv_JNI_NewStringUTF(env=%p, bytes=%s)", env, bytes));
-
-       s = (java_lang_String *) javastring_safe_new_from_utf8(bytes);
-
-    return (jstring) jni_NewLocalRef(env, (jobject) s);
-}
-
-
-/****************** returns the utf8 length in bytes of a string *******************/
-
-jsize _Jv_JNI_GetStringUTFLength(JNIEnv *env, jstring string)
-{   
-       java_lang_String *s;
-       s4                length;
-
-       TRACEJNICALLS(("_Jv_JNI_GetStringUTFLength(env=%p, string=%p)", env, string));
-
-       s = (java_lang_String *) string;
-
-       length = u2_utflength(LLNI_field_direct(s, value)->data, LLNI_field_direct(s, count));
-
-       return length;
-}
-
-
-/* GetStringUTFChars ***********************************************************
-
-   Returns a pointer to an array of UTF-8 characters of the
-   string. This array is valid until it is released by
-   ReleaseStringUTFChars().
-
-*******************************************************************************/
-
-const char *_Jv_JNI_GetStringUTFChars(JNIEnv *env, jstring string,
-                                                                         jboolean *isCopy)
-{
-       utf *u;
-
-       STATISTICS(jniinvokation());
-
-       if (string == NULL)
-               return "";
-
-       if (isCopy)
-               *isCopy = JNI_TRUE;
-       
-       u = javastring_toutf((java_handle_t *) string, false);
-
-       if (u != NULL)
-               return u->text;
-
-       return "";
-}
-
-
-/* ReleaseStringUTFChars *******************************************************
-
-   Informs the VM that the native code no longer needs access to
-   utf. The utf argument is a pointer derived from string using
-   GetStringUTFChars().
-
-*******************************************************************************/
-
-void _Jv_JNI_ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *utf)
-{
-       STATISTICS(jniinvokation());
-
-    /* XXX we don't release utf chars right now, perhaps that should be done 
-          later. Since there is always one reference the garbage collector will
-          never get them */
-}
-
-
-/* Array Operations ***********************************************************/
-
-/* GetArrayLength **************************************************************
-
-   Returns the number of elements in the array.
-
-*******************************************************************************/
-
-jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array)
-{
-       java_handle_t *a;
-       jsize          size;
-
-       TRACEJNICALLS(("_Jv_JNI_GetArrayLength(env=%p, array=%p)", env, array));
-
-       a = (java_handle_t *) array;
-
-       size = LLNI_array_size(a);
-
-       return size;
-}
-
-
-/* NewObjectArray **************************************************************
-
-   Constructs a new array holding objects in class elementClass. All
-   elements are initially set to initialElement.
-
-*******************************************************************************/
-
-jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length,
-                                                                       jclass elementClass, jobject initialElement)
-{
-       classinfo                 *c;
-       java_handle_t             *o;
-       java_handle_objectarray_t *oa;
-       s4                         i;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(elementClass);
-       o = (java_handle_t *) initialElement;
-
-       if (length < 0) {
-               exceptions_throw_negativearraysizeexception();
-               return NULL;
-       }
-
-    oa = builtin_anewarray(length, c);
-
-       if (oa == NULL)
-               return NULL;
-
-       /* set all elements to initialElement */
-
-       for (i = 0; i < length; i++)
-               array_objectarray_element_set(oa, i, o);
-
-       return (jobjectArray) jni_NewLocalRef(env, (jobject) oa);
-}
-
-
-jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array,
-                                                                         jsize index)
-{
-       java_handle_objectarray_t *oa;
-       java_handle_t             *o;
-
-       STATISTICS(jniinvokation());
-
-       oa = (java_handle_objectarray_t *) array;
-
-       if (index >= LLNI_array_size(oa)) {
-               exceptions_throw_arrayindexoutofboundsexception();
-               return NULL;
-       }
-
-       o = array_objectarray_element_get(oa, index);
-
-       return jni_NewLocalRef(env, (jobject) o);
-}
-
-
-void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array,
-                                                                  jsize index, jobject val)
-{
-       java_handle_objectarray_t *oa;
-       java_handle_t             *o;
-
-       STATISTICS(jniinvokation());
-
-       oa = (java_handle_objectarray_t *) array;
-       o  = (java_handle_t *) val;
-
-       if (index >= LLNI_array_size(oa)) {
-               exceptions_throw_arrayindexoutofboundsexception();
-               return;
-       }
-
-       /* check if the class of value is a subclass of the element class
-          of the array */
-
-       if (!builtin_canstore(oa, o))
-               return;
-
-       array_objectarray_element_set(oa, index, o);
-}
-
-
-#define JNI_NEW_ARRAY(name, type, intern)                \
-type _Jv_JNI_New##name##Array(JNIEnv *env, jsize len)    \
-{                                                        \
-       java_handle_##intern##array_t *a;                    \
-                                                         \
-       STATISTICS(jniinvokation());                         \
-                                                         \
-       if (len < 0) {                                       \
-               exceptions_throw_negativearraysizeexception();   \
-               return NULL;                                     \
-       }                                                    \
-                                                         \
-       a = builtin_newarray_##intern(len);                  \
-                                                         \
-       return (type) jni_NewLocalRef(env, (jobject) a); \
-}
-
-JNI_NEW_ARRAY(Boolean, jbooleanArray, boolean)
-JNI_NEW_ARRAY(Byte,    jbyteArray,    byte)
-JNI_NEW_ARRAY(Char,    jcharArray,    char)
-JNI_NEW_ARRAY(Short,   jshortArray,   short)
-JNI_NEW_ARRAY(Int,     jintArray,     int)
-JNI_NEW_ARRAY(Long,    jlongArray,    long)
-JNI_NEW_ARRAY(Float,   jfloatArray,   float)
-JNI_NEW_ARRAY(Double,  jdoubleArray,  double)
-
-
-/* Get<PrimitiveType>ArrayElements *********************************************
-
-   A family of functions that returns the body of the primitive array.
-
-*******************************************************************************/
-
-#define JNI_GET_ARRAY_ELEMENTS(name, type, intern)                     \
-type *_Jv_JNI_Get##name##ArrayElements(JNIEnv *env, type##Array array, \
-                                                                                jboolean *isCopy)             \
-{                                                                      \
-       java_handle_##intern##array_t *a;                                  \
-                                                                       \
-       TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "ArrayElements(env=%p, array=%p, isCopy=%d)", env, array, isCopy)); \
-                                                                       \
-       a = (java_handle_##intern##array_t *) array;                       \
-                                                                       \
-       if (isCopy)                                                        \
-               *isCopy = JNI_FALSE;                                           \
-                                                                       \
-       return (type *) LLNI_array_data(a);                                \
-}
-
-JNI_GET_ARRAY_ELEMENTS(Boolean, jboolean, boolean)
-JNI_GET_ARRAY_ELEMENTS(Byte,    jbyte,    byte)
-JNI_GET_ARRAY_ELEMENTS(Char,    jchar,    char)
-JNI_GET_ARRAY_ELEMENTS(Short,   jshort,   short)
-JNI_GET_ARRAY_ELEMENTS(Int,     jint,     int)
-JNI_GET_ARRAY_ELEMENTS(Long,    jlong,    long)
-JNI_GET_ARRAY_ELEMENTS(Float,   jfloat,   float)
-JNI_GET_ARRAY_ELEMENTS(Double,  jdouble,  double)
-
-
-/* Release<PrimitiveType>ArrayElements *****************************************
-
-   A family of functions that informs the VM that the native code no
-   longer needs access to elems. The elems argument is a pointer
-   derived from array using the corresponding
-   Get<PrimitiveType>ArrayElements() function. If necessary, this
-   function copies back all changes made to elems to the original
-   array.
-
-*******************************************************************************/
-
-#define JNI_RELEASE_ARRAY_ELEMENTS(name, type, intern, intern2)            \
-void _Jv_JNI_Release##name##ArrayElements(JNIEnv *env, type##Array array,  \
-                                                                                 type *elems, jint mode)          \
-{                                                                          \
-       java_handle_##intern##array_t *a;                                      \
-                                                                           \
-       STATISTICS(jniinvokation());                                           \
-                                                                           \
-       a = (java_handle_##intern##array_t *) array;                           \
-                                                                           \
-       if (elems != (type *) LLNI_array_data(a)) {                            \
-               switch (mode) {                                                    \
-               case JNI_COMMIT:                                                   \
-                       MCOPY(LLNI_array_data(a), elems, intern2, LLNI_array_size(a)); \
-                       break;                                                         \
-               case 0:                                                            \
-                       MCOPY(LLNI_array_data(a), elems, intern2, LLNI_array_size(a)); \
-                       /* XXX TWISTI how should it be freed? */                       \
-                       break;                                                         \
-               case JNI_ABORT:                                                    \
-                       /* XXX TWISTI how should it be freed? */                       \
-                       break;                                                         \
-               }                                                                  \
-       }                                                                      \
-}
-
-JNI_RELEASE_ARRAY_ELEMENTS(Boolean, jboolean, boolean, u1)
-JNI_RELEASE_ARRAY_ELEMENTS(Byte,    jbyte,    byte,    s1)
-JNI_RELEASE_ARRAY_ELEMENTS(Char,    jchar,    char,    u2)
-JNI_RELEASE_ARRAY_ELEMENTS(Short,   jshort,   short,   s2)
-JNI_RELEASE_ARRAY_ELEMENTS(Int,     jint,     int,     s4)
-JNI_RELEASE_ARRAY_ELEMENTS(Long,    jlong,    long,    s8)
-JNI_RELEASE_ARRAY_ELEMENTS(Float,   jfloat,   float,   float)
-JNI_RELEASE_ARRAY_ELEMENTS(Double,  jdouble,  double,  double)
-
-
-/*  Get<PrimitiveType>ArrayRegion **********************************************
-
-       A family of functions that copies a region of a primitive array
-       into a buffer.
-
-*******************************************************************************/
-
-#define JNI_GET_ARRAY_REGION(name, type, intern, intern2)               \
-void _Jv_JNI_Get##name##ArrayRegion(JNIEnv *env, type##Array array,     \
-                                                                       jsize start, jsize len, type *buf)  \
-{                                                                       \
-       java_handle_##intern##array_t *a;                                   \
-                                                                        \
-       TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "ArrayRegion(env=%p, array=%p, start=%d, len=%d, buf=%p)", env, array, start, len, buf)); \
-                                                                        \
-       a = (java_handle_##intern##array_t *) array;                        \
-                                                                        \
-       if ((start < 0) || (len < 0) || (start + len > LLNI_array_size(a))) \
-               exceptions_throw_arrayindexoutofboundsexception();              \
-       else                                                                \
-               MCOPY(buf, &LLNI_array_direct(a, start), intern2, len);         \
-}
-
-JNI_GET_ARRAY_REGION(Boolean, jboolean, boolean, u1)
-JNI_GET_ARRAY_REGION(Byte,    jbyte,    byte,    s1)
-JNI_GET_ARRAY_REGION(Char,    jchar,    char,    u2)
-JNI_GET_ARRAY_REGION(Short,   jshort,   short,   s2)
-JNI_GET_ARRAY_REGION(Int,     jint,     int,     s4)
-JNI_GET_ARRAY_REGION(Long,    jlong,    long,    s8)
-JNI_GET_ARRAY_REGION(Float,   jfloat,   float,   float)
-JNI_GET_ARRAY_REGION(Double,  jdouble,  double,  double)
-
-
-/*  Set<PrimitiveType>ArrayRegion **********************************************
-
-       A family of functions that copies back a region of a primitive
-       array from a buffer.
-
-*******************************************************************************/
-
-#define JNI_SET_ARRAY_REGION(name, type, intern, intern2)                    \
-void _Jv_JNI_Set##name##ArrayRegion(JNIEnv *env, type##Array array,          \
-                                                                       jsize start, jsize len, const type *buf) \
-{                                                                            \
-       java_handle_##intern##array_t *a;                                        \
-                                                                             \
-       STATISTICS(jniinvokation());                                             \
-                                                                             \
-       a = (java_handle_##intern##array_t *) array;                             \
-                                                                             \
-       if ((start < 0) || (len < 0) || (start + len > LLNI_array_size(a)))      \
-               exceptions_throw_arrayindexoutofboundsexception();                   \
-       else                                                                     \
-               MCOPY(&LLNI_array_direct(a, start), buf, intern2, len);              \
-}
-
-JNI_SET_ARRAY_REGION(Boolean, jboolean, boolean, u1)
-JNI_SET_ARRAY_REGION(Byte,    jbyte,    byte,    s1)
-JNI_SET_ARRAY_REGION(Char,    jchar,    char,    u2)
-JNI_SET_ARRAY_REGION(Short,   jshort,   short,   s2)
-JNI_SET_ARRAY_REGION(Int,     jint,     int,     s4)
-JNI_SET_ARRAY_REGION(Long,    jlong,    long,    s8)
-JNI_SET_ARRAY_REGION(Float,   jfloat,   float,   float)
-JNI_SET_ARRAY_REGION(Double,  jdouble,  double,  double)
-
-
-/* Registering Native Methods *************************************************/
-
-/* RegisterNatives *************************************************************
-
-   Registers native methods with the class specified by the clazz
-   argument. The methods parameter specifies an array of
-   JNINativeMethod structures that contain the names, signatures, and
-   function pointers of the native methods. The nMethods parameter
-   specifies the number of native methods in the array.
-
-*******************************************************************************/
-
-jint _Jv_JNI_RegisterNatives(JNIEnv *env, jclass clazz,
-                                                        const JNINativeMethod *methods, jint nMethods)
-{
-       classinfo *c;
-
-       STATISTICS(jniinvokation());
-
-       c = LLNI_classinfo_unwrap(clazz);
-
-       /* XXX: if implemented this needs a call to jvmti_NativeMethodBind
-       if (jvmti) jvmti_NativeMethodBind(method, address,  new_address_ptr);
-       */
-
-       native_method_register(c->name, methods, nMethods);
-
-    return 0;
-}
-
-
-/* UnregisterNatives ***********************************************************
-
-   Unregisters native methods of a class. The class goes back to the
-   state before it was linked or registered with its native method
-   functions.
-
-   This function should not be used in normal native code. Instead, it
-   provides special programs a way to reload and relink native
-   libraries.
-
-*******************************************************************************/
-
-jint _Jv_JNI_UnregisterNatives(JNIEnv *env, jclass clazz)
-{
-       STATISTICS(jniinvokation());
-
-       /* XXX TWISTI hmm, maybe we should not support that (like kaffe) */
-
-    log_text("JNI-Call: UnregisterNatives: IMPLEMENT ME!!!");
-
-    return 0;
-}
-
-
-/* Monitor Operations *********************************************************/
-
-/* MonitorEnter ****************************************************************
-
-   Enters the monitor associated with the underlying Java object
-   referred to by obj.
-
-*******************************************************************************/
-
-jint _Jv_JNI_MonitorEnter(JNIEnv *env, jobject obj)
-{
-       STATISTICS(jniinvokation());
-
-       if (obj == NULL) {
-               exceptions_throw_nullpointerexception();
-               return JNI_ERR;
-       }
-
-       LOCK_MONITOR_ENTER(obj);
-
-       return JNI_OK;
-}
-
-
-/* MonitorExit *****************************************************************
-
-   The current thread must be the owner of the monitor associated with
-   the underlying Java object referred to by obj. The thread
-   decrements the counter indicating the number of times it has
-   entered this monitor. If the value of the counter becomes zero, the
-   current thread releases the monitor.
-
-*******************************************************************************/
-
-jint _Jv_JNI_MonitorExit(JNIEnv *env, jobject obj)
-{
-       STATISTICS(jniinvokation());
-
-       if (obj == NULL) {
-               exceptions_throw_nullpointerexception();
-               return JNI_ERR;
-       }
-
-       LOCK_MONITOR_EXIT(obj);
-
-       return JNI_OK;
-}
-
-
-/* JavaVM Interface ***********************************************************/
-
-/* GetJavaVM *******************************************************************
-
-   Returns the Java VM interface (used in the Invocation API)
-   associated with the current thread. The result is placed at the
-   location pointed to by the second argument, vm.
-
-*******************************************************************************/
-
-jint _Jv_JNI_GetJavaVM(JNIEnv *env, JavaVM **vm)
-{
-       STATISTICS(jniinvokation());
-
-    *vm = (JavaVM *) _Jv_jvm;
-
-       return 0;
-}
-
-
-/* GetStringRegion *************************************************************
-
-   Copies len number of Unicode characters beginning at offset start
-   to the given buffer buf.
-
-   Throws StringIndexOutOfBoundsException on index overflow.
-
-*******************************************************************************/
-
-void _Jv_JNI_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len,
-                                                        jchar *buf)
-{
-       java_lang_String        *s;
-       java_handle_chararray_t *ca;
-
-       STATISTICS(jniinvokation());
-
-       s  = (java_lang_String *) str;
-       LLNI_field_get_ref(s, value, ca);
-
-       if ((start < 0) || (len < 0) || (start > LLNI_field_direct(s, count)) ||
-               (start + len > LLNI_field_direct(s, count))) {
-               exceptions_throw_stringindexoutofboundsexception();
-               return;
-       }
-
-       MCOPY(buf, &LLNI_array_direct(ca, start), u2, len);
-}
-
-
-/* GetStringUTFRegion **********************************************************
-
-    Translates len number of Unicode characters beginning at offset
-    start into UTF-8 format and place the result in the given buffer
-    buf.
-
-    Throws StringIndexOutOfBoundsException on index overflow. 
-
-*******************************************************************************/
-
-void _Jv_JNI_GetStringUTFRegion(JNIEnv* env, jstring str, jsize start,
-                                                               jsize len, char *buf)
-{
-       java_lang_String        *s;
-       java_handle_chararray_t *ca;
-       s4                       i;
-       int32_t                  count;
-       int32_t                  offset;
-
-       TRACEJNICALLS(("_Jv_JNI_GetStringUTFRegion(env=%p, str=%p, start=%d, len=%d, buf=%p)", env, str, start, len, buf));
-
-       s  = (java_lang_String *) str;
-       LLNI_field_get_ref(s, value, ca);
-       LLNI_field_get_val(s, count, count);
-       LLNI_field_get_val(s, offset, offset);
-
-       if ((start < 0) || (len < 0) || (start > count) || (start + len > count)) {
-               exceptions_throw_stringindexoutofboundsexception();
-               return;
-       }
-
-       for (i = 0; i < len; i++)
-               buf[i] = LLNI_array_direct(ca, offset + start + i);
-
-       buf[i] = '\0';
-}
-
-
-/* GetPrimitiveArrayCritical ***************************************************
-
-   Obtain a direct pointer to array elements.
-
-   ATTENTION: Critical section keeps open when this function returns!
-   See ReleasePrimitiveArrayCritical.
-
-*******************************************************************************/
-
-void* jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy)
-{
-       java_handle_t*   h;
-       java_array_t*    a;
-       arraydescriptor* ad;
-       void*            data;
-
-       TRACEJNICALLS(("jni_GetPrimitiveArrayCritical(env=%p, array=%p, isCopy=%d)", env, array, isCopy));
-
-       if (isCopy != NULL) {
-               *isCopy = JNI_FALSE;
-       }
-
-       LLNI_CRITICAL_START;
-
-       h  = (java_handle_t*) array;
-       a  = (java_array_t*) LLNI_UNWRAP(h);
-       ad = a->objheader.vftbl->arraydesc;
-
-       /* Sanity check. */
-
-       assert(ad != NULL);
-
-       data = (void*) (((intptr_t) a) + ad->dataoffset);
-
-       return data;
-}
-
-
-/* ReleasePrimitiveArrayCritical ***********************************************
-
-   No specific documentation.
-
-   ATTENTION: This function closes the critical section opened in
-   GetPrimitiveArrayCritical!
-
-*******************************************************************************/
-
-void jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode)
-{
-       TRACEJNICALLS(("jni_ReleasePrimitiveArrayCritical(env=%p, array=%p, carray=%p, mode=%d)", env, array, carray, mode));
-
-       LLNI_CRITICAL_END;
-}
-
-
-/* GetStringCritical ***********************************************************
-
-   The semantics of these two functions are similar to the existing
-   Get/ReleaseStringChars functions.
-
-*******************************************************************************/
-
-const jchar *_Jv_JNI_GetStringCritical(JNIEnv *env, jstring string,
-                                                                          jboolean *isCopy)
-{
-       STATISTICS(jniinvokation());
-
-       return _Jv_JNI_GetStringChars(env, string, isCopy);
-}
-
-
-void _Jv_JNI_ReleaseStringCritical(JNIEnv *env, jstring string,
-                                                                  const jchar *cstring)
-{
-       STATISTICS(jniinvokation());
-
-       _Jv_JNI_ReleaseStringChars(env, string, cstring);
-}
-
-
-jweak _Jv_JNI_NewWeakGlobalRef(JNIEnv* env, jobject obj)
-{
-       TRACEJNICALLS(("_Jv_JNI_NewWeakGlobalRef(env=%p, obj=%p): IMPLEMENT ME!", env, obj));
-
-       return obj;
-}
-
-
-void _Jv_JNI_DeleteWeakGlobalRef(JNIEnv* env, jweak ref)
-{
-       TRACEJNICALLS(("_Jv_JNI_DeleteWeakGlobalRef(env=%p, ref=%p): IMPLEMENT ME", env, ref));
-}
-
-
-/* NewGlobalRef ****************************************************************
-
-   Creates a new global reference to the object referred to by the obj
-   argument.
-
-*******************************************************************************/
-    
-jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj)
-{
-       hashtable_global_ref_entry *gre;
-       u4   key;                           /* hashkey                            */
-       u4   slot;                          /* slot in hashtable                  */
-       java_handle_t *o;
-
-       STATISTICS(jniinvokation());
-
-       o = (java_handle_t *) obj;
-
-       LOCK_MONITOR_ENTER(hashtable_global_ref->header);
-
-       LLNI_CRITICAL_START;
-
-       /* normally addresses are aligned to 4, 8 or 16 bytes */
-
-       key  = heap_hashcode(LLNI_DIRECT(o)) >> 4; /* align to 16-byte boundaries */
-       slot = key & (hashtable_global_ref->size - 1);
-       gre  = hashtable_global_ref->ptr[slot];
-       
-       /* search external hash chain for the entry */
-
-       while (gre) {
-               if (gre->o == LLNI_DIRECT(o)) {
-                       /* global object found, increment the reference */
-
-                       gre->refs++;
-
-                       break;
-               }
-
-               gre = gre->hashlink;                /* next element in external chain */
-       }
-
-       LLNI_CRITICAL_END;
-
-       /* global ref not found, create a new one */
-
-       if (gre == NULL) {
-               gre = NEW(hashtable_global_ref_entry);
-
-#if defined(ENABLE_GC_CACAO)
-               /* register global ref with the GC */
-
-               gc_reference_register(&(gre->o), GC_REFTYPE_JNI_GLOBALREF);
-#endif
-
-               LLNI_CRITICAL_START;
-
-               gre->o    = LLNI_DIRECT(o);
-               gre->refs = 1;
-
-               LLNI_CRITICAL_END;
-
-               /* insert entry into hashtable */
-
-               gre->hashlink = hashtable_global_ref->ptr[slot];
-
-               hashtable_global_ref->ptr[slot] = gre;
-
-               /* update number of hashtable-entries */
-
-               hashtable_global_ref->entries++;
-       }
-
-       LOCK_MONITOR_EXIT(hashtable_global_ref->header);
-
-#if defined(ENABLE_HANDLES)
-       return gre;
-#else
-       return obj;
-#endif
-}
-
-
-/* DeleteGlobalRef *************************************************************
-
-   Deletes the global reference pointed to by globalRef.
-
-*******************************************************************************/
-
-void _Jv_JNI_DeleteGlobalRef(JNIEnv* env, jobject globalRef)
-{
-       hashtable_global_ref_entry *gre;
-       hashtable_global_ref_entry *prevgre;
-       u4   key;                           /* hashkey                            */
-       u4   slot;                          /* slot in hashtable                  */
-       java_handle_t              *o;
-
-       STATISTICS(jniinvokation());
-
-       o = (java_handle_t *) globalRef;
-
-       LOCK_MONITOR_ENTER(hashtable_global_ref->header);
-
-       LLNI_CRITICAL_START;
-
-       /* normally addresses are aligned to 4, 8 or 16 bytes */
-
-       key  = heap_hashcode(LLNI_DIRECT(o)) >> 4; /* align to 16-byte boundaries */
-       slot = key & (hashtable_global_ref->size - 1);
-       gre  = hashtable_global_ref->ptr[slot];
-
-       /* initialize prevgre */
-
-       prevgre = NULL;
-
-       /* search external hash chain for the entry */
-
-       while (gre) {
-               if (gre->o == LLNI_DIRECT(o)) {
-                       /* global object found, decrement the reference count */
-
-                       gre->refs--;
-
-                       /* if reference count is 0, remove the entry */
-
-                       if (gre->refs == 0) {
-                               /* special handling if it's the first in the chain */
-
-                               if (prevgre == NULL)
-                                       hashtable_global_ref->ptr[slot] = gre->hashlink;
-                               else
-                                       prevgre->hashlink = gre->hashlink;
-
-#if defined(ENABLE_GC_CACAO)
-                               /* unregister global ref with the GC */
-
-                               gc_reference_unregister(&(gre->o));
-#endif
-
-                               FREE(gre, hashtable_global_ref_entry);
-                       }
-
-                       LLNI_CRITICAL_END;
-
-                       LOCK_MONITOR_EXIT(hashtable_global_ref->header);
-
-                       return;
-               }
-
-               prevgre = gre;                    /* save current pointer for removal */
-               gre     = gre->hashlink;            /* next element in external chain */
-       }
-
-       log_println("JNI-DeleteGlobalRef: global reference not found");
-
-       LLNI_CRITICAL_END;
-
-       LOCK_MONITOR_EXIT(hashtable_global_ref->header);
-}
-
-
-/* ExceptionCheck **************************************************************
-
-   Returns JNI_TRUE when there is a pending exception; otherwise,
-   returns JNI_FALSE.
-
-*******************************************************************************/
-
-jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env)
-{
-       java_handle_t *o;
-
-       STATISTICS(jniinvokation());
-
-       o = exceptions_get_exception();
-
-       return (o != NULL) ? JNI_TRUE : JNI_FALSE;
-}
-
-
-/* New JNI 1.4 functions ******************************************************/
-
-/* NewDirectByteBuffer *********************************************************
-
-   Allocates and returns a direct java.nio.ByteBuffer referring to the
-   block of memory starting at the memory address address and
-   extending capacity bytes.
-
-*******************************************************************************/
-
-jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
-{
-#if defined(ENABLE_JAVASE)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_handle_t           *nbuf;
-
-# if SIZEOF_VOID_P == 8
-       gnu_classpath_Pointer64 *paddress;
-# else
-       gnu_classpath_Pointer32 *paddress;
-# endif
-
-       TRACEJNICALLS(("_Jv_JNI_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld", env, address, capacity));
-
-       /* alocate a gnu.classpath.Pointer{32,64} object */
-
-# if SIZEOF_VOID_P == 8
-       if (!(paddress = (gnu_classpath_Pointer64 *)
-                 builtin_new(class_gnu_classpath_Pointer64)))
-# else
-       if (!(paddress = (gnu_classpath_Pointer32 *)
-                 builtin_new(class_gnu_classpath_Pointer32)))
-# endif
-               return NULL;
-
-       /* fill gnu.classpath.Pointer{32,64} with address */
-
-       LLNI_field_set_val(paddress, data, (ptrint) address);
-
-       /* create a java.nio.DirectByteBufferImpl$ReadWrite object */
-
-       nbuf = (*env)->NewObject(env, class_java_nio_DirectByteBufferImpl_ReadWrite,
-                                                        (jmethodID) dbbirw_init, NULL, paddress,
-                                                        (jint) capacity, (jint) capacity, (jint) 0);
-
-       /* add local reference and return the value */
-
-       return jni_NewLocalRef(env, nbuf);
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       jobject o;
-       int64_t addr;
-       int32_t cap;
-
-       TRACEJNICALLS(("_Jv_JNI_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld", env, address, capacity));
-
-       /* Be paranoid about address sign-extension. */
-
-       addr = (int64_t) ((uintptr_t) address);
-       cap  = (int32_t) capacity;
-
-       o = (*env)->NewObject(env, (jclass) class_java_nio_DirectByteBuffer,
-                                                 (jmethodID) dbb_init, addr, cap);
-
-       /* Add local reference and return the value. */
-
-       return jni_NewLocalRef(env, o);
-
-# else
-#  error unknown classpath configuration
-# endif
-
-#else
-       vm_abort("_Jv_JNI_NewDirectByteBuffer: not implemented in this configuration");
-
-       /* keep compiler happy */
-
-       return NULL;
-#endif
-}
-
-
-/* GetDirectBufferAddress ******************************************************
-
-   Fetches and returns the starting address of the memory region
-   referenced by the given direct java.nio.Buffer.
-
-*******************************************************************************/
-
-void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
-{
-#if defined(ENABLE_JAVASE)
-       java_handle_t                 *h;
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       java_nio_DirectByteBufferImpl *nbuf;
-       gnu_classpath_Pointer         *po;
-#  if SIZEOF_VOID_P == 8
-       gnu_classpath_Pointer64       *paddress;
-       int64_t                        address;
-#  else
-       gnu_classpath_Pointer32       *paddress;
-       int32_t                        address;
-#  endif
-       void                          *p;
-
-       TRACEJNICALLS(("_Jv_JNI_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
-
-       /* Prevent compiler warning. */
-
-       h = (java_handle_t *) buf;
-
-       if ((h != NULL) && !builtin_instanceof(h, class_java_nio_Buffer))
-               return NULL;
-
-       nbuf = (java_nio_DirectByteBufferImpl *) buf;
-
-       LLNI_field_get_ref(nbuf, address, po);
-
-#  if SIZEOF_VOID_P == 8
-       paddress = (gnu_classpath_Pointer64 *) po;
-#  else
-       paddress = (gnu_classpath_Pointer32 *) po;
-#  endif
-
-       if (paddress == NULL)
-               return NULL;
-
-       LLNI_field_get_val(paddress, data, address);
-
-       p = (void *) (intptr_t) address;
-
-       return p;
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       java_nio_Buffer *o;
-       int64_t          address;
-       void            *p;
-
-       TRACEJNICALLS(("_Jv_JNI_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
-
-       /* Prevent compiler warning. */
-
-       h = (java_handle_t *) buf;
-
-       if ((h != NULL) && !builtin_instanceof(h, class_sun_nio_ch_DirectBuffer))
-               return NULL;
-
-       o = (java_nio_Buffer *) buf;
-
-       LLNI_field_get_val(o, address, address);
-
-       p = (void *) (intptr_t) address;
-
-       return p;
-
-# else
-#  error unknown classpath configuration
-# endif
-
-#else
-
-       vm_abort("_Jv_JNI_GetDirectBufferAddress: not implemented in this configuration");
-
-       /* keep compiler happy */
-
-       return NULL;
-
-#endif
-}
-
-
-/* GetDirectBufferCapacity *****************************************************
-
-   Fetches and returns the capacity in bytes of the memory region
-   referenced by the given direct java.nio.Buffer.
-
-*******************************************************************************/
-
-jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
-{
-#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_handle_t   *o;
-       java_nio_Buffer *nbuf;
-       jlong            capacity;
-
-       STATISTICS(jniinvokation());
-
-       o = (java_handle_t *) buf;
-
-       if (!builtin_instanceof(o, class_java_nio_DirectByteBufferImpl))
-               return -1;
-
-       nbuf = (java_nio_Buffer *) o;
-
-       LLNI_field_get_val(nbuf, cap, capacity);
-
-       return capacity;
-#else
-       vm_abort("_Jv_JNI_GetDirectBufferCapacity: not implemented in this configuration");
-
-       /* keep compiler happy */
-
-       return 0;
-#endif
-}
-
-
-/* GetObjectRefType ************************************************************
-
-   Returns the type of the object referred to by the obj argument. The
-   argument obj can either be a local, global or weak global
-   reference.
-
-*******************************************************************************/
-
-jobjectRefType jni_GetObjectRefType(JNIEnv *env, jobject obj)
-{
-       log_println("jni_GetObjectRefType: IMPLEMENT ME!");
-
-       return -1;
-}
-
-
-/* DestroyJavaVM ***************************************************************
-
-   Unloads a Java VM and reclaims its resources. Only the main thread
-   can unload the VM. The system waits until the main thread is only
-   remaining user thread before it destroys the VM.
-
-*******************************************************************************/
-
-jint _Jv_JNI_DestroyJavaVM(JavaVM *vm)
-{
-       int status;
-
-       TRACEJNICALLS(("_Jv_JNI_DestroyJavaVM(vm=%p)", vm));
-
-       if (vm_created == false)
-               return JNI_ERR;
-
-    status = vm_destroy(vm);
-
-       return status;
-}
-
-
-/* AttachCurrentThread *********************************************************
-
-   Attaches the current thread to a Java VM. Returns a JNI interface
-   pointer in the JNIEnv argument.
-
-   Trying to attach a thread that is already attached is a no-op.
-
-   A native thread cannot be attached simultaneously to two Java VMs.
-
-   When a thread is attached to the VM, the context class loader is
-   the bootstrap loader.
-
-*******************************************************************************/
-
-static int jni_attach_current_thread(void **p_env, void *thr_args, bool isdaemon)
-{
-#if defined(ENABLE_THREADS)
-       JavaVMAttachArgs *vm_aargs;
-       bool              result;
-
-    /* If the current thread has already been attached, this operation
-          is a no-op. */
-
-       result = thread_current_is_attached();
-
-       if (result == true) {
-               *p_env = _Jv_env;
-
-               return JNI_OK;
-       }
-
-       vm_aargs = (JavaVMAttachArgs *) thr_args;
-
-       if (vm_aargs != NULL) {
-               if ((vm_aargs->version != JNI_VERSION_1_2) &&
-                       (vm_aargs->version != JNI_VERSION_1_4))
-                       return JNI_EVERSION;
-       }
-
-       if (!threads_attach_current_thread(vm_aargs, false))
-               return JNI_ERR;
-
-       if (!localref_table_init())
-               return JNI_ERR;
-#endif
-
-       *p_env = _Jv_env;
-
-       return JNI_OK;
-}
-
-
-jint _Jv_JNI_AttachCurrentThread(JavaVM *vm, void **p_env, void *thr_args)
-{
-       int result;
-
-       TRACEJNICALLS(("_Jv_JNI_AttachCurrentThread(vm=%p, p_env=%p, thr_args=%p)", vm, p_env, thr_args));
-
-       if (vm_created == false)
-               return JNI_ERR;
-
-       result = jni_attach_current_thread(p_env, thr_args, false);
-
-       return result;
-}
-
-
-/* DetachCurrentThread *********************************************************
-
-   Detaches the current thread from a Java VM. All Java monitors held
-   by this thread are released. All Java threads waiting for this
-   thread to die are notified.
-
-   In JDK 1.1, the main thread cannot be detached from the VM. It must
-   call DestroyJavaVM to unload the entire VM.
-
-   In the JDK, the main thread can be detached from the VM.
-
-   The main thread, which is the thread that created the Java VM,
-   cannot be detached from the VM. Instead, the main thread must call
-   JNI_DestroyJavaVM() to unload the entire VM.
-
-*******************************************************************************/
-
-jint _Jv_JNI_DetachCurrentThread(JavaVM *vm)
-{
-#if defined(ENABLE_THREADS)
-       threadobject *t;
-       bool          result;
-
-       TRACEJNICALLS(("_Jv_JNI_DetachCurrentThread(vm=%p)", vm));
-
-       t = thread_get_current();
-
-       /* Sanity check. */
-
-       assert(t != NULL);
-
-    /* If the given thread has already been detached, this operation
-          is a no-op. */
-
-       result = thread_is_attached(t);
-
-       if (result == false)
-               return true;
-
-       /* We need to pop all frames before we can destroy the table. */
-
-       localref_frame_pop_all();
-
-       if (!localref_table_destroy())
-               return JNI_ERR;
-
-       if (!threads_detach_thread(t))
-               return JNI_ERR;
-#endif
-
-       return JNI_OK;
-}
-
-
-/* GetEnv **********************************************************************
-
-   If the current thread is not attached to the VM, sets *env to NULL,
-   and returns JNI_EDETACHED. If the specified version is not
-   supported, sets *env to NULL, and returns JNI_EVERSION. Otherwise,
-   sets *env to the appropriate interface, and returns JNI_OK.
-
-*******************************************************************************/
-
-jint jni_GetEnv(JavaVM *vm, void **env, jint version)
-{
-       TRACEJNICALLS(("jni_GetEnv(vm=%p, env=%p, version=%d)", vm, env, version));
-
-       if (vm_created == false) {
-               *env = NULL;
-               return JNI_EDETACHED;
-       }
-
-#if defined(ENABLE_THREADS)
-       if (thread_get_current() == NULL) {
-               *env = NULL;
-
-               return JNI_EDETACHED;
-       }
-#endif
-
-       /* Check the JNI version. */
-
-       if (jni_version_check(version) == true) {
-               *env = _Jv_env;
-               return JNI_OK;
-       }
-
-#if defined(ENABLE_JVMTI)
-       if ((version & JVMTI_VERSION_MASK_INTERFACE_TYPE) 
-               == JVMTI_VERSION_INTERFACE_JVMTI) {
-
-               *env = (void *) jvmti_new_environment();
-
-               if (env != NULL)
-                       return JNI_OK;
-       }
-#endif
-       
-       *env = NULL;
-
-       return JNI_EVERSION;
-}
-
-
-/* AttachCurrentThreadAsDaemon *************************************************
-
-   Same semantics as AttachCurrentThread, but the newly-created
-   java.lang.Thread instance is a daemon.
-
-   If the thread has already been attached via either
-   AttachCurrentThread or AttachCurrentThreadAsDaemon, this routine
-   simply sets the value pointed to by penv to the JNIEnv of the
-   current thread. In this case neither AttachCurrentThread nor this
-   routine have any effect on the daemon status of the thread.
-
-*******************************************************************************/
-
-jint _Jv_JNI_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *args)
-{
-       int result;
-
-       TRACEJNICALLS(("_Jv_JNI_AttachCurrentThreadAsDaemon(vm=%p, penv=%p, args=%p)", vm, penv, args));
-
-       if (vm_created == false)
-               return JNI_ERR;
-
-       result = jni_attach_current_thread(penv, args, true);
-
-       return result;
-}
-
-
-/* JNI invocation table *******************************************************/
-
-const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface = {
-       NULL,
-       NULL,
-       NULL,
-
-       _Jv_JNI_DestroyJavaVM,
-       _Jv_JNI_AttachCurrentThread,
-       _Jv_JNI_DetachCurrentThread,
-       jni_GetEnv,
-       _Jv_JNI_AttachCurrentThreadAsDaemon
-};
-
-
-/* JNI function table *********************************************************/
-
-struct JNINativeInterface_ _Jv_JNINativeInterface = {
-       NULL,
-       NULL,
-       NULL,
-       NULL,    
-       _Jv_JNI_GetVersion,
-
-       _Jv_JNI_DefineClass,
-       jni_FindClass,
-       jni_FromReflectedMethod,
-       jni_FromReflectedField,
-       _Jv_JNI_ToReflectedMethod,
-       _Jv_JNI_GetSuperclass,
-       _Jv_JNI_IsAssignableFrom,
-       _Jv_JNI_ToReflectedField,
-
-       _Jv_JNI_Throw,
-       _Jv_JNI_ThrowNew,
-       _Jv_JNI_ExceptionOccurred,
-       jni_ExceptionDescribe,
-       jni_ExceptionClear,
-       _Jv_JNI_FatalError,
-       jni_PushLocalFrame,
-       jni_PopLocalFrame,
-
-       _Jv_JNI_NewGlobalRef,
-       _Jv_JNI_DeleteGlobalRef,
-       jni_DeleteLocalRef,
-       _Jv_JNI_IsSameObject,
-       jni_NewLocalRef,
-       jni_EnsureLocalCapacity,
-
-       _Jv_JNI_AllocObject,
-       _Jv_JNI_NewObject,
-       _Jv_JNI_NewObjectV,
-       _Jv_JNI_NewObjectA,
-
-       _Jv_JNI_GetObjectClass,
-       _Jv_JNI_IsInstanceOf,
-
-       _Jv_JNI_GetMethodID,
-
-       _Jv_JNI_CallObjectMethod,
-       _Jv_JNI_CallObjectMethodV,
-       _Jv_JNI_CallObjectMethodA,
-       _Jv_JNI_CallBooleanMethod,
-       _Jv_JNI_CallBooleanMethodV,
-       _Jv_JNI_CallBooleanMethodA,
-       _Jv_JNI_CallByteMethod,
-       _Jv_JNI_CallByteMethodV,
-       _Jv_JNI_CallByteMethodA,
-       _Jv_JNI_CallCharMethod,
-       _Jv_JNI_CallCharMethodV,
-       _Jv_JNI_CallCharMethodA,
-       _Jv_JNI_CallShortMethod,
-       _Jv_JNI_CallShortMethodV,
-       _Jv_JNI_CallShortMethodA,
-       _Jv_JNI_CallIntMethod,
-       _Jv_JNI_CallIntMethodV,
-       _Jv_JNI_CallIntMethodA,
-       _Jv_JNI_CallLongMethod,
-       _Jv_JNI_CallLongMethodV,
-       _Jv_JNI_CallLongMethodA,
-       _Jv_JNI_CallFloatMethod,
-       _Jv_JNI_CallFloatMethodV,
-       _Jv_JNI_CallFloatMethodA,
-       _Jv_JNI_CallDoubleMethod,
-       _Jv_JNI_CallDoubleMethodV,
-       _Jv_JNI_CallDoubleMethodA,
-       _Jv_JNI_CallVoidMethod,
-       _Jv_JNI_CallVoidMethodV,
-       _Jv_JNI_CallVoidMethodA,
-
-       _Jv_JNI_CallNonvirtualObjectMethod,
-       _Jv_JNI_CallNonvirtualObjectMethodV,
-       _Jv_JNI_CallNonvirtualObjectMethodA,
-       _Jv_JNI_CallNonvirtualBooleanMethod,
-       _Jv_JNI_CallNonvirtualBooleanMethodV,
-       _Jv_JNI_CallNonvirtualBooleanMethodA,
-       _Jv_JNI_CallNonvirtualByteMethod,
-       _Jv_JNI_CallNonvirtualByteMethodV,
-       _Jv_JNI_CallNonvirtualByteMethodA,
-       _Jv_JNI_CallNonvirtualCharMethod,
-       _Jv_JNI_CallNonvirtualCharMethodV,
-       _Jv_JNI_CallNonvirtualCharMethodA,
-       _Jv_JNI_CallNonvirtualShortMethod,
-       _Jv_JNI_CallNonvirtualShortMethodV,
-       _Jv_JNI_CallNonvirtualShortMethodA,
-       _Jv_JNI_CallNonvirtualIntMethod,
-       _Jv_JNI_CallNonvirtualIntMethodV,
-       _Jv_JNI_CallNonvirtualIntMethodA,
-       _Jv_JNI_CallNonvirtualLongMethod,
-       _Jv_JNI_CallNonvirtualLongMethodV,
-       _Jv_JNI_CallNonvirtualLongMethodA,
-       _Jv_JNI_CallNonvirtualFloatMethod,
-       _Jv_JNI_CallNonvirtualFloatMethodV,
-       _Jv_JNI_CallNonvirtualFloatMethodA,
-       _Jv_JNI_CallNonvirtualDoubleMethod,
-       _Jv_JNI_CallNonvirtualDoubleMethodV,
-       _Jv_JNI_CallNonvirtualDoubleMethodA,
-       _Jv_JNI_CallNonvirtualVoidMethod,
-       _Jv_JNI_CallNonvirtualVoidMethodV,
-       _Jv_JNI_CallNonvirtualVoidMethodA,
-
-       _Jv_JNI_GetFieldID,
-
-       _Jv_JNI_GetObjectField,
-       _Jv_JNI_GetBooleanField,
-       _Jv_JNI_GetByteField,
-       _Jv_JNI_GetCharField,
-       _Jv_JNI_GetShortField,
-       _Jv_JNI_GetIntField,
-       _Jv_JNI_GetLongField,
-       _Jv_JNI_GetFloatField,
-       _Jv_JNI_GetDoubleField,
-       _Jv_JNI_SetObjectField,
-       _Jv_JNI_SetBooleanField,
-       _Jv_JNI_SetByteField,
-       _Jv_JNI_SetCharField,
-       _Jv_JNI_SetShortField,
-       _Jv_JNI_SetIntField,
-       _Jv_JNI_SetLongField,
-       _Jv_JNI_SetFloatField,
-       _Jv_JNI_SetDoubleField,
-
-       _Jv_JNI_GetStaticMethodID,
-
-       _Jv_JNI_CallStaticObjectMethod,
-       _Jv_JNI_CallStaticObjectMethodV,
-       _Jv_JNI_CallStaticObjectMethodA,
-       _Jv_JNI_CallStaticBooleanMethod,
-       _Jv_JNI_CallStaticBooleanMethodV,
-       _Jv_JNI_CallStaticBooleanMethodA,
-       _Jv_JNI_CallStaticByteMethod,
-       _Jv_JNI_CallStaticByteMethodV,
-       _Jv_JNI_CallStaticByteMethodA,
-       _Jv_JNI_CallStaticCharMethod,
-       _Jv_JNI_CallStaticCharMethodV,
-       _Jv_JNI_CallStaticCharMethodA,
-       _Jv_JNI_CallStaticShortMethod,
-       _Jv_JNI_CallStaticShortMethodV,
-       _Jv_JNI_CallStaticShortMethodA,
-       _Jv_JNI_CallStaticIntMethod,
-       _Jv_JNI_CallStaticIntMethodV,
-       _Jv_JNI_CallStaticIntMethodA,
-       _Jv_JNI_CallStaticLongMethod,
-       _Jv_JNI_CallStaticLongMethodV,
-       _Jv_JNI_CallStaticLongMethodA,
-       _Jv_JNI_CallStaticFloatMethod,
-       _Jv_JNI_CallStaticFloatMethodV,
-       _Jv_JNI_CallStaticFloatMethodA,
-       _Jv_JNI_CallStaticDoubleMethod,
-       _Jv_JNI_CallStaticDoubleMethodV,
-       _Jv_JNI_CallStaticDoubleMethodA,
-       _Jv_JNI_CallStaticVoidMethod,
-       _Jv_JNI_CallStaticVoidMethodV,
-       _Jv_JNI_CallStaticVoidMethodA,
-
-       _Jv_JNI_GetStaticFieldID,
-
-       _Jv_JNI_GetStaticObjectField,
-       _Jv_JNI_GetStaticBooleanField,
-       _Jv_JNI_GetStaticByteField,
-       _Jv_JNI_GetStaticCharField,
-       _Jv_JNI_GetStaticShortField,
-       _Jv_JNI_GetStaticIntField,
-       _Jv_JNI_GetStaticLongField,
-       _Jv_JNI_GetStaticFloatField,
-       _Jv_JNI_GetStaticDoubleField,
-       _Jv_JNI_SetStaticObjectField,
-       _Jv_JNI_SetStaticBooleanField,
-       _Jv_JNI_SetStaticByteField,
-       _Jv_JNI_SetStaticCharField,
-       _Jv_JNI_SetStaticShortField,
-       _Jv_JNI_SetStaticIntField,
-       _Jv_JNI_SetStaticLongField,
-       _Jv_JNI_SetStaticFloatField,
-       _Jv_JNI_SetStaticDoubleField,
-
-       _Jv_JNI_NewString,
-       _Jv_JNI_GetStringLength,
-       _Jv_JNI_GetStringChars,
-       _Jv_JNI_ReleaseStringChars,
-
-       _Jv_JNI_NewStringUTF,
-       _Jv_JNI_GetStringUTFLength,
-       _Jv_JNI_GetStringUTFChars,
-       _Jv_JNI_ReleaseStringUTFChars,
-
-       _Jv_JNI_GetArrayLength,
-
-       _Jv_JNI_NewObjectArray,
-       _Jv_JNI_GetObjectArrayElement,
-       _Jv_JNI_SetObjectArrayElement,
-
-       _Jv_JNI_NewBooleanArray,
-       _Jv_JNI_NewByteArray,
-       _Jv_JNI_NewCharArray,
-       _Jv_JNI_NewShortArray,
-       _Jv_JNI_NewIntArray,
-       _Jv_JNI_NewLongArray,
-       _Jv_JNI_NewFloatArray,
-       _Jv_JNI_NewDoubleArray,
-
-       _Jv_JNI_GetBooleanArrayElements,
-       _Jv_JNI_GetByteArrayElements,
-       _Jv_JNI_GetCharArrayElements,
-       _Jv_JNI_GetShortArrayElements,
-       _Jv_JNI_GetIntArrayElements,
-       _Jv_JNI_GetLongArrayElements,
-       _Jv_JNI_GetFloatArrayElements,
-       _Jv_JNI_GetDoubleArrayElements,
-
-       _Jv_JNI_ReleaseBooleanArrayElements,
-       _Jv_JNI_ReleaseByteArrayElements,
-       _Jv_JNI_ReleaseCharArrayElements,
-       _Jv_JNI_ReleaseShortArrayElements,
-       _Jv_JNI_ReleaseIntArrayElements,
-       _Jv_JNI_ReleaseLongArrayElements,
-       _Jv_JNI_ReleaseFloatArrayElements,
-       _Jv_JNI_ReleaseDoubleArrayElements,
-
-       _Jv_JNI_GetBooleanArrayRegion,
-       _Jv_JNI_GetByteArrayRegion,
-       _Jv_JNI_GetCharArrayRegion,
-       _Jv_JNI_GetShortArrayRegion,
-       _Jv_JNI_GetIntArrayRegion,
-       _Jv_JNI_GetLongArrayRegion,
-       _Jv_JNI_GetFloatArrayRegion,
-       _Jv_JNI_GetDoubleArrayRegion,
-       _Jv_JNI_SetBooleanArrayRegion,
-       _Jv_JNI_SetByteArrayRegion,
-       _Jv_JNI_SetCharArrayRegion,
-       _Jv_JNI_SetShortArrayRegion,
-       _Jv_JNI_SetIntArrayRegion,
-       _Jv_JNI_SetLongArrayRegion,
-       _Jv_JNI_SetFloatArrayRegion,
-       _Jv_JNI_SetDoubleArrayRegion,
-
-       _Jv_JNI_RegisterNatives,
-       _Jv_JNI_UnregisterNatives,
-
-       _Jv_JNI_MonitorEnter,
-       _Jv_JNI_MonitorExit,
-
-       _Jv_JNI_GetJavaVM,
-
-       /* New JNI 1.2 functions. */
-
-       _Jv_JNI_GetStringRegion,
-       _Jv_JNI_GetStringUTFRegion,
-
-       jni_GetPrimitiveArrayCritical,
-       jni_ReleasePrimitiveArrayCritical,
-
-       _Jv_JNI_GetStringCritical,
-       _Jv_JNI_ReleaseStringCritical,
-
-       _Jv_JNI_NewWeakGlobalRef,
-       _Jv_JNI_DeleteWeakGlobalRef,
-
-       _Jv_JNI_ExceptionCheck,
-
-       /* New JNI 1.4 functions. */
-
-       _Jv_JNI_NewDirectByteBuffer,
-       _Jv_JNI_GetDirectBufferAddress,
-       _Jv_JNI_GetDirectBufferCapacity,
-
-       /* New JNI 1.6 functions. */
-
-       jni_GetObjectRefType
-};
-
-
-/* Invocation API Functions ***************************************************/
-
-/* JNI_GetDefaultJavaVMInitArgs ************************************************
-
-   Returns a default configuration for the Java VM.
-
-*******************************************************************************/
-
-jint JNI_GetDefaultJavaVMInitArgs(void *vm_args)
-{
-       JavaVMInitArgs *_vm_args;
-
-       _vm_args = (JavaVMInitArgs *) vm_args;
-
-       /* GNU classpath currently supports JNI 1.2 */
-
-       switch (_vm_args->version) {
-    case JNI_VERSION_1_1:
-               _vm_args->version = JNI_VERSION_1_1;
-               break;
-
-    case JNI_VERSION_1_2:
-    case JNI_VERSION_1_4:
-               _vm_args->ignoreUnrecognized = JNI_FALSE;
-               _vm_args->options = NULL;
-               _vm_args->nOptions = 0;
-               break;
-
-    default:
-               return -1;
-       }
-  
-       return 0;
-}
-
-
-/* JNI_GetCreatedJavaVMs *******************************************************
-
-   Returns all Java VMs that have been created. Pointers to VMs are written in
-   the buffer vmBuf in the order they are created. At most bufLen number of
-   entries will be written. The total number of created VMs is returned in
-   *nVMs.
-
-*******************************************************************************/
-
-jint JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs)
-{
-       TRACEJNICALLS(("JNI_GetCreatedJavaVMs(vmBuf=%p, jsize=%d, jsize=%p)", vmBuf, bufLen, nVMs));
-
-       if (bufLen <= 0)
-               return JNI_ERR;
-
-       /* We currently only support 1 VM running. */
-
-       vmBuf[0] = (JavaVM *) _Jv_jvm;
-       *nVMs    = 1;
-
-    return JNI_OK;
-}
-
-
-/* JNI_CreateJavaVM ************************************************************
-
-   Loads and initializes a Java VM. The current thread becomes the main thread.
-   Sets the env argument to the JNI interface pointer of the main thread.
-
-*******************************************************************************/
-
-jint JNI_CreateJavaVM(JavaVM **p_vm, void **p_env, void *vm_args)
-{
-       TRACEJNICALLS(("JNI_CreateJavaVM(p_vm=%p, p_env=%p, vm_args=%p)", p_vm, p_env, vm_args));
-
-       /* actually create the JVM */
-
-       if (!vm_createjvm(p_vm, p_env, vm_args))
-               return JNI_ERR;
-
-       return JNI_OK;
-}
-
-
-/*
- * 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/native/jni.cpp b/src/native/jni.cpp
new file mode 100644 (file)
index 0000000..674f3b8
--- /dev/null
@@ -0,0 +1,4206 @@
+/* src/native/jni.cpp - implementation of the Java Native Interface 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 <stdint.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "mm/gc.hpp"
+#include "mm/memory.h"
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JVMTI)
+# include "native/jvmti/cacaodbg.h"
+#endif
+
+#include "threads/lock.hpp"
+#include "threads/mutex.hpp"
+#include "threads/thread.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/array.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/initialize.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/resolve.hpp"
+#include "vm/statistics.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/stacktrace.hpp"
+
+
+/* debug **********************************************************************/
+
+#if !defined(NDEBUG)
+
+# define TRACEJNICALLS(x)                                              \
+    do {                                                                               \
+        if (opt_TraceJNICalls) {                               \
+            log_println x;                                             \
+        }                                                                              \
+    } while (0)
+
+# define TRACEJNICALLSENTER(x)                                                                 \
+    do {                                                                                                               \
+        if (opt_TraceJNICalls) {                                                               \
+                       log_start();                                                                            \
+            log_print x;                                                                               \
+        }                                                                                                              \
+    } while (0)
+
+# define TRACEJNICALLSEXIT(x)                                                                  \
+    do {                                                                                                               \
+        if (opt_TraceJNICalls) {                                                               \
+                       log_print x;                                                                            \
+                       log_finish();                                                                           \
+        }                                                                                                              \
+    } while (0)
+
+#else
+
+# define TRACEJNICALLS(x)
+# define TRACEJNICALLSENTER(x)
+# define TRACEJNICALLSEXIT(x)
+
+#endif
+
+
+/* global variables ***********************************************************/
+
+/* global reference table *****************************************************/
+
+/* hashsize must be power of 2 */
+
+#define HASHTABLE_GLOBAL_REF_SIZE    64 /* initial size of globalref-hash     */
+
+static hashtable *hashtable_global_ref; /* hashtable for globalrefs           */
+
+
+/* direct buffer stuff ********************************************************/
+
+#if defined(ENABLE_JAVASE)
+static classinfo *class_java_nio_Buffer;
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+static classinfo *class_java_nio_DirectByteBufferImpl;
+static classinfo *class_java_nio_DirectByteBufferImpl_ReadWrite;
+
+#  if SIZEOF_VOID_P == 8
+static classinfo *class_gnu_classpath_Pointer64;
+#  else
+static classinfo *class_gnu_classpath_Pointer32;
+#  endif
+
+static methodinfo *dbbirw_init;
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+static classinfo *class_sun_nio_ch_DirectBuffer;
+static classinfo *class_java_nio_DirectByteBuffer;
+
+static methodinfo *dbb_init;
+
+# endif
+#endif
+
+
+/* some forward declarations **************************************************/
+
+extern "C" {
+jobject jni_NewLocalRef(JNIEnv *env, jobject ref);
+}
+
+
+/* jni_init ********************************************************************
+
+   Initialize the JNI subsystem.
+
+*******************************************************************************/
+
+bool jni_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("jni_init");
+
+       /* create global ref hashtable */
+
+       hashtable_global_ref = NEW(hashtable);
+
+       hashtable_create(hashtable_global_ref, HASHTABLE_GLOBAL_REF_SIZE);
+
+
+#if defined(ENABLE_JAVASE)
+       /* Direct buffer stuff. */
+
+       if (!(class_java_nio_Buffer =
+                 load_class_bootstrap(utf_new_char("java/nio/Buffer"))) ||
+               !link_class(class_java_nio_Buffer))
+               return false;
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       if (!(class_java_nio_DirectByteBufferImpl =
+                 load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl"))) ||
+               !link_class(class_java_nio_DirectByteBufferImpl))
+               return false;
+
+       if (!(class_java_nio_DirectByteBufferImpl_ReadWrite =
+                 load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl$ReadWrite"))) ||
+               !link_class(class_java_nio_DirectByteBufferImpl_ReadWrite))
+               return false;
+
+       if (!(dbbirw_init =
+               class_resolvemethod(class_java_nio_DirectByteBufferImpl_ReadWrite,
+                                                       utf_init,
+                                                       utf_new_char("(Ljava/lang/Object;Lgnu/classpath/Pointer;III)V"))))
+               return false;
+
+#  if SIZEOF_VOID_P == 8
+       if (!(class_gnu_classpath_Pointer64 =
+                 load_class_bootstrap(utf_new_char("gnu/classpath/Pointer64"))) ||
+               !link_class(class_gnu_classpath_Pointer64))
+               return false;
+#  else
+       if (!(class_gnu_classpath_Pointer32 =
+                 load_class_bootstrap(utf_new_char("gnu/classpath/Pointer32"))) ||
+               !link_class(class_gnu_classpath_Pointer32))
+               return false;
+#  endif
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       if (!(class_sun_nio_ch_DirectBuffer =
+                 load_class_bootstrap(utf_new_char("sun/nio/ch/DirectBuffer"))))
+               vm_abort("jni_init: loading sun/nio/ch/DirectBuffer failed");
+
+       if (!link_class(class_sun_nio_ch_DirectBuffer))
+               vm_abort("jni_init: linking sun/nio/ch/DirectBuffer failed");
+
+       if (!(class_java_nio_DirectByteBuffer =
+                 load_class_bootstrap(utf_new_char("java/nio/DirectByteBuffer"))))
+               vm_abort("jni_init: loading java/nio/DirectByteBuffer failed");
+
+       if (!link_class(class_java_nio_DirectByteBuffer))
+               vm_abort("jni_init: linking java/nio/DirectByteBuffer failed");
+
+       if (!(dbb_init =
+                 class_resolvemethod(class_java_nio_DirectByteBuffer,
+                                                         utf_init,
+                                                         utf_new_char("(JI)V"))))
+               vm_abort("jni_init: resolving java/nio/DirectByteBuffer.init(JI)V failed");
+
+# endif
+
+#endif /* defined(ENABLE_JAVASE) */
+
+       return true;
+}
+
+
+/* jni_version_check ***********************************************************
+
+   Check if the given JNI version is supported.
+
+   IN:
+       version....JNI version to check
+
+   RETURN VALUE:
+       true.......supported
+       false......not supported
+
+*******************************************************************************/
+
+bool jni_version_check(int version)
+{
+       switch (version) {
+       case JNI_VERSION_1_1:
+       case JNI_VERSION_1_2:
+       case JNI_VERSION_1_4:
+       case JNI_VERSION_1_6:
+               return true;
+       default:
+               return false;
+       }
+}
+
+
+/* _Jv_jni_CallObjectMethod ****************************************************
+
+   Internal function to call Java Object methods.
+
+*******************************************************************************/
+
+static java_handle_t *_Jv_jni_CallObjectMethod(java_handle_t *o,
+                                                                                          vftbl_t *vftbl,
+                                                                                          methodinfo *m, va_list ap)
+{
+       methodinfo    *resm;
+       java_handle_t *ro;
+
+       STATISTICS(jniinvokation());
+
+       if (m == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+
+       } else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       STATISTICS(jnicallXmethodnvokation());
+
+       ro = vm_call_method_valist(resm, o, ap);
+
+       return ro;
+}
+
+
+/* _Jv_jni_CallObjectMethodA ***************************************************
+
+   Internal function to call Java Object methods.
+
+*******************************************************************************/
+
+static java_handle_t *_Jv_jni_CallObjectMethodA(java_handle_t *o,
+                                                                                               vftbl_t *vftbl,
+                                                                                               methodinfo *m,
+                                                                                               const jvalue *args)
+{
+       methodinfo    *resm;
+       java_handle_t *ro;
+
+       STATISTICS(jniinvokation());
+
+       if (m == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+
+       } else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       STATISTICS(jnicallXmethodnvokation());
+
+       ro = vm_call_method_jvalue(resm, o, args);
+
+       return ro;
+}
+
+
+/* _Jv_jni_CallIntMethod *******************************************************
+
+   Internal function to call Java integer class methods (boolean,
+   byte, char, short, int).
+
+*******************************************************************************/
+
+static jint _Jv_jni_CallIntMethod(java_handle_t *o, vftbl_t *vftbl,
+                                                                 methodinfo *m, va_list ap)
+{
+       methodinfo *resm;
+       jint        i;
+
+       STATISTICS(jniinvokation());
+
+       if (m == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+        
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+
+       } else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       STATISTICS(jnicallXmethodnvokation());
+
+       i = vm_call_method_int_valist(resm, o, ap);
+
+       return i;
+}
+
+
+/* _Jv_jni_CallIntMethodA ******************************************************
+
+   Internal function to call Java integer class methods (boolean,
+   byte, char, short, int).
+
+*******************************************************************************/
+
+static jint _Jv_jni_CallIntMethodA(java_handle_t *o, vftbl_t *vftbl,
+                                                                  methodinfo *m, const jvalue *args)
+{
+       methodinfo *resm;
+       jint        i;
+
+       STATISTICS(jniinvokation());
+
+       if (m == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+        
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+
+       } else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       STATISTICS(jnicallXmethodnvokation());
+
+       i = vm_call_method_int_jvalue(resm, o, args);
+
+       return i;
+}
+
+
+/* _Jv_jni_CallLongMethod ******************************************************
+
+   Internal function to call Java long methods.
+
+*******************************************************************************/
+
+static jlong _Jv_jni_CallLongMethod(java_handle_t *o, vftbl_t *vftbl,
+                                                                       methodinfo *m, va_list ap)
+{
+       methodinfo *resm;
+       jlong       l;
+
+       STATISTICS(jniinvokation());
+
+       if (m == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+
+       } else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       STATISTICS(jnicallXmethodnvokation());
+
+       l = vm_call_method_long_valist(resm, o, ap);
+
+       return l;
+}
+
+
+/* _Jv_jni_CallLongMethodA *****************************************************
+
+   Internal function to call Java long methods.
+
+*******************************************************************************/
+
+static jlong _Jv_jni_CallLongMethodA(java_handle_t *o, vftbl_t *vftbl,
+                                                                        methodinfo *m, const jvalue *args)
+{
+       methodinfo *resm;
+       jlong       l;
+
+       STATISTICS(jniinvokation());
+
+       if (m == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+       }
+       else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       STATISTICS(jnicallXmethodnvokation());
+
+       l = vm_call_method_long_jvalue(resm, o, args);
+
+       return l;
+}
+
+
+/* _Jv_jni_CallFloatMethod *****************************************************
+
+   Internal function to call Java float methods.
+
+*******************************************************************************/
+
+static jfloat _Jv_jni_CallFloatMethod(java_handle_t *o, vftbl_t *vftbl,
+                                                                         methodinfo *m, va_list ap)
+{
+       methodinfo *resm;
+       jfloat      f;
+
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+
+       } else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       STATISTICS(jnicallXmethodnvokation());
+
+       f = vm_call_method_float_valist(resm, o, ap);
+
+       return f;
+}
+
+
+/* _Jv_jni_CallFloatMethodA ****************************************************
+
+   Internal function to call Java float methods.
+
+*******************************************************************************/
+
+static jfloat _Jv_jni_CallFloatMethodA(java_handle_t *o, vftbl_t *vftbl,
+                                                                          methodinfo *m, const jvalue *args)
+{
+       methodinfo *resm;
+       jfloat      f;
+
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+       }
+       else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       STATISTICS(jnicallXmethodnvokation());
+
+       f = vm_call_method_float_jvalue(resm, o, args);
+
+       return f;
+}
+
+
+/* _Jv_jni_CallDoubleMethod ****************************************************
+
+   Internal function to call Java double methods.
+
+*******************************************************************************/
+
+static jdouble _Jv_jni_CallDoubleMethod(java_handle_t *o, vftbl_t *vftbl,
+                                                                               methodinfo *m, va_list ap)
+{
+       methodinfo *resm;
+       jdouble     d;
+
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+
+       } else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       d = vm_call_method_double_valist(resm, o, ap);
+
+       return d;
+}
+
+
+/* _Jv_jni_CallDoubleMethodA ***************************************************
+
+   Internal function to call Java double methods.
+
+*******************************************************************************/
+
+static jdouble _Jv_jni_CallDoubleMethodA(java_handle_t *o, vftbl_t *vftbl,
+                                                                                methodinfo *m, const jvalue *args)
+{
+       methodinfo *resm;
+       jdouble     d;
+
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+       }
+       else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       d = vm_call_method_double_jvalue(resm, o, args);
+
+       return d;
+}
+
+
+/* _Jv_jni_CallVoidMethod ******************************************************
+
+   Internal function to call Java void methods.
+
+*******************************************************************************/
+
+static void _Jv_jni_CallVoidMethod(java_handle_t *o, vftbl_t *vftbl,
+                                                                  methodinfo *m, va_list ap)
+{      
+       methodinfo *resm;
+
+       if (m == NULL) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+
+       } else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       STATISTICS(jnicallXmethodnvokation());
+
+       (void) vm_call_method_valist(resm, o, ap);
+}
+
+
+/* _Jv_jni_CallVoidMethodA *****************************************************
+
+   Internal function to call Java void methods.
+
+*******************************************************************************/
+
+static void _Jv_jni_CallVoidMethodA(java_handle_t *o, vftbl_t *vftbl,
+                                                                       methodinfo *m, const jvalue *args)
+{      
+       methodinfo *resm;
+
+       if (m == NULL) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       /* Class initialization is done by the JIT compiler.  This is ok
+          since a static method always belongs to the declaring class. */
+
+       if (m->flags & ACC_STATIC) {
+               /* For static methods we reset the object. */
+
+               if (o != NULL)
+                       o = NULL;
+
+               /* for convenience */
+
+               resm = m;
+
+       } else {
+               /* For instance methods we make a virtual function table lookup. */
+
+               resm = method_vftbl_lookup(vftbl, m);
+       }
+
+       STATISTICS(jnicallXmethodnvokation());
+
+       (void) vm_call_method_jvalue(resm, o, args);
+}
+
+
+// JNI functions are exported as C functions.
+extern "C" {
+
+/* GetVersion ******************************************************************
+
+   Returns the major version number in the higher 16 bits and the
+   minor version number in the lower 16 bits.
+
+*******************************************************************************/
+
+jint _Jv_JNI_GetVersion(JNIEnv *env)
+{
+       TRACEJNICALLS(("_Jv_JNI_GetVersion(env=%p)", env));
+
+       /* We support JNI 1.6. */
+
+       return JNI_VERSION_1_6;
+}
+
+
+/* Class Operations ***********************************************************/
+
+/* DefineClass *****************************************************************
+
+   Loads a class from a buffer of raw class data. The buffer
+   containing the raw class data is not referenced by the VM after the
+   DefineClass call returns, and it may be discarded if desired.
+
+*******************************************************************************/
+
+jclass jni_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize bufLen)
+{
+#if defined(ENABLE_JAVASE)
+       utf           *u;
+       classloader_t *cl;
+       classinfo     *c;
+       java_handle_t* h;
+
+       TRACEJNICALLS(("jni_DefineClass(env=%p, name=%s, loader=%p, buf=%p, bufLen=%d)", env, name, loader, buf, bufLen));
+
+       u  = utf_new_char(name);
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       c = class_define(u, cl, bufLen, (uint8_t *) buf, NULL);
+
+       h = LLNI_classinfo_wrap(c);
+
+       return (jclass) jni_NewLocalRef(env, (jobject) h);
+#else
+       vm_abort("jni_DefineClass: Not implemented in this configuration");
+
+       // Keep compiler happy.
+
+       return 0;
+#endif
+}
+
+
+/* FindClass *******************************************************************
+
+   This function loads a locally-defined class. It searches the
+   directories and zip files specified by the CLASSPATH environment
+   variable for the class with the specified name.
+
+*******************************************************************************/
+
+jclass jni_FindClass(JNIEnv *env, const char *name)
+{
+#if defined(ENABLE_JAVASE)
+
+       utf*       u;    
+       classinfo* cc;
+       classinfo* c;
+       java_handle_t* h;
+
+       TRACEJNICALLS(("jni_FindClass(env=%p, name=%s)", env, name));
+
+       /* FIXME If name is NULL we have a problem here. */
+
+       u = utf_new_char_classname((char *) name);
+
+       if ((u == NULL) /*|| (int)strlen(name) > symbolOopDesc::max_length() */) {
+               exceptions_throw_noclassdeffounderror(u);
+               return NULL;
+       }
+
+       /* Check stacktrace for classloader, if one found use it,
+          otherwise use the system classloader. */
+
+       /* Quote from the JNI documentation:
+        
+          In the Java 2 Platform, FindClass locates the class loader
+          associated with the current native method.  If the native code
+          belongs to a system class, no class loader will be
+          involved. Otherwise, the proper class loader will be invoked to
+          load and link the named class. When FindClass is called through
+          the Invocation Interface, there is no current native method or
+          its associated class loader. In that case, the result of
+          ClassLoader.getBaseClassLoader is used." */
+
+       cc = stacktrace_get_current_class();
+
+       if (cc == NULL)
+               c = load_class_from_sysloader(u);
+       else
+               c = load_class_from_classloader(u, cc->classloader);
+
+       if (c == NULL) {
+               resolve_handle_pending_exception(true);
+               return NULL;
+       }
+
+       if (!link_class(c))
+               return NULL;
+
+       h = LLNI_classinfo_wrap(c);
+
+       return (jclass) jni_NewLocalRef(env, (jobject) h);
+
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+
+       utf       *u;
+       classinfo *c;
+
+       TRACEJNICALLS(("jni_FindClass(env=%p, name=%s)", env, name));
+
+       u = utf_new_char_classname((char *) name);
+       c = load_class_bootstrap(u);
+
+       if (c == NULL) {
+               resolve_handle_pending_exception(true);
+               return NULL;
+       }
+
+       if (!link_class(c))
+               return NULL;
+
+       return (jclass) jni_NewLocalRef(env, (jobject) c);
+       
+#else
+       vm_abort("jni_FindClass: not implemented in this configuration");
+
+       /* keep compiler happy */
+
+       return NULL;
+#endif
+}
+  
+
+/* GetSuperclass ***************************************************************
+
+   If clazz represents any class other than the class Object, then
+   this function returns the object that represents the superclass of
+   the class specified by clazz.
+
+*******************************************************************************/
+jclass jni_GetSuperclass(JNIEnv *env, jclass sub)
+{
+       classinfo* c;
+       classinfo* super;
+
+       TRACEJNICALLS(("jni_GetSuperclass(env=%p, sub=%p)", env, sub));
+
+       c = LLNI_classinfo_unwrap(sub);
+
+       if (c == NULL)
+               return NULL;
+
+       super = class_get_superclass(c);
+
+       java_handle_t* h = LLNI_classinfo_wrap(super);
+
+       return (jclass) jni_NewLocalRef(env, (jobject) h);
+}
+  
+/* IsAssignableFrom ************************************************************
+
+   Determines whether an object of sub can be safely cast to sup.
+
+*******************************************************************************/
+
+jboolean _Jv_JNI_IsAssignableFrom(JNIEnv *env, jclass sub, jclass sup)
+{
+       classinfo *to;
+       classinfo *from;
+
+       TRACEJNICALLS(("_Jv_JNI_IsAssignableFrom(env=%p, sub=%p, sup=%p)", env, sub, sup));
+
+       to   = (classinfo *) sup;
+       from = (classinfo *) sub;
+
+       return class_is_assignable_from(to, from);
+}
+
+
+/* Throw ***********************************************************************
+
+   Causes a java.lang.Throwable object to be thrown.
+
+*******************************************************************************/
+
+jint _Jv_JNI_Throw(JNIEnv *env, jthrowable obj)
+{
+       java_handle_t *o;
+
+       STATISTICS(jniinvokation());
+
+       o = (java_handle_t *) obj;
+
+       exceptions_set_exception(o);
+
+       return JNI_OK;
+}
+
+
+/* ThrowNew ********************************************************************
+
+   Constructs an exception object from the specified class with the
+   message specified by message and causes that exception to be
+   thrown.
+
+*******************************************************************************/
+
+jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg) 
+{
+       classinfo     *c;
+       java_handle_t *o;
+       java_handle_t *s;
+
+       STATISTICS(jniinvokation());
+
+       c = LLNI_classinfo_unwrap(clazz);
+       if (msg == NULL)
+               msg = "";
+       s = javastring_new_from_utf_string(msg);
+
+       /* instantiate exception object */
+
+       o = native_new_and_init_string(c, s);
+
+       if (o == NULL)
+               return -1;
+
+       exceptions_set_exception(o);
+
+       return 0;
+}
+
+
+/* ExceptionOccurred ***********************************************************
+
+   Determines if an exception is being thrown. The exception stays
+   being thrown until either the native code calls ExceptionClear(),
+   or the Java code handles the exception.
+
+*******************************************************************************/
+
+jthrowable _Jv_JNI_ExceptionOccurred(JNIEnv *env)
+{
+       java_handle_t *o;
+
+       TRACEJNICALLS(("_Jv_JNI_ExceptionOccurred(env=%p)", env));
+
+       o = exceptions_get_exception();
+
+       return (jthrowable) jni_NewLocalRef(env, (jthrowable) o);
+}
+
+
+/* ExceptionDescribe ***********************************************************
+
+   Prints an exception and a backtrace of the stack to a system
+   error-reporting channel, such as stderr. This is a convenience
+   routine provided for debugging.
+
+*******************************************************************************/
+
+void jni_ExceptionDescribe(JNIEnv *env)
+{
+       TRACEJNICALLS(("jni_ExceptionDescribe(env=%p)", env));
+
+       exceptions_print_stacktrace();
+}
+
+
+/* ExceptionClear **************************************************************
+
+   Clears any exception that is currently being thrown. If no
+   exception is currently being thrown, this routine has no effect.
+
+*******************************************************************************/
+
+void jni_ExceptionClear(JNIEnv *env)
+{
+       TRACEJNICALLS(("jni_ExceptionClear(env=%p)", env));
+
+       exceptions_clear_exception();
+}
+
+
+/* FatalError ******************************************************************
+
+   Raises a fatal error and does not expect the VM to recover. This
+   function does not return.
+
+*******************************************************************************/
+
+void _Jv_JNI_FatalError(JNIEnv *env, const char *msg)
+{
+       STATISTICS(jniinvokation());
+
+       /* this seems to be the best way */
+
+       vm_abort("JNI Fatal error: %s", msg);
+}
+
+
+/* PushLocalFrame **************************************************************
+
+   Creates a new local reference frame, in which at least a given
+   number of local references can be created.
+
+*******************************************************************************/
+
+jint jni_PushLocalFrame(JNIEnv* env, jint capacity)
+{
+       TRACEJNICALLS(("jni_PushLocalFrame(env=%p, capacity=%d)", env, capacity));
+
+       if (capacity <= 0)
+               return -1;
+
+       /* add new local reference frame to current table */
+
+       if (!localref_frame_push(capacity))
+               return -1;
+
+       return 0;
+}
+
+
+/* PopLocalFrame ***************************************************************
+
+   Pops off the current local reference frame, frees all the local
+   references, and returns a local reference in the previous local
+   reference frame for the given result object.
+
+*******************************************************************************/
+
+jobject jni_PopLocalFrame(JNIEnv* env, jobject result)
+{
+       TRACEJNICALLS(("jni_PopLocalFrame(env=%p, result=%p)", env, result));
+
+       /* release all current local frames */
+
+       localref_frame_pop_all();
+
+       /* add local reference and return the value */
+
+       return jni_NewLocalRef(env, result);
+}
+
+
+/* DeleteLocalRef **************************************************************
+
+   Deletes the local reference pointed to by localRef.
+
+*******************************************************************************/
+
+void jni_DeleteLocalRef(JNIEnv *env, jobject localRef)
+{
+       java_handle_t *o;
+
+       TRACEJNICALLS(("jni_DeleteLocalRef(env=%p, ref=%p)", env, localRef));
+
+       o = (java_handle_t *) localRef;
+
+       if (o == NULL)
+               return;
+
+       /* delete the reference */
+
+       localref_del(o);
+}
+
+
+/* IsSameObject ****************************************************************
+
+   Tests whether two references refer to the same Java object.
+
+*******************************************************************************/
+
+jboolean _Jv_JNI_IsSameObject(JNIEnv *env, jobject ref1, jobject ref2)
+{
+       java_handle_t *o1;
+       java_handle_t *o2;
+       jboolean       result;
+
+       STATISTICS(jniinvokation());
+
+       o1 = (java_handle_t *) ref1;
+       o2 = (java_handle_t *) ref2;
+
+       LLNI_CRITICAL_START;
+
+       if (LLNI_UNWRAP(o1) == LLNI_UNWRAP(o2))
+               result = JNI_TRUE;
+       else
+               result = JNI_FALSE;
+
+       LLNI_CRITICAL_END;
+
+       return result;
+}
+
+
+/* NewLocalRef *****************************************************************
+
+   Creates a new local reference that refers to the same object as ref.
+
+*******************************************************************************/
+
+jobject jni_NewLocalRef(JNIEnv *env, jobject ref)
+{
+       java_handle_t *o;
+       java_handle_t *localref;
+
+       TRACEJNICALLS(("jni_NewLocalRef(env=%p, ref=%p)", env, ref));
+
+       o = (java_handle_t *) ref;
+
+       if (o == NULL)
+               return NULL;
+
+       /* insert the reference */
+
+       localref = localref_add(LLNI_DIRECT(o));
+
+       return (jobject) localref;
+}
+
+
+/* EnsureLocalCapacity *********************************************************
+
+   Ensures that at least a given number of local references can be
+   created in the current thread
+
+*******************************************************************************/
+
+jint jni_EnsureLocalCapacity(JNIEnv* env, jint capacity)
+{
+       localref_table *lrt;
+
+       TRACEJNICALLS(("jni_EnsureLocalCapacity(env=%p, capacity=%d)", env, capacity));
+
+       /* get local reference table (thread specific) */
+
+       lrt = LOCALREFTABLE;
+
+       /* check if capacity elements are available in the local references table */
+
+       if ((lrt->used + capacity) > lrt->capacity)
+               return jni_PushLocalFrame(env, capacity);
+
+       return 0;
+}
+
+
+/* AllocObject *****************************************************************
+
+   Allocates a new Java object without invoking any of the
+   constructors for the object. Returns a reference to the object.
+
+*******************************************************************************/
+
+jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz)
+{
+       classinfo     *c;
+       java_handle_t *o;
+
+       STATISTICS(jniinvokation());
+
+       c = LLNI_classinfo_unwrap(clazz);
+
+       if ((c->flags & ACC_INTERFACE) || (c->flags & ACC_ABSTRACT)) {
+               exceptions_throw_instantiationexception(c);
+               return NULL;
+       }
+               
+       o = builtin_new(c);
+
+       return jni_NewLocalRef(env, (jobject) o);
+}
+
+
+/* NewObject *******************************************************************
+
+   Programmers place all arguments that are to be passed to the
+   constructor immediately following the methodID
+   argument. NewObject() accepts these arguments and passes them to
+   the Java method that the programmer wishes to invoke.
+
+*******************************************************************************/
+
+jobject jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       java_handle_t *o;
+       classinfo     *c;
+       methodinfo    *m;
+       va_list        ap;
+
+       TRACEJNICALLSENTER(("jni_NewObject(env=%p, clazz=%p, methodID=%p, ...)", env, clazz, methodID));
+
+       c = LLNI_classinfo_unwrap(clazz);
+       m = (methodinfo *) methodID;
+
+       /* create object */
+
+       o = builtin_new(c);
+       
+       if (o == NULL)
+               return NULL;
+
+       /* call constructor */
+
+       va_start(ap, methodID);
+       _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, ap);
+       va_end(ap);
+
+       TRACEJNICALLSEXIT(("->%p", o));
+
+       return jni_NewLocalRef(env, (jobject) o);
+}
+
+
+/* NewObjectV ******************************************************************
+
+   Programmers place all arguments that are to be passed to the
+   constructor in an args argument of type va_list that immediately
+   follows the methodID argument. NewObjectV() accepts these
+   arguments, and, in turn, passes them to the Java method that the
+   programmer wishes to invoke.
+
+*******************************************************************************/
+
+jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID,
+                                                  va_list args)
+{
+       java_handle_t *o;
+       classinfo     *c;
+       methodinfo    *m;
+
+       STATISTICS(jniinvokation());
+
+       c = LLNI_classinfo_unwrap(clazz);
+       m = (methodinfo *) methodID;
+
+       /* create object */
+
+       o = builtin_new(c);
+       
+       if (o == NULL)
+               return NULL;
+
+       /* call constructor */
+
+       _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, args);
+
+       return jni_NewLocalRef(env, (jobject) o);
+}
+
+
+/* NewObjectA ***************************************************************** 
+
+   Programmers place all arguments that are to be passed to the
+   constructor in an args array of jvalues that immediately follows
+   the methodID argument. NewObjectA() accepts the arguments in this
+   array, and, in turn, passes them to the Java method that the
+   programmer wishes to invoke.
+
+*******************************************************************************/
+
+jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID,
+                                                  const jvalue *args)
+{
+       java_handle_t *o;
+       classinfo     *c;
+       methodinfo    *m;
+
+       STATISTICS(jniinvokation());
+
+       c = LLNI_classinfo_unwrap(clazz);
+       m = (methodinfo *) methodID;
+
+       /* create object */
+
+       o = builtin_new(c);
+       
+       if (o == NULL)
+               return NULL;
+
+       /* call constructor */
+
+       _Jv_jni_CallVoidMethodA(o, LLNI_vftbl_direct(o), m, args);
+
+       return jni_NewLocalRef(env, (jobject) o);
+}
+
+
+/* GetObjectClass **************************************************************
+
+ Returns the class of an object.
+
+*******************************************************************************/
+
+jclass jni_GetObjectClass(JNIEnv *env, jobject obj)
+{
+       java_handle_t* o;
+       classinfo*     c;
+
+       TRACEJNICALLS(("jni_GetObjectClass(env=%p, obj=%p)", env, obj));
+
+       o = (java_handle_t *) obj;
+
+       if ((o == NULL) || (LLNI_vftbl_direct(o) == NULL))
+               return NULL;
+
+       LLNI_class_get(o, c);
+
+       java_handle_t* h = LLNI_classinfo_wrap(c);
+
+       return (jclass) jni_NewLocalRef(env, (jobject) h);
+}
+
+
+/* IsInstanceOf ****************************************************************
+
+   Tests whether an object is an instance of a class.
+
+*******************************************************************************/
+
+jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)
+{
+       classinfo     *c;
+       java_handle_t *h;
+
+       TRACEJNICALLS(("_Jv_JNI_IsInstanceOf(env=%p, obj=%p, clazz=%p)", env, obj, clazz));
+
+       /* XXX Is this correct? */
+       c = LLNI_classinfo_unwrap(clazz);
+       h = (java_handle_t *) obj;
+
+       return class_is_instance(c, h);
+}
+
+
+/* Reflection Support *********************************************************/
+
+/* FromReflectedMethod *********************************************************
+
+   Converts java.lang.reflect.Method or java.lang.reflect.Constructor
+   object to a method ID.
+  
+*******************************************************************************/
+  
+jmethodID jni_FromReflectedMethod(JNIEnv *env, jobject method)
+{
+#if defined(ENABLE_JAVASE)
+       methodinfo*    m;
+
+       TRACEJNICALLS(("jni_FromReflectedMethod(env=%p, method=%p)", env, method));
+
+       java_lang_Object o(method);
+
+       if (o.is_null())
+               return NULL;
+
+       if (o.get_Class() == class_java_lang_reflect_Constructor) {
+               java_lang_reflect_Constructor rc(method);
+               m = rc.get_method();
+       }
+       else {
+               assert(o.get_Class() == class_java_lang_reflect_Method);
+
+               java_lang_reflect_Method rm(method);
+               m = rm.get_method();
+       }
+
+       return (jmethodID) m;
+#else
+       vm_abort("jni_FromReflectedMethod: Not implemented in this configuration.");
+
+       // Keep compiler happy.
+       return NULL;
+#endif
+}
+
+
+/* FromReflectedField **********************************************************
+
+   Converts a java.lang.reflect.Field to a field ID.
+
+*******************************************************************************/
+jfieldID jni_FromReflectedField(JNIEnv* env, jobject field)
+{
+#if defined(ENABLE_JAVASE)
+
+       TRACEJNICALLS(("jni_FromReflectedField(env=%p, field=%p)", env, field));
+
+       java_lang_reflect_Field rf(field);
+
+       if (rf.is_null())
+               return NULL;
+
+       fieldinfo* f = rf.get_field();
+
+       return (jfieldID) f;
+#else
+       vm_abort("jni_FromReflectedField: Not implemented in this configuration.");
+
+       // Keep compiler happy.
+       return NULL;
+#endif
+}
+
+
+/* ToReflectedMethod ***********************************************************
+
+   Converts a method ID derived from cls to an instance of the
+   java.lang.reflect.Method class or to an instance of the
+   java.lang.reflect.Constructor class.
+
+*******************************************************************************/
+
+jobject jni_ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID, jboolean isStatic)
+{
+#if defined(ENABLE_JAVASE)
+       TRACEJNICALLS(("jni_ToReflectedMethod(env=%p, cls=%p, methodID=%p, isStatic=%d)", env, cls, methodID, isStatic));
+
+       methodinfo* m = (methodinfo *) methodID;
+
+       /* HotSpot does the same assert. */
+
+       assert(((m->flags & ACC_STATIC) != 0) == (isStatic != 0));
+
+       java_handle_t* h;
+
+       if (m->name == utf_init) {
+               h = java_lang_reflect_Constructor(m).get_handle();
+       }
+       else {
+               h = java_lang_reflect_Method(m).get_handle();
+       }
+
+       return (jobject) h;
+#else
+       vm_abort("jni_ToReflectedMethod: Not implemented in this configuration.");
+
+       /* keep compiler happy */
+
+       return NULL;
+#endif
+}
+
+
+/* ToReflectedField ************************************************************
+
+   Converts a field ID derived from cls to an instance of the
+   java.lang.reflect.Field class.
+
+*******************************************************************************/
+
+jobject _Jv_JNI_ToReflectedField(JNIEnv* env, jclass cls, jfieldID fieldID,
+                                                                jboolean isStatic)
+{
+       STATISTICS(jniinvokation());
+
+       log_text("JNI-Call: ToReflectedField: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* Calling Instance Methods ***************************************************/
+
+/* GetMethodID *****************************************************************
+
+   Returns the method ID for an instance (nonstatic) method of a class
+   or interface. The method may be defined in one of the clazz's
+   superclasses and inherited by clazz. The method is determined by
+   its name and signature.
+
+   GetMethodID() causes an uninitialized class to be initialized.
+
+*******************************************************************************/
+
+jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name,
+                                                         const char *sig)
+{
+       classinfo  *c;
+       utf        *uname;
+       utf        *udesc;
+       methodinfo *m;
+
+       STATISTICS(jniinvokation());
+
+       c = LLNI_classinfo_unwrap(clazz);
+
+       if (c == NULL)
+               return NULL;
+
+       if (!(c->state & CLASS_INITIALIZED))
+               if (!initialize_class(c))
+                       return NULL;
+
+       /* try to get the method of the class or one of it's superclasses */
+
+       uname = utf_new_char((char *) name);
+       udesc = utf_new_char((char *) sig);
+
+       m = class_resolvemethod(c, uname, udesc);
+
+       if ((m == NULL) || (m->flags & ACC_STATIC)) {
+               exceptions_throw_nosuchmethoderror(c, uname, udesc);
+
+               return NULL;
+       }
+
+       return (jmethodID) m;
+}
+
+
+/* JNI-functions for calling instance methods *********************************/
+
+#define JNI_CALL_VIRTUAL_METHOD(name, type, intern)         \
+type _Jv_JNI_Call##name##Method(JNIEnv *env, jobject obj,   \
+                                                               jmethodID methodID, ...)    \
+{                                                           \
+       java_handle_t *o;                                       \
+       methodinfo    *m;                                       \
+       va_list        ap;                                      \
+       type           ret;                                     \
+                                                            \
+       o = (java_handle_t *) obj;                              \
+       m = (methodinfo *) methodID;                            \
+                                                            \
+       va_start(ap, methodID);                                 \
+       ret = _Jv_jni_Call##intern##Method(o, LLNI_vftbl_direct(o), m, ap); \
+       va_end(ap);                                             \
+                                                            \
+       return ret;                                             \
+}
+
+JNI_CALL_VIRTUAL_METHOD(Boolean, jboolean, Int)
+JNI_CALL_VIRTUAL_METHOD(Byte,    jbyte,    Int)
+JNI_CALL_VIRTUAL_METHOD(Char,    jchar,    Int)
+JNI_CALL_VIRTUAL_METHOD(Short,   jshort,   Int)
+JNI_CALL_VIRTUAL_METHOD(Int,     jint,     Int)
+JNI_CALL_VIRTUAL_METHOD(Long,    jlong,    Long)
+JNI_CALL_VIRTUAL_METHOD(Float,   jfloat,   Float)
+JNI_CALL_VIRTUAL_METHOD(Double,  jdouble,  Double)
+
+
+#define JNI_CALL_VIRTUAL_METHOD_V(name, type, intern)              \
+type _Jv_JNI_Call##name##MethodV(JNIEnv *env, jobject obj,         \
+                                                                jmethodID methodID, va_list args) \
+{                                                                  \
+       java_handle_t *o;                                              \
+       methodinfo    *m;                                              \
+       type           ret;                                            \
+                                                                   \
+       o = (java_handle_t *) obj;                                     \
+       m = (methodinfo *) methodID;                                   \
+                                                                   \
+       ret = _Jv_jni_Call##intern##Method(o, LLNI_vftbl_direct(o), m, args);      \
+                                                                   \
+       return ret;                                                    \
+}
+
+JNI_CALL_VIRTUAL_METHOD_V(Boolean, jboolean, Int)
+JNI_CALL_VIRTUAL_METHOD_V(Byte,    jbyte,    Int)
+JNI_CALL_VIRTUAL_METHOD_V(Char,    jchar,    Int)
+JNI_CALL_VIRTUAL_METHOD_V(Short,   jshort,   Int)
+JNI_CALL_VIRTUAL_METHOD_V(Int,     jint,     Int)
+JNI_CALL_VIRTUAL_METHOD_V(Long,    jlong,    Long)
+JNI_CALL_VIRTUAL_METHOD_V(Float,   jfloat,   Float)
+JNI_CALL_VIRTUAL_METHOD_V(Double,  jdouble,  Double)
+
+
+#define JNI_CALL_VIRTUAL_METHOD_A(name, type, intern)          \
+type _Jv_JNI_Call##name##MethodA(JNIEnv *env, jobject obj,     \
+                                                                jmethodID methodID,           \
+                                                                const jvalue *args)           \
+{                                                              \
+       java_handle_t *o;                                          \
+       methodinfo    *m;                                          \
+       type           ret;                                        \
+                                                               \
+       o = (java_handle_t *) obj;                                 \
+       m = (methodinfo *) methodID;                               \
+                                                               \
+       ret = _Jv_jni_Call##intern##MethodA(o, LLNI_vftbl_direct(o), m, args); \
+                                                               \
+       return ret;                                                \
+}
+
+JNI_CALL_VIRTUAL_METHOD_A(Boolean, jboolean, Int)
+JNI_CALL_VIRTUAL_METHOD_A(Byte,    jbyte,    Int)
+JNI_CALL_VIRTUAL_METHOD_A(Char,    jchar,    Int)
+JNI_CALL_VIRTUAL_METHOD_A(Short,   jshort,   Int)
+JNI_CALL_VIRTUAL_METHOD_A(Int,     jint,     Int)
+JNI_CALL_VIRTUAL_METHOD_A(Long,    jlong,    Long)
+JNI_CALL_VIRTUAL_METHOD_A(Float,   jfloat,   Float)
+JNI_CALL_VIRTUAL_METHOD_A(Double,  jdouble,  Double)
+
+
+jobject _Jv_JNI_CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID,
+                                                                ...)
+{
+       java_handle_t *o;
+       methodinfo    *m;
+       java_handle_t *ret;
+       va_list        ap;
+
+       o = (java_handle_t *) obj;
+       m = (methodinfo *) methodID;
+
+       va_start(ap, methodID);
+       ret = _Jv_jni_CallObjectMethod(o, LLNI_vftbl_direct(o), m, ap);
+       va_end(ap);
+
+       return jni_NewLocalRef(env, (jobject) ret);
+}
+
+
+jobject _Jv_JNI_CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
+                                                                 va_list args)
+{
+       java_handle_t *o;
+       methodinfo    *m;
+       java_handle_t *ret;
+
+       o = (java_handle_t *) obj;
+       m = (methodinfo *) methodID;
+
+       ret = _Jv_jni_CallObjectMethod(o, LLNI_vftbl_direct(o), m, args);
+
+       return jni_NewLocalRef(env, (jobject) ret);
+}
+
+
+jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
+                                                                 const jvalue *args)
+{
+       java_handle_t *o;
+       methodinfo    *m;
+       java_handle_t *ret;
+
+       o = (java_handle_t *) obj;
+       m = (methodinfo *) methodID;
+
+       ret = _Jv_jni_CallObjectMethodA(o, LLNI_vftbl_direct(o), m, args);
+
+       return jni_NewLocalRef(env, (jobject) ret);
+}
+
+
+
+void _Jv_JNI_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       java_handle_t *o;
+       methodinfo    *m;
+       va_list        ap;
+
+       o = (java_handle_t *) obj;
+       m = (methodinfo *) methodID;
+
+       va_start(ap, methodID);
+       _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, ap);
+       va_end(ap);
+}
+
+
+void _Jv_JNI_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
+                                                        va_list args)
+{
+       java_handle_t *o;
+       methodinfo    *m;
+
+       o = (java_handle_t *) obj;
+       m = (methodinfo *) methodID;
+
+       _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, args);
+}
+
+
+void _Jv_JNI_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
+                                                        const jvalue *args)
+{
+       java_handle_t *o;
+       methodinfo    *m;
+
+       o = (java_handle_t *) obj;
+       m = (methodinfo *) methodID;
+
+       _Jv_jni_CallVoidMethodA(o, LLNI_vftbl_direct(o), m, args);
+}
+
+
+
+#define JNI_CALL_NONVIRTUAL_METHOD(name, type, intern)                      \
+type _Jv_JNI_CallNonvirtual##name##Method(JNIEnv *env, jobject obj,         \
+                                                                                 jclass clazz, jmethodID methodID, \
+                                                                                 ...)                              \
+{                                                                           \
+       java_handle_t *o;                                                       \
+       classinfo     *c;                                                       \
+       methodinfo    *m;                                                       \
+       va_list        ap;                                                      \
+       type           ret;                                                     \
+                                                                            \
+       o = (java_handle_t *) obj;                                              \
+       c = LLNI_classinfo_unwrap(clazz);                                       \
+       m = (methodinfo *) methodID;                                            \
+                                                                            \
+       va_start(ap, methodID);                                                 \
+       ret = _Jv_jni_Call##intern##Method(o, c->vftbl, m, ap);                 \
+       va_end(ap);                                                             \
+                                                                            \
+       return ret;                                                             \
+}
+
+JNI_CALL_NONVIRTUAL_METHOD(Boolean, jboolean, Int)
+JNI_CALL_NONVIRTUAL_METHOD(Byte,    jbyte,    Int)
+JNI_CALL_NONVIRTUAL_METHOD(Char,    jchar,    Int)
+JNI_CALL_NONVIRTUAL_METHOD(Short,   jshort,   Int)
+JNI_CALL_NONVIRTUAL_METHOD(Int,     jint,     Int)
+JNI_CALL_NONVIRTUAL_METHOD(Long,    jlong,    Long)
+JNI_CALL_NONVIRTUAL_METHOD(Float,   jfloat,   Float)
+JNI_CALL_NONVIRTUAL_METHOD(Double,  jdouble,  Double)
+
+
+#define JNI_CALL_NONVIRTUAL_METHOD_V(name, type, intern)                     \
+type _Jv_JNI_CallNonvirtual##name##MethodV(JNIEnv *env, jobject obj,         \
+                                                                                  jclass clazz, jmethodID methodID, \
+                                                                                  va_list args)                     \
+{                                                                            \
+       java_handle_t *o;                                                        \
+       classinfo     *c;                                                        \
+       methodinfo    *m;                                                        \
+       type           ret;                                                      \
+                                                                             \
+       o = (java_handle_t *) obj;                                               \
+       c = LLNI_classinfo_unwrap(clazz);                                        \
+       m = (methodinfo *) methodID;                                             \
+                                                                             \
+       ret = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);                       \
+                                                                             \
+       return ret;                                                              \
+}
+
+JNI_CALL_NONVIRTUAL_METHOD_V(Boolean, jboolean, Int)
+JNI_CALL_NONVIRTUAL_METHOD_V(Byte,    jbyte,    Int)
+JNI_CALL_NONVIRTUAL_METHOD_V(Char,    jchar,    Int)
+JNI_CALL_NONVIRTUAL_METHOD_V(Short,   jshort,   Int)
+JNI_CALL_NONVIRTUAL_METHOD_V(Int,     jint,     Int)
+JNI_CALL_NONVIRTUAL_METHOD_V(Long,    jlong,    Long)
+JNI_CALL_NONVIRTUAL_METHOD_V(Float,   jfloat,   Float)
+JNI_CALL_NONVIRTUAL_METHOD_V(Double,  jdouble,  Double)
+
+
+#define JNI_CALL_NONVIRTUAL_METHOD_A(name, type, intern)                     \
+type _Jv_JNI_CallNonvirtual##name##MethodA(JNIEnv *env, jobject obj,         \
+                                                                                  jclass clazz, jmethodID methodID, \
+                                                                                  const jvalue *args)               \
+{                                                                            \
+       log_text("JNI-Call: CallNonvirtual##name##MethodA: IMPLEMENT ME!");      \
+                                                                             \
+       return 0;                                                                \
+}
+
+JNI_CALL_NONVIRTUAL_METHOD_A(Boolean, jboolean, Int)
+JNI_CALL_NONVIRTUAL_METHOD_A(Byte,    jbyte,    Int)
+JNI_CALL_NONVIRTUAL_METHOD_A(Char,    jchar,    Int)
+JNI_CALL_NONVIRTUAL_METHOD_A(Short,   jshort,   Int)
+JNI_CALL_NONVIRTUAL_METHOD_A(Int,     jint,     Int)
+JNI_CALL_NONVIRTUAL_METHOD_A(Long,    jlong,    Long)
+JNI_CALL_NONVIRTUAL_METHOD_A(Float,   jfloat,   Float)
+JNI_CALL_NONVIRTUAL_METHOD_A(Double,  jdouble,  Double)
+
+jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj,
+                                                                                  jclass clazz, jmethodID methodID,
+                                                                                  ...)
+{
+       java_handle_t *o;
+       classinfo     *c;
+       methodinfo    *m;
+       java_handle_t *r;
+       va_list        ap;
+
+       o = (java_handle_t *) obj;
+       c = LLNI_classinfo_unwrap(clazz);
+       m = (methodinfo *) methodID;
+
+       va_start(ap, methodID);
+       r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap);
+       va_end(ap);
+
+       return jni_NewLocalRef(env, (jobject) r);
+}
+
+
+jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj,
+                                                                                       jclass clazz, jmethodID methodID,
+                                                                                       va_list args)
+{
+       java_handle_t *o;
+       classinfo     *c;
+       methodinfo    *m;
+       java_handle_t *r;
+
+       o = (java_handle_t *) obj;
+       c = LLNI_classinfo_unwrap(clazz);
+       m = (methodinfo *) methodID;
+
+       r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args);
+
+       return jni_NewLocalRef(env, (jobject) r);
+}
+
+
+jobject _Jv_JNI_CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj,
+                                                                                       jclass clazz, jmethodID methodID,
+                                                                                       const jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!");
+
+       return jni_NewLocalRef(env, NULL);
+}
+
+
+void _Jv_JNI_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz,
+                                                                         jmethodID methodID, ...)
+{
+       java_handle_t *o;
+       classinfo     *c;
+       methodinfo    *m;
+       va_list        ap;
+
+       o = (java_handle_t *) obj;
+       c = LLNI_classinfo_unwrap(clazz);
+       m = (methodinfo *) methodID;
+
+       va_start(ap, methodID);
+       _Jv_jni_CallVoidMethod(o, c->vftbl, m, ap);
+       va_end(ap);
+}
+
+
+void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz,
+                                                                          jmethodID methodID, va_list args)
+{
+       java_handle_t *o;
+       classinfo     *c;
+       methodinfo    *m;
+
+       o = (java_handle_t *) obj;
+       c = LLNI_classinfo_unwrap(clazz);
+       m = (methodinfo *) methodID;
+
+       _Jv_jni_CallVoidMethod(o, c->vftbl, m, args);
+}
+
+
+void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz,
+                                                                          jmethodID methodID, const jvalue * args)
+{      
+       java_handle_t *o;
+       classinfo     *c;
+       methodinfo    *m;
+
+       o = (java_handle_t *) obj;
+       c = LLNI_classinfo_unwrap(clazz);
+       m = (methodinfo *) methodID;
+
+       _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args);
+}
+
+
+/* Accessing Fields of Objects ************************************************/
+
+/* GetFieldID ******************************************************************
+
+   Returns the field ID for an instance (nonstatic) field of a
+   class. The field is specified by its name and signature. The
+   Get<type>Field and Set<type>Field families of accessor functions
+   use field IDs to retrieve object fields.
+
+*******************************************************************************/
+
+jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name,
+                                                       const char *sig)
+{
+       classinfo *c;
+       fieldinfo *f;
+       utf       *uname;
+       utf       *udesc;
+
+       STATISTICS(jniinvokation());
+
+       c = LLNI_classinfo_unwrap(clazz);
+
+       /* XXX NPE check? */
+
+       uname = utf_new_char((char *) name);
+       udesc = utf_new_char((char *) sig);
+
+       f = class_findfield(c, uname, udesc); 
+       
+       if (f == NULL)
+               exceptions_throw_nosuchfielderror(c, uname);  
+
+       return (jfieldID) f;
+}
+
+
+/* Get<type>Field Routines *****************************************************
+
+   This family of accessor routines returns the value of an instance
+   (nonstatic) field of an object. The field to access is specified by
+   a field ID obtained by calling GetFieldID().
+
+*******************************************************************************/
+
+#define GET_FIELD(o,type,f) \
+    *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset)))
+
+#define JNI_GET_FIELD(name, type, intern)                                 \
+type _Jv_JNI_Get##name##Field(JNIEnv *env, jobject obj, jfieldID fieldID) \
+{                                                                         \
+       intern ret;                                                           \
+                                                                          \
+       TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "Field(env=%p, obj=%p, fieldId=%p)", env, obj, fieldID)); \
+                                                                          \
+       LLNI_CRITICAL_START;                                                  \
+                                                                          \
+       ret = GET_FIELD(LLNI_DIRECT((java_handle_t *) obj), intern, fieldID); \
+                                                                          \
+       LLNI_CRITICAL_END;                                                    \
+                                                                          \
+       return (type) ret;                                                    \
+}
+
+JNI_GET_FIELD(Boolean, jboolean, s4)
+JNI_GET_FIELD(Byte,    jbyte,    s4)
+JNI_GET_FIELD(Char,    jchar,    s4)
+JNI_GET_FIELD(Short,   jshort,   s4)
+JNI_GET_FIELD(Int,     jint,     s4)
+JNI_GET_FIELD(Long,    jlong,    s8)
+JNI_GET_FIELD(Float,   jfloat,   float)
+JNI_GET_FIELD(Double,  jdouble,  double)
+
+
+jobject _Jv_JNI_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       java_handle_t *o;
+
+       TRACEJNICALLS(("_Jv_JNI_GetObjectField(env=%p, obj=%p, fieldId=%p)", env, obj, fieldID));
+
+       LLNI_CRITICAL_START;
+
+       o = LLNI_WRAP(GET_FIELD(LLNI_DIRECT((java_handle_t *) obj), java_object_t*, fieldID));
+
+       LLNI_CRITICAL_END;
+
+       return jni_NewLocalRef(env, (jobject) o);
+}
+
+
+/* Set<type>Field Routines *****************************************************
+
+   This family of accessor routines sets the value of an instance
+   (nonstatic) field of an object. The field to access is specified by
+   a field ID obtained by calling GetFieldID().
+
+*******************************************************************************/
+
+#define SET_FIELD(o,type,f,value) \
+    *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset))) = (type) (value)
+
+#define JNI_SET_FIELD(name, type, intern)                                  \
+void _Jv_JNI_Set##name##Field(JNIEnv *env, jobject obj, jfieldID fieldID,  \
+                                                         type value)                                  \
+{                                                                          \
+       TRACEJNICALLS(("_Jv_JNI_Set" STR(name) "Field(env=%p, obj=%p, fieldId=%p, value=%p)", env, obj, fieldID, value)); \
+                                                                           \
+       LLNI_CRITICAL_START;                                                   \
+                                                                           \
+       SET_FIELD(LLNI_DIRECT((java_handle_t *) obj), intern, fieldID, value); \
+                                                                              \
+       LLNI_CRITICAL_START;                                                   \
+}
+
+JNI_SET_FIELD(Boolean, jboolean, s4)
+JNI_SET_FIELD(Byte,    jbyte,    s4)
+JNI_SET_FIELD(Char,    jchar,    s4)
+JNI_SET_FIELD(Short,   jshort,   s4)
+JNI_SET_FIELD(Int,     jint,     s4)
+JNI_SET_FIELD(Long,    jlong,    s8)
+JNI_SET_FIELD(Float,   jfloat,   float)
+JNI_SET_FIELD(Double,  jdouble,  double)
+
+
+void _Jv_JNI_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID,
+                                                       jobject value)
+{
+       TRACEJNICALLS(("_Jv_JNI_SetObjectField(env=%p, obj=%p, fieldId=%p, value=%p)", env, obj, fieldID, value));
+
+       LLNI_CRITICAL_START;
+
+       SET_FIELD(obj, java_handle_t*, fieldID, LLNI_UNWRAP((java_handle_t*) value));
+
+       LLNI_CRITICAL_END;
+}
+
+
+/* Calling Static Methods *****************************************************/
+
+/* GetStaticMethodID ***********************************************************
+
+   Returns the method ID for a static method of a class. The method is
+   specified by its name and signature.
+
+   GetStaticMethodID() causes an uninitialized class to be
+   initialized.
+
+*******************************************************************************/
+
+jmethodID _Jv_JNI_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name,
+                                                                       const char *sig)
+{
+       classinfo  *c;
+       utf        *uname;
+       utf        *udesc;
+       methodinfo *m;
+
+       TRACEJNICALLS(("_Jv_JNI_GetStaticMethodID(env=%p, clazz=%p, name=%s, sig=%s)", env, clazz, name, sig));
+
+       c = LLNI_classinfo_unwrap(clazz);
+
+       if (c == NULL)
+               return NULL;
+
+       if (!(c->state & CLASS_INITIALIZED))
+               if (!initialize_class(c))
+                       return NULL;
+
+       /* try to get the static method of the class */
+
+       uname = utf_new_char((char *) name);
+       udesc = utf_new_char((char *) sig);
+
+       m = class_resolvemethod(c, uname, udesc);
+
+       if ((m == NULL) || !(m->flags & ACC_STATIC)) {
+               exceptions_throw_nosuchmethoderror(c, uname, udesc);
+
+               return NULL;
+       }
+
+       return (jmethodID) m;
+}
+
+
+#define JNI_CALL_STATIC_METHOD(name, type, intern)               \
+type _Jv_JNI_CallStatic##name##Method(JNIEnv *env, jclass clazz, \
+                                                                         jmethodID methodID, ...)   \
+{                                                                \
+       methodinfo *m;                                               \
+       va_list     ap;                                              \
+       type        res;                                             \
+                                                                 \
+       m = (methodinfo *) methodID;                                 \
+                                                                 \
+       va_start(ap, methodID);                                      \
+       res = _Jv_jni_Call##intern##Method(NULL, NULL, m, ap);       \
+       va_end(ap);                                                  \
+                                                                 \
+       return res;                                                  \
+}
+
+JNI_CALL_STATIC_METHOD(Boolean, jboolean, Int)
+JNI_CALL_STATIC_METHOD(Byte,    jbyte,    Int)
+JNI_CALL_STATIC_METHOD(Char,    jchar,    Int)
+JNI_CALL_STATIC_METHOD(Short,   jshort,   Int)
+JNI_CALL_STATIC_METHOD(Int,     jint,     Int)
+JNI_CALL_STATIC_METHOD(Long,    jlong,    Long)
+JNI_CALL_STATIC_METHOD(Float,   jfloat,   Float)
+JNI_CALL_STATIC_METHOD(Double,  jdouble,  Double)
+
+
+#define JNI_CALL_STATIC_METHOD_V(name, type, intern)                     \
+type _Jv_JNI_CallStatic##name##MethodV(JNIEnv *env, jclass clazz,        \
+                                                                          jmethodID methodID, va_list args) \
+{                                                                        \
+       methodinfo *m;                                                       \
+       type        res;                                                     \
+                                                                         \
+       m = (methodinfo *) methodID;                                         \
+                                                                         \
+       res = _Jv_jni_Call##intern##Method(NULL, NULL, m, args);             \
+                                                                         \
+       return res;                                                          \
+}
+
+JNI_CALL_STATIC_METHOD_V(Boolean, jboolean, Int)
+JNI_CALL_STATIC_METHOD_V(Byte,    jbyte,    Int)
+JNI_CALL_STATIC_METHOD_V(Char,    jchar,    Int)
+JNI_CALL_STATIC_METHOD_V(Short,   jshort,   Int)
+JNI_CALL_STATIC_METHOD_V(Int,     jint,     Int)
+JNI_CALL_STATIC_METHOD_V(Long,    jlong,    Long)
+JNI_CALL_STATIC_METHOD_V(Float,   jfloat,   Float)
+JNI_CALL_STATIC_METHOD_V(Double,  jdouble,  Double)
+
+
+#define JNI_CALL_STATIC_METHOD_A(name, type, intern)                           \
+type _Jv_JNI_CallStatic##name##MethodA(JNIEnv *env, jclass clazz,              \
+                                                                          jmethodID methodID, const jvalue *args) \
+{                                                                              \
+       methodinfo *m;                                                             \
+       type        res;                                                           \
+                                                                               \
+       m = (methodinfo *) methodID;                                               \
+                                                                               \
+       res = _Jv_jni_Call##intern##MethodA(NULL, NULL, m, args);                  \
+                                                                               \
+       return res;                                                                \
+}
+
+JNI_CALL_STATIC_METHOD_A(Boolean, jboolean, Int)
+JNI_CALL_STATIC_METHOD_A(Byte,    jbyte,    Int)
+JNI_CALL_STATIC_METHOD_A(Char,    jchar,    Int)
+JNI_CALL_STATIC_METHOD_A(Short,   jshort,   Int)
+JNI_CALL_STATIC_METHOD_A(Int,     jint,     Int)
+JNI_CALL_STATIC_METHOD_A(Long,    jlong,    Long)
+JNI_CALL_STATIC_METHOD_A(Float,   jfloat,   Float)
+JNI_CALL_STATIC_METHOD_A(Double,  jdouble,  Double)
+
+
+jobject _Jv_JNI_CallStaticObjectMethod(JNIEnv *env, jclass clazz,
+                                                                          jmethodID methodID, ...)
+{
+       methodinfo    *m;
+       java_handle_t *o;
+       va_list        ap;
+
+       TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethod(env=%p, clazz=%p, methodID=%p, ...)", env, clazz, methodID));
+
+       m = (methodinfo *) methodID;
+
+       va_start(ap, methodID);
+       o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap);
+       va_end(ap);
+
+       return jni_NewLocalRef(env, (jobject) o);
+}
+
+
+jobject _Jv_JNI_CallStaticObjectMethodV(JNIEnv *env, jclass clazz,
+                                                                               jmethodID methodID, va_list args)
+{
+       methodinfo    *m;
+       java_handle_t *o;
+
+       TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethodV(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args));
+
+       m = (methodinfo *) methodID;
+
+       o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args);
+
+       return jni_NewLocalRef(env, (jobject) o);
+}
+
+
+jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz,
+                                                                               jmethodID methodID, const jvalue *args)
+{
+       methodinfo    *m;
+       java_handle_t *o;
+
+       TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethodA(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args));
+
+       m = (methodinfo *) methodID;
+
+       o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args);
+
+       return jni_NewLocalRef(env, (jobject) o);
+}
+
+
+void _Jv_JNI_CallStaticVoidMethod(JNIEnv *env, jclass clazz,
+                                                                 jmethodID methodID, ...)
+{
+       methodinfo *m;
+       va_list     ap;
+
+       TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethod(env=%p, clazz=%p, methodID=%p, ...)", env, clazz, methodID));
+
+       m = (methodinfo *) methodID;
+
+       va_start(ap, methodID);
+       _Jv_jni_CallVoidMethod(NULL, NULL, m, ap);
+       va_end(ap);
+}
+
+
+void _Jv_JNI_CallStaticVoidMethodV(JNIEnv *env, jclass clazz,
+                                                                  jmethodID methodID, va_list args)
+{
+       methodinfo *m;
+
+       TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethodV(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args));
+
+       m = (methodinfo *) methodID;
+
+       _Jv_jni_CallVoidMethod(NULL, NULL, m, args);
+}
+
+
+void _Jv_JNI_CallStaticVoidMethodA(JNIEnv *env, jclass clazz,
+                                                                  jmethodID methodID, const jvalue * args)
+{
+       methodinfo *m;
+
+       TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethodA(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args));
+
+       m = (methodinfo *) methodID;
+
+       _Jv_jni_CallVoidMethodA(NULL, NULL, m, args);
+}
+
+
+/* Accessing Static Fields ****************************************************/
+
+/* GetStaticFieldID ************************************************************
+
+   Returns the field ID for a static field of a class. The field is
+   specified by its name and signature. The GetStatic<type>Field and
+   SetStatic<type>Field families of accessor functions use field IDs
+   to retrieve static fields.
+
+*******************************************************************************/
+
+jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name,
+                                                                 const char *sig)
+{
+       classinfo *c;
+       fieldinfo *f;
+       utf       *uname;
+       utf       *usig;
+
+       STATISTICS(jniinvokation());
+
+       c = LLNI_classinfo_unwrap(clazz);
+
+       uname = utf_new_char((char *) name);
+       usig  = utf_new_char((char *) sig);
+
+       f = class_findfield(c, uname, usig);
+       
+       if (f == NULL)
+               exceptions_throw_nosuchfielderror(c, uname);
+
+       return (jfieldID) f;
+}
+
+
+/* GetStatic<type>Field ********************************************************
+
+   This family of accessor routines returns the value of a static
+   field of an object.
+
+*******************************************************************************/
+
+#define JNI_GET_STATIC_FIELD(name, type, field)                \
+type _Jv_JNI_GetStatic##name##Field(JNIEnv *env, jclass clazz, \
+                                                                       jfieldID fieldID)          \
+{                                                              \
+       classinfo *c;                                              \
+       fieldinfo *f;                                              \
+                                                               \
+       STATISTICS(jniinvokation());                               \
+                                                               \
+       c = LLNI_classinfo_unwrap(clazz);                          \
+       f = (fieldinfo *) fieldID;                                 \
+                                                               \
+       if (!(c->state & CLASS_INITIALIZED))                       \
+               if (!initialize_class(c))                              \
+                       return 0;                                          \
+                                                               \
+       return f->value->field;                                    \
+}
+
+JNI_GET_STATIC_FIELD(Boolean, jboolean, i)
+JNI_GET_STATIC_FIELD(Byte,    jbyte,    i)
+JNI_GET_STATIC_FIELD(Char,    jchar,    i)
+JNI_GET_STATIC_FIELD(Short,   jshort,   i)
+JNI_GET_STATIC_FIELD(Int,     jint,     i)
+JNI_GET_STATIC_FIELD(Long,    jlong,    l)
+JNI_GET_STATIC_FIELD(Float,   jfloat,   f)
+JNI_GET_STATIC_FIELD(Double,  jdouble,  d)
+
+
+jobject _Jv_JNI_GetStaticObjectField(JNIEnv *env, jclass clazz,
+                                                                        jfieldID fieldID)
+{
+       classinfo     *c;
+       fieldinfo     *f;
+       java_handle_t *h;
+
+       STATISTICS(jniinvokation());
+
+       c = LLNI_classinfo_unwrap(clazz);
+       f = (fieldinfo *) fieldID;
+
+       if (!(c->state & CLASS_INITIALIZED))
+               if (!initialize_class(c))
+                       return NULL;
+
+       h = (java_handle_t*) LLNI_WRAP(f->value->a);
+
+       return jni_NewLocalRef(env, (jobject) h);
+}
+
+
+/*  SetStatic<type>Field *******************************************************
+
+       This family of accessor routines sets the value of a static field
+       of an object.
+
+*******************************************************************************/
+
+#define JNI_SET_STATIC_FIELD(name, type, field)                \
+void _Jv_JNI_SetStatic##name##Field(JNIEnv *env, jclass clazz, \
+                                                                       jfieldID fieldID,          \
+                                                                       type value)                \
+{                                                              \
+       classinfo *c;                                              \
+       fieldinfo *f;                                              \
+                                                               \
+       STATISTICS(jniinvokation());                               \
+                                                               \
+       c = LLNI_classinfo_unwrap(clazz);                          \
+       f = (fieldinfo *) fieldID;                                 \
+                                                               \
+       if (!(c->state & CLASS_INITIALIZED))                       \
+               if (!initialize_class(c))                              \
+                       return;                                            \
+                                                               \
+       f->value->field = value;                                   \
+}
+
+JNI_SET_STATIC_FIELD(Boolean, jboolean, i)
+JNI_SET_STATIC_FIELD(Byte,    jbyte,    i)
+JNI_SET_STATIC_FIELD(Char,    jchar,    i)
+JNI_SET_STATIC_FIELD(Short,   jshort,   i)
+JNI_SET_STATIC_FIELD(Int,     jint,     i)
+JNI_SET_STATIC_FIELD(Long,    jlong,    l)
+JNI_SET_STATIC_FIELD(Float,   jfloat,   f)
+JNI_SET_STATIC_FIELD(Double,  jdouble,  d)
+
+
+void _Jv_JNI_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID,
+                                                                 jobject value)
+{
+       classinfo *c;
+       fieldinfo *f;
+
+       STATISTICS(jniinvokation());
+
+       c = LLNI_classinfo_unwrap(clazz);
+       f = (fieldinfo *) fieldID;
+
+       if (!(c->state & CLASS_INITIALIZED))
+               if (!initialize_class(c))
+                       return;
+
+       f->value->a = LLNI_UNWRAP((java_handle_t *) value);
+}
+
+
+/* String Operations **********************************************************/
+
+/* NewString *******************************************************************
+
+   Create new java.lang.String object from an array of Unicode
+   characters.
+
+*******************************************************************************/
+
+jstring jni_NewString(JNIEnv *env, const jchar *buf, jsize len)
+{
+       TRACEJNICALLS(("jni_NewString(env=%p, buf=%p, len=%d)", env, buf, len));
+       
+       java_handle_chararray_t* a = builtin_newarray_char(len);
+
+       if (a == NULL)
+               return NULL;
+
+       /* copy text */
+       for (jsize i = 0; i < len; i++)
+               LLNI_array_direct(a, i) = buf[i];
+
+       java_handle_t* h = builtin_new(class_java_lang_String);
+
+       if (h == NULL)
+               return NULL;
+
+       java_lang_String s(h, a, len, 0);
+
+       return (jstring) jni_NewLocalRef(env, (jobject) s.get_handle());
+}
+
+
+static jchar emptyStringJ[]={0,0};
+
+/* GetStringLength *************************************************************
+
+   Returns the length (the count of Unicode characters) of a Java
+   string.
+
+*******************************************************************************/
+
+jsize jni_GetStringLength(JNIEnv *env, jstring str)
+{
+       TRACEJNICALLSENTER(("jni_GetStringLength(env=%p, str=%p)", env, str));
+
+       java_lang_String s(str);
+       jsize count = s.get_count();
+
+       TRACEJNICALLSEXIT(("->%d)", count));
+
+       return count;
+}
+
+
+/* GetStringChars **************************************************************
+
+   Returns a pointer to the array of Unicode characters of the
+   string. This pointer is valid until ReleaseStringChars() is called.
+
+*******************************************************************************/
+
+const jchar* jni_GetStringChars(JNIEnv *env, jstring str, jboolean *isCopy)
+{      
+       u2      *stringbuffer;
+       int32_t  i;
+
+       TRACEJNICALLS(("jni_GetStringChars(env=%p, str=%p, isCopy=%p)", env, str, isCopy));
+
+       if (str == NULL)
+               // FIXME This is really ugly.
+               return emptyStringJ;
+
+       java_lang_String s(str);
+
+       java_handle_chararray_t* ca     = s.get_value();
+       int32_t                  count  = s.get_count();
+       int32_t                  offset = s.get_offset();
+       
+       if (ca == NULL)
+               return NULL;
+
+       /* allocate memory */
+
+       stringbuffer = MNEW(u2, count + 1);
+
+       /* copy text */
+
+       for (i = 0; i < count; i++)
+               stringbuffer[i] = LLNI_array_direct(ca, offset + i);
+       
+       /* terminate string */
+
+       stringbuffer[i] = '\0';
+
+       if (isCopy)
+               *isCopy = JNI_TRUE;
+
+       return (jchar*) stringbuffer;
+}
+
+
+/* ReleaseStringChars **********************************************************
+
+   Informs the VM that the native code no longer needs access to
+   chars. The chars argument is a pointer obtained from string using
+   GetStringChars().
+
+*******************************************************************************/
+
+void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)
+{
+       TRACEJNICALLS(("jni_ReleaseStringChars(env=%p, str=%p, chars=%p)", env, str, chars));
+
+       // FIXME
+       if (chars == emptyStringJ)
+               return;
+
+       java_lang_String s(str);
+       int32_t count = s.get_count();
+
+       MFREE(((jchar*) chars), jchar, count + 1);
+}
+
+
+/* NewStringUTF ****************************************************************
+
+   Constructs a new java.lang.String object from an array of UTF-8
+   characters.
+
+*******************************************************************************/
+
+jstring jni_NewStringUTF(JNIEnv *env, const char *bytes)
+{
+       TRACEJNICALLS(("jni_NewStringUTF(env=%p, bytes=%s)", env, bytes));
+
+       java_handle_t *h = javastring_safe_new_from_utf8(bytes);
+
+    return (jstring) jni_NewLocalRef(env, (jobject) h);
+}
+
+
+/****************** returns the utf8 length in bytes of a string *******************/
+
+jsize jni_GetStringUTFLength(JNIEnv *env, jstring string)
+{   
+       TRACEJNICALLS(("jni_GetStringUTFLength(env=%p, string=%p)", env, string));
+
+       java_lang_String s(string);
+       java_handle_chararray_t* ca     = s.get_value();
+       int32_t                  count  = s.get_count();
+
+       // FIXME GC critical section!
+       int32_t length = u2_utflength(ca->data, count);
+
+       return length;
+}
+
+
+/* GetStringUTFChars ***********************************************************
+
+   Returns a pointer to an array of UTF-8 characters of the
+   string. This array is valid until it is released by
+   ReleaseStringUTFChars().
+
+*******************************************************************************/
+
+const char *_Jv_JNI_GetStringUTFChars(JNIEnv *env, jstring string,
+                                                                         jboolean *isCopy)
+{
+       utf *u;
+
+       STATISTICS(jniinvokation());
+
+       if (string == NULL)
+               return "";
+
+       if (isCopy)
+               *isCopy = JNI_TRUE;
+       
+       u = javastring_toutf((java_handle_t *) string, false);
+
+       if (u != NULL)
+               return u->text;
+
+       return "";
+}
+
+
+/* ReleaseStringUTFChars *******************************************************
+
+   Informs the VM that the native code no longer needs access to
+   utf. The utf argument is a pointer derived from string using
+   GetStringUTFChars().
+
+*******************************************************************************/
+
+void _Jv_JNI_ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *utf)
+{
+       STATISTICS(jniinvokation());
+
+    /* XXX we don't release utf chars right now, perhaps that should be done 
+          later. Since there is always one reference the garbage collector will
+          never get them */
+}
+
+
+/* Array Operations ***********************************************************/
+
+/* GetArrayLength **************************************************************
+
+   Returns the number of elements in the array.
+
+*******************************************************************************/
+
+jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array)
+{
+       java_handle_t *a;
+       jsize          size;
+
+       TRACEJNICALLS(("_Jv_JNI_GetArrayLength(env=%p, array=%p)", env, array));
+
+       a = (java_handle_t *) array;
+
+       size = LLNI_array_size(a);
+
+       return size;
+}
+
+
+/* NewObjectArray **************************************************************
+
+   Constructs a new array holding objects in class elementClass. All
+   elements are initially set to initialElement.
+
+*******************************************************************************/
+
+jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length,
+                                                                       jclass elementClass, jobject initialElement)
+{
+       classinfo                 *c;
+       java_handle_t             *o;
+       java_handle_objectarray_t *oa;
+       s4                         i;
+
+       STATISTICS(jniinvokation());
+
+       c = LLNI_classinfo_unwrap(elementClass);
+       o = (java_handle_t *) initialElement;
+
+       if (length < 0) {
+               exceptions_throw_negativearraysizeexception();
+               return NULL;
+       }
+
+    oa = builtin_anewarray(length, c);
+
+       if (oa == NULL)
+               return NULL;
+
+       /* set all elements to initialElement */
+
+       for (i = 0; i < length; i++)
+               array_objectarray_element_set(oa, i, o);
+
+       return (jobjectArray) jni_NewLocalRef(env, (jobject) oa);
+}
+
+
+jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array,
+                                                                         jsize index)
+{
+       java_handle_objectarray_t *oa;
+       java_handle_t             *o;
+
+       STATISTICS(jniinvokation());
+
+       oa = (java_handle_objectarray_t *) array;
+
+       if (index >= LLNI_array_size(oa)) {
+               exceptions_throw_arrayindexoutofboundsexception();
+               return NULL;
+       }
+
+       o = array_objectarray_element_get(oa, index);
+
+       return jni_NewLocalRef(env, (jobject) o);
+}
+
+
+void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array,
+                                                                  jsize index, jobject val)
+{
+       java_handle_objectarray_t *oa;
+       java_handle_t             *o;
+
+       STATISTICS(jniinvokation());
+
+       oa = (java_handle_objectarray_t *) array;
+       o  = (java_handle_t *) val;
+
+       if (index >= LLNI_array_size(oa)) {
+               exceptions_throw_arrayindexoutofboundsexception();
+               return;
+       }
+
+       /* check if the class of value is a subclass of the element class
+          of the array */
+
+       if (!builtin_canstore(oa, o))
+               return;
+
+       array_objectarray_element_set(oa, index, o);
+}
+
+
+#define JNI_NEW_ARRAY(name, type, intern)                \
+type _Jv_JNI_New##name##Array(JNIEnv *env, jsize len)    \
+{                                                        \
+       java_handle_##intern##array_t *a;                    \
+                                                         \
+       STATISTICS(jniinvokation());                         \
+                                                         \
+       if (len < 0) {                                       \
+               exceptions_throw_negativearraysizeexception();   \
+               return NULL;                                     \
+       }                                                    \
+                                                         \
+       a = builtin_newarray_##intern(len);                  \
+                                                         \
+       return (type) jni_NewLocalRef(env, (jobject) a); \
+}
+
+JNI_NEW_ARRAY(Boolean, jbooleanArray, boolean)
+JNI_NEW_ARRAY(Byte,    jbyteArray,    byte)
+JNI_NEW_ARRAY(Char,    jcharArray,    char)
+JNI_NEW_ARRAY(Short,   jshortArray,   short)
+JNI_NEW_ARRAY(Int,     jintArray,     int)
+JNI_NEW_ARRAY(Long,    jlongArray,    long)
+JNI_NEW_ARRAY(Float,   jfloatArray,   float)
+JNI_NEW_ARRAY(Double,  jdoubleArray,  double)
+
+
+/* Get<PrimitiveType>ArrayElements *********************************************
+
+   A family of functions that returns the body of the primitive array.
+
+*******************************************************************************/
+
+#define JNI_GET_ARRAY_ELEMENTS(name, type, intern)                     \
+type *_Jv_JNI_Get##name##ArrayElements(JNIEnv *env, type##Array array, \
+                                                                                jboolean *isCopy)             \
+{                                                                      \
+       java_handle_##intern##array_t *a;                                  \
+                                                                       \
+       TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "ArrayElements(env=%p, array=%p, isCopy=%d)", env, array, isCopy)); \
+                                                                       \
+       a = (java_handle_##intern##array_t *) array;                       \
+                                                                       \
+       if (isCopy)                                                        \
+               *isCopy = JNI_FALSE;                                           \
+                                                                       \
+       return (type *) LLNI_array_data(a);                                \
+}
+
+JNI_GET_ARRAY_ELEMENTS(Boolean, jboolean, boolean)
+JNI_GET_ARRAY_ELEMENTS(Byte,    jbyte,    byte)
+JNI_GET_ARRAY_ELEMENTS(Char,    jchar,    char)
+JNI_GET_ARRAY_ELEMENTS(Short,   jshort,   short)
+JNI_GET_ARRAY_ELEMENTS(Int,     jint,     int)
+JNI_GET_ARRAY_ELEMENTS(Long,    jlong,    long)
+JNI_GET_ARRAY_ELEMENTS(Float,   jfloat,   float)
+JNI_GET_ARRAY_ELEMENTS(Double,  jdouble,  double)
+
+
+/* Release<PrimitiveType>ArrayElements *****************************************
+
+   A family of functions that informs the VM that the native code no
+   longer needs access to elems. The elems argument is a pointer
+   derived from array using the corresponding
+   Get<PrimitiveType>ArrayElements() function. If necessary, this
+   function copies back all changes made to elems to the original
+   array.
+
+*******************************************************************************/
+
+#define JNI_RELEASE_ARRAY_ELEMENTS(name, type, intern, intern2)            \
+void _Jv_JNI_Release##name##ArrayElements(JNIEnv *env, type##Array array,  \
+                                                                                 type *elems, jint mode)          \
+{                                                                          \
+       java_handle_##intern##array_t *a;                                      \
+                                                                           \
+       STATISTICS(jniinvokation());                                           \
+                                                                           \
+       a = (java_handle_##intern##array_t *) array;                           \
+                                                                           \
+       if (elems != (type *) LLNI_array_data(a)) {                            \
+               switch (mode) {                                                    \
+               case JNI_COMMIT:                                                   \
+                       MCOPY(LLNI_array_data(a), elems, intern2, LLNI_array_size(a)); \
+                       break;                                                         \
+               case 0:                                                            \
+                       MCOPY(LLNI_array_data(a), elems, intern2, LLNI_array_size(a)); \
+                       /* XXX TWISTI how should it be freed? */                       \
+                       break;                                                         \
+               case JNI_ABORT:                                                    \
+                       /* XXX TWISTI how should it be freed? */                       \
+                       break;                                                         \
+               }                                                                  \
+       }                                                                      \
+}
+
+JNI_RELEASE_ARRAY_ELEMENTS(Boolean, jboolean, boolean, u1)
+JNI_RELEASE_ARRAY_ELEMENTS(Byte,    jbyte,    byte,    s1)
+JNI_RELEASE_ARRAY_ELEMENTS(Char,    jchar,    char,    u2)
+JNI_RELEASE_ARRAY_ELEMENTS(Short,   jshort,   short,   s2)
+JNI_RELEASE_ARRAY_ELEMENTS(Int,     jint,     int,     s4)
+JNI_RELEASE_ARRAY_ELEMENTS(Long,    jlong,    long,    s8)
+JNI_RELEASE_ARRAY_ELEMENTS(Float,   jfloat,   float,   float)
+JNI_RELEASE_ARRAY_ELEMENTS(Double,  jdouble,  double,  double)
+
+
+/*  Get<PrimitiveType>ArrayRegion **********************************************
+
+       A family of functions that copies a region of a primitive array
+       into a buffer.
+
+*******************************************************************************/
+
+#define JNI_GET_ARRAY_REGION(name, type, intern, intern2)               \
+void _Jv_JNI_Get##name##ArrayRegion(JNIEnv *env, type##Array array,     \
+                                                                       jsize start, jsize len, type *buf)  \
+{                                                                       \
+       java_handle_##intern##array_t *a;                                   \
+                                                                        \
+       TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "ArrayRegion(env=%p, array=%p, start=%d, len=%d, buf=%p)", env, array, start, len, buf)); \
+                                                                        \
+       a = (java_handle_##intern##array_t *) array;                        \
+                                                                        \
+       if ((start < 0) || (len < 0) || (start + len > LLNI_array_size(a))) \
+               exceptions_throw_arrayindexoutofboundsexception();              \
+       else                                                                \
+               MCOPY(buf, &LLNI_array_direct(a, start), intern2, len);         \
+}
+
+JNI_GET_ARRAY_REGION(Boolean, jboolean, boolean, u1)
+JNI_GET_ARRAY_REGION(Byte,    jbyte,    byte,    s1)
+JNI_GET_ARRAY_REGION(Char,    jchar,    char,    u2)
+JNI_GET_ARRAY_REGION(Short,   jshort,   short,   s2)
+JNI_GET_ARRAY_REGION(Int,     jint,     int,     s4)
+JNI_GET_ARRAY_REGION(Long,    jlong,    long,    s8)
+JNI_GET_ARRAY_REGION(Float,   jfloat,   float,   float)
+JNI_GET_ARRAY_REGION(Double,  jdouble,  double,  double)
+
+
+/*  Set<PrimitiveType>ArrayRegion **********************************************
+
+       A family of functions that copies back a region of a primitive
+       array from a buffer.
+
+*******************************************************************************/
+
+#define JNI_SET_ARRAY_REGION(name, type, intern, intern2)                    \
+void _Jv_JNI_Set##name##ArrayRegion(JNIEnv *env, type##Array array,          \
+                                                                       jsize start, jsize len, const type *buf) \
+{                                                                            \
+       java_handle_##intern##array_t *a;                                        \
+                                                                             \
+       STATISTICS(jniinvokation());                                             \
+                                                                             \
+       a = (java_handle_##intern##array_t *) array;                             \
+                                                                             \
+       if ((start < 0) || (len < 0) || (start + len > LLNI_array_size(a)))      \
+               exceptions_throw_arrayindexoutofboundsexception();                   \
+       else                                                                     \
+               MCOPY(&LLNI_array_direct(a, start), buf, intern2, len);              \
+}
+
+JNI_SET_ARRAY_REGION(Boolean, jboolean, boolean, u1)
+JNI_SET_ARRAY_REGION(Byte,    jbyte,    byte,    s1)
+JNI_SET_ARRAY_REGION(Char,    jchar,    char,    u2)
+JNI_SET_ARRAY_REGION(Short,   jshort,   short,   s2)
+JNI_SET_ARRAY_REGION(Int,     jint,     int,     s4)
+JNI_SET_ARRAY_REGION(Long,    jlong,    long,    s8)
+JNI_SET_ARRAY_REGION(Float,   jfloat,   float,   float)
+JNI_SET_ARRAY_REGION(Double,  jdouble,  double,  double)
+
+
+/* Registering Native Methods *************************************************/
+
+/* RegisterNatives *************************************************************
+
+   Registers native methods with the class specified by the clazz
+   argument. The methods parameter specifies an array of
+   JNINativeMethod structures that contain the names, signatures, and
+   function pointers of the native methods. The nMethods parameter
+   specifies the number of native methods in the array.
+
+*******************************************************************************/
+
+jint jni_RegisterNatives(JNIEnv* env, jclass clazz, const JNINativeMethod* methods, jint nMethods)
+{
+       TRACEJNICALLS(("jni_RegisterNatives(env=%p, clazz=%p, methods=%p, nMethods=%d)", env, clazz, methods, nMethods));
+
+       classinfo* c = LLNI_classinfo_unwrap(clazz);
+
+       /* XXX: if implemented this needs a call to jvmti_NativeMethodBind
+       if (jvmti) jvmti_NativeMethodBind(method, address,  new_address_ptr);
+       */
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(c->name, methods, nMethods);
+
+    return 0;
+}
+
+
+/* UnregisterNatives ***********************************************************
+
+   Unregisters native methods of a class. The class goes back to the
+   state before it was linked or registered with its native method
+   functions.
+
+   This function should not be used in normal native code. Instead, it
+   provides special programs a way to reload and relink native
+   libraries.
+
+*******************************************************************************/
+
+jint _Jv_JNI_UnregisterNatives(JNIEnv *env, jclass clazz)
+{
+       STATISTICS(jniinvokation());
+
+       /* XXX TWISTI hmm, maybe we should not support that (like kaffe) */
+
+    log_text("JNI-Call: UnregisterNatives: IMPLEMENT ME!!!");
+
+    return 0;
+}
+
+
+/* Monitor Operations *********************************************************/
+
+/* MonitorEnter ****************************************************************
+
+   Enters the monitor associated with the underlying Java object
+   referred to by obj.
+
+*******************************************************************************/
+
+jint _Jv_JNI_MonitorEnter(JNIEnv *env, jobject obj)
+{
+       STATISTICS(jniinvokation());
+
+       if (obj == NULL) {
+               exceptions_throw_nullpointerexception();
+               return JNI_ERR;
+       }
+
+       LOCK_MONITOR_ENTER(obj);
+
+       return JNI_OK;
+}
+
+
+/* MonitorExit *****************************************************************
+
+   The current thread must be the owner of the monitor associated with
+   the underlying Java object referred to by obj. The thread
+   decrements the counter indicating the number of times it has
+   entered this monitor. If the value of the counter becomes zero, the
+   current thread releases the monitor.
+
+*******************************************************************************/
+
+jint _Jv_JNI_MonitorExit(JNIEnv *env, jobject obj)
+{
+       STATISTICS(jniinvokation());
+
+       if (obj == NULL) {
+               exceptions_throw_nullpointerexception();
+               return JNI_ERR;
+       }
+
+       LOCK_MONITOR_EXIT(obj);
+
+       return JNI_OK;
+}
+
+
+/* JavaVM Interface ***********************************************************/
+
+/* GetJavaVM *******************************************************************
+
+   Returns the Java VM interface (used in the Invocation API)
+   associated with the current thread. The result is placed at the
+   location pointed to by the second argument, vm.
+
+*******************************************************************************/
+
+jint _Jv_JNI_GetJavaVM(JNIEnv *env, JavaVM **javavm)
+{
+       STATISTICS(jniinvokation());
+
+    *javavm = VM::get_current()->get_javavm();
+
+       return 0;
+}
+
+
+/* GetStringRegion *************************************************************
+
+   Copies len number of Unicode characters beginning at offset start
+   to the given buffer buf.
+
+   Throws StringIndexOutOfBoundsException on index overflow.
+
+*******************************************************************************/
+
+void jni_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len, jchar *buf)
+{
+       java_lang_String s(str);
+       java_handle_chararray_t* ca    = s.get_value();
+       int32_t                  count = s.get_count();
+
+       if ((start < 0) || (len < 0) || (start > count) || (start + len > count)) {
+               exceptions_throw_stringindexoutofboundsexception();
+               return;
+       }
+
+       MCOPY(buf, &LLNI_array_direct(ca, start), u2, len);
+}
+
+
+/* GetStringUTFRegion **********************************************************
+
+    Translates len number of Unicode characters beginning at offset
+    start into UTF-8 format and place the result in the given buffer
+    buf.
+
+    Throws StringIndexOutOfBoundsException on index overflow. 
+
+*******************************************************************************/
+
+void jni_GetStringUTFRegion(JNIEnv* env, jstring str, jsize start, jsize len, char *buf)
+{
+       TRACEJNICALLS(("jni_GetStringUTFRegion(env=%p, str=%p, start=%d, len=%d, buf=%p)", env, str, start, len, buf));
+
+       java_lang_String s(str);
+       java_handle_chararray_t* ca     = s.get_value();
+       int32_t                  count  = s.get_count();
+       int32_t                  offset = s.get_offset();
+
+       if ((start < 0) || (len < 0) || (start > count) || (start + len > count)) {
+               exceptions_throw_stringindexoutofboundsexception();
+               return;
+       }
+
+       int32_t i;
+
+       for (i = 0; i < len; i++)
+               buf[i] = LLNI_array_direct(ca, offset + start + i);
+
+       buf[i] = '\0';
+}
+
+
+/* GetPrimitiveArrayCritical ***************************************************
+
+   Obtain a direct pointer to array elements.
+
+   ATTENTION: Critical section keeps open when this function returns!
+   See ReleasePrimitiveArrayCritical.
+
+*******************************************************************************/
+
+void* jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy)
+{
+       java_handle_t*   h;
+       java_array_t*    a;
+       arraydescriptor* ad;
+       void*            data;
+
+       TRACEJNICALLS(("jni_GetPrimitiveArrayCritical(env=%p, array=%p, isCopy=%d)", env, array, isCopy));
+
+       if (isCopy != NULL) {
+               *isCopy = JNI_FALSE;
+       }
+
+       LLNI_CRITICAL_START;
+
+       h  = (java_handle_t*) array;
+       a  = (java_array_t*) LLNI_UNWRAP(h);
+       ad = a->objheader.vftbl->arraydesc;
+
+       /* Sanity check. */
+
+       assert(ad != NULL);
+
+       data = (void*) (((intptr_t) a) + ad->dataoffset);
+
+       return data;
+}
+
+
+/* ReleasePrimitiveArrayCritical ***********************************************
+
+   No specific documentation.
+
+   ATTENTION: This function closes the critical section opened in
+   GetPrimitiveArrayCritical!
+
+*******************************************************************************/
+
+void jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode)
+{
+       TRACEJNICALLS(("jni_ReleasePrimitiveArrayCritical(env=%p, array=%p, carray=%p, mode=%d)", env, array, carray, mode));
+
+       LLNI_CRITICAL_END;
+}
+
+
+/* GetStringCritical ***********************************************************
+
+   The semantics of these two functions are similar to the existing
+   Get/ReleaseStringChars functions.
+
+*******************************************************************************/
+
+const jchar *_Jv_JNI_GetStringCritical(JNIEnv *env, jstring string,
+                                                                          jboolean *isCopy)
+{
+       STATISTICS(jniinvokation());
+
+       return jni_GetStringChars(env, string, isCopy);
+}
+
+
+void _Jv_JNI_ReleaseStringCritical(JNIEnv *env, jstring string,
+                                                                  const jchar *cstring)
+{
+       STATISTICS(jniinvokation());
+
+       _Jv_JNI_ReleaseStringChars(env, string, cstring);
+}
+
+
+jweak _Jv_JNI_NewWeakGlobalRef(JNIEnv* env, jobject obj)
+{
+       TRACEJNICALLS(("_Jv_JNI_NewWeakGlobalRef(env=%p, obj=%p): IMPLEMENT ME!", env, obj));
+
+       return (jweak) obj;
+}
+
+
+void _Jv_JNI_DeleteWeakGlobalRef(JNIEnv* env, jweak ref)
+{
+       TRACEJNICALLS(("_Jv_JNI_DeleteWeakGlobalRef(env=%p, ref=%p): IMPLEMENT ME", env, ref));
+}
+
+
+/* NewGlobalRef ****************************************************************
+
+   Creates a new global reference to the object referred to by the obj
+   argument.
+
+*******************************************************************************/
+
+jobject jni_NewGlobalRef(JNIEnv* env, jobject obj)
+{
+       hashtable_global_ref_entry *gre;
+       u4   key;                           /* hashkey                            */
+       u4   slot;                          /* slot in hashtable                  */
+       java_handle_t *o;
+
+       TRACEJNICALLS(("jni_NewGlobalRef(env=%p, obj=%p)", env, obj));
+
+       o = (java_handle_t *) obj;
+
+       hashtable_global_ref->mutex->lock();
+
+       LLNI_CRITICAL_START;
+
+       /* normally addresses are aligned to 4, 8 or 16 bytes */
+
+       key  = heap_hashcode(LLNI_DIRECT(o)) >> 4; /* align to 16-byte boundaries */
+       slot = key & (hashtable_global_ref->size - 1);
+       gre  = (hashtable_global_ref_entry*) hashtable_global_ref->ptr[slot];
+       
+       /* search external hash chain for the entry */
+
+       while (gre) {
+               if (gre->o == LLNI_DIRECT(o)) {
+                       /* global object found, increment the reference */
+
+                       gre->refs++;
+
+                       break;
+               }
+
+               gre = gre->hashlink;                /* next element in external chain */
+       }
+
+       LLNI_CRITICAL_END;
+
+       /* global ref not found, create a new one */
+
+       if (gre == NULL) {
+               gre = (hashtable_global_ref_entry*) heap_alloc_uncollectable(sizeof(hashtable_global_ref_entry));
+
+#if defined(ENABLE_GC_CACAO)
+               /* register global ref with the GC */
+
+               gc_reference_register(&(gre->o), GC_REFTYPE_JNI_GLOBALREF);
+#endif
+
+               LLNI_CRITICAL_START;
+
+               gre->o    = LLNI_DIRECT(o);
+               gre->refs = 1;
+
+               LLNI_CRITICAL_END;
+
+               /* insert entry into hashtable */
+
+               gre->hashlink = (hashtable_global_ref_entry*) hashtable_global_ref->ptr[slot];
+
+               hashtable_global_ref->ptr[slot] = gre;
+
+               /* update number of hashtable-entries */
+
+               hashtable_global_ref->entries++;
+       }
+
+       hashtable_global_ref->mutex->unlock();
+
+#if defined(ENABLE_HANDLES)
+       return gre;
+#else
+       return obj;
+#endif
+}
+
+
+/* DeleteGlobalRef *************************************************************
+
+   Deletes the global reference pointed to by globalRef.
+
+*******************************************************************************/
+
+void jni_DeleteGlobalRef(JNIEnv* env, jobject globalRef)
+{
+       hashtable_global_ref_entry *gre;
+       hashtable_global_ref_entry *prevgre;
+       u4   key;                           /* hashkey                            */
+       u4   slot;                          /* slot in hashtable                  */
+       java_handle_t              *o;
+
+       TRACEJNICALLS(("jni_DeleteGlobalRef(env=%p, globalRef=%p)", env, globalRef));
+
+       o = (java_handle_t *) globalRef;
+
+       hashtable_global_ref->mutex->lock();
+
+       LLNI_CRITICAL_START;
+
+       /* normally addresses are aligned to 4, 8 or 16 bytes */
+
+       key  = heap_hashcode(LLNI_DIRECT(o)) >> 4; /* align to 16-byte boundaries */
+       slot = key & (hashtable_global_ref->size - 1);
+       gre  = (hashtable_global_ref_entry*) hashtable_global_ref->ptr[slot];
+
+       /* initialize prevgre */
+
+       prevgre = NULL;
+
+       /* search external hash chain for the entry */
+
+       while (gre) {
+               if (gre->o == LLNI_DIRECT(o)) {
+                       /* global object found, decrement the reference count */
+
+                       gre->refs--;
+
+                       /* if reference count is 0, remove the entry */
+
+                       if (gre->refs == 0) {
+                               /* special handling if it's the first in the chain */
+
+                               if (prevgre == NULL)
+                                       hashtable_global_ref->ptr[slot] = gre->hashlink;
+                               else
+                                       prevgre->hashlink = gre->hashlink;
+
+#if defined(ENABLE_GC_CACAO)
+                               /* unregister global ref with the GC */
+
+                               gc_reference_unregister(&(gre->o));
+#endif
+
+                               heap_free(gre);
+                       }
+
+                       LLNI_CRITICAL_END;
+
+                       hashtable_global_ref->mutex->unlock();
+
+                       return;
+               }
+
+               prevgre = gre;                    /* save current pointer for removal */
+               gre     = gre->hashlink;            /* next element in external chain */
+       }
+
+       log_println("jni_DeleteGlobalRef: Global reference not found.");
+
+       LLNI_CRITICAL_END;
+
+       hashtable_global_ref->mutex->unlock();
+}
+
+
+/* ExceptionCheck **************************************************************
+
+   Returns JNI_TRUE when there is a pending exception; otherwise,
+   returns JNI_FALSE.
+
+*******************************************************************************/
+
+jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env)
+{
+       java_handle_t *o;
+
+       STATISTICS(jniinvokation());
+
+       o = exceptions_get_exception();
+
+       return (o != NULL) ? JNI_TRUE : JNI_FALSE;
+}
+
+
+/* New JNI 1.4 functions ******************************************************/
+
+/* NewDirectByteBuffer *********************************************************
+
+   Allocates and returns a direct java.nio.ByteBuffer referring to the
+   block of memory starting at the memory address address and
+   extending capacity bytes.
+
+*******************************************************************************/
+
+jobject jni_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
+{
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       TRACEJNICALLSENTER(("jni_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld)", env, address, capacity));
+
+       // Allocate a gnu.classpath.Pointer{32,64} object.
+
+# if SIZEOF_VOID_P == 8
+       java_handle_t* h = builtin_new(class_gnu_classpath_Pointer64);
+# else
+       java_handle_t* h = builtin_new(class_gnu_classpath_Pointer32);
+# endif
+
+       if (h == NULL)
+               return NULL;
+
+       gnu_classpath_Pointer p(h, address);
+
+       // Create a java.nio.DirectByteBufferImpl$ReadWrite object.
+
+       java_handle_t* nbuf =
+               (java_handle_t*) jni_NewObject(env, (jclass) class_java_nio_DirectByteBufferImpl_ReadWrite,
+                                                                          (jmethodID) dbbirw_init, NULL, p.get_handle(),
+                                                                          (jint) capacity, (jint) capacity, (jint) 0);
+
+       // Add a local reference and return the value.
+
+       TRACEJNICALLSEXIT(("->%p", nbuf));
+
+       return jni_NewLocalRef(env, (jobject) nbuf);
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       jobject o;
+       int64_t addr;
+       int32_t cap;
+
+       TRACEJNICALLSENTER(("jni_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld)", env, address, capacity));
+
+       /* Be paranoid about address sign-extension. */
+
+       addr = (int64_t) ((uintptr_t) address);
+       cap  = (int32_t) capacity;
+
+       o = jni_NewObject(env, (jclass) class_java_nio_DirectByteBuffer,
+                                         (jmethodID) dbb_init, addr, cap);
+
+       /* Add local reference and return the value. */
+
+       TRACEJNICALLSEXIT(("->%p", o));
+
+       return jni_NewLocalRef(env, o);
+
+# else
+#  error unknown classpath configuration
+# endif
+
+#else
+       vm_abort("jni_NewDirectByteBuffer: Not implemented in this configuration.");
+
+       /* keep compiler happy */
+
+       return NULL;
+#endif
+}
+
+
+/* GetDirectBufferAddress ******************************************************
+
+   Fetches and returns the starting address of the memory region
+   referenced by the given direct java.nio.Buffer.
+
+*******************************************************************************/
+
+void* jni_GetDirectBufferAddress(JNIEnv *env, jobject buf)
+{
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       TRACEJNICALLSENTER(("jni_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
+
+       /* Prevent compiler warning. */
+
+       java_handle_t* h = (java_handle_t *) buf;
+
+       if ((h != NULL) && !builtin_instanceof(h, class_java_nio_Buffer))
+               return NULL;
+
+       java_nio_DirectByteBufferImpl dbb(buf);
+       java_handle_t* address = dbb.get_address();
+
+       if (address == NULL) {
+               TRACEJNICALLSEXIT(("->%p", NULL));
+               return NULL;
+       }
+
+       gnu_classpath_Pointer p(address);
+       void* data = p.get_data();
+
+       TRACEJNICALLSEXIT(("->%p", data));
+
+       return data;
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       TRACEJNICALLS(("jni_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
+
+       java_nio_Buffer jnb(buf);
+
+       if (jnb.is_non_null() && !builtin_instanceof(jnb.get_handle(), class_sun_nio_ch_DirectBuffer))
+               return NULL;
+
+       void* address = jnb.get_address();
+
+       return address;
+
+# else
+#  error unknown classpath configuration
+# endif
+
+#else
+
+       vm_abort("jni_GetDirectBufferAddress: Not implemented in this configuration.");
+
+       // Keep compiler happy.
+       return NULL;
+
+#endif
+}
+
+
+/* GetDirectBufferCapacity *****************************************************
+
+   Fetches and returns the capacity in bytes of the memory region
+   referenced by the given direct java.nio.Buffer.
+
+*******************************************************************************/
+
+jlong jni_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
+{
+#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       TRACEJNICALLS(("jni_GetDirectBufferCapacity(env=%p, buf=%p)", env, buf));
+
+       java_handle_t* h = (java_handle_t *) buf;
+
+       if (!builtin_instanceof(h, class_java_nio_DirectByteBufferImpl))
+               return -1;
+
+       java_nio_Buffer b(h);
+       jlong capacity = b.get_cap();
+
+       return capacity;
+#else
+       vm_abort("jni_GetDirectBufferCapacity: not implemented in this configuration");
+
+       // Keep compiler happy.
+
+       return 0;
+#endif
+}
+
+
+/* GetObjectRefType ************************************************************
+
+   Returns the type of the object referred to by the obj argument. The
+   argument obj can either be a local, global or weak global
+   reference.
+
+*******************************************************************************/
+
+jobjectRefType jni_GetObjectRefType(JNIEnv *env, jobject obj)
+{
+       log_println("jni_GetObjectRefType: IMPLEMENT ME!");
+
+       return (jobjectRefType) NULL;
+}
+
+
+/* DestroyJavaVM ***************************************************************
+
+   Unloads a Java VM and reclaims its resources. Only the main thread
+   can unload the VM. The system waits until the main thread is only
+   remaining user thread before it destroys the VM.
+
+*******************************************************************************/
+
+jint _Jv_JNI_DestroyJavaVM(JavaVM *javavm)
+{
+       int status;
+
+       TRACEJNICALLS(("_Jv_JNI_DestroyJavaVM(javavm=%p)", javavm));
+
+       if (VM::get_current()->is_created() == false)
+               return JNI_ERR;
+
+    status = vm_destroy(javavm);
+
+       return status;
+}
+
+
+/* AttachCurrentThread *********************************************************
+
+   Attaches the current thread to a Java VM. Returns a JNI interface
+   pointer in the JNIEnv argument.
+
+   Trying to attach a thread that is already attached is a no-op.
+
+   A native thread cannot be attached simultaneously to two Java VMs.
+
+   When a thread is attached to the VM, the context class loader is
+   the bootstrap loader.
+
+*******************************************************************************/
+
+static int jni_attach_current_thread(void **p_env, void *thr_args, bool isdaemon)
+{
+#if defined(ENABLE_THREADS)
+       JavaVMAttachArgs *vm_aargs;
+       bool              result;
+
+    /* If the current thread has already been attached, this operation
+          is a no-op. */
+
+       result = thread_current_is_attached();
+
+       if (result == true) {
+               *p_env = VM::get_current()->get_jnienv();
+               return JNI_OK;
+       }
+
+       vm_aargs = (JavaVMAttachArgs *) thr_args;
+
+       if (vm_aargs != NULL) {
+               if ((vm_aargs->version != JNI_VERSION_1_2) &&
+                       (vm_aargs->version != JNI_VERSION_1_4))
+                       return JNI_EVERSION;
+       }
+
+       if (!thread_attach_current_external_thread(vm_aargs, false))
+               return JNI_ERR;
+
+       if (!localref_table_init())
+               return JNI_ERR;
+#endif
+
+       *p_env = VM::get_current()->get_jnienv();
+
+       return JNI_OK;
+}
+
+
+jint jni_AttachCurrentThread(JavaVM *javavm, void **p_env, void *thr_args)
+{
+       int result;
+
+       TRACEJNICALLS(("jni_AttachCurrentThread(javavm=%p, p_env=%p, thr_args=%p)", javavm, p_env, thr_args));
+
+       if (VM::get_current()->is_created() == false)
+               return JNI_ERR;
+
+       result = jni_attach_current_thread(p_env, thr_args, false);
+
+       return result;
+}
+
+
+/* DetachCurrentThread *********************************************************
+
+   Detaches the current thread from a Java VM. All Java monitors held
+   by this thread are released. All Java threads waiting for this
+   thread to die are notified.
+
+   In JDK 1.1, the main thread cannot be detached from the VM. It must
+   call DestroyJavaVM to unload the entire VM.
+
+   In the JDK, the main thread can be detached from the VM.
+
+   The main thread, which is the thread that created the Java VM,
+   cannot be detached from the VM. Instead, the main thread must call
+   JNI_DestroyJavaVM() to unload the entire VM.
+
+*******************************************************************************/
+
+jint jni_DetachCurrentThread(JavaVM *vm)
+{
+#if defined(ENABLE_THREADS)
+       bool result;
+
+       TRACEJNICALLS(("jni_DetachCurrentThread(vm=%p)", vm));
+
+    /* If the current thread has already been detached, this operation
+          is a no-op. */
+
+       result = thread_current_is_attached();
+
+       if (result == false)
+               return true;
+
+       /* We need to pop all frames before we can destroy the table. */
+
+       localref_frame_pop_all();
+
+       if (!localref_table_destroy())
+               return JNI_ERR;
+
+       if (!thread_detach_current_external_thread())
+               return JNI_ERR;
+#endif
+
+       return JNI_OK;
+}
+
+
+/* GetEnv **********************************************************************
+
+   If the current thread is not attached to the VM, sets *env to NULL,
+   and returns JNI_EDETACHED. If the specified version is not
+   supported, sets *env to NULL, and returns JNI_EVERSION. Otherwise,
+   sets *env to the appropriate interface, and returns JNI_OK.
+
+*******************************************************************************/
+
+jint jni_GetEnv(JavaVM *javavm, void **env, jint version)
+{
+       TRACEJNICALLS(("jni_GetEnv(javavm=%p, env=%p, version=%d)", javavm, env, version));
+
+       if (VM::get_current()->is_created() == false) {
+               *env = NULL;
+               return JNI_EDETACHED;
+       }
+
+#if defined(ENABLE_THREADS)
+       if (thread_get_current() == NULL) {
+               *env = NULL;
+
+               return JNI_EDETACHED;
+       }
+#endif
+
+       /* Check the JNI version. */
+
+       if (jni_version_check(version) == true) {
+               *env = VM::get_current()->get_jnienv();
+               return JNI_OK;
+       }
+
+#if defined(ENABLE_JVMTI)
+       if ((version & JVMTI_VERSION_MASK_INTERFACE_TYPE) 
+               == JVMTI_VERSION_INTERFACE_JVMTI) {
+
+               *env = (void *) jvmti_new_environment();
+
+               if (env != NULL)
+                       return JNI_OK;
+       }
+#endif
+       
+       *env = NULL;
+
+       return JNI_EVERSION;
+}
+
+
+/* AttachCurrentThreadAsDaemon *************************************************
+
+   Same semantics as AttachCurrentThread, but the newly-created
+   java.lang.Thread instance is a daemon.
+
+   If the thread has already been attached via either
+   AttachCurrentThread or AttachCurrentThreadAsDaemon, this routine
+   simply sets the value pointed to by penv to the JNIEnv of the
+   current thread. In this case neither AttachCurrentThread nor this
+   routine have any effect on the daemon status of the thread.
+
+*******************************************************************************/
+
+jint jni_AttachCurrentThreadAsDaemon(JavaVM *javavm, void **penv, void *args)
+{
+       int result;
+
+       TRACEJNICALLS(("jni_AttachCurrentThreadAsDaemon(javavm=%p, penv=%p, args=%p)", javavm, penv, args));
+
+       if (VM::get_current()->is_created() == false)
+               return JNI_ERR;
+
+       result = jni_attach_current_thread(penv, args, true);
+
+       return result;
+}
+
+
+/* JNI invocation table *******************************************************/
+
+const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface = {
+       NULL,
+       NULL,
+       NULL,
+
+       _Jv_JNI_DestroyJavaVM,
+       jni_AttachCurrentThread,
+       jni_DetachCurrentThread,
+       jni_GetEnv,
+       jni_AttachCurrentThreadAsDaemon
+};
+
+
+/* JNI function table *********************************************************/
+
+struct JNINativeInterface_ _Jv_JNINativeInterface = {
+       NULL,
+       NULL,
+       NULL,
+       NULL,    
+       _Jv_JNI_GetVersion,
+
+       jni_DefineClass,
+       jni_FindClass,
+       jni_FromReflectedMethod,
+       jni_FromReflectedField,
+       jni_ToReflectedMethod,
+       jni_GetSuperclass,
+       _Jv_JNI_IsAssignableFrom,
+       _Jv_JNI_ToReflectedField,
+
+       _Jv_JNI_Throw,
+       _Jv_JNI_ThrowNew,
+       _Jv_JNI_ExceptionOccurred,
+       jni_ExceptionDescribe,
+       jni_ExceptionClear,
+       _Jv_JNI_FatalError,
+       jni_PushLocalFrame,
+       jni_PopLocalFrame,
+
+       jni_NewGlobalRef,
+       jni_DeleteGlobalRef,
+       jni_DeleteLocalRef,
+       _Jv_JNI_IsSameObject,
+       jni_NewLocalRef,
+       jni_EnsureLocalCapacity,
+
+       _Jv_JNI_AllocObject,
+       jni_NewObject,
+       _Jv_JNI_NewObjectV,
+       _Jv_JNI_NewObjectA,
+
+       jni_GetObjectClass,
+       _Jv_JNI_IsInstanceOf,
+
+       _Jv_JNI_GetMethodID,
+
+       _Jv_JNI_CallObjectMethod,
+       _Jv_JNI_CallObjectMethodV,
+       _Jv_JNI_CallObjectMethodA,
+       _Jv_JNI_CallBooleanMethod,
+       _Jv_JNI_CallBooleanMethodV,
+       _Jv_JNI_CallBooleanMethodA,
+       _Jv_JNI_CallByteMethod,
+       _Jv_JNI_CallByteMethodV,
+       _Jv_JNI_CallByteMethodA,
+       _Jv_JNI_CallCharMethod,
+       _Jv_JNI_CallCharMethodV,
+       _Jv_JNI_CallCharMethodA,
+       _Jv_JNI_CallShortMethod,
+       _Jv_JNI_CallShortMethodV,
+       _Jv_JNI_CallShortMethodA,
+       _Jv_JNI_CallIntMethod,
+       _Jv_JNI_CallIntMethodV,
+       _Jv_JNI_CallIntMethodA,
+       _Jv_JNI_CallLongMethod,
+       _Jv_JNI_CallLongMethodV,
+       _Jv_JNI_CallLongMethodA,
+       _Jv_JNI_CallFloatMethod,
+       _Jv_JNI_CallFloatMethodV,
+       _Jv_JNI_CallFloatMethodA,
+       _Jv_JNI_CallDoubleMethod,
+       _Jv_JNI_CallDoubleMethodV,
+       _Jv_JNI_CallDoubleMethodA,
+       _Jv_JNI_CallVoidMethod,
+       _Jv_JNI_CallVoidMethodV,
+       _Jv_JNI_CallVoidMethodA,
+
+       _Jv_JNI_CallNonvirtualObjectMethod,
+       _Jv_JNI_CallNonvirtualObjectMethodV,
+       _Jv_JNI_CallNonvirtualObjectMethodA,
+       _Jv_JNI_CallNonvirtualBooleanMethod,
+       _Jv_JNI_CallNonvirtualBooleanMethodV,
+       _Jv_JNI_CallNonvirtualBooleanMethodA,
+       _Jv_JNI_CallNonvirtualByteMethod,
+       _Jv_JNI_CallNonvirtualByteMethodV,
+       _Jv_JNI_CallNonvirtualByteMethodA,
+       _Jv_JNI_CallNonvirtualCharMethod,
+       _Jv_JNI_CallNonvirtualCharMethodV,
+       _Jv_JNI_CallNonvirtualCharMethodA,
+       _Jv_JNI_CallNonvirtualShortMethod,
+       _Jv_JNI_CallNonvirtualShortMethodV,
+       _Jv_JNI_CallNonvirtualShortMethodA,
+       _Jv_JNI_CallNonvirtualIntMethod,
+       _Jv_JNI_CallNonvirtualIntMethodV,
+       _Jv_JNI_CallNonvirtualIntMethodA,
+       _Jv_JNI_CallNonvirtualLongMethod,
+       _Jv_JNI_CallNonvirtualLongMethodV,
+       _Jv_JNI_CallNonvirtualLongMethodA,
+       _Jv_JNI_CallNonvirtualFloatMethod,
+       _Jv_JNI_CallNonvirtualFloatMethodV,
+       _Jv_JNI_CallNonvirtualFloatMethodA,
+       _Jv_JNI_CallNonvirtualDoubleMethod,
+       _Jv_JNI_CallNonvirtualDoubleMethodV,
+       _Jv_JNI_CallNonvirtualDoubleMethodA,
+       _Jv_JNI_CallNonvirtualVoidMethod,
+       _Jv_JNI_CallNonvirtualVoidMethodV,
+       _Jv_JNI_CallNonvirtualVoidMethodA,
+
+       _Jv_JNI_GetFieldID,
+
+       _Jv_JNI_GetObjectField,
+       _Jv_JNI_GetBooleanField,
+       _Jv_JNI_GetByteField,
+       _Jv_JNI_GetCharField,
+       _Jv_JNI_GetShortField,
+       _Jv_JNI_GetIntField,
+       _Jv_JNI_GetLongField,
+       _Jv_JNI_GetFloatField,
+       _Jv_JNI_GetDoubleField,
+       _Jv_JNI_SetObjectField,
+       _Jv_JNI_SetBooleanField,
+       _Jv_JNI_SetByteField,
+       _Jv_JNI_SetCharField,
+       _Jv_JNI_SetShortField,
+       _Jv_JNI_SetIntField,
+       _Jv_JNI_SetLongField,
+       _Jv_JNI_SetFloatField,
+       _Jv_JNI_SetDoubleField,
+
+       _Jv_JNI_GetStaticMethodID,
+
+       _Jv_JNI_CallStaticObjectMethod,
+       _Jv_JNI_CallStaticObjectMethodV,
+       _Jv_JNI_CallStaticObjectMethodA,
+       _Jv_JNI_CallStaticBooleanMethod,
+       _Jv_JNI_CallStaticBooleanMethodV,
+       _Jv_JNI_CallStaticBooleanMethodA,
+       _Jv_JNI_CallStaticByteMethod,
+       _Jv_JNI_CallStaticByteMethodV,
+       _Jv_JNI_CallStaticByteMethodA,
+       _Jv_JNI_CallStaticCharMethod,
+       _Jv_JNI_CallStaticCharMethodV,
+       _Jv_JNI_CallStaticCharMethodA,
+       _Jv_JNI_CallStaticShortMethod,
+       _Jv_JNI_CallStaticShortMethodV,
+       _Jv_JNI_CallStaticShortMethodA,
+       _Jv_JNI_CallStaticIntMethod,
+       _Jv_JNI_CallStaticIntMethodV,
+       _Jv_JNI_CallStaticIntMethodA,
+       _Jv_JNI_CallStaticLongMethod,
+       _Jv_JNI_CallStaticLongMethodV,
+       _Jv_JNI_CallStaticLongMethodA,
+       _Jv_JNI_CallStaticFloatMethod,
+       _Jv_JNI_CallStaticFloatMethodV,
+       _Jv_JNI_CallStaticFloatMethodA,
+       _Jv_JNI_CallStaticDoubleMethod,
+       _Jv_JNI_CallStaticDoubleMethodV,
+       _Jv_JNI_CallStaticDoubleMethodA,
+       _Jv_JNI_CallStaticVoidMethod,
+       _Jv_JNI_CallStaticVoidMethodV,
+       _Jv_JNI_CallStaticVoidMethodA,
+
+       _Jv_JNI_GetStaticFieldID,
+
+       _Jv_JNI_GetStaticObjectField,
+       _Jv_JNI_GetStaticBooleanField,
+       _Jv_JNI_GetStaticByteField,
+       _Jv_JNI_GetStaticCharField,
+       _Jv_JNI_GetStaticShortField,
+       _Jv_JNI_GetStaticIntField,
+       _Jv_JNI_GetStaticLongField,
+       _Jv_JNI_GetStaticFloatField,
+       _Jv_JNI_GetStaticDoubleField,
+       _Jv_JNI_SetStaticObjectField,
+       _Jv_JNI_SetStaticBooleanField,
+       _Jv_JNI_SetStaticByteField,
+       _Jv_JNI_SetStaticCharField,
+       _Jv_JNI_SetStaticShortField,
+       _Jv_JNI_SetStaticIntField,
+       _Jv_JNI_SetStaticLongField,
+       _Jv_JNI_SetStaticFloatField,
+       _Jv_JNI_SetStaticDoubleField,
+
+       jni_NewString,
+       jni_GetStringLength,
+       jni_GetStringChars,
+       _Jv_JNI_ReleaseStringChars,
+
+       jni_NewStringUTF,
+       jni_GetStringUTFLength,
+       _Jv_JNI_GetStringUTFChars,
+       _Jv_JNI_ReleaseStringUTFChars,
+
+       _Jv_JNI_GetArrayLength,
+
+       _Jv_JNI_NewObjectArray,
+       _Jv_JNI_GetObjectArrayElement,
+       _Jv_JNI_SetObjectArrayElement,
+
+       _Jv_JNI_NewBooleanArray,
+       _Jv_JNI_NewByteArray,
+       _Jv_JNI_NewCharArray,
+       _Jv_JNI_NewShortArray,
+       _Jv_JNI_NewIntArray,
+       _Jv_JNI_NewLongArray,
+       _Jv_JNI_NewFloatArray,
+       _Jv_JNI_NewDoubleArray,
+
+       _Jv_JNI_GetBooleanArrayElements,
+       _Jv_JNI_GetByteArrayElements,
+       _Jv_JNI_GetCharArrayElements,
+       _Jv_JNI_GetShortArrayElements,
+       _Jv_JNI_GetIntArrayElements,
+       _Jv_JNI_GetLongArrayElements,
+       _Jv_JNI_GetFloatArrayElements,
+       _Jv_JNI_GetDoubleArrayElements,
+
+       _Jv_JNI_ReleaseBooleanArrayElements,
+       _Jv_JNI_ReleaseByteArrayElements,
+       _Jv_JNI_ReleaseCharArrayElements,
+       _Jv_JNI_ReleaseShortArrayElements,
+       _Jv_JNI_ReleaseIntArrayElements,
+       _Jv_JNI_ReleaseLongArrayElements,
+       _Jv_JNI_ReleaseFloatArrayElements,
+       _Jv_JNI_ReleaseDoubleArrayElements,
+
+       _Jv_JNI_GetBooleanArrayRegion,
+       _Jv_JNI_GetByteArrayRegion,
+       _Jv_JNI_GetCharArrayRegion,
+       _Jv_JNI_GetShortArrayRegion,
+       _Jv_JNI_GetIntArrayRegion,
+       _Jv_JNI_GetLongArrayRegion,
+       _Jv_JNI_GetFloatArrayRegion,
+       _Jv_JNI_GetDoubleArrayRegion,
+       _Jv_JNI_SetBooleanArrayRegion,
+       _Jv_JNI_SetByteArrayRegion,
+       _Jv_JNI_SetCharArrayRegion,
+       _Jv_JNI_SetShortArrayRegion,
+       _Jv_JNI_SetIntArrayRegion,
+       _Jv_JNI_SetLongArrayRegion,
+       _Jv_JNI_SetFloatArrayRegion,
+       _Jv_JNI_SetDoubleArrayRegion,
+
+       jni_RegisterNatives,
+       _Jv_JNI_UnregisterNatives,
+
+       _Jv_JNI_MonitorEnter,
+       _Jv_JNI_MonitorExit,
+
+       _Jv_JNI_GetJavaVM,
+
+       /* New JNI 1.2 functions. */
+
+       jni_GetStringRegion,
+       jni_GetStringUTFRegion,
+
+       jni_GetPrimitiveArrayCritical,
+       jni_ReleasePrimitiveArrayCritical,
+
+       _Jv_JNI_GetStringCritical,
+       _Jv_JNI_ReleaseStringCritical,
+
+       _Jv_JNI_NewWeakGlobalRef,
+       _Jv_JNI_DeleteWeakGlobalRef,
+
+       _Jv_JNI_ExceptionCheck,
+
+       /* New JNI 1.4 functions. */
+
+       jni_NewDirectByteBuffer,
+       jni_GetDirectBufferAddress,
+       jni_GetDirectBufferCapacity,
+
+       /* New JNI 1.6 functions. */
+
+       jni_GetObjectRefType
+};
+
+
+/* Invocation API Functions ***************************************************/
+
+/* JNI_GetDefaultJavaVMInitArgs ************************************************
+
+   Returns a default configuration for the Java VM.
+
+*******************************************************************************/
+
+jint JNI_GetDefaultJavaVMInitArgs(void *vm_args)
+{
+       JavaVMInitArgs *_vm_args;
+
+       _vm_args = (JavaVMInitArgs *) vm_args;
+
+       /* GNU classpath currently supports JNI 1.2 */
+
+       switch (_vm_args->version) {
+    case JNI_VERSION_1_1:
+               _vm_args->version = JNI_VERSION_1_1;
+               break;
+
+    case JNI_VERSION_1_2:
+    case JNI_VERSION_1_4:
+               _vm_args->ignoreUnrecognized = JNI_FALSE;
+               _vm_args->options = NULL;
+               _vm_args->nOptions = 0;
+               break;
+
+    default:
+               return -1;
+       }
+  
+       return 0;
+}
+
+
+/* JNI_GetCreatedJavaVMs *******************************************************
+
+   Returns all Java VMs that have been created. Pointers to VMs are written in
+   the buffer vmBuf in the order they are created. At most bufLen number of
+   entries will be written. The total number of created VMs is returned in
+   *nVMs.
+
+*******************************************************************************/
+
+jint JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs)
+{
+       TRACEJNICALLS(("JNI_GetCreatedJavaVMs(vmBuf=%p, jsize=%d, jsize=%p)", vmBuf, bufLen, nVMs));
+
+       if (bufLen <= 0)
+               return JNI_ERR;
+
+       // We currently only support 1 VM running.
+
+       vmBuf[0] = VM::get_current()->get_javavm();
+       *nVMs    = 1;
+
+    return JNI_OK;
+}
+
+
+/* JNI_CreateJavaVM ************************************************************
+
+   Loads and initializes a Java VM. The current thread becomes the main thread.
+   Sets the env argument to the JNI interface pointer of the main thread.
+
+*******************************************************************************/
+
+jint JNI_CreateJavaVM(JavaVM **p_vm, void **p_env, void *vm_args)
+{
+       TRACEJNICALLS(("JNI_CreateJavaVM(p_vm=%p, p_env=%p, vm_args=%p)", p_vm, p_env, vm_args));
+
+       /* actually create the JVM */
+
+       if (!VM_create(p_vm, p_env, vm_args))
+               return JNI_ERR;
+
+       return JNI_OK;
+}
+
+} // extern "C"
+
+
+/*
+ * 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/native/jni.h b/src/native/jni.h
deleted file mode 100644 (file)
index a74f686..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/* src/native/jni.h - JNI types and data structures
-
-   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.
-
-*/
-
-
-/* jni.h ***********************************************************************
-
-   ATTENTION: We include this file before we actually define our own
-   jni.h.  We do this because otherwise we can get into unresolvable
-   circular header dependencies.
-
-   This is OK as GNU Classpath defines:
-
-   #define __CLASSPATH_JNI_MD_H__
-   #define _CLASSPATH_JNI_H
-
-   and OpenJDK defines:
-
-   #define _JAVASOFT_JNI_MD_H_
-   #define _JAVASOFT_JNI_H_
-
-   CLASSPATH_JNI_MD_H and CLASSPATH_JNI_H are defined in config.h.
-
-*******************************************************************************/
-
-#include "config.h"
-
-/* We include both headers with the absolute path so we can be sure
-   that the preprocessor does not take another header.  Furthermore we
-   include jni_md.h before jni.h as the latter includes the former. */
-
-#include INCLUDE_JNI_MD_H
-#include INCLUDE_JNI_H
-
-#ifndef _JNI_H
-#define _JNI_H
-
-
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#include "vmcore/method.h"
-
-
-/* _Jv_JNIEnv *****************************************************************/
-
-typedef struct _Jv_JNIEnv _Jv_JNIEnv;
-
-struct _Jv_JNIEnv {
-       const struct JNINativeInterface_ *env;    /* This MUST be the first entry */
-};
-
-
-/* _Jv_JavaVM *****************************************************************/
-
-typedef struct _Jv_JavaVM _Jv_JavaVM;
-
-struct _Jv_JavaVM {
-       const struct JNIInvokeInterface_ *functions;/*This MUST be the first entry*/
-
-       /* JVM instance-specific variables */
-
-       s8 starttime;                       /* VM startup time                    */
-
-       s4 Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose;
-       s4 Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose;
-       s4 java_lang_management_ThreadMXBean_PeakThreadCount;
-       s4 java_lang_management_ThreadMXBean_ThreadCount;
-       s8 java_lang_management_ThreadMXBean_TotalStartedThreadCount;
-};
-
-
-/* CACAO related stuff ********************************************************/
-
-extern const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface;
-extern struct JNINativeInterface_ _Jv_JNINativeInterface;
-
-
-/* hashtable_global_ref_entry *************************************************/
-
-typedef struct hashtable_global_ref_entry hashtable_global_ref_entry;
-
-struct hashtable_global_ref_entry {
-       java_object_t              *o;      /* object pointer of global ref       */
-       s4                          refs;   /* references of the current pointer  */
-       hashtable_global_ref_entry *hashlink; /* link for external chaining       */
-};
-
-
-/* function prototypes ********************************************************/
-
-bool jni_init(void);
-bool jni_version_check(int version);
-
-#endif /* _JNI_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:
- */
diff --git a/src/native/jni.hpp b/src/native/jni.hpp
new file mode 100644 (file)
index 0000000..16933ec
--- /dev/null
@@ -0,0 +1,202 @@
+/* src/native/jni.hpp - JNI types and data structures
+
+   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.
+
+*/
+
+
+/* jni.hpp *********************************************************************
+
+   ATTENTION: We include this file before we actually define our own
+   jni.h.  We do this because otherwise we can get into unresolvable
+   circular header dependencies.
+
+   GNU Classpath's headers define:
+
+   #define __CLASSPATH_JNI_MD_H__
+   #define _CLASSPATH_JNI_H
+
+   and jni.h uses:
+
+   _CLASSPATH_VM_JNI_TYPES_DEFINED
+   
+   OpenJDK's headers define:
+
+   #define _JAVASOFT_JNI_MD_H_
+   #define _JAVASOFT_JNI_H_
+
+   and jni.h uses:
+
+   JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H
+
+   CLASSPATH_JNI_MD_H and CLASSPATH_JNI_H are defined in config.h.
+
+   We include both headers (jni.h and jni_md.h) with the absolute path
+   so we can be sure that the preprocessor does not pick up another
+   header from the search path.  Furthermore we include jni_md.h
+   before jni.h as the latter includes the former.
+
+*******************************************************************************/
+
+
+#ifndef _JNI_HPP
+#define _JNI_HPP
+
+#include "config.h"
+
+#include <stdbool.h>
+#include <stdint.h>
+
+
+// Define these to override the typedefs in jni.h
+#define _CLASSPATH_VM_JNI_TYPES_DEFINED          1 // GNU Classpath
+#define JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H    1 // OpenJDK
+
+// First include jni_md.h so we have the Java primitive types.
+#include INCLUDE_JNI_MD_H
+
+
+// Include the C++ wrapper classes.
+//#include "vm/javaobjects.hpp"
+#include "vm/global.h"
+
+// Typedef the JNI types.
+typedef java_handle_t*              jobject;
+typedef java_handle_t*              jclass;
+typedef java_handle_t*              jstring;
+typedef java_handle_t*              jthrowable;
+typedef java_handle_t*              jweak; // FIXME
+typedef java_handle_array_t*        jarray;
+typedef java_handle_objectarray_t*  jobjectArray;
+typedef java_handle_booleanarray_t* jbooleanArray;
+typedef java_handle_bytearray_t*    jbyteArray;
+typedef java_handle_chararray_t*    jcharArray;
+typedef java_handle_shortarray_t*   jshortArray;
+typedef java_handle_intarray_t*     jintArray;
+typedef java_handle_longarray_t*    jlongArray;
+typedef java_handle_floatarray_t*   jfloatArray;
+typedef java_handle_doublearray_t*  jdoubleArray;
+
+
+// We need some additional stuff for the various JNI headers.
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+// These typedefs and defines are copied from GNU Classpath's jni.h
+#define JNI_TRUE true
+#define JNI_FALSE false
+
+typedef struct _Jv_JNIEnv JNIEnv;
+typedef struct _Jv_JavaVM JavaVM;
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+// These typedefs are copied from OpenJDK's jni.h
+typedef unsigned char   jboolean;
+typedef unsigned short  jchar;
+typedef short           jshort;
+typedef float           jfloat;
+typedef double          jdouble;
+
+typedef jint            jsize;
+
+typedef union jvalue {
+    jboolean z;
+    jbyte    b;
+    jchar    c;
+    jshort   s;
+    jint     i;
+    jlong    j;
+    jfloat   f;
+    jdouble  d;
+    jobject  l;
+} jvalue;
+
+struct _jfieldID;
+typedef struct _jfieldID *jfieldID;
+
+struct _jmethodID;
+typedef struct _jmethodID *jmethodID;
+
+/* Return values from jobjectRefType */
+typedef enum _jobjectType {
+     JNIInvalidRefType    = 0,
+     JNILocalRefType      = 1,
+     JNIGlobalRefType     = 2,
+     JNIWeakGlobalRefType = 3
+} jobjectRefType;
+
+#endif
+
+
+// Now include jni.h to complete the JNI header.
+#include INCLUDE_JNI_H
+
+
+// Includes.
+#include "vm/global.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* CACAO related stuff ********************************************************/
+
+extern const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface;
+extern struct JNINativeInterface_ _Jv_JNINativeInterface;
+
+
+/* hashtable_global_ref_entry *************************************************/
+
+typedef struct hashtable_global_ref_entry hashtable_global_ref_entry;
+
+struct hashtable_global_ref_entry {
+       java_object_t              *o;      /* object pointer of global ref       */
+       int32_t                     refs;   /* references of the current pointer  */
+       hashtable_global_ref_entry *hashlink; /* link for external chaining       */
+};
+
+
+/* function prototypes ********************************************************/
+
+bool jni_init(void);
+bool jni_version_check(int version);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _JNI_HPP
+
+
+/*
+ * 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 8db874a8fb8d8102250be0fe2d80aeb16f0ffbf1..eb29c6f7b5313c27252ea99087e8647816281fd3 100644 (file)
 #include "native/jvmti/jvmti.h"
 #include "native/jvmti/cacaodbg.h"
 #include "native/jvmti/dbg.h"
-#include "vm/vm.h"
-#include "vm/loader.h"
-#include "vm/exceptions.h"
-#include "vm/builtin.h"
+#include "vm/vm.hpp"
+#include "vm/loader.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/jit/builtin.hpp"
 #include "vm/jit/asmpart.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "toolbox/logging.h"
 #include "threads/mutex.h"
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
 #include <sys/types.h>
 #include <unistd.h>
index 4b4a219eb7025cd7e2b4dc57d8f111821369e188..04abbd85c2a04d45fef38bc426c7a8557e85d100 100644 (file)
@@ -26,7 +26,7 @@
 #define _CACAODBG_H
 
 #include "threads/mutex.h"
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 #include "native/jvmti/jvmti.h"
 #include "native/include/java_lang_String.h"
 #include <ltdl.h>
index b80dae48d18ee8f3658d0990544d205cc2ddde94..e152104dc03727f421198320dcd9683368b92726 100644 (file)
 #include <unistd.h>
 #include <sched.h>
 
-#include "native/jni.h"
-#include "native/native.h"
+#include "native/jni.hpp"
+#include "native/native.hpp"
 #include "native/jvmti/cacaodbg.h"
 #include "native/jvmti/jvmti.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/global.h"
-#include "vm/loader.h"
-#include "vm/builtin.h"
+#include "vm/loader.hpp"
+#include "vm/jit/builtin.hpp"
 #include "vm/jit/asmpart.h"
-#include "vm/class.h"
-#include "vm/classcache.h"
-#include "mm/gc-common.h"
+#include "vm/class.hpp"
+#include "vm/classcache.hpp"
+#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.h"
-#include "threads/lock-common.h"
-#include "vm/exceptions.h"
-#include "native/include/java_util_Vector.h"
+#include "threads/thread.hpp"
+#include "threads/lock.hpp"
+#include "vm/exceptions.hpp"
 #include "native/include/java_io_PrintStream.h"
 #include "native/include/java_io_InputStream.h"
 #include "native/include/java_lang_Cloneable.h"
@@ -64,7 +63,7 @@
 #include "native/include/java_lang_VMObject.h"
 #include "native/include/java_lang_VMSystem.h"
 #include "native/include/java_lang_VMClass.h"
-#include "vm/suck.h"
+#include "vm/suck.hpp"
 #include "boehm-gc/include/gc.h"
 
 #if defined(ENABLE_THREADS)
@@ -1158,7 +1157,7 @@ GetThreadState (jvmtiEnv * env, jthread thread, jint * thread_state_ptr)
                if (false) *thread_state_ptr |= JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT;
                if (false) *thread_state_ptr |= JVMTI_THREAD_STATE_IN_OBJECT_WAIT;
                if (false) *thread_state_ptr |= JVMTI_THREAD_STATE_PARKED;
-               if (t->sleeping) *thread_state_ptr |= JVMTI_THREAD_STATE_SLEEPING;
+               if (false) *thread_state_ptr |= JVMTI_THREAD_STATE_SLEEPING;
        }
 #else
        return JVMTI_ERROR_INTERNAL;
index b0774abb289b260ef83c63b1c13dc91b49e2664b..576c7ee2b0643a315c75a8e10507e0d077025ca4 100644 (file)
@@ -1,10 +1,8 @@
 /* src/native/jvmti.c - implementation of the Java Virtual Machine Tool 
                         Interface functions
 
-   Copyright (C) 1996-2005, 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) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Author: Martin Platter
-
-   Changes:             
+*/
 
-   
 
-*/
 #ifndef _JVMTI_H
 #define _JVMTI_H
 
-#include "native/jni.h"
+#include "config.h"
+
+#include "native/jni.hpp"
 
 
 #define JVMTI_VERSION_INTERFACE_JNI   0x00000000
index e9df0d64328252041395f42b32d6abbe3af08c55..02c171b7bc1ef05ac449846de7a967609a6502b4 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <assert.h>
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
 
 /* LLNI critical sections ******************************************************
index 65e708685bd69a83c88cc14ccc77e757b50681a1..6112dfbfe4a4b286db7632a7e3430ef3219c7e91 100644 (file)
 #endif
 
 
-#include "native/localref.h"
+#include "native/localref.hpp"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
 
-/* LLNI macros *****************************************************************
-
-   The following macros should be used whenever a Java Object is
-   accessed in native code without the use of an JNI function.
-
-   LLNI_field_set_val, LLNI_field_get_val:
-     Deal with primitive values like integer and float values. Do
-     not use these macros to access pointers or references!
-
-   LLNI_field_set_ref, LLNI_field_get_ref:
-     Deal with references to other objects.
-
-   LLNI_field_set_cls, LLNI_field_get_cls:
-     Deal with references to Java Classes which are internally
-     represented by classinfo or java_lang_Class.
-
-*******************************************************************************/
-
-#define LLNI_field_set_val(obj, field, value) \
-       LLNI_field_direct(obj, field) = (value)
-
-#define LLNI_field_set_ref(obj, field, reference) \
-       LLNI_field_direct(obj, field) = LLNI_UNWRAP(reference)
-
-#define LLNI_field_set_cls(obj, field, value) \
-       LLNI_field_direct(obj, field) = (java_lang_Class *) (value)
-
-#define LLNI_field_get_val(obj, field, variable) \
-       (variable) = LLNI_field_direct(obj, field)
-
-#define LLNI_field_get_ref(obj, field, variable) \
-       (variable) = LLNI_WRAP(LLNI_field_direct(obj, field))
-
-#define LLNI_field_get_cls(obj, field, variable) \
-       (variable) = (classinfo *) LLNI_field_direct(obj, field)
-
 #define LLNI_class_get(obj, variable) \
        (variable) = LLNI_field_direct((java_handle_t *) obj, vftbl->clazz)
 
 *******************************************************************************/
 
 #define LLNI_classinfo_wrap(classinfo) \
-       ((java_lang_Class *) LLNI_WRAP(classinfo))
+       ((java_handle_t*) LLNI_WRAP(classinfo))
 
 #define LLNI_classinfo_unwrap(clazz) \
        ((classinfo *) LLNI_UNWRAP((java_handle_t *) (clazz)))
 # define LLNI_CRITICAL_END_THREAD(t)
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void llni_critical_start();
 void llni_critical_end();
 void llni_critical_start_thread(threadobject *t);
 void llni_critical_end_thread(threadobject *t);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _LLNI_H */
 
diff --git a/src/native/localref.c b/src/native/localref.c
deleted file mode 100644 (file)
index 8e364b5..0000000
+++ /dev/null
@@ -1,643 +0,0 @@
-/* src/native/localref.c - Management of local reference tables
-
-   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 <stdint.h>
-
-#include "mm/memory.h"
-
-#include "native/localref.h"
-
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/vm.h"
-
-#include "vm/jit/argument.h"
-
-#include "vmcore/options.h"
-
-
-/* debug **********************************************************************/
-
-#if !defined(NDEBUG)
-# define DEBUGLOCALREF(message, index) \
-       do { \
-               if (opt_DebugLocalReferences) { \
-                       localref_table *dlrt = LOCALREFTABLE; \
-                       log_start(); \
-                       log_print("[local reference %-12s: lrt=%016p frame=%d capacity=%d used=%d", message, dlrt, dlrt->localframes, dlrt->capacity, dlrt->used); \
-                       if (index >= 0) \
-                               log_print(" localref=%p object=%p", &(dlrt->refs[index]), dlrt->refs[index]); \
-                       log_print("]"); \
-                       log_finish(); \
-               } \
-       } while (0)
-#else
-# define DEBUGLOCALREF(message, index)
-#endif
-
-
-/* global variables ***********************************************************/
-
-#if !defined(ENABLE_THREADS)
-localref_table *_no_threads_localref_table;
-#endif
-
-
-/* some forward declarations **************************************************/
-
-#if !defined(NDEBUG)
-static bool localref_check_uncleared();
-#endif
-
-
-/* localref_table_init *********************************************************
-
-   Initializes the local references table of the current thread.
-
-*******************************************************************************/
-
-bool localref_table_init(void)
-{
-       localref_table *lrt;
-
-       TRACESUBSYSTEMINITIALIZATION("localref_table_init");
-
-       assert(LOCALREFTABLE == NULL);
-
-#if !defined(ENABLE_GC_BOEHM)
-       /* this is freed by localref_table_destroy */
-       lrt = NEW(localref_table);
-#else
-       /* this does not need to be freed again */
-       lrt = GCNEW(localref_table);
-#endif
-
-       if (lrt == NULL)
-               return false;
-
-       localref_table_add(lrt);
-
-       DEBUGLOCALREF("table init", -1);
-
-       return true;
-}
-
-
-/* localref_table_destroy ******************************************************
-
-   Destroys the complete local references table of the current thread.
-
-*******************************************************************************/
-
-bool localref_table_destroy(void)
-{
-       localref_table *lrt;
-
-       lrt = LOCALREFTABLE;
-       assert(lrt != NULL);
-       assert(lrt->prev == NULL);
-
-       DEBUGLOCALREF("table destroy", -1);
-
-#if !defined(ENABLE_GC_BOEHM)
-       FREE(lrt, localref_table);
-#endif
-
-       LOCALREFTABLE = NULL;
-
-       return true;
-}
-
-
-/* localref_table_add **********************************************************
-
-   Adds a new local references table to the current thread.
-
-*******************************************************************************/
-
-void localref_table_add(localref_table *lrt)
-{
-       /* initialize the local reference table */
-
-       lrt->capacity    = LOCALREFTABLE_CAPACITY;
-       lrt->used        = 0;
-       lrt->localframes = 1;
-       lrt->prev        = LOCALREFTABLE;
-
-       /* clear the references array (memset is faster the a for-loop) */
-
-       MSET(lrt->refs, 0, void*, LOCALREFTABLE_CAPACITY);
-
-       /* add given local references table to this thread */
-
-       LOCALREFTABLE = lrt;
-
-       /*DEBUGLOCALREF("table add", -1);*/
-}
-
-
-/* localref_table_remove *******************************************************
-
-   Removes the topmost local references table from the current thread.
-
-*******************************************************************************/
-
-void localref_table_remove()
-{
-       localref_table *lrt;
-
-#if !defined(NDEBUG)
-       /* check for uncleared local references */
-
-       localref_check_uncleared();
-#endif
-
-       /* get current local reference table from thread */
-
-       lrt = LOCALREFTABLE;
-       assert(lrt != NULL);
-       assert(lrt->localframes == 1);
-
-       /*DEBUGLOCALREF("table remove", -1);*/
-
-       lrt = lrt->prev;
-
-       LOCALREFTABLE = lrt;
-}
-
-
-/* localref_frame_push *********************************************************
-
-   Creates a new local reference frame, in which at least a given
-   number of local references can be created.
-
-*******************************************************************************/
-
-bool localref_frame_push(int32_t capacity)
-{
-       localref_table *lrt;
-       localref_table *nlrt;
-       int32_t         additionalrefs;
-
-       /* get current local reference table from thread */
-
-       lrt = LOCALREFTABLE;
-       assert(lrt != NULL);
-       assert(capacity > 0);
-
-       /* Allocate new local reference table on Java heap.  Calculate the
-          additional memory we have to allocate. */
-
-       if (capacity > LOCALREFTABLE_CAPACITY)
-               additionalrefs = capacity - LOCALREFTABLE_CAPACITY;
-       else
-               additionalrefs = 0;
-
-#if !defined(ENABLE_GC_BOEHM)
-       nlrt = (localref_table *)
-                       MNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
-#else
-       nlrt = (localref_table *)
-                       GCMNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
-#endif
-
-       if (nlrt == NULL)
-               return false;
-
-       /* Set up the new local reference table and add it to the local
-          frames chain. */
-
-       nlrt->capacity    = capacity;
-       nlrt->used        = 0;
-       nlrt->localframes = lrt->localframes + 1;
-       nlrt->prev        = lrt;
-
-       /* store new local reference table in thread */
-
-       LOCALREFTABLE = nlrt;
-
-       DEBUGLOCALREF("frame push", -1);
-
-       return true;
-}
-
-
-/* localref_frame_pop_all ******************************************************
-
-   Pops off all the local reference frames of the current table.
-
-*******************************************************************************/
-
-void localref_frame_pop_all(void)
-{
-       localref_table *lrt;
-       localref_table *plrt;
-       int32_t         localframes;
-#if !defined(ENABLE_GC_BOEHM)
-       int32_t         additionalrefs;
-#endif
-
-       /* get current local reference table from thread */
-
-       lrt = LOCALREFTABLE;
-       assert(lrt != NULL);
-
-       localframes = lrt->localframes;
-
-       /* Don't delete the top local frame, as this one is allocated in
-          the native stub on the stack and is freed automagically on
-          return. */
-
-       if (localframes == 1)
-               return;
-
-       /* release all current local frames */
-
-       for (; localframes > 1; localframes--) {
-               /* get previous frame */
-
-               plrt = lrt->prev;
-
-               DEBUGLOCALREF("frame pop", -1);
-
-               /* clear all reference entries */
-
-               MSET(lrt->refs, 0, void*, lrt->capacity);
-
-               lrt->prev = NULL;
-
-#if !defined(ENABLE_GC_BOEHM)
-               /* for the exact GC local reference tables are not on the heap,
-                  so we need to free them explicitly here. */
-
-               if (lrt->capacity > LOCALREFTABLE_CAPACITY)
-                       additionalrefs = lrt->capacity - LOCALREFTABLE_CAPACITY;
-               else
-                       additionalrefs = 0;
-
-               MFREE(lrt, u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
-#endif
-
-               /* set new local references table */
-
-               lrt = plrt;
-       }
-
-       /* store new local reference table in thread */
-
-       LOCALREFTABLE = lrt;
-}
-
-
-/* localref_add ****************************************************************
-
-   Adds a new entry into the local reference table and returns the
-   new local reference.
-
-*******************************************************************************/
-
-java_handle_t *localref_add(java_object_t *o)
-{
-       localref_table *lrt;
-       java_handle_t  *h;
-       int32_t         i;
-
-       /* get current local reference table from thread */
-
-       lrt = LOCALREFTABLE;
-       assert(lrt != NULL);
-       assert(o != NULL);
-       /* XXX: assert that we are in a GC critical section! */
-
-       /* Check if we have space for the requested reference?  No,
-          allocate a new frame.  This is actually not what the spec says,
-          but for compatibility reasons... */
-
-    if (lrt->used == lrt->capacity) {
-               if (!localref_frame_push(64))
-                       assert(0);
-
-               /* get the new local reference table */ 
-
-               lrt = LOCALREFTABLE;
-       }
-
-       /* insert the reference into the local reference table */
-
-       for (i = 0; i < lrt->capacity; i++) {
-               if (lrt->refs[i] == NULL) {
-                       lrt->refs[i] = o;
-                       lrt->used++;
-
-#if defined(ENABLE_HANDLES)
-                       h = (java_handle_t *) &(lrt->refs[i]);
-#else
-                       h = (java_handle_t *) o;
-#endif
-
-                       /*DEBUGLOCALREF("entry add", i);*/
-
-                       return h;
-               }
-       }
-
-       /* this should not happen */
-
-       log_println("localref_add: WARNING: unable to add localref for %p", o);
-
-       return NULL;
-}
-
-
-/* localref_del ****************************************************************
-
-   Deletes an entry from the local reference table.
-
-*******************************************************************************/
-
-void localref_del(java_handle_t *localref)
-{
-       localref_table *lrt;
-       java_handle_t  *h;
-       int32_t         localframes;
-       int32_t         i;
-
-       /* get local reference table from thread */
-
-       lrt = LOCALREFTABLE;
-       assert(lrt != NULL);
-       assert(localref != NULL);
-
-       localframes = lrt->localframes;
-
-       /* go through all local frames of the current table */
-       /* XXX: this is propably not what the spec wants! */
-
-       for (; localframes > 0; localframes--) {
-
-               /* and try to remove the reference */
-    
-               for (i = 0; i < lrt->capacity; i++) {
-#if defined(ENABLE_HANDLES)
-                       h = (java_handle_t *) &(lrt->refs[i]);
-#else
-                       h = (java_handle_t *) lrt->refs[i];
-#endif
-
-                       if (h == localref) {
-                               DEBUGLOCALREF("entry delete", i);
-
-                               lrt->refs[i] = NULL;
-                               lrt->used--;
-
-                               return;
-                       }
-               }
-
-               lrt = lrt->prev;
-       }
-
-       /* this should not happen */
-
-       log_println("localref_del: WARNING: unable to find localref %p", localref);
-}
-
-
-/* localref_native_enter *******************************************************
-
-   Insert arguments to a native method into the local reference table.
-   This is done by the native stub through codegen_start_native_call.
-
-*******************************************************************************/
-
-void localref_native_enter(methodinfo *m, uint64_t *argument_regs, uint64_t *argument_stack)
-{
-       localref_table *lrt;
-       methoddesc     *md;
-       imm_union       arg;
-       java_handle_t  *h;
-       int i;
-
-       /* get local reference table from thread */
-
-       lrt = LOCALREFTABLE;
-       assert(lrt != NULL);
-       assert(m != NULL);
-
-       md = m->parseddesc;
-
-       /* walk through all parameters to the method */
-
-       for (i = 0; i < md->paramcount; ++i) {
-               /* load TYPE_ADR parameters ... */
-
-               if (md->paramtypes[i].type == TYPE_ADR) {
-                       arg = argument_jitarray_load(md, i, argument_regs, argument_stack);
-
-                       if (arg.a == NULL)
-                               continue;
-
-                       /* ... and insert them into the table */
-
-                       h = localref_add((java_object_t *) arg.a);
-
-#if defined(ENABLE_HANDLES)
-                       /* update the modified parameter if necesarry */
-
-                       arg.a = (void *) h;
-                       argument_jitarray_store(md, i, argument_regs, argument_stack, arg);
-#endif
-               }
-       }
-}
-
-
-/* localref_native_exit ********************************************************
-
-   Undo the wrapping of the return value of a native method. This is
-   done by the native stub through codegen_finish_native_call.
-
-   NOTE: This function is only useful if handles are enabled.
-
-*******************************************************************************/
-
-#if defined(ENABLE_HANDLES)
-void localref_native_exit(methodinfo *m, uint64_t *return_regs)
-{
-       localref_table *lrt;
-       methoddesc     *md;
-       imm_union       ret;
-       java_handle_t  *h;
-
-       /* get local reference table from thread */
-
-       lrt = LOCALREFTABLE;
-       assert(lrt != NULL);
-       assert(m != NULL);
-
-       md = m->parseddesc;
-
-       /* load TYPE_ADR return values ... */
-
-       if (md->returntype.type == TYPE_ADR) {
-               ret = argument_jitreturn_load(md, return_regs);
-
-               if (ret.a == NULL)
-                       return;
-
-               h = (java_handle_t *) ret.a;
-
-               /* update the modified return valie */
-
-               ret.a = (void *) h->heap_object;
-               argument_jitreturn_store(md, return_regs, ret);
-
-#if !defined(NDEBUG) && 0
-               /* removing the entry from the local reference table is not really
-                  necesarry, but gives us warnings if the entry does not exist. */
-
-               localref_del(h);
-#endif
-       }
-}
-#endif /* defined(ENABLE_HANDLES) */
-
-
-/* localref_dump ***************************************************************
-
-   Dumps all local reference tables, including all frames.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-# define LOCALREF_DUMP_REFS_PER_LINE 4
-void localref_dump()
-{
-       localref_table *lrt;
-       int i, j;
-
-       /* get current local reference table from thread */
-
-       lrt = LOCALREFTABLE;
-
-       log_println("--------- Local Reference Tables Dump ---------");
-
-       while (lrt != NULL) {
-               log_println("Frame #%d, Used=%d, Capacity=%d, Addr=%p:", lrt->localframes, lrt->used, lrt->capacity, (void *) lrt);
-
-                       if (lrt->used != 0) {
-
-                               log_start();
-
-                               j = 0;
-                               for (i = 0; i < lrt->capacity; i++) {
-                                       if (lrt->refs[i] != NULL) {
-                                               if (j != 0 && j % LOCALREF_DUMP_REFS_PER_LINE == 0) {
-                                                       log_finish();
-                                                       log_start();
-                                               }
-                                               j++;
-                                               log_print("\t0x%016lx ", (intptr_t) lrt->refs[i]);
-                                       }
-                               }
-
-                               log_finish();
-                       }
-
-               lrt = lrt->prev;
-       }
-}
-#endif /* !defined(NDEBUG) */
-
-
-/* localref_check_uncleared ****************************************************
-
-   Checks the topmost local reference table for uncleared references.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-static bool localref_check_uncleared()
-{
-       localref_table *lrt;
-       int32_t         localframes;
-       int32_t         lrt_uncleared;
-       int32_t         lrt_used;
-       int i;
-
-       /* get current local reference table from thread */
-
-       lrt = LOCALREFTABLE;
-       assert(lrt != NULL);
-       assert(lrt->localframes > 0);
-
-       localframes   = lrt->localframes;
-       lrt_uncleared = 0;
-       lrt_used      = 0;
-
-       for (; localframes > 0; localframes--) {
-               lrt_used += lrt->used;
-
-               for (i = 0; i < lrt->capacity; i++) {
-                       if (lrt->refs[i] != NULL)
-                               lrt_uncleared++;
-               }
-
-               lrt = lrt->prev;
-       }
-
-       if (lrt_uncleared != lrt_used) {
-               localref_dump();
-               vm_abort("localref_check_uncleared: (uncleared=%d) != (used=%d)", lrt_uncleared, lrt_used);
-       }
-
-       if (lrt_uncleared <= 1)
-               return true;
-       else {
-               /*log_println("localref_check_uncleared: %d uncleared local references", lrt_uncleared);*/
-               return false;
-       }
-}
-#endif
-
-
-/*
- * 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/native/localref.cpp b/src/native/localref.cpp
new file mode 100644 (file)
index 0000000..d236afb
--- /dev/null
@@ -0,0 +1,642 @@
+/* src/native/localref.cpp - Management of local reference tables
+
+   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 <stdint.h>
+
+#include "mm/memory.h"
+
+#include "native/localref.hpp"
+
+#include "threads/thread.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/options.h"
+#include "vm/vm.hpp"
+
+#include "vm/jit/argument.hpp"
+
+
+/* debug **********************************************************************/
+
+#if !defined(NDEBUG)
+# define DEBUGLOCALREF(message, index) \
+       do { \
+               if (opt_DebugLocalReferences) { \
+                       localref_table *dlrt = LOCALREFTABLE; \
+                       log_start(); \
+                       log_print("[local reference %-12s: lrt=%016p frame=%d capacity=%d used=%d", message, dlrt, dlrt->localframes, dlrt->capacity, dlrt->used); \
+                       if (index >= 0) \
+                               log_print(" localref=%p object=%p", &(dlrt->refs[index]), dlrt->refs[index]); \
+                       log_print("]"); \
+                       log_finish(); \
+               } \
+       } while (0)
+#else
+# define DEBUGLOCALREF(message, index)
+#endif
+
+
+/* global variables ***********************************************************/
+
+#if !defined(ENABLE_THREADS)
+localref_table *_no_threads_localref_table;
+#endif
+
+
+/* some forward declarations **************************************************/
+
+#if !defined(NDEBUG)
+static bool localref_check_uncleared();
+#endif
+
+
+/* localref_table_init *********************************************************
+
+   Initializes the local references table of the current thread.
+
+*******************************************************************************/
+
+bool localref_table_init(void)
+{
+       localref_table *lrt;
+
+       TRACESUBSYSTEMINITIALIZATION("localref_table_init");
+
+       assert(LOCALREFTABLE == NULL);
+
+#if !defined(ENABLE_GC_BOEHM)
+       /* this is freed by localref_table_destroy */
+       lrt = (localref_table*) NEW(localref_table);
+#else
+       /* this does not need to be freed again */
+       lrt = (localref_table*) GCNEW(localref_table);
+#endif
+
+       if (lrt == NULL)
+               return false;
+
+       localref_table_add(lrt);
+
+       DEBUGLOCALREF("table init", -1);
+
+       return true;
+}
+
+
+/* localref_table_destroy ******************************************************
+
+   Destroys the complete local references table of the current thread.
+
+*******************************************************************************/
+
+bool localref_table_destroy(void)
+{
+       localref_table *lrt;
+
+       lrt = LOCALREFTABLE;
+       assert(lrt != NULL);
+       assert(lrt->prev == NULL);
+
+       DEBUGLOCALREF("table destroy", -1);
+
+#if !defined(ENABLE_GC_BOEHM)
+       FREE(lrt, localref_table);
+#endif
+
+       LOCALREFTABLE = NULL;
+
+       return true;
+}
+
+
+/* localref_table_add **********************************************************
+
+   Adds a new local references table to the current thread.
+
+*******************************************************************************/
+
+void localref_table_add(localref_table *lrt)
+{
+       /* initialize the local reference table */
+
+       lrt->capacity    = LOCALREFTABLE_CAPACITY;
+       lrt->used        = 0;
+       lrt->localframes = 1;
+       lrt->prev        = LOCALREFTABLE;
+
+       /* clear the references array (memset is faster the a for-loop) */
+
+       MSET(lrt->refs, 0, void*, LOCALREFTABLE_CAPACITY);
+
+       /* add given local references table to this thread */
+
+       LOCALREFTABLE = lrt;
+
+       /*DEBUGLOCALREF("table add", -1);*/
+}
+
+
+/* localref_table_remove *******************************************************
+
+   Removes the topmost local references table from the current thread.
+
+*******************************************************************************/
+
+void localref_table_remove()
+{
+       localref_table *lrt;
+
+#if !defined(NDEBUG)
+       /* check for uncleared local references */
+
+       localref_check_uncleared();
+#endif
+
+       /* get current local reference table from thread */
+
+       lrt = LOCALREFTABLE;
+       assert(lrt != NULL);
+       assert(lrt->localframes == 1);
+
+       /*DEBUGLOCALREF("table remove", -1);*/
+
+       lrt = lrt->prev;
+
+       LOCALREFTABLE = lrt;
+}
+
+
+/* localref_frame_push *********************************************************
+
+   Creates a new local reference frame, in which at least a given
+   number of local references can be created.
+
+*******************************************************************************/
+
+bool localref_frame_push(int32_t capacity)
+{
+       localref_table *lrt;
+       localref_table *nlrt;
+       int32_t         additionalrefs;
+
+       /* get current local reference table from thread */
+
+       lrt = LOCALREFTABLE;
+       assert(lrt != NULL);
+       assert(capacity > 0);
+
+       /* Allocate new local reference table on Java heap.  Calculate the
+          additional memory we have to allocate. */
+
+       if (capacity > LOCALREFTABLE_CAPACITY)
+               additionalrefs = capacity - LOCALREFTABLE_CAPACITY;
+       else
+               additionalrefs = 0;
+
+#if !defined(ENABLE_GC_BOEHM)
+       nlrt = (localref_table *)
+                       MNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
+#else
+       nlrt = (localref_table *)
+                       GCMNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
+#endif
+
+       if (nlrt == NULL)
+               return false;
+
+       /* Set up the new local reference table and add it to the local
+          frames chain. */
+
+       nlrt->capacity    = capacity;
+       nlrt->used        = 0;
+       nlrt->localframes = lrt->localframes + 1;
+       nlrt->prev        = lrt;
+
+       /* store new local reference table in thread */
+
+       LOCALREFTABLE = nlrt;
+
+       DEBUGLOCALREF("frame push", -1);
+
+       return true;
+}
+
+
+/* localref_frame_pop_all ******************************************************
+
+   Pops off all the local reference frames of the current table.
+
+*******************************************************************************/
+
+void localref_frame_pop_all(void)
+{
+       localref_table *lrt;
+       localref_table *plrt;
+       int32_t         localframes;
+#if !defined(ENABLE_GC_BOEHM)
+       int32_t         additionalrefs;
+#endif
+
+       /* get current local reference table from thread */
+
+       lrt = LOCALREFTABLE;
+       assert(lrt != NULL);
+
+       localframes = lrt->localframes;
+
+       /* Don't delete the top local frame, as this one is allocated in
+          the native stub on the stack and is freed automagically on
+          return. */
+
+       if (localframes == 1)
+               return;
+
+       /* release all current local frames */
+
+       for (; localframes > 1; localframes--) {
+               /* get previous frame */
+
+               plrt = lrt->prev;
+
+               DEBUGLOCALREF("frame pop", -1);
+
+               /* clear all reference entries */
+
+               MSET(lrt->refs, 0, void*, lrt->capacity);
+
+               lrt->prev = NULL;
+
+#if !defined(ENABLE_GC_BOEHM)
+               /* for the exact GC local reference tables are not on the heap,
+                  so we need to free them explicitly here. */
+
+               if (lrt->capacity > LOCALREFTABLE_CAPACITY)
+                       additionalrefs = lrt->capacity - LOCALREFTABLE_CAPACITY;
+               else
+                       additionalrefs = 0;
+
+               MFREE(lrt, u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
+#endif
+
+               /* set new local references table */
+
+               lrt = plrt;
+       }
+
+       /* store new local reference table in thread */
+
+       LOCALREFTABLE = lrt;
+}
+
+
+/* localref_add ****************************************************************
+
+   Adds a new entry into the local reference table and returns the
+   new local reference.
+
+*******************************************************************************/
+
+java_handle_t *localref_add(java_object_t *o)
+{
+       localref_table *lrt;
+       java_handle_t  *h;
+       int32_t         i;
+
+       /* get current local reference table from thread */
+
+       lrt = LOCALREFTABLE;
+       assert(lrt != NULL);
+       assert(o != NULL);
+       /* XXX: assert that we are in a GC critical section! */
+
+       /* Check if we have space for the requested reference?  No,
+          allocate a new frame.  This is actually not what the spec says,
+          but for compatibility reasons... */
+
+    if (lrt->used == lrt->capacity) {
+               if (!localref_frame_push(64))
+                       assert(0);
+
+               /* get the new local reference table */ 
+
+               lrt = LOCALREFTABLE;
+       }
+
+       /* insert the reference into the local reference table */
+
+       for (i = 0; i < lrt->capacity; i++) {
+               if (lrt->refs[i] == NULL) {
+                       lrt->refs[i] = o;
+                       lrt->used++;
+
+#if defined(ENABLE_HANDLES)
+                       h = (java_handle_t *) &(lrt->refs[i]);
+#else
+                       h = (java_handle_t *) o;
+#endif
+
+                       /*DEBUGLOCALREF("entry add", i);*/
+
+                       return h;
+               }
+       }
+
+       /* this should not happen */
+
+       log_println("localref_add: WARNING: unable to add localref for %p", o);
+
+       return NULL;
+}
+
+
+/* localref_del ****************************************************************
+
+   Deletes an entry from the local reference table.
+
+*******************************************************************************/
+
+void localref_del(java_handle_t *localref)
+{
+       localref_table *lrt;
+       java_handle_t  *h;
+       int32_t         localframes;
+       int32_t         i;
+
+       /* get local reference table from thread */
+
+       lrt = LOCALREFTABLE;
+       assert(lrt != NULL);
+       assert(localref != NULL);
+
+       localframes = lrt->localframes;
+
+       /* go through all local frames of the current table */
+       /* XXX: this is propably not what the spec wants! */
+
+       for (; localframes > 0; localframes--) {
+
+               /* and try to remove the reference */
+    
+               for (i = 0; i < lrt->capacity; i++) {
+#if defined(ENABLE_HANDLES)
+                       h = (java_handle_t *) &(lrt->refs[i]);
+#else
+                       h = (java_handle_t *) lrt->refs[i];
+#endif
+
+                       if (h == localref) {
+                               DEBUGLOCALREF("entry delete", i);
+
+                               lrt->refs[i] = NULL;
+                               lrt->used--;
+
+                               return;
+                       }
+               }
+
+               lrt = lrt->prev;
+       }
+
+       /* this should not happen */
+
+       log_println("localref_del: WARNING: unable to find localref %p", localref);
+}
+
+
+/* localref_native_enter *******************************************************
+
+   Insert arguments to a native method into the local reference table.
+   This is done by the native stub through codegen_start_native_call.
+
+*******************************************************************************/
+
+void localref_native_enter(methodinfo *m, uint64_t *argument_regs, uint64_t *argument_stack)
+{
+       localref_table *lrt;
+       methoddesc     *md;
+       imm_union       arg;
+       java_handle_t  *h;
+       int i;
+
+       /* get local reference table from thread */
+
+       lrt = LOCALREFTABLE;
+       assert(lrt != NULL);
+       assert(m != NULL);
+
+       md = m->parseddesc;
+
+       /* walk through all parameters to the method */
+
+       for (i = 0; i < md->paramcount; ++i) {
+               /* load TYPE_ADR parameters ... */
+
+               if (md->paramtypes[i].type == TYPE_ADR) {
+                       arg = argument_jitarray_load(md, i, argument_regs, argument_stack);
+
+                       if (arg.a == NULL)
+                               continue;
+
+                       /* ... and insert them into the table */
+
+                       h = localref_add((java_object_t *) arg.a);
+
+#if defined(ENABLE_HANDLES)
+                       /* update the modified parameter if necesarry */
+
+                       arg.a = (void *) h;
+                       argument_jitarray_store(md, i, argument_regs, argument_stack, arg);
+#endif
+               }
+       }
+}
+
+
+/* localref_native_exit ********************************************************
+
+   Undo the wrapping of the return value of a native method. This is
+   done by the native stub through codegen_finish_native_call.
+
+   NOTE: This function is only useful if handles are enabled.
+
+*******************************************************************************/
+
+#if defined(ENABLE_HANDLES)
+void localref_native_exit(methodinfo *m, uint64_t *return_regs)
+{
+       localref_table *lrt;
+       methoddesc     *md;
+       imm_union       ret;
+       java_handle_t  *h;
+
+       /* get local reference table from thread */
+
+       lrt = LOCALREFTABLE;
+       assert(lrt != NULL);
+       assert(m != NULL);
+
+       md = m->parseddesc;
+
+       /* load TYPE_ADR return values ... */
+
+       if (md->returntype.type == TYPE_ADR) {
+               ret = argument_jitreturn_load(md, return_regs);
+
+               if (ret.a == NULL)
+                       return;
+
+               h = (java_handle_t *) ret.a;
+
+               /* update the modified return valie */
+
+               ret.a = (void *) h->heap_object;
+               argument_jitreturn_store(md, return_regs, ret);
+
+#if !defined(NDEBUG) && 0
+               /* removing the entry from the local reference table is not really
+                  necesarry, but gives us warnings if the entry does not exist. */
+
+               localref_del(h);
+#endif
+       }
+}
+#endif /* defined(ENABLE_HANDLES) */
+
+
+/* localref_dump ***************************************************************
+
+   Dumps all local reference tables, including all frames.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+# define LOCALREF_DUMP_REFS_PER_LINE 4
+void localref_dump()
+{
+       localref_table *lrt;
+       int i, j;
+
+       /* get current local reference table from thread */
+
+       lrt = LOCALREFTABLE;
+
+       log_println("--------- Local Reference Tables Dump ---------");
+
+       while (lrt != NULL) {
+               log_println("Frame #%d, Used=%d, Capacity=%d, Addr=%p:", lrt->localframes, lrt->used, lrt->capacity, (void *) lrt);
+
+                       if (lrt->used != 0) {
+
+                               log_start();
+
+                               j = 0;
+                               for (i = 0; i < lrt->capacity; i++) {
+                                       if (lrt->refs[i] != NULL) {
+                                               if (j != 0 && j % LOCALREF_DUMP_REFS_PER_LINE == 0) {
+                                                       log_finish();
+                                                       log_start();
+                                               }
+                                               j++;
+                                               log_print("\t0x%016lx ", (intptr_t) lrt->refs[i]);
+                                       }
+                               }
+
+                               log_finish();
+                       }
+
+               lrt = lrt->prev;
+       }
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* localref_check_uncleared ****************************************************
+
+   Checks the topmost local reference table for uncleared references.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+static bool localref_check_uncleared()
+{
+       localref_table *lrt;
+       int32_t         localframes;
+       int32_t         lrt_uncleared;
+       int32_t         lrt_used;
+       int i;
+
+       /* get current local reference table from thread */
+
+       lrt = LOCALREFTABLE;
+       assert(lrt != NULL);
+       assert(lrt->localframes > 0);
+
+       localframes   = lrt->localframes;
+       lrt_uncleared = 0;
+       lrt_used      = 0;
+
+       for (; localframes > 0; localframes--) {
+               lrt_used += lrt->used;
+
+               for (i = 0; i < lrt->capacity; i++) {
+                       if (lrt->refs[i] != NULL)
+                               lrt_uncleared++;
+               }
+
+               lrt = lrt->prev;
+       }
+
+       if (lrt_uncleared != lrt_used) {
+               localref_dump();
+               vm_abort("localref_check_uncleared: (uncleared=%d) != (used=%d)", lrt_uncleared, lrt_used);
+       }
+
+       if (lrt_uncleared <= 1)
+               return true;
+       else {
+               /*log_println("localref_check_uncleared: %d uncleared local references", lrt_uncleared);*/
+               return false;
+       }
+}
+#endif
+
+
+/*
+ * 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/native/localref.h b/src/native/localref.h
deleted file mode 100644 (file)
index f99a56b..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/* src/native/localref.h - Management of local reference tables
-
-   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
-
-   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 _LOCALREF_H
-#define _LOCALREF_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct localref_table localref_table;
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#include "vmcore/method.h"
-
-
-/* localref_table **************************************************************
-
-   ATTENTION: keep this structure a multiple of 8-bytes!!! This is
-   essential for the native stub on 64-bit architectures.
-
-*******************************************************************************/
-
-#define LOCALREFTABLE_CAPACITY    16
-
-struct localref_table {
-       s4                 capacity;        /* table size                         */
-       s4                 used;            /* currently used references          */
-       s4                 localframes;     /* number of current frames           */
-       s4                 PADDING;         /* 8-byte padding                     */
-       localref_table    *prev;            /* link to prev table (LocalFrame)    */
-       java_object_t     *refs[LOCALREFTABLE_CAPACITY]; /* references            */
-};
-
-
-#if defined(ENABLE_THREADS)
-#define LOCALREFTABLE    (THREADOBJECT->_localref_table)
-#else
-extern localref_table *_no_threads_localref_table;
-
-#define LOCALREFTABLE    (_no_threads_localref_table)
-#endif
-
-
-/* function prototypes ********************************************************/
-
-bool localref_table_init(void);
-bool localref_table_destroy(void);
-void localref_table_add(localref_table *lrt);
-void localref_table_remove();
-
-bool localref_frame_push(int32_t capacity);
-void localref_frame_pop_all(void);
-
-java_handle_t *localref_add(java_object_t *o);
-void           localref_del(java_handle_t *localref);
-
-void localref_native_enter(methodinfo *m, uint64_t *argument_regs, uint64_t *argument_stack);
-void localref_native_exit(methodinfo *m, uint64_t *return_regs);
-
-#if !defined(NDEBUG)
-void localref_dump(void);
-#endif
-
-
-#endif /* _LOCALREF_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:
- */
diff --git a/src/native/localref.hpp b/src/native/localref.hpp
new file mode 100644 (file)
index 0000000..11e212e
--- /dev/null
@@ -0,0 +1,112 @@
+/* src/native/localref.hpp - Management of local reference tables
+
+   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 _LOCALREF_HPP
+#define _LOCALREF_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct localref_table localref_table;
+
+#include "config.h"
+
+#include "vm/types.h"
+
+#include "vm/global.h"
+#include "vm/method.hpp"
+
+
+/* localref_table **************************************************************
+
+   ATTENTION: keep this structure a multiple of 8-bytes!!! This is
+   essential for the native stub on 64-bit architectures.
+
+*******************************************************************************/
+
+#define LOCALREFTABLE_CAPACITY    16
+
+struct localref_table {
+       s4                 capacity;        /* table size                         */
+       s4                 used;            /* currently used references          */
+       s4                 localframes;     /* number of current frames           */
+       s4                 PADDING;         /* 8-byte padding                     */
+       localref_table    *prev;            /* link to prev table (LocalFrame)    */
+       java_object_t     *refs[LOCALREFTABLE_CAPACITY]; /* references            */
+};
+
+
+#if defined(ENABLE_THREADS)
+#define LOCALREFTABLE    (THREADOBJECT->_localref_table)
+#else
+extern localref_table *_no_threads_localref_table;
+
+#define LOCALREFTABLE    (_no_threads_localref_table)
+#endif
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool localref_table_init(void);
+bool localref_table_destroy(void);
+void localref_table_add(localref_table *lrt);
+void localref_table_remove();
+
+bool localref_frame_push(int32_t capacity);
+void localref_frame_pop_all(void);
+
+java_handle_t *localref_add(java_object_t *o);
+void           localref_del(java_handle_t *localref);
+
+void localref_native_enter(methodinfo *m, uint64_t *argument_regs, uint64_t *argument_stack);
+void localref_native_exit(methodinfo *m, uint64_t *return_regs);
+
+#if !defined(NDEBUG)
+void localref_dump(void);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LOCALREF_HPP
+
+
+/*
+ * 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/native/native.c b/src/native/native.c
deleted file mode 100644 (file)
index 9a4cd34..0000000
+++ /dev/null
@@ -1,1027 +0,0 @@
-/* src/native/native.c - table of native 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 <ctype.h>
-
-#if defined(ENABLE_LTDL) && defined(HAVE_LTDL_H)
-# include <ltdl.h>
-#endif
-
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/vm/nativevm.h"
-
-#include "threads/lock-common.h"
-
-#include "toolbox/avl.h"
-#include "toolbox/hashtable.h"
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vm/resolve.h"
-
-#if defined(ENABLE_JVMTI)
-#include "native/jvmti/cacaodbg.h"
-#endif
-
-
-/* global variables ***********************************************************/
-
-static avl_tree_t *tree_native_methods;
-
-#if defined(ENABLE_LTDL)
-static hashtable *hashtable_library;
-#endif
-
-
-/* prototypes *****************************************************************/
-
-static s4 native_tree_native_methods_comparator(const void *treenode, const void *node);
-
-
-/* native_init *****************************************************************
-
-   Initializes the native subsystem.
-
-*******************************************************************************/
-
-bool native_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("native_init");
-
-#if defined(ENABLE_LTDL)
-       /* initialize libltdl */
-
-       if (lt_dlinit())
-               vm_abort("native_init: lt_dlinit failed: %s\n", lt_dlerror());
-
-       /* initialize library hashtable, 10 entries should be enough */
-
-       hashtable_library = NEW(hashtable);
-
-       hashtable_create(hashtable_library, 10);
-#endif
-
-       /* initialize the native methods table */
-
-       tree_native_methods = avl_create(&native_tree_native_methods_comparator);
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* native_tree_native_methods_comparator ***************************************
-
-   Comparison function for AVL tree of native methods.
-
-   IN:
-       treenode....node in the tree
-          node........node to compare with tree-node
-
-   RETURN VALUE:
-       -1, 0, +1
-
-*******************************************************************************/
-
-static s4 native_tree_native_methods_comparator(const void *treenode, const void *node)
-{
-       const native_methods_node_t *treenmn;
-       const native_methods_node_t *nmn;
-
-       treenmn = treenode;
-       nmn     = node;
-
-       /* these are for walking the tree */
-
-       if (treenmn->classname < nmn->classname)
-               return -1;
-       else if (treenmn->classname > nmn->classname)
-               return 1;
-
-       if (treenmn->name < nmn->name)
-               return -1;
-       else if (treenmn->name > nmn->name)
-               return 1;
-
-       if (treenmn->descriptor < nmn->descriptor)
-               return -1;
-       else if (treenmn->descriptor > nmn->descriptor)
-               return 1;
-
-       /* all pointers are equal, we have found the entry */
-
-       return 0;
-}
-
-
-/* native_make_overloaded_function *********************************************
-
-   XXX
-
-*******************************************************************************/
-
-static utf *native_make_overloaded_function(utf *name, utf *descriptor)
-{
-       char *newname;
-       s4    namelen;
-       char *utf_ptr;
-       u2    c;
-       s4    i;
-       utf  *u;
-       int32_t dumpmarker;
-
-       /* mark memory */
-
-       DMARKER;
-
-       utf_ptr = descriptor->text;
-       namelen = strlen(name->text) + strlen("__") + strlen("0");
-
-       /* calculate additional length */
-
-       while ((c = utf_nextu2(&utf_ptr)) != ')') {
-               switch (c) {
-               case 'Z':
-               case 'B':
-               case 'C':
-               case 'S':
-               case 'I':
-               case 'J':
-               case 'F':
-               case 'D':
-                       namelen++;
-                       break;
-               case '[':
-                       namelen += 2;
-                       break;
-               case 'L':
-                       namelen++;
-                       while (utf_nextu2(&utf_ptr) != ';')
-                               namelen++;
-                       namelen += 2;
-                       break;
-               case '(':
-                       break;
-               default:
-                       assert(0);
-               }
-       }
-
-       /* reallocate memory */
-
-       i = strlen(name->text);
-
-       newname = DMNEW(char, namelen);
-       MCOPY(newname, name->text, char, i);
-
-       utf_ptr = descriptor->text;
-
-       newname[i++] = '_';
-       newname[i++] = '_';
-
-       while ((c = utf_nextu2(&utf_ptr)) != ')') {
-               switch (c) {
-               case 'Z':
-               case 'B':
-               case 'C':
-               case 'S':
-               case 'J':
-               case 'I':
-               case 'F':
-               case 'D':
-                       newname[i++] = c;
-                       break;
-               case '[':
-                       newname[i++] = '_';
-                       newname[i++] = '3';
-                       break;
-               case 'L':
-                       newname[i++] = 'L';
-                       while ((c = utf_nextu2(&utf_ptr)) != ';')
-                               if (((c >= 'a') && (c <= 'z')) ||
-                                       ((c >= 'A') && (c <= 'Z')) ||
-                                       ((c >= '0') && (c <= '9')))
-                                       newname[i++] = c;
-                               else
-                                       newname[i++] = '_';
-                       newname[i++] = '_';
-                       newname[i++] = '2';
-                       break;
-               case '(':
-                       break;
-               default:
-                       assert(0);
-               }
-       }
-
-       /* close string */
-
-       newname[i] = '\0';
-
-       /* make a utf-string */
-
-       u = utf_new_char(newname);
-
-       /* release memory */
-
-       DRELEASE;
-
-       return u;
-}
-
-
-/* native_insert_char **********************************************************
-
-   Inserts the passed UTF character into the native method name.  If
-   necessary it is escaped properly.
-
-*******************************************************************************/
-
-static s4 native_insert_char(char *name, u4 pos, u2 c)
-{
-       s4 val;
-       s4 i;
-
-       switch (c) {
-       case '/':
-       case '.':
-               /* replace '/' or '.' with '_' */
-               name[pos] = '_';
-               break;
-
-       case '_':
-               /* escape sequence for '_' is '_1' */
-               name[pos]   = '_';
-               name[++pos] = '1';
-               break;
-
-       case ';':
-               /* escape sequence for ';' is '_2' */
-               name[pos]   = '_';
-               name[++pos] = '2';
-               break;
-
-       case '[':
-               /* escape sequence for '[' is '_1' */
-               name[pos]   = '_';
-               name[++pos] = '3';
-               break;
-
-       default:
-               if (isalnum(c))
-                       name[pos] = c;
-               else {
-                       /* unicode character */
-                       name[pos]   = '_';
-                       name[++pos] = '0';
-
-                       for (i = 0; i < 4; ++i) {
-                               val = c & 0x0f;
-                               name[pos + 4 - i] = (val > 10) ? ('a' + val - 10) : ('0' + val);
-                               c >>= 4;
-                       }
-
-                       pos += 4;
-               }
-               break;
-       }
-
-       /* return the new buffer index */
-
-       return pos;
-}
-
-
-/* native_method_symbol ********************************************************
-
-   Generate a method-symbol string out of the class name and the
-   method name.
-
-*******************************************************************************/
-
-static utf *native_method_symbol(utf *classname, utf *methodname)
-{
-       char *name;
-       s4    namelen;
-       char *utf_ptr;
-       char *utf_endptr;
-       u2    c;
-       u4    pos;
-       utf  *u;
-       int32_t dumpmarker;
-
-       /* mark memory */
-
-       DMARKER;
-
-       /* Calculate length of native function name.  We multiply the
-          class and method name length by 6 as this is the maxium
-          escape-sequence that can be generated (unicode). */
-
-       namelen =
-               strlen("Java_") +
-               utf_get_number_of_u2s(classname) * 6 +
-               strlen("_") +
-               utf_get_number_of_u2s(methodname) * 6 +
-               strlen("0");
-
-       /* allocate memory */
-
-       name = DMNEW(char, namelen);
-
-       /* generate name of native functions */
-
-       strcpy(name, "Java_");
-       pos = strlen("Java_");
-
-       utf_ptr    = classname->text;
-       utf_endptr = UTF_END(classname);
-
-       for (; utf_ptr < utf_endptr; utf_ptr++, pos++) {
-               c   = *utf_ptr;
-               pos = native_insert_char(name, pos, c);
-       }
-
-       /* seperator between class and method */
-
-       name[pos++] = '_';
-
-       utf_ptr    = methodname->text;
-       utf_endptr = UTF_END(methodname);
-
-       for (; utf_ptr < utf_endptr; utf_ptr++, pos++) {
-               c   = *utf_ptr;
-               pos = native_insert_char(name, pos, c);
-       }
-
-       /* close string */
-
-       name[pos] = '\0';
-
-       /* check for an buffer overflow */
-
-       assert(pos <= namelen);
-
-       /* make a utf-string */
-
-       u = utf_new_char(name);
-
-       /* release memory */
-
-       DRELEASE;
-
-       return u;
-}
-
-
-/* native_method_register ******************************************************
-
-   Register a native method in the native method table.
-
-*******************************************************************************/
-
-void native_method_register(utf *classname, const JNINativeMethod *methods,
-                                                       int32_t count)
-{
-       native_methods_node_t *nmn;
-       utf                   *name;
-       utf                   *descriptor;
-       int32_t                i;
-
-       /* insert all methods passed */
-
-       for (i = 0; i < count; i++) {
-               if (opt_verbosejni) {
-                       printf("[Registering JNI native method ");
-                       utf_display_printable_ascii_classname(classname);
-                       printf(".%s]\n", methods[i].name);
-               }
-
-               /* generate the utf8 names */
-
-               name       = utf_new_char(methods[i].name);
-               descriptor = utf_new_char(methods[i].signature);
-
-               /* allocate a new tree node */
-
-               nmn = NEW(native_methods_node_t);
-
-               nmn->classname  = classname;
-               nmn->name       = name;
-               nmn->descriptor = descriptor;
-               nmn->function   = (functionptr) (ptrint) methods[i].fnPtr;
-
-               /* insert the method into the tree */
-
-               avl_insert(tree_native_methods, nmn);
-       }
-}
-
-
-/* native_method_find **********************************************************
-
-   Find a native method in the native method table.
-
-*******************************************************************************/
-
-static functionptr native_method_find(methodinfo *m)
-{
-       native_methods_node_t  tmpnmn;
-       native_methods_node_t *nmn;
-
-       /* fill the temporary structure used for searching the tree */
-
-       tmpnmn.classname  = m->clazz->name;
-       tmpnmn.name       = m->name;
-       tmpnmn.descriptor = m->descriptor;
-
-       /* find the entry in the AVL-tree */
-
-       nmn = avl_find(tree_native_methods, &tmpnmn);
-
-       if (nmn == NULL)
-               return NULL;
-
-       return nmn->function;
-}
-
-
-/* native_method_resolve *******************************************************
-
-   Resolves a native method, maybe from a dynamic library.
-
-   IN:
-       m ... methodinfo of the native Java method to resolve
-
-   RESULT:
-       pointer to the resolved method (symbol)
-
-*******************************************************************************/
-
-functionptr native_method_resolve(methodinfo *m)
-{
-       utf                            *name;
-       utf                            *newname;
-       functionptr                     f;
-#if defined(ENABLE_LTDL)
-       classloader_t                  *cl;
-       hashtable_library_loader_entry *le;
-       hashtable_library_name_entry   *ne;
-       u4                              key;    /* hashkey                        */
-       u4                              slot;   /* slot in hashtable              */
-#endif
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       methodinfo                     *method_findNative;
-       java_handle_t                  *s;
-#endif
-
-       /* verbose output */
-
-       if (opt_verbosejni) {
-               printf("[Dynamic-linking native method ");
-               utf_display_printable_ascii_classname(m->clazz->name);
-               printf(".");
-               utf_display_printable_ascii(m->name);
-               printf(" ... ");
-       }
-
-       /* generate method symbol string */
-
-       name = native_method_symbol(m->clazz->name, m->name);
-
-       /* generate overloaded function (having the types in it's name)           */
-
-       newname = native_make_overloaded_function(name, m->descriptor);
-
-       /* check the library hash entries of the classloader of the
-          methods's class  */
-
-       f = NULL;
-
-#if defined(ENABLE_LTDL)
-       /* Get the classloader. */
-
-       cl = class_get_classloader(m->clazz);
-
-       /* normally addresses are aligned to 4, 8 or 16 bytes */
-
-       key  = ((u4) (ptrint) cl) >> 4;                       /* align to 16-byte */
-       slot = key & (hashtable_library->size - 1);
-       le   = hashtable_library->ptr[slot];
-
-       /* iterate through loaders in this hash slot */
-
-       while ((le != NULL) && (f == NULL)) {
-               /* iterate through names in this loader */
-
-               ne = le->namelink;
-                       
-               while ((ne != NULL) && (f == NULL)) {
-                       f = (functionptr) (ptrint) lt_dlsym(ne->handle, name->text);
-
-                       if (f == NULL)
-                               f = (functionptr) (ptrint) lt_dlsym(ne->handle, newname->text);
-
-                       ne = ne->hashlink;
-               }
-
-               le = le->hashlink;
-       }
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       if (f == NULL) {
-               /* We can resolve the function directly from
-                  java.lang.ClassLoader as it's a static function. */
-               /* XXX should be done in native_init */
-
-               method_findNative =
-                       class_resolveclassmethod(class_java_lang_ClassLoader,
-                                                                        utf_findNative,
-                                                                        utf_java_lang_ClassLoader_java_lang_String__J,
-                                                                        class_java_lang_ClassLoader,
-                                                                        true);
-
-               if (method_findNative == NULL)
-                       return NULL;
-
-               /* try the normal name */
-
-               s = javastring_new(name);
-
-               f = (functionptr) (intptr_t) vm_call_method_long(method_findNative,
-                                                                                                                NULL, cl, s);
-
-               /* if not found, try the mangled name */
-
-               if (f == NULL) {
-                       s = javastring_new(newname);
-
-                       f = (functionptr) (intptr_t) vm_call_method_long(method_findNative,
-                                                                                                                        NULL, cl, s);
-               }
-       }
-# endif
-
-       if (f != NULL)
-               if (opt_verbosejni)
-                       printf("JNI ]\n");
-#endif
-
-       /* If not found, try to find the native function symbol in the
-          main program. */
-
-       if (f == NULL) {
-               f = native_method_find(m);
-
-               if (f != NULL)
-                       if (opt_verbosejni)
-                               printf("internal ]\n");
-       }
-
-#if defined(ENABLE_JVMTI)
-       /* fire Native Method Bind event */
-       if (jvmti) jvmti_NativeMethodBind(m, f, &f);
-#endif
-
-       /* no symbol found? throw exception */
-
-       if (f == NULL) {
-               if (opt_verbosejni)
-                       printf("failed ]\n");
-
-               exceptions_throw_unsatisfiedlinkerror(m->name);
-       }
-
-       return f;
-}
-
-
-/* native_library_open *********************************************************
-
-   Open a native library with the given utf8 name.
-
-   IN:
-       filename ... filename of the library to open
-
-   RETURN:
-       handle of the opened library
-
-*******************************************************************************/
-
-#if defined(ENABLE_LTDL)
-lt_dlhandle native_library_open(utf *filename)
-{
-       lt_dlhandle handle;
-
-       if (opt_verbosejni) {
-               printf("[Loading native library ");
-               utf_display_printable_ascii(filename);
-               printf(" ... ");
-       }
-
-       /* try to open the library */
-
-       handle = lt_dlopen(filename->text);
-
-       if (handle == NULL) {
-               if (opt_verbosejni)
-                       printf("failed ]\n");
-
-               if (opt_verbose) {
-                       log_start();
-                       log_print("native_library_open: lt_dlopen failed: ");
-                       log_print(lt_dlerror());
-                       log_finish();
-               }
-
-               return NULL;
-       }
-
-       if (opt_verbosejni)
-               printf("OK ]\n");
-
-       return handle;
-}
-#endif
-
-
-/* native_library_close ********************************************************
-
-   Close the native library of the given handle.
-
-   IN:
-       handle ... handle of the open library
-
-*******************************************************************************/
-
-#if defined(ENABLE_LTDL)
-void native_library_close(lt_dlhandle handle)
-{
-       int result;
-
-       if (opt_verbosejni) {
-               printf("[Unloading native library ");
-/*             utf_display_printable_ascii(filename); */
-               printf(" ... ");
-       }
-
-       /* Close the library. */
-
-       result = lt_dlclose(handle);
-
-       if (result != 0) {
-               if (opt_verbose) {
-                       log_start();
-                       log_print("native_library_close: lt_dlclose failed: ");
-                       log_print(lt_dlerror());
-                       log_finish();
-               }
-       }
-}
-#endif
-
-
-/* native_library_add **********************************************************
-
-   Adds an entry to the native library hashtable.
-
-*******************************************************************************/
-
-#if defined(ENABLE_LTDL)
-void native_library_add(utf *filename, classloader_t *loader, lt_dlhandle handle)
-{
-       hashtable_library_loader_entry *le;
-       hashtable_library_name_entry   *ne; /* library name                       */
-       u4   key;                           /* hashkey                            */
-       u4   slot;                          /* slot in hashtable                  */
-
-       LOCK_MONITOR_ENTER(hashtable_library->header);
-
-       /* normally addresses are aligned to 4, 8 or 16 bytes */
-
-       key  = ((u4) (ptrint) loader) >> 4;        /* align to 16-byte boundaries */
-       slot = key & (hashtable_library->size - 1);
-       le   = hashtable_library->ptr[slot];
-
-       /* search external hash chain for the entry */
-
-       while (le) {
-               if (le->loader == loader)
-                       break;
-
-               le = le->hashlink;                  /* next element in external chain */
-       }
-
-       /* no loader found? create a new entry */
-
-       if (le == NULL) {
-               le = NEW(hashtable_library_loader_entry);
-
-               le->loader   = loader;
-               le->namelink = NULL;
-
-               /* insert entry into hashtable */
-
-               le->hashlink =
-                       (hashtable_library_loader_entry *) hashtable_library->ptr[slot];
-               hashtable_library->ptr[slot] = le;
-
-               /* update number of hashtable-entries */
-
-               hashtable_library->entries++;
-       }
-
-
-       /* search for library name */
-
-       ne = le->namelink;
-
-       while (ne) {
-               if (ne->name == filename) {
-                       LOCK_MONITOR_EXIT(hashtable_library->header);
-
-                       return;
-               }
-
-               ne = ne->hashlink;                  /* next element in external chain */
-       }
-
-       /* not found? add the library name to the classloader */
-
-       ne = NEW(hashtable_library_name_entry);
-
-       ne->name   = filename;
-       ne->handle = handle;
-
-       /* insert entry into external chain */
-
-       ne->hashlink = le->namelink;
-       le->namelink = ne;
-
-       LOCK_MONITOR_EXIT(hashtable_library->header);
-}
-#endif
-
-
-/* native_library_find *********************************************************
-
-   Find an entry in the native library hashtable.
-
-*******************************************************************************/
-
-#if defined(ENABLE_LTDL)
-hashtable_library_name_entry *native_library_find(utf *filename,
-                                                                                                 classloader_t *loader)
-{
-       hashtable_library_loader_entry *le;
-       hashtable_library_name_entry   *ne; /* library name                       */
-       u4   key;                           /* hashkey                            */
-       u4   slot;                          /* slot in hashtable                  */
-
-       /* normally addresses are aligned to 4, 8 or 16 bytes */
-
-       key  = ((u4) (ptrint) loader) >> 4;        /* align to 16-byte boundaries */
-       slot = key & (hashtable_library->size - 1);
-       le   = hashtable_library->ptr[slot];
-
-       /* search external hash chain for the entry */
-
-       while (le) {
-               if (le->loader == loader)
-                       break;
-
-               le = le->hashlink;                  /* next element in external chain */
-       }
-
-       /* no loader found? return NULL */
-
-       if (le == NULL)
-               return NULL;
-
-       /* search for library name */
-
-       ne = le->namelink;
-
-       while (ne) {
-               if (ne->name == filename)
-                       return ne;
-
-               ne = ne->hashlink;                  /* next element in external chain */
-       }
-
-       /* return entry, if no entry was found, ne is NULL */
-
-       return ne;
-}
-#endif
-
-
-/* native_library_load *********************************************************
-
-   Load a native library and initialize it, if possible.
-
-   IN:
-       name ... name of the library
-          cl ..... classloader which loads this library
-
-   RETURN:
-       1 ... library loaded successfully
-       0 ... error
-
-*******************************************************************************/
-
-int native_library_load(JNIEnv *env, utf *name, classloader_t *cl)
-{
-#if defined(ENABLE_LTDL)
-       lt_dlhandle        handle;
-# if defined(ENABLE_JNI)
-       lt_ptr             onload;
-       int32_t            version;
-# endif
-
-       if (name == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       /* Is the library already loaded? */
-
-       if (native_library_find(name, cl) != NULL)
-               return 1;
-
-       /* Open the library. */
-
-       handle = native_library_open(name);
-
-       if (handle == NULL)
-               return 0;
-
-# if defined(ENABLE_JNI)
-       /* Resolve JNI_OnLoad function. */
-
-       onload = lt_dlsym(handle, "JNI_OnLoad");
-
-       if (onload != NULL) {
-               JNIEXPORT int32_t (JNICALL *JNI_OnLoad) (JavaVM *, void *);
-               JavaVM *vm;
-
-               JNI_OnLoad = (JNIEXPORT int32_t (JNICALL *)(JavaVM *, void *)) (ptrint) onload;
-
-               (*env)->GetJavaVM(env, &vm);
-
-               version = JNI_OnLoad(vm, NULL);
-
-               /* If the version is not 1.2 and not 1.4 the library cannot be
-                  loaded. */
-
-               if ((version != JNI_VERSION_1_2) && (version != JNI_VERSION_1_4)) {
-                       lt_dlclose(handle);
-                       return 0;
-               }
-       }
-# endif
-
-       /* Insert the library name into the library hash. */
-
-       native_library_add(name, cl, handle);
-
-       return 1;
-#else
-       vm_abort("native_library_load: not available");
-
-       /* Keep compiler happy. */
-
-       return 0;
-#endif
-}
-
-
-/* native_new_and_init *********************************************************
-
-   Creates a new object on the heap and calls the initializer.
-   Returns the object pointer or NULL if memory is exhausted.
-                       
-*******************************************************************************/
-
-java_handle_t *native_new_and_init(classinfo *c)
-{
-       methodinfo    *m;
-       java_handle_t *o;
-
-       if (c == NULL)
-               vm_abort("native_new_and_init: c == NULL");
-
-       /* create object */
-
-       o = builtin_new(c);
-       
-       if (o == NULL)
-               return NULL;
-
-       /* try to find the initializer */
-
-       m = class_findmethod(c, utf_init, utf_void__void);
-                                                     
-       /* ATTENTION: returning the object here is ok, since the class may
-       not have an initializer */
-
-       if (m == NULL)
-               return o;
-
-       /* call initializer */
-
-       (void) vm_call_method(m, o);
-
-       return o;
-}
-
-
-java_handle_t *native_new_and_init_string(classinfo *c, java_handle_t *s)
-{
-       methodinfo    *m;
-       java_handle_t *o;
-
-       if (c == NULL)
-               vm_abort("native_new_and_init_string: c == NULL");
-
-       /* create object */
-
-       o = builtin_new(c);
-
-       if (o == NULL)
-               return NULL;
-
-       /* find initializer */
-
-       m = class_findmethod(c, utf_init, utf_java_lang_String__void);
-
-       /* initializer not found */
-
-       if (m == NULL)
-               return NULL;
-
-       /* call initializer */
-
-       (void) vm_call_method(m, o, s);
-
-       return o;
-}
-
-
-/*
- * 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/native/native.cpp b/src/native/native.cpp
new file mode 100644 (file)
index 0000000..7f0f078
--- /dev/null
@@ -0,0 +1,814 @@
+/* src/native/native.cpp - native library support
+
+   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 <ctype.h>
+
+#include <stdint.h>
+
+#include <algorithm>
+#include <functional>
+#include <map>
+
+#include "mm/memory.h"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#include "threads/mutex.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/os.hpp"
+#include "vm/resolve.hpp"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/jit.hpp"
+
+#if defined(ENABLE_JVMTI)
+#include "native/jvmti/cacaodbg.h"
+#endif
+
+
+/* native_make_overloaded_function *********************************************
+
+   XXX
+
+*******************************************************************************/
+
+static utf *native_make_overloaded_function(utf *name, utf *descriptor)
+{
+       char *newname;
+       s4    namelen;
+       char *utf_ptr;
+       u2    c;
+       s4    i;
+       utf  *u;
+
+       utf_ptr = descriptor->text;
+       namelen = strlen(name->text) + strlen("__") + strlen("0");
+
+       /* calculate additional length */
+
+       while ((c = utf_nextu2(&utf_ptr)) != ')') {
+               switch (c) {
+               case 'Z':
+               case 'B':
+               case 'C':
+               case 'S':
+               case 'I':
+               case 'J':
+               case 'F':
+               case 'D':
+                       namelen++;
+                       break;
+               case '[':
+                       namelen += 2;
+                       break;
+               case 'L':
+                       namelen++;
+                       while (utf_nextu2(&utf_ptr) != ';')
+                               namelen++;
+                       namelen += 2;
+                       break;
+               case '(':
+                       break;
+               default:
+                       assert(0);
+               }
+       }
+
+       /* reallocate memory */
+
+       i = strlen(name->text);
+
+       newname = MNEW(char, namelen);
+       MCOPY(newname, name->text, char, i);
+
+       utf_ptr = descriptor->text;
+
+       newname[i++] = '_';
+       newname[i++] = '_';
+
+       while ((c = utf_nextu2(&utf_ptr)) != ')') {
+               switch (c) {
+               case 'Z':
+               case 'B':
+               case 'C':
+               case 'S':
+               case 'J':
+               case 'I':
+               case 'F':
+               case 'D':
+                       newname[i++] = c;
+                       break;
+               case '[':
+                       newname[i++] = '_';
+                       newname[i++] = '3';
+                       break;
+               case 'L':
+                       newname[i++] = 'L';
+                       while ((c = utf_nextu2(&utf_ptr)) != ';')
+                               if (((c >= 'a') && (c <= 'z')) ||
+                                       ((c >= 'A') && (c <= 'Z')) ||
+                                       ((c >= '0') && (c <= '9')))
+                                       newname[i++] = c;
+                               else
+                                       newname[i++] = '_';
+                       newname[i++] = '_';
+                       newname[i++] = '2';
+                       break;
+               case '(':
+                       break;
+               default:
+                       assert(0);
+               }
+       }
+
+       /* close string */
+
+       newname[i] = '\0';
+
+       /* make a utf-string */
+
+       u = utf_new_char(newname);
+
+       /* release memory */
+
+       MFREE(newname, char, namelen);
+
+       return u;
+}
+
+
+/* native_insert_char **********************************************************
+
+   Inserts the passed UTF character into the native method name.  If
+   necessary it is escaped properly.
+
+*******************************************************************************/
+
+static s4 native_insert_char(char *name, u4 pos, u2 c)
+{
+       s4 val;
+       s4 i;
+
+       switch (c) {
+       case '/':
+       case '.':
+               /* replace '/' or '.' with '_' */
+               name[pos] = '_';
+               break;
+
+       case '_':
+               /* escape sequence for '_' is '_1' */
+               name[pos]   = '_';
+               name[++pos] = '1';
+               break;
+
+       case ';':
+               /* escape sequence for ';' is '_2' */
+               name[pos]   = '_';
+               name[++pos] = '2';
+               break;
+
+       case '[':
+               /* escape sequence for '[' is '_1' */
+               name[pos]   = '_';
+               name[++pos] = '3';
+               break;
+
+       default:
+               if (isalnum(c))
+                       name[pos] = c;
+               else {
+                       /* unicode character */
+                       name[pos]   = '_';
+                       name[++pos] = '0';
+
+                       for (i = 0; i < 4; ++i) {
+                               val = c & 0x0f;
+                               name[pos + 4 - i] = (val > 10) ? ('a' + val - 10) : ('0' + val);
+                               c >>= 4;
+                       }
+
+                       pos += 4;
+               }
+               break;
+       }
+
+       /* return the new buffer index */
+
+       return pos;
+}
+
+
+/* native_method_symbol ********************************************************
+
+   Generate a method-symbol string out of the class name and the
+   method name.
+
+*******************************************************************************/
+
+static utf *native_method_symbol(utf *classname, utf *methodname)
+{
+       char *name;
+       s4    namelen;
+       char *utf_ptr;
+       char *utf_endptr;
+       u2    c;
+       u4    pos;
+       utf  *u;
+
+       /* Calculate length of native function name.  We multiply the
+          class and method name length by 6 as this is the maxium
+          escape-sequence that can be generated (unicode). */
+
+       namelen =
+               strlen("Java_") +
+               utf_get_number_of_u2s(classname) * 6 +
+               strlen("_") +
+               utf_get_number_of_u2s(methodname) * 6 +
+               strlen("0");
+
+       /* allocate memory */
+
+       name = MNEW(char, namelen);
+
+       /* generate name of native functions */
+
+       strcpy(name, "Java_");
+       pos = strlen("Java_");
+
+       utf_ptr    = classname->text;
+       utf_endptr = UTF_END(classname);
+
+       for (; utf_ptr < utf_endptr; utf_ptr++, pos++) {
+               c   = *utf_ptr;
+               pos = native_insert_char(name, pos, c);
+       }
+
+       /* seperator between class and method */
+
+       name[pos++] = '_';
+
+       utf_ptr    = methodname->text;
+       utf_endptr = UTF_END(methodname);
+
+       for (; utf_ptr < utf_endptr; utf_ptr++, pos++) {
+               c   = *utf_ptr;
+               pos = native_insert_char(name, pos, c);
+       }
+
+       /* close string */
+
+       name[pos] = '\0';
+
+       /* check for an buffer overflow */
+
+       assert((int32_t) pos <= namelen);
+
+       /* make a utf-string */
+
+       u = utf_new_char(name);
+
+       /* release memory */
+
+       MFREE(name, char, namelen);
+
+       return u;
+}
+
+
+bool operator< (const NativeMethod& first, const NativeMethod& second)
+{
+       if (first._classname < second._classname)
+               return true;
+       else if (first._classname > second._classname)
+               return false;
+               
+       if (first._name < second._name)
+               return true;
+       else if (first._name > second._name)
+               return false;
+
+       if (first._descriptor < second._descriptor)
+               return true;
+       else if (first._descriptor > second._descriptor)
+               return false;
+
+       // All pointers are equal, we have found the entry.
+       return false;
+}
+
+
+/**
+ * Register native methods with the VM.  This is done by inserting
+ * them into the native method table.
+ *
+ * @param classname
+ * @param methods   Native methods array.
+ * @param count     Number of methods in the array.
+ */
+void NativeMethods::register_methods(utf* classname, const JNINativeMethod* methods, size_t count)
+{
+       // Insert all methods passed */
+       for (size_t i = 0; i < count; i++) {
+               if (opt_verbosejni) {
+                       printf("[Registering JNI native method ");
+                       utf_display_printable_ascii_classname(classname);
+                       printf(".%s]\n", methods[i].name);
+               }
+
+               // Generate the UTF8 names.
+               utf* name      = utf_new_char(methods[i].name);
+               utf* signature = utf_new_char(methods[i].signature);
+
+               NativeMethod nm(classname, name, signature, methods[i].fnPtr);
+
+               // Insert the method into the table.
+               _methods.insert(nm);
+       }
+}
+
+
+/**
+ * Resolves a native method, maybe from a dynamic library.
+ *
+ * @param m Method structure of the native Java method to resolve.
+ *
+ * @return Pointer to the resolved method (symbol).
+ */
+void* NativeMethods::resolve_method(methodinfo* m)
+{
+       // Verbose output.
+       if (opt_verbosejni) {
+               printf("[Dynamic-linking native method ");
+               utf_display_printable_ascii_classname(m->clazz->name);
+               printf(".");
+               utf_display_printable_ascii(m->name);
+               printf(" ... ");
+       }
+
+       /* generate method symbol string */
+
+       utf* name = native_method_symbol(m->clazz->name, m->name);
+
+       /* generate overloaded function (having the types in it's name)           */
+
+       utf* newname = native_make_overloaded_function(name, m->descriptor);
+
+       // Try to find the symbol.
+       void* symbol = NULL;
+
+#if defined(ENABLE_DL)
+       // Get the classloader.
+       classloader_t* classloader = class_get_classloader(m->clazz);
+
+       // Resolve the native method name from the native libraries.
+       NativeLibraries& libraries = VM::get_current()->get_nativelibraries();
+       symbol = libraries.resolve_symbol(name, classloader);
+
+       if (symbol == NULL)
+               symbol = libraries.resolve_symbol(newname, classloader);
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       if (symbol == NULL) {
+               /* We can resolve the function directly from
+                  java.lang.ClassLoader as it's a static function. */
+               /* XXX should be done in native_init */
+
+               methodinfo* method_findNative =
+                       class_resolveclassmethod(class_java_lang_ClassLoader,
+                                                                        utf_findNative,
+                                                                        utf_java_lang_ClassLoader_java_lang_String__J,
+                                                                        class_java_lang_ClassLoader,
+                                                                        true);
+
+               if (method_findNative == NULL)
+                       return NULL;
+
+               // Try the normal name.
+               java_handle_t* s = javastring_new(name);
+               symbol = (void*) vm_call_method_long(method_findNative, NULL, classloader, s);
+
+               // If not found, try the mangled name.
+               if (symbol == NULL) {
+                       s = javastring_new(newname);
+                       symbol = (void*) vm_call_method_long(method_findNative, NULL, classloader, s);
+               }
+       }
+# endif
+
+       if (symbol != NULL)
+               if (opt_verbosejni)
+                       printf("JNI ]\n");
+#endif
+
+       // If not found already, try to find the native method symbol in
+       // the native methods registered with the VM.
+       if (symbol == NULL) {
+               symbol = find_registered_method(m);
+
+               if (symbol != NULL)
+                       if (opt_verbosejni)
+                               printf("internal ]\n");
+       }
+
+#if defined(ENABLE_JVMTI)
+       /* fire Native Method Bind event */
+       if (jvmti) jvmti_NativeMethodBind(m, f, &f);
+#endif
+
+       // Symbol not found?  Throw an exception.
+       if (symbol == NULL) {
+               if (opt_verbosejni)
+                       printf("failed ]\n");
+
+               exceptions_throw_unsatisfiedlinkerror(m->name);
+       }
+
+       return symbol;
+}
+
+
+/**
+ * Try to find the given method in the native methods registered with
+ * the VM.
+ *
+ * @param m Method structure.
+ *
+ * @return Pointer to function if found, NULL otherwise.
+ */
+void* NativeMethods::find_registered_method(methodinfo* m)
+{
+       NativeMethod nm(m);
+       std::set<NativeMethod>::iterator it = _methods.find(nm);
+
+       if (it == _methods.end())
+               return NULL;
+
+       return (*it).get_function();
+}
+
+
+/**
+ * Open this native library.
+ *
+ * @return File handle on success, NULL otherwise.
+ */
+#if defined(ENABLE_DL)
+void* NativeLibrary::open()
+{
+       if (opt_verbosejni) {
+               printf("[Loading native library ");
+               utf_display_printable_ascii(_filename);
+               printf(" ... ");
+       }
+
+       // Sanity check.
+       assert(_filename != NULL);
+
+       // Try to open the library.
+       _handle = os::dlopen(_filename->text, RTLD_LAZY);
+
+       if (_handle == NULL) {
+               if (opt_verbosejni)
+                       printf("failed ]\n");
+
+               if (opt_verbose) {
+                       log_start();
+                       log_print("NativeLibrary::open: os::dlopen failed: ");
+                       log_print(os::dlerror());
+                       log_finish();
+               }
+
+               return NULL;
+       }
+
+       if (opt_verbosejni)
+               printf("OK ]\n");
+
+       return _handle;
+}
+#endif
+
+
+/**
+ * Close this native library.
+ */
+#if defined(ENABLE_DL)
+void NativeLibrary::close()
+{
+       if (opt_verbosejni) {
+               printf("[Unloading native library ");
+/*             utf_display_printable_ascii(filename); */
+               printf(" ... ");
+       }
+
+       // Sanity check.
+       assert(_handle != NULL);
+
+       // Close the library.
+       int result = os::dlclose(_handle);
+
+       if (result != 0) {
+               if (opt_verbosejni)
+                       printf("failed ]\n");
+
+               if (opt_verbose) {
+                       log_start();
+                       log_print("NativeLibrary::close: os::dlclose failed: ");
+                       log_print(os::dlerror());
+                       log_finish();
+               }
+       }
+
+       if (opt_verbosejni)
+               printf("OK ]\n");
+}
+#endif
+
+
+/**
+ * Load this native library and initialize it, if possible.
+ *
+ * @param env JNI environment.
+ *
+ * @return true if library loaded successfully, false otherwise.
+ */
+bool NativeLibrary::load(JNIEnv* env)
+{
+#if defined(ENABLE_DL)
+       if (_filename == NULL) {
+               exceptions_throw_nullpointerexception();
+               return false;
+       }
+
+       // Is the library already loaded?
+       if (is_loaded())
+               return true;
+
+       // Open the library.
+       open();
+
+       if (_handle == NULL)
+               return false;
+
+# if defined(ENABLE_JNI)
+       // Resolve JNI_OnLoad function.
+       void* onload = os::dlsym(_handle, "JNI_OnLoad");
+
+       if (onload != NULL) {
+               JNIEXPORT jint (JNICALL *JNI_OnLoad) (JavaVM*, void*);
+               JavaVM *vm;
+
+               JNI_OnLoad = (JNIEXPORT jint (JNICALL *)(JavaVM*, void*)) (uintptr_t) onload;
+
+               env->GetJavaVM(&vm);
+
+               jint version = JNI_OnLoad(vm, NULL);
+
+               // If the version is not 1.2 and not 1.4 the library cannot be
+               // loaded.
+               if ((version != JNI_VERSION_1_2) && (version != JNI_VERSION_1_4)) {
+                       os::dlclose(_handle);
+                       return false;
+               }
+       }
+# endif
+
+       // Insert the library name into the native library table.
+       NativeLibraries& nativelibraries = VM::get_current()->get_nativelibraries();
+       nativelibraries.add(*this);
+
+       return true;
+#else
+       os::abort("NativeLibrary::load: Not available in this configuration.");
+
+       // Keep the compiler happy.
+       return false;
+#endif
+}
+
+
+/**
+ * Checks if this native library is loaded.
+ *
+ * @return true if loaded, false otherwise.
+ */
+#if defined(ENABLE_DL)
+bool NativeLibrary::is_loaded()
+{
+       NativeLibraries& libraries = VM::get_current()->get_nativelibraries();
+       return libraries.is_loaded(*this);
+}
+#endif
+
+
+/**
+ * Resolve the given symbol in this native library.
+ *
+ * @param symbolname Symbol name.
+ *
+ * @return Pointer to symbol if found, NULL otherwise.
+ */
+void* NativeLibrary::resolve_symbol(utf* symbolname) const
+{
+       return os::dlsym(_handle, symbolname->text);
+}
+
+
+/**
+ * Add the given native library to the native libraries table.
+ *
+ * @param library Native library to insert.
+ */
+#if defined(ENABLE_DL)
+void NativeLibraries::add(NativeLibrary& library)
+{
+       // Make the container thread-safe.
+       _mutex.lock();
+
+       // XXX Check for double entries.
+       // Insert the native library.
+       _libraries.insert(std::make_pair(library.get_classloader(), library));
+
+       _mutex.unlock();
+}
+#endif
+
+
+/**
+ * Checks if the given native library is loaded.
+ *
+ * @param library Native library.
+ *
+ * @return true if loaded, false otherwise.
+ */
+bool NativeLibraries::is_loaded(NativeLibrary& library)
+{
+       std::pair<MAP::const_iterator, MAP::const_iterator> its = _libraries.equal_range(library.get_classloader());
+
+       // No entry for the classloader was found (the range has length
+       // zero).
+       if (its.first == its.second)
+               return false;
+       
+       MAP::const_iterator it = find_if(its.first, its.second, std::bind2nd(comparator(), library.get_filename()));
+
+       // No matching entry in the range found.
+       if (it == its.second)
+               return false;
+
+       return true;
+}
+
+
+/**
+ * Try to find a symbol with the given name in all loaded native
+ * libraries defined by classloader.
+ *
+ * @param symbolname  Name of the symbol to find.
+ * @param classloader Defining classloader.
+ *
+ * @return Pointer to symbol if found, NULL otherwise.
+ */
+void* NativeLibraries::resolve_symbol(utf* symbolname, classloader_t* classloader)
+{
+       std::pair<MAP::const_iterator, MAP::const_iterator> its = _libraries.equal_range(classloader);
+
+       // No entry for the classloader was found (the range has length
+       // zero).
+       if (its.first == its.second)
+               return NULL;
+
+       for (MAP::const_iterator it = its.first; it != its.second; it++) {
+               const NativeLibrary& library = (*it).second;
+               void* symbol = library.resolve_symbol(symbolname);
+
+               if (symbol != NULL)
+                       return symbol;
+       }
+
+       return NULL;
+}
+
+
+/* native_new_and_init *********************************************************
+
+   Creates a new object on the heap and calls the initializer.
+   Returns the object pointer or NULL if memory is exhausted.
+                       
+*******************************************************************************/
+
+java_handle_t *native_new_and_init(classinfo *c)
+{
+       methodinfo    *m;
+       java_handle_t *o;
+
+       if (c == NULL)
+               vm_abort("native_new_and_init: c == NULL");
+
+       /* create object */
+
+       o = builtin_new(c);
+       
+       if (o == NULL)
+               return NULL;
+
+       /* try to find the initializer */
+
+       m = class_findmethod(c, utf_init, utf_void__void);
+                                                     
+       /* ATTENTION: returning the object here is ok, since the class may
+       not have an initializer */
+
+       if (m == NULL)
+               return o;
+
+       /* call initializer */
+
+       (void) vm_call_method(m, o);
+
+       return o;
+}
+
+
+java_handle_t *native_new_and_init_string(classinfo *c, java_handle_t *s)
+{
+       methodinfo    *m;
+       java_handle_t *o;
+
+       if (c == NULL)
+               vm_abort("native_new_and_init_string: c == NULL");
+
+       /* create object */
+
+       o = builtin_new(c);
+
+       if (o == NULL)
+               return NULL;
+
+       /* find initializer */
+
+       m = class_findmethod(c, utf_init, utf_java_lang_String__void);
+
+       /* initializer not found */
+
+       if (m == NULL)
+               return NULL;
+
+       /* call initializer */
+
+       (void) vm_call_method(m, o, s);
+
+       return o;
+}
+
+
+/*
+ * 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/native/native.h b/src/native/native.h
deleted file mode 100644 (file)
index 974a02b..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/* src/native/native.h - table of native 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.
-
-*/
-
-
-#ifndef _NATIVE_H
-#define _NATIVE_H
-
-#include "config.h"
-
-#if defined(ENABLE_LTDL) && defined(HAVE_LTDL_H)
-# include <ltdl.h>
-#endif
-
-#include <stdint.h>
-
-#include "native/jni.h"
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-#include "vmcore/utf8.h"
-
-
-/* defines ********************************************************************/
-
-#define NATIVE_METHODS_COUNT    sizeof(methods) / sizeof(JNINativeMethod)
-
-
-/* native_methods_node_t ******************************************************/
-
-typedef struct native_methods_node_t native_methods_node_t;
-
-struct native_methods_node_t {
-       utf         *classname;             /* class name                         */
-       utf         *name;                  /* method name                        */
-       utf         *descriptor;            /* descriptor name                    */
-       functionptr  function;              /* pointer to the implementation      */
-};
-
-
-/* hashtable_library_loader_entry *********************************************/
-
-#if defined(ENABLE_LTDL)
-typedef struct hashtable_library_loader_entry hashtable_library_loader_entry;
-typedef struct hashtable_library_name_entry   hashtable_library_name_entry;
-
-struct hashtable_library_loader_entry {
-       classloader_t                  *loader;  /* class loader                  */
-       hashtable_library_name_entry   *namelink;/* libs loaded by this loader    */
-       hashtable_library_loader_entry *hashlink;/* link for external chaining    */
-};
-#endif
-
-
-/* hashtable_library_name_entry ***********************************************/
-
-#if defined(ENABLE_LTDL)
-struct hashtable_library_name_entry {
-       utf                          *name;      /* library name                  */
-       lt_dlhandle                   handle;    /* libtool library handle        */
-       hashtable_library_name_entry *hashlink;  /* link for external chaining    */
-};
-#endif
-
-
-/* function prototypes ********************************************************/
-
-bool native_init(void);
-
-void        native_method_register(utf *classname, const JNINativeMethod *methods, int32_t count);
-functionptr native_method_resolve(methodinfo *m);
-
-#if defined(ENABLE_LTDL)
-lt_dlhandle native_library_open(utf *filename);
-void        native_library_close(lt_dlhandle handle);
-void        native_library_add(utf *filename, classloader_t *loader, lt_dlhandle handle);
-hashtable_library_name_entry *native_library_find(utf *filename, classloader_t *loader);
-int         native_library_load(JNIEnv *env, utf *name, classloader_t *cl);
-#endif
-
-java_handle_t *native_new_and_init(classinfo *c);
-java_handle_t *native_new_and_init_string(classinfo *c, java_handle_t *s);
-
-#endif /* _NATIVE_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/native/native.hpp b/src/native/native.hpp
new file mode 100644 (file)
index 0000000..c373e96
--- /dev/null
@@ -0,0 +1,190 @@
+/* src/native/native.hpp - native library support
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _NATIVE_HPP
+#define _NATIVE_HPP
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+#include <map>
+#include <set>
+#endif
+
+#include "native/jni.hpp"
+
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/loader.hpp"
+#include "vm/method.hpp"
+#include "vm/os.hpp"
+#include "vm/utf8.h"
+
+
+/* defines ********************************************************************/
+
+#define NATIVE_METHODS_COUNT    sizeof(methods) / sizeof(JNINativeMethod)
+
+
+#define NATIVE_LIBRARY_PREFIX     "lib"
+
+#if defined(__DARWIN__)
+# define NATIVE_LIBRARY_SUFFIX    ".dylib"
+#else
+# define NATIVE_LIBRARY_SUFFIX    ".so"
+#endif
+
+
+#ifdef __cplusplus
+
+#if defined(ENABLE_DL)
+/**
+ * Represents a native library.
+ */
+class NativeLibrary {
+private:
+       utf*           _filename;    ///< Name of the native library.
+       classloader_t* _classloader; ///< Defining classloader.
+       void*          _handle;      ///< Filesystem handle.
+
+public:
+       NativeLibrary(utf* filename, classloader_t* classloader = 0, void* handle = 0) : _filename(filename), _classloader(classloader), _handle(handle) {}
+       NativeLibrary(void* handle) : _filename(0), _classloader(0), _handle(handle) {}
+
+       inline classloader_t* get_classloader() const { return _classloader; }
+       inline utf*           get_filename   () const { return _filename; }
+       inline void*          get_handle     () const { return _handle; }
+
+       void* open();
+       void  close();
+       bool  load(JNIEnv* env);
+       bool  is_loaded();
+       void* resolve_symbol(utf* symbolname) const;
+};
+
+
+/**
+ * Table containing all loaded native libraries.
+ */
+class NativeLibraries {
+private:
+       Mutex _mutex; ///< Mutex to make the container thread-safe.
+       typedef std::multimap<classloader_t*, NativeLibrary> MAP;
+       MAP _libraries;
+
+private:
+       // Comparator class.
+       class comparator : public std::binary_function<std::pair<classloader_t*, NativeLibrary>, utf*, bool> {
+       public:
+               bool operator() (std::pair<classloader_t*, NativeLibrary> args, const utf* filename) const
+               {
+                       return (args.second.get_filename() == filename);
+               }
+       };
+
+public:
+       void  add(NativeLibrary& library);
+       bool  is_loaded(NativeLibrary& library);
+       void* resolve_symbol(utf* symbolname, classloader_t* classloader);
+};
+#endif
+
+
+/**
+ * Represents a native method.
+ */
+class NativeMethod {
+private:
+       utf*  _classname;  ///< Class name.
+       utf*  _name;       ///< Method name.
+       utf*  _descriptor; ///< Method signature.
+       void* _function;   ///< Pointer to the native function.
+
+       friend bool operator< (const NativeMethod& first, const NativeMethod& second);
+
+public:
+       NativeMethod(utf* classname, utf* name, utf* signature, void* function) : _classname(classname), _name(name), _descriptor(signature), _function(function) {}
+       NativeMethod(methodinfo* m) : _classname(m->clazz->name), _name(m->name), _descriptor(m->descriptor), _function(0) {}
+
+       inline void* get_function() const { return _function; }
+};
+
+
+/**
+ * Table containing all native methods registered with the VM.
+ */
+class NativeMethods {
+private:
+       Mutex _mutex;
+       std::set<NativeMethod> _methods;
+
+private:
+       // Comparator class.
+       class comparator : public std::binary_function<std::pair<classloader_t*, NativeLibrary>, utf*, bool> {
+       public:
+               bool operator() (std::pair<classloader_t*, NativeLibrary> args, const utf* filename) const
+               {
+                       return (args.second.get_filename() == filename);
+               }
+       };
+       
+public:
+       void  register_methods(utf* classname, const JNINativeMethod* methods, size_t count);
+       void* resolve_method(methodinfo* m);
+       void* find_registered_method(methodinfo* m);
+};
+
+#endif
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+java_handle_t *native_new_and_init(classinfo *c);
+java_handle_t *native_new_and_init_string(classinfo *c, java_handle_t *s);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _NATIVE_HPP
+
+
+/*
+ * 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 70d401e344d2d2535952352380e3d77fbf0af077..f7f843f7a213a03c7f5a3d8eb8dd86549317179e 100644 (file)
@@ -55,21 +55,21 @@ NATIVEVM_LIB = \
 endif
 
 if ENABLE_JAVASE
-REFLECT_SOURCES = \
-       reflect.c \
-       reflect.h
+REFLECTION_SOURCES = \
+       reflection.cpp \
+       reflection.hpp
 
 SUN_MISC_UNSAFE_SOURCES = \
-       sun_misc_Unsafe.c
+       sun_misc_Unsafe.cpp
 endif
 
 noinst_LTLIBRARIES = \
        libnativevm.la
 
 libnativevm_la_SOURCES = \
-       nativevm.c \
-       nativevm.h \
-       $(REFLECT_SOURCES) \
+       nativevm.cpp \
+       nativevm.hpp \
+       $(REFLECTION_SOURCES) \
        $(SUN_MISC_UNSAFE_SOURCES)
 
 libnativevm_la_LIBADD = \
index 625d9acec0b804dd5b89bef2910eee810385bdcc..3cc9877172b4150e2d00f3079341279e9e6dc68a 100644 (file)
@@ -1,9 +1,7 @@
 ## src/native/vm/cldc1.1/Makefile.am
 ##
-## 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.
 ##
@@ -31,20 +29,20 @@ noinst_LTLIBRARIES = \
        libnativevmcore.la
 
 libnativevmcore_la_SOURCES = \
-       com_sun_cldc_io_ResourceInputStream.c \
-       com_sun_cldc_io_j2me_socket_Protocol.c \
-       com_sun_cldchi_io_ConsoleOutputStream.c \
-       com_sun_cldchi_jvm_JVM.c \
-       java_lang_Class.c \
-       java_lang_Double.c \
-       java_lang_Float.c \
-       java_lang_Math.c \
-       java_lang_Object.c \
-       java_lang_Runtime.c \
-       java_lang_String.c \
-       java_lang_System.c \
-       java_lang_Thread.c \
-       java_lang_Throwable.c
+       com_sun_cldc_io_ResourceInputStream.cpp \
+       com_sun_cldc_io_j2me_socket_Protocol.cpp \
+       com_sun_cldchi_io_ConsoleOutputStream.cpp \
+       com_sun_cldchi_jvm_JVM.cpp \
+       java_lang_Class.cpp \
+       java_lang_Double.cpp \
+       java_lang_Float.cpp \
+       java_lang_Math.cpp \
+       java_lang_Object.cpp \
+       java_lang_Runtime.cpp \
+       java_lang_String.cpp \
+       java_lang_System.cpp \
+       java_lang_Thread.cpp \
+       java_lang_Throwable.cpp
 
 
 ## Local variables:
diff --git a/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c b/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c
deleted file mode 100644 (file)
index 8395ada..0000000
+++ /dev/null
@@ -1,412 +0,0 @@
-/* src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c
-
-   Copyright (C) 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
-
-   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 <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <zlib.h>
-
-#include "config.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/com_sun_cldc_io_ResourceInputStream.h"
-#include "native/include/com_sun_cldchi_jvm_FileDescriptor.h"
-
-#include "vm/types.h"
-#include "vm/builtin.h"
-#include "vm/vm.h" /* REMOVE ME: temporarily */
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/zip.h"
-
-#include "threads/lock-common.h"
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "open", "(Ljava/lang/String;)Ljava/lang/Object;", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_open },
-       { "bytesRemain", "(Ljava/lang/Object;)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_bytesRemain },
-       { "readByte", "(Ljava/lang/Object;)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_readByte },
-       { "readBytes", "(Ljava/lang/Object;[BII)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_readBytes },
-       { "clone", "(Ljava/lang/Object;)Ljava/lang/Object;", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_clone },
-};
-/* _Jv_com_sun_cldc_io_ResourceInputStream_init ********************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_com_sun_cldc_io_ResourceInputStream_init(void)
-{
-       utf *u;
-       u = utf_new_char("com/sun/cldc/io/ResourceInputStream");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-static struct com_sun_cldchi_jvm_FileDescriptor* zip_read_resource(list_classpath_entry *lce, utf *name)
-{
-       hashtable_zipfile_entry *htzfe;
-       lfh                      lfh;
-       u1                      *indata;
-       u1                      *outdata;
-       z_stream                 zs;
-       int                      err;
-       
-       classinfo *ci;
-       com_sun_cldchi_jvm_FileDescriptor *fileDescriptor = NULL;
-
-       /* try to find the class in the current archive */
-
-       htzfe = zip_find(lce, name);
-
-       if (htzfe == NULL)
-               return NULL;
-
-       /* read stuff from local file header */
-
-       lfh.filenamelength   = SUCK_LE_U2(htzfe->data + LFH_FILE_NAME_LENGTH);
-       lfh.extrafieldlength = SUCK_LE_U2(htzfe->data + LFH_EXTRA_FIELD_LENGTH);
-
-       indata = htzfe->data +
-               LFH_HEADER_SIZE +
-               lfh.filenamelength +
-               lfh.extrafieldlength;
-
-       /* allocate buffer for uncompressed data */
-
-       outdata = MNEW(u1, htzfe->uncompressedsize);
-
-       /* how is the file stored? */
-
-       switch (htzfe->compressionmethod) {
-       case Z_DEFLATED:
-               /* fill z_stream structure */
-
-               zs.next_in   = indata;
-               zs.avail_in  = htzfe->compressedsize;
-               zs.next_out  = outdata;
-               zs.avail_out = htzfe->uncompressedsize;
-
-               zs.zalloc = Z_NULL;
-               zs.zfree  = Z_NULL;
-               zs.opaque = Z_NULL;
-
-               /* initialize this inflate run */
-
-               if (inflateInit2(&zs, -MAX_WBITS) != Z_OK)
-                       vm_abort("zip_get: inflateInit2 failed: %s", strerror(errno));
-
-               /* decompress the file into buffer */
-
-               err = inflate(&zs, Z_SYNC_FLUSH);
-
-               if ((err != Z_STREAM_END) && (err != Z_OK))
-                       vm_abort("zip_get: inflate failed: %s", strerror(errno));
-
-               /* finish this inflate run */
-
-               if (inflateEnd(&zs) != Z_OK)
-                       vm_abort("zip_get: inflateEnd failed: %s", strerror(errno));
-               break;
-
-       case 0:
-               /* uncompressed file, just copy the data */
-               MCOPY(outdata, indata, u1, htzfe->compressedsize);
-               break;
-
-       default:
-               vm_abort("zip_get: unknown compression method %d",
-                                htzfe->compressionmethod);
-       }
-               
-       /* Create a file descriptor object */
-       ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
-       fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci);
-       LLNI_field_set_val(fileDescriptor, pointer, (int)outdata);
-       LLNI_field_set_val(fileDescriptor, length, htzfe->uncompressedsize);
-       LLNI_field_set_val(fileDescriptor, position, 0);
-       return fileDescriptor;
-       
-}
-
-static struct com_sun_cldchi_jvm_FileDescriptor* file_read_resource(char *path) 
-{
-       int len;
-       struct stat statBuffer;
-       u1 *filep;
-       com_sun_cldchi_jvm_FileDescriptor *fileDescriptor = NULL; 
-       classinfo *ci;
-       int fd;
-       
-       fd = open(path, O_RDONLY);
-       
-       if (fd > 0) {
-               
-               if (fstat(fd, &statBuffer) != -1) {
-                       len = statBuffer.st_size;
-               } else {  
-                       return NULL;
-               }
-               
-               /* Map file into the memory */
-               filep = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0);
-               
-               /* Create a file descriptor object */
-               ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
-               fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci);
-               LLNI_field_set_val(fileDescriptor, pointer, (int)filep);
-               LLNI_field_set_val(fileDescriptor, length, len);
-               LLNI_field_set_val(fileDescriptor, position, 0);
-               
-               return fileDescriptor;  
-               
-       } else {
-               return NULL;
-       }
-       
-}
-
-
-/*
- * Class:     com/sun/cldc/io/ResourceInputStream
- * Method:    open
- * Signature: (Ljava/lang/String;)Ljava/lang/Object;
- */
-JNIEXPORT struct java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *env, jclass clazz, java_lang_String *name)
-{
-       
-       list_classpath_entry *lce;
-       char *filename;
-       s4 filenamelen;
-       char *path;
-       utf *uname;
-       com_sun_cldchi_jvm_FileDescriptor* descriptor;
-       
-       /* get the classname as char string (do it here for the warning at
-       the end of the function) */
-
-       uname = javastring_toutf((java_handle_t *)name, false);
-       filenamelen = utf_bytes(uname) + strlen("0");
-       filename = MNEW(char, filenamelen);
-       utf_copy(filename, uname);
-       
-       /* walk through all classpath entries */
-
-       for (lce = list_first(list_classpath_entries); lce != NULL;
-                lce = list_next(list_classpath_entries, lce)) {
-                       
-#if defined(ENABLE_ZLIB)
-               if (lce->type == CLASSPATH_ARCHIVE) {
-
-                       /* enter a monitor on zip/jar archives */
-                       LOCK_MONITOR_ENTER(lce);
-
-                       /* try to get the file in current archive */
-                       descriptor = zip_read_resource(lce, uname);
-
-                       /* leave the monitor */
-                       LOCK_MONITOR_EXIT(lce);
-                       
-                       if (descriptor != NULL) { /* file exists */
-                               break;
-                       }
-
-               } else {
-#endif
-                       
-                       path = MNEW(char, lce->pathlen + filenamelen);
-                       strcpy(path, lce->path);
-                       strcat(path, filename);
-
-                       descriptor = file_read_resource(path);
-                       
-                       MFREE(path, char, lce->pathlen + filenamelen);
-
-                       if (descriptor != NULL) { /* file exists */
-                               break;
-                       }
-                       
-#if defined(ENABLE_ZLIB)
-               }
-#endif 
-                       
-       }
-
-       MFREE(filename, char, filenamelen);
-
-       return (java_lang_Object*) descriptor;
-       
-}
-
-
-/*
- * Class:     com_sun_cldc_io_ResourceInputStream
- * Method:    bytesRemain
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_bytesRemain(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
-       
-       com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
-       int32_t length;
-       int32_t position;
-
-       fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
-       LLNI_field_get_val(fileDescriptor, position, position);
-       LLNI_field_get_val(fileDescriptor, length, length);
-       
-       return length - position;
-
-}
-
-/*
- * Class:     com_sun_cldc_io_ResourceInputStream
- * Method:    readByte
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_readByte(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
-       
-       com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
-       u1 byte;
-       int32_t length;
-       int32_t position;
-       int64_t filep;
-       
-       fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
-       LLNI_field_get_val(fileDescriptor, position, position);
-       LLNI_field_get_val(fileDescriptor, length, length);
-       LLNI_field_get_val(fileDescriptor, pointer, filep);
-       
-       if (position < length) {
-               byte = ((u1*)(int)filep)[position];
-               position++;
-       } else {
-               return -1; /* EOF */
-       }
-
-       /* Update access position */
-       LLNI_field_set_val(fileDescriptor, position, position);
-       
-       return (byte & 0xFF);
-
-}
-
-/*
- * Class:     com_sun_cldc_io_ResourceInputStream
- * Method:    readBytes
- * Signature: (Ljava/lang/Object;[BII)I
- */
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_readBytes(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj, java_handle_bytearray_t* byteArray, s4 off, s4 len) {
-       
-       com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
-       s4 readBytes = -1;
-       int32_t fileLength;
-       int32_t position;
-       s4 available;
-       int64_t filep;
-       void *buf;
-
-       /* get pointer to the buffer */
-       buf = &(LLNI_array_direct(byteArray, off));
-       
-       fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
-       LLNI_field_get_val(fileDescriptor, position, position);
-       LLNI_field_get_val(fileDescriptor, length, fileLength);
-       LLNI_field_get_val(fileDescriptor, pointer, filep);
-       
-       if (position < fileLength) {
-               available = fileLength - position;
-               if (available < len) {
-                       readBytes = available;
-               } else {
-                       readBytes = len;
-               }
-               memcpy(buf, ((u1*)(int)filep) + position, readBytes * sizeof(u1));
-               position += readBytes;
-       } else {
-               return -1; /* EOF */
-       }
-
-       /* Update access position */
-       LLNI_field_set_val(fileDescriptor, position, position);
-       
-       return readBytes;
-}
-
-/*
- * Class:     com_sun_cldc_io_ResourceInputStream
- * Method:    clone
- * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
- */
-JNIEXPORT struct java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_clone(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
-       
-       classinfo *ci;
-       com_sun_cldchi_jvm_FileDescriptor *srcFileDescriptor;
-       com_sun_cldchi_jvm_FileDescriptor *dstFileDescriptor;
-       int32_t srcLength;
-       int32_t srcPosition;
-       int64_t srcFilePointer;
-       
-       srcFileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
-       LLNI_field_get_val(srcFileDescriptor, position, srcPosition);
-       LLNI_field_get_val(srcFileDescriptor, length, srcLength);
-       LLNI_field_get_val(srcFileDescriptor, pointer, srcFilePointer);
-       
-       ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
-       dstFileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci);
-       LLNI_field_set_val(dstFileDescriptor, position, srcPosition);
-       LLNI_field_set_val(dstFileDescriptor, length, srcLength);
-       LLNI_field_set_val(dstFileDescriptor, pointer, srcFilePointer);
-       
-       return (java_lang_Object*) dstFileDescriptor;
-
-}
-
-
-/*
- * 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/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp b/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp
new file mode 100644 (file)
index 0000000..2ece32f
--- /dev/null
@@ -0,0 +1,399 @@
+/* src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp
+
+   Copyright (C) 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 <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <zlib.h>
+
+#include "mm/memory.h"
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/com_sun_cldc_io_ResourceInputStream.h"
+#endif
+
+#include "threads/mutex.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/string.hpp"
+#include "vm/types.h"
+#include "vm/vm.hpp" /* REMOVE ME: temporarily */
+#include "vm/zip.hpp"
+
+
+static java_handle_t* zip_read_resource(list_classpath_entry *lce, utf *name)
+{
+       hashtable_zipfile_entry *htzfe;
+       lfh                      lfh;
+       u1                      *indata;
+       u1                      *outdata;
+       z_stream                 zs;
+       int                      err;
+       
+       classinfo *ci;
+
+       /* try to find the class in the current archive */
+
+       htzfe = zip_find(lce, name);
+
+       if (htzfe == NULL)
+               return NULL;
+
+       /* read stuff from local file header */
+
+       lfh.filenamelength   = SUCK_LE_U2(htzfe->data + LFH_FILE_NAME_LENGTH);
+       lfh.extrafieldlength = SUCK_LE_U2(htzfe->data + LFH_EXTRA_FIELD_LENGTH);
+
+       indata = htzfe->data +
+               LFH_HEADER_SIZE +
+               lfh.filenamelength +
+               lfh.extrafieldlength;
+
+       /* allocate buffer for uncompressed data */
+
+       outdata = MNEW(u1, htzfe->uncompressedsize);
+
+       /* how is the file stored? */
+
+       switch (htzfe->compressionmethod) {
+       case Z_DEFLATED:
+               /* fill z_stream structure */
+
+               zs.next_in   = indata;
+               zs.avail_in  = htzfe->compressedsize;
+               zs.next_out  = outdata;
+               zs.avail_out = htzfe->uncompressedsize;
+
+               zs.zalloc = Z_NULL;
+               zs.zfree  = Z_NULL;
+               zs.opaque = Z_NULL;
+
+               /* initialize this inflate run */
+
+               if (inflateInit2(&zs, -MAX_WBITS) != Z_OK)
+                       vm_abort("zip_get: inflateInit2 failed: %s", strerror(errno));
+
+               /* decompress the file into buffer */
+
+               err = inflate(&zs, Z_SYNC_FLUSH);
+
+               if ((err != Z_STREAM_END) && (err != Z_OK))
+                       vm_abort("zip_get: inflate failed: %s", strerror(errno));
+
+               /* finish this inflate run */
+
+               if (inflateEnd(&zs) != Z_OK)
+                       vm_abort("zip_get: inflateEnd failed: %s", strerror(errno));
+               break;
+
+       case 0:
+               /* uncompressed file, just copy the data */
+               MCOPY(outdata, indata, u1, htzfe->compressedsize);
+               break;
+
+       default:
+               vm_abort("zip_get: unknown compression method %d",
+                                htzfe->compressionmethod);
+       }
+               
+       // Create a file descriptor object.
+       ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
+       java_handle_t* h = native_new_and_init(ci);
+
+       if (h == NULL)
+               return NULL;
+
+       com_sun_cldchi_jvm_FileDescriptor fd(h, (int64_t) outdata, 0, htzfe->uncompressedsize);
+
+       return fd.get_handle();
+}
+
+
+static java_handle_t* file_read_resource(char *path) 
+{
+       int len;
+       struct stat statBuffer;
+       u1 *filep;
+       classinfo *ci;
+       int fd;
+       
+       fd = open(path, O_RDONLY);
+       
+       if (fd > 0) {
+               
+               if (fstat(fd, &statBuffer) != -1) {
+                       len = statBuffer.st_size;
+               } else {  
+                       return NULL;
+               }
+               
+               /* Map file into the memory */
+               filep = (u1*) mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0);
+               
+               /* Create a file descriptor object */
+               ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
+               java_handle_t* h = native_new_and_init(ci);
+
+               if (h == NULL)
+                       return NULL;
+
+               com_sun_cldchi_jvm_FileDescriptor fd(h, (int64_t) filep, 0, len); 
+
+               return fd.get_handle(); 
+       }
+       else {
+               return NULL;
+       }
+}
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     com/sun/cldc/io/ResourceInputStream
+ * Method:    open
+ * Signature: (Ljava/lang/String;)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *env, jclass clazz, jstring name)
+{
+       char *filename;
+       s4 filenamelen;
+       char *path;
+       utf *uname;
+       java_handle_t* descriptor;
+       
+       /* get the classname as char string (do it here for the warning at
+       the end of the function) */
+
+       uname = javastring_toutf((java_handle_t *)name, false);
+       filenamelen = utf_bytes(uname) + strlen("0");
+       filename = MNEW(char, filenamelen);
+       utf_copy(filename, uname);
+       
+       /* walk through all classpath entries */
+
+       for (List<list_classpath_entry*>::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end(); it++) {
+               list_classpath_entry* lce = *it;
+
+#if defined(ENABLE_ZLIB)
+               if (lce->type == CLASSPATH_ARCHIVE) {
+
+                       /* enter a monitor on zip/jar archives */
+                       lce->mutex->lock();
+
+                       /* try to get the file in current archive */
+                       descriptor = zip_read_resource(lce, uname);
+
+                       /* leave the monitor */
+                       lce->mutex->unlock();
+                       
+                       if (descriptor != NULL) { /* file exists */
+                               break;
+                       }
+
+               } else {
+#endif
+                       
+                       path = MNEW(char, lce->pathlen + filenamelen);
+                       strcpy(path, lce->path);
+                       strcat(path, filename);
+
+                       descriptor = file_read_resource(path);
+                       
+                       MFREE(path, char, lce->pathlen + filenamelen);
+
+                       if (descriptor != NULL) { /* file exists */
+                               break;
+                       }
+#if defined(ENABLE_ZLIB)
+               }
+#endif 
+       }
+
+       MFREE(filename, char, filenamelen);
+
+       return (jobject) descriptor;
+}
+
+
+/*
+ * Class:     com/sun/cldc/io/ResourceInputStream
+ * Method:    bytesRemain
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_ResourceInputStream_bytesRemain(JNIEnv *env, jclass clazz, jobject jobj)
+{
+       com_sun_cldchi_jvm_FileDescriptor fd(jobj);
+       int32_t length   = fd.get_position();
+       int32_t position = fd.get_length();
+
+       return length - position;
+}
+
+
+/*
+ * Class:     com/sun/cldc/io/ResourceInputStream
+ * Method:    readByte
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_ResourceInputStream_readByte(JNIEnv *env, jclass clazz, jobject jobj)
+{
+       com_sun_cldchi_jvm_FileDescriptor fd(jobj);
+
+       int64_t filep    = fd.get_pointer();
+       int32_t position = fd.get_position();
+       int32_t length   = fd.get_length();
+
+       uint8_t byte;
+
+       if (position < length) {
+               byte = ((uint8_t*) filep)[position];
+               position++;
+       }
+       else {
+               return -1; /* EOF */
+       }
+
+       // Update access position.
+       fd.set_position(position);
+       
+       return (byte & 0xFF);
+}
+
+
+/*
+ * Class:     com/sun/cldc/io/ResourceInputStream
+ * Method:    readBytes
+ * Signature: (Ljava/lang/Object;[BII)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_ResourceInputStream_readBytes(JNIEnv *env, jclass clazz, jobject jobj, jbyteArray byteArray, jint off, jint len)
+{
+       /* get pointer to the buffer */
+       // XXX Not GC safe.
+       void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) byteArray, off));
+       
+       com_sun_cldchi_jvm_FileDescriptor fd(jobj);
+
+       int64_t filep      = fd.get_pointer();
+       int32_t position   = fd.get_position();
+       int32_t fileLength = fd.get_length();
+
+       int32_t readBytes = -1;
+
+       if (position < fileLength) {
+               int32_t available = fileLength - position;
+
+               if (available < len) {
+                       readBytes = available;
+               } else {
+                       readBytes = len;
+               }
+
+               os::memcpy(buf, ((uint8_t*) filep) + position, readBytes * sizeof(uint8_t));
+               position += readBytes;
+       }
+       else {
+               return -1; /* EOF */
+       }
+
+       // Update access position.
+       fd.set_position(position);
+       
+       return readBytes;
+}
+
+
+/*
+ * Class:     com/sun/cldc/io/ResourceInputStream
+ * Method:    clone
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_com_sun_cldc_io_ResourceInputStream_clone(JNIEnv *env, jclass clazz, jobject jobj)
+{
+       com_sun_cldchi_jvm_FileDescriptor fd(jobj);
+
+       classinfo* c = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
+       java_handle_t* h = native_new_and_init(c);
+
+       if (h == NULL)
+               return NULL;
+
+       com_sun_cldchi_jvm_FileDescriptor clonefd(h, fd);
+       
+       return (jobject) clonefd.get_handle();
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "open",        (char*) "(Ljava/lang/String;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_open        },
+       { (char*) "bytesRemain", (char*) "(Ljava/lang/Object;)I",                  (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_bytesRemain },
+       { (char*) "readByte",    (char*) "(Ljava/lang/Object;)I",                  (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_readByte    },
+       { (char*) "readBytes",   (char*) "(Ljava/lang/Object;[BII)I",              (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_readBytes   },
+       { (char*) "clone",       (char*) "(Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_clone       },
+};
+
+/* _Jv_com_sun_cldc_io_ResourceInputStream_init ********************************
+   Register native functions.
+*******************************************************************************/
+void _Jv_com_sun_cldc_io_ResourceInputStream_init(void)
+{
+       utf* u = utf_new_char("com/sun/cldc/io/ResourceInputStream");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c b/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c
deleted file mode 100644 (file)
index ee32030..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-/* src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c
-
-   Copyright (C) 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
-
-   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 <errno.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/com_sun_cldc_io_j2me_socket_Protocol.h"
-
-#include "vm/global.h"
-#include "vm/vm.h" /* REMOVE ME: temporarily */
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "open0",      "([BII)I",  (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_open0      },
-       { "readBuf",    "(I[BII)I", (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf    },
-       { "readByte",   "(I)I",     (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_readByte   },
-       { "writeBuf",   "(I[BII)I", (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf   },
-       { "writeByte",  "(II)I",    (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte  },
-       { "available0", "(I)I",     (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_available0 },
-       { "close0",     "(I)V",     (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_close0     },
-};
-
-/* _Jv_com_sun_cldc_io_j2me_socket_Protocol_init *******************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_com_sun_cldc_io_j2me_socket_Protocol_init(void)
-{
-       utf *u;
-       u = utf_new_char("com/sun/cldc/io/j2me/socket/Protocol");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     com/sun/cldc/io/j2me/socket/Protocol
- * Method:    open0
- * Signature: ([BII)I
- */
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_open0(JNIEnv *env, jclass clazz, java_handle_bytearray_t *hostname, s4 port, s4 mode)
-{
-       struct hostent *phostent;
-    struct sockaddr_in serv_addr;
-       char           *name;
-       s4              sockfd;
-       s4              result;
-
-       /* The hostname byte-array is a NULL terminated C-string. */
-
-       name = (char *) &(LLNI_array_data(hostname));
-
-       /* get the host */
-
-       phostent = gethostbyname(name);
-
-       if (phostent == NULL)
-               return -1;
-
-       /* fill the sockaddr structure */
-
-       serv_addr.sin_family = AF_INET;
-       serv_addr.sin_port   = htons(port);
-
-       MCOPY(&serv_addr.sin_addr, phostent->h_addr, u1, phostent->h_length);
-
-       /* create the socket */
-
-       sockfd = socket(AF_INET, SOCK_STREAM, 0);
-
-       if (sockfd < 0)
-               return -1;
-
-       /* connect the socket */
-
-       result = connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
-
-       if (result < 0)
-               return -1;
-
-       return sockfd;
-}
-
-
-/*
- * Class:     com/sun/cldc/io/j2me/socket/Protocol
- * Method:    readBuf
- * Signature: (I[BII)I
- */
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf(JNIEnv *env, jclass clazz, s4 handle, java_handle_bytearray_t *b, s4 off, s4 len)
-{
-       void    *buf;
-       ssize_t  result;
-
-       /* get pointer to the buffer */
-
-       buf = &(LLNI_array_direct(b, off));
-
-       /* receive from the socket */
-
-       result = recv(handle, buf, len, 0);
-
-       if (result == 0) {
-               /* the peer has performed an orderly shutdown */
-
-               return -1;
-       }
-       else if (result < 0) {
-               vm_abort("Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf: recv failed: %s", strerror(errno));
-       }
-
-       return result;
-}
-
-
-/*
- * Class:     com/sun/cldc/io/j2me/socket/Protocol
- * Method:    readByte
- * Signature: (I)I
- */
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readByte(JNIEnv *env, jclass clazz, s4 handle) {
-       
-       char    byte;
-       ssize_t result;
-       
-       /* receive from the socket */
-
-       result = recv(handle, &byte, 1, 0);
-
-       if (result == 0) {
-               /* the peer has performed an orderly shutdown */
-
-               return -1;
-       }
-       else if (result < 0) {
-               /* should throw an IOException */
-
-               vm_abort("Java_com_sun_cldc_io_j2me_socket_Protocol_readByte: recv failed: %s", strerror(errno));
-       }
-
-       return byte;
-}
-
-
-/*
- * Class:     com/sun/cldc/io/j2me/socket/Protocol
- * Method:    writeBuf
- * Signature: (I[BII)I
- */
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf(JNIEnv *env, jclass clazz, s4 handle, java_handle_bytearray_t * b, s4 off, s4 len) {
-
-       void    *buf;
-       ssize_t  result;
-
-       /* get pointer to the buffer */
-
-       buf = &(LLNI_array_direct(b, off));
-       
-       /* send the given byte to the socket */
-
-       result = send(handle, buf, len, 0);
-
-       if (result < 0)
-               /* should throw an IOException */
-
-               vm_abort("Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf: send failed: %s", strerror(errno));
-
-       return result;
-
-}
-
-
-/*
- * Class:     com/sun/cldc/io/j2me/socket/Protocol
- * Method:    writeByte
- * Signature: (II)I
- */
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte(JNIEnv *env, jclass clazz, s4 handle, s4 b)
-{
-       char    byte;
-       ssize_t result;
-
-       byte = (char) b;
-
-       /* send the given byte to the socket */
-
-       result = send(handle, &byte, 1, 0);
-
-       if (result < 0)
-               vm_abort("Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte: send failed: %s", strerror(errno));
-
-       return result;
-}
-
-
-/*
- * Class:     com/sun/cldc/io/j2me/socket/Protocol
- * Method:    available0
- * Signature: (I)I
- */
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_available0(JNIEnv *env, jclass clazz, s4 handle)
-{
-       /* NOTE: Sun doesn't have an implementation too */
-
-       return 0;
-}
-
-
-/*
- * Class:     com/sun/cldc/io/j2me/socket/Protocol
- * Method:    close0
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_close0(JNIEnv *env, jclass clazz, s4 handle)
-{
-       int result;
-
-       /* close the file descriptor */
-
-       result = close(handle);
-
-       if (result < 0)
-               vm_abort("Java_com_sun_cldc_io_j2me_socket_Protocol_close0: close failed: %s", strerror(errno));
-}
-
-
-/*
- * 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/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp b/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp
new file mode 100644 (file)
index 0000000..9ad7f7c
--- /dev/null
@@ -0,0 +1,262 @@
+/* src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp
+
+   Copyright (C) 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 <stdint.h>
+#include <errno.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/com_sun_cldc_io_j2me_socket_Protocol.h"
+#endif
+
+#include "vm/global.h"
+#include "vm/vm.hpp" /* REMOVE ME: temporarily */
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     com/sun/cldc/io/j2me/socket/Protocol
+ * Method:    open0
+ * Signature: ([BII)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_open0(JNIEnv *env, jclass clazz, jbyteArray hostname, jint port, jint mode)
+{
+       struct hostent *phostent;
+    struct sockaddr_in serv_addr;
+
+       // The hostname byte-array is a NULL terminated C-string.
+       // XXX Not GC safe.
+       char* name = (char*) &(LLNI_array_data((java_handle_bytearray_t*) hostname));
+
+       /* get the host */
+
+       phostent = gethostbyname(name);
+
+       if (phostent == NULL)
+               return -1;
+
+       /* fill the sockaddr structure */
+
+       serv_addr.sin_family = AF_INET;
+       serv_addr.sin_port   = htons(port);
+
+       MCOPY(&serv_addr.sin_addr, phostent->h_addr, u1, phostent->h_length);
+
+       /* create the socket */
+
+       int sockfd = socket(AF_INET, SOCK_STREAM, 0);
+
+       if (sockfd < 0)
+               return -1;
+
+       /* connect the socket */
+
+       int result = connect(sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr));
+
+       if (result < 0)
+               return -1;
+
+       return sockfd;
+}
+
+
+/*
+ * Class:     com/sun/cldc/io/j2me/socket/Protocol
+ * Method:    readBuf
+ * Signature: (I[BII)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf(JNIEnv *env, jclass clazz, jint handle, jbyteArray b, jint off, jint len)
+{
+       // Get pointer to the buffer.
+       // XXX Not GC safe.
+       void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) b, off));
+
+       // Receive from the socket.
+       ssize_t result = recv(handle, buf, len, 0);
+
+       if (result == 0) {
+               // The peer has performed an orderly shutdown.
+               return -1;
+       }
+       else if (result < 0) {
+               vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf: recv failed");
+       }
+
+       return result;
+}
+
+
+/*
+ * Class:     com/sun/cldc/io/j2me/socket/Protocol
+ * Method:    readByte
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readByte(JNIEnv *env, jclass clazz, jint handle)
+{
+       char byte;
+       
+       // Receive from the socket.
+       ssize_t result = recv(handle, &byte, 1, 0);
+
+       if (result == 0) {
+               // The peer has performed an orderly shutdown.
+               return -1;
+       }
+       else if (result < 0) {
+               // TODO Should throw an IOException.
+               vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readByte: recv failed");
+       }
+
+       return byte;
+}
+
+
+/*
+ * Class:     com/sun/cldc/io/j2me/socket/Protocol
+ * Method:    writeBuf
+ * Signature: (I[BII)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf(JNIEnv *env, jclass clazz, jint handle, jbyteArray b, jint off, jint len)
+{
+       // Get pointer to the buffer.
+       // XXX Not GC safe.
+       void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) b, off));
+       
+       // Send the given byte to the socket.
+       ssize_t result = send(handle, buf, len, 0);
+
+       if (result < 0) {
+               // TODO Should throw an IOException.
+               vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf: send failed");
+       }
+
+       return result;
+}
+
+
+/*
+ * Class:     com/sun/cldc/io/j2me/socket/Protocol
+ * Method:    writeByte
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte(JNIEnv *env, jclass clazz, jint handle, jint b)
+{
+       char byte = (char) b;
+
+       // Send the given byte to the socket.
+       ssize_t result = send(handle, &byte, 1, 0);
+
+       if (result < 0)
+               vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte: send failed");
+
+       return result;
+}
+
+
+/*
+ * Class:     com/sun/cldc/io/j2me/socket/Protocol
+ * Method:    available0
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_available0(JNIEnv *env, jclass clazz, jint handle)
+{
+       // NOTE: Sun doesn't have an implementation too.
+       return 0;
+}
+
+
+/*
+ * Class:     com/sun/cldc/io/j2me/socket/Protocol
+ * Method:    close0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_close0(JNIEnv *env, jclass clazz, jint handle)
+{
+       // Close the file descriptor.
+       int result = close(handle);
+
+       if (result < 0)
+               vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_close0: close failed");
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "open0",      (char*) "([BII)I",  (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_open0      },
+       { (char*) "readBuf",    (char*) "(I[BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf    },
+       { (char*) "readByte",   (char*) "(I)I",     (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_readByte   },
+       { (char*) "writeBuf",   (char*) "(I[BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf   },
+       { (char*) "writeByte",  (char*) "(II)I",    (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte  },
+       { (char*) "available0", (char*) "(I)I",     (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_available0 },
+       { (char*) "close0",     (char*) "(I)V",     (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_close0     },
+};
+
+/* _Jv_com_sun_cldc_io_j2me_socket_Protocol_init *******************************
+   Register native functions.
+*******************************************************************************/
+void _Jv_com_sun_cldc_io_j2me_socket_Protocol_init(void)
+{
+       utf* u = utf_new_char("com/sun/cldc/io/j2me/socket/Protocol");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c b/src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c
deleted file mode 100644 (file)
index fc642a1..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/* src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.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
-
-   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 <stdio.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/com_sun_cldchi_io_ConsoleOutputStream.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "write", "(I)V", (void *) (ptrint) &Java_com_sun_cldchi_io_ConsoleOutputStream_write },
-};
-
-/* _Jv_com_sun_cldchi_io_ConsoleOutputStream_init ******************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_com_sun_cldchi_io_ConsoleOutputStream_init(void)
-{
-       utf *u;
-       u = utf_new_char("com/sun/cldchi/io/ConsoleOutputStream");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     com/sun/cldchi/io/ConsoleOutputStream
- * Method:    write
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sun_cldchi_io_ConsoleOutputStream_write(JNIEnv *env, com_sun_cldchi_io_ConsoleOutputStream *this, s4 c)
-{
-       (void) fputc(c, stdout);
-}
-
-
-/*
- * 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/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.cpp b/src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.cpp
new file mode 100644 (file)
index 0000000..96aeb01
--- /dev/null
@@ -0,0 +1,93 @@
+/* src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.cpp
+
+   Copyright (C) 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 <stdint.h>
+#include <stdio.h>
+
+#include "vm/types.h"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/com_sun_cldchi_io_ConsoleOutputStream.h"
+#endif
+
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     com/sun/cldchi/io/ConsoleOutputStream
+ * Method:    write
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_cldchi_io_ConsoleOutputStream_write(JNIEnv *env, jobject _this, jint c)
+{
+       (void) fputc(c, stdout);
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "write", (char*) "(I)V", (void*) (uintptr_t) &Java_com_sun_cldchi_io_ConsoleOutputStream_write },
+};
+
+/* _Jv_com_sun_cldchi_io_ConsoleOutputStream_init ******************************
+   Register native functions.
+*******************************************************************************/
+void _Jv_com_sun_cldchi_io_ConsoleOutputStream_init(void)
+{
+       utf* u = utf_new_char("com/sun/cldchi/io/ConsoleOutputStream");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c b/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c
deleted file mode 100644 (file)
index b5b113a..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/* src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c
-
-   Copyright (C) 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 "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_String.h"
-
-#include "native/include/com_sun_cldchi_jvm_JVM.h"
-
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "loadLibrary", "(Ljava/lang/String;)V", (void *) (ptrint) &Java_com_sun_cldchi_jvm_JVM_loadLibrary },
-};
-
-
-/* _Jv_com_sun_cldchi_jvm_JVM_init *********************************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_com_sun_cldchi_jvm_JVM_init(void)
-{
-       utf *u;
-       u = utf_new_char("com/sun/cldchi/jvm/JVM");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     com/sun/cldchi/jvm/JVM
- * Method:    loadLibrary
- * Signature: (Ljava/lang/String;)V
- */
-JNIEXPORT void JNICALL Java_com_sun_cldchi_jvm_JVM_loadLibrary(JNIEnv *env, jclass clazz, java_lang_String *libName)
-{
-       int  result;
-       utf *name;
-
-       /* REMOVEME When we use Java-strings internally. */
-
-       if (libName == NULL) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       name = javastring_toutf((java_handle_t *) libName, false);
-
-       result = native_library_load(env, name, NULL);
-
-       /* Check for error and throw an exception in case. */
-
-       if (result == 0) {
-               exceptions_throw_unsatisfiedlinkerror(name);
-       }
-}
-
-
-/*
- * 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/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.cpp b/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.cpp
new file mode 100644 (file)
index 0000000..69acddd
--- /dev/null
@@ -0,0 +1,106 @@
+/* src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.cpp
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/com_sun_cldchi_jvm_JVM.h"
+#endif
+
+#include "vm/exceptions.hpp"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     com/sun/cldchi/jvm/JVM
+ * Method:    loadLibrary
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_cldchi_jvm_JVM_loadLibrary(JNIEnv *env, jclass clazz, jstring libName)
+{
+       if (libName == NULL) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       // REMOVEME When we use Java-strings internally.
+       utf* name = javastring_toutf((java_handle_t*) libName, false);
+
+       NativeLibrary nl(name);
+       bool result = nl.load(env);
+
+       // Check for error and throw an exception in case.
+       if (result == false) {
+               exceptions_throw_unsatisfiedlinkerror(name);
+       }
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "loadLibrary", (char*) "(Ljava/lang/String;)V", (void*) (uintptr_t) &Java_com_sun_cldchi_jvm_JVM_loadLibrary },
+};
+
+
+/* _Jv_com_sun_cldchi_jvm_JVM_init *********************************************
+   Register native functions.
+*******************************************************************************/
+void _Jv_com_sun_cldchi_jvm_JVM_init(void)
+{
+       utf* u = utf_new_char("com/sun/cldchi/jvm/JVM");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/cldc1.1/java_lang_Class.c b/src/native/vm/cldc1.1/java_lang_Class.c
deleted file mode 100644 (file)
index 3d438a7..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/* src/native/vm/cldc1.1/java_lang_Class.c
-
-   Copyright (C) 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 "vm/types.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_String.h"             /* required by j.l.C */
-#include "native/include/java_lang_Object.h"
-
-#include "native/include/java_lang_Class.h"
-
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "forName",          "(Ljava/lang/String;)Ljava/lang/Class;",(void *) (ptrint) &Java_java_lang_Class_forName          },
-       { "newInstance",      "()Ljava/lang/Object;",                 (void *) (ptrint) &Java_java_lang_Class_newInstance      },
-       { "isInstance",       "(Ljava/lang/Object;)Z",                (void *) (ptrint) &Java_java_lang_Class_isInstance       },
-       { "isAssignableFrom", "(Ljava/lang/Class;)Z",                 (void *) (ptrint) &Java_java_lang_Class_isAssignableFrom },
-       { "isInterface",      "()Z",                                  (void *) (ptrint) &Java_java_lang_Class_isInterface      },
-       { "isArray",          "()Z",                                  (void *) (ptrint) &Java_java_lang_Class_isArray          },
-       { "getName",          "()Ljava/lang/String;",                 (void *) (ptrint) &Java_java_lang_Class_getName          },
-};
-
-/* _Jv_java_lang_Class_init ****************************************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_java_lang_Class_init(void)
-{
-       utf *u;
-       u = utf_new_char("java/lang/Class");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    forName
- * Signature: (Ljava/lang/String;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Class_forName(JNIEnv *env, jclass clazz, java_lang_String *name)
-{
-       utf       *ufile;
-       utf       *uname;
-       classinfo *c;
-       u2        *pos;
-       s4         i;
-
-       /* illegal argument */
-
-       if (name == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* create utf string in which '.' is replaced by '/' */
-
-       ufile = javastring_toutf((java_handle_t *) name, true);
-       uname = javastring_toutf((java_handle_t *) name, false);
-
-       /* name must not contain '/' (mauve test) */
-
-       for (i = 0, pos = LLNI_field_direct(name, value)->data + LLNI_field_direct(name, offset); i < LLNI_field_direct(name, count); i++, pos++) {
-               if (*pos == '/') {
-                       exceptions_throw_classnotfoundexception(uname);
-                       return NULL;
-               }
-       }
-
-       /* try to load, ... */
-
-       c = load_class_bootstrap(ufile);
-
-       if (c == NULL)
-           return NULL;
-
-       /* link, ... */
-
-       if (!link_class(c))
-               return NULL;
-       
-       /* ...and initialize it. */
-
-       if (!initialize_class(c))
-               return NULL;
-
-       return LLNI_classinfo_wrap(c);
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    newInstance
- * Signature: ()Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_Class_newInstance(JNIEnv *env, java_lang_Class* this)
-{
-       classinfo     *c;
-       java_handle_t *o;
-
-       c = LLNI_classinfo_unwrap(this);
-
-       o = native_new_and_init(c);
-
-       return (java_lang_Object *) o;
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    isInstance
- * Signature: (Ljava/lang/Object;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_Class_isInstance(JNIEnv *env, java_lang_Class *this, java_lang_Object *obj)
-{
-       classinfo     *c;
-       java_handle_t *h;
-
-       c = LLNI_classinfo_unwrap(this);
-       h = (java_handle_t *) obj;
-
-       return class_is_instance(c, h);
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    isAssignableFrom
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_Class_isAssignableFrom(JNIEnv *env, java_lang_Class *this, java_lang_Class *cls)
-{
-       classinfo *to;
-       classinfo *from;
-
-       to   = LLNI_classinfo_unwrap(this);
-       from = LLNI_classinfo_unwrap(cls);
-
-       if (from == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       return class_is_assignable_from(to, from);
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    isInterface
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_Class_isInterface(JNIEnv *env, java_lang_Class *this)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(this);
-
-       return class_is_interface(c);
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    isArray
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_Class_isArray(JNIEnv *env, java_lang_Class *this)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(this);
-
-       return class_is_array(c);
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    getName
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_Class_getName(JNIEnv *env, java_lang_Class *this)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(this);
-
-       return (java_lang_String*) class_get_classname(c);
-}
-
-
-/*
- * 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/native/vm/cldc1.1/java_lang_Class.cpp b/src/native/vm/cldc1.1/java_lang_Class.cpp
new file mode 100644 (file)
index 0000000..4a2d0ee
--- /dev/null
@@ -0,0 +1,245 @@
+/* src/native/vm/cldc1.1/java_lang_Class.cpp
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Class.h"
+#endif
+
+#include "vm/exceptions.hpp"
+#include "vm/initialize.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/Class
+ * Method:    forName
+ * Signature: (Ljava/lang/String;)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_Class_forName(JNIEnv *env, jclass clazz, jstring name)
+{
+       utf       *ufile;
+       utf       *uname;
+       classinfo *c;
+       char*      pos;
+       int32_t    i;
+
+       /* illegal argument */
+
+       if (name == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* create utf string in which '.' is replaced by '/' */
+
+       ufile = javastring_toutf((java_handle_t *) name, true);
+       uname = javastring_toutf((java_handle_t *) name, false);
+
+       /* name must not contain '/' (mauve test) */
+
+       // FIXME Move this check into a function.
+       for (i = 0, pos = uname->text; i < uname->blength; i++, pos++) {
+               if (*pos == '/') {
+                       exceptions_throw_classnotfoundexception(uname);
+                       return NULL;
+               }
+       }
+
+       /* try to load, ... */
+
+       c = load_class_bootstrap(ufile);
+
+       if (c == NULL)
+           return NULL;
+
+       /* link, ... */
+
+       if (!link_class(c))
+               return NULL;
+       
+       /* ...and initialize it. */
+
+       if (!initialize_class(c))
+               return NULL;
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    newInstance
+ * Signature: ()Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_Class_newInstance(JNIEnv *env, jclass _this)
+{
+       classinfo     *c;
+       java_handle_t *o;
+
+       c = LLNI_classinfo_unwrap(_this);
+
+       o = native_new_and_init(c);
+
+       return (jobject) o;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isInstance
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_Class_isInstance(JNIEnv *env, jclass _this, jobject obj)
+{
+       classinfo     *c;
+       java_handle_t *h;
+
+       c = LLNI_classinfo_unwrap(_this);
+       h = (java_handle_t *) obj;
+
+       return class_is_instance(c, h);
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isAssignableFrom
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_Class_isAssignableFrom(JNIEnv *env, jclass _this, jclass cls)
+{
+       classinfo *to;
+       classinfo *from;
+
+       to   = LLNI_classinfo_unwrap(_this);
+       from = LLNI_classinfo_unwrap(cls);
+
+       if (from == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       return class_is_assignable_from(to, from);
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isInterface
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_Class_isInterface(JNIEnv *env, jclass _this)
+{
+       classinfo *c;
+
+       c = LLNI_classinfo_unwrap(_this);
+
+       return class_is_interface(c);
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isArray
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_Class_isArray(JNIEnv *env, jclass _this)
+{
+       classinfo *c;
+
+       c = LLNI_classinfo_unwrap(_this);
+
+       return class_is_array(c);
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getName
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_java_lang_Class_getName(JNIEnv *env, jclass _this)
+{
+       classinfo *c;
+
+       c = LLNI_classinfo_unwrap(_this);
+
+       return (jstring) class_get_classname(c);
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "forName",          (char*) "(Ljava/lang/String;)Ljava/lang/Class;",(void*) (uintptr_t) &Java_java_lang_Class_forName          },
+       { (char*) "newInstance",      (char*) "()Ljava/lang/Object;",                 (void*) (uintptr_t) &Java_java_lang_Class_newInstance      },
+       { (char*) "isInstance",       (char*) "(Ljava/lang/Object;)Z",                (void*) (uintptr_t) &Java_java_lang_Class_isInstance       },
+       { (char*) "isAssignableFrom", (char*) "(Ljava/lang/Class;)Z",                 (void*) (uintptr_t) &Java_java_lang_Class_isAssignableFrom },
+       { (char*) "isInterface",      (char*) "()Z",                                  (void*) (uintptr_t) &Java_java_lang_Class_isInterface      },
+       { (char*) "isArray",          (char*) "()Z",                                  (void*) (uintptr_t) &Java_java_lang_Class_isArray          },
+       { (char*) "getName",          (char*) "()Ljava/lang/String;",                 (void*) (uintptr_t) &Java_java_lang_Class_getName          },
+};
+
+
+/* _Jv_java_lang_Class_init ****************************************************
+   Register native functions.
+*******************************************************************************/
+
+void _Jv_java_lang_Class_init(void)
+{
+       utf* u = utf_new_char("java/lang/Class");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/cldc1.1/java_lang_Double.c b/src/native/vm/cldc1.1/java_lang_Double.c
deleted file mode 100644 (file)
index 99f3195..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/* src/native/vm/cldc1.1/java_lang_Double.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
-
-   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 "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Double.h"
-
-#include "vm/builtin.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "doubleToLongBits", "(D)J", (void *) (ptrint) &Java_java_lang_Double_doubleToLongBits },
-       { "longBitsToDouble", "(J)D", (void *) (ptrint) &Java_java_lang_Double_longBitsToDouble },
-};
-/* _Jv_java_lang_Double_init ***************************************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_java_lang_Double_init(void)
-{
-       utf *u;
-       u = utf_new_char("java/lang/Double");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/Double
- * Method:    doubleToLongBits
- * Signature: (D)J
- */
-JNIEXPORT s8 JNICALL Java_java_lang_Double_doubleToLongBits(JNIEnv *env, jclass clazz, double doubleValue)
-{
-       jvalue val;
-       s8  e, f;
-       val.d = doubleValue;
-
-#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
-       /* On little endian ARM processors when using FPA, word order of
-          doubles is still big endian. So take that into account here. When
-          using VFP, word order of doubles follows byte order. */
-
-#define SWAP_DOUBLE(a)    (((a) << 32) | (((a) >> 32) & 0x00000000ffffffff))
-
-       val.j = SWAP_DOUBLE(val.j);
-#endif
-
-       e = val.j & 0x7ff0000000000000LL;
-       f = val.j & 0x000fffffffffffffLL;
-
-       if (e == DBL_POSINF && f != 0L)
-               val.j = DBL_NAN;
-
-       return val.j;
-}
-
-
-/*
- * Class:     java/lang/Double
- * Method:    longBitsToDouble
- * Signature: (J)D
- */
-JNIEXPORT double JNICALL Java_java_lang_Double_longBitsToDouble(JNIEnv *env, jclass clazz, s8 longValue)
-{
-       jvalue val;
-       val.j = longValue;
-
-#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
-       val.j = SWAP_DOUBLE(val.j);
-#endif
-
-       return val.d;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/cldc1.1/java_lang_Double.cpp b/src/native/vm/cldc1.1/java_lang_Double.cpp
new file mode 100644 (file)
index 0000000..6f5f701
--- /dev/null
@@ -0,0 +1,130 @@
+/* src/native/vm/cldc1.1/java_lang_Double.c
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Double.h"
+#endif
+
+#include "vm/vm.hpp"
+
+#include "vm/jit/builtin.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/Double
+ * Method:    doubleToLongBits
+ * Signature: (D)J
+ */
+JNIEXPORT jlong JNICALL Java_java_lang_Double_doubleToLongBits(JNIEnv *env, jclass clazz, jdouble doubleValue)
+{
+       jvalue val;
+       s8  e, f;
+       val.d = doubleValue;
+
+#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
+       /* On little endian ARM processors when using FPA, word order of
+          doubles is still big endian. So take that into account here. When
+          using VFP, word order of doubles follows byte order. */
+
+#define SWAP_DOUBLE(a)    (((a) << 32) | (((a) >> 32) & 0x00000000ffffffff))
+
+       val.j = SWAP_DOUBLE(val.j);
+#endif
+
+       e = val.j & 0x7ff0000000000000LL;
+       f = val.j & 0x000fffffffffffffLL;
+
+       if (e == DBL_POSINF && f != 0L)
+               val.j = DBL_NAN;
+
+       return val.j;
+}
+
+
+/*
+ * Class:     java/lang/Double
+ * Method:    longBitsToDouble
+ * Signature: (J)D
+ */
+JNIEXPORT jdouble JNICALL Java_java_lang_Double_longBitsToDouble(JNIEnv *env, jclass clazz, jlong longValue)
+{
+       jvalue val;
+       val.j = longValue;
+
+#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
+       val.j = SWAP_DOUBLE(val.j);
+#endif
+
+       return val.d;
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "doubleToLongBits", (char*) "(D)J", (void*) (uintptr_t) &Java_java_lang_Double_doubleToLongBits },
+       { (char*) "longBitsToDouble", (char*) "(J)D", (void*) (uintptr_t) &Java_java_lang_Double_longBitsToDouble },
+};
+/* _Jv_java_lang_Double_init ***************************************************
+   Register native functions.
+*******************************************************************************/
+
+void _Jv_java_lang_Double_init(void)
+{
+       utf* u = utf_new_char("java/lang/Double");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/cldc1.1/java_lang_Float.c b/src/native/vm/cldc1.1/java_lang_Float.c
deleted file mode 100644 (file)
index 67cb004..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* src/native/vm/cldc1.1/java_lang_Float.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
-
-   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 "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Float.h"
-
-#include "vm/builtin.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "floatToIntBits", "(F)I",     (void *) (ptrint) &Java_java_lang_Float_floatToIntBits },
-};
-/* _Jv_java_lang_Float_init ****************************************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_java_lang_Float_init(void)
-{
-       utf *u;
-       u = utf_new_char("java/lang/Float");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-/*
- * Class:     java/lang/Float
- * Method:    floatToIntBits
- * Signature: (F)I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_Float_floatToIntBits(JNIEnv *env, jclass clazz, float value)
-{
-       imm_union val;
-       int e, f;
-
-       val.f = value;
-
-       e = val.i & 0x7f800000;
-       f = val.i & 0x007fffff;
-
-       if (e == FLT_POSINF && f != 0)
-               return FLT_NAN;
-
-       return val.i;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/cldc1.1/java_lang_Float.cpp b/src/native/vm/cldc1.1/java_lang_Float.cpp
new file mode 100644 (file)
index 0000000..9d521e2
--- /dev/null
@@ -0,0 +1,102 @@
+/* src/native/vm/cldc1.1/java_lang_Float.cpp
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Float.h"
+#endif
+
+#include "vm/vm.hpp"
+
+#include "vm/jit/builtin.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/Float
+ * Method:    floatToIntBits
+ * Signature: (F)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_Float_floatToIntBits(JNIEnv *env, jclass clazz, jfloat value)
+{
+       imm_union val;
+       int e, f;
+
+       val.f = value;
+
+       e = val.i & 0x7f800000;
+       f = val.i & 0x007fffff;
+
+       if (e == FLT_POSINF && f != 0)
+               return FLT_NAN;
+
+       return val.i;
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "floatToIntBits", (char*) "(F)I", (void*) (uintptr_t) &Java_java_lang_Float_floatToIntBits },
+};
+/* _Jv_java_lang_Float_init ****************************************************
+   Register native functions.
+*******************************************************************************/
+
+void _Jv_java_lang_Float_init(void)
+{
+       utf* u = utf_new_char("java/lang/Float");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/cldc1.1/java_lang_Math.c b/src/native/vm/cldc1.1/java_lang_Math.c
deleted file mode 100644 (file)
index 9d542b7..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/* src/native/vm/cldc1.1/java_lang_Math.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
-
-   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 "vm/types.h"
-
-#include "fdlibm/fdlibm.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Math.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "ceil",  "(D)D", (void *) (ptrint) &Java_java_lang_Math_ceil  },
-       { "cos",   "(D)D", (void *) (ptrint) &Java_java_lang_Math_cos   },
-       { "floor", "(D)D", (void *) (ptrint) &Java_java_lang_Math_floor },
-       { "sin",   "(D)D", (void *) (ptrint) &Java_java_lang_Math_sin   },
-       { "sqrt",  "(D)D", (void *) (ptrint) &Java_java_lang_Math_sqrt  },
-       { "tan",   "(D)D", (void *) (ptrint) &Java_java_lang_Math_tan   },
-};
-/* _Jv_java_lang_Math_init *****************************************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_java_lang_Math_init(void)
-{
-       utf *u;
-       u = utf_new_char("java/lang/Math");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/Math
- * Method:    ceil
- * Signature: (D)D
- */
-JNIEXPORT double JNICALL Java_java_lang_Math_ceil(JNIEnv *env, jclass clazz, double a)
-{
-       return ceil(a);
-}
-
-
-/*
- * Class:     java/lang/Math
- * Method:    cos
- * Signature: (D)D
- */
-JNIEXPORT double JNICALL Java_java_lang_Math_cos(JNIEnv *env, jclass clazz, double a)
-{
-       return cos(a);
-}
-
-
-/*
- * Class:     java/lang/Math
- * Method:    floor
- * Signature: (D)D
- */
-JNIEXPORT double JNICALL Java_java_lang_Math_floor(JNIEnv *env, jclass clazz, double a)
-{
-       return floor(a);
-}
-
-
-/*
- * Class:     java/lang/Math
- * Method:    sin
- * Signature: (D)D
- */
-JNIEXPORT double JNICALL Java_java_lang_Math_sin(JNIEnv *env, jclass clazz, double a)
-{
-       return sin(a);
-}
-
-
-/*
- * Class:     java/lang/Math
- * Method:    sqrt
- * Signature: (D)D
- */
-JNIEXPORT double JNICALL Java_java_lang_Math_sqrt(JNIEnv *env, jclass clazz, double a)
-{
-       return sqrt(a);
-}
-
-
-/*
- * Class:     java/lang/Math
- * Method:    tan
- * Signature: (D)D
- */
-JNIEXPORT double JNICALL Java_java_lang_Math_tan(JNIEnv *env, jclass clazz, double a)
-{
-       return tan(a);
-}
-
-
-/*
- * 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/native/vm/cldc1.1/java_lang_Math.cpp b/src/native/vm/cldc1.1/java_lang_Math.cpp
new file mode 100644 (file)
index 0000000..50f2c93
--- /dev/null
@@ -0,0 +1,152 @@
+/* src/native/vm/cldc1.1/java_lang_Math.cpp
+
+   Copyright (C) 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 <stdint.h>
+
+#include "fdlibm/fdlibm.h"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Math.h"
+#endif
+
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/Math
+ * Method:    ceil
+ * Signature: (D)D
+ */
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_ceil(JNIEnv *env, jclass clazz, jdouble a)
+{
+       return ceil(a);
+}
+
+
+/*
+ * Class:     java/lang/Math
+ * Method:    cos
+ * Signature: (D)D
+ */
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_cos(JNIEnv *env, jclass clazz, jdouble a)
+{
+       return cos(a);
+}
+
+
+/*
+ * Class:     java/lang/Math
+ * Method:    floor
+ * Signature: (D)D
+ */
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_floor(JNIEnv *env, jclass clazz, jdouble a)
+{
+       return floor(a);
+}
+
+
+/*
+ * Class:     java/lang/Math
+ * Method:    sin
+ * Signature: (D)D
+ */
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_sin(JNIEnv *env, jclass clazz, jdouble a)
+{
+       return sin(a);
+}
+
+
+/*
+ * Class:     java/lang/Math
+ * Method:    sqrt
+ * Signature: (D)D
+ */
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_sqrt(JNIEnv *env, jclass clazz, jdouble a)
+{
+       return sqrt(a);
+}
+
+
+/*
+ * Class:     java/lang/Math
+ * Method:    tan
+ * Signature: (D)D
+ */
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_tan(JNIEnv *env, jclass clazz, jdouble a)
+{
+       return tan(a);
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "ceil",  (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_ceil  },
+       { (char*) "cos",   (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_cos   },
+       { (char*) "floor", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_floor },
+       { (char*) "sin",   (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_sin   },
+       { (char*) "sqrt",  (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_sqrt  },
+       { (char*) "tan",   (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_tan   },
+};
+/* _Jv_java_lang_Math_init *****************************************************
+   Register native functions.
+*******************************************************************************/
+
+void _Jv_java_lang_Math_init(void)
+{
+       utf* u = utf_new_char("java/lang/Math");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/cldc1.1/java_lang_Object.c b/src/native/vm/cldc1.1/java_lang_Object.c
deleted file mode 100644 (file)
index 26808ea..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/* src/native/vm/cldc1.1/java_lang_Object.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
-
-   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 <stdlib.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_String.h"             /* required by j.l.C */
-#include "native/include/java_lang_Class.h"
-
-#include "native/include/java_lang_Object.h"
-
-#include "threads/lock-common.h"
-
-#include "vm/exceptions.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "getClass",  "()Ljava/lang/Class;",                   (void *) (ptrint) &Java_java_lang_Object_getClass  },
-       { "hashCode",  "()I",                                   (void *) (ptrint) &Java_java_lang_Object_hashCode  },
-       { "notify",    "()V",                                   (void *) (ptrint) &Java_java_lang_Object_notify    },
-       { "notifyAll", "()V",                                   (void *) (ptrint) &Java_java_lang_Object_notifyAll },
-       { "wait",      "(J)V",                                  (void *) (ptrint) &Java_java_lang_Object_wait      },
-};
-/* _Jv_java_lang_Object_init ***************************************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_java_lang_Object_init(void)
-{
-       utf *u;
-       u = utf_new_char("java/lang/Object");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/Object
- * Method:    getClass
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Object_getClass(JNIEnv *env, java_lang_Object *obj)
-{
-       classinfo *c;
-
-       if (obj == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       LLNI_class_get(obj, c);
-
-       return LLNI_classinfo_wrap(c);
-}
-
-
-/*
- * Class:     java/lang/Object
- * Method:    hashCode
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, java_lang_Object *this)
-{
-#if defined(ENABLE_GC_CACAO)
-       assert(0);
-#else
-       return (int32_t) ((intptr_t) this);
-#endif
-}
-
-
-/*
- * Class:     java/lang/Object
- * Method:    notify
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, java_lang_Object *this)
-{
-#if defined(ENABLE_THREADS)
-       lock_notify_object((java_handle_t *) this);
-#endif
-}
-
-
-/*
- * Class:     java/lang/Object
- * Method:    notifyAll
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, java_lang_Object *this)
-{
-#if defined(ENABLE_THREADS)
-       lock_notify_all_object((java_handle_t *) this);
-#endif
-}
-
-
-/*
- * Class:     java/lang/Object
- * Method:    wait
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, java_lang_Object *this, s8 timeout)
-{
-#if defined(ENABLE_JVMTI)
-       /* Monitor Wait */
-       if (jvmti) jvmti_MonitorWaiting(true, this, timeout);
-#endif
-
-#if defined(ENABLE_THREADS)
-       lock_wait_for_object((java_handle_t *) this, timeout, 0);
-#endif
-
-#if defined(ENABLE_JVMTI)
-       /* Monitor Waited */
-       /* XXX: How do you know if wait timed out ?*/
-       if (jvmti) jvmti_MonitorWaiting(false, this, 0);
-#endif
-}
-
-
-/*
- * 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/native/vm/cldc1.1/java_lang_Object.cpp b/src/native/vm/cldc1.1/java_lang_Object.cpp
new file mode 100644 (file)
index 0000000..ac38a37
--- /dev/null
@@ -0,0 +1,169 @@
+/* src/native/vm/cldc1.1/java_lang_Object.c
+
+   Copyright (C) 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 <stdint.h>
+#include <stdlib.h>
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Object.h"
+#endif
+
+#include "threads/lock.hpp"
+
+#include "vm/exceptions.hpp"
+#include "vm/javaobjects.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/Object
+ * Method:    getClass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_Object_getClass(JNIEnv *env, jobject obj)
+{
+       if (obj == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       java_lang_Object o(obj);
+
+       return (jclass) LLNI_classinfo_wrap(o.get_Class());
+}
+
+
+/*
+ * Class:     java/lang/Object
+ * Method:    hashCode
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, jobject _this)
+{
+       java_lang_Object o(_this);
+
+       return o.get_hashcode();
+}
+
+
+/*
+ * Class:     java/lang/Object
+ * Method:    notify
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, jobject _this)
+{
+#if defined(ENABLE_THREADS)
+       lock_notify_object((java_handle_t *) _this);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/Object
+ * Method:    notifyAll
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, jobject _this)
+{
+#if defined(ENABLE_THREADS)
+       lock_notify_all_object((java_handle_t *) _this);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/Object
+ * Method:    wait
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, jobject _this, jlong timeout)
+{
+#if defined(ENABLE_JVMTI)
+       /* Monitor Wait */
+       if (jvmti) jvmti_MonitorWaiting(true, _this, timeout);
+#endif
+
+#if defined(ENABLE_THREADS)
+       lock_wait_for_object((java_handle_t *) _this, timeout, 0);
+#endif
+
+#if defined(ENABLE_JVMTI)
+       /* Monitor Waited */
+       /* XXX: How do you know if wait timed out ?*/
+       if (jvmti) jvmti_MonitorWaiting(false, _this, 0);
+#endif
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "getClass",  (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_Object_getClass  },
+       { (char*) "hashCode",  (char*) "()I",                 (void*) (uintptr_t) &Java_java_lang_Object_hashCode  },
+       { (char*) "notify",    (char*) "()V",                 (void*) (uintptr_t) &Java_java_lang_Object_notify    },
+       { (char*) "notifyAll", (char*) "()V",                 (void*) (uintptr_t) &Java_java_lang_Object_notifyAll },
+       { (char*) "wait",      (char*) "(J)V",                (void*) (uintptr_t) &Java_java_lang_Object_wait      },
+};
+/* _Jv_java_lang_Object_init ***************************************************
+   Register native functions.
+*******************************************************************************/
+void _Jv_java_lang_Object_init(void)
+{
+       utf* u = utf_new_char("java/lang/Object");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/cldc1.1/java_lang_Runtime.c b/src/native/vm/cldc1.1/java_lang_Runtime.c
deleted file mode 100644 (file)
index 838c683..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/* src/native/vm/cldc1.1/java_lang_Runtime.c
-
-   Copyright (C) 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 <stdint.h>
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Runtime.h"
-
-#include "vm/vm.h"
-
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "exitInternal", "(I)V", (void *) (intptr_t) &Java_java_lang_Runtime_exitInternal },
-       { "freeMemory",   "()J",  (void *) (intptr_t) &Java_java_lang_Runtime_freeMemory   },
-       { "totalMemory",  "()J",  (void *) (intptr_t) &Java_java_lang_Runtime_totalMemory  },
-       { "gc",           "()V",  (void *) (intptr_t) &Java_java_lang_Runtime_gc           },
-};
-/* _Jv_java_lang_Runtime_init **************************************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_java_lang_Runtime_init(void)
-{
-       utf *u;
-       u = utf_new_char("java/lang/Runtime");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/Runtime
- * Method:    exitInternal
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_java_lang_Runtime_exitInternal(JNIEnv *env, java_lang_Runtime *this, int32_t status)
-{
-       vm_shutdown(status);
-}
-
-
-/*
- * Class:     java/lang/Runtime
- * Method:    freeMemory
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_java_lang_Runtime_freeMemory(JNIEnv *env, java_lang_Runtime *this)
-{
-       return gc_get_free_bytes();
-}
-
-
-/*
- * Class:     java/lang/Runtime
- * Method:    totalMemory
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_java_lang_Runtime_totalMemory(JNIEnv *env, java_lang_Runtime *this)
-{
-       return gc_get_heap_size();
-}
-
-
-/*
- * Class:     java/lang/Runtime
- * Method:    gc
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_Runtime_gc(JNIEnv *env, java_lang_Runtime *this)
-{
-       gc_call();
-}
-
-
-/*
- * 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/native/vm/cldc1.1/java_lang_Runtime.cpp b/src/native/vm/cldc1.1/java_lang_Runtime.cpp
new file mode 100644 (file)
index 0000000..a837bf2
--- /dev/null
@@ -0,0 +1,129 @@
+/* src/native/vm/cldc1.1/java_lang_Runtime.cpp
+
+   Copyright (C) 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 <stdint.h>
+
+#include "mm/gc.hpp"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Runtime.h"
+#endif
+
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/Runtime
+ * Method:    exitInternal
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_exitInternal(JNIEnv *env, jobject _this, jint status)
+{
+       vm_shutdown(status);
+}
+
+
+/*
+ * Class:     java/lang/Runtime
+ * Method:    freeMemory
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_java_lang_Runtime_freeMemory(JNIEnv *env, jobject _this)
+{
+       return gc_get_free_bytes();
+}
+
+
+/*
+ * Class:     java/lang/Runtime
+ * Method:    totalMemory
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_java_lang_Runtime_totalMemory(JNIEnv *env, jobject _this)
+{
+       return gc_get_heap_size();
+}
+
+
+/*
+ * Class:     java/lang/Runtime
+ * Method:    gc
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_gc(JNIEnv *env, jobject _this)
+{
+       gc_call();
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "exitInternal", (char*) "(I)V", (void*) (uintptr_t) &Java_java_lang_Runtime_exitInternal },
+       { (char*) "freeMemory",   (char*) "()J",  (void*) (uintptr_t) &Java_java_lang_Runtime_freeMemory   },
+       { (char*) "totalMemory",  (char*) "()J",  (void*) (uintptr_t) &Java_java_lang_Runtime_totalMemory  },
+       { (char*) "gc",           (char*) "()V",  (void*) (uintptr_t) &Java_java_lang_Runtime_gc           },
+};
+/* _Jv_java_lang_Runtime_init **************************************************
+   Register native functions.
+*******************************************************************************/
+void _Jv_java_lang_Runtime_init(void)
+{
+       utf* u = utf_new_char("java/lang/Runtime");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/cldc1.1/java_lang_String.c b/src/native/vm/cldc1.1/java_lang_String.c
deleted file mode 100644 (file)
index c0ba6ad..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/* 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
-
-   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 <stdlib.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-
-#include "native/include/java_lang_String.h"
-
-#include "vm/stringlocal.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "hashCode",    "()I",                    (void *) (ptrint) &Java_java_lang_String_hashCode        },
-       { "indexOf",     "(I)I",                   (void *) (ptrint) &Java_java_lang_String_indexOf__I      },
-       { "indexOf",     "(II)I",                  (void *) (ptrint) &Java_java_lang_String_indexOf__II     },
-       { "lastIndexOf", "(I)I",                   (void *) (ptrint) &Java_java_lang_String_lastIndexOf__I  },
-       { "lastIndexOf", "(II)I",                  (void *) (ptrint) &Java_java_lang_String_lastIndexOf__II },
-#if 0
-       { "equals",      "(Ljava/lang/Object;)Z;", (void *) (ptrint) &Java_java_lang_String_equals          },
-#endif
-       { "intern",      "()Ljava/lang/String;",   (void *) (ptrint) &Java_java_lang_String_intern          },
-};
-
-
-/* _Jv_java_lang_String_init ***************************************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_java_lang_String_init(void)
-{
-       utf *u;
-       u = utf_new_char("java/lang/String");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/String
- * Method:    hashCode
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_String_hashCode(JNIEnv *env, java_lang_String *this)
-{
-       java_handle_chararray_t *value;
-       int32_t                 offset;
-       int32_t                 count;
-       s4                              hash;
-       s4                              i;
-
-       /* get values from Java object */
-       
-       LLNI_field_get_val(this, offset, offset);
-       LLNI_field_get_val(this, count, count);
-       LLNI_field_get_ref(this, value, value);
-
-       hash = 0;
-
-       for (i = 0; i < count; i++) {
-               hash = (31 * hash) + LLNI_array_direct(value, offset + i);
-       }
-
-       return hash;
-}
-
-
-/*
- * Class:     java/lang/String
- * Method:    indexOf
- * Signature: (I)I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_String_indexOf__I(JNIEnv *env, java_lang_String *this, s4 ch)
-{
-       java_handle_chararray_t *value;
-       int32_t                 offset;
-       int32_t                 count;
-       s4                              i;
-
-       /* get values from Java object */
-
-       LLNI_field_get_val(this, offset, offset);
-       LLNI_field_get_val(this, count, count);
-       LLNI_field_get_ref(this, value, value);
-
-       for (i = 0; i < count; i++) {
-               if (LLNI_array_direct(value, offset + i) == ch) {
-                       return i;
-               }
-       }
-
-       return -1;
-}
-
-
-/*
- * Class:     java/lang/String
- * Method:    indexOf
- * Signature: (II)I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_String_indexOf__II(JNIEnv *env, java_lang_String *this, s4 ch, s4 fromIndex)
-{
-       java_handle_chararray_t *value;
-       int32_t                 offset;
-       int32_t                 count;
-       s4                              i;
-
-       /* get values from Java object */
-
-       LLNI_field_get_val(this, offset, offset);
-       LLNI_field_get_val(this, count, count);
-       LLNI_field_get_ref(this, value, value);
-
-       if (fromIndex < 0) {
-               fromIndex = 0;
-       }
-       else if (fromIndex >= count) {
-               /* Note: fromIndex might be near -1>>>1. */
-               return -1;
-       }
-
-       for (i = fromIndex ; i < count ; i++) {
-               if (LLNI_array_direct(value, offset + i) == ch) {
-                       return i;
-               }
-       }
-
-       return -1;
-}
-
-
-/*
- * Class:     java/lang/String
- * Method:    lastIndexOf
- * Signature: (I)I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_String_lastIndexOf__I(JNIEnv *env, java_lang_String *this, s4 ch)
-{
-       int32_t count;
-       
-       LLNI_field_get_val(this, count, count);
-       
-       return Java_java_lang_String_lastIndexOf__II(env, this, ch, count - 1);
-}
-
-
-/*
- * Class:     java/lang/String
- * Method:    lastIndexOf
- * Signature: (II)I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_String_lastIndexOf__II(JNIEnv *env, java_lang_String *this, s4 ch, s4 fromIndex)
-{
-       java_handle_chararray_t *value;
-       int32_t                 offset;
-       int32_t                 count;
-       s4                              start;
-       s4                              i;
-
-       /* get values from Java object */
-
-       LLNI_field_get_val(this, offset, offset);
-       LLNI_field_get_val(this, count, count);
-       LLNI_field_get_ref(this, value, value);
-
-       start = ((fromIndex >= count) ? count - 1 : fromIndex);
-
-       for (i = start; i >= 0; i--) {
-               if (LLNI_array_direct(value, offset + i) == ch) {
-                       return i;
-               }
-       }
-
-       return -1;
-}
-
-
-#if 0
-/*
- * Class:     java/lang/String
- * Method:    equals
- * Signature: (Ljava/lang/Object;)Z;
- */
-JNIEXPORT s4 JNICALL Java_java_lang_String_equals(JNIEnv *env, java_lang_String* this, java_lang_Object *o)
-{
-       java_lang_String*               s;
-       java_handle_chararray_t *value;
-       int32_t                 offset;
-       int32_t                 count;
-       java_handle_chararray_t *dvalue;
-       int32_t                 doffset;
-       int32_t                 dcount;
-       classinfo                       *c;
-       
-       LLNI_field_get_val(this, offset, offset);
-       LLNI_field_get_val(this, count, count);
-       LLNI_field_get_ref(this, value, value);
-       LLNI_class_get(o, c);
-
-       /* TODO: is this the correct implementation for short-circuiting on object identity? */
-       if ((java_lang_Object*)this == o)
-               return 1;
-       
-       if (c != class_java_lang_String) 
-               return 0;
-
-       s = (java_lang_String *) o;
-       LLNI_field_get_val(this, offset, doffset);
-       LLNI_field_get_val(this, count, dcount);
-       LLNI_field_get_ref(this, value, dvalue);
-
-       if (count != dcount)
-               return 0;
-
-       return ( 0 == memcmp((void*)(LLNI_array_direct(value, offset)),
-                                                (void*)(LLNI_array_direct(dvalue, doffset),
-                                                count) );
-
-}
-#endif
-
-
-/*
- * Class:     java/lang/String
- * Method:    intern
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_String_intern(JNIEnv *env, java_lang_String *this)
-{
-       if (this == NULL)
-               return NULL;
-
-       return (java_lang_String *) javastring_intern((java_handle_t *) this);
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/cldc1.1/java_lang_String.cpp b/src/native/vm/cldc1.1/java_lang_String.cpp
new file mode 100644 (file)
index 0000000..b86e539
--- /dev/null
@@ -0,0 +1,221 @@
+/* src/native/vm/cldc1.1/java_lang_String.cpp
+
+   Copyright (C) 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 <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_String.h"
+#endif
+
+#include "vm/javaobjects.hpp"
+#include "vm/string.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/String
+ * Method:    hashCode
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_String_hashCode(JNIEnv *env, jstring _this)
+{
+       java_lang_String jls(_this);
+
+       java_handle_chararray_t* value = jls.get_value();
+       int32_t offset = jls.get_offset();
+       int32_t count  = jls.get_count();
+
+       int32_t hash = 0;
+
+       for (int32_t i = 0; i < count; i++) {
+               hash = (31 * hash) + LLNI_array_direct(value, offset + i);
+       }
+
+       return hash;
+}
+
+
+/*
+ * Class:     java/lang/String
+ * Method:    indexOf
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_String_indexOf__I(JNIEnv *env, jstring _this, jint ch)
+{
+       java_lang_String jls(_this);
+
+       java_handle_chararray_t* value = jls.get_value();
+       int32_t offset = jls.get_offset();
+       int32_t count  = jls.get_count();
+
+       for (int32_t i = 0; i < count; i++) {
+               if (LLNI_array_direct(value, offset + i) == ch) {
+                       return i;
+               }
+       }
+
+       return -1;
+}
+
+
+/*
+ * Class:     java/lang/String
+ * Method:    indexOf
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_String_indexOf__II(JNIEnv *env, jstring _this, jint ch, jint fromIndex)
+{
+       java_lang_String jls(_this);
+
+       java_handle_chararray_t* value = jls.get_value();
+       int32_t offset = jls.get_offset();
+       int32_t count  = jls.get_count();
+
+       if (fromIndex < 0) {
+               fromIndex = 0;
+       }
+       else if (fromIndex >= count) {
+               // Note: fromIndex might be near -1>>>1.
+               return -1;
+       }
+
+       for (int32_t i = fromIndex ; i < count ; i++) {
+               if (LLNI_array_direct(value, offset + i) == ch) {
+                       return i;
+               }
+       }
+
+       return -1;
+}
+
+
+/*
+ * Class:     java/lang/String
+ * Method:    lastIndexOf
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_String_lastIndexOf__II(JNIEnv *env, jstring _this, jint ch, jint fromIndex)
+{
+       java_lang_String jls(_this);
+
+       java_handle_chararray_t* value = jls.get_value();
+       int32_t offset = jls.get_offset();
+       int32_t count  = jls.get_count();
+
+       int32_t start = ((fromIndex >= count) ? count - 1 : fromIndex);
+
+       for (int32_t i = start; i >= 0; i--) {
+               if (LLNI_array_direct(value, offset + i) == ch) {
+                       return i;
+               }
+       }
+
+       return -1;
+}
+
+
+/*
+ * Class:     java/lang/String
+ * Method:    lastIndexOf
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_String_lastIndexOf__I(JNIEnv *env, jstring _this, jint ch)
+{
+       java_lang_String jls(_this);
+       
+       return Java_java_lang_String_lastIndexOf__II(env, _this, ch, jls.get_count() - 1);
+}
+
+
+/*
+ * Class:     java/lang/String
+ * Method:    intern
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_java_lang_String_intern(JNIEnv *env, jstring _this)
+{
+       java_lang_String jls(_this);
+
+       if (jls.is_null())
+               return NULL;
+
+       return (jstring) javastring_intern(jls.get_handle());
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "hashCode",    (char*) "()I",                    (void*) (uintptr_t) &Java_java_lang_String_hashCode        },
+       { (char*) "indexOf",     (char*) "(I)I",                   (void*) (uintptr_t) &Java_java_lang_String_indexOf__I      },
+       { (char*) "indexOf",     (char*) "(II)I",                  (void*) (uintptr_t) &Java_java_lang_String_indexOf__II     },
+       { (char*) "lastIndexOf", (char*) "(II)I",                  (void*) (uintptr_t) &Java_java_lang_String_lastIndexOf__II },
+       { (char*) "lastIndexOf", (char*) "(I)I",                   (void*) (uintptr_t) &Java_java_lang_String_lastIndexOf__I  },
+#if 0
+       { (char*) "equals",      (char*) "(Ljava/lang/Object;)Z;", (void*) (uintptr_t) &Java_java_lang_String_equals          },
+#endif
+       { (char*) "intern",      (char*) "()Ljava/lang/String;",   (void*) (uintptr_t) &Java_java_lang_String_intern          },
+};
+
+
+/* _Jv_java_lang_String_init ***************************************************
+   Register native functions.
+*******************************************************************************/
+void _Jv_java_lang_String_init(void)
+{
+       utf* u = utf_new_char("java/lang/String");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/cldc1.1/java_lang_System.c b/src/native/vm/cldc1.1/java_lang_System.c
deleted file mode 100644 (file)
index 7a14f9e..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/* 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
-
-   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 <stdlib.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-
-#include "native/include/java_lang_System.h"
-
-#include "vm/builtin.h"
-#include "vm/properties.h"
-#include "vm/stringlocal.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "arraycopy",    "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void *) (ptrint) &Java_java_lang_System_arraycopy    },
-       { "getProperty0", "(Ljava/lang/String;)Ljava/lang/String;",     (void *) (ptrint) &Java_java_lang_System_getProperty0 },
-};
-
-
-/* _Jv_java_lang_System_init ***************************************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_java_lang_System_init(void)
-{
-       utf *u;
-       u = utf_new_char("java/lang/System");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/System
- * Method:    arraycopy
- * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V
- */
-JNIEXPORT void JNICALL Java_java_lang_System_arraycopy(JNIEnv *env, jclass clazz, java_lang_Object *src, s4 srcStart, java_lang_Object *dest, s4 destStart, s4 len)
-{
-       builtin_arraycopy((java_handle_t *) src, srcStart,
-                                         (java_handle_t *) dest, destStart, len);
-}
-
-
-/*
- * Class:     java/lang/System
- * Method:    getProperty0
- * Signature: (Ljava/lang/String;)Ljava/lang/String;
- */
-
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_System_getProperty0(JNIEnv *env, jclass clazz, java_lang_String *s)
-{
-       java_handle_t *so;
-       char*          key;
-       char*          value;
-       java_handle_t *result;
-
-       so = (java_handle_t *) s;
-
-       /* build an ASCII string out of the java/lang/String passed */
-
-       key = javastring_tochar(so);
-
-       /* get the property from the internal table */
-
-       value = properties_get(key);
-
-       /* release the memory allocated in javastring_tochar */
-
-       MFREE(key, char, 0);
-
-       if (value == NULL)
-               return NULL;
-
-       result = javastring_new_from_ascii(value);
-
-       return (java_lang_String *) result;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/cldc1.1/java_lang_System.cpp b/src/native/vm/cldc1.1/java_lang_System.cpp
new file mode 100644 (file)
index 0000000..ccc1c0e
--- /dev/null
@@ -0,0 +1,133 @@
+/* src/native/vm/cldc1.1/java_lang_System.cpp
+
+   Copyright (C) 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 <stdint.h>
+#include <stdlib.h>
+
+#include "mm/memory.h"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_System.h"
+#endif
+
+#include "vm/jit/builtin.hpp"
+#include "vm/properties.hpp"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/System
+ * Method:    arraycopy
+ * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_System_arraycopy(JNIEnv *env, jclass clazz, jobject src, jint srcStart, jobject dest, jint destStart, jint len)
+{
+       builtin_arraycopy((java_handle_t *) src, srcStart,
+                                         (java_handle_t *) dest, destStart, len);
+}
+
+
+/*
+ * Class:     java/lang/System
+ * Method:    getProperty0
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+
+JNIEXPORT jstring JNICALL Java_java_lang_System_getProperty0(JNIEnv *env, jclass clazz, jstring s)
+{
+       java_handle_t *so;
+       char*          key;
+       const char*    value;
+       java_handle_t *result;
+
+       so = (java_handle_t *) s;
+
+       /* build an ASCII string out of the java/lang/String passed */
+
+       key = javastring_tochar(so);
+
+       /* get the property from the internal table */
+
+       value = VM::get_current()->get_properties().get(key);
+
+       /* release the memory allocated in javastring_tochar */
+
+       MFREE(key, char, 0);
+
+       if (value == NULL)
+               return NULL;
+
+       result = javastring_new_from_ascii(value);
+
+       return (jstring) result;
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "arraycopy",    (char*) "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void*) (uintptr_t) &Java_java_lang_System_arraycopy    },
+       { (char*) "getProperty0", (char*) "(Ljava/lang/String;)Ljava/lang/String;",     (void*) (uintptr_t) &Java_java_lang_System_getProperty0 },
+};
+
+
+/* _Jv_java_lang_System_init ***************************************************
+   Register native functions.
+*******************************************************************************/
+void _Jv_java_lang_System_init(void)
+{
+       utf* u = utf_new_char("java/lang/System");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/cldc1.1/java_lang_Thread.c b/src/native/vm/cldc1.1/java_lang_Thread.c
deleted file mode 100644 (file)
index da9ffd0..0000000
+++ /dev/null
@@ -1,236 +0,0 @@
-/* src/native/vm/cldc1.1/java_lang_Thread.c
-
-   Copyright (C) 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 <stdint.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Thread.h"
-
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "currentThread", "()Ljava/lang/Thread;", (void *) (ptrint) &Java_java_lang_Thread_currentThread },
-       { "setPriority0",  "(II)V",                (void *) (ptrint) &Java_java_lang_Thread_setPriority0  },
-       { "sleep",         "(J)V",                 (void *) (ptrint) &Java_java_lang_Thread_sleep         },
-       { "start0",        "()V",                  (void *) (ptrint) &Java_java_lang_Thread_start0        },
-       { "isAlive",       "()Z",                  (void *) (ptrint) &Java_java_lang_Thread_isAlive       },
-#if 0
-       { "activeCount",   "()I",                  (void *) (ptrint) &Java_java_lang_Thread_activeCount   },
-       { "setPriority0",  "(II)V",                (void *) (ptrint) &Java_java_lang_Thread_setPriority0  },
-       { "interrupt0",    "()V",                  (void *) (ptrint) &Java_java_lang_Thread_interrupt0    },
-       { "internalExit",  "()V",                  (void *) (ptrint) &Java_java_lang_Thread_internalExit  },
-#endif
-       { "yield",         "()V",                  (void *) (ptrint) &Java_java_lang_Thread_yield         },
-};
-
-
-/* _Jv_java_lang_Thread_init ***************************************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_java_lang_Thread_init(void)
-{
-       utf *u;
-       u = utf_new_char("java/lang/Thread");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/Thread
- * Method:    currentThread
- * Signature: ()Ljava/lang/Thread;
- */
-JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_Thread_currentThread(JNIEnv *env, jclass clazz)
-{
-       java_lang_Thread *to;
-
-       to = (java_lang_Thread *) thread_get_current_object();
-
-       return to;
-}
-
-
-/*
- * Class:     java/lang/Thread
- * Method:    setPriority0
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, java_lang_Thread *this, s4 oldPriority, s4 newPriority)
-{
-#if defined(ENABLE_THREADS)
-       threadobject *t;
-
-       t = (threadobject *) this->vm_thread;
-
-       /* The threadobject is null when a thread is created in Java. The
-          priority is set later during startup. */
-
-       if (t == NULL)
-               return;
-
-       threads_set_thread_priority(t->tid, newPriority);
-#endif
-}
-
-
-/*
- * Class:     java/lang/Thread
- * Method:    sleep
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL Java_java_lang_Thread_sleep(JNIEnv *env, jclass clazz, s8 millis)
-{
-#if defined(ENABLE_THREADS)
-       threads_sleep(millis, 0);
-#endif
-}
-
-
-/*
- * Class:     java/lang/Thread
- * Method:    start0
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_Thread_start0(JNIEnv *env, java_lang_Thread *this)
-{
-#if defined(ENABLE_THREADS)
-       threads_thread_start((java_handle_t *) this);
-#endif
-}
-
-
-/*
- * Class:     java/lang/Thread
- * Method:    isAlive
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, java_lang_Thread *this)
-{
-#if defined(ENABLE_THREADS)
-       threadobject *t;
-       bool          result;
-
-       t = (threadobject *) this->vm_thread;
-
-       if (t == NULL)
-               return 0;
-
-       result = threads_thread_is_alive(t);
-
-       return result;
-#else
-       /* If threads are disabled, the only thread running is alive. */
-
-       return 1;
-#endif
-}
-
-
-#if 0
-/*
- * Class:     java/lang/Thread
- * Method:    activeCount
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_Thread_activeCount(JNIEnv *env, jclass clazz)
-{
-}
-
-
-/*
- * Class:     java/lang/Thread
- * Method:    setPriority0
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, struct java_lang_Thread* this, s4 par1, s4 par2)
-{
-}
-
-
-/*
- * Class:     java/lang/Thread
- * Method:    interrupt0
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_Thread_interrupt0(JNIEnv *env, struct java_lang_Thread* this)
-{
-}
-
-
-/*
- * Class:     java/lang/Thread
- * Method:    internalExit
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_Thread_internalExit(JNIEnv *env, struct java_lang_Thread* this)
-{
-}
-#endif
-
-
-/*
- * Class:     java/lang/Thread
- * Method:    yield
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_Thread_yield(JNIEnv *env, jclass clazz)
-{
-#if defined(ENABLE_THREADS)
-       threads_yield();
-#endif
-}
-
-
-/*
- * 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/native/vm/cldc1.1/java_lang_Thread.cpp b/src/native/vm/cldc1.1/java_lang_Thread.cpp
new file mode 100644 (file)
index 0000000..99a7393
--- /dev/null
@@ -0,0 +1,223 @@
+/* src/native/vm/cldc1.1/java_lang_Thread.cpp
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Thread.h"
+#endif
+
+#include "threads/thread.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/javaobjects.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    currentThread
+ * Signature: ()Ljava/lang/Thread;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_Thread_currentThread(JNIEnv *env, jclass clazz)
+{
+       return (jobject) thread_get_current_object();
+}
+
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    setPriority0
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, jobject _this, jint oldPriority, jint newPriority)
+{
+#if defined(ENABLE_THREADS)
+       java_lang_Thread jlt(_this);
+       threadobject* t = jlt.get_vm_thread();
+
+       // The threadobject is null when a thread is created in Java. The
+       // priority is set later during startup.
+       if (t == NULL)
+               return;
+
+       threads_set_thread_priority(t->tid, newPriority);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    sleep
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_sleep(JNIEnv *env, jclass clazz, jlong millis)
+{
+#if defined(ENABLE_THREADS)
+       threads_sleep(millis, 0);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    start0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_start0(JNIEnv *env, jobject _this)
+{
+#if defined(ENABLE_THREADS)
+       java_lang_Thread jlt(_this);
+       threads_thread_start(jlt.get_handle());
+#endif
+}
+
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    isAlive
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, jobject _this)
+{
+#if defined(ENABLE_THREADS)
+       java_lang_Thread jlt(_this);
+       threadobject* t = jlt.get_vm_thread();
+
+       if (t == NULL)
+               return 0;
+
+       bool result = threads_thread_is_alive(t);
+
+       return result;
+#else
+       // If threads are disabled, the only thread running is alive.
+       return 1;
+#endif
+}
+
+
+#if 0
+/*
+ * Class:     java/lang/Thread
+ * Method:    activeCount
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Thread_activeCount(JNIEnv *env, jclass clazz)
+{
+}
+
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    interrupt0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_interrupt0(JNIEnv *env, jobject _this)
+{
+}
+
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    internalExit
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_internalExit(JNIEnv *env, jobject _this)
+{
+}
+#endif
+
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    yield
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_yield(JNIEnv *env, jclass clazz)
+{
+#if defined(ENABLE_THREADS)
+       threads_yield();
+#endif
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "currentThread", (char*) "()Ljava/lang/Thread;", (void*) (uintptr_t) &Java_java_lang_Thread_currentThread },
+       { (char*) "setPriority0",  (char*) "(II)V",                (void*) (uintptr_t) &Java_java_lang_Thread_setPriority0  },
+       { (char*) "sleep",         (char*) "(J)V",                 (void*) (uintptr_t) &Java_java_lang_Thread_sleep         },
+       { (char*) "start0",        (char*) "()V",                  (void*) (uintptr_t) &Java_java_lang_Thread_start0        },
+       { (char*) "isAlive",       (char*) "()Z",                  (void*) (uintptr_t) &Java_java_lang_Thread_isAlive       },
+#if 0
+       { (char*) "activeCount",   (char*) "()I",                  (void*) (uintptr_t) &Java_java_lang_Thread_activeCount   },
+       { (char*) "setPriority0",  (char*) "(II)V",                (void*) (uintptr_t) &Java_java_lang_Thread_setPriority0  },
+       { (char*) "interrupt0",    (char*) "()V",                  (void*) (uintptr_t) &Java_java_lang_Thread_interrupt0    },
+       { (char*) "internalExit",  (char*) "()V",                  (void*) (uintptr_t) &Java_java_lang_Thread_internalExit  },
+#endif
+       { (char*) "yield",         (char*) "()V",                  (void*) (uintptr_t) &Java_java_lang_Thread_yield         },
+};
+
+
+/* _Jv_java_lang_Thread_init ***************************************************
+   Register native functions.
+*******************************************************************************/
+void _Jv_java_lang_Thread_init(void)
+{
+       utf* u = utf_new_char("java/lang/Thread");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/cldc1.1/java_lang_Throwable.c b/src/native/vm/cldc1.1/java_lang_Throwable.c
deleted file mode 100644 (file)
index 35885d1..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/* src/native/vm/cldc1.1/java_lang_Throwable.c - java/lang/Throwable
-
-   Copyright (C) 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 <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Throwable.h"
-
-#include "vm/exceptions.h"
-#include "vm/jit/stacktrace.h"
-
-
-/* native methods implemented by this file ************************************/
-static JNINativeMethod methods[] = {
-       { "printStackTrace",  "()V", (void *) (uintptr_t) &Java_java_lang_Throwable_printStackTrace  },
-       { "fillInStackTrace", "()V", (void *) (uintptr_t) &Java_java_lang_Throwable_fillInStackTrace },
-};
-
-
-/* _Jv_java_lang_Throwable_init ************************************************
-   Register native functions.
-*******************************************************************************/
-void _Jv_java_lang_Throwable_init(void)
-{
-       utf *u;
-       u = utf_new_char("java/lang/Throwable");
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/Throwable
- * Method:    printStackTrace
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, java_lang_Throwable *this)
-{
-       java_handle_t *o;
-
-       o = (java_handle_t *) this;
-
-       exceptions_print_exception(o);
-       stacktrace_print_exception(o);
-}
-
-
-/*
- * Class:     java/lang/Throwable
- * Method:    fillInStackTrace
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, java_lang_Throwable *this)
-{
-       java_handle_bytearray_t *ba;
-
-       ba = stacktrace_get_current();
-
-       if (ba == NULL)
-               return;
-
-       LLNI_field_set_ref(this, backtrace, (java_lang_Object *) ba);
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/cldc1.1/java_lang_Throwable.cpp b/src/native/vm/cldc1.1/java_lang_Throwable.cpp
new file mode 100644 (file)
index 0000000..f5d566e
--- /dev/null
@@ -0,0 +1,115 @@
+/* src/native/vm/cldc1.1/java_lang_Throwable.cpp
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Throwable.h"
+#endif
+
+#include "vm/exceptions.hpp"
+#include "vm/javaobjects.hpp"
+
+#include "vm/jit/stacktrace.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/Throwable
+ * Method:    printStackTrace
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, jobject _this)
+{
+       java_lang_Throwable jlt(_this);
+
+       exceptions_print_exception(jlt.get_handle());
+       stacktrace_print_exception(jlt.get_handle());
+}
+
+
+/*
+ * Class:     java/lang/Throwable
+ * Method:    fillInStackTrace
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, jobject _this)
+{
+       java_handle_bytearray_t* ba = stacktrace_get_current();
+
+       if (ba == NULL)
+               return;
+
+       java_lang_Throwable jlt(_this);
+       jlt.set_backtrace(ba);
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { (char*) "printStackTrace",  (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_printStackTrace  },
+       { (char*) "fillInStackTrace", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_fillInStackTrace },
+};
+
+
+/* _Jv_java_lang_Throwable_init ************************************************
+   Register native functions.
+*******************************************************************************/
+void _Jv_java_lang_Throwable_init(void)
+{
+       utf* u = utf_new_char("java/lang/Throwable");
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
index 219f88d5ea8bcba0284f962f6f308d410c3e3319..b232ed826f09fc15bf31e652c46e511403264e41 100644 (file)
@@ -1,4 +1,4 @@
-## src/native/vm/gnu/Makefile.am
+## src/native/vm/gnuclasspath/Makefile.am
 ##
 ## Copyright (C) 1996-2005, 2006, 2008
 ## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
@@ -35,32 +35,32 @@ endif
 
 if ENABLE_ANNOTATIONS
 SUN_REFLECT_SOURCES = \
-       sun_reflect_ConstantPool.c
+       sun_reflect_ConstantPool.cpp
 endif
 
 libnativevmcore_la_SOURCES = \
-       gnu_classpath_VMStackWalker.c \
-       gnu_classpath_VMSystemProperties.c \
-       gnu_java_lang_VMCPStringBuilder.c \
-       gnu_java_lang_management_VMClassLoadingMXBeanImpl.c \
-       gnu_java_lang_management_VMMemoryMXBeanImpl.c \
-       gnu_java_lang_management_VMRuntimeMXBeanImpl.c \
-       gnu_java_lang_management_VMThreadMXBeanImpl.c \
-       java_lang_VMClass.c \
-       java_lang_VMClassLoader.c \
-       java_lang_VMObject.c \
-       java_lang_VMRuntime.c \
-       java_lang_VMString.c \
-       java_lang_VMSystem.c \
-       java_lang_VMThread.c \
-       java_lang_VMThrowable.c \
-       java_lang_management_VMManagementFactory.c \
-       java_lang_reflect_VMConstructor.c \
-       java_lang_reflect_VMField.c \
-       java_lang_reflect_VMMethod.c \
+       gnu_classpath_VMStackWalker.cpp \
+       gnu_classpath_VMSystemProperties.cpp \
+       gnu_java_lang_VMCPStringBuilder.cpp \
+       gnu_java_lang_management_VMClassLoadingMXBeanImpl.cpp \
+       gnu_java_lang_management_VMMemoryMXBeanImpl.cpp \
+       gnu_java_lang_management_VMRuntimeMXBeanImpl.cpp \
+       gnu_java_lang_management_VMThreadMXBeanImpl.cpp \
+       java_lang_VMClass.cpp \
+       java_lang_VMClassLoader.cpp \
+       java_lang_VMObject.cpp \
+       java_lang_VMRuntime.cpp \
+       java_lang_VMString.cpp \
+       java_lang_VMSystem.cpp \
+       java_lang_VMThread.cpp \
+       java_lang_VMThrowable.cpp \
+       java_lang_management_VMManagementFactory.cpp \
+       java_lang_reflect_VMConstructor.cpp \
+       java_lang_reflect_VMField.cpp \
+       java_lang_reflect_VMMethod.cpp \
        java_lang_reflect_VMProxy.c \
-       java_security_VMAccessController.c \
-       java_util_concurrent_atomic_AtomicLong.c \
+       java_security_VMAccessController.cpp \
+       java_util_concurrent_atomic_AtomicLong.cpp \
        $(SUN_REFLECT_SOURCES)
 
 if ENABLE_JVMTI
diff --git a/src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c b/src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c
deleted file mode 100644 (file)
index eca8f53..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/* src/native/vm/gnu/gnu_classpath_VMStackWalker.c
-
-   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 "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
-
-#include "native/include/gnu_classpath_VMStackWalker.h"
-
-#include "vm/global.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getClassContext",         "()[Ljava/lang/Class;",      (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getClassContext         },
-       { "getCallingClass",         "()Ljava/lang/Class;",       (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClass         },
-       { "getCallingClassLoader",   "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClassLoader   },
-       { "firstNonNullClassLoader", "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader },
-};
-
-
-/* _Jv_gnu_classpath_VMStackWalker_init ****************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_classpath_VMStackWalker_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/classpath/VMStackWalker");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/classpath/VMStackWalker
- * Method:    getClassContext
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
-{
-       java_handle_objectarray_t *oa;
-
-       oa = stacktrace_getClassContext();
-
-       return oa;
-}
-
-
-/*
- * Class:     gnu/classpath/VMStackWalker
- * Method:    getCallingClass
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
-{
-       classinfo *c;
-
-       c = stacktrace_get_caller_class(2);
-
-       return (java_lang_Class *) c;
-}
-
-
-/*
- * Class:     gnu/classpath/VMStackWalker
- * Method:    getCallingClassLoader
- * Signature: ()Ljava/lang/ClassLoader;
- */
-JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
-{
-       classinfo     *c;
-       classloader_t *cl;
-
-       c  = stacktrace_get_caller_class(2);
-       cl = class_get_classloader(c);
-
-       return (java_lang_ClassLoader *) cl;
-}
-
-
-/*
- * Class:     gnu/classpath/VMStackWalker
- * Method:    firstNonNullClassLoader
- * Signature: ()Ljava/lang/ClassLoader;
- */
-JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
-{
-       classloader_t *cl;
-
-       cl = stacktrace_first_nonnull_classloader();
-
-       return (java_lang_ClassLoader *) cl;
-}
-
-
-/*
- * 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/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.cpp b/src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.cpp
new file mode 100644 (file)
index 0000000..3331c2f
--- /dev/null
@@ -0,0 +1,148 @@
+/* src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.cpp
+
+   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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/gnu_classpath_VMStackWalker.h"
+#endif
+
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/utf8.h"
+
+#include "vm/jit/stacktrace.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     gnu/classpath/VMStackWalker
+ * Method:    getClassContext
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT jobjectArray JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
+{
+       java_handle_objectarray_t *oa;
+
+       oa = stacktrace_getClassContext();
+
+       return (jobjectArray) oa;
+}
+
+
+/*
+ * Class:     gnu/classpath/VMStackWalker
+ * Method:    getCallingClass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
+{
+       classinfo *c;
+
+       c = stacktrace_get_caller_class(2);
+
+       return (jclass) c;
+}
+
+
+/*
+ * Class:     gnu/classpath/VMStackWalker
+ * Method:    getCallingClassLoader
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
+{
+       classinfo     *c;
+       classloader_t *cl;
+
+       c  = stacktrace_get_caller_class(2);
+       cl = class_get_classloader(c);
+
+       return (jobject) cl;
+}
+
+
+/*
+ * Class:     gnu/classpath/VMStackWalker
+ * Method:    firstNonNullClassLoader
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
+{
+       classloader_t *cl;
+
+       cl = stacktrace_first_nonnull_classloader();
+
+       return (jobject) cl;
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "getClassContext",         (char*) "()[Ljava/lang/Class;",      (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getClassContext         },
+       { (char*) "getCallingClass",         (char*) "()Ljava/lang/Class;",       (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getCallingClass         },
+       { (char*) "getCallingClassLoader",   (char*) "()Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getCallingClassLoader   },
+       { (char*) "firstNonNullClassLoader", (char*) "()Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader },
+};
+
+
+/* _Jv_gnu_classpath_VMStackWalker_init ****************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_classpath_VMStackWalker_init(void)
+{
+       utf* u = utf_new_char("gnu/classpath/VMStackWalker");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.c b/src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.c
deleted file mode 100644 (file)
index 5517c6c..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/* src/native/vm/gnu/gnu_classpath_VMSystemProperties.c
-
-   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 <stdlib.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_util_Properties.h"
-
-#include "native/include/gnu_classpath_VMSystemProperties.h"
-
-#include "vm/exceptions.h"
-#include "vm/properties.h"
-#include "vm/vm.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "preInit",  "(Ljava/util/Properties;)V", (void *) (ptrint) &Java_gnu_classpath_VMSystemProperties_preInit  },
-       { "postInit", "(Ljava/util/Properties;)V", (void *) (ptrint) &Java_gnu_classpath_VMSystemProperties_postInit },
-};
-
-
-/* _Jv_gnu_classpat_VMSystemProperties_init ************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_classpath_VMSystemProperties_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/classpath/VMSystemProperties");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/classpath/VMSystemProperties
- * Method:    preInit
- * Signature: (Ljava/util/Properties;)V
- */
-JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, java_util_Properties *properties)
-{
-       java_handle_t *p;
-
-       p = (java_handle_t *) properties;
-
-       if (p == NULL) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       /* fill the java.util.Properties object */
-
-       properties_system_add_all(p);
-}
-
-
-/*
- * Class:     gnu/classpath/VMSystemProperties
- * Method:    postInit
- * Signature: (Ljava/util/Properties;)V
- */
-JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, java_util_Properties *properties)
-{
-       java_handle_t *p;
-#if defined(ENABLE_JRE_LAYOUT)
-       char *java_home;
-       char *path;
-       s4    len;
-#endif
-
-       p = (java_handle_t *) properties;
-
-       if (p == NULL) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       /* post-set some properties */
-
-#if defined(ENABLE_JRE_LAYOUT)
-       /* XXX when we do it that way, we can't set these properties on
-          commandline */
-
-       java_home = properties_get("java.home");
-
-       properties_system_add(p, "gnu.classpath.home", java_home);
-
-       len =
-               strlen("file://") +
-               strlen(java_home) +
-               strlen("/lib") +
-               strlen("0");
-
-       path = MNEW(char, len);
-
-       strcpy(path, "file://");
-       strcat(path, java_home);
-       strcat(path, "/lib");
-
-       properties_system_add(p, "gnu.classpath.home.url", path);
-
-       MFREE(path, char, len);
-#endif
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.cpp b/src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.cpp
new file mode 100644 (file)
index 0000000..0789c0e
--- /dev/null
@@ -0,0 +1,157 @@
+/* src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.cpp
+
+   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 <stdlib.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/gnu_classpath_VMSystemProperties.h"
+#endif
+
+#include "vm/exceptions.hpp"
+#include "vm/properties.hpp"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     gnu/classpath/VMSystemProperties
+ * Method:    preInit
+ * Signature: (Ljava/util/Properties;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, jobject properties)
+{
+       java_handle_t *p;
+
+       p = (java_handle_t *) properties;
+
+       if (p == NULL) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       // Fill the java.util.Properties object.
+       VM::get_current()->get_properties().fill(p);
+}
+
+
+/*
+ * Class:     gnu/classpath/VMSystemProperties
+ * Method:    postInit
+ * Signature: (Ljava/util/Properties;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, jobject properties)
+{
+       java_handle_t *p;
+#if defined(ENABLE_JRE_LAYOUT)
+       const char *java_home;
+       char *path;
+       s4    len;
+#endif
+
+       p = (java_handle_t *) properties;
+
+       if (p == NULL) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       /* post-set some properties */
+
+#if defined(ENABLE_JRE_LAYOUT)
+       /* XXX when we do it that way, we can't set these properties on
+          commandline */
+
+       java_home = VM::get_current()->get_properties().get("java.home");
+
+       Properties::put(p, "gnu.classpath.home", java_home);
+
+       len =
+               strlen("file://") +
+               strlen(java_home) +
+               strlen("/lib") +
+               strlen("0");
+
+       path = MNEW(char, len);
+
+       strcpy(path, "file://");
+       strcat(path, java_home);
+       strcat(path, "/lib");
+
+       Properties::put(p, "gnu.classpath.home.url", path);
+
+       MFREE(path, char, len);
+#endif
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "preInit",  (char*) "(Ljava/util/Properties;)V", (void*) (uintptr_t) &Java_gnu_classpath_VMSystemProperties_preInit  },
+       { (char*) "postInit", (char*) "(Ljava/util/Properties;)V", (void*) (uintptr_t) &Java_gnu_classpath_VMSystemProperties_postInit },
+};
+
+
+/* _Jv_gnu_classpat_VMSystemProperties_init ************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_classpath_VMSystemProperties_init(void)
+{
+       utf* u = utf_new_char("gnu/classpath/VMSystemProperties");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
index e647e4d940e81a9a47d05b95fcde3f0701693496..9276ebb8feebcbf5fec468178da435e9fc36cf48 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <stdint.h>
 
-#include "native/jni.h"
+#include "native/jni.hpp"
 
 #include "native/include/java_lang_Object.h"
 #include "native/include/gnu_classpath_jdwp_VMFrame.h"
index 54ff53478a647926d4dce1029cc3a94d181551c8..dec60350128f393c74ed6dd420b681ff6c6179b2 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <stdint.h>
 
-#include "native/jni.h"
+#include "native/jni.hpp"
 
 #include "native/include/gnu_classpath_jdwp_VMMethod.h"
 
index 9e06a6b57b737eb72827bb27444d8296e3118aa1..eaf47e6301c3cfea38b5233c8360fbd5f19c5cb4 100644 (file)
@@ -29,7 +29,7 @@
 #include <string.h>
 
 #include "toolbox/logging.h"
-#include "native/jni.h"
+#include "native/jni.hpp"
 #include "native/include/java_lang_Thread.h"
 #include "native/include/java_nio_ByteBuffer.h"
 #include "native/include/java_lang_Class.h"
diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.c b/src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.c
deleted file mode 100644 (file)
index 0511085..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/* src/native/vm/gnu/java_lang_reflect_VMConstructor.c
-
-   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 <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_String.h"
-
-#include "native/include/gnu_java_lang_VMCPStringBuilder.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "toString", "([CII)Ljava/lang/String;", (void *) (intptr_t) &Java_gnu_java_lang_VMCPStringBuilder_toString },
-};
-
-
-/* _Jv_gnu_java_lang_VMCPStringBuilder *****************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_java_lang_VMCPStringBuilder_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/java/lang/VMCPStringBuilder");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/java/lang/VMCPStringBuilder
- * Method:    toString
- * Signature: ([CII)Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_gnu_java_lang_VMCPStringBuilder_toString(JNIEnv *env, jclass clazz, java_handle_chararray_t *value, int32_t startIndex, int32_t count)
-{
-       int32_t          length;
-       java_handle_t    *o;
-       java_lang_String *s;
-
-       /* This is a native version of
-          java.lang.String.<init>([CIIZ)Ljava/lang/String; */
-
-    if (startIndex < 0) {
-/*             exceptions_throw_stringindexoutofboundsexception("offset: " + offset); */
-               exceptions_throw_stringindexoutofboundsexception();
-               return NULL;
-       }
-
-    if (count < 0) {
-/*             exceptions_throw_stringindexoutofboundsexception("count: " + count); */
-               exceptions_throw_stringindexoutofboundsexception();
-               return NULL;
-       }
-
-    /* equivalent to: offset + count < 0 || offset + count > data.length */
-
-       LLNI_CRITICAL_START;
-       length = LLNI_array_size(value);
-       LLNI_CRITICAL_END;
-
-    if (length - startIndex < count) {
-/*             exceptions_throw_stringindexoutofboundsexception("offset + count: " + (offset + count)); */
-               exceptions_throw_stringindexoutofboundsexception();
-               return NULL;
-       }
-
-       o = builtin_new(class_java_lang_String);
-
-       if (o == NULL)
-               return NULL;
-
-       s = (java_lang_String *) o;
-
-       LLNI_field_set_ref(s, value,  value);
-       LLNI_field_set_val(s, count,  count);
-       LLNI_field_set_val(s, offset, startIndex);
-
-       return s;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.cpp b/src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.cpp
new file mode 100644 (file)
index 0000000..c0b3419
--- /dev/null
@@ -0,0 +1,124 @@
+/* src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.cpp
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/gnu_java_lang_VMCPStringBuilder.h"
+#endif
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/javaobjects.hpp"
+
+
+/*
+ * Class:     gnu/java/lang/VMCPStringBuilder
+ * Method:    toString
+ * Signature: ([CII)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_gnu_java_lang_VMCPStringBuilder_toString(JNIEnv *env, jclass clazz, jcharArray value, jint startIndex, jint count)
+{
+       /* This is a native version of
+          java.lang.String.<init>([CIIZ)Ljava/lang/String; */
+
+    if (startIndex < 0) {
+/*             exceptions_throw_stringindexoutofboundsexception("offset: " + offset); */
+               exceptions_throw_stringindexoutofboundsexception();
+               return NULL;
+       }
+
+    if (count < 0) {
+/*             exceptions_throw_stringindexoutofboundsexception("count: " + count); */
+               exceptions_throw_stringindexoutofboundsexception();
+               return NULL;
+       }
+
+    /* equivalent to: offset + count < 0 || offset + count > data.length */
+
+       java_handle_chararray_t* ca = (java_handle_chararray_t*) value;
+
+       LLNI_CRITICAL_START;
+       int32_t length = LLNI_array_size(ca);
+       LLNI_CRITICAL_END;
+
+    if (length - startIndex < count) {
+/*             exceptions_throw_stringindexoutofboundsexception("offset + count: " + (offset + count)); */
+               exceptions_throw_stringindexoutofboundsexception();
+               return NULL;
+       }
+
+       java_handle_t* h = builtin_new(class_java_lang_String);
+
+       if (h == NULL)
+               return NULL;
+
+       java_lang_String s(h, ca, (int32_t) count, (int32_t) startIndex);
+
+       return (jstring) s.get_handle();
+}
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "toString", (char*) "([CII)Ljava/lang/String;", (void*) (uintptr_t) &Java_gnu_java_lang_VMCPStringBuilder_toString },
+};
+
+
+/* _Jv_gnu_java_lang_VMCPStringBuilder *****************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_java_lang_VMCPStringBuilder_init(void)
+{
+       utf* u = utf_new_char("gnu/java/lang/VMCPStringBuilder");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
deleted file mode 100644 (file)
index ce3b6b4..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/* src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
-
-   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
-
-   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 <stdint.h>
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/gnu_java_lang_management_VMClassLoadingMXBeanImpl.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/vm.h"
-
-#include "vmcore/classcache.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getLoadedClassCount",   "()I",  (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount   },
-       { "getUnloadedClassCount", "()J",  (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount },
-       { "isVerbose",             "()Z",  (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose             },
-       { "setVerbose",            "(Z)V", (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose            },
-};
-
-
-/* _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init ******************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/java/lang/management/VMClassLoadingMXBeanImpl");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
- * Method:    getLoadedClassCount
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount(JNIEnv *env, jclass clazz)
-{
-       int32_t count;
-
-       count = classcache_get_loaded_class_count();
-
-       return count;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
- * Method:    getUnloadedClassCount
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
- * Method:    isVerbose
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
-{
-       return _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
- * Method:    setVerbose
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, int32_t verbose)
-{
-       _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose = verbose;
-}
-
-
-/*
- * 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/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.cpp b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.cpp
new file mode 100644 (file)
index 0000000..c706681
--- /dev/null
@@ -0,0 +1,143 @@
+/* src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.cpp
+
+   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 <stdint.h>
+
+#include "mm/gc.hpp"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/gnu_java_lang_management_VMClassLoadingMXBeanImpl.h"
+#endif
+
+#include "toolbox/logging.h"
+
+#include "vm/classcache.hpp"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
+ * Method:    getLoadedClassCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount(JNIEnv *env, jclass clazz)
+{
+       int32_t count;
+
+       count = classcache_get_loaded_class_count();
+
+       return count;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
+ * Method:    getUnloadedClassCount
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
+ * Method:    isVerbose
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
+{
+/*     return _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose; */
+#warning Move to C++
+       log_println("Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose: MOVE TO C++!");
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
+ * Method:    setVerbose
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, jboolean verbose)
+{
+/*     _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose = verbose; */
+#warning Move to C++
+       log_println("Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose: MOVE TO C++!");
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "getLoadedClassCount",   (char*) "()I",  (void*) (uintptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount   },
+       { (char*) "getUnloadedClassCount", (char*) "()J",  (void*) (uintptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount },
+       { (char*) "isVerbose",             (char*) "()Z",  (void*) (uintptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose             },
+       { (char*) "setVerbose",            (char*) "(Z)V", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose            },
+};
+
+
+/* _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init ******************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init(void)
+{
+       utf* u = utf_new_char("gnu/java/lang/management/VMClassLoadingMXBeanImpl");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.c
deleted file mode 100644 (file)
index 4c05838..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/* src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c
-
-   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 <stdint.h>
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_management_MemoryUsage.h"
-
-#include "native/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h"
-
-#include "vm/builtin.h"
-#include "vm/global.h"
-#include "vm/vm.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"               /* XXX only for load_class_bootstrap */
-#include "vmcore/options.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getHeapMemoryUsage",                "()Ljava/lang/management/MemoryUsage;", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage                },
-       { "getNonHeapMemoryUsage",             "()Ljava/lang/management/MemoryUsage;", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage             },
-       { "getObjectPendingFinalizationCount", "()I",                                  (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount },
-       { "isVerbose",                         "()Z",                                  (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose                         },
-       { "setVerbose",                        "(Z)V",                                 (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose                        },
-};
-
-
-/* _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init ************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/java/lang/management/VMMemoryMXBeanImpl");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
- * Method:    getHeapMemoryUsage
- * Signature: ()Ljava/lang/management/MemoryUsage;
- */
-JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz)
-{
-       classinfo                        *class_java_lang_management_MemoryUsage;
-       java_handle_t                    *o;
-       java_lang_management_MemoryUsage *mu;
-       methodinfo                       *m;
-       int64_t                           init;
-       int64_t                           used;
-       int64_t                           commited;
-       int64_t                           maximum;
-
-       /* get the class */
-       /* XXX optimize me! sometime... */
-
-       if (!(class_java_lang_management_MemoryUsage = load_class_bootstrap(utf_new_char("java/lang/management/MemoryUsage"))))
-               return false;
-
-       /* create the object */
-
-       o = builtin_new(class_java_lang_management_MemoryUsage);
-       
-       if (o == NULL)
-               return NULL;
-
-       /* cast the object to a MemoryUsage object (for debugability) */
-
-       mu = (java_lang_management_MemoryUsage *) o;
-
-       /* find initializer */
-
-       m = class_findmethod(class_java_lang_management_MemoryUsage,
-                                                utf_init, utf_new_char("(JJJJ)V"));
-                                                     
-       /* initializer not found */
-
-       if (m == NULL)
-               return NULL;
-
-       /* get values from the VM */
-       /* XXX if we ever support more than one VM, change this */
-
-       init     = opt_heapstartsize;
-       used     = gc_get_total_bytes();
-       commited = gc_get_heap_size();
-       maximum  = gc_get_max_heap_size();
-
-       /* call initializer */
-
-       (void) vm_call_method(m, o, init, used, commited, maximum);
-
-       return mu;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
- * Method:    getNonHeapMemoryUsage
- * Signature: ()Ljava/lang/management/MemoryUsage;
- */
-JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
- * Method:    getObjectPendingFinalizationCount
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
- * Method:    isVerbose
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
-{
-       return _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
- * Method:    setVerbose
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, int32_t verbose)
-{
-       _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose = verbose;
-}
-
-
-/*
- * 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/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.cpp b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.cpp
new file mode 100644 (file)
index 0000000..96a848d
--- /dev/null
@@ -0,0 +1,197 @@
+/* src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.cpp
+
+   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 <stdint.h>
+
+#include "mm/gc.hpp"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h"
+#endif
+
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/loader.hpp"               /* XXX only for load_class_bootstrap */
+#include "vm/options.h"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
+ * Method:    getHeapMemoryUsage
+ * Signature: ()Ljava/lang/management/MemoryUsage;
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz)
+{
+       classinfo     *class_java_lang_management_MemoryUsage;
+       java_handle_t *o;
+       methodinfo    *m;
+       int64_t        init;
+       int64_t        used;
+       int64_t        commited;
+       int64_t        maximum;
+
+       /* get the class */
+       /* XXX optimize me! sometime... */
+
+       if (!(class_java_lang_management_MemoryUsage = load_class_bootstrap(utf_new_char("java/lang/management/MemoryUsage"))))
+               return false;
+
+       /* create the object */
+
+       o = builtin_new(class_java_lang_management_MemoryUsage);
+       
+       if (o == NULL)
+               return NULL;
+
+       /* find initializer */
+
+       m = class_findmethod(class_java_lang_management_MemoryUsage,
+                                                utf_init, utf_new_char("(JJJJ)V"));
+                                                     
+       /* initializer not found */
+
+       if (m == NULL)
+               return NULL;
+
+       /* get values from the VM */
+       /* XXX if we ever support more than one VM, change this */
+
+       init     = opt_heapstartsize;
+       used     = gc_get_total_bytes();
+       commited = gc_get_heap_size();
+       maximum  = gc_get_max_heap_size();
+
+       /* call initializer */
+
+       (void) vm_call_method(m, o, init, used, commited, maximum);
+
+       return (jobject) o;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
+ * Method:    getNonHeapMemoryUsage
+ * Signature: ()Ljava/lang/management/MemoryUsage;
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
+ * Method:    getObjectPendingFinalizationCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
+ * Method:    isVerbose
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
+{
+/*     return _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose; */
+#warning Move to C++
+       log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose: MOVE TO C++!");
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
+ * Method:    setVerbose
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, jboolean verbose)
+{
+/*     _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose = verbose; */
+#warning Move to C++
+       log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose: MOVE TO C++!");
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "getHeapMemoryUsage",                (char*) "()Ljava/lang/management/MemoryUsage;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage                },
+       { (char*) "getNonHeapMemoryUsage",             (char*) "()Ljava/lang/management/MemoryUsage;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage             },
+       { (char*) "getObjectPendingFinalizationCount", (char*) "()I",                                  (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount },
+       { (char*) "isVerbose",                         (char*) "()Z",                                  (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose                         },
+       { (char*) "setVerbose",                        (char*) "(Z)V",                                 (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose                        },
+};
+
+
+/* _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init ************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init(void)
+{
+       utf* u = utf_new_char("gnu/java/lang/management/VMMemoryMXBeanImpl");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
deleted file mode 100644 (file)
index cbd1e96..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/* src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
-
-   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
-
-   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 <stdint.h>
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/gnu_java_lang_management_VMRuntimeMXBeanImpl.h"
-
-#include "vm/builtin.h"
-#include "vm/global.h"
-#include "vm/vm.h"
-
-#include "vmcore/class.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getInputArguments", "()[Ljava/lang/String;", (void *) (intptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments },
-       { "getStartTime",      "()J",                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime      },
-};
-
-
-/* _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init ***********************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/java/lang/management/VMRuntimeMXBeanImpl");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMRuntimeMXBeanImpl
- * Method:    getInputArguments
- * Signature: ()[Ljava/lang/String;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments: IMPLEMENT ME!");
-
-       return builtin_anewarray(0, class_java_lang_String);
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMRuntimeMXBeanImpl
- * Method:    getStartTime
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime(JNIEnv *env, jclass clazz)
-{
-       return _Jv_jvm->starttime;
-}
-
-/*
- * 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/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.cpp b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.cpp
new file mode 100644 (file)
index 0000000..c17382a
--- /dev/null
@@ -0,0 +1,108 @@
+/* src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.cpp
+
+   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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/gnu_java_lang_management_VMRuntimeMXBeanImpl.h"
+#endif
+
+#include "vm/jit/builtin.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     gnu/java/lang/management/VMRuntimeMXBeanImpl
+ * Method:    getInputArguments
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments: IMPLEMENT ME!");
+
+       return builtin_anewarray(0, class_java_lang_String);
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMRuntimeMXBeanImpl
+ * Method:    getStartTime
+ * Signature: ()J
+ */
+JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime(JNIEnv *env, jclass clazz)
+{
+       return VM::get_current()->get_starttime();
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "getInputArguments", (char*) "()[Ljava/lang/String;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments },
+       { (char*) "getStartTime",      (char*) "()J",                   (void*) (uintptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime      },
+};
+
+
+/* _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init ***********************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init(void)
+{
+       utf* u = utf_new_char("gnu/java/lang/management/VMRuntimeMXBeanImpl");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.c
deleted file mode 100644 (file)
index 862ed07..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/* src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c
-
-   Copyright (C) 1996-2005, 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
-
-   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 <stdint.h>
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_lang_management_ThreadInfo.h"
-
-#include "native/include/gnu_java_lang_management_VMThreadMXBeanImpl.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/vm.h"
-
-#include "vmcore/classcache.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "findMonitorDeadlockedThreads", "()[J",                                  (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads },
-       { "getCurrentThreadCpuTime",      "()J",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime      },
-       { "getCurrentThreadUserTime",     "()J",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime     },
-       { "getPeakThreadCount",           "()I",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount           },
-       { "getThreadCpuTime",             "(J)J",                                  (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime             },
-       { "getThreadInfoForId",           "(JI)Ljava/lang/management/ThreadInfo;", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId           },
-       { "getThreadUserTime",            "(J)J",                                  (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime            },
-       { "getTotalStartedThreadCount",   "()J",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount   },
-       { "resetPeakThreadCount",         "()V",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount         },
-};
-
-
-/* _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init ************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/java/lang/management/VMThreadMXBeanImpl");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    findMonitorDeadlockedThreads
- * Signature: ()[J
- */
-JNIEXPORT java_handle_longarray_t* JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getCurrentThreadCpuTime
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getCurrentThreadUserTime
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getPeakThreadCount
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount(JNIEnv *env, jclass clazz)
-{
-       return _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getThreadCpuTime
- * Signature: (J)J
- */
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime(JNIEnv *env, jclass clazz, int64_t id)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getThreadInfoForId
- * Signature: (JI)Ljava/lang/management/ThreadInfo;
- */
-JNIEXPORT java_lang_management_ThreadInfo* JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId(JNIEnv *env, jclass clazz, int64_t id, int32_t maxDepth)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getThreadUserTime
- * Signature: (J)J
- */
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime(JNIEnv *env, jclass clazz, int64_t par1)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getTotalStartedThreadCount
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount(JNIEnv *env, jclass clazz)
-{
-       return _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    resetPeakThreadCount
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount(JNIEnv *env, jclass clazz)
-{
-       _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount =
-               _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount;
-}
-
-
-/*
- * 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/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.cpp b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.cpp
new file mode 100644 (file)
index 0000000..f04140f
--- /dev/null
@@ -0,0 +1,213 @@
+/* src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.cpp
+
+   Copyright (C) 1996-2005, 2006, 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 <stdint.h>
+
+#include "mm/gc.hpp"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/gnu_java_lang_management_VMThreadMXBeanImpl.h"
+#endif
+
+#include "toolbox/logging.h"
+
+#include "vm/classcache.hpp"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    findMonitorDeadlockedThreads
+ * Signature: ()[J
+ */
+JNIEXPORT jlongArray JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getCurrentThreadCpuTime
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getCurrentThreadUserTime
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getPeakThreadCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount(JNIEnv *env, jclass clazz)
+{
+/*     return _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount; */
+#warning Move to C++
+       log_println("Java_gnu_java_lang_management_ThreadMXBean_getPeakThreadCount: MOVE TO C++!");
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getThreadCpuTime
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime(JNIEnv *env, jclass clazz, jlong id)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getThreadInfoForId
+ * Signature: (JI)Ljava/lang/management/ThreadInfo;
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId(JNIEnv *env, jclass clazz, jlong id, jint maxDepth)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getThreadUserTime
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime(JNIEnv *env, jclass clazz, jlong par1)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getTotalStartedThreadCount
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount(JNIEnv *env, jclass clazz)
+{
+/*     return _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount; */
+#warning Move to C++
+       log_println("Java_gnu_java_lang_management_ThreadMXBean_getTotalStartedThreadCount: MOVE TO C++!");
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    resetPeakThreadCount
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount(JNIEnv *env, jclass clazz)
+{
+/*     _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount = */
+/*             _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount; */
+#warning Move to C++
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount: MOVE TO C++!");
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "findMonitorDeadlockedThreads", (char*) "()[J",                                  (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads },
+       { (char*) "getCurrentThreadCpuTime",      (char*) "()J",                                   (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime      },
+       { (char*) "getCurrentThreadUserTime",     (char*) "()J",                                   (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime     },
+       { (char*) "getPeakThreadCount",           (char*) "()I",                                   (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount           },
+       { (char*) "getThreadCpuTime",             (char*) "(J)J",                                  (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime             },
+       { (char*) "getThreadInfoForId",           (char*) "(JI)Ljava/lang/management/ThreadInfo;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId           },
+       { (char*) "getThreadUserTime",            (char*) "(J)J",                                  (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime            },
+       { (char*) "getTotalStartedThreadCount",   (char*) "()J",                                   (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount   },
+       { (char*) "resetPeakThreadCount",         (char*) "()V",                                   (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount         },
+};
+
+
+/* _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init ************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init(void)
+{
+       utf* u = utf_new_char("gnu/java/lang/management/VMThreadMXBeanImpl");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/gnuclasspath/java_lang_VMClass.c b/src/native/vm/gnuclasspath/java_lang_VMClass.c
deleted file mode 100644 (file)
index c61e4cc..0000000
+++ /dev/null
@@ -1,654 +0,0 @@
-/* src/native/vm/gnuclasspath/java_lang_VMClass.c
-
-   Copyright (C) 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 <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_lang_reflect_Constructor.h"
-#include "native/include/java_lang_reflect_Method.h"
-
-#include "native/include/java_lang_VMClass.h"
-
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/class.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-#include "native/include/sun_reflect_ConstantPool.h"
-
-#include "vm/vm.h"
-
-#include "vmcore/annotation.h"
-#endif
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "isInstance",              "(Ljava/lang/Class;Ljava/lang/Object;)Z",                        (void *) (uintptr_t) &Java_java_lang_VMClass_isInstance              },
-       { "isAssignableFrom",        "(Ljava/lang/Class;Ljava/lang/Class;)Z",                         (void *) (uintptr_t) &Java_java_lang_VMClass_isAssignableFrom        },
-       { "isInterface",             "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isInterface             },
-       { "isPrimitive",             "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isPrimitive             },
-       { "getName",                 "(Ljava/lang/Class;)Ljava/lang/String;",                         (void *) (uintptr_t) &Java_java_lang_VMClass_getName                 },
-       { "getSuperclass",           "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getSuperclass           },
-       { "getInterfaces",           "(Ljava/lang/Class;)[Ljava/lang/Class;",                         (void *) (uintptr_t) &Java_java_lang_VMClass_getInterfaces           },
-       { "getComponentType",        "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getComponentType        },
-       { "getModifiers",            "(Ljava/lang/Class;Z)I",                                         (void *) (uintptr_t) &Java_java_lang_VMClass_getModifiers            },
-       { "getDeclaringClass",       "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaringClass       },
-       { "getDeclaredClasses",      "(Ljava/lang/Class;Z)[Ljava/lang/Class;",                        (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredClasses      },
-       { "getDeclaredFields",       "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;",                (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredFields       },
-       { "getDeclaredMethods",      "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;",               (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredMethods      },
-       { "getDeclaredConstructors", "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;",          (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredConstructors },
-       { "getClassLoader",          "(Ljava/lang/Class;)Ljava/lang/ClassLoader;",                    (void *) (uintptr_t) &Java_java_lang_VMClass_getClassLoader          },
-       { "forName",                 "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClass_forName                 },
-       { "isArray",                 "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isArray                 },
-       { "throwException",          "(Ljava/lang/Throwable;)V",                                      (void *) (uintptr_t) &Java_java_lang_VMClass_throwException          },
-#if defined(ENABLE_ANNOTATIONS)
-       { "getDeclaredAnnotations",  "(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;",         (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredAnnotations  },
-#endif
-       { "getEnclosingClass",       "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingClass       },
-       { "getEnclosingConstructor", "(Ljava/lang/Class;)Ljava/lang/reflect/Constructor;",            (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingConstructor },
-       { "getEnclosingMethod",      "(Ljava/lang/Class;)Ljava/lang/reflect/Method;",                 (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingMethod      },
-       { "getClassSignature",       "(Ljava/lang/Class;)Ljava/lang/String;",                         (void *) (uintptr_t) &Java_java_lang_VMClass_getClassSignature       },
-       { "isAnonymousClass",        "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isAnonymousClass        },
-       { "isLocalClass",            "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isLocalClass            },
-       { "isMemberClass",           "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isMemberClass           },
-};
-
-
-/* _Jv_java_lang_VMClass_init **************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMClass_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMClass");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isInstance
- * Signature: (Ljava/lang/Class;Ljava/lang/Object;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Object *o)
-{
-       classinfo     *c;
-       java_handle_t *h;
-
-       c = LLNI_classinfo_unwrap(klass);
-       h = (java_handle_t *) o;
-
-       return class_is_instance(c, h);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isAssignableFrom
- * Signature: (Ljava/lang/Class;Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Class *c)
-{
-       classinfo *to;
-       classinfo *from;
-
-       to   = LLNI_classinfo_unwrap(klass);
-       from = LLNI_classinfo_unwrap(c);
-
-       if (from == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       return class_is_assignable_from(to, from);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isInterface
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       return class_is_interface(c);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isPrimitive
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       return class_is_primitive(c);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getName
- * Signature: (Ljava/lang/Class;)Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getName(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo* c;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       return (java_lang_String*) class_get_classname(c);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getSuperclass
- * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getSuperclass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-       classinfo *super;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       super = class_get_superclass(c);
-
-       return LLNI_classinfo_wrap(super);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getInterfaces
- * Signature: (Ljava/lang/Class;)[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       oa = class_get_interfaces(c);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getComponentType
- * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getComponentType(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-       classinfo *component;
-       
-       c = LLNI_classinfo_unwrap(klass);
-       
-       component = class_get_componenttype(c);
-
-       return LLNI_classinfo_wrap(component);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getModifiers
- * Signature: (Ljava/lang/Class;Z)I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t ignoreInnerClassesAttrib)
-{
-       classinfo *c;
-       int32_t    flags;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       flags = class_get_modifiers(c, ignoreInnerClassesAttrib);
-
-       return flags;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaringClass
- * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-       classinfo *dc;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       dc = class_get_declaringclass(c);
-
-       return LLNI_classinfo_wrap(dc);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredClasses
- * Signature: (Ljava/lang/Class;Z)[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredClasses(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       oa = class_get_declaredclasses(c, publicOnly);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredFields
- * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredFields(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       oa = class_get_declaredfields(c, publicOnly);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredMethods
- * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredMethods(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       oa = class_get_declaredmethods(c, publicOnly);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredConstructors
- * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredConstructors(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       oa = class_get_declaredconstructors(c, publicOnly);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getClassLoader
- * Signature: (Ljava/lang/Class;)Ljava/lang/ClassLoader;
- */
-JNIEXPORT java_lang_ClassLoader* JNICALL Java_java_lang_VMClass_getClassLoader(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo     *c;
-       classloader_t *cl;
-
-       c  = LLNI_classinfo_unwrap(klass);
-       cl = class_get_classloader(c);
-
-       return (java_lang_ClassLoader *) cl;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    forName
- * Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_forName(JNIEnv *env, jclass clazz, java_lang_String *name, int32_t initialize, java_lang_ClassLoader *loader)
-{
-       classloader_t *cl;
-       utf           *ufile;
-       utf           *uname;
-       classinfo     *c;
-       u2            *pos;
-       int32_t        i;
-
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       /* illegal argument */
-
-       if (name == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* create utf string in which '.' is replaced by '/' */
-
-       ufile = javastring_toutf((java_handle_t *) name, true);
-       uname = javastring_toutf((java_handle_t *) name, false);
-
-       /* name must not contain '/' (mauve test) */
-
-       for (i = 0, pos = LLNI_field_direct(name, value)->data + LLNI_field_direct(name, offset); i < LLNI_field_direct(name, count); i++, pos++) {
-               if (*pos == '/') {
-                       exceptions_throw_classnotfoundexception(uname);
-                       return NULL;
-               }
-       }
-
-       /* try to load, ... */
-
-       c = load_class_from_classloader(ufile, cl);
-
-       if (c == NULL)
-           return NULL;
-
-       /* link, ... */
-
-       if (!link_class(c))
-               return NULL;
-       
-       /* ...and initialize it, if required */
-
-       if (initialize)
-               if (!initialize_class(c))
-                       return NULL;
-
-       return LLNI_classinfo_wrap(c);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isArray
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isArray(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       return class_is_array(c);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    throwException
- * Signature: (Ljava/lang/Throwable;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMClass_throwException(JNIEnv *env, jclass clazz, java_lang_Throwable *t)
-{
-       java_handle_t *o;
-
-       o = (java_handle_t *) t;
-
-       exceptions_set_exception(o);
-}
-
-
-#if defined(ENABLE_ANNOTATIONS)
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredAnnotations
- * Signature: (Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredAnnotations(JNIEnv *env, jclass clazz, java_lang_Class* klass)
-{
-       classinfo                *c               = NULL; /* classinfo for the java.lang.Class object 'klass'       */
-       static methodinfo        *m_parseAnnotationsIntoArray   = NULL; /* parser method (cached, therefore static) */
-       utf                      *utf_parseAnnotationsIntoArray = NULL; /* parser method name     */
-       utf                      *utf_desc        = NULL;               /* parser method descriptor (signature)     */
-       java_handle_bytearray_t  *annotations     = NULL;               /* unparsed annotations   */
-       sun_reflect_ConstantPool *constantPool    = NULL;               /* constant pool of klass */
-       java_lang_Object         *constantPoolOop = (java_lang_Object*)klass; /* constantPoolOop field of */
-                                                                             /* sun.reflect.ConstantPool */
-
-       if (klass == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-       
-       c = LLNI_classinfo_unwrap(klass);
-
-       /* get annotations: */
-       annotations = class_get_annotations(c);
-
-       constantPool = 
-               (sun_reflect_ConstantPool*)native_new_and_init(
-                       class_sun_reflect_ConstantPool);
-       
-       if (constantPool == NULL) {
-               /* out of memory */
-               return NULL;
-       }
-
-       LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
-
-       /* only resolve the parser method the first time */
-       if (m_parseAnnotationsIntoArray == NULL) {
-               utf_parseAnnotationsIntoArray = utf_new_char("parseAnnotationsIntoArray");
-               utf_desc = utf_new_char(
-                       "([BLsun/reflect/ConstantPool;Ljava/lang/Class;)"
-                       "[Ljava/lang/annotation/Annotation;");
-
-               if (utf_parseAnnotationsIntoArray == NULL || utf_desc == NULL) {
-                       /* out of memory */
-                       return NULL;
-               }
-
-               m_parseAnnotationsIntoArray = class_resolveclassmethod(
-                       class_sun_reflect_annotation_AnnotationParser,
-                       utf_parseAnnotationsIntoArray,
-                       utf_desc,
-                       class_java_lang_Class,
-                       true);
-
-               if (m_parseAnnotationsIntoArray == NULL) {
-                       /* method not found */
-                       return NULL;
-               }
-       }
-
-       return (java_handle_objectarray_t*)vm_call_method(
-               m_parseAnnotationsIntoArray, NULL,
-               annotations, constantPool, klass);
-}
-#endif
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getEnclosingClass
- * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getEnclosingClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-       classinfo *result;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       result = class_get_enclosingclass(c);
-
-       return LLNI_classinfo_wrap(result);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getEnclosingConstructor
- * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
- */
-JNIEXPORT java_lang_reflect_Constructor* JNICALL Java_java_lang_VMClass_getEnclosingConstructor(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo*     c;
-       java_handle_t* h;
-
-       c = LLNI_classinfo_unwrap(klass);
-       h = class_get_enclosingconstructor(c);
-
-       return (java_lang_reflect_Constructor*) h;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getEnclosingMethod
- * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Method;
- */
-JNIEXPORT java_lang_reflect_Method* JNICALL Java_java_lang_VMClass_getEnclosingMethod(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo*     c;
-       java_handle_t* h;
-
-       c = LLNI_classinfo_unwrap(klass);
-       h = class_get_enclosingmethod(c);
-
-       return (java_lang_reflect_Method*) h;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getClassSignature
- * Signature: (Ljava/lang/Class;)Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getClassSignature(JNIEnv *env, jclass clazz, java_lang_Class* klass)
-{
-       classinfo     *c;
-       utf           *u;
-       java_handle_t *s;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       u = class_get_signature(c);
-
-       if (u == NULL)
-               return NULL;
-
-       s = javastring_new(u);
-
-       /* in error case s is NULL */
-
-       return (java_lang_String *) s;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isAnonymousClass
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       return class_is_anonymousclass(LLNI_classinfo_unwrap(klass));
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isLocalClass
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       return class_is_localclass(LLNI_classinfo_unwrap(klass));
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isMemberClass
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       return class_is_memberclass(LLNI_classinfo_unwrap(klass));
-}
-
-
-/*
- * 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/native/vm/gnuclasspath/java_lang_VMClass.cpp b/src/native/vm/gnuclasspath/java_lang_VMClass.cpp
new file mode 100644 (file)
index 0000000..5141c33
--- /dev/null
@@ -0,0 +1,639 @@
+/* src/native/vm/gnuclasspath/java_lang_VMClass.cpp
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_VMClass.h"
+#endif
+
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/initialize.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/string.hpp"
+
+#if defined(ENABLE_ANNOTATIONS)
+#include "vm/annotation.h"
+#include "vm/vm.hpp"
+#endif
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isInstance
+ * Signature: (Ljava/lang/Class;Ljava/lang/Object;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz, jclass klass, jobject o)
+{
+       classinfo     *c;
+       java_handle_t *h;
+
+       c = LLNI_classinfo_unwrap(klass);
+       h = (java_handle_t *) o;
+
+       return class_is_instance(c, h);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isAssignableFrom
+ * Signature: (Ljava/lang/Class;Ljava/lang/Class;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, jclass klass, jclass c)
+{
+       classinfo *to;
+       classinfo *from;
+
+       to   = LLNI_classinfo_unwrap(klass);
+       from = LLNI_classinfo_unwrap(c);
+
+       if (from == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       return class_is_assignable_from(to, from);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isInterface
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo *c;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       return class_is_interface(c);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isPrimitive
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo *c;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       return class_is_primitive(c);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getName
+ * Signature: (Ljava/lang/Class;)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_java_lang_VMClass_getName(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo* c;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       return (jstring) class_get_classname(c);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getSuperclass
+ * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getSuperclass(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo *c;
+       classinfo *super;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       super = class_get_superclass(c);
+
+       return (jclass) LLNI_classinfo_wrap(super);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getInterfaces
+ * Signature: (Ljava/lang/Class;)[Ljava/lang/Class;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       oa = class_get_interfaces(c);
+
+       return (jobjectArray) oa;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getComponentType
+ * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getComponentType(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo *c;
+       classinfo *component;
+       
+       c = LLNI_classinfo_unwrap(klass);
+       
+       component = class_get_componenttype(c);
+
+       return (jclass) LLNI_classinfo_wrap(component);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getModifiers
+ * Signature: (Ljava/lang/Class;Z)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass clazz, jclass klass, jboolean ignoreInnerClassesAttrib)
+{
+       classinfo *c;
+       int32_t    flags;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       flags = class_get_modifiers(c, ignoreInnerClassesAttrib);
+
+       return flags;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaringClass
+ * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo *c;
+       classinfo *dc;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       dc = class_get_declaringclass(c);
+
+       return (jclass) LLNI_classinfo_wrap(dc);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredClasses
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/Class;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredClasses(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       oa = class_get_declaredclasses(c, publicOnly);
+
+       return (jobjectArray) oa;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredFields
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredFields(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       oa = class_get_declaredfields(c, publicOnly);
+
+       return (jobjectArray) oa;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredMethods
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredMethods(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       oa = class_get_declaredmethods(c, publicOnly);
+
+       return (jobjectArray) oa;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredConstructors
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredConstructors(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       oa = class_get_declaredconstructors(c, publicOnly);
+
+       return (jobjectArray) oa;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getClassLoader
+ * Signature: (Ljava/lang/Class;)Ljava/lang/ClassLoader;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_VMClass_getClassLoader(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo     *c;
+       classloader_t *cl;
+
+       c  = LLNI_classinfo_unwrap(klass);
+       cl = class_get_classloader(c);
+
+       return (jobject) cl;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    forName
+ * Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_VMClass_forName(JNIEnv *env, jclass clazz, jstring name, jboolean initialize, jobject loader)
+{
+       classloader_t *cl;
+       utf           *ufile;
+       utf           *uname;
+       classinfo     *c;
+       char*          pos;
+       int32_t        i;
+
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       /* illegal argument */
+
+       if (name == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* create utf string in which '.' is replaced by '/' */
+
+       ufile = javastring_toutf((java_handle_t *) name, true);
+       uname = javastring_toutf((java_handle_t *) name, false);
+
+       /* name must not contain '/' (mauve test) */
+
+       // FIXME Move this check into a function.
+       for (i = 0, pos = uname->text; i < uname->blength; i++, pos++) {
+               if (*pos == '/') {
+                       exceptions_throw_classnotfoundexception(uname);
+                       return NULL;
+               }
+       }
+
+       /* try to load, ... */
+
+       c = load_class_from_classloader(ufile, cl);
+
+       if (c == NULL)
+           return NULL;
+
+       /* link, ... */
+
+       if (!link_class(c))
+               return NULL;
+       
+       /* ...and initialize it, if required */
+
+       if (initialize)
+               if (!initialize_class(c))
+                       return NULL;
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isArray
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isArray(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo *c;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       return class_is_array(c);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    throwException
+ * Signature: (Ljava/lang/Throwable;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMClass_throwException(JNIEnv *env, jclass clazz, jobject t)
+{
+       java_handle_t *o;
+
+       o = (java_handle_t *) t;
+
+       exceptions_set_exception(o);
+}
+
+
+#if defined(ENABLE_ANNOTATIONS)
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredAnnotations
+ * Signature: (Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredAnnotations(JNIEnv *env, jclass clazz, jclass klass)
+{
+       static methodinfo* m_parseAnnotationsIntoArray = NULL;
+
+       if (klass == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+       
+       classinfo* c = LLNI_classinfo_unwrap(klass);
+
+       /* get annotations: */
+       java_handle_bytearray_t* annotations = class_get_annotations(c);
+
+       java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool);
+       
+       if (h == NULL)
+               return NULL;
+
+       sun_reflect_ConstantPool cp(h);
+       cp.set_constantPoolOop(klass);
+
+       /* only resolve the parser method the first time */
+       if (m_parseAnnotationsIntoArray == NULL) {
+               utf* utf_parseAnnotationsIntoArray = utf_new_char("parseAnnotationsIntoArray");
+               utf* utf_desc = utf_new_char("([BLsun/reflect/ConstantPool;Ljava/lang/Class;)"
+                                                                        "[Ljava/lang/annotation/Annotation;");
+
+               if (utf_parseAnnotationsIntoArray == NULL || utf_desc == NULL) {
+                       /* out of memory */
+                       return NULL;
+               }
+
+               m_parseAnnotationsIntoArray = class_resolveclassmethod(
+                       class_sun_reflect_annotation_AnnotationParser,
+                       utf_parseAnnotationsIntoArray,
+                       utf_desc,
+                       class_java_lang_Class,
+                       true);
+
+               if (m_parseAnnotationsIntoArray == NULL) {
+                       /* method not found */
+                       return NULL;
+               }
+       }
+
+       java_handle_objectarray_t* oa = (java_handle_objectarray_t*) vm_call_method(m_parseAnnotationsIntoArray, NULL, annotations, cp.get_handle(), klass);
+       return (jobjectArray) oa;
+}
+#endif
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getEnclosingClass
+ * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getEnclosingClass(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo *c;
+       classinfo *result;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       result = class_get_enclosingclass(c);
+
+       return (jclass) LLNI_classinfo_wrap(result);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getEnclosingConstructor
+ * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_VMClass_getEnclosingConstructor(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo*     c;
+       java_handle_t* h;
+
+       c = LLNI_classinfo_unwrap(klass);
+       h = class_get_enclosingconstructor(c);
+
+       return (jobject) h;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getEnclosingMethod
+ * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Method;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_VMClass_getEnclosingMethod(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo*     c;
+       java_handle_t* h;
+
+       c = LLNI_classinfo_unwrap(klass);
+       h = class_get_enclosingmethod(c);
+
+       return (jobject) h;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getClassSignature
+ * Signature: (Ljava/lang/Class;)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_java_lang_VMClass_getClassSignature(JNIEnv *env, jclass clazz, jclass klass)
+{
+       classinfo     *c;
+       utf           *u;
+       java_handle_t *s;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       u = class_get_signature(c);
+
+       if (u == NULL)
+               return NULL;
+
+       s = javastring_new(u);
+
+       /* in error case s is NULL */
+
+       return (jstring) s;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isAnonymousClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, jclass klass)
+{
+       return class_is_anonymousclass(LLNI_classinfo_unwrap(klass));
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isLocalClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, jclass klass)
+{
+       return class_is_localclass(LLNI_classinfo_unwrap(klass));
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isMemberClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, jclass klass)
+{
+       return class_is_memberclass(LLNI_classinfo_unwrap(klass));
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "isInstance",              (char*) "(Ljava/lang/Class;Ljava/lang/Object;)Z",                        (void*) (uintptr_t) &Java_java_lang_VMClass_isInstance              },
+       { (char*) "isAssignableFrom",        (char*) "(Ljava/lang/Class;Ljava/lang/Class;)Z",                         (void*) (uintptr_t) &Java_java_lang_VMClass_isAssignableFrom        },
+       { (char*) "isInterface",             (char*) "(Ljava/lang/Class;)Z",                                          (void*) (uintptr_t) &Java_java_lang_VMClass_isInterface             },
+       { (char*) "isPrimitive",             (char*) "(Ljava/lang/Class;)Z",                                          (void*) (uintptr_t) &Java_java_lang_VMClass_isPrimitive             },
+       { (char*) "getName",                 (char*) "(Ljava/lang/Class;)Ljava/lang/String;",                         (void*) (uintptr_t) &Java_java_lang_VMClass_getName                 },
+       { (char*) "getSuperclass",           (char*) "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void*) (uintptr_t) &Java_java_lang_VMClass_getSuperclass           },
+       { (char*) "getInterfaces",           (char*) "(Ljava/lang/Class;)[Ljava/lang/Class;",                         (void*) (uintptr_t) &Java_java_lang_VMClass_getInterfaces           },
+       { (char*) "getComponentType",        (char*) "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void*) (uintptr_t) &Java_java_lang_VMClass_getComponentType        },
+       { (char*) "getModifiers",            (char*) "(Ljava/lang/Class;Z)I",                                         (void*) (uintptr_t) &Java_java_lang_VMClass_getModifiers            },
+       { (char*) "getDeclaringClass",       (char*) "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaringClass       },
+       { (char*) "getDeclaredClasses",      (char*) "(Ljava/lang/Class;Z)[Ljava/lang/Class;",                        (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredClasses      },
+       { (char*) "getDeclaredFields",       (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;",                (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredFields       },
+       { (char*) "getDeclaredMethods",      (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;",               (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredMethods      },
+       { (char*) "getDeclaredConstructors", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;",          (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredConstructors },
+       { (char*) "getClassLoader",          (char*) "(Ljava/lang/Class;)Ljava/lang/ClassLoader;",                    (void*) (uintptr_t) &Java_java_lang_VMClass_getClassLoader          },
+       { (char*) "forName",                 (char*) "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_forName                 },
+       { (char*) "isArray",                 (char*) "(Ljava/lang/Class;)Z",                                          (void*) (uintptr_t) &Java_java_lang_VMClass_isArray                 },
+       { (char*) "throwException",          (char*) "(Ljava/lang/Throwable;)V",                                      (void*) (uintptr_t) &Java_java_lang_VMClass_throwException          },
+#if defined(ENABLE_ANNOTATIONS)
+       { (char*) "getDeclaredAnnotations",  (char*) "(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;",         (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredAnnotations  },
+#endif
+       { (char*) "getEnclosingClass",       (char*) "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingClass       },
+       { (char*) "getEnclosingConstructor", (char*) "(Ljava/lang/Class;)Ljava/lang/reflect/Constructor;",            (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingConstructor },
+       { (char*) "getEnclosingMethod",      (char*) "(Ljava/lang/Class;)Ljava/lang/reflect/Method;",                 (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingMethod      },
+       { (char*) "getClassSignature",       (char*) "(Ljava/lang/Class;)Ljava/lang/String;",                         (void*) (uintptr_t) &Java_java_lang_VMClass_getClassSignature       },
+       { (char*) "isAnonymousClass",        (char*) "(Ljava/lang/Class;)Z",                                          (void*) (uintptr_t) &Java_java_lang_VMClass_isAnonymousClass        },
+       { (char*) "isLocalClass",            (char*) "(Ljava/lang/Class;)Z",                                          (void*) (uintptr_t) &Java_java_lang_VMClass_isLocalClass            },
+       { (char*) "isMemberClass",           (char*) "(Ljava/lang/Class;)Z",                                          (void*) (uintptr_t) &Java_java_lang_VMClass_isMemberClass           },
+};
+
+
+/* _Jv_java_lang_VMClass_init **************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMClass_init(void)
+{
+       utf* u = utf_new_char("java/lang/VMClass");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/gnuclasspath/java_lang_VMClassLoader.c b/src/native/vm/gnuclasspath/java_lang_VMClassLoader.c
deleted file mode 100644 (file)
index 6f6547b..0000000
+++ /dev/null
@@ -1,628 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMClassLoader.c
-
-   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 <stdint.h>
-#include <sys/stat.h>
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_security_ProtectionDomain.h"  /* required by... */
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_util_Vector.h"
-#include "native/include/java_util_HashMap.h"
-#include "native/include/java_util_Map.h"
-#include "native/include/java_lang_Boolean.h"
-
-#include "native/include/java_lang_VMClassLoader.h"
-
-#include "toolbox/logging.h"
-#include "toolbox/list.h"
-
-#if defined(ENABLE_ASSERTION)
-#include "vm/assertion.h"
-#endif
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/primitive.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/asmpart.h"
-
-#include "vmcore/class.h"
-#include "vmcore/classcache.h"
-#include "vmcore/linker.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-#include "vmcore/suck.h"
-#include "vmcore/zip.h"
-
-#if defined(ENABLE_JVMTI)
-#include "native/jvmti/cacaodbg.h"
-#endif
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "defineClass",                "(Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defineClass                },
-       { "getPrimitiveClass",          "(C)Ljava/lang/Class;",                                                                             (void *) (uintptr_t) &Java_java_lang_VMClassLoader_getPrimitiveClass          },
-       { "resolveClass",               "(Ljava/lang/Class;)V",                                                                             (void *) (uintptr_t) &Java_java_lang_VMClassLoader_resolveClass               },
-       { "loadClass",                  "(Ljava/lang/String;Z)Ljava/lang/Class;",                                                           (void *) (uintptr_t) &Java_java_lang_VMClassLoader_loadClass                  },
-       { "nativeGetResources",         "(Ljava/lang/String;)Ljava/util/Vector;",                                                           (void *) (uintptr_t) &Java_java_lang_VMClassLoader_nativeGetResources         },
-       { "defaultAssertionStatus",     "()Z",                                                                                              (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defaultAssertionStatus     },
-       { "defaultUserAssertionStatus", "()Z",                                                                                              (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defaultUserAssertionStatus },
-       { "packageAssertionStatus0",    "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;",                                          (void *) (uintptr_t) &Java_java_lang_VMClassLoader_packageAssertionStatus0    },
-       { "classAssertionStatus0",      "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;",                                          (void *) (uintptr_t) &Java_java_lang_VMClassLoader_classAssertionStatus0      },
-       { "findLoadedClass",            "(Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;",                                     (void *) (uintptr_t) &Java_java_lang_VMClassLoader_findLoadedClass            },
-};
-
-
-/* _Jv_java_lang_VMClassLoader_init ********************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMClassLoader_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMClassLoader");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    defineClass
- * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_defineClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *cl, java_lang_String *name, java_handle_bytearray_t *data, int32_t offset, int32_t len, java_security_ProtectionDomain *pd)
-{
-       utf             *utfname;
-       classinfo       *c;
-       classloader_t   *loader;
-       java_lang_Class *o;
-
-#if defined(ENABLE_JVMTI)
-       jint new_class_data_len = 0;
-       unsigned char* new_class_data = NULL;
-#endif
-
-       /* check if data was passed */
-
-       if (data == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* check the indexes passed */
-
-       if ((offset < 0) || (len < 0) || ((offset + len) > LLNI_array_size(data))) {
-               exceptions_throw_arrayindexoutofboundsexception();
-               return NULL;
-       }
-
-       /* add classloader to classloader hashtable */
-
-       loader = loader_hashtable_classloader_add((java_handle_t *) cl);
-
-       if (name != NULL) {
-               /* convert '.' to '/' in java string */
-
-               utfname = javastring_toutf((java_handle_t *) name, true);
-       } 
-       else {
-               utfname = NULL;
-       }
-
-#if defined(ENABLE_JVMTI)
-       /* XXX again this will not work because of the indirection cell for classloaders */
-       assert(0);
-       /* fire Class File Load Hook JVMTI event */
-
-       if (jvmti)
-               jvmti_ClassFileLoadHook(utfname, len, (unsigned char *) data->data, 
-                                                               loader, (java_handle_t *) pd, 
-                                                               &new_class_data_len, &new_class_data);
-#endif
-
-       /* define the class */
-
-#if defined(ENABLE_JVMTI)
-       /* check if the JVMTI wants to modify the class */
-
-       if (new_class_data == NULL)
-               c = class_define(utfname, loader, new_class_data_len, new_class_data, pd); 
-       else
-#endif
-               c = class_define(utfname, loader, len, (uint8_t *) &LLNI_array_direct(data, offset), (java_handle_t *) pd);
-
-       if (c == NULL)
-               return NULL;
-
-       /* for convenience */
-
-       o = LLNI_classinfo_wrap(c);
-
-       /* set ProtectionDomain */
-
-       LLNI_field_set_ref(o, pd, pd);
-
-       return o;
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    getPrimitiveClass
- * Signature: (C)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_getPrimitiveClass(JNIEnv *env, jclass clazz, int32_t type)
-{
-       classinfo *c;
-
-       c = primitive_class_get_by_char(type);
-
-       if (c == NULL) {
-               exceptions_throw_classnotfoundexception(utf_null);
-               return NULL;
-       }
-
-       return LLNI_classinfo_wrap(c);
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    resolveClass
- * Signature: (Ljava/lang/Class;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMClassLoader_resolveClass(JNIEnv *env, jclass clazz, java_lang_Class *c)
-{
-       classinfo *ci;
-
-       ci = LLNI_classinfo_unwrap(c);
-
-       if (!ci) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       /* link the class */
-
-       if (!(ci->state & CLASS_LINKED))
-               (void) link_class(ci);
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    loadClass
- * Signature: (Ljava/lang/String;Z)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv *env, jclass clazz, java_lang_String *name, int32_t resolve)
-{
-       classinfo *c;
-       utf       *u;
-
-       if (name == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* create utf string in which '.' is replaced by '/' */
-
-       u = javastring_toutf((java_handle_t *) name, true);
-
-       /* load class */
-
-       c = load_class_bootstrap(u);
-
-       if (c == NULL)
-               return NULL;
-
-       /* resolve class -- if requested */
-
-/*     if (resolve) */
-               if (!link_class(c))
-                       return NULL;
-
-       return LLNI_classinfo_wrap(c);
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    nativeGetResources
- * Signature: (Ljava/lang/String;)Ljava/util/Vector;
- */
-JNIEXPORT java_util_Vector* JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv *env, jclass clazz, java_lang_String *name)
-{
-       java_handle_t        *o;         /* vector being created     */
-       methodinfo           *m;         /* "add" method of vector   */
-       java_handle_t        *path;      /* path to be added         */
-       list_classpath_entry *lce;       /* classpath entry          */
-       utf                  *utfname;   /* utf to look for          */
-       char                 *buffer;    /* char buffer              */
-       char                 *namestart; /* start of name to use     */
-       char                 *tmppath;   /* temporary buffer         */
-       int32_t               namelen;   /* length of name to use    */
-       int32_t               searchlen; /* length of name to search */
-       int32_t               bufsize;   /* size of buffer allocated */
-       int32_t               pathlen;   /* name of path to assemble */
-       struct stat           buf;       /* buffer for stat          */
-       jboolean              ret;       /* return value of "add"    */
-
-       /* get the resource name as utf string */
-
-       utfname = javastring_toutf((java_handle_t *) name, false);
-
-       if (utfname == NULL)
-               return NULL;
-
-       /* copy it to a char buffer */
-
-       namelen   = utf_bytes(utfname);
-       searchlen = namelen;
-       bufsize   = namelen + strlen("0");
-       buffer    = MNEW(char, bufsize);
-
-       utf_copy(buffer, utfname);
-       namestart = buffer;
-
-       /* skip leading '/' */
-
-       if (namestart[0] == '/') {
-               namestart++;
-               namelen--;
-               searchlen--;
-       }
-
-       /* remove trailing `.class' */
-
-       if (namelen >= 6 && strcmp(namestart + (namelen - 6), ".class") == 0) {
-               searchlen -= 6;
-       }
-
-       /* create a new needle to look for, if necessary */
-
-       if (searchlen != bufsize-1) {
-               utfname = utf_new(namestart, searchlen);
-               if (utfname == NULL)
-                       goto return_NULL;
-       }
-                       
-       /* new Vector() */
-
-       o = native_new_and_init(class_java_util_Vector);
-
-       if (o == NULL)
-               goto return_NULL;
-
-       /* get Vector.add() method */
-
-       m = class_resolveclassmethod(class_java_util_Vector,
-                                                                utf_add,
-                                                                utf_new_char("(Ljava/lang/Object;)Z"),
-                                                                NULL,
-                                                                true);
-
-       if (m == NULL)
-               goto return_NULL;
-
-       /* iterate over all classpath entries */
-
-       for (lce = list_first(list_classpath_entries); lce != NULL;
-                lce = list_next(list_classpath_entries, lce)) {
-               /* clear path pointer */
-               path = NULL;
-
-#if defined(ENABLE_ZLIB)
-               if (lce->type == CLASSPATH_ARCHIVE) {
-
-                       if (zip_find(lce, utfname)) {
-                               pathlen = strlen("jar:file://") + lce->pathlen + strlen("!/") +
-                                       namelen + strlen("0");
-
-                               tmppath = MNEW(char, pathlen);
-
-                               sprintf(tmppath, "jar:file://%s!/%s", lce->path, namestart);
-                               path = javastring_new_from_utf_string(tmppath),
-
-                               MFREE(tmppath, char, pathlen);
-                       }
-
-               } else {
-#endif /* defined(ENABLE_ZLIB) */
-                       pathlen = strlen("file://") + lce->pathlen + namelen + strlen("0");
-
-                       tmppath = MNEW(char, pathlen);
-
-                       sprintf(tmppath, "file://%s%s", lce->path, namestart);
-
-                       /* Does this file exist? */
-
-                       if (stat(tmppath + strlen("file://") - 1, &buf) == 0)
-                               if (!S_ISDIR(buf.st_mode))
-                                       path = javastring_new_from_utf_string(tmppath);
-
-                       MFREE(tmppath, char, pathlen);
-#if defined(ENABLE_ZLIB)
-               }
-#endif
-
-               /* if a resource was found, add it to the vector */
-
-               if (path != NULL) {
-                       ret = vm_call_method_int(m, o, path);
-
-                       if (exceptions_get_exception() != NULL)
-                               goto return_NULL;
-
-                       if (ret == 0) 
-                               goto return_NULL;
-               }
-       }
-
-       MFREE(buffer, char, bufsize);
-
-       return (java_util_Vector *) o;
-
-return_NULL:
-       MFREE(buffer, char, bufsize);
-
-       return NULL;
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    defaultAssertionStatus
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClassLoader_defaultAssertionStatus(JNIEnv *env, jclass clazz)
-{
-#if defined(ENABLE_ASSERTION)
-       return assertion_system_enabled;
-#else
-       return false;
-#endif
-}
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    userAssertionStatus
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClassLoader_defaultUserAssertionStatus(JNIEnv *env, jclass clazz)
-{
-#if defined(ENABLE_ASSERTION)
-       return assertion_user_enabled;
-#else
-       return false;
-#endif
-}
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    packageAssertionStatus
- * Signature: ()Ljava_util_Map;
- */
-JNIEXPORT java_util_Map* JNICALL Java_java_lang_VMClassLoader_packageAssertionStatus0(JNIEnv *env, jclass clazz, java_lang_Boolean *jtrue, java_lang_Boolean *jfalse)
-{
-       java_handle_t     *hm;
-#if defined(ENABLE_ASSERTION)
-       java_handle_t     *js;
-       methodinfo        *m;
-       assertion_name_t  *item;
-#endif
-
-       /* new HashMap() */
-
-       hm = native_new_and_init(class_java_util_HashMap);
-       if (hm == NULL) {
-               return NULL;
-       }
-
-#if defined(ENABLE_ASSERTION)
-       /* if nothing todo, return now */
-
-       if (assertion_package_count == 0) {
-               return (java_util_Map *) hm;
-       }
-
-       /* get HashMap.put method */
-
-       m = class_resolveclassmethod(class_java_util_HashMap,
-                                 utf_put,
-                                 utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
-                                 NULL,
-                                 true);
-
-       if (m == NULL) {
-               return NULL;
-       }
-
-       item = (assertion_name_t *)list_first(list_assertion_names);
-
-       while (item != NULL) {
-               if (item->package == false) {
-                       item = (assertion_name_t *)list_next(list_assertion_names, item);
-                       continue;
-               }
-               
-               if (strcmp(item->name, "") == 0) {
-                       /* unnamed package wanted */
-                       js = NULL;
-               }
-               else {
-                       js = javastring_new_from_ascii(item->name);
-                       if (js == NULL) {
-                               return NULL;
-                       }
-               }
-
-               if (item->enabled == true) {
-                       vm_call_method(m, hm, js, jtrue);
-               }
-               else {
-                       vm_call_method(m, hm, js, jfalse);
-               }
-
-               item = (assertion_name_t *)list_next(list_assertion_names, item);
-       }
-#endif
-
-       return (java_util_Map *) hm;
-}
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    classAssertionStatus
- * Signature: ()Ljava_util_Map;
- */
-JNIEXPORT java_util_Map* JNICALL Java_java_lang_VMClassLoader_classAssertionStatus0(JNIEnv *env, jclass clazz, java_lang_Boolean *jtrue, java_lang_Boolean *jfalse)
-{
-       java_handle_t     *hm;
-#if defined(ENABLE_ASSERTION)
-       java_handle_t     *js;
-       methodinfo        *m;
-       assertion_name_t  *item;
-#endif
-
-       /* new HashMap() */
-
-       hm = native_new_and_init(class_java_util_HashMap);
-       if (hm == NULL) {
-               return NULL;
-       }
-
-#if defined(ENABLE_ASSERTION)
-       /* if nothing todo, return now */
-
-       if (assertion_class_count == 0) {
-               return (java_util_Map *) hm;
-       }
-
-       /* get HashMap.put method */
-
-       m = class_resolveclassmethod(class_java_util_HashMap,
-                                 utf_put,
-                                 utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
-                                 NULL,
-                                 true);
-
-       if (m == NULL) {
-               return NULL;
-       }
-
-       item = (assertion_name_t *)list_first(list_assertion_names);
-
-       while (item != NULL) {
-               if (item->package == true) {
-                       item = (assertion_name_t *)list_next(list_assertion_names, item);
-                       continue;
-               }
-
-               js = javastring_new_from_ascii(item->name);
-               if (js == NULL) {
-                       return NULL;
-               }
-
-               if (item->enabled == true) {
-                       vm_call_method(m, hm, js, jtrue);
-               }
-               else {
-                       vm_call_method(m, hm, js, jfalse);
-               }
-
-               item = (assertion_name_t *)list_next(list_assertion_names, item);
-       }
-#endif
-
-       return (java_util_Map *) hm;
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    findLoadedClass
- * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_findLoadedClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *loader, java_lang_String *name)
-{
-       classloader_t *cl;
-       classinfo     *c;
-       utf           *u;
-
-       /* XXX is it correct to add the classloader to the hashtable here? */
-
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       /* replace `.' by `/', this is required by the classcache */
-
-       u = javastring_toutf((java_handle_t *) name, true);
-
-       /* lookup for defining classloader */
-
-       c = classcache_lookup_defined(cl, u);
-
-       /* if not found, lookup for initiating classloader */
-
-       if (c == NULL)
-               c = classcache_lookup(cl, u);
-
-       return LLNI_classinfo_wrap(c);
-}
-
-
-/*
- * 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/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp b/src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp
new file mode 100644 (file)
index 0000000..7e2c0b8
--- /dev/null
@@ -0,0 +1,621 @@
+/* src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp
+
+   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 <stdint.h>
+#include <sys/stat.h>
+
+#include "mm/memory.h"
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_VMClassLoader.h"
+#endif
+
+#include "toolbox/logging.h"
+#include "toolbox/list.hpp"
+
+#if defined(ENABLE_ASSERTION)
+#include "vm/assertion.hpp"
+#endif
+
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/classcache.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/initialize.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/linker.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/statistics.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+#include "vm/zip.hpp"
+
+#include "vm/jit/asmpart.h"
+
+#if defined(ENABLE_JVMTI)
+#include "native/jvmti/cacaodbg.h"
+#endif
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    defineClass
+ * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_defineClass(JNIEnv *env, jclass clazz, jobject cl, jstring name, jbyteArray data, jint offset, jint len, jobject pd)
+{
+       utf             *utfname;
+       classinfo       *c;
+       classloader_t   *loader;
+       java_handle_bytearray_t* ba;
+       uint8_t*                 stream;
+
+#if defined(ENABLE_JVMTI)
+       jint new_class_data_len = 0;
+       unsigned char* new_class_data = NULL;
+#endif
+
+       /* check if data was passed */
+
+       if (data == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* check the indexes passed */
+
+       if ((offset < 0) || (len < 0) || ((offset + len) > LLNI_array_size(data))) {
+               exceptions_throw_arrayindexoutofboundsexception();
+               return NULL;
+       }
+
+       /* add classloader to classloader hashtable */
+
+       loader = loader_hashtable_classloader_add((java_handle_t *) cl);
+
+       if (name != NULL) {
+               /* convert '.' to '/' in java string */
+
+               utfname = javastring_toutf((java_handle_t *) name, true);
+       } 
+       else {
+               utfname = NULL;
+       }
+
+#if defined(ENABLE_JVMTI)
+       /* XXX again this will not work because of the indirection cell for classloaders */
+       assert(0);
+       /* fire Class File Load Hook JVMTI event */
+
+       if (jvmti)
+               jvmti_ClassFileLoadHook(utfname, len, (unsigned char *) data->data, 
+                                                               loader, (java_handle_t *) pd, 
+                                                               &new_class_data_len, &new_class_data);
+#endif
+
+       /* define the class */
+
+#if defined(ENABLE_JVMTI)
+       /* check if the JVMTI wants to modify the class */
+
+       if (new_class_data == NULL)
+               c = class_define(utfname, loader, new_class_data_len, new_class_data, pd); 
+       else
+#endif
+       {
+               ba = (java_handle_bytearray_t*) data;
+               stream = (uint8_t *) &LLNI_array_direct(ba, offset);
+               c = class_define(utfname, loader, len, stream, (java_handle_t *) pd);
+       }
+
+       if (c == NULL)
+               return NULL;
+
+       // REMOVEME
+       java_handle_t* h = LLNI_classinfo_wrap(c);
+
+       // Set ProtectionDomain.
+       java_lang_Class jlc(h);
+       jlc.set_pd(pd);
+
+       return (jclass) jlc.get_handle();
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    getPrimitiveClass
+ * Signature: (C)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_getPrimitiveClass(JNIEnv *env, jclass clazz, jchar type)
+{
+       classinfo *c;
+
+       c = Primitive::get_class_by_char(type);
+
+       if (c == NULL) {
+               exceptions_throw_classnotfoundexception(utf_null);
+               return NULL;
+       }
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    resolveClass
+ * Signature: (Ljava/lang/Class;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMClassLoader_resolveClass(JNIEnv *env, jclass clazz, jclass c)
+{
+       classinfo *ci;
+
+       ci = LLNI_classinfo_unwrap(c);
+
+       if (!ci) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       /* link the class */
+
+       if (!(ci->state & CLASS_LINKED))
+               (void) link_class(ci);
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    loadClass
+ * Signature: (Ljava/lang/String;Z)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv *env, jclass clazz, jstring name, jboolean resolve)
+{
+       classinfo *c;
+       utf       *u;
+
+       if (name == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* create utf string in which '.' is replaced by '/' */
+
+       u = javastring_toutf((java_handle_t *) name, true);
+
+       /* load class */
+
+       c = load_class_bootstrap(u);
+
+       if (c == NULL)
+               return NULL;
+
+       /* resolve class -- if requested */
+
+/*     if (resolve) */
+               if (!link_class(c))
+                       return NULL;
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    nativeGetResources
+ * Signature: (Ljava/lang/String;)Ljava/util/Vector;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv *env, jclass clazz, jstring name)
+{
+       java_handle_t        *o;         /* vector being created     */
+       methodinfo           *m;         /* "add" method of vector   */
+       java_handle_t        *path;      /* path to be added         */
+       utf                  *utfname;   /* utf to look for          */
+       char                 *buffer;    /* char buffer              */
+       char                 *namestart; /* start of name to use     */
+       char                 *tmppath;   /* temporary buffer         */
+       int32_t               namelen;   /* length of name to use    */
+       int32_t               searchlen; /* length of name to search */
+       int32_t               bufsize;   /* size of buffer allocated */
+       int32_t               pathlen;   /* name of path to assemble */
+       struct stat           buf;       /* buffer for stat          */
+       jboolean              ret;       /* return value of "add"    */
+
+       /* get the resource name as utf string */
+
+       utfname = javastring_toutf((java_handle_t *) name, false);
+
+       if (utfname == NULL)
+               return NULL;
+
+       /* copy it to a char buffer */
+
+       namelen   = utf_bytes(utfname);
+       searchlen = namelen;
+       bufsize   = namelen + strlen("0");
+       buffer    = MNEW(char, bufsize);
+
+       utf_copy(buffer, utfname);
+       namestart = buffer;
+
+       /* skip leading '/' */
+
+       if (namestart[0] == '/') {
+               namestart++;
+               namelen--;
+               searchlen--;
+       }
+
+       /* remove trailing `.class' */
+
+       if (namelen >= 6 && strcmp(namestart + (namelen - 6), ".class") == 0) {
+               searchlen -= 6;
+       }
+
+       /* create a new needle to look for, if necessary */
+
+       if (searchlen != bufsize-1) {
+               utfname = utf_new(namestart, searchlen);
+               if (utfname == NULL)
+                       goto return_NULL;
+       }
+                       
+       /* new Vector() */
+
+       o = native_new_and_init(class_java_util_Vector);
+
+       if (o == NULL)
+               goto return_NULL;
+
+       /* get Vector.add() method */
+
+       m = class_resolveclassmethod(class_java_util_Vector,
+                                                                utf_add,
+                                                                utf_new_char("(Ljava/lang/Object;)Z"),
+                                                                NULL,
+                                                                true);
+
+       if (m == NULL)
+               goto return_NULL;
+
+       /* iterate over all classpath entries */
+
+       for (List<list_classpath_entry*>::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end(); it++) {
+               list_classpath_entry* lce = *it;
+
+               /* clear path pointer */
+               path = NULL;
+
+#if defined(ENABLE_ZLIB)
+               if (lce->type == CLASSPATH_ARCHIVE) {
+
+                       if (zip_find(lce, utfname)) {
+                               pathlen = strlen("jar:file://") + lce->pathlen + strlen("!/") +
+                                       namelen + strlen("0");
+
+                               tmppath = MNEW(char, pathlen);
+
+                               sprintf(tmppath, "jar:file://%s!/%s", lce->path, namestart);
+                               path = javastring_new_from_utf_string(tmppath),
+
+                               MFREE(tmppath, char, pathlen);
+                       }
+
+               } else {
+#endif /* defined(ENABLE_ZLIB) */
+                       pathlen = strlen("file://") + lce->pathlen + namelen + strlen("0");
+
+                       tmppath = MNEW(char, pathlen);
+
+                       sprintf(tmppath, "file://%s%s", lce->path, namestart);
+
+                       /* Does this file exist? */
+
+                       if (stat(tmppath + strlen("file://") - 1, &buf) == 0)
+                               if (!S_ISDIR(buf.st_mode))
+                                       path = javastring_new_from_utf_string(tmppath);
+
+                       MFREE(tmppath, char, pathlen);
+#if defined(ENABLE_ZLIB)
+               }
+#endif
+
+               /* if a resource was found, add it to the vector */
+
+               if (path != NULL) {
+                       ret = vm_call_method_int(m, o, path);
+
+                       if (exceptions_get_exception() != NULL)
+                               goto return_NULL;
+
+                       if (ret == 0) 
+                               goto return_NULL;
+               }
+       }
+
+       MFREE(buffer, char, bufsize);
+
+       return (jobject) o;
+
+return_NULL:
+       MFREE(buffer, char, bufsize);
+
+       return NULL;
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    defaultAssertionStatus
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClassLoader_defaultAssertionStatus(JNIEnv *env, jclass clazz)
+{
+#if defined(ENABLE_ASSERTION)
+       return assertion_system_enabled;
+#else
+       return false;
+#endif
+}
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    userAssertionStatus
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClassLoader_defaultUserAssertionStatus(JNIEnv *env, jclass clazz)
+{
+#if defined(ENABLE_ASSERTION)
+       return assertion_user_enabled;
+#else
+       return false;
+#endif
+}
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    packageAssertionStatus
+ * Signature: (Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_VMClassLoader_packageAssertionStatus0(JNIEnv *env, jclass clazz, jobject jtrue, jobject jfalse)
+{
+       java_handle_t     *hm;
+#if defined(ENABLE_ASSERTION)
+       java_handle_t     *js;
+       methodinfo        *m;
+#endif
+
+       /* new HashMap() */
+
+       hm = native_new_and_init(class_java_util_HashMap);
+       if (hm == NULL) {
+               return NULL;
+       }
+
+#if defined(ENABLE_ASSERTION)
+       /* if nothing todo, return now */
+
+       if (assertion_package_count == 0) {
+               return (jobject) hm;
+       }
+
+       /* get HashMap.put method */
+
+       m = class_resolveclassmethod(class_java_util_HashMap,
+                                 utf_put,
+                                 utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
+                                 NULL,
+                                 true);
+
+       if (m == NULL) {
+               return NULL;
+       }
+
+       for (List<assertion_name_t*>::iterator it = list_assertion_names->begin(); it != list_assertion_names->end(); it++) {
+               assertion_name_t* item = *it;
+
+               if (item->package == false)
+                       continue;
+               
+               if (strcmp(item->name, "") == 0) {
+                       /* unnamed package wanted */
+                       js = NULL;
+               }
+               else {
+                       js = javastring_new_from_ascii(item->name);
+                       if (js == NULL) {
+                               return NULL;
+                       }
+               }
+
+               if (item->enabled == true) {
+                       vm_call_method(m, hm, js, jtrue);
+               }
+               else {
+                       vm_call_method(m, hm, js, jfalse);
+               }
+       }
+#endif
+
+       return (jobject) hm;
+}
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    classAssertionStatus
+ * Signature: (Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_VMClassLoader_classAssertionStatus0(JNIEnv *env, jclass clazz, jobject jtrue, jobject jfalse)
+{
+       java_handle_t     *hm;
+#if defined(ENABLE_ASSERTION)
+       java_handle_t     *js;
+       methodinfo        *m;
+#endif
+
+       /* new HashMap() */
+
+       hm = native_new_and_init(class_java_util_HashMap);
+       if (hm == NULL) {
+               return NULL;
+       }
+
+#if defined(ENABLE_ASSERTION)
+       /* if nothing todo, return now */
+
+       if (assertion_class_count == 0) {
+               return (jobject) hm;
+       }
+
+       /* get HashMap.put method */
+
+       m = class_resolveclassmethod(class_java_util_HashMap,
+                                 utf_put,
+                                 utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
+                                 NULL,
+                                 true);
+
+       if (m == NULL) {
+               return NULL;
+       }
+
+       for (List<assertion_name_t*>::iterator it = list_assertion_names->begin(); it != list_assertion_names->end(); it++) {
+               assertion_name_t* item = *it;
+
+               if (item->package == true)
+                       continue;
+
+               js = javastring_new_from_ascii(item->name);
+               if (js == NULL) {
+                       return NULL;
+               }
+
+               if (item->enabled == true) {
+                       vm_call_method(m, hm, js, jtrue);
+               }
+               else {
+                       vm_call_method(m, hm, js, jfalse);
+               }
+       }
+#endif
+
+       return (jobject) hm;
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    findLoadedClass
+ * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_findLoadedClass(JNIEnv *env, jclass clazz, jobject loader, jstring name)
+{
+       classloader_t *cl;
+       classinfo     *c;
+       utf           *u;
+
+       /* XXX is it correct to add the classloader to the hashtable here? */
+
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       /* replace `.' by `/', this is required by the classcache */
+
+       u = javastring_toutf((java_handle_t *) name, true);
+
+       /* lookup for defining classloader */
+
+       c = classcache_lookup_defined(cl, u);
+
+       /* if not found, lookup for initiating classloader */
+
+       if (c == NULL)
+               c = classcache_lookup(cl, u);
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "defineClass",                (char*) "(Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClassLoader_defineClass                },
+       { (char*) "getPrimitiveClass",          (char*) "(C)Ljava/lang/Class;",                                                                             (void*) (uintptr_t) &Java_java_lang_VMClassLoader_getPrimitiveClass          },
+       { (char*) "resolveClass",               (char*) "(Ljava/lang/Class;)V",                                                                             (void*) (uintptr_t) &Java_java_lang_VMClassLoader_resolveClass               },
+       { (char*) "loadClass",                  (char*) "(Ljava/lang/String;Z)Ljava/lang/Class;",                                                           (void*) (uintptr_t) &Java_java_lang_VMClassLoader_loadClass                  },
+       { (char*) "nativeGetResources",         (char*) "(Ljava/lang/String;)Ljava/util/Vector;",                                                           (void*) (uintptr_t) &Java_java_lang_VMClassLoader_nativeGetResources         },
+       { (char*) "defaultAssertionStatus",     (char*) "()Z",                                                                                              (void*) (uintptr_t) &Java_java_lang_VMClassLoader_defaultAssertionStatus     },
+       { (char*) "defaultUserAssertionStatus", (char*) "()Z",                                                                                              (void*) (uintptr_t) &Java_java_lang_VMClassLoader_defaultUserAssertionStatus },
+       { (char*) "packageAssertionStatus0",    (char*) "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;",                                          (void*) (uintptr_t) &Java_java_lang_VMClassLoader_packageAssertionStatus0    },
+       { (char*) "classAssertionStatus0",      (char*) "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;",                                          (void*) (uintptr_t) &Java_java_lang_VMClassLoader_classAssertionStatus0      },
+       { (char*) "findLoadedClass",            (char*) "(Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;",                                     (void*) (uintptr_t) &Java_java_lang_VMClassLoader_findLoadedClass            },
+};
+
+
+/* _Jv_java_lang_VMClassLoader_init ********************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMClassLoader_init(void)
+{
+       utf* u = utf_new_char("java/lang/VMClassLoader");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/gnuclasspath/java_lang_VMObject.c b/src/native/vm/gnuclasspath/java_lang_VMObject.c
deleted file mode 100644 (file)
index ea0ba0e..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMObject.c - java/lang/VMObject
-
-   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
-
-   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 <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Class.h"            /* required by j.l.VMO */
-#include "native/include/java_lang_Cloneable.h"        /* required by j.l.VMO */
-#include "native/include/java_lang_Object.h"           /* required by j.l.VMO */
-
-#include "native/include/java_lang_VMObject.h"
-
-#include "threads/lock-common.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getClass",  "(Ljava/lang/Object;)Ljava/lang/Class;",     (void *) (intptr_t) &Java_java_lang_VMObject_getClass  },
-       { "clone",     "(Ljava/lang/Cloneable;)Ljava/lang/Object;", (void *) (intptr_t) &Java_java_lang_VMObject_clone     },
-       { "notify",    "(Ljava/lang/Object;)V",                     (void *) (intptr_t) &Java_java_lang_VMObject_notify    },
-       { "notifyAll", "(Ljava/lang/Object;)V",                     (void *) (intptr_t) &Java_java_lang_VMObject_notifyAll },
-       { "wait",      "(Ljava/lang/Object;JI)V",                   (void *) (intptr_t) &Java_java_lang_VMObject_wait      },
-};
-
-
-/* _Jv_java_lang_VMObject_init *************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMObject_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMObject");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    getClass
- * Signature: (Ljava/lang/Object;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMObject_getClass(JNIEnv *env, jclass clazz, java_lang_Object *obj)
-{
-       classinfo *c;
-
-       if (obj == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       LLNI_class_get(obj, c);
-
-       return LLNI_classinfo_wrap(c);
-}
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    clone
- * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, jclass clazz, java_lang_Cloneable *this)
-{
-       java_handle_t *o;
-       java_handle_t *co;
-
-       o = (java_handle_t *) this;
-
-       co = builtin_clone(NULL, o);
-
-       return (java_lang_Object *) co;
-}
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    notify
- * Signature: (Ljava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, java_lang_Object *this)
-{
-#if defined(ENABLE_THREADS)
-       lock_notify_object((java_handle_t *) this);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    notifyAll
- * Signature: (Ljava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, java_lang_Object *this)
-{
-#if defined(ENABLE_THREADS)
-       lock_notify_all_object((java_handle_t *) this);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    wait
- * Signature: (Ljava/lang/Object;JI)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, java_lang_Object *o, int64_t ms, int32_t ns)
-{
-#if defined(ENABLE_JVMTI)
-       /* Monitor Wait */
-       if (jvmti) jvmti_MonitorWaiting(true, o, ms);
-#endif
-
-#if defined(ENABLE_THREADS)
-       lock_wait_for_object((java_handle_t *) o, ms, ns);
-#endif
-
-#if defined(ENABLE_JVMTI)
-       /* Monitor Waited */
-       /* XXX: How do you know if wait timed out ?*/
-       if (jvmti) jvmti_MonitorWaiting(false, o, 0);
-#endif
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/gnuclasspath/java_lang_VMObject.cpp b/src/native/vm/gnuclasspath/java_lang_VMObject.cpp
new file mode 100644 (file)
index 0000000..769d1a0
--- /dev/null
@@ -0,0 +1,167 @@
+/* src/native/vm/gnuclasspath/java_lang_VMObject.cpp - java/lang/VMObject
+
+   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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_VMObject.h"
+#endif
+
+#include "threads/lock.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/utf8.h"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    getClass
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_VMObject_getClass(JNIEnv* env, jclass clazz, jobject obj)
+{
+       if (obj == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       java_lang_Object o(obj);
+
+       return (jclass) LLNI_classinfo_wrap(o.get_Class());
+}
+
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    clone
+ * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_VMObject_clone(JNIEnv* env, jclass clazz, jobject _this)
+{
+       return builtin_clone(NULL, _this);
+}
+
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    notify
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv* env, jclass clazz, jobject _this)
+{
+#if defined(ENABLE_THREADS)
+       lock_notify_object(_this);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    notifyAll
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv* env, jclass clazz, jobject _this)
+{
+#if defined(ENABLE_THREADS)
+       lock_notify_all_object(_this);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    wait
+ * Signature: (Ljava/lang/Object;JI)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv* env, jclass clazz, jobject o, jlong ms, jint ns)
+{
+#if defined(ENABLE_JVMTI)
+       /* Monitor Wait */
+       if (jvmti) jvmti_MonitorWaiting(true, o, ms);
+#endif
+
+#if defined(ENABLE_THREADS)
+       lock_wait_for_object(o, ms, ns);
+#endif
+
+#if defined(ENABLE_JVMTI)
+       /* Monitor Waited */
+       /* XXX: How do you know if wait timed out ?*/
+       if (jvmti) jvmti_MonitorWaiting(false, o, 0);
+#endif
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "getClass",  (char*) "(Ljava/lang/Object;)Ljava/lang/Class;",     (void*) (uintptr_t) &Java_java_lang_VMObject_getClass  },
+       { (char*) "clone",     (char*) "(Ljava/lang/Cloneable;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_VMObject_clone     },
+       { (char*) "notify",    (char*) "(Ljava/lang/Object;)V",                     (void*) (uintptr_t) &Java_java_lang_VMObject_notify    },
+       { (char*) "notifyAll", (char*) "(Ljava/lang/Object;)V",                     (void*) (uintptr_t) &Java_java_lang_VMObject_notifyAll },
+       { (char*) "wait",      (char*) "(Ljava/lang/Object;JI)V",                   (void*) (uintptr_t) &Java_java_lang_VMObject_wait      },
+};
+
+
+/* _Jv_java_lang_VMObject_init *************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMObject_init(void)
+{
+       utf* u = utf_new_char("java/lang/VMObject");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/gnuclasspath/java_lang_VMRuntime.c b/src/native/vm/gnuclasspath/java_lang_VMRuntime.c
deleted file mode 100644 (file)
index 25be0db..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMRuntime.c
-
-   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 <string.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/utsname.h>
-
-#if defined(__DARWIN__)
-# if defined(__POWERPC__)
-#  define OS_INLINE    /* required for <libkern/ppc/OSByteOrder.h> */
-# endif
-# include <mach/mach.h>
-#endif
-
-#include "mm/dumpmemory.h"
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_io_File.h"
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Process.h"
-
-#include "native/include/java_lang_VMRuntime.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vmcore/system.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "exit",                   "(I)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_exit                   },
-       { "freeMemory",             "()J",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_freeMemory             },
-       { "totalMemory",            "()J",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_totalMemory            },
-       { "maxMemory",              "()J",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_maxMemory              },
-       { "gc",                     "()V",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_gc                     },
-       { "runFinalization",        "()V",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalization        },
-       { "runFinalizersOnExit",    "(Z)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalizersOnExit    },
-       { "runFinalizationForExit", "()V",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalizationForExit },
-       { "traceInstructions",      "(Z)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_traceInstructions      },
-       { "traceMethodCalls",       "(Z)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_traceMethodCalls       },
-       { "availableProcessors",    "()I",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_availableProcessors    },
-       { "nativeLoad",             "(Ljava/lang/String;Ljava/lang/ClassLoader;)I", (void *) (intptr_t) &Java_java_lang_VMRuntime_nativeLoad             },
-       { "mapLibraryName",         "(Ljava/lang/String;)Ljava/lang/String;",       (void *) (intptr_t) &Java_java_lang_VMRuntime_mapLibraryName         },
-};
-
-
-/* _Jv_java_lang_VMRuntime_init ************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMRuntime_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMRuntime");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-static bool finalizeOnExit = false;
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    exit
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_exit(JNIEnv *env, jclass clazz, int32_t status)
-{
-       if (finalizeOnExit)
-               gc_finalize_all();
-
-       vm_shutdown(status);
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    freeMemory
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_freeMemory(JNIEnv *env, jclass clazz)
-{
-       return gc_get_free_bytes();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    totalMemory
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz)
-{
-       return gc_get_heap_size();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    maxMemory
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_maxMemory(JNIEnv *env, jclass clazz)
-{
-       return gc_get_max_heap_size();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    gc
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_gc(JNIEnv *env, jclass clazz)
-{
-       gc_call();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    runFinalization
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalization(JNIEnv *env, jclass clazz)
-{
-       gc_invoke_finalizers();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    runFinalizersOnExit
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizersOnExit(JNIEnv *env, jclass clazz, int32_t value)
-{
-       /* XXX threading */
-
-       finalizeOnExit = value;
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    runFinalizationsForExit
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizationForExit(JNIEnv *env, jclass clazz)
-{
-/*     if (finalizeOnExit) { */
-/*             gc_call(); */
-       /* gc_finalize_all(); */
-/*     } */
-/*     log_text("Java_java_lang_VMRuntime_runFinalizationForExit called"); */
-       /*gc_finalize_all();*/
-       /*gc_invoke_finalizers();*/
-       /*gc_call();*/
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    traceInstructions
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceInstructions(JNIEnv *env, jclass clazz, int32_t par1)
-{
-       /* not supported */
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    traceMethodCalls
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceMethodCalls(JNIEnv *env, jclass clazz, int32_t par1)
-{
-       /* not supported */
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    availableProcessors
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *env, jclass clazz)
-{
-       return system_processors_online();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    nativeLoad
- * Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;)I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, java_lang_String *libname, java_lang_ClassLoader *loader)
-{
-       classloader_t *cl;
-       utf           *name;
-
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       /* REMOVEME When we use Java-strings internally. */
-
-       if (libname == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       name = javastring_toutf((java_handle_t *) libname, false);
-
-       return native_library_load(env, name, cl);
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    mapLibraryName
- * Signature: (Ljava/lang/String;)Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMRuntime_mapLibraryName(JNIEnv *env, jclass clazz, java_lang_String *libname)
-{
-       utf           *u;
-       char          *buffer;
-       int32_t        buffer_len;
-       java_handle_t *o;
-       int32_t        dumpmarker;
-
-       if (libname == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       u = javastring_toutf((java_handle_t *) libname, false);
-
-       /* calculate length of library name */
-
-       buffer_len = strlen("lib");
-
-       buffer_len += utf_bytes(u);
-
-#if defined(__DARWIN__)
-       buffer_len += strlen(".dylib");
-#else
-       buffer_len += strlen(".so");
-#endif
-
-       buffer_len += strlen("0");
-
-       DMARKER;
-
-       buffer = DMNEW(char, buffer_len);
-
-       /* generate library name */
-
-       strcpy(buffer, "lib");
-       utf_cat(buffer, u);
-
-#if defined(__DARWIN__)
-       strcat(buffer, ".dylib");
-#else
-       strcat(buffer, ".so");
-#endif
-
-       o = javastring_new_from_utf_string(buffer);
-
-       /* release memory */
-
-       DRELEASE;
-
-       return (java_lang_String *) o;
-}
-
-
-/*
- * 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/native/vm/gnuclasspath/java_lang_VMRuntime.cpp b/src/native/vm/gnuclasspath/java_lang_VMRuntime.cpp
new file mode 100644 (file)
index 0000000..93b8833
--- /dev/null
@@ -0,0 +1,315 @@
+/* src/native/vm/gnuclasspath/java_lang_VMRuntime.cpp
+
+   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 <string.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+
+#if defined(__DARWIN__)
+# if defined(__POWERPC__)
+#  define OS_INLINE    /* required for <libkern/ppc/OSByteOrder.h> */
+# endif
+# include <mach/mach.h>
+#endif
+
+#include "mm/memory.h"
+#include "mm/gc.hpp"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_VMRuntime.h"
+#endif
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/os.hpp"
+#include "vm/string.hpp"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+
+static bool finalizeOnExit = false;
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    exit
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_exit(JNIEnv *env, jclass clazz, jint status)
+{
+       if (finalizeOnExit)
+               gc_finalize_all();
+
+       vm_shutdown(status);
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    freeMemory
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_java_lang_VMRuntime_freeMemory(JNIEnv *env, jclass clazz)
+{
+       return gc_get_free_bytes();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    totalMemory
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz)
+{
+       return gc_get_heap_size();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    maxMemory
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_java_lang_VMRuntime_maxMemory(JNIEnv *env, jclass clazz)
+{
+       return gc_get_max_heap_size();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    gc
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_gc(JNIEnv *env, jclass clazz)
+{
+       gc_call();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    runFinalization
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalization(JNIEnv *env, jclass clazz)
+{
+       gc_invoke_finalizers();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    runFinalizersOnExit
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizersOnExit(JNIEnv *env, jclass clazz, jboolean value)
+{
+       /* XXX threading */
+
+       finalizeOnExit = value;
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    runFinalizationsForExit
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizationForExit(JNIEnv *env, jclass clazz)
+{
+/*     if (finalizeOnExit) { */
+/*             gc_call(); */
+       /* gc_finalize_all(); */
+/*     } */
+/*     log_text("Java_java_lang_VMRuntime_runFinalizationForExit called"); */
+       /*gc_finalize_all();*/
+       /*gc_invoke_finalizers();*/
+       /*gc_call();*/
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    traceInstructions
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceInstructions(JNIEnv *env, jclass clazz, jboolean par1)
+{
+       /* not supported */
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    traceMethodCalls
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceMethodCalls(JNIEnv *env, jclass clazz, jboolean par1)
+{
+       /* not supported */
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    availableProcessors
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *env, jclass clazz)
+{
+       return os::processors_online();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    nativeLoad
+ * Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, jstring libname, jobject loader)
+{
+       classloader_t* cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       /* REMOVEME When we use Java-strings internally. */
+
+       if (libname == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       utf* name = javastring_toutf((java_handle_t *) libname, false);
+
+       NativeLibrary library(name, cl);
+       return library.load(env);
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    mapLibraryName
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_java_lang_VMRuntime_mapLibraryName(JNIEnv *env, jclass clazz, jstring libname)
+{
+       utf           *u;
+       char          *buffer;
+       int32_t        buffer_len;
+       java_handle_t *o;
+
+       if (libname == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       u = javastring_toutf((java_handle_t *) libname, false);
+
+       /* calculate length of library name */
+
+       buffer_len =
+               strlen(NATIVE_LIBRARY_PREFIX) +
+               utf_bytes(u) +
+               strlen(NATIVE_LIBRARY_SUFFIX) +
+               strlen("0");
+
+       buffer = MNEW(char, buffer_len);
+
+       /* generate library name */
+
+       strcpy(buffer, NATIVE_LIBRARY_PREFIX);
+       utf_cat(buffer, u);
+       strcat(buffer, NATIVE_LIBRARY_SUFFIX);
+
+       o = javastring_new_from_utf_string(buffer);
+
+       /* release memory */
+
+       MFREE(buffer, char, buffer_len);
+
+       return (jstring) o;
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "exit",                   (char*) "(I)V",                                         (void*) (uintptr_t) &Java_java_lang_VMRuntime_exit                   },
+       { (char*) "freeMemory",             (char*) "()J",                                          (void*) (uintptr_t) &Java_java_lang_VMRuntime_freeMemory             },
+       { (char*) "totalMemory",            (char*) "()J",                                          (void*) (uintptr_t) &Java_java_lang_VMRuntime_totalMemory            },
+       { (char*) "maxMemory",              (char*) "()J",                                          (void*) (uintptr_t) &Java_java_lang_VMRuntime_maxMemory              },
+       { (char*) "gc",                     (char*) "()V",                                          (void*) (uintptr_t) &Java_java_lang_VMRuntime_gc                     },
+       { (char*) "runFinalization",        (char*) "()V",                                          (void*) (uintptr_t) &Java_java_lang_VMRuntime_runFinalization        },
+       { (char*) "runFinalizersOnExit",    (char*) "(Z)V",                                         (void*) (uintptr_t) &Java_java_lang_VMRuntime_runFinalizersOnExit    },
+       { (char*) "runFinalizationForExit", (char*) "()V",                                          (void*) (uintptr_t) &Java_java_lang_VMRuntime_runFinalizationForExit },
+       { (char*) "traceInstructions",      (char*) "(Z)V",                                         (void*) (uintptr_t) &Java_java_lang_VMRuntime_traceInstructions      },
+       { (char*) "traceMethodCalls",       (char*) "(Z)V",                                         (void*) (uintptr_t) &Java_java_lang_VMRuntime_traceMethodCalls       },
+       { (char*) "availableProcessors",    (char*) "()I",                                          (void*) (uintptr_t) &Java_java_lang_VMRuntime_availableProcessors    },
+       { (char*) "nativeLoad",             (char*) "(Ljava/lang/String;Ljava/lang/ClassLoader;)I", (void*) (uintptr_t) &Java_java_lang_VMRuntime_nativeLoad             },
+       { (char*) "mapLibraryName",         (char*) "(Ljava/lang/String;)Ljava/lang/String;",       (void*) (uintptr_t) &Java_java_lang_VMRuntime_mapLibraryName         },
+};
+
+
+/* _Jv_java_lang_VMRuntime_init ************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMRuntime_init(void)
+{
+       utf* u = utf_new_char("java/lang/VMRuntime");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/gnuclasspath/java_lang_VMString.c b/src/native/vm/gnuclasspath/java_lang_VMString.c
deleted file mode 100644 (file)
index 993b661..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* src/native/vm/gnu/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
-
-   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 <stdlib.h>
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_VMString.h"
-
-#include "vm/stringlocal.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "intern", "(Ljava/lang/String;)Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_VMString_intern },
-};
-
-
-/* _Jv_java_lang_VMString_init *************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMString_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMString");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/VMString
- * Method:    intern
- * Signature: (Ljava/lang/String;)Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMString_intern(JNIEnv *env, jclass clazz, java_lang_String *str)
-{
-       if (str == NULL)
-               return NULL;
-
-       return (java_lang_String *) javastring_intern((java_handle_t *) str);
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/gnuclasspath/java_lang_VMString.cpp b/src/native/vm/gnuclasspath/java_lang_VMString.cpp
new file mode 100644 (file)
index 0000000..9579db2
--- /dev/null
@@ -0,0 +1,94 @@
+/* src/native/vm/gnuclasspath/java_lang_VMString.cpp - java/lang/VMString
+
+   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 <stdint.h>
+#include <stdlib.h>
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_VMString.h"
+#endif
+
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/VMString
+ * Method:    intern
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_java_lang_VMString_intern(JNIEnv *env, jclass clazz, jstring str)
+{
+       if (str == NULL)
+               return NULL;
+
+       return (jstring) javastring_intern((java_handle_t *) str);
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "intern", (char*) "(Ljava/lang/String;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_VMString_intern },
+};
+
+
+/* _Jv_java_lang_VMString_init *************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMString_init(void)
+{
+       utf* u = utf_new_char("java/lang/VMString");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/gnuclasspath/java_lang_VMSystem.c b/src/native/vm/gnuclasspath/java_lang_VMSystem.c
deleted file mode 100644 (file)
index 40c978c..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMSystem.c - java/lang/VMSystem
-
-   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 <stdint.h>
-#include <string.h>
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_io_InputStream.h"        /* required by j.l.VMS */
-#include "native/include/java_io_PrintStream.h"        /* required by j.l.VMS */
-
-#include "native/include/java_lang_VMSystem.h"
-
-#include "vm/builtin.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "arraycopy",        "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void *) (uintptr_t) &Java_java_lang_VMSystem_arraycopy },
-       { "identityHashCode", "(Ljava/lang/Object;)I",                      (void *) (uintptr_t) &Java_java_lang_VMSystem_identityHashCode },
-};
-
-
-/* _Jv_java_lang_VMSystem_init *************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMSystem_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMSystem");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/VMSystem
- * Method:    arraycopy
- * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMSystem_arraycopy(JNIEnv *env, jclass clazz, java_lang_Object *src, int32_t srcStart, java_lang_Object *dest, int32_t destStart, int32_t len)
-{
-       builtin_arraycopy((java_handle_t *) src, srcStart,
-                                         (java_handle_t *) dest, destStart, len);
-}
-
-
-/*
- * Class:     java/lang/VMSystem
- * Method:    identityHashCode
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, java_lang_Object *o)
-{
-       int32_t hashcode;
-
-       LLNI_CRITICAL_START;
-
-       hashcode = heap_hashcode(LLNI_UNWRAP((java_handle_t *) o));
-
-       LLNI_CRITICAL_END;
-
-       return hashcode;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/gnuclasspath/java_lang_VMSystem.cpp b/src/native/vm/gnuclasspath/java_lang_VMSystem.cpp
new file mode 100644 (file)
index 0000000..e5b3e95
--- /dev/null
@@ -0,0 +1,109 @@
+/* src/native/vm/gnuclasspath/java_lang_VMSystem.cpp - java/lang/VMSystem
+
+   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 <stdint.h>
+#include <string.h>
+
+#include "mm/gc.hpp"
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vminclude/java_lang_VMSystem.h"
+#endif
+
+#include "vm/jit/builtin.hpp"
+#include "vm/javaobjects.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/VMSystem
+ * Method:    arraycopy
+ * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMSystem_arraycopy(JNIEnv *env, jclass clazz, jobject src, jint srcStart, jobject dest, jint destStart, jint len)
+{
+       builtin_arraycopy((java_handle_t *) src, srcStart,
+                                         (java_handle_t *) dest, destStart, len);
+}
+
+
+/*
+ * Class:     java/lang/VMSystem
+ * Method:    identityHashCode
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, jobject obj)
+{
+       java_lang_Object o(obj);
+
+       return o.get_hashcode();
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "arraycopy",        (char*) "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void*) (uintptr_t) &Java_java_lang_VMSystem_arraycopy },
+       { (char*) "identityHashCode", (char*) "(Ljava/lang/Object;)I",                      (void*) (uintptr_t) &Java_java_lang_VMSystem_identityHashCode },
+};
+
+
+/* _Jv_java_lang_VMSystem_init *************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMSystem_init(void)
+{
+       utf* u = utf_new_char("java/lang/VMSystem");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/gnuclasspath/java_lang_VMThread.c b/src/native/vm/gnuclasspath/java_lang_VMThread.c
deleted file mode 100644 (file)
index 178bd41..0000000
+++ /dev/null
@@ -1,360 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMThread.c
-
-   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 <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_ThreadGroup.h"
-#include "native/include/java_lang_Object.h"            /* java_lang_Thread.h */
-#include "native/include/java_lang_Throwable.h"         /* java_lang_Thread.h */
-#include "native/include/java_lang_VMThread.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Thread.h"
-
-#include "threads/lock-common.h"
-#include "threads/thread.h"
-
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "countStackFrames",  "()I",                      (void *) (intptr_t) &Java_java_lang_VMThread_countStackFrames  },
-       { "start",             "(J)V",                     (void *) (intptr_t) &Java_java_lang_VMThread_start             },
-       { "interrupt",         "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_interrupt         },
-       { "isInterrupted",     "()Z",                      (void *) (intptr_t) &Java_java_lang_VMThread_isInterrupted     },
-       { "suspend",           "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_suspend           },
-       { "resume",            "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_resume            },
-       { "nativeSetPriority", "(I)V",                     (void *) (intptr_t) &Java_java_lang_VMThread_nativeSetPriority },
-       { "nativeStop",        "(Ljava/lang/Throwable;)V", (void *) (intptr_t) &Java_java_lang_VMThread_nativeStop        },
-       { "currentThread",     "()Ljava/lang/Thread;",     (void *) (intptr_t) &Java_java_lang_VMThread_currentThread     },
-       { "yield",             "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_yield             },
-       { "interrupted",       "()Z",                      (void *) (intptr_t) &Java_java_lang_VMThread_interrupted       },
-       { "holdsLock",         "(Ljava/lang/Object;)Z",    (void *) (intptr_t) &Java_java_lang_VMThread_holdsLock         },
-       { "getState",          "()Ljava/lang/String;",     (void *) (intptr_t) &Java_java_lang_VMThread_getState          },
-};
-
-
-/* _Jv_java_lang_VMThread_init *************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMThread_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMThread");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    countStackFrames
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *this)
-{
-       java_lang_Thread *thread;
-
-       LLNI_field_get_ref(this, thread, thread);
-
-    log_println("Java_java_lang_VMThread_countStackFrames: IMPLEMENT ME!");
-
-    return 0;
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    start
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMThread *this, int64_t stacksize)
-{
-       java_lang_Thread *thread;
-
-       LLNI_field_get_ref(this, thread, thread);
-
-#if defined(ENABLE_THREADS)
-       threads_thread_start((java_handle_t *) thread);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    interrupt
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_VMThread *this)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *h;
-       threadobject  *t;
-
-       h = (java_handle_t *) this;
-       t = thread_get_thread(h);
-
-       threads_thread_interrupt(t);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    isInterrupted
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *h;
-       threadobject  *t;
-
-       h = (java_handle_t *) this;
-       t = thread_get_thread(h);
-
-       return thread_is_interrupted(t);
-#else
-       return 0;
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    suspend
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VMThread *this)
-{
-#if defined(ENABLE_THREADS)
-       /* TODO Should we implement this or is it obsolete? */
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    resume
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMThread *this)
-{
-#if defined(ENABLE_THREADS)
-       /* TODO Should we implement this or is it obsolete? */
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    nativeSetPriority
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, int32_t priority)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *h;
-       threadobject  *t;
-
-       h = (java_handle_t *) this;
-       t = thread_get_thread(h);
-
-       threads_set_thread_priority(t->tid, priority);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    nativeStop
- * Signature: (Ljava/lang/Throwable;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t)
-{
-#if defined(ENABLE_THREADS)
-       /* TODO Should we implement this or is it obsolete? */
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    currentThread
- * Signature: ()Ljava/lang/Thread;
- */
-JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz)
-{
-       java_lang_Thread *to;
-
-       to = (java_lang_Thread *) thread_get_current_object();
-
-       return to;
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    yield
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz)
-{
-#if defined(ENABLE_THREADS)
-       threads_yield();
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    interrupted
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
-{
-#if defined(ENABLE_THREADS)
-       threadobject *t;
-       int32_t       interrupted;
-
-       t = thread_get_current();
-
-       interrupted = thread_is_interrupted(t);
-
-       if (interrupted)
-               thread_set_interrupted(t, false);
-
-       return interrupted;
-#else
-       return 0;
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    holdsLock
- * Signature: (Ljava/lang/Object;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *h;
-
-       h = (java_handle_t *) o;
-
-       if (h == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       return lock_is_held_by_current_thread(h);
-#else
-       return 0;
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    getState
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, java_lang_VMThread *this)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *h;
-       threadobject  *t;
-       int            state;
-       utf           *u;
-       java_handle_t *o;
-
-       h = (java_handle_t *) this;
-       t = thread_get_thread(h);
-
-       state = cacaothread_get_state(t);
-       
-       switch (state) {
-       case THREAD_STATE_NEW:
-               u = utf_new_char("NEW");
-               break;
-       case THREAD_STATE_RUNNABLE:
-               u = utf_new_char("RUNNABLE");
-               break;
-       case THREAD_STATE_BLOCKED:
-               u = utf_new_char("BLOCKED");
-               break;
-       case THREAD_STATE_WAITING:
-               u = utf_new_char("WAITING");
-               break;
-       case THREAD_STATE_TIMED_WAITING:
-               u = utf_new_char("TIMED_WAITING");
-               break;
-       case THREAD_STATE_TERMINATED:
-               u = utf_new_char("TERMINATED");
-               break;
-       default:
-               vm_abort("Java_java_lang_VMThread_getState: unknown thread state %d", state);
-
-               /* Keep compiler happy. */
-
-               u = NULL;
-       }
-
-       o = javastring_new(u);
-
-       return (java_lang_String *) o;
-#else
-       return NULL;
-#endif
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/gnuclasspath/java_lang_VMThread.cpp b/src/native/vm/gnuclasspath/java_lang_VMThread.cpp
new file mode 100644 (file)
index 0000000..da3eccb
--- /dev/null
@@ -0,0 +1,369 @@
+/* src/native/vm/gnuclasspath/java_lang_VMThread.cpp
+
+   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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_VMThread.h"
+#endif
+
+#include "threads/lock.hpp"
+#include "threads/thread.hpp"
+
+#include "vm/exceptions.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/string.hpp"
+#include "vm/utf8.h"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    countStackFrames
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, jobject _this)
+{
+       log_println("Java_java_lang_VMThread_countStackFrames: Deprecated.  Not implemented.");
+
+    return 0;
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    start
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, jobject _this, jlong stacksize)
+{
+#if defined(ENABLE_THREADS)
+       java_lang_VMThread jlvmt(_this);
+
+       threads_thread_start(jlvmt.get_thread());
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    interrupt
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, jobject _this)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *h;
+       threadobject  *t;
+
+       h = (java_handle_t *) _this;
+       t = thread_get_thread(h);
+
+       threads_thread_interrupt(t);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    isInterrupted
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, jobject _this)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *h;
+       threadobject  *t;
+
+       h = (java_handle_t *) _this;
+       t = thread_get_thread(h);
+
+       return thread_is_interrupted(t);
+#else
+       return 0;
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    suspend
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, jobject _this)
+{
+#if defined(ENABLE_THREADS)
+       log_println("Java_java_lang_VMThread_suspend: Deprecated.  Not implemented.");
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    resume
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, jobject _this)
+{
+#if defined(ENABLE_THREADS)
+       log_println("Java_java_lang_VMThread_resume: Deprecated.  Not implemented.");
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    nativeSetPriority
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, jobject _this, jint priority)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *h;
+       threadobject  *t;
+
+       h = (java_handle_t *) _this;
+       t = thread_get_thread(h);
+
+       threads_set_thread_priority(t->tid, priority);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    nativeStop
+ * Signature: (Ljava/lang/Throwable;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, jobject _this, jobject t)
+{
+#if defined(ENABLE_THREADS)
+       log_println("Java_java_lang_VMThread_nativeStop: Deprecated.  Not implemented.");
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    currentThread
+ * Signature: ()Ljava/lang/Thread;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz)
+{
+       java_handle_t* h;
+
+       h = thread_get_current_object();
+
+       return (jobject) h;
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    yield
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz)
+{
+#if defined(ENABLE_THREADS)
+       threads_yield();
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    sleep
+ * Signature: (JI)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_sleep(JNIEnv *env, jclass clazz, int64_t ms, int32_t ns)
+{
+#if defined(ENABLE_THREADS)
+       threads_sleep(ms, ns);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    interrupted
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
+{
+#if defined(ENABLE_THREADS)
+       threadobject *t;
+       int32_t       interrupted;
+
+       t = thread_get_current();
+
+       interrupted = thread_is_interrupted(t);
+
+       if (interrupted)
+               thread_set_interrupted(t, false);
+
+       return interrupted;
+#else
+       return 0;
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    holdsLock
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, jobject o)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *h;
+
+       h = (java_handle_t *) o;
+
+       if (h == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       return lock_is_held_by_current_thread(h);
+#else
+       return 0;
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    getState
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, jobject _this)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *h;
+       threadobject  *t;
+       int            state;
+       utf           *u;
+       java_handle_t *o;
+
+       h = (java_handle_t *) _this;
+       t = thread_get_thread(h);
+
+       state = cacaothread_get_state(t);
+       
+       switch (state) {
+       case THREAD_STATE_NEW:
+               u = utf_new_char("NEW");
+               break;
+       case THREAD_STATE_RUNNABLE:
+               u = utf_new_char("RUNNABLE");
+               break;
+       case THREAD_STATE_BLOCKED:
+               u = utf_new_char("BLOCKED");
+               break;
+       case THREAD_STATE_WAITING:
+               u = utf_new_char("WAITING");
+               break;
+       case THREAD_STATE_TIMED_WAITING:
+               u = utf_new_char("TIMED_WAITING");
+               break;
+       case THREAD_STATE_TERMINATED:
+               u = utf_new_char("TERMINATED");
+               break;
+       default:
+               vm_abort("Java_java_lang_VMThread_getState: unknown thread state %d", state);
+
+               /* Keep compiler happy. */
+
+               u = NULL;
+       }
+
+       o = javastring_new(u);
+
+       return (jstring) o;
+#else
+       return NULL;
+#endif
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "countStackFrames",  (char*) "()I",                      (void*) (uintptr_t) &Java_java_lang_VMThread_countStackFrames  },
+       { (char*) "start",             (char*) "(J)V",                     (void*) (uintptr_t) &Java_java_lang_VMThread_start             },
+       { (char*) "interrupt",         (char*) "()V",                      (void*) (uintptr_t) &Java_java_lang_VMThread_interrupt         },
+       { (char*) "isInterrupted",     (char*) "()Z",                      (void*) (uintptr_t) &Java_java_lang_VMThread_isInterrupted     },
+       { (char*) "suspend",           (char*) "()V",                      (void*) (uintptr_t) &Java_java_lang_VMThread_suspend           },
+       { (char*) "resume",            (char*) "()V",                      (void*) (uintptr_t) &Java_java_lang_VMThread_resume            },
+       { (char*) "nativeSetPriority", (char*) "(I)V",                     (void*) (uintptr_t) &Java_java_lang_VMThread_nativeSetPriority },
+       { (char*) "nativeStop",        (char*) "(Ljava/lang/Throwable;)V", (void*) (uintptr_t) &Java_java_lang_VMThread_nativeStop        },
+       { (char*) "currentThread",     (char*) "()Ljava/lang/Thread;",     (void*) (uintptr_t) &Java_java_lang_VMThread_currentThread     },
+       { (char*) "yield",             (char*) "()V",                      (void*) (uintptr_t) &Java_java_lang_VMThread_yield             },
+       { (char*) "sleep",             (char*) "(JI)V",                    (void*) (uintptr_t) &Java_java_lang_VMThread_sleep             },
+       { (char*) "interrupted",       (char*) "()Z",                      (void*) (uintptr_t) &Java_java_lang_VMThread_interrupted       },
+       { (char*) "holdsLock",         (char*) "(Ljava/lang/Object;)Z",    (void*) (uintptr_t) &Java_java_lang_VMThread_holdsLock         },
+       { (char*) "getState",          (char*) "()Ljava/lang/String;",     (void*) (uintptr_t) &Java_java_lang_VMThread_getState          },
+};
+
+
+/* _Jv_java_lang_VMThread_init *************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMThread_init(void)
+{
+       utf* u = utf_new_char("java/lang/VMThread");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/gnuclasspath/java_lang_VMThrowable.c b/src/native/vm/gnuclasspath/java_lang_VMThrowable.c
deleted file mode 100644 (file)
index 29d6f65..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMThrowable.c
-
-   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 "vm/types.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_StackTraceElement.h"
-#include "native/include/java_lang_Throwable.h"
-
-#include "native/include/java_lang_VMThrowable.h"
-
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-
-#include "vm/jit/code.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "fillInStackTrace", "(Ljava/lang/Throwable;)Ljava/lang/VMThrowable;",        (void *) (ptrint) &Java_java_lang_VMThrowable_fillInStackTrace },
-       { "getStackTrace",    "(Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;", (void *) (ptrint) &Java_java_lang_VMThrowable_getStackTrace    },
-};
-
-
-/* _Jv_java_lang_VMThrowable_init **********************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMThrowable_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMThrowable");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/VMThrowable
- * Method:    fillInStackTrace
- * Signature: (Ljava/lang/Throwable;)Ljava/lang/VMThrowable;
- */
-JNIEXPORT java_lang_VMThrowable* JNICALL Java_java_lang_VMThrowable_fillInStackTrace(JNIEnv *env, jclass clazz, java_lang_Throwable *t)
-{
-       java_lang_VMThrowable   *vmto;
-       java_handle_bytearray_t *ba;
-       java_lang_Object        *o;
-
-       vmto = (java_lang_VMThrowable *)
-               native_new_and_init(class_java_lang_VMThrowable);
-
-       if (vmto == NULL)
-               return NULL;
-
-       ba = stacktrace_get_current();
-
-       if (ba == NULL)
-               return NULL;
-
-       o = (java_lang_Object *) ba;
-
-       LLNI_field_set_ref(vmto, vmdata, o);
-
-       return vmto;
-}
-
-
-/*
- * Class:     java/lang/VMThrowable
- * Method:    getStackTrace
- * Signature: (Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNIEnv *env, java_lang_VMThrowable *this, java_lang_Throwable *t)
-{
-       java_lang_Object            *o;
-       java_handle_bytearray_t     *ba;
-       stacktrace_t                *st;
-       stacktrace_entry_t          *ste;
-       java_handle_objectarray_t   *oa;
-       java_lang_StackTraceElement *steo;
-       codeinfo                    *code;
-       methodinfo                  *m;
-       java_lang_String            *filename;
-       s4                           linenumber;
-       java_handle_t               *declaringclass;
-       int                          i;
-
-       /* Get the stacktrace from the VMThrowable object. */
-
-       LLNI_field_get_ref(this, vmdata, o);
-
-       ba = (java_handle_bytearray_t *) o;
-
-       st = (stacktrace_t *) LLNI_array_data(ba);
-
-       assert(st != NULL);
-
-       ste = st->entries;
-
-       /* Create the stacktrace element array. */
-
-       oa = builtin_anewarray(st->length, class_java_lang_StackTraceElement);
-
-       if (oa == NULL)
-               return NULL;
-
-       for (i = 0; i < st->length; i++, ste++) {
-               /* allocate a new stacktrace element */
-
-               steo = (java_lang_StackTraceElement *)
-                       builtin_new(class_java_lang_StackTraceElement);
-
-               if (steo == NULL)
-                       return NULL;
-
-               /* Get the codeinfo and methodinfo. */
-
-               code = ste->code;
-               m    = code->m;
-
-               /* Get filename. */
-
-               if (!(m->flags & ACC_NATIVE)) {
-                       if (m->clazz->sourcefile)
-                               filename = (java_lang_String *) javastring_new(m->clazz->sourcefile);
-                       else
-                               filename = NULL;
-               }
-               else
-                       filename = NULL;
-
-               /* get line number */
-
-               if (m->flags & ACC_NATIVE) {
-                       linenumber = -1;
-               }
-               else {
-                       /* FIXME The linenumbertable_linenumber_for_pc could
-                          change the methodinfo pointer when hitting an inlined
-                          method. */
-
-                       linenumber = linenumbertable_linenumber_for_pc(&m, code, ste->pc);
-                       linenumber = (linenumber == 0) ? -1 : linenumber;
-               }
-
-               /* get declaring class name */
-
-               declaringclass = class_get_classname(m->clazz);
-
-               /* Fill the java.lang.StackTraceElement object. */
-
-               LLNI_field_set_ref(steo, fileName      , filename);
-               LLNI_field_set_val(steo, lineNumber    , linenumber);
-               LLNI_field_set_ref(steo, declaringClass, (java_lang_String*) declaringclass);
-               LLNI_field_set_ref(steo, methodName    , (java_lang_String *) javastring_new(m->name));
-               LLNI_field_set_val(steo, isNative      , (m->flags & ACC_NATIVE) ? 1 : 0);
-
-               array_objectarray_element_set(oa, i, (java_handle_t *) steo);
-       }
-
-       return oa;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp b/src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp
new file mode 100644 (file)
index 0000000..d62fe29
--- /dev/null
@@ -0,0 +1,203 @@
+/* src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp
+
+   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 <stdint.h>
+#include <assert.h>
+
+#include "vm/types.h"
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_VMThrowable.h"
+#endif
+
+#include "vm/array.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/loader.hpp"
+#include "vm/string.hpp"
+
+#include "vm/jit/code.hpp"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/stacktrace.hpp"
+
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/VMThrowable
+ * Method:    fillInStackTrace
+ * Signature: (Ljava/lang/Throwable;)Ljava/lang/VMThrowable;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_VMThrowable_fillInStackTrace(JNIEnv *env, jclass clazz, jobject t)
+{
+       java_handle_t* h;
+       java_handle_bytearray_t* ba;
+
+       h = native_new_and_init(class_java_lang_VMThrowable);
+
+       if (h == NULL)
+               return NULL;
+
+       java_lang_VMThrowable vmt(h);
+
+       ba = stacktrace_get_current();
+
+       if (ba == NULL)
+               return NULL;
+
+       vmt.set_vmdata(ba);
+
+       return (jobject) vmt.get_handle();
+}
+
+
+/*
+ * Class:     java/lang/VMThrowable
+ * Method:    getStackTrace
+ * Signature: (Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMThrowable_getStackTrace(JNIEnv *env, jobject _this, jobject t)
+{
+       java_lang_VMThrowable vmt(_this);
+
+       // Get the stacktrace from the VMThrowable object.
+
+       java_handle_bytearray_t* ba = vmt.get_vmdata();
+
+       // XXX Critical GC section?
+       stacktrace_t* st = (stacktrace_t*) LLNI_array_data(ba);
+
+       assert(st != NULL);
+
+       stacktrace_entry_t* ste = st->entries;
+
+       /* Create the stacktrace element array. */
+
+       java_handle_objectarray_t* oa = builtin_anewarray(st->length, class_java_lang_StackTraceElement);
+
+       if (oa == NULL)
+               return NULL;
+
+       for (int i = 0; i < st->length; i++, ste++) {
+               /* Get the codeinfo and methodinfo. */
+
+               codeinfo*   code = ste->code;
+               methodinfo* m    = code->m;
+
+               /* Get filename. */
+
+               java_handle_t* filename;
+
+               if (!(m->flags & ACC_NATIVE)) {
+                       if (m->clazz->sourcefile)
+                               filename = javastring_new(m->clazz->sourcefile);
+                       else
+                               filename = NULL;
+               }
+               else
+                       filename = NULL;
+
+               /* get line number */
+
+               int32_t linenumber;
+
+               if (m->flags & ACC_NATIVE) {
+                       linenumber = -1;
+               }
+               else {
+                       /* FIXME linenumbertable->find could change the methodinfo
+                          pointer when hitting an inlined method. */
+
+                       linenumber = code->linenumbertable->find(&m, ste->pc);
+                       linenumber = (linenumber == 0) ? -1 : linenumber;
+               }
+
+               /* get declaring class name */
+
+               java_handle_t* declaringclass = class_get_classname(m->clazz);
+
+               /* allocate a new stacktrace element */
+
+               java_handle_t* h = builtin_new(class_java_lang_StackTraceElement);
+
+               if (h == NULL)
+                       return NULL;
+
+               java_lang_StackTraceElement ste(h, filename, linenumber, declaringclass, javastring_new(m->name), ((m->flags & ACC_NATIVE) ? 1 : 0));
+
+               array_objectarray_element_set(oa, i, ste.get_handle());
+       }
+
+       return (jobjectArray) oa;
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "fillInStackTrace", (char*) "(Ljava/lang/Throwable;)Ljava/lang/VMThrowable;",        (void*) (uintptr_t) &Java_java_lang_VMThrowable_fillInStackTrace },
+       { (char*) "getStackTrace",    (char*) "(Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;", (void*) (uintptr_t) &Java_java_lang_VMThrowable_getStackTrace    },
+};
+
+
+/* _Jv_java_lang_VMThrowable_init **********************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMThrowable_init(void)
+{
+       utf* u = utf_new_char("java/lang/VMThrowable");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.c b/src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.c
deleted file mode 100644 (file)
index 62e1a8f..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/* src/native/vm/gnu/java_lang_management_VMManagementFactory.c
-
-   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
-
-   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 <stdlib.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_management_VMManagementFactory.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-
-#include "vmcore/class.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getMemoryPoolNames",       "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getMemoryPoolNames       },
-       { "getMemoryManagerNames",    "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getMemoryManagerNames    },
-       { "getGarbageCollectorNames", "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames },
-};
-
-
-/* _Jv_java_lang_management_VMManagementFactory_init ***************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_management_VMManagementFactory_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/management/VMManagementFactory");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/management/VMManagementFactory
- * Method:    getMemoryPoolNames
- * Signature: ()[Ljava/lang/String;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryPoolNames(JNIEnv *env, jclass clazz)
-{
-       java_handle_objectarray_t *oa;
-
-       log_println("Java_java_lang_management_VMManagementFactory_getMemoryPoolNames: IMPLEMENT ME!");
-
-       oa = builtin_anewarray(0, class_java_lang_String);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/management/VMManagementFactory
- * Method:    getMemoryManagerNames
- * Signature: ()[Ljava/lang/String;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryManagerNames(JNIEnv *env, jclass clazz)
-{
-       java_handle_objectarray_t *oa;
-
-       log_println("Java_java_lang_management_VMManagementFactory_getMemoryManagerNames: IMPLEMENT ME!");
-
-       oa = builtin_anewarray(0, class_java_lang_String);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/management/VMManagementFactory
- * Method:    getGarbageCollectorNames
- * Signature: ()[Ljava/lang/String;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames(JNIEnv *env, jclass clazz)
-{
-       java_handle_objectarray_t *oa;
-
-       log_println("Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames: IMPLEMENT ME!");
-
-       oa = builtin_anewarray(0, class_java_lang_String);
-
-       return oa;
-}
-
-
-/*
- * 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/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.cpp b/src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.cpp
new file mode 100644 (file)
index 0000000..10f450d
--- /dev/null
@@ -0,0 +1,139 @@
+/* src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.cpp
+
+   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 <stdlib.h>
+
+#include "vm/types.h"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_management_VMManagementFactory.h"
+#endif
+
+#include "toolbox/logging.h"
+
+#include "vm/globals.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/builtin.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/management/VMManagementFactory
+ * Method:    getMemoryPoolNames
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_management_VMManagementFactory_getMemoryPoolNames(JNIEnv *env, jclass clazz)
+{
+       java_handle_objectarray_t *oa;
+
+       log_println("Java_java_lang_management_VMManagementFactory_getMemoryPoolNames: IMPLEMENT ME!");
+
+       oa = builtin_anewarray(0, class_java_lang_String);
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/management/VMManagementFactory
+ * Method:    getMemoryManagerNames
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_management_VMManagementFactory_getMemoryManagerNames(JNIEnv *env, jclass clazz)
+{
+       java_handle_objectarray_t *oa;
+
+       log_println("Java_java_lang_management_VMManagementFactory_getMemoryManagerNames: IMPLEMENT ME!");
+
+       oa = builtin_anewarray(0, class_java_lang_String);
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/management/VMManagementFactory
+ * Method:    getGarbageCollectorNames
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames(JNIEnv *env, jclass clazz)
+{
+       java_handle_objectarray_t *oa;
+
+       log_println("Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames: IMPLEMENT ME!");
+
+       oa = builtin_anewarray(0, class_java_lang_String);
+
+       return oa;
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "getMemoryPoolNames",       (char*) "()[Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_management_VMManagementFactory_getMemoryPoolNames       },
+       { (char*) "getMemoryManagerNames",    (char*) "()[Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_management_VMManagementFactory_getMemoryManagerNames    },
+       { (char*) "getGarbageCollectorNames", (char*) "()[Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames },
+};
+
+
+/* _Jv_java_lang_management_VMManagementFactory_init ***************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_management_VMManagementFactory_init(void)
+{
+       utf* u = utf_new_char("java/lang/management/VMManagementFactory");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.c b/src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.c
deleted file mode 100644 (file)
index db90cf9..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/* src/native/vm/gnu/java_lang_reflect_VMConstructor.c
-
-   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 <stdlib.h>
-
-#if defined(ENABLE_ANNOTATIONS)
-#include "vm/vm.h"
-#include "vm/exceptions.h"
-#endif
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-# include "native/include/java_util_Map.h"
-# include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/include/java_lang_reflect_Constructor.h"
-#include "native/include/java_lang_reflect_VMConstructor.h"
-
-#include "native/vm/reflect.h"
-
-#include "vm/stringlocal.h"
-
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getModifiersInternal",    "()I",                                                       (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getModifiersInternal    },
-       { "getParameterTypes",       "()[Ljava/lang/Class;",                                      (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getParameterTypes       },
-       { "getExceptionTypes",       "()[Ljava/lang/Class;",                                      (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getExceptionTypes       },
-       { "construct",               "([Ljava/lang/Object;)Ljava/lang/Object;",                   (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_construct               },
-       { "getSignature",            "()Ljava/lang/String;",                                      (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getSignature            },
-#if defined(ENABLE_ANNOTATIONS)
-       { "declaredAnnotations",     "()Ljava/util/Map;",                                         (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_declaredAnnotations     },
-       { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;",                     (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getParameterAnnotations },
-#endif
-};
-
-
-/* _Jv_java_lang_reflect_VMConstructor_init ************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_reflect_VMConstructor_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/reflect/VMConstructor");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    getModifiersInternal
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMConstructor_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       m = &(c->methods[slot]);
-
-       return m->flags;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    getParameterTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterTypes(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       m = &(c->methods[slot]);
-
-       return method_get_parametertypearray(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    getExceptionTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       m = &(c->methods[slot]);
-
-       return method_get_exceptionarray(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    construct
- * Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMConstructor_construct(JNIEnv *env, java_lang_reflect_VMConstructor *this, java_handle_objectarray_t *args)
-{
-       classinfo                     *c;
-       int32_t                        slot;
-       java_lang_reflect_Constructor *rc;
-       int32_t                        override;
-       methodinfo                    *m;
-       java_handle_t                 *o;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       LLNI_field_get_ref(this, cons,  rc);
-       LLNI_field_get_val(rc,   flag,  override);
-
-       m = &(c->methods[slot]);
-
-       o = reflect_constructor_newinstance(m, args, override);
-
-       return (java_lang_Object *) o;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    getSignature
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMConstructor_getSignature(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       classinfo     *c;
-       methodinfo    *m;
-       java_handle_t *o;
-       int32_t        slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       m = &(c->methods[slot]);
-
-       if (m->signature == NULL)
-               return NULL;
-
-       o = javastring_new(m->signature);
-
-       /* In error case o is NULL. */
-
-       return (java_lang_String *) o;
-}
-
-
-#if defined(ENABLE_ANNOTATIONS)
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    declaredAnnotations
- * Signature: ()Ljava/util/Map;
- *
- * Parses the annotations (if they aren't parsed yet) and stores them into
- * the declaredAnnotations map and return this map.
- */
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMConstructor_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       java_util_Map           *declaredAnnotations = NULL; /* parsed annotations                                */
-       java_handle_bytearray_t *annotations         = NULL; /* unparsed annotations                              */
-       java_lang_Class         *declaringClass      = NULL; /* the constant pool of this class is used           */
-       classinfo               *referer             = NULL; /* class, which calles the annotation parser         */
-                                                            /* (for the parameter 'referer' of vm_call_method()) */
-
-       LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
-
-       /* are the annotations parsed yet? */
-       if (declaredAnnotations == NULL) {
-               LLNI_field_get_ref(this, annotations, annotations);
-               LLNI_field_get_ref(this, clazz, declaringClass);
-               LLNI_class_get(this, referer);
-
-               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
-
-               LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
-       }
-
-       return declaredAnnotations;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    getParameterAnnotations
- * Signature: ()[[Ljava/lang/annotation/Annotation;
- *
- * Parses the parameter annotations and returns them in an 2 dimensional array.
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations                    */
-       int32_t                  slot                 = -1;   /* slot of the method                                */
-       java_lang_Class         *declaringClass       = NULL; /* the constant pool of this class is used           */
-       classinfo               *referer              = NULL; /* class, which calles the annotation parser         */
-                                                             /* (for the parameter 'referer' of vm_call_method()) */
-
-       LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
-       LLNI_field_get_val(this, slot, slot);
-       LLNI_field_get_ref(this, clazz, declaringClass);
-       LLNI_class_get(this, referer);
-
-       return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, referer);
-}
-#endif
-
-/*
- * 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:
- */
diff --git a/src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.cpp b/src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.cpp
new file mode 100644 (file)
index 0000000..3a302b3
--- /dev/null
@@ -0,0 +1,227 @@
+/* src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.cpp
+
+   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 <stdlib.h>
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_reflect_VMConstructor.h"
+#endif
+
+#include "native/vm/reflection.hpp"
+
+#include "vm/javaobjects.hpp"
+#include "vm/string.hpp"
+#include "vm/utf8.h"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    getModifiersInternal
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_reflect_VMConstructor_getModifiersInternal(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMConstructor rvmc(_this);
+       methodinfo* m = rvmc.get_method();
+       return m->flags;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    getParameterTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getParameterTypes(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMConstructor rvmc(_this);
+       methodinfo* m = rvmc.get_method();
+
+       java_handle_objectarray_t* hoa = method_get_parametertypearray(m);
+
+       return (jobjectArray) hoa;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    getExceptionTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getExceptionTypes(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMConstructor rvmc(_this);
+       methodinfo* m = rvmc.get_method();
+
+       java_handle_objectarray_t* hoa = method_get_exceptionarray(m);
+
+       return (jobjectArray) hoa;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    construct
+ * Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMConstructor_construct(JNIEnv *env, jobject _this, jobjectArray args)
+{
+       java_lang_reflect_VMConstructor jlrvmc(_this);
+       java_lang_reflect_Constructor jlrc(jlrvmc.get_cons());
+
+       java_handle_t* o = jlrc.new_instance((java_handle_objectarray_t*) args);
+
+       return (jobject) o;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    getSignature
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_java_lang_reflect_VMConstructor_getSignature(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMConstructor rvmc(_this);
+       methodinfo* m = rvmc.get_method();
+       java_handle_t *o;
+
+       if (m->signature == NULL)
+               return NULL;
+
+       o = javastring_new(m->signature);
+
+       /* In error case o is NULL. */
+
+       return (jstring) o;
+}
+
+
+#if defined(ENABLE_ANNOTATIONS)
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    declaredAnnotations
+ * Signature: ()Ljava/util/Map;
+ *
+ * Parses the annotations (if they aren't parsed yet) and stores them into
+ * the declaredAnnotations map and return this map.
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMConstructor_declaredAnnotations(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMConstructor rvmc(_this);
+
+       java_handle_t* declaredAnnotations = rvmc.get_declaredAnnotations();
+
+       /* are the annotations parsed yet? */
+       if (declaredAnnotations == NULL) {
+               java_handle_bytearray_t* annotations    = rvmc.get_annotations();
+               classinfo*               declaringClass = rvmc.get_clazz();
+               classinfo*               referer        = rvmc.get_Class();
+
+               declaredAnnotations = Reflection::get_declaredannotations(annotations, declaringClass, referer);
+
+               rvmc.set_declaredAnnotations(declaredAnnotations);
+       }
+
+       return (jobject) declaredAnnotations;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    getParameterAnnotations
+ * Signature: ()[[Ljava/lang/annotation/Annotation;
+ *
+ * Parses the parameter annotations and returns them in an 2 dimensional array.
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getParameterAnnotations(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMConstructor rvmc(_this);
+
+       java_handle_bytearray_t* parameterAnnotations = rvmc.get_parameterAnnotations();
+       methodinfo* m = rvmc.get_method();
+       classinfo* referer = rvmc.get_Class();
+
+       java_handle_objectarray_t* oa = Reflection::get_parameterannotations(parameterAnnotations, m, referer);
+
+       return (jobjectArray) oa;
+}
+#endif
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "getModifiersInternal",    (char*) "()I",                                     (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getModifiersInternal    },
+       { (char*) "getParameterTypes",       (char*) "()[Ljava/lang/Class;",                    (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterTypes       },
+       { (char*) "getExceptionTypes",       (char*) "()[Ljava/lang/Class;",                    (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getExceptionTypes       },
+       { (char*) "construct",               (char*) "([Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_construct               },
+       { (char*) "getSignature",            (char*) "()Ljava/lang/String;",                    (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getSignature            },
+#if defined(ENABLE_ANNOTATIONS)
+       { (char*) "declaredAnnotations",     (char*) "()Ljava/util/Map;",                       (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_declaredAnnotations     },
+       { (char*) "getParameterAnnotations", (char*) "()[[Ljava/lang/annotation/Annotation;",   (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterAnnotations },
+#endif
+};
+
+
+/* _Jv_java_lang_reflect_VMConstructor_init ************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_VMConstructor_init(void)
+{
+       utf* u = utf_new_char("java/lang/reflect/VMConstructor");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/gnuclasspath/java_lang_reflect_VMField.c b/src/native/vm/gnuclasspath/java_lang_reflect_VMField.c
deleted file mode 100644 (file)
index b3da621..0000000
+++ /dev/null
@@ -1,1345 +0,0 @@
-/* src/native/vm/gnu/java_lang_reflect_VMField.c
-
-   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 <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Boolean.h"
-#include "native/include/java_lang_Byte.h"
-#include "native/include/java_lang_Character.h"
-#include "native/include/java_lang_Short.h"
-#include "native/include/java_lang_Integer.h"
-#include "native/include/java_lang_Long.h"
-#include "native/include/java_lang_Float.h"
-#include "native/include/java_lang_Double.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-
-#include "native/include/java_lang_reflect_Field.h"
-#include "native/include/java_lang_reflect_VMField.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-#include "native/include/java_util_Map.h"
-#include "native/include/sun_reflect_ConstantPool.h"
-#include "native/vm/reflect.h"
-#endif
-
-#include "vm/access.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/primitive.h"
-#include "vm/resolve.h"
-#include "vm/stringlocal.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getModifiersInternal", "()I",                                     (void *) (intptr_t) &Java_java_lang_reflect_VMField_getModifiersInternal },
-       { "getType",              "()Ljava/lang/Class;",                     (void *) (intptr_t) &Java_java_lang_reflect_VMField_getType              },
-       { "get",                  "(Ljava/lang/Object;)Ljava/lang/Object;",  (void *) (intptr_t) &Java_java_lang_reflect_VMField_get                  },
-       { "getBoolean",           "(Ljava/lang/Object;)Z",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getBoolean           },
-       { "getByte",              "(Ljava/lang/Object;)B",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getByte              },
-       { "getChar",              "(Ljava/lang/Object;)C",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getChar              },
-       { "getShort",             "(Ljava/lang/Object;)S",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getShort             },
-       { "getInt",               "(Ljava/lang/Object;)I",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getInt               },
-       { "getLong",              "(Ljava/lang/Object;)J",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getLong              },
-       { "getFloat",             "(Ljava/lang/Object;)F",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getFloat             },
-       { "getDouble",            "(Ljava/lang/Object;)D",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getDouble            },
-       { "set",                  "(Ljava/lang/Object;Ljava/lang/Object;)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_set                  },
-       { "setBoolean",           "(Ljava/lang/Object;Z)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setBoolean           },
-       { "setByte",              "(Ljava/lang/Object;B)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setByte              },
-       { "setChar",              "(Ljava/lang/Object;C)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setChar              },
-       { "setShort",             "(Ljava/lang/Object;S)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setShort             },
-       { "setInt",               "(Ljava/lang/Object;I)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setInt               },
-       { "setLong",              "(Ljava/lang/Object;J)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setLong              },
-       { "setFloat",             "(Ljava/lang/Object;F)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setFloat             },
-       { "setDouble",            "(Ljava/lang/Object;D)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setDouble            },
-       { "getSignature",         "()Ljava/lang/String;",                    (void *) (intptr_t) &Java_java_lang_reflect_VMField_getSignature         },
-#if defined(ENABLE_ANNOTATIONS)
-       { "declaredAnnotations",  "()Ljava/util/Map;",                       (void *) (intptr_t) &Java_java_lang_reflect_VMField_declaredAnnotations  },
-#endif
-};
-
-
-/* _Jv_java_lang_reflect_VMField_init ******************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_reflect_VMField_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/reflect/VMField");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/* _field_access_check *********************************************************
-
-   Checks if the field can be accessed.
-
-   RETURN VALUE:
-      true......field can be accessed, or
-      false.....otherwise (maybe an Exception was thrown).
-
-*******************************************************************************/
-
-static bool _field_access_check(java_lang_reflect_VMField *this,
-                                                               fieldinfo *f, classinfo *c, java_handle_t *o)
-{
-       java_lang_reflect_Field *rf;
-       int32_t                  flag;
-
-       /* check if we should bypass security checks (AccessibleObject) */
-
-       LLNI_field_get_ref(this, f, rf);
-       LLNI_field_get_val(rf, flag, flag);
-
-       if (flag == false) {
-               /* This function is always called like this:
-                      [0] java.lang.reflect.VMField.xxx (Native Method)
-                      [1] java.lang.reflect.Field.xxx
-                      [2] <caller>
-               */
-
-               if (!access_check_field(f, 2))
-                       return false;
-       }
-
-       /* some general checks */
-
-       if (f->flags & ACC_STATIC) {
-               /* initialize class if required */
-
-               if (!(c->state & CLASS_INITIALIZED))
-                       if (!initialize_class(c))
-                               return false;
-
-               /* everything is ok */
-
-               return true;
-       }
-       else {
-               /* obj is required for not-static fields */
-
-               if (o == NULL) {
-                       exceptions_throw_nullpointerexception();
-                       return false;
-               }
-       
-               if (builtin_instanceof(o, c))
-                       return true;
-       }
-
-       /* exception path */
-
-       exceptions_throw_illegalargumentexception();
-       return false;
-}
-
-
-/* _field_get_type *************************************************************
-
-   Returns the content of the given field.
-
-*******************************************************************************/
-
-#define _FIELD_GET_TYPE(name, type, uniontype) \
-static inline type _field_get_##name(fieldinfo *f, java_lang_Object *o) \
-{ \
-       type ret; \
-       if (f->flags & ACC_STATIC) { \
-               ret = f->value->uniontype; \
-       } else { \
-               LLNI_CRITICAL_START; \
-               ret = *(type *) (((intptr_t) LLNI_DIRECT(o)) + f->offset); \
-               LLNI_CRITICAL_END; \
-       } \
-       return ret; \
-}
-
-static inline java_handle_t *_field_get_handle(fieldinfo *f, java_lang_Object *o)
-{
-       java_object_t *obj;
-       java_handle_t *hdl;
-
-       LLNI_CRITICAL_START;
-
-       if (f->flags & ACC_STATIC) {
-               obj = f->value->a;
-       } else {
-               obj = *(java_object_t **) (((intptr_t) LLNI_DIRECT(o)) + f->offset);
-       }
-
-       hdl = LLNI_WRAP(obj);
-
-       LLNI_CRITICAL_END;
-
-       return hdl;
-}
-
-_FIELD_GET_TYPE(int,    int32_t, i)
-_FIELD_GET_TYPE(long,   int64_t, l)
-_FIELD_GET_TYPE(float,  float,   f)
-_FIELD_GET_TYPE(double, double,  d)
-
-
-/* _field_set_type *************************************************************
-
-   Sets the content of the given field to the given value.
-
-*******************************************************************************/
-
-#define _FIELD_SET_TYPE(name, type, uniontype) \
-static inline void _field_set_##name(fieldinfo *f, java_lang_Object *o, type value) \
-{ \
-       if (f->flags & ACC_STATIC) { \
-               f->value->uniontype = value; \
-       } else { \
-               LLNI_CRITICAL_START; \
-               *(type *) (((intptr_t) LLNI_DIRECT(o)) + f->offset) = value; \
-               LLNI_CRITICAL_END; \
-       } \
-}
-
-static inline void _field_set_handle(fieldinfo *f, java_lang_Object *o, java_handle_t *value)
-{
-       LLNI_CRITICAL_START;
-
-       if (f->flags & ACC_STATIC) {
-               f->value->a = LLNI_DIRECT(value);
-       } else {
-               *(java_object_t **) (((intptr_t) LLNI_DIRECT(o)) + f->offset) = LLNI_DIRECT(value);
-       }
-
-       LLNI_CRITICAL_END;
-}
-
-_FIELD_SET_TYPE(int,    int32_t, i)
-_FIELD_SET_TYPE(long,   int64_t, l)
-_FIELD_SET_TYPE(float,  float,   f)
-_FIELD_SET_TYPE(double, double,  d)
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getModifiersInternal
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMField *this)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &(c->fields[slot]);
-
-       return f->flags;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getType
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMField_getType(JNIEnv *env, java_lang_reflect_VMField *this)
-{
-       classinfo *c;
-       typedesc  *desc;
-       classinfo *ret;
-       int32_t    slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       desc = c->fields[slot].parseddesc;
-
-       if (desc == NULL)
-               return NULL;
-
-       if (!resolve_class_from_typedesc(desc, true, false, &ret))
-               return NULL;
-       
-       return LLNI_classinfo_wrap(ret);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    get
- * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMField_get(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-       imm_union  value;
-       java_handle_t *object;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return NULL;
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BOOLEAN:
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               value.i = _field_get_int(f, o);
-               break;
-
-       case PRIMITIVETYPE_LONG:
-               value.l = _field_get_long(f, o);
-               break;
-
-       case PRIMITIVETYPE_FLOAT:
-               value.f = _field_get_float(f, o);
-               break;
-
-       case PRIMITIVETYPE_DOUBLE:
-               value.d = _field_get_double(f, o);
-               break;
-
-       case TYPE_ADR:
-               return (java_lang_Object *) _field_get_handle(f, o);
-       }
-
-       /* Now box the primitive types. */
-
-       object = primitive_box(f->parseddesc->decltype, value);
-
-       return (java_lang_Object *) object;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getBoolean
- * Signature: (Ljava/lang/Object;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getBoolean(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BOOLEAN:
-               return (int32_t) _field_get_int(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getByte
- * Signature: (Ljava/lang/Object;)B
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getByte(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-               return (int32_t) _field_get_int(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getChar
- * Signature: (Ljava/lang/Object;)C
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getChar(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_CHAR:
-               return (int32_t) _field_get_int(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getShort
- * Signature: (Ljava/lang/Object;)S
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getShort(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_SHORT:
-               return (int32_t) _field_get_int(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getInt
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getInt(JNIEnv *env , java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               return (int32_t) _field_get_int(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getLong
- * Signature: (Ljava/lang/Object;)J
- */
-JNIEXPORT int64_t JNICALL Java_java_lang_reflect_VMField_getLong(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               return (int64_t) _field_get_int(f, o);
-       case PRIMITIVETYPE_LONG:
-               return (int64_t) _field_get_long(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getFloat
- * Signature: (Ljava/lang/Object;)F
- */
-JNIEXPORT float JNICALL Java_java_lang_reflect_VMField_getFloat(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               return (float) _field_get_int(f, o);
-       case PRIMITIVETYPE_LONG:
-               return (float) _field_get_long(f, o);
-       case PRIMITIVETYPE_FLOAT:
-               return (float) _field_get_float(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getDouble
- * Signature: (Ljava/lang/Object;)D
- */
-JNIEXPORT double JNICALL Java_java_lang_reflect_VMField_getDouble(JNIEnv *env , java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               return (double) _field_get_int(f, o);
-       case PRIMITIVETYPE_LONG:
-               return (double) _field_get_long(f, o);
-       case PRIMITIVETYPE_FLOAT:
-               return (double) _field_get_float(f, o);
-       case PRIMITIVETYPE_DOUBLE:
-               return (double) _field_get_double(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    set
- * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_set(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, java_lang_Object *value)
-{
-       classinfo *sc;
-       classinfo *dc;
-       fieldinfo *sf;
-       fieldinfo *df;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, dc);
-       LLNI_field_get_val(this, slot , slot);
-       df = &dc->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, df, dc, (java_handle_t *) o))
-               return;
-
-       /* get the source classinfo from the object */
-
-       if (value == NULL)
-               sc = NULL;
-       else
-               LLNI_class_get(value, sc);
-
-       /* The fieldid is used to set the new value, for primitive
-          types the value has to be retrieved from the wrapping
-          object */
-
-       switch (df->parseddesc->decltype) {
-       case PRIMITIVETYPE_BOOLEAN: {
-               int32_t val;
-
-               /* determine the field to read the value */
-
-               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_Z)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BOOLEAN:
-                       LLNI_field_get_val((java_lang_Boolean *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_int(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_BYTE: {
-               int32_t val;
-
-               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_B)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               default:        
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_int(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_CHAR: {
-               int32_t val;
-
-               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_C)))
-                       break;
-                                  
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_CHAR:
-                       LLNI_field_get_val((java_lang_Character *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_int(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_SHORT: {
-               int32_t val;
-
-               /* get field only by name, it can be one of B, S */
-
-               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
-                       break;
-                                  
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       LLNI_field_get_val((java_lang_Short *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_int(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_INT: {
-               int32_t val;
-
-               /* get field only by name, it can be one of B, S, C, I */
-
-               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       LLNI_field_get_val((java_lang_Character *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       LLNI_field_get_val((java_lang_Short *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_INT:
-                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_int(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_LONG: {
-               int64_t val;
-
-               /* get field only by name, it can be one of B, S, C, I, J */
-
-               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       LLNI_field_get_val((java_lang_Character *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       LLNI_field_get_val((java_lang_Short *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_INT:
-                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_LONG:
-                       LLNI_field_get_val((java_lang_Long *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_long(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_FLOAT: {
-               float val;
-
-               /* get field only by name, it can be one of B, S, C, I, J, F */
-
-               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       LLNI_field_get_val((java_lang_Character *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       LLNI_field_get_val((java_lang_Short *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_INT:
-                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_LONG:
-                       LLNI_field_get_val((java_lang_Long *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_FLOAT:
-                       LLNI_field_get_val((java_lang_Float *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_float(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_DOUBLE: {
-               double val;
-
-               /* get field only by name, it can be one of B, S, C, I, J, F, D */
-
-               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       LLNI_field_get_val((java_lang_Character *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       LLNI_field_get_val((java_lang_Short *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_INT:
-                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_LONG:
-                       LLNI_field_get_val((java_lang_Long *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_FLOAT:
-                       LLNI_field_get_val((java_lang_Float *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_DOUBLE:
-                       LLNI_field_get_val((java_lang_Double *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_double(df, o, val);
-               return;
-       }
-
-       case TYPE_ADR:
-               /* check if value is an instance of the destination class */
-
-               /* XXX TODO */
-               /*                      if (!builtin_instanceof((java_handle_t *) value, df->class)) */
-               /*                              break; */
-
-               _field_set_handle(df, o, (java_handle_t *) value);
-               return;
-       }
-
-       /* raise exception */
-
-       exceptions_throw_illegalargumentexception();
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setBoolean
- * Signature: (Ljava/lang/Object;Z)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setBoolean(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BOOLEAN:
-               _field_set_int(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setByte
- * Signature: (Ljava/lang/Object;B)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setByte(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               _field_set_int(f, o, value);
-               break;
-       case PRIMITIVETYPE_LONG:
-               _field_set_long(f, o, value);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setChar
- * Signature: (Ljava/lang/Object;C)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setChar(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_INT:
-               _field_set_int(f, o, value);
-               break;
-       case PRIMITIVETYPE_LONG:
-               _field_set_long(f, o, value);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setShort
- * Signature: (Ljava/lang/Object;S)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setShort(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               _field_set_int(f, o, value);
-               break;
-       case PRIMITIVETYPE_LONG:
-               _field_set_long(f, o, value);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setInt
- * Signature: (Ljava/lang/Object;I)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setInt(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_INT:
-               _field_set_int(f, o, value);
-               break;
-       case PRIMITIVETYPE_LONG:
-               _field_set_long(f, o, value);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setLong
- * Signature: (Ljava/lang/Object;J)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setLong(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int64_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_LONG:
-               _field_set_long(f, o, value);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setFloat
- * Signature: (Ljava/lang/Object;F)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setFloat(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, float value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setDouble
- * Signature: (Ljava/lang/Object;D)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setDouble(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, double value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getSignature
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMField_getSignature(JNIEnv *env, java_lang_reflect_VMField* this)
-{
-       classinfo     *c;
-       fieldinfo     *f;
-       java_handle_t *o;
-       int32_t        slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       if (f->signature == NULL)
-               return NULL;
-
-       o = javastring_new(f->signature);
-
-       /* in error case o is NULL */
-
-       return (java_lang_String *) o;
-}
-
-
-#if defined(ENABLE_ANNOTATIONS)
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    declaredAnnotations
- * Signature: ()Ljava/util/Map;
- */
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMField_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMField *this)
-{
-       java_util_Map           *declaredAnnotations = NULL; /* parsed annotations                                */
-       java_handle_bytearray_t *annotations         = NULL; /* unparsed annotations                              */
-       java_lang_Class         *declaringClass      = NULL; /* the constant pool of this class is used           */
-       classinfo               *referer             = NULL; /* class, which calles the annotation parser         */
-                                                            /* (for the parameter 'referer' of vm_call_method()) */
-
-       LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
-
-       /* are the annotations parsed yet? */
-       if (declaredAnnotations == NULL) {
-               LLNI_field_get_ref(this, annotations, annotations);
-               LLNI_field_get_ref(this, clazz, declaringClass);
-               LLNI_class_get(this, referer);
-
-               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
-
-               LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
-       }
-
-       return declaredAnnotations;
-}
-#endif
-
-
-/*
- * 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/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp b/src/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp
new file mode 100644 (file)
index 0000000..c39f058
--- /dev/null
@@ -0,0 +1,1135 @@
+/* src/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp
+
+   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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_reflect_VMField.h"
+#endif
+
+#if defined(ENABLE_ANNOTATIONS)
+// REMOVEME
+# include "native/vm/reflection.hpp"
+#endif
+
+#include "vm/access.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/initialize.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/loader.hpp"
+#include "vm/primitive.hpp"
+#include "vm/resolve.hpp"
+#include "vm/string.hpp"
+#include "vm/utf8.h"
+
+
+/* _field_access_check *********************************************************
+
+   Checks if the field can be accessed.
+
+   RETURN VALUE:
+      true......field can be accessed, or
+      false.....otherwise (maybe an Exception was thrown).
+
+*******************************************************************************/
+
+static bool _field_access_check(const java_lang_reflect_VMField& rvmf, fieldinfo *f, java_handle_t *o)
+{
+       // Check if we should bypass security checks (AccessibleObject).
+
+       java_lang_reflect_Field rf(rvmf.get_f());
+       int32_t override = rf.get_flag();
+
+       if (override == false) {
+               /* This function is always called like this:
+                      [0] java.lang.reflect.VMField.xxx (Native Method)
+                      [1] java.lang.reflect.Field.xxx
+                      [2] <caller>
+               */
+
+               if (!access_check_field(f, 2))
+                       return false;
+       }
+
+       /* some general checks */
+
+       if (f->flags & ACC_STATIC) {
+               /* initialize class if required */
+
+               if (!(f->clazz->state & CLASS_INITIALIZED))
+                       if (!initialize_class(f->clazz))
+                               return false;
+
+               /* everything is ok */
+
+               return true;
+       }
+       else {
+               /* obj is required for not-static fields */
+
+               if (o == NULL) {
+                       exceptions_throw_nullpointerexception();
+                       return false;
+               }
+       
+               if (builtin_instanceof(o, f->clazz))
+                       return true;
+       }
+
+       /* exception path */
+
+       exceptions_throw_illegalargumentexception();
+       return false;
+}
+
+
+/* _field_get_type *************************************************************
+
+   Returns the content of the given field.
+
+*******************************************************************************/
+
+#define _FIELD_GET_TYPE(name, type, uniontype) \
+static inline type _field_get_##name(fieldinfo *f, java_handle_t* h) \
+{ \
+       type ret; \
+       if (f->flags & ACC_STATIC) { \
+               ret = f->value->uniontype; \
+       } else { \
+               LLNI_CRITICAL_START; \
+               ret = *(type *) (((intptr_t) LLNI_DIRECT(h)) + f->offset); \
+               LLNI_CRITICAL_END; \
+       } \
+       return ret; \
+}
+
+static inline java_handle_t *_field_get_handle(fieldinfo *f, java_handle_t* h)
+{
+       java_object_t* result;
+       java_handle_t* hresult;
+
+       LLNI_CRITICAL_START;
+
+       if (f->flags & ACC_STATIC) {
+               result = (java_object_t*) f->value->a;
+       } else {
+               result = *(java_object_t**) (((intptr_t) LLNI_DIRECT(h)) + f->offset);
+       }
+
+       hresult = LLNI_WRAP(result);
+
+       LLNI_CRITICAL_END;
+
+       return hresult;
+}
+
+_FIELD_GET_TYPE(int,    int32_t, i)
+_FIELD_GET_TYPE(long,   int64_t, l)
+_FIELD_GET_TYPE(float,  float,   f)
+_FIELD_GET_TYPE(double, double,  d)
+
+
+/* _field_set_type *************************************************************
+
+   Sets the content of the given field to the given value.
+
+*******************************************************************************/
+
+#define _FIELD_SET_TYPE(name, type, uniontype) \
+static inline void _field_set_##name(fieldinfo* f, java_handle_t* h, type value) \
+{ \
+       if (f->flags & ACC_STATIC) { \
+               f->value->uniontype = value; \
+       } else { \
+               LLNI_CRITICAL_START; \
+               *(type *) (((intptr_t) LLNI_DIRECT(h)) + f->offset) = value; \
+               LLNI_CRITICAL_END; \
+       } \
+}
+
+static inline void _field_set_handle(fieldinfo* f, java_handle_t* h, java_handle_t* hvalue)
+{
+       LLNI_CRITICAL_START;
+
+       if (f->flags & ACC_STATIC) {
+               f->value->a = LLNI_DIRECT(hvalue);
+       } else {
+               *(java_object_t**) (((intptr_t) LLNI_DIRECT(h)) + f->offset) = LLNI_DIRECT(hvalue);
+       }
+
+       LLNI_CRITICAL_END;
+}
+
+_FIELD_SET_TYPE(int,    int32_t, i)
+_FIELD_SET_TYPE(long,   int64_t, l)
+_FIELD_SET_TYPE(float,  float,   f)
+_FIELD_SET_TYPE(double, double,  d)
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getModifiersInternal
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_reflect_VMField_getModifiersInternal(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+       return f->flags;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getType
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_reflect_VMField_getType(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+       classinfo *ret;
+
+       typedesc* desc = f->parseddesc;
+
+       if (desc == NULL)
+               return NULL;
+
+       if (!resolve_class_from_typedesc(desc, true, false, &ret))
+               return NULL;
+       
+       return (jclass) LLNI_classinfo_wrap(ret);
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    get
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMField_get(JNIEnv *env, jobject _this, jobject o)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return NULL;
+
+       imm_union value;
+
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_BOOLEAN:
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               value.i = _field_get_int(f, o);
+               break;
+
+       case PRIMITIVETYPE_LONG:
+               value.l = _field_get_long(f, o);
+               break;
+
+       case PRIMITIVETYPE_FLOAT:
+               value.f = _field_get_float(f, o);
+               break;
+
+       case PRIMITIVETYPE_DOUBLE:
+               value.d = _field_get_double(f, o);
+               break;
+
+       case TYPE_ADR:
+               return (jobject) _field_get_handle(f, o);
+       }
+
+       // Now box the primitive types.
+       java_handle_t* object = Primitive::box(f->parseddesc->primitivetype, value);
+
+       return object;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getBoolean
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_reflect_VMField_getBoolean(JNIEnv *env, jobject _this, jobject o)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return 0;
+
+       // Check the field type and return the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_BOOLEAN:
+               return (jint) _field_get_int(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getByte
+ * Signature: (Ljava/lang/Object;)B
+ */
+JNIEXPORT jbyte JNICALL Java_java_lang_reflect_VMField_getByte(JNIEnv *env, jobject _this, jobject o)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return 0;
+
+       // Check the field type and return the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_BYTE:
+               return (jint) _field_get_int(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getChar
+ * Signature: (Ljava/lang/Object;)C
+ */
+JNIEXPORT jchar JNICALL Java_java_lang_reflect_VMField_getChar(JNIEnv *env, jobject _this, jobject o)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return 0;
+
+       // Check the field type and return the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_CHAR:
+               return (jint) _field_get_int(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getShort
+ * Signature: (Ljava/lang/Object;)S
+ */
+JNIEXPORT jshort JNICALL Java_java_lang_reflect_VMField_getShort(JNIEnv *env, jobject _this, jobject o)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return 0;
+
+       // Check the field type and return the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_SHORT:
+               return (jint) _field_get_int(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getInt
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_reflect_VMField_getInt(JNIEnv *env , jobject _this, jobject o)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return 0;
+
+       // Check the field type and return the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               return (jint) _field_get_int(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getLong
+ * Signature: (Ljava/lang/Object;)J
+ */
+JNIEXPORT jlong JNICALL Java_java_lang_reflect_VMField_getLong(JNIEnv *env, jobject _this, jobject o)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return 0;
+
+       // Check the field type and return the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               return (jlong) _field_get_int(f, o);
+       case PRIMITIVETYPE_LONG:
+               return (jlong) _field_get_long(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getFloat
+ * Signature: (Ljava/lang/Object;)F
+ */
+JNIEXPORT jfloat JNICALL Java_java_lang_reflect_VMField_getFloat(JNIEnv *env, jobject _this, jobject o)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return 0;
+
+       // Check the field type and return the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               return (jfloat) _field_get_int(f, o);
+       case PRIMITIVETYPE_LONG:
+               return (jfloat) _field_get_long(f, o);
+       case PRIMITIVETYPE_FLOAT:
+               return (jfloat) _field_get_float(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getDouble
+ * Signature: (Ljava/lang/Object;)D
+ */
+JNIEXPORT jdouble JNICALL Java_java_lang_reflect_VMField_getDouble(JNIEnv *env , jobject _this, jobject o)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return 0;
+
+       // Check the field type and return the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               return (jdouble) _field_get_int(f, o);
+       case PRIMITIVETYPE_LONG:
+               return (jdouble) _field_get_long(f, o);
+       case PRIMITIVETYPE_FLOAT:
+               return (jdouble) _field_get_float(f, o);
+       case PRIMITIVETYPE_DOUBLE:
+               return (jdouble) _field_get_double(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    set
+ * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_set(JNIEnv *env, jobject _this, jobject o, jobject value)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* df = rvmf.get_field();
+
+       classinfo *sc;
+       fieldinfo *sf;
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, df, o))
+               return;
+
+       // Get the source classinfo from the object.
+       if (value == NULL)
+               sc = NULL;
+       else
+               LLNI_class_get(value, sc);
+
+       /* The fieldid is used to set the new value, for primitive
+          types the value has to be retrieved from the wrapping
+          object */
+
+       switch (df->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_BOOLEAN: {
+               int32_t val;
+
+               /* determine the field to read the value */
+
+               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_Z)))
+                       break;
+
+               switch (sf->parseddesc->primitivetype) {
+               case PRIMITIVETYPE_BOOLEAN:
+                       val = java_lang_Boolean(value).get_value();
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_int(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_BYTE: {
+               int32_t val;
+
+               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_B)))
+                       break;
+
+               switch (sf->parseddesc->primitivetype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = java_lang_Byte(value).get_value();
+                       break;
+               default:        
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_int(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_CHAR: {
+               int32_t val;
+
+               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_C)))
+                       break;
+                                  
+               switch (sf->parseddesc->primitivetype) {
+               case PRIMITIVETYPE_CHAR:
+                       val = java_lang_Character(value).get_value();
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_int(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_SHORT: {
+               int32_t val;
+
+               /* get field only by name, it can be one of B, S */
+
+               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
+                       break;
+                                  
+               switch (sf->parseddesc->primitivetype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = java_lang_Byte(value).get_value();
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       val = java_lang_Short(value).get_value();
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_int(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_INT: {
+               int32_t val;
+
+               /* get field only by name, it can be one of B, S, C, I */
+
+               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
+                       break;
+
+               switch (sf->parseddesc->primitivetype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = java_lang_Byte(value).get_value();
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       val = java_lang_Character(value).get_value();
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       val = java_lang_Short(value).get_value();
+                       break;
+               case PRIMITIVETYPE_INT:
+                       val = java_lang_Integer(value).get_value();
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_int(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_LONG: {
+               int64_t val;
+
+               /* get field only by name, it can be one of B, S, C, I, J */
+
+               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
+                       break;
+
+               switch (sf->parseddesc->primitivetype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = java_lang_Byte(value).get_value();
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       val = java_lang_Character(value).get_value();
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       val = java_lang_Short(value).get_value();
+                       break;
+               case PRIMITIVETYPE_INT:
+                       val = java_lang_Integer(value).get_value();
+                       break;
+               case PRIMITIVETYPE_LONG:
+                       val = java_lang_Long(value).get_value();
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_long(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_FLOAT: {
+               float val;
+
+               /* get field only by name, it can be one of B, S, C, I, J, F */
+
+               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
+                       break;
+
+               switch (sf->parseddesc->primitivetype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = java_lang_Byte(value).get_value();
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       val = java_lang_Character(value).get_value();
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       val = java_lang_Short(value).get_value();
+                       break;
+               case PRIMITIVETYPE_INT:
+                       val = java_lang_Integer(value).get_value();
+                       break;
+               case PRIMITIVETYPE_LONG:
+                       val = java_lang_Long(value).get_value();
+                       break;
+               case PRIMITIVETYPE_FLOAT:
+                       val = java_lang_Float(value).get_value();
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_float(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_DOUBLE: {
+               double val;
+
+               /* get field only by name, it can be one of B, S, C, I, J, F, D */
+
+               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
+                       break;
+
+               switch (sf->parseddesc->primitivetype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = java_lang_Byte(value).get_value();
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       val = java_lang_Character(value).get_value();
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       val = java_lang_Short(value).get_value();
+                       break;
+               case PRIMITIVETYPE_INT:
+                       val = java_lang_Integer(value).get_value();
+                       break;
+               case PRIMITIVETYPE_LONG:
+                       val = java_lang_Long(value).get_value();
+                       break;
+               case PRIMITIVETYPE_FLOAT:
+                       val = java_lang_Float(value).get_value();
+                       break;
+               case PRIMITIVETYPE_DOUBLE:
+                       val = java_lang_Double(value).get_value();
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_double(df, o, val);
+               return;
+       }
+
+       case TYPE_ADR:
+               /* check if value is an instance of the destination class */
+
+               /* XXX TODO */
+               /*                      if (!builtin_instanceof((java_handle_t *) value, df->class)) */
+               /*                              break; */
+
+               _field_set_handle(df, o, value);
+               return;
+       }
+
+       /* raise exception */
+
+       exceptions_throw_illegalargumentexception();
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setBoolean
+ * Signature: (Ljava/lang/Object;Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setBoolean(JNIEnv *env, jobject _this, jobject o, jboolean value)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return;
+
+       // Check the field type and set the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_BOOLEAN:
+               _field_set_int(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setByte
+ * Signature: (Ljava/lang/Object;B)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setByte(JNIEnv *env, jobject _this, jobject o, jbyte value)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return;
+
+       // Check the field type and set the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               _field_set_int(f, o, value);
+               break;
+       case PRIMITIVETYPE_LONG:
+               _field_set_long(f, o, value);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setChar
+ * Signature: (Ljava/lang/Object;C)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setChar(JNIEnv *env, jobject _this, jobject o, jchar value)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return;
+
+       // Check the field type and set the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_INT:
+               _field_set_int(f, o, value);
+               break;
+       case PRIMITIVETYPE_LONG:
+               _field_set_long(f, o, value);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setShort
+ * Signature: (Ljava/lang/Object;S)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setShort(JNIEnv *env, jobject _this, jobject o, jshort value)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return;
+
+       // Check the field type and set the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               _field_set_int(f, o, value);
+               break;
+       case PRIMITIVETYPE_LONG:
+               _field_set_long(f, o, value);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setInt
+ * Signature: (Ljava/lang/Object;I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setInt(JNIEnv *env, jobject _this, jobject o, jint value)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return;
+
+       // Check the field type and set the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_INT:
+               _field_set_int(f, o, value);
+               break;
+       case PRIMITIVETYPE_LONG:
+               _field_set_long(f, o, value);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setLong
+ * Signature: (Ljava/lang/Object;J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setLong(JNIEnv *env, jobject _this, jobject o, jlong value)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return;
+
+       // Check the field type and set the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_LONG:
+               _field_set_long(f, o, value);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setFloat
+ * Signature: (Ljava/lang/Object;F)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setFloat(JNIEnv *env, jobject _this, jobject o, jfloat value)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return;
+
+       // Check the field type and set the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setDouble
+ * Signature: (Ljava/lang/Object;D)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setDouble(JNIEnv *env, jobject _this, jobject o, jdouble value)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       // Check if the field can be accessed.
+       if (!_field_access_check(rvmf, f, o))
+               return;
+
+       // Check the field type and set the value.
+       switch (f->parseddesc->primitivetype) {
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getSignature
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_java_lang_reflect_VMField_getSignature(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMField rvmf(_this);
+       fieldinfo* f = rvmf.get_field();
+
+       if (f->signature == NULL)
+               return NULL;
+
+       java_handle_t* o = javastring_new(f->signature);
+
+       /* in error case o is NULL */
+
+       return o;
+}
+
+
+#if defined(ENABLE_ANNOTATIONS)
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    declaredAnnotations
+ * Signature: ()Ljava/util/Map;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMField_declaredAnnotations(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMField rvmf(_this);
+
+       java_handle_t* declaredAnnotations = rvmf.get_declaredAnnotations();
+
+       // Are the annotations parsed yet?
+       if (declaredAnnotations == NULL) {
+               java_handle_bytearray_t* annotations    = rvmf.get_annotations();
+               classinfo*               declaringClass = rvmf.get_clazz();
+               classinfo*               referer        = rvmf.get_Class();
+
+               declaredAnnotations = Reflection::get_declaredannotations(annotations, declaringClass, referer);
+
+               rvmf.set_declaredAnnotations(declaredAnnotations);
+       }
+
+       return (jobject) declaredAnnotations;
+}
+#endif
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static const JNINativeMethod methods[] = {
+       { (char*) "getModifiersInternal", (char*) "()I",                                     (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getModifiersInternal },
+       { (char*) "getType",              (char*) "()Ljava/lang/Class;",                     (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getType              },
+       { (char*) "get",                  (char*) "(Ljava/lang/Object;)Ljava/lang/Object;",  (void*) (uintptr_t) &Java_java_lang_reflect_VMField_get                  },
+       { (char*) "getBoolean",           (char*) "(Ljava/lang/Object;)Z",                   (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getBoolean           },
+       { (char*) "getByte",              (char*) "(Ljava/lang/Object;)B",                   (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getByte              },
+       { (char*) "getChar",              (char*) "(Ljava/lang/Object;)C",                   (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getChar              },
+       { (char*) "getShort",             (char*) "(Ljava/lang/Object;)S",                   (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getShort             },
+       { (char*) "getInt",               (char*) "(Ljava/lang/Object;)I",                   (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getInt               },
+       { (char*) "getLong",              (char*) "(Ljava/lang/Object;)J",                   (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getLong              },
+       { (char*) "getFloat",             (char*) "(Ljava/lang/Object;)F",                   (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getFloat             },
+       { (char*) "getDouble",            (char*) "(Ljava/lang/Object;)D",                   (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getDouble            },
+       { (char*) "set",                  (char*) "(Ljava/lang/Object;Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_set                  },
+       { (char*) "setBoolean",           (char*) "(Ljava/lang/Object;Z)V",                  (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setBoolean           },
+       { (char*) "setByte",              (char*) "(Ljava/lang/Object;B)V",                  (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setByte              },
+       { (char*) "setChar",              (char*) "(Ljava/lang/Object;C)V",                  (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setChar              },
+       { (char*) "setShort",             (char*) "(Ljava/lang/Object;S)V",                  (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setShort             },
+       { (char*) "setInt",               (char*) "(Ljava/lang/Object;I)V",                  (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setInt               },
+       { (char*) "setLong",              (char*) "(Ljava/lang/Object;J)V",                  (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setLong              },
+       { (char*) "setFloat",             (char*) "(Ljava/lang/Object;F)V",                  (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setFloat             },
+       { (char*) "setDouble",            (char*) "(Ljava/lang/Object;D)V",                  (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setDouble            },
+       { (char*) "getSignature",         (char*) "()Ljava/lang/String;",                    (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getSignature         },
+#if defined(ENABLE_ANNOTATIONS)
+       { (char*) "declaredAnnotations",  (char*) "()Ljava/util/Map;",                       (void*) (uintptr_t) &Java_java_lang_reflect_VMField_declaredAnnotations  },
+#endif
+};
+
+
+/* _Jv_java_lang_reflect_VMField_init ******************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_VMField_init(void)
+{
+       utf* u = utf_new_char("java/lang/reflect/VMField");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/gnuclasspath/java_lang_reflect_VMMethod.c b/src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.c
deleted file mode 100644 (file)
index 8b1853f..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
-/* src/native/vm/gnu/java_lang_reflect_VMMethod.c
-
-   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 <stdint.h>
-
-#if defined(ENABLE_ANNOTATIONS)
-#include "vm/vm.h"
-#endif
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-# include "native/include/java_util_Map.h"
-# include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/include/java_lang_reflect_Method.h"
-#include "native/include/java_lang_reflect_VMMethod.h"
-
-#include "native/vm/reflect.h"
-
-#include "vm/access.h"
-#include "vm/global.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/resolve.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/method.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getModifiersInternal",    "()I",                                                       (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getModifiersInternal    },
-       { "getReturnType",           "()Ljava/lang/Class;",                                       (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getReturnType           },
-       { "getParameterTypes",       "()[Ljava/lang/Class;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterTypes       },
-       { "getExceptionTypes",       "()[Ljava/lang/Class;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getExceptionTypes       },
-       { "invoke",                  "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_invoke                  },
-       { "getSignature",            "()Ljava/lang/String;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getSignature            },
-#if defined(ENABLE_ANNOTATIONS)
-       { "getDefaultValue",         "()Ljava/lang/Object;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getDefaultValue         },
-       { "declaredAnnotations",     "()Ljava/util/Map;",                                         (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_declaredAnnotations     },
-       { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;",                     (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterAnnotations },
-#endif
-};
-
-
-/* _Jv_java_lang_reflect_VMMethod_init *******************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_reflect_VMMethod_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/reflect/VMMethod");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getModifiersInternal
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMMethod_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       m = &(c->methods[slot]);
-
-       return m->flags;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getReturnType
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMMethod_getReturnType(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       classinfo  *result;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       m = &(c->methods[slot]);
-
-       result = method_returntype_get(m);
-
-       return LLNI_classinfo_wrap(result);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getParameterTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getParameterTypes(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       m = &(c->methods[slot]);
-
-       return method_get_parametertypearray(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getExceptionTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getExceptionTypes(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       m = &(c->methods[slot]);
-
-       return method_get_exceptionarray(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    invoke
- * Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_invoke(JNIEnv *env, java_lang_reflect_VMMethod *this, java_lang_Object *o, java_handle_objectarray_t *args)
-{
-       classinfo                *c;
-       int32_t                   slot;
-       java_lang_reflect_Method *rm;
-       int32_t                   override;
-       methodinfo               *m;
-       java_handle_t            *ro;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       LLNI_field_get_ref(this, m,     rm);
-       LLNI_field_get_val(rm,   flag,  override);
-
-       m = &(c->methods[slot]);
-
-       ro = reflect_method_invoke(m, (java_handle_t *) o, args, override);
-
-       return (java_lang_Object *) ro;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getSignature
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMMethod_getSignature(JNIEnv *env, java_lang_reflect_VMMethod* this)
-{
-       classinfo     *c;
-       methodinfo    *m;
-       java_handle_t *o;
-       int32_t        slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       m = &(c->methods[slot]);
-
-       if (m->signature == NULL)
-               return NULL;
-
-       o = javastring_new(m->signature);
-
-       /* in error case o is NULL */
-
-       return (java_lang_String *) o;
-}
-
-#if defined(ENABLE_ANNOTATIONS)
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getDefaultValue
- * Signature: ()Ljava/lang/Object;
- *
- * Parses the annotation default value and returnes it (boxed, if it's a primitive).
- */
-JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_getDefaultValue(JNIEnv *env, struct java_lang_reflect_VMMethod* this)
-{
-       java_handle_bytearray_t  *annotationDefault          = NULL; /* unparsed annotation default value                 */
-       static methodinfo        *m_parseAnnotationDefault   = NULL; /* parser method (will be chached, therefore static) */
-       utf                      *utf_parseAnnotationDefault = NULL; /* parser method name                                */
-       utf                      *utf_desc        = NULL;            /* parser method descriptor (signature)              */
-       sun_reflect_ConstantPool *constantPool    = NULL;            /* constant pool object to use                       */
-       java_lang_Class          *constantPoolOop = NULL;            /* methods declaring class                           */
-       classinfo                *referer         = NULL;            /* class, which calles the annotation parser         */
-                                                                    /* (for the parameter 'referer' of vm_call_method()) */
-       java_lang_reflect_Method* rm;
-       java_handle_t*            h;
-
-       if (this == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       constantPool = 
-               (sun_reflect_ConstantPool*)native_new_and_init(
-                       class_sun_reflect_ConstantPool);
-       
-       if (constantPool == NULL) {
-               /* out of memory */
-               return NULL;
-       }
-
-       LLNI_field_get_ref(this, clazz, constantPoolOop);
-       LLNI_field_set_ref(constantPool, constantPoolOop, (java_lang_Object*)constantPoolOop);
-
-       /* only resolve the parser method the first time */
-       if (m_parseAnnotationDefault == NULL) {
-               utf_parseAnnotationDefault = utf_new_char("parseAnnotationDefault");
-               utf_desc = utf_new_char(
-                       "(Ljava/lang/reflect/Method;[BLsun/reflect/ConstantPool;)"
-                       "Ljava/lang/Object;");
-
-               if (utf_parseAnnotationDefault == NULL || utf_desc == NULL) {
-                       /* out of memory */
-                       return NULL;
-               }
-
-               LLNI_class_get(this, referer);
-
-               m_parseAnnotationDefault = class_resolveclassmethod(
-                       class_sun_reflect_annotation_AnnotationParser,
-                       utf_parseAnnotationDefault,
-                       utf_desc,
-                       referer,
-                       true);
-
-               if (m_parseAnnotationDefault == NULL) {
-                       /* method not found */
-                       return NULL;
-               }
-       }
-
-       LLNI_field_get_ref(this, m,                 rm);
-       LLNI_field_get_ref(this, annotationDefault, annotationDefault);
-
-       h = vm_call_method(m_parseAnnotationDefault, NULL, rm, annotationDefault, constantPool);
-
-       return (java_lang_Object*) h;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    declaredAnnotations
- * Signature: ()Ljava/util/Map;
- *
- * Parses the annotations (if they aren't parsed yet) and stores them into
- * the declaredAnnotations map and return this map.
- */
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMMethod_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       java_util_Map           *declaredAnnotations = NULL; /* parsed annotations                                */
-       java_handle_bytearray_t *annotations         = NULL; /* unparsed annotations                              */
-       java_lang_Class         *declaringClass      = NULL; /* the constant pool of this class is used           */
-       classinfo               *referer             = NULL; /* class, which calles the annotation parser         */
-                                                            /* (for the parameter 'referer' of vm_call_method()) */
-
-       LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
-
-       /* are the annotations parsed yet? */
-       if (declaredAnnotations == NULL) {
-               LLNI_field_get_ref(this, annotations, annotations);
-               LLNI_field_get_ref(this, clazz, declaringClass);
-               LLNI_class_get(this, referer);
-
-               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
-
-               LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
-       }
-
-       return declaredAnnotations;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getParameterAnnotations
- * Signature: ()[[Ljava/lang/annotation/Annotation;
- *
- * Parses the parameter annotations and returns them in an 2 dimensional array.
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getParameterAnnotations(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations                    */
-       int32_t                  slot                 = -1;   /* slot of the method                                */
-       java_lang_Class         *declaringClass       = NULL; /* the constant pool of this class is used           */
-       classinfo               *referer              = NULL; /* class, which calles the annotation parser         */
-                                                             /* (for the parameter 'referer' of vm_call_method()) */
-
-       LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
-       LLNI_field_get_val(this, slot, slot);
-       LLNI_field_get_ref(this, clazz, declaringClass);
-       LLNI_class_get(this, referer);
-
-       return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, referer);
-}
-#endif
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.cpp b/src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.cpp
new file mode 100644 (file)
index 0000000..e4cbf89
--- /dev/null
@@ -0,0 +1,308 @@
+/* src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.cpp
+
+   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 <stdint.h>
+
+#if defined(ENABLE_ANNOTATIONS)
+#include "vm/vm.hpp"
+#endif
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_reflect_VMMethod.h"
+#endif
+
+#include "native/vm/reflection.hpp"
+
+#include "vm/access.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/initialize.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/method.hpp"
+#include "vm/resolve.hpp"
+#include "vm/string.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getModifiersInternal
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_reflect_VMMethod_getModifiersInternal(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMMethod rvmm(_this);
+       methodinfo* m = rvmm.get_method();
+       return m->flags;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getReturnType
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_java_lang_reflect_VMMethod_getReturnType(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMMethod rvmm(_this);
+       methodinfo* m = rvmm.get_method();
+       classinfo*  c = method_returntype_get(m);
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getParameterTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMMethod_getParameterTypes(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMMethod rvmm(_this);
+       methodinfo* m = rvmm.get_method();
+       java_handle_objectarray_t* oa = method_get_parametertypearray(m);
+       return (jobjectArray) oa;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getExceptionTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMMethod_getExceptionTypes(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMMethod rvmm(_this);
+       methodinfo* m = rvmm.get_method();
+       java_handle_objectarray_t* oa = method_get_exceptionarray(m);
+       return (jobjectArray) oa;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    invoke
+ * Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMMethod_invoke(JNIEnv *env, jobject _this, jobject o, jobjectArray args)
+{
+       java_lang_reflect_VMMethod jlrvmm(_this);
+       java_lang_reflect_Method jlrm(jlrvmm.get_m());
+
+       java_handle_t* result = jlrm.invoke((java_handle_t*) o, (java_handle_objectarray_t*) args);
+
+       return (jobject) result;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getSignature
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_java_lang_reflect_VMMethod_getSignature(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMMethod rvmm(_this);
+       methodinfo* m = rvmm.get_method();
+
+       if (m->signature == NULL)
+               return NULL;
+
+       java_handle_t* s = javastring_new(m->signature);
+
+       /* in error case o is NULL */
+
+       return (jstring) s;
+}
+
+
+#if defined(ENABLE_ANNOTATIONS)
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getDefaultValue
+ * Signature: ()Ljava/lang/Object;
+ *
+ * Parses the annotation default value and returnes it (boxed, if it's a primitive).
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMMethod_getDefaultValue(JNIEnv *env, jobject _this)
+{
+       static methodinfo        *m_parseAnnotationDefault   = NULL; /* parser method (will be chached, therefore static) */
+       utf                      *utf_parseAnnotationDefault = NULL; /* parser method name                                */
+       utf                      *utf_desc        = NULL;            /* parser method descriptor (signature)              */
+
+       if (_this == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       // TODO Use a constructor.
+       java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool);
+
+       if (h == NULL)
+               return NULL;
+
+       sun_reflect_ConstantPool cp(h);
+       
+       java_lang_reflect_VMMethod rvmm(_this);
+       classinfo* declaringClass = rvmm.get_clazz();
+       cp.set_constantPoolOop(declaringClass);
+
+       /* only resolve the parser method the first time */
+       if (m_parseAnnotationDefault == NULL) {
+               utf_parseAnnotationDefault = utf_new_char("parseAnnotationDefault");
+               utf_desc = utf_new_char(
+                       "(Ljava/lang/reflect/Method;[BLsun/reflect/ConstantPool;)"
+                       "Ljava/lang/Object;");
+
+               if (utf_parseAnnotationDefault == NULL || utf_desc == NULL) {
+                       /* out of memory */
+                       return NULL;
+               }
+
+               classinfo *referer = rvmm.get_Class();
+
+               m_parseAnnotationDefault = class_resolveclassmethod(
+                       class_sun_reflect_annotation_AnnotationParser,
+                       utf_parseAnnotationDefault,
+                       utf_desc,
+                       referer,
+                       true);
+
+               if (m_parseAnnotationDefault == NULL) {
+                       /* method not found */
+                       return NULL;
+               }
+       }
+
+       java_lang_reflect_Method rm(rvmm.get_m());
+       java_handle_bytearray_t* annotationDefault = rvmm.get_annotationDefault();
+
+       java_handle_t* result = vm_call_method(m_parseAnnotationDefault, NULL, rm.get_handle(), annotationDefault, cp.get_handle());
+
+       return (jobject) result;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    declaredAnnotations
+ * Signature: ()Ljava/util/Map;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMMethod_declaredAnnotations(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMMethod rvmm(_this);
+       java_handle_t* declaredAnnotations = rvmm.get_declaredAnnotations();
+
+       // Are the annotations parsed yet?
+       if (declaredAnnotations == NULL) {
+               java_handle_bytearray_t* annotations    = rvmm.get_annotations();
+               classinfo*               declaringClass = rvmm.get_clazz();
+               classinfo*               referer        = rvmm.get_Class();
+
+               declaredAnnotations = Reflection::get_declaredannotations(annotations, declaringClass, referer);
+
+               rvmm.set_declaredAnnotations(declaredAnnotations);
+       }
+
+       return (jobject) declaredAnnotations;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getParameterAnnotations
+ * Signature: ()[[Ljava/lang/annotation/Annotation;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMMethod_getParameterAnnotations(JNIEnv *env, jobject _this)
+{
+       java_lang_reflect_VMMethod rvmm(_this);
+       java_handle_bytearray_t* parameterAnnotations = rvmm.get_parameterAnnotations();
+       methodinfo* m = rvmm.get_method();
+       classinfo* referer = rvmm.get_Class();
+
+       java_handle_objectarray_t* oa = Reflection::get_parameterannotations(parameterAnnotations, m, referer);
+       return (jobjectArray) oa;
+}
+#endif
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "getModifiersInternal",    (char*) "()I",                                                       (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getModifiersInternal    },
+       { (char*) "getReturnType",           (char*) "()Ljava/lang/Class;",                                       (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getReturnType           },
+       { (char*) "getParameterTypes",       (char*) "()[Ljava/lang/Class;",                                      (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterTypes       },
+       { (char*) "getExceptionTypes",       (char*) "()[Ljava/lang/Class;",                                      (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getExceptionTypes       },
+       { (char*) "invoke",                  (char*) "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_invoke                  },
+       { (char*) "getSignature",            (char*) "()Ljava/lang/String;",                                      (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getSignature            },
+#if defined(ENABLE_ANNOTATIONS)
+       { (char*) "getDefaultValue",         (char*) "()Ljava/lang/Object;",                                      (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getDefaultValue         },
+       { (char*) "declaredAnnotations",     (char*) "()Ljava/util/Map;",                                         (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_declaredAnnotations     },
+       { (char*) "getParameterAnnotations", (char*) "()[[Ljava/lang/annotation/Annotation;",                     (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterAnnotations },
+#endif
+};
+
+
+/* _Jv_java_lang_reflect_VMMethod_init *****************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_VMMethod_init(void)
+{
+       utf* u = utf_new_char("java/lang/reflect/VMMethod");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
index b2138421ff66adbabdd081eb927781ee559f3c1b..29f894bfb482023edd55305837cffa0bc38d577f 100644 (file)
@@ -1,9 +1,7 @@
-/* src/native/vm/gnu/java_lang_reflect_VMProxy.c - java/lang/reflect/VMProxy
+/* src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c - java/lang/reflect/VMProxy
 
-   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.
 
 
 #include <stdlib.h>
 
-#include "native/jni.h"
-#include "native/native.h"
+#include "native/jni.hpp"
+#include "native/native.hpp"
 
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
-
-#include "native/include/java_lang_reflect_VMProxy.h"
+// FIXME
+//#include "native/include/java_lang_reflect_VMProxy.h"
 
 
 /* native methods implemented by this file ************************************/
@@ -55,16 +51,16 @@ static JNINativeMethod methods[] = {
 
 *******************************************************************************/
 
+#if 0
 void _Jv_java_lang_reflect_VMProxy_init(void)
 {
-#if 0
        utf *u;
 
        u = utf_new_char("java/lang/reflect/VMProxy");
 
        native_method_register(u, methods, NATIVE_METHODS_COUNT);
-#endif
 }
+#endif
 
 
 #if 0
diff --git a/src/native/vm/gnuclasspath/java_security_VMAccessController.c b/src/native/vm/gnuclasspath/java_security_VMAccessController.c
deleted file mode 100644 (file)
index 7e86b68..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* src/native/vm/gnu/java_security_VMAccessController.c
-
-   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
-
-   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 <stdint.h>
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_security_VMAccessController.h"
-
-#include "vm/global.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getStack", "()[[Ljava/lang/Object;", (void *) (uintptr_t) &Java_java_security_VMAccessController_getStack },
-};
-
-
-/* _Jv_java_security_VMAccessController_init ***********************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_security_VMAccessController_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/security/VMAccessController");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/security/VMAccessController
- * Method:    getStack
- * Signature: ()[[Ljava/lang/Object;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz)
-{
-       return stacktrace_get_stack();
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/gnuclasspath/java_security_VMAccessController.cpp b/src/native/vm/gnuclasspath/java_security_VMAccessController.cpp
new file mode 100644 (file)
index 0000000..8997719
--- /dev/null
@@ -0,0 +1,92 @@
+/* src/native/vm/gnuclasspath/java_security_VMAccessController.cpp
+
+   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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_security_VMAccessController.h"
+#endif
+
+#include "vm/global.h"
+#include "vm/utf8.h"
+
+#include "vm/jit/stacktrace.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/security/VMAccessController
+ * Method:    getStack
+ * Signature: ()[[Ljava/lang/Object;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz)
+{
+       return (jobjectArray) stacktrace_get_stack();
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "getStack", (char*) "()[[Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_security_VMAccessController_getStack },
+};
+
+
+/* _Jv_java_security_VMAccessController_init ***********************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_security_VMAccessController_init(void)
+{
+       utf* u = utf_new_char("java/security/VMAccessController");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.c b/src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.c
deleted file mode 100644 (file)
index 7105e65..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c
-
-   Copyright (C) 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
-
-   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 <stdint.h>
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_util_concurrent_atomic_AtomicLong.h"
-
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "VMSupportsCS8", "()Z", (void *) (intptr_t) &Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8 },
-};
-
-
-/* _Jv_java_util_concurrent_atomic_AtomicLong_init *****************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_util_concurrent_atomic_AtomicLong_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/util/concurrent/atomic/AtomicLong");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/util/concurrent/atomic/AtomicLong
- * Method:    VMSupportsCS8
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8(JNIEnv *env, jclass clazz)
-{
-       /* IMPLEMENT ME */
-
-       return 0;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.cpp b/src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.cpp
new file mode 100644 (file)
index 0000000..8ee6b74
--- /dev/null
@@ -0,0 +1,91 @@
+/* src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.cpp
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_util_concurrent_atomic_AtomicLong.h"
+#endif
+
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     java/util/concurrent/atomic/AtomicLong
+ * Method:    VMSupportsCS8
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8(JNIEnv *env, jclass clazz)
+{
+       // IMPLEMENT ME
+       return 0;
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "VMSupportsCS8", (char*) "()Z", (void*) (uintptr_t) &Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8 },
+};
+
+
+/* _Jv_java_util_concurrent_atomic_AtomicLong_init *****************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_util_concurrent_atomic_AtomicLong_init(void)
+{
+       utf* u = utf_new_char("java/util/concurrent/atomic/AtomicLong");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/native/vm/gnuclasspath/sun_reflect_ConstantPool.c b/src/native/vm/gnuclasspath/sun_reflect_ConstantPool.c
deleted file mode 100644 (file)
index 66b7ac4..0000000
+++ /dev/null
@@ -1,427 +0,0 @@
-/* src/native/vm/gnu/sun_reflect_ConstantPool.c
-
-   Copyright (C) 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, M. S. Panzenböck Institut f. Computersprachen - TU Wien
-
-   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.
-
-*/
-
-/*******************************************************************************
-
-   XXX: The Methods in this file are very redundant to thouse in
-        src/native/vm/sun/jvm.c Unless someone has a good idea how to cover
-        such redundancy I leave it how it is.
-
-  The ConstantPool class represents an interface to the constant pool of a
-  class and is used by the annotations parser (sun.reflect.annotation.
-  AnnotationParser) to get the values of the constants refered by the
-  annotations.
-
-*******************************************************************************/
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdint.h>
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/sun_reflect_ConstantPool.h"
-
-#include "native/vm/reflect.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/vm.h"
-#include "vm/exceptions.h"
-#include "vm/resolve.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/class.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getSize0",             "(Ljava/lang/Object;I)I",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getSize0             },
-       { "getClassAt0",          "(Ljava/lang/Object;I)Ljava/lang/Class;",          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getClassAt0          },
-       { "getClassAtIfLoaded0",  "(Ljava/lang/Object;I)Ljava/lang/Class;",          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getClassAtIfLoaded0  },
-       { "getMethodAt0",         "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMethodAt0         },
-       { "getMethodAtIfLoaded0", "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0 },
-       { "getFieldAt0",          "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;",  (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFieldAt0          },
-       { "getFieldAtIfLoaded0",  "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;",  (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0  },
-       { "getMemberRefInfoAt0",  "(Ljava/lang/Object;I)[Ljava/lang/String;",        (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMemberRefInfoAt0  },
-       { "getIntAt0",            "(Ljava/lang/Object;I)I",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getIntAt0            },
-       { "getLongAt0",           "(Ljava/lang/Object;I)J",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getLongAt0           },
-       { "getFloatAt0",          "(Ljava/lang/Object;I)F",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFloatAt0          },
-       { "getDoubleAt0",         "(Ljava/lang/Object;I)D",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getDoubleAt0         },
-       { "getStringAt0",         "(Ljava/lang/Object;I)Ljava/lang/String;",         (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getStringAt0         },
-       { "getUTF8At0",           "(Ljava/lang/Object;I)Ljava/lang/String;",         (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getUTF8At0           }, 
-};
-
-
-/* _Jv_sun_reflect_ConstantPool_init ******************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_sun_reflect_ConstantPool_init(void)
-{
-       native_method_register(utf_new_char("sun/reflect/ConstantPool"), methods, NATIVE_METHODS_COUNT);
-}
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getSize0
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getSize0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool)
-{
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-       return cls->cpcount;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getClassAt0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/Class;
- */
-JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClassAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_classref *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_classref*)class_getconstant(
-               cls, index, CONSTANT_Class);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       return LLNI_classinfo_wrap(resolve_classref_eager(ref));
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getClassAtIfLoaded0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/Class;
- */
-JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClassAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_classref *ref;
-       classinfo *c = NULL;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_classref*)class_getconstant(
-               cls, index, CONSTANT_Class);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-       
-       if (!resolve_classref(NULL,ref,resolveLazy,true,true,&c)) {
-               return NULL;
-       }
-
-       if (c == NULL || !(c->state & CLASS_LOADED)) {
-               return NULL;
-       }
-       
-       return LLNI_classinfo_wrap(c);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getMethodAt0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member;
- */
-JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool_getMethodAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_FMIref *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-       
-       ref = (constant_FMIref*)class_getconstant(
-               cls, index, CONSTANT_Methodref);
-       
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: is that right? or do I have to use resolve_method_*? */
-       return (jobject)reflect_method_new(ref->p.method);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getMethodAtIfLoaded0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member;
- */
-JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_FMIref *ref;
-       classinfo *c = NULL;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_FMIref*)class_getconstant(
-               cls, index, CONSTANT_Methodref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) {
-               return NULL;
-       }
-
-       if (c == NULL || !(c->state & CLASS_LOADED)) {
-               return NULL;
-       }
-
-       return (jobject)reflect_method_new(ref->p.method);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getFieldAt0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field;
- */
-JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_getFieldAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_FMIref *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_FMIref*)class_getconstant(
-               cls, index, CONSTANT_Fieldref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       return (jobject)reflect_field_new(ref->p.field);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getFieldAtIfLoaded0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field;
- */
-JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_FMIref *ref;
-       classinfo *c;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_FMIref*)class_getconstant(
-               cls, index, CONSTANT_Fieldref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) {
-               return NULL;
-       }
-
-       if (c == NULL || !(c->state & CLASS_LOADED)) {
-               return NULL;
-       }
-
-       return (jobject)reflect_field_new(ref->p.field);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getMemberRefInfoAt0
- * Signature: (Ljava/lang/Object;I)[Ljava/lang/String;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       log_println("Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(env=%p, jcpool=%p, index=%d): IMPLEMENT ME!", env, jcpool, index);
-       return NULL;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getIntAt0
- * Signature: (Ljava/lang/Object;I)I
- */
-JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getIntAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_integer *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_integer*)class_getconstant(
-               cls, index, CONSTANT_Integer);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getLongAt0
- * Signature: (Ljava/lang/Object;I)J
- */
-JNIEXPORT int64_t JNICALL Java_sun_reflect_ConstantPool_getLongAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_long *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_long*)class_getconstant(
-               cls, index, CONSTANT_Long);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getFloatAt0
- * Signature: (Ljava/lang/Object;I)F
- */
-JNIEXPORT float JNICALL Java_sun_reflect_ConstantPool_getFloatAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_float *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_float*)class_getconstant(
-               cls, index, CONSTANT_Float);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getDoubleAt0
- * Signature: (Ljava/lang/Object;I)D
- */
-JNIEXPORT double JNICALL Java_sun_reflect_ConstantPool_getDoubleAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_double *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_double*)class_getconstant(
-               cls, index, CONSTANT_Double);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getStringAt0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/String;
- */
-JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getStringAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       utf *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-       
-       ref = (utf*)class_getconstant(cls, index, CONSTANT_String);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: I hope literalstring_new is the right Function. */
-       return (java_lang_String*)literalstring_new(ref);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getUTF8At0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/String;
- */
-JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getUTF8At0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       utf *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: I hope literalstring_new is the right Function. */
-       return (java_lang_String*)literalstring_new(ref);
-}
-
-
-/*
- * 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/native/vm/gnuclasspath/sun_reflect_ConstantPool.cpp b/src/native/vm/gnuclasspath/sun_reflect_ConstantPool.cpp
new file mode 100644 (file)
index 0000000..b56ca42
--- /dev/null
@@ -0,0 +1,440 @@
+/* src/native/vm/gnuclasspath/sun_reflect_ConstantPool.cpp
+
+   Copyright (C) 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.
+
+*/
+
+/*******************************************************************************
+
+   XXX: The Methods in this file are very redundant to thouse in
+        src/native/vm/sun/jvm.c Unless someone has a good idea how to cover
+        such redundancy I leave it how it is.
+
+  The ConstantPool class represents an interface to the constant pool of a
+  class and is used by the annotations parser (sun.reflect.annotation.
+  AnnotationParser) to get the values of the constants refered by the
+  annotations.
+
+*******************************************************************************/
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "mm/memory.h"
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+// FIXME
+//#include "native/include/sun_reflect_ConstantPool.h"
+
+#include "native/vm/reflection.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/resolve.hpp"
+#include "vm/string.hpp"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getSize0
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT jint JNICALL Java_sun_reflect_ConstantPool_getSize0(JNIEnv *env, jobject _this, jobject jcpool)
+{
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+       return cls->cpcount;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getClassAt0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_sun_reflect_ConstantPool_getClassAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       constant_classref *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_classref*)class_getconstant(
+               cls, index, CONSTANT_Class);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       return (jclass) LLNI_classinfo_wrap(resolve_classref_eager(ref));
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getClassAtIfLoaded0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_sun_reflect_ConstantPool_getClassAtIfLoaded0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       constant_classref *ref;
+       classinfo *c = NULL;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_classref*)class_getconstant(
+               cls, index, CONSTANT_Class);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+       
+       if (!resolve_classref(NULL,ref,resolveLazy,true,true,&c)) {
+               return NULL;
+       }
+
+       if (c == NULL || !(c->state & CLASS_LOADED)) {
+               return NULL;
+       }
+       
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getMethodAt0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member;
+ */
+JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getMethodAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       constant_FMIref *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+       
+       ref = (constant_FMIref*)class_getconstant(
+               cls, index, CONSTANT_Methodref);
+       
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX: is that right? or do I have to use resolve_method_*? */
+       java_lang_reflect_Method jlrm(ref->p.method);
+
+       return (jobject) jlrm.get_handle();
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getMethodAtIfLoaded0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member;
+ */
+JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       constant_FMIref *ref;
+       classinfo *c = NULL;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_FMIref*)class_getconstant(
+               cls, index, CONSTANT_Methodref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) {
+               return NULL;
+       }
+
+       if (c == NULL || !(c->state & CLASS_LOADED)) {
+               return NULL;
+       }
+
+       java_lang_reflect_Method jlrm(ref->p.method);
+
+       return (jobject) jlrm.get_handle();
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getFieldAt0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field;
+ */
+JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getFieldAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       constant_FMIref *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_FMIref*) class_getconstant(cls, index, CONSTANT_Fieldref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       // Create a new java.lang.reflect.Field Java object.
+       java_lang_reflect_Field jlrf(ref->p.field);
+
+       return (jobject) jlrf.get_handle();
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getFieldAtIfLoaded0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field;
+ */
+JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       constant_FMIref *ref;
+       classinfo *c;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_FMIref*) class_getconstant(cls, index, CONSTANT_Fieldref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) {
+               return NULL;
+       }
+
+       if (c == NULL || !(c->state & CLASS_LOADED)) {
+               return NULL;
+       }
+
+       // Create a new java.lang.reflect.Field Java object.
+       java_lang_reflect_Field jlrf(ref->p.field);
+
+       return (jobject) jlrf.get_handle();
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getMemberRefInfoAt0
+ * Signature: (Ljava/lang/Object;I)[Ljava/lang/String;
+ */
+JNIEXPORT jobjectArray JNICALL Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       log_println("Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(env=%p, jcpool=%p, index=%d): IMPLEMENT ME!", env, jcpool, index);
+       return NULL;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getIntAt0
+ * Signature: (Ljava/lang/Object;I)I
+ */
+JNIEXPORT jint JNICALL Java_sun_reflect_ConstantPool_getIntAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       constant_integer *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_integer*) class_getconstant(cls, index, CONSTANT_Integer);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getLongAt0
+ * Signature: (Ljava/lang/Object;I)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_reflect_ConstantPool_getLongAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       constant_long *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_long*)class_getconstant(
+               cls, index, CONSTANT_Long);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getFloatAt0
+ * Signature: (Ljava/lang/Object;I)F
+ */
+JNIEXPORT float JNICALL Java_sun_reflect_ConstantPool_getFloatAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       constant_float *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_float*)class_getconstant(
+               cls, index, CONSTANT_Float);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getDoubleAt0
+ * Signature: (Ljava/lang/Object;I)D
+ */
+JNIEXPORT double JNICALL Java_sun_reflect_ConstantPool_getDoubleAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       constant_double *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_double*)class_getconstant(
+               cls, index, CONSTANT_Double);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getStringAt0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_sun_reflect_ConstantPool_getStringAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       utf *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+       
+       ref = (utf*)class_getconstant(cls, index, CONSTANT_String);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX: I hope literalstring_new is the right Function. */
+       return (jstring) literalstring_new(ref);
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getUTF8At0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_sun_reflect_ConstantPool_getUTF8At0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
+{
+       utf *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX: I hope literalstring_new is the right Function. */
+       return (jstring) literalstring_new(ref);
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "getSize0",             (char*) "(Ljava/lang/Object;I)I",                          (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getSize0             },
+       { (char*) "getClassAt0",          (char*) "(Ljava/lang/Object;I)Ljava/lang/Class;",          (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getClassAt0          },
+       { (char*) "getClassAtIfLoaded0",  (char*) "(Ljava/lang/Object;I)Ljava/lang/Class;",          (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getClassAtIfLoaded0  },
+       { (char*) "getMethodAt0",         (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMethodAt0         },
+       { (char*) "getMethodAtIfLoaded0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0 },
+       { (char*) "getFieldAt0",          (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;",  (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFieldAt0          },
+       { (char*) "getFieldAtIfLoaded0",  (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;",  (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0  },
+       { (char*) "getMemberRefInfoAt0",  (char*) "(Ljava/lang/Object;I)[Ljava/lang/String;",        (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMemberRefInfoAt0  },
+       { (char*) "getIntAt0",            (char*) "(Ljava/lang/Object;I)I",                          (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getIntAt0            },
+       { (char*) "getLongAt0",           (char*) "(Ljava/lang/Object;I)J",                          (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getLongAt0           },
+       { (char*) "getFloatAt0",          (char*) "(Ljava/lang/Object;I)F",                          (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFloatAt0          },
+       { (char*) "getDoubleAt0",         (char*) "(Ljava/lang/Object;I)D",                          (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getDoubleAt0         },
+       { (char*) "getStringAt0",         (char*) "(Ljava/lang/Object;I)Ljava/lang/String;",         (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getStringAt0         },
+       { (char*) "getUTF8At0",           (char*) "(Ljava/lang/Object;I)Ljava/lang/String;",         (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getUTF8At0           }, 
+};
+
+
+/* _Jv_sun_reflect_ConstantPool_init ******************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_sun_reflect_ConstantPool_init(void)
+{
+       utf* u = utf_new_char("sun/reflect/ConstantPool");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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/native/vm/nativevm.c b/src/native/vm/nativevm.c
deleted file mode 100644 (file)
index ed3806e..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-/* src/native/vm/nativevm.c - register the native functions
-
-   Copyright (C) 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 <stdint.h>
-
-#include "native/vm/nativevm.h"
-
-#include "vm/initialize.h"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-#include "vmcore/system.h"
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-# include "mm/memory.h"
-
-# include "native/native.h"
-
-# include "native/vm/openjdk/hpi.h"
-
-# include "vm/properties.h"
-# include "vm/vm.h"
-
-# include "vmcore/utf8.h"
-#endif
-
-
-/* nativevm_preinit ************************************************************
-
-   Pre-initialize the implementation specific native stuff.
-
-*******************************************************************************/
-
-void nativevm_preinit(void)
-{
-       /* Register native methods of all classes implemented. */
-
-#if defined(ENABLE_JAVASE)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       TRACESUBSYSTEMINITIALIZATION("nativevm_preinit");
-
-       _Jv_gnu_classpath_VMStackWalker_init();
-       _Jv_gnu_classpath_VMSystemProperties_init();
-       _Jv_gnu_java_lang_VMCPStringBuilder_init();
-       _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init();
-       _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init();
-       _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init();
-       _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init();
-       _Jv_java_lang_VMClass_init();
-       _Jv_java_lang_VMClassLoader_init();
-       _Jv_java_lang_VMObject_init();
-       _Jv_java_lang_VMRuntime_init();
-       _Jv_java_lang_VMSystem_init();
-       _Jv_java_lang_VMString_init();
-       _Jv_java_lang_VMThread_init();
-       _Jv_java_lang_VMThrowable_init();
-       _Jv_java_lang_management_VMManagementFactory_init();
-       _Jv_java_lang_reflect_VMConstructor_init();
-       _Jv_java_lang_reflect_VMField_init();
-       _Jv_java_lang_reflect_VMMethod_init();
-       _Jv_java_lang_reflect_VMProxy_init();
-       _Jv_java_security_VMAccessController_init();
-       _Jv_java_util_concurrent_atomic_AtomicLong_init();
-       _Jv_sun_misc_Unsafe_init();
-
-#if defined(ENABLE_ANNOTATIONS)
-       _Jv_sun_reflect_ConstantPool_init();
-#endif
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       char        *boot_library_path;
-       int          len;
-       char        *p;
-       utf         *u;
-       lt_dlhandle  handle;
-
-       TRACESUBSYSTEMINITIALIZATION("nativevm_preinit");
-
-       /* Load libjava.so */
-
-       boot_library_path = properties_get("sun.boot.library.path");
-
-       len =
-               system_strlen(boot_library_path) +
-               system_strlen("/libjava.so") +
-               system_strlen("0");
-
-       p = MNEW(char, len);
-
-       system_strcpy(p, boot_library_path);
-       system_strcat(p, "/libjava.so");
-
-       u = utf_new_char(p);
-
-       handle = native_library_open(u);
-
-       if (handle == NULL)
-               vm_abort("nativevm_init: failed to open libjava.so at: %s", p);
-
-       MFREE(p, char, len);
-
-       native_library_add(u, NULL, handle);
-
-       /* Initialize the HPI. */
-
-       hpi_initialize();
-
-       _Jv_sun_misc_Unsafe_init();
-
-# else
-#  error unknown classpath configuration
-# endif
-
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-
-       TRACESUBSYSTEMINITIALIZATION("nativevm_preinit");
-
-       _Jv_com_sun_cldc_io_ResourceInputStream_init();
-       _Jv_com_sun_cldc_io_j2me_socket_Protocol_init();
-       _Jv_com_sun_cldchi_io_ConsoleOutputStream_init();
-       _Jv_com_sun_cldchi_jvm_JVM_init();
-       _Jv_java_lang_Class_init();
-       _Jv_java_lang_Double_init();
-       _Jv_java_lang_Float_init();
-       _Jv_java_lang_Math_init();
-       _Jv_java_lang_Object_init();
-       _Jv_java_lang_Runtime_init();
-       _Jv_java_lang_String_init();
-       _Jv_java_lang_System_init();
-       _Jv_java_lang_Thread_init();
-       _Jv_java_lang_Throwable_init();
-
-#else
-# error unknown Java configuration
-#endif
-}
-
-
-/* nativevm_init ***************************************************************
-
-   Initialize the implementation specific native stuff.
-
-*******************************************************************************/
-
-void nativevm_init(void)
-{
-#if defined(ENABLE_JAVASE)
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       TRACESUBSYSTEMINITIALIZATION("nativevm_init");
-
-       /* nothing to do */
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       methodinfo *m;
-
-       TRACESUBSYSTEMINITIALIZATION("nativevm_init");
-
-       m = class_resolveclassmethod(class_java_lang_System,
-                                                                utf_new_char("initializeSystemClass"),
-                                                                utf_void__void,
-                                                                class_java_lang_Object,
-                                                                false);
-
-       if (m == NULL)
-               vm_abort("nativevm_init: Error resolving java.lang.System.initializeSystemClass()");
-
-       (void) vm_call_method(m, NULL);
-
-# else
-#  error unknown classpath configuration
-# endif
-
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-
-       TRACESUBSYSTEMINITIALIZATION("nativevm_init");
-
-       /* nothing to do */
-
-#else
-# error unknown Java configuration
-#endif
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/nativevm.cpp b/src/native/vm/nativevm.cpp
new file mode 100644 (file)
index 0000000..a61f619
--- /dev/null
@@ -0,0 +1,213 @@
+/* src/native/vm/nativevm.cpp - Register native VM interface functions.
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/vm/nativevm.hpp"
+
+#include "vm/class.hpp"
+#include "vm/initialize.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/os.hpp"
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+# include "mm/memory.h"
+
+# include "native/native.hpp"
+
+# include "native/vm/openjdk/hpi.hpp"
+
+# include "vm/globals.hpp"
+# include "vm/properties.hpp"
+# include "vm/utf8.h"
+# include "vm/vm.hpp"
+#endif
+
+
+/* nativevm_preinit ************************************************************
+
+   Pre-initialize the implementation specific native stuff.
+
+*******************************************************************************/
+
+void nativevm_preinit(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("nativevm_preinit");
+
+       /* Register native methods of all classes implemented. */
+
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       _Jv_gnu_classpath_VMStackWalker_init();
+       _Jv_gnu_classpath_VMSystemProperties_init();
+       _Jv_gnu_java_lang_VMCPStringBuilder_init();
+       _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init();
+       _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init();
+       _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init();
+       _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init();
+       _Jv_java_lang_VMClass_init();
+       _Jv_java_lang_VMClassLoader_init();
+       _Jv_java_lang_VMObject_init();
+       _Jv_java_lang_VMRuntime_init();
+       _Jv_java_lang_VMSystem_init();
+       _Jv_java_lang_VMString_init();
+       _Jv_java_lang_VMThread_init();
+       _Jv_java_lang_VMThrowable_init();
+       _Jv_java_lang_management_VMManagementFactory_init();
+       _Jv_java_lang_reflect_VMConstructor_init();
+       _Jv_java_lang_reflect_VMField_init();
+       _Jv_java_lang_reflect_VMMethod_init();
+       //_Jv_java_lang_reflect_VMProxy_init();
+       _Jv_java_security_VMAccessController_init();
+       _Jv_java_util_concurrent_atomic_AtomicLong_init();
+       _Jv_sun_misc_Unsafe_init();
+
+#if defined(ENABLE_ANNOTATIONS)
+       _Jv_sun_reflect_ConstantPool_init();
+#endif
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       // Load libjava.so
+       VM* vm = VM::get_current();
+       Properties& properties = vm->get_properties();
+       const char* boot_library_path = properties.get("sun.boot.library.path");
+
+       size_t len =
+               os::strlen(boot_library_path) +
+               os::strlen("/libjava.so") +
+               os::strlen("0");
+
+       char* p = MNEW(char, len);
+
+       os::strcpy(p, boot_library_path);
+       os::strcat(p, "/libjava.so");
+
+       utf* u = utf_new_char(p);
+
+       NativeLibrary nl(u);
+       void* handle = nl.open();
+
+       if (handle == NULL)
+               os::abort("nativevm_init: failed to open libjava.so at: %s", p);
+
+       MFREE(p, char, len);
+
+       NativeLibraries& nls = vm->get_nativelibraries();
+       nls.add(nl);
+
+       // Initialize the HPI.
+       HPI& hpi = vm->get_hpi();
+       hpi.initialize();
+
+       _Jv_sun_misc_Unsafe_init();
+
+# else
+#  error unknown classpath configuration
+# endif
+
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+
+       _Jv_com_sun_cldc_io_ResourceInputStream_init();
+       _Jv_com_sun_cldc_io_j2me_socket_Protocol_init();
+       _Jv_com_sun_cldchi_io_ConsoleOutputStream_init();
+       _Jv_com_sun_cldchi_jvm_JVM_init();
+       _Jv_java_lang_Class_init();
+       _Jv_java_lang_Double_init();
+       _Jv_java_lang_Float_init();
+       _Jv_java_lang_Math_init();
+       _Jv_java_lang_Object_init();
+       _Jv_java_lang_Runtime_init();
+       _Jv_java_lang_String_init();
+       _Jv_java_lang_System_init();
+       _Jv_java_lang_Thread_init();
+       _Jv_java_lang_Throwable_init();
+
+#else
+# error unknown Java configuration
+#endif
+}
+
+
+/* nativevm_init ***************************************************************
+
+   Initialize the implementation specific native stuff.
+
+*******************************************************************************/
+
+void nativevm_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("nativevm_init");
+
+#if defined(ENABLE_JAVASE)
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       // Nothing to do.
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       methodinfo* m = class_resolveclassmethod(class_java_lang_System,
+                                                                                        utf_new_char("initializeSystemClass"),
+                                                                                        utf_void__void,
+                                                                                        class_java_lang_Object,
+                                                                                        false);
+
+       if (m == NULL)
+               os::abort("nativevm_init: Error resolving java.lang.System.initializeSystemClass()");
+
+       (void) vm_call_method(m, NULL);
+
+# else
+#  error unknown classpath configuration
+# endif
+
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+
+       // Nothing to do.
+
+#else
+# error unknown Java configuration
+#endif
+}
+
+
+/*
+ * 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/native/vm/nativevm.h b/src/native/vm/nativevm.h
deleted file mode 100644 (file)
index db22ee6..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/* src/native/vm/nativevm.h - register the native functions
-
-   Copyright (C) 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 _NATIVEVM_H
-#define _NATIVEVM_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-
-/* function prototypes ********************************************************/
-
-void nativevm_preinit(void);
-void nativevm_init(void);
-
-#if defined(ENABLE_JAVASE)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-void _Jv_gnu_classpath_VMStackWalker_init();
-void _Jv_gnu_classpath_VMSystemProperties_init();
-void _Jv_gnu_java_lang_VMCPStringBuilder_init();
-void _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init();
-void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init();
-void _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init();
-void _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init();
-void _Jv_java_lang_VMClass_init();
-void _Jv_java_lang_VMClassLoader_init();
-void _Jv_java_lang_VMObject_init();
-void _Jv_java_lang_VMRuntime_init();
-void _Jv_java_lang_VMString_init();
-void _Jv_java_lang_VMSystem_init();
-void _Jv_java_lang_VMThread_init();
-void _Jv_java_lang_VMThrowable_init();
-void _Jv_java_lang_management_VMManagementFactory_init();
-void _Jv_java_lang_reflect_VMConstructor_init();
-void _Jv_java_lang_reflect_VMField_init();
-void _Jv_java_lang_reflect_VMMethod_init();
-void _Jv_java_lang_reflect_VMProxy_init();
-void _Jv_java_security_VMAccessController_init();
-void _Jv_java_util_concurrent_atomic_AtomicLong_init();
-void _Jv_sun_misc_Unsafe_init();
-
-#if defined(ENABLE_ANNOTATIONS)
-void _Jv_sun_reflect_ConstantPool_init();
-#endif
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-void _Jv_sun_misc_Unsafe_init();
-
-# else
-#  error unknown classpath configuration
-# endif
-
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-
-void _Jv_com_sun_cldc_io_ResourceInputStream_init();
-void _Jv_com_sun_cldc_io_j2me_socket_Protocol_init();
-void _Jv_com_sun_cldchi_io_ConsoleOutputStream_init();
-void _Jv_com_sun_cldchi_jvm_JVM_init();
-void _Jv_java_lang_Class_init();
-void _Jv_java_lang_Double_init();
-void _Jv_java_lang_Float_init();
-void _Jv_java_lang_Math_init();
-void _Jv_java_lang_Object_init();
-void _Jv_java_lang_Runtime_init();
-void _Jv_java_lang_String_init();
-void _Jv_java_lang_System_init();
-void _Jv_java_lang_Thread_init();
-void _Jv_java_lang_Throwable_init();
-
-#else
-# error unknown Java configuration
-#endif
-
-#endif /* _NATIVEVM_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:
- */
diff --git a/src/native/vm/nativevm.hpp b/src/native/vm/nativevm.hpp
new file mode 100644 (file)
index 0000000..826643f
--- /dev/null
@@ -0,0 +1,111 @@
+/* src/native/vm/nativevm.hpp - Register native VM interface functions.
+
+   Copyright (C) 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 _NATIVEVM_HPP
+#define _NATIVEVM_HPP
+
+#include "config.h"
+
+/* function prototypes ********************************************************/
+
+void nativevm_preinit(void);
+void nativevm_init(void);
+
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+void _Jv_gnu_classpath_VMStackWalker_init();
+void _Jv_gnu_classpath_VMSystemProperties_init();
+void _Jv_gnu_java_lang_VMCPStringBuilder_init();
+void _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init();
+void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init();
+void _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init();
+void _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init();
+void _Jv_java_lang_VMClass_init();
+void _Jv_java_lang_VMClassLoader_init();
+void _Jv_java_lang_VMObject_init();
+void _Jv_java_lang_VMRuntime_init();
+void _Jv_java_lang_VMString_init();
+void _Jv_java_lang_VMSystem_init();
+void _Jv_java_lang_VMThread_init();
+void _Jv_java_lang_VMThrowable_init();
+void _Jv_java_lang_management_VMManagementFactory_init();
+void _Jv_java_lang_reflect_VMConstructor_init();
+void _Jv_java_lang_reflect_VMField_init();
+void _Jv_java_lang_reflect_VMMethod_init();
+void _Jv_java_lang_reflect_VMProxy_init();
+void _Jv_java_security_VMAccessController_init();
+void _Jv_java_util_concurrent_atomic_AtomicLong_init();
+void _Jv_sun_misc_Unsafe_init();
+
+#if defined(ENABLE_ANNOTATIONS)
+void _Jv_sun_reflect_ConstantPool_init();
+#endif
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+void _Jv_sun_misc_Unsafe_init();
+
+# else
+#  error unknown classpath configuration
+# endif
+
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+
+void _Jv_com_sun_cldc_io_ResourceInputStream_init();
+void _Jv_com_sun_cldc_io_j2me_socket_Protocol_init();
+void _Jv_com_sun_cldchi_io_ConsoleOutputStream_init();
+void _Jv_com_sun_cldchi_jvm_JVM_init();
+void _Jv_java_lang_Class_init();
+void _Jv_java_lang_Double_init();
+void _Jv_java_lang_Float_init();
+void _Jv_java_lang_Math_init();
+void _Jv_java_lang_Object_init();
+void _Jv_java_lang_Runtime_init();
+void _Jv_java_lang_String_init();
+void _Jv_java_lang_System_init();
+void _Jv_java_lang_Thread_init();
+void _Jv_java_lang_Throwable_init();
+
+#else
+# error unknown Java configuration
+#endif
+
+#endif // _NATIVEVM_HPP
+
+
+/*
+ * 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 1f1753140d188af5bfe7fe41af157071becfe6c4..1e5bfd3bd19ff7cab27660b9c572ac09b8e0c953 100644 (file)
@@ -1,4 +1,4 @@
-## src/native/vm/sun/Makefile.am
+## src/native/vm/openjdk/Makefile.am
 ##
 ## Copyright (C) 2007, 2008
 ## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
@@ -29,9 +29,11 @@ noinst_LTLIBRARIES = \
        libnativevmcore.la
 
 libnativevmcore_la_SOURCES = \
-       hpi.c \
-       hpi.h \
-       jvm.c
+       hpi.cpp \
+       hpi.hpp \
+       jvm.cpp \
+       management.cpp \
+       management.hpp
 
 
 ## Local variables:
diff --git a/src/native/vm/openjdk/hpi.c b/src/native/vm/openjdk/hpi.c
deleted file mode 100644 (file)
index 87f0a7d..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/* src/native/vm/openjdk/hpi.c - HotSpot HPI interface functions
-
-   Copyright (C) 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"
-
-/* We include hpi_md.h before hpi.h as the latter includes the
-   former. */
-
-#include INCLUDE_HPI_MD_H
-#include INCLUDE_HPI_H
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "vm/properties.h"
-#include "vm/vm.h"
-
-#include "vmcore/options.h"
-#include "vmcore/system.h"
-#include "vmcore/utf8.h"
-
-
-/* VM callback functions ******************************************************/
-
-static vm_calls_t callbacks = {
-       /* TODO What should we use here? */
-/*   jio_fprintf, */
-/*   unimplemented_panic, */
-/*   unimplemented_monitorRegister, */
-       NULL,
-       NULL,
-       NULL,
-       
-       NULL, /* unused */
-       NULL, /* unused */
-       NULL  /* unused */
-};
-
-
-/* HPI interfaces *************************************************************/
-
-GetInterfaceFunc      hpi_get_interface = NULL;
-HPI_FileInterface    *hpi_file          = NULL;
-HPI_SocketInterface  *hpi_socket        = NULL;
-HPI_LibraryInterface *hpi_library       = NULL;
-HPI_SystemInterface  *hpi_system        = NULL;
-
-
-/* hpi_initialize **************************************************************
-
-   Initialize the Host Porting Interface (HPI).
-
-*******************************************************************************/
-
-void hpi_initialize(void)
-{
-       char        *boot_library_path;
-       int          len;
-       char        *p;
-       utf         *u;
-       lt_dlhandle  handle;
-       lt_ptr       dll_initialize;
-       int          result;
-    jint (JNICALL * DLL_Initialize)(GetInterfaceFunc *, void *);
-
-       TRACESUBSYSTEMINITIALIZATION("hpi_init");
-
-       /* Load libhpi.so */
-
-       boot_library_path = properties_get("sun.boot.library.path");
-
-       len =
-               system_strlen(boot_library_path) +
-               system_strlen("/native_threads/libhpi.so") +
-               system_strlen("0");
-
-       p = MNEW(char, len);
-
-       system_strcpy(p, boot_library_path);
-       system_strcat(p, "/native_threads/libhpi.so");
-
-       u = utf_new_char(p);
-
-    if (opt_TraceHPI)
-               log_println("hpi_init: Loading HPI %s ", p);
-
-       MFREE(p, char, len);
-
-       handle = native_library_open(u);
-
-       if (handle == NULL)
-               if (opt_TraceHPI)
-                       vm_abort("hpi_init: HPI open failed");
-
-       /* Resolve the DLL_Initialize function from the library. */
-
-       dll_initialize = lt_dlsym(handle, "DLL_Initialize");
-
-    DLL_Initialize = (jint (JNICALL *)(GetInterfaceFunc *, void *)) (intptr_t) dll_initialize;
-
-    if (opt_TraceHPI && DLL_Initialize == NULL)
-               log_println("hpi_init: HPI dlsym of DLL_Initialize failed: %s", lt_dlerror());
-
-    if (DLL_Initialize == NULL ||
-        (*DLL_Initialize)(&hpi_get_interface, &callbacks) < 0) {
-
-        if (opt_TraceHPI)
-                       vm_abort("hpi_init: HPI DLL_Initialize failed");
-    }
-
-       native_library_add(u, NULL, handle);
-
-    if (opt_TraceHPI)
-               log_println("hpi_init: HPI loaded successfully");
-
-       /* Resolve the interfaces. */
-       /* NOTE: The intptr_t-case is only to prevent the a compiler
-          warning with -O2: warning: dereferencing type-punned pointer
-          will break strict-aliasing rules */
-
-       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_file, "File", 1);
-
-       if (result != 0)
-               vm_abort("hpi_init: Can't find HPI_FileInterface");
-
-       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_library, "Library", 1);
-
-       if (result != 0)
-               vm_abort("hpi_init: Can't find HPI_LibraryInterface");
-
-       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_system, "System", 1);
-
-       if (result != 0)
-               vm_abort("hpi_init: Can't find HPI_SystemInterface");
-}
-
-
-/* hpi_initialize_socket_library ***********************************************
-
-   Initialize the library Host Porting Interface (HPI).
-
-*******************************************************************************/
-
-int hpi_initialize_socket_library(void)
-{
-       int result;
-
-       /* Resolve the socket library interface. */
-
-       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_socket, "Socket", 1);
-
-       if (result != 0) {
-               if (opt_TraceHPI)
-                       log_println("hpi_initialize_socket_library: Can't find HPI_SocketInterface");
-
-               return JNI_ERR;
-       }
-
-       return JNI_OK;
-}
-
-
-/*
- * 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/native/vm/openjdk/hpi.cpp b/src/native/vm/openjdk/hpi.cpp
new file mode 100644 (file)
index 0000000..ad6eec5
--- /dev/null
@@ -0,0 +1,180 @@
+/* src/native/vm/openjdk/hpi.cpp - HotSpot HPI interface functions
+
+   Copyright (C) 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 this one early.
+#include "native/vm/openjdk/hpi.hpp"
+
+#include "mm/memory.h"
+
+#include "native/native.hpp"
+
+#include "vm/options.h"
+#include "vm/os.hpp"
+#include "vm/properties.hpp"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+
+/* VM callback functions ******************************************************/
+
+static vm_calls_t callbacks = {
+       /* TODO What should we use here? */
+/*   jio_fprintf, */
+/*   unimplemented_panic, */
+/*   unimplemented_monitorRegister, */
+       NULL,
+       NULL,
+       NULL,
+       
+       NULL, /* unused */
+       NULL, /* unused */
+       NULL  /* unused */
+};
+
+
+/**
+ * Initialize the Host Porting Interface (HPI).
+ */
+HPI::HPI()
+{
+}
+
+void HPI::initialize() // REMOVEME
+{
+       TRACESUBSYSTEMINITIALIZATION("hpi_init");
+
+       // Load libhpi.so
+       VM* vm = VM::get_current();
+       Properties& properties = vm->get_properties();
+       const char* boot_library_path = properties.get("sun.boot.library.path");
+
+       size_t len =
+               os::strlen(boot_library_path) +
+               os::strlen("/native_threads/libhpi.so") +
+               os::strlen("0");
+
+       char* p = MNEW(char, len);
+
+       os::strcpy(p, boot_library_path);
+       os::strcat(p, "/native_threads/libhpi.so");
+
+       utf* u = utf_new_char(p);
+
+    if (opt_TraceHPI)
+               log_println("HPI::initialize: Loading HPI %s ", p);
+
+       MFREE(p, char, len);
+
+       NativeLibrary nl(u);
+       void* handle = nl.open();
+
+       if (handle == NULL)
+               if (opt_TraceHPI)
+                       os::abort("HPI::initialize: HPI open failed");
+
+       // Resolve the DLL_Initialize function from the library.
+       void* dll_initialize = os::dlsym(handle, "DLL_Initialize");
+
+    jint (JNICALL *DLL_Initialize)(GetInterfaceFunc*, void*);
+    DLL_Initialize = (jint (JNICALL *)(GetInterfaceFunc*, void*)) (uintptr_t) dll_initialize;
+
+    if (opt_TraceHPI && DLL_Initialize == NULL)
+               log_println("hpi_init: HPI dlsym of DLL_Initialize failed: %s", os::dlerror());
+
+    if (DLL_Initialize == NULL || (*DLL_Initialize)(&_get_interface, &callbacks) < 0) {
+        if (opt_TraceHPI)
+                       vm_abort("hpi_init: HPI DLL_Initialize failed");
+    }
+
+       NativeLibraries& nls = vm->get_nativelibraries();
+       nls.add(nl);
+
+    if (opt_TraceHPI)
+               log_println("HPI::initialize: HPI loaded successfully");
+
+       // Resolve the interfaces.
+       /* NOTE: The intptr_t-case is only to prevent the a compiler
+          warning with -O2: warning: dereferencing type-punned pointer
+          will break strict-aliasing rules */
+
+       int result;
+
+       result = (*_get_interface)((void**) (uintptr_t) &_file, "File", 1);
+
+       if (result != 0)
+               os::abort("hpi_init: Can't find HPI_FileInterface");
+
+       result = (*_get_interface)((void**) (uintptr_t) &_library, "Library", 1);
+
+       if (result != 0)
+               os::abort("hpi_init: Can't find HPI_LibraryInterface");
+
+       result = (*_get_interface)((void**) (uintptr_t) &_system, "System", 1);
+
+       if (result != 0)
+               os::abort("hpi_init: Can't find HPI_SystemInterface");
+}
+
+
+/**
+ * Initialize the Host Porting Interface (HPI) socket library.
+ */
+int HPI::initialize_socket_library()
+{
+       // Resolve the socket library interface.
+       int result = (*_get_interface)((void**) (uintptr_t) &_socket, "Socket", 1);
+
+       if (result != 0) {
+               if (opt_TraceHPI)
+                       log_println("HPI::initialize_socket_library: Can't find HPI_SocketInterface");
+
+               return JNI_ERR;
+       }
+
+       return JNI_OK;
+}
+
+
+// Legacy C interface.
+extern "C" {
+       void HPI_initialize() { VM::get_current()->get_hpi().initialize(); }
+}
+
+
+/*
+ * 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/native/vm/openjdk/hpi.h b/src/native/vm/openjdk/hpi.h
deleted file mode 100644 (file)
index 03880e6..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* src/native/vm/openjdk/hpi.h - HotSpot HPI interface functions
-
-   Copyright (C) 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 _HPI_H
-#define _HPI_H
-
-#include "config.h"
-
-/* HPI headers *****************************************************************
-
-   We include hpi_md.h before hpi.h as the latter includes the former.
-
-   These includes define:
-
-   #define _JAVASOFT_HPI_MD_H_
-   #define _JAVASOFT_HPI_H_
-
-*******************************************************************************/
-
-#include INCLUDE_HPI_MD_H
-#include INCLUDE_HPI_H
-
-
-/* HPI interfaces *************************************************************/
-
-extern HPI_FileInterface    *hpi_file;
-extern HPI_SocketInterface  *hpi_socket;
-extern HPI_LibraryInterface *hpi_library;
-extern HPI_SystemInterface  *hpi_system;
-
-
-/* functions ******************************************************************/
-
-void hpi_initialize(void);
-int  hpi_initialize_socket_library(void);
-
-#endif /* _HPI_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/native/vm/openjdk/hpi.hpp b/src/native/vm/openjdk/hpi.hpp
new file mode 100644 (file)
index 0000000..3b09bf2
--- /dev/null
@@ -0,0 +1,97 @@
+/* src/native/vm/openjdk/hpi.hpp - HotSpot HPI interface functions
+
+   Copyright (C) 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 _HPI_HPP
+#define _HPI_HPP
+
+#include "config.h"
+
+/* HPI headers *****************************************************************
+
+   We include hpi_md.h before hpi.h as the latter includes the former.
+
+   These includes define:
+
+   #define _JAVASOFT_HPI_MD_H_
+   #define _JAVASOFT_HPI_H_
+
+*******************************************************************************/
+
+// Include our JNI header before the HPI headers, because the HPI
+// headers include jni.h and we want to override the typedefs in
+// jni.h.
+#include "native/jni.hpp"
+
+#include INCLUDE_HPI_MD_H
+#include INCLUDE_HPI_H
+
+
+#ifdef __cplusplus
+
+/**
+ * Host Porting Interface (HPI).
+ */
+class HPI {
+private:
+       GetInterfaceFunc      _get_interface;
+       HPI_FileInterface*    _file;
+       HPI_SocketInterface*  _socket;
+       HPI_LibraryInterface* _library;
+       HPI_SystemInterface*  _system;
+
+public:        
+       HPI();
+
+       inline HPI_FileInterface&    get_file   () const { return *_file; }
+       inline HPI_SocketInterface&  get_socket () const { return *_socket; }
+       inline HPI_LibraryInterface& get_library() const { return *_library; }
+       inline HPI_SystemInterface&  get_system () const { return *_system; }
+       
+       void initialize(); // REMOVEME
+       int initialize_socket_library();
+};
+
+#else
+
+void HPI_initialize();
+
+#endif
+
+#endif // _HPI_HPP
+
+
+/*
+ * 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/native/vm/openjdk/jvm.c b/src/native/vm/openjdk/jvm.c
deleted file mode 100644 (file)
index 4723b5c..0000000
+++ /dev/null
@@ -1,3738 +0,0 @@
-/* src/native/vm/openjdk/jvm.c - HotSpot JVM interface functions
-
-   Copyright (C) 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 <errno.h>
-#include <ltdl.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#if defined(HAVE_SYS_IOCTL_H)
-#define BSD_COMP /* Get FIONREAD on Solaris2 */
-#include <sys/ioctl.h>
-#endif
-
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_AssertionStatusDirectives.h"
-#include "native/include/java_lang_String.h"            /* required by j.l.CL */
-#include "native/include/java_nio_ByteBuffer.h"         /* required by j.l.CL */
-#include "native/include/java_lang_ClassLoader.h"        /* required by j.l.C */
-#include "native/include/java_lang_StackTraceElement.h"
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_security_ProtectionDomain.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-#include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/vm/reflect.h"
-
-#include "native/vm/openjdk/hpi.h"
-
-#include "threads/lock-common.h"
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-#include "toolbox/list.h"
-
-#include "vm/array.h"
-
-#if defined(ENABLE_ASSERTION)
-#include "vm/assertion.h"
-#endif
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/package.h"
-#include "vm/primitive.h"
-#include "vm/properties.h"
-#include "vm/resolve.h"
-#include "vm/signallocal.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/classcache.h"
-#include "vmcore/options.h"
-#include "vmcore/system.h"
-
-
-/* debugging macros ***********************************************************/
-
-#if !defined(NDEBUG)
-
-# define TRACEJVMCALLS(x)                                                                              \
-    do {                                                                                                               \
-        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
-            log_println x;                                                                             \
-        }                                                                                                              \
-    } while (0)
-
-# define TRACEJVMCALLSENTER(x)                                                                 \
-    do {                                                                                                               \
-        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
-                       log_start();                                                                            \
-            log_print x;                                                                               \
-        }                                                                                                              \
-    } while (0)
-
-# define TRACEJVMCALLSEXIT(x)                                                                  \
-    do {                                                                                                               \
-        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
-                       log_print x;                                                                            \
-                       log_finish();                                                                           \
-        }                                                                                                              \
-    } while (0)
-
-# define TRACEJVMCALLSVERBOSE(x)                               \
-    do {                                                                               \
-        if (opt_TraceJVMCallsVerbose) {                        \
-            log_println x;                                             \
-        }                                                                              \
-    } while (0)
-
-# define PRINTJVMWARNINGS(x)
-/*     do { \ */
-/*         if (opt_PrintJVMWarnings) { \ */
-/*             log_println x; \ */
-/*         } \ */
-/*     } while (0) */
-
-#else
-
-# define TRACEJVMCALLS(x)
-# define TRACEJVMCALLSENTER(x)
-# define TRACEJVMCALLSEXIT(x)
-# define TRACEJVMCALLSVERBOSE(x)
-# define PRINTJVMWARNINGS(x)
-
-#endif
-
-
-typedef struct {
-    /* Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx */
-    unsigned int jvm_version;   /* Consists of major, minor, micro (n.n.n) */
-                                /* and build number (xx) */
-    unsigned int update_version : 8;         /* Update release version (uu) */
-    unsigned int special_update_version : 8; /* Special update release version (c) */
-    unsigned int reserved1 : 16; 
-    unsigned int reserved2; 
-
-    /* The following bits represents JVM supports that JDK has dependency on.
-     * JDK can use these bits to determine which JVM version
-     * and support it has to maintain runtime compatibility.
-     *
-     * When a new bit is added in a minor or update release, make sure
-     * the new bit is also added in the main/baseline.
-     */
-    unsigned int is_attachable : 1;
-    unsigned int : 31;
-    unsigned int : 32;
-    unsigned int : 32;
-} jvm_version_info;
-
-
-/*
- * A structure used to a capture exception table entry in a Java method.
- */
-typedef struct {
-    jint start_pc;
-    jint end_pc;
-    jint handler_pc;
-    jint catchType;
-} JVM_ExceptionTableEntryType;
-
-
-int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
-{
-       if ((intptr_t) count <= 0)
-               return -1;
-
-       return vsnprintf(str, count, fmt, args);
-}
-
-
-int jio_snprintf(char *str, size_t count, const char *fmt, ...)
-{
-       va_list ap;
-       int     len;
-
-       va_start(ap, fmt);
-       len = jio_vsnprintf(str, count, fmt, ap);
-       va_end(ap);
-
-       return len;
-}
-
-
-int jio_fprintf(FILE* f, const char *fmt, ...)
-{
-       log_println("jio_fprintf: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-int jio_vfprintf(FILE* f, const char *fmt, va_list args)
-{
-       log_println("jio_vfprintf: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-int jio_printf(const char *fmt, ...)
-{
-       log_println("jio_printf: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetInterfaceVersion */
-
-jint JVM_GetInterfaceVersion()
-{
-       /* This is defined in hotspot/src/share/vm/prims/jvm.h */
-
-#define JVM_INTERFACE_VERSION 4
-
-       return JVM_INTERFACE_VERSION;
-}
-
-
-/* JVM_CurrentTimeMillis */
-
-jlong JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored)
-{
-       TRACEJVMCALLS(("JVM_CurrentTimeMillis(env=%p, ignored=%p)", env, ignored));
-
-       return (jlong) builtin_currenttimemillis();
-}
-
-
-/* JVM_NanoTime */
-
-jlong JVM_NanoTime(JNIEnv *env, jclass ignored)
-{
-       TRACEJVMCALLS(("JVM_NanoTime(env=%p, ignored=%p)", env, ignored));
-
-       return (jlong) builtin_nanotime();
-}
-
-
-/* JVM_ArrayCopy */
-
-void JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length)
-{
-       java_handle_t *s;
-       java_handle_t *d;
-
-       s = (java_handle_t *) src;
-       d = (java_handle_t *) dst;
-
-       TRACEJVMCALLSVERBOSE(("JVM_ArrayCopy(env=%p, ignored=%p, src=%p, src_pos=%d, dst=%p, dst_pos=%d, length=%d)", env, ignored, src, src_pos, dst, dst_pos, length));
-
-       builtin_arraycopy(s, src_pos, d, dst_pos, length);
-}
-
-
-/* JVM_InitProperties */
-
-jobject JVM_InitProperties(JNIEnv *env, jobject properties)
-{
-       java_handle_t *h;
-       char           buf[256];
-
-       TRACEJVMCALLS(("JVM_InitProperties(env=%p, properties=%p)", env, properties));
-
-       h = (java_handle_t *) properties;
-
-       /* Convert the -XX:MaxDirectMemorySize= command line flag to the
-          sun.nio.MaxDirectMemorySize property.  Do this after setting
-          user properties to prevent people from setting the value with a
-          -D option, as requested. */
-
-       jio_snprintf(buf, sizeof(buf), PRINTF_FORMAT_INT64_T, opt_MaxDirectMemorySize);
-       properties_add("sun.nio.MaxDirectMemorySize", buf);
-
-       /* Add all properties. */
-
-       properties_system_add_all(h);
-
-       return properties;
-}
-
-
-/* JVM_Exit */
-
-void JVM_Exit(jint code)
-{
-       log_println("JVM_Exit: IMPLEMENT ME!");
-}
-
-
-/* JVM_Halt */
-
-void JVM_Halt(jint code)
-{
-       TRACEJVMCALLS(("JVM_Halt(code=%d)", code));
-
-/*     vm_exit(code); */
-       vm_shutdown(code);
-}
-
-
-/* JVM_OnExit(void (*func)) */
-
-void JVM_OnExit(void (*func)(void))
-{
-       log_println("JVM_OnExit(void (*func): IMPLEMENT ME!");
-}
-
-
-/* JVM_GC */
-
-void JVM_GC(void)
-{
-       TRACEJVMCALLS(("JVM_GC()"));
-
-       gc_call();
-}
-
-
-/* JVM_MaxObjectInspectionAge */
-
-jlong JVM_MaxObjectInspectionAge(void)
-{
-       log_println("JVM_MaxObjectInspectionAge: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_TraceInstructions */
-
-void JVM_TraceInstructions(jboolean on)
-{
-       log_println("JVM_TraceInstructions: IMPLEMENT ME!");
-}
-
-
-/* JVM_TraceMethodCalls */
-
-void JVM_TraceMethodCalls(jboolean on)
-{
-       log_println("JVM_TraceMethodCalls: IMPLEMENT ME!");
-}
-
-
-/* JVM_TotalMemory */
-
-jlong JVM_TotalMemory(void)
-{
-       TRACEJVMCALLS(("JVM_TotalMemory()"));
-
-       return gc_get_heap_size();
-}
-
-
-/* JVM_FreeMemory */
-
-jlong JVM_FreeMemory(void)
-{
-       TRACEJVMCALLS(("JVM_FreeMemory()"));
-
-       return gc_get_free_bytes();
-}
-
-
-/* JVM_MaxMemory */
-
-jlong JVM_MaxMemory(void)
-{
-       TRACEJVMCALLS(("JVM_MaxMemory()"));
-
-       return gc_get_max_heap_size();
-}
-
-
-/* JVM_ActiveProcessorCount */
-
-jint JVM_ActiveProcessorCount(void)
-{
-       TRACEJVMCALLS(("JVM_ActiveProcessorCount()"));
-
-       return system_processors_online();
-}
-
-
-/* JVM_FillInStackTrace */
-
-void JVM_FillInStackTrace(JNIEnv *env, jobject receiver)
-{
-       java_lang_Throwable     *o;
-       java_handle_bytearray_t *ba;
-
-       TRACEJVMCALLS(("JVM_FillInStackTrace(env=%p, receiver=%p)", env, receiver));
-
-       o = (java_lang_Throwable *) receiver;
-
-       ba = stacktrace_get_current();
-
-       if (ba == NULL)
-               return;
-
-       LLNI_field_set_ref(o, backtrace, (java_lang_Object *) ba);
-}
-
-
-/* JVM_PrintStackTrace */
-
-void JVM_PrintStackTrace(JNIEnv *env, jobject receiver, jobject printable)
-{
-       log_println("JVM_PrintStackTrace: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetStackTraceDepth */
-
-jint JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable)
-{
-       java_lang_Throwable     *to;
-       java_lang_Object        *o;
-       java_handle_bytearray_t *ba;
-       stacktrace_t            *st;
-       int32_t                  depth;
-
-       TRACEJVMCALLS(("JVM_GetStackTraceDepth(env=%p, throwable=%p)", env, throwable));
-
-       if (throwable == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       to = (java_lang_Throwable *) throwable;
-
-       LLNI_field_get_ref(to, backtrace, o);
-
-       ba = (java_handle_bytearray_t *) o;
-
-       if (ba == NULL)
-               return 0;
-
-       /* We need a critical section here as the stacktrace structure is
-          mapped onto a Java byte-array. */
-
-       LLNI_CRITICAL_START;
-
-       st = (stacktrace_t *) LLNI_array_data(ba);
-
-       depth = st->length;
-
-       LLNI_CRITICAL_END;
-
-       return depth;
-}
-
-
-/* JVM_GetStackTraceElement */
-
-jobject JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index)
-{
-       java_lang_Throwable         *to;
-       java_lang_Object            *o;
-       java_handle_bytearray_t     *ba;
-       stacktrace_t                *st;
-       stacktrace_entry_t          *ste;
-       codeinfo                    *code;
-       methodinfo                  *m;
-       classinfo                   *c;
-       java_lang_StackTraceElement *steo;
-       java_handle_t*               declaringclass;
-       java_lang_String            *filename;
-       int32_t                      linenumber;
-
-       TRACEJVMCALLS(("JVM_GetStackTraceElement(env=%p, throwable=%p, index=%d)", env, throwable, index));
-
-       to = (java_lang_Throwable *) throwable;
-
-       LLNI_field_get_ref(to, backtrace, o);
-
-       ba = (java_handle_bytearray_t *) o;
-
-       /* FIXME critical section */
-
-       st = (stacktrace_t *) LLNI_array_data(ba);
-
-       if ((index < 0) || (index >= st->length)) {
-               /* XXX This should be an IndexOutOfBoundsException (check this
-                  again). */
-
-               exceptions_throw_arrayindexoutofboundsexception();
-               return NULL;
-       }
-
-       /* Get the stacktrace entry. */
-
-       ste = &(st->entries[index]);
-
-       /* Get the codeinfo, methodinfo and classinfo. */
-
-       code = ste->code;
-       m    = code->m;
-       c    = m->clazz;
-
-       /* allocate a new StackTraceElement */
-
-       steo = (java_lang_StackTraceElement *)
-               builtin_new(class_java_lang_StackTraceElement);
-
-       if (steo == NULL)
-               return NULL;
-
-       /* get filename */
-
-       if (!(m->flags & ACC_NATIVE)) {
-               if (c->sourcefile != NULL)
-                       filename = (java_lang_String *) javastring_new(c->sourcefile);
-               else
-                       filename = NULL;
-       }
-       else
-               filename = NULL;
-
-       /* get line number */
-
-       if (m->flags & ACC_NATIVE) {
-               linenumber = -2;
-       }
-       else {
-               /* FIXME The linenumbertable_linenumber_for_pc could change
-                  the methodinfo pointer when hitting an inlined method. */
-
-               linenumber = linenumbertable_linenumber_for_pc(&m, code, ste->pc);
-               linenumber = (linenumber == 0) ? -1 : linenumber;
-       }
-
-       /* get declaring class name */
-
-       declaringclass = class_get_classname(c);
-
-       /* fill the java.lang.StackTraceElement element */
-
-       /* FIXME critical section */
-
-       steo->declaringClass = (java_lang_String*) declaringclass;
-       steo->methodName     = (java_lang_String*) javastring_new(m->name);
-       steo->fileName       = filename;
-       steo->lineNumber     = linenumber;
-
-       return (jobject) steo;
-}
-
-
-/* JVM_IHashCode */
-
-jint JVM_IHashCode(JNIEnv* env, jobject handle)
-{
-       TRACEJVMCALLS(("JVM_IHashCode(env=%p, jobject=%p)", env, handle));
-
-       return (jint) ((ptrint) handle);
-}
-
-
-/* JVM_MonitorWait */
-
-void JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *o;
-#endif
-
-       TRACEJVMCALLS(("JVM_MonitorWait(env=%p, handle=%p, ms=%ld)", env, handle, ms));
-    if (ms < 0) {
-/*             exceptions_throw_illegalargumentexception("argument out of range"); */
-               exceptions_throw_illegalargumentexception();
-               return;
-       }
-
-#if defined(ENABLE_THREADS)
-       o = (java_handle_t *) handle;
-
-       lock_wait_for_object(o, ms, 0);
-#endif
-}
-
-
-/* JVM_MonitorNotify */
-
-void JVM_MonitorNotify(JNIEnv* env, jobject handle)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *o;
-#endif
-
-       TRACEJVMCALLS(("JVM_MonitorNotify(env=%p, handle=%p)", env, handle));
-
-#if defined(ENABLE_THREADS)
-       o = (java_handle_t *) handle;
-
-       lock_notify_object(o);
-#endif
-}
-
-
-/* JVM_MonitorNotifyAll */
-
-void JVM_MonitorNotifyAll(JNIEnv* env, jobject handle)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *o;
-#endif
-
-       TRACEJVMCALLS(("JVM_MonitorNotifyAll(env=%p, handle=%p)", env, handle));
-
-#if defined(ENABLE_THREADS)
-       o = (java_handle_t *) handle;
-
-       lock_notify_all_object(o);
-#endif
-}
-
-
-/* JVM_Clone */
-
-jobject JVM_Clone(JNIEnv* env, jobject handle)
-{
-       TRACEJVMCALLS(("JVM_Clone(env=%p, handle=%p)", env, handle));
-
-       return (jobject) builtin_clone(env, (java_handle_t *) handle);
-}
-
-
-/* JVM_InitializeCompiler  */
-
-void JVM_InitializeCompiler (JNIEnv *env, jclass compCls)
-{
-       log_println("JVM_InitializeCompiler : IMPLEMENT ME!");
-}
-
-
-/* JVM_IsSilentCompiler */
-
-jboolean JVM_IsSilentCompiler(JNIEnv *env, jclass compCls)
-{
-       log_println("JVM_IsSilentCompiler: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_CompileClass */
-
-jboolean JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls)
-{
-       log_println("JVM_CompileClass: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_CompileClasses */
-
-jboolean JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname)
-{
-       log_println("JVM_CompileClasses: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_CompilerCommand */
-
-jobject JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg)
-{
-       log_println("JVM_CompilerCommand: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_EnableCompiler */
-
-void JVM_EnableCompiler(JNIEnv *env, jclass compCls)
-{
-       TRACEJVMCALLS(("JVM_EnableCompiler(env=%p, compCls=%p)", env, compCls));
-       PRINTJVMWARNINGS(("JVM_EnableCompiler not supported"));
-}
-
-
-/* JVM_DisableCompiler */
-
-void JVM_DisableCompiler(JNIEnv *env, jclass compCls)
-{
-       TRACEJVMCALLS(("JVM_DisableCompiler(env=%p, compCls=%p)", env, compCls));
-       PRINTJVMWARNINGS(("JVM_DisableCompiler not supported"));
-}
-
-
-/* JVM_GetLastErrorString */
-
-jint JVM_GetLastErrorString(char *buf, int len)
-{
-       TRACEJVMCALLS(("JVM_GetLastErrorString(buf=%p, len=%d", buf, len));
-
-       return hpi_system->GetLastErrorString(buf, len);
-}
-
-
-/* JVM_NativePath */
-
-char *JVM_NativePath(char *path)
-{
-       TRACEJVMCALLS(("JVM_NativePath(path=%s)", path));
-
-       return hpi_file->NativePath(path);
-}
-
-
-/* JVM_GetCallerClass */
-
-jclass JVM_GetCallerClass(JNIEnv* env, int depth)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_GetCallerClass(env=%p, depth=%d)", env, depth));
-
-       c = stacktrace_get_caller_class(depth);
-
-       return (jclass) c;
-}
-
-
-/* JVM_FindPrimitiveClass */
-
-jclass JVM_FindPrimitiveClass(JNIEnv* env, const char* s)
-{
-       classinfo *c;
-       utf       *u;
-
-       TRACEJVMCALLS(("JVM_FindPrimitiveClass(env=%p, s=%s)", env, s));
-
-       u = utf_new_char(s);
-       c = primitive_class_get_by_name(u);
-
-       return (jclass) LLNI_classinfo_wrap(c);
-}
-
-
-/* JVM_ResolveClass */
-
-void JVM_ResolveClass(JNIEnv* env, jclass cls)
-{
-       TRACEJVMCALLS(("JVM_ResolveClass(env=%p, cls=%p)", env, cls));
-       PRINTJVMWARNINGS(("JVM_ResolveClass not implemented"));
-}
-
-
-/* JVM_FindClassFromClassLoader */
-
-jclass JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, jboolean init, jobject loader, jboolean throwError)
-{
-       classinfo     *c;
-       utf           *u;
-       classloader_t *cl;
-
-       TRACEJVMCALLS(("JVM_FindClassFromClassLoader(name=%s, init=%d, loader=%p, throwError=%d)", name, init, loader, throwError));
-
-       /* As of now, OpenJDK does not call this function with throwError
-          is true. */
-
-       assert(throwError == false);
-
-       u  = utf_new_char(name);
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       c = load_class_from_classloader(u, cl);
-
-       if (c == NULL)
-               return NULL;
-
-       if (init)
-               if (!(c->state & CLASS_INITIALIZED))
-                       if (!initialize_class(c))
-                               return NULL;
-
-       return (jclass) LLNI_classinfo_wrap(c);
-}
-
-
-/* JVM_FindClassFromClass */
-
-jclass JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, jclass from)
-{
-       log_println("JVM_FindClassFromClass: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_DefineClass */
-
-jclass JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd)
-{
-       log_println("JVM_DefineClass: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_DefineClassWithSource */
-
-jclass JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source)
-{
-       classinfo     *c;
-       utf           *u;
-       classloader_t *cl;
-
-       TRACEJVMCALLS(("JVM_DefineClassWithSource(env=%p, name=%s, loader=%p, buf=%p, len=%d, pd=%p, source=%s)", env, name, loader, buf, len, pd, source));
-
-       if (name != NULL)
-               u = utf_new_char(name);
-       else
-               u = NULL;
-
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       /* XXX do something with source */
-
-       c = class_define(u, cl, len, (uint8_t *) buf, (java_handle_t *) pd);
-
-       return (jclass) LLNI_classinfo_wrap(c);
-}
-
-
-/* JVM_FindLoadedClass */
-
-jclass JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)
-{
-       classloader_t *cl;
-       utf           *u;
-       classinfo     *c;
-
-       TRACEJVMCALLS(("JVM_FindLoadedClass(env=%p, loader=%p, name=%p)", env, loader, name));
-
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       u = javastring_toutf((java_handle_t *) name, true);
-       c = classcache_lookup(cl, u);
-
-       return (jclass) LLNI_classinfo_wrap(c);
-}
-
-
-/* JVM_GetClassName */
-
-jstring JVM_GetClassName(JNIEnv *env, jclass cls)
-{
-       classinfo* c;
-
-       TRACEJVMCALLS(("JVM_GetClassName(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       return (jstring) class_get_classname(c);
-}
-
-
-/* JVM_GetClassInterfaces */
-
-jobjectArray JVM_GetClassInterfaces(JNIEnv *env, jclass cls)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetClassInterfaces(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       oa = class_get_interfaces(c);
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetClassLoader */
-
-jobject JVM_GetClassLoader(JNIEnv *env, jclass cls)
-{
-       classinfo     *c;
-       classloader_t *cl;
-
-       TRACEJVMCALLSENTER(("JVM_GetClassLoader(env=%p, cls=%p)", env, cls));
-
-       c  = LLNI_classinfo_unwrap(cls);
-       cl = class_get_classloader(c);
-
-       TRACEJVMCALLSEXIT(("->%p", cl));
-
-       return (jobject) cl;
-}
-
-
-/* JVM_IsInterface */
-
-jboolean JVM_IsInterface(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_IsInterface(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       return class_is_interface(c);
-}
-
-
-/* JVM_GetClassSigners */
-
-jobjectArray JVM_GetClassSigners(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetClassSigners: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_SetClassSigners */
-
-void JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *hoa;
-
-       TRACEJVMCALLS(("JVM_SetClassSigners(env=%p, cls=%p, signers=%p)", env, cls, signers));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       hoa = (java_handle_objectarray_t *) signers;
-
-    /* This call is ignored for primitive types and arrays.  Signers
-          are only set once, ClassLoader.java, and thus shouldn't be
-          called with an array.  Only the bootstrap loader creates
-          arrays. */
-
-       if (class_is_primitive(c) || class_is_array(c))
-               return;
-
-       LLNI_classinfo_field_set(c, signers, hoa);
-}
-
-
-/* JVM_GetProtectionDomain */
-
-jobject JVM_GetProtectionDomain(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_GetProtectionDomain(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       if (c == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-    /* Primitive types do not have a protection domain. */
-
-       if (class_is_primitive(c))
-               return NULL;
-
-       return (jobject) c->protectiondomain;
-}
-
-
-/* JVM_SetProtectionDomain */
-
-void JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain)
-{
-       log_println("JVM_SetProtectionDomain: IMPLEMENT ME!");
-}
-
-
-/* JVM_DoPrivileged */
-
-jobject JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, jobject context, jboolean wrapException)
-{
-       java_handle_t *h;
-       classinfo     *c;
-       methodinfo    *m;
-       java_handle_t *result;
-       java_handle_t *e;
-
-       TRACEJVMCALLS(("JVM_DoPrivileged(env=%p, cls=%p, action=%p, context=%p, wrapException=%d)", env, cls, action, context, wrapException));
-
-       h = (java_handle_t *) action;
-       LLNI_class_get(h, c);
-
-       if (action == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* lookup run() method (throw no exceptions) */
-
-       m = class_resolveclassmethod(c, utf_run, utf_void__java_lang_Object, c,
-                                                                false);
-
-       if ((m == NULL) || !(m->flags & ACC_PUBLIC) || (m->flags & ACC_STATIC)) {
-               exceptions_throw_internalerror("No run method");
-               return NULL;
-       }
-
-       /* XXX It seems something with a privileged stack needs to be done
-          here. */
-
-       result = vm_call_method(m, h);
-
-       e = exceptions_get_exception();
-
-       if (e != NULL) {
-               if ( builtin_instanceof(e, class_java_lang_Exception) &&
-                       !builtin_instanceof(e, class_java_lang_RuntimeException)) {
-                       exceptions_clear_exception();
-                       exceptions_throw_privilegedactionexception(e);
-               }
-
-               return NULL;
-       }
-
-       return (jobject) result;
-}
-
-
-/* JVM_GetInheritedAccessControlContext */
-
-jobject JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetInheritedAccessControlContext: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetStackAccessControlContext */
-
-jobject JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)
-{
-       TRACEJVMCALLS(("JVM_GetStackAccessControlContext(env=%p, cls=%p): IMPLEMENT ME!", env, cls));
-
-       /* XXX All stuff I tested so far works without that function.  At
-          some point we have to implement it, but I disable the output
-          for now to make IcedTea happy. */
-
-       return NULL;
-}
-
-
-/* JVM_IsArrayClass */
-
-jboolean JVM_IsArrayClass(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_IsArrayClass(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       return class_is_array(c);
-}
-
-
-/* JVM_IsPrimitiveClass */
-
-jboolean JVM_IsPrimitiveClass(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_IsPrimitiveClass(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       return class_is_primitive(c);
-}
-
-
-/* JVM_GetComponentType */
-
-jclass JVM_GetComponentType(JNIEnv *env, jclass cls)
-{
-       classinfo *component;
-       classinfo *c;
-       
-       TRACEJVMCALLS(("JVM_GetComponentType(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-       
-       component = class_get_componenttype(c);
-
-       return (jclass) LLNI_classinfo_wrap(component);
-}
-
-
-/* JVM_GetClassModifiers */
-
-jint JVM_GetClassModifiers(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-       int32_t    flags;
-
-       TRACEJVMCALLS(("JVM_GetClassModifiers(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       flags = class_get_modifiers(c, false);
-
-       return flags;
-}
-
-
-/* JVM_GetDeclaredClasses */
-
-jobjectArray JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetDeclaredClasses(env=%p, ofClass=%p)", env, ofClass));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       oa = class_get_declaredclasses(c, false);
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetDeclaringClass */
-
-jclass JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)
-{
-       classinfo *c;
-       classinfo *dc;
-
-       TRACEJVMCALLS(("JVM_GetDeclaringClass(env=%p, ofClass=%p)", env, ofClass));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       dc = class_get_declaringclass(c);
-
-       return (jclass) LLNI_classinfo_wrap(dc);
-}
-
-
-/* JVM_GetClassSignature */
-
-jstring JVM_GetClassSignature(JNIEnv *env, jclass cls)
-{
-       classinfo     *c;
-       utf           *u;
-       java_handle_t *s;
-
-       TRACEJVMCALLS(("JVM_GetClassSignature(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       /* Get the signature of the class. */
-
-       u = class_get_signature(c);
-
-       if (u == NULL)
-               return NULL;
-
-       /* Convert UTF-string to a Java-string. */
-
-       s = javastring_new(u);
-
-       return (jstring) s;
-}
-
-
-/* JVM_GetClassAnnotations */
-
-jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls)
-{
-       classinfo               *c           = NULL; /* classinfo for 'cls'  */
-       java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
-
-       TRACEJVMCALLS(("JVM_GetClassAnnotations: cls=%p", cls));
-
-       if (cls == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-       
-       c = LLNI_classinfo_unwrap(cls);
-
-       /* get annotations: */
-       annotations = class_get_annotations(c);
-
-       return (jbyteArray)annotations;
-}
-
-
-/* JVM_GetFieldAnnotations */
-
-jbyteArray JVM_GetFieldAnnotations(JNIEnv *env, jobject field)
-{
-       java_lang_reflect_Field *rf = NULL; /* java.lang.reflect.Field for 'field' */
-       java_handle_bytearray_t *ba = NULL; /* unparsed annotations */
-
-       TRACEJVMCALLS(("JVM_GetFieldAnnotations: field=%p", field));
-
-       if (field == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       rf = (java_lang_reflect_Field*)field;
-
-       LLNI_field_get_ref(rf, annotations, ba);
-
-       return (jbyteArray)ba;
-}
-
-
-/* JVM_GetMethodAnnotations */
-
-jbyteArray JVM_GetMethodAnnotations(JNIEnv *env, jobject method)
-{
-       java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
-       java_handle_bytearray_t  *ba = NULL; /* unparsed annotations */
-
-       TRACEJVMCALLS(("JVM_GetMethodAnnotations: method=%p", method));
-
-       if (method == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       rm = (java_lang_reflect_Method*)method;
-
-       LLNI_field_get_ref(rm, annotations, ba);
-
-       return (jbyteArray)ba;
-}
-
-
-/* JVM_GetMethodDefaultAnnotationValue */
-
-jbyteArray JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)
-{
-       java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
-       java_handle_bytearray_t  *ba = NULL; /* unparsed annotation default value */
-
-       TRACEJVMCALLS(("JVM_GetMethodDefaultAnnotationValue: method=%p", method));
-
-       if (method == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       rm = (java_lang_reflect_Method*)method;
-
-       LLNI_field_get_ref(rm, annotationDefault, ba);
-
-       return (jbyteArray)ba;
-}
-
-
-/* JVM_GetMethodParameterAnnotations */
-
-jbyteArray JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)
-{
-       java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
-       java_handle_bytearray_t  *ba = NULL; /* unparsed parameter annotations */
-
-       TRACEJVMCALLS(("JVM_GetMethodParameterAnnotations: method=%p", method));
-
-       if (method == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       rm = (java_lang_reflect_Method*)method;
-
-       LLNI_field_get_ref(rm, parameterAnnotations, ba);
-
-       return (jbyteArray)ba;
-}
-
-
-/* JVM_GetClassDeclaredFields */
-
-jobjectArray JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetClassDeclaredFields(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       oa = class_get_declaredfields(c, publicOnly);
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetClassDeclaredMethods */
-
-jobjectArray JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetClassDeclaredMethods(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       oa = class_get_declaredmethods(c, publicOnly);
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetClassDeclaredConstructors */
-
-jobjectArray JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetClassDeclaredConstructors(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       oa = class_get_declaredconstructors(c, publicOnly);
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetClassAccessFlags */
-
-jint JVM_GetClassAccessFlags(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_GetClassAccessFlags(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       /* Primitive type classes have the correct access flags. */
-
-       return c->flags & ACC_CLASS_REFLECT_MASK;
-}
-
-
-/* JVM_GetClassConstantPool */
-
-jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls)
-{
-#if defined(ENABLE_ANNOTATIONS)
-       sun_reflect_ConstantPool *constantPool    = NULL;
-                     /* constant pool object for the class refered by 'cls' */
-       java_lang_Object         *constantPoolOop = (java_lang_Object*)cls;
-                     /* constantPoolOop field of the constant pool object   */
-
-       TRACEJVMCALLS(("JVM_GetClassConstantPool(env=%p, cls=%p)", env, cls));
-
-       constantPool = 
-               (sun_reflect_ConstantPool*)native_new_and_init(
-                       class_sun_reflect_ConstantPool);
-       
-       if (constantPool == NULL) {
-               /* out of memory */
-               return NULL;
-       }
-       
-       LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
-
-       return (jobject)constantPool;
-#else
-       log_println("JVM_GetClassConstantPool(env=%p, cls=%p): not implemented in this configuration!", env, cls);
-       return NULL;
-#endif
-}
-
-
-/* JVM_ConstantPoolGetSize */
-
-jint JVM_ConstantPoolGetSize(JNIEnv *env, jobject unused, jobject jcpool)
-{
-       classinfo *c; /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetSize(env=%p, unused=%p, jcpool=%p)", env, unused, jcpool));
-
-       c = LLNI_classinfo_unwrap(jcpool);
-
-       return c->cpcount;
-}
-
-
-/* JVM_ConstantPoolGetClassAt */
-
-jclass JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_classref *ref;    /* classref to the class at constant pool index 'index' */
-       classinfo         *c;      /* classinfo of the class for which 'this' is the constant pool */
-       classinfo         *result; /* classinfo of the class at constant pool index 'index' */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetClassAt(env=%p, jcpool=%p, index=%d)", env, jcpool, index));
-
-       c = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       result = resolve_classref_eager(ref);
-
-       return (jclass) LLNI_classinfo_wrap(result);
-}
-
-
-/* JVM_ConstantPoolGetClassAtIfLoaded */
-
-jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_classref *ref;    /* classref to the class at constant pool index 'index' */
-       classinfo         *c;      /* classinfo of the class for which 'this' is the constant pool */
-       classinfo         *result; /* classinfo of the class at constant pool index 'index' */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetClassAtIfLoaded(env=%p, unused=%p, jcpool=%p, index=%d)", env, unused, jcpool, index));
-
-       c = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-       
-       if (!resolve_classref(NULL, ref, resolveLazy, true, true, &result)) {
-               return NULL;
-       }
-
-       if ((result == NULL) || !(result->state & CLASS_LOADED)) {
-               return NULL;
-       }
-       
-       return (jclass) LLNI_classinfo_wrap(result);
-}
-
-
-/* JVM_ConstantPoolGetMethodAt */
-
-jobject JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */
-       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
-       
-       TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAt: jcpool=%p, index=%d", jcpool, index));
-       
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
-       
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: is that right? or do I have to use resolve_method_*? */
-       return (jobject)reflect_method_new(ref->p.method);
-}
-
-
-/* JVM_ConstantPoolGetMethodAtIfLoaded */
-
-jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */
-       classinfo *c = NULL;  /* resolved declaring class of the method */
-       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAtIfLoaded: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) {
-               return NULL;
-       }
-
-       if (c == NULL || !(c->state & CLASS_LOADED)) {
-               return NULL;
-       }
-
-       return (jobject)reflect_method_new(ref->p.method);
-}
-
-
-/* JVM_ConstantPoolGetFieldAt */
-
-jobject JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */
-       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
-       
-       TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAt: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       return (jobject)reflect_field_new(ref->p.field);
-}
-
-
-/* JVM_ConstantPoolGetFieldAtIfLoaded */
-
-jobject JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */
-       classinfo *c;         /* resolved declaring class for the field */
-       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAtIfLoaded: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) {
-               return NULL;
-       }
-
-       if (c == NULL || !(c->state & CLASS_LOADED)) {
-               return NULL;
-       }
-
-       return (jobject)reflect_field_new(ref->p.field);
-}
-
-
-/* JVM_ConstantPoolGetMemberRefInfoAt */
-
-jobjectArray JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       log_println("JVM_ConstantPoolGetMemberRefInfoAt: jcpool=%p, index=%d, IMPLEMENT ME!", jcpool, index);
-
-       /* TODO: implement. (this is yet unused be OpenJDK but, so very low priority) */
-
-       return NULL;
-}
-
-
-/* JVM_ConstantPoolGetIntAt */
-
-jint JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_integer *ref; /* reference to the int value in constant pool at index 'index' */
-       classinfo *cls;        /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetIntAt: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_integer*)class_getconstant(cls, index, CONSTANT_Integer);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/* JVM_ConstantPoolGetLongAt */
-
-jlong JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_long *ref; /* reference to the long value in constant pool at index 'index' */
-       classinfo *cls;     /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetLongAt: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_long*)class_getconstant(cls, index, CONSTANT_Long);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/* JVM_ConstantPoolGetFloatAt */
-
-jfloat JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_float *ref; /* reference to the float value in constant pool at index 'index' */
-       classinfo *cls;      /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetFloatAt: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_float*)class_getconstant(cls, index, CONSTANT_Float);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/* JVM_ConstantPoolGetDoubleAt */
-
-jdouble JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_double *ref; /* reference to the double value in constant pool at index 'index' */
-       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetDoubleAt: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_double*)class_getconstant(cls, index, CONSTANT_Double);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/* JVM_ConstantPoolGetStringAt */
-
-jstring JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       utf *ref;       /* utf object for the string in constant pool at index 'index' */
-       classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetStringAt: jcpool=%p, index=%d", jcpool, index));
-       
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (utf*)class_getconstant(cls, index, CONSTANT_String);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: I hope literalstring_new is the right Function. */
-       return (jstring)literalstring_new(ref);
-}
-
-
-/* JVM_ConstantPoolGetUTF8At */
-
-jstring JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       utf *ref; /* utf object for the utf8 data in constant pool at index 'index' */
-       classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetUTF8At: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: I hope literalstring_new is the right Function. */
-       return (jstring)literalstring_new(ref);
-}
-
-
-/* JVM_DesiredAssertionStatus */
-
-jboolean JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls)
-{
-#if defined(ENABLE_ASSERTION)
-       assertion_name_t  *item;
-       classinfo         *c;
-       jboolean           status;
-       utf               *name;
-
-       TRACEJVMCALLS(("JVM_DesiredAssertionStatus(env=%p, unused=%p, cls=%p)", env, unused, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       if (c->classloader == NULL) {
-               status = (jboolean)assertion_system_enabled;
-       }
-       else {
-               status = (jboolean)assertion_user_enabled;
-       }
-
-       if (list_assertion_names != NULL) {
-               item = (assertion_name_t *)list_first(list_assertion_names);
-               while (item != NULL) {
-                       name = utf_new_char(item->name);
-                       if (name == c->packagename) {
-                               status = (jboolean)item->enabled;
-                       }
-                       else if (name == c->name) {
-                               status = (jboolean)item->enabled;
-                       }
-
-                       item = (assertion_name_t *)list_next(list_assertion_names, item);
-               }
-       }
-
-       return status;
-#else
-       return (jboolean)false;
-#endif
-}
-
-
-/* JVM_AssertionStatusDirectives */
-
-jobject JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused)
-{
-       classinfo                             *c;
-       java_lang_AssertionStatusDirectives   *o;
-       java_handle_objectarray_t             *classes;
-       java_handle_objectarray_t             *packages;
-       java_booleanarray_t                   *classEnabled;
-       java_booleanarray_t                   *packageEnabled;
-#if defined(ENABLE_ASSERTION)
-       assertion_name_t                      *item;
-       java_handle_t                         *js;
-       s4                                     i, j;
-#endif
-
-       TRACEJVMCALLS(("JVM_AssertionStatusDirectives(env=%p, unused=%p)", env, unused));
-
-       c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
-
-       if (c == NULL)
-               return NULL;
-
-       o = (java_lang_AssertionStatusDirectives *) builtin_new(c);
-
-       if (o == NULL)
-               return NULL;
-
-#if defined(ENABLE_ASSERTION)
-       classes = builtin_anewarray(assertion_class_count, class_java_lang_Object);
-#else
-       classes = builtin_anewarray(0, class_java_lang_Object);
-#endif
-       if (classes == NULL)
-               return NULL;
-
-#if defined(ENABLE_ASSERTION)
-       packages = builtin_anewarray(assertion_package_count, class_java_lang_Object);
-#else
-       packages = builtin_anewarray(0, class_java_lang_Object);
-#endif
-       if (packages == NULL)
-               return NULL;
-       
-#if defined(ENABLE_ASSERTION)
-       classEnabled = builtin_newarray_boolean(assertion_class_count);
-#else
-       classEnabled = builtin_newarray_boolean(0);
-#endif
-       if (classEnabled == NULL)
-               return NULL;
-
-#if defined(ENABLE_ASSERTION)
-       packageEnabled = builtin_newarray_boolean(assertion_package_count);
-#else
-       packageEnabled = builtin_newarray_boolean(0);
-#endif
-       if (packageEnabled == NULL)
-               return NULL;
-
-#if defined(ENABLE_ASSERTION)
-       /* initialize arrays */
-
-       if (list_assertion_names != NULL) {
-               i = 0;
-               j = 0;
-               
-               item = (assertion_name_t *)list_first(list_assertion_names);
-               while (item != NULL) {
-                       js = javastring_new_from_ascii(item->name);
-                       if (js == NULL) {
-                               return NULL;
-                       }
-
-                       if (item->package == false) {
-                               classes->data[i] = js;
-                               classEnabled->data[i] = (jboolean) item->enabled;
-                               i += 1;
-                       }
-                       else {
-                               packages->data[j] = js;
-                               packageEnabled->data[j] = (jboolean) item->enabled;
-                               j += 1;
-                       }
-
-                       item = (assertion_name_t *)list_next(list_assertion_names, item);
-               }
-       }
-#endif
-
-       /* set instance fields */
-
-       o->classes  = classes;
-       o->packages = packages;
-       o->classEnabled = classEnabled;
-       o->packageEnabled = packageEnabled;
-
-       return (jobject) o;
-}
-
-
-/* JVM_GetClassNameUTF */
-
-const char *JVM_GetClassNameUTF(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetClassNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassCPTypes */
-
-void JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char *types)
-{
-       log_println("JVM_GetClassCPTypes: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetClassCPEntriesCount */
-
-jint JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetClassCPEntriesCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetClassFieldsCount */
-
-jint JVM_GetClassFieldsCount(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetClassFieldsCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetClassMethodsCount */
-
-jint JVM_GetClassMethodsCount(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetClassMethodsCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxExceptionIndexes */
-
-void JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions)
-{
-       log_println("JVM_GetMethodIxExceptionIndexes: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetMethodIxExceptionsCount */
-
-jint JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index)
-{
-       log_println("JVM_GetMethodIxExceptionsCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxByteCode */
-
-void JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code)
-{
-       log_println("JVM_GetMethodIxByteCode: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetMethodIxByteCodeLength */
-
-jint JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index)
-{
-       log_println("JVM_GetMethodIxByteCodeLength: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxExceptionTableEntry */
-
-void JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry)
-{
-       log_println("JVM_GetMethodIxExceptionTableEntry: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetMethodIxExceptionTableLength */
-
-jint JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_GetMethodIxExceptionTableLength: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxModifiers */
-
-jint JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_GetMethodIxModifiers: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetFieldIxModifiers */
-
-jint JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index)
-{
-       log_println("JVM_GetFieldIxModifiers: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxLocalsCount */
-
-jint JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_GetMethodIxLocalsCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxArgsSize */
-
-jint JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_GetMethodIxArgsSize: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxMaxStack */
-
-jint JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_GetMethodIxMaxStack: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_IsConstructorIx */
-
-jboolean JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_IsConstructorIx: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxNameUTF */
-
-const char *JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index)
-{
-       log_println("JVM_GetMethodIxNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetMethodIxSignatureUTF */
-
-const char *JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cls, jint method_index)
-{
-       log_println("JVM_GetMethodIxSignatureUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPFieldNameUTF */
-
-const char *JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPFieldNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPMethodNameUTF */
-
-const char *JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPMethodNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPMethodSignatureUTF */
-
-const char *JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPMethodSignatureUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPFieldSignatureUTF */
-
-const char *JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPFieldSignatureUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPClassNameUTF */
-
-const char *JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPClassNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPFieldClassNameUTF */
-
-const char *JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPFieldClassNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPMethodClassNameUTF */
-
-const char *JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPMethodClassNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPFieldModifiers */
-
-jint JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)
-{
-       log_println("JVM_GetCPFieldModifiers: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetCPMethodModifiers */
-
-jint JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)
-{
-       log_println("JVM_GetCPMethodModifiers: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_ReleaseUTF */
-
-void JVM_ReleaseUTF(const char *utf)
-{
-       log_println("JVM_ReleaseUTF: IMPLEMENT ME!");
-}
-
-
-/* JVM_IsSameClassPackage */
-
-jboolean JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2)
-{
-       log_println("JVM_IsSameClassPackage: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Open */
-
-/* Taken from: hotspot/src/share/vm/prims/jvm.h */
-
-/*
- * JVM I/O error codes
- */
-#define JVM_EEXIST       -100
-
-jint JVM_Open(const char *fname, jint flags, jint mode)
-{
-       int result;
-
-       TRACEJVMCALLS(("JVM_Open(fname=%s, flags=%d, mode=%d)", fname, flags, mode));
-
-       result = hpi_file->Open(fname, flags, mode);
-
-       if (result >= 0) {
-               return result;
-       }
-       else {
-               switch (errno) {
-               case EEXIST:
-                       return JVM_EEXIST;
-               default:
-                       return -1;
-               }
-       }
-}
-
-
-/* JVM_Close */
-
-jint JVM_Close(jint fd)
-{
-       TRACEJVMCALLS(("JVM_Close(fd=%d)", fd));
-
-       return hpi_file->Close(fd);
-}
-
-
-/* JVM_Read */
-
-jint JVM_Read(jint fd, char *buf, jint nbytes)
-{
-       TRACEJVMCALLS(("JVM_Read(fd=%d, buf=%p, nbytes=%d)", fd, buf, nbytes));
-
-       return (jint) hpi_file->Read(fd, buf, nbytes);
-}
-
-
-/* JVM_Write */
-
-jint JVM_Write(jint fd, char *buf, jint nbytes)
-{
-       TRACEJVMCALLS(("JVM_Write(fd=%d, buf=%s, nbytes=%d)", fd, buf, nbytes));
-
-       return (jint) hpi_file->Write(fd, buf, nbytes);
-}
-
-
-/* JVM_Available */
-
-jint JVM_Available(jint fd, jlong *pbytes)
-{
-       TRACEJVMCALLS(("JVM_Available(fd=%d, pbytes=%p)", fd, pbytes));
-
-       return hpi_file->Available(fd, pbytes);
-}
-
-
-/* JVM_Lseek */
-
-jlong JVM_Lseek(jint fd, jlong offset, jint whence)
-{
-       TRACEJVMCALLS(("JVM_Lseek(fd=%d, offset=%ld, whence=%d)", fd, offset, whence));
-
-       return hpi_file->Seek(fd, (off_t) offset, whence);
-}
-
-
-/* JVM_SetLength */
-
-jint JVM_SetLength(jint fd, jlong length)
-{
-       TRACEJVMCALLS(("JVM_SetLength(fd=%d, length=%ld)", length));
-
-       return hpi_file->SetLength(fd, length);
-}
-
-
-/* JVM_Sync */
-
-jint JVM_Sync(jint fd)
-{
-       TRACEJVMCALLS(("JVM_Sync(fd=%d)", fd));
-
-       return hpi_file->Sync(fd);
-}
-
-
-/* JVM_StartThread */
-
-void JVM_StartThread(JNIEnv* env, jobject jthread)
-{
-       TRACEJVMCALLS(("JVM_StartThread(env=%p, jthread=%p)", env, jthread));
-
-       threads_thread_start((java_handle_t *) jthread);
-}
-
-
-/* JVM_StopThread */
-
-void JVM_StopThread(JNIEnv* env, jobject jthread, jobject throwable)
-{
-       log_println("JVM_StopThread: IMPLEMENT ME!");
-}
-
-
-/* JVM_IsThreadAlive */
-
-jboolean JVM_IsThreadAlive(JNIEnv* env, jobject jthread)
-{
-       java_handle_t *h;
-       threadobject  *t;
-       bool           result;
-
-       TRACEJVMCALLS(("JVM_IsThreadAlive(env=%p, jthread=%p)", env, jthread));
-
-       h = (java_handle_t *) jthread;
-       t = thread_get_thread(h);
-
-       /* The threadobject is null when a thread is created in Java. The
-          priority is set later during startup. */
-
-       if (t == NULL)
-               return 0;
-
-       result = threads_thread_is_alive(t);
-
-       return result;
-}
-
-
-/* JVM_SuspendThread */
-
-void JVM_SuspendThread(JNIEnv* env, jobject jthread)
-{
-       log_println("JVM_SuspendThread: IMPLEMENT ME!");
-}
-
-
-/* JVM_ResumeThread */
-
-void JVM_ResumeThread(JNIEnv* env, jobject jthread)
-{
-       log_println("JVM_ResumeThread: IMPLEMENT ME!");
-}
-
-
-/* JVM_SetThreadPriority */
-
-void JVM_SetThreadPriority(JNIEnv* env, jobject jthread, jint prio)
-{
-       java_handle_t *h;
-       threadobject  *t;
-
-       TRACEJVMCALLS(("JVM_SetThreadPriority(env=%p, jthread=%p, prio=%d)", env, jthread, prio));
-
-       h = (java_handle_t *) jthread;
-       t = thread_get_thread(h);
-
-       /* The threadobject is null when a thread is created in Java. The
-          priority is set later during startup. */
-
-       if (t == NULL)
-               return;
-
-       threads_set_thread_priority(t->tid, prio);
-}
-
-
-/* JVM_Yield */
-
-void JVM_Yield(JNIEnv *env, jclass threadClass)
-{
-       TRACEJVMCALLS(("JVM_Yield(env=%p, threadClass=%p)", env, threadClass));
-
-       threads_yield();
-}
-
-
-/* JVM_Sleep */
-
-void JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)
-{
-       TRACEJVMCALLS(("JVM_Sleep(env=%p, threadClass=%p, millis=%ld)", env, threadClass, millis));
-
-       threads_sleep(millis, 0);
-}
-
-
-/* JVM_CurrentThread */
-
-jobject JVM_CurrentThread(JNIEnv* env, jclass threadClass)
-{
-       java_object_t *o;
-
-       TRACEJVMCALLSVERBOSE(("JVM_CurrentThread(env=%p, threadClass=%p)", env, threadClass));
-
-       o = thread_get_current_object();
-
-       return (jobject) o;
-}
-
-
-/* JVM_CountStackFrames */
-
-jint JVM_CountStackFrames(JNIEnv* env, jobject jthread)
-{
-       log_println("JVM_CountStackFrames: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Interrupt */
-
-void JVM_Interrupt(JNIEnv* env, jobject jthread)
-{
-       java_handle_t *h;
-       threadobject  *t;
-
-       TRACEJVMCALLS(("JVM_Interrupt(env=%p, jthread=%p)", env, jthread));
-
-       h = (java_handle_t *) jthread;
-       t = thread_get_thread(h);
-
-       if (t == NULL)
-               return;
-
-       threads_thread_interrupt(t);
-}
-
-
-/* JVM_IsInterrupted */
-
-jboolean JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrupted)
-{
-       java_handle_t *h;
-       threadobject  *t;
-       jboolean       interrupted;
-
-       TRACEJVMCALLS(("JVM_IsInterrupted(env=%p, jthread=%p, clear_interrupted=%d)", env, jthread, clear_interrupted));
-
-       h = (java_handle_t *) jthread;
-       t = thread_get_thread(h);
-
-       interrupted = thread_is_interrupted(t);
-
-       if (interrupted && clear_interrupted)
-               thread_set_interrupted(t, false);
-
-       return interrupted;
-}
-
-
-/* JVM_HoldsLock */
-
-jboolean JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj)
-{
-       java_handle_t *h;
-       bool           result;
-
-       TRACEJVMCALLS(("JVM_HoldsLock(env=%p, threadClass=%p, obj=%p)", env, threadClass, obj));
-
-       h = (java_handle_t *) obj;
-
-       if (h == NULL) {
-               exceptions_throw_nullpointerexception();
-               return JNI_FALSE;
-       }
-
-       result = lock_is_held_by_current_thread(h);
-
-       return result;
-}
-
-
-/* JVM_DumpAllStacks */
-
-void JVM_DumpAllStacks(JNIEnv* env, jclass unused)
-{
-       log_println("JVM_DumpAllStacks: IMPLEMENT ME!");
-}
-
-
-/* JVM_CurrentLoadedClass */
-
-jclass JVM_CurrentLoadedClass(JNIEnv *env)
-{
-       log_println("JVM_CurrentLoadedClass: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_CurrentClassLoader */
-
-jobject JVM_CurrentClassLoader(JNIEnv *env)
-{
-    /* XXX if a method in a class in a trusted loader is in a
-          doPrivileged, return NULL */
-
-       log_println("JVM_CurrentClassLoader: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassContext */
-
-jobjectArray JVM_GetClassContext(JNIEnv *env)
-{
-       TRACEJVMCALLS(("JVM_GetClassContext(env=%p)", env));
-
-       return (jobjectArray) stacktrace_getClassContext();
-}
-
-
-/* JVM_ClassDepth */
-
-jint JVM_ClassDepth(JNIEnv *env, jstring name)
-{
-       log_println("JVM_ClassDepth: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_ClassLoaderDepth */
-
-jint JVM_ClassLoaderDepth(JNIEnv *env)
-{
-       log_println("JVM_ClassLoaderDepth: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetSystemPackage */
-
-jstring JVM_GetSystemPackage(JNIEnv *env, jstring name)
-{
-       java_handle_t *s;
-       utf *u;
-       utf *result;
-
-       TRACEJVMCALLS(("JVM_GetSystemPackage(env=%p, name=%p)", env, name));
-
-/*     s = package_find(name); */
-       u = javastring_toutf((java_handle_t *) name, false);
-
-       result = package_find(u);
-
-       if (result != NULL)
-               s = javastring_new(result);
-       else
-               s = NULL;
-
-       return (jstring) s;
-}
-
-
-/* JVM_GetSystemPackages */
-
-jobjectArray JVM_GetSystemPackages(JNIEnv *env)
-{
-       log_println("JVM_GetSystemPackages: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_AllocateNewObject */
-
-jobject JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass currClass, jclass initClass)
-{
-       log_println("JVM_AllocateNewObject: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_AllocateNewArray */
-
-jobject JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, jint length)
-{
-       log_println("JVM_AllocateNewArray: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_LatestUserDefinedLoader */
-
-jobject JVM_LatestUserDefinedLoader(JNIEnv *env)
-{
-       classloader_t *cl;
-
-       TRACEJVMCALLS(("JVM_LatestUserDefinedLoader(env=%p)", env));
-
-       cl = stacktrace_first_nonnull_classloader();
-
-       return (jobject) cl;
-}
-
-
-/* JVM_LoadClass0 */
-
-jclass JVM_LoadClass0(JNIEnv *env, jobject receiver, jclass currClass, jstring currClassName)
-{
-       log_println("JVM_LoadClass0: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetArrayLength */
-
-jint JVM_GetArrayLength(JNIEnv *env, jobject arr)
-{
-       java_handle_t *a;
-
-       TRACEJVMCALLS(("JVM_GetArrayLength(arr=%p)", arr));
-
-       a = (java_handle_t *) arr;
-
-       return array_length_get(a);
-}
-
-
-/* JVM_GetArrayElement */
-
-jobject JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index)
-{
-       java_handle_t *a;
-       java_handle_t *o;
-
-       TRACEJVMCALLS(("JVM_GetArrayElement(env=%p, arr=%p, index=%d)", env, arr, index));
-
-       a = (java_handle_t *) arr;
-
-/*     if (!class_is_array(a->objheader.vftbl->class)) { */
-/*             exceptions_throw_illegalargumentexception(); */
-/*             return NULL; */
-/*     } */
-
-       o = array_element_get(a, index);
-
-       return (jobject) o;
-}
-
-
-/* JVM_GetPrimitiveArrayElement */
-
-jvalue JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode)
-{
-       jvalue jv;
-
-       log_println("JVM_GetPrimitiveArrayElement: IMPLEMENT ME!");
-
-       jv.l = NULL;
-
-       return jv;
-}
-
-
-/* JVM_SetArrayElement */
-
-void JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val)
-{
-       java_handle_t *a;
-       java_handle_t *value;
-
-       TRACEJVMCALLS(("JVM_SetArrayElement(env=%p, arr=%p, index=%d, val=%p)", env, arr, index, val));
-
-       a     = (java_handle_t *) arr;
-       value = (java_handle_t *) val;
-
-       array_element_set(a, index, value);
-}
-
-
-/* JVM_SetPrimitiveArrayElement */
-
-void JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, unsigned char vCode)
-{
-       log_println("JVM_SetPrimitiveArrayElement: IMPLEMENT ME!");
-}
-
-
-/* JVM_NewArray */
-
-jobject JVM_NewArray(JNIEnv *env, jclass eltClass, jint length)
-{
-       classinfo                 *c;
-       classinfo                 *pc;
-       java_handle_t             *a;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_NewArray(env=%p, eltClass=%p, length=%d)", env, eltClass, length));
-
-       if (eltClass == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* NegativeArraySizeException is checked in builtin_newarray. */
-
-       c = LLNI_classinfo_unwrap(eltClass);
-
-       /* Create primitive or object array. */
-
-       if (class_is_primitive(c)) {
-               pc = primitive_arrayclass_get_by_name(c->name);
-
-               /* void arrays are not allowed. */
-
-               if (pc == NULL) {
-                       exceptions_throw_illegalargumentexception();
-                       return NULL;
-               }
-
-               a = builtin_newarray(length, pc);
-
-               return (jobject) a;
-       }
-       else {
-               oa = builtin_anewarray(length, c);
-
-               return (jobject) oa;
-       }
-}
-
-
-/* JVM_NewMultiArray */
-
-jobject JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim)
-{
-       classinfo                 *c;
-       java_handle_intarray_t    *ia;
-       int32_t                    length;
-       long                      *dims;
-       int32_t                    value;
-       int32_t                    i;
-       classinfo                 *ac;
-       java_handle_objectarray_t *a;
-
-       TRACEJVMCALLS(("JVM_NewMultiArray(env=%p, eltClass=%p, dim=%p)", env, eltClass, dim));
-
-       if (eltClass == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* NegativeArraySizeException is checked in builtin_newarray. */
-
-       c = LLNI_classinfo_unwrap(eltClass);
-
-       ia = (java_handle_intarray_t *) dim;
-
-       length = array_length_get((java_handle_t *) ia);
-
-       /* We check here for exceptions thrown in array_length_get,
-          otherwise these exceptions get overwritten by the following
-          IllegalArgumentException. */
-
-       if (length < 0)
-               return NULL;
-
-       if ((length <= 0) || (length > /* MAX_DIM */ 255)) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX This is just a quick hack to get it working. */
-
-       dims = MNEW(long, length);
-
-       for (i = 0; i < length; i++) {
-               value = LLNI_array_direct(ia, i);
-               dims[i] = (long) value;
-       }
-
-       /* Create an array-class if necessary. */
-
-       if (class_is_primitive(c))
-               ac = primitive_arrayclass_get_by_name(c->name);
-       else
-               ac = class_array_of(c, true);
-
-       if (ac == NULL)
-               return NULL;
-
-       a = builtin_multianewarray(length, (java_handle_t *) ac, dims);
-
-       return (jobject) a;
-}
-
-
-/* JVM_InitializeSocketLibrary */
-
-jint JVM_InitializeSocketLibrary()
-{
-       TRACEJVMCALLS(("JVM_InitializeSocketLibrary()"));
-
-       return hpi_initialize_socket_library();
-}
-
-
-/* JVM_Socket */
-
-jint JVM_Socket(jint domain, jint type, jint protocol)
-{
-       TRACEJVMCALLS(("JVM_Socket(domain=%d, type=%d, protocol=%d)", domain, type, protocol));
-
-       return system_socket(domain, type, protocol);
-}
-
-
-/* JVM_SocketClose */
-
-jint JVM_SocketClose(jint fd)
-{
-       TRACEJVMCALLS(("JVM_SocketClose(fd=%d)", fd));
-
-       return system_close(fd);
-}
-
-
-/* JVM_SocketShutdown */
-
-jint JVM_SocketShutdown(jint fd, jint howto)
-{
-       TRACEJVMCALLS(("JVM_SocketShutdown(fd=%d, howto=%d)", fd, howto));
-
-       return system_shutdown(fd, howto);
-}
-
-
-/* JVM_Recv */
-
-jint JVM_Recv(jint fd, char *buf, jint nBytes, jint flags)
-{
-       log_println("JVM_Recv: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Send */
-
-jint JVM_Send(jint fd, char *buf, jint nBytes, jint flags)
-{
-       log_println("JVM_Send: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Timeout */
-
-jint JVM_Timeout(int fd, long timeout)
-{
-       log_println("JVM_Timeout: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Listen */
-
-jint JVM_Listen(jint fd, jint count)
-{
-       TRACEJVMCALLS(("JVM_Listen(fd=%d, count=%d)", fd, count));
-
-       return system_listen(fd, count);
-}
-
-
-/* JVM_Connect */
-
-jint JVM_Connect(jint fd, struct sockaddr *him, jint len)
-{
-       TRACEJVMCALLS(("JVM_Connect(fd=%d, him=%p, len=%d)", fd, him, len));
-
-       return system_connect(fd, him, len);
-}
-
-
-/* JVM_Bind */
-
-jint JVM_Bind(jint fd, struct sockaddr *him, jint len)
-{
-       log_println("JVM_Bind: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Accept */
-
-jint JVM_Accept(jint fd, struct sockaddr *him, jint *len)
-{
-       TRACEJVMCALLS(("JVM_Accept(fd=%d, him=%p, len=%p)", fd, him, len));
-
-       return system_accept(fd, him, (socklen_t *) len);
-}
-
-
-/* JVM_RecvFrom */
-
-jint JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen)
-{
-       log_println("JVM_RecvFrom: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetSockName */
-
-jint JVM_GetSockName(jint fd, struct sockaddr *him, int *len)
-{
-       TRACEJVMCALLS(("JVM_GetSockName(fd=%d, him=%p, len=%p)", fd, him, len));
-
-       return system_getsockname(fd, him, (socklen_t *) len);
-}
-
-
-/* JVM_SendTo */
-
-jint JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen)
-{
-       log_println("JVM_SendTo: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_SocketAvailable */
-
-jint JVM_SocketAvailable(jint fd, jint *pbytes)
-{
-#if defined(FIONREAD)
-       int bytes;
-       int result;
-
-       TRACEJVMCALLS(("JVM_SocketAvailable(fd=%d, pbytes=%p)", fd, pbytes));
-
-       *pbytes = 0;
-
-       result = ioctl(fd, FIONREAD, &bytes);
-
-       if (result < 0)
-               return 0;
-
-       *pbytes = bytes;
-
-       return 1;
-#else
-# error FIONREAD not defined
-#endif
-}
-
-
-/* JVM_GetSockOpt */
-
-jint JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen)
-{
-       TRACEJVMCALLS(("JVM_GetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%p)", fd, level, optname, optval, optlen));
-
-       return system_getsockopt(fd, level, optname, optval, (socklen_t *) optlen);
-}
-
-
-/* JVM_SetSockOpt */
-
-jint JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen)
-{
-       TRACEJVMCALLS(("JVM_SetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%d)", fd, level, optname, optval, optlen));
-
-       return system_setsockopt(fd, level, optname, optval, optlen);
-}
-
-
-/* JVM_GetHostName */
-
-int JVM_GetHostName(char *name, int namelen)
-{
-       int result;
-
-       TRACEJVMCALLSENTER(("JVM_GetHostName(name=%s, namelen=%d)", name, namelen));
-
-       result = system_gethostname(name, namelen);
-
-       TRACEJVMCALLSEXIT(("->%d (name=%s)", result, name));
-
-       return result;
-}
-
-
-/* JVM_GetHostByAddr */
-
-struct hostent *JVM_GetHostByAddr(const char* name, int len, int type)
-{
-       log_println("JVM_GetHostByAddr: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetHostByName */
-
-struct hostent *JVM_GetHostByName(char* name)
-{
-       log_println("JVM_GetHostByName: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetProtoByName */
-
-struct protoent *JVM_GetProtoByName(char* name)
-{
-       log_println("JVM_GetProtoByName: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_LoadLibrary */
-
-void *JVM_LoadLibrary(const char *name)
-{
-       utf*  u;
-       void* handle;
-
-       TRACEJVMCALLSENTER(("JVM_LoadLibrary(name=%s)", name));
-
-       u = utf_new_char(name);
-
-       handle = native_library_open(u);
-
-       TRACEJVMCALLSEXIT(("->%p", handle));
-
-       return handle;
-}
-
-
-/* JVM_UnloadLibrary */
-
-void JVM_UnloadLibrary(void* handle)
-{
-       TRACEJVMCALLS(("JVM_UnloadLibrary(handle=%p)", handle));
-
-       native_library_close(handle);
-}
-
-
-/* JVM_FindLibraryEntry */
-
-void *JVM_FindLibraryEntry(void *handle, const char *name)
-{
-       lt_ptr symbol;
-
-       TRACEJVMCALLSENTER(("JVM_FindLibraryEntry(handle=%p, name=%s)", handle, name));
-
-       symbol = lt_dlsym(handle, name);
-
-       TRACEJVMCALLSEXIT(("->%p", symbol));
-
-       return symbol;
-}
-
-
-/* JVM_IsNaN */
-
-jboolean JVM_IsNaN(jdouble a)
-{
-       log_println("JVM_IsNaN: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_IsSupportedJNIVersion */
-
-jboolean JVM_IsSupportedJNIVersion(jint version)
-{
-       TRACEJVMCALLS(("JVM_IsSupportedJNIVersion(version=%d)", version));
-
-       return jni_version_check(version);
-}
-
-
-/* JVM_InternString */
-
-jstring JVM_InternString(JNIEnv *env, jstring str)
-{
-       TRACEJVMCALLS(("JVM_InternString(env=%p, str=%p)", env, str));
-
-       return (jstring) javastring_intern((java_handle_t *) str);
-}
-
-
-/* JVM_RawMonitorCreate */
-
-JNIEXPORT void* JNICALL JVM_RawMonitorCreate(void)
-{
-       java_object_t *o;
-
-       TRACEJVMCALLS(("JVM_RawMonitorCreate()"));
-
-       o = NEW(java_object_t);
-
-       lock_init_object_lock(o);
-
-       return o;
-}
-
-
-/* JVM_RawMonitorDestroy */
-
-JNIEXPORT void JNICALL JVM_RawMonitorDestroy(void *mon)
-{
-       TRACEJVMCALLS(("JVM_RawMonitorDestroy(mon=%p)", mon));
-
-       FREE(mon, java_object_t);
-}
-
-
-/* JVM_RawMonitorEnter */
-
-JNIEXPORT jint JNICALL JVM_RawMonitorEnter(void *mon)
-{
-       TRACEJVMCALLS(("JVM_RawMonitorEnter(mon=%p)", mon));
-
-       (void) lock_monitor_enter((java_object_t *) mon);
-
-       return 0;
-}
-
-
-/* JVM_RawMonitorExit */
-
-JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon)
-{
-       TRACEJVMCALLS(("JVM_RawMonitorExit(mon=%p)", mon));
-
-       (void) lock_monitor_exit((java_object_t *) mon);
-}
-
-
-/* JVM_SetPrimitiveFieldValues */
-
-void JVM_SetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)
-{
-       log_println("JVM_SetPrimitiveFieldValues: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetPrimitiveFieldValues */
-
-void JVM_GetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)
-{
-       log_println("JVM_GetPrimitiveFieldValues: IMPLEMENT ME!");
-}
-
-
-/* JVM_AccessVMBooleanFlag */
-
-jboolean JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get)
-{
-       log_println("JVM_AccessVMBooleanFlag: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_AccessVMIntFlag */
-
-jboolean JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get)
-{
-       log_println("JVM_AccessVMIntFlag: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_VMBreakPoint */
-
-void JVM_VMBreakPoint(JNIEnv *env, jobject obj)
-{
-       log_println("JVM_VMBreakPoint: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetClassFields */
-
-jobjectArray JVM_GetClassFields(JNIEnv *env, jclass cls, jint which)
-{
-       log_println("JVM_GetClassFields: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassMethods */
-
-jobjectArray JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which)
-{
-       log_println("JVM_GetClassMethods: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassConstructors */
-
-jobjectArray JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which)
-{
-       log_println("JVM_GetClassConstructors: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassField */
-
-jobject JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which)
-{
-       log_println("JVM_GetClassField: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassMethod */
-
-jobject JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types, jint which)
-{
-       log_println("JVM_GetClassMethod: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassConstructor */
-
-jobject JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types, jint which)
-{
-       log_println("JVM_GetClassConstructor: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_NewInstance */
-
-jobject JVM_NewInstance(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_NewInstance: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetField */
-
-jobject JVM_GetField(JNIEnv *env, jobject field, jobject obj)
-{
-       log_println("JVM_GetField: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetPrimitiveField */
-
-jvalue JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj, unsigned char wCode)
-{
-       jvalue jv;
-
-       log_println("JVM_GetPrimitiveField: IMPLEMENT ME!");
-
-       jv.l = NULL;
-
-       return jv;
-}
-
-
-/* JVM_SetField */
-
-void JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val)
-{
-       log_println("JVM_SetField: IMPLEMENT ME!");
-}
-
-
-/* JVM_SetPrimitiveField */
-
-void JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v, unsigned char vCode)
-{
-       log_println("JVM_SetPrimitiveField: IMPLEMENT ME!");
-}
-
-
-/* JVM_InvokeMethod */
-
-jobject JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)
-{
-       java_lang_reflect_Method *rm;
-       classinfo     *c;
-       int32_t        slot;
-       int32_t        override;
-       methodinfo    *m;
-       java_handle_t *ro;
-
-       TRACEJVMCALLS(("JVM_InvokeMethod(env=%p, method=%p, obj=%p, args0=%p)", env, method, obj, args0));
-
-       rm = (java_lang_reflect_Method *) method;
-
-       LLNI_field_get_cls(rm, clazz,    c);
-       LLNI_field_get_val(rm, slot,     slot);
-       LLNI_field_get_val(rm, override, override);
-
-       m = &(c->methods[slot]);
-
-       ro = reflect_method_invoke(m, (java_handle_t *) obj, (java_handle_objectarray_t *) args0, override);
-
-       return (jobject) ro;
-}
-
-
-/* JVM_NewInstanceFromConstructor */
-
-jobject JVM_NewInstanceFromConstructor(JNIEnv *env, jobject con, jobjectArray args0)
-{
-       java_lang_reflect_Constructor *rc;
-       classinfo                     *c;
-       int32_t                        slot;
-       int32_t                        override;
-       methodinfo                    *m;
-       java_handle_t                 *o;
-
-       TRACEJVMCALLS(("JVM_NewInstanceFromConstructor(env=%p, c=%p, args0=%p)", env, con, args0));
-
-       rc = (java_lang_reflect_Constructor *) con;
-
-       LLNI_field_get_cls(rc, clazz,    c);
-       LLNI_field_get_val(rc, slot,     slot);
-       LLNI_field_get_val(rc, override, override);
-
-       m = &(c->methods[slot]);
-
-       o = reflect_constructor_newinstance(m, (java_handle_objectarray_t *) args0, override);
-
-       return (jobject) o;
-}
-
-
-/* JVM_SupportsCX8 */
-
-jboolean JVM_SupportsCX8()
-{
-       TRACEJVMCALLS(("JVM_SupportsCX8()"));
-
-       /* IMPLEMENT ME */
-
-       return 0;
-}
-
-
-/* JVM_CX8Field */
-
-jboolean JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fid, jlong oldVal, jlong newVal)
-{
-       log_println("JVM_CX8Field: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetAllThreads */
-
-jobjectArray JVM_GetAllThreads(JNIEnv *env, jclass dummy)
-{
-       log_println("JVM_GetAllThreads: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_DumpThreads */
-
-jobjectArray JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads)
-{
-       log_println("JVM_DumpThreads: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetManagement */
-
-void *JVM_GetManagement(jint version)
-{
-       TRACEJVMCALLS(("JVM_GetManagement(version=%d)", version));
-
-       /* TODO We current don't support the management interface. */
-
-       return NULL;
-}
-
-
-/* JVM_InitAgentProperties */
-
-jobject JVM_InitAgentProperties(JNIEnv *env, jobject properties)
-{
-       log_println("JVM_InitAgentProperties: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetEnclosingMethodInfo */
-
-jobjectArray JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass)
-{
-       classinfo                 *c;
-       methodinfo                *m;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetEnclosingMethodInfo(env=%p, ofClass=%p)", env, ofClass));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       if ((c == NULL) || class_is_primitive(c))
-               return NULL;
-
-       m = class_get_enclosingmethod_raw(c);
-
-       if (m == NULL)
-               return NULL;
-
-       oa = builtin_anewarray(3, class_java_lang_Object);
-
-       if (oa == NULL)
-               return NULL;
-
-       array_objectarray_element_set(oa, 0, (java_handle_t *) LLNI_classinfo_wrap(m->clazz));
-       array_objectarray_element_set(oa, 1, javastring_new(m->name));
-       array_objectarray_element_set(oa, 2, javastring_new(m->descriptor));
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetThreadStateValues */
-
-jintArray JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState)
-{
-       java_handle_intarray_t *ia;
-
-       TRACEJVMCALLS(("JVM_GetThreadStateValues(env=%p, javaThreadState=%d)",
-                                 env, javaThreadState));
-
-       /* If new thread states are added in future JDK and VM versions,
-          this should check if the JDK version is compatible with thread
-          states supported by the VM.  Return NULL if not compatible.
-       
-          This function must map the VM java_lang_Thread::ThreadStatus
-          to the Java thread state that the JDK supports. */
-
-       switch (javaThreadState) {
-    case THREAD_STATE_NEW:
-               ia = builtin_newarray_int(1);
-
-               if (ia == NULL)
-                       return NULL;
-
-               array_intarray_element_set(ia, 0, THREAD_STATE_NEW);
-               break; 
-
-    case THREAD_STATE_RUNNABLE:
-               ia = builtin_newarray_int(1);
-
-               if (ia == NULL)
-                       return NULL;
-
-               array_intarray_element_set(ia, 0, THREAD_STATE_RUNNABLE);
-               break; 
-
-    case THREAD_STATE_BLOCKED:
-               ia = builtin_newarray_int(1);
-
-               if (ia == NULL)
-                       return NULL;
-
-               array_intarray_element_set(ia, 0, THREAD_STATE_BLOCKED);
-               break; 
-
-    case THREAD_STATE_WAITING:
-               ia = builtin_newarray_int(2);
-
-               if (ia == NULL)
-                       return NULL;
-
-               array_intarray_element_set(ia, 0, THREAD_STATE_WAITING);
-               /* XXX Implement parked stuff. */
-/*             array_intarray_element_set(ia, 1, PARKED); */
-               break; 
-
-    case THREAD_STATE_TIMED_WAITING:
-               ia = builtin_newarray_int(3);
-
-               if (ia == NULL)
-                       return NULL;
-
-               /* XXX Not sure about that one. */
-/*             array_intarray_element_set(ia, 0, SLEEPING); */
-               array_intarray_element_set(ia, 0, THREAD_STATE_TIMED_WAITING);
-               /* XXX Implement parked stuff. */
-/*             array_intarray_element_set(ia, 2, PARKED); */
-               break; 
-
-    case THREAD_STATE_TERMINATED:
-               ia = builtin_newarray_int(1);
-
-               if (ia == NULL)
-                       return NULL;
-
-               array_intarray_element_set(ia, 0, THREAD_STATE_TERMINATED);
-               break; 
-
-    default:
-               /* Unknown state - probably incompatible JDK version */
-               return NULL;
-       }
-
-       return (jintArray) ia;
-}
-
-
-/* JVM_GetThreadStateNames */
-
-jobjectArray JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values)
-{
-       java_handle_intarray_t    *ia;
-       java_handle_objectarray_t *oa;
-       java_object_t             *s;
-
-       TRACEJVMCALLS(("JVM_GetThreadStateNames(env=%p, javaThreadState=%d, values=%p)",
-                                 env, javaThreadState, values));
-
-       ia = (java_handle_intarray_t *) values;
-
-       /* If new thread states are added in future JDK and VM versions,
-          this should check if the JDK version is compatible with thread
-          states supported by the VM.  Return NULL if not compatible.
-       
-          This function must map the VM java_lang_Thread::ThreadStatus
-          to the Java thread state that the JDK supports. */
-
-       if (values == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       switch (javaThreadState) {
-    case THREAD_STATE_NEW:
-               assert(ia->header.size == 1 && ia->data[0] == THREAD_STATE_NEW);
-
-               oa = builtin_anewarray(1, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-               s = javastring_new(utf_new_char("NEW"));
-
-               if (s == NULL)
-                       return NULL;
-
-               array_objectarray_element_set(oa, 0, s);
-               break; 
-
-    case THREAD_STATE_RUNNABLE:
-               oa = builtin_anewarray(1, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-               s = javastring_new(utf_new_char("RUNNABLE"));
-
-               if (s == NULL)
-                       return NULL;
-
-               array_objectarray_element_set(oa, 0, s);
-               break; 
-
-    case THREAD_STATE_BLOCKED:
-               oa = builtin_anewarray(1, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-               s = javastring_new(utf_new_char("BLOCKED"));
-
-               if (s == NULL)
-                       return NULL;
-
-               array_objectarray_element_set(oa, 0, s);
-               break; 
-
-    case THREAD_STATE_WAITING:
-               oa = builtin_anewarray(2, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-               s = javastring_new(utf_new_char("WAITING.OBJECT_WAIT"));
-/*             s = javastring_new(utf_new_char("WAITING.PARKED")); */
-
-               if (s == NULL)
-                       return NULL;
-
-               array_objectarray_element_set(oa, 0, s);
-/*             array_objectarray_element_set(oa, 1, s); */
-               break; 
-
-    case THREAD_STATE_TIMED_WAITING:
-               oa = builtin_anewarray(3, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-/*             s = javastring_new(utf_new_char("TIMED_WAITING.SLEEPING")); */
-               s = javastring_new(utf_new_char("TIMED_WAITING.OBJECT_WAIT"));
-/*             s = javastring_new(utf_new_char("TIMED_WAITING.PARKED")); */
-
-               if (s == NULL)
-                       return NULL;
-
-/*             array_objectarray_element_set(oa, 0, s); */
-               array_objectarray_element_set(oa, 0, s);
-/*             array_objectarray_element_set(oa, 2, s); */
-               break; 
-
-    case THREAD_STATE_TERMINATED:
-               oa = builtin_anewarray(1, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-               s = javastring_new(utf_new_char("TERMINATED"));
-
-               if (s == NULL)
-                       return NULL;
-
-               array_objectarray_element_set(oa, 0, s);
-               break; 
-
-       default:
-               /* Unknown state - probably incompatible JDK version */
-               return NULL;
-       }
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetVersionInfo */
-
-void JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size)
-{
-       log_println("JVM_GetVersionInfo: IMPLEMENT ME!");
-}
-
-
-/* OS: JVM_RegisterSignal */
-
-void *JVM_RegisterSignal(jint sig, void *handler)
-{
-       functionptr newHandler;
-
-       TRACEJVMCALLS(("JVM_RegisterSignal(sig=%d, handler=%p)", sig, handler));
-
-       if (handler == (void *) 2)
-               newHandler = (functionptr) signal_thread_handler;
-       else
-               newHandler = (functionptr) (uintptr_t) handler;
-
-       switch (sig) {
-    case SIGILL:
-    case SIGFPE:
-    case SIGUSR1:
-    case SIGSEGV:
-               /* These signals are already used by the VM. */
-               return (void *) -1;
-
-    case SIGQUIT:
-               /* This signal is used by the VM to dump thread stacks unless
-                  ReduceSignalUsage is set, in which case the user is allowed
-                  to set his own _native_ handler for this signal; thus, in
-                  either case, we do not allow JVM_RegisterSignal to change
-                  the handler. */
-               return (void *) -1;
-
-       case SIGHUP:
-       case SIGINT:
-       case SIGTERM:
-               break;
-       }
-
-       signal_register_signal(sig, newHandler, 0);
-
-       /* XXX Should return old handler. */
-
-       return (void *) 2;
-}
-
-
-/* OS: JVM_RaiseSignal */
-
-jboolean JVM_RaiseSignal(jint sig)
-{
-       log_println("JVM_RaiseSignal: IMPLEMENT ME! sig=%s", sig);
-
-       return false;
-}
-
-
-/* OS: JVM_FindSignal */
-
-jint JVM_FindSignal(const char *name)
-{
-       TRACEJVMCALLS(("JVM_FindSignal(name=%s)", name));
-
-#if defined(__LINUX__)
-       if (strcmp(name, "HUP") == 0)
-               return SIGHUP;
-
-       if (strcmp(name, "INT") == 0)
-               return SIGINT;
-
-       if (strcmp(name, "TERM") == 0)
-               return SIGTERM;
-#else
-# error not implemented for this OS
-#endif
-
-       return -1;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/openjdk/jvm.cpp b/src/native/vm/openjdk/jvm.cpp
new file mode 100644 (file)
index 0000000..7a63880
--- /dev/null
@@ -0,0 +1,3611 @@
+/* src/native/vm/openjdk/jvm.cpp - HotSpot VM interface functions
+
+   Copyright (C) 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 <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#if defined(HAVE_SYS_IOCTL_H)
+#define BSD_COMP /* Get FIONREAD on Solaris2 */
+#include <sys/ioctl.h>
+#endif
+
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+// Include our JNI header before the JVM headers, because the JVM
+// headers include jni.h and we want to override the typedefs in
+// jni.h.
+#include "native/jni.hpp"
+
+// We include jvm_md.h before jvm.h as the latter includes the former.
+#include INCLUDE_JVM_MD_H
+#include INCLUDE_JVM_H
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#include "native/vm/reflection.hpp"
+
+#include "native/vm/openjdk/hpi.hpp"
+#include "native/vm/openjdk/management.hpp"
+
+#include "threads/lock.hpp"
+#include "threads/thread.hpp"
+
+#include "toolbox/logging.h"
+#include "toolbox/list.hpp"
+
+#include "vm/array.hpp"
+
+#if defined(ENABLE_ASSERTION)
+#include "vm/assertion.hpp"
+#endif
+
+#include "vm/jit/builtin.hpp"
+#include "vm/classcache.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/initialize.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/options.h"
+#include "vm/os.hpp"
+#include "vm/package.hpp"
+#include "vm/primitive.hpp"
+#include "vm/properties.hpp"
+#include "vm/resolve.hpp"
+#include "vm/signallocal.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/stacktrace.hpp"
+
+
+/* debugging macros ***********************************************************/
+
+#if !defined(NDEBUG)
+
+# define TRACEJVMCALLS(x)                                                                              \
+    do {                                                                                                               \
+        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
+            log_println x;                                                                             \
+        }                                                                                                              \
+    } while (0)
+
+# define TRACEJVMCALLSENTER(x)                                                                 \
+    do {                                                                                                               \
+        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
+                       log_start();                                                                            \
+            log_print x;                                                                               \
+        }                                                                                                              \
+    } while (0)
+
+# define TRACEJVMCALLSEXIT(x)                                                                  \
+    do {                                                                                                               \
+        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
+                       log_print x;                                                                            \
+                       log_finish();                                                                           \
+        }                                                                                                              \
+    } while (0)
+
+# define TRACEJVMCALLSVERBOSE(x)                               \
+    do {                                                                               \
+        if (opt_TraceJVMCallsVerbose) {                        \
+            log_println x;                                             \
+        }                                                                              \
+    } while (0)
+
+# define PRINTJVMWARNINGS(x)
+/*     do { \ */
+/*         if (opt_PrintJVMWarnings) { \ */
+/*             log_println x; \ */
+/*         } \ */
+/*     } while (0) */
+
+#else
+
+# define TRACEJVMCALLS(x)
+# define TRACEJVMCALLSENTER(x)
+# define TRACEJVMCALLSEXIT(x)
+# define TRACEJVMCALLSVERBOSE(x)
+# define PRINTJVMWARNINGS(x)
+
+#endif
+
+
+// Interface functions are exported as C functions.
+extern "C" {
+
+int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
+{
+       if ((intptr_t) count <= 0)
+               return -1;
+
+       return vsnprintf(str, count, fmt, args);
+}
+
+
+int jio_snprintf(char *str, size_t count, const char *fmt, ...)
+{
+       va_list ap;
+       int     len;
+
+       va_start(ap, fmt);
+       len = jio_vsnprintf(str, count, fmt, ap);
+       va_end(ap);
+
+       return len;
+}
+
+
+int jio_fprintf(FILE* f, const char *fmt, ...)
+{
+       log_println("jio_fprintf: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+int jio_vfprintf(FILE* f, const char *fmt, va_list args)
+{
+       log_println("jio_vfprintf: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+int jio_printf(const char *fmt, ...)
+{
+       log_println("jio_printf: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetInterfaceVersion */
+
+jint JVM_GetInterfaceVersion()
+{
+       /* This is defined in hotspot/src/share/vm/prims/jvm.h */
+
+#define JVM_INTERFACE_VERSION 4
+
+       return JVM_INTERFACE_VERSION;
+}
+
+
+/* JVM_CurrentTimeMillis */
+
+jlong JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored)
+{
+       TRACEJVMCALLS(("JVM_CurrentTimeMillis(env=%p, ignored=%p)", env, ignored));
+
+       return (jlong) builtin_currenttimemillis();
+}
+
+
+/* JVM_NanoTime */
+
+jlong JVM_NanoTime(JNIEnv *env, jclass ignored)
+{
+       TRACEJVMCALLS(("JVM_NanoTime(env=%p, ignored=%p)", env, ignored));
+
+       return (jlong) builtin_nanotime();
+}
+
+
+/* JVM_ArrayCopy */
+
+void JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length)
+{
+       java_handle_t *s;
+       java_handle_t *d;
+
+       s = (java_handle_t *) src;
+       d = (java_handle_t *) dst;
+
+       TRACEJVMCALLSVERBOSE(("JVM_ArrayCopy(env=%p, ignored=%p, src=%p, src_pos=%d, dst=%p, dst_pos=%d, length=%d)", env, ignored, src, src_pos, dst, dst_pos, length));
+
+       builtin_arraycopy(s, src_pos, d, dst_pos, length);
+}
+
+
+/* JVM_InitProperties */
+
+jobject JVM_InitProperties(JNIEnv *env, jobject properties)
+{
+       java_handle_t *h;
+       char           buf[256];
+
+       TRACEJVMCALLS(("JVM_InitProperties(env=%p, properties=%p)", env, properties));
+
+       h = (java_handle_t *) properties;
+
+       /* Convert the -XX:MaxDirectMemorySize= command line flag to the
+          sun.nio.MaxDirectMemorySize property.  Do this after setting
+          user properties to prevent people from setting the value with a
+          -D option, as requested. */
+
+       jio_snprintf(buf, sizeof(buf), PRINTF_FORMAT_INT64_T, opt_MaxDirectMemorySize);
+       VM::get_current()->get_properties().put("sun.nio.MaxDirectMemorySize", buf);
+
+       // Fill the java.util.Properties object.
+       VM::get_current()->get_properties().fill(h);
+
+       return properties;
+}
+
+
+/* JVM_Exit */
+
+void JVM_Exit(jint code)
+{
+       log_println("JVM_Exit: IMPLEMENT ME!");
+}
+
+
+/* JVM_Halt */
+
+void JVM_Halt(jint code)
+{
+       TRACEJVMCALLS(("JVM_Halt(code=%d)", code));
+
+/*     vm_exit(code); */
+       vm_shutdown(code);
+}
+
+
+/* JVM_OnExit(void (*func)) */
+
+void JVM_OnExit(void (*func)(void))
+{
+       log_println("JVM_OnExit(void (*func): IMPLEMENT ME!");
+}
+
+
+/* JVM_GC */
+
+void JVM_GC(void)
+{
+       TRACEJVMCALLS(("JVM_GC()"));
+
+       gc_call();
+}
+
+
+/* JVM_MaxObjectInspectionAge */
+
+jlong JVM_MaxObjectInspectionAge(void)
+{
+       log_println("JVM_MaxObjectInspectionAge: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_TraceInstructions */
+
+void JVM_TraceInstructions(jboolean on)
+{
+       log_println("JVM_TraceInstructions: IMPLEMENT ME!");
+}
+
+
+/* JVM_TraceMethodCalls */
+
+void JVM_TraceMethodCalls(jboolean on)
+{
+       log_println("JVM_TraceMethodCalls: IMPLEMENT ME!");
+}
+
+
+/* JVM_TotalMemory */
+
+jlong JVM_TotalMemory(void)
+{
+       TRACEJVMCALLS(("JVM_TotalMemory()"));
+
+       return gc_get_heap_size();
+}
+
+
+/* JVM_FreeMemory */
+
+jlong JVM_FreeMemory(void)
+{
+       TRACEJVMCALLS(("JVM_FreeMemory()"));
+
+       return gc_get_free_bytes();
+}
+
+
+/* JVM_MaxMemory */
+
+jlong JVM_MaxMemory(void)
+{
+       TRACEJVMCALLS(("JVM_MaxMemory()"));
+
+       return gc_get_max_heap_size();
+}
+
+
+/* JVM_ActiveProcessorCount */
+
+jint JVM_ActiveProcessorCount(void)
+{
+       TRACEJVMCALLS(("JVM_ActiveProcessorCount()"));
+
+       return os::processors_online();
+}
+
+
+/* JVM_FillInStackTrace */
+
+void JVM_FillInStackTrace(JNIEnv *env, jobject receiver)
+{
+       TRACEJVMCALLS(("JVM_FillInStackTrace(env=%p, receiver=%p)", env, receiver));
+
+       java_handle_bytearray_t* ba = stacktrace_get_current();
+
+       if (ba == NULL)
+               return;
+
+       java_lang_Throwable jlt(receiver, ba);
+}
+
+
+/* JVM_PrintStackTrace */
+
+void JVM_PrintStackTrace(JNIEnv *env, jobject receiver, jobject printable)
+{
+       log_println("JVM_PrintStackTrace: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetStackTraceDepth */
+
+jint JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable)
+{
+       TRACEJVMCALLS(("JVM_GetStackTraceDepth(env=%p, throwable=%p)", env, throwable));
+
+       java_lang_Throwable jlt(throwable);
+
+       if (jlt.is_null()) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       java_handle_bytearray_t* ba = jlt.get_backtrace();
+
+       if (ba == NULL)
+               return 0;
+
+       // We need a critical section here as the stacktrace structure is
+       // mapped onto a Java byte-array.
+
+       LLNI_CRITICAL_START;
+
+       stacktrace_t* st = (stacktrace_t *) LLNI_array_data(ba);
+
+       int32_t depth = st->length;
+
+       LLNI_CRITICAL_END;
+
+       return depth;
+}
+
+
+/* JVM_GetStackTraceElement */
+
+jobject JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index)
+{
+       TRACEJVMCALLS(("JVM_GetStackTraceElement(env=%p, throwable=%p, index=%d)", env, throwable, index));
+
+       java_lang_Throwable jlt(throwable);
+       java_handle_bytearray_t* ba = jlt.get_backtrace();
+
+       // We need a critical section here as the stacktrace structure is
+       // mapped onto a Java byte-array.
+       LLNI_CRITICAL_START;
+
+       stacktrace_t* st = (stacktrace_t *) LLNI_array_data(ba);
+
+       if ((index < 0) || (index >= st->length)) {
+               /* XXX This should be an IndexOutOfBoundsException (check this
+                  again). */
+               exceptions_throw_arrayindexoutofboundsexception();
+               return NULL;
+       }
+
+       // Get the stacktrace entry.
+       stacktrace_entry_t* ste = &(st->entries[index]);
+
+       // Get the codeinfo, methodinfo and classinfo.
+       codeinfo*   code = ste->code;
+       methodinfo* m    = code->m;
+       classinfo*  c    = m->clazz;
+
+       // Get filename.
+       java_handle_t* filename;
+
+       if (!(m->flags & ACC_NATIVE)) {
+               if (c->sourcefile != NULL)
+                       filename = javastring_new(c->sourcefile);
+               else
+                       filename = NULL;
+       }
+       else
+               filename = NULL;
+
+       // Get line number.
+       int32_t linenumber;
+
+       if (m->flags & ACC_NATIVE) {
+               linenumber = -2;
+       }
+       else {
+               // FIXME linenumbertable->find could change the methodinfo
+               // pointer when hitting an inlined method.
+               linenumber = code->linenumbertable->find(&m, ste->pc);
+               linenumber = (linenumber == 0) ? -1 : linenumber;
+       }
+
+       LLNI_CRITICAL_END;
+
+       // Get declaring class name.
+       java_handle_t* declaringclass = class_get_classname(c);
+
+       // Allocate a new StackTraceElement object.
+       java_lang_StackTraceElement jlste(declaringclass, javastring_new(m->name), filename, linenumber);
+
+       if (jlste.is_null())
+               return NULL;
+
+       return (jobject) jlste.get_handle();
+}
+
+
+/* JVM_IHashCode */
+
+jint JVM_IHashCode(JNIEnv* env, jobject handle)
+{
+       TRACEJVMCALLS(("JVM_IHashCode(env=%p, jobject=%p)", env, handle));
+
+       java_lang_Object o(handle);
+
+       return o.get_hashcode();
+}
+
+
+/* JVM_MonitorWait */
+
+void JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *o;
+#endif
+
+       TRACEJVMCALLS(("JVM_MonitorWait(env=%p, handle=%p, ms=%ld)", env, handle, ms));
+    if (ms < 0) {
+/*             exceptions_throw_illegalargumentexception("argument out of range"); */
+               exceptions_throw_illegalargumentexception();
+               return;
+       }
+
+#if defined(ENABLE_THREADS)
+       o = (java_handle_t *) handle;
+
+       lock_wait_for_object(o, ms, 0);
+#endif
+}
+
+
+/* JVM_MonitorNotify */
+
+void JVM_MonitorNotify(JNIEnv* env, jobject handle)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *o;
+#endif
+
+       TRACEJVMCALLS(("JVM_MonitorNotify(env=%p, handle=%p)", env, handle));
+
+#if defined(ENABLE_THREADS)
+       o = (java_handle_t *) handle;
+
+       lock_notify_object(o);
+#endif
+}
+
+
+/* JVM_MonitorNotifyAll */
+
+void JVM_MonitorNotifyAll(JNIEnv* env, jobject handle)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *o;
+#endif
+
+       TRACEJVMCALLS(("JVM_MonitorNotifyAll(env=%p, handle=%p)", env, handle));
+
+#if defined(ENABLE_THREADS)
+       o = (java_handle_t *) handle;
+
+       lock_notify_all_object(o);
+#endif
+}
+
+
+/* JVM_Clone */
+
+jobject JVM_Clone(JNIEnv* env, jobject handle)
+{
+       TRACEJVMCALLS(("JVM_Clone(env=%p, handle=%p)", env, handle));
+
+       return (jobject) builtin_clone(env, (java_handle_t *) handle);
+}
+
+
+/* JVM_InitializeCompiler  */
+
+void JVM_InitializeCompiler (JNIEnv *env, jclass compCls)
+{
+       log_println("JVM_InitializeCompiler : IMPLEMENT ME!");
+}
+
+
+/* JVM_IsSilentCompiler */
+
+jboolean JVM_IsSilentCompiler(JNIEnv *env, jclass compCls)
+{
+       log_println("JVM_IsSilentCompiler: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_CompileClass */
+
+jboolean JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls)
+{
+       log_println("JVM_CompileClass: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_CompileClasses */
+
+jboolean JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname)
+{
+       log_println("JVM_CompileClasses: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_CompilerCommand */
+
+jobject JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg)
+{
+       log_println("JVM_CompilerCommand: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_EnableCompiler */
+
+void JVM_EnableCompiler(JNIEnv *env, jclass compCls)
+{
+       TRACEJVMCALLS(("JVM_EnableCompiler(env=%p, compCls=%p)", env, compCls));
+       PRINTJVMWARNINGS(("JVM_EnableCompiler not supported"));
+}
+
+
+/* JVM_DisableCompiler */
+
+void JVM_DisableCompiler(JNIEnv *env, jclass compCls)
+{
+       TRACEJVMCALLS(("JVM_DisableCompiler(env=%p, compCls=%p)", env, compCls));
+       PRINTJVMWARNINGS(("JVM_DisableCompiler not supported"));
+}
+
+
+/* JVM_GetLastErrorString */
+
+jint JVM_GetLastErrorString(char* buf, int len)
+{
+       TRACEJVMCALLS(("JVM_GetLastErrorString(buf=%p, len=%d", buf, len));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       return hpi.get_system().GetLastErrorString(buf, len);
+}
+
+
+/* JVM_NativePath */
+
+char *JVM_NativePath(char* path)
+{
+       TRACEJVMCALLS(("JVM_NativePath(path=%s)", path));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       return hpi.get_file().NativePath(path);
+}
+
+
+/* JVM_GetCallerClass */
+
+jclass JVM_GetCallerClass(JNIEnv* env, int depth)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_GetCallerClass(env=%p, depth=%d)", env, depth));
+
+       c = stacktrace_get_caller_class(depth);
+
+       return (jclass) c;
+}
+
+
+/* JVM_FindPrimitiveClass */
+
+jclass JVM_FindPrimitiveClass(JNIEnv* env, const char* s)
+{
+       classinfo *c;
+       utf       *u;
+
+       TRACEJVMCALLS(("JVM_FindPrimitiveClass(env=%p, s=%s)", env, s));
+
+       u = utf_new_char(s);
+       c = Primitive::get_class_by_name(u);
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/* JVM_ResolveClass */
+
+void JVM_ResolveClass(JNIEnv* env, jclass cls)
+{
+       TRACEJVMCALLS(("JVM_ResolveClass(env=%p, cls=%p)", env, cls));
+       PRINTJVMWARNINGS(("JVM_ResolveClass not implemented"));
+}
+
+
+/* JVM_FindClassFromClassLoader */
+
+jclass JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, jboolean init, jobject loader, jboolean throwError)
+{
+       classinfo     *c;
+       utf           *u;
+       classloader_t *cl;
+
+       TRACEJVMCALLS(("JVM_FindClassFromClassLoader(name=%s, init=%d, loader=%p, throwError=%d)", name, init, loader, throwError));
+
+       /* As of now, OpenJDK does not call this function with throwError
+          is true. */
+
+       assert(throwError == false);
+
+       u  = utf_new_char(name);
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       c = load_class_from_classloader(u, cl);
+
+       if (c == NULL)
+               return NULL;
+
+       if (init)
+               if (!(c->state & CLASS_INITIALIZED))
+                       if (!initialize_class(c))
+                               return NULL;
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/* JVM_FindClassFromClass */
+
+jclass JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, jclass from)
+{
+       log_println("JVM_FindClassFromClass: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_DefineClass */
+
+jclass JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd)
+{
+       log_println("JVM_DefineClass: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_DefineClassWithSource */
+
+jclass JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source)
+{
+       classinfo     *c;
+       utf           *u;
+       classloader_t *cl;
+
+       TRACEJVMCALLS(("JVM_DefineClassWithSource(env=%p, name=%s, loader=%p, buf=%p, len=%d, pd=%p, source=%s)", env, name, loader, buf, len, pd, source));
+
+       if (name != NULL)
+               u = utf_new_char(name);
+       else
+               u = NULL;
+
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       /* XXX do something with source */
+
+       c = class_define(u, cl, len, (uint8_t *) buf, (java_handle_t *) pd);
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/* JVM_FindLoadedClass */
+
+jclass JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)
+{
+       classloader_t *cl;
+       utf           *u;
+       classinfo     *c;
+
+       TRACEJVMCALLS(("JVM_FindLoadedClass(env=%p, loader=%p, name=%p)", env, loader, name));
+
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       u = javastring_toutf((java_handle_t *) name, true);
+       c = classcache_lookup(cl, u);
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/* JVM_GetClassName */
+
+jstring JVM_GetClassName(JNIEnv *env, jclass cls)
+{
+       classinfo* c;
+
+       TRACEJVMCALLS(("JVM_GetClassName(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       return (jstring) class_get_classname(c);
+}
+
+
+/* JVM_GetClassInterfaces */
+
+jobjectArray JVM_GetClassInterfaces(JNIEnv *env, jclass cls)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_GetClassInterfaces(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       oa = class_get_interfaces(c);
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetClassLoader */
+
+jobject JVM_GetClassLoader(JNIEnv *env, jclass cls)
+{
+       classinfo     *c;
+       classloader_t *cl;
+
+       TRACEJVMCALLSENTER(("JVM_GetClassLoader(env=%p, cls=%p)", env, cls));
+
+       c  = LLNI_classinfo_unwrap(cls);
+       cl = class_get_classloader(c);
+
+       TRACEJVMCALLSEXIT(("->%p", cl));
+
+       return (jobject) cl;
+}
+
+
+/* JVM_IsInterface */
+
+jboolean JVM_IsInterface(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_IsInterface(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       return class_is_interface(c);
+}
+
+
+/* JVM_GetClassSigners */
+
+jobjectArray JVM_GetClassSigners(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetClassSigners: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_SetClassSigners */
+
+void JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *hoa;
+
+       TRACEJVMCALLS(("JVM_SetClassSigners(env=%p, cls=%p, signers=%p)", env, cls, signers));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       hoa = (java_handle_objectarray_t *) signers;
+
+    /* This call is ignored for primitive types and arrays.  Signers
+          are only set once, ClassLoader.java, and thus shouldn't be
+          called with an array.  Only the bootstrap loader creates
+          arrays. */
+
+       if (class_is_primitive(c) || class_is_array(c))
+               return;
+
+       LLNI_classinfo_field_set(c, signers, hoa);
+}
+
+
+/* JVM_GetProtectionDomain */
+
+jobject JVM_GetProtectionDomain(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_GetProtectionDomain(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       if (c == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+    /* Primitive types do not have a protection domain. */
+
+       if (class_is_primitive(c))
+               return NULL;
+
+       return (jobject) c->protectiondomain;
+}
+
+
+/* JVM_SetProtectionDomain */
+
+void JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain)
+{
+       log_println("JVM_SetProtectionDomain: IMPLEMENT ME!");
+}
+
+
+/* JVM_DoPrivileged */
+
+jobject JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, jobject context, jboolean wrapException)
+{
+       java_handle_t *h;
+       classinfo     *c;
+       methodinfo    *m;
+       java_handle_t *result;
+       java_handle_t *e;
+
+       TRACEJVMCALLS(("JVM_DoPrivileged(env=%p, cls=%p, action=%p, context=%p, wrapException=%d)", env, cls, action, context, wrapException));
+
+       h = (java_handle_t *) action;
+       LLNI_class_get(h, c);
+
+       if (action == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* lookup run() method (throw no exceptions) */
+
+       m = class_resolveclassmethod(c, utf_run, utf_void__java_lang_Object, c,
+                                                                false);
+
+       if ((m == NULL) || !(m->flags & ACC_PUBLIC) || (m->flags & ACC_STATIC)) {
+               exceptions_throw_internalerror("No run method");
+               return NULL;
+       }
+
+       /* XXX It seems something with a privileged stack needs to be done
+          here. */
+
+       result = vm_call_method(m, h);
+
+       e = exceptions_get_exception();
+
+       if (e != NULL) {
+               if ( builtin_instanceof(e, class_java_lang_Exception) &&
+                       !builtin_instanceof(e, class_java_lang_RuntimeException)) {
+                       exceptions_clear_exception();
+                       exceptions_throw_privilegedactionexception(e);
+               }
+
+               return NULL;
+       }
+
+       return (jobject) result;
+}
+
+
+/* JVM_GetInheritedAccessControlContext */
+
+jobject JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetInheritedAccessControlContext: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetStackAccessControlContext */
+
+jobject JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)
+{
+       TRACEJVMCALLS(("JVM_GetStackAccessControlContext(env=%p, cls=%p): IMPLEMENT ME!", env, cls));
+
+       /* XXX All stuff I tested so far works without that function.  At
+          some point we have to implement it, but I disable the output
+          for now to make IcedTea happy. */
+
+       return NULL;
+}
+
+
+/* JVM_IsArrayClass */
+
+jboolean JVM_IsArrayClass(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_IsArrayClass(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       return class_is_array(c);
+}
+
+
+/* JVM_IsPrimitiveClass */
+
+jboolean JVM_IsPrimitiveClass(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_IsPrimitiveClass(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       return class_is_primitive(c);
+}
+
+
+/* JVM_GetComponentType */
+
+jclass JVM_GetComponentType(JNIEnv *env, jclass cls)
+{
+       classinfo *component;
+       classinfo *c;
+       
+       TRACEJVMCALLS(("JVM_GetComponentType(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+       
+       component = class_get_componenttype(c);
+
+       return (jclass) LLNI_classinfo_wrap(component);
+}
+
+
+/* JVM_GetClassModifiers */
+
+jint JVM_GetClassModifiers(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+       int32_t    flags;
+
+       TRACEJVMCALLS(("JVM_GetClassModifiers(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       flags = class_get_modifiers(c, false);
+
+       return flags;
+}
+
+
+/* JVM_GetDeclaredClasses */
+
+jobjectArray JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_GetDeclaredClasses(env=%p, ofClass=%p)", env, ofClass));
+
+       c = LLNI_classinfo_unwrap(ofClass);
+
+       oa = class_get_declaredclasses(c, false);
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetDeclaringClass */
+
+jclass JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)
+{
+       classinfo *c;
+       classinfo *dc;
+
+       TRACEJVMCALLS(("JVM_GetDeclaringClass(env=%p, ofClass=%p)", env, ofClass));
+
+       c = LLNI_classinfo_unwrap(ofClass);
+
+       dc = class_get_declaringclass(c);
+
+       return (jclass) LLNI_classinfo_wrap(dc);
+}
+
+
+/* JVM_GetClassSignature */
+
+jstring JVM_GetClassSignature(JNIEnv *env, jclass cls)
+{
+       classinfo     *c;
+       utf           *u;
+       java_handle_t *s;
+
+       TRACEJVMCALLS(("JVM_GetClassSignature(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       /* Get the signature of the class. */
+
+       u = class_get_signature(c);
+
+       if (u == NULL)
+               return NULL;
+
+       /* Convert UTF-string to a Java-string. */
+
+       s = javastring_new(u);
+
+       return (jstring) s;
+}
+
+
+/* JVM_GetClassAnnotations */
+
+jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls)
+{
+       TRACEJVMCALLS(("JVM_GetClassAnnotations(env=%p, cls=%p)", env, cls));
+
+       if (cls == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+       
+       classinfo* c = LLNI_classinfo_unwrap(cls);
+
+       /* get annotations: */
+       java_handle_bytearray_t* annotations = class_get_annotations(c);
+
+       return (jbyteArray) annotations;
+}
+
+
+/* JVM_GetFieldAnnotations */
+
+jbyteArray JVM_GetFieldAnnotations(JNIEnv *env, jobject field)
+{
+       TRACEJVMCALLS(("JVM_GetFieldAnnotations(env=%p, field=%p)", env, field));
+
+       java_lang_reflect_Field jlrf(field);
+
+       if (jlrf.is_null()) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       return (jbyteArray) jlrf.get_annotations();
+}
+
+
+/* JVM_GetMethodAnnotations */
+
+jbyteArray JVM_GetMethodAnnotations(JNIEnv *env, jobject method)
+{
+       TRACEJVMCALLS(("JVM_GetMethodAnnotations(env=%p, method=%p)", env, method));
+
+       java_lang_reflect_Method jlrm(method);
+
+       if (jlrm.is_null()) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       return (jbyteArray) jlrm.get_annotations();
+}
+
+
+/* JVM_GetMethodDefaultAnnotationValue */
+
+jbyteArray JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)
+{
+       TRACEJVMCALLS(("JVM_GetMethodDefaultAnnotationValue(env=%p, method=%p)", env, method));
+
+       java_lang_reflect_Method jlrm(method);
+
+       if (jlrm.is_null()) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       return (jbyteArray) jlrm.get_annotationDefault();
+}
+
+
+/* JVM_GetMethodParameterAnnotations */
+
+jbyteArray JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)
+{
+       TRACEJVMCALLS(("JVM_GetMethodParameterAnnotations(env=%p, method=%p)", env, method));
+
+       java_lang_reflect_Method jlrm(method);
+
+       if (jlrm.is_null()) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       return (jbyteArray) jlrm.get_parameterAnnotations();
+}
+
+
+/* JVM_GetClassDeclaredFields */
+
+jobjectArray JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_GetClassDeclaredFields(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
+
+       c = LLNI_classinfo_unwrap(ofClass);
+
+       oa = class_get_declaredfields(c, publicOnly);
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetClassDeclaredMethods */
+
+jobjectArray JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly)
+{
+       TRACEJVMCALLS(("JVM_GetClassDeclaredMethods(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
+
+       classinfo* c = LLNI_classinfo_unwrap(ofClass);
+
+       java_handle_objectarray_t* oa = class_get_declaredmethods(c, publicOnly);
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetClassDeclaredConstructors */
+
+jobjectArray JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_GetClassDeclaredConstructors(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
+
+       c = LLNI_classinfo_unwrap(ofClass);
+
+       oa = class_get_declaredconstructors(c, publicOnly);
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetClassAccessFlags */
+
+jint JVM_GetClassAccessFlags(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_GetClassAccessFlags(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       /* Primitive type classes have the correct access flags. */
+
+       return c->flags & ACC_CLASS_REFLECT_MASK;
+}
+
+
+/* JVM_GetClassConstantPool */
+
+jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls)
+{
+#if defined(ENABLE_ANNOTATIONS)
+       TRACEJVMCALLS(("JVM_GetClassConstantPool(env=%p, cls=%p)", env, cls));
+
+       java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool);
+       sun_reflect_ConstantPool cp(h, cls);
+       
+       if (cp.is_null()) {
+               return NULL;
+       }
+       
+       return (jobject) cp.get_handle();
+#else
+       log_println("JVM_GetClassConstantPool(env=%p, cls=%p): not implemented in this configuration!", env, cls);
+       return NULL;
+#endif
+}
+
+
+/* JVM_ConstantPoolGetSize */
+
+jint JVM_ConstantPoolGetSize(JNIEnv *env, jobject unused, jobject jcpool)
+{
+       classinfo *c; /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetSize(env=%p, unused=%p, jcpool=%p)", env, unused, jcpool));
+
+       c = LLNI_classinfo_unwrap(jcpool);
+
+       return c->cpcount;
+}
+
+
+/* JVM_ConstantPoolGetClassAt */
+
+jclass JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_classref *ref;    /* classref to the class at constant pool index 'index' */
+       classinfo         *c;      /* classinfo of the class for which 'this' is the constant pool */
+       classinfo         *result; /* classinfo of the class at constant pool index 'index' */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetClassAt(env=%p, jcpool=%p, index=%d)", env, jcpool, index));
+
+       c = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       result = resolve_classref_eager(ref);
+
+       return (jclass) LLNI_classinfo_wrap(result);
+}
+
+
+/* JVM_ConstantPoolGetClassAtIfLoaded */
+
+jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_classref *ref;    /* classref to the class at constant pool index 'index' */
+       classinfo         *c;      /* classinfo of the class for which 'this' is the constant pool */
+       classinfo         *result; /* classinfo of the class at constant pool index 'index' */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetClassAtIfLoaded(env=%p, unused=%p, jcpool=%p, index=%d)", env, unused, jcpool, index));
+
+       c = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+       
+       if (!resolve_classref(NULL, ref, resolveLazy, true, true, &result)) {
+               return NULL;
+       }
+
+       if ((result == NULL) || !(result->state & CLASS_LOADED)) {
+               return NULL;
+       }
+       
+       return (jclass) LLNI_classinfo_wrap(result);
+}
+
+
+/* JVM_ConstantPoolGetMethodAt */
+
+jobject JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */
+       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
+       
+       TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAt: jcpool=%p, index=%d", jcpool, index));
+       
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
+       
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       // Create a new java.lang.reflect.Method Java object.
+       /* XXX: is that right? or do I have to use resolve_method_*? */
+       java_lang_reflect_Method jlrm(ref->p.method);
+
+       return (jobject) jlrm.get_handle();
+}
+
+
+/* JVM_ConstantPoolGetMethodAtIfLoaded */
+
+jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */
+       classinfo *c = NULL;  /* resolved declaring class of the method */
+       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAtIfLoaded: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) {
+               return NULL;
+       }
+
+       if (c == NULL || !(c->state & CLASS_LOADED)) {
+               return NULL;
+       }
+
+       // Create a new java.lang.reflect.Method Java object.
+       java_lang_reflect_Method jlrm(ref->p.method);
+
+       return (jobject) jlrm.get_handle();
+}
+
+
+/* JVM_ConstantPoolGetFieldAt */
+
+jobject JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */
+       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
+       
+       TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAt: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       // Create a new java.lang.reflect.Field Java object.
+       java_lang_reflect_Field jlrf(ref->p.field);
+
+       return (jobject) jlrf.get_handle();
+}
+
+
+/* JVM_ConstantPoolGetFieldAtIfLoaded */
+
+jobject JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */
+       classinfo *c;         /* resolved declaring class for the field */
+       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAtIfLoaded: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) {
+               return NULL;
+       }
+
+       if (c == NULL || !(c->state & CLASS_LOADED)) {
+               return NULL;
+       }
+
+       // Create a new java.lang.reflect.Field Java object.
+       java_lang_reflect_Field jlrf(ref->p.field);
+
+       return (jobject) jlrf.get_handle();
+}
+
+
+/* JVM_ConstantPoolGetMemberRefInfoAt */
+
+jobjectArray JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       log_println("JVM_ConstantPoolGetMemberRefInfoAt: jcpool=%p, index=%d, IMPLEMENT ME!", jcpool, index);
+
+       /* TODO: implement. (this is yet unused be OpenJDK but, so very low priority) */
+
+       return NULL;
+}
+
+
+/* JVM_ConstantPoolGetIntAt */
+
+jint JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_integer *ref; /* reference to the int value in constant pool at index 'index' */
+       classinfo *cls;        /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetIntAt: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_integer*)class_getconstant(cls, index, CONSTANT_Integer);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/* JVM_ConstantPoolGetLongAt */
+
+jlong JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_long *ref; /* reference to the long value in constant pool at index 'index' */
+       classinfo *cls;     /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetLongAt: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_long*)class_getconstant(cls, index, CONSTANT_Long);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/* JVM_ConstantPoolGetFloatAt */
+
+jfloat JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_float *ref; /* reference to the float value in constant pool at index 'index' */
+       classinfo *cls;      /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetFloatAt: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_float*)class_getconstant(cls, index, CONSTANT_Float);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/* JVM_ConstantPoolGetDoubleAt */
+
+jdouble JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_double *ref; /* reference to the double value in constant pool at index 'index' */
+       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetDoubleAt: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_double*)class_getconstant(cls, index, CONSTANT_Double);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/* JVM_ConstantPoolGetStringAt */
+
+jstring JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       utf *ref;       /* utf object for the string in constant pool at index 'index' */
+       classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetStringAt: jcpool=%p, index=%d", jcpool, index));
+       
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (utf*)class_getconstant(cls, index, CONSTANT_String);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX: I hope literalstring_new is the right Function. */
+       return (jstring)literalstring_new(ref);
+}
+
+
+/* JVM_ConstantPoolGetUTF8At */
+
+jstring JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       utf *ref; /* utf object for the utf8 data in constant pool at index 'index' */
+       classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetUTF8At: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX: I hope literalstring_new is the right Function. */
+       return (jstring)literalstring_new(ref);
+}
+
+
+/* JVM_DesiredAssertionStatus */
+
+jboolean JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls)
+{
+#if defined(ENABLE_ASSERTION)
+       classinfo         *c;
+       jboolean           status;
+       utf               *name;
+
+       TRACEJVMCALLS(("JVM_DesiredAssertionStatus(env=%p, unused=%p, cls=%p)", env, unused, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       if (c->classloader == NULL) {
+               status = (jboolean)assertion_system_enabled;
+       }
+       else {
+               status = (jboolean)assertion_user_enabled;
+       }
+
+       if (list_assertion_names != NULL) {
+               for (List<assertion_name_t*>::iterator it = list_assertion_names->begin();
+                        it != list_assertion_names->end(); it++) {
+                       assertion_name_t* item = *it;
+
+                       name = utf_new_char(item->name);
+                       if (name == c->packagename) {
+                               status = (jboolean)item->enabled;
+                       }
+                       else if (name == c->name) {
+                               status = (jboolean)item->enabled;
+                       }
+               }
+       }
+
+       return status;
+#else
+       return (jboolean)false;
+#endif
+}
+
+
+/* JVM_AssertionStatusDirectives */
+
+jobject JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused)
+{
+       java_handle_objectarray_t             *classes;
+       java_handle_objectarray_t             *packages;
+       java_booleanarray_t                   *classEnabled;
+       java_booleanarray_t                   *packageEnabled;
+#if defined(ENABLE_ASSERTION)
+       java_handle_t                         *js;
+       s4                                     i, j;
+#endif
+
+       TRACEJVMCALLS(("JVM_AssertionStatusDirectives(env=%p, unused=%p)", env, unused));
+
+#if defined(ENABLE_ASSERTION)
+       classes = builtin_anewarray(assertion_class_count, class_java_lang_Object);
+#else
+       classes = builtin_anewarray(0, class_java_lang_Object);
+#endif
+       if (classes == NULL)
+               return NULL;
+
+#if defined(ENABLE_ASSERTION)
+       packages = builtin_anewarray(assertion_package_count, class_java_lang_Object);
+#else
+       packages = builtin_anewarray(0, class_java_lang_Object);
+#endif
+       if (packages == NULL)
+               return NULL;
+       
+#if defined(ENABLE_ASSERTION)
+       classEnabled = builtin_newarray_boolean(assertion_class_count);
+#else
+       classEnabled = builtin_newarray_boolean(0);
+#endif
+       if (classEnabled == NULL)
+               return NULL;
+
+#if defined(ENABLE_ASSERTION)
+       packageEnabled = builtin_newarray_boolean(assertion_package_count);
+#else
+       packageEnabled = builtin_newarray_boolean(0);
+#endif
+       if (packageEnabled == NULL)
+               return NULL;
+
+#if defined(ENABLE_ASSERTION)
+       /* initialize arrays */
+
+       if (list_assertion_names != NULL) {
+               i = 0;
+               j = 0;
+               
+               for (List<assertion_name_t*>::iterator it = list_assertion_names->begin(); it != list_assertion_names->end(); it++) {
+                       assertion_name_t* item = *it;
+
+                       js = javastring_new_from_ascii(item->name);
+                       if (js == NULL) {
+                               return NULL;
+                       }
+
+                       if (item->package == false) {
+                               classes->data[i] = js;
+                               classEnabled->data[i] = (jboolean) item->enabled;
+                               i += 1;
+                       }
+                       else {
+                               packages->data[j] = js;
+                               packageEnabled->data[j] = (jboolean) item->enabled;
+                               j += 1;
+                       }
+               }
+       }
+#endif
+
+       /* set instance fields */
+
+       java_lang_AssertionStatusDirectives jlasd(classes, classEnabled, packages, packageEnabled);
+
+       return (jobject) jlasd.get_handle();
+}
+
+
+/* JVM_GetClassNameUTF */
+
+const char *JVM_GetClassNameUTF(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetClassNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassCPTypes */
+
+void JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char *types)
+{
+       log_println("JVM_GetClassCPTypes: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetClassCPEntriesCount */
+
+jint JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetClassCPEntriesCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetClassFieldsCount */
+
+jint JVM_GetClassFieldsCount(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetClassFieldsCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetClassMethodsCount */
+
+jint JVM_GetClassMethodsCount(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetClassMethodsCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxExceptionIndexes */
+
+void JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions)
+{
+       log_println("JVM_GetMethodIxExceptionIndexes: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetMethodIxExceptionsCount */
+
+jint JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index)
+{
+       log_println("JVM_GetMethodIxExceptionsCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxByteCode */
+
+void JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code)
+{
+       log_println("JVM_GetMethodIxByteCode: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetMethodIxByteCodeLength */
+
+jint JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index)
+{
+       log_println("JVM_GetMethodIxByteCodeLength: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxExceptionTableEntry */
+
+void JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry)
+{
+       log_println("JVM_GetMethodIxExceptionTableEntry: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetMethodIxExceptionTableLength */
+
+jint JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_GetMethodIxExceptionTableLength: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxModifiers */
+
+jint JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_GetMethodIxModifiers: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetFieldIxModifiers */
+
+jint JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index)
+{
+       log_println("JVM_GetFieldIxModifiers: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxLocalsCount */
+
+jint JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_GetMethodIxLocalsCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxArgsSize */
+
+jint JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_GetMethodIxArgsSize: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxMaxStack */
+
+jint JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_GetMethodIxMaxStack: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_IsConstructorIx */
+
+jboolean JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_IsConstructorIx: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxNameUTF */
+
+const char *JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index)
+{
+       log_println("JVM_GetMethodIxNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetMethodIxSignatureUTF */
+
+const char *JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cls, jint method_index)
+{
+       log_println("JVM_GetMethodIxSignatureUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPFieldNameUTF */
+
+const char *JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPFieldNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPMethodNameUTF */
+
+const char *JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPMethodNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPMethodSignatureUTF */
+
+const char *JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPMethodSignatureUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPFieldSignatureUTF */
+
+const char *JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPFieldSignatureUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPClassNameUTF */
+
+const char *JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPClassNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPFieldClassNameUTF */
+
+const char *JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPFieldClassNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPMethodClassNameUTF */
+
+const char *JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPMethodClassNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPFieldModifiers */
+
+jint JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)
+{
+       log_println("JVM_GetCPFieldModifiers: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetCPMethodModifiers */
+
+jint JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)
+{
+       log_println("JVM_GetCPMethodModifiers: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_ReleaseUTF */
+
+void JVM_ReleaseUTF(const char *utf)
+{
+       log_println("JVM_ReleaseUTF: IMPLEMENT ME!");
+}
+
+
+/* JVM_IsSameClassPackage */
+
+jboolean JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2)
+{
+       log_println("JVM_IsSameClassPackage: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_Open */
+
+/* Taken from: hotspot/src/share/vm/prims/jvm.h */
+
+/*
+ * JVM I/O error codes
+ */
+#define JVM_EEXIST       -100
+
+jint JVM_Open(const char* fname, jint flags, jint mode)
+{
+       int result;
+
+       TRACEJVMCALLS(("JVM_Open(fname=%s, flags=%d, mode=%d)", fname, flags, mode));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       result = hpi.get_file().Open(fname, flags, mode);
+
+       if (result >= 0) {
+               return result;
+       }
+       else {
+               switch (errno) {
+               case EEXIST:
+                       return JVM_EEXIST;
+               default:
+                       return -1;
+               }
+       }
+}
+
+
+/* JVM_Close */
+
+jint JVM_Close(jint fd)
+{
+       TRACEJVMCALLS(("JVM_Close(fd=%d)", fd));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       return hpi.get_file().Close(fd);
+}
+
+
+/* JVM_Read */
+
+jint JVM_Read(jint fd, char* buf, jint nbytes)
+{
+       TRACEJVMCALLS(("JVM_Read(fd=%d, buf=%p, nbytes=%d)", fd, buf, nbytes));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       return (jint) hpi.get_file().Read(fd, buf, nbytes);
+}
+
+
+/* JVM_Write */
+
+jint JVM_Write(jint fd, char* buf, jint nbytes)
+{
+       TRACEJVMCALLS(("JVM_Write(fd=%d, buf=%s, nbytes=%d)", fd, buf, nbytes));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       return (jint) hpi.get_file().Write(fd, buf, nbytes);
+}
+
+
+/* JVM_Available */
+
+jint JVM_Available(jint fd, jlong* pbytes)
+{
+       TRACEJVMCALLS(("JVM_Available(fd=%d, pbytes=%p)", fd, pbytes));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       return hpi.get_file().Available(fd, pbytes);
+}
+
+
+/* JVM_Lseek */
+
+jlong JVM_Lseek(jint fd, jlong offset, jint whence)
+{
+       TRACEJVMCALLS(("JVM_Lseek(fd=%d, offset=%ld, whence=%d)", fd, offset, whence));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       return hpi.get_file().Seek(fd, (off_t) offset, whence);
+}
+
+
+/* JVM_SetLength */
+
+jint JVM_SetLength(jint fd, jlong length)
+{
+       TRACEJVMCALLS(("JVM_SetLength(fd=%d, length=%ld)", length));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       return hpi.get_file().SetLength(fd, length);
+}
+
+
+/* JVM_Sync */
+
+jint JVM_Sync(jint fd)
+{
+       TRACEJVMCALLS(("JVM_Sync(fd=%d)", fd));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       return hpi.get_file().Sync(fd);
+}
+
+
+/* JVM_StartThread */
+
+void JVM_StartThread(JNIEnv* env, jobject jthread)
+{
+       TRACEJVMCALLS(("JVM_StartThread(env=%p, jthread=%p)", env, jthread));
+
+       threads_thread_start((java_handle_t *) jthread);
+}
+
+
+/* JVM_StopThread */
+
+void JVM_StopThread(JNIEnv* env, jobject jthread, jobject throwable)
+{
+       log_println("JVM_StopThread: Deprecated.  Not implemented.");
+}
+
+
+/* JVM_IsThreadAlive */
+
+jboolean JVM_IsThreadAlive(JNIEnv* env, jobject jthread)
+{
+       java_handle_t *h;
+       threadobject  *t;
+       bool           result;
+
+       TRACEJVMCALLS(("JVM_IsThreadAlive(env=%p, jthread=%p)", env, jthread));
+
+       h = (java_handle_t *) jthread;
+       t = thread_get_thread(h);
+
+       /* The threadobject is null when a thread is created in Java. The
+          priority is set later during startup. */
+
+       if (t == NULL)
+               return 0;
+
+       result = threads_thread_is_alive(t);
+
+       return result;
+}
+
+
+/* JVM_SuspendThread */
+
+void JVM_SuspendThread(JNIEnv* env, jobject jthread)
+{
+       log_println("JVM_SuspendThread: Deprecated.  Not implemented.");
+}
+
+
+/* JVM_ResumeThread */
+
+void JVM_ResumeThread(JNIEnv* env, jobject jthread)
+{
+       log_println("JVM_ResumeThread: Deprecated.  Not implemented.");
+}
+
+
+/* JVM_SetThreadPriority */
+
+void JVM_SetThreadPriority(JNIEnv* env, jobject jthread, jint prio)
+{
+       java_handle_t *h;
+       threadobject  *t;
+
+       TRACEJVMCALLS(("JVM_SetThreadPriority(env=%p, jthread=%p, prio=%d)", env, jthread, prio));
+
+       h = (java_handle_t *) jthread;
+       t = thread_get_thread(h);
+
+       /* The threadobject is null when a thread is created in Java. The
+          priority is set later during startup. */
+
+       if (t == NULL)
+               return;
+
+       threads_set_thread_priority(t->tid, prio);
+}
+
+
+/* JVM_Yield */
+
+void JVM_Yield(JNIEnv *env, jclass threadClass)
+{
+       TRACEJVMCALLS(("JVM_Yield(env=%p, threadClass=%p)", env, threadClass));
+
+       threads_yield();
+}
+
+
+/* JVM_Sleep */
+
+void JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)
+{
+       TRACEJVMCALLS(("JVM_Sleep(env=%p, threadClass=%p, millis=%ld)", env, threadClass, millis));
+
+       threads_sleep(millis, 0);
+}
+
+
+/* JVM_CurrentThread */
+
+jobject JVM_CurrentThread(JNIEnv* env, jclass threadClass)
+{
+       java_object_t *o;
+
+       TRACEJVMCALLSVERBOSE(("JVM_CurrentThread(env=%p, threadClass=%p)", env, threadClass));
+
+       o = thread_get_current_object();
+
+       return (jobject) o;
+}
+
+
+/* JVM_CountStackFrames */
+
+jint JVM_CountStackFrames(JNIEnv* env, jobject jthread)
+{
+       log_println("JVM_CountStackFrames: Deprecated.  Not implemented.");
+
+       return 0;
+}
+
+
+/* JVM_Interrupt */
+
+void JVM_Interrupt(JNIEnv* env, jobject jthread)
+{
+       java_handle_t *h;
+       threadobject  *t;
+
+       TRACEJVMCALLS(("JVM_Interrupt(env=%p, jthread=%p)", env, jthread));
+
+       h = (java_handle_t *) jthread;
+       t = thread_get_thread(h);
+
+       if (t == NULL)
+               return;
+
+       threads_thread_interrupt(t);
+}
+
+
+/* JVM_IsInterrupted */
+
+jboolean JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrupted)
+{
+       java_handle_t *h;
+       threadobject  *t;
+       jboolean       interrupted;
+
+       TRACEJVMCALLS(("JVM_IsInterrupted(env=%p, jthread=%p, clear_interrupted=%d)", env, jthread, clear_interrupted));
+
+       h = (java_handle_t *) jthread;
+       t = thread_get_thread(h);
+
+       interrupted = thread_is_interrupted(t);
+
+       if (interrupted && clear_interrupted)
+               thread_set_interrupted(t, false);
+
+       return interrupted;
+}
+
+
+/* JVM_HoldsLock */
+
+jboolean JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj)
+{
+       java_handle_t *h;
+       bool           result;
+
+       TRACEJVMCALLS(("JVM_HoldsLock(env=%p, threadClass=%p, obj=%p)", env, threadClass, obj));
+
+       h = (java_handle_t *) obj;
+
+       if (h == NULL) {
+               exceptions_throw_nullpointerexception();
+               return JNI_FALSE;
+       }
+
+       result = lock_is_held_by_current_thread(h);
+
+       return result;
+}
+
+
+/* JVM_DumpAllStacks */
+
+void JVM_DumpAllStacks(JNIEnv* env, jclass unused)
+{
+       log_println("JVM_DumpAllStacks: IMPLEMENT ME!");
+}
+
+
+/* JVM_CurrentLoadedClass */
+
+jclass JVM_CurrentLoadedClass(JNIEnv *env)
+{
+       log_println("JVM_CurrentLoadedClass: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_CurrentClassLoader */
+
+jobject JVM_CurrentClassLoader(JNIEnv *env)
+{
+    /* XXX if a method in a class in a trusted loader is in a
+          doPrivileged, return NULL */
+
+       log_println("JVM_CurrentClassLoader: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassContext */
+
+jobjectArray JVM_GetClassContext(JNIEnv *env)
+{
+       TRACEJVMCALLS(("JVM_GetClassContext(env=%p)", env));
+
+       return (jobjectArray) stacktrace_getClassContext();
+}
+
+
+/* JVM_ClassDepth */
+
+jint JVM_ClassDepth(JNIEnv *env, jstring name)
+{
+       log_println("JVM_ClassDepth: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_ClassLoaderDepth */
+
+jint JVM_ClassLoaderDepth(JNIEnv *env)
+{
+       log_println("JVM_ClassLoaderDepth: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetSystemPackage */
+
+jstring JVM_GetSystemPackage(JNIEnv *env, jstring name)
+{
+       java_handle_t *s;
+       utf *u;
+       utf *result;
+
+       TRACEJVMCALLS(("JVM_GetSystemPackage(env=%p, name=%p)", env, name));
+
+/*     s = Package::find(name); */
+       u = javastring_toutf((java_handle_t *) name, false);
+
+       result = Package::find(u);
+
+       if (result != NULL)
+               s = javastring_new(result);
+       else
+               s = NULL;
+
+       return (jstring) s;
+}
+
+
+/* JVM_GetSystemPackages */
+
+jobjectArray JVM_GetSystemPackages(JNIEnv *env)
+{
+       log_println("JVM_GetSystemPackages: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_AllocateNewObject */
+
+jobject JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass currClass, jclass initClass)
+{
+       log_println("JVM_AllocateNewObject: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_AllocateNewArray */
+
+jobject JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, jint length)
+{
+       log_println("JVM_AllocateNewArray: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_LatestUserDefinedLoader */
+
+jobject JVM_LatestUserDefinedLoader(JNIEnv *env)
+{
+       classloader_t *cl;
+
+       TRACEJVMCALLS(("JVM_LatestUserDefinedLoader(env=%p)", env));
+
+       cl = stacktrace_first_nonnull_classloader();
+
+       return (jobject) cl;
+}
+
+
+/* JVM_LoadClass0 */
+
+jclass JVM_LoadClass0(JNIEnv *env, jobject receiver, jclass currClass, jstring currClassName)
+{
+       log_println("JVM_LoadClass0: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetArrayLength */
+
+jint JVM_GetArrayLength(JNIEnv *env, jobject arr)
+{
+       java_handle_t *a;
+
+       TRACEJVMCALLS(("JVM_GetArrayLength(arr=%p)", arr));
+
+       a = (java_handle_t *) arr;
+
+       return array_length_get(a);
+}
+
+
+/* JVM_GetArrayElement */
+
+jobject JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index)
+{
+       java_handle_t *a;
+       java_handle_t *o;
+
+       TRACEJVMCALLS(("JVM_GetArrayElement(env=%p, arr=%p, index=%d)", env, arr, index));
+
+       a = (java_handle_t *) arr;
+
+/*     if (!class_is_array(a->objheader.vftbl->class)) { */
+/*             exceptions_throw_illegalargumentexception(); */
+/*             return NULL; */
+/*     } */
+
+       o = array_element_get(a, index);
+
+       return (jobject) o;
+}
+
+
+/* JVM_GetPrimitiveArrayElement */
+
+jvalue JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode)
+{
+       jvalue jv;
+
+       log_println("JVM_GetPrimitiveArrayElement: IMPLEMENT ME!");
+
+       jv.l = NULL;
+
+       return jv;
+}
+
+
+/* JVM_SetArrayElement */
+
+void JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val)
+{
+       java_handle_t *a;
+       java_handle_t *value;
+
+       TRACEJVMCALLS(("JVM_SetArrayElement(env=%p, arr=%p, index=%d, val=%p)", env, arr, index, val));
+
+       a     = (java_handle_t *) arr;
+       value = (java_handle_t *) val;
+
+       array_element_set(a, index, value);
+}
+
+
+/* JVM_SetPrimitiveArrayElement */
+
+void JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, unsigned char vCode)
+{
+       log_println("JVM_SetPrimitiveArrayElement: IMPLEMENT ME!");
+}
+
+
+/* JVM_NewArray */
+
+jobject JVM_NewArray(JNIEnv *env, jclass eltClass, jint length)
+{
+       classinfo                 *c;
+       classinfo                 *pc;
+       java_handle_t             *a;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_NewArray(env=%p, eltClass=%p, length=%d)", env, eltClass, length));
+
+       if (eltClass == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* NegativeArraySizeException is checked in builtin_newarray. */
+
+       c = LLNI_classinfo_unwrap(eltClass);
+
+       /* Create primitive or object array. */
+
+       if (class_is_primitive(c)) {
+               pc = Primitive::get_arrayclass_by_name(c->name);
+
+               /* void arrays are not allowed. */
+
+               if (pc == NULL) {
+                       exceptions_throw_illegalargumentexception();
+                       return NULL;
+               }
+
+               a = builtin_newarray(length, pc);
+
+               return (jobject) a;
+       }
+       else {
+               oa = builtin_anewarray(length, c);
+
+               return (jobject) oa;
+       }
+}
+
+
+/* JVM_NewMultiArray */
+
+jobject JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim)
+{
+       classinfo                 *c;
+       java_handle_intarray_t    *ia;
+       int32_t                    length;
+       long                      *dims;
+       int32_t                    value;
+       int32_t                    i;
+       classinfo                 *ac;
+       java_handle_objectarray_t *a;
+
+       TRACEJVMCALLS(("JVM_NewMultiArray(env=%p, eltClass=%p, dim=%p)", env, eltClass, dim));
+
+       if (eltClass == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* NegativeArraySizeException is checked in builtin_newarray. */
+
+       c = LLNI_classinfo_unwrap(eltClass);
+
+       ia = (java_handle_intarray_t *) dim;
+
+       length = array_length_get((java_handle_t *) ia);
+
+       /* We check here for exceptions thrown in array_length_get,
+          otherwise these exceptions get overwritten by the following
+          IllegalArgumentException. */
+
+       if (length < 0)
+               return NULL;
+
+       if ((length <= 0) || (length > /* MAX_DIM */ 255)) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX This is just a quick hack to get it working. */
+
+       dims = MNEW(long, length);
+
+       for (i = 0; i < length; i++) {
+               value = LLNI_array_direct(ia, i);
+               dims[i] = (long) value;
+       }
+
+       /* Create an array-class if necessary. */
+
+       if (class_is_primitive(c))
+               ac = Primitive::get_arrayclass_by_name(c->name);
+       else
+               ac = class_array_of(c, true);
+
+       if (ac == NULL)
+               return NULL;
+
+       a = builtin_multianewarray(length, (java_handle_t *) ac, dims);
+
+       return (jobject) a;
+}
+
+
+/* JVM_InitializeSocketLibrary */
+
+jint JVM_InitializeSocketLibrary()
+{
+       TRACEJVMCALLS(("JVM_InitializeSocketLibrary()"));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       return hpi.initialize_socket_library();
+}
+
+
+/* JVM_Socket */
+
+jint JVM_Socket(jint domain, jint type, jint protocol)
+{
+       TRACEJVMCALLS(("JVM_Socket(domain=%d, type=%d, protocol=%d)", domain, type, protocol));
+
+       return os::socket(domain, type, protocol);
+}
+
+
+/* JVM_SocketClose */
+
+jint JVM_SocketClose(jint fd)
+{
+       TRACEJVMCALLS(("JVM_SocketClose(fd=%d)", fd));
+
+       return os::close(fd);
+}
+
+
+/* JVM_SocketShutdown */
+
+jint JVM_SocketShutdown(jint fd, jint howto)
+{
+       TRACEJVMCALLS(("JVM_SocketShutdown(fd=%d, howto=%d)", fd, howto));
+
+       return os::shutdown(fd, howto);
+}
+
+
+/* JVM_Recv */
+
+jint JVM_Recv(jint fd, char *buf, jint nBytes, jint flags)
+{
+       log_println("JVM_Recv: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_Send */
+
+jint JVM_Send(jint fd, char *buf, jint nBytes, jint flags)
+{
+       log_println("JVM_Send: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_Timeout */
+
+jint JVM_Timeout(int fd, long timeout)
+{
+       log_println("JVM_Timeout: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_Listen */
+
+jint JVM_Listen(jint fd, jint count)
+{
+       TRACEJVMCALLS(("JVM_Listen(fd=%d, count=%d)", fd, count));
+
+       return os::listen(fd, count);
+}
+
+
+/* JVM_Connect */
+
+jint JVM_Connect(jint fd, struct sockaddr *him, jint len)
+{
+       TRACEJVMCALLS(("JVM_Connect(fd=%d, him=%p, len=%d)", fd, him, len));
+
+       return os::connect(fd, him, len);
+}
+
+
+/* JVM_Bind */
+
+jint JVM_Bind(jint fd, struct sockaddr *him, jint len)
+{
+       log_println("JVM_Bind: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_Accept */
+
+jint JVM_Accept(jint fd, struct sockaddr *him, jint *len)
+{
+       TRACEJVMCALLS(("JVM_Accept(fd=%d, him=%p, len=%p)", fd, him, len));
+
+       return os::accept(fd, him, (socklen_t *) len);
+}
+
+
+/* JVM_RecvFrom */
+
+jint JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen)
+{
+       log_println("JVM_RecvFrom: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetSockName */
+
+jint JVM_GetSockName(jint fd, struct sockaddr *him, int *len)
+{
+       TRACEJVMCALLS(("JVM_GetSockName(fd=%d, him=%p, len=%p)", fd, him, len));
+
+       return os::getsockname(fd, him, (socklen_t *) len);
+}
+
+
+/* JVM_SendTo */
+
+jint JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen)
+{
+       log_println("JVM_SendTo: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_SocketAvailable */
+
+jint JVM_SocketAvailable(jint fd, jint *pbytes)
+{
+#if defined(FIONREAD)
+       int bytes;
+       int result;
+
+       TRACEJVMCALLS(("JVM_SocketAvailable(fd=%d, pbytes=%p)", fd, pbytes));
+
+       *pbytes = 0;
+
+       result = ioctl(fd, FIONREAD, &bytes);
+
+       if (result < 0)
+               return 0;
+
+       *pbytes = bytes;
+
+       return 1;
+#else
+# error FIONREAD not defined
+#endif
+}
+
+
+/* JVM_GetSockOpt */
+
+jint JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen)
+{
+       TRACEJVMCALLS(("JVM_GetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%p)", fd, level, optname, optval, optlen));
+
+       return os::getsockopt(fd, level, optname, optval, (socklen_t *) optlen);
+}
+
+
+/* JVM_SetSockOpt */
+
+jint JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen)
+{
+       TRACEJVMCALLS(("JVM_SetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%d)", fd, level, optname, optval, optlen));
+
+       return os::setsockopt(fd, level, optname, optval, optlen);
+}
+
+
+/* JVM_GetHostName */
+
+int JVM_GetHostName(char *name, int namelen)
+{
+       int result;
+
+       TRACEJVMCALLSENTER(("JVM_GetHostName(name=%s, namelen=%d)", name, namelen));
+
+       result = os::gethostname(name, namelen);
+
+       TRACEJVMCALLSEXIT(("->%d (name=%s)", result, name));
+
+       return result;
+}
+
+
+/* JVM_GetHostByAddr */
+
+struct hostent *JVM_GetHostByAddr(const char* name, int len, int type)
+{
+       log_println("JVM_GetHostByAddr: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetHostByName */
+
+struct hostent *JVM_GetHostByName(char* name)
+{
+       log_println("JVM_GetHostByName: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetProtoByName */
+
+struct protoent *JVM_GetProtoByName(char* name)
+{
+       log_println("JVM_GetProtoByName: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_LoadLibrary */
+
+void* JVM_LoadLibrary(const char* name)
+{
+       TRACEJVMCALLSENTER(("JVM_LoadLibrary(name=%s)", name));
+
+       utf* u = utf_new_char(name);
+
+       NativeLibrary nl(u);
+       void* handle = nl.open();
+       
+       TRACEJVMCALLSEXIT(("->%p", handle));
+
+       return handle;
+}
+
+
+/* JVM_UnloadLibrary */
+
+void JVM_UnloadLibrary(void* handle)
+{
+       TRACEJVMCALLS(("JVM_UnloadLibrary(handle=%p)", handle));
+
+       NativeLibrary nl(handle);
+       nl.close();
+}
+
+
+/* JVM_FindLibraryEntry */
+
+void *JVM_FindLibraryEntry(void* handle, const char* name)
+{
+       void* symbol;
+
+       TRACEJVMCALLSENTER(("JVM_FindLibraryEntry(handle=%p, name=%s)", handle, name));
+
+       HPI& hpi = VM::get_current()->get_hpi();
+       symbol = hpi.get_library().FindLibraryEntry(handle, name);
+
+       TRACEJVMCALLSEXIT(("->%p", symbol));
+
+       return symbol;
+}
+
+
+/* JVM_IsNaN */
+
+jboolean JVM_IsNaN(jdouble a)
+{
+       log_println("JVM_IsNaN: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_IsSupportedJNIVersion */
+
+jboolean JVM_IsSupportedJNIVersion(jint version)
+{
+       TRACEJVMCALLS(("JVM_IsSupportedJNIVersion(version=%d)", version));
+
+       return jni_version_check(version);
+}
+
+
+/* JVM_InternString */
+
+jstring JVM_InternString(JNIEnv *env, jstring str)
+{
+       TRACEJVMCALLS(("JVM_InternString(env=%p, str=%p)", env, str));
+
+       return (jstring) javastring_intern((java_handle_t *) str);
+}
+
+
+/* JVM_RawMonitorCreate */
+
+JNIEXPORT void* JNICALL JVM_RawMonitorCreate(void)
+{
+       TRACEJVMCALLS(("JVM_RawMonitorCreate()"));
+
+       Mutex* m = new Mutex();
+
+       return m;
+}
+
+
+/* JVM_RawMonitorDestroy */
+
+JNIEXPORT void JNICALL JVM_RawMonitorDestroy(void* mon)
+{
+       TRACEJVMCALLS(("JVM_RawMonitorDestroy(mon=%p)", mon));
+
+       delete ((Mutex*) mon);
+}
+
+
+/* JVM_RawMonitorEnter */
+
+JNIEXPORT jint JNICALL JVM_RawMonitorEnter(void* mon)
+{
+       TRACEJVMCALLS(("JVM_RawMonitorEnter(mon=%p)", mon));
+
+       ((Mutex*) mon)->lock();
+
+       return 0;
+}
+
+
+/* JVM_RawMonitorExit */
+
+JNIEXPORT void JNICALL JVM_RawMonitorExit(void* mon)
+{
+       TRACEJVMCALLS(("JVM_RawMonitorExit(mon=%p)", mon));
+
+       ((Mutex*) mon)->unlock();
+}
+
+
+/* JVM_SetPrimitiveFieldValues */
+
+void JVM_SetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)
+{
+       log_println("JVM_SetPrimitiveFieldValues: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetPrimitiveFieldValues */
+
+void JVM_GetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)
+{
+       log_println("JVM_GetPrimitiveFieldValues: IMPLEMENT ME!");
+}
+
+
+/* JVM_AccessVMBooleanFlag */
+
+jboolean JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get)
+{
+       log_println("JVM_AccessVMBooleanFlag: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_AccessVMIntFlag */
+
+jboolean JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get)
+{
+       log_println("JVM_AccessVMIntFlag: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_VMBreakPoint */
+
+void JVM_VMBreakPoint(JNIEnv *env, jobject obj)
+{
+       log_println("JVM_VMBreakPoint: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetClassFields */
+
+jobjectArray JVM_GetClassFields(JNIEnv *env, jclass cls, jint which)
+{
+       log_println("JVM_GetClassFields: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassMethods */
+
+jobjectArray JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which)
+{
+       log_println("JVM_GetClassMethods: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassConstructors */
+
+jobjectArray JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which)
+{
+       log_println("JVM_GetClassConstructors: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassField */
+
+jobject JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which)
+{
+       log_println("JVM_GetClassField: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassMethod */
+
+jobject JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types, jint which)
+{
+       log_println("JVM_GetClassMethod: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassConstructor */
+
+jobject JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types, jint which)
+{
+       log_println("JVM_GetClassConstructor: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_NewInstance */
+
+jobject JVM_NewInstance(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_NewInstance: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetField */
+
+jobject JVM_GetField(JNIEnv *env, jobject field, jobject obj)
+{
+       log_println("JVM_GetField: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetPrimitiveField */
+
+jvalue JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj, unsigned char wCode)
+{
+       jvalue jv;
+
+       log_println("JVM_GetPrimitiveField: IMPLEMENT ME!");
+
+       jv.l = NULL;
+
+       return jv;
+}
+
+
+/* JVM_SetField */
+
+void JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val)
+{
+       log_println("JVM_SetField: IMPLEMENT ME!");
+}
+
+
+/* JVM_SetPrimitiveField */
+
+void JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v, unsigned char vCode)
+{
+       log_println("JVM_SetPrimitiveField: IMPLEMENT ME!");
+}
+
+
+/* JVM_InvokeMethod */
+
+jobject JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)
+{
+       TRACEJVMCALLS(("JVM_InvokeMethod(env=%p, method=%p, obj=%p, args0=%p)", env, method, obj, args0));
+
+       java_lang_reflect_Method jlrm(method);
+       
+       java_handle_t* result = jlrm.invoke((java_handle_t*) obj, (java_handle_objectarray_t*) args0);
+
+       return (jobject) result;
+}
+
+
+/* JVM_NewInstanceFromConstructor */
+
+jobject JVM_NewInstanceFromConstructor(JNIEnv *env, jobject con, jobjectArray args0)
+{
+       TRACEJVMCALLS(("JVM_NewInstanceFromConstructor(env=%p, c=%p, args0=%p)", env, con, args0));
+
+       java_lang_reflect_Constructor jlrc(con);
+       java_handle_t* o = jlrc.new_instance((java_handle_objectarray_t*) args0);
+
+       return (jobject) o;
+}
+
+
+/* JVM_SupportsCX8 */
+
+jboolean JVM_SupportsCX8()
+{
+       TRACEJVMCALLS(("JVM_SupportsCX8()"));
+
+       /* IMPLEMENT ME */
+
+       return 0;
+}
+
+
+/* JVM_CX8Field */
+
+jboolean JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fid, jlong oldVal, jlong newVal)
+{
+       log_println("JVM_CX8Field: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetAllThreads */
+
+jobjectArray JVM_GetAllThreads(JNIEnv *env, jclass dummy)
+{
+       log_println("JVM_GetAllThreads: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_DumpThreads */
+
+jobjectArray JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads)
+{
+       log_println("JVM_DumpThreads: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetManagement */
+
+void *JVM_GetManagement(jint version)
+{
+       TRACEJVMCALLS(("JVM_GetManagement(version=%d)", version));
+
+       return Management::get_jmm_interface(version);
+}
+
+
+/* JVM_InitAgentProperties */
+
+jobject JVM_InitAgentProperties(JNIEnv *env, jobject properties)
+{
+       log_println("JVM_InitAgentProperties: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetEnclosingMethodInfo */
+
+jobjectArray JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass)
+{
+       classinfo                 *c;
+       methodinfo                *m;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_GetEnclosingMethodInfo(env=%p, ofClass=%p)", env, ofClass));
+
+       c = LLNI_classinfo_unwrap(ofClass);
+
+       if ((c == NULL) || class_is_primitive(c))
+               return NULL;
+
+       m = class_get_enclosingmethod_raw(c);
+
+       if (m == NULL)
+               return NULL;
+
+       oa = builtin_anewarray(3, class_java_lang_Object);
+
+       if (oa == NULL)
+               return NULL;
+
+       array_objectarray_element_set(oa, 0, (java_handle_t *) LLNI_classinfo_wrap(m->clazz));
+       array_objectarray_element_set(oa, 1, javastring_new(m->name));
+       array_objectarray_element_set(oa, 2, javastring_new(m->descriptor));
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetThreadStateValues */
+
+jintArray JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState)
+{
+       java_handle_intarray_t *ia;
+
+       TRACEJVMCALLS(("JVM_GetThreadStateValues(env=%p, javaThreadState=%d)",
+                                 env, javaThreadState));
+
+       /* If new thread states are added in future JDK and VM versions,
+          this should check if the JDK version is compatible with thread
+          states supported by the VM.  Return NULL if not compatible.
+       
+          This function must map the VM java_lang_Thread::ThreadStatus
+          to the Java thread state that the JDK supports. */
+
+       switch (javaThreadState) {
+    case THREAD_STATE_NEW:
+               ia = builtin_newarray_int(1);
+
+               if (ia == NULL)
+                       return NULL;
+
+               array_intarray_element_set(ia, 0, THREAD_STATE_NEW);
+               break; 
+
+    case THREAD_STATE_RUNNABLE:
+               ia = builtin_newarray_int(1);
+
+               if (ia == NULL)
+                       return NULL;
+
+               array_intarray_element_set(ia, 0, THREAD_STATE_RUNNABLE);
+               break; 
+
+    case THREAD_STATE_BLOCKED:
+               ia = builtin_newarray_int(1);
+
+               if (ia == NULL)
+                       return NULL;
+
+               array_intarray_element_set(ia, 0, THREAD_STATE_BLOCKED);
+               break; 
+
+    case THREAD_STATE_WAITING:
+               ia = builtin_newarray_int(2);
+
+               if (ia == NULL)
+                       return NULL;
+
+               array_intarray_element_set(ia, 0, THREAD_STATE_WAITING);
+               /* XXX Implement parked stuff. */
+/*             array_intarray_element_set(ia, 1, PARKED); */
+               break; 
+
+    case THREAD_STATE_TIMED_WAITING:
+               ia = builtin_newarray_int(3);
+
+               if (ia == NULL)
+                       return NULL;
+
+               /* XXX Not sure about that one. */
+/*             array_intarray_element_set(ia, 0, SLEEPING); */
+               array_intarray_element_set(ia, 0, THREAD_STATE_TIMED_WAITING);
+               /* XXX Implement parked stuff. */
+/*             array_intarray_element_set(ia, 2, PARKED); */
+               break; 
+
+    case THREAD_STATE_TERMINATED:
+               ia = builtin_newarray_int(1);
+
+               if (ia == NULL)
+                       return NULL;
+
+               array_intarray_element_set(ia, 0, THREAD_STATE_TERMINATED);
+               break; 
+
+    default:
+               /* Unknown state - probably incompatible JDK version */
+               return NULL;
+       }
+
+       return (jintArray) ia;
+}
+
+
+/* JVM_GetThreadStateNames */
+
+jobjectArray JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values)
+{
+       java_handle_intarray_t    *ia;
+       java_handle_objectarray_t *oa;
+       java_object_t             *s;
+
+       TRACEJVMCALLS(("JVM_GetThreadStateNames(env=%p, javaThreadState=%d, values=%p)",
+                                 env, javaThreadState, values));
+
+       ia = (java_handle_intarray_t *) values;
+
+       /* If new thread states are added in future JDK and VM versions,
+          this should check if the JDK version is compatible with thread
+          states supported by the VM.  Return NULL if not compatible.
+       
+          This function must map the VM java_lang_Thread::ThreadStatus
+          to the Java thread state that the JDK supports. */
+
+       if (values == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       switch (javaThreadState) {
+    case THREAD_STATE_NEW:
+               assert(ia->header.size == 1 && ia->data[0] == THREAD_STATE_NEW);
+
+               oa = builtin_anewarray(1, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+               s = javastring_new(utf_new_char("NEW"));
+
+               if (s == NULL)
+                       return NULL;
+
+               array_objectarray_element_set(oa, 0, s);
+               break; 
+
+    case THREAD_STATE_RUNNABLE:
+               oa = builtin_anewarray(1, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+               s = javastring_new(utf_new_char("RUNNABLE"));
+
+               if (s == NULL)
+                       return NULL;
+
+               array_objectarray_element_set(oa, 0, s);
+               break; 
+
+    case THREAD_STATE_BLOCKED:
+               oa = builtin_anewarray(1, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+               s = javastring_new(utf_new_char("BLOCKED"));
+
+               if (s == NULL)
+                       return NULL;
+
+               array_objectarray_element_set(oa, 0, s);
+               break; 
+
+    case THREAD_STATE_WAITING:
+               oa = builtin_anewarray(2, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+               s = javastring_new(utf_new_char("WAITING.OBJECT_WAIT"));
+/*             s = javastring_new(utf_new_char("WAITING.PARKED")); */
+
+               if (s == NULL)
+                       return NULL;
+
+               array_objectarray_element_set(oa, 0, s);
+/*             array_objectarray_element_set(oa, 1, s); */
+               break; 
+
+    case THREAD_STATE_TIMED_WAITING:
+               oa = builtin_anewarray(3, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+/*             s = javastring_new(utf_new_char("TIMED_WAITING.SLEEPING")); */
+               s = javastring_new(utf_new_char("TIMED_WAITING.OBJECT_WAIT"));
+/*             s = javastring_new(utf_new_char("TIMED_WAITING.PARKED")); */
+
+               if (s == NULL)
+                       return NULL;
+
+/*             array_objectarray_element_set(oa, 0, s); */
+               array_objectarray_element_set(oa, 0, s);
+/*             array_objectarray_element_set(oa, 2, s); */
+               break; 
+
+    case THREAD_STATE_TERMINATED:
+               oa = builtin_anewarray(1, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+               s = javastring_new(utf_new_char("TERMINATED"));
+
+               if (s == NULL)
+                       return NULL;
+
+               array_objectarray_element_set(oa, 0, s);
+               break; 
+
+       default:
+               /* Unknown state - probably incompatible JDK version */
+               return NULL;
+       }
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetVersionInfo */
+
+void JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size)
+{
+       log_println("JVM_GetVersionInfo: IMPLEMENT ME!");
+}
+
+
+/* OS: JVM_RegisterSignal */
+
+void *JVM_RegisterSignal(jint sig, void *handler)
+{
+       functionptr newHandler;
+
+       TRACEJVMCALLS(("JVM_RegisterSignal(sig=%d, handler=%p)", sig, handler));
+
+       if (handler == (void *) 2)
+               newHandler = (functionptr) signal_thread_handler;
+       else
+               newHandler = (functionptr) (uintptr_t) handler;
+
+       switch (sig) {
+    case SIGILL:
+    case SIGFPE:
+    case SIGUSR1:
+    case SIGSEGV:
+               /* These signals are already used by the VM. */
+               return (void *) -1;
+
+    case SIGQUIT:
+               /* This signal is used by the VM to dump thread stacks unless
+                  ReduceSignalUsage is set, in which case the user is allowed
+                  to set his own _native_ handler for this signal; thus, in
+                  either case, we do not allow JVM_RegisterSignal to change
+                  the handler. */
+               return (void *) -1;
+
+       case SIGHUP:
+       case SIGINT:
+       case SIGTERM:
+               break;
+       }
+
+       signal_register_signal(sig, newHandler, SA_RESTART | SA_SIGINFO);
+
+       /* XXX Should return old handler. */
+
+       return (void *) 2;
+}
+
+
+/* OS: JVM_RaiseSignal */
+
+jboolean JVM_RaiseSignal(jint sig)
+{
+       log_println("JVM_RaiseSignal: IMPLEMENT ME! sig=%s", sig);
+
+       return false;
+}
+
+
+/* OS: JVM_FindSignal */
+
+jint JVM_FindSignal(const char *name)
+{
+       TRACEJVMCALLS(("JVM_FindSignal(name=%s)", name));
+
+#if defined(__LINUX__)
+       if (strcmp(name, "HUP") == 0)
+               return SIGHUP;
+
+       if (strcmp(name, "INT") == 0)
+               return SIGINT;
+
+       if (strcmp(name, "TERM") == 0)
+               return SIGTERM;
+#elif defined(__SOLARIS__)
+       int signum;
+
+       if (os::str2sig(name, &signum) == -1)
+               return -1;
+
+       return signum;
+#else
+# error Not implemented for this OS.
+#endif
+
+       return -1;
+}
+
+} // extern "C"
+
+
+/*
+ * 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/native/vm/openjdk/management.cpp b/src/native/vm/openjdk/management.cpp
new file mode 100644 (file)
index 0000000..3884893
--- /dev/null
@@ -0,0 +1,377 @@
+ /* src/native/vm/openjdk/management.cpp - HotSpot management interface functions
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 <stdint.h>
+
+// Include our JNI header before the JMM header, because the JMM
+// header include jni.h and we want to override the typedefs in jni.h.
+#include "native/jni.hpp"
+
+#include INCLUDE_JMM_H
+
+#include "native/vm/openjdk/management.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/os.hpp"
+#include "vm/vm.hpp"
+
+
+/**
+ * Initialize the Management subsystem.
+ */
+Management::Management()
+{
+       // Initialize optional support
+       _optional_support.isLowMemoryDetectionSupported = 1;
+       _optional_support.isCompilationTimeMonitoringSupported = 1;
+       _optional_support.isThreadContentionMonitoringSupported = 1;
+
+//     if (os::is_thread_cpu_time_supported()) {
+       if (false) {
+               _optional_support.isCurrentThreadCpuTimeSupported = 1;
+               _optional_support.isOtherThreadCpuTimeSupported = 1;
+       }
+       else {
+               _optional_support.isCurrentThreadCpuTimeSupported = 0;
+               _optional_support.isOtherThreadCpuTimeSupported = 0;
+       }
+
+       _optional_support.isBootClassPathSupported = 1;
+       _optional_support.isObjectMonitorUsageSupported = 1;
+       _optional_support.isSynchronizerUsageSupported = 1;
+}
+
+
+/**
+ * Return a pointer to the optional support structure.
+ *
+ * @param Pointer to optional support structure.
+ */
+const jmmOptionalSupport& Management::get_optional_support() const
+{
+       return _optional_support;
+}
+
+
+// Interface functions are exported as C functions.
+extern "C" {
+
+// Returns a version string and sets major and minor version if the
+// input parameters are non-null.
+jint jmm_GetVersion(JNIEnv* env)
+{
+       return JMM_VERSION;
+}
+
+
+// Gets the list of VM monitoring and management optional supports
+// Returns 0 if succeeded; otherwise returns non-zero.
+jint jmm_GetOptionalSupport(JNIEnv* env, jmmOptionalSupport* support)
+{
+       if (support == NULL) {
+               return -1;
+       }
+
+       Management& mm = VM::get_current()->get_management();
+
+       // memcpy the structure.
+       os::memcpy(support, &mm.get_optional_support(), sizeof(jmmOptionalSupport));
+
+       return 0;
+}
+
+
+jobject jmm_GetInputArguments(JNIEnv* env)
+{
+       log_println("jmm_GetInputArguments: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jobjectArray jmm_GetInputArgumentArray(JNIEnv* env)
+{
+       log_println("jmm_GetInputArgumentArray: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jobjectArray jmm_GetMemoryPools(JNIEnv* env, jobject obj)
+{
+       log_println("jmm_GetMemoryPools: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jobjectArray jmm_GetMemoryManagers(JNIEnv* env, jobject obj)
+{
+       log_println("jmm_GetMemoryManagers: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jobject jmm_GetMemoryPoolUsage(JNIEnv* env, jobject obj)
+{
+       log_println("jmm_GetMemoryPoolUsage: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jobject jmm_GetPeakMemoryPoolUsage(JNIEnv* env, jobject obj)
+{
+       log_println("jmm_GetPeakMemoryPoolUsage: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jobject jmm_GetPoolCollectionUsage(JNIEnv* env, jobject obj)
+{
+       log_println("jmm_GetPoolCollectionUsage: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+void jmm_SetPoolSensor(JNIEnv* env, jobject obj, jmmThresholdType type, jobject sensorObj)
+{
+       log_println("jmm_SetPoolSensor: IMPLEMENT ME!");
+}
+
+
+jlong jmm_SetPoolThreshold(JNIEnv* env, jobject obj, jmmThresholdType type, jlong threshold)
+{
+       log_println("jmm_SetPoolThreshold: IMPLEMENT ME!");
+       return 0;
+}
+
+
+jobject jmm_GetMemoryUsage(JNIEnv* env, jboolean heap)
+{
+       log_println("jmm_GetMemoryUsage: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jboolean jmm_GetBoolAttribute(JNIEnv* env, jmmBoolAttribute att)
+{
+       log_println("jmm_GetBoolAttribute: IMPLEMENT ME!");
+       return 0;
+}
+
+
+jboolean jmm_SetBoolAttribute(JNIEnv* env, jmmBoolAttribute att, jboolean flag)
+{
+       log_println("jmm_SetBoolAttribute: IMPLEMENT ME!");
+       return 0;
+}
+
+
+jlong jmm_GetLongAttribute(JNIEnv* env, jobject obj, jmmLongAttribute att)
+{
+       log_println("jmm_GetLongAttribute: IMPLEMENT ME!");
+       return 0;
+}
+
+
+jint jmm_GetLongAttributes(JNIEnv* env, jobject obj, jmmLongAttribute* atts, jint count, jlong* result)
+{
+       log_println("jmm_GetLongAttributes: IMPLEMENT ME!");
+       return 0;
+}
+
+
+jint jmm_GetThreadInfo(JNIEnv* env, jlongArray ids, jint maxDepth, jobjectArray infoArray)
+{
+       log_println("jmm_GetThreadInfo: IMPLEMENT ME!");
+       return 0;
+}
+
+
+jobjectArray jmm_DumpThreads(JNIEnv* env, jlongArray thread_ids, jboolean locked_monitors, jboolean locked_synchronizers)
+{
+       log_println("jmm_DumpThreads: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jobjectArray jmm_GetLoadedClasses(JNIEnv* env)
+{
+       log_println("jmm_GetLoadedClasses: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jboolean jmm_ResetStatistic(JNIEnv* env, jvalue obj, jmmStatisticType type)
+{
+       log_println("jmm_ResetStatistic: IMPLEMENT ME!");
+       return 0;
+}
+
+
+jlong jmm_GetThreadCpuTime(JNIEnv* env, jlong thread_id)
+{
+       log_println("jmm_GetThreadCpuTime: IMPLEMENT ME!");
+       return 0;
+}
+
+
+jlong jmm_GetThreadCpuTimeWithKind(JNIEnv* env, jlong thread_id, jboolean user_sys_cpu_time)
+{
+       log_println("jmm_GetThreadCpuTimeWithKind: IMPLEMENT ME!");
+       return 0;
+}
+
+
+jobjectArray jmm_GetVMGlobalNames(JNIEnv* env)
+{
+       log_println("jmm_GetVMGlobalNames: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jint jmm_GetVMGlobals(JNIEnv* env, jobjectArray names, jmmVMGlobal* globals, jint count)
+{
+       log_println("jmm_GetVMGlobals: IMPLEMENT ME!");
+       return 0;
+}
+
+
+void jmm_SetVMGlobal(JNIEnv* env, jstring flag_name, jvalue new_value)
+{
+       log_println("jmm_SetVMGlobal: IMPLEMENT ME!");
+}
+
+
+jint jmm_GetInternalThreadTimes(JNIEnv* env, jobjectArray names, jlongArray times)
+{
+       log_println("jmm_GetInternalThreadTimes: IMPLEMENT ME!");
+       return 0;
+}
+
+
+jobjectArray jmm_FindDeadlockedThreads(JNIEnv* env, jboolean object_monitors_only)
+{
+       log_println("jmm_FindDeadlockedThreads: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jobjectArray jmm_FindMonitorDeadlockedThreads(JNIEnv* env)
+{
+       log_println("jmm_FindMonitorDeadlockedThreads: IMPLEMENT ME!");
+       return NULL;
+}
+
+
+jint jmm_GetGCExtAttributeInfo(JNIEnv* env, jobject mgr, jmmExtAttributeInfo* info, jint count)
+{
+       log_println("jmm_GetGCExtAttributeInfo: IMPLEMENT ME!");
+       return 0;
+}
+
+
+void jmm_GetLastGCStat(JNIEnv* env, jobject obj, jmmGCStat* gc_stat)
+{
+       log_println("jmm_GetLastGCStat: IMPLEMENT ME!");
+}
+
+
+jint jmm_DumpHeap0(JNIEnv* env, jstring outputfile, jboolean live)
+{
+       log_println("jmm_DumpHeap0: IMPLEMENT ME!");
+       return 0;
+}
+
+} // extern "C"
+
+
+const struct jmmInterface_1_ jmm_interface = {
+       NULL,
+       NULL,
+       jmm_GetVersion,
+       jmm_GetOptionalSupport,
+       jmm_GetInputArguments,
+       jmm_GetThreadInfo,
+       jmm_GetInputArgumentArray,
+       jmm_GetMemoryPools,
+       jmm_GetMemoryManagers,
+       jmm_GetMemoryPoolUsage,
+       jmm_GetPeakMemoryPoolUsage,
+       NULL,
+       jmm_GetMemoryUsage,
+       jmm_GetLongAttribute,
+       jmm_GetBoolAttribute,
+       jmm_SetBoolAttribute,
+       jmm_GetLongAttributes,
+       jmm_FindMonitorDeadlockedThreads,
+       jmm_GetThreadCpuTime,
+       jmm_GetVMGlobalNames,
+       jmm_GetVMGlobals,
+       jmm_GetInternalThreadTimes,
+       jmm_ResetStatistic,
+       jmm_SetPoolSensor,
+       jmm_SetPoolThreshold,
+       jmm_GetPoolCollectionUsage,
+       jmm_GetGCExtAttributeInfo,
+       jmm_GetLastGCStat,
+       jmm_GetThreadCpuTimeWithKind,
+       NULL,
+       jmm_DumpHeap0,
+       jmm_FindDeadlockedThreads,
+       jmm_SetVMGlobal,
+       NULL,
+       jmm_DumpThreads
+};
+
+
+/**
+ * Return the requested management interface.
+ *
+ * @param version Requested management interface version.
+ *
+ * @return Pointer to management interface structure.
+ */
+void* Management::get_jmm_interface(int version)
+{
+       if (version == JMM_VERSION_1_0) {
+               return (void*) &jmm_interface;
+       }
+
+       return NULL;
+}
+
+/*
+ * 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/native/vm/openjdk/management.hpp b/src/native/vm/openjdk/management.hpp
new file mode 100644 (file)
index 0000000..4c83d88
--- /dev/null
@@ -0,0 +1,75 @@
+/* src/native/vm/openjdk/management.hpp - HotSpot management interface functions
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MANAGEMENT_HPP
+#define _MANAGEMENT_HPP
+
+#include <stdint.h>
+
+// Include our JNI header before the JMM header, because the JMM
+// header include jni.h and we want to override the typedefs in jni.h.
+#include "native/jni.hpp"
+
+#include INCLUDE_JMM_H
+
+
+#ifdef __cplusplus
+
+/**
+ * Management support.
+ */
+class Management {
+private:
+       jmmOptionalSupport _optional_support;
+
+public:
+       Management();
+
+       static void* get_jmm_interface(int version);
+
+       const jmmOptionalSupport& get_optional_support() const;
+};
+
+#else
+
+typedef struct Management Management;
+
+#endif
+
+#endif // _MANAGEMENT_HPP
+
+
+/*
+ * 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/native/vm/reflect.c b/src/native/vm/reflect.c
deleted file mode 100644 (file)
index 90b1729..0000000
+++ /dev/null
@@ -1,700 +0,0 @@
-/* src/native/vm/reflect.c - helper functions for java/lang/reflect
-
-   Copyright (C) 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 <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-/* keep this order of the native includes */
-
-#include "native/include/java_lang_String.h"
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-# include "native/include/java_nio_ByteBuffer.h"        /* required by j.l.CL */
-#endif
-#include "native/include/java_lang_ClassLoader.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_reflect_Constructor.h"
-#include "native/include/java_lang_reflect_Field.h"
-#include "native/include/java_lang_reflect_Method.h"
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/java_lang_reflect_VMConstructor.h"
-# include "native/include/java_lang_reflect_VMField.h"
-# include "native/include/java_lang_reflect_VMMethod.h"
-#endif
-
-#if defined(ENABLE_ANNOTATIONS) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "vm/vm.h"
-# include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/vm/reflect.h"
-
-#include "vm/access.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/method.h"
-
-
-/* reflect_constructor_new *****************************************************
-
-   Allocates a new java.lang.reflect.Constructor object and
-   initializes the fields with the method passed.
-
-*******************************************************************************/
-
-java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m)
-{
-       java_handle_t                   *o;
-       java_lang_reflect_Constructor   *rc;
-       int32_t                          slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_reflect_VMConstructor *rvmc;
-#endif
-
-       /* Allocate a java.lang.reflect.Constructor object. */
-
-       o = builtin_new(class_java_lang_reflect_Constructor);
-
-       if (o == NULL)
-               return NULL;
-
-       /* Initialize instance fields. */
-
-       rc = (java_lang_reflect_Constructor *) o;
-
-       /* Calculate the slot. */
-
-       slot = m - m->clazz->methods;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       /* Allocate a java.lang.reflect.VMConstructor object. */
-
-       o = builtin_new(class_java_lang_reflect_VMConstructor);
-
-       if (o == NULL)
-               return NULL;
-
-       rvmc = (java_lang_reflect_VMConstructor *) o;
-
-       /* Link the two Java objects. */
-
-       LLNI_field_set_ref(rc,   cons, rvmc);
-       LLNI_field_set_ref(rvmc, cons, rc);
-
-       /* Set Java object instance fields. */
-
-       LLNI_field_set_cls(rvmc, clazz,                m->clazz);
-       LLNI_field_set_val(rvmc, slot,                 slot);
-       LLNI_field_set_ref(rvmc, annotations,          method_get_annotations(m));
-       LLNI_field_set_ref(rvmc, parameterAnnotations, method_get_parameterannotations(m));
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       /* Set Java object instance fields. */
-
-       LLNI_field_set_cls(rc, clazz               , m->clazz);
-       LLNI_field_set_ref(rc, parameterTypes      , method_get_parametertypearray(m));
-       LLNI_field_set_ref(rc, exceptionTypes      , method_get_exceptionarray(m));
-       LLNI_field_set_val(rc, modifiers           , m->flags & ACC_CLASS_REFLECT_MASK);
-       LLNI_field_set_val(rc, slot                , slot);
-       LLNI_field_set_ref(rc, signature           , m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL);
-       LLNI_field_set_ref(rc, annotations         , method_get_annotations(m));
-       LLNI_field_set_ref(rc, parameterAnnotations, method_get_parameterannotations(m));
-
-#else
-# error unknown classpath configuration
-#endif
-
-       return rc;
-}
-
-
-/* reflect_field_new ***********************************************************
-
-   Allocates a new java.lang.reflect.Field object and initializes the
-   fields with the field passed.
-
-*******************************************************************************/
-
-java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
-{
-       java_handle_t             *o;
-       java_lang_reflect_Field   *rf;
-       int32_t                    slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_reflect_VMField *rvmf;
-#endif
-
-       /* Allocate a java.lang.reflect.Field object. */
-
-       o = builtin_new(class_java_lang_reflect_Field);
-
-       if (o == NULL)
-               return NULL;
-
-       /* initialize instance fields */
-
-       rf = (java_lang_reflect_Field *) o;
-
-       /* Calculate the slot. */
-
-       slot = f - f->clazz->fields;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       /* Allocate a java.lang.reflect.VMField object. */
-
-       o = builtin_new(class_java_lang_reflect_VMField);
-
-       if (o == NULL)
-               return NULL;
-
-       rvmf = (java_lang_reflect_VMField *) o;
-
-       /* Link the two Java objects. */
-
-       LLNI_field_set_ref(rf,   f, rvmf);
-       LLNI_field_set_ref(rvmf, f, rf);
-
-       /* Set the Java object fields. */
-
-       LLNI_field_set_cls(rvmf, clazz,       f->clazz);
-
-       /* The name needs to be interned */
-       /* XXX implement me better! */
-
-       LLNI_field_set_ref(rvmf, name,        (java_lang_String *) javastring_intern(javastring_new(f->name)));
-       LLNI_field_set_val(rvmf, slot,        slot);
-       LLNI_field_set_ref(rvmf, annotations, field_get_annotations(f));
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       /* Set the Java object fields. */
-
-       LLNI_field_set_cls(rf, clazz,       f->clazz);
-
-       /* The name needs to be interned */
-       /* XXX implement me better! */
-
-       LLNI_field_set_ref(rf, name,        (java_lang_String *) javastring_intern(javastring_new(f->name)));
-       LLNI_field_set_cls(rf, type,        (java_lang_Class *) field_get_type(f));
-       LLNI_field_set_val(rf, modifiers,   f->flags);
-       LLNI_field_set_val(rf, slot,        slot);
-       LLNI_field_set_ref(rf, signature,   f->signature ? (java_lang_String *) javastring_new(f->signature) : NULL);
-       LLNI_field_set_ref(rf, annotations, field_get_annotations(f));
-
-#else
-# error unknown classpath configuration
-#endif
-
-       return rf;
-}
-
-
-/* reflect_method_new **********************************************************
-
-   Allocates a new java.lang.reflect.Method object and initializes the
-   fields with the method passed.
-
-*******************************************************************************/
-
-java_lang_reflect_Method *reflect_method_new(methodinfo *m)
-{
-       java_handle_t              *o;
-       java_lang_reflect_Method   *rm;
-       int32_t                     slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_reflect_VMMethod *rvmm;
-#endif
-
-       /* Allocate a java.lang.reflect.Method object. */
-
-       o = builtin_new(class_java_lang_reflect_Method);
-
-       if (o == NULL)
-               return NULL;
-
-       /* initialize instance fields */
-
-       rm = (java_lang_reflect_Method *) o;
-
-       /* Calculate the slot. */
-
-       slot = m - m->clazz->methods;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       /* Allocate a java.lang.reflect.VMMethod object. */
-
-       o = builtin_new(class_java_lang_reflect_VMMethod);
-
-       if (o == NULL)
-               return NULL;
-
-       rvmm = (java_lang_reflect_VMMethod *) o;
-
-       /* Link the two Java objects. */
-
-       LLNI_field_set_ref(rm,   m, rvmm);
-       LLNI_field_set_ref(rvmm, m, rm);
-
-       /* Set Java object instance fields. */
-
-       LLNI_field_set_cls(rvmm, clazz,                m->clazz);
-
-       /* The name needs to be interned */
-       /* XXX implement me better! */
-
-       LLNI_field_set_ref(rvmm, name,                 (java_lang_String *) javastring_intern(javastring_new(m->name)));
-       LLNI_field_set_val(rvmm, slot,                 slot);
-       LLNI_field_set_ref(rvmm, annotations,          method_get_annotations(m));
-       LLNI_field_set_ref(rvmm, parameterAnnotations, method_get_parameterannotations(m));
-       LLNI_field_set_ref(rvmm, annotationDefault,    method_get_annotationdefault(m));
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       LLNI_field_set_cls(rm, clazz,                m->clazz);
-
-       /* The name needs to be interned */
-       /* XXX implement me better! */
-
-       LLNI_field_set_ref(rm, name,                 (java_lang_String *) javastring_intern(javastring_new(m->name)));
-       LLNI_field_set_ref(rm, parameterTypes,       method_get_parametertypearray(m));
-       LLNI_field_set_cls(rm, returnType,           (java_lang_Class *) method_returntype_get(m));
-       LLNI_field_set_ref(rm, exceptionTypes,       method_get_exceptionarray(m));
-       LLNI_field_set_val(rm, modifiers,            m->flags & ACC_CLASS_REFLECT_MASK);
-       LLNI_field_set_val(rm, slot,                 slot);
-       LLNI_field_set_ref(rm, signature,            m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL);
-       LLNI_field_set_ref(rm, annotations,          method_get_annotations(m));
-       LLNI_field_set_ref(rm, parameterAnnotations, method_get_parameterannotations(m));
-       LLNI_field_set_ref(rm, annotationDefault,    method_get_annotationdefault(m));
-
-#else
-# error unknown classpath configuration
-#endif
-
-       return rm;
-}
-
-
-/* reflect_invoke **************************************************************
-
-   Invoke a method on the given object with the given arguments.
-
-   For instance methods OBJ must be != NULL and the method is looked up
-   in the vftbl of the object.
-
-   For static methods, OBJ is ignored.
-
-*******************************************************************************/
-
-static java_handle_t *reflect_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params)
-{
-       methodinfo    *resm;
-       java_handle_t *ro;
-       int            argcount;
-       int            paramcount;
-
-       /* Sanity check. */
-
-       assert(m != NULL);
-
-       argcount = m->parseddesc->paramcount;
-       paramcount = argcount;
-
-       /* If method is non-static, remove the `this' pointer. */
-
-       if (!(m->flags & ACC_STATIC))
-               paramcount--;
-
-       /* For instance methods the object has to be an instance of the
-          class the method belongs to. For static methods the obj
-          parameter is ignored. */
-
-       if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->clazz))) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* check if we got the right number of arguments */
-
-       if (((params == NULL) && (paramcount != 0)) ||
-               (params && (LLNI_array_size(params) != paramcount))) 
-       {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* for instance methods we need an object */
-
-       if (!(m->flags & ACC_STATIC) && (o == NULL)) {
-               /* XXX not sure if that is the correct exception */
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* for static methods, zero object to make subsequent code simpler */
-       if (m->flags & ACC_STATIC)
-               o = NULL;
-
-       if (o != NULL) {
-               /* for instance methods we must do a vftbl lookup */
-               resm = method_vftbl_lookup(LLNI_vftbl_direct(o), m);
-       }
-       else {
-               /* for static methods, just for convenience */
-               resm = m;
-       }
-
-       ro = vm_call_method_objectarray(resm, o, params);
-
-       return ro;
-}
-
-
-/* reflect_constructor_newinstance ********************************************
-
-   Creates an Java object instance of the given constructor.
-
-   ARGUMENTS:
-      m .......... methodinfo of the constructor
-      args ....... constructor arguments
-      override ... override security checks
-
-   RETURN:
-      constructed Java object
-
-*******************************************************************************/
-
-java_handle_t *reflect_constructor_newinstance(methodinfo *m, java_handle_objectarray_t *args, bool override)
-{
-       java_handle_t *o;
-
-       /* Should we bypass security the checks (AccessibleObject)? */
-
-       if (override == false) {
-               /* This method is always called like this:
-                      [0] java.lang.reflect.Constructor.constructNative (Native Method)
-                      [1] java.lang.reflect.Constructor.newInstance
-                      [2] <caller>
-               */
-
-               if (!access_check_method(m, 2))
-                       return NULL;
-       }
-
-       /* Create a Java object. */
-
-       o = builtin_new(m->clazz);
-
-       if (o == NULL)
-               return NULL;
-        
-       /* Call initializer. */
-
-       (void) reflect_invoke(m, o, args);
-
-       return o;
-}
-
-
-/* reflect_method_invoke *******************************************************
-
-   Invokes the given method.
-
-   ARGUMENTS:
-      m .......... methodinfo
-      args ....... method arguments
-      override ... override security checks
-
-   RETURN:
-      return value of the method
-
-*******************************************************************************/
-
-java_handle_t *reflect_method_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *args, bool override)
-{
-       java_handle_t *ro;
-
-       /* Should we bypass security the checks (AccessibleObject)? */
-
-       if (override == false) {
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-               /* This method is always called like this:
-                      [0] java.lang.reflect.Method.invokeNative (Native Method)
-                      [1] java.lang.reflect.Method.invoke (Method.java:329)
-                      [2] <caller>
-               */
-
-               if (!access_check_method(m, 2))
-                       return NULL;
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-               /* We only pass 1 here as stacktrace_get_caller_class, which
-                  is called from access_check_method, skips
-                  java.lang.reflect.Method.invoke(). */
-
-               if (!access_check_method(m, 1))
-                       return NULL;
-#else
-# error unknown classpath configuration
-#endif
-       }
-
-       /* Check if method class is initialized. */
-
-       if (!(m->clazz->state & CLASS_INITIALIZED))
-               if (!initialize_class(m->clazz))
-                       return NULL;
-
-       /* Call the Java method. */
-
-       ro = reflect_invoke(m, o, args);
-
-       return ro;
-}
-
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
-/* reflect_get_declaredannotatios *********************************************
-
-   Calls the annotation parser with the unparsed annotations and returnes
-   the parsed annotations as a map.
-   
-   IN:
-       annotations........the unparsed annotations
-       declaringClass.....the class in which the annotated element is declared
-       referer............the calling class (for the 'referer' parameter of
-                          vm_call_method())
-
-   RETURN VALUE:
-       The parsed annotations as a
-          java.util.Map<Class<? extends Annotation>, Annotation>.
-
-*******************************************************************************/
-
-struct java_util_Map* reflect_get_declaredannotatios(
-       java_handle_bytearray_t *annotations,
-       java_lang_Class         *declaringClass,
-       classinfo               *referer)
-{
-       static methodinfo        *m_parseAnnotations   = NULL;
-                                   /* parser method (chached, therefore static)  */
-       utf                      *utf_parseAnnotations = NULL;
-                                   /* parser method name                         */
-       utf                      *utf_desc             = NULL;
-                                   /* parser method descriptor (signature)       */
-       sun_reflect_ConstantPool *constantPool         = NULL;
-                                   /* constant pool of the declaring class       */
-       java_lang_Object         *constantPoolOop      = (java_lang_Object*)declaringClass;
-                                   /* constantPoolOop field of the constant pool */
-                                   /* object (sun.reflect.ConstantPool)          */
-
-       constantPool = 
-               (sun_reflect_ConstantPool*)native_new_and_init(
-                       class_sun_reflect_ConstantPool);
-               
-       if(constantPool == NULL) {
-               /* out of memory */
-               return NULL;
-       }
-               
-       LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
-               
-       /* only resolve the parser method the first time */
-       if (m_parseAnnotations == NULL) {
-               utf_parseAnnotations = utf_new_char("parseAnnotations");
-               utf_desc = utf_new_char(
-                       "([BLsun/reflect/ConstantPool;Ljava/lang/Class;)"
-                       "Ljava/util/Map;");
-
-               if (utf_parseAnnotations == NULL || utf_desc == NULL) {
-                       /* out of memory */
-                       return NULL;
-               }
-               
-               m_parseAnnotations = class_resolveclassmethod(
-                       class_sun_reflect_annotation_AnnotationParser,
-                       utf_parseAnnotations,
-                       utf_desc,
-                       referer,
-                       true);
-       
-               if (m_parseAnnotations == NULL) {
-                       /* method not found */
-                       return NULL;
-               }
-       }
-       
-       return (struct java_util_Map*)vm_call_method(
-                       m_parseAnnotations, NULL, annotations,
-                       constantPool, declaringClass);
-}
-
-
-/* reflect_get_parameterannotations *******************************************
-
-   Calls the annotation parser with the unparsed parameter annotations of
-   a method and returnes the parsed parameter annotations in a 2 dimensional
-   array.
-   
-   IN:
-       parameterAnnotations....the unparsed parameter annotations
-          slot....................the slot of the method
-       declaringClass..........the class in which the annotated element is
-                                  declared
-       referer.................the calling class (for the 'referer' parameter
-                               of vm_call_method())
-
-   RETURN VALUE:
-       The parsed parameter annotations in a 2 dimensional array.
-
-*******************************************************************************/
-
-java_handle_objectarray_t* reflect_get_parameterannotations(
-       java_handle_t     *parameterAnnotations,
-       int32_t            slot,
-       java_lang_Class   *declaringClass,
-       classinfo         *referer)
-{
-       /* This method in java would be basically the following.
-        * We don't do it in java because we don't want to make a
-        * public method with wich you can get a ConstantPool, because
-        * with that you could read any kind of constants (even private
-        * ones).
-        *
-        * ConstantPool constPool = new ConstantPool();
-        * constPool.constantPoolOop = method.getDeclaringClass();
-        * return sun.reflect.AnnotationParser.parseParameterAnnotations(
-        *        parameterAnnotations,
-        *        constPool,
-        *        method.getDeclaringClass(),
-        *        method.getParameterTypes().length);
-        */
-       static methodinfo        *m_parseParameterAnnotations   = NULL;
-                            /* parser method (cached, therefore static)          */
-       utf                      *utf_parseParameterAnnotations = NULL;
-                            /* parser method name                                */
-       utf                      *utf_desc        = NULL;
-                            /* parser method descriptor (signature)              */
-       sun_reflect_ConstantPool *constantPool    = NULL;
-                            /* constant pool of the declaring class              */
-       java_lang_Object         *constantPoolOop = (java_lang_Object*)declaringClass;
-                            /* constantPoolOop field of the constant pool object */
-       classinfo                *c               = NULL;
-                            /* classinfo of the decaring class                   */
-       methodinfo               *m               = NULL;
-                            /* method info of the annotated method               */
-       int32_t                   numParameters   = -1;
-                            /* parameter count of the annotated method           */
-
-       /* get parameter count */
-
-       c = LLNI_classinfo_unwrap(declaringClass);
-       m = &(c->methods[slot]);
-
-       numParameters = method_get_parametercount(m);
-
-       if (numParameters < 0) {
-               /* error parsing descriptor */
-               return NULL;
-       }
-
-       /* get ConstantPool */
-
-       constantPool = 
-               (sun_reflect_ConstantPool*)native_new_and_init(
-                       class_sun_reflect_ConstantPool);
-       
-       if(constantPool == NULL) {
-               /* out of memory */
-               return NULL;
-       }
-
-       LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
-
-       /* only resolve the parser method the first time */
-       if (m_parseParameterAnnotations == NULL) {
-               utf_parseParameterAnnotations = utf_new_char("parseParameterAnnotations");
-               utf_desc = utf_new_char(
-                       "([BLsun/reflect/ConstantPool;Ljava/lang/Class;I)"
-                       "[[Ljava/lang/annotation/Annotation;");
-
-               if (utf_parseParameterAnnotations == NULL || utf_desc == NULL) {
-                       /* out of memory */
-                       return NULL;
-               }
-
-               /* get parser method */
-
-               m_parseParameterAnnotations = class_resolveclassmethod(
-                       class_sun_reflect_annotation_AnnotationParser,
-                       utf_parseParameterAnnotations,
-                       utf_desc,
-                       referer,
-                       true);
-
-               if (m_parseParameterAnnotations == NULL)
-               {
-                       /* method not found */
-                       return NULL;
-               }
-       }
-
-       return (java_handle_objectarray_t*)vm_call_method(
-               m_parseParameterAnnotations, NULL, parameterAnnotations,
-               constantPool, declaringClass, numParameters);
-}
-#endif
-
-
-/*
- * 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/native/vm/reflect.h b/src/native/vm/reflect.h
deleted file mode 100644 (file)
index 6c6b451..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* src/native/vm/reflect.h - helper functions for java/lang/reflect
-
-   Copyright (C) 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 _REFLECT_H
-#define _REFLECT_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-#include "native/native.h"
-
-/* Keep this order of the native includes. */
-
-#include "native/include/java_lang_String.h"
-
-#if defined(ENABLE_JAVASE)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-#  include "native/include/java_nio_ByteBuffer.h"       /* required by j.l.CL */
-# endif
-# include "native/include/java_lang_ClassLoader.h"
-#endif
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-
-#if defined(ENABLE_JAVASE)
-# include "native/include/java_lang_reflect_Constructor.h"
-# include "native/include/java_lang_reflect_Field.h"
-# include "native/include/java_lang_reflect_Method.h"
-#endif
-
-#include "vmcore/field.h"
-#include "vmcore/method.h"
-
-
-/* function prototypes ********************************************************/
-
-java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m);
-java_lang_reflect_Field       *reflect_field_new(fieldinfo *f);
-java_lang_reflect_Method      *reflect_method_new(methodinfo *m);
-java_handle_t                 *reflect_constructor_newinstance(methodinfo *m, java_handle_objectarray_t *args, bool override);
-java_handle_t                 *reflect_method_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *args, bool override);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
-struct java_util_Map* reflect_get_declaredannotatios(
-       java_handle_bytearray_t *annotations,
-       java_lang_Class         *declaringClass,
-       classinfo               *referer);
-
-java_handle_objectarray_t* reflect_get_parameterannotations(
-       java_handle_t   *parameterAnnotations,
-       int32_t          slot,
-       java_lang_Class *declaringClass,
-       classinfo       *referer);
-#endif
-
-#endif /* _REFLECT_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/native/vm/reflection.cpp b/src/native/vm/reflection.cpp
new file mode 100644 (file)
index 0000000..73a8545
--- /dev/null
@@ -0,0 +1,269 @@
+/* src/native/vm/reflection.cpp - helper functions for java/lang/reflect
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_ANNOTATIONS) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+# include "vm/vm.hpp"
+#endif
+
+#include "native/vm/reflection.hpp"
+
+#include "vm/access.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/initialize.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/method.hpp"
+#include "vm/string.hpp"
+
+
+/**
+ * Invoke a method on the given object with the given arguments.
+ *
+ * For instance methods OBJ must be != NULL and the method is looked up
+ * in the vftbl of the object.
+ *
+ * For static methods, OBJ is ignored.
+ */
+java_handle_t* Reflection::invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params)
+{
+       methodinfo    *resm;
+       java_handle_t *ro;
+       int            argcount;
+       int            paramcount;
+
+       /* Sanity check. */
+
+       assert(m != NULL);
+
+       argcount = m->parseddesc->paramcount;
+       paramcount = argcount;
+
+       /* If method is non-static, remove the `this' pointer. */
+
+       if (!(m->flags & ACC_STATIC))
+               paramcount--;
+
+       /* For instance methods the object has to be an instance of the
+          class the method belongs to. For static methods the obj
+          parameter is ignored. */
+
+       if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->clazz))) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* check if we got the right number of arguments */
+
+       if (((params == NULL) && (paramcount != 0)) ||
+               (params && (LLNI_array_size(params) != paramcount))) 
+       {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* for instance methods we need an object */
+
+       if (!(m->flags & ACC_STATIC) && (o == NULL)) {
+               /* XXX not sure if that is the correct exception */
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* for static methods, zero object to make subsequent code simpler */
+       if (m->flags & ACC_STATIC)
+               o = NULL;
+
+       if (o != NULL) {
+               /* for instance methods we must do a vftbl lookup */
+               resm = method_vftbl_lookup(LLNI_vftbl_direct(o), m);
+       }
+       else {
+               /* for static methods, just for convenience */
+               resm = m;
+       }
+
+       ro = vm_call_method_objectarray(resm, o, params);
+
+       return ro;
+}
+
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
+/* reflect_get_declaredannotations *********************************************
+
+   Calls the annotation parser with the unparsed annotations and returnes
+   the parsed annotations as a map.
+   
+   IN:
+       annotations........the unparsed annotations
+       declaringClass.....the class in which the annotated element is declared
+       referer............the calling class (for the 'referer' parameter of
+                          vm_call_method())
+
+   RETURN VALUE:
+       The parsed annotations as a
+          java.util.Map<Class<? extends Annotation>, Annotation>.
+
+*******************************************************************************/
+
+java_handle_t* Reflection::get_declaredannotations(java_handle_bytearray_t *annotations, classinfo* declaringClass, classinfo *referer)
+{
+       static methodinfo* m_parseAnnotations = NULL;
+
+       java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool);
+               
+       if (h == NULL)
+               return NULL;
+
+       sun_reflect_ConstantPool cp(h);
+       cp.set_constantPoolOop(declaringClass);
+               
+       /* only resolve the parser method the first time */
+       if (m_parseAnnotations == NULL) {
+               // FIXME Use globals.
+               utf* utf_parseAnnotations = utf_new_char("parseAnnotations");
+               utf* utf_desc = utf_new_char("([BLsun/reflect/ConstantPool;Ljava/lang/Class;)Ljava/util/Map;");
+
+               if (utf_parseAnnotations == NULL || utf_desc == NULL)
+                       return NULL;
+               
+               m_parseAnnotations = class_resolveclassmethod(
+                       class_sun_reflect_annotation_AnnotationParser,
+                       utf_parseAnnotations,
+                       utf_desc,
+                       referer,
+                       true);
+       
+               if (m_parseAnnotations == NULL)
+                       return NULL;
+       }
+       
+       return (java_handle_t*) vm_call_method(m_parseAnnotations, NULL, annotations, cp.get_handle(), declaringClass);
+}
+
+
+/* reflect_get_parameterannotations *******************************************
+
+   Calls the annotation parser with the unparsed parameter annotations of
+   a method and returnes the parsed parameter annotations in a 2 dimensional
+   array.
+   
+   IN:
+       parameterAnnotations....the unparsed parameter annotations
+          slot....................the slot of the method
+       declaringClass..........the class in which the annotated element is
+                                  declared
+       referer.................the calling class (for the 'referer' parameter
+                               of vm_call_method())
+
+   RETURN VALUE:
+       The parsed parameter annotations in a 2 dimensional array.
+
+*******************************************************************************/
+
+java_handle_objectarray_t* Reflection::get_parameterannotations(java_handle_bytearray_t* parameterAnnotations, methodinfo* m, classinfo* referer)
+{
+       /* This method in java would be basically the following.
+        * We don't do it in java because we don't want to make a
+        * public method with wich you can get a ConstantPool, because
+        * with that you could read any kind of constants (even private
+        * ones).
+        *
+        * ConstantPool constPool = new ConstantPool();
+        * constPool.constantPoolOop = method.getDeclaringClass();
+        * return sun.reflect.AnnotationParser.parseParameterAnnotations(
+        *        parameterAnnotations,
+        *        constPool,
+        *        method.getDeclaringClass(),
+        *        method.getParameterTypes().length);
+        */
+
+       static methodinfo* m_parseParameterAnnotations = NULL;
+
+       /* get parameter count */
+
+       int32_t numParameters = method_get_parametercount(m);
+
+       if (numParameters < 0)
+               return NULL;
+
+       /* get ConstantPool */
+
+       java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool);
+       
+       if (h == NULL)
+               return NULL;
+
+       sun_reflect_ConstantPool cp(h);
+       cp.set_constantPoolOop(m->clazz);
+
+       /* only resolve the parser method the first time */
+       if (m_parseParameterAnnotations == NULL) {
+               utf* utf_parseParameterAnnotations = utf_new_char("parseParameterAnnotations");
+               utf* utf_desc = utf_new_char("([BLsun/reflect/ConstantPool;Ljava/lang/Class;I)[[Ljava/lang/annotation/Annotation;");
+
+               if (utf_parseParameterAnnotations == NULL || utf_desc == NULL)
+                       return NULL;
+
+               /* get parser method */
+
+               m_parseParameterAnnotations = class_resolveclassmethod(
+                       class_sun_reflect_annotation_AnnotationParser,
+                       utf_parseParameterAnnotations,
+                       utf_desc,
+                       referer,
+                       true);
+
+               if (m_parseParameterAnnotations == NULL)
+                       return NULL;
+       }
+
+       return (java_handle_objectarray_t*) vm_call_method(m_parseParameterAnnotations, NULL, parameterAnnotations, cp.get_handle(), m->clazz, numParameters);
+}
+#endif
+
+
+/*
+ * 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/native/vm/reflection.hpp b/src/native/vm/reflection.hpp
new file mode 100644 (file)
index 0000000..2901c0f
--- /dev/null
@@ -0,0 +1,64 @@
+/* src/native/vm/reflection.hpp - helper functions for java/lang/reflect
+
+   Copyright (C) 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 _REFLECTION_HPP
+#define _REFLECTION_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/native.hpp"
+
+#include "vm/field.hpp"
+#include "vm/method.hpp"
+
+
+class Reflection {
+public:
+       static java_handle_t* invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params);
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
+       static java_handle_t* get_declaredannotations(java_handle_bytearray_t *annotations, classinfo* declaringClass, classinfo *referer);
+       static java_handle_objectarray_t* get_parameterannotations(java_handle_bytearray_t* parameterAnnotations, methodinfo* m, classinfo *referer);
+#endif
+};
+
+#endif // _REFLECTION_HPP
+
+
+/*
+ * 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/native/vm/sun_misc_Unsafe.c b/src/native/vm/sun_misc_Unsafe.c
deleted file mode 100644 (file)
index 737559d..0000000
+++ /dev/null
@@ -1,1381 +0,0 @@
-/* src/native/vm/sun_misc_Unsafe.c - sun/misc/Unsafe
-
-   Copyright (C) 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 <stdint.h>
-#include <unistd.h>
-
-#include "machine-instr.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"                  /* before c.l.C */
-#include "native/include/java_lang_String.h"            /* required by j.l.CL */
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-# include "native/include/java_nio_ByteBuffer.h"        /* required by j.l.CL */
-#endif
-
-#include "native/include/java_lang_ClassLoader.h"        /* required by j.l.C */
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_reflect_Field.h"
-#include "native/include/java_lang_Thread.h"             /* required by s.m.U */
-#include "native/include/java_lang_Throwable.h"
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/java_lang_reflect_VMField.h"
-#endif
-
-#include "native/include/java_security_ProtectionDomain.h" /* required by smU */
-
-#include "native/include/sun_misc_Unsafe.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/system.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "registerNatives",        "()V",                                                        (void *) (intptr_t) &Java_sun_misc_Unsafe_registerNatives                },
-       { "getInt",                 "(Ljava/lang/Object;J)I",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J   },
-       { "putInt",                 "(Ljava/lang/Object;JI)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI  },
-       { "getObject",              "(Ljava/lang/Object;J)Ljava/lang/Object;",                    (void *) (intptr_t) &Java_sun_misc_Unsafe_getObject                      },
-       { "putObject",              "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void *) (intptr_t) &Java_sun_misc_Unsafe_putObject                      },
-       { "getBoolean",             "(Ljava/lang/Object;J)Z",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getBoolean                     },
-       { "putBoolean",             "(Ljava/lang/Object;JZ)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putBoolean                     },
-       { "getByte",                "(Ljava/lang/Object;J)B",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J  },
-       { "putByte",                "(Ljava/lang/Object;JB)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB },
-       { "getShort",               "(Ljava/lang/Object;J)S",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J },
-       { "putShort",               "(Ljava/lang/Object;JS)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS },
-       { "getChar",                "(Ljava/lang/Object;J)C",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J  },
-       { "putChar",                "(Ljava/lang/Object;JC)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC },
-       { "getLong",                "(Ljava/lang/Object;J)J",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J  },
-       { "putLong",                "(Ljava/lang/Object;JJ)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ },
-       { "getFloat",               "(Ljava/lang/Object;J)F",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J },
-       { "putFloat",               "(Ljava/lang/Object;JF)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF },
-       { "getDouble",              "(Ljava/lang/Object;J)D",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J },
-       { "putDouble",              "(Ljava/lang/Object;JD)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD },
-       { "getByte",                "(J)B",                                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_getByte__J                     },
-       { "putByte",                "(JB)V",                                                      (void *) (intptr_t) &Java_sun_misc_Unsafe_putByte__JB                    },
-       { "getShort",               "(J)S",                                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_getShort__J                    },
-       { "putShort",               "(JS)V",                                                      (void *) (intptr_t) &Java_sun_misc_Unsafe_putShort__JS                   },
-       { "getChar",                "(J)C",                                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_getChar__J                     },
-       { "putChar",                "(JC)V",                                                      (void *) (intptr_t) &Java_sun_misc_Unsafe_putChar__JC                    },
-       { "getInt",                 "(J)I",                                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_getInt__J                      },
-       { "putInt",                 "(JI)V",                                                      (void *) (intptr_t) &Java_sun_misc_Unsafe_putInt__JI                     },
-       { "getLong",                "(J)J",                                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_getLong__J                     },
-       { "putLong",                "(JJ)V",                                                      (void *) (intptr_t) &Java_sun_misc_Unsafe_putLong__JJ                    },
-       { "getFloat",               "(J)F",                                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_getFloat__J                    },
-       { "objectFieldOffset",      "(Ljava/lang/reflect/Field;)J",                               (void *) (intptr_t) &Java_sun_misc_Unsafe_objectFieldOffset              },
-       { "allocateMemory",         "(J)J",                                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_allocateMemory                 },
-#if 0
-       /* OpenJDK 7 */
-       { "setMemory",              "(Ljava/lang/Object;JJB)V",                                   (void *) (intptr_t) &Java_sun_misc_Unsafe_setMemory                      },
-       { "copyMemory",             "(Ljava/lang/Object;JLjava/lang/Object;JJ)V",                 (void *) (intptr_t) &Java_sun_misc_Unsafe_copyMemory                     },
-#else
-       { "setMemory",              "(JJB)V",                                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_setMemory                      },
-       { "copyMemory",             "(JJJ)V",                                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_copyMemory                     },
-#endif
-       { "freeMemory",             "(J)V",                                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_freeMemory                     },
-       { "staticFieldOffset",      "(Ljava/lang/reflect/Field;)J",                               (void *) (intptr_t) &Java_sun_misc_Unsafe_staticFieldOffset              },
-       { "staticFieldBase",        "(Ljava/lang/reflect/Field;)Ljava/lang/Object;",              (void *) (intptr_t) &Java_sun_misc_Unsafe_staticFieldBase                },
-       { "ensureClassInitialized", "(Ljava/lang/Class;)V",                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_ensureClassInitialized         },
-       { "arrayBaseOffset",        "(Ljava/lang/Class;)I",                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_arrayBaseOffset                },
-       { "arrayIndexScale",        "(Ljava/lang/Class;)I",                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_arrayIndexScale                },
-       { "addressSize",            "()I",                                                        (void *) (intptr_t) &Java_sun_misc_Unsafe_addressSize                    },
-       { "pageSize",               "()I",                                                        (void *) (intptr_t) &Java_sun_misc_Unsafe_pageSize                       },
-       { "defineClass",            "(Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;", (void *) (intptr_t) &Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2 },
-       { "allocateInstance",       "(Ljava/lang/Class;)Ljava/lang/Object;",                      (void *) (intptr_t) &Java_sun_misc_Unsafe_allocateInstance               },
-       { "throwException",         "(Ljava/lang/Throwable;)V",                                   (void *) (intptr_t) &Java_sun_misc_Unsafe_throwException                 },
-       { "compareAndSwapObject",   "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", (void *) (intptr_t) &Java_sun_misc_Unsafe_compareAndSwapObject           },
-       { "compareAndSwapInt",      "(Ljava/lang/Object;JII)Z",                                   (void *) (intptr_t) &Java_sun_misc_Unsafe_compareAndSwapInt              },
-       { "compareAndSwapLong",     "(Ljava/lang/Object;JJJ)Z",                                   (void *) (intptr_t) &Java_sun_misc_Unsafe_compareAndSwapLong             },
-       { "getObjectVolatile",      "(Ljava/lang/Object;J)Ljava/lang/Object;",                    (void *) (intptr_t) &Java_sun_misc_Unsafe_getObjectVolatile              },
-       { "putObjectVolatile",      "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void *) (intptr_t) &Java_sun_misc_Unsafe_putObjectVolatile              },
-       { "getIntVolatile",         "(Ljava/lang/Object;J)I",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getIntVolatile                 },
-       { "putIntVolatile",         "(Ljava/lang/Object;JI)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putIntVolatile                 },
-       { "getLongVolatile",        "(Ljava/lang/Object;J)J",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getLongVolatile                },
-       { "putLongVolatile",        "(Ljava/lang/Object;JJ)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putLongVolatile                },
-       { "putOrderedObject",       "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void *) (intptr_t) &Java_sun_misc_Unsafe_putOrderedObject               },
-       { "putOrderedInt",          "(Ljava/lang/Object;JI)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putOrderedInt                  },
-       { "putOrderedLong",         "(Ljava/lang/Object;JJ)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putOrderedLong                 },
-       { "unpark",                 "(Ljava/lang/Object;)V",                                      (void *) (intptr_t) &Java_sun_misc_Unsafe_unpark                         },
-       { "park",                   "(ZJ)V",                                                      (void *) (intptr_t) &Java_sun_misc_Unsafe_park                           },
-};
-
-
-/* _Jv_sun_misc_Unsafe_init ****************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_sun_misc_Unsafe_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("sun/misc/Unsafe");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    registerNatives
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_registerNatives(JNIEnv *env, jclass clazz)
-{
-       /* The native methods of this function are already registered in
-          _Jv_sun_misc_Unsafe_init() which is called during VM
-          startup. */
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getInt
- * Signature: (Ljava/lang/Object;J)I
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       int32_t *p;
-       int32_t  value;
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putInt
- * Signature: (Ljava/lang/Object;JI)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x)
-{
-       int32_t *p;
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       *p = x;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getObject
- * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObject(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       void **p;
-       void  *value;
-
-       p = (void **) (((uint8_t *) o) + offset);
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putObject
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObject(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, java_lang_Object *x)
-{
-       void **p;
-
-       p = (void **) (((uint8_t *) o) + offset);
-
-       *p = (void *) x;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getBoolean
- * Signature: (Ljava/lang/Object;J)Z
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getBoolean(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       int32_t *p;
-       int32_t  value;
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putBoolean
- * Signature: (Ljava/lang/Object;JZ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putBoolean(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x)
-{
-       int32_t *p;
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       *p = x;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getByte
- * Signature: (Ljava/lang/Object;J)B
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       int32_t *p;
-       int32_t  value;
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putByte
- * Signature: (Ljava/lang/Object;JB)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x)
-{
-       int32_t *p;
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       *p = x;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getShort
- * Signature: (Ljava/lang/Object;J)S
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       int32_t *p;
-       int32_t  value;
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putShort
- * Signature: (Ljava/lang/Object;JS)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x)
-{
-       int32_t *p;
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       *p = x;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getChar
- * Signature: (Ljava/lang/Object;J)C
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       int32_t *p;
-       int32_t  value;
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putChar
- * Signature: (Ljava/lang/Object;JC)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x)
-{
-       int32_t *p;
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       *p = x;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getLong
- * Signature: (Ljava/lang/Object;J)J
- */
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       int64_t *p;
-       int64_t  value;
-
-       p = (int64_t *) (((uint8_t *) o) + offset);
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putLong
- * Signature: (Ljava/lang/Object;JJ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int64_t x)
-{
-       int64_t *p;
-
-       p = (int64_t *) (((uint8_t *) o) + offset);
-
-       *p = x;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getFloat
- * Signature: (Ljava/lang/Object;J)F
- */
-JNIEXPORT float JNICALL Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       float *p;
-       float  value;
-
-       p = (float *) (((uint8_t *) o) + offset);
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putFloat
- * Signature: (Ljava/lang/Object;JF)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, float x)
-{
-       float *p;
-
-       p = (float *) (((uint8_t *) o) + offset);
-
-       *p = x;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getDouble
- * Signature: (Ljava/lang/Object;J)D
- */
-JNIEXPORT double JNICALL Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       double *p;
-       double  value;
-
-       p = (double *) (((uint8_t *) o) + offset);
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putDouble
- * Signature: (Ljava/lang/Object;JD)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, double x)
-{
-       double *p;
-
-       p = (double *) (((uint8_t *) o) + offset);
-
-       *p = x;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getByte
- * Signature: (J)B
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getByte__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address)
-{
-       int8_t *p;
-       int8_t  value;
-
-       p = (int8_t *) (intptr_t) address;
-
-       value = *p;
-
-       return (int32_t) value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putByte
- * Signature: (JB)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__JB(JNIEnv *env, sun_misc_Unsafe *this, int64_t address, int32_t value)
-{
-       int8_t *p;
-
-       p = (int8_t *) (intptr_t) address;
-
-       *p = (int8_t) value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getShort
- * Signature: (J)S
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getShort__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address)
-{
-       int16_t *p;
-       int16_t  value;
-
-       p = (int16_t *) (intptr_t) address;
-
-       value = *p;
-
-       return (int32_t) value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putShort
- * Signature: (JS)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__JS(JNIEnv *env, sun_misc_Unsafe *this, int64_t address, int32_t value)
-{
-       int16_t *p;
-
-       p = (int16_t *) (intptr_t) address;
-
-       *p = (int16_t) value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getChar
- * Signature: (J)C
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getChar__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address)
-{
-       uint16_t *p;
-       uint16_t  value;
-
-       p = (uint16_t *) (intptr_t) address;
-
-       value = *p;
-
-       return (int32_t) value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putChar
- * Signature: (JC)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__JC(JNIEnv *env, sun_misc_Unsafe *this, int64_t address, int32_t value)
-{
-       uint16_t *p;
-
-       p = (uint16_t *) (intptr_t) address;
-
-       *p = (uint16_t) value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getInt
- * Signature: (J)I
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getInt__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address)
-{
-       int32_t *p;
-       int32_t  value;
-
-       p = (int32_t *) (intptr_t) address;
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putInt
- * Signature: (JI)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__JI(JNIEnv *env, struct sun_misc_Unsafe* this, int64_t address, int32_t value)
-{
-       int32_t *p;
-
-       p = (int32_t *) (intptr_t) address;
-
-       *p = value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getLong
- * Signature: (J)J
- */
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_getLong__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address)
-{
-       int64_t *p;
-       int64_t  value;
-
-       p = (int64_t *) (intptr_t) address;
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putLong
- * Signature: (JJ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__JJ(JNIEnv *env, sun_misc_Unsafe *this, int64_t address, int64_t value)
-{
-       int64_t *p;
-
-       p = (int64_t *) (intptr_t) address;
-
-       *p = value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getFloat
- * Signature: (J)F
- */
-JNIEXPORT float JNICALL Java_sun_misc_Unsafe_getFloat__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address)
-{
-       float *p;
-       float  value;
-
-       p = (float *) (intptr_t) address;
-
-       value = *p;
-
-       return value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    objectFieldOffset
- * Signature: (Ljava/lang/reflect/Field;)J
- */
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, sun_misc_Unsafe *this, java_lang_reflect_Field *field)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_reflect_VMField *rvmf;
-#endif
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       LLNI_field_get_ref(field, f,     rvmf);
-       LLNI_field_get_cls(rvmf,  clazz, c);
-       LLNI_field_get_val(rvmf,  slot , slot);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       LLNI_field_get_cls(field, clazz, c);
-       LLNI_field_get_val(field, slot , slot);
-
-#else
-# error unknown configuration
-#endif
-
-       f = &(c->fields[slot]);
-
-       return (int64_t) f->offset;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    allocateMemory
- * Signature: (J)J
- */
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_allocateMemory(JNIEnv *env, sun_misc_Unsafe *this, int64_t bytes)
-{
-       size_t  length;
-       void   *p;
-
-       length = (size_t) bytes;
-
-       if ((length != (uint64_t) bytes) || (bytes < 0)) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       p = MNEW(uint8_t, length);
-
-       return (int64_t) (intptr_t) p;
-}
-
-
-#if 0
-/* OpenJDK 7 */
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    setMemory
- * Signature: (Ljava/lang/Object;JJB)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int64_t bytes, int32_t value)
-{
-       size_t  length;
-       void   *p;
-
-       length = (size_t) bytes;
-
-       if ((length != (uint64_t) bytes) || (bytes < 0)) {
-               exceptions_throw_illegalargumentexception();
-               return;
-       }
-
-       /* XXX Missing LLNI: we need to unwrap this object. */
-
-       p = (void *) (((uint8_t *) o) + offset);
-
-       /* XXX Not sure this is correct. */
-
-       system_memset(p, value, length);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    copyMemory
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;JJ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *srcBase, int64_t srcOffset, java_lang_Object *destBase, int64_t destOffset, int64_t bytes)
-{
-       size_t  length;
-       void   *src;
-       void   *dest;
-
-       if (bytes == 0)
-               return;
-
-       length = (size_t) bytes;
-
-       if ((length != (uint64_t) bytes) || (bytes < 0)) {
-               exceptions_throw_illegalargumentexception();
-               return;
-       }
-
-       /* XXX Missing LLNI: We need to unwrap these objects. */
-
-       src  = (void *) (((uint8_t *) srcBase) + srcOffset);
-       dest = (void *) (((uint8_t *) destBase) + destOffset);
-
-       system_memcpy(dest, src, length);
-}
-#else
-/*
- * Class:     sun/misc/Unsafe
- * Method:    setMemory
- * Signature: (JJB)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, sun_misc_Unsafe *this, int64_t address, int64_t bytes, int32_t value)
-{
-       size_t  length;
-       void   *p;
-
-       length = (size_t) bytes;
-
-       if ((length != (uint64_t) bytes) || (bytes < 0)) {
-               exceptions_throw_illegalargumentexception();
-               return;
-       }
-
-       p = (void *) (intptr_t) address;
-
-       /* XXX Not sure this is correct. */
-
-       system_memset(p, value, length);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    copyMemory
- * Signature: (JJJ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, sun_misc_Unsafe *this, int64_t srcAddress, int64_t destAddress, int64_t bytes)
-{
-       size_t  length;
-       void   *src;
-       void   *dest;
-
-       if (bytes == 0)
-               return;
-
-       length = (size_t) bytes;
-
-       if ((length != (uint64_t) bytes) || (bytes < 0)) {
-               exceptions_throw_illegalargumentexception();
-               return;
-       }
-
-       src  = (void *) (intptr_t) srcAddress;
-       dest = (void *) (intptr_t) destAddress;
-
-       system_memcpy(dest, src, length);
-}
-#endif
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    freeMemory
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_freeMemory(JNIEnv *env, sun_misc_Unsafe *this, int64_t address)
-{
-       void *p;
-
-       p = (void *) (intptr_t) address;
-
-       if (p == NULL)
-               return;
-
-       /* we pass length 1 to trick the free function */
-
-       MFREE(p, uint8_t, 1);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    staticFieldOffset
- * Signature: (Ljava/lang/reflect/Field;)J
- */
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_staticFieldOffset(JNIEnv *env, sun_misc_Unsafe *this, java_lang_reflect_Field *f)
-{
-       /* The offset of static fields is 0. */
-
-       return 0;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    staticFieldBase
- * Signature: (Ljava/lang/reflect/Field;)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_staticFieldBase(JNIEnv *env, sun_misc_Unsafe *this, java_lang_reflect_Field *rf)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_reflect_VMField *rvmf;
-#endif
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       LLNI_field_get_ref(rf,   f,     rvmf);
-       LLNI_field_get_cls(rvmf, clazz, c);
-       LLNI_field_get_val(rvmf, slot , slot);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       LLNI_field_get_cls(rf, clazz, c);
-       LLNI_field_get_val(rf, slot , slot);
-
-#else
-# error unknown configuration
-#endif
-
-       f = &(c->fields[slot]);
-
-       return (java_lang_Object *) (f->value);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    ensureClassInitialized
- * Signature: (Ljava/lang/Class;)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_ensureClassInitialized(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Class *class)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(class);
-
-       if (!(c->state & CLASS_INITIALIZED))
-               initialize_class(c);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    arrayBaseOffset
- * Signature: (Ljava/lang/Class;)I
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Class *arrayClass)
-{
-       classinfo       *c;
-       arraydescriptor *ad;
-
-       c  = LLNI_classinfo_unwrap(arrayClass);
-       ad = c->vftbl->arraydesc;
-
-       if (ad == NULL) {
-               /* XXX does that exception exist? */
-               exceptions_throw_internalerror("java/lang/InvalidClassException");
-               return 0;
-       }
-
-       return ad->dataoffset;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    arrayIndexScale
- * Signature: (Ljava/lang/Class;)I
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Class *arrayClass)
-{
-       classinfo       *c;
-       arraydescriptor *ad;
-
-       c  = LLNI_classinfo_unwrap(arrayClass);
-       ad = c->vftbl->arraydesc;
-
-       if (ad == NULL) {
-               /* XXX does that exception exist? */
-               exceptions_throw_internalerror("java/lang/InvalidClassException");
-               return 0;
-       }
-
-       return ad->componentsize;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    addressSize
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv *env, sun_misc_Unsafe *this)
-{
-       return SIZEOF_VOID_P;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    pageSize
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_pageSize(JNIEnv *env, sun_misc_Unsafe *this)
-{
-       int sz;
-
-       sz = getpagesize();
-
-       return sz;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    defineClass
- * Signature: (Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2(JNIEnv *env, sun_misc_Unsafe *this, java_lang_String *name, java_handle_bytearray_t *b, int32_t off, int32_t len, java_lang_ClassLoader *loader, java_security_ProtectionDomain *protectionDomain)
-{
-       classloader_t   *cl;
-       utf             *utfname;
-       classinfo       *c;
-       java_lang_Class *o;
-
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       /* check if data was passed */
-
-       if (b == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* check the indexes passed */
-
-       if ((off < 0) || (len < 0) || ((off + len) > LLNI_array_size(b))) {
-               exceptions_throw_arrayindexoutofboundsexception();
-               return NULL;
-       }
-
-       if (name != NULL) {
-               /* convert '.' to '/' in java string */
-
-               utfname = javastring_toutf((java_handle_t *) name, true);
-       } 
-       else {
-               utfname = NULL;
-       }
-
-       /* define the class */
-
-       c = class_define(utfname, cl, len, (uint8_t *) &(LLNI_array_direct(b, off)),
-                                        (java_handle_t *) protectionDomain);
-
-       if (c == NULL)
-               return NULL;
-
-       /* for convenience */
-
-       o = LLNI_classinfo_wrap(c);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       /* set ProtectionDomain */
-
-       LLNI_field_set_ref(o, pd, protectionDomain);
-#endif
-
-       return o;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    allocateInstance
- * Signature: (Ljava/lang/Class;)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_allocateInstance(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Class *cls)
-{
-       classinfo     *c;
-       java_handle_t *o;
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       o = builtin_new(c);
-
-       return (java_lang_Object *) o;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    throwException
- * Signature: (Ljava/lang/Throwable;)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_throwException(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Throwable *ee)
-{
-       java_handle_t *o;
-
-       o = (java_handle_t *) ee;
-
-       exceptions_set_exception(o);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    compareAndSwapObject
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, java_lang_Object *expected, java_lang_Object *x)
-{
-#if 1
-       void **p;
-       void  *value;
-
-       p = (void **) (((uint8_t *) o) + offset);
-
-       /* XXX this should be atomic */
-
-       value = *p;
-
-       if (value == expected) {
-               *p = x;
-
-               return true;
-       }
-
-       return false;
-#else
-       volatile void **p;
-       void           *result;
-
-       /* XXX Use LLNI */
-
-       p = (volatile void **) (((uint8_t *) o) + offset);
-
-       result = atomic_compare_and_swap_address(p, expected, x);
-
-       if (result == expected)
-               return true;
-
-       return false;
-#endif
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    compareAndSwapInt
- * Signature: (Ljava/lang/Object;JII)Z
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, sun_misc_Unsafe* this, java_lang_Object* o, int64_t offset, int32_t expected, int32_t x)
-{
-#if 1
-       int32_t *p;
-       int32_t  value;
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       /* XXX this should be atomic */
-
-       value = *p;
-
-       if (value == expected) {
-               *p = x;
-
-               return true;
-       }
-
-       return false;
-#else
-       int32_t *p;
-       int32_t  result;
-
-       /* XXX Use LLNI */
-
-       p = (int32_t *) (((uint8_t *) o) + offset);
-
-       result = atomic_compare_and_swap_int(p, expected, x);
-
-       if (result == expected)
-               return true;
-
-       return false;
-#endif
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    compareAndSwapLong
- * Signature: (Ljava/lang/Object;JJJ)Z
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int64_t expected, int64_t x)
-{
-       int64_t *p;
-       int64_t  value;
-
-       p = (int64_t *) (((uint8_t *) o) + offset);
-
-       /* XXX this should be atomic */
-
-       value = *p;
-
-       if (value == expected) {
-               *p = x;
-
-               return true;
-       }
-
-       return false;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getObjectVolatile
- * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       volatile void **p;
-       volatile void  *value;
-
-       p = (volatile void **) (((uint8_t *) o) + offset);
-
-       value = *p;
-
-       return (java_lang_Object *) value;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putObjectVolatile
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, java_lang_Object *x)
-{
-       volatile void **p;
-
-       p = (volatile void **) (((uint8_t *) o) + offset);
-
-       *p = x;
-}
-
-
-#define UNSAFE_GET_VOLATILE(type)                                                      \
-       java_handle_t *_h;                                                                              \
-       java_object_t *_o;                                                                              \
-       volatile type *_p;                                                                              \
-       volatile type  _x;                                                                              \
-                                                                                                                       \
-       _h = (java_handle_t *) o;                                                               \
-                                                                                                                       \
-       LLNI_CRITICAL_START;                                                                    \
-                                                                                                                       \
-       _o = LLNI_UNWRAP(_h);                                                                   \
-       _p = (volatile type *) (((uint8_t *) _o) + offset);             \
-                                                                                                                       \
-       _x = *_p;                                                                                               \
-                                                                                                                       \
-       LLNI_CRITICAL_END;                                                                              \
-                                                                                                                       \
-       return _x;
-
-
-#define UNSAFE_PUT_VOLATILE(type)                                                      \
-       java_handle_t *_h;                                                                              \
-       java_object_t *_o;                                                                              \
-       volatile type *_p;                                                                              \
-                                                                                                                       \
-       _h = (java_handle_t *) o;                                                               \
-                                                                                                                       \
-       LLNI_CRITICAL_START;                                                                    \
-                                                                                                                       \
-       _o = LLNI_UNWRAP(_h);                                                                   \
-       _p = (volatile type *) (((uint8_t *) _o) + offset);             \
-                                                                                                                       \
-       *_p = x;                                                                                                \
-                                                                                                                       \
-       MEMORY_BARRIER();                                                                               \
-                                                                                                                       \
-       LLNI_CRITICAL_END;
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getIntVolatile
- * Signature: (Ljava/lang/Object;J)I
- */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       UNSAFE_GET_VOLATILE(int32_t);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putIntVolatile
- * Signature: (Ljava/lang/Object;JI)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x)
-{
-       UNSAFE_PUT_VOLATILE(int32_t);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getLongVolatile
- * Signature: (Ljava/lang/Object;J)J
- */
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
-{
-       UNSAFE_GET_VOLATILE(int64_t);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putLongVolatile
- * Signature: (Ljava/lang/Object;JJ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int64_t x)
-{
-       UNSAFE_PUT_VOLATILE(int64_t);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putOrderedObject
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, java_lang_Object *x)
-{
-       java_handle_t  *_h;
-       java_handle_t  *_hx;
-       java_object_t  *_o;
-       java_object_t  *_x;
-       volatile void **_p;
-
-       _h  = (java_handle_t *) o;
-       _hx = (java_handle_t *) x;
-
-       LLNI_CRITICAL_START;
-
-       _o = LLNI_UNWRAP(_h);
-       _x = LLNI_UNWRAP(_hx);
-       _p = (volatile void **) (((uint8_t *) _o) + offset);
-
-       *_p = _x;
-
-       MEMORY_BARRIER();
-
-       LLNI_CRITICAL_END;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putOrderedInt
- * Signature: (Ljava/lang/Object;JI)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x)
-{
-       UNSAFE_PUT_VOLATILE(int32_t);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putOrderedLong
- * Signature: (Ljava/lang/Object;JJ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int64_t x)
-{
-       UNSAFE_PUT_VOLATILE(int64_t);
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    unpark
- * Signature: (Ljava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *thread)
-{
-       /* XXX IMPLEMENT ME */
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    park
- * Signature: (ZJ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, sun_misc_Unsafe *this, int32_t isAbsolute, int64_t time)
-{
-       /* XXX IMPLEMENT ME */
-}
-
-
-/*
- * 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:
- */
diff --git a/src/native/vm/sun_misc_Unsafe.cpp b/src/native/vm/sun_misc_Unsafe.cpp
new file mode 100644 (file)
index 0000000..950df13
--- /dev/null
@@ -0,0 +1,1197 @@
+/* src/native/vm/sun_misc_Unsafe.cpp - sun/misc/Unsafe
+
+   Copyright (C) 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 <stdint.h>
+#include <unistd.h>
+
+#include "threads/atomic.hpp"
+
+#include "mm/memory.h"
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/sun_misc_Unsafe.h"
+#endif
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/initialize.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/os.hpp"
+#include "vm/string.hpp"
+#include "vm/utf8.h"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_registerNatives(JNIEnv *env, jclass clazz)
+{
+       /* The native methods of this function are already registered in
+          _Jv_sun_misc_Unsafe_init() which is called during VM
+          startup. */
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getInt
+ * Signature: (Ljava/lang/Object;J)I
+ */
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get<int32_t>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putInt
+ * Signature: (Ljava/lang/Object;JI)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x)
+{
+       FieldAccess::set(o, offset, x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getObject
+ * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_getObject(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get<jobject>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putObject
+ * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x)
+{
+       FieldAccess::set(o, offset, x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getBoolean
+ * Signature: (Ljava/lang/Object;J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_getBoolean(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get<int32_t>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putBoolean
+ * Signature: (Ljava/lang/Object;JZ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putBoolean(JNIEnv *env, jobject _this, jobject o, jlong offset, jboolean x)
+{
+       FieldAccess::set(o, offset, (int32_t) x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getByte
+ * Signature: (Ljava/lang/Object;J)B
+ */
+JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get<int32_t>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putByte
+ * Signature: (Ljava/lang/Object;JB)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB(JNIEnv *env, jobject _this, jobject o, jlong offset, jbyte x)
+{
+       FieldAccess::set(o, offset, (int32_t) x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getShort
+ * Signature: (Ljava/lang/Object;J)S
+ */
+JNIEXPORT jshort JNICALL Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get<int32_t>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putShort
+ * Signature: (Ljava/lang/Object;JS)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS(JNIEnv *env, jobject _this, jobject o, jlong offset, jshort x)
+{
+       FieldAccess::set(o, offset, (int32_t) x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getChar
+ * Signature: (Ljava/lang/Object;J)C
+ */
+JNIEXPORT jchar JNICALL Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get<int32_t>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putChar
+ * Signature: (Ljava/lang/Object;JC)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC(JNIEnv *env, jobject _this, jobject o, jlong offset, jchar x)
+{
+       FieldAccess::set(o, offset, (int32_t) x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getLong
+ * Signature: (Ljava/lang/Object;J)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get<int64_t>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putLong
+ * Signature: (Ljava/lang/Object;JJ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x)
+{
+       FieldAccess::set(o, offset, x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getFloat
+ * Signature: (Ljava/lang/Object;J)F
+ */
+JNIEXPORT jfloat JNICALL Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get<float>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putFloat
+ * Signature: (Ljava/lang/Object;JF)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF(JNIEnv *env, jobject _this, jobject o, jlong offset, jfloat x)
+{
+       FieldAccess::set(o, offset, x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getDouble
+ * Signature: (Ljava/lang/Object;J)D
+ */
+JNIEXPORT jdouble JNICALL Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get<double>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putDouble
+ * Signature: (Ljava/lang/Object;JD)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD(JNIEnv *env, jobject _this, jobject o, jlong offset, jdouble x)
+{
+       FieldAccess::set(o, offset, x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getByte
+ * Signature: (J)B
+ */
+JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByte__J(JNIEnv *env, jobject _this, jlong address)
+{
+       int8_t *p;
+       int8_t  value;
+
+       p = (int8_t *) (intptr_t) address;
+
+       value = *p;
+
+       return (int32_t) value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putByte
+ * Signature: (JB)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__JB(JNIEnv *env, jobject _this, jlong address, jbyte value)
+{
+       int8_t *p;
+
+       p = (int8_t *) (intptr_t) address;
+
+       *p = (int8_t) value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getShort
+ * Signature: (J)S
+ */
+JNIEXPORT jshort JNICALL Java_sun_misc_Unsafe_getShort__J(JNIEnv *env, jobject _this, jlong address)
+{
+       int16_t *p;
+       int16_t  value;
+
+       p = (int16_t *) (intptr_t) address;
+
+       value = *p;
+
+       return (int32_t) value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putShort
+ * Signature: (JS)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__JS(JNIEnv *env, jobject _this, jlong address, jshort value)
+{
+       int16_t *p;
+
+       p = (int16_t *) (intptr_t) address;
+
+       *p = (int16_t) value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getChar
+ * Signature: (J)C
+ */
+JNIEXPORT jchar JNICALL Java_sun_misc_Unsafe_getChar__J(JNIEnv *env, jobject _this, jlong address)
+{
+       uint16_t *p;
+       uint16_t  value;
+
+       p = (uint16_t *) (intptr_t) address;
+
+       value = *p;
+
+       return (int32_t) value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putChar
+ * Signature: (JC)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__JC(JNIEnv *env, jobject _this, jlong address, jchar value)
+{
+       uint16_t *p;
+
+       p = (uint16_t *) (intptr_t) address;
+
+       *p = (uint16_t) value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getInt
+ * Signature: (J)I
+ */
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getInt__J(JNIEnv *env, jobject _this, jlong address)
+{
+       int32_t *p;
+       int32_t  value;
+
+       p = (int32_t *) (intptr_t) address;
+
+       value = *p;
+
+       return value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putInt
+ * Signature: (JI)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__JI(JNIEnv *env, jobject _this, jlong address, jint value)
+{
+       int32_t *p;
+
+       p = (int32_t *) (intptr_t) address;
+
+       *p = value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getLong
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLong__J(JNIEnv *env, jobject _this, jlong address)
+{
+       int64_t *p;
+       int64_t  value;
+
+       p = (int64_t *) (intptr_t) address;
+
+       value = *p;
+
+       return value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putLong
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__JJ(JNIEnv *env, jobject _this, jlong address, jlong value)
+{
+       int64_t *p;
+
+       p = (int64_t *) (intptr_t) address;
+
+       *p = value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getFloat
+ * Signature: (J)F
+ */
+JNIEXPORT jfloat JNICALL Java_sun_misc_Unsafe_getFloat__J(JNIEnv *env, jobject _this, jlong address)
+{
+       float *p;
+       float  value;
+
+       p = (float *) (intptr_t) address;
+
+       value = *p;
+
+       return value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putFloat
+ * Signature: (JF)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__JF(JNIEnv *env, jobject _this, jlong address, jfloat value)
+{
+       float* p;
+
+       p = (float*) (intptr_t) address;
+
+       *p = value;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    objectFieldOffset
+ * Signature: (Ljava/lang/reflect/Field;)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, jobject _this, jobject field)
+{
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       java_lang_reflect_Field rf(field);
+       java_lang_reflect_VMField rvmf(rf.get_f());
+       fieldinfo* f = rvmf.get_field();
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       java_lang_reflect_Field rf(field);
+       fieldinfo* f = rf.get_field();
+
+#else
+# error unknown configuration
+#endif
+
+       return (jlong) f->offset;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    allocateMemory
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_allocateMemory(JNIEnv *env, jobject _this, jlong bytes)
+{
+       size_t  length;
+       void   *p;
+
+       length = (size_t) bytes;
+
+       if ((length != (uint64_t) bytes) || (bytes < 0)) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       p = MNEW(uint8_t, length);
+
+       return (int64_t) (intptr_t) p;
+}
+
+
+#if 0
+/* OpenJDK 7 */
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    setMemory
+ * Signature: (Ljava/lang/Object;JJB)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong bytes, jbyte value)
+{
+       size_t  length;
+       void   *p;
+
+       length = (size_t) bytes;
+
+       if ((length != (uint64_t) bytes) || (bytes < 0)) {
+               exceptions_throw_illegalargumentexception();
+               return;
+       }
+
+       /* XXX Missing LLNI: we need to unwrap _this object. */
+
+       p = (void *) (((uint8_t *) o) + offset);
+
+       /* XXX Not sure this is correct. */
+
+       os::memset(p, value, length);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    copyMemory
+ * Signature: (Ljava/lang/Object;JLjava/lang/Object;JJ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, jobject _this, jobject srcBase, jlong srcOffset, jobject destBase, jlong destOffset, jlong bytes)
+{
+       size_t  length;
+       void   *src;
+       void   *dest;
+
+       if (bytes == 0)
+               return;
+
+       length = (size_t) bytes;
+
+       if ((length != (uint64_t) bytes) || (bytes < 0)) {
+               exceptions_throw_illegalargumentexception();
+               return;
+       }
+
+       /* XXX Missing LLNI: We need to unwrap these objects. */
+
+       src  = (void *) (((uint8_t *) srcBase) + srcOffset);
+       dest = (void *) (((uint8_t *) destBase) + destOffset);
+
+       os::memcpy(dest, src, length);
+}
+#else
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    setMemory
+ * Signature: (JJB)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, jobject _this, jlong address, jlong bytes, jbyte value)
+{
+       size_t  length;
+       void   *p;
+
+       length = (size_t) bytes;
+
+       if ((length != (uint64_t) bytes) || (bytes < 0)) {
+               exceptions_throw_illegalargumentexception();
+               return;
+       }
+
+       p = (void *) (intptr_t) address;
+
+       /* XXX Not sure this is correct. */
+
+       os::memset(p, value, length);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    copyMemory
+ * Signature: (JJJ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, jobject _this, jlong srcAddress, jlong destAddress, jlong bytes)
+{
+       size_t  length;
+       void   *src;
+       void   *dest;
+
+       if (bytes == 0)
+               return;
+
+       length = (size_t) bytes;
+
+       if ((length != (uint64_t) bytes) || (bytes < 0)) {
+               exceptions_throw_illegalargumentexception();
+               return;
+       }
+
+       src  = (void *) (intptr_t) srcAddress;
+       dest = (void *) (intptr_t) destAddress;
+
+       os::memcpy(dest, src, length);
+}
+#endif
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    freeMemory
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_freeMemory(JNIEnv *env, jobject _this, jlong address)
+{
+       void *p;
+
+       p = (void *) (intptr_t) address;
+
+       if (p == NULL)
+               return;
+
+       /* we pass length 1 to trick the free function */
+
+       MFREE(p, uint8_t, 1);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    staticFieldOffset
+ * Signature: (Ljava/lang/reflect/Field;)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_staticFieldOffset(JNIEnv *env, jobject _this, jobject f)
+{
+       /* The offset of static fields is 0. */
+
+       return 0;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    staticFieldBase
+ * Signature: (Ljava/lang/reflect/Field;)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_staticFieldBase(JNIEnv *env, jobject _this, jobject field)
+{
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       java_lang_reflect_Field rf(field);
+       java_lang_reflect_VMField rvmf(rf.get_f());
+       fieldinfo* f = rvmf.get_field();
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       java_lang_reflect_Field rf(field);
+       fieldinfo* f = rf.get_field();
+
+#else
+# error unknown configuration
+#endif
+
+       return (jobject) (f->value);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    ensureClassInitialized
+ * Signature: (Ljava/lang/Class;)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_ensureClassInitialized(JNIEnv *env, jobject _this, jclass clazz)
+{
+       classinfo *c;
+
+       c = LLNI_classinfo_unwrap(clazz);
+
+       if (!(c->state & CLASS_INITIALIZED))
+               initialize_class(c);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    arrayBaseOffset
+ * Signature: (Ljava/lang/Class;)I
+ */
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, jobject _this, jclass arrayClass)
+{
+       classinfo       *c;
+       arraydescriptor *ad;
+
+       c  = LLNI_classinfo_unwrap(arrayClass);
+       ad = c->vftbl->arraydesc;
+
+       if (ad == NULL) {
+               /* XXX does that exception exist? */
+               exceptions_throw_internalerror("java/lang/InvalidClassException");
+               return 0;
+       }
+
+       return ad->dataoffset;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    arrayIndexScale
+ * Signature: (Ljava/lang/Class;)I
+ */
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, jobject _this, jclass arrayClass)
+{
+       classinfo       *c;
+       arraydescriptor *ad;
+
+       c  = LLNI_classinfo_unwrap(arrayClass);
+       ad = c->vftbl->arraydesc;
+
+       if (ad == NULL) {
+               /* XXX does that exception exist? */
+               exceptions_throw_internalerror("java/lang/InvalidClassException");
+               return 0;
+       }
+
+       return ad->componentsize;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    addressSize
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv *env, jobject _this)
+{
+       return SIZEOF_VOID_P;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    pageSize
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_pageSize(JNIEnv *env, jobject _this)
+{
+       int sz;
+
+       sz = getpagesize();
+
+       return sz;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    defineClass
+ * Signature: (Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;
+ */
+JNIEXPORT jclass JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2(JNIEnv *env, jobject _this, jstring name, jbyteArray b, jint off, jint len, jobject loader, jobject protectionDomain)
+{
+       classloader_t   *cl;
+       utf             *utfname;
+       classinfo       *c;
+
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       /* check if data was passed */
+
+       if (b == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* check the indexes passed */
+
+       if ((off < 0) || (len < 0) || ((off + len) > LLNI_array_size(b))) {
+               exceptions_throw_arrayindexoutofboundsexception();
+               return NULL;
+       }
+
+       if (name != NULL) {
+               /* convert '.' to '/' in java string */
+
+               utfname = javastring_toutf((java_handle_t *) name, true);
+       } 
+       else {
+               utfname = NULL;
+       }
+
+       /* define the class */
+
+       c = class_define(utfname, cl, len, (uint8_t *) &(LLNI_array_direct((java_handle_bytearray_t*) b, off)),
+                                        (java_handle_t *) protectionDomain);
+
+       if (c == NULL)
+               return NULL;
+
+       java_handle_t* h = LLNI_classinfo_wrap(c);
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       // Set ProtectionDomain.
+       java_lang_Class jlc(h);
+       jlc.set_pd(protectionDomain);
+#endif
+
+       return (jclass) h;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    allocateInstance
+ * Signature: (Ljava/lang/Class;)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_allocateInstance(JNIEnv *env, jobject _this, jclass cls)
+{
+       classinfo     *c;
+       java_handle_t *o;
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       o = builtin_new(c);
+
+       return (jobject ) o;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    throwException
+ * Signature: (Ljava/lang/Throwable;)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_throwException(JNIEnv *env, jobject _this, jobject ee)
+{
+       java_handle_t *o;
+
+       o = (java_handle_t *) ee;
+
+       exceptions_set_exception(o);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    compareAndSwapObject
+ * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject expected, jobject x)
+{
+       volatile void **p;
+       void           *result;
+
+       /* XXX Use LLNI */
+
+       p = (volatile void **) (((uint8_t *) o) + offset);
+
+       result = Atomic::compare_and_swap(p, expected, x);
+
+       if (result == expected)
+               return true;
+
+       return false;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    compareAndSwapInt
+ * Signature: (Ljava/lang/Object;JII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, jobject _this, jobject o, jlong offset, jint expected, jint x)
+{
+       uint32_t *p;
+       uint32_t  result;
+
+       /* XXX Use LLNI */
+
+       p = (uint32_t *) (((uint8_t *) o) + offset);
+
+       result = Atomic::compare_and_swap(p, expected, x);
+
+       if (result == (uint32_t) expected)
+               return true;
+
+       return false;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    compareAndSwapLong
+ * Signature: (Ljava/lang/Object;JJJ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong expected, jlong x)
+{
+       uint64_t *p;
+       uint64_t  result;
+
+       /* XXX Use LLNI */
+
+       p = (uint64_t *) (((uint8_t *) o) + offset);
+
+       result = Atomic::compare_and_swap(p, expected, x);
+
+       if (result == (uint64_t) expected)
+               return true;
+
+       return false;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getObjectVolatile
+ * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get_volatile<jobject>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putObjectVolatile
+ * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x)
+{
+       FieldAccess::set_volatile(o, offset, x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getByteVolatile
+ * Signature: (Ljava/lang/Object;J)B
+ */
+JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByteVolatile(JNIEnv* env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get_volatile<int32_t>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getIntVolatile
+ * Signature: (Ljava/lang/Object;J)I
+ */
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get_volatile<int32_t>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putIntVolatile
+ * Signature: (Ljava/lang/Object;JI)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x)
+{
+       FieldAccess::set_volatile(o, offset, x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getLongVolatile
+ * Signature: (Ljava/lang/Object;J)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get_volatile<int64_t>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putLongVolatile
+ * Signature: (Ljava/lang/Object;JJ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x)
+{
+       FieldAccess::set_volatile(o, offset, x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getFloatVolatile
+ * Signature: (Ljava/lang/Object;J)F
+ */
+JNIEXPORT jfloat JNICALL Java_sun_misc_Unsafe_getFloatVolatile(JNIEnv* env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get_volatile<float>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getDoubleVolatile
+ * Signature: (Ljava/lang/Object;J)D
+ */
+JNIEXPORT jdouble JNICALL Java_sun_misc_Unsafe_getDoubleVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
+{
+       return FieldAccess::get_volatile<double>(o, offset);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putOrderedObject
+ * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x)
+{
+       FieldAccess::set_volatile(o, offset, x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putOrderedInt
+ * Signature: (Ljava/lang/Object;JI)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x)
+{
+       FieldAccess::set_volatile(o, offset, x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putOrderedLong
+ * Signature: (Ljava/lang/Object;JJ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x)
+{
+       FieldAccess::set_volatile(o, offset, x);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    unpark
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, jobject _this, jobject thread)
+{
+       java_handle_t *h = (java_handle_t *) thread;
+       threadobject *t;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       h = java_lang_Thread(h).get_vmThread();
+#endif
+       t = thread_get_thread(h);
+
+       threads_unpark(t);
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    park
+ * Signature: (ZJ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, jobject _this, jboolean isAbsolute, jlong time)
+{
+       threads_park(isAbsolute, time);
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "registerNatives",        (char*) "()V",                                                        (void*) (uintptr_t) &Java_sun_misc_Unsafe_registerNatives                  },
+       { (char*) "getInt",                 (char*) "(Ljava/lang/Object;J)I",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J     },
+       { (char*) "putInt",                 (char*) "(Ljava/lang/Object;JI)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI    },
+       { (char*) "getObject",              (char*) "(Ljava/lang/Object;J)Ljava/lang/Object;",                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_getObject                        },
+       { (char*) "putObject",              (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_putObject                        },
+       { (char*) "getBoolean",             (char*) "(Ljava/lang/Object;J)Z",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getBoolean                       },
+       { (char*) "putBoolean",             (char*) "(Ljava/lang/Object;JZ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putBoolean                       },
+       { (char*) "getByte",                (char*) "(Ljava/lang/Object;J)B",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J    },
+       { (char*) "putByte",                (char*) "(Ljava/lang/Object;JB)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB   },
+       { (char*) "getShort",               (char*) "(Ljava/lang/Object;J)S",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J   },
+       { (char*) "putShort",               (char*) "(Ljava/lang/Object;JS)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS  },
+       { (char*) "getChar",                (char*) "(Ljava/lang/Object;J)C",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J    },
+       { (char*) "putChar",                (char*) "(Ljava/lang/Object;JC)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC   },
+       { (char*) "getLong",                (char*) "(Ljava/lang/Object;J)J",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J    },
+       { (char*) "putLong",                (char*) "(Ljava/lang/Object;JJ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ   },
+       { (char*) "getFloat",               (char*) "(Ljava/lang/Object;J)F",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J   },
+       { (char*) "putFloat",               (char*) "(Ljava/lang/Object;JF)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF  },
+       { (char*) "getDouble",              (char*) "(Ljava/lang/Object;J)D",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J  },
+       { (char*) "putDouble",              (char*) "(Ljava/lang/Object;JD)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD },
+       { (char*) "getByte",                (char*) "(J)B",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByte__J                       },
+       { (char*) "putByte",                (char*) "(JB)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putByte__JB                      },
+       { (char*) "getShort",               (char*) "(J)S",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getShort__J                      },
+       { (char*) "putShort",               (char*) "(JS)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putShort__JS                     },
+       { (char*) "getChar",                (char*) "(J)C",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getChar__J                       },
+       { (char*) "putChar",                (char*) "(JC)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putChar__JC                      },
+       { (char*) "getInt",                 (char*) "(J)I",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getInt__J                        },
+       { (char*) "putInt",                 (char*) "(JI)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putInt__JI                       },
+       { (char*) "getLong",                (char*) "(J)J",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLong__J                       },
+       { (char*) "putLong",                (char*) "(JJ)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLong__JJ                      },
+       { (char*) "getFloat",               (char*) "(J)F",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloat__J                      },
+       { (char*) "putFloat",               (char*) "(JF)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putFloat__JF                     },
+       { (char*) "objectFieldOffset",      (char*) "(Ljava/lang/reflect/Field;)J",                               (void*) (uintptr_t) &Java_sun_misc_Unsafe_objectFieldOffset                },
+       { (char*) "allocateMemory",         (char*) "(J)J",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_allocateMemory                   },
+#if 0
+       // OpenJDK 7
+       { (char*) "setMemory",              (char*) "(Ljava/lang/Object;JJB)V",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_setMemory                        },
+       { (char*) "copyMemory",             (char*) "(Ljava/lang/Object;JLjava/lang/Object;JJ)V",                 (void*) (uintptr_t) &Java_sun_misc_Unsafe_copyMemory                       },
+#else
+       { (char*) "setMemory",              (char*) "(JJB)V",                                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_setMemory                        },
+       { (char*) "copyMemory",             (char*) "(JJJ)V",                                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_copyMemory                       },
+#endif
+       { (char*) "freeMemory",             (char*) "(J)V",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_freeMemory                       },
+       { (char*) "staticFieldOffset",      (char*) "(Ljava/lang/reflect/Field;)J",                               (void*) (uintptr_t) &Java_sun_misc_Unsafe_staticFieldOffset                },
+       { (char*) "staticFieldBase",        (char*) "(Ljava/lang/reflect/Field;)Ljava/lang/Object;",              (void*) (uintptr_t) &Java_sun_misc_Unsafe_staticFieldBase                  },
+       { (char*) "ensureClassInitialized", (char*) "(Ljava/lang/Class;)V",                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_ensureClassInitialized           },
+       { (char*) "arrayBaseOffset",        (char*) "(Ljava/lang/Class;)I",                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_arrayBaseOffset                  },
+       { (char*) "arrayIndexScale",        (char*) "(Ljava/lang/Class;)I",                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_arrayIndexScale                  },
+       { (char*) "addressSize",            (char*) "()I",                                                        (void*) (uintptr_t) &Java_sun_misc_Unsafe_addressSize                      },
+       { (char*) "pageSize",               (char*) "()I",                                                        (void*) (uintptr_t) &Java_sun_misc_Unsafe_pageSize                         },
+       { (char*) "defineClass",            (char*) "(Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2 },
+       { (char*) "allocateInstance",       (char*) "(Ljava/lang/Class;)Ljava/lang/Object;",                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_allocateInstance                 },
+       { (char*) "throwException",         (char*) "(Ljava/lang/Throwable;)V",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_throwException                   },
+       { (char*) "compareAndSwapObject",   (char*) "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapObject             },
+       { (char*) "compareAndSwapInt",      (char*) "(Ljava/lang/Object;JII)Z",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapInt                },
+       { (char*) "compareAndSwapLong",     (char*) "(Ljava/lang/Object;JJJ)Z",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapLong               },
+       { (char*) "getObjectVolatile",      (char*) "(Ljava/lang/Object;J)Ljava/lang/Object;",                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_getObjectVolatile                },
+       { (char*) "putObjectVolatile",      (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_putObjectVolatile                },
+       { (char*) "getByteVolatile",        (char*) "(Ljava/lang/Object;J)B",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByteVolatile                  },
+       { (char*) "getIntVolatile",         (char*) "(Ljava/lang/Object;J)I",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getIntVolatile                   },
+       { (char*) "putIntVolatile",         (char*) "(Ljava/lang/Object;JI)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putIntVolatile                   },
+       { (char*) "getLongVolatile",        (char*) "(Ljava/lang/Object;J)J",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLongVolatile                  },
+       { (char*) "putLongVolatile",        (char*) "(Ljava/lang/Object;JJ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLongVolatile                  },
+       { (char*) "getFloatVolatile",       (char*) "(Ljava/lang/Object;J)F",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloatVolatile                 },
+       { (char*) "getDoubleVolatile",      (char*) "(Ljava/lang/Object;J)D",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getDoubleVolatile                },
+       { (char*) "putOrderedObject",       (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedObject                 },
+       { (char*) "putOrderedInt",          (char*) "(Ljava/lang/Object;JI)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedInt                    },
+       { (char*) "putOrderedLong",         (char*) "(Ljava/lang/Object;JJ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedLong                   },
+       { (char*) "unpark",                 (char*) "(Ljava/lang/Object;)V",                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_unpark                           },
+       { (char*) "park",                   (char*) "(ZJ)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_park                             },
+};
+
+
+/* _Jv_sun_misc_Unsafe_init ****************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_sun_misc_Unsafe_init(void)
+{
+       utf* u = utf_new_char("sun/misc/Unsafe");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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 b6cf86dd5bdfc94439964c1c0c7c11cd74faf3aa..b8c40a9ae558ec8e4b018c747b02a27e09eff58e 100644 (file)
@@ -49,14 +49,19 @@ noinst_LTLIBRARIES = \
 
 if ENABLE_THREADS
 libthreads_la_SOURCES = \
-       critical.c \
-       critical.h \
-       lock-common.h \
-       mutex.h \
-       threadlist.c \
-       threadlist.h \
-       thread.c \
-       thread.h
+       atomic.cpp \
+       atomic.hpp \
+       condition.hpp \
+       lock.cpp \
+       lock.hpp \
+       lockword.cpp \
+       lockword.hpp \
+       removeme.cpp \
+       mutex.hpp \
+       threadlist.cpp \
+       threadlist.hpp \
+       thread.cpp \
+       thread.hpp
 else
 libthreads_la_SOURCES =
 endif
diff --git a/src/threads/atomic.cpp b/src/threads/atomic.cpp
new file mode 100644 (file)
index 0000000..e5ca7c8
--- /dev/null
@@ -0,0 +1,159 @@
+/* src/threads/atomic.cpp - atomic instructions
+
+   Copyright (C) 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 <stdint.h>
+
+#include "threads/atomic.hpp"
+#include "threads/mutex.hpp"
+
+// Gobal mutex for generic atomic instructions.
+static Mutex lock;
+
+
+/**
+ * A generic atomic compare and swap for 32-bit integer values.  This
+ * function is using a mutex to provide atomicity.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+uint32_t Atomic::generic_compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
+{
+       uint32_t result;
+
+       lock.lock();
+
+       // Do the compare-and-swap.
+
+       result = *p;
+
+       if (oldval == result)
+               *p = newval;
+
+       lock.unlock();
+
+       return result;
+}
+
+
+/**
+ * A generic atomic compare and swap for 64-bit integer values.  This
+ * function is using a mutex to provide atomicity.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+uint64_t Atomic::generic_compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
+{
+       uint64_t result;
+
+       lock.lock();
+
+       // Do the compare-and-swap.
+
+       result = *p;
+
+       if (oldval == result)
+               *p = newval;
+
+       lock.unlock();
+
+       return result;
+}
+
+
+/**
+ * A generic atomic compare and swap for pointer values.  This
+ * function is using a mutex to provide atomicity.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+void* Atomic::generic_compare_and_swap(volatile void** p, void* oldval, void* newval)
+{
+       void* result;
+
+       lock.lock();
+
+       // Do the compare-and-swap.
+
+       result = (void*) *p;
+
+       if (oldval == result)
+               *p = newval;
+
+       lock.lock();
+
+       return result;
+}
+
+
+/**
+ * A generic memory barrier.  This function is using a mutex to
+ * provide atomicity.
+ */
+void Atomic::generic_memory_barrier(void)
+{
+       lock.lock();
+       lock.unlock();
+}
+
+
+// Legacy C interface.
+
+extern "C" {
+uint32_t Atomic_compare_and_swap_32(volatile uint32_t *p, uint32_t oldval, uint32_t newval) { return Atomic::compare_and_swap(p, oldval, newval); }
+uint64_t Atomic_compare_and_swap_64(volatile uint64_t *p, uint64_t oldval, uint64_t newval) { return Atomic::compare_and_swap(p, oldval, newval); }
+void*    Atomic_compare_and_swap_ptr(volatile void** p, void* oldval, void* newval) { return Atomic::compare_and_swap(p, oldval, newval); }
+void     Atomic_memory_barrier(void) { Atomic::memory_barrier(); }
+void     Atomic_write_memory_barrier(void) { Atomic::write_memory_barrier(); }
+void     Atomic_instruction_barrier(void) { Atomic::instruction_barrier(); }
+}
+
+
+/*
+ * 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/threads/atomic.hpp b/src/threads/atomic.hpp
new file mode 100644 (file)
index 0000000..382a872
--- /dev/null
@@ -0,0 +1,83 @@
+/* src/threads/atomic.hpp - atomic instructions
+
+   Copyright (C) 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 _ATOMIC_HPP
+#define _ATOMIC_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+
+class Atomic {
+public:
+       // Generic functions.
+       static uint32_t generic_compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval);
+       static uint64_t generic_compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval);
+       static void*    generic_compare_and_swap(volatile void** p, void* oldval, void* newval);
+       static void     generic_memory_barrier(void);
+
+       // Machine dependent functions.
+       static uint32_t compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval);
+       static uint64_t compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval);
+       static void*    compare_and_swap(volatile void** p, void* oldval, void* newval);
+       static void     memory_barrier(void);
+       static void     write_memory_barrier(void);
+       static void     instruction_barrier(void);
+};
+
+// Include machine dependent implementation.
+#include "md-atomic.hpp"
+
+#else
+
+// Legacy C interface.
+
+uint32_t Atomic_compare_and_swap_32(volatile uint32_t *p, uint32_t oldval, uint32_t newval);
+uint64_t Atomic_compare_and_swap_64(volatile uint64_t *p, uint64_t oldval, uint64_t newval);
+void*    Atomic_compare_and_swap_ptr(volatile void** p, void* oldval, void* newval);
+void     Atomic_memory_barrier(void);
+void     Atomic_write_memory_barrier(void);
+void     Atomic_instruction_barrier(void);
+
+#endif
+
+#endif // _ATOMIC_HPP
+
+
+/*
+ * 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/threads/condition.hpp b/src/threads/condition.hpp
new file mode 100644 (file)
index 0000000..b237835
--- /dev/null
@@ -0,0 +1,52 @@
+/* src/threads/condition.hpp - condition variable
+
+   Copyright (C) 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 _CONDITION_HPP
+#define _CONDITION_HPP
+
+#include "config.h"
+
+#include "threads/mutex.hpp"
+
+#if defined(ENABLE_THREADS)
+# include "threads/posix/condition-posix.hpp"
+#endif
+
+#endif /* _CONDITION_HPP */
+
+
+/*
+ * 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/threads/critical.c b/src/threads/critical.c
deleted file mode 100644 (file)
index 51c3317..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/* src/threads/critical.c - restartable critical sections
-
-   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
-
-   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 <stddef.h>
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "threads/critical.h"
-
-#include "toolbox/avl.h"
-
-
-/* the AVL tree containing the critical sections */
-
-static avl_tree_t *criticaltree;
-
-
-/* prototypes *****************************************************************/
-
-static int critical_comparator(const void *treenode, const void *node);
-
-
-/* critical_init ***************************************************************
-
-   Init global data structures.
-
-*******************************************************************************/
-
-void critical_init(void)
-{
-    criticaltree = avl_create(&critical_comparator);
-}
-
-
-/* critical_comparator *********************************************************
-
-   Comparison function for AVL tree of critical section.
-
-   IN:
-       treenode....node in the tree
-          node........node to compare with tree-node
-
-   RETURN VALUE:
-       -1, 0, +1 for (pa <, ==, > pb)
-
-*******************************************************************************/
-
-static int critical_comparator(const void *treenode, const void *node)
-{
-       const critical_section_node_t *treecsn;
-       const critical_section_node_t *csn;
-
-       treecsn = treenode;
-       csn     = node;
-
-#ifdef __S390__
-#      define ADDR_MASK(x) ((u1 *)((s4)(x) & 0x7FFFFFFF))
-#else
-#      define ADDR_MASK(x) (x)
-#endif
-
-       /* compare for avl_find if we have found an entry */
-
-       if (
-               (ADDR_MASK(treecsn->start) <= ADDR_MASK(csn->start)) && 
-               (ADDR_MASK(csn->start) < ADDR_MASK(treecsn->end))
-       )
-               return 0;
-
-       /* these are for walking the tree */
-
-       if (ADDR_MASK(treecsn->start) < ADDR_MASK(csn->start))
-               return -1;
-       else
-               return 1;
-
-#undef ADDR_MASK
-}
-
-
-/* critical_section_register ***************************************************
-   Register a critical section.
-
-   IN:
-       csn....node for the critical section
-
-*******************************************************************************/
-
-void critical_section_register(critical_section_node_t *csn)
-{
-       (void) avl_insert(criticaltree, csn);
-}
-
-
-/* critical_find_restart_point *************************************************
-
-   Find a restart point for the given PC, in case it is in a critical
-   section.
-
-   IN:
-       pc.........PC
-
-   OUT:
-       PC of the restart point, or
-          NULL if the given mcodeptr is not in a critical section
-
-*******************************************************************************/
-
-u1 *critical_find_restart_point(u1 *pc)
-{
-       critical_section_node_t        csnpc;
-       const critical_section_node_t *csn;
-
-       /* fill the temporary node for comparison */
-
-       csnpc.start = pc;
-
-       /* see if there's an entry for that PC */
-
-       csn = avl_find(criticaltree, &csnpc);
-
-       if (csn == NULL)
-               return NULL;
-
-       return csn->restart;
-}
-
-
-/*
- * 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/threads/critical.h b/src/threads/critical.h
deleted file mode 100644 (file)
index 7bb2917..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/* src/threads/native/critical.h - restartable critical sections
-
-   Copyright (C) 1996-2005, 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
-
-   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.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Stefan Ring
-                       Edwin Steiner
-
-   Changes: Christian Thalinger
-
-*/
-
-
-#ifndef _CRITICAL_H
-#define _CRITICAL_H
-
-#include "config.h"
-
-#include <signal.h>   /* required on some older Darwin systems for ucontext.h */
-#include <ucontext.h>
-
-
-/* forward typedefs ***********************************************************/
-
-typedef struct critical_section_node_t critical_section_node_t;
-
-
-/* critical_section_node_t *****************************************************
-
-   A node representing a restartable critical section.
-
-*******************************************************************************/
-
-struct critical_section_node_t {
-       u1 *start;
-       u1 *end;
-       u1 *restart;
-};
-
-
-/* functions ******************************************************************/
-
-void  critical_init(void);
-void  critical_section_register(critical_section_node_t *);
-u1   *critical_find_restart_point(u1*);
-
-/* this is a machine dependent function (see src/vm/jit/$(ARCH_DIR)/md.c) */
-void  md_critical_section_restart(ucontext_t *_uc);
-
-#endif /* _CRITICAL_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/threads/lock-common.h b/src/threads/lock-common.h
deleted file mode 100644 (file)
index 1bc3cdc..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* src/threads/lock-common.h - common stuff of lock implementation
-
-   Copyright (C) 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 _LOCK_COMMON_H
-#define _LOCK_COMMON_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#if defined(ENABLE_THREADS)
-# include "threads/posix/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
-
-
-/* only define the following stuff with thread enabled ************************/
-
-#if defined(ENABLE_THREADS)
-
-/* functions ******************************************************************/
-
-void lock_init(void);
-
-void lock_init_object_lock(java_object_t *);
-
-ptrint lock_pre_compute_thinlock(s4 index);
-
-bool lock_monitor_enter(java_handle_t *);
-bool lock_monitor_exit(java_handle_t *);
-
-#define LOCK_monitor_enter    (functionptr) lock_monitor_enter
-#define LOCK_monitor_exit     (functionptr) lock_monitor_exit
-
-bool lock_is_held_by_current_thread(java_handle_t *o);
-
-void lock_wait_for_object(java_handle_t *o, s8 millis, s4 nanos);
-void lock_notify_object(java_handle_t *o);
-void lock_notify_all_object(java_handle_t *o);
-
-#endif /* ENABLE_THREADS */
-
-#endif /* _LOCK_COMMON_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/threads/lock.cpp b/src/threads/lock.cpp
new file mode 100644 (file)
index 0000000..5bcee69
--- /dev/null
@@ -0,0 +1,1392 @@
+/* src/threads/lock.cpp - lock implementation
+
+   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 <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "threads/atomic.hpp"
+#include "threads/lock.hpp"
+#include "threads/mutex.hpp"
+#include "threads/threadlist.hpp"
+#include "threads/thread.hpp"
+
+#include "toolbox/list.hpp"
+
+#include "vm/exceptions.hpp"
+#include "vm/finalizer.h"
+#include "vm/global.h"
+#include "vm/options.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
+#if defined(ENABLE_JVMTI)
+#include "native/jvmti/cacaodbg.h"
+#endif
+
+#if defined(ENABLE_GC_BOEHM)
+# include "mm/boehm-gc/include/gc.h"
+#endif
+
+
+/* debug **********************************************************************/
+
+#if !defined(NDEBUG)
+# define DEBUGLOCKS(format) \
+    do { \
+        if (opt_DebugLocks) { \
+            log_println format; \
+        } \
+    } while (0)
+#else
+# define DEBUGLOCKS(format)
+#endif
+
+
+/******************************************************************************/
+/* MACROS                                                                     */
+/******************************************************************************/
+
+/* number of lock records in the first pool allocated for a thread */
+#define LOCK_INITIAL_LOCK_RECORDS 8
+
+#define LOCK_INITIAL_HASHTABLE_SIZE  1613  /* a prime in the middle between 1024 and 2048 */
+
+
+/******************************************************************************/
+/* MACROS FOR THIN/FAT LOCKS                                                  */
+/******************************************************************************/
+
+/* We use a variant of the tasuki locks described in the paper
+ *     
+ *     Tamiya Onodera, Kiyokuni Kawachiya
+ *     A Study of Locking Objects with Bimodal Fields
+ *     Proceedings of the ACM OOPSLA '99, pp. 223-237
+ *     1999
+ *
+ * The underlying thin locks are a variant of the thin locks described in
+ * 
+ *     Bacon, Konuru, Murthy, Serrano
+ *     Thin Locks: Featherweight Synchronization for Java
+ *        Proceedings of the ACM Conference on Programming Language Design and 
+ *        Implementation (Montreal, Canada), SIGPLAN Notices volume 33, number 6,
+ *        June 1998
+ *
+ * In thin lock mode the lockword looks like this:
+ *
+ *     ,----------------------,-----------,---,
+ *     |      thread ID       |   count   | 0 |
+ *     `----------------------'-----------'---'
+ *
+ *     thread ID......the 'index' of the owning thread, or 0
+ *     count..........number of times the lock has been entered        minus 1
+ *     0..............the shape bit is 0 in thin lock mode
+ *
+ * In fat lock mode it is basically a lock_record_t *:
+ *
+ *     ,----------------------------------,---,
+ *     |    lock_record_t * (without LSB) | 1 |
+ *     `----------------------------------'---'
+ *
+ *     1..............the shape bit is 1 in fat lock mode
+ */
+
+/* global variables ***********************************************************/
+
+/* hashtable mapping objects to lock records */
+static lock_hashtable_t lock_hashtable;
+
+
+/******************************************************************************/
+/* PROTOTYPES                                                                 */
+/******************************************************************************/
+
+static void lock_hashtable_init(void);
+
+static inline Lockword* lock_lockword_get(java_handle_t* o);
+static void lock_record_enter(threadobject *t, lock_record_t *lr);
+static void lock_record_exit(threadobject *t, lock_record_t *lr);
+static bool lock_record_wait(threadobject *t, lock_record_t *lr, s8 millis, s4 nanos);
+static void lock_record_notify(threadobject *t, lock_record_t *lr, bool one);
+
+
+/*============================================================================*/
+/* INITIALIZATION OF DATA STRUCTURES                                          */
+/*============================================================================*/
+
+
+/* lock_init *******************************************************************
+
+   Initialize global data for locking.
+
+*******************************************************************************/
+
+void lock_init(void)
+{
+       /* initialize lock hashtable */
+
+       lock_hashtable_init();
+
+#if defined(ENABLE_VMLOG)
+       vmlog_cacao_init_lock();
+#endif
+}
+
+
+/* lock_record_new *************************************************************
+
+   Allocate a lock record.
+
+*******************************************************************************/
+
+static lock_record_t *lock_record_new(void)
+{
+       lock_record_t *lr;
+
+       /* allocate the data structure on the C heap */
+
+       lr = NEW(lock_record_t);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_lock_record += sizeof(lock_record_t);
+#endif
+
+       /* initialize the members */
+
+       lr->object  = NULL;
+       lr->owner   = NULL;
+       lr->count   = 0;
+       lr->waiters = new List<threadobject*>();
+
+#if defined(ENABLE_GC_CACAO)
+       /* register the lock object as weak reference with the GC */
+
+       gc_weakreference_register(&(lr->object), GC_REFTYPE_LOCKRECORD);
+#endif
+
+       // Initialize the mutex.
+       lr->mutex = new Mutex();
+
+       DEBUGLOCKS(("[lock_record_new   : lr=%p]", (void *) lr));
+
+       return lr;
+}
+
+
+/* lock_record_free ************************************************************
+
+   Free a lock record.
+
+   IN:
+       lr....lock record to free
+
+*******************************************************************************/
+
+static void lock_record_free(lock_record_t *lr)
+{
+       DEBUGLOCKS(("[lock_record_free  : lr=%p]", (void *) lr));
+
+       // Destroy the mutex.
+       delete lr->mutex;
+
+#if defined(ENABLE_GC_CACAO)
+       /* unregister the lock object reference with the GC */
+
+       gc_weakreference_unregister(&(lr->object));
+#endif
+
+       // Free the waiters list.
+       delete lr->waiters;
+
+       /* Free the data structure. */
+
+       FREE(lr, lock_record_t);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_lock_record -= sizeof(lock_record_t);
+#endif
+}
+
+
+/*============================================================================*/
+/* HASHTABLE MAPPING OBJECTS TO LOCK RECORDS                                  */
+/*============================================================================*/
+
+/* lock_hashtable_init *********************************************************
+
+   Initialize the global hashtable mapping objects to lock records.
+
+*******************************************************************************/
+
+static void lock_hashtable_init(void)
+{
+       lock_hashtable.mutex   = new Mutex();
+
+       lock_hashtable.size    = LOCK_INITIAL_HASHTABLE_SIZE;
+       lock_hashtable.entries = 0;
+       lock_hashtable.ptr     = MNEW(lock_record_t *, lock_hashtable.size);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_lock_hashtable += sizeof(lock_record_t *) * lock_hashtable.size;
+#endif
+
+       MZERO(lock_hashtable.ptr, lock_record_t *, lock_hashtable.size);
+}
+
+
+/* lock_hashtable_grow *********************************************************
+
+   Grow the lock record hashtable to about twice its current size and
+   rehash the entries.
+
+*******************************************************************************/
+
+/* must be called with hashtable mutex locked */
+static void lock_hashtable_grow(void)
+{
+       u4 oldsize;
+       u4 newsize;
+       lock_record_t **oldtable;
+       lock_record_t **newtable;
+       lock_record_t *lr;
+       lock_record_t *next;
+       u4 i;
+       u4 h;
+       u4 newslot;
+
+       /* allocate a new table */
+
+       oldsize = lock_hashtable.size;
+       newsize = oldsize*2 + 1; /* XXX should use prime numbers */
+
+       DEBUGLOCKS(("growing lock hashtable to size %d", newsize));
+
+       oldtable = lock_hashtable.ptr;
+       newtable = MNEW(lock_record_t *, newsize);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_lock_hashtable += sizeof(lock_record_t *) * newsize;
+#endif
+
+       MZERO(newtable, lock_record_t *, newsize);
+
+       /* rehash the entries */
+
+       for (i = 0; i < oldsize; i++) {
+               lr = oldtable[i];
+               while (lr) {
+                       next = lr->hashlink;
+
+                       h = heap_hashcode(lr->object);
+                       newslot = h % newsize;
+
+                       lr->hashlink = newtable[newslot];
+                       newtable[newslot] = lr;
+
+                       lr = next;
+               }
+       }
+
+       /* replace the old table */
+
+       lock_hashtable.ptr  = newtable;
+       lock_hashtable.size = newsize;
+
+       MFREE(oldtable, lock_record_t *, oldsize);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_lock_hashtable -= sizeof(lock_record_t *) * oldsize;
+#endif
+}
+
+
+/* lock_hashtable_cleanup ******************************************************
+
+   Removes (and frees) lock records which have a cleared object reference
+   from the hashtable. The locked object was reclaimed by the GC.
+
+*******************************************************************************/
+
+#if defined(ENABLE_GC_CACAO)
+void lock_hashtable_cleanup(void)
+{
+       threadobject  *t;
+       lock_record_t *lr;
+       lock_record_t *prev;
+       lock_record_t *next;
+       int i;
+
+       t = THREADOBJECT;
+
+       /* lock the hashtable */
+
+       Mutex_lock(lock_hashtable.mutex);
+
+       /* search the hashtable for cleared references */
+
+       for (i = 0; i < lock_hashtable.size; i++) {
+               lr = lock_hashtable.ptr[i];
+               prev = NULL;
+
+               while (lr) {
+                       next = lr->hashlink;
+
+                       /* remove lock records with cleared references */
+
+                       if (lr->object == NULL) {
+
+                               /* unlink the lock record from the hashtable */
+
+                               if (prev == NULL)
+                                       lock_hashtable.ptr[i] = next;
+                               else
+                                       prev->hashlink = next;
+
+                               /* free the lock record */
+
+                               lock_record_free(lr);
+
+                       } else {
+                               prev = lr;
+                       }
+
+                       lr = next;
+               }
+       }
+
+       /* unlock the hashtable */
+
+       Mutex_unlock(lock_hashtable.mutex);
+}
+#endif
+
+
+/* lock_hashtable_get **********************************************************
+
+   Find the lock record for the given object.  If it does not exists,
+   yet, create it and enter it in the hashtable.
+
+   IN:
+         o....the object to look up
+
+   RETURN VALUE:
+      the lock record to use for this object
+
+*******************************************************************************/
+
+#if defined(ENABLE_GC_BOEHM)
+static void lock_record_finalizer(void *object, void *p);
+#endif
+
+static lock_record_t *lock_hashtable_get(java_handle_t* o)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       u4             slot;
+       lock_record_t *lr;
+
+       Lockword* lockword = lock_lockword_get(o);
+
+       if (lockword->is_fat_lock())
+               return lockword->get_fat_lock();
+
+       // Lock the hashtable.
+       lock_hashtable.mutex->lock();
+
+       /* lookup the lock record in the hashtable */
+
+       slot = heap_hashcode(LLNI_DIRECT(o)) % lock_hashtable.size;
+       lr   = lock_hashtable.ptr[slot];
+
+       for (; lr != NULL; lr = lr->hashlink) {
+               if (lr->object == LLNI_DIRECT(o))
+                       break;
+       }
+
+       if (lr == NULL) {
+               /* not found, we must create a new one */
+
+               lr = lock_record_new();
+
+               lr->object = LLNI_DIRECT(o);
+
+#if defined(ENABLE_GC_BOEHM)
+               /* register new finalizer to clean up the lock record */
+
+               GC_REGISTER_FINALIZER(LLNI_DIRECT(o), lock_record_finalizer, 0, 0, 0);
+#endif
+
+               /* enter it in the hashtable */
+
+               lr->hashlink             = lock_hashtable.ptr[slot];
+               lock_hashtable.ptr[slot] = lr;
+               lock_hashtable.entries++;
+
+               /* check whether the hash should grow */
+
+               if (lock_hashtable.entries * 3 > lock_hashtable.size * 4) {
+                       lock_hashtable_grow();
+               }
+       }
+
+       // Unlock the hashtable.
+       lock_hashtable.mutex->unlock();
+
+       /* return the new lock record */
+
+       return lr;
+}
+
+
+/* lock_hashtable_remove *******************************************************
+
+   Remove the lock record for the given object from the hashtable
+   and free it afterwards.
+
+   IN:
+       t....the current thread
+       o....the object to look up
+
+*******************************************************************************/
+
+static void lock_hashtable_remove(threadobject *t, java_handle_t *o)
+{
+       lock_record_t *lr;
+       u4             slot;
+       lock_record_t *tmplr;
+
+       // Lock the hashtable.
+       lock_hashtable.mutex->lock();
+
+       /* get lock record */
+
+       Lockword* lockword = lock_lockword_get(o);
+
+       // Sanity check.
+       assert(lockword->is_fat_lock());
+
+       lr = lockword->get_fat_lock();
+
+       /* remove the lock-record from the hashtable */
+
+       slot  = heap_hashcode(LLNI_DIRECT(o)) % lock_hashtable.size;
+       tmplr = lock_hashtable.ptr[slot];
+
+       if (tmplr == lr) {
+               /* special handling if it's the first in the chain */
+
+               lock_hashtable.ptr[slot] = lr->hashlink;
+       }
+       else {
+               for (; tmplr != NULL; tmplr = tmplr->hashlink) {
+                       if (tmplr->hashlink == lr) {
+                               tmplr->hashlink = lr->hashlink;
+                               break;
+                       }
+               }
+
+               assert(tmplr != NULL);
+       }
+
+       /* decrease entry count */
+
+       lock_hashtable.entries--;
+
+       // Unlock the hashtable.
+       lock_hashtable.mutex->unlock();
+
+       /* free the lock record */
+
+       lock_record_free(lr);
+}
+
+
+/* lock_record_finalizer *******************************************************
+
+   XXX Remove me for exact GC.
+
+*******************************************************************************/
+
+static void lock_record_finalizer(void *object, void *p)
+{
+       java_handle_t *o;
+       classinfo     *c;
+
+       o = (java_handle_t *) object;
+
+#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES)
+       /* XXX this is only a dirty hack to make Boehm work with handles */
+
+       o = LLNI_WRAP((java_object_t *) o);
+#endif
+
+       LLNI_class_get(o, c);
+
+#if !defined(NDEBUG)
+       if (opt_DebugFinalizer) {
+               log_start();
+               log_print("[finalizer lockrecord: o=%p p=%p class=", object, p);
+               class_print(c);
+               log_print("]");
+               log_finish();
+       }
+#endif
+
+       /* check for a finalizer function */
+
+       if (c->finalizer != NULL)
+               finalizer_run(object, p);
+
+       /* remove the lock-record entry from the hashtable and free it */
+
+       lock_hashtable_remove(THREADOBJECT, o);
+}
+
+
+/*============================================================================*/
+/* LOCKING ALGORITHM                                                          */
+/*============================================================================*/
+
+
+/* lock_lockword_get ***********************************************************
+
+   Get the lockword for the given object.
+
+   IN:
+      o............the object
+
+*******************************************************************************/
+
+static inline Lockword* lock_lockword_get(java_handle_t* o)
+{
+#if defined(ENABLE_GC_CACAO)
+       // Sanity check.
+       assert(GCCriticalSection::inside() == true);
+#endif
+
+       return &(LLNI_DIRECT(o)->lockword);
+}
+
+
+/* lock_record_enter ***********************************************************
+
+   Enter the lock represented by the given lock record.
+
+   IN:
+      t.................the current thread
+         lr................the lock record
+
+*******************************************************************************/
+
+static inline void lock_record_enter(threadobject *t, lock_record_t *lr)
+{
+       lr->mutex->lock();
+       lr->owner = t;
+}
+
+
+/* lock_record_exit ************************************************************
+
+   Release the lock represented by the given lock record.
+
+   IN:
+      t.................the current thread
+         lr................the lock record
+
+   PRE-CONDITION:
+      The current thread must own the lock represented by this lock record.
+         This is NOT checked by this function!
+
+*******************************************************************************/
+
+static inline void lock_record_exit(threadobject *t, lock_record_t *lr)
+{
+       lr->owner = NULL;
+       lr->mutex->unlock();
+}
+
+
+/* lock_inflate ****************************************************************
+
+   Inflate the lock of the given object. This may only be called by the
+   owner of the monitor of the object.
+
+   IN:
+         o............the object of which to inflate the lock
+         lr...........the lock record to install. The current thread must
+                      own the lock of this lock record!
+
+   PRE-CONDITION:
+      The current thread must be the owner of this object's monitor AND
+         of the lock record's lock!
+
+*******************************************************************************/
+
+static void lock_inflate(java_handle_t *o, lock_record_t *lr)
+{
+       Lockword* lockword = lock_lockword_get(o);
+       lockword->inflate(lr);
+}
+
+
+static void sable_flc_waiting(Lockword *lockword, threadobject *t, java_handle_t *o)
+{
+       int32_t index;
+       threadobject *t_other;
+       int old_flc;
+
+       index = lockword->get_thin_lock_thread_index();
+       t_other = ThreadList::get_thread_by_index(index);
+
+       // The lockword could have changed during our way here.  If the
+       // thread index is zero, the lock got unlocked and we simply
+       // return.
+       if (t_other == NULL)
+/*             failure, TODO: add statistics */
+               return;
+
+       t_other->flc_lock->lock();
+       old_flc = t_other->flc_bit;
+       t_other->flc_bit = true;
+
+       DEBUGLOCKS(("thread %d set flc bit for lock-holding thread %d", t->index, t_other->index));
+
+       // Set FLC bit first, then read the lockword again.
+       Atomic::memory_barrier();
+
+       lockword = lock_lockword_get(o);
+
+       /* Lockword is still the way it was seen before */
+       if (lockword->is_thin_lock() && (lockword->get_thin_lock_thread_index() == index))
+       {
+               threadobject *f;
+               /* Add tuple (t, o) to the other thread's FLC list */
+               t->flc_object = o;
+               t->flc_next = t_other->flc_list;
+               t_other->flc_list = t;
+               if (t->flc_next == 0)
+                       t_other->flc_tail = t;
+               f = t_other->flc_tail;
+
+               for (;;)
+               {
+                       threadobject *current;
+
+                       // Wait until another thread sees the flc bit and notifies
+                       // us of unlocking.
+                       t->flc_cond->wait(t_other->flc_lock);
+
+                       if (t_other->flc_tail != f)
+                               break;
+                       /* Traverse FLC list looking if we're still there */
+                       current = t_other->flc_list;
+                       while (current && current != t)
+                               current = current->flc_next;
+                       if (!current)
+                               /* not in list anymore, can stop waiting */
+                               break;
+
+                       /* We are still in the list -- the other thread cannot have seen
+                          the FLC bit yet */
+                       assert(t_other->flc_bit);
+               }
+
+               t->flc_object = NULL;   /* for garbage collector? */
+               t->flc_next = NULL;
+       }
+       else
+               t_other->flc_bit = old_flc;
+
+       t_other->flc_lock->unlock();
+}
+
+static void notify_flc_waiters(threadobject *t, java_handle_t *o)
+{
+       threadobject *current;
+
+       t->flc_lock->lock();
+
+       current = t->flc_list;
+       while (current)
+       {
+               if (current->flc_object != o)
+               {
+                       /* The object has to be inflated so the other threads can properly
+                          block on it. */
+
+                       // Only if not already inflated.
+                       Lockword* lockword = lock_lockword_get(current->flc_object);
+                       if (lockword->is_thin_lock()) {
+                               lock_record_t *lr = lock_hashtable_get(current->flc_object);
+                               lock_record_enter(t, lr);
+
+                               DEBUGLOCKS(("thread %d inflating lock of %p to lr %p",
+                                                       t->index, (void*) current->flc_object, (void*) lr));
+
+                               lock_inflate(current->flc_object, lr);
+                       }
+               }
+
+               // Wake the waiting threads.
+               current->flc_cond->broadcast();
+
+               current = current->flc_next;
+       }
+
+       t->flc_list = NULL;
+       t->flc_bit = false;
+
+       t->flc_lock->unlock();
+}
+
+/* lock_monitor_enter **********************************************************
+
+   Acquire the monitor of the given object. If the current thread already
+   owns the monitor, the lock counter is simply increased.
+
+   This function blocks until it can acquire the monitor.
+
+   IN:
+      t............the current thread
+         o............the object of which to enter the monitor
+
+   RETURN VALUE:
+      true.........the lock has been successfully acquired
+         false........an exception has been thrown
+
+*******************************************************************************/
+
+bool lock_monitor_enter(java_handle_t *o)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       if (o == NULL) {
+               exceptions_throw_nullpointerexception();
+               return false;
+       }
+
+       threadobject* t = thread_get_current();
+
+       uintptr_t thinlock = t->thinlock;
+
+retry:
+       // Most common case: try to thin-lock an unlocked object.
+       Lockword* lockword = lock_lockword_get(o);
+       bool result = lockword->lock(thinlock);
+
+       if (result == true) {
+               // Success, we locked it.
+               // NOTE: The Java Memory Model requires an instruction barrier
+               // here (because of the CAS above).
+               Atomic::instruction_barrier();
+               return true;
+       }
+
+       // Next common case: recursive lock with small recursion count.
+       // NOTE: We don't have to worry about stale values here, as any
+       // stale value will indicate another thread holding the lock (or
+       // an inflated lock).
+       if (lockword->get_thin_lock_without_count() == thinlock) {
+               // We own this monitor.  Check the current recursion count.
+               if (lockword->is_max_thin_lock_count() == false) {
+                       // The recursion count is low enough.
+                       lockword->increase_thin_lock_count();
+
+                       // Success, we locked it.
+                       return true;
+               }
+               else {
+                       // Recursion count overflow.
+                       lock_record_t* lr = lock_hashtable_get(o);
+                       lock_record_enter(t, lr);
+                       lock_inflate(o, lr);
+                       lr->count++;
+
+                       notify_flc_waiters(t, o);
+
+                       return true;
+               }
+       }
+
+       // The lock is either contented or fat.
+       if (lockword->is_fat_lock()) {
+               lock_record_t* lr = lockword->get_fat_lock();
+
+               // Check for recursive entering.
+               if (lr->owner == t) {
+                       lr->count++;
+                       return true;
+               }
+
+               // Acquire the mutex of the lock record.
+               lock_record_enter(t, lr);
+
+               // Sanity check.
+               assert(lr->count == 0);
+               return true;
+       }
+
+       /****** inflation path ******/
+
+#if defined(ENABLE_JVMTI)
+       /* Monitor Contended Enter */
+       jvmti_MonitorContendedEntering(false, o);
+#endif
+
+       sable_flc_waiting(lockword, t, o);
+
+#if defined(ENABLE_JVMTI)
+       /* Monitor Contended Entered */
+       jvmti_MonitorContendedEntering(true, o);
+#endif
+       goto retry;
+}
+
+
+/* lock_monitor_exit ***********************************************************
+
+   Decrement the counter of a (currently owned) monitor. If the counter
+   reaches zero, release the monitor.
+
+   If the current thread is not the owner of the monitor, an 
+   IllegalMonitorState exception is thrown.
+
+   IN:
+      t............the current thread
+         o............the object of which to exit the monitor
+
+   RETURN VALUE:
+      true.........everything ok,
+         false........an exception has been thrown
+
+*******************************************************************************/
+
+bool lock_monitor_exit(java_handle_t* o)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       if (o == NULL) {
+               exceptions_throw_nullpointerexception();
+               return false;
+       }
+
+       threadobject* t = thread_get_current();
+
+       uintptr_t thinlock = t->thinlock;
+
+       // We don't have to worry about stale values here, as any stale
+       // value will indicate that we don't own the lock.
+       Lockword* lockword = lock_lockword_get(o);
+
+       // Most common case: we release a thin lock that we hold once.
+       if (lockword->get_thin_lock() == thinlock) {
+               // Memory barrier for Java Memory Model.
+               Atomic::write_memory_barrier();
+               lockword->unlock();
+               // Memory barrier for thin locking.
+               Atomic::memory_barrier();
+
+               /* check if there has been a flat lock contention on this object */
+
+               if (t->flc_bit) {
+                       DEBUGLOCKS(("thread %d saw flc bit", t->index));
+
+                       /* there has been a contention on this thin lock */
+                       notify_flc_waiters(t, o);
+               }
+
+               return true;
+       }
+
+       // Next common case: we release a recursive lock, count > 0.
+       if (lockword->get_thin_lock_without_count() == thinlock) {
+               lockword->decrease_thin_lock_count();
+               return true;
+       }
+
+       // Either the lock is fat, or we don't hold it at all.
+       if (lockword->is_fat_lock()) {
+               lock_record_t* lr = lockword->get_fat_lock();
+
+               // Check if we own this monitor.
+               // NOTE: We don't have to worry about stale values here, as
+               // any stale value will be != t and thus fail this check.
+               if (lr->owner != t) {
+                       exceptions_throw_illegalmonitorstateexception();
+                       return false;
+               }
+
+               /* { the current thread `t` owns the lock record `lr` on object `o` } */
+
+               if (lr->count != 0) {
+                       // We had locked this one recursively.  Just decrement, it
+                       // will still be locked.
+                       lr->count--;
+                       return true;
+               }
+
+               // Unlock this lock record.
+               lock_record_exit(t, lr);
+               return true;
+       }
+
+       // Legal thin lock cases have been handled above, so this is an
+       // error.
+       exceptions_throw_illegalmonitorstateexception();
+
+       return false;
+}
+
+
+/* lock_record_add_waiter ******************************************************
+
+   Add a thread to the list of waiting threads of a lock record.
+
+   IN:
+      lr...........the lock record
+      thread.......the thread to add
+
+*******************************************************************************/
+
+static void lock_record_add_waiter(lock_record_t *lr, threadobject* t)
+{
+       // Add the thread as last entry to waiters list.
+       lr->waiters->push_back(t);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_lock_waiter += sizeof(threadobject*);
+#endif
+}
+
+
+/* lock_record_remove_waiter ***************************************************
+
+   Remove a thread from the list of waiting threads of a lock record.
+
+   IN:
+      lr...........the lock record
+      t............the current thread
+
+   PRE-CONDITION:
+      The current thread must be the owner of the lock record.
+   
+*******************************************************************************/
+
+static void lock_record_remove_waiter(lock_record_t *lr, threadobject* t)
+{
+       // Remove the thread from the waiters.
+       lr->waiters->remove(t);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_lock_waiter -= sizeof(threadobject*);
+#endif
+}
+
+
+/* lock_record_wait ************************************************************
+
+   Wait on a lock record for a given (maximum) amount of time.
+
+   IN:
+      t............the current thread
+         lr...........the lock record
+         millis.......milliseconds of timeout
+         nanos........nanoseconds of timeout
+
+   RETURN VALUE:
+      true.........we have been interrupted,
+      false........everything ok
+
+   PRE-CONDITION:
+      The current thread must be the owner of the lock record.
+         This is NOT checked by this function!
+   
+*******************************************************************************/
+
+static bool lock_record_wait(threadobject *thread, lock_record_t *lr, s8 millis, s4 nanos)
+{
+       s4   lockcount;
+       bool wasinterrupted = false;
+
+       DEBUGLOCKS(("[lock_record_wait  : lr=%p, t=%p, millis=%lld, nanos=%d]",
+                               lr, thread, millis, nanos));
+
+       /* { the thread t owns the fat lock record lr on the object o } */
+
+       /* register us as waiter for this object */
+
+       lock_record_add_waiter(lr, thread);
+
+       /* remember the old lock count */
+
+       lockcount = lr->count;
+
+       /* unlock this record */
+
+       lr->count = 0;
+       lock_record_exit(thread, lr);
+
+       /* wait until notified/interrupted/timed out */
+
+       threads_wait_with_timeout_relative(thread, millis, nanos);
+
+       /* re-enter the monitor */
+
+       lock_record_enter(thread, lr);
+
+       /* remove us from the list of waiting threads */
+
+       lock_record_remove_waiter(lr, thread);
+
+       /* restore the old lock count */
+
+       lr->count = lockcount;
+
+       /* We can only be signaled OR interrupted, not both. If both flags
+          are set, reset only signaled and leave the thread in
+          interrupted state. Otherwise, clear both. */
+
+       if (!thread->signaled) {
+               wasinterrupted = thread->interrupted;
+               thread->interrupted = false;
+       }
+
+       thread->signaled = false;
+
+       /* return if we have been interrupted */
+
+       return wasinterrupted;
+}
+
+
+/* lock_monitor_wait ***********************************************************
+
+   Wait on an object for a given (maximum) amount of time.
+
+   IN:
+      t............the current thread
+         o............the object
+         millis.......milliseconds of timeout
+         nanos........nanoseconds of timeout
+
+   PRE-CONDITION:
+      The current thread must be the owner of the object's monitor.
+   
+*******************************************************************************/
+
+static void lock_monitor_wait(threadobject *t, java_handle_t *o, s8 millis, s4 nanos)
+{
+       lock_record_t *lr;
+
+       Lockword* lockword = lock_lockword_get(o);
+
+       // Check if we own this monitor.
+       // NOTE: We don't have to worry about stale values here, as any
+       // stale value will fail this check.
+       if (lockword->is_fat_lock()) {
+               lr = lockword->get_fat_lock();
+
+               if (lr->owner != t) {
+                       exceptions_throw_illegalmonitorstateexception();
+                       return;
+               }
+       }
+       else {
+               // It's a thin lock.
+               if (lockword->get_thin_lock_without_count() != t->thinlock) {
+                       exceptions_throw_illegalmonitorstateexception();
+                       return;
+               }
+
+               // Get the lock-record.
+               lr = lock_hashtable_get(o);
+               lock_record_enter(t, lr);
+
+               // Inflate this lock.
+               lockword->inflate(lr);
+
+               notify_flc_waiters(t, o);
+       }
+
+       /* { the thread t owns the fat lock record lr on the object o } */
+
+       if (lock_record_wait(t, lr, millis, nanos))
+               exceptions_throw_interruptedexception();
+}
+
+
+/* lock_record_notify **********************************************************
+
+   Notify one thread or all threads waiting on the given lock record.
+
+   IN:
+      t............the current thread
+         lr...........the lock record
+         one..........if true, only notify one thread
+
+   PRE-CONDITION:
+      The current thread must be the owner of the lock record.
+         This is NOT checked by this function!
+   
+*******************************************************************************/
+
+static void lock_record_notify(threadobject *t, lock_record_t *lr, bool one)
+{
+#if defined(ENABLE_GC_CACAO)
+       // Sanity check.
+       assert(GCCriticalSection::inside() == false);
+#endif
+
+       // { The thread t owns the fat lock record lr on the object o }
+
+       for (List<threadobject*>::iterator it = lr->waiters->begin(); it != lr->waiters->end(); it++) {
+               threadobject* waiter = *it;
+
+               // We must skip threads which have already been notified. They
+               // will remove themselves from the list.
+               if (waiter->signaled)
+                       continue;
+
+               // Enter the wait-mutex.
+               waiter->waitmutex->lock();
+
+               DEBUGLOCKS(("[lock_record_notify: lr=%p, t=%p, waitingthread=%p, one=%d]", lr, t, waiter, one));
+
+               // Signal the waiter.
+               waiter->waitcond->signal();
+
+               // Mark the thread as signaled.
+               waiter->signaled = true;
+
+               // Leave the wait-mutex.
+               waiter->waitmutex->unlock();
+
+               // If we should only wake one thread, we are done.
+               if (one)
+                       break;
+       }
+}
+
+
+/* lock_monitor_notify *********************************************************
+
+   Notify one thread or all threads waiting on the given object.
+
+   IN:
+      t............the current thread
+         o............the object
+         one..........if true, only notify one thread
+
+   PRE-CONDITION:
+      The current thread must be the owner of the object's monitor.
+   
+*******************************************************************************/
+
+static void lock_monitor_notify(threadobject *t, java_handle_t *o, bool one)
+{
+       lock_record_t* lr = NULL;
+
+       {
+               // This scope is inside a critical section.
+               GCCriticalSection cs;
+
+               Lockword* lockword = lock_lockword_get(o);
+
+               // Check if we own this monitor.
+               // NOTE: We don't have to worry about stale values here, as any
+               // stale value will fail this check.
+
+               if (lockword->is_fat_lock()) {
+                       lr = lockword->get_fat_lock();
+
+                       if (lr->owner != t) {
+                               exceptions_throw_illegalmonitorstateexception();
+                               return;
+                       }
+               }
+               else {
+                       // It's a thin lock.
+                       if (lockword->get_thin_lock_without_count() != t->thinlock) {
+                               exceptions_throw_illegalmonitorstateexception();
+                               return;
+                       }
+
+                       // No thread can wait on a thin lock, so there's nothing to do.
+                       return;
+               }
+       }
+
+       // { The thread t owns the fat lock record lr on the object o }
+       lock_record_notify(t, lr, one);
+}
+
+
+
+/*============================================================================*/
+/* INQUIRY FUNCIONS                                                           */
+/*============================================================================*/
+
+
+/* lock_is_held_by_current_thread **********************************************
+
+   Return true if the current thread owns the monitor of the given object.
+
+   IN:
+         o............the object
+
+   RETURN VALUE:
+      true, if the current thread holds the lock of this object.
+   
+*******************************************************************************/
+
+bool lock_is_held_by_current_thread(java_handle_t *o)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       // Check if we own this monitor.
+       // NOTE: We don't have to worry about stale values here, as any
+       // stale value will fail this check.
+       threadobject* t = thread_get_current();
+       Lockword* lockword = lock_lockword_get(o);
+
+       if (lockword->is_fat_lock()) {
+               // It's a fat lock.
+               lock_record_t* lr = lockword->get_fat_lock();
+               return (lr->owner == t);
+       }
+       else {
+               // It's a thin lock.
+               return (lockword->get_thin_lock_without_count() == t->thinlock);
+       }
+}
+
+
+
+/*============================================================================*/
+/* WRAPPERS FOR OPERATIONS ON THE CURRENT THREAD                              */
+/*============================================================================*/
+
+
+/* lock_wait_for_object ********************************************************
+
+   Wait for the given object.
+
+   IN:
+         o............the object
+         millis.......milliseconds to wait
+         nanos........nanoseconds to wait
+   
+*******************************************************************************/
+
+void lock_wait_for_object(java_handle_t *o, s8 millis, s4 nanos)
+{
+       threadobject *thread;
+
+       thread = THREADOBJECT;
+
+       lock_monitor_wait(thread, o, millis, nanos);
+}
+
+
+/* lock_notify_object **********************************************************
+
+   Notify one thread waiting on the given object.
+
+   IN:
+         o............the object
+   
+*******************************************************************************/
+
+void lock_notify_object(java_handle_t *o)
+{
+       threadobject *thread;
+
+       thread = THREADOBJECT;
+
+       lock_monitor_notify(thread, o, true);
+}
+
+
+/* lock_notify_all_object ******************************************************
+
+   Notify all threads waiting on the given object.
+
+   IN:
+         o............the object
+   
+*******************************************************************************/
+
+void lock_notify_all_object(java_handle_t *o)
+{
+       threadobject *thread;
+
+       thread = THREADOBJECT;
+
+       lock_monitor_notify(thread, o, false);
+}
+
+
+/*
+ * 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/threads/lock.hpp b/src/threads/lock.hpp
new file mode 100644 (file)
index 0000000..87519d9
--- /dev/null
@@ -0,0 +1,131 @@
+/* src/threads/lock.hpp - lock implementation
+
+   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 _LOCK_HPP
+#define _LOCK_HPP
+
+#include <stdint.h>
+
+#include "native/llni.h"
+
+#include "threads/mutex.hpp"
+
+#include "toolbox/list.hpp"
+
+#include "vm/global.h"
+
+
+/* typedefs *******************************************************************/
+
+typedef struct lock_record_t    lock_record_t;
+typedef struct lock_hashtable_t lock_hashtable_t;
+
+
+/* lock_record_t ***************************************************************
+
+   Lock record struct representing an inflated ("fat") lock.
+
+*******************************************************************************/
+
+struct lock_record_t {
+       java_object_t       *object;             /* object for which this lock is */
+       struct threadobject *owner;              /* current owner of this monitor */
+       s4                   count;              /* recursive lock count          */
+       Mutex*               mutex;              /* mutex for synchronizing       */
+#ifdef __cplusplus
+       List<threadobject*>* waiters;            /* list of threads waiting       */
+#else
+       List* waiters;
+#endif
+       lock_record_t       *hashlink;           /* next record in hash chain     */
+};
+
+
+/* lock_hashtable_t ************************************************************
+   The global hashtable mapping objects to lock records.
+
+*******************************************************************************/
+
+struct lock_hashtable_t {
+    Mutex*               mutex;       /* mutex for synch. access to the table */
+       u4                   size;        /* number of slots                      */
+       u4                   entries;     /* current number of entries            */
+       lock_record_t      **ptr;         /* the table of slots, uses ext. chain. */
+};
+
+
+/* functions ******************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void lock_init(void);
+
+bool lock_monitor_enter(java_handle_t *);
+bool lock_monitor_exit(java_handle_t *);
+
+#define LOCK_monitor_enter    (functionptr) lock_monitor_enter
+#define LOCK_monitor_exit     (functionptr) lock_monitor_exit
+
+bool lock_is_held_by_current_thread(java_handle_t *o);
+
+void lock_wait_for_object(java_handle_t *o, s8 millis, s4 nanos);
+void lock_notify_object(java_handle_t *o);
+void lock_notify_all_object(java_handle_t *o);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* defines ********************************************************************/
+
+/* only define the following stuff with thread enabled ************************/
+
+#if defined(ENABLE_THREADS)
+
+#define LOCK_MONITOR_ENTER(o)    lock_monitor_enter((java_handle_t *) LLNI_QUICKWRAP(o))
+#define LOCK_MONITOR_EXIT(o)     lock_monitor_exit((java_handle_t *) LLNI_QUICKWRAP(o))
+
+#endif
+
+#endif // _LOCK_HPP
+
+
+/*
+ * 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/threads/lockword.cpp b/src/threads/lockword.cpp
new file mode 100644 (file)
index 0000000..25e2c9c
--- /dev/null
@@ -0,0 +1,78 @@
+/* src/threads/lockword.cpp - lockword implementation
+
+   Copyright (C) 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 <stdint.h>
+
+#include "threads/lock.hpp"
+
+
+/**
+ * Inflate the lock of the given object. This may only be called by
+ * the owner of the monitor of the object.
+ * 
+ * PRE-CONDITION: The current thread must be the owner of this
+ * object's monitor AND of the lock record's lock!
+ *
+ * @param lr The lock-record to install.  The current thread must own
+ *              the lock of this lock record!
+ */
+void Lockword::inflate(lock_record_t* lr)
+{
+       if (is_fat_lock()) {
+               // Sanity check.
+               assert(get_fat_lock() == lr);
+               return;
+       }
+
+       // Sanity check.
+       assert(get_thin_lock_without_count() == thread_get_current()->thinlock);
+
+       // Copy the count from the thinlock.
+       lr->count = get_thin_lock_count();
+
+//     DEBUGLOCKS(("[lock_inflate      : lr=%p, t=%p, o=%p, o->lockword=%lx, count=%d]",
+//                             lr, thread_get_current(), o, get_thin_lock(), lr->count));
+
+       // Install the lock-record in the lockword.
+       set(lr);
+}
+
+
+/*
+ * 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/threads/lockword.hpp b/src/threads/lockword.hpp
new file mode 100644 (file)
index 0000000..74ccb94
--- /dev/null
@@ -0,0 +1,248 @@
+/* src/threads/lockword.hpp - lockword implementation
+
+   Copyright (C) 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 _LOCKWORD_HPP
+#define _LOCKWORD_HPP
+
+#include <stdint.h>
+
+
+#ifdef __cplusplus
+
+/**
+ * Lockword.
+ */
+class Lockword {
+private:
+       static const int       THIN_LOCK_WORD_SIZE   = SIZEOF_VOID_P * 8; // Pointer size multiplied by 8-bit.
+       static const int       THIN_LOCK_SHAPE_BIT   = 0x01;
+
+       static const uintptr_t THIN_UNLOCKED         = 0;
+
+       static const int       THIN_LOCK_COUNT_SHIFT = 1;
+       static const int       THIN_LOCK_COUNT_SIZE  = 8;
+       static const int       THIN_LOCK_COUNT_INCR  = (1 << THIN_LOCK_COUNT_SHIFT);
+       static const int       THIN_LOCK_COUNT_MAX   = ((1 << THIN_LOCK_COUNT_SIZE) - 1);
+
+       static const int       THIN_LOCK_COUNT_MASK  = (THIN_LOCK_COUNT_MAX << THIN_LOCK_COUNT_SHIFT);
+
+       static const int       THIN_LOCK_TID_SHIFT   = (THIN_LOCK_COUNT_SIZE + THIN_LOCK_COUNT_SHIFT);
+       static const int       THIN_LOCK_TID_SIZE    = (THIN_LOCK_WORD_SIZE - THIN_LOCK_TID_SHIFT);
+
+private:
+       // The actual lockword.
+       uintptr_t _lockword;
+
+private:
+       Lockword(uintptr_t lockword) : _lockword(lockword) {}
+
+public:
+       Lockword() : _lockword(THIN_UNLOCKED) {}
+
+       void init() { _lockword = THIN_UNLOCKED; } // REMOVEME
+
+       static inline uintptr_t pre_compute_thinlock(int32_t index);
+
+       inline bool is_thin_lock         () const;
+       inline bool is_fat_lock          () const;
+
+       inline bool is_unlocked() const;
+       inline bool lock       (uintptr_t thinlock);
+       inline void unlock     ();
+
+       inline uintptr_t             get_thin_lock              () const;
+       inline uintptr_t             get_thin_lock_without_count() const;
+       inline int32_t               get_thin_lock_count        () const;
+       inline int32_t               get_thin_lock_thread_index () const;
+       inline struct lock_record_t* get_fat_lock               () const;
+
+       inline void set(uintptr_t lockword);
+       inline void set(struct lock_record_t* lr);
+
+       inline bool is_max_thin_lock_count  () const;
+       inline void increase_thin_lock_count();
+       inline void decrease_thin_lock_count();
+
+       void inflate(struct lock_record_t* lr);
+};
+
+
+// Includes.
+#include <assert.h>
+
+#include "threads/atomic.hpp"
+
+
+/**
+ * Pre-compute the thin lock value for a thread index.
+ *
+ * @param index The thead index (>= 1).
+ *
+ * @return The thin lock value for this thread index.
+ */
+uintptr_t Lockword::pre_compute_thinlock(int32_t index)
+{
+       return (index << THIN_LOCK_TID_SHIFT) | THIN_UNLOCKED;
+}
+
+
+bool Lockword::is_thin_lock() const
+{
+       return ((_lockword & THIN_LOCK_SHAPE_BIT) == 0);
+}
+
+
+bool Lockword::is_fat_lock() const
+{
+       return ((_lockword & THIN_LOCK_SHAPE_BIT) != 0);
+}
+
+
+/**
+ * Check if the lockword is an unlocked thin-lock.
+ *
+ * @return true if unlocked, false otherwise.
+ */
+bool Lockword::is_unlocked() const
+{
+       return (_lockword == THIN_UNLOCKED);
+}
+
+
+/**
+ * Try to lock the lockword with the given thin-lock value.
+ *
+ * @param thinlock Thin-lock value to store in the Lockword.
+ *
+ * @return true if lock was successful, false otherwise.
+ */
+bool Lockword::lock(uintptr_t thinlock)
+{
+       // Atomically exchange the lockword value.
+       uintptr_t oldlockword = Atomic::compare_and_swap(&_lockword, THIN_UNLOCKED, thinlock);
+
+       return Lockword(oldlockword).is_unlocked();
+}
+
+
+/**
+ * Set the lockword to THIN_UNLOCKED.
+ */
+void Lockword::unlock()
+{
+       _lockword = THIN_UNLOCKED;
+}
+
+
+uintptr_t Lockword::get_thin_lock() const
+{
+       return _lockword;
+}
+
+
+uintptr_t Lockword::get_thin_lock_without_count() const
+{
+       return (_lockword & ~THIN_LOCK_COUNT_MASK);
+}
+
+
+int32_t Lockword::get_thin_lock_count() const
+{
+       return (int32_t) (_lockword & THIN_LOCK_COUNT_MASK) >> THIN_LOCK_COUNT_SHIFT;
+}
+
+
+int32_t Lockword::get_thin_lock_thread_index() const
+{
+       return (int32_t) (_lockword >> THIN_LOCK_TID_SHIFT);
+}
+
+
+struct lock_record_t* Lockword::get_fat_lock() const
+{
+       return (struct lock_record_t*) (_lockword & ~THIN_LOCK_SHAPE_BIT);
+}
+
+
+void Lockword::set(uintptr_t lockword)
+{
+       _lockword = lockword;
+}
+
+
+void Lockword::set(struct lock_record_t* lr)
+{
+       _lockword = ((uintptr_t) lr) | THIN_LOCK_SHAPE_BIT;
+}
+
+
+bool Lockword::is_max_thin_lock_count() const
+{
+       return (get_thin_lock_count() >= THIN_LOCK_COUNT_MAX);
+}
+
+
+void Lockword::increase_thin_lock_count()
+{
+       // Sanity check.
+       assert(get_thin_lock_count() < THIN_LOCK_COUNT_MAX);
+
+       _lockword += (1 << THIN_LOCK_COUNT_SHIFT);
+}
+
+
+void Lockword::decrease_thin_lock_count()
+{
+       // Sanity check.
+       assert(get_thin_lock_count() > 0);
+
+       _lockword -= (1 << THIN_LOCK_COUNT_SHIFT);
+}
+
+#else
+
+// This structure must have the same layout as the C++ class above.
+typedef struct Lockword {
+       uintptr_t _lockword;
+} Lockword;
+
+#endif
+
+#endif // _LOCKWORD_HPP
+
+
+/*
+ * 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/threads/mutex.h b/src/threads/mutex.h
deleted file mode 100644 (file)
index 7458b0d..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* src/threads/mutex.h - machine independent mutual exclusion functions
-
-   Copyright (C) 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 _MUTEX_H
-#define _MUTEX_H
-
-#include "config.h"
-
-#if defined(ENABLE_THREADS)
-# include "threads/posix/mutex-posix.h"
-#endif
-
-
-#endif /* _MUTEX_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/threads/mutex.hpp b/src/threads/mutex.hpp
new file mode 100644 (file)
index 0000000..e8bbce3
--- /dev/null
@@ -0,0 +1,50 @@
+/* src/threads/mutex.hpp - machine independent mutual exclusion functions
+
+   Copyright (C) 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 _MUTEX_HPP
+#define _MUTEX_HPP
+
+#include "config.h"
+
+#if defined(ENABLE_THREADS)
+# include "threads/posix/mutex-posix.hpp"
+#endif
+
+#endif /* _MUTEX_HPP */
+
+
+/*
+ * 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 dcf09918d5eb036dcdd2d2fed7560e647ee37b91..5a48ae5327fdce600d8d755d6265cdca3d2173f9 100644 (file)
@@ -30,8 +30,6 @@
 
 /* define some stuff to no-ops *************************************************/
 
-#define LOCK_INIT_OBJECT_LOCK(o)
-
 #define LOCK_MONITOR_ENTER(o)
 #define LOCK_MONITOR_EXIT(o)
 
index 8c333adaf254c1109a534d0e75d54db45c15b440..de21e8aed7278da8ff2d65fc403b290e03cec976 100644 (file)
@@ -27,9 +27,9 @@
 
 #include <stdint.h>
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* global variables ***********************************************************/
index cefeeacebc589cf37770ab75767c46192784ee28..21b3bee53b8cf73403718484afa884855ea1f336 100644 (file)
 
 #include "vm/types.h"
 
-#include "vm/builtin.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/globals.hpp"
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* define some stuff we need to no-ops ****************************************/
index 880d47f293f9b8cf5e1c84e3cad1451e3f140eaa..4abed884a9f27f3b05c49d9b4187aca0d52a70ff 100644 (file)
@@ -29,11 +29,10 @@ noinst_LTLIBRARIES = \
        libthreadsposix.la
 
 libthreadsposix_la_SOURCES = \
-       lock.c \
-       lock.h \
-       mutex-posix.h \
-       thread-posix.c \
-       thread-posix.h
+       condition-posix.hpp \
+       mutex-posix.hpp \
+       thread-posix.cpp \
+       thread-posix.hpp
 
 
 ## Local variables:
diff --git a/src/threads/posix/condition-posix.hpp b/src/threads/posix/condition-posix.hpp
new file mode 100644 (file)
index 0000000..6df1cda
--- /dev/null
@@ -0,0 +1,188 @@
+/* src/threads/posix/condition-posix.hpp - POSIX condition variable
+
+   Copyright (C) 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 _CONDITION_POSIX_HPP
+#define _CONDITION_POSIX_HPP
+
+#include "config.h"
+
+#include <pthread.h>
+#include <time.h>
+
+
+#ifdef __cplusplus
+
+/**
+ * POSIX condition variable.
+ */
+class Condition {
+private:
+       // POSIX condition structure.
+       pthread_cond_t _cond;
+
+public:
+       Condition();
+       ~Condition();
+
+       void broadcast();
+       void signal();
+       void timedwait(Mutex* mutex, const struct timespec* abstime);
+       void wait(Mutex* mutex);
+       void wait(Mutex& mutex);
+};
+
+
+// Includes.
+#include "vm/vm.hpp"
+
+
+// Includes.
+#include "vm/os.hpp"
+
+
+/**
+ * Initialize a POSIX condition variable.
+ */
+inline Condition::Condition()
+{
+       int result = pthread_cond_init(&_cond, NULL);
+
+       if (result != 0) {
+               os::abort_errnum(result, "Condition::Condition(): pthread_cond_init failed");
+       }
+}
+
+
+/**
+ * Destroys a POSIX condition variable.
+ */
+inline Condition::~Condition()
+{
+       // Restart all threads waiting on this condition.
+       broadcast();
+
+       int result = pthread_cond_destroy(&_cond);
+
+       if (result != 0) {
+               os::abort_errnum(result, "Condition::~Condition(): pthread_cond_destroy failed");
+       }
+}
+
+
+/**
+ * Restarts all the threads that are waiting on the condition
+ * variable.
+ */
+inline void Condition::broadcast()
+{
+       int result = pthread_cond_broadcast(&_cond);
+
+       if (result != 0) {
+               os::abort_errnum(result, "Condition::broadcast(): pthread_cond_broadcast failed");
+       }
+}
+
+
+/**
+ * Restarts one of the threads that are waiting on this condition
+ * variable.
+ */
+inline void Condition::signal()
+{
+       int result = pthread_cond_signal(&_cond);
+
+       if (result != 0) {
+               os::abort_errnum(result, "Condition::signal(): pthread_cond_signal failed");
+       }
+}
+
+
+/**
+ * Waits on the condition variable, as wait() does, but it also bounds
+ * the duration of the wait.
+ */
+inline void Condition::timedwait(Mutex* mutex, const struct timespec* abstime)
+{
+       // This function can return return values which are valid.
+       (void) pthread_cond_timedwait(&_cond, &(mutex->_mutex), abstime);
+}
+
+
+/**
+ * Waits for the condition variable.
+ */
+inline void Condition::wait(Mutex* mutex)
+{
+       wait(*mutex);
+}
+
+
+/**
+ * Waits for the condition variable.
+ */
+inline void Condition::wait(Mutex& mutex)
+{
+       int result = pthread_cond_wait(&_cond, &(mutex._mutex));
+
+       if (result != 0) {
+               os::abort_errnum(result, "Condition::wait(): pthread_cond_wait failed");
+       }
+}
+
+#else
+
+// This structure must have the same layout as the class above.
+typedef struct Condition {
+       pthread_mutex_t _mutex;
+       pthread_cond_t _cond;
+} Condition;
+
+Condition* Condition_new();
+void       Condition_delete(Condition* cond);
+void       Condition_lock(Condition* cond);
+void       Condition_unlock(Condition* cond);
+void       Condition_broadcast(Condition* cond);
+void       Condition_signal(Condition* cond);
+void       Condition_timedwait(Condition* cond, Mutex *mutex, const struct timespec* abstime);
+void       Condition_wait(Condition* cond, Mutex* mutex);
+
+#endif
+
+#endif /* _CONDITION_POSIX_HPP */
+
+
+/*
+ * 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/threads/posix/generic-primitives.h b/src/threads/posix/generic-primitives.h
deleted file mode 100644 (file)
index 2ab03a1..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* src/threads/native/generic-primitives.h - machine independent atomic
-                                             operations
-
-   Copyright (C) 1996-2005, 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
-
-   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.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-            Anton Ertl
-
-   Changes: 
-
-
-*/
-
-
-#ifndef _MACHINE_INSTR_H
-#define _MACHINE_INSTR_H
-
-#include <pthread.h>
-
-#include "threads/mutex.h"
-
-
-extern mutex_t _cas_lock;
-extern mutex_t _mb_lock;
-
-
-static inline long compare_and_swap(volatile long *p, long oldval, long newval)
-{
-  long ret;
-
-  mutex_lock(&_cas_lock);
-
-  /* do the compare-and-swap */
-
-  ret = *p;
-
-  if (oldval == ret)
-    *p = newval;
-
-  mutex_unlock(&_cas_lock);
-
-  return ret;
-}
-
-
-#define MEMORY_BARRIER()                  (mutex_lock(&_mb_lock), \
-                                           mutex_unlock(&_mb_lock))
-#define STORE_ORDER_BARRIER()             MEMORY_BARRIER()
-#define MEMORY_BARRIER_AFTER_ATOMIC()     /* nothing */
-
-#endif /* _MACHINE_INSTR_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:
- */
diff --git a/src/threads/posix/lock.c b/src/threads/posix/lock.c
deleted file mode 100644 (file)
index 4d69503..0000000
+++ /dev/null
@@ -1,1625 +0,0 @@
-/* src/threads/posix/lock.c - lock implementation
-
-   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 <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <pthread.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/llni.h"
-
-#include "threads/lock-common.h"
-#include "threads/mutex.h"
-#include "threads/threadlist.h"
-#include "threads/thread.h"
-
-#include "threads/posix/lock.h"
-
-#include "toolbox/list.h"
-
-#include "vm/global.h"
-#include "vm/exceptions.h"
-#include "vm/finalizer.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vmcore/options.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
-#if defined(ENABLE_VMLOG)
-#include <vmlog_cacao.h>
-#endif
-
-/* arch.h must be here because it defines USE_FAKE_ATOMIC_INSTRUCTIONS */
-
-#include "arch.h"
-
-/* includes for atomic instructions: */
-
-#if defined(USE_FAKE_ATOMIC_INSTRUCTIONS)
-#include "threads/posix/generic-primitives.h"
-#else
-#include "machine-instr.h"
-#endif
-
-#if defined(ENABLE_JVMTI)
-#include "native/jvmti/cacaodbg.h"
-#endif
-
-#if defined(ENABLE_GC_BOEHM)
-# include "mm/boehm-gc/include/gc.h"
-#endif
-
-
-/* debug **********************************************************************/
-
-#if !defined(NDEBUG)
-# define DEBUGLOCKS(format) \
-    do { \
-        if (opt_DebugLocks) { \
-            log_println format; \
-        } \
-    } while (0)
-#else
-# define DEBUGLOCKS(format)
-#endif
-
-
-/******************************************************************************/
-/* MACROS                                                                     */
-/******************************************************************************/
-
-/* number of lock records in the first pool allocated for a thread */
-#define LOCK_INITIAL_LOCK_RECORDS 8
-
-#define LOCK_INITIAL_HASHTABLE_SIZE  1613  /* a prime in the middle between 1024 and 2048 */
-
-#define COMPARE_AND_SWAP_OLD_VALUE(address, oldvalue, newvalue) \
-       ((ptrint) compare_and_swap((long *)(address), (long)(oldvalue), (long)(newvalue)))
-
-
-/******************************************************************************/
-/* MACROS FOR THIN/FAT LOCKS                                                  */
-/******************************************************************************/
-
-/* We use a variant of the tasuki locks described in the paper
- *     
- *     Tamiya Onodera, Kiyokuni Kawachiya
- *     A Study of Locking Objects with Bimodal Fields
- *     Proceedings of the ACM OOPSLA '99, pp. 223-237
- *     1999
- *
- * The underlying thin locks are a variant of the thin locks described in
- * 
- *     Bacon, Konuru, Murthy, Serrano
- *     Thin Locks: Featherweight Synchronization for Java
- *        Proceedings of the ACM Conference on Programming Language Design and 
- *        Implementation (Montreal, Canada), SIGPLAN Notices volume 33, number 6,
- *        June 1998
- *
- * In thin lock mode the lockword looks like this:
- *
- *     ,----------------------,-----------,---,
- *     |      thread ID       |   count   | 0 |
- *     `----------------------'-----------'---'
- *
- *     thread ID......the 'index' of the owning thread, or 0
- *     count..........number of times the lock has been entered        minus 1
- *     0..............the shape bit is 0 in thin lock mode
- *
- * In fat lock mode it is basically a lock_record_t *:
- *
- *     ,----------------------------------,---,
- *     |    lock_record_t * (without LSB) | 1 |
- *     `----------------------------------'---'
- *
- *     1..............the shape bit is 1 in fat lock mode
- */
-
-#if SIZEOF_VOID_P == 8
-#define THIN_LOCK_WORD_SIZE    64
-#else
-#define THIN_LOCK_WORD_SIZE    32
-#endif
-
-#define THIN_LOCK_SHAPE_BIT    0x01
-
-#define THIN_UNLOCKED          0
-
-#define THIN_LOCK_COUNT_SHIFT  1
-#define THIN_LOCK_COUNT_SIZE   8
-#define THIN_LOCK_COUNT_INCR   (1 << THIN_LOCK_COUNT_SHIFT)
-#define THIN_LOCK_COUNT_MAX    ((1 << THIN_LOCK_COUNT_SIZE) - 1)
-#define THIN_LOCK_COUNT_MASK   (THIN_LOCK_COUNT_MAX << THIN_LOCK_COUNT_SHIFT)
-
-#define THIN_LOCK_TID_SHIFT    (THIN_LOCK_COUNT_SIZE + THIN_LOCK_COUNT_SHIFT)
-#define THIN_LOCK_TID_SIZE     (THIN_LOCK_WORD_SIZE - THIN_LOCK_TID_SHIFT)
-
-#define IS_THIN_LOCK(lockword)  (!((lockword) & THIN_LOCK_SHAPE_BIT))
-#define IS_FAT_LOCK(lockword)     ((lockword) & THIN_LOCK_SHAPE_BIT)
-
-#define GET_FAT_LOCK(lockword)  ((lock_record_t *) ((lockword) & ~THIN_LOCK_SHAPE_BIT))
-#define MAKE_FAT_LOCK(ptr)      ((uintptr_t) (ptr) | THIN_LOCK_SHAPE_BIT)
-
-#define LOCK_WORD_WITHOUT_COUNT(lockword) ((lockword) & ~THIN_LOCK_COUNT_MASK)
-#define GET_THREAD_INDEX(lockword) ((unsigned) lockword >> THIN_LOCK_TID_SHIFT)
-
-
-/* global variables ***********************************************************/
-
-/* hashtable mapping objects to lock records */
-static lock_hashtable_t lock_hashtable;
-
-
-/******************************************************************************/
-/* PROTOTYPES                                                                 */
-/******************************************************************************/
-
-static void lock_hashtable_init(void);
-
-static inline uintptr_t lock_lockword_get(threadobject *t, java_handle_t *o);
-static inline void lock_lockword_set(threadobject *t, java_handle_t *o, uintptr_t lockword);
-static void lock_record_enter(threadobject *t, lock_record_t *lr);
-static void lock_record_exit(threadobject *t, lock_record_t *lr);
-static bool lock_record_wait(threadobject *t, lock_record_t *lr, s8 millis, s4 nanos);
-static void lock_record_notify(threadobject *t, lock_record_t *lr, bool one);
-
-
-/*============================================================================*/
-/* INITIALIZATION OF DATA STRUCTURES                                          */
-/*============================================================================*/
-
-
-/* lock_init *******************************************************************
-
-   Initialize global data for locking.
-
-*******************************************************************************/
-
-void lock_init(void)
-{
-       /* initialize lock hashtable */
-
-       lock_hashtable_init();
-
-#if defined(ENABLE_VMLOG)
-       vmlog_cacao_init_lock();
-#endif
-}
-
-
-/* lock_pre_compute_thinlock ***************************************************
-
-   Pre-compute the thin lock value for a thread index.
-
-   IN:
-      index........the thead index (>= 1)
-
-   RETURN VALUE:
-      the thin lock value for this thread index
-
-*******************************************************************************/
-
-ptrint lock_pre_compute_thinlock(s4 index)
-{
-       return (index << THIN_LOCK_TID_SHIFT) | THIN_UNLOCKED;
-}
-
-
-/* lock_record_new *************************************************************
-
-   Allocate a lock record.
-
-*******************************************************************************/
-
-static lock_record_t *lock_record_new(void)
-{
-       lock_record_t *lr;
-
-       /* allocate the data structure on the C heap */
-
-       lr = NEW(lock_record_t);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_lock_record += sizeof(lock_record_t);
-#endif
-
-       /* initialize the members */
-
-       lr->object  = NULL;
-       lr->owner   = NULL;
-       lr->count   = 0;
-       lr->waiters = list_create(OFFSET(lock_waiter_t, linkage));
-
-#if defined(ENABLE_GC_CACAO)
-       /* register the lock object as weak reference with the GC */
-
-       gc_weakreference_register(&(lr->object), GC_REFTYPE_LOCKRECORD);
-#endif
-
-       /* initialize the mutex */
-
-       mutex_init(&(lr->mutex));
-
-       DEBUGLOCKS(("[lock_record_new   : lr=%p]", (void *) lr));
-
-       return lr;
-}
-
-
-/* lock_record_free ************************************************************
-
-   Free a lock record.
-
-   IN:
-       lr....lock record to free
-
-*******************************************************************************/
-
-static void lock_record_free(lock_record_t *lr)
-{
-       DEBUGLOCKS(("[lock_record_free  : lr=%p]", (void *) lr));
-
-       /* Destroy the mutex. */
-
-       mutex_destroy(&(lr->mutex));
-
-#if defined(ENABLE_GC_CACAO)
-       /* unregister the lock object reference with the GC */
-
-       gc_weakreference_unregister(&(lr->object));
-#endif
-
-       /* Free the waiters list. */
-
-       list_free(lr->waiters);
-
-       /* Free the data structure. */
-
-       FREE(lr, lock_record_t);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_lock_record -= sizeof(lock_record_t);
-#endif
-}
-
-
-/*============================================================================*/
-/* HASHTABLE MAPPING OBJECTS TO LOCK RECORDS                                  */
-/*============================================================================*/
-
-/* lock_hashtable_init *********************************************************
-
-   Initialize the global hashtable mapping objects to lock records.
-
-*******************************************************************************/
-
-static void lock_hashtable_init(void)
-{
-       mutex_init(&(lock_hashtable.mutex));
-
-       lock_hashtable.size    = LOCK_INITIAL_HASHTABLE_SIZE;
-       lock_hashtable.entries = 0;
-       lock_hashtable.ptr     = MNEW(lock_record_t *, lock_hashtable.size);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_lock_hashtable += sizeof(lock_record_t *) * lock_hashtable.size;
-#endif
-
-       MZERO(lock_hashtable.ptr, lock_record_t *, lock_hashtable.size);
-}
-
-
-/* lock_hashtable_grow *********************************************************
-
-   Grow the lock record hashtable to about twice its current size and
-   rehash the entries.
-
-*******************************************************************************/
-
-/* must be called with hashtable mutex locked */
-static void lock_hashtable_grow(void)
-{
-       u4 oldsize;
-       u4 newsize;
-       lock_record_t **oldtable;
-       lock_record_t **newtable;
-       lock_record_t *lr;
-       lock_record_t *next;
-       u4 i;
-       u4 h;
-       u4 newslot;
-
-       /* allocate a new table */
-
-       oldsize = lock_hashtable.size;
-       newsize = oldsize*2 + 1; /* XXX should use prime numbers */
-
-       DEBUGLOCKS(("growing lock hashtable to size %d", newsize));
-
-       oldtable = lock_hashtable.ptr;
-       newtable = MNEW(lock_record_t *, newsize);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_lock_hashtable += sizeof(lock_record_t *) * newsize;
-#endif
-
-       MZERO(newtable, lock_record_t *, newsize);
-
-       /* rehash the entries */
-
-       for (i = 0; i < oldsize; i++) {
-               lr = oldtable[i];
-               while (lr) {
-                       next = lr->hashlink;
-
-                       h = heap_hashcode(lr->object);
-                       newslot = h % newsize;
-
-                       lr->hashlink = newtable[newslot];
-                       newtable[newslot] = lr;
-
-                       lr = next;
-               }
-       }
-
-       /* replace the old table */
-
-       lock_hashtable.ptr  = newtable;
-       lock_hashtable.size = newsize;
-
-       MFREE(oldtable, lock_record_t *, oldsize);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_lock_hashtable -= sizeof(lock_record_t *) * oldsize;
-#endif
-}
-
-
-/* lock_hashtable_cleanup ******************************************************
-
-   Removes (and frees) lock records which have a cleared object reference
-   from the hashtable. The locked object was reclaimed by the GC.
-
-*******************************************************************************/
-
-#if defined(ENABLE_GC_CACAO)
-void lock_hashtable_cleanup(void)
-{
-       threadobject  *t;
-       lock_record_t *lr;
-       lock_record_t *prev;
-       lock_record_t *next;
-       int i;
-
-       t = THREADOBJECT;
-
-       /* lock the hashtable */
-
-       mutex_lock(&(lock_hashtable.mutex));
-
-       /* search the hashtable for cleared references */
-
-       for (i = 0; i < lock_hashtable.size; i++) {
-               lr = lock_hashtable.ptr[i];
-               prev = NULL;
-
-               while (lr) {
-                       next = lr->hashlink;
-
-                       /* remove lock records with cleared references */
-
-                       if (lr->object == NULL) {
-
-                               /* unlink the lock record from the hashtable */
-
-                               if (prev == NULL)
-                                       lock_hashtable.ptr[i] = next;
-                               else
-                                       prev->hashlink = next;
-
-                               /* free the lock record */
-
-                               lock_record_free(lr);
-
-                       } else {
-                               prev = lr;
-                       }
-
-                       lr = next;
-               }
-       }
-
-       /* unlock the hashtable */
-
-       mutex_unlock(&(lock_hashtable.mutex));
-}
-#endif
-
-
-/* lock_hashtable_get **********************************************************
-
-   Find the lock record for the given object.  If it does not exists,
-   yet, create it and enter it in the hashtable.
-
-   IN:
-      t....the current thread
-         o....the object to look up
-
-   RETURN VALUE:
-      the lock record to use for this object
-
-*******************************************************************************/
-
-#if defined(ENABLE_GC_BOEHM)
-static void lock_record_finalizer(void *object, void *p);
-#endif
-
-static lock_record_t *lock_hashtable_get(threadobject *t, java_handle_t *o)
-{
-       uintptr_t      lockword;
-       u4             slot;
-       lock_record_t *lr;
-
-       lockword = lock_lockword_get(t, o);
-
-       if (IS_FAT_LOCK(lockword))
-               return GET_FAT_LOCK(lockword);
-
-       /* lock the hashtable */
-
-       mutex_lock(&(lock_hashtable.mutex));
-
-       /* lookup the lock record in the hashtable */
-
-       LLNI_CRITICAL_START_THREAD(t);
-       slot = heap_hashcode(LLNI_DIRECT(o)) % lock_hashtable.size;
-       lr   = lock_hashtable.ptr[slot];
-
-       for (; lr != NULL; lr = lr->hashlink) {
-               if (lr->object == LLNI_DIRECT(o))
-                       break;
-       }
-       LLNI_CRITICAL_END_THREAD(t);
-
-       if (lr == NULL) {
-               /* not found, we must create a new one */
-
-               lr = lock_record_new();
-
-               LLNI_CRITICAL_START_THREAD(t);
-               lr->object = LLNI_DIRECT(o);
-               LLNI_CRITICAL_END_THREAD(t);
-
-#if defined(ENABLE_GC_BOEHM)
-               /* register new finalizer to clean up the lock record */
-
-               GC_REGISTER_FINALIZER(LLNI_DIRECT(o), lock_record_finalizer, 0, 0, 0);
-#endif
-
-               /* enter it in the hashtable */
-
-               lr->hashlink             = lock_hashtable.ptr[slot];
-               lock_hashtable.ptr[slot] = lr;
-               lock_hashtable.entries++;
-
-               /* check whether the hash should grow */
-
-               if (lock_hashtable.entries * 3 > lock_hashtable.size * 4) {
-                       lock_hashtable_grow();
-               }
-       }
-
-       /* unlock the hashtable */
-
-       mutex_unlock(&(lock_hashtable.mutex));
-
-       /* return the new lock record */
-
-       return lr;
-}
-
-
-/* lock_hashtable_remove *******************************************************
-
-   Remove the lock record for the given object from the hashtable
-   and free it afterwards.
-
-   IN:
-       t....the current thread
-       o....the object to look up
-
-*******************************************************************************/
-
-static void lock_hashtable_remove(threadobject *t, java_handle_t *o)
-{
-       uintptr_t      lockword;
-       lock_record_t *lr;
-       u4             slot;
-       lock_record_t *tmplr;
-
-       /* lock the hashtable */
-
-       mutex_lock(&(lock_hashtable.mutex));
-
-       /* get lock record */
-
-       lockword = lock_lockword_get(t, o);
-
-       assert(IS_FAT_LOCK(lockword));
-
-       lr = GET_FAT_LOCK(lockword);
-
-       /* remove the lock-record from the hashtable */
-
-       LLNI_CRITICAL_START_THREAD(t);
-       slot  = heap_hashcode(LLNI_DIRECT(o)) % lock_hashtable.size;
-       tmplr = lock_hashtable.ptr[slot];
-       LLNI_CRITICAL_END_THREAD(t);
-
-       if (tmplr == lr) {
-               /* special handling if it's the first in the chain */
-
-               lock_hashtable.ptr[slot] = lr->hashlink;
-       }
-       else {
-               for (; tmplr != NULL; tmplr = tmplr->hashlink) {
-                       if (tmplr->hashlink == lr) {
-                               tmplr->hashlink = lr->hashlink;
-                               break;
-                       }
-               }
-
-               assert(tmplr != NULL);
-       }
-
-       /* decrease entry count */
-
-       lock_hashtable.entries--;
-
-       /* unlock the hashtable */
-
-       mutex_unlock(&(lock_hashtable.mutex));
-
-       /* free the lock record */
-
-       lock_record_free(lr);
-}
-
-
-/* lock_record_finalizer *******************************************************
-
-   XXX Remove me for exact GC.
-
-*******************************************************************************/
-
-static void lock_record_finalizer(void *object, void *p)
-{
-       java_handle_t *o;
-       classinfo     *c;
-
-       o = (java_handle_t *) object;
-
-#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES)
-       /* XXX this is only a dirty hack to make Boehm work with handles */
-
-       o = LLNI_WRAP((java_object_t *) o);
-#endif
-
-       LLNI_class_get(o, c);
-
-#if !defined(NDEBUG)
-       if (opt_DebugFinalizer) {
-               log_start();
-               log_print("[finalizer lockrecord: o=%p p=%p class=", object, p);
-               class_print(c);
-               log_print("]");
-               log_finish();
-       }
-#endif
-
-       /* check for a finalizer function */
-
-       if (c->finalizer != NULL)
-               finalizer_run(object, p);
-
-       /* remove the lock-record entry from the hashtable and free it */
-
-       lock_hashtable_remove(THREADOBJECT, o);
-}
-
-
-/*============================================================================*/
-/* OBJECT LOCK INITIALIZATION                                                 */
-/*============================================================================*/
-
-
-/* lock_init_object_lock *******************************************************
-
-   Initialize the monitor pointer of the given object. The monitor gets
-   initialized to an unlocked state.
-
-*******************************************************************************/
-
-void lock_init_object_lock(java_object_t *o)
-{
-       assert(o);
-
-       o->lockword = THIN_UNLOCKED;
-}
-
-
-/*============================================================================*/
-/* LOCKING ALGORITHM                                                          */
-/*============================================================================*/
-
-
-/* lock_lockword_get ***********************************************************
-
-   Get the lockword for the given object.
-
-   IN:
-      t............the current thread
-      o............the object
-
-*******************************************************************************/
-
-static inline uintptr_t lock_lockword_get(threadobject *t, java_handle_t *o)
-{
-       uintptr_t lockword;
-
-       LLNI_CRITICAL_START_THREAD(t);
-       lockword = LLNI_DIRECT(o)->lockword;
-       LLNI_CRITICAL_END_THREAD(t);
-
-       return lockword;
-}
-
-
-/* lock_lockword_set ***********************************************************
-
-   Set the lockword for the given object.
-
-   IN:
-      t............the current thread
-      o............the object
-         lockword.....the new lockword value
-
-*******************************************************************************/
-
-static inline void lock_lockword_set(threadobject *t, java_handle_t *o, uintptr_t lockword)
-{
-       LLNI_CRITICAL_START_THREAD(t);
-       LLNI_DIRECT(o)->lockword = lockword;
-       LLNI_CRITICAL_END_THREAD(t);
-}
-
-
-/* lock_record_enter ***********************************************************
-
-   Enter the lock represented by the given lock record.
-
-   IN:
-      t.................the current thread
-         lr................the lock record
-
-*******************************************************************************/
-
-static inline void lock_record_enter(threadobject *t, lock_record_t *lr)
-{
-       mutex_lock(&(lr->mutex));
-       lr->owner = t;
-}
-
-
-/* lock_record_exit ************************************************************
-
-   Release the lock represented by the given lock record.
-
-   IN:
-      t.................the current thread
-         lr................the lock record
-
-   PRE-CONDITION:
-      The current thread must own the lock represented by this lock record.
-         This is NOT checked by this function!
-
-*******************************************************************************/
-
-static inline void lock_record_exit(threadobject *t, lock_record_t *lr)
-{
-       lr->owner = NULL;
-       mutex_unlock(&(lr->mutex));
-}
-
-
-/* lock_inflate ****************************************************************
-
-   Inflate the lock of the given object. This may only be called by the
-   owner of the monitor of the object.
-
-   IN:
-      t............the current thread
-         o............the object of which to inflate the lock
-         lr...........the lock record to install. The current thread must
-                      own the lock of this lock record!
-
-   PRE-CONDITION:
-      The current thread must be the owner of this object's monitor AND
-         of the lock record's lock!
-
-*******************************************************************************/
-
-static void lock_inflate(threadobject *t, java_handle_t *o, lock_record_t *lr)
-{
-       uintptr_t lockword;
-
-       /* get the current lock count */
-
-       lockword = lock_lockword_get(t, o);
-
-       if (IS_FAT_LOCK(lockword)) {
-               assert(GET_FAT_LOCK(lockword) == lr);
-               return;
-       }
-       else {
-               assert(LOCK_WORD_WITHOUT_COUNT(lockword) == t->thinlock);
-
-               /* copy the count from the thin lock */
-
-               lr->count = (lockword & THIN_LOCK_COUNT_MASK) >> THIN_LOCK_COUNT_SHIFT;
-       }
-
-       DEBUGLOCKS(("[lock_inflate      : lr=%p, t=%p, o=%p, o->lockword=%lx, count=%d]",
-                               lr, t, o, lockword, lr->count));
-
-       /* install it */
-
-       lock_lockword_set(t, o, MAKE_FAT_LOCK(lr));
-}
-
-
-/* TODO Move this function into threadlist.[ch]. */
-
-static threadobject *threads_lookup_thread_id(int index)
-{
-       threadobject *t;
-
-       threadlist_lock();
-
-       for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
-               if (t->state == THREAD_STATE_NEW)
-                       continue;
-               if (t->index == index)
-                       break;
-       }
-
-       threadlist_unlock();
-       return t;
-}
-
-static void sable_flc_waiting(ptrint lockword, threadobject *t, java_handle_t *o)
-{
-       int index;
-       threadobject *t_other;
-       int old_flc;
-
-       index = GET_THREAD_INDEX(lockword);
-       t_other = threads_lookup_thread_id(index);
-       if (!t_other)
-/*             failure, TODO: add statistics */
-               return;
-
-       mutex_lock(&t_other->flc_lock);
-       old_flc = t_other->flc_bit;
-       t_other->flc_bit = true;
-
-       DEBUGLOCKS(("thread %d set flc bit for lock-holding thread %d",
-                               t->index, t_other->index));
-
-       /* Set FLC bit first, then read the lockword again */
-       MEMORY_BARRIER();
-
-       lockword = lock_lockword_get(t, o);
-
-       /* Lockword is still the way it was seen before */
-       if (IS_THIN_LOCK(lockword) && (GET_THREAD_INDEX(lockword) == index))
-       {
-               /* Add tuple (t, o) to the other thread's FLC list */
-               t->flc_object = o;
-               t->flc_next = t_other->flc_list;
-               t_other->flc_list = t;
-
-               for (;;)
-               {
-                       threadobject *current;
-
-                       /* Wait until another thread sees the flc bit and notifies
-                          us of unlocking. */
-                       pthread_cond_wait(&t->flc_cond, &t_other->flc_lock);
-
-                       /* Traverse FLC list looking if we're still there */
-                       current = t_other->flc_list;
-                       while (current && current != t)
-                               current = current->flc_next;
-                       if (!current)
-                               /* not in list anymore, can stop waiting */
-                               break;
-
-                       /* We are still in the list -- the other thread cannot have seen
-                          the FLC bit yet */
-                       assert(t_other->flc_bit);
-               }
-
-               t->flc_object = NULL;   /* for garbage collector? */
-               t->flc_next = NULL;
-       }
-       else
-               t_other->flc_bit = old_flc;
-
-       mutex_unlock(&t_other->flc_lock);
-}
-
-static void notify_flc_waiters(threadobject *t, java_handle_t *o)
-{
-       threadobject *current;
-
-       mutex_lock(&t->flc_lock);
-
-       current = t->flc_list;
-       while (current)
-       {
-               if (current->flc_object != o)
-               {
-                       /* The object has to be inflated so the other threads can properly
-                          block on it. */
-
-                       /* Only if not already inflated */
-                       ptrint lockword = lock_lockword_get(t, current->flc_object);
-                       if (IS_THIN_LOCK(lockword)) {
-                               lock_record_t *lr = lock_hashtable_get(t, current->flc_object);
-                               lock_record_enter(t, lr);
-
-                               DEBUGLOCKS(("thread %d inflating lock of %p to lr %p",
-                                                       t->index, (void*) current->flc_object, (void*) lr));
-
-                               lock_inflate(t, current->flc_object, lr);
-                       }
-               }
-               /* Wake the waiting thread */
-               pthread_cond_broadcast(&current->flc_cond);
-
-               current = current->flc_next;
-       }
-
-       t->flc_list = NULL;
-       t->flc_bit = false;
-       mutex_unlock(&t->flc_lock);
-}
-
-/* lock_monitor_enter **********************************************************
-
-   Acquire the monitor of the given object. If the current thread already
-   owns the monitor, the lock counter is simply increased.
-
-   This function blocks until it can acquire the monitor.
-
-   IN:
-      t............the current thread
-         o............the object of which to enter the monitor
-
-   RETURN VALUE:
-      true.........the lock has been successfully acquired
-         false........an exception has been thrown
-
-*******************************************************************************/
-
-bool lock_monitor_enter(java_handle_t *o)
-{
-       threadobject  *t;
-       /* CAUTION: This code assumes that ptrint is unsigned! */
-       ptrint         lockword;
-       ptrint         thinlock;
-       lock_record_t *lr;
-
-       if (o == NULL) {
-               exceptions_throw_nullpointerexception();
-               return false;
-       }
-
-       t = THREADOBJECT;
-
-       thinlock = t->thinlock;
-
-retry:
-       /* most common case: try to thin-lock an unlocked object */
-
-       LLNI_CRITICAL_START_THREAD(t);
-       lockword = COMPARE_AND_SWAP_OLD_VALUE(&(LLNI_DIRECT(o)->lockword), THIN_UNLOCKED, thinlock);
-       LLNI_CRITICAL_END_THREAD(t);
-
-       if (lockword == THIN_UNLOCKED) {
-               /* success. we locked it */
-               /* The Java Memory Model requires a memory barrier here: */
-               /* Because of the CAS above, this barrier is a nop on x86 / x86_64 */
-               MEMORY_BARRIER_AFTER_ATOMIC();
-               return true;
-       }
-
-       /* next common case: recursive lock with small recursion count */
-       /* We don't have to worry about stale values here, as any stale value  */
-       /* will indicate another thread holding the lock (or an inflated lock) */
-
-       if (LOCK_WORD_WITHOUT_COUNT(lockword) == thinlock) {
-               /* we own this monitor               */
-               /* check the current recursion count */
-
-               if ((lockword ^ thinlock) < (THIN_LOCK_COUNT_MAX << THIN_LOCK_COUNT_SHIFT))
-               {
-                       /* the recursion count is low enough */
-
-                       lock_lockword_set(t, o, lockword + THIN_LOCK_COUNT_INCR);
-
-                       /* success. we locked it */
-                       return true;
-               }
-               else {
-                       /* recursion count overflow */
-
-                       lr = lock_hashtable_get(t, o);
-                       lock_record_enter(t, lr);
-                       lock_inflate(t, o, lr);
-                       lr->count++;
-
-                       notify_flc_waiters(t, o);
-
-                       return true;
-               }
-       }
-
-       /* the lock is either contented or fat */
-
-       if (IS_FAT_LOCK(lockword)) {
-
-               lr = GET_FAT_LOCK(lockword);
-
-               /* check for recursive entering */
-               if (lr->owner == t) {
-                       lr->count++;
-                       return true;
-               }
-
-               /* acquire the mutex of the lock record */
-
-               lock_record_enter(t, lr);
-
-               assert(lr->count == 0);
-
-               return true;
-       }
-
-       /****** inflation path ******/
-
-#if defined(ENABLE_JVMTI)
-       /* Monitor Contended Enter */
-       jvmti_MonitorContendedEntering(false, o);
-#endif
-
-       sable_flc_waiting(lockword, t, o);
-
-#if defined(ENABLE_JVMTI)
-       /* Monitor Contended Entered */
-       jvmti_MonitorContendedEntering(true, o);
-#endif
-       goto retry;
-}
-
-
-/* lock_monitor_exit ***********************************************************
-
-   Decrement the counter of a (currently owned) monitor. If the counter
-   reaches zero, release the monitor.
-
-   If the current thread is not the owner of the monitor, an 
-   IllegalMonitorState exception is thrown.
-
-   IN:
-      t............the current thread
-         o............the object of which to exit the monitor
-
-   RETURN VALUE:
-      true.........everything ok,
-         false........an exception has been thrown
-
-*******************************************************************************/
-
-bool lock_monitor_exit(java_handle_t *o)
-{
-       threadobject *t;
-       uintptr_t     lockword;
-       ptrint        thinlock;
-
-       if (o == NULL) {
-               exceptions_throw_nullpointerexception();
-               return false;
-       }
-
-       t = THREADOBJECT;
-
-       thinlock = t->thinlock;
-
-       /* We don't have to worry about stale values here, as any stale value */
-       /* will indicate that we don't own the lock.                          */
-
-       lockword = lock_lockword_get(t, o);
-
-       /* most common case: we release a thin lock that we hold once */
-
-       if (lockword == thinlock) {
-               /* memory barrier for Java Memory Model */
-               STORE_ORDER_BARRIER();
-               lock_lockword_set(t, o, THIN_UNLOCKED);
-               /* memory barrier for thin locking */
-               MEMORY_BARRIER();
-
-               /* check if there has been a flat lock contention on this object */
-
-               if (t->flc_bit) {
-                       DEBUGLOCKS(("thread %d saw flc bit", t->index));
-
-                       /* there has been a contention on this thin lock */
-                       notify_flc_waiters(t, o);
-               }
-
-               return true;
-       }
-
-       /* next common case: we release a recursive lock, count > 0 */
-
-       if (LOCK_WORD_WITHOUT_COUNT(lockword) == thinlock) {
-               lock_lockword_set(t, o, lockword - THIN_LOCK_COUNT_INCR);
-               return true;
-       }
-
-       /* either the lock is fat, or we don't hold it at all */
-
-       if (IS_FAT_LOCK(lockword)) {
-
-               lock_record_t *lr;
-
-               lr = GET_FAT_LOCK(lockword);
-
-               /* check if we own this monitor */
-               /* We don't have to worry about stale values here, as any stale value */
-               /* will be != t and thus fail this check.                             */
-
-               if (lr->owner != t) {
-                       exceptions_throw_illegalmonitorstateexception();
-                       return false;
-               }
-
-               /* { the current thread `t` owns the lock record `lr` on object `o` } */
-
-               if (lr->count != 0) {
-                       /* we had locked this one recursively. just decrement, it will */
-                       /* still be locked. */
-                       lr->count--;
-                       return true;
-               }
-
-               /* unlock this lock record */
-
-               lr->owner = NULL;
-               mutex_unlock(&(lr->mutex));
-
-               return true;
-       }
-
-       /* legal thin lock cases have been handled above, so this is an error */
-
-       exceptions_throw_illegalmonitorstateexception();
-
-       return false;
-}
-
-
-/* lock_record_add_waiter ******************************************************
-
-   Add a thread to the list of waiting threads of a lock record.
-
-   IN:
-      lr...........the lock record
-      thread.......the thread to add
-
-*******************************************************************************/
-
-static void lock_record_add_waiter(lock_record_t *lr, threadobject *thread)
-{
-       lock_waiter_t *w;
-
-       /* Allocate a waiter data structure. */
-
-       w = NEW(lock_waiter_t);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_lock_waiter += sizeof(lock_waiter_t);
-#endif
-
-       /* Store the thread in the waiter structure. */
-
-       w->thread = thread;
-
-       /* Add the waiter as last entry to waiters list. */
-
-       list_add_last(lr->waiters, w);
-}
-
-
-/* lock_record_remove_waiter ***************************************************
-
-   Remove a thread from the list of waiting threads of a lock record.
-
-   IN:
-      lr...........the lock record
-      t............the current thread
-
-   PRE-CONDITION:
-      The current thread must be the owner of the lock record.
-   
-*******************************************************************************/
-
-static void lock_record_remove_waiter(lock_record_t *lr, threadobject *thread)
-{
-       list_t        *l;
-       lock_waiter_t *w;
-
-       /* Get the waiters list. */
-
-       l = lr->waiters;
-
-       for (w = list_first(l); w != NULL; w = list_next(l, w)) {
-               if (w->thread == thread) {
-                       /* Remove the waiter entry from the list. */
-
-                       list_remove(l, w);
-
-                       /* Free the waiter data structure. */
-
-                       FREE(w, lock_waiter_t);
-
-#if defined(ENABLE_STATISTICS)
-                       if (opt_stat)
-                               size_lock_waiter -= sizeof(lock_waiter_t);
-#endif
-
-                       return;
-               }
-       }
-
-       /* This should never happen. */
-
-       vm_abort("lock_record_remove_waiter: thread not found in list of waiters\n");
-}
-
-
-/* lock_record_wait ************************************************************
-
-   Wait on a lock record for a given (maximum) amount of time.
-
-   IN:
-      t............the current thread
-         lr...........the lock record
-         millis.......milliseconds of timeout
-         nanos........nanoseconds of timeout
-
-   RETURN VALUE:
-      true.........we have been interrupted,
-      false........everything ok
-
-   PRE-CONDITION:
-      The current thread must be the owner of the lock record.
-         This is NOT checked by this function!
-   
-*******************************************************************************/
-
-static bool lock_record_wait(threadobject *thread, lock_record_t *lr, s8 millis, s4 nanos)
-{
-       s4   lockcount;
-       bool wasinterrupted = false;
-
-       DEBUGLOCKS(("[lock_record_wait  : lr=%p, t=%p, millis=%lld, nanos=%d]",
-                               lr, thread, millis, nanos));
-
-       /* { the thread t owns the fat lock record lr on the object o } */
-
-       /* register us as waiter for this object */
-
-       lock_record_add_waiter(lr, thread);
-
-       /* remember the old lock count */
-
-       lockcount = lr->count;
-
-       /* unlock this record */
-
-       lr->count = 0;
-       lock_record_exit(thread, lr);
-
-       /* wait until notified/interrupted/timed out */
-
-       threads_wait_with_timeout_relative(thread, millis, nanos);
-
-       /* re-enter the monitor */
-
-       lock_record_enter(thread, lr);
-
-       /* remove us from the list of waiting threads */
-
-       lock_record_remove_waiter(lr, thread);
-
-       /* restore the old lock count */
-
-       lr->count = lockcount;
-
-       /* We can only be signaled OR interrupted, not both. If both flags
-          are set, reset only signaled and leave the thread in
-          interrupted state. Otherwise, clear both. */
-
-       if (!thread->signaled) {
-               wasinterrupted = thread->interrupted;
-               thread->interrupted = false;
-       }
-
-       thread->signaled = false;
-
-       /* return if we have been interrupted */
-
-       return wasinterrupted;
-}
-
-
-/* lock_monitor_wait ***********************************************************
-
-   Wait on an object for a given (maximum) amount of time.
-
-   IN:
-      t............the current thread
-         o............the object
-         millis.......milliseconds of timeout
-         nanos........nanoseconds of timeout
-
-   PRE-CONDITION:
-      The current thread must be the owner of the object's monitor.
-   
-*******************************************************************************/
-
-static void lock_monitor_wait(threadobject *t, java_handle_t *o, s8 millis, s4 nanos)
-{
-       uintptr_t      lockword;
-       lock_record_t *lr;
-
-       lockword = lock_lockword_get(t, o);
-
-       /* check if we own this monitor */
-       /* We don't have to worry about stale values here, as any stale value */
-       /* will fail this check.                                              */
-
-       if (IS_FAT_LOCK(lockword)) {
-
-               lr = GET_FAT_LOCK(lockword);
-
-               if (lr->owner != t) {
-                       exceptions_throw_illegalmonitorstateexception();
-                       return;
-               }
-       }
-       else {
-               /* it's a thin lock */
-
-               if (LOCK_WORD_WITHOUT_COUNT(lockword) != t->thinlock) {
-                       exceptions_throw_illegalmonitorstateexception();
-                       return;
-               }
-
-               /* inflate this lock */
-
-               lr = lock_hashtable_get(t, o);
-               lock_record_enter(t, lr);
-               lock_inflate(t, o, lr);
-
-               notify_flc_waiters(t, o);
-       }
-
-       /* { the thread t owns the fat lock record lr on the object o } */
-
-       if (lock_record_wait(t, lr, millis, nanos))
-               exceptions_throw_interruptedexception();
-}
-
-
-/* lock_record_notify **********************************************************
-
-   Notify one thread or all threads waiting on the given lock record.
-
-   IN:
-      t............the current thread
-         lr...........the lock record
-         one..........if true, only notify one thread
-
-   PRE-CONDITION:
-      The current thread must be the owner of the lock record.
-         This is NOT checked by this function!
-   
-*******************************************************************************/
-
-static void lock_record_notify(threadobject *t, lock_record_t *lr, bool one)
-{
-       list_t        *l;
-       lock_waiter_t *w;
-       threadobject  *waitingthread;
-
-       /* { the thread t owns the fat lock record lr on the object o } */
-
-       /* Get the waiters list. */
-
-       l = lr->waiters;
-
-       for (w = list_first(l); w != NULL; w = list_next(l, w)) {
-               /* signal the waiting thread */
-
-               waitingthread = w->thread;
-
-               /* We must skip threads which have already been notified. They will
-                  remove themselves from the list. */
-
-               if (waitingthread->signaled)
-                       continue;
-
-               /* Enter the wait-mutex. */
-
-               mutex_lock(&(waitingthread->waitmutex));
-
-               DEBUGLOCKS(("[lock_record_notify: lr=%p, t=%p, waitingthread=%p, sleeping=%d, one=%d]",
-                                       lr, t, waitingthread, waitingthread->sleeping, one));
-
-               /* Signal the thread if it's sleeping. sleeping can be false
-                  when the waiting thread is blocked between giving up the
-                  monitor and entering the waitmutex. It will eventually
-                  observe that it's signaled and refrain from going to
-                  sleep. */
-
-               if (waitingthread->sleeping)
-                       pthread_cond_signal(&(waitingthread->waitcond));
-
-               /* Mark the thread as signaled. */
-
-               waitingthread->signaled = true;
-
-               /* Leave the wait-mutex. */
-
-               mutex_unlock(&(waitingthread->waitmutex));
-
-               /* if we should only wake one, we are done */
-
-               if (one)
-                       break;
-       }
-}
-
-
-/* lock_monitor_notify *********************************************************
-
-   Notify one thread or all threads waiting on the given object.
-
-   IN:
-      t............the current thread
-         o............the object
-         one..........if true, only notify one thread
-
-   PRE-CONDITION:
-      The current thread must be the owner of the object's monitor.
-   
-*******************************************************************************/
-
-static void lock_monitor_notify(threadobject *t, java_handle_t *o, bool one)
-{
-       uintptr_t      lockword;
-       lock_record_t *lr;
-
-       lockword = lock_lockword_get(t, o);
-
-       /* check if we own this monitor */
-       /* We don't have to worry about stale values here, as any stale value */
-       /* will fail this check.                                              */
-
-       if (IS_FAT_LOCK(lockword)) {
-
-               lr = GET_FAT_LOCK(lockword);
-
-               if (lr->owner != t) {
-                       exceptions_throw_illegalmonitorstateexception();
-                       return;
-               }
-       }
-       else {
-               /* it's a thin lock */
-
-               if (LOCK_WORD_WITHOUT_COUNT(lockword) != t->thinlock) {
-                       exceptions_throw_illegalmonitorstateexception();
-                       return;
-               }
-
-               /* no thread can wait on a thin lock, so there's nothing to do. */
-               return;
-       }
-
-       /* { the thread t owns the fat lock record lr on the object o } */
-
-       lock_record_notify(t, lr, one);
-}
-
-
-
-/*============================================================================*/
-/* INQUIRY FUNCIONS                                                           */
-/*============================================================================*/
-
-
-/* lock_is_held_by_current_thread **********************************************
-
-   Return true if the current thread owns the monitor of the given object.
-
-   IN:
-         o............the object
-
-   RETURN VALUE:
-      true, if the current thread holds the lock of this object.
-   
-*******************************************************************************/
-
-bool lock_is_held_by_current_thread(java_handle_t *o)
-{
-       threadobject  *t;
-       uintptr_t      lockword;
-       lock_record_t *lr;
-
-       t = THREADOBJECT;
-
-       /* check if we own this monitor */
-       /* We don't have to worry about stale values here, as any stale value */
-       /* will fail this check.                                              */
-
-       lockword = lock_lockword_get(t, o);
-
-       if (IS_FAT_LOCK(lockword)) {
-               /* it's a fat lock */
-
-               lr = GET_FAT_LOCK(lockword);
-
-               return (lr->owner == t);
-       }
-       else {
-               /* it's a thin lock */
-
-               return (LOCK_WORD_WITHOUT_COUNT(lockword) == t->thinlock);
-       }
-}
-
-
-
-/*============================================================================*/
-/* WRAPPERS FOR OPERATIONS ON THE CURRENT THREAD                              */
-/*============================================================================*/
-
-
-/* lock_wait_for_object ********************************************************
-
-   Wait for the given object.
-
-   IN:
-         o............the object
-         millis.......milliseconds to wait
-         nanos........nanoseconds to wait
-   
-*******************************************************************************/
-
-void lock_wait_for_object(java_handle_t *o, s8 millis, s4 nanos)
-{
-       threadobject *thread;
-
-       thread = THREADOBJECT;
-
-       lock_monitor_wait(thread, o, millis, nanos);
-}
-
-
-/* lock_notify_object **********************************************************
-
-   Notify one thread waiting on the given object.
-
-   IN:
-         o............the object
-   
-*******************************************************************************/
-
-void lock_notify_object(java_handle_t *o)
-{
-       threadobject *thread;
-
-       thread = THREADOBJECT;
-
-       lock_monitor_notify(thread, o, true);
-}
-
-
-/* lock_notify_all_object ******************************************************
-
-   Notify all threads waiting on the given object.
-
-   IN:
-         o............the object
-   
-*******************************************************************************/
-
-void lock_notify_all_object(java_handle_t *o)
-{
-       threadobject *thread;
-
-       thread = THREADOBJECT;
-
-       lock_monitor_notify(thread, o, false);
-}
-
-
-/*
- * 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/threads/posix/lock.h b/src/threads/posix/lock.h
deleted file mode 100644 (file)
index 56e1722..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/* src/threads/posix/lock.h - lock implementation
-
-   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 _LOCK_H
-#define _LOCK_H
-
-#include "config.h"
-
-#include <pthread.h>
-
-#include "vm/types.h"
-
-#include "native/llni.h"
-
-#include "threads/mutex.h"
-
-#include "toolbox/list.h"
-
-#include "vm/global.h"
-
-
-
-/* typedefs *******************************************************************/
-
-typedef struct lock_record_t    lock_record_t;
-typedef struct lock_waiter_t    lock_waiter_t;
-typedef struct lock_hashtable_t lock_hashtable_t;
-
-
-/* lock_waiter_t ***************************************************************
-
-   List node for storing a waiting thread.
-
-*******************************************************************************/
-
-struct lock_waiter_t {
-       struct threadobject *thread;        /* the waiting thread                 */
-       listnode_t           linkage;
-};
-
-
-/* lock_record_t ***************************************************************
-
-   Lock record struct representing an inflated ("fat") lock.
-
-*******************************************************************************/
-
-struct lock_record_t {
-       java_object_t       *object;             /* object for which this lock is */
-       struct threadobject *owner;              /* current owner of this monitor */
-       s4                   count;              /* recursive lock count          */
-       mutex_t              mutex;              /* mutex for synchronizing       */
-       list_t              *waiters;            /* list of threads waiting       */
-       lock_record_t       *hashlink;           /* next record in hash chain     */
-};
-
-
-/* lock_hashtable_t ************************************************************
-   The global hashtable mapping objects to lock records.
-
-*******************************************************************************/
-
-struct lock_hashtable_t {
-       mutex_t              mutex;       /* mutex for synch. access to the table */
-       u4                   size;        /* number of slots                      */
-       u4                   entries;     /* current number of entries            */
-       lock_record_t      **ptr;         /* the table of slots, uses ext. chain. */
-};
-
-
-/* defines ********************************************************************/
-
-#define LOCK_INIT_OBJECT_LOCK(o) lock_init_object_lock((java_object_t *) (o))
-
-#define LOCK_MONITOR_ENTER(o)    lock_monitor_enter((java_handle_t *) LLNI_QUICKWRAP(o))
-#define LOCK_MONITOR_EXIT(o)     lock_monitor_exit((java_handle_t *) LLNI_QUICKWRAP(o))
-
-#define LOCK_WAIT_FOREVER(o)     lock_wait_for_object((java_handle_t *) LLNI_QUICKWRAP(o), 0, 0)
-#define LOCK_NOTIFY(o)           lock_notify_object((java_handle_t *) LLNI_QUICKWRAP(o))
-
-#endif /* _LOCK_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/threads/posix/mutex-posix.h b/src/threads/posix/mutex-posix.h
deleted file mode 100644 (file)
index b178c51..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/* src/threads/posix/mutex-posix.h - POSIX mutual exclusion functions
-
-   Copyright (C) 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 _MUTEX_POSIX_H
-#define _MUTEX_POSIX_H
-
-#include "config.h"
-
-#include <pthread.h>
-
-#include "vm/vm.h"
-
-
-/* POSIX mutex object *********************************************************/
-
-typedef pthread_mutex_t mutex_t;
-
-
-/* static mutex initializer ***************************************************/
-
-#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
-
-
-/* inline functions ***********************************************************/
-
-/* mutex_init ******************************************************************
-
-   Initializes the given mutex object and checks for errors.
-
-   ARGUMENTS:
-       mutex ... POSIX mutex object
-
-*******************************************************************************/
-
-inline static void mutex_init(mutex_t *mutex)
-{
-       int result;
-
-       result = pthread_mutex_init(mutex, NULL);
-
-       if (result != 0)
-               vm_abort_errnum(result, "mutex_init: pthread_mutex_init failed");
-}
-
-
-/* mutex_lock ******************************************************************
-
-   Locks the given mutex object and checks for errors. If the mutex is
-   already locked by another thread, the calling thread is suspended until
-   the mutex is unlocked.
-
-   If the mutex is already locked by the calling thread, the same applies,
-   thus effectively causing the calling thread to deadlock. (This is because
-   we use "fast" pthread mutexes without error checking.)
-
-   ARGUMENTS:
-       mutex ... POSIX mutex object
-
-*******************************************************************************/
-
-inline static void mutex_lock(mutex_t *mutex)
-{
-       int result;
-
-       result = pthread_mutex_lock(mutex);
-
-       if (result != 0)
-               vm_abort_errnum(result, "mutex_lock: pthread_mutex_lock failed");
-}
-
-
-/* mutex_unlock ****************************************************************
-
-   Unlocks the given mutex object and checks for errors. The mutex is
-   assumed to be locked and owned by the calling thread.
-
-   ARGUMENTS:
-       mutex ... POSIX mutex object
-
-*******************************************************************************/
-
-inline static void mutex_unlock(mutex_t *mutex)
-{
-       int result;
-
-       result = pthread_mutex_unlock(mutex);
-
-       if (result != 0)
-               vm_abort_errnum(result, "mutex_unlock: pthread_mutex_unlock failed");
-}
-
-
-/* mutex_destroy ***************************************************************
-
-   Destroys the given mutex object and checks for errors.
-
-   ARGUMENTS:
-       mutex ... POSIX mutex object
-
-*******************************************************************************/
-
-inline static void mutex_destroy(mutex_t *mutex)
-{
-       int result;
-
-       result = pthread_mutex_destroy(mutex);
-
-       if (result != 0)
-               vm_abort_errnum(result, "mutex_destroy: pthread_mutex_destroy failed");
-}
-
-
-#endif /* _MUTEX_POSIX_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/threads/posix/mutex-posix.hpp b/src/threads/posix/mutex-posix.hpp
new file mode 100644 (file)
index 0000000..e7206d5
--- /dev/null
@@ -0,0 +1,178 @@
+/* src/threads/posix/mutex-posix.hpp - POSIX mutual exclusion functions
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MUTEX_POSIX_HPP
+#define _MUTEX_POSIX_HPP
+
+#include "config.h"
+
+#include <pthread.h>
+
+
+#ifdef __cplusplus
+
+/**
+ * POSIX implementation of a mutex.
+ */
+class Mutex {
+private:
+       // POSIX mutex structure.
+       pthread_mutex_t     _mutex;
+       pthread_mutexattr_t _attr;
+
+       // Condition class needs to access _mutex for wait() and
+       // timedwait().
+       friend class Condition;
+       
+public:
+       inline Mutex();
+       inline ~Mutex();
+
+       inline void lock();
+       inline void unlock();
+};
+
+#else
+
+// Forward typedefs
+typedef struct Mutex Mutex;
+
+#endif
+
+
+// Includes.
+#include "vm/os.hpp"
+
+
+#ifdef __cplusplus
+
+/**
+ * Initializes the given mutex object and checks for errors.
+ */
+inline Mutex::Mutex()
+{
+       int result = pthread_mutexattr_init(&_attr);
+
+       if (result != 0) {
+               os::abort_errnum(result, "Mutex::Mutex(): pthread_mutexattr_init failed");
+       }
+
+       result = pthread_mutexattr_settype(&_attr, PTHREAD_MUTEX_RECURSIVE);
+
+       if (result != 0) {
+               os::abort_errnum(result, "Mutex::Mutex(): pthread_mutexattr_settype failed");
+       }
+
+       result = pthread_mutex_init(&_mutex, &_attr);
+
+       if (result != 0) {
+               os::abort_errnum(result, "Mutex::Mutex(): pthread_mutex_init failed");
+       }
+}
+
+
+/**
+ * Destroys the given mutex object and checks for errors.
+ */
+inline Mutex::~Mutex()
+{
+       int result = pthread_mutexattr_destroy(&_attr);
+
+       if (result != 0) {
+               os::abort_errnum(result, "Mutex::~Mutex(): pthread_mutexattr_destroy failed");
+       }
+
+       result = pthread_mutex_destroy(&_mutex);
+
+       if (result != 0) {
+               os::abort_errnum(result, "Mutex::~Mutex(): pthread_mutex_destroy failed");
+       }
+}
+
+
+/**
+ * Locks the given mutex object and checks for errors. If the mutex is
+ * already locked by another thread, the calling thread is suspended until
+ * the mutex is unlocked.
+ *
+ * If the mutex is already locked by the calling thread, the same applies,
+ * thus effectively causing the calling thread to deadlock. (This is because
+ * we use "fast" pthread mutexes without error checking.)
+ */
+inline void Mutex::lock()
+{
+       int result = pthread_mutex_lock(&_mutex);
+
+       if (result != 0) {
+               os::abort_errnum(result, "Mutex::lock(): pthread_mutex_lock failed");
+       }
+}
+
+
+/**
+ * Unlocks the given mutex object and checks for errors. The mutex is
+ * assumed to be locked and owned by the calling thread.
+ */
+inline void Mutex::unlock()
+{
+       int result = pthread_mutex_unlock(&_mutex);
+
+       if (result != 0) {
+               os::abort_errnum(result, "Mutex::unlock: pthread_mutex_unlock failed");
+       }
+}
+
+#else
+
+// This structure must have the same layout as the class above.
+struct Mutex {
+       pthread_mutex_t     _mutex;
+       pthread_mutexattr_t _attr;
+};
+
+Mutex* Mutex_new();
+void   Mutex_delete(Mutex* mutex);
+void   Mutex_lock(Mutex* mutex);
+void   Mutex_unlock(Mutex* mutex);
+
+#endif
+
+#endif /* _MUTEX_POSIX_HPP */
+
+
+/*
+ * 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/threads/posix/thread-posix.c b/src/threads/posix/thread-posix.c
deleted file mode 100644 (file)
index 9ed9ad8..0000000
+++ /dev/null
@@ -1,1822 +0,0 @@
-/* src/threads/posix/thread-posix.c - POSIX thread 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"
-
-/* XXX cleanup these includes */
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/time.h>
-#include <time.h>
-#include <errno.h>
-
-#include <pthread.h>
-
-#include "vm/types.h"
-
-#include "arch.h"
-
-#if !defined(USE_FAKE_ATOMIC_INSTRUCTIONS)
-# include "machine-instr.h"
-#else
-# include "threads/posix/generic-primitives.h"
-#endif
-
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-
-#if defined(ENABLE_GC_CACAO)
-# include "mm/cacao-gc/gc.h"
-#endif
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_lang_Thread.h"
-
-#if defined(ENABLE_JAVASE)
-# include "native/include/java_lang_ThreadGroup.h"
-#endif
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/java_lang_VMThread.h"
-#endif
-
-#include "threads/lock-common.h"
-#include "threads/mutex.h"
-#include "threads/threadlist.h"
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/asmpart.h"
-
-#include "vmcore/options.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
-#if !defined(__DARWIN__)
-# include <semaphore.h>
-#endif
-# if defined(__LINUX__)
-#  define GC_LINUX_THREADS
-# elif defined(__IRIX__)
-#  define GC_IRIX_THREADS
-# elif defined(__DARWIN__)
-#  define GC_DARWIN_THREADS
-# endif
-# if defined(ENABLE_GC_BOEHM)
-/* We need to include Boehm's gc.h here because it overrides
-   pthread_create and friends. */
-#  include "mm/boehm-gc/include/gc.h"
-# endif
-
-#if defined(ENABLE_JVMTI)
-#include "native/jvmti/cacaodbg.h"
-#endif
-
-#if defined(__DARWIN__)
-/* Darwin has no working semaphore implementation.  This one is taken
-   from Boehm-GC. */
-
-/*
-   This is a very simple semaphore implementation for darwin. It
-   is implemented in terms of pthreads calls so it isn't async signal
-   safe. This isn't a problem because signals aren't used to
-   suspend threads on darwin.
-*/
-   
-static int sem_init(sem_t *sem, int pshared, int value)
-{
-       if (pshared)
-               assert(0);
-
-       sem->value = value;
-    
-       mutex_init(&sem->mutex);
-
-       if (pthread_cond_init(&sem->cond, NULL) < 0)
-               return -1;
-
-       return 0;
-}
-
-static int sem_post(sem_t *sem)
-{
-       mutex_lock(&sem->mutex);
-
-       sem->value++;
-
-       if (pthread_cond_signal(&sem->cond) < 0) {
-               mutex_unlock(&sem->mutex);
-               return -1;
-       }
-
-       mutex_unlock(&sem->mutex);
-
-       return 0;
-}
-
-static int sem_wait(sem_t *sem)
-{
-       mutex_lock(&sem->mutex);
-
-       while (sem->value == 0) {
-               pthread_cond_wait(&sem->cond, &sem->mutex);
-       }
-
-       sem->value--;
-
-       mutex_unlock(&sem->mutex);
-
-       return 0;
-}
-
-static int sem_destroy(sem_t *sem)
-{
-       if (pthread_cond_destroy(&sem->cond) < 0)
-               return -1;
-
-       mutex_destroy(&sem->mutex);
-
-       return 0;
-}
-#endif /* defined(__DARWIN__) */
-
-
-/* internally used constants **************************************************/
-
-/* CAUTION: Do not change these values. Boehm GC code depends on them.        */
-#define STOPWORLD_FROM_GC               1
-#define STOPWORLD_FROM_CLASS_NUMBERING  2
-
-
-/* startupinfo *****************************************************************
-
-   Struct used to pass info from threads_start_thread to 
-   threads_startup_thread.
-
-******************************************************************************/
-
-typedef struct {
-       threadobject *thread;      /* threadobject for this thread             */
-       functionptr   function;    /* function to run in the new thread        */
-       sem_t        *psem;        /* signals when thread has been entered     */
-                                  /* in the thread list                       */
-       sem_t        *psem_first;  /* signals when pthread_create has returned */
-} startupinfo;
-
-
-/* prototypes *****************************************************************/
-
-static void threads_calc_absolute_time(struct timespec *tm, s8 millis, s4 nanos);
-
-
-/******************************************************************************/
-/* GLOBAL VARIABLES                                                           */
-/******************************************************************************/
-
-/* the thread object of the current thread                                    */
-/* This is either a thread-local variable defined with __thread, or           */
-/* a thread-specific value stored with key threads_current_threadobject_key.  */
-#if defined(HAVE___THREAD)
-__thread threadobject *thread_current;
-#else
-pthread_key_t thread_current_key;
-#endif
-
-/* global mutex for stop-the-world                                            */
-static mutex_t stopworldlock;
-
-#if defined(ENABLE_GC_CACAO)
-/* global mutex for the GC */
-static mutex_t mutex_gc;
-#endif
-
-/* global mutex and condition for joining threads on exit */
-static mutex_t mutex_join;
-static pthread_cond_t  cond_join;
-
-/* this is one of the STOPWORLD_FROM_ constants, telling why the world is     */
-/* being stopped                                                              */
-static volatile int stopworldwhere;
-
-#if defined(ENABLE_GC_CACAO)
-
-/* semaphore used for acknowleding thread suspension                          */
-static sem_t suspend_ack;
-#if defined(__IRIX__)
-static mutex_t suspend_ack_lock = MUTEX_INITIALIZER;
-static pthread_cond_t suspend_cond = PTHREAD_COND_INITIALIZER;
-#endif
-
-#endif /* ENABLE_GC_CACAO */
-
-/* mutexes used by the fake atomic instructions                               */
-#if defined(USE_FAKE_ATOMIC_INSTRUCTIONS)
-mutex_t _cas_lock = MUTEX_INITIALIZER;
-mutex_t _mb_lock = MUTEX_INITIALIZER;
-#endif
-
-
-/* threads_sem_init ************************************************************
-   Initialize a semaphore. Checks against errors and interruptions.
-
-   IN:
-       sem..............the semaphore to initialize
-          shared...........true if this semaphore will be shared between processes
-          value............the initial value for the semaphore
-   
-*******************************************************************************/
-
-void threads_sem_init(sem_t *sem, bool shared, int value)
-{
-       int r;
-
-       assert(sem);
-
-       do {
-               r = sem_init(sem, shared, value);
-               if (r == 0)
-                       return;
-       } while (errno == EINTR);
-
-       vm_abort("sem_init failed: %s", strerror(errno));
-}
-
-
-/* threads_sem_wait ************************************************************
-   Wait for a semaphore, non-interruptible.
-
-   IMPORTANT: Always use this function instead of `sem_wait` directly, as
-              `sem_wait` may be interrupted by signals!
-  
-   IN:
-       sem..............the semaphore to wait on
-   
-*******************************************************************************/
-
-void threads_sem_wait(sem_t *sem)
-{
-       int r;
-
-       assert(sem);
-
-       do {
-               r = sem_wait(sem);
-               if (r == 0)
-                       return;
-       } while (errno == EINTR);
-
-       vm_abort("sem_wait failed: %s", strerror(errno));
-}
-
-
-/* threads_sem_post ************************************************************
-   Increase the count of a semaphore. Checks for errors.
-
-   IN:
-       sem..............the semaphore to increase the count of
-   
-*******************************************************************************/
-
-void threads_sem_post(sem_t *sem)
-{
-       int r;
-
-       assert(sem);
-
-       /* unlike sem_wait, sem_post is not interruptible */
-
-       r = sem_post(sem);
-       if (r == 0)
-               return;
-
-       vm_abort("sem_post failed: %s", strerror(errno));
-}
-
-
-/* lock_stopworld **************************************************************
-
-   Enter the stopworld lock, specifying why the world shall be stopped.
-
-   IN:
-      where........ STOPWORLD_FROM_GC              (1) from within GC
-                    STOPWORLD_FROM_CLASS_NUMBERING (2) class numbering
-
-******************************************************************************/
-
-void lock_stopworld(int where)
-{
-       mutex_lock(&stopworldlock);
-/*     stopworldwhere = where; */
-}
-
-
-/* unlock_stopworld ************************************************************
-
-   Release the stopworld lock.
-
-******************************************************************************/
-
-void unlock_stopworld(void)
-{
-/*     stopworldwhere = 0; */
-       mutex_unlock(&stopworldlock);
-}
-
-/* XXX We disable that whole bunch of code until we have the exact-GC
-   running. Some of it may only be needed by the old Boehm-based
-   suspension handling. */
-
-#if 0
-
-#if !defined(__DARWIN__)
-/* Caller must hold threadlistlock */
-static s4 threads_cast_sendsignals(s4 sig)
-{
-       threadobject *t;
-       threadobject *self;
-       s4            count;
-
-       self = THREADOBJECT;
-
-       /* iterate over all started threads */
-
-       count = 0;
-
-       for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
-               /* don't send the signal to ourself */
-
-               if (t == self)
-                       continue;
-
-               /* don't send the signal to NEW threads (because they are not
-                  completely initialized) */
-
-               if (t->state == THREAD_STATE_NEW)
-                       continue;
-
-               /* send the signal */
-
-               pthread_kill(t->tid, sig);
-
-               /* increase threads count */
-
-               count++;
-       }
-
-       return count;
-}
-
-#else
-
-static void threads_cast_darwinstop(void)
-{
-       threadobject *tobj = mainthreadobj;
-       threadobject *self = THREADOBJECT;
-
-       do {
-               if (tobj != self)
-               {
-                       thread_state_flavor_t flavor = MACHINE_THREAD_STATE;
-                       mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT;
-#if defined(__I386__)
-                       i386_thread_state_t thread_state;
-#else
-                       ppc_thread_state_t thread_state;
-#endif
-                       mach_port_t thread = tobj->mach_thread;
-                       kern_return_t r;
-
-                       r = thread_suspend(thread);
-
-                       if (r != KERN_SUCCESS)
-                               vm_abort("thread_suspend failed");
-
-                       r = thread_get_state(thread, flavor, (natural_t *) &thread_state,
-                                                                &thread_state_count);
-
-                       if (r != KERN_SUCCESS)
-                               vm_abort("thread_get_state failed");
-
-                       md_critical_section_restart((ucontext_t *) &thread_state);
-
-                       r = thread_set_state(thread, flavor, (natural_t *) &thread_state,
-                                                                thread_state_count);
-
-                       if (r != KERN_SUCCESS)
-                               vm_abort("thread_set_state failed");
-               }
-
-               tobj = tobj->next;
-       } while (tobj != mainthreadobj);
-}
-
-static void threads_cast_darwinresume(void)
-{
-       threadobject *tobj = mainthreadobj;
-       threadobject *self = THREADOBJECT;
-
-       do {
-               if (tobj != self)
-               {
-                       mach_port_t thread = tobj->mach_thread;
-                       kern_return_t r;
-
-                       r = thread_resume(thread);
-
-                       if (r != KERN_SUCCESS)
-                               vm_abort("thread_resume failed");
-               }
-
-               tobj = tobj->next;
-       } while (tobj != mainthreadobj);
-}
-
-#endif
-
-#if defined(__IRIX__)
-static void threads_cast_irixresume(void)
-{
-       mutex_lock(&suspend_ack_lock);
-       pthread_cond_broadcast(&suspend_cond);
-       mutex_unlock(&suspend_ack_lock);
-}
-#endif
-
-#if defined(ENABLE_GC_BOEHM) && !defined(__DARWIN__)
-static void threads_sigsuspend_handler(ucontext_t *_uc)
-{
-       int sig;
-       sigset_t sigs;
-
-       /* XXX TWISTI: this is just a quick hack */
-#if defined(ENABLE_JIT)
-       md_critical_section_restart(_uc);
-#endif
-
-       /* Do as Boehm does. On IRIX a condition variable is used for wake-up
-          (not POSIX async-safe). */
-#if defined(__IRIX__)
-       mutex_lock(&suspend_ack_lock);
-       threads_sem_post(&suspend_ack);
-       pthread_cond_wait(&suspend_cond, &suspend_ack_lock);
-       mutex_unlock(&suspend_ack_lock);
-#elif defined(__CYGWIN__)
-       /* TODO */
-       assert(0);
-#else
-
-       sig = GC_signum2();
-       sigfillset(&sigs);
-       sigdelset(&sigs, sig);
-       sigsuspend(&sigs);
-#endif
-}
-#endif
-
-
-/* threads_stopworld ***********************************************************
-
-   Stops the world from turning. All threads except the calling one
-   are suspended. The function returns as soon as all threads have
-   acknowledged their suspension.
-
-*******************************************************************************/
-
-void threads_stopworld(void)
-{
-#if !defined(__DARWIN__) && !defined(__CYGWIN__)
-       threadobject *t;
-       threadobject *self;
-       bool result;
-       s4 count, i;
-#endif
-
-       lock_stopworld(STOPWORLD_FROM_CLASS_NUMBERING);
-
-       /* lock the threads lists */
-
-       threadlist_lock();
-
-#if defined(__DARWIN__)
-       /*threads_cast_darwinstop();*/
-       assert(0);
-#elif defined(__CYGWIN__)
-       /* TODO */
-       assert(0);
-#else
-       self = THREADOBJECT;
-
-       DEBUGTHREADS("stops World", self);
-
-       count = 0;
-
-       /* suspend all running threads */
-       for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
-               /* don't send the signal to ourself */
-
-               if (t == self)
-                       continue;
-
-               /* don't send the signal to NEW threads (because they are not
-                  completely initialized) */
-
-               if (t->state == THREAD_STATE_NEW)
-                       continue;
-
-               /* send the signal */
-
-               result = threads_suspend_thread(t, SUSPEND_REASON_STOPWORLD);
-               assert(result);
-
-               /* increase threads count */
-
-               count++;
-       }
-
-       /* wait for all threads signaled to suspend */
-       for (i = 0; i < count; i++)
-               threads_sem_wait(&suspend_ack);
-#endif
-
-       /* ATTENTION: Don't unlock the threads-lists here so that
-          non-signaled NEW threads can't change their state and execute
-          code. */
-}
-
-
-/* threads_startworld **********************************************************
-
-   Starts the world again after it has previously been stopped. 
-
-*******************************************************************************/
-
-void threads_startworld(void)
-{
-#if !defined(__DARWIN__) && !defined(__CYGWIN__)
-       threadobject *t;
-       threadobject *self;
-       bool result;
-       s4 count, i;
-#endif
-
-#if defined(__DARWIN__)
-       /*threads_cast_darwinresume();*/
-       assert(0);
-#elif defined(__IRIX__)
-       threads_cast_irixresume();
-#elif defined(__CYGWIN__)
-       /* TODO */
-       assert(0);
-#else
-       self = THREADOBJECT;
-
-       DEBUGTHREADS("starts World", self);
-
-       count = 0;
-
-       /* resume all thread we haltet */
-       for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
-               /* don't send the signal to ourself */
-
-               if (t == self)
-                       continue;
-
-               /* don't send the signal to NEW threads (because they are not
-                  completely initialized) */
-
-               if (t->state == THREAD_STATE_NEW)
-                       continue;
-
-               /* send the signal */
-
-               result = threads_resume_thread(t);
-               assert(result);
-
-               /* increase threads count */
-
-               count++;
-       }
-
-       /* wait for all threads signaled to suspend */
-       for (i = 0; i < count; i++)
-               threads_sem_wait(&suspend_ack);
-
-#endif
-
-       /* unlock the threads lists */
-
-       threadlist_unlock();
-
-       unlock_stopworld();
-}
-
-#endif
-
-
-/* threads_impl_thread_init ****************************************************
-
-   Initialize OS-level locking constructs in threadobject.
-
-   IN:
-      t....the threadobject
-
-*******************************************************************************/
-
-void threads_impl_thread_init(threadobject *t)
-{
-       int result;
-
-       /* initialize the mutex and the condition */
-
-       mutex_init(&t->flc_lock);
-
-       result = pthread_cond_init(&t->flc_cond, NULL);
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_thread_new: pthread_cond_init failed");
-
-       mutex_init(&(t->waitmutex));
-
-       result = pthread_cond_init(&(t->waitcond), NULL);
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_thread_new: pthread_cond_init failed");
-
-       mutex_init(&(t->suspendmutex));
-
-       result = pthread_cond_init(&(t->suspendcond), NULL);
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_thread_new: pthread_cond_init failed");
-}
-
-/* threads_impl_thread_clear ***************************************************
-
-   Clears all fields in threadobject the way an MZERO would have
-   done. MZERO cannot be used anymore because it would mess up the
-   pthread_* bits.
-
-   IN:
-      t....the threadobject
-
-*******************************************************************************/
-
-void threads_impl_thread_clear(threadobject *t)
-{
-       t->object = NULL;
-
-       t->thinlock = 0;
-
-       t->index = 0;
-       t->flags = 0;
-       t->state = 0;
-
-       t->tid = 0;
-
-#if defined(__DARWIN__)
-       t->mach_thread = 0;
-#endif
-
-       t->interrupted = false;
-       t->signaled = false;
-       t->sleeping = false;
-
-       t->suspended = false;
-       t->suspend_reason = 0;
-
-       t->pc = NULL;
-
-       t->_exceptionptr = NULL;
-       t->_stackframeinfo = NULL;
-       t->_localref_table = NULL;
-
-#if defined(ENABLE_INTRP)
-       t->_global_sp = NULL;
-#endif
-
-#if defined(ENABLE_GC_CACAO)
-       t->gc_critical = false;
-
-       t->ss = NULL;
-       t->es = NULL;
-#endif
-
-       MZERO(&t->dumpinfo, dumpinfo_t, 1);
-}
-
-/* threads_impl_thread_reuse ***************************************************
-
-   Resets some implementation fields in threadobject. This was
-   previously done in threads_impl_thread_new.
-
-   IN:
-      t....the threadobject
-
-*******************************************************************************/
-
-void threads_impl_thread_reuse(threadobject *t)
-{
-       /* get the pthread id */
-
-       t->tid = pthread_self();
-
-#if defined(ENABLE_DEBUG_FILTER)
-       /* Initialize filter counters */
-       t->filterverbosecallctr[0] = 0;
-       t->filterverbosecallctr[1] = 0;
-#endif
-
-#if !defined(NDEBUG)
-       t->tracejavacallindent = 0;
-       t->tracejavacallcount = 0;
-#endif
-
-       t->flc_bit = false;
-       t->flc_next = NULL;
-       t->flc_list = NULL;
-
-/*     not really needed */
-       t->flc_object = NULL;
-}
-
-
-/* threads_impl_thread_free ****************************************************
-
-   Cleanup thread stuff.
-
-   IN:
-      t....the threadobject
-
-*******************************************************************************/
-
-#if 0
-/* never used */
-void threads_impl_thread_free(threadobject *t)
-{
-       int result;
-
-       /* Destroy the mutex and the condition. */
-
-       mutex_destroy(&(t->flc_lock));
-
-       result = pthread_cond_destroy(&(t->flc_cond));
-
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed");
-
-       mutex_destroy(&(t->waitmutex));
-
-       result = pthread_cond_destroy(&(t->waitcond));
-
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed");
-
-       mutex_destroy(&(t->suspendmutex));
-
-       result = pthread_cond_destroy(&(t->suspendcond));
-
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed");
-}
-#endif
-
-
-/* threads_impl_preinit ********************************************************
-
-   Do some early initialization of stuff required.
-
-   ATTENTION: Do NOT use any Java heap allocation here, as gc_init()
-   is called AFTER this function!
-
-*******************************************************************************/
-
-void threads_impl_preinit(void)
-{
-       int result;
-
-       mutex_init(&stopworldlock);
-
-       /* initialize exit mutex and condition (on exit we join all
-          threads) */
-
-       mutex_init(&mutex_join);
-
-       result = pthread_cond_init(&cond_join, NULL);
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_preinit: pthread_cond_init failed");
-
-#if defined(ENABLE_GC_CACAO)
-       /* initialize the GC mutex & suspend semaphore */
-
-       mutex_init(&mutex_gc);
-       threads_sem_init(&suspend_ack, 0, 0);
-#endif
-
-#if !defined(HAVE___THREAD)
-       result = pthread_key_create(&thread_current_key, NULL);
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_preinit: pthread_key_create failed");
-#endif
-}
-
-
-/* threads_mutex_gc_lock *******************************************************
-
-   Enter the global GC mutex.
-
-*******************************************************************************/
-
-#if defined(ENABLE_GC_CACAO)
-void threads_mutex_gc_lock(void)
-{
-       mutex_lock(&mutex_gc);
-}
-#endif
-
-
-/* threads_mutex_gc_unlock *****************************************************
-
-   Leave the global GC mutex.
-
-*******************************************************************************/
-
-#if defined(ENABLE_GC_CACAO)
-void threads_mutex_gc_unlock(void)
-{
-       mutex_unlock(&mutex_gc);
-}
-#endif
-
-/* threads_mutex_join_lock *****************************************************
-
-   Enter the join mutex.
-
-*******************************************************************************/
-
-void threads_mutex_join_lock(void)
-{
-       mutex_lock(&mutex_join);
-}
-
-
-/* threads_mutex_join_unlock ***************************************************
-
-   Leave the join mutex.
-
-*******************************************************************************/
-
-void threads_mutex_join_unlock(void)
-{
-       mutex_unlock(&mutex_join);
-}
-
-
-/* threads_impl_init ***********************************************************
-
-   Initializes the implementation specific bits.
-
-*******************************************************************************/
-
-void threads_impl_init(void)
-{
-       pthread_attr_t attr;
-       int            result;
-
-       threads_set_thread_priority(pthread_self(), NORM_PRIORITY);
-
-       /* Initialize the thread attribute object. */
-
-       result = pthread_attr_init(&attr);
-
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_init: pthread_attr_init failed");
-
-       result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_init: pthread_attr_setdetachstate failed");
-}
-
-
-/* threads_startup_thread ******************************************************
-
-   Thread startup function called by pthread_create.
-
-   Thread which have a startup.function != NULL are marked as internal
-   threads. All other threads are threated as normal Java threads.
-
-   NOTE: This function is not called directly by pthread_create. The Boehm GC
-         inserts its own GC_start_routine in between, which then calls
-                threads_startup.
-
-   IN:
-      arg..........the argument passed to pthread_create, ie. a pointer to
-                      a startupinfo struct. CAUTION: When the `psem` semaphore
-                                  is posted, the startupinfo struct becomes invalid! (It
-                                  is allocated on the stack of threads_start_thread.)
-
-******************************************************************************/
-
-static void *threads_startup_thread(void *arg)
-{
-       startupinfo        *startup;
-       threadobject       *t;
-       java_lang_Thread   *object;
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_VMThread *vmt;
-#endif
-       sem_t              *psem;
-       classinfo          *c;
-       methodinfo         *m;
-       java_handle_t      *o;
-       functionptr         function;
-
-#if defined(ENABLE_INTRP)
-       u1 *intrp_thread_stack;
-
-       /* create interpreter stack */
-
-       if (opt_intrp) {
-               intrp_thread_stack = GCMNEW(u1, opt_stacksize);
-               MSET(intrp_thread_stack, 0, u1, opt_stacksize);
-       }
-       else
-               intrp_thread_stack = NULL;
-#endif
-
-       /* get passed startupinfo structure and the values in there */
-
-       startup = arg;
-
-       t        = startup->thread;
-       function = startup->function;
-       psem     = startup->psem;
-
-       /* Seems like we've encountered a situation where thread->tid was
-          not set by pthread_create. We alleviate this problem by waiting
-          for pthread_create to return. */
-
-       threads_sem_wait(startup->psem_first);
-
-#if defined(__DARWIN__)
-       t->mach_thread = mach_thread_self();
-#endif
-
-       /* Now that we are in the new thread, we can store the internal
-          thread data-structure in the TSD. */
-
-       thread_set_current(t);
-
-       /* get the java.lang.Thread object for this thread */
-
-       object = (java_lang_Thread *) thread_get_object(t);
-
-       /* set our priority */
-
-       threads_set_thread_priority(t->tid, LLNI_field_direct(object, priority));
-
-       /* Thread is completely initialized. */
-
-       thread_set_state_runnable(t);
-
-       /* tell threads_startup_thread that we registered ourselves */
-       /* CAUTION: *startup becomes invalid with this!             */
-
-       startup = NULL;
-       threads_sem_post(psem);
-
-#if defined(ENABLE_INTRP)
-       /* set interpreter stack */
-
-       if (opt_intrp)
-               thread->_global_sp = (Cell *) (intrp_thread_stack + opt_stacksize);
-#endif
-
-#if defined(ENABLE_JVMTI)
-       /* fire thread start event */
-
-       if (jvmti) 
-               jvmti_ThreadStartEnd(JVMTI_EVENT_THREAD_START);
-#endif
-
-       DEBUGTHREADS("starting", t);
-
-       /* find and run the Thread.run()V method if no other function was passed */
-
-       if (function == NULL) {
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-               /* We need to start the run method of
-                  java.lang.VMThread. Since this is a final class, we can use
-                  the class object directly. */
-
-               c = class_java_lang_VMThread;
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-               LLNI_class_get(object, c);
-#else
-# error unknown classpath configuration
-#endif
-
-               m = class_resolveclassmethod(c, utf_run, utf_void__void, c, true);
-
-               if (m == NULL)
-                       vm_abort("threads_startup_thread: run() method not found in class");
-
-               /* set ThreadMXBean variables */
-
-               _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++;
-               _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++;
-
-               if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount >
-                       _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount)
-                       _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount =
-                               _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-               /* we need to start the run method of java.lang.VMThread */
-
-               LLNI_field_get_ref(object, vmThread, vmt);
-               o = (java_handle_t *) vmt;
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-               o = (java_handle_t *) object;
-#else
-# error unknown classpath configuration
-#endif
-
-               /* Run the thread. */
-
-               (void) vm_call_method(m, o);
-       }
-       else {
-               /* set ThreadMXBean variables */
-
-               _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++;
-               _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++;
-
-               if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount >
-                       _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount)
-                       _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount =
-                               _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount;
-
-               /* call passed function, e.g. finalizer_thread */
-
-               (function)();
-       }
-
-       DEBUGTHREADS("stopping", t);
-
-#if defined(ENABLE_JVMTI)
-       /* fire thread end event */
-
-       if (jvmti)
-               jvmti_ThreadStartEnd(JVMTI_EVENT_THREAD_END);
-#endif
-
-       /* We ignore the return value. */
-
-       (void) threads_detach_thread(t);
-
-       /* set ThreadMXBean variables */
-
-       _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount--;
-
-       return NULL;
-}
-
-
-/* threads_impl_thread_start ***************************************************
-
-   Start a thread in the JVM.  Both (vm internal and java) thread
-   objects exist.
-
-   IN:
-      thread....the thread object
-         f.........function to run in the new thread. NULL means that the
-                   "run" method of the object `t` should be called
-
-******************************************************************************/
-
-void threads_impl_thread_start(threadobject *thread, functionptr f)
-{
-       sem_t          sem;
-       sem_t          sem_first;
-       pthread_attr_t attr;
-       startupinfo    startup;
-       int            result;
-
-       /* fill startupinfo structure passed by pthread_create to
-        * threads_startup_thread */
-
-       startup.thread     = thread;
-       startup.function   = f;              /* maybe we don't call Thread.run()V */
-       startup.psem       = &sem;
-       startup.psem_first = &sem_first;
-
-       threads_sem_init(&sem, 0, 0);
-       threads_sem_init(&sem_first, 0, 0);
-
-       /* Initialize thread attributes. */
-
-       result = pthread_attr_init(&attr);
-
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_init failed");
-
-    result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-
-    if (result != 0)
-               vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_setdetachstate failed");
-
-       /* initialize thread stacksize */
-
-       result = pthread_attr_setstacksize(&attr, opt_stacksize);
-
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_setstacksize failed");
-
-       /* create the thread */
-
-       result = pthread_create(&(thread->tid), &attr, threads_startup_thread, &startup);
-
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_thread_start: pthread_create failed");
-
-       /* destroy the thread attributes */
-
-       result = pthread_attr_destroy(&attr);
-
-       if (result != 0)
-               vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_destroy failed");
-
-       /* signal that pthread_create has returned, so thread->tid is valid */
-
-       threads_sem_post(&sem_first);
-
-       /* wait here until the thread has entered itself into the thread list */
-
-       threads_sem_wait(&sem);
-
-       /* cleanup */
-
-       sem_destroy(&sem);
-       sem_destroy(&sem_first);
-}
-
-
-/* threads_set_thread_priority *************************************************
-
-   Set the priority of the given thread.
-
-   IN:
-      tid..........thread id
-         priority.....priority to set
-
-******************************************************************************/
-
-void threads_set_thread_priority(pthread_t tid, int priority)
-{
-       struct sched_param schedp;
-       int policy;
-
-       pthread_getschedparam(tid, &policy, &schedp);
-       schedp.sched_priority = priority;
-       pthread_setschedparam(tid, policy, &schedp);
-}
-
-
-/* threads_detach_thread *******************************************************
-
-   Detaches the passed thread from the VM.  Used in JNI.
-
-*******************************************************************************/
-
-bool threads_detach_thread(threadobject *t)
-{
-       bool                   result;
-       java_lang_Thread      *object;
-       java_handle_t         *o;
-#if defined(ENABLE_JAVASE)
-       java_lang_ThreadGroup *group;
-       java_handle_t         *e;
-       void                  *handler;
-       classinfo             *c;
-       methodinfo            *m;
-#endif
-
-    /* If the given thread has already been detached, this operation
-          is a no-op. */
-
-       result = thread_is_attached(t);
-
-       if (result == false)
-               return true;
-
-       DEBUGTHREADS("detaching", t);
-
-       object = (java_lang_Thread *) thread_get_object(t);
-
-#if defined(ENABLE_JAVASE)
-       LLNI_field_get_ref(object, group, group);
-
-    /* If there's an uncaught exception, call uncaughtException on the
-       thread's exception handler, or the thread's group if this is
-       unset. */
-
-       e = exceptions_get_and_clear_exception();
-
-    if (e != NULL) {
-               /* We use the type void* for handler here, as it's not trivial
-                  to build the java_lang_Thread_UncaughtExceptionHandler
-                  header file with cacaoh. */
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-               LLNI_field_get_ref(object, exceptionHandler, handler);
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-               LLNI_field_get_ref(object, uncaughtExceptionHandler, handler);
-# endif
-
-               if (handler != NULL) {
-                       LLNI_class_get(handler, c);
-                       o = (java_handle_t *) handler;
-               }
-               else {
-                       LLNI_class_get(group, c);
-                       o = (java_handle_t *) group;
-               }
-
-               m = class_resolveclassmethod(c,
-                                                                        utf_uncaughtException,
-                                                                        utf_java_lang_Thread_java_lang_Throwable__V,
-                                                                        NULL,
-                                                                        true);
-
-               if (m == NULL)
-                       return false;
-
-               (void) vm_call_method(m, o, object, e);
-
-               if (exceptions_get_exception())
-                       return false;
-    }
-
-       /* XXX TWISTI: should all threads be in a ThreadGroup? */
-
-       /* Remove thread from the thread group. */
-
-       if (group != NULL) {
-               LLNI_class_get(group, c);
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-               m = class_resolveclassmethod(c,
-                                                                        utf_removeThread,
-                                                                        utf_java_lang_Thread__V,
-                                                                        class_java_lang_ThreadGroup,
-                                                                        true);
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-               m = class_resolveclassmethod(c,
-                                                                        utf_remove,
-                                                                        utf_java_lang_Thread__V,
-                                                                        class_java_lang_ThreadGroup,
-                                                                        true);
-# else
-#  error unknown classpath configuration
-# endif
-
-               if (m == NULL)
-                       return false;
-
-               o = (java_handle_t *) group;
-
-               (void) vm_call_method(m, o, object);
-
-               if (exceptions_get_exception())
-                       return false;
-
-               /* Reset the threadgroup in the Java thread object (Mauve
-                  test: gnu/testlet/java/lang/Thread/getThreadGroup). */
-
-               LLNI_field_set_ref(object, group, NULL);
-       }
-#endif
-
-       /* Thread has terminated. */
-
-       thread_set_state_terminated(t);
-
-       /* Notify all threads waiting on this thread.  These are joining
-          this thread. */
-
-       o = (java_handle_t *) object;
-
-       /* XXX Care about exceptions? */
-       (void) lock_monitor_enter(o);
-       
-       lock_notify_all_object(o);
-
-       /* XXX Care about exceptions? */
-       (void) lock_monitor_exit(o);
-
-       /* Enter the join-mutex before calling thread_free, so
-          threads_join_all_threads gets the correct number of non-daemon
-          threads. */
-
-       threads_mutex_join_lock();
-
-       /* Free the internal thread data-structure. */
-
-       thread_free(t);
-
-       /* Signal that this thread has finished and leave the mutex. */
-
-       pthread_cond_signal(&cond_join);
-       threads_mutex_join_unlock();
-
-       return true;
-}
-
-
-#if defined(ENABLE_GC_CACAO)
-
-/* threads_suspend_thread ******************************************************
-
-   Suspend the passed thread. Execution stops until the thread
-   is explicitly resumend again.
-
-   IN:
-     reason.....Reason for suspending this thread.
-
-*******************************************************************************/
-
-bool threads_suspend_thread(threadobject *thread, s4 reason)
-{
-       /* acquire the suspendmutex */
-       mutex_lock(&(thread->suspendmutex));
-
-       if (thread->suspended) {
-               mutex_unlock(&(thread->suspendmutex));
-               return false;
-       }
-
-       /* set the reason for the suspension */
-       thread->suspend_reason = reason;
-
-       /* send the suspend signal to the thread */
-       assert(thread != THREADOBJECT);
-       if (pthread_kill(thread->tid, SIGUSR1) != 0)
-               vm_abort("threads_suspend_thread: pthread_kill failed: %s",
-                                strerror(errno));
-
-       /* REMEMBER: do not release the suspendmutex, this is done
-          by the thread itself in threads_suspend_ack().  */
-
-       return true;
-}
-
-
-/* threads_suspend_ack *********************************************************
-
-   Acknowledges the suspension of the current thread.
-
-   IN:
-     pc.....The PC where the thread suspended its execution.
-     sp.....The SP before the thread suspended its execution.
-
-*******************************************************************************/
-
-void threads_suspend_ack(u1* pc, u1* sp)
-{
-       threadobject *thread;
-
-       thread = THREADOBJECT;
-
-       assert(thread->suspend_reason != 0);
-
-       /* TODO: remember dump memory size */
-
-       /* inform the GC about the suspension */
-       if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD && gc_pending) {
-
-               /* check if the GC wants to leave the thread running */
-               if (!gc_suspend(thread, pc, sp)) {
-
-                       /* REMEMBER: we do not unlock the suspendmutex because the thread
-                          will suspend itself again at a later time */
-                       return;
-
-               }
-       }
-
-       /* mark this thread as suspended and remember the PC */
-       thread->pc        = pc;
-       thread->suspended = true;
-
-       /* if we are stopping the world, we should send a global ack */
-       if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD) {
-               threads_sem_post(&suspend_ack);
-       }
-
-       DEBUGTHREADS("suspending", thread);
-
-       /* release the suspension mutex and wait till we are resumed */
-       pthread_cond_wait(&(thread->suspendcond), &(thread->suspendmutex));
-
-       DEBUGTHREADS("resuming", thread);
-
-       /* if we are stopping the world, we should send a global ack */
-       if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD) {
-               threads_sem_post(&suspend_ack);
-       }
-
-       /* TODO: free dump memory */
-
-       /* release the suspendmutex */
-       mutex_unlock(&(thread->suspendmutex));
-}
-
-
-/* threads_resume_thread *******************************************************
-
-   Resumes the execution of the passed thread.
-
-*******************************************************************************/
-
-bool threads_resume_thread(threadobject *thread)
-{
-       /* acquire the suspendmutex */
-       mutex_lock(&(thread->suspendmutex));
-
-       if (!thread->suspended) {
-               mutex_unlock(&(thread->suspendmutex));
-               return false;
-       }
-
-       thread->suspended = false;
-
-       /* tell everyone that the thread should resume */
-       assert(thread != THREADOBJECT);
-       pthread_cond_broadcast(&(thread->suspendcond));
-
-       /* release the suspendmutex */
-       mutex_unlock(&(thread->suspendmutex));
-
-       return true;
-}
-
-#endif
-
-/* threads_join_all_threads ****************************************************
-
-   Join all non-daemon threads.
-
-*******************************************************************************/
-
-void threads_join_all_threads(void)
-{
-       threadobject *t;
-
-       /* get current thread */
-
-       t = THREADOBJECT;
-
-       /* This thread is waiting for all non-daemon threads to exit. */
-
-       thread_set_state_waiting(t);
-
-       /* enter join mutex */
-
-       threads_mutex_join_lock();
-
-       /* Wait for condition as long as we have non-daemon threads.  We
-          compare against 1 because the current (main thread) is also a
-          non-daemon thread. */
-
-       while (threadlist_get_non_daemons() > 1)
-               pthread_cond_wait(&cond_join, &mutex_join);
-
-       /* leave join mutex */
-
-       threads_mutex_join_unlock();
-}
-
-
-/* threads_timespec_earlier ****************************************************
-
-   Return true if timespec tv1 is earlier than timespec tv2.
-
-   IN:
-      tv1..........first timespec
-         tv2..........second timespec
-
-   RETURN VALUE:
-      true, if the first timespec is earlier
-
-*******************************************************************************/
-
-static inline bool threads_timespec_earlier(const struct timespec *tv1,
-                                                                                       const struct timespec *tv2)
-{
-       return (tv1->tv_sec < tv2->tv_sec)
-                               ||
-               (tv1->tv_sec == tv2->tv_sec && tv1->tv_nsec < tv2->tv_nsec);
-}
-
-
-/* threads_current_time_is_earlier_than ****************************************
-
-   Check if the current time is earlier than the given timespec.
-
-   IN:
-      tv...........the timespec to compare against
-
-   RETURN VALUE:
-      true, if the current time is earlier
-
-*******************************************************************************/
-
-static bool threads_current_time_is_earlier_than(const struct timespec *tv)
-{
-       struct timeval tvnow;
-       struct timespec tsnow;
-
-       /* get current time */
-
-       if (gettimeofday(&tvnow, NULL) != 0)
-               vm_abort("gettimeofday failed: %s\n", strerror(errno));
-
-       /* convert it to a timespec */
-
-       tsnow.tv_sec = tvnow.tv_sec;
-       tsnow.tv_nsec = tvnow.tv_usec * 1000;
-
-       /* compare current time with the given timespec */
-
-       return threads_timespec_earlier(&tsnow, tv);
-}
-
-
-/* threads_wait_with_timeout ***************************************************
-
-   Wait until the given point in time on a monitor until either
-   we are notified, we are interrupted, or the time is up.
-
-   IN:
-      t............the current thread
-         wakeupTime...absolute (latest) wakeup time
-                          If both tv_sec and tv_nsec are zero, this function
-                                          waits for an unlimited amount of time.
-
-*******************************************************************************/
-
-static void threads_wait_with_timeout(threadobject *t, struct timespec *wakeupTime)
-{
-       /* acquire the waitmutex */
-
-       mutex_lock(&t->waitmutex);
-
-       /* mark us as sleeping */
-
-       t->sleeping = true;
-
-       /* wait on waitcond */
-
-       if (wakeupTime->tv_sec || wakeupTime->tv_nsec) {
-               /* with timeout */
-               while (!t->interrupted && !t->signaled
-                          && threads_current_time_is_earlier_than(wakeupTime))
-               {
-                       thread_set_state_timed_waiting(t);
-
-                       pthread_cond_timedwait(&t->waitcond, &t->waitmutex,
-                                                                  wakeupTime);
-
-                       thread_set_state_runnable(t);
-               }
-       }
-       else {
-               /* no timeout */
-               while (!t->interrupted && !t->signaled) {
-                       thread_set_state_waiting(t);
-
-                       pthread_cond_wait(&t->waitcond, &t->waitmutex);
-
-                       thread_set_state_runnable(t);
-               }
-       }
-
-       t->sleeping    = false;
-
-       /* release the waitmutex */
-
-       mutex_unlock(&t->waitmutex);
-}
-
-
-/* threads_wait_with_timeout_relative ******************************************
-
-   Wait for the given maximum amount of time on a monitor until either
-   we are notified, we are interrupted, or the time is up.
-
-   IN:
-      t............the current thread
-         millis.......milliseconds to wait
-         nanos........nanoseconds to wait
-
-*******************************************************************************/
-
-void threads_wait_with_timeout_relative(threadobject *thread, s8 millis,
-                                                                               s4 nanos)
-{
-       struct timespec wakeupTime;
-
-       /* calculate the the (latest) wakeup time */
-
-       threads_calc_absolute_time(&wakeupTime, millis, nanos);
-
-       /* wait */
-
-       threads_wait_with_timeout(thread, &wakeupTime);
-}
-
-
-/* threads_calc_absolute_time **************************************************
-
-   Calculate the absolute point in time a given number of ms and ns from now.
-
-   IN:
-      millis............milliseconds from now
-         nanos.............nanoseconds from now
-
-   OUT:
-      *tm...............receives the timespec of the absolute point in time
-
-*******************************************************************************/
-
-static void threads_calc_absolute_time(struct timespec *tm, s8 millis, s4 nanos)
-{
-       if ((millis != 0x7fffffffffffffffLLU) && (millis || nanos)) {
-               struct timeval tv;
-               long nsec;
-               gettimeofday(&tv, NULL);
-               tv.tv_sec += millis / 1000;
-               millis %= 1000;
-               nsec = tv.tv_usec * 1000 + (s4) millis * 1000000 + nanos;
-               tm->tv_sec = tv.tv_sec + nsec / 1000000000;
-               tm->tv_nsec = nsec % 1000000000;
-       }
-       else {
-               tm->tv_sec = 0;
-               tm->tv_nsec = 0;
-       }
-}
-
-
-/* threads_thread_interrupt ****************************************************
-
-   Interrupt the given thread.
-
-   The thread gets the "waitcond" signal and 
-   its interrupted flag is set to true.
-
-   IN:
-      thread............the thread to interrupt
-
-*******************************************************************************/
-
-void threads_thread_interrupt(threadobject *thread)
-{
-       /* Signal the thread a "waitcond" and tell it that it has been
-          interrupted. */
-
-       mutex_lock(&thread->waitmutex);
-
-       DEBUGTHREADS("interrupted", thread);
-
-       /* Interrupt blocking system call using a signal. */
-
-       pthread_kill(thread->tid, SIGHUP);
-
-       if (thread->sleeping)
-               pthread_cond_signal(&thread->waitcond);
-
-       thread->interrupted = true;
-
-       mutex_unlock(&thread->waitmutex);
-}
-
-
-/* threads_sleep ***************************************************************
-
-   Sleep the current thread for the specified amount of time.
-
-*******************************************************************************/
-
-void threads_sleep(int64_t millis, int32_t nanos)
-{
-       threadobject    *t;
-       struct timespec  wakeupTime;
-       bool             interrupted;
-
-       if (millis < 0) {
-/*             exceptions_throw_illegalargumentexception("timeout value is negative"); */
-               exceptions_throw_illegalargumentexception();
-               return;
-       }
-
-       t = thread_get_current();
-
-       if (thread_is_interrupted(t) && !exceptions_get_exception()) {
-               /* Clear interrupted flag (Mauve test:
-                  gnu/testlet/java/lang/Thread/interrupt). */
-
-               thread_set_interrupted(t, false);
-
-/*             exceptions_throw_interruptedexception("sleep interrupted"); */
-               exceptions_throw_interruptedexception();
-               return;
-       }
-
-       threads_calc_absolute_time(&wakeupTime, millis, nanos);
-
-       threads_wait_with_timeout(t, &wakeupTime);
-
-       interrupted = thread_is_interrupted(t);
-
-       if (interrupted) {
-               thread_set_interrupted(t, false);
-
-               /* An other exception could have been thrown
-                  (e.g. ThreadDeathException). */
-
-               if (!exceptions_get_exception())
-                       exceptions_throw_interruptedexception();
-       }
-}
-
-
-/* threads_yield ***************************************************************
-
-   Yield to the scheduler.
-
-*******************************************************************************/
-
-void threads_yield(void)
-{
-       sched_yield();
-}
-
-
-/*
- * 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/threads/posix/thread-posix.cpp b/src/threads/posix/thread-posix.cpp
new file mode 100644 (file)
index 0000000..949c1b5
--- /dev/null
@@ -0,0 +1,1637 @@
+/* src/threads/posix/thread-posix.cpp - POSIX thread 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"
+
+/* XXX cleanup these includes */
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <time.h>
+#include <errno.h>
+
+#include <pthread.h>
+
+#include "vm/types.h"
+
+#include "arch.h"
+
+#include "mm/gc.hpp"
+#include "mm/memory.h"
+
+#if defined(ENABLE_GC_CACAO)
+# include "mm/cacao-gc/gc.h"
+#endif
+
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#include "threads/condition.hpp"
+#include "threads/lock.hpp"
+#include "threads/mutex.hpp"
+#include "threads/threadlist.hpp"
+#include "threads/thread.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/options.h"
+#include "vm/signallocal.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#include "vm/jit/asmpart.h"
+
+#if !defined(__DARWIN__)
+# include <semaphore.h>
+#endif
+
+#if defined(__LINUX__)
+# define GC_LINUX_THREADS
+#elif defined(__IRIX__)
+# define GC_IRIX_THREADS
+#elif defined(__DARWIN__)
+# define GC_DARWIN_THREADS
+#endif
+
+#if defined(ENABLE_GC_BOEHM)
+/* We need to include Boehm's gc.h here because it overrides
+   pthread_create and friends. */
+# include "mm/boehm-gc/include/gc.h"
+#endif
+
+#if defined(ENABLE_JVMTI)
+#include "native/jvmti/cacaodbg.h"
+#endif
+
+
+#if defined(__DARWIN__)
+/* Darwin has no working semaphore implementation.  This one is taken
+   from Boehm-GC. */
+
+/*
+   This is a very simple semaphore implementation for Darwin. It
+   is implemented in terms of pthreads calls so it isn't async signal
+   safe. This isn't a problem because signals aren't used to
+   suspend threads on Darwin.
+*/
+   
+static int sem_init(sem_t *sem, int pshared, int value)
+{
+       if (pshared)
+               assert(0);
+
+       sem->mutex = new Mutex();
+       sem->cond  = new Condition();
+       sem->value = value;
+
+       return 0;
+}
+
+static int sem_post(sem_t *sem)
+{
+       sem->mutex->lock();
+       sem->value++;
+       sem->cond->signal();
+       sem->mutex->unlock();
+
+       return 0;
+}
+
+static int sem_wait(sem_t *sem)
+{
+       sem->mutex->lock();
+
+       while (sem->value == 0) {
+               sem->cond->wait(sem->mutex);
+       }
+
+       sem->value--;
+       sem->mutex->unlock();
+
+       return 0;
+}
+
+static int sem_destroy(sem_t *sem)
+{
+       delete sem->cond;
+       delete sem->mutex;
+
+       return 0;
+}
+#endif /* defined(__DARWIN__) */
+
+
+/* startupinfo *****************************************************************
+
+   Struct used to pass info from threads_start_thread to 
+   threads_startup_thread.
+
+******************************************************************************/
+
+typedef struct {
+       threadobject *thread;      /* threadobject for this thread             */
+       functionptr   function;    /* function to run in the new thread        */
+       sem_t        *psem;        /* signals when thread has been entered     */
+                                  /* in the thread list                       */
+       sem_t        *psem_first;  /* signals when pthread_create has returned */
+} startupinfo;
+
+
+/* prototypes *****************************************************************/
+
+static void threads_calc_absolute_time(struct timespec *tm, s8 millis, s4 nanos);
+
+
+/******************************************************************************/
+/* GLOBAL VARIABLES                                                           */
+/******************************************************************************/
+
+/* the thread object of the current thread                                    */
+/* This is either a thread-local variable defined with __thread, or           */
+/* a thread-specific value stored with key threads_current_threadobject_key.  */
+#if defined(HAVE___THREAD)
+__thread threadobject *thread_current;
+#else
+pthread_key_t thread_current_key;
+#endif
+
+/* global mutex for stop-the-world                                            */
+static Mutex* stopworldlock;
+
+#if defined(ENABLE_GC_CACAO)
+/* global mutex for the GC */
+static Mutex* mutex_gc;
+#endif
+
+/* global mutex and condition for joining threads on exit */
+static Mutex* mutex_join;
+static Condition* cond_join;
+
+#if defined(ENABLE_GC_CACAO)
+/* semaphore used for acknowleding thread suspension                          */
+static sem_t suspend_ack;
+#endif
+
+
+/* threads_sem_init ************************************************************
+   Initialize a semaphore. Checks against errors and interruptions.
+
+   IN:
+       sem..............the semaphore to initialize
+          shared...........true if this semaphore will be shared between processes
+          value............the initial value for the semaphore
+   
+*******************************************************************************/
+
+void threads_sem_init(sem_t *sem, bool shared, int value)
+{
+       int r;
+
+       assert(sem);
+
+       do {
+               r = sem_init(sem, shared, value);
+               if (r == 0)
+                       return;
+       } while (errno == EINTR);
+
+       vm_abort("sem_init failed: %s", strerror(errno));
+}
+
+
+/* threads_sem_wait ************************************************************
+   Wait for a semaphore, non-interruptible.
+
+   IMPORTANT: Always use this function instead of `sem_wait` directly, as
+              `sem_wait` may be interrupted by signals!
+  
+   IN:
+       sem..............the semaphore to wait on
+   
+*******************************************************************************/
+
+void threads_sem_wait(sem_t *sem)
+{
+       int r;
+
+       assert(sem);
+
+       do {
+               r = sem_wait(sem);
+               if (r == 0)
+                       return;
+       } while (errno == EINTR);
+
+       vm_abort("sem_wait failed: %s", strerror(errno));
+}
+
+
+/* threads_sem_post ************************************************************
+   Increase the count of a semaphore. Checks for errors.
+
+   IN:
+       sem..............the semaphore to increase the count of
+   
+*******************************************************************************/
+
+void threads_sem_post(sem_t *sem)
+{
+       int r;
+
+       assert(sem);
+
+       /* unlike sem_wait, sem_post is not interruptible */
+
+       r = sem_post(sem);
+       if (r == 0)
+               return;
+
+       vm_abort("sem_post failed: %s", strerror(errno));
+}
+
+
+/* threads_stopworld ***********************************************************
+
+   Stops the world from turning. All threads except the calling one
+   are suspended. The function returns as soon as all threads have
+   acknowledged their suspension.
+
+*******************************************************************************/
+
+#if defined(ENABLE_GC_CACAO)
+void threads_stopworld(void)
+{
+#if !defined(__DARWIN__) && !defined(__CYGWIN__)
+       threadobject *t;
+       threadobject *self;
+       bool result;
+       s4 count, i;
+#endif
+
+       stopworldlock->lock();
+
+       /* lock the threads lists */
+
+       threadlist_lock();
+
+#if defined(__DARWIN__)
+       /*threads_cast_darwinstop();*/
+       assert(0);
+#elif defined(__CYGWIN__)
+       /* TODO */
+       assert(0);
+#else
+       self = THREADOBJECT;
+
+       DEBUGTHREADS("stops World", self);
+
+       count = 0;
+
+       /* suspend all running threads */
+       for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
+               /* don't send the signal to ourself */
+
+               if (t == self)
+                       continue;
+
+               /* don't send the signal to NEW threads (because they are not
+                  completely initialized) */
+
+               if (t->state == THREAD_STATE_NEW)
+                       continue;
+
+               /* send the signal */
+
+               result = threads_suspend_thread(t, SUSPEND_REASON_STOPWORLD);
+               assert(result);
+
+               /* increase threads count */
+
+               count++;
+       }
+
+       /* wait for all threads signaled to suspend */
+       for (i = 0; i < count; i++)
+               threads_sem_wait(&suspend_ack);
+#endif
+
+       /* ATTENTION: Don't unlock the threads-lists here so that
+          non-signaled NEW threads can't change their state and execute
+          code. */
+}
+#endif
+
+
+/* threads_startworld **********************************************************
+
+   Starts the world again after it has previously been stopped. 
+
+*******************************************************************************/
+
+#if defined(ENABLE_GC_CACAO)
+void threads_startworld(void)
+{
+#if !defined(__DARWIN__) && !defined(__CYGWIN__)
+       threadobject *t;
+       threadobject *self;
+       bool result;
+       s4 count, i;
+#endif
+
+#if defined(__DARWIN__)
+       /*threads_cast_darwinresume();*/
+       assert(0);
+#elif defined(__IRIX__)
+       threads_cast_irixresume();
+#elif defined(__CYGWIN__)
+       /* TODO */
+       assert(0);
+#else
+       self = THREADOBJECT;
+
+       DEBUGTHREADS("starts World", self);
+
+       count = 0;
+
+       /* resume all thread we haltet */
+       for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
+               /* don't send the signal to ourself */
+
+               if (t == self)
+                       continue;
+
+               /* don't send the signal to NEW threads (because they are not
+                  completely initialized) */
+
+               if (t->state == THREAD_STATE_NEW)
+                       continue;
+
+               /* send the signal */
+
+               result = threads_resume_thread(t);
+               assert(result);
+
+               /* increase threads count */
+
+               count++;
+       }
+
+       /* wait for all threads signaled to suspend */
+       for (i = 0; i < count; i++)
+               threads_sem_wait(&suspend_ack);
+
+#endif
+
+       /* unlock the threads lists */
+
+       threadlist_unlock();
+
+       stopworldlock->unlock();
+}
+#endif
+
+
+/* threads_impl_thread_clear ***************************************************
+
+   Clears all fields in threadobject the way an MZERO would have
+   done. MZERO cannot be used anymore because it would mess up the
+   pthread_* bits.
+
+   IN:
+      t....the threadobject
+
+*******************************************************************************/
+
+void threads_impl_thread_clear(threadobject *t)
+{
+       t->object = NULL;
+
+       t->thinlock = 0;
+
+       t->index = 0;
+       t->flags = 0;
+       t->state = 0;
+
+       t->tid = 0;
+
+#if defined(__DARWIN__)
+       t->mach_thread = 0;
+#endif
+
+       t->interrupted = false;
+       t->signaled = false;
+
+       t->suspended = false;
+       t->suspend_reason = 0;
+
+       t->pc = NULL;
+
+       t->_exceptionptr = NULL;
+       t->_stackframeinfo = NULL;
+       t->_localref_table = NULL;
+
+#if defined(ENABLE_INTRP)
+       t->_global_sp = NULL;
+#endif
+
+#if defined(ENABLE_GC_CACAO)
+       t->gc_critical = false;
+
+       t->ss = NULL;
+       t->es = NULL;
+#endif
+
+       // Simply reuse the existing dump memory.
+}
+
+/* threads_impl_thread_reuse ***************************************************
+
+   Resets some implementation fields in threadobject. This was
+   previously done in threads_impl_thread_new.
+
+   IN:
+      t....the threadobject
+
+*******************************************************************************/
+
+void threads_impl_thread_reuse(threadobject *t)
+{
+       /* get the pthread id */
+
+       t->tid = pthread_self();
+
+#if defined(ENABLE_DEBUG_FILTER)
+       /* Initialize filter counters */
+       t->filterverbosecallctr[0] = 0;
+       t->filterverbosecallctr[1] = 0;
+#endif
+
+#if !defined(NDEBUG)
+       t->tracejavacallindent = 0;
+       t->tracejavacallcount = 0;
+#endif
+
+       t->flc_bit = false;
+       t->flc_next = NULL;
+       t->flc_list = NULL;
+
+/*     not really needed */
+       t->flc_object = NULL;
+
+#if defined(ENABLE_TLH)
+       tlh_destroy(&(t->tlh));
+       tlh_init(&(t->tlh));
+#endif
+}
+
+
+/* threads_impl_thread_free ****************************************************
+
+   Cleanup thread stuff.
+
+   IN:
+      t....the threadobject
+
+*******************************************************************************/
+
+#if 0
+/* never used */
+void threads_impl_thread_free(threadobject *t)
+{
+       int result;
+
+       /* Destroy the mutex and the condition. */
+
+       delete t->flc_lock;
+
+       result = pthread_cond_destroy(&(t->flc_cond));
+
+       if (result != 0)
+               vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed");
+
+       delete t->waitmutex;
+
+       result = pthread_cond_destroy(&(t->waitcond));
+
+       if (result != 0)
+               vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed");
+
+       delete t->suspendmutex;
+
+       result = pthread_cond_destroy(&(t->suspendcond));
+
+       if (result != 0)
+               vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed");
+}
+#endif
+
+
+/* threads_impl_preinit ********************************************************
+
+   Do some early initialization of stuff required.
+
+   ATTENTION: Do NOT use any Java heap allocation here, as gc_init()
+   is called AFTER this function!
+
+*******************************************************************************/
+
+void threads_impl_preinit(void)
+{
+       int result;
+
+       stopworldlock = new Mutex();
+
+       /* initialize exit mutex and condition (on exit we join all
+          threads) */
+
+       mutex_join = new Mutex();
+       cond_join = new Condition();
+
+#if defined(ENABLE_GC_CACAO)
+       /* initialize the GC mutex & suspend semaphore */
+
+       mutex_gc = new Mutex();
+       threads_sem_init(&suspend_ack, 0, 0);
+#endif
+
+#if !defined(HAVE___THREAD)
+       result = pthread_key_create(&thread_current_key, NULL);
+       if (result != 0)
+               vm_abort_errnum(result, "threads_impl_preinit: pthread_key_create failed");
+#endif
+}
+
+
+/* threads_mutex_gc_lock *******************************************************
+
+   Enter the global GC mutex.
+
+*******************************************************************************/
+
+#if defined(ENABLE_GC_CACAO)
+void threads_mutex_gc_lock(void)
+{
+       mutex_gc->lock();
+}
+#endif
+
+
+/* threads_mutex_gc_unlock *****************************************************
+
+   Leave the global GC mutex.
+
+*******************************************************************************/
+
+#if defined(ENABLE_GC_CACAO)
+void threads_mutex_gc_unlock(void)
+{
+       mutex_gc->unlock();
+}
+#endif
+
+/* threads_mutex_join_lock *****************************************************
+
+   Enter the join mutex.
+
+*******************************************************************************/
+
+void threads_mutex_join_lock(void)
+{
+       mutex_join->lock();
+}
+
+
+/* threads_mutex_join_unlock ***************************************************
+
+   Leave the join mutex.
+
+*******************************************************************************/
+
+void threads_mutex_join_unlock(void)
+{
+       mutex_join->unlock();
+}
+
+
+/* threads_impl_init ***********************************************************
+
+   Initializes the implementation specific bits.
+
+*******************************************************************************/
+
+void threads_impl_init(void)
+{
+       pthread_attr_t attr;
+       int            result;
+
+       threads_set_thread_priority(pthread_self(), NORM_PRIORITY);
+
+       /* Initialize the thread attribute object. */
+
+       result = pthread_attr_init(&attr);
+
+       if (result != 0)
+               vm_abort_errnum(result, "threads_impl_init: pthread_attr_init failed");
+
+       result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+       if (result != 0)
+               vm_abort_errnum(result, "threads_impl_init: pthread_attr_setdetachstate failed");
+}
+
+
+/* threads_startup_thread ******************************************************
+
+   Thread startup function called by pthread_create.
+
+   Thread which have a startup.function != NULL are marked as internal
+   threads. All other threads are threated as normal Java threads.
+
+   NOTE: This function is not called directly by pthread_create. The Boehm GC
+         inserts its own GC_start_routine in between, which then calls
+                threads_startup.
+
+   IN:
+      arg..........the argument passed to pthread_create, ie. a pointer to
+                      a startupinfo struct. CAUTION: When the `psem` semaphore
+                                  is posted, the startupinfo struct becomes invalid! (It
+                                  is allocated on the stack of threads_start_thread.)
+
+******************************************************************************/
+
+static void *threads_startup_thread(void *arg)
+{
+       startupinfo  *startup;
+       threadobject *t;
+       sem_t        *psem;
+       classinfo    *c;
+       methodinfo   *m;
+       functionptr   function;
+
+#if defined(ENABLE_GC_BOEHM)
+# if !defined(__DARWIN__)
+       struct GC_stack_base sb;
+       int result;
+# endif
+#endif
+
+#if defined(ENABLE_INTRP)
+       u1 *intrp_thread_stack;
+#endif
+
+#if defined(ENABLE_INTRP)
+       /* create interpreter stack */
+
+       if (opt_intrp) {
+               intrp_thread_stack = GCMNEW(u1, opt_stacksize);
+               MSET(intrp_thread_stack, 0, u1, opt_stacksize);
+       }
+       else
+               intrp_thread_stack = NULL;
+#endif
+
+       /* get passed startupinfo structure and the values in there */
+
+       startup = (startupinfo*) arg;
+
+       t        = startup->thread;
+       function = startup->function;
+       psem     = startup->psem;
+
+       /* Seems like we've encountered a situation where thread->tid was
+          not set by pthread_create. We alleviate this problem by waiting
+          for pthread_create to return. */
+
+       threads_sem_wait(startup->psem_first);
+
+#if defined(__DARWIN__)
+       t->mach_thread = mach_thread_self();
+#endif
+
+       /* Now that we are in the new thread, we can store the internal
+          thread data-structure in the TSD. */
+
+       thread_set_current(t);
+
+#if defined(ENABLE_GC_BOEHM)
+# if defined(__DARWIN__)
+       // This is currently not implemented in Boehm-GC.  Just fail silently.
+# else
+       /* Register the thread with Boehm-GC.  This must happen before the
+          thread allocates any memory from the GC heap.*/
+
+       result = GC_get_stack_base(&sb);
+
+       if (result != 0)
+               vm_abort("threads_startup_thread: GC_get_stack_base failed: result=%d", result);
+
+       GC_register_my_thread(&sb);
+# endif
+#endif
+
+       // Get the java.lang.Thread object for this thread.
+       java_handle_t* object = thread_get_object(t);
+       java_lang_Thread jlt(object);
+
+       /* set our priority */
+
+       threads_set_thread_priority(t->tid, jlt.get_priority());
+
+       /* Thread is completely initialized. */
+
+       thread_set_state_runnable(t);
+
+       /* tell threads_startup_thread that we registered ourselves */
+       /* CAUTION: *startup becomes invalid with this!             */
+
+       startup = NULL;
+       threads_sem_post(psem);
+
+#if defined(ENABLE_INTRP)
+       /* set interpreter stack */
+
+       if (opt_intrp)
+               thread->_global_sp = (Cell *) (intrp_thread_stack + opt_stacksize);
+#endif
+
+#if defined(ENABLE_JVMTI)
+       /* fire thread start event */
+
+       if (jvmti) 
+               jvmti_ThreadStartEnd(JVMTI_EVENT_THREAD_START);
+#endif
+
+       DEBUGTHREADS("starting", t);
+
+       /* find and run the Thread.run()V method if no other function was passed */
+
+       if (function == NULL) {
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+               /* We need to start the run method of
+                  java.lang.VMThread. Since this is a final class, we can use
+                  the class object directly. */
+
+               c = class_java_lang_VMThread;
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+               LLNI_class_get(object, c);
+#else
+# error unknown classpath configuration
+#endif
+
+               m = class_resolveclassmethod(c, utf_run, utf_void__void, c, true);
+
+               if (m == NULL)
+                       vm_abort("threads_startup_thread: run() method not found in class");
+
+               /* set ThreadMXBean variables */
+
+/*             _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++; */
+/*             _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++; */
+
+/*             if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount > */
+/*                     _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount) */
+/*                     _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount = */
+/*                             _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount; */
+#warning Move to C++
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+               // We need to start the run method of java.lang.VMThread.
+               java_lang_VMThread jlvmt(jlt.get_vmThread());
+               java_handle_t* h = jlvmt.get_handle();
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+               java_handle_t* h = jlt.get_handle();
+
+#else
+# error unknown classpath configuration
+#endif
+
+               /* Run the thread. */
+
+               (void) vm_call_method(m, h);
+       }
+       else {
+               /* set ThreadMXBean variables */
+
+/*             _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++; */
+/*             _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++; */
+
+/*             if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount > */
+/*                     _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount) */
+/*                     _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount = */
+/*                             _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount; */
+#warning Move to C++
+
+               /* call passed function, e.g. finalizer_thread */
+
+               (function)();
+       }
+
+       DEBUGTHREADS("stopping", t);
+
+#if defined(ENABLE_JVMTI)
+       /* fire thread end event */
+
+       if (jvmti)
+               jvmti_ThreadStartEnd(JVMTI_EVENT_THREAD_END);
+#endif
+
+       /* We ignore the return value. */
+
+       (void) thread_detach_current_thread();
+
+       /* set ThreadMXBean variables */
+
+/*     _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount--; */
+#warning Move to C++
+
+       return NULL;
+}
+
+
+/* threads_impl_thread_start ***************************************************
+
+   Start a thread in the JVM.  Both (vm internal and java) thread
+   objects exist.
+
+   IN:
+      thread....the thread object
+         f.........function to run in the new thread. NULL means that the
+                   "run" method of the object `t` should be called
+
+******************************************************************************/
+
+void threads_impl_thread_start(threadobject *thread, functionptr f)
+{
+       sem_t          sem;
+       sem_t          sem_first;
+       pthread_attr_t attr;
+       startupinfo    startup;
+       int            result;
+
+       /* fill startupinfo structure passed by pthread_create to
+        * threads_startup_thread */
+
+       startup.thread     = thread;
+       startup.function   = f;              /* maybe we don't call Thread.run()V */
+       startup.psem       = &sem;
+       startup.psem_first = &sem_first;
+
+       threads_sem_init(&sem, 0, 0);
+       threads_sem_init(&sem_first, 0, 0);
+
+       /* Initialize thread attributes. */
+
+       result = pthread_attr_init(&attr);
+
+       if (result != 0)
+               vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_init failed");
+
+    result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+    if (result != 0)
+               vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_setdetachstate failed");
+
+       /* initialize thread stacksize */
+
+       result = pthread_attr_setstacksize(&attr, opt_stacksize);
+
+       if (result != 0)
+               vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_setstacksize failed");
+
+       /* create the thread */
+
+       result = pthread_create(&(thread->tid), &attr, threads_startup_thread, &startup);
+
+       if (result != 0)
+               vm_abort_errnum(result, "threads_impl_thread_start: pthread_create failed");
+
+       /* destroy the thread attributes */
+
+       result = pthread_attr_destroy(&attr);
+
+       if (result != 0)
+               vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_destroy failed");
+
+       /* signal that pthread_create has returned, so thread->tid is valid */
+
+       threads_sem_post(&sem_first);
+
+       /* wait here until the thread has entered itself into the thread list */
+
+       threads_sem_wait(&sem);
+
+       /* cleanup */
+
+       sem_destroy(&sem);
+       sem_destroy(&sem_first);
+}
+
+
+/* threads_set_thread_priority *************************************************
+
+   Set the priority of the given thread.
+
+   IN:
+      tid..........thread id
+         priority.....priority to set
+
+******************************************************************************/
+
+void threads_set_thread_priority(pthread_t tid, int priority)
+{
+       struct sched_param schedp;
+       int policy;
+
+       pthread_getschedparam(tid, &policy, &schedp);
+       schedp.sched_priority = priority;
+       pthread_setschedparam(tid, policy, &schedp);
+}
+
+
+/**
+ * Detaches the current thread from the VM.
+ *
+ * @return true on success, false otherwise
+ */
+bool thread_detach_current_thread(void)
+{
+       threadobject* t = thread_get_current();
+
+       /* Sanity check. */
+
+       assert(t != NULL);
+
+    /* If the given thread has already been detached, this operation
+          is a no-op. */
+
+       if (thread_is_attached(t) == false)
+               return true;
+
+       DEBUGTHREADS("detaching", t);
+
+       java_handle_t* object = thread_get_object(t);
+       java_lang_Thread jlt(object);
+
+#if defined(ENABLE_JAVASE)
+       java_handle_t* group = jlt.get_group();
+
+    /* If there's an uncaught exception, call uncaughtException on the
+       thread's exception handler, or the thread's group if this is
+       unset. */
+
+       java_handle_t* e = exceptions_get_and_clear_exception();
+
+    if (e != NULL) {
+               /* We use the type void* for handler here, as it's not trivial
+                  to build the java_lang_Thread_UncaughtExceptionHandler
+                  header file with cacaoh. */
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+               java_handle_t* handler = jlt.get_exceptionHandler();
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+               java_handle_t* handler = jlt.get_uncaughtExceptionHandler();
+
+# endif
+
+               classinfo*     c;
+               java_handle_t* h;
+
+               if (handler != NULL) {
+                       LLNI_class_get(handler, c);
+                       h = (java_handle_t *) handler;
+               }
+               else {
+                       LLNI_class_get(group, c);
+                       h = (java_handle_t *) group;
+               }
+
+               methodinfo* m = class_resolveclassmethod(c,
+                                                                                                utf_uncaughtException,
+                                                                                                utf_java_lang_Thread_java_lang_Throwable__V,
+                                                                                                NULL,
+                                                                                                true);
+
+               if (m == NULL)
+                       return false;
+
+               (void) vm_call_method(m, h, object, e);
+
+               if (exceptions_get_exception())
+                       return false;
+    }
+
+       /* XXX TWISTI: should all threads be in a ThreadGroup? */
+
+       /* Remove thread from the thread group. */
+
+       if (group != NULL) {
+               classinfo* c;
+               LLNI_class_get(group, c);
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+               methodinfo* m = class_resolveclassmethod(c,
+                                                                                                utf_removeThread,
+                                                                                                utf_java_lang_Thread__V,
+                                                                                                class_java_lang_ThreadGroup,
+                                                                                                true);
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+               methodinfo* m = class_resolveclassmethod(c,
+                                                                                                utf_remove,
+                                                                                                utf_java_lang_Thread__V,
+                                                                                                class_java_lang_ThreadGroup,
+                                                                                                true);
+# else
+#  error unknown classpath configuration
+# endif
+
+               if (m == NULL)
+                       return false;
+
+               (void) vm_call_method(m, group, object);
+
+               if (exceptions_get_exception())
+                       return false;
+
+               // Clear the ThreadGroup in the Java thread object (Mauve
+               // test: gnu/testlet/java/lang/Thread/getThreadGroup).
+               jlt.set_group(NULL);
+       }
+#endif
+
+       /* Thread has terminated. */
+
+       thread_set_state_terminated(t);
+
+       /* Notify all threads waiting on this thread.  These are joining
+          this thread. */
+
+       /* XXX Care about exceptions? */
+       (void) lock_monitor_enter(jlt.get_handle());
+       
+       lock_notify_all_object(jlt.get_handle());
+
+       /* XXX Care about exceptions? */
+       (void) lock_monitor_exit(jlt.get_handle());
+
+       /* Enter the join-mutex before calling thread_free, so
+          threads_join_all_threads gets the correct number of non-daemon
+          threads. */
+
+       threads_mutex_join_lock();
+
+       /* Free the internal thread data-structure. */
+
+       thread_free(t);
+
+       /* Signal that this thread has finished and leave the mutex. */
+
+       cond_join->signal();
+       threads_mutex_join_unlock();
+
+       return true;
+}
+
+
+/* threads_suspend_thread ******************************************************
+
+   Suspend the passed thread. Execution stops until the thread
+   is explicitly resumend again.
+
+   IN:
+     reason.....Reason for suspending this thread.
+
+*******************************************************************************/
+
+bool threads_suspend_thread(threadobject *thread, s4 reason)
+{
+       /* acquire the suspendmutex */
+       thread->suspendmutex->lock();
+
+       if (thread->suspended) {
+               thread->suspendmutex->unlock();
+               return false;
+       }
+
+       /* set the reason for the suspension */
+       thread->suspend_reason = reason;
+
+       /* send the suspend signal to the thread */
+       assert(thread != THREADOBJECT);
+       if (pthread_kill(thread->tid, SIGUSR1) != 0)
+               vm_abort("threads_suspend_thread: pthread_kill failed: %s",
+                                strerror(errno));
+
+       /* REMEMBER: do not release the suspendmutex, this is done
+          by the thread itself in threads_suspend_ack().  */
+
+       return true;
+}
+
+
+/* threads_suspend_ack *********************************************************
+
+   Acknowledges the suspension of the current thread.
+
+   IN:
+     pc.....The PC where the thread suspended its execution.
+     sp.....The SP before the thread suspended its execution.
+
+*******************************************************************************/
+
+#if defined(ENABLE_GC_CACAO)
+void threads_suspend_ack(u1* pc, u1* sp)
+{
+       threadobject *thread;
+
+       thread = THREADOBJECT;
+
+       assert(thread->suspend_reason != 0);
+
+       /* TODO: remember dump memory size */
+
+       /* inform the GC about the suspension */
+       if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD && gc_pending) {
+
+               /* check if the GC wants to leave the thread running */
+               if (!gc_suspend(thread, pc, sp)) {
+
+                       /* REMEMBER: we do not unlock the suspendmutex because the thread
+                          will suspend itself again at a later time */
+                       return;
+
+               }
+       }
+
+       /* mark this thread as suspended and remember the PC */
+       thread->pc        = pc;
+       thread->suspended = true;
+
+       /* if we are stopping the world, we should send a global ack */
+       if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD) {
+               threads_sem_post(&suspend_ack);
+       }
+
+       DEBUGTHREADS("suspending", thread);
+
+       /* release the suspension mutex and wait till we are resumed */
+       thread->suspendcond->wait(thread->suspendmutex);
+
+       DEBUGTHREADS("resuming", thread);
+
+       /* if we are stopping the world, we should send a global ack */
+       if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD) {
+               threads_sem_post(&suspend_ack);
+       }
+
+       /* TODO: free dump memory */
+
+       /* release the suspendmutex */
+       thread->suspendmutex->unlock();
+}
+#endif
+
+
+/* threads_resume_thread *******************************************************
+
+   Resumes the execution of the passed thread.
+
+*******************************************************************************/
+
+#if defined(ENABLE_GC_CACAO)
+bool threads_resume_thread(threadobject *thread)
+{
+       /* acquire the suspendmutex */
+       thread->suspendmutex->lock();
+
+       if (!thread->suspended) {
+               thread->suspendmutex->unlock();
+               return false;
+       }
+
+       thread->suspended = false;
+
+       /* tell everyone that the thread should resume */
+       assert(thread != THREADOBJECT);
+       thread->suspendcond->broadcast();
+
+       /* release the suspendmutex */
+       thread->suspendmutex->unlock();
+
+       return true;
+}
+#endif
+
+
+/* threads_join_all_threads ****************************************************
+
+   Join all non-daemon threads.
+
+*******************************************************************************/
+
+void threads_join_all_threads(void)
+{
+       threadobject *t;
+
+       /* get current thread */
+
+       t = THREADOBJECT;
+
+       /* This thread is waiting for all non-daemon threads to exit. */
+
+       thread_set_state_waiting(t);
+
+       /* enter join mutex */
+
+       threads_mutex_join_lock();
+
+       /* Wait for condition as long as we have non-daemon threads.  We
+          compare against 1 because the current (main thread) is also a
+          non-daemon thread. */
+
+       while (ThreadList::get_number_of_non_daemon_threads() > 1)
+               cond_join->wait(mutex_join);
+
+       /* leave join mutex */
+
+       threads_mutex_join_unlock();
+}
+
+
+/* threads_timespec_earlier ****************************************************
+
+   Return true if timespec tv1 is earlier than timespec tv2.
+
+   IN:
+      tv1..........first timespec
+         tv2..........second timespec
+
+   RETURN VALUE:
+      true, if the first timespec is earlier
+
+*******************************************************************************/
+
+static inline bool threads_timespec_earlier(const struct timespec *tv1,
+                                                                                       const struct timespec *tv2)
+{
+       return (tv1->tv_sec < tv2->tv_sec)
+                               ||
+               (tv1->tv_sec == tv2->tv_sec && tv1->tv_nsec < tv2->tv_nsec);
+}
+
+
+/* threads_current_time_is_earlier_than ****************************************
+
+   Check if the current time is earlier than the given timespec.
+
+   IN:
+      tv...........the timespec to compare against
+
+   RETURN VALUE:
+      true, if the current time is earlier
+
+*******************************************************************************/
+
+static bool threads_current_time_is_earlier_than(const struct timespec *tv)
+{
+       struct timeval tvnow;
+       struct timespec tsnow;
+
+       /* get current time */
+
+       if (gettimeofday(&tvnow, NULL) != 0)
+               vm_abort("gettimeofday failed: %s\n", strerror(errno));
+
+       /* convert it to a timespec */
+
+       tsnow.tv_sec = tvnow.tv_sec;
+       tsnow.tv_nsec = tvnow.tv_usec * 1000;
+
+       /* compare current time with the given timespec */
+
+       return threads_timespec_earlier(&tsnow, tv);
+}
+
+
+/* threads_wait_with_timeout ***************************************************
+
+   Wait until the given point in time on a monitor until either
+   we are notified, we are interrupted, or the time is up.
+
+   IN:
+      t............the current thread
+         wakeupTime...absolute (latest) wakeup time
+                          If both tv_sec and tv_nsec are zero, this function
+                                          waits for an unlimited amount of time.
+
+*******************************************************************************/
+
+static void threads_wait_with_timeout(threadobject *t, struct timespec *wakeupTime, bool parking)
+{
+       // Acquire the waitmutex.
+       t->waitmutex->lock();
+
+       /* wait on waitcond */
+
+       if (wakeupTime->tv_sec || wakeupTime->tv_nsec) {
+               /* with timeout */
+               while (!t->interrupted && !(parking ? t->park_permit : t->signaled)
+                          && threads_current_time_is_earlier_than(wakeupTime))
+               {
+                       thread_set_state_timed_waiting(t);
+
+                       t->waitcond->timedwait(t->waitmutex, wakeupTime);
+
+                       thread_set_state_runnable(t);
+               }
+       }
+       else {
+               /* no timeout */
+               while (!t->interrupted && !(parking ? t->park_permit : t->signaled)) {
+                       thread_set_state_waiting(t);
+
+                       t->waitcond->wait(t->waitmutex);
+
+                       thread_set_state_runnable(t);
+               }
+       }
+
+       if (parking)
+               t->park_permit = false;
+
+       // Release the waitmutex.
+       t->waitmutex->unlock();
+}
+
+
+/* threads_wait_with_timeout_relative ******************************************
+
+   Wait for the given maximum amount of time on a monitor until either
+   we are notified, we are interrupted, or the time is up.
+
+   IN:
+      t............the current thread
+         millis.......milliseconds to wait
+         nanos........nanoseconds to wait
+
+*******************************************************************************/
+
+void threads_wait_with_timeout_relative(threadobject *thread, s8 millis,
+                                                                               s4 nanos)
+{
+       struct timespec wakeupTime;
+
+       /* calculate the the (latest) wakeup time */
+
+       threads_calc_absolute_time(&wakeupTime, millis, nanos);
+
+       /* wait */
+
+       threads_wait_with_timeout(thread, &wakeupTime, false);
+}
+
+
+/* threads_calc_absolute_time **************************************************
+
+   Calculate the absolute point in time a given number of ms and ns from now.
+
+   IN:
+      millis............milliseconds from now
+         nanos.............nanoseconds from now
+
+   OUT:
+      *tm...............receives the timespec of the absolute point in time
+
+*******************************************************************************/
+
+static void threads_calc_absolute_time(struct timespec *tm, s8 millis, s4 nanos)
+{
+       if ((millis != 0x7fffffffffffffffLLU) && (millis || nanos)) {
+               struct timeval tv;
+               long nsec;
+               gettimeofday(&tv, NULL);
+               tv.tv_sec += millis / 1000;
+               millis %= 1000;
+               nsec = tv.tv_usec * 1000 + (s4) millis * 1000000 + nanos;
+               tm->tv_sec = tv.tv_sec + nsec / 1000000000;
+               tm->tv_nsec = nsec % 1000000000;
+       }
+       else {
+               tm->tv_sec = 0;
+               tm->tv_nsec = 0;
+       }
+}
+
+
+/* threads_thread_interrupt ****************************************************
+
+   Interrupt the given thread.
+
+   The thread gets the "waitcond" signal and 
+   its interrupted flag is set to true.
+
+   IN:
+      thread............the thread to interrupt
+
+*******************************************************************************/
+
+void threads_thread_interrupt(threadobject *t)
+{
+       /* Signal the thread a "waitcond" and tell it that it has been
+          interrupted. */
+
+       t->waitmutex->lock();
+
+       DEBUGTHREADS("interrupted", t);
+
+       /* Interrupt blocking system call using a signal. */
+
+       pthread_kill(t->tid, Signal_INTERRUPT_SYSTEM_CALL);
+
+       t->waitcond->signal();
+
+       t->interrupted = true;
+
+       t->waitmutex->unlock();
+}
+
+
+/**
+ * Sleep the current thread for the specified amount of time.
+ *
+ * @param millis Milliseconds to sleep.
+ * @param nanos  Nanoseconds to sleep.
+ */
+void threads_sleep(int64_t millis, int32_t nanos)
+{
+       threadobject    *t;
+       struct timespec  wakeupTime;
+       bool             interrupted;
+
+       if (millis < 0) {
+/*             exceptions_throw_illegalargumentexception("timeout value is negative"); */
+               exceptions_throw_illegalargumentexception();
+               return;
+       }
+
+       t = thread_get_current();
+
+       if (thread_is_interrupted(t) && !exceptions_get_exception()) {
+               /* Clear interrupted flag (Mauve test:
+                  gnu/testlet/java/lang/Thread/interrupt). */
+
+               thread_set_interrupted(t, false);
+
+/*             exceptions_throw_interruptedexception("sleep interrupted"); */
+               exceptions_throw_interruptedexception();
+               return;
+       }
+
+       // (Note taken from classpath/vm/reference/java/lang/VMThread.java (sleep))
+       // Note: JDK treats a zero length sleep is like Thread.yield(),
+       // without checking the interrupted status of the thread.  It's
+       // unclear if this is a bug in the implementation or the spec.
+       // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203 */
+       if (millis == 0 && nanos == 0) {
+               threads_yield();
+       }
+       else {
+               threads_calc_absolute_time(&wakeupTime, millis, nanos);
+
+               threads_wait_with_timeout(t, &wakeupTime, false);
+
+               interrupted = thread_is_interrupted(t);
+
+               if (interrupted) {
+                       thread_set_interrupted(t, false);
+
+                       // An other exception could have been thrown
+                       // (e.g. ThreadDeathException).
+                       if (!exceptions_get_exception())
+                               exceptions_throw_interruptedexception();
+               }
+       }
+}
+
+/**
+ * Park the current thread for the specified amount of time or until a
+ * specified deadline.
+ *
+ * @param absolute Is the time in nanos a deadline or a duration?
+ * @param nanos    Nanoseconds to park (absolute=false)
+ *                 or deadline in milliseconds (absolute=true)
+ */
+void threads_park(bool absolute, int64_t nanos)
+{
+       threadobject    *t;
+       struct timespec  wakeupTime;
+
+       t = thread_get_current();
+
+       if (absolute) {
+               wakeupTime.tv_nsec = 0;
+               wakeupTime.tv_sec = nanos / 1000; /* milliseconds */
+       }
+       else
+               threads_calc_absolute_time(&wakeupTime, nanos / 1000000, nanos % 1000000);
+
+       threads_wait_with_timeout(t, &wakeupTime, true);
+}
+
+/**
+ * Unpark the specified thread.
+ *
+ * @param t The thread to unpark.
+ */
+void threads_unpark(threadobject *t)
+{
+       t->waitmutex->lock();
+
+       t->waitcond->signal();
+
+       t->park_permit = true;
+
+       t->waitmutex->unlock();
+}
+
+
+/* threads_yield ***************************************************************
+
+   Yield to the scheduler.
+
+*******************************************************************************/
+
+void threads_yield(void)
+{
+       sched_yield();
+}
+
+#if defined(ENABLE_TLH)
+
+void threads_tlh_add_frame() {
+       tlh_add_frame(&(THREADOBJECT->tlh));
+}
+
+void threads_tlh_remove_frame() {
+       tlh_remove_frame(&(THREADOBJECT->tlh));
+}
+
+#endif
+
+
+/*
+ * 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/threads/posix/thread-posix.h b/src/threads/posix/thread-posix.h
deleted file mode 100644 (file)
index 58f7d84..0000000
+++ /dev/null
@@ -1,305 +0,0 @@
-/* src/threads/posix/thread-posix.h - POSIX thread 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.
-
-*/
-
-
-#ifndef _THREAD_POSIX_H
-#define _THREAD_POSIX_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct threadobject threadobject;
-
-
-#include "config.h"
-
-#include <pthread.h>
-#include <ucontext.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/localref.h"
-
-#include "threads/mutex.h"
-
-#include "threads/posix/lock.h"
-
-#include "vm/global.h"
-#include "vm/vm.h"
-
-#if defined(ENABLE_GC_CACAO)
-# include "vm/jit/replace.h"
-#endif
-
-#include "vm/jit/stacktrace.h"
-
-#if defined(ENABLE_INTRP)
-#include "vm/jit/intrp/intrp.h"
-#endif
-
-#if defined(__DARWIN__)
-# include <mach/mach.h>
-
-typedef struct {
-       mutex_t mutex;
-       pthread_cond_t cond;
-       int value;
-} sem_t;
-
-#else
-# include <semaphore.h>
-#endif
-
-
-/* current threadobject *******************************************************/
-
-#if defined(HAVE___THREAD)
-
-#define THREADOBJECT      thread_current
-
-extern __thread threadobject *thread_current;
-
-#else /* defined(HAVE___THREAD) */
-
-#define THREADOBJECT \
-       ((threadobject *) pthread_getspecific(thread_current_key))
-
-extern pthread_key_t thread_current_key;
-
-#endif /* defined(HAVE___THREAD) */
-
-
-/* threadobject ****************************************************************
-
-   Struct holding thread local variables.
-
-*******************************************************************************/
-
-#define THREAD_FLAG_JAVA        0x01    /* a normal Java thread               */
-#define THREAD_FLAG_INTERNAL    0x02    /* CACAO internal thread              */
-#define THREAD_FLAG_DAEMON      0x04    /* daemon thread                      */
-#define THREAD_FLAG_IN_NATIVE   0x08    /* currently executing native code    */
-
-#define SUSPEND_REASON_JNI       1      /* suspended from JNI                 */
-#define SUSPEND_REASON_STOPWORLD 2      /* suspended from stop-thw-world      */
-
-
-struct threadobject {
-       java_object_t        *object;       /* link to java.lang.Thread object    */
-
-       ptrint                thinlock;     /* pre-computed thin lock value       */
-
-       s4                    index;        /* thread index, starting with 1      */
-       u4                    flags;        /* flag field                         */
-       u4                    state;        /* state field                        */
-
-       pthread_t             tid;          /* pthread id                         */
-
-#if defined(__DARWIN__)
-       mach_port_t           mach_thread;       /* Darwin thread id              */
-#endif
-
-       /* for the sable tasuki lock extension */
-       bool                  flc_bit;
-       struct threadobject  *flc_list;     /* FLC list head for this thread      */
-       struct threadobject  *flc_next;     /* next pointer for FLC list          */
-       java_handle_t        *flc_object;
-       mutex_t               flc_lock;     /* controlling access to these fields */
-       pthread_cond_t        flc_cond;
-
-       /* these are used for the wait/notify implementation                      */
-       mutex_t               waitmutex;
-       pthread_cond_t        waitcond;
-
-       mutex_t               suspendmutex; /* lock before suspending this thread */
-       pthread_cond_t        suspendcond;  /* notify to resume this thread       */
-
-       bool                  interrupted;
-       bool                  signaled;
-       bool                  sleeping;
-
-       bool                  suspended;    /* is this thread suspended?          */
-       s4                    suspend_reason; /* reason for suspending            */
-
-       u1                   *pc;           /* current PC (used for profiling)    */
-
-       java_object_t        *_exceptionptr;     /* current exception             */
-       stackframeinfo_t     *_stackframeinfo;   /* current native stackframeinfo */
-       localref_table       *_localref_table;   /* JNI local references          */
-
-#if defined(ENABLE_INTRP)
-       Cell                 *_global_sp;        /* stack pointer for interpreter */
-#endif
-
-#if defined(ENABLE_GC_CACAO)
-       bool                  gc_critical;  /* indicates a critical section       */
-
-       sourcestate_t        *ss;
-       executionstate_t     *es;
-#endif
-
-       dumpinfo_t            dumpinfo;     /* dump memory info structure         */
-
-#if defined(ENABLE_DEBUG_FILTER)
-       u2                    filterverbosecallctr[2]; /* counters for verbose call filter */
-#endif
-
-#if !defined(NDEBUG)
-       s4                    tracejavacallindent;
-       u4                    tracejavacallcount;
-#endif
-
-       listnode_t            linkage;      /* threads-list                       */
-       listnode_t            linkage_free; /* free-list                          */
-};
-
-
-/* native-world flags *********************************************************/
-
-#if defined(ENABLE_GC_CACAO)
-# define THREAD_NATIVEWORLD_ENTER THREADOBJECT->flags |=  THREAD_FLAG_IN_NATIVE
-# define THREAD_NATIVEWORLD_EXIT  THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE
-#else
-# define THREAD_NATIVEWORLD_ENTER /*nop*/
-# define THREAD_NATIVEWORLD_EXIT  /*nop*/
-#endif
-
-
-/* counter for verbose call filter ********************************************/
-
-#if defined(ENABLE_DEBUG_FILTER)
-#      define FILTERVERBOSECALLCTR (THREADOBJECT->filterverbosecallctr)
-#endif
-
-/* state for trace java call **************************************************/
-
-#if !defined(NDEBUG)
-#      define TRACEJAVACALLINDENT (THREADOBJECT->tracejavacallindent)
-#      define TRACEJAVACALLCOUNT (THREADOBJECT->tracejavacallcount)
-#endif
-
-
-/* inline functions ***********************************************************/
-
-/* thread_get_current **********************************************************
-
-   Return the threadobject of the current thread.
-   
-   RETURN:
-       the current threadobject *
-
-*******************************************************************************/
-
-inline static threadobject *thread_get_current(void)
-{
-       threadobject *t;
-
-#if defined(HAVE___THREAD)
-       t = thread_current;
-#else
-       t = (threadobject *) pthread_getspecific(thread_current_key);
-#endif
-
-       return t;
-}
-
-
-/* thread_set_current **********************************************************
-
-   Set the current thread object.
-   
-   IN:
-      t ... the thread object to set
-
-*******************************************************************************/
-
-inline static void thread_set_current(threadobject *t)
-{
-#if defined(HAVE___THREAD)
-       thread_current = t;
-#else
-       int result;
-
-       result = pthread_setspecific(thread_current_key, t);
-
-       if (result != 0)
-               vm_abort_errnum(result, "thread_set_current: pthread_setspecific failed");
-#endif
-}
-
-
-inline static stackframeinfo_t *threads_get_current_stackframeinfo(void)
-{
-       return THREADOBJECT->_stackframeinfo;
-}
-
-inline static void threads_set_current_stackframeinfo(stackframeinfo_t *sfi)
-{
-       THREADOBJECT->_stackframeinfo = sfi;
-}
-
-
-/* functions ******************************************************************/
-
-void threads_sem_init(sem_t *sem, bool shared, int value);
-void threads_sem_wait(sem_t *sem);
-void threads_sem_post(sem_t *sem);
-
-void threads_start_thread(threadobject *thread, functionptr function);
-
-void threads_set_thread_priority(pthread_t tid, int priority);
-
-bool threads_detach_thread(threadobject *thread);
-
-#if defined(ENABLE_GC_CACAO)
-bool threads_suspend_thread(threadobject *thread, s4 reason);
-void threads_suspend_ack(u1* pc, u1* sp);
-bool threads_resume_thread(threadobject *thread);
-#endif
-
-void threads_join_all_threads(void);
-
-void threads_sleep(int64_t millis, int32_t nanos);
-
-void threads_wait_with_timeout_relative(threadobject *t, s8 millis, s4 nanos);
-
-void threads_thread_interrupt(threadobject *thread);
-
-#endif /* _THREAD_POSIX_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/threads/posix/thread-posix.hpp b/src/threads/posix/thread-posix.hpp
new file mode 100644 (file)
index 0000000..76892b7
--- /dev/null
@@ -0,0 +1,336 @@
+/* src/threads/posix/thread-posix.hpp - POSIX thread 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.
+
+*/
+
+
+#ifndef _THREAD_POSIX_HPP
+#define _THREAD_POSIX_HPP
+
+#include "config.h"
+
+#include <pthread.h>
+#include <ucontext.h>
+
+#include "vm/types.h"
+
+
+// Includes required by Thread.
+
+#if defined(ENABLE_TLH)
+# include "mm/tlh.h"
+#endif
+
+#include "threads/condition.hpp"
+#include "threads/mutex.hpp"
+
+#include "vm/global.h"
+
+
+/* threadobject ****************************************************************
+
+   Struct holding thread local variables.
+
+*******************************************************************************/
+
+#define THREAD_FLAG_JAVA        0x01    /* a normal Java thread               */
+#define THREAD_FLAG_INTERNAL    0x02    /* CACAO internal thread              */
+#define THREAD_FLAG_DAEMON      0x04    /* daemon thread                      */
+#define THREAD_FLAG_IN_NATIVE   0x08    /* currently executing native code    */
+
+#define SUSPEND_REASON_JNI       1      /* suspended from JNI                 */
+#define SUSPEND_REASON_STOPWORLD 2      /* suspended from stop-thw-world      */
+
+
+typedef struct threadobject threadobject;
+
+struct threadobject {
+       java_object_t        *object;       /* link to java.lang.Thread object    */
+
+       ptrint                thinlock;     /* pre-computed thin lock value       */
+
+       s4                    index;        /* thread index, starting with 1      */
+       u4                    flags;        /* flag field                         */
+       u4                    state;        /* state field                        */
+
+       pthread_t             tid;          /* pthread id                         */
+
+#if defined(__DARWIN__)
+       mach_port_t           mach_thread;       /* Darwin thread id              */
+#endif
+
+       /* for the sable tasuki lock extension */
+       bool                  flc_bit;
+       struct threadobject  *flc_list;     /* FLC list head for this thread      */
+       struct threadobject  *flc_tail;     /* tail pointer for FLC list          */
+       struct threadobject  *flc_next;     /* next pointer for FLC list          */
+       java_handle_t        *flc_object;
+       Mutex*                flc_lock;     /* controlling access to these fields */
+       Condition*            flc_cond;
+
+       /* these are used for the wait/notify implementation                      */
+       Mutex*                waitmutex;
+       Condition*            waitcond;
+
+       Mutex*                suspendmutex; /* lock before suspending this thread */
+       Condition*            suspendcond;  /* notify to resume this thread       */
+
+       bool                  interrupted;
+       bool                  signaled;
+       bool                  park_permit;
+
+       bool                  suspended;    /* is this thread suspended?          */
+       s4                    suspend_reason; /* reason for suspending            */
+
+       u1                   *pc;           /* current PC (used for profiling)    */
+
+       java_object_t        *_exceptionptr;     /* current exception             */
+       struct stackframeinfo_t     *_stackframeinfo;   /* current native stackframeinfo */
+       struct localref_table       *_localref_table;   /* JNI local references          */
+
+#if defined(ENABLE_INTRP)
+       Cell                 *_global_sp;        /* stack pointer for interpreter */
+#endif
+
+#if defined(ENABLE_GC_CACAO)
+       bool                  gc_critical;  /* indicates a critical section       */
+
+       sourcestate_t        *ss;
+       executionstate_t     *es;
+#endif
+
+       struct DumpMemory*    _dumpmemory;     ///< Dump memory structure.
+
+#if defined(ENABLE_DEBUG_FILTER)
+       u2                    filterverbosecallctr[2]; /* counters for verbose call filter */
+#endif
+
+#if !defined(NDEBUG)
+       s4                    tracejavacallindent;
+       u4                    tracejavacallcount;
+#endif
+
+#if defined(ENABLE_TLH)
+       tlh_t                 tlh;
+#endif
+
+#if defined(ENABLE_ESCAPE_REASON)
+       void *escape_reasons;
+#endif
+};
+
+
+/* current threadobject *******************************************************/
+
+#if defined(HAVE___THREAD)
+
+#define THREADOBJECT      thread_current
+
+extern __thread threadobject *thread_current;
+
+#else /* defined(HAVE___THREAD) */
+
+#define THREADOBJECT \
+       ((threadobject *) pthread_getspecific(thread_current_key))
+
+extern pthread_key_t thread_current_key;
+
+#endif /* defined(HAVE___THREAD) */
+
+
+/* native-world flags *********************************************************/
+
+#if defined(ENABLE_GC_CACAO)
+# define THREAD_NATIVEWORLD_ENTER THREADOBJECT->flags |=  THREAD_FLAG_IN_NATIVE
+# define THREAD_NATIVEWORLD_EXIT  THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE
+#else
+# define THREAD_NATIVEWORLD_ENTER /*nop*/
+# define THREAD_NATIVEWORLD_EXIT  /*nop*/
+#endif
+
+
+/* counter for verbose call filter ********************************************/
+
+#if defined(ENABLE_DEBUG_FILTER)
+#      define FILTERVERBOSECALLCTR (THREADOBJECT->filterverbosecallctr)
+#endif
+
+/* state for trace java call **************************************************/
+
+#if !defined(NDEBUG)
+#      define TRACEJAVACALLINDENT (THREADOBJECT->tracejavacallindent)
+#      define TRACEJAVACALLCOUNT (THREADOBJECT->tracejavacallcount)
+#endif
+
+
+// FIXME
+#ifdef __cplusplus
+extern "C" {
+#endif
+inline static threadobject* thread_get_current(void);
+#ifdef __cplusplus
+}
+#endif
+
+
+// Includes.
+#include "mm/memory.h"
+
+#include "native/localref.hpp"
+
+#include "threads/lock.hpp"
+
+#include "vm/global.h"
+#include "vm/vm.hpp"
+
+#if defined(ENABLE_GC_CACAO)
+# include "vm/jit/executionstate.h"
+# include "vm/jit/replace.hpp"
+#endif
+
+#if defined(ENABLE_INTRP)
+#include "vm/jit/intrp/intrp.h"
+#endif
+
+#if defined(__DARWIN__)
+# include <mach/mach.h>
+
+typedef struct {
+       Mutex* mutex;
+       Condition* cond;
+       int value;
+} sem_t;
+
+#else
+# include <semaphore.h>
+#endif
+
+
+// FIXME
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* inline functions ***********************************************************/
+
+/**
+ * Return the Thread object of the current thread.
+ *
+ * @return The current Thread object.
+ */
+inline static threadobject* thread_get_current(void)
+{
+       threadobject *t;
+
+#if defined(HAVE___THREAD)
+       t = thread_current;
+#else
+       t = (threadobject *) pthread_getspecific(thread_current_key);
+#endif
+
+       return t;
+}
+
+
+/**
+ * Set the current Thread object.
+ *
+ * @param t The thread object to set.
+ */
+inline static void thread_set_current(threadobject* t)
+{
+#if defined(HAVE___THREAD)
+       thread_current = t;
+#else
+       int result;
+
+       result = pthread_setspecific(thread_current_key, t);
+
+       if (result != 0)
+               vm_abort_errnum(result, "thread_set_current: pthread_setspecific failed");
+#endif
+}
+
+
+inline static struct stackframeinfo_t* threads_get_current_stackframeinfo(void)
+{
+       return THREADOBJECT->_stackframeinfo;
+}
+
+inline static void threads_set_current_stackframeinfo(struct stackframeinfo_t* sfi)
+{
+       THREADOBJECT->_stackframeinfo = sfi;
+}
+
+
+/* functions ******************************************************************/
+
+void threads_sem_init(sem_t *sem, bool shared, int value);
+void threads_sem_wait(sem_t *sem);
+void threads_sem_post(sem_t *sem);
+
+void threads_start_thread(threadobject *thread, functionptr function);
+
+void threads_set_thread_priority(pthread_t tid, int priority);
+
+#if defined(ENABLE_GC_CACAO)
+bool threads_suspend_thread(threadobject *thread, s4 reason);
+void threads_suspend_ack(u1* pc, u1* sp);
+bool threads_resume_thread(threadobject *thread);
+#endif
+
+void threads_join_all_threads(void);
+
+void threads_sleep(int64_t millis, int32_t nanos);
+
+void threads_wait_with_timeout_relative(threadobject *t, s8 millis, s4 nanos);
+
+void threads_thread_interrupt(threadobject *thread);
+
+void threads_park(bool absolute, int64_t nanos);
+void threads_unpark(threadobject *thread);
+
+#if defined(ENABLE_TLH)
+void threads_tlh_add_frame();
+void threads_tlh_remove_frame();
+#endif
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _THREAD_POSIX_HPP
+
+
+/*
+ * 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/threads/removeme.cpp b/src/threads/removeme.cpp
new file mode 100644 (file)
index 0000000..60878ce
--- /dev/null
@@ -0,0 +1,61 @@
+/* src/threads/removeme.cpp
+
+   Copyright (C) 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.
+
+*/
+
+// XXX Remove me as soon as all using files have been converted to C++!
+
+#include "config.h"
+
+#include "threads/condition.hpp"
+#include "threads/mutex.hpp"
+
+extern "C" {
+
+Mutex* Mutex_new() { return new Mutex(); }
+void Mutex_delete(Mutex* mutex) { delete mutex; }
+void Mutex_lock(Mutex* mutex) { mutex->lock(); }
+void Mutex_unlock(Mutex* mutex) { mutex->unlock(); }
+
+Condition* Condition_new() { return new Condition(); }
+void Condition_delete(Condition* cond) { delete cond; }
+void Condition_broadcast(Condition* cond) { cond->broadcast(); }
+void Condition_signal(Condition* cond) { cond->signal(); }
+void Condition_timedwait(Condition* cond, Mutex* mutex, const struct timespec* abstime) { cond->timedwait(mutex, abstime); }
+void Condition_wait(Condition* cond, Mutex* mutex) { cond->wait(mutex); }
+
+}
+
+
+/*
+ * 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/threads/thread.c b/src/threads/thread.c
deleted file mode 100644 (file)
index aa0609a..0000000
+++ /dev/null
@@ -1,1224 +0,0 @@
-/* src/threads/thread.c - machine independent thread functions
-
-   Copyright (C) 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 <stdint.h>
-#include <unistd.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Thread.h"
-
-#if defined(ENABLE_JAVASE)
-# include "native/include/java_lang_ThreadGroup.h"
-#endif
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/java_lang_VMThread.h"
-#endif
-
-#include "threads/critical.h"
-#include "threads/lock-common.h"
-#include "threads/threadlist.h"
-#include "threads/thread.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
-#include "vmcore/utf8.h"
-
-
-/* global variables ***********************************************************/
-
-static methodinfo    *thread_method_init;
-static java_handle_t *threadgroup_system;
-static java_handle_t *threadgroup_main;
-
-#if defined(__LINUX__)
-/* XXX Remove for exact-GC. */
-bool threads_pthreads_implementation_nptl;
-#endif
-
-
-/* static functions ***********************************************************/
-
-static void          thread_create_initial_threadgroups(void);
-static void          thread_create_initial_thread(void);
-static threadobject *thread_new(void);
-
-
-/* threads_preinit *************************************************************
-
-   Do some early initialization of stuff required.
-
-*******************************************************************************/
-
-void threads_preinit(void)
-{
-       threadobject *mainthread;
-#if defined(__LINUX__) && defined(_CS_GNU_LIBPTHREAD_VERSION)
-       char         *pathbuf;
-       size_t        len;
-#endif
-
-       TRACESUBSYSTEMINITIALIZATION("threads_preinit");
-
-#if defined(__LINUX__)
-       /* XXX Remove for exact-GC. */
-
-       /* On Linux we need to check the pthread implementation. */
-
-       /* _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2) */
-       /* If the glibc is a pre-2.3.2 version, we fall back to
-          linuxthreads. */
-
-# if defined(_CS_GNU_LIBPTHREAD_VERSION)
-       len = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0);
-
-       /* Some systems return as length 0 (maybe cross-compilation
-          related).  In this case we also fall back to linuxthreads. */
-
-       if (len > 0) {
-               pathbuf = MNEW(char, len);
-
-               (void) confstr(_CS_GNU_LIBPTHREAD_VERSION, pathbuf, len);
-
-               if (strstr(pathbuf, "NPTL") != NULL)
-                       threads_pthreads_implementation_nptl = true;
-               else
-                       threads_pthreads_implementation_nptl = false;
-       }
-       else
-               threads_pthreads_implementation_nptl = false;
-# else
-       threads_pthreads_implementation_nptl = false;
-# endif
-#endif
-
-       /* Initialize the threads implementation (sets the thinlock on the
-          main thread). */
-
-       threads_impl_preinit();
-
-       /* Create internal thread data-structure for the main thread. */
-
-       mainthread = thread_new();
-
-       /* The main thread should always have index 1. */
-
-       if (mainthread->index != 1)
-               vm_abort("threads_preinit: main thread index not 1: %d != 1",
-                                mainthread->index);
-
-       /* thread is a Java thread and running */
-
-       mainthread->flags |= THREAD_FLAG_JAVA;
-       mainthread->state = THREAD_STATE_RUNNABLE;
-
-       /* Store the internal thread data-structure in the TSD. */
-
-       thread_set_current(mainthread);
-}
-
-
-/* threads_init ****************************************************************
-
-   Initialize the main thread.
-
-*******************************************************************************/
-
-void threads_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("threads_init");
-
-       /* Create the system and main thread groups. */
-
-       thread_create_initial_threadgroups();
-
-       /* Cache the java.lang.Thread initialization method. */
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       thread_method_init =
-               class_resolveclassmethod(class_java_lang_Thread,
-                                                                utf_init,
-                                                                utf_new_char("(Ljava/lang/VMThread;Ljava/lang/String;IZ)V"),
-                                                                class_java_lang_Thread,
-                                                                true);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       thread_method_init =
-               class_resolveclassmethod(class_java_lang_Thread,
-                                                                utf_init,
-                                                                utf_new_char("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V"),
-                                                                class_java_lang_Thread,
-                                                                true);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-
-       thread_method_init =
-               class_resolveclassmethod(class_java_lang_Thread,
-                                                                utf_init,
-                                                                utf_java_lang_String__void,
-                                                                class_java_lang_Thread,
-                                                                true);
-
-#else
-# error unknown classpath configuration
-#endif
-
-       if (thread_method_init == NULL)
-               vm_abort("threads_init: failed to resolve thread init method");
-
-       thread_create_initial_thread();
-}
-
-
-/* thread_create_object ********************************************************
-
-   Create a Java thread object for the given thread data-structure,
-   initializes it and adds the thread to the threadgroup.
-
-   ARGUMENTS:
-
-       t ....... thread
-       name .... thread name
-       group ... threadgroup
-
-   RETURN:
-
-*******************************************************************************/
-
-static bool thread_create_object(threadobject *t, java_handle_t *name, java_handle_t *group)
-{
-       java_handle_t    *o;
-       java_lang_Thread *to;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_VMThread    *vmto;
-       classinfo             *c;
-       methodinfo            *m;
-       bool                   isdaemon;
-#endif
-
-       /* Create a java.lang.Thread Java object. */
-
-       o = builtin_new(class_java_lang_Thread);
-
-       if (o == NULL)
-               return false;
-
-       to = (java_lang_Thread *) o;
-
-       /* Set the Java object in the thread data-structure.  This
-          indicates that the thread is attached to the VM. */
-
-       thread_set_object(t, (java_handle_t *) to);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       /* Create a java.lang.VMThread Java object. */
-
-       vmto = (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
-
-       if (vmto == NULL)
-               return false;
-
-       /* Set the Java thread object in the Java VM-thread object. */
-
-       LLNI_field_set_ref(vmto, thread, to);
-
-       /* Set the thread data-structure in the Java VM-thread object. */
-
-       LLNI_field_set_val(vmto, vmdata, (java_lang_Object *) t);
-
-       /* Call:
-          java.lang.Thread.<init>(Ljava/lang/VMThread;Ljava/lang/String;IZ)V */
-
-       isdaemon = thread_is_daemon(t);
-
-       (void) vm_call_method(thread_method_init, o, vmto, name, NORM_PRIORITY,
-                                                 isdaemon);
-
-       if (exceptions_get_exception())
-               return false;
-
-       /* Set the threadgroup in the Java thread object. */
-
-       LLNI_field_set_ref(to, group, (java_lang_ThreadGroup *) group);
-
-       /* Add thread to the threadgroup. */
-
-       LLNI_class_get(group, c);
-
-       m = class_resolveclassmethod(c,
-                                                                utf_addThread,
-                                                                utf_java_lang_Thread__V,
-                                                                class_java_lang_ThreadGroup,
-                                                                true);
-
-       if (m == NULL)
-               return false;
-
-       (void) vm_call_method(m, group, to);
-
-       if (exceptions_get_exception())
-               return false;
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       /* OpenJDK's java.lang.Thread does not have a VMThread field in
-          the class.  Nothing to do here. */
-
-       /* Set the priority.  java.lang.Thread.<init> requires it because
-          it sets the priority of the current thread to the parent's one
-          (which is the current thread in this case). */
-
-       LLNI_field_set_val(to, priority, NORM_PRIORITY);
-
-       /* Call:
-          java.lang.Thread.<init>(Ljava/lang/ThreadGroup;Ljava/lang/String;)V */
-
-       (void) vm_call_method(thread_method_init, o, group, name);
-
-       if (exceptions_get_exception())
-               return false;
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-
-       /* Set the thread data-structure in the Java thread object. */
-
-       LLNI_field_set_val(to, vm_thread, (java_lang_Object *) t);
-
-       /* Call: public Thread(Ljava/lang/String;)V */
-
-       (void) vm_call_method(thread_method_init, o, name);
-
-       if (exceptions_get_exception())
-               return false;
-
-#else
-# error unknown classpath configuration
-#endif
-
-       return true;
-}
-
-
-/* thread_create_initial_threadgroups ******************************************
-
-   Create the initial threadgroups.
-
-   GNU Classpath:
-       Create the main threadgroup only and set the system
-       threadgroup to the main threadgroup.
-
-   SUN:
-       Create the system and main threadgroup.
-
-   CLDC:
-       This function is a no-op.
-
-*******************************************************************************/
-
-static void thread_create_initial_threadgroups(void)
-{
-#if defined(ENABLE_JAVASE)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       /* Allocate and initialize the main thread group. */
-
-       threadgroup_main = native_new_and_init(class_java_lang_ThreadGroup);
-
-       if (threadgroup_main == NULL)
-               vm_abort("thread_create_initial_threadgroups: failed to allocate main threadgroup");
-
-       /* Use the same threadgroup for system as for main. */
-
-       threadgroup_system = threadgroup_main;
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       java_handle_t *name;
-       methodinfo    *m;
-
-       /* Allocate and initialize the system thread group. */
-
-       threadgroup_system = native_new_and_init(class_java_lang_ThreadGroup);
-
-       if (threadgroup_system == NULL)
-               vm_abort("thread_create_initial_threadgroups: failed to allocate system threadgroup");
-
-       /* Allocate and initialize the main thread group. */
-
-       threadgroup_main = builtin_new(class_java_lang_ThreadGroup);
-
-       if (threadgroup_main == NULL)
-               vm_abort("thread_create_initial_threadgroups: failed to allocate main threadgroup");
-
-       name = javastring_new(utf_main);
-
-       m = class_resolveclassmethod(class_java_lang_ThreadGroup,
-                                                                utf_init,
-                                                                utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V,
-                                                                class_java_lang_ThreadGroup,
-                                                                true);
-
-       if (m == NULL)
-               vm_abort("thread_create_initial_threadgroups: failed to resolve threadgroup init method");
-
-       (void) vm_call_method(m, threadgroup_main, threadgroup_system, name);
-
-       if (exceptions_get_exception())
-               vm_abort("thread_create_initial_threadgroups: exception while initializing main threadgroup");
-
-# else
-#  error unknown classpath configuration
-# endif
-#endif
-}
-
-
-/* thread_create_initial_thread ***********************************************
-
-   Create the initial thread: main
-
-*******************************************************************************/
-
-static void thread_create_initial_thread(void)
-{
-       threadobject  *t;
-       java_handle_t *name;
-
-       /* Get the main-thread (NOTE: The main thread is always the first
-          thread in the list). */
-
-       t = threadlist_first();
-
-       /* The thread name. */
-
-       name = javastring_new(utf_main);
-
-#if defined(ENABLE_INTRP)
-       /* create interpreter stack */
-
-       if (opt_intrp) {
-               MSET(intrp_main_stack, 0, u1, opt_stacksize);
-               mainthread->_global_sp = (Cell*) (intrp_main_stack + opt_stacksize);
-       }
-#endif
-
-       /* Create the Java thread object. */
-
-       if (!thread_create_object(t, name, threadgroup_main))
-               vm_abort("thread_create_initial_thread: failed to create Java object");
-
-       /* Initialize the implementation specific bits. */
-
-       threads_impl_init();
-
-       DEBUGTHREADS("starting (main)", t);
-}
-
-
-/* thread_new ******************************************************************
-
-   Allocates and initializes an internal thread data-structure and
-   adds it to the threads list.
-
-*******************************************************************************/
-
-static threadobject *thread_new(void)
-{
-       int32_t       index;
-       threadobject *t;
-       
-       /* Lock the thread lists */
-
-       threadlist_lock();
-
-       index = threadlist_get_free_index();
-
-       /* Allocate a thread data structure. */
-
-       /* First, try to get one from the free-list. */
-
-       t = threadlist_free_first();
-
-       if (t != NULL) {
-               /* Remove from free list. */
-
-               threadlist_free_remove(t);
-
-               /* Equivalent of MZERO on the else path */
-
-               threads_impl_thread_clear(t);
-       }
-       else {
-#if defined(ENABLE_GC_BOEHM)
-               t = GCNEW_UNCOLLECTABLE(threadobject, 1);
-#else
-               t = NEW(threadobject);
-#endif
-
-#if defined(ENABLE_STATISTICS)
-               if (opt_stat)
-                       size_threadobject += sizeof(threadobject);
-#endif
-
-               /* Clear memory. */
-
-               MZERO(t, threadobject, 1);
-
-#if defined(ENABLE_GC_CACAO)
-               /* Register reference to java.lang.Thread with the GC. */
-               /* FIXME is it ok to do this only once? */
-
-               gc_reference_register(&(t->object), GC_REFTYPE_THREADOBJECT);
-               gc_reference_register(&(t->_exceptionptr), GC_REFTYPE_THREADOBJECT);
-#endif
-
-               /* Initialize the implementation-specific bits. */
-
-               threads_impl_thread_init(t);
-       }
-
-       /* Pre-compute the thinlock-word. */
-
-       assert(index != 0);
-
-       t->index     = index;
-       t->thinlock  = lock_pre_compute_thinlock(t->index);
-       t->flags     = 0;
-       t->state     = THREAD_STATE_NEW;
-
-#if defined(ENABLE_GC_CACAO)
-       t->flags    |= THREAD_FLAG_IN_NATIVE; 
-#endif
-
-       /* Initialize the implementation-specific bits. */
-
-       threads_impl_thread_reuse(t);
-
-       /* Add the thread to the thread list. */
-
-       threadlist_add(t);
-
-       /* Unlock the thread lists. */
-
-       threadlist_unlock();
-
-       return t;
-}
-
-
-/* thread_free *****************************************************************
-
-   Remove the thread from the threads-list and free the internal
-   thread data structure.  The thread index is added to the
-   thread-index free-list.
-
-   IN:
-       t ... thread data structure
-
-*******************************************************************************/
-
-void thread_free(threadobject *t)
-{
-       /* Lock the thread lists. */
-
-       threadlist_lock();
-
-       /* Remove the thread from the thread-list. */
-
-       threadlist_remove(t);
-
-       /* Add the thread index to the free list. */
-
-       threadlist_index_add(t->index);
-
-       /* Set the reference to the Java object to NULL. */
-
-       thread_set_object(t, NULL);
-
-       /* Add the thread data structure to the free list. */
-
-       threadlist_free_add(t);
-
-       /* Unlock the thread lists. */
-
-       threadlist_unlock();
-}
-
-
-/* threads_thread_start_internal ***********************************************
-
-   Start an internal thread in the JVM.  No Java thread objects exists
-   so far.
-
-   IN:
-      name.......UTF-8 name of the thread
-      f..........function pointer to C function to start
-
-*******************************************************************************/
-
-bool threads_thread_start_internal(utf *name, functionptr f)
-{
-       threadobject *t;
-
-       /* Enter the join-mutex, so if the main-thread is currently
-          waiting to join all threads, the number of non-daemon threads
-          is correct. */
-
-       threads_mutex_join_lock();
-
-       /* Create internal thread data-structure. */
-
-       t = thread_new();
-
-       t->flags |= THREAD_FLAG_INTERNAL | THREAD_FLAG_DAEMON;
-
-       /* The thread is flagged as (non-)daemon thread, we can leave the
-          mutex. */
-
-       threads_mutex_join_unlock();
-
-       /* Create the Java thread object. */
-
-       if (!thread_create_object(t, javastring_new(name), threadgroup_system))
-               return false;
-
-       /* Start the thread. */
-
-       threads_impl_thread_start(t, f);
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* threads_thread_start ********************************************************
-
-   Start a Java thread in the JVM.  Only the java thread object exists
-   so far.
-
-   IN:
-      object.....the java thread object java.lang.Thread
-
-*******************************************************************************/
-
-void threads_thread_start(java_handle_t *object)
-{
-       java_lang_Thread   *to;
-       threadobject       *t;
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_VMThread *vmto;
-#endif
-
-       to = (java_lang_Thread *) object;
-
-       /* Enter the join-mutex, so if the main-thread is currently
-          waiting to join all threads, the number of non-daemon threads
-          is correct. */
-
-       threads_mutex_join_lock();
-
-       /* Create internal thread data-structure. */
-
-       t = thread_new();
-
-       /* this is a normal Java thread */
-
-       t->flags |= THREAD_FLAG_JAVA;
-
-#if defined(ENABLE_JAVASE)
-       /* Is this a daemon thread? */
-
-       if (LLNI_field_direct(to, daemon) == true)
-               t->flags |= THREAD_FLAG_DAEMON;
-#endif
-
-       /* The thread is flagged and (non-)daemon thread, we can leave the
-          mutex. */
-
-       threads_mutex_join_unlock();
-
-       /* Link the two objects together. */
-
-       thread_set_object(t, object);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       /* Get the java.lang.VMThread object and do some sanity checks. */
-
-       LLNI_field_get_ref(to, vmThread, vmto);
-
-       assert(vmto);
-       assert(LLNI_field_direct(vmto, vmdata) == NULL);
-
-       LLNI_field_set_val(vmto, vmdata, (java_lang_Object *) t);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       /* Nothing to do. */
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-
-       LLNI_field_set_val(to, vm_thread, (java_lang_Object *) t);
-
-#else
-# error unknown classpath configuration
-#endif
-
-       /* Start the thread.  Don't pass a function pointer (NULL) since
-          we want Thread.run()V here. */
-
-       threads_impl_thread_start(t, NULL);
-}
-
-
-/* threads_attach_current_thread ***********************************************
-
-   Attaches the current thread to the VM.  Used in JNI.
-
-*******************************************************************************/
-
-bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon)
-{
-       bool           result;
-       threadobject  *t;
-       utf           *u;
-       java_handle_t *name;
-       java_handle_t *group;
-
-    /* If the current thread has already been attached, this operation
-          is a no-op. */
-
-       result = thread_current_is_attached();
-
-       if (result == true)
-               return true;
-
-       /* Enter the join-mutex, so if the main-thread is currently
-          waiting to join all threads, the number of non-daemon threads
-          is correct. */
-
-       threads_mutex_join_lock();
-
-       /* Create internal thread data structure. */
-
-       t = thread_new();
-
-       /* Thread is a Java thread and running. */
-
-       t->flags = THREAD_FLAG_JAVA;
-
-       if (isdaemon)
-               t->flags |= THREAD_FLAG_DAEMON;
-
-       /* Store the internal thread data-structure in the TSD. */
-
-       thread_set_current(t);
-
-       /* The thread is flagged and (non-)daemon thread, we can leave the
-          mutex. */
-
-       threads_mutex_join_unlock();
-
-       DEBUGTHREADS("attaching", t);
-
-       /* Get the thread name. */
-
-       if (vm_aargs != NULL) {
-               u = utf_new_char(vm_aargs->name);
-       }
-       else {
-               u = utf_null;
-       }
-
-       name = javastring_new(u);
-
-#if defined(ENABLE_JAVASE)
-       /* Get the threadgroup. */
-
-       if (vm_aargs != NULL)
-               group = (java_handle_t *) vm_aargs->group;
-       else
-               group = NULL;
-
-       /* If no threadgroup was given, use the main threadgroup. */
-
-       if (group == NULL)
-               group = threadgroup_main;
-#endif
-
-#if defined(ENABLE_INTRP)
-       /* create interpreter stack */
-
-       if (opt_intrp) {
-               MSET(intrp_main_stack, 0, u1, opt_stacksize);
-               thread->_global_sp = (Cell *) (intrp_main_stack + opt_stacksize);
-       }
-#endif
-
-       /* Create the Java thread object. */
-
-       if (!thread_create_object(t, name, group))
-               return false;
-
-       /* The thread is completely initialized. */
-
-       thread_set_state_runnable(t);
-
-       return true;
-}
-
-
-/* thread_fprint_name **********************************************************
-
-   Print the name of the given thread to the given stream.
-
-   ARGUMENTS:
-       t ........ thread data-structure
-       stream ... stream to print to
-
-*******************************************************************************/
-
-void thread_fprint_name(threadobject *t, FILE *stream)
-{
-       java_lang_Thread *to;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_String *name;
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-       java_chararray_t *name;
-#endif
-
-       to = (java_lang_Thread *) thread_get_object(t);
-
-       if (to == NULL)
-               vm_abort("");
-
-       LLNI_field_get_ref(to, name, name);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       javastring_fprint((java_handle_t *) name, stream);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-
-       /* FIXME: In OpenJDK and CLDC the name is a char[]. */
-       /* FIXME This prints to stdout. */
-       utf_display_printable_ascii(utf_null);
-
-#else
-# error unknown classpath configuration
-#endif
-}
-
-
-/* thread_print_info ***********************************************************
-
-   Print information of the passed thread.
-
-   ARGUMENTS:
-       t ... thread data-structure.
-
-*******************************************************************************/
-
-void thread_print_info(threadobject *t)
-{
-       java_lang_Thread *to;
-       int               state;
-
-       /* If the thread is currently in initalization, don't print it. */
-
-       to = (java_lang_Thread *) thread_get_object(t);
-
-       /* Print as much as we can when we are in state NEW. */
-
-       if (to != NULL) {
-               /* Print thread name. */
-
-               printf("\"");
-               thread_fprint_name(t, stdout);
-               printf("\"");
-       }
-       else {
-       }
-
-       if (thread_is_daemon(t))
-               printf(" daemon");
-
-       if (to != NULL) {
-               printf(" prio=%d", LLNI_field_direct(to, priority));
-       }
-
-#if SIZEOF_VOID_P == 8
-       printf(" t=0x%016lx tid=0x%016lx (%ld)",
-                  (ptrint) t, (ptrint) t->tid, (ptrint) t->tid);
-#else
-       printf(" t=0x%08x tid=0x%08x (%d)",
-                  (ptrint) t, (ptrint) t->tid, (ptrint) t->tid);
-#endif
-
-       printf(" index=%d", t->index);
-
-       /* Print thread state. */
-
-       state = cacaothread_get_state(t);
-
-       switch (state) {
-       case THREAD_STATE_NEW:
-               printf(" new");
-               break;
-       case THREAD_STATE_RUNNABLE:
-               printf(" runnable");
-               break;
-       case THREAD_STATE_BLOCKED:
-               printf(" blocked");
-               break;
-       case THREAD_STATE_WAITING:
-               printf(" waiting");
-               break;
-       case THREAD_STATE_TIMED_WAITING:
-               printf(" waiting on condition");
-               break;
-       case THREAD_STATE_TERMINATED:
-               printf(" terminated");
-               break;
-       default:
-               vm_abort("thread_print_info: unknown thread state %d", state);
-       }
-}
-
-
-/* threads_get_current_tid *****************************************************
-
-   Return the tid of the current thread.
-   
-   RETURN VALUE:
-       the current tid
-
-*******************************************************************************/
-
-intptr_t threads_get_current_tid(void)
-{
-       threadobject *thread;
-
-       thread = THREADOBJECT;
-
-       /* this may happen during bootstrap */
-
-       if (thread == NULL)
-               return 0;
-
-       return (intptr_t) thread->tid;
-}
-
-
-/* thread_set_state_runnable ***************************************************
-
-   Set the current state of the given thread to THREAD_STATE_RUNNABLE.
-
-   NOTE: If the thread has already terminated, don't set the state.
-         This is important for threads_detach_thread.
-
-*******************************************************************************/
-
-void thread_set_state_runnable(threadobject *t)
-{
-       /* Set the state inside a lock. */
-
-       threadlist_lock();
-
-       if (t->state != THREAD_STATE_TERMINATED) {
-               t->state = THREAD_STATE_RUNNABLE;
-
-               DEBUGTHREADS("is RUNNABLE", t);
-       }
-
-       threadlist_unlock();
-}
-
-
-/* thread_set_state_waiting ****************************************************
-
-   Set the current state of the given thread to THREAD_STATE_WAITING.
-
-   NOTE: If the thread has already terminated, don't set the state.
-         This is important for threads_detach_thread.
-
-*******************************************************************************/
-
-void thread_set_state_waiting(threadobject *t)
-{
-       /* Set the state inside a lock. */
-
-       threadlist_lock();
-
-       if (t->state != THREAD_STATE_TERMINATED) {
-               t->state = THREAD_STATE_WAITING;
-
-               DEBUGTHREADS("is WAITING", t);
-       }
-
-       threadlist_unlock();
-}
-
-
-/* thread_set_state_timed_waiting **********************************************
-
-   Set the current state of the given thread to
-   THREAD_STATE_TIMED_WAITING.
-
-   NOTE: If the thread has already terminated, don't set the state.
-         This is important for threads_detach_thread.
-
-*******************************************************************************/
-
-void thread_set_state_timed_waiting(threadobject *t)
-{
-       /* Set the state inside a lock. */
-
-       threadlist_lock();
-
-       if (t->state != THREAD_STATE_TERMINATED) {
-               t->state = THREAD_STATE_TIMED_WAITING;
-
-               DEBUGTHREADS("is TIMED_WAITING", t);
-       }
-
-       threadlist_unlock();
-}
-
-
-/* thread_set_state_terminated *************************************************
-
-   Set the current state of the given thread to
-   THREAD_STATE_TERMINATED.
-
-*******************************************************************************/
-
-void thread_set_state_terminated(threadobject *t)
-{
-       /* Set the state inside a lock. */
-
-       threadlist_lock();
-
-       t->state = THREAD_STATE_TERMINATED;
-
-       DEBUGTHREADS("is TERMINATED", t);
-
-       threadlist_unlock();
-}
-
-
-/* thread_get_thread **********************************************************
-
-   Return the thread data structure of the given Java thread object.
-
-   ARGUMENTS:
-       h ... java.lang.{VM}Thread object
-
-   RETURN VALUE:
-       the thread object
-
-*******************************************************************************/
-
-threadobject *thread_get_thread(java_handle_t *h)
-{
-       threadobject       *t;
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_VMThread *vmto;
-       java_lang_Object   *to;
-#endif
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       bool                equal;
-#endif
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       vmto = (java_lang_VMThread *) h;
-
-       LLNI_field_get_val(vmto, vmdata, to);
-
-       t = (threadobject *) to;
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       /* XXX This is just a quick hack. */
-
-       threadlist_lock();
-
-       for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
-               LLNI_equals(t->object, h, equal);
-
-               if (equal == true)
-                       break;
-       }
-
-       threadlist_unlock();
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-
-       log_println("threads_get_thread: IMPLEMENT ME!");
-
-#else
-# error unknown classpath configuration
-#endif
-
-       return t;
-}
-
-
-/* threads_thread_is_alive *****************************************************
-
-   Returns if the give thread is alive.
-
-*******************************************************************************/
-
-bool threads_thread_is_alive(threadobject *t)
-{
-       int state;
-
-       state = cacaothread_get_state(t);
-
-       switch (state) {
-       case THREAD_STATE_NEW:
-       case THREAD_STATE_TERMINATED:
-               return false;
-
-       case THREAD_STATE_RUNNABLE:
-       case THREAD_STATE_BLOCKED:
-       case THREAD_STATE_WAITING:
-       case THREAD_STATE_TIMED_WAITING:
-               return true;
-
-       default:
-               vm_abort("threads_thread_is_alive: unknown thread state %d", state);
-       }
-
-       /* keep compiler happy */
-
-       return false;
-}
-
-
-/* threads_dump ****************************************************************
-
-   Dumps info for all threads running in the JVM.  This function is
-   called when SIGQUIT (<ctrl>-\) is sent to CACAO.
-
-*******************************************************************************/
-
-void threads_dump(void)
-{
-       threadobject *t;
-
-       /* XXX we should stop the world here */
-
-       /* Lock the thread lists. */
-
-       threadlist_lock();
-
-       printf("Full thread dump CACAO "VERSION":\n");
-
-       /* iterate over all started threads */
-
-       for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
-               /* ignore threads which are in state NEW */
-               if (t->state == THREAD_STATE_NEW)
-                       continue;
-
-#if defined(ENABLE_GC_CACAO)
-               /* Suspend the thread. */
-               /* XXX Is the suspend reason correct? */
-
-               if (threads_suspend_thread(t, SUSPEND_REASON_JNI) == false)
-                       vm_abort("threads_dump: threads_suspend_thread failed");
-#endif
-
-               /* Print thread info. */
-
-               printf("\n");
-               thread_print_info(t);
-               printf("\n");
-
-               /* Print trace of thread. */
-
-               stacktrace_print_of_thread(t);
-
-#if defined(ENABLE_GC_CACAO)
-               /* Resume the thread. */
-
-               if (threads_resume_thread(t) == false)
-                       vm_abort("threads_dump: threads_resume_thread failed");
-#endif
-       }
-
-       /* Unlock the thread lists. */
-
-       threadlist_unlock();
-}
-
-
-/*
- * 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/threads/thread.cpp b/src/threads/thread.cpp
new file mode 100644 (file)
index 0000000..8804f6e
--- /dev/null
@@ -0,0 +1,1163 @@
+/* src/threads/thread.cpp - machine independent thread functions
+
+   Copyright (C) 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 <stdint.h>
+#include <unistd.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#if defined(ENABLE_GC_BOEHM)
+/* We need to include Boehm's gc.h here for GC_register_my_thread and
+   friends. */
+# include "mm/boehm-gc/include/gc.h"
+#endif
+
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#include "threads/lock.hpp"
+#include "threads/threadlist.hpp"
+#include "threads/thread.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/string.hpp"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#include "vm/jit/stacktrace.hpp"
+
+
+/* global variables ***********************************************************/
+
+static methodinfo    *thread_method_init;
+static java_handle_t *threadgroup_system;
+static java_handle_t *threadgroup_main;
+
+#if defined(__LINUX__)
+/* XXX Remove for exact-GC. */
+bool threads_pthreads_implementation_nptl;
+#endif
+
+
+/* static functions ***********************************************************/
+
+static void          thread_create_initial_threadgroups(void);
+static void          thread_create_initial_thread(void);
+static threadobject *thread_new(void);
+
+
+/* threads_preinit *************************************************************
+
+   Do some early initialization of stuff required.
+
+*******************************************************************************/
+
+void threads_preinit(void)
+{
+       threadobject *mainthread;
+#if defined(__LINUX__) && defined(_CS_GNU_LIBPTHREAD_VERSION)
+       char         *pathbuf;
+       size_t        len;
+#endif
+
+       TRACESUBSYSTEMINITIALIZATION("threads_preinit");
+
+#if defined(__LINUX__)
+       /* XXX Remove for exact-GC. */
+
+       /* On Linux we need to check the pthread implementation. */
+
+       /* _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2) */
+       /* If the glibc is a pre-2.3.2 version, we fall back to
+          linuxthreads. */
+
+# if defined(_CS_GNU_LIBPTHREAD_VERSION)
+       len = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0);
+
+       /* Some systems return as length 0 (maybe cross-compilation
+          related).  In this case we also fall back to linuxthreads. */
+
+       if (len > 0) {
+               pathbuf = MNEW(char, len);
+
+               (void) confstr(_CS_GNU_LIBPTHREAD_VERSION, pathbuf, len);
+
+               if (strstr(pathbuf, "NPTL") != NULL)
+                       threads_pthreads_implementation_nptl = true;
+               else
+                       threads_pthreads_implementation_nptl = false;
+       }
+       else
+               threads_pthreads_implementation_nptl = false;
+# else
+       threads_pthreads_implementation_nptl = false;
+# endif
+#endif
+
+       /* Initialize the threads implementation (sets the thinlock on the
+          main thread). */
+
+       threads_impl_preinit();
+
+       /* Create internal thread data-structure for the main thread. */
+
+       mainthread = thread_new();
+
+       /* The main thread should always have index 1. */
+
+       if (mainthread->index != 1)
+               vm_abort("threads_preinit: main thread index not 1: %d != 1",
+                                mainthread->index);
+
+       /* thread is a Java thread and running */
+
+       mainthread->flags |= THREAD_FLAG_JAVA;
+       mainthread->state = THREAD_STATE_RUNNABLE;
+
+       /* Store the internal thread data-structure in the TSD. */
+
+       thread_set_current(mainthread);
+}
+
+
+/* threads_init ****************************************************************
+
+   Initialize the main thread.
+
+*******************************************************************************/
+
+void threads_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("threads_init");
+
+       /* Create the system and main thread groups. */
+
+       thread_create_initial_threadgroups();
+
+       /* Cache the java.lang.Thread initialization method. */
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       thread_method_init =
+               class_resolveclassmethod(class_java_lang_Thread,
+                                                                utf_init,
+                                                                utf_new_char("(Ljava/lang/VMThread;Ljava/lang/String;IZ)V"),
+                                                                class_java_lang_Thread,
+                                                                true);
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       thread_method_init =
+               class_resolveclassmethod(class_java_lang_Thread,
+                                                                utf_init,
+                                                                utf_new_char("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V"),
+                                                                class_java_lang_Thread,
+                                                                true);
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+       thread_method_init =
+               class_resolveclassmethod(class_java_lang_Thread,
+                                                                utf_init,
+                                                                utf_java_lang_String__void,
+                                                                class_java_lang_Thread,
+                                                                true);
+
+#else
+# error unknown classpath configuration
+#endif
+
+       if (thread_method_init == NULL)
+               vm_abort("threads_init: failed to resolve thread init method");
+
+       thread_create_initial_thread();
+}
+
+
+/* thread_create_object ********************************************************
+
+   Create a Java thread object for the given thread data-structure,
+   initializes it and adds the thread to the threadgroup.
+
+   ARGUMENTS:
+
+       t ....... thread
+       name .... thread name
+       group ... threadgroup
+
+   RETURN:
+
+*******************************************************************************/
+
+static bool thread_create_object(threadobject *t, java_handle_t *name, java_handle_t *group)
+{
+       /* Create a java.lang.Thread Java object. */
+
+       java_handle_t* h = builtin_new(class_java_lang_Thread);
+
+       if (h == NULL)
+               return false;
+
+       java_lang_Thread jlt(h);
+
+       // Set the Java object in the thread data-structure.  This
+       // indicates that the thread is attached to the VM.
+       thread_set_object(t, jlt.get_handle());
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       h = builtin_new(class_java_lang_VMThread);
+
+       if (h == NULL)
+               return false;
+
+       // Create and initialize a java.lang.VMThread object.
+       java_lang_VMThread jlvmt(h, jlt.get_handle(), t);
+
+       /* Call:
+          java.lang.Thread.<init>(Ljava/lang/VMThread;Ljava/lang/String;IZ)V */
+
+       bool isdaemon = thread_is_daemon(t);
+
+       (void) vm_call_method(thread_method_init, jlt.get_handle(), jlvmt.get_handle(),
+                                                 name, NORM_PRIORITY, isdaemon);
+
+       if (exceptions_get_exception())
+               return false;
+
+       // Set the ThreadGroup in the Java thread object.
+       jlt.set_group(group);
+
+       /* Add thread to the threadgroup. */
+
+       classinfo* c;
+       LLNI_class_get(group, c);
+
+       methodinfo* m = class_resolveclassmethod(c,
+                                                                                        utf_addThread,
+                                                                                        utf_java_lang_Thread__V,
+                                                                                        class_java_lang_ThreadGroup,
+                                                                                        true);
+
+       if (m == NULL)
+               return false;
+
+       (void) vm_call_method(m, group, jlt.get_handle());
+
+       if (exceptions_get_exception())
+               return false;
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       /* Set the priority.  java.lang.Thread.<init> requires it because
+          it sets the priority of the current thread to the parent's one
+          (which is the current thread in this case). */
+       jlt.set_priority(NORM_PRIORITY);
+
+       // Call: java.lang.Thread.<init>(Ljava/lang/ThreadGroup;Ljava/lang/String;)V
+
+       (void) vm_call_method(thread_method_init, jlt.get_handle(), group, name);
+
+       if (exceptions_get_exception())
+               return false;
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+       // Set the thread data-structure in the Java thread object.
+       jlt.set_vm_thread(t);
+
+       // Call: public Thread(Ljava/lang/String;)V
+       (void) vm_call_method(thread_method_init, jlt.get_handle(), name);
+
+       if (exceptions_get_exception())
+               return false;
+
+#else
+# error unknown classpath configuration
+#endif
+
+       return true;
+}
+
+
+/* thread_create_initial_threadgroups ******************************************
+
+   Create the initial threadgroups.
+
+   GNU Classpath:
+       Create the main threadgroup only and set the system
+       threadgroup to the main threadgroup.
+
+   SUN:
+       Create the system and main threadgroup.
+
+   CLDC:
+       This function is a no-op.
+
+*******************************************************************************/
+
+static void thread_create_initial_threadgroups(void)
+{
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       /* Allocate and initialize the main thread group. */
+
+       threadgroup_main = native_new_and_init(class_java_lang_ThreadGroup);
+
+       if (threadgroup_main == NULL)
+               vm_abort("thread_create_initial_threadgroups: failed to allocate main threadgroup");
+
+       /* Use the same threadgroup for system as for main. */
+
+       threadgroup_system = threadgroup_main;
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       java_handle_t *name;
+       methodinfo    *m;
+
+       /* Allocate and initialize the system thread group. */
+
+       threadgroup_system = native_new_and_init(class_java_lang_ThreadGroup);
+
+       if (threadgroup_system == NULL)
+               vm_abort("thread_create_initial_threadgroups: failed to allocate system threadgroup");
+
+       /* Allocate and initialize the main thread group. */
+
+       threadgroup_main = builtin_new(class_java_lang_ThreadGroup);
+
+       if (threadgroup_main == NULL)
+               vm_abort("thread_create_initial_threadgroups: failed to allocate main threadgroup");
+
+       name = javastring_new(utf_main);
+
+       m = class_resolveclassmethod(class_java_lang_ThreadGroup,
+                                                                utf_init,
+                                                                utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V,
+                                                                class_java_lang_ThreadGroup,
+                                                                true);
+
+       if (m == NULL)
+               vm_abort("thread_create_initial_threadgroups: failed to resolve threadgroup init method");
+
+       (void) vm_call_method(m, threadgroup_main, threadgroup_system, name);
+
+       if (exceptions_get_exception())
+               vm_abort("thread_create_initial_threadgroups: exception while initializing main threadgroup");
+
+# else
+#  error unknown classpath configuration
+# endif
+#endif
+}
+
+
+/* thread_create_initial_thread ***********************************************
+
+   Create the initial thread: main
+
+*******************************************************************************/
+
+static void thread_create_initial_thread(void)
+{
+       threadobject  *t;
+       java_handle_t *name;
+
+       /* Get the main-thread (NOTE: The main thread is always the first
+          thread in the list). */
+
+       t = ThreadList::get_main_thread();
+
+       /* The thread name. */
+
+       name = javastring_new(utf_main);
+
+#if defined(ENABLE_INTRP)
+       /* create interpreter stack */
+
+       if (opt_intrp) {
+               MSET(intrp_main_stack, 0, u1, opt_stacksize);
+               mainthread->_global_sp = (Cell*) (intrp_main_stack + opt_stacksize);
+       }
+#endif
+
+       /* Create the Java thread object. */
+
+       if (!thread_create_object(t, name, threadgroup_main))
+               vm_abort("thread_create_initial_thread: failed to create Java object");
+
+       /* Initialize the implementation specific bits. */
+
+       threads_impl_init();
+
+       DEBUGTHREADS("starting (main)", t);
+}
+
+
+/* thread_new ******************************************************************
+
+   Allocates and initializes an internal thread data-structure and
+   adds it to the threads list.
+
+*******************************************************************************/
+
+static threadobject *thread_new(void)
+{
+       int32_t       index;
+       threadobject *t;
+       
+       /* Lock the thread lists */
+
+       ThreadList::lock();
+
+       index = ThreadList::get_free_thread_index();
+
+       /* Allocate a thread data structure. */
+
+       /* First, try to get one from the free-list. */
+
+       t = ThreadList::get_free_thread();
+
+       if (t != NULL) {
+               /* Equivalent of MZERO on the else path */
+
+               threads_impl_thread_clear(t);
+       }
+       else {
+#if defined(ENABLE_GC_BOEHM)
+               t = GCNEW_UNCOLLECTABLE(threadobject, 1);
+#else
+               t = NEW(threadobject);
+#endif
+
+#if defined(ENABLE_STATISTICS)
+               if (opt_stat)
+                       size_threadobject += sizeof(threadobject);
+#endif
+
+               /* Clear memory. */
+
+               MZERO(t, threadobject, 1);
+
+               // Initialize the mutex and the condition.
+               t->flc_lock = new Mutex();
+               t->flc_cond = new Condition();
+
+               t->waitmutex = new Mutex();
+               t->waitcond = new Condition();
+
+               t->suspendmutex = new Mutex();
+               t->suspendcond = new Condition();
+
+#if defined(ENABLE_TLH)
+               tlh_init(&(t->tlh));
+#endif
+
+#if defined(ENABLE_GC_CACAO)
+               /* Register reference to java.lang.Thread with the GC. */
+               /* FIXME is it ok to do this only once? */
+
+               gc_reference_register(&(t->object), GC_REFTYPE_THREADOBJECT);
+               gc_reference_register(&(t->_exceptionptr), GC_REFTYPE_THREADOBJECT);
+#endif
+
+               t->_dumpmemory = new DumpMemory();
+       }
+
+       /* Pre-compute the thinlock-word. */
+
+       assert(index != 0);
+
+       t->index     = index;
+       t->thinlock  = Lockword::pre_compute_thinlock(t->index);
+       t->flags     = 0;
+       t->state     = THREAD_STATE_NEW;
+
+#if defined(ENABLE_GC_CACAO)
+       t->flags    |= THREAD_FLAG_IN_NATIVE; 
+#endif
+
+       /* Initialize the implementation-specific bits. */
+
+       threads_impl_thread_reuse(t);
+
+       /* Add the thread to the thread list. */
+
+       ThreadList::add_to_active_thread_list(t);
+
+       /* Unlock the thread lists. */
+
+       ThreadList::unlock();
+
+       return t;
+}
+
+
+/* thread_free *****************************************************************
+
+   Remove the thread from the threads-list and free the internal
+   thread data structure.  The thread index is added to the
+   thread-index free-list.
+
+   IN:
+       t ... thread data structure
+
+*******************************************************************************/
+
+void thread_free(threadobject *t)
+{
+       /* Set the reference to the Java object to NULL. */
+
+       thread_set_object(t, NULL);
+
+       /* Release the thread. */
+
+       ThreadList::release_thread(t);
+}
+
+
+/* threads_thread_start_internal ***********************************************
+
+   Start an internal thread in the JVM.  No Java thread objects exists
+   so far.
+
+   IN:
+      name.......UTF-8 name of the thread
+      f..........function pointer to C function to start
+
+*******************************************************************************/
+
+bool threads_thread_start_internal(utf *name, functionptr f)
+{
+       threadobject *t;
+
+       /* Enter the join-mutex, so if the main-thread is currently
+          waiting to join all threads, the number of non-daemon threads
+          is correct. */
+
+       threads_mutex_join_lock();
+
+       /* Create internal thread data-structure. */
+
+       t = thread_new();
+
+       t->flags |= THREAD_FLAG_INTERNAL | THREAD_FLAG_DAEMON;
+
+       /* The thread is flagged as (non-)daemon thread, we can leave the
+          mutex. */
+
+       threads_mutex_join_unlock();
+
+       /* Create the Java thread object. */
+
+       if (!thread_create_object(t, javastring_new(name), threadgroup_system))
+               return false;
+
+       /* Start the thread. */
+
+       threads_impl_thread_start(t, f);
+
+       /* everything's ok */
+
+       return true;
+}
+
+
+/* threads_thread_start ********************************************************
+
+   Start a Java thread in the JVM.  Only the java thread object exists
+   so far.
+
+   IN:
+      object.....the java thread object java.lang.Thread
+
+*******************************************************************************/
+
+void threads_thread_start(java_handle_t *object)
+{
+       java_lang_Thread jlt(object);
+
+       /* Enter the join-mutex, so if the main-thread is currently
+          waiting to join all threads, the number of non-daemon threads
+          is correct. */
+
+       threads_mutex_join_lock();
+
+       /* Create internal thread data-structure. */
+
+       threadobject* t = thread_new();
+
+       /* this is a normal Java thread */
+
+       t->flags |= THREAD_FLAG_JAVA;
+
+#if defined(ENABLE_JAVASE)
+       /* Is this a daemon thread? */
+
+       if (jlt.get_daemon() == true)
+               t->flags |= THREAD_FLAG_DAEMON;
+#endif
+
+       /* The thread is flagged and (non-)daemon thread, we can leave the
+          mutex. */
+
+       threads_mutex_join_unlock();
+
+       /* Link the two objects together. */
+
+       thread_set_object(t, object);
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       /* Get the java.lang.VMThread object and do some sanity checks. */
+       java_lang_VMThread jlvmt(jlt.get_vmThread());
+
+       assert(jlvmt.get_handle() != NULL);
+       assert(jlvmt.get_vmdata() == NULL);
+
+       jlvmt.set_vmdata(t);
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       // Nothing to do.
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+       jlt.set_vm_thread(t);
+
+#else
+# error unknown classpath configuration
+#endif
+
+       /* Start the thread.  Don't pass a function pointer (NULL) since
+          we want Thread.run()V here. */
+
+       threads_impl_thread_start(t, NULL);
+}
+
+
+/**
+ * Attaches the current thread to the VM.
+ *
+ * @param vm_aargs Attach arguments.
+ * @param isdaemon true if the attached thread should be a daemon
+ *                 thread.
+ *
+ * @return true on success, false otherwise.
+ */
+bool thread_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon)
+{
+       bool           result;
+       threadobject  *t;
+       utf           *u;
+       java_handle_t *name;
+       java_handle_t *group;
+
+    /* If the current thread has already been attached, this operation
+          is a no-op. */
+
+       result = thread_current_is_attached();
+
+       if (result == true)
+               return true;
+
+       /* Enter the join-mutex, so if the main-thread is currently
+          waiting to join all threads, the number of non-daemon threads
+          is correct. */
+
+       threads_mutex_join_lock();
+
+       /* Create internal thread data structure. */
+
+       t = thread_new();
+
+       /* Thread is a Java thread and running. */
+
+       t->flags = THREAD_FLAG_JAVA;
+
+       if (isdaemon)
+               t->flags |= THREAD_FLAG_DAEMON;
+
+       /* Store the internal thread data-structure in the TSD. */
+
+       thread_set_current(t);
+
+       /* The thread is flagged and (non-)daemon thread, we can leave the
+          mutex. */
+
+       threads_mutex_join_unlock();
+
+       DEBUGTHREADS("attaching", t);
+
+       /* Get the thread name. */
+
+       if (vm_aargs != NULL) {
+               u = utf_new_char(vm_aargs->name);
+       }
+       else {
+               u = utf_null;
+       }
+
+       name = javastring_new(u);
+
+#if defined(ENABLE_JAVASE)
+       /* Get the threadgroup. */
+
+       if (vm_aargs != NULL)
+               group = (java_handle_t *) vm_aargs->group;
+       else
+               group = NULL;
+
+       /* If no threadgroup was given, use the main threadgroup. */
+
+       if (group == NULL)
+               group = threadgroup_main;
+#endif
+
+#if defined(ENABLE_INTRP)
+       /* create interpreter stack */
+
+       if (opt_intrp) {
+               MSET(intrp_main_stack, 0, u1, opt_stacksize);
+               thread->_global_sp = (Cell *) (intrp_main_stack + opt_stacksize);
+       }
+#endif
+
+       /* Create the Java thread object. */
+
+       if (!thread_create_object(t, name, group))
+               return false;
+
+       /* The thread is completely initialized. */
+
+       thread_set_state_runnable(t);
+
+       return true;
+}
+
+
+/**
+ * Attaches the current external thread to the VM.  This function is
+ * called by JNI's AttachCurrentThread.
+ *
+ * @param vm_aargs Attach arguments.
+ * @param isdaemon true if the attached thread should be a daemon
+ *                 thread.
+ *
+ * @return true on success, false otherwise.
+ */
+bool thread_attach_current_external_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon)
+{
+       int result;
+
+#if defined(ENABLE_GC_BOEHM)
+       struct GC_stack_base sb;
+#endif
+
+#if defined(ENABLE_GC_BOEHM)
+       /* Register the thread with Boehm-GC.  This must happen before the
+          thread allocates any memory from the GC heap.*/
+
+       result = GC_get_stack_base(&sb);
+
+       if (result != GC_SUCCESS)
+               vm_abort("threads_attach_current_thread: GC_get_stack_base failed");
+
+       GC_register_my_thread(&sb);
+#endif
+
+       result = thread_attach_current_thread(vm_aargs, isdaemon);
+
+       if (result == false) {
+#if defined(ENABLE_GC_BOEHM)
+               /* Unregister the thread. */
+
+               GC_unregister_my_thread();
+#endif
+
+               return false;
+       }
+
+       return true;
+}
+
+
+/**
+ * Detaches the current external thread from the VM.  This function is
+ * called by JNI's DetachCurrentThread.
+ *
+ * @return true on success, false otherwise.
+ */
+bool thread_detach_current_external_thread(void)
+{
+       int result;
+
+       result = thread_detach_current_thread();
+
+       if (result == false)
+               return false;
+
+#if defined(ENABLE_GC_BOEHM)
+       /* Unregister the thread with Boehm-GC.  This must happen after
+          the thread allocates any memory from the GC heap. */
+
+       /* Don't detach the main thread.  This is a workaround for
+          OpenJDK's java binary. */
+       if (thread_get_current()->index != 1)
+               GC_unregister_my_thread();
+#endif
+
+       return true;
+}
+
+
+/* thread_fprint_name **********************************************************
+
+   Print the name of the given thread to the given stream.
+
+   ARGUMENTS:
+       t ........ thread data-structure
+       stream ... stream to print to
+
+*******************************************************************************/
+
+void thread_fprint_name(threadobject *t, FILE *stream)
+{
+       if (thread_get_object(t) == NULL)
+               vm_abort("");
+
+       java_lang_Thread jlt(thread_get_object(t));
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       java_handle_t* name = jlt.get_name();
+       javastring_fprint(name, stream);
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+       /* FIXME: In OpenJDK and CLDC the name is a char[]. */
+       //java_chararray_t *name;
+
+       /* FIXME This prints to stdout. */
+       utf_display_printable_ascii(utf_null);
+
+#else
+# error unknown classpath configuration
+#endif
+}
+
+
+/* thread_print_info ***********************************************************
+
+   Print information of the passed thread.
+
+   ARGUMENTS:
+       t ... thread data-structure.
+
+*******************************************************************************/
+
+void thread_print_info(threadobject *t)
+{
+       java_lang_Thread jlt(thread_get_object(t));
+
+       /* Print as much as we can when we are in state NEW. */
+
+       if (jlt.get_handle() != NULL) {
+               /* Print thread name. */
+
+               printf("\"");
+               thread_fprint_name(t, stdout);
+               printf("\"");
+       }
+       else {
+       }
+
+       if (thread_is_daemon(t))
+               printf(" daemon");
+
+       if (jlt.get_handle() != NULL) {
+               printf(" prio=%d", jlt.get_priority());
+       }
+
+#if SIZEOF_VOID_P == 8
+       printf(" t=0x%016lx tid=0x%016lx (%ld)",
+                  (ptrint) t, (ptrint) t->tid, (ptrint) t->tid);
+#else
+       printf(" t=0x%08x tid=0x%08x (%d)",
+                  (ptrint) t, (ptrint) t->tid, (ptrint) t->tid);
+#endif
+
+       printf(" index=%d", t->index);
+
+       /* Print thread state. */
+
+       int state = cacaothread_get_state(t);
+
+       switch (state) {
+       case THREAD_STATE_NEW:
+               printf(" new");
+               break;
+       case THREAD_STATE_RUNNABLE:
+               printf(" runnable");
+               break;
+       case THREAD_STATE_BLOCKED:
+               printf(" blocked");
+               break;
+       case THREAD_STATE_WAITING:
+               printf(" waiting");
+               break;
+       case THREAD_STATE_TIMED_WAITING:
+               printf(" waiting on condition");
+               break;
+       case THREAD_STATE_TERMINATED:
+               printf(" terminated");
+               break;
+       default:
+               vm_abort("thread_print_info: unknown thread state %d", state);
+       }
+}
+
+
+/* threads_get_current_tid *****************************************************
+
+   Return the tid of the current thread.
+   
+   RETURN VALUE:
+       the current tid
+
+*******************************************************************************/
+
+intptr_t threads_get_current_tid(void)
+{
+       threadobject *thread;
+
+       thread = THREADOBJECT;
+
+       /* this may happen during bootstrap */
+
+       if (thread == NULL)
+               return 0;
+
+       return (intptr_t) thread->tid;
+}
+
+
+/* thread_set_state_runnable ***************************************************
+
+   Set the current state of the given thread to THREAD_STATE_RUNNABLE.
+
+   NOTE: If the thread has already terminated, don't set the state.
+         This is important for threads_detach_thread.
+
+*******************************************************************************/
+
+void thread_set_state_runnable(threadobject *t)
+{
+       /* Set the state inside a lock. */
+
+       ThreadList::lock();
+
+       if (t->state != THREAD_STATE_TERMINATED) {
+               t->state = THREAD_STATE_RUNNABLE;
+
+               DEBUGTHREADS("is RUNNABLE", t);
+       }
+
+       ThreadList::unlock();
+}
+
+
+/* thread_set_state_waiting ****************************************************
+
+   Set the current state of the given thread to THREAD_STATE_WAITING.
+
+   NOTE: If the thread has already terminated, don't set the state.
+         This is important for threads_detach_thread.
+
+*******************************************************************************/
+
+void thread_set_state_waiting(threadobject *t)
+{
+       /* Set the state inside a lock. */
+
+       ThreadList::lock();
+
+       if (t->state != THREAD_STATE_TERMINATED) {
+               t->state = THREAD_STATE_WAITING;
+
+               DEBUGTHREADS("is WAITING", t);
+       }
+
+       ThreadList::unlock();
+}
+
+
+/* thread_set_state_timed_waiting **********************************************
+
+   Set the current state of the given thread to
+   THREAD_STATE_TIMED_WAITING.
+
+   NOTE: If the thread has already terminated, don't set the state.
+         This is important for threads_detach_thread.
+
+*******************************************************************************/
+
+void thread_set_state_timed_waiting(threadobject *t)
+{
+       /* Set the state inside a lock. */
+
+       ThreadList::lock();
+
+       if (t->state != THREAD_STATE_TERMINATED) {
+               t->state = THREAD_STATE_TIMED_WAITING;
+
+               DEBUGTHREADS("is TIMED_WAITING", t);
+       }
+
+       ThreadList::unlock();
+}
+
+
+/* thread_set_state_terminated *************************************************
+
+   Set the current state of the given thread to
+   THREAD_STATE_TERMINATED.
+
+*******************************************************************************/
+
+void thread_set_state_terminated(threadobject *t)
+{
+       /* Set the state inside a lock. */
+
+       ThreadList::lock();
+
+       t->state = THREAD_STATE_TERMINATED;
+
+       DEBUGTHREADS("is TERMINATED", t);
+
+       ThreadList::unlock();
+}
+
+
+/* thread_get_thread **********************************************************
+
+   Return the thread data structure of the given Java thread object.
+
+   ARGUMENTS:
+       h ... java.lang.{VM}Thread object
+
+   RETURN VALUE:
+       the thread object
+
+*******************************************************************************/
+
+threadobject *thread_get_thread(java_handle_t *h)
+{
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       java_lang_VMThread jlvmt(h);
+       threadobject* t = jlvmt.get_vmdata();
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       /* XXX This is just a quick hack. */
+       threadobject* t = ThreadList::get_thread_from_java_object(h);
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+       log_println("thread_get_thread: IMPLEMENT ME!");
+       threadobject* t = NULL;
+
+#else
+# error unknown classpath configuration
+#endif
+
+       return t;
+}
+
+
+/* threads_thread_is_alive *****************************************************
+
+   Returns if the give thread is alive.
+
+*******************************************************************************/
+
+bool threads_thread_is_alive(threadobject *t)
+{
+       int state;
+
+       state = cacaothread_get_state(t);
+
+       switch (state) {
+       case THREAD_STATE_NEW:
+       case THREAD_STATE_TERMINATED:
+               return false;
+
+       case THREAD_STATE_RUNNABLE:
+       case THREAD_STATE_BLOCKED:
+       case THREAD_STATE_WAITING:
+       case THREAD_STATE_TIMED_WAITING:
+               return true;
+
+       default:
+               vm_abort("threads_thread_is_alive: unknown thread state %d", state);
+       }
+
+       /* keep compiler happy */
+
+       return false;
+}
+
+
+/*
+ * 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/threads/thread.h b/src/threads/thread.h
deleted file mode 100644 (file)
index 50099e3..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-/* src/threads/thread.h - machine independent thread functions
-
-   Copyright (C) 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 _THREAD_H
-#define _THREAD_H
-
-#include "config.h"
-
-#include "vmcore/system.h"
-
-#if defined(ENABLE_THREADS)
-# include "threads/posix/thread-posix.h"
-#else
-# include "threads/none/thread-none.h"
-#endif
-
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-
-#include "vmcore/utf8.h"
-
-
-/* only define the following stuff with thread enabled ************************/
-
-#if defined(ENABLE_THREADS)
-
-/* thread states **************************************************************/
-
-#define THREAD_STATE_NEW              0
-#define THREAD_STATE_RUNNABLE         1
-#define THREAD_STATE_BLOCKED          2
-#define THREAD_STATE_WAITING          3
-#define THREAD_STATE_TIMED_WAITING    4
-#define THREAD_STATE_TERMINATED       5
-
-
-/* thread priorities **********************************************************/
-
-#define MIN_PRIORITY     1
-#define NORM_PRIORITY    5
-#define MAX_PRIORITY     10
-
-
-/* debug **********************************************************************/
-
-#if !defined(NDEBUG)
-# define DEBUGTHREADS(message, thread) \
-       do { \
-               if (opt_DebugThreads) { \
-                       printf("[Thread %-16s: ", message); \
-                       thread_print_info(thread); \
-                       printf("]\n"); \
-               } \
-       } while (0)
-#else
-# define DEBUGTHREADS(message, thread)
-#endif
-
-
-/* global variables ***********************************************************/
-
-#if defined(__LINUX__)
-/* XXX Remove for exact-GC. */
-extern bool threads_pthreads_implementation_nptl;
-#endif
-
-
-/* inline functions ***********************************************************/
-
-/* thread_get_object ***********************************************************
-
-   Return the Java for the given thread.
-
-   ARGUMENTS:
-       t ... thread
-
-   RETURN:
-       the Java object
-
-*******************************************************************************/
-
-inline static java_handle_t *thread_get_object(threadobject *t)
-{
-       return LLNI_WRAP(t->object);
-}
-
-
-/* threads_thread_set_object ***************************************************
-
-   Set the Java object for the given thread.
-
-   ARGUMENTS:
-       t ... thread
-          o ... Java object
-
-*******************************************************************************/
-
-inline static void thread_set_object(threadobject *t, java_handle_t *o)
-{
-       t->object = LLNI_DIRECT(o);
-}
-
-
-/* thread_get_current_object **************************************************
-
-   Return the Java object of the current thread.
-   
-   RETURN VALUE:
-       the Java object
-
-*******************************************************************************/
-
-inline static java_handle_t *thread_get_current_object(void)
-{
-       threadobject  *t;
-       java_handle_t *o;
-
-       t = THREADOBJECT;
-       o = thread_get_object(t);
-
-       return o;
-}
-
-
-/* cacaothread_get_state *******************************************************
-
-   Returns the current state of the given thread.
-
-   ARGUMENTS:
-       t ... the thread to check
-
-   RETURN:
-       thread state
-
-*******************************************************************************/
-
-inline static int cacaothread_get_state(threadobject *t)
-{
-       return t->state;
-}
-
-
-/* thread_is_attached **********************************************************
-
-   Returns if the given thread is attached to the VM.
-
-   ARGUMENTS:
-       t ... the thread to check
-
-   RETURN:
-       true .... the thread is attached to the VM
-       false ... the thread is not
-
-*******************************************************************************/
-
-inline static bool thread_is_attached(threadobject *t)
-{
-       java_handle_t *o;
-
-       o = thread_get_object(t);
-
-       if (o != NULL)
-               return true;
-       else
-               return false;
-}
-
-
-/* thread_is_interrupted *******************************************************
-
-   Check if the given thread has been interrupted.
-
-   ARGUMENTS:
-       t ... the thread to check
-
-   RETURN VALUE:
-      true, if the given thread had been interrupted
-
-*******************************************************************************/
-
-inline static bool thread_is_interrupted(threadobject *t)
-{
-       return t->interrupted;
-}
-
-
-/* thread_set_interrupted ******************************************************
-
-   Set the interrupted flag to the given value.
-
-   ARGUMENTS:
-       interrupted ... value to set
-
-*******************************************************************************/
-
-inline static void thread_set_interrupted(threadobject *t, bool interrupted)
-{
-       mutex_lock(&t->waitmutex);
-
-       /* Set interrupted flag. */
-
-       t->interrupted = interrupted;
-
-       mutex_unlock(&t->waitmutex);
-}
-
-
-/* thread_is_daemon ************************************************************
-
-   Returns if the given thread is a daemon thread.
-
-   ARGUMENTS:
-       t ... the thread to check
-
-   RETURN:
-       true .... the thread is a daemon thread
-       false ... the thread is not
-
-*******************************************************************************/
-
-inline static bool thread_is_daemon(threadobject *t)
-{
-       if (t->flags & THREAD_FLAG_DAEMON)
-               return true;
-       else
-               return false;
-}
-
-
-/* thread_current_is_attached **************************************************
-
-   Returns if the current thread is attached to the VM.
-
-   RETURN:
-       true .... the thread is attached to the VM
-       false ... the thread is not
-
-*******************************************************************************/
-
-inline static bool thread_current_is_attached(void)
-{
-       threadobject  *t;
-       bool           result;
-
-       t = thread_get_current();
-
-       if (t == NULL)
-               return false;
-
-       result = thread_is_attached(t);
-
-       return result;
-}
-
-
-/* function prototypes ********************************************************/
-
-void          threads_preinit(void);
-void          threads_init(void);
-
-void          thread_free(threadobject *t);
-
-bool          threads_thread_start_internal(utf *name, functionptr f);
-void          threads_thread_start(java_handle_t *object);
-
-bool          threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon);
-
-void          thread_fprint_name(threadobject *t, FILE *stream);
-void          thread_print_info(threadobject *t);
-
-intptr_t      threads_get_current_tid(void);
-
-void          thread_set_state_runnable(threadobject *t);
-void          thread_set_state_waiting(threadobject *t);
-void          thread_set_state_timed_waiting(threadobject *t);
-void          thread_set_state_terminated(threadobject *t);
-
-threadobject *thread_get_thread(java_handle_t *h);
-
-bool          threads_thread_is_alive(threadobject *t);
-
-void          threads_dump(void);
-
-
-/* implementation specific functions */
-
-void          threads_impl_preinit(void);
-void          threads_impl_init(void);
-
-#if defined(ENABLE_GC_CACAO)
-void          threads_mutex_gc_lock(void);
-void          threads_mutex_gc_unlock(void);
-#endif
-
-void          threads_mutex_join_lock(void);
-void          threads_mutex_join_unlock(void);
-
-void          threads_impl_thread_init(threadobject *t);
-void          threads_impl_thread_clear(threadobject *t);
-void          threads_impl_thread_reuse(threadobject *t);
-void          threads_impl_thread_free(threadobject *t);
-void          threads_impl_thread_start(threadobject *thread, functionptr f);
-
-void          threads_yield(void);
-
-#endif /* ENABLE_THREADS */
-
-#endif /* _THREAD_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/threads/thread.hpp b/src/threads/thread.hpp
new file mode 100644 (file)
index 0000000..b50db43
--- /dev/null
@@ -0,0 +1,377 @@
+/* src/threads/thread.hpp - machine independent thread functions
+
+   Copyright (C) 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 _THREAD_HPP
+#define _THREAD_HPP
+
+#include "config.h"
+
+#include "vm/types.h"
+
+// Include early to get threadobject.
+#if defined(ENABLE_THREADS)
+# include "threads/posix/thread-posix.hpp"
+#else
+# include "threads/none/thread-none.h"
+#endif
+
+#include "vm/os.hpp"
+
+#include "native/llni.h"
+
+#include "threads/mutex.hpp"
+
+#include "vm/global.h"
+#include "vm/utf8.h"
+
+
+/* only define the following stuff with thread enabled ************************/
+
+#if defined(ENABLE_THREADS)
+
+/* thread states **************************************************************/
+
+#define THREAD_STATE_NEW              0
+#define THREAD_STATE_RUNNABLE         1
+#define THREAD_STATE_BLOCKED          2
+#define THREAD_STATE_WAITING          3
+#define THREAD_STATE_TIMED_WAITING    4
+#define THREAD_STATE_TERMINATED       5
+
+
+/* thread priorities **********************************************************/
+
+#define MIN_PRIORITY     1
+#define NORM_PRIORITY    5
+#define MAX_PRIORITY     10
+
+
+/* debug **********************************************************************/
+
+#if !defined(NDEBUG)
+# define DEBUGTHREADS(message, thread) \
+       do { \
+               if (opt_DebugThreads) { \
+                       printf("[Thread %-16s: ", message); \
+                       thread_print_info(thread); \
+                       printf("]\n"); \
+               } \
+       } while (0)
+#else
+# define DEBUGTHREADS(message, thread)
+#endif
+
+
+/* global variables ***********************************************************/
+
+#if defined(__LINUX__)
+/* XXX Remove for exact-GC. */
+extern bool threads_pthreads_implementation_nptl;
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* inline functions ***********************************************************/
+
+/* thread_get_object ***********************************************************
+
+   Return the Java for the given thread.
+
+   ARGUMENTS:
+       t ... thread
+
+   RETURN:
+       the Java object
+
+*******************************************************************************/
+
+inline static java_handle_t *thread_get_object(threadobject *t)
+{
+       return LLNI_WRAP(t->object);
+}
+
+
+/* threads_thread_set_object ***************************************************
+
+   Set the Java object for the given thread.
+
+   ARGUMENTS:
+       t ... thread
+          o ... Java object
+
+*******************************************************************************/
+
+inline static void thread_set_object(threadobject *t, java_handle_t *o)
+{
+       t->object = LLNI_DIRECT(o);
+}
+
+
+/* thread_get_current_object **************************************************
+
+   Return the Java object of the current thread.
+   
+   RETURN VALUE:
+       the Java object
+
+*******************************************************************************/
+
+inline static java_handle_t *thread_get_current_object(void)
+{
+       threadobject  *t;
+       java_handle_t *o;
+
+       t = THREADOBJECT;
+       o = thread_get_object(t);
+
+       return o;
+}
+
+
+/* cacaothread_get_state *******************************************************
+
+   Returns the current state of the given thread.
+
+   ARGUMENTS:
+       t ... the thread to check
+
+   RETURN:
+       thread state
+
+*******************************************************************************/
+
+inline static int cacaothread_get_state(threadobject *t)
+{
+       return t->state;
+}
+
+
+/* thread_is_attached **********************************************************
+
+   Returns if the given thread is attached to the VM.
+
+   ARGUMENTS:
+       t ... the thread to check
+
+   RETURN:
+       true .... the thread is attached to the VM
+       false ... the thread is not
+
+*******************************************************************************/
+
+inline static bool thread_is_attached(threadobject *t)
+{
+       java_handle_t *o;
+
+       o = thread_get_object(t);
+
+       if (o != NULL)
+               return true;
+       else
+               return false;
+}
+
+
+/* thread_is_interrupted *******************************************************
+
+   Check if the given thread has been interrupted.
+
+   ARGUMENTS:
+       t ... the thread to check
+
+   RETURN VALUE:
+      true, if the given thread had been interrupted
+
+*******************************************************************************/
+
+inline static bool thread_is_interrupted(threadobject *t)
+{
+       bool interrupted;
+
+       /* We need the mutex because classpath will call this function when
+          a blocking system call is interrupted. The mutex ensures that it will
+          see the correct value for the interrupted flag. */
+
+#ifdef __cplusplus
+       t->waitmutex->lock();
+       interrupted = t->interrupted;
+       t->waitmutex->unlock();
+#else
+       Mutex_lock(t->waitmutex);
+       interrupted = t->interrupted;
+       Mutex_unlock(t->waitmutex);
+#endif
+
+       return interrupted;
+}
+
+
+/* thread_set_interrupted ******************************************************
+
+   Set the interrupted flag to the given value.
+
+   ARGUMENTS:
+       interrupted ... value to set
+
+*******************************************************************************/
+
+inline static void thread_set_interrupted(threadobject *t, bool interrupted)
+{
+#ifdef __cplusplus
+       t->waitmutex->lock();
+       t->interrupted = interrupted;
+       t->waitmutex->unlock();
+#else
+       Mutex_lock(t->waitmutex);
+       t->interrupted = interrupted;
+       Mutex_unlock(t->waitmutex);
+#endif
+}
+
+
+/* thread_is_daemon ************************************************************
+
+   Returns if the given thread is a daemon thread.
+
+   ARGUMENTS:
+       t ... the thread to check
+
+   RETURN:
+       true .... the thread is a daemon thread
+       false ... the thread is not
+
+*******************************************************************************/
+
+inline static bool thread_is_daemon(threadobject *t)
+{
+       if (t->flags & THREAD_FLAG_DAEMON)
+               return true;
+       else
+               return false;
+}
+
+
+/* thread_current_is_attached **************************************************
+
+   Returns if the current thread is attached to the VM.
+
+   RETURN:
+       true .... the thread is attached to the VM
+       false ... the thread is not
+
+*******************************************************************************/
+
+inline static bool thread_current_is_attached(void)
+{
+       threadobject  *t;
+       bool           result;
+
+       t = thread_get_current();
+
+       if (t == NULL)
+               return false;
+
+       result = thread_is_attached(t);
+
+       return result;
+}
+
+
+/* function prototypes ********************************************************/
+
+void          threads_preinit(void);
+void          threads_init(void);
+
+void          thread_free(threadobject *t);
+
+bool          threads_thread_start_internal(utf *name, functionptr f);
+void          threads_thread_start(java_handle_t *object);
+
+bool          thread_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon);
+bool          thread_attach_current_external_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon);
+bool          thread_detach_current_thread(void);
+
+bool          thread_detach_current_external_thread(void);
+
+void          thread_fprint_name(threadobject *t, FILE *stream);
+void          thread_print_info(threadobject *t);
+
+intptr_t      threads_get_current_tid(void);
+
+void          thread_set_state_runnable(threadobject *t);
+void          thread_set_state_waiting(threadobject *t);
+void          thread_set_state_timed_waiting(threadobject *t);
+void          thread_set_state_terminated(threadobject *t);
+
+threadobject *thread_get_thread(java_handle_t *h);
+
+bool          threads_thread_is_alive(threadobject *t);
+
+
+/* implementation specific functions */
+
+void          threads_impl_preinit(void);
+void          threads_impl_init(void);
+
+#if defined(ENABLE_GC_CACAO)
+void          threads_mutex_gc_lock(void);
+void          threads_mutex_gc_unlock(void);
+#endif
+
+void          threads_mutex_join_lock(void);
+void          threads_mutex_join_unlock(void);
+
+void          threads_impl_thread_clear(threadobject *t);
+void          threads_impl_thread_reuse(threadobject *t);
+void          threads_impl_thread_free(threadobject *t);
+void          threads_impl_thread_start(threadobject *thread, functionptr f);
+
+void          threads_yield(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ENABLE_THREADS */
+
+#endif // _THREAD_HPP
+
+
+/*
+ * 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/threads/threadlist.c b/src/threads/threadlist.c
deleted file mode 100644 (file)
index 8b7d92e..0000000
+++ /dev/null
@@ -1,379 +0,0 @@
-/* src/threads/threadlist.c - different thread-lists
-
-   Copyright (C) 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 <stdint.h>
-
-#include "mm/memory.h"
-
-#include "threads/mutex.h"
-#include "threads/threadlist.h"
-#include "threads/thread.h"
-
-#include "toolbox/list.h"
-
-#include "vmcore/options.h"
-
-
-/* global variables ***********************************************************/
-
-static mutex_t threadlist_mutex;          /* global mutex for the thread list */
-
-static list_t *list_thread;                            /* global threads list */
-static list_t *list_thread_free;                  /* global free threads list */
-static list_t *list_thread_index_free;
-
-
-typedef struct thread_index_t {
-       int32_t    index;
-       listnode_t linkage;
-} thread_index_t;
-
-
-/* threadlist_init *************************************************************
-
-   Initialize thread-lists.
-
-*******************************************************************************/
-
-void threadlist_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("threadlist_init");
-
-       /* Initialize the thread list mutex. */
-
-       mutex_init(&threadlist_mutex);
-
-       /* Initialize the thread lists. */
-
-       list_thread            = list_create(OFFSET(threadobject, linkage));
-       list_thread_free       = list_create(OFFSET(threadobject, linkage_free));
-       list_thread_index_free = list_create(OFFSET(thread_index_t, linkage));
-}
-
-
-/* threadlist_lock *************************************************************
-
-   Enter the thread list mutex.
-
-   NOTE: We need this function as we can't use an internal lock for
-         the threads lists because the thread's lock is initialized in
-         threads_table_add (when we have the thread index), but we
-         already need the lock at the entry of the function.
-
-*******************************************************************************/
-
-void threadlist_lock(void)
-{
-       mutex_lock(&threadlist_mutex);
-}
-
-
-/* threadlist_unlock *********************************************************
-
-   Leave the thread list mutex.
-
-*******************************************************************************/
-
-void threadlist_unlock(void)
-{
-       mutex_unlock(&threadlist_mutex);
-}
-
-
-/* threadlist_add **************************************************************
-
-   Add the given threadobject as last entry to the thread list.
-
-   IN:
-       t ... threadobject to be added
-
-*******************************************************************************/
-
-void threadlist_add(threadobject *t)
-{
-       list_add_last(list_thread, t);
-}
-
-
-/* threadlist_remove ***********************************************************
-
-   Remove the given threadobject from the thread list.
-
-   IN:
-       t ... threadobject to be removed
-
-*******************************************************************************/
-
-void threadlist_remove(threadobject *t)
-{
-       list_remove(list_thread, t);
-}
-
-
-/* threadlist_first ************************************************************
-
-   Return the first entry in the thread list.
-
-   RETURN:
-       threadobject of the first entry
-
-*******************************************************************************/
-
-threadobject *threadlist_first(void)
-{
-       threadobject *t;
-
-       t = list_first(list_thread);
-
-       return t;
-}
-
-
-/* threadlist_next *************************************************************
-
-   Return the next entry in the thread list.
-
-   IN:
-       t ... threadobject to get next thread of
-
-   RETURN:
-       threadobject of the next entry
-
-*******************************************************************************/
-
-threadobject *threadlist_next(threadobject *t)
-{
-       threadobject *next;
-
-       next = list_next(list_thread, t);
-
-       return next;
-}
-
-
-/* threadlist_free_add *********************************************************
-
-   Add the given threadobject as last entry to the free thread list.
-
-   IN:
-       t ... threadobject to be added
-
-*******************************************************************************/
-
-void threadlist_free_add(threadobject *t)
-{
-       list_add_last(list_thread_free, t);
-}
-
-
-/* threadlist_free_remove ******************************************************
-
-   Remove the given entry from the free thread list.
-
-   IN:
-       t ... threadobject to be removed
-
-*******************************************************************************/
-
-void threadlist_free_remove(threadobject *t)
-{
-       list_remove(list_thread_free, t);
-}
-
-
-/* threadlist_free_first *******************************************************
-
-   Return the first entry in the free thread list.
-
-   RETURN:
-       threadobject of the first free entry
-
-*******************************************************************************/
-
-threadobject *threadlist_free_first(void)
-{
-       threadobject *t;
-
-       t = list_first(list_thread_free);
-
-       return t;
-}
-
-
-/* threadlist_get_non_daemons **************************************************
-
-   Return the number of non-daemon threads.
-
-   NOTE: This function does a linear-search over the threads list,
-         because it's only used for joining the threads.
-
-*******************************************************************************/
-
-int threadlist_get_non_daemons(void)
-{
-       threadobject *t;
-       int           nondaemons;
-
-       /* Lock the thread lists. */
-
-       threadlist_lock();
-
-       nondaemons = 0;
-
-       for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
-               if (!thread_is_daemon(t))
-                       nondaemons++;
-       }
-
-       /* Unlock the thread lists. */
-
-       threadlist_unlock();
-
-       return nondaemons;
-}
-
-
-/* threadlist_index_first ******************************************************
-
-   Return the first entry in the thread-index list.
-
-   RETURN VALUE:
-       thread-index structure
-
-*******************************************************************************/
-
-static inline thread_index_t *threadlist_index_first(void)
-{
-       thread_index_t *ti;
-
-       ti = list_first(list_thread_index_free);
-
-       return ti;
-}
-
-
-/* threadlist_index_add ********************************************************
-
-   Add the given thread-index to the thread-index free list.
-
-   IN:
-       i ... thread index
-
-*******************************************************************************/
-
-void threadlist_index_add(int index)
-{
-       thread_index_t *ti;
-
-       ti = NEW(thread_index_t);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_thread_index_t += sizeof(thread_index_t);
-#endif
-
-       /* Set the index in the structure. */
-
-       ti->index = index;
-
-       list_add_last(list_thread_index_free, ti);
-}
-
-
-/* threadlist_index_remove *****************************************************
-
-   Remove the given thread-index from the thread-index list and free
-   the thread-index structure.
-
-   IN:
-       ti ... thread-index structure
-
-*******************************************************************************/
-
-static inline void threadlist_index_remove(thread_index_t *ti)
-{
-       list_remove(list_thread_index_free, ti);
-
-       FREE(ti, thread_index_t);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_thread_index_t -= sizeof(thread_index_t);
-#endif
-}
-
-
-/* threadlist_get_free_index ***************************************************
-
-   Return a free thread index.
-
-   RETURN VALUE:
-       free thread index
-
-*******************************************************************************/
-
-int threadlist_get_free_index(void)
-{
-       thread_index_t *ti;
-       int             index;
-
-       /* Try to get a thread index from the free-list. */
-
-       ti = threadlist_index_first();
-
-       /* Is a free thread index available? */
-
-       if (ti != NULL) {
-               /* Yes, get the index and remove it from the free list. */
-
-               index = ti->index;
-
-               threadlist_index_remove(ti);
-       }
-       else {
-               /* Get a new the thread index. */
-
-               index = list_thread->size + 1;
-       }
-
-       return index;
-}
-
-
-/*
- * 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/threads/threadlist.cpp b/src/threads/threadlist.cpp
new file mode 100644 (file)
index 0000000..bcf7f0e
--- /dev/null
@@ -0,0 +1,284 @@
+/* src/threads/threadlist.cpp - thread list
+
+   Copyright (C) 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 <stdint.h>
+
+#include <algorithm>
+
+#include "threads/mutex.hpp"
+#include "threads/threadlist.hpp"
+#include "threads/thread.hpp"
+
+#include "toolbox/list.hpp"
+#include "toolbox/logging.h"
+
+#include "vm/jit/stacktrace.hpp"
+
+
+/* class variables */
+
+Mutex               ThreadList::_mutex;                // a mutex for all thread lists
+
+list<threadobject*> ThreadList::_active_thread_list;   // list of active threads
+list<threadobject*> ThreadList::_free_thread_list;     // list of free threads
+list<int32_t>       ThreadList::_free_index_list;      // list of free thread indexes
+
+int32_t             ThreadList::_number_of_non_daemon_threads;
+
+
+/**
+ * Dumps info for all threads running in the VM.  This function is
+ * called when SIGQUIT (<ctrl>-\) is sent to the VM.
+ */
+void ThreadList::dump_threads()
+{
+       // XXX we should stop the world here
+       // Lock the thread lists.
+       lock();
+
+       printf("Full thread dump CACAO "VERSION":\n");
+
+       // Iterate over all started threads.
+       for (List<threadobject*>::iterator it = _active_thread_list.begin(); it != _active_thread_list.end(); it++) {
+               threadobject* t = *it;
+
+               // Ignore threads which are in state NEW.
+               if (t->state == THREAD_STATE_NEW)
+                       continue;
+
+#if defined(ENABLE_GC_CACAO)
+               /* Suspend the thread. */
+               /* XXX Is the suspend reason correct? */
+
+               if (threads_suspend_thread(t, SUSPEND_REASON_JNI) == false)
+                       vm_abort("threads_dump: threads_suspend_thread failed");
+#endif
+
+               /* Print thread info. */
+
+               printf("\n");
+               thread_print_info(t);
+               printf("\n");
+
+               /* Print trace of thread. */
+
+               stacktrace_print_of_thread(t);
+
+#if defined(ENABLE_GC_CACAO)
+               /* Resume the thread. */
+
+               if (threads_resume_thread(t) == false)
+                       vm_abort("threads_dump: threads_resume_thread failed");
+#endif
+       }
+
+       // Unlock the thread lists.
+       unlock();
+}
+
+
+/**
+ * Return a free thread object.
+ *
+ * @return free thread object or NULL if none available
+ */
+threadobject* ThreadList::get_free_thread()
+{
+       threadobject* t = NULL;
+
+       // Do we have free threads in the free-list?
+       if (_free_thread_list.empty() == false) {
+               // Yes, get the index and remove it from the free list.
+               threadobject* t = _free_thread_list.front();
+               _free_thread_list.remove(t);
+       }
+
+       return t;
+}
+
+
+/**
+ * Return a free thread index.
+ *
+ * @return free thread index
+ */
+int32_t ThreadList::get_free_thread_index()
+{
+       int32_t index;
+
+       // Do we have free indexes in the free-list?
+       if (_free_index_list.empty() == false) {
+               // Yes, get the index and remove it from the free list.
+               index = _free_index_list.front();
+               _free_index_list.remove(index);
+       }
+       else {
+               // Get a new the thread index.
+               index = _active_thread_list.size() + 1;
+       }
+
+       return index;
+}
+
+
+/**
+ * Return the number of non-daemon threads.
+ *
+ * NOTE: This function does a linear-search over the threads list,
+ *       because it is only used for joining the threads.
+ *
+ * @return number of non daemon threads
+ */
+int32_t ThreadList::get_number_of_non_daemon_threads(void)
+{
+       int nondaemons = 0;
+
+       lock();
+
+       for (List<threadobject*>::iterator it = _active_thread_list.begin(); it != _active_thread_list.end(); it++) {
+               threadobject* t = *it;
+
+               if (!thread_is_daemon(t))
+                       nondaemons++;
+       }
+
+       unlock();
+
+       return nondaemons;
+}
+
+
+/**
+ * Return the thread object with the given index.
+ *
+ * @return thread object
+ */
+threadobject* ThreadList::get_thread_by_index(int32_t index)
+{
+       lock();
+
+       List<threadobject*>::iterator it = find_if(_active_thread_list.begin(), _active_thread_list.end(), std::bind2nd(comparator(), index));
+
+       // No thread found.
+       if (it == _active_thread_list.end()) {
+               unlock();
+               return NULL;
+       }
+
+       threadobject* t = *it;
+
+       // The thread found is in state new.
+       if (t->state == THREAD_STATE_NEW) {
+               unlock();
+               return NULL;
+       }
+
+       unlock();
+       return t;
+}
+
+
+/**
+ * Return the Java thread object from the given thread object.
+ *
+ * @return Java thread object
+ */
+threadobject* ThreadList::get_thread_from_java_object(java_handle_t* h)
+{
+       List<threadobject*>::iterator it;
+       threadobject* t;
+       bool          equal;
+
+       lock();
+
+       for (it = _active_thread_list.begin(); it != _active_thread_list.end(); it++) {
+               t = *it;
+
+               LLNI_equals(t->object, h, equal);
+
+               if (equal == true) {
+                       unlock();
+                       return t;
+               }
+       }
+
+       unlock();
+
+       return NULL;
+}
+
+
+/**
+ * Release the thread.
+ *
+ * @return free thread index
+ */
+void ThreadList::release_thread(threadobject* t)
+{
+       lock();
+
+       // Move thread from active thread list to free thread list.
+       remove_from_active_thread_list(t);
+       add_to_free_thread_list(t);
+
+       // Add thread index to free index list.
+       add_to_free_index_list(t->index);
+
+       unlock();
+}
+
+
+/* C interface functions ******************************************************/
+
+extern "C" {
+       void ThreadList_lock() { ThreadList::lock(); }
+       void ThreadList_unlock() { ThreadList::unlock(); }
+       void ThreadList_dump_threads() { ThreadList::dump_threads(); }
+       void ThreadList_release_thread(threadobject* t) { ThreadList::release_thread(t); }
+       threadobject* ThreadList_get_free_thread() { return ThreadList::get_free_thread(); }
+       int32_t ThreadList_get_free_thread_index() { return ThreadList::get_free_thread_index(); }
+       void ThreadList_add_to_active_thread_list(threadobject* t) { ThreadList::add_to_active_thread_list(t); }
+       threadobject* ThreadList_get_thread_by_index(int32_t index) { return ThreadList::get_thread_by_index(index); }
+       threadobject* ThreadList_get_main_thread() { return ThreadList::get_main_thread(); }
+       threadobject* ThreadList_get_thread_from_java_object(java_handle_t* h) { return ThreadList::get_thread_from_java_object(h); }
+
+       int32_t ThreadList_get_number_of_non_daemon_threads() { return ThreadList::get_number_of_non_daemon_threads(); }
+}
+
+/*
+ * 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/threads/threadlist.h b/src/threads/threadlist.h
deleted file mode 100644 (file)
index b3dd2cb..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/* src/threads/threadlist.h - different thread-lists
-
-   Copyright (C) 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 _THREADLIST_H
-#define _THREADLIST_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "threads/thread.h"
-
-
-/* function prototypes ********************************************************/
-
-void          threadlist_init(void);
-
-void          threadlist_add(threadobject *t);
-void          threadlist_remove(threadobject *t);
-threadobject *threadlist_first(void);
-threadobject *threadlist_next(threadobject *t);
-
-void          threadlist_free_add(threadobject *t);
-void          threadlist_free_remove(threadobject *t);
-threadobject *threadlist_free_first(void);
-
-int           threadlist_get_non_daemons(void);
-
-void          threadlist_index_add(int index);
-int           threadlist_get_free_index(void);
-
-/* implementation specific functions */
-
-void          threadlist_impl_init(void);
-
-void          threadlist_lock(void);
-void          threadlist_unlock(void);
-
-#endif /* _THREADLIST_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/threads/threadlist.hpp b/src/threads/threadlist.hpp
new file mode 100644 (file)
index 0000000..2a9f205
--- /dev/null
@@ -0,0 +1,144 @@
+/* src/threads/threadlist.hpp - different thread-lists
+
+   Copyright (C) 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 _THREADLIST_HPP
+#define _THREADLIST_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "threads/thread.hpp"
+
+#include "toolbox/list.hpp"
+
+
+/* ThreadList *****************************************************************/
+
+#ifdef __cplusplus
+
+using std::list;
+
+class ThreadList {
+private:
+       static Mutex               _mutex;              // a mutex for all thread lists
+
+       static list<threadobject*> _active_thread_list; // list of active threads
+       static list<threadobject*> _free_thread_list;   // list of free threads
+       static list<int32_t>       _free_index_list;    // list of free thread indexes
+
+       static int32_t             _number_of_non_daemon_threads;
+
+       static inline void          remove_from_active_thread_list(threadobject* t);
+       static inline void          add_to_free_thread_list(threadobject* t);
+       static inline void          add_to_free_index_list(int32_t index);
+
+private:
+       // Comparator class.
+       class comparator : public std::binary_function<threadobject*, int32_t, bool> {
+       public:
+               bool operator() (const threadobject* t, const int32_t index) const
+               {
+                       return (t->index == index);
+               }
+       };
+
+public:
+       static inline void          lock()   { _mutex.lock(); }
+       static inline void          unlock() { _mutex.unlock(); }
+
+       // TODO make private
+       static inline void          add_to_active_thread_list(threadobject* t);
+
+       static void                 dump_threads();
+       static inline threadobject* get_main_thread();
+       static threadobject*        get_free_thread();
+       static int32_t              get_free_thread_index();
+       static int32_t              get_number_of_non_daemon_threads();
+       static threadobject*        get_thread_by_index(int32_t index);
+       static threadobject*        get_thread_from_java_object(java_handle_t* h);
+       static void                 release_thread(threadobject* t);
+};
+
+
+inline void ThreadList::add_to_active_thread_list(threadobject* t)
+{
+       _active_thread_list.push_back(t);
+}
+
+inline void ThreadList::remove_from_active_thread_list(threadobject* t)
+{
+       _active_thread_list.remove(t);
+}
+
+inline void ThreadList::add_to_free_thread_list(threadobject* t)
+{
+       _free_thread_list.push_back(t);
+}
+
+inline void ThreadList::add_to_free_index_list(int32_t index)
+{
+       _free_index_list.push_back(index);
+}
+
+inline threadobject* ThreadList::get_main_thread()
+{
+       return _active_thread_list.front();
+}
+
+#else
+
+typedef struct ThreadList ThreadList;
+
+void ThreadList_lock();
+void ThreadList_unlock();
+void ThreadList_dump_threads();
+void ThreadList_release_thread(threadobject* t);
+threadobject* ThreadList_get_free_thread();
+int32_t ThreadList_get_free_thread_index();
+void ThreadList_add_to_active_thread_list(threadobject* t);
+threadobject* ThreadList_get_thread_by_index(int32_t index);
+threadobject* ThreadList_get_main_thread();
+threadobject* ThreadList_get_thread_from_java_object(java_handle_t* h);
+int32_t ThreadList_get_number_of_non_daemon_threads();
+
+#endif
+
+#endif // _THREADLIST_HPP
+
+
+/*
+ * 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 e6d1085cd40a0158c499e11e25802783ae87ce1b..c5c2cae128d049c22d2c0a37dde36f5f7a120854 100644 (file)
@@ -1,9 +1,7 @@
 ## src/toolbox/Makefile.am
 ##
-## 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.
 ##
 ## along with this program; if not, write to the Free Software
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
-##
-## Contact: cacao@cacaojvm.org
-##
-## Authors: Christian Thalinger
-##
-##
+
+
 AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR)
 
 LIBS =
@@ -39,18 +33,13 @@ libtoolbox_la_SOURCES = \
        avl.h \
        bitvector.c \
        bitvector.h \
-       chain.c \
-       chain.h \
        hashtable.c \
        hashtable.h \
-       list.c \
-       list.h \
+       list.hpp \
        logging.c \
        logging.h \
        set.h \
        set.c \
-       tree.c \
-       tree.h \
        util.c \
        util.h \
        worklist.c \
index 4fe67c5c992af864f4d44c727f00df683831af79..404328c05dba516049198abc7f42db81b3fa7332 100644 (file)
@@ -1,9 +1,7 @@
 /* src/toolbox/avl.c - AVL tree implementation
 
-   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.
 
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
 
 #include "toolbox/avl.h"
 #include "toolbox/logging.h"
 
 #include "vm/global.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 
 /* avl_create ******************************************************************
@@ -54,18 +52,11 @@ avl_tree_t *avl_create(avl_comparator *comparator)
 
        t = NEW(avl_tree_t);
 
+       t->mutex      = Mutex_new();
        t->root       = NULL;
        t->comparator = comparator;
        t->entries    = 0;
 
-#if defined(ENABLE_THREADS)
-       /* create lock object for this tree */
-
-       t->lock       = NEW(java_object_t);
-
-       LOCK_INIT_OBJECT_LOCK(t->lock);
-#endif
-
        return t;
 }
 
@@ -312,7 +303,7 @@ bool avl_insert(avl_tree_t *tree, void *data)
        assert(tree);
        assert(data);
 
-       LOCK_MONITOR_ENTER(tree->lock);
+       Mutex_lock(tree->mutex);
 
        /* if we don't have a root node, create one */
 
@@ -325,7 +316,7 @@ bool avl_insert(avl_tree_t *tree, void *data)
 
        tree->entries++;
 
-       LOCK_MONITOR_EXIT(tree->lock);
+       Mutex_unlock(tree->mutex);
 
        /* insertion was ok */
 
@@ -348,7 +339,7 @@ void *avl_find(avl_tree_t *tree, void *data)
        assert(tree);
        assert(data);
 
-       LOCK_MONITOR_ENTER(tree->lock);
+       Mutex_lock(tree->mutex);
 
        /* search the tree for the given node */
 
@@ -360,7 +351,7 @@ void *avl_find(avl_tree_t *tree, void *data)
                /* was the entry found? return it */
 
                if (res == 0) {
-                       LOCK_MONITOR_EXIT(tree->lock);
+                       Mutex_unlock(tree->mutex);
 
                        return node->data;
                }
@@ -370,7 +361,7 @@ void *avl_find(avl_tree_t *tree, void *data)
                node = node->childs[(res < 0) ? AVL_LEFT : AVL_RIGHT];
        }
 
-       LOCK_MONITOR_EXIT(tree->lock);
+       Mutex_unlock(tree->mutex);
 
        /* entry was not found, returning NULL */
 
index a8dcaba588949a370324a4f0adb0daecf23861ce..c95513b30ea0312a43e77701b4452ab9046be80f 100644 (file)
@@ -1,9 +1,7 @@
 /* src/toolbox/avl.h - AVL tree implementation
 
-   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.
 
@@ -32,6 +30,8 @@
 
 #include "vm/types.h"
 
+#include "threads/mutex.hpp"
+
 #include "vm/global.h"
 
 
@@ -55,12 +55,10 @@ typedef struct avl_node_t avl_node_t;
 /* avl_tree_t *****************************************************************/
 
 struct avl_tree_t {
-#if defined(ENABLE_THREADS)
-       java_object_t     *lock;            /* threads lock object                */
-#endif
-       avl_node_t        *root;            /* pointer to root node               */
-       avl_comparator    *comparator;      /* pointer to comparison function     */
-       s4                 entries;         /* contains number of entries         */
+       Mutex*          mutex;              ///< Mutex to lock the tree.
+       avl_node_t     *root;               /* pointer to root node               */
+       avl_comparator *comparator;         /* pointer to comparison function     */
+       s4              entries;            /* contains number of entries         */
 };
 
 
@@ -75,6 +73,10 @@ struct avl_node_t {
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 avl_tree_t *avl_create(avl_comparator *comparator);
 bool        avl_insert(avl_tree_t *tree, void *data);
 void       *avl_find(avl_tree_t *tree, void *data);
@@ -83,6 +85,10 @@ void       *avl_find(avl_tree_t *tree, void *data);
 void        avl_dump(avl_node_t* node, s4 indent);
 #endif
 
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
 #endif /* _AVL_H */
 
 
index bde41ff7ce95d2f4aecff7f569eede28e8d8ede1..66b9df11561033c0222f2486dd8a1f527b5551a0 100644 (file)
@@ -1,9 +1,8 @@
 /* src/toolbox/bitvector.c - bitvector implementation
 
-   Copyright (C) 2005, 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) 2005, 2006
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
 
    This file is part of CACAO.
 
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    02111-1307, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Christian Ullrich
+*/
 
 
-*/
+#include "config.h"
 
 #include "mm/memory.h"
 #include "toolbox/bitvector.h"
@@ -115,7 +112,7 @@ bitvector bv_new(int size) {
     /* n = (((size+7)/8) + sizeof(int) - 1)/sizeof(int);  */
        n = BV_NUM_INTS(size);
 
-       bv = DMNEW(int, n);
+       bv = DumpMemory_allocate(sizeof(int) * n);
 
        for(i = 0; i < n; i++) bv[i] = 0;
    
diff --git a/src/toolbox/chain.c b/src/toolbox/chain.c
deleted file mode 100644 (file)
index ae1bb7c..0000000
+++ /dev/null
@@ -1,315 +0,0 @@
-/* src/toolbox/chain.c - management of doubly linked lists with external linking
-
-   Copyright (C) 1996-2005, 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
-
-   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.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Reinhard Grafl
-
-   Changes: Christian Thalinger
-
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "mm/memory.h"
-#include "toolbox/chain.h"
-
-
-chain *chain_new(void)
-{
-       chain *c;
-       
-       c = NEW(chain);
-       c->usedump = 0;
-       c->first = NULL;
-       c->last = NULL;
-       c->active = NULL;
-
-       return c;
-}
-
-
-chain *chain_dnew(void)
-{
-       chain *c;
-       
-       c = DNEW(chain);
-       c->usedump = 1;
-       c->first = NULL;
-       c->last = NULL;
-       c->active = NULL;
-
-       return c;
-}
-
-
-void chain_free(chain *c)
-{
-       chainlink *l;
-
-       assert(!c->usedump);
-
-       l = c->first;
-       while (l) {
-               chainlink *nextl = l->next;
-               
-               FREE(l, chainlink);
-               l = nextl;      
-       }
-       
-       FREE(c, chain);
-}
-
-
-void chain_addafter(chain *c, void *element)
-{
-       chainlink *active;
-       chainlink *newlink;
-
-    active = c->active;
-
-       if (c->usedump) {
-               newlink = DNEW(chainlink);
-
-       } else {
-               newlink = NEW(chainlink);
-       }
-
-       newlink->element = element;
-       
-       if (active) {
-               newlink->next = active->next;
-               newlink->prev = active;
-               
-               active->next = newlink;
-               if (newlink->next) {
-                       newlink->next->prev = newlink;
-
-               } else {
-                       c->last = newlink;
-               }
-
-       } else {
-               newlink->next = NULL;
-               newlink->prev = NULL;
-
-               c->active = newlink;    
-               c->first = newlink;
-               c->last = newlink;
-       }
-}
-
-
-void chain_addbefore(chain *c, void *element)
-{
-       chainlink *active;
-       chainlink *newlink;
-
-    active = c->active;
-
-       if (c->usedump) {
-               newlink = DNEW(chainlink);
-
-       } else {
-               newlink = NEW(chainlink);
-       }
-       
-       newlink->element = element;
-       
-       if (active) {
-               newlink->next = active;
-               newlink->prev = active->prev;
-               
-               active->prev = newlink;
-               if (newlink->prev) {
-                       newlink->prev->next = newlink;
-
-               } else {
-                       c->first = newlink;
-               }
-
-       } else {
-               newlink->next = NULL;
-               newlink->prev = NULL;
-
-               c->active = newlink;    
-               c->first = newlink;
-               c->last = newlink;
-       }
-}
-
-
-void chain_addlast(chain *c, void *e)
-{
-       chain_last(c);
-       chain_addafter(c, e);
-}
-
-
-void chain_addfirst(chain *c, void *e)
-{
-       chain_first(c);
-       chain_addbefore(c, e);
-}
-
-
-void chain_remove(chain *c)
-{
-       chainlink *active;
-       
-       active = c->active;
-       assert(active);
-
-       if (active->next) {
-               active->next->prev = active->prev;
-
-       } else {
-               c->last = active->prev;
-       }
-       
-       if (active->prev) {
-               active->prev->next = active->next;
-
-       } else {
-               c->first = active->next;
-       }
-
-
-       if (active->prev) {
-               c->active = active->prev;
-
-       } else {
-               c->active = active->next;
-       }
-
-       if (!c->usedump)
-               FREE(active, chainlink);
-}
-
-
-void *chain_remove_go_prev(chain *c)
-{
-       chain_remove(c);
-       return chain_this(c);
-}
-
-
-
-void chain_removespecific(chain *c, void *e)
-{
-       void *ce;
-       
-       ce = chain_first(c);
-       while (ce) {
-               if (e == ce) {
-                       chain_remove(c);
-                       return;
-               }
-
-        ce = chain_next(c);
-       }
-}
-
-
-void *chain_next(chain *c)
-{
-       chainlink *active;
-       
-       active = c->active;
-
-       if (!active)
-               return NULL;
-       
-       if (active->next) {
-               c->active = active->next;
-               return c->active->element;
-       }
-               
-       return NULL;
-}
-
-
-void *chain_prev(chain *c)
-{
-       chainlink *active;
-       
-       active = c->active;
-
-       if (!active)
-               return NULL;
-       
-       if (active->prev) {
-               c->active = active->prev;
-               return c->active->element;
-       }
-
-       return NULL;
-}
-
-
-void *chain_this(chain *c)
-{
-       if (c->active)
-               return c->active->element;
-
-       return NULL;
-}
-
-
-void *chain_first(chain *c)
-{
-       c->active = c->first;
-
-       if (c -> active)
-               return c->active->element;
-
-       return NULL;
-}
-
-void *chain_last(chain *c)
-{
-       c->active = c->last;
-
-       if (c->active)
-               return c->active->element;
-
-       return NULL;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/toolbox/chain.h b/src/toolbox/chain.h
deleted file mode 100644 (file)
index 29ec746..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/* toolbox/chain.h - management of doubly linked lists with external linking
-
-   Copyright (C) 1996-2005, 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
-
-   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.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Reinhard Grafl
-
-
-*/
-
-
-#ifndef _CHAIN_H
-#define _CHAIN_H
-
-typedef struct chainlink {          /* structure for list element */
-       struct chainlink *next;
-       struct chainlink *prev;
-       void *element;
-} chainlink;
-
-typedef struct chain {             /* structure for list */
-       int  usedump;   
-
-       chainlink *first;
-       chainlink *last;
-       chainlink *active;
-} chain;
-
-
-/* function prototypes */
-chain *chain_new(void);
-chain *chain_dnew(void);
-void chain_free(chain *c);
-
-void chain_addafter(chain *c, void *element);
-void chain_addbefore(chain *c, void *element);
-void chain_addlast(chain *c, void *element);
-void chain_addfirst(chain *c, void *element);
-
-void chain_remove(chain *c);
-void *chain_remove_go_prev(chain *c);
-void chain_removespecific(chain *c, void *element);
-
-void *chain_next(chain *c);
-void *chain_prev(chain *c);
-void *chain_this(chain *c);
-
-void *chain_first(chain *c);
-void *chain_last(chain *c);
-
-
-/*
---------------------------- interface description ------------------------
-
-Usage of these functions for list management is possible without additional
-preparation in the element structures, as opposed to the module 'list'.
-
-Consequently, the functions are a little slower and need more memory.
-
-A new list is created with
-       chain_new
-or  chain_dnew.
-The latter allocates all additional data structures on the dump memory (faster)
-for which no explicit freeing is necessary after the processing. Care needs to
-be taken to not accidentally free parts of these structures by calling
-'dump_release' too early.
-
-After usage, a list can be freed with
-       chain_free.
-(use only if the list was created with 'chain_new')
-
-
-Adding elements is easy with:
-       chain_addafter, chain_addlast, chain_addbefore, chain_addfirst          
-       
-Search the list with:
-       chain_first, chain_last, chain_prev, chain_next, chain_this
-       
-Delete elements from the list:
-       chain_remove, chain_remove_go_prev, chain_removespecific
-       
-       
-ATTENTION: As mentioned earlier, there are no pointers to the list or to other
-nodes inside the list elements, so list elements cannot be used as pointers
-into the list. Therefore a 'cursor' is used to make one element current. Every
-insertion/deletion occurs at a position relative to this cursor.
-
-*/
-
-#endif /* _CHAIN_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:
- */
index f502fca4d8e48ad819c84b06e5ee6a1fcc9a27be..dd49f3de543a65e191c909da805d04ab9c5764df 100644 (file)
@@ -1,9 +1,7 @@
 /* src/toolbox/hashtable.c - functions for internal hashtables
 
-   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.
 
@@ -30,7 +28,7 @@
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
 
 #include "toolbox/hashtable.h"
 
@@ -41,7 +39,7 @@
 
    Initializes a hashtable structure and allocates memory. The
    parameter size specifies the initial size of the hashtable.
-       
+
 *******************************************************************************/
 
 void hashtable_create(hashtable *hash, u4 size)
@@ -49,13 +47,11 @@ void hashtable_create(hashtable *hash, u4 size)
        /* initialize locking pointer */
 
 #if defined(ENABLE_THREADS)
-       /* We need to seperately allocate a java_object_t here, as we
-          need to store the lock object in the new hashtable if it's
-          resized.  Otherwise we get an IllegalMonitorStateException. */
-
-       hash->header = NEW(java_object_t);
+       /* We need to seperately allocate a mutex here, as we need to
+          store the lock object in the new hashtable if it's resized.
+          Otherwise we get an IllegalMonitorStateException. */
 
-       LOCK_INIT_OBJECT_LOCK(hash->header);
+       hash->mutex   = Mutex_new();
 #endif
 
        /* set initial hash values */
@@ -89,9 +85,9 @@ hashtable *hashtable_resize(hashtable *hash, u4 size)
        /* We need to store the old lock object in the new hashtable.
           Otherwise we get an IllegalMonitorStateException. */
 
-       FREE(newhash->header, java_object_t);
+       Mutex_delete(newhash->mutex);
 
-       newhash->header  = hash->header;
+       newhash->mutex   = hash->mutex;
 #endif
 
        /* store the number of entries in the new hashtable */
index 1712ae99dd8cd1174fe641e5066e20a7edc8b2d2..65b166e41defb5fcdec43d9b46ae216975b756f9 100644 (file)
@@ -1,9 +1,7 @@
 /* src/toolbox/hashtable.h - functions for internal hashtables
 
-   Copyright (C) 1996-2005, 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) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Reinhard Grafl
-            Christian Thalinger
-
 */
 
 
@@ -41,8 +34,10 @@ typedef struct hashtable hashtable;
 #include "config.h"
 #include "vm/types.h"
 
+#include "threads/mutex.hpp"
+
 #include "vm/global.h"
-#include "vmcore/utf8.h"
+#include "vm/utf8.h"
 
 
 /* data structures for hashtables ********************************************
@@ -100,7 +95,7 @@ hashtable.ptr-->+-------------------+
 
 struct hashtable {            
 #if defined(ENABLE_THREADS)
-       java_object_t      *header;         /* required for locking               */
+       Mutex              *mutex;          /* required for locking               */
 #endif
        u4                  size;           /* current size of the hashtable      */
        u4                  entries;        /* number of entries in the table     */
@@ -110,6 +105,10 @@ struct hashtable {
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* create hashtable */
 void hashtable_create(hashtable *hash, u4 size);
 
@@ -119,6 +118,10 @@ hashtable *hashtable_resize(hashtable *hash, u4 size);
 /* frees a hashtable */
 void hashtable_free(hashtable *hash);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _HASHTABLE_H */
 
 
diff --git a/src/toolbox/list.c b/src/toolbox/list.c
deleted file mode 100644 (file)
index 4de7222..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-/* src/toolbox/list.c - double linked list
-
-   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 <stdint.h>
-#include <stdlib.h>
-
-#include "mm/memory.h"
-
-#include "threads/lock-common.h"
-
-#include "toolbox/list.h"
-
-
-/* list_create *****************************************************************
-
-   Allocates a new list and initializes the lock object.
-
-*******************************************************************************/
-
-list_t *list_create(int nodeoffset)
-{
-       list_t *l;
-
-       l = NEW(list_t);
-
-       LOCK_INIT_OBJECT_LOCK(l);
-
-       l->first      = NULL;
-       l->last       = NULL;
-       l->nodeoffset = nodeoffset;
-       l->size       = 0;
-
-       return l;
-}
-
-
-/* list_free *******************************************************************
-
-   Free a list.
-
-*******************************************************************************/
-
-void list_free(list_t *l)
-{
-       assert(l != NULL);
-
-       FREE(l, list_t);
-}
-
-
-/* list_create_dump ************************************************************
-
-   Allocates a new list on the dump memory.
-
-   ATTENTION: This list does NOT initialize the locking object!!!
-
-*******************************************************************************/
-
-list_t *list_create_dump(int nodeoffset)
-{
-       list_t *l;
-
-       l = DNEW(list_t);
-
-       l->first      = NULL;
-       l->last       = NULL;
-       l->nodeoffset = nodeoffset;
-       l->size       = 0;
-
-       return l;
-}
-
-
-/* list_lock *******************************************************************
-
-   Locks the list.
-
-*******************************************************************************/
-
-void list_lock(list_t *l)
-{
-       LOCK_MONITOR_ENTER(l);
-}
-
-
-/* list_unlock *****************************************************************
-
-   Unlocks the list.
-
-*******************************************************************************/
-
-void list_unlock(list_t *l)
-{
-       LOCK_MONITOR_EXIT(l);
-}
-
-
-/* list_add_first **************************************************************
-
-   Adds the element as first element.
-
-*******************************************************************************/
-
-void list_add_first(list_t *l, void *element)
-{
-       listnode_t *ln;
-
-       ln = (listnode_t *) (((uint8_t *) element) + l->nodeoffset);
-
-       if (l->first) {
-               ln->prev       = NULL;
-               ln->next       = l->first;
-               l->first->prev = ln;
-               l->first       = ln;
-       }
-       else {
-               ln->prev = NULL;
-               ln->next = NULL;
-               l->last  = ln;
-               l->first = ln;
-       }
-
-       /* Increase number of elements. */
-
-       l->size++;
-}
-
-
-/* list_add_last ***************************************************************
-
-   Adds the element as last element.
-
-*******************************************************************************/
-
-void list_add_last(list_t *l, void *element)
-{
-       listnode_t *ln;
-
-       ln = (listnode_t *) (((uint8_t *) element) + l->nodeoffset);
-
-       if (l->last) {
-               ln->prev      = l->last;
-               ln->next      = NULL;
-               l->last->next = ln;
-               l->last       = ln;
-       }
-       else {
-               ln->prev = NULL;
-               ln->next = NULL;
-               l->last  = ln;
-               l->first = ln;
-       }
-
-       /* Increase number of elements. */
-
-       l->size++;
-}
-
-
-/* list_add_before *************************************************************
-
-   Adds the element newelement to the list l before element.
-
-   [ A ] <-> [ newn ] <-> [ n ] <-> [ B ]
-
-*******************************************************************************/
-
-void list_add_before(list_t *l, void *element, void *newelement)
-{
-       listnode_t *ln;
-       listnode_t *newln;
-
-       ln    = (listnode_t *) (((uint8_t *) element) + l->nodeoffset);
-       newln = (listnode_t *) (((uint8_t *) newelement) + l->nodeoffset);
-
-       /* Set the new links. */
-
-       newln->prev = ln->prev;
-       newln->next = ln;
-
-       if (newln->prev)
-               newln->prev->next = newln;
-
-       ln->prev = newln;
-
-       /* set list's first and last if necessary */
-
-       if (l->first == ln)
-               l->first = newln;
-
-       if (l->last == ln)
-               l->last = newln;
-
-       /* Increase number of elements. */
-
-       l->size++;
-}
-
-
-/* list_remove ***************************************************************
-
-   Removes the element.
-
-*******************************************************************************/
-
-void list_remove(list_t *l, void *element)
-{
-       listnode_t *ln;
-
-       ln = (listnode_t *) (((uint8_t *) element) + l->nodeoffset);
-       
-       if (ln->next)
-               ln->next->prev = ln->prev;
-       else
-               l->last = ln->prev;
-
-       if (ln->prev)
-               ln->prev->next = ln->next;
-       else
-               l->first = ln->next;
-
-       ln->next = NULL;
-       ln->prev = NULL;
-
-       /* Decrease number of elements. */
-
-       l->size--;
-}
-
-/* list_first ******************************************************************
-
-   Returns the first element of the list.
-
-*******************************************************************************/
-
-void *list_first(list_t *l)
-{
-       void *el;
-
-       if (l->first == NULL)
-               el = NULL;
-       else
-               el = ((uint8_t *) l->first) - l->nodeoffset;
-
-       return el;
-}
-
-
-/* list_last *******************************************************************
-
-   Returns the last element of the list.
-
-*******************************************************************************/
-
-void *list_last(list_t *l)
-{
-       void *el;
-
-       if (l->last == NULL)
-               el = NULL;
-       else
-               el = ((uint8_t *) l->last) - l->nodeoffset;
-
-       return el;
-}
-
-
-/* list_next *******************************************************************
-
-   Returns the next element of element from the list.
-
-*******************************************************************************/
-
-void *list_next(list_t *l, void *element)
-{
-       listnode_t *ln;
-       void       *el;
-
-       ln = (listnode_t *) (((uint8_t *) element) + l->nodeoffset);
-
-       if (ln->next == NULL)
-               el = NULL;
-       else
-               el = ((uint8_t *) ln->next) - l->nodeoffset;
-
-       return el;
-}
-
-       
-/* list_prev *******************************************************************
-
-   Returns the previous element of element from the list.
-
-*******************************************************************************/
-
-void *list_prev(list_t *l, void *element)
-{
-       listnode_t *ln;
-       void       *el;
-
-       ln = (listnode_t *) (((uint8_t *) element) + l->nodeoffset);
-
-       if (ln->prev == NULL)
-               el = NULL;
-       else
-               el = ((uint8_t *) ln->prev) - l->nodeoffset;
-
-       return el;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/toolbox/list.h b/src/toolbox/list.h
deleted file mode 100644 (file)
index 6837e3b..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/* src/toolbox/list.h - synchronized linked list
-
-   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 _LIST_H
-#define _LIST_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/global.h"
-
-
-/* ---------------------- interface description -----------------------------
-
-The list management with this module works like this:
-       
-       - to be used in a list, a structure must have an element of type
-         'listnode'.
-         
-       - there needs to be a structure of type 'list'.
-       
-       - the function list_init(l, nodeoffset) initializes the structure.
-         nodeoffset is the offset of the 'listnode' from the start of the
-         structure in bytes.
-         
-       - The remaining functions provide inserting, removing and searching.
-         
-This small example aims to demonstrate correct usage:
-
-
-
-       void bsp() {
-               struct node {
-                       listnode linkage;
-                       int value;
-                       } a,b,c, *el;
-                       
-               list l;
-               
-               a.value = 7;
-               b.value = 9;
-               c.value = 11;
-               
-               list_init (&l, OFFSET(struct node,linkage) );
-               list_addlast (&l, a);
-               list_addlast (&l, b);
-               list_addlast (&l, c);
-               
-               e = list_first (&l);
-               while (e) {
-                       printf ("Element: %d\n", e->value);
-                       e = list_next (&l,e);
-                       }
-       }
-       
-       
-       The output from this program should be:
-               7
-               9
-               11
-
-
-
-The reason for the usage of 'nodeoffset' is that this way, the same node can
-part of different lists (there must be one 'listnode' element for every
-distinct list).
-
-*/
-
-/* listnode_t *****************************************************************/
-
-typedef struct listnode_t listnode_t;
-
-struct listnode_t {
-       listnode_t *next;
-       listnode_t *prev;
-};
-
-
-/* list_t *********************************************************************/
-
-typedef struct list_t list_t;
-
-struct list_t {
-#if defined(ENABLE_THREADS)
-       java_object_t      lock;            /* threads lock object                */
-#endif
-       listnode_t        *first;
-       listnode_t        *last;
-       int                nodeoffset;
-       int                size;            /* number of elements in the list     */
-};
-
-
-/* function prototypes ********************************************************/
-
-list_t *list_create(int nodeoffset);
-list_t *list_create_dump(int nodeoffset);
-
-void    list_free(list_t *l);
-
-void    list_lock(list_t *l);
-void    list_unlock(list_t *l);
-
-void    list_add_first(list_t *l, void *element);
-void    list_add_last(list_t *l, void *element);
-void    list_add_before(list_t *l, void *element, void *newelement);
-
-void    list_remove(list_t *l, void *element);
-
-void   *list_first(list_t *l);
-void   *list_last(list_t *l);
-
-void   *list_next(list_t *l, void *element);
-void   *list_prev(list_t *l, void *element);
-
-#endif /* _LIST_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:
- */
diff --git a/src/toolbox/list.hpp b/src/toolbox/list.hpp
new file mode 100644 (file)
index 0000000..0ca05c8
--- /dev/null
@@ -0,0 +1,132 @@
+/* src/toolbox/list.hpp - linked list
+
+   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 _LIST_HPP
+#define _LIST_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+#include <list>
+#endif
+
+#include "threads/mutex.hpp"
+
+
+#ifdef __cplusplus
+
+/**
+ * List implementation with a Mutex.
+ */
+template<class T> class List : protected std::list<T> {
+private:
+       Mutex _mutex;
+
+public:
+       virtual ~List() {}
+
+       void lock  () { _mutex.lock(); }
+       void unlock() { _mutex.unlock(); }
+
+       // make iterator of std::list visible
+       using std::list<T>::iterator;
+       using std::list<T>::reverse_iterator;
+
+       // make functions of std::list visible
+       using std::list<T>::back;
+       using std::list<T>::begin;
+       using std::list<T>::clear;
+       using std::list<T>::empty;
+       using std::list<T>::end;
+       using std::list<T>::front;
+       using std::list<T>::push_back;
+       using std::list<T>::push_front;
+       using std::list<T>::rbegin;
+       using std::list<T>::remove;
+       using std::list<T>::rend;
+       using std::list<T>::size;
+};
+
+
+// Required by DumpList.
+#include "mm/dumpmemory.hpp"
+
+
+/**
+ * List implementation with dump memory.
+ */
+template<class T> class DumpList : protected std::list<T, DumpMemoryAllocator<T> > {
+public:
+       virtual ~DumpList() {}
+
+       // make iterator of std::list visible
+       using std::list<T, DumpMemoryAllocator<T> >::iterator;
+       using std::list<T, DumpMemoryAllocator<T> >::reverse_iterator;
+
+       // make functions of std::list visible
+       using std::list<T, DumpMemoryAllocator<T> >::back;
+       using std::list<T, DumpMemoryAllocator<T> >::begin;
+       using std::list<T, DumpMemoryAllocator<T> >::clear;
+       using std::list<T, DumpMemoryAllocator<T> >::empty;
+       using std::list<T, DumpMemoryAllocator<T> >::end;
+       using std::list<T, DumpMemoryAllocator<T> >::front;
+       using std::list<T, DumpMemoryAllocator<T> >::push_back;
+       using std::list<T, DumpMemoryAllocator<T> >::push_front;
+       using std::list<T, DumpMemoryAllocator<T> >::rbegin;
+       using std::list<T, DumpMemoryAllocator<T> >::remove;
+       using std::list<T, DumpMemoryAllocator<T> >::rend;
+       using std::list<T, DumpMemoryAllocator<T> >::size;
+
+       void* operator new(size_t size) {
+               return DumpMemory::allocate(size);
+       }
+
+       void operator delete(void* p) {}
+};
+
+#else
+
+typedef struct List List;
+typedef struct DumpList DumpList;
+
+#endif
+
+#endif // _LIST_HPP
+
+
+/*
+ * 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:
+ */
index c9fea656a0933c2942b683ff8ddd6640008f5f6d..7ff7f1b69fafe369178fa28fa28f77f1d6bb440a 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "mm/memory.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
 #include "toolbox/logging.h"
 #include "toolbox/util.h"
@@ -41,7 +41,7 @@
 #include "vm/global.h"
 
 #if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
+# include "vm/statistics.h"
 #endif
 
 
index f6def38059908089d224f4f29446b0f8ac2e031e..eed61bd8dd9173fbc10d2483de899d05c97366d7 100644 (file)
@@ -1,9 +1,7 @@
 /* src/toolbox/logging.h - contains logging functions
 
-   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.
 
 #include <stdio.h>
 #include <stdarg.h>
 
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/utf8.h"
+#include "vm/class.hpp"
+#include "vm/method.hpp"
+#include "vm/utf8.h"
 
 
-/*500 is to small for eclipse traces, (builtin_trace_args, perhaps the
-buffer should be created there dynamically, if the text is longer,
-instead of setting the size for all invocations that big*/
-
-#define MAXLOGTEXT  16383 
-
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void log_init(const char *fname);
 
 void log_start(void);
@@ -67,6 +63,10 @@ void log_message_method(const char *msg, methodinfo *m);
 #define log_text(s) log_println("%s", (s))
 #define dolog log_println
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _LOGGING_H */
 
 
index b4fd7e71e6de9c93f90b6b9ac2353bd5014a8507..c63ddf8827f91b68d35225c7f09820a02111219d 100644 (file)
    elements (pointers).
 */
 
-#include "toolbox/set.h"
+
+#include "config.h"
 
 #include <assert.h>
 
+#include "toolbox/set.h"
+
 #include "mm/memory.h"
 
+#include "vm/global.h"
+
+
 /* struct set ******************************************************************
 
    Represents the set.
@@ -57,9 +63,9 @@ struct set {
 *******************************************************************************/
 
 set *set_new(unsigned capacity) {
-       set *s = DNEW(set);
+       set *s = DumpMemory_allocate(sizeof(set));
 
-       s->elements = DMNEW(void *, capacity);
+       s->elements = DumpMemory_allocate(sizeof(void*) * capacity);
        MZERO(s->elements, void *, capacity);
        s->capacity = capacity;
        s->size = 0;
index 491ce4f17aa0a89f1d4b53668d332ae1d0ce0c1d..5f11bf3c98c10ec7d57ade0ef9e37876349fda02 100644 (file)
 
 */
 
+
 #ifndef _TOOLBOX_SET_H
 #define _TOOLBOX_SET_H
 
+#include "config.h"
+
 #include "vm/global.h"
 
+
 typedef struct set set;
 
 set *set_new(unsigned capacity);
diff --git a/src/toolbox/tree.c b/src/toolbox/tree.c
deleted file mode 100644 (file)
index e76fd23..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/* toolbox/tree.h - binary tree management
-
-   Copyright (C) 1996-2005, 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
-
-   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.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Reinhard Grafl
-
-
-*/
-
-
-#include <stdio.h>
-#include <assert.h>
-
-#include "mm/memory.h"
-#include "toolbox/tree.h"
-
-
-tree *tree_new(treeelementcomperator comperator)
-{
-       tree *t = NEW(tree);
-       
-       t->usedump = 0;
-       t->comperator = comperator;
-       t->top = NULL;
-       t->active = NULL;
-               
-       return t;
-}
-
-
-tree *tree_dnew(treeelementcomperator comperator)
-{
-       tree *t = DNEW(tree);
-       
-       t->usedump = 1;
-       t->comperator = comperator;
-       t->top = NULL;
-       t->active = NULL;
-       
-       return t;
-}
-
-
-static void tree_nodefree(treenode *tn)
-{
-       if (!tn)
-               return;
-
-       tree_nodefree(tn->left);
-       tree_nodefree(tn->right);
-       FREE(tn, treenode);
-}
-
-
-void tree_free(tree *t)
-{
-       assert(!t->usedump);
-       
-       tree_nodefree(t->top);
-       FREE(t, tree);
-}
-
-
-static treenode *tree_nodeadd(tree *t, treenode *par, treenode *n, 
-                                                         void *element, void *key)
-{
-       if (!n) {
-               if (t->usedump) {
-                       n = DNEW(treenode);
-
-               } else {
-                       n = NEW(treenode);
-               }
-               
-               n->left = NULL;
-               n->right = NULL;
-               n->parent = par;
-               n->element = element;
-
-       } else {
-               if (t->comperator(key, n->element) < 0) {
-                       n->left = tree_nodeadd(t, n, n->left, element, key);
-
-               } else {
-                       n->right = tree_nodeadd(t, n, n->right, element, key);
-               }
-       }
-               
-       return n;
-}
-
-
-void tree_add(tree *t, void *element, void *key)
-{
-       t->top = tree_nodeadd(t, NULL, t->top, element, key);
-       t->active = t->top;
-}
-
-
-static treenode *tree_nodefind(tree *t, treenode *n, void *key)
-{
-       int way;
-
-       if (!n)
-               return NULL;
-
-       way = t->comperator(key, n->element);
-       if (way == 0)
-               return n;
-
-       if (way < 0) {
-               return tree_nodefind(t, n->left, key);
-
-       } else {
-               return tree_nodefind (t, n -> right, key);
-       }
-}
-
-
-void *tree_find(tree *t, void *key)
-{
-       treenode *tn = tree_nodefind(t, t->top, key);
-
-       if (!tn)
-               return NULL;
-
-       t->active = tn;
-
-       return tn->element;
-}
-
-
-
-void *tree_this(tree *t)
-{      
-       if (!t->active)
-               return NULL;
-
-       return t->active->element;
-}
-
-
-static treenode *leftmostnode(treenode *t)
-{
-       while (t->left) {
-               t = t->left;
-       }
-
-       return t;
-}
-
-
-void *tree_first(tree *t)
-{
-       treenode *a = t->top;
-
-       if (!a)
-               return NULL;
-
-       a = leftmostnode(a);
-       t->active = a;
-
-       return a->element;
-}
-
-
-void *tree_next (tree *t)
-{
-       treenode *a = t->active;
-       treenode *comefrom = NULL;
-
-       while (a) {
-               if (!a)
-                       return NULL;
-
-               if (a->left && (a->left == comefrom)) {
-                       t -> active = a;
-                       return a->element;
-               }
-       
-               if (a->right && (a->right != comefrom)) {
-                       a = leftmostnode(a->right);
-                       t -> active = a;
-                       return a->element;
-               }
-               
-               comefrom = a;
-               a = a->parent;
-       }
-
-       t->active = NULL;
-
-       return NULL;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/toolbox/tree.h b/src/toolbox/tree.h
deleted file mode 100644 (file)
index e031f93..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* toolbox/tree.h - binary tree management
-
-   Copyright (C) 1996-2005, 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
-
-   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.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Reinhard Grafl
-
-
-*/
-
-
-#ifndef _TREE_H
-#define _TREE_H
-
-typedef int (*treeelementcomperator) (void *key, void * element);
-
-
-typedef struct treenode {
-       struct treenode *left,*right;
-       struct treenode *parent;
-       
-       void *element;
-} treenode;
-
-typedef struct {
-       int usedump;
-       treeelementcomperator comperator;       
-
-       treenode *top;
-       treenode *active;
-} tree;
-
-
-/* function prototypes */
-
-tree *tree_new(treeelementcomperator comperator);
-tree *tree_dnew(treeelementcomperator comperator);
-void tree_free(tree *t);
-
-void tree_add(tree *t, void *element, void *key);
-void *tree_find(tree *t, void *key);
-
-void *tree_this(tree *t);
-void *tree_first(tree *t);
-void *tree_next(tree *t);
-
-#endif /* _TREE_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:
- */
index 82acc8ff7f517543a2999cb0fd9af244295f7f15..2e26c259b6c1be35205db5583e73d469480cd6f7 100644 (file)
@@ -1,9 +1,7 @@
 /* src/toolbox/util.c - contains some utility functions
 
-   Copyright (C) 1996-2005, 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) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
 */
 
 
@@ -41,7 +33,7 @@
 #include "vm/types.h"
 
 #include "mm/memory.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 
 /* _Jv_getcwd ******************************************************************
index 866f410a800be978d805931c80230b242b45e8d3..659ab0eb967aaa913edacc8eb5544aad606fc82a 100644 (file)
@@ -1,9 +1,7 @@
 /* src/toolbox/util.h - contains some utility functions
 
-   Copyright (C) 1996-2005, 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) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
 */
 
 
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 char *_Jv_getcwd(void);
 int   get_variable_message_length(const char *fmt, va_list ap);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _UTIL_H */
 
 
index fb3c8ba88f96f2177342070b9e071271e43ff67b..4dd35b7777dffcaf8468de71eaf49b9965f24311 100644 (file)
@@ -1,9 +1,7 @@
 ## src/vm/Makefile.am
 ##
-## 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.
 ##
@@ -22,7 +20,6 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 
-## Process this file with automake to produce Makefile.in
 
 AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) -I$(top_builddir)/src -I$(top_srcdir)/contrib/vmlog -I$(top_srcdir)/src/native
 
@@ -32,8 +29,8 @@ SUBDIRS = jit
 
 if ENABLE_ASSERTION
 ASSERTION_SOURCES = \
-       assertion.c \
-       assertion.h
+       assertion.cpp \
+       assertion.hpp
 endif
 
 if ENABLE_CYCLES_STATS
@@ -42,6 +39,36 @@ CYCLES_STATS_SOURCES = \
        cycles-stats.h
 endif
 
+if ENABLE_JAVASE
+if ENABLE_ANNOTATIONS
+ANNOTATION_SOURCES = \
+       annotation.c \
+       annotation.h
+endif
+
+STACKMAP_SOURCES = \
+       stackmap.c \
+       stackmap.h
+endif
+
+if ENABLE_RT_TIMING
+RT_TIMING_SOURCES = \
+       rt-timing.c \
+       rt-timing.h
+endif
+
+if ENABLE_STATISTICS
+STATISTICS_SOURCES = \
+       statistics.c \
+       statistics.h
+endif
+
+if ENABLE_ZLIB
+ZLIB_SOURCES = \
+       zip.cpp \
+       zip.hpp
+endif
+
 noinst_HEADERS = \
        global.h \
        types.h
@@ -50,36 +77,65 @@ noinst_LTLIBRARIES = \
        libvm.la
 
 libvm_la_SOURCES = \
+       access.cpp \
+       access.hpp \
+       $(ANNOTATION_SOURCES) \
+       array.cpp \
+       array.hpp \
        $(ASSERTION_SOURCES) \
-       access.c \
-       access.h \
-       array.c \
-       array.h \
-       builtin.c \
-       builtin.h \
-       builtintable.inc \
+       class.cpp \
+       class.hpp \
+       classcache.cpp \
+       classcache.hpp \
        $(CYCLES_STATS_SOURCES) \
-       exceptions.c \
-       exceptions.h \
+       descriptor.c \
+       descriptor.h \
+       exceptions.cpp \
+       exceptions.hpp \
+       field.cpp \
+       field.hpp \
        finalizer.c \
        finalizer.h \
-       initialize.c \
-       initialize.h \
-       jit_interface.h \
-       package.c \
-       package.h \
-       primitive.c \
-       primitive.h \
-       properties.c \
-       properties.h \
-       resolve.c \
-       resolve.h \
+       globals.cpp \
+       globals.hpp \
+       initialize.cpp \
+       initialize.hpp \
+       javaobjects.cpp \
+       javaobjects.hpp \
+       linker.cpp \
+       linker.hpp \
+       loader.cpp \
+       loader.hpp \
+       method.cpp \
+       method.hpp \
+       options.c \
+       options.h \
+       os.cpp \
+       os.hpp \
+       package.cpp \
+       package.hpp \
+       primitive.cpp \
+       primitive.hpp \
+       properties.cpp \
+       properties.hpp \
+       references.h \
+       resolve.cpp \
+       resolve.hpp \
+       $(RT_TIMING_SOURCES) \
        signal.c \
        signallocal.h \
-       string.c \
-       stringlocal.h \
-       vm.c \
-       vm.h
+       $(STACKMAP_SOURCES) \
+       $(STATISTICS_SOURCES) \
+       string.cpp \
+       string.hpp \
+       suck.cpp \
+       suck.hpp \
+       utf8.c \
+       utf8.h \
+       vftbl.hpp \
+       vm.cpp \
+       vm.hpp \
+       $(ZLIB_SOURCES)
 
 libvm_la_LIBADD = \
        jit/libjit.la
diff --git a/src/vm/access.c b/src/vm/access.c
deleted file mode 100644 (file)
index 81ea764..0000000
+++ /dev/null
@@ -1,356 +0,0 @@
-/* src/vm/access.c - checking access rights
-
-   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 <string.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/llni.h"
-
-#include "vm/access.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/method.h"
-
-
-/* access_is_accessible_class **************************************************
-   Check if a class is accessible from another class
-  
-   IN:
-       referer..........the class containing the reference
-       cls..............the result of resolving the reference
-  
-   RETURN VALUE:
-       true.............access permitted
-       false............access denied
-   
-   NOTE:
-       This function performs the checks listed in section 5.4.4.
-          "Access Control" of "The Java(TM) Virtual Machine Specification,
-          Second Edition".
-
-*******************************************************************************/
-
-bool access_is_accessible_class(classinfo *referer, classinfo *cls)
-{
-       assert(referer);
-       assert(cls);
-
-       /* Public classes are always accessible. */
-
-       if (cls->flags & ACC_PUBLIC)
-               return true;
-
-       /* A class in the same package is always accessible. */
-
-       if (SAME_PACKAGE(referer, cls))
-               return true;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       /* Code for Sun's OpenJDK (see
-          hotspot/src/share/vm/runtime/reflection.cpp
-          (Reflection::verify_class_access)): Allow all accesses from
-          sun/reflect/MagicAccessorImpl subclasses to succeed
-          trivially. */
-
-       /* NOTE: This check must be before checks that could return
-          false. */
-
-       if (class_issubclass(referer, class_sun_reflect_MagicAccessorImpl))
-               return true;
-#endif
-
-       /* A non-public class in another package is not accessible. */
-
-       return false;
-}
-
-
-/* access_is_accessible_member *************************************************
-   Check if a field or method is accessible from a given class
-  
-   IN:
-       referer..........the class containing the reference
-       declarer.........the class declaring the member
-       memberflags......the access flags of the member
-  
-   RETURN VALUE:
-       true.............access permitted
-       false............access denied
-
-   NOTE:
-       This function only performs the checks listed in section 5.4.4.
-          "Access Control" of "The Java(TM) Virtual Machine Specification,
-          Second Edition".
-
-          In particular a special condition for protected access with is
-          part of the verification process according to the spec is not
-          checked in this function.
-   
-*******************************************************************************/
-
-bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
-                                                                s4 memberflags)
-{
-       assert(referer);
-       assert(declarer);
-
-       /* Public members are accessible. */
-
-       if (memberflags & ACC_PUBLIC)
-               return true;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       /* Code for Sun's OpenJDK (see
-          hotspot/src/share/vm/runtime/reflection.cpp
-          (Reflection::verify_class_access)): Allow all accesses from
-          sun/reflect/MagicAccessorImpl subclasses to succeed
-          trivially. */
-
-       /* NOTE: This check must be before checks that could return
-          false. */
-
-       if (class_issubclass(referer, class_sun_reflect_MagicAccessorImpl))
-               return true;
-#endif
-
-       /* {declarer is not an interface} */
-
-       /* private members are only accessible by the class itself */
-
-       if (memberflags & ACC_PRIVATE)
-               return (referer == declarer);
-
-       /* {the member is protected or package private} */
-
-       /* protected and package private members are accessible in the
-          same package */
-
-       if (SAME_PACKAGE(referer, declarer))
-               return true;
-
-       /* package private members are not accessible outside the package */
-
-       if (!(memberflags & ACC_PROTECTED))
-               return false;
-
-       /* {the member is protected and declarer is in another package} */
-
-       /* a necessary condition for access is that referer is a subclass
-          of declarer */
-
-       assert((referer->state & CLASS_LINKED) && (declarer->state & CLASS_LINKED));
-
-       if (class_isanysubclass(referer, declarer))
-               return true;
-
-       return false;
-}
-
-
-/* access_check_field **********************************************************
-   Check if the (indirect) caller has access rights to the specified
-   field.
-  
-   IN:
-       f................the field to check
-          callerdepth......number of callers to ignore
-                           For example if the stacktrace looks like this:
-
-                                  [0] java.lang.reflect.Method.invokeNative (Native Method)
-                                  [1] java.lang.reflect.Method.invoke
-                                  [2] <caller>
-
-                                       you must specify 2 so the access rights of <caller> 
-                                               are checked.
-  
-   RETURN VALUE:
-       true.............access permitted
-       false............access denied, an exception has been thrown
-   
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-bool access_check_field(fieldinfo *f, int callerdepth)
-{
-       classinfo *callerclass;
-       char      *msg;
-       int        msglen;
-       utf       *u;
-
-       /* If everything is public, there is nothing to check. */
-
-       if ((f->clazz->flags & ACC_PUBLIC) && (f->flags & ACC_PUBLIC))
-               return true;
-
-       /* Get the caller's class. */
-
-       callerclass = stacktrace_get_caller_class(callerdepth);
-
-       if (callerclass == NULL)
-               return false;
-
-       /* Check access rights. */
-
-       if (!access_is_accessible_member(callerclass, f->clazz, f->flags)) {
-               msglen =
-                       utf_bytes(f->clazz->name) +
-                       strlen(".") +
-                       utf_bytes(f->name) +
-                       strlen(" not accessible from ") +
-                       utf_bytes(callerclass->name) +
-                       strlen("0");
-
-               msg = MNEW(char, msglen);
-
-               utf_copy_classname(msg, f->clazz->name);
-               strcat(msg, ".");
-               utf_cat_classname(msg, f->name);
-               strcat(msg, " not accessible from ");
-               utf_cat_classname(msg, callerclass->name);
-
-               u = utf_new_char(msg);
-
-               MFREE(msg, char, msglen);
-               
-               exceptions_throw_illegalaccessexception(u);
-
-               return false;
-       }
-
-       /* access granted */
-
-       return true;
-}
-#endif
-
-
-/* access_check_method *********************************************************
-   Check if the (indirect) caller has access rights to the specified
-   method.
-  
-   IN:
-       m................the method to check
-          callerdepth......number of callers to ignore
-                           For example if the stacktrace looks like this:
-
-                                  [1] java.lang.reflect.Method.invokeNative (Native Method)
-                                  [1] java.lang.reflect.Method.invoke
-                                  [2] <caller>
-
-                                       you must specify 2 so the access rights of <caller> 
-                                               are checked.
-  
-   RETURN VALUE:
-       true.............access permitted
-       false............access denied, an exception has been thrown
-   
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-bool access_check_method(methodinfo *m, int callerdepth)
-{
-       classinfo *callerclass;
-       char      *msg;
-       int        msglen;
-       utf       *u;
-
-       /* If everything is public, there is nothing to check. */
-
-       if ((m->clazz->flags & ACC_PUBLIC) && (m->flags & ACC_PUBLIC))
-               return true;
-
-       /* Get the caller's class. */
-
-       callerclass = stacktrace_get_caller_class(callerdepth);
-
-       if (callerclass == NULL)
-               return false;
-
-       /* Check access rights. */
-
-       if (!access_is_accessible_member(callerclass, m->clazz, m->flags)) {
-               msglen =
-                       utf_bytes(m->clazz->name) +
-                       strlen(".") +
-                       utf_bytes(m->name) +
-                       utf_bytes(m->descriptor) +
-                       strlen(" not accessible from ") +
-                       utf_bytes(callerclass->name) +
-                       strlen("0");
-
-               msg = MNEW(char, msglen);
-
-               utf_copy_classname(msg, m->clazz->name);
-               strcat(msg, ".");
-               utf_cat_classname(msg, m->name);
-               utf_cat_classname(msg, m->descriptor);
-               strcat(msg, " not accessible from ");
-               utf_cat_classname(msg, callerclass->name);
-
-               u = utf_new_char(msg);
-
-               MFREE(msg, char, msglen);
-               
-               exceptions_throw_illegalaccessexception(u);
-
-               return false;
-       }
-
-       /* access granted */
-
-       return true;
-}
-#endif
-
-
-/*
- * 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/access.cpp b/src/vm/access.cpp
new file mode 100644 (file)
index 0000000..a0abbc1
--- /dev/null
@@ -0,0 +1,364 @@
+/* src/vm/access.c - checking access rights
+
+   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 <string.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "vm/access.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/field.hpp"
+#include "vm/globals.hpp"
+#include "vm/method.hpp"
+
+#include "vm/jit/stacktrace.hpp"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* access_is_accessible_class **************************************************
+   Check if a class is accessible from another class
+  
+   IN:
+       referer..........the class containing the reference
+       cls..............the result of resolving the reference
+  
+   RETURN VALUE:
+       true.............access permitted
+       false............access denied
+   
+   NOTE:
+       This function performs the checks listed in section 5.4.4.
+          "Access Control" of "The Java(TM) Virtual Machine Specification,
+          Second Edition".
+
+*******************************************************************************/
+
+bool access_is_accessible_class(classinfo *referer, classinfo *cls)
+{
+       assert(referer);
+       assert(cls);
+
+       /* Public classes are always accessible. */
+
+       if (cls->flags & ACC_PUBLIC)
+               return true;
+
+       /* A class in the same package is always accessible. */
+
+       if (SAME_PACKAGE(referer, cls))
+               return true;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       /* Code for Sun's OpenJDK (see
+          hotspot/src/share/vm/runtime/reflection.cpp
+          (Reflection::verify_class_access)): Allow all accesses from
+          sun/reflect/MagicAccessorImpl subclasses to succeed
+          trivially. */
+
+       /* NOTE: This check must be before checks that could return
+          false. */
+
+       if (class_issubclass(referer, class_sun_reflect_MagicAccessorImpl))
+               return true;
+#endif
+
+       /* A non-public class in another package is not accessible. */
+
+       return false;
+}
+
+
+/* access_is_accessible_member *************************************************
+   Check if a field or method is accessible from a given class
+  
+   IN:
+       referer..........the class containing the reference
+       declarer.........the class declaring the member
+       memberflags......the access flags of the member
+  
+   RETURN VALUE:
+       true.............access permitted
+       false............access denied
+
+   NOTE:
+       This function only performs the checks listed in section 5.4.4.
+          "Access Control" of "The Java(TM) Virtual Machine Specification,
+          Second Edition".
+
+          In particular a special condition for protected access with is
+          part of the verification process according to the spec is not
+          checked in this function.
+   
+*******************************************************************************/
+
+bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
+                                                                s4 memberflags)
+{
+       assert(referer);
+       assert(declarer);
+
+       /* Public members are accessible. */
+
+       if (memberflags & ACC_PUBLIC)
+               return true;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       /* Code for Sun's OpenJDK (see
+          hotspot/src/share/vm/runtime/reflection.cpp
+          (Reflection::verify_class_access)): Allow all accesses from
+          sun/reflect/MagicAccessorImpl subclasses to succeed
+          trivially. */
+
+       /* NOTE: This check must be before checks that could return
+          false. */
+
+       if (class_issubclass(referer, class_sun_reflect_MagicAccessorImpl))
+               return true;
+#endif
+
+       /* {declarer is not an interface} */
+
+       /* private members are only accessible by the class itself */
+
+       if (memberflags & ACC_PRIVATE)
+               return (referer == declarer);
+
+       /* {the member is protected or package private} */
+
+       /* protected and package private members are accessible in the
+          same package */
+
+       if (SAME_PACKAGE(referer, declarer))
+               return true;
+
+       /* package private members are not accessible outside the package */
+
+       if (!(memberflags & ACC_PROTECTED))
+               return false;
+
+       /* {the member is protected and declarer is in another package} */
+
+       /* a necessary condition for access is that referer is a subclass
+          of declarer */
+
+       assert((referer->state & CLASS_LINKED) && (declarer->state & CLASS_LINKED));
+
+       if (class_isanysubclass(referer, declarer))
+               return true;
+
+       return false;
+}
+
+
+/* access_check_field **********************************************************
+   Check if the (indirect) caller has access rights to the specified
+   field.
+  
+   IN:
+       f................the field to check
+          callerdepth......number of callers to ignore
+                           For example if the stacktrace looks like this:
+
+                                  [0] java.lang.reflect.Method.invokeNative (Native Method)
+                                  [1] java.lang.reflect.Method.invoke
+                                  [2] <caller>
+
+                                       you must specify 2 so the access rights of <caller> 
+                                               are checked.
+  
+   RETURN VALUE:
+       true.............access permitted
+       false............access denied, an exception has been thrown
+   
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+bool access_check_field(fieldinfo *f, int callerdepth)
+{
+       classinfo *callerclass;
+       char      *msg;
+       int        msglen;
+       utf       *u;
+
+       /* If everything is public, there is nothing to check. */
+
+       if ((f->clazz->flags & ACC_PUBLIC) && (f->flags & ACC_PUBLIC))
+               return true;
+
+       /* Get the caller's class. */
+
+       callerclass = stacktrace_get_caller_class(callerdepth);
+
+       if (callerclass == NULL)
+               return false;
+
+       /* Check access rights. */
+
+       if (!access_is_accessible_member(callerclass, f->clazz, f->flags)) {
+               msglen =
+                       utf_bytes(f->clazz->name) +
+                       strlen(".") +
+                       utf_bytes(f->name) +
+                       strlen(" not accessible from ") +
+                       utf_bytes(callerclass->name) +
+                       strlen("0");
+
+               msg = MNEW(char, msglen);
+
+               utf_copy_classname(msg, f->clazz->name);
+               strcat(msg, ".");
+               utf_cat_classname(msg, f->name);
+               strcat(msg, " not accessible from ");
+               utf_cat_classname(msg, callerclass->name);
+
+               u = utf_new_char(msg);
+
+               MFREE(msg, char, msglen);
+               
+               exceptions_throw_illegalaccessexception(u);
+
+               return false;
+       }
+
+       /* access granted */
+
+       return true;
+}
+#endif
+
+
+/* access_check_method *********************************************************
+   Check if the (indirect) caller has access rights to the specified
+   method.
+  
+   IN:
+       m................the method to check
+          callerdepth......number of callers to ignore
+                           For example if the stacktrace looks like this:
+
+                                  [1] java.lang.reflect.Method.invokeNative (Native Method)
+                                  [1] java.lang.reflect.Method.invoke
+                                  [2] <caller>
+
+                                       you must specify 2 so the access rights of <caller> 
+                                               are checked.
+  
+   RETURN VALUE:
+       true.............access permitted
+       false............access denied, an exception has been thrown
+   
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+bool access_check_method(methodinfo *m, int callerdepth)
+{
+       classinfo *callerclass;
+       char      *msg;
+       int        msglen;
+       utf       *u;
+
+       /* If everything is public, there is nothing to check. */
+
+       if ((m->clazz->flags & ACC_PUBLIC) && (m->flags & ACC_PUBLIC))
+               return true;
+
+       /* Get the caller's class. */
+
+       callerclass = stacktrace_get_caller_class(callerdepth);
+
+       if (callerclass == NULL)
+               return false;
+
+       /* Check access rights. */
+
+       if (!access_is_accessible_member(callerclass, m->clazz, m->flags)) {
+               msglen =
+                       utf_bytes(m->clazz->name) +
+                       strlen(".") +
+                       utf_bytes(m->name) +
+                       utf_bytes(m->descriptor) +
+                       strlen(" not accessible from ") +
+                       utf_bytes(callerclass->name) +
+                       strlen("0");
+
+               msg = MNEW(char, msglen);
+
+               utf_copy_classname(msg, m->clazz->name);
+               strcat(msg, ".");
+               utf_cat_classname(msg, m->name);
+               utf_cat_classname(msg, m->descriptor);
+               strcat(msg, " not accessible from ");
+               utf_cat_classname(msg, callerclass->name);
+
+               u = utf_new_char(msg);
+
+               MFREE(msg, char, msglen);
+               
+               exceptions_throw_illegalaccessexception(u);
+
+               return false;
+       }
+
+       /* access granted */
+
+       return true;
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
+
+
+/*
+ * 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/access.h b/src/vm/access.h
deleted file mode 100644 (file)
index 2b8a10c..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* src/vm/access.h - checking access rights
-
-   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 _ACCESS_H
-#define _ACCESS_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/method.h"
-
-
-/* macros *********************************************************************/
-
-#define SAME_PACKAGE(a,b)                                  \
-                       ((a)->classloader == (b)->classloader &&       \
-                        (a)->packagename == (b)->packagename)
-
-
-/* function prototypes ********************************************************/
-
-bool access_is_accessible_class(classinfo *referer, classinfo *cls);
-
-bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
-                                                                int32_t memberflags);
-
-#if defined(ENABLE_JAVASE)
-bool access_check_field(fieldinfo *f, int callerdepth);
-bool access_check_method(methodinfo *m, int callerdepth);
-#endif
-
-#endif /* _ACCESS_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/access.hpp b/src/vm/access.hpp
new file mode 100644 (file)
index 0000000..9ec44c9
--- /dev/null
@@ -0,0 +1,82 @@
+/* src/vm/access.h - checking access rights
+
+   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 _ACCESS_H
+#define _ACCESS_H
+
+#include "config.h"
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/global.h"
+#include "vm/method.hpp"
+
+
+/* macros *********************************************************************/
+
+#define SAME_PACKAGE(a,b)                                  \
+                       ((a)->classloader == (b)->classloader &&       \
+                        (a)->packagename == (b)->packagename)
+
+
+/* function prototypes ********************************************************/
+
+bool access_is_accessible_class(classinfo *referer, classinfo *cls);
+
+bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
+                                                                int32_t memberflags);
+
+#if defined(ENABLE_JAVASE)
+bool access_check_field(fieldinfo *f, int callerdepth);
+bool access_check_method(methodinfo *m, int callerdepth);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACCESS_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/annotation.c b/src/vm/annotation.c
new file mode 100644 (file)
index 0000000..bbca2af
--- /dev/null
@@ -0,0 +1,614 @@
+/* src/vm/annotation.c - class annotations
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/llni.h"
+
+#include "mm/memory.h"
+
+#include "toolbox/logging.h"
+
+#include "vm/annotation.h"
+#include "vm/array.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/loader.hpp"
+#include "vm/primitive.hpp"
+#include "vm/suck.hpp"
+#include "vm/types.h"
+
+#if !defined(ENABLE_ANNOTATIONS)
+# error annotation support has to be enabled when compling this file!
+#endif
+
+
+/* annotation_bytearrays_resize ***********************************************
+
+   Resize an array of bytearrays.
+
+   IN:
+       bytearrays.....array of bytearrays
+       size...........new size of the refered array
+   
+   RETURN VALUE:
+       The new array if a resize was neccessarry, the old if the given size
+       equals the current size or NULL if an error occured.
+
+*******************************************************************************/
+
+static java_handle_objectarray_t *annotation_bytearrays_resize(
+       java_handle_objectarray_t *bytearrays, uint32_t size)
+{
+       java_handle_objectarray_t *newbas = NULL; /* new array     */
+       uint32_t minsize = 0;      /* count of object refs to copy */
+       uint32_t oldsize = 0;      /* size of old array            */
+
+       if (bytearrays != NULL) {
+               oldsize = array_length_get((java_handle_t*)bytearrays);
+               
+               /* if the size already fits do nothing */
+               if (size == oldsize) {
+                       return bytearrays;
+               }
+       }
+       
+       newbas = builtin_anewarray(size,
+               Primitive_get_arrayclass_by_type(PRIMITIVETYPE_BYTE));
+       
+       /* is there a old byte array array? */
+       if (newbas != NULL && bytearrays != NULL) {
+               minsize = size < oldsize ? size : oldsize;
+
+               LLNI_CRITICAL_START;
+               MCOPY(
+                       LLNI_array_data(newbas), LLNI_array_data(bytearrays),
+                       java_object_t*, minsize);
+               LLNI_CRITICAL_END;
+       }
+
+       return newbas;
+}
+
+
+/* annotation_bytearrays_insert ***********************************************
+
+   Insert a bytearray into an array of bytearrays.
+
+   IN:
+       bytearrays........array of bytearrays where 'bytearray' has to be
+                         inserted at position 'index'.
+       index.............position where 'ba' has to be inserted into
+                         'bytearrays'.
+       bytearray.........byte array which has to be inserted into
+                         'bytearrays'.
+
+   RETURN VALUE:
+       The new array if a resize was neccessarry, the old if the given size
+       equals the current size or NULL if an error occured.
+
+*******************************************************************************/
+
+static java_handle_t *annotation_bytearrays_insert(
+       java_handle_t *bytearrays, uint32_t index,
+       java_handle_bytearray_t *bytearray)
+{
+       java_handle_objectarray_t *bas; /* bytearrays                */
+       uint32_t size = 0;              /* current size of the array */
+
+       /* do nothing if NULL is inserted but no array exists */
+       if (bytearray == NULL && bytearrays == NULL) {
+               return NULL;
+       }
+
+       /* get lengths if array exists */
+       if (bytearrays != NULL) {
+               size = array_length_get(bytearrays);
+       }
+
+       bas = (java_handle_objectarray_t*)bytearrays;
+
+       if (bytearray == NULL) {
+               /* insert NULL only if array is big enough */
+               if (size > index) {
+                       array_objectarray_element_set(bas, index, NULL);
+               }
+       }
+       else {
+               /* resize array if it's not enough for inserted value */
+               if (size <= index) {
+                       bas = annotation_bytearrays_resize(bas, index + 1);
+
+                       if (bas == NULL) {
+                               /* out of memory */
+                               return NULL;
+                       }
+               }
+
+               array_objectarray_element_set(bas, index, (java_handle_t*)bytearray);
+       }
+       
+       return (java_handle_t*)bas;
+}
+
+
+/* annotation_load_attribute_body *********************************************
+
+   This function loads the body of a generic attribute.
+
+   XXX: Maybe this function should be called loader_load_attribute_body and
+        located in vm/loader.c?
+
+   attribute_info {
+       u2 attribute_name_index;
+       u4 attribute_length;
+       u1 info[attribute_length];
+   }
+
+   IN:
+       cb.................classbuffer from which to read the data.
+       errormsg_prefix....prefix for error messages (if any).
+
+   OUT:
+       attribute..........bytearray-pointer which will be set to the read data.
+   
+   RETURN VALUE:
+       true if all went good. false otherwhise.
+
+*******************************************************************************/
+
+static bool annotation_load_attribute_body(classbuffer *cb,
+       java_handle_bytearray_t **attribute, const char *errormsg_prefix)
+{
+       uint32_t                 size = 0;    /* size of the attribute     */
+       java_handle_bytearray_t *ba   = NULL; /* the raw attributes' bytes */
+
+       assert(cb != NULL);
+       assert(attribute != NULL);
+
+       if (!suck_check_classbuffer_size(cb, 4)) {
+               log_println("%s: size missing", errormsg_prefix);
+               return false;
+       }
+
+       /* load attribute_length */
+       size = suck_u4(cb);
+       
+       if (!suck_check_classbuffer_size(cb, size)) {
+               log_println("%s: invalid size", errormsg_prefix);
+               return false;
+       }
+       
+       /* if attribute_length == 0 then NULL is
+        * the right value for this attribute */
+       if (size > 0) {
+               ba = builtin_newarray_byte(size);
+
+               if (ba == NULL) {
+                       /* out of memory */
+                       return false;
+               }
+
+               /* load data */
+               LLNI_CRITICAL_START;
+
+               suck_nbytes((uint8_t*)LLNI_array_data(ba), cb, size);
+
+               LLNI_CRITICAL_END;
+
+               /* return data */
+               *attribute = ba;
+       }
+       
+       return true;
+}
+
+
+/* annotation_load_method_attribute_annotationdefault *************************
+
+   Load annotation default value.
+
+   AnnotationDefault_attribute {
+       u2 attribute_name_index;
+       u4 attribute_length;
+       element_value default_value;
+   }
+
+   IN:
+       cb.................classbuffer from which to read the data.
+       m..................methodinfo for the method of which the annotation
+                          default value is read and into which the value is
+                          stored into.
+
+   RETURN VALUE:
+       true if all went good. false otherwhise.
+
+*******************************************************************************/
+
+bool annotation_load_method_attribute_annotationdefault(
+               classbuffer *cb, methodinfo *m)
+{
+       int                      slot               = 0;
+                                /* the slot of the method                        */
+       java_handle_bytearray_t *annotationdefault  = NULL;
+                                /* unparsed annotation defalut value             */
+       java_handle_t           *annotationdefaults = NULL;
+                                /* array of unparsed annotation default values   */
+
+       assert(cb != NULL);
+       assert(m != NULL);
+
+       LLNI_classinfo_field_get(
+               m->clazz, method_annotationdefaults, annotationdefaults);
+
+       if (!annotation_load_attribute_body(
+                       cb, &annotationdefault,
+                       "invalid annotation default method attribute")) {
+               return false;
+       }
+
+       if (annotationdefault != NULL) {
+               slot = m - m->clazz->methods;
+               annotationdefaults = annotation_bytearrays_insert(
+                               annotationdefaults, slot, annotationdefault);
+
+               if (annotationdefaults == NULL) {
+                       return false;
+               }
+
+               LLNI_classinfo_field_set(
+                       m->clazz, method_annotationdefaults, annotationdefaults);
+       }
+
+       return true;
+}
+
+
+/* annotation_load_method_attribute_runtimevisibleparameterannotations ********
+
+   Load runtime visible parameter annotations.
+
+   RuntimeVisibleParameterAnnotations_attribute {
+       u2 attribute_name_index;
+       u4 attribute_length;
+       u1 num_parameters;
+       {
+           u2 num_annotations;
+           annotation annotations[num_annotations];
+       } parameter_annotations[num_parameters];
+   }
+
+   IN:
+       cb.................classbuffer from which to read the data.
+       m..................methodinfo for the method of which the parameter
+                          annotations are read and into which the parameter
+                          annotations are stored into.
+
+   RETURN VALUE:
+       true if all went good. false otherwhise.
+
+*******************************************************************************/
+
+bool annotation_load_method_attribute_runtimevisibleparameterannotations(
+               classbuffer *cb, methodinfo *m)
+{
+       int                      slot                 = 0;
+                                /* the slot of the method                  */
+       java_handle_bytearray_t *annotations          = NULL;
+                                /* unparsed parameter annotations          */
+       java_handle_t           *parameterannotations = NULL;
+                                /* array of unparsed parameter annotations */
+
+       assert(cb != NULL);
+       assert(m != NULL);
+
+       LLNI_classinfo_field_get(
+               m->clazz, method_parameterannotations, parameterannotations);
+
+       if (!annotation_load_attribute_body(
+                       cb, &annotations,
+                       "invalid runtime visible parameter annotations method attribute")) {
+               return false;
+       }
+
+       if (annotations != NULL) {
+               slot = m - m->clazz->methods;
+               parameterannotations = annotation_bytearrays_insert(
+                               parameterannotations, slot, annotations);
+
+               if (parameterannotations == NULL) {
+                       return false;
+               }
+
+               LLNI_classinfo_field_set(
+                       m->clazz, method_parameterannotations, parameterannotations);
+       }
+
+       return true;
+}
+
+
+/* annotation_load_method_attribute_runtimeinvisibleparameterannotations ******
+   Load runtime invisible parameter annotations.
+
+   <quote cite="http://jcp.org/en/jsr/detail?id=202">
+   The RuntimeInvisibleParameterAnnotations attribute is similar to the
+   RuntimeVisibleParameterAnnotations attribute, except that the annotations
+   represented by a RuntimeInvisibleParameterAnnotations attribute must not be
+   made available for return by reflective APIs, unless the the JVM has
+   specifically been instructed to retain these annotations via some
+   implementation-specific mechanism such as a command line flag. In the
+   absence of such instructions, the JVM ignores this attribute.
+   </quote>
+
+   Hotspot loads them into the same bytearray as the runtime visible parameter
+   annotations (after the runtime visible parameter annotations). But in J2SE
+   the bytearray will only be parsed as if there is only one annotation
+   structure in it, so the runtime invisible parameter annotatios will be
+   ignored.
+
+   Therefore I do not even bother to read them.
+
+   RuntimeInvisibleParameterAnnotations_attribute {
+       u2 attribute_name_index;
+       u4 attribute_length;
+       u1 num_parameters;
+       {
+           u2 num_annotations;
+           annotation annotations[num_annotations];
+       } parameter_annotations[num_parameters];
+   }
+
+   IN:
+       cb.................classbuffer from which to read the data.
+       m..................methodinfo for the method of which the parameter
+                          annotations are read and into which the parameter
+                          annotations are stored into.
+
+   RETURN VALUE:
+       true if all went good. false otherwhise.
+
+*******************************************************************************/
+
+bool annotation_load_method_attribute_runtimeinvisibleparameterannotations(
+               classbuffer *cb, methodinfo *m)
+{
+       return loader_skip_attribute_body(cb);
+}
+
+
+/* annotation_load_class_attribute_runtimevisibleannotations ******************
+   
+   Load runtime visible annotations of a class.
+   
+   IN:
+       cb........the classbuffer from which the attribute has to be loaded.
+
+   RETURN VALUE:
+       true if all went good. false otherwhise.
+
+*******************************************************************************/
+
+bool annotation_load_class_attribute_runtimevisibleannotations(
+       classbuffer *cb)
+{
+       java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
+       
+       if (!annotation_load_attribute_body(
+                       cb, &annotations,
+                       "invalid runtime visible annotations class attribute")) {
+               return false;
+       }
+
+       LLNI_classinfo_field_set(cb->clazz, annotations, (java_handle_t*)annotations);
+
+       return true;
+}
+
+
+/* annotation_load_class_attribute_runtimeinvisibleannotations ****************
+   
+   Load runtime invisible annotations of a class (just skip them).
+   
+   IN:
+       cb........the classbuffer from which the attribute has to be loaded.
+
+   RETURN VALUE:
+       true if all went good. false otherwhise.
+
+*******************************************************************************/
+
+bool annotation_load_class_attribute_runtimeinvisibleannotations(
+       classbuffer *cb)
+{
+       return loader_skip_attribute_body(cb);
+}
+
+
+/* annotation_load_method_attribute_runtimevisibleannotations *****************
+   
+   Load runtime visible annotations of a method.
+  
+   IN:
+       cb........the classbuffer from which the attribute has to be loaded.
+       m.........the method of which the runtime visible annotations have
+                 to be loaded.
+
+   RETURN VALUE:
+       true if all went good. false otherwhise.
+
+*******************************************************************************/
+
+bool annotation_load_method_attribute_runtimevisibleannotations(
+       classbuffer *cb, methodinfo *m)
+{
+       int                      slot               = 0;
+                                /* slot of the method */
+       java_handle_bytearray_t *annotations        = NULL;
+                                /* unparsed annotations */
+       java_handle_t           *method_annotations = NULL;
+                                /* array of unparsed method annotations */
+
+       assert(cb != NULL);
+       assert(m != NULL);
+
+       LLNI_classinfo_field_get(
+               m->clazz, method_annotations, method_annotations);
+
+       if (!annotation_load_attribute_body(
+                       cb, &annotations,
+                       "invalid runtime visible annotations method attribute")) {
+               return false;
+       }
+
+       if (annotations != NULL) {
+               slot = m - m->clazz->methods;
+               method_annotations = annotation_bytearrays_insert(
+                               method_annotations, slot, annotations);
+
+               if (method_annotations == NULL) {
+                       return false;
+               }
+               
+               LLNI_classinfo_field_set(
+                       m->clazz, method_annotations, method_annotations);
+       }
+
+       return true;
+}
+
+
+/* annotation_load_method_attribute_runtimeinvisibleannotations ****************
+   
+   Load runtime invisible annotations of a method (just skip them).
+   
+   IN:
+       cb........the classbuffer from which the attribute has to be loaded.
+       m.........the method of which the runtime invisible annotations have
+                 to be loaded.
+
+   RETURN VALUE:
+       true if all went good. false otherwhise.
+
+*******************************************************************************/
+
+bool annotation_load_method_attribute_runtimeinvisibleannotations(
+       classbuffer *cb, methodinfo *m)
+{
+       return loader_skip_attribute_body(cb);
+}
+
+
+/* annotation_load_field_attribute_runtimevisibleannotations ******************
+   
+   Load runtime visible annotations of a field.
+   
+   IN:
+       cb........the classbuffer from which the attribute has to be loaded.
+       f.........the field of which the runtime visible annotations have
+                 to be loaded.
+
+   RETURN VALUE:
+       true if all went good. false otherwhise.
+
+*******************************************************************************/
+
+bool annotation_load_field_attribute_runtimevisibleannotations(
+       classbuffer *cb, fieldinfo *f)
+{
+       int                      slot              = 0;
+                                /* slot of the field                   */
+       java_handle_bytearray_t *annotations       = NULL;
+                                /* unparsed annotations                */
+       java_handle_t           *field_annotations = NULL;
+                                /* array of unparsed field annotations */
+
+       assert(cb != NULL);
+       assert(f != NULL);
+
+       LLNI_classinfo_field_get(
+               f->clazz, field_annotations, field_annotations);
+
+       if (!annotation_load_attribute_body(
+                       cb, &annotations,
+                       "invalid runtime visible annotations field attribute")) {
+               return false;
+       }
+
+       if (annotations != NULL) {
+               slot = f - f->clazz->fields;
+               field_annotations = annotation_bytearrays_insert(
+                               field_annotations, slot, annotations);
+
+               if (field_annotations == NULL) {
+                       return false;
+               }
+
+               LLNI_classinfo_field_set(
+                       f->clazz, field_annotations, field_annotations);
+       }
+
+       return true;
+}
+
+
+/* annotation_load_field_attribute_runtimeinvisibleannotations ****************
+   
+   Load runtime invisible annotations of a field (just skip them).
+   
+   IN:
+       cb........the classbuffer from which the attribute has to be loaded.
+       f.........the field of which the runtime invisible annotations have
+                 to be loaded.
+
+   RETURN VALUE:
+       true if all went good. false otherwhise.
+
+*******************************************************************************/
+
+bool annotation_load_field_attribute_runtimeinvisibleannotations(
+       classbuffer *cb, fieldinfo *f)
+{
+       return loader_skip_attribute_body(cb);
+}
+
+
+/*
+ * 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/annotation.h b/src/vm/annotation.h
new file mode 100644 (file)
index 0000000..2a8b116
--- /dev/null
@@ -0,0 +1,93 @@
+/* src/vm/annotation.h - class annotations
+
+   Copyright (C) 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 _ANNOTATION_H
+#define _ANNOTATION_H
+
+
+#include "config.h"
+
+#include "vm/types.h"
+
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/global.h"
+#include "vm/loader.hpp"
+#include "vm/method.hpp"
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool annotation_load_class_attribute_runtimevisibleannotations(
+       classbuffer *cb);
+
+bool annotation_load_class_attribute_runtimeinvisibleannotations(
+       classbuffer *cb);
+
+bool annotation_load_method_attribute_runtimevisibleannotations(
+       classbuffer *cb, methodinfo *m);
+
+bool annotation_load_method_attribute_runtimeinvisibleannotations(
+       classbuffer *cb, methodinfo *m);
+
+bool annotation_load_field_attribute_runtimevisibleannotations(
+       classbuffer *cb, fieldinfo *f);
+
+bool annotation_load_field_attribute_runtimeinvisibleannotations(
+       classbuffer *cb, fieldinfo *f);
+
+bool annotation_load_method_attribute_annotationdefault(
+       classbuffer *cb, methodinfo *m);
+
+bool annotation_load_method_attribute_runtimevisibleparameterannotations(
+       classbuffer *cb, methodinfo *m);
+
+bool annotation_load_method_attribute_runtimeinvisibleparameterannotations(
+       classbuffer *cb, methodinfo *m);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ANNOTATION_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/array.c b/src/vm/array.c
deleted file mode 100644 (file)
index 30f231d..0000000
+++ /dev/null
@@ -1,396 +0,0 @@
-/* src/vm/array.c - Java array functions
-
-   Copyright (C) 2007
-   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 <stdint.h>
-
-#include "native/llni.h"
-
-#include "vm/array.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/primitive.h"
-#include "vm/vm.h"
-
-
-/* array_element_get ***********************************************************
-
-   Returns a boxed element of the given Java array.
-
-*******************************************************************************/
-
-java_handle_t *array_element_get(java_handle_t *a, int32_t index)
-{
-       vftbl_t       *v;
-       int            type;
-       imm_union      value;
-       java_handle_t *o;
-
-       if (a == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       v = LLNI_vftbl_direct(a);
-
-       type = v->arraydesc->arraytype;
-
-       value = array_element_primitive_get(a, index);
-
-       o = primitive_box(type, value);
-
-       return o;
-}
-
-
-/* array_element_set ***********************************************************
-
-   Sets a boxed element in the given Java array.
-
-*******************************************************************************/
-
-void array_element_set(java_handle_t *a, int32_t index, java_handle_t *o)
-{
-       imm_union value;
-
-       value = primitive_unbox(o);
-
-       array_element_primitive_set(a, index, value);
-}
-
-
-/* array_element_primitive_get *************************************************
-
-   Returns a primitive element of the given Java array.
-
-*******************************************************************************/
-
-imm_union array_element_primitive_get(java_handle_t *a, int32_t index)
-{
-       vftbl_t  *v;
-       int       type;
-       imm_union value;
-
-       if (a == NULL) {
-               exceptions_throw_nullpointerexception();
-               value.a = NULL;
-               return value;
-       }
-
-       v = LLNI_vftbl_direct(a);
-
-       type = v->arraydesc->arraytype;
-
-       switch (type) {
-       case ARRAYTYPE_BOOLEAN:
-               value.i = array_booleanarray_element_get((java_handle_booleanarray_t *) a, index);
-               break;
-       case ARRAYTYPE_BYTE:
-               value.i = array_bytearray_element_get((java_handle_bytearray_t *) a,
-                                                                                         index);
-               break;
-       case ARRAYTYPE_CHAR:
-               value.i = array_chararray_element_get((java_handle_chararray_t *) a,
-                                                                                         index);
-               break;
-       case ARRAYTYPE_SHORT:
-               value.i = array_shortarray_element_get((java_handle_shortarray_t *) a,
-                                                                                          index);
-               break;
-       case ARRAYTYPE_INT:
-               value.i = array_intarray_element_get((java_handle_intarray_t *) a,
-                                                                                        index);
-               break;
-       case ARRAYTYPE_LONG:
-               value.l = array_longarray_element_get((java_handle_longarray_t *) a,
-                                                                                         index);
-               break;
-       case ARRAYTYPE_FLOAT:
-               value.f = array_floatarray_element_get((java_handle_floatarray_t *) a,
-                                                                                          index);
-               break;
-       case ARRAYTYPE_DOUBLE:
-               value.d = array_doublearray_element_get((java_handle_doublearray_t *) a,
-                                                                                               index);
-               break;
-       case ARRAYTYPE_OBJECT:
-               value.a = array_objectarray_element_get((java_handle_objectarray_t *) a,
-                                                                                               index);
-               break;
-       default:
-               vm_abort("array_element_primitive_get: invalid array element type %d",
-                                type);
-       }
-
-       return value;
-}
-
-
-/* array_element_primitive_set *************************************************
-
-   Sets a primitive element in the given Java array.
-
-*******************************************************************************/
-
-void array_element_primitive_set(java_handle_t *a, int32_t index, imm_union value)
-{
-       vftbl_t *v;
-       int      type;
-
-       if (a == NULL) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       v = LLNI_vftbl_direct(a);
-
-       type = v->arraydesc->arraytype;
-
-       switch (type) {
-       case ARRAYTYPE_BOOLEAN:
-               array_booleanarray_element_set((java_handle_booleanarray_t *) a,
-                                                                          index, value.i);
-               break;
-       case ARRAYTYPE_BYTE:
-               array_bytearray_element_set((java_handle_bytearray_t *) a,
-                                                                       index, value.i);
-               break;
-       case ARRAYTYPE_CHAR:
-               array_chararray_element_set((java_handle_chararray_t *) a,
-                                                                       index, value.i);
-               break;
-       case ARRAYTYPE_SHORT:
-               array_shortarray_element_set((java_handle_shortarray_t *) a,
-                                                                        index, value.i);
-               break;
-       case ARRAYTYPE_INT:
-               array_intarray_element_set((java_handle_intarray_t *) a,
-                                                                  index, value.i);
-               break;
-       case ARRAYTYPE_LONG:
-               array_longarray_element_set((java_handle_longarray_t *) a,
-                                                                       index, value.l);
-               break;
-       case ARRAYTYPE_FLOAT:
-               array_floatarray_element_set((java_handle_floatarray_t *) a,
-                                                                        index, value.f);
-               break;
-       case ARRAYTYPE_DOUBLE:
-               array_doublearray_element_set((java_handle_doublearray_t *) a,
-                                                                         index, value.d);
-               break;
-       case ARRAYTYPE_OBJECT:
-               array_objectarray_element_set((java_handle_objectarray_t *) a,
-                                                                         index, value.a);
-               break;
-       default:
-               vm_abort("array_element_primitive_set: invalid array element type %d",
-                                type);
-       }
-}
-
-
-/* array_xxxarray_element_get **************************************************
-
-   Returns a primitive element of the given Java array.
-
-*******************************************************************************/
-
-#define ARRAY_TYPEARRAY_ELEMENT_GET(name, type)                                \
-type array_##name##array_element_get(java_handle_##name##array_t *a, int32_t index) \
-{                                                                              \
-       type    value;                                                             \
-       int32_t size;                                                              \
-                                                                               \
-       if (a == NULL) {                                                           \
-               exceptions_throw_nullpointerexception();                               \
-               return (type) 0;                                                       \
-       }                                                                          \
-                                                                               \
-       size = LLNI_array_size(a);                                                 \
-                                                                               \
-       if ((index < 0) || (index >= size)) {                                      \
-               exceptions_throw_arrayindexoutofboundsexception();                     \
-               return (type) 0;                                                       \
-       }                                                                          \
-                                                                               \
-       value = LLNI_array_direct(a, index);                                       \
-                                                                               \
-       return value;                                                              \
-}
-
-java_handle_t *array_objectarray_element_get(java_handle_objectarray_t *a, int32_t index)
-{
-       java_handle_t *value;
-       int32_t size;
-
-       if (a == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       size = LLNI_array_size(a);
-
-       if ((index < 0) || (index >= size)) {
-               exceptions_throw_arrayindexoutofboundsexception();
-               return NULL;
-       }
-
-       LLNI_CRITICAL_START;
-       value = LLNI_WRAP(LLNI_array_direct(a, index));
-       LLNI_CRITICAL_END;
-
-       return value;
-}
-
-ARRAY_TYPEARRAY_ELEMENT_GET(boolean, uint8_t)
-ARRAY_TYPEARRAY_ELEMENT_GET(byte,    int8_t)
-ARRAY_TYPEARRAY_ELEMENT_GET(char,    uint16_t)
-ARRAY_TYPEARRAY_ELEMENT_GET(short,   int16_t)
-ARRAY_TYPEARRAY_ELEMENT_GET(int,     int32_t)
-ARRAY_TYPEARRAY_ELEMENT_GET(long,    int64_t)
-ARRAY_TYPEARRAY_ELEMENT_GET(float,   float)
-ARRAY_TYPEARRAY_ELEMENT_GET(double,  double)
-
-
-/* array_xxxarray_element_set **************************************************
-
-   Sets a primitive element in the given Java array.
-
-*******************************************************************************/
-
-#define ARRAY_TYPEARRAY_ELEMENT_SET(name, type)                                \
-void array_##name##array_element_set(java_handle_##name##array_t *a, int32_t index, type value) \
-{                                                                              \
-       int32_t size;                                                              \
-                                                                               \
-       if (a == NULL) {                                                           \
-               exceptions_throw_nullpointerexception();                               \
-               return;                                                                \
-       }                                                                          \
-                                                                               \
-       size = LLNI_array_size(a);                                                 \
-                                                                               \
-       if ((index < 0) || (index >= size)) {                                      \
-               exceptions_throw_arrayindexoutofboundsexception();                     \
-               return;                                                                \
-       }                                                                          \
-                                                                               \
-       LLNI_array_direct(a, index) = value;                                       \
-}
-
-void array_objectarray_element_set(java_handle_objectarray_t *a, int32_t index, java_handle_t *value)
-{
-       int32_t size;
-
-       if (a == NULL) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       /* Sanity check. */
-
-       assert(a->header.objheader.vftbl->arraydesc->arraytype == ARRAYTYPE_OBJECT);
-
-       if (value != NULL) {
-               if (builtin_canstore(a, value) == false) {
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-       }
-
-       size = LLNI_array_size(a);
-
-       if ((index < 0) || (index >= size)) {
-               exceptions_throw_arrayindexoutofboundsexception();
-               return;
-       }
-
-       LLNI_CRITICAL_START;
-       LLNI_array_direct(a, index) = LLNI_UNWRAP(value);
-       LLNI_CRITICAL_END;
-}
-
-ARRAY_TYPEARRAY_ELEMENT_SET(boolean, uint8_t)
-ARRAY_TYPEARRAY_ELEMENT_SET(byte,    int8_t)
-ARRAY_TYPEARRAY_ELEMENT_SET(char,    uint16_t)
-ARRAY_TYPEARRAY_ELEMENT_SET(short,   int16_t)
-ARRAY_TYPEARRAY_ELEMENT_SET(int,     int32_t)
-ARRAY_TYPEARRAY_ELEMENT_SET(long,    int64_t)
-ARRAY_TYPEARRAY_ELEMENT_SET(float,   float)
-ARRAY_TYPEARRAY_ELEMENT_SET(double,  double)
-
-
-/* array_length_get ***********************************************************
-
-   Returns a the length of the given Java array.
-
-   ARGUMENTS:
-       a ... Java array
-
-   RETURN VALUE:
-         -1 ... exception thrown
-          >= 0 ... length of the Java array
-
-*******************************************************************************/
-
-int32_t array_length_get(java_handle_t *a)
-{
-       classinfo *c;
-       int32_t    size;
-
-       if (a == NULL) {
-               exceptions_throw_nullpointerexception();
-               return -1;
-       }
-
-       LLNI_class_get(a, c);
-
-       if (!class_is_array(c)) {
-/*             exceptions_throw_illegalargumentexception("Argument is not an array"); */
-               exceptions_throw_illegalargumentexception();
-               return -1;
-       }
-
-       size = LLNI_array_size(a);
-
-       return size;
-}
-
-
-/*
- * 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/array.cpp b/src/vm/array.cpp
new file mode 100644 (file)
index 0000000..de602db
--- /dev/null
@@ -0,0 +1,396 @@
+/* src/vm/array.cpp - Java array functions
+
+   Copyright (C) 2007
+   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 <stdint.h>
+
+#include "native/llni.h"
+
+#include "vm/array.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/primitive.hpp"
+#include "vm/vm.hpp"
+
+
+/* array_element_get ***********************************************************
+
+   Returns a boxed element of the given Java array.
+
+*******************************************************************************/
+
+java_handle_t *array_element_get(java_handle_t *a, int32_t index)
+{
+       vftbl_t       *v;
+       int            type;
+       imm_union      value;
+       java_handle_t *o;
+
+       if (a == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       v = LLNI_vftbl_direct(a);
+
+       type = v->arraydesc->arraytype;
+
+       value = array_element_primitive_get(a, index);
+
+       o = Primitive::box(type, value);
+
+       return o;
+}
+
+
+/* array_element_set ***********************************************************
+
+   Sets a boxed element in the given Java array.
+
+*******************************************************************************/
+
+void array_element_set(java_handle_t *a, int32_t index, java_handle_t *o)
+{
+       imm_union value;
+
+       value = Primitive::unbox(o);
+
+       array_element_primitive_set(a, index, value);
+}
+
+
+/* array_element_primitive_get *************************************************
+
+   Returns a primitive element of the given Java array.
+
+*******************************************************************************/
+
+imm_union array_element_primitive_get(java_handle_t *a, int32_t index)
+{
+       vftbl_t  *v;
+       int       type;
+       imm_union value;
+
+       if (a == NULL) {
+               exceptions_throw_nullpointerexception();
+               value.a = NULL;
+               return value;
+       }
+
+       v = LLNI_vftbl_direct(a);
+
+       type = v->arraydesc->arraytype;
+
+       switch (type) {
+       case ARRAYTYPE_BOOLEAN:
+               value.i = array_booleanarray_element_get((java_handle_booleanarray_t *) a, index);
+               break;
+       case ARRAYTYPE_BYTE:
+               value.i = array_bytearray_element_get((java_handle_bytearray_t *) a,
+                                                                                         index);
+               break;
+       case ARRAYTYPE_CHAR:
+               value.i = array_chararray_element_get((java_handle_chararray_t *) a,
+                                                                                         index);
+               break;
+       case ARRAYTYPE_SHORT:
+               value.i = array_shortarray_element_get((java_handle_shortarray_t *) a,
+                                                                                          index);
+               break;
+       case ARRAYTYPE_INT:
+               value.i = array_intarray_element_get((java_handle_intarray_t *) a,
+                                                                                        index);
+               break;
+       case ARRAYTYPE_LONG:
+               value.l = array_longarray_element_get((java_handle_longarray_t *) a,
+                                                                                         index);
+               break;
+       case ARRAYTYPE_FLOAT:
+               value.f = array_floatarray_element_get((java_handle_floatarray_t *) a,
+                                                                                          index);
+               break;
+       case ARRAYTYPE_DOUBLE:
+               value.d = array_doublearray_element_get((java_handle_doublearray_t *) a,
+                                                                                               index);
+               break;
+       case ARRAYTYPE_OBJECT:
+               value.a = array_objectarray_element_get((java_handle_objectarray_t *) a,
+                                                                                               index);
+               break;
+       default:
+               vm_abort("array_element_primitive_get: invalid array element type %d",
+                                type);
+       }
+
+       return value;
+}
+
+
+/* array_element_primitive_set *************************************************
+
+   Sets a primitive element in the given Java array.
+
+*******************************************************************************/
+
+void array_element_primitive_set(java_handle_t *a, int32_t index, imm_union value)
+{
+       vftbl_t *v;
+       int      type;
+
+       if (a == NULL) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       v = LLNI_vftbl_direct(a);
+
+       type = v->arraydesc->arraytype;
+
+       switch (type) {
+       case ARRAYTYPE_BOOLEAN:
+               array_booleanarray_element_set((java_handle_booleanarray_t *) a,
+                                                                          index, value.i);
+               break;
+       case ARRAYTYPE_BYTE:
+               array_bytearray_element_set((java_handle_bytearray_t *) a,
+                                                                       index, value.i);
+               break;
+       case ARRAYTYPE_CHAR:
+               array_chararray_element_set((java_handle_chararray_t *) a,
+                                                                       index, value.i);
+               break;
+       case ARRAYTYPE_SHORT:
+               array_shortarray_element_set((java_handle_shortarray_t *) a,
+                                                                        index, value.i);
+               break;
+       case ARRAYTYPE_INT:
+               array_intarray_element_set((java_handle_intarray_t *) a,
+                                                                  index, value.i);
+               break;
+       case ARRAYTYPE_LONG:
+               array_longarray_element_set((java_handle_longarray_t *) a,
+                                                                       index, value.l);
+               break;
+       case ARRAYTYPE_FLOAT:
+               array_floatarray_element_set((java_handle_floatarray_t *) a,
+                                                                        index, value.f);
+               break;
+       case ARRAYTYPE_DOUBLE:
+               array_doublearray_element_set((java_handle_doublearray_t *) a,
+                                                                         index, value.d);
+               break;
+       case ARRAYTYPE_OBJECT:
+               array_objectarray_element_set((java_handle_objectarray_t *) a,
+                                                                         index, static_cast<java_handle_t*>(value.a));
+               break;
+       default:
+               vm_abort("array_element_primitive_set: invalid array element type %d",
+                                type);
+       }
+}
+
+
+/* array_xxxarray_element_get **************************************************
+
+   Returns a primitive element of the given Java array.
+
+*******************************************************************************/
+
+#define ARRAY_TYPEARRAY_ELEMENT_GET(name, type)                                \
+type array_##name##array_element_get(java_handle_##name##array_t *a, int32_t index) \
+{                                                                              \
+       type    value;                                                             \
+       int32_t size;                                                              \
+                                                                               \
+       if (a == NULL) {                                                           \
+               exceptions_throw_nullpointerexception();                               \
+               return (type) 0;                                                       \
+       }                                                                          \
+                                                                               \
+       size = LLNI_array_size(a);                                                 \
+                                                                               \
+       if ((index < 0) || (index >= size)) {                                      \
+               exceptions_throw_arrayindexoutofboundsexception();                     \
+               return (type) 0;                                                       \
+       }                                                                          \
+                                                                               \
+       value = LLNI_array_direct(a, index);                                       \
+                                                                               \
+       return value;                                                              \
+}
+
+java_handle_t *array_objectarray_element_get(java_handle_objectarray_t *a, int32_t index)
+{
+       java_handle_t *value;
+       int32_t size;
+
+       if (a == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       size = LLNI_array_size(a);
+
+       if ((index < 0) || (index >= size)) {
+               exceptions_throw_arrayindexoutofboundsexception();
+               return NULL;
+       }
+
+       LLNI_CRITICAL_START;
+       value = LLNI_WRAP(LLNI_array_direct(a, index));
+       LLNI_CRITICAL_END;
+
+       return value;
+}
+
+ARRAY_TYPEARRAY_ELEMENT_GET(boolean, uint8_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(byte,    int8_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(char,    uint16_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(short,   int16_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(int,     int32_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(long,    int64_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(float,   float)
+ARRAY_TYPEARRAY_ELEMENT_GET(double,  double)
+
+
+/* array_xxxarray_element_set **************************************************
+
+   Sets a primitive element in the given Java array.
+
+*******************************************************************************/
+
+#define ARRAY_TYPEARRAY_ELEMENT_SET(name, type)                                \
+void array_##name##array_element_set(java_handle_##name##array_t *a, int32_t index, type value) \
+{                                                                              \
+       int32_t size;                                                              \
+                                                                               \
+       if (a == NULL) {                                                           \
+               exceptions_throw_nullpointerexception();                               \
+               return;                                                                \
+       }                                                                          \
+                                                                               \
+       size = LLNI_array_size(a);                                                 \
+                                                                               \
+       if ((index < 0) || (index >= size)) {                                      \
+               exceptions_throw_arrayindexoutofboundsexception();                     \
+               return;                                                                \
+       }                                                                          \
+                                                                               \
+       LLNI_array_direct(a, index) = value;                                       \
+}
+
+void array_objectarray_element_set(java_handle_objectarray_t *a, int32_t index, java_handle_t *value)
+{
+       int32_t size;
+
+       if (a == NULL) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       /* Sanity check. */
+
+       assert(a->header.objheader.vftbl->arraydesc->arraytype == ARRAYTYPE_OBJECT);
+
+       if (value != NULL) {
+               if (builtin_canstore(a, value) == false) {
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+       }
+
+       size = LLNI_array_size(a);
+
+       if ((index < 0) || (index >= size)) {
+               exceptions_throw_arrayindexoutofboundsexception();
+               return;
+       }
+
+       LLNI_CRITICAL_START;
+       LLNI_array_direct(a, index) = LLNI_UNWRAP(value);
+       LLNI_CRITICAL_END;
+}
+
+ARRAY_TYPEARRAY_ELEMENT_SET(boolean, uint8_t)
+ARRAY_TYPEARRAY_ELEMENT_SET(byte,    int8_t)
+ARRAY_TYPEARRAY_ELEMENT_SET(char,    uint16_t)
+ARRAY_TYPEARRAY_ELEMENT_SET(short,   int16_t)
+ARRAY_TYPEARRAY_ELEMENT_SET(int,     int32_t)
+ARRAY_TYPEARRAY_ELEMENT_SET(long,    int64_t)
+ARRAY_TYPEARRAY_ELEMENT_SET(float,   float)
+ARRAY_TYPEARRAY_ELEMENT_SET(double,  double)
+
+
+/* array_length_get ***********************************************************
+
+   Returns a the length of the given Java array.
+
+   ARGUMENTS:
+       a ... Java array
+
+   RETURN VALUE:
+         -1 ... exception thrown
+          >= 0 ... length of the Java array
+
+*******************************************************************************/
+
+int32_t array_length_get(java_handle_t *a)
+{
+       classinfo *c;
+       int32_t    size;
+
+       if (a == NULL) {
+               exceptions_throw_nullpointerexception();
+               return -1;
+       }
+
+       LLNI_class_get(a, c);
+
+       if (!class_is_array(c)) {
+/*             exceptions_throw_illegalargumentexception("Argument is not an array"); */
+               exceptions_throw_illegalargumentexception();
+               return -1;
+       }
+
+       size = LLNI_array_size(a);
+
+       return size;
+}
+
+
+/*
+ * 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/array.h b/src/vm/array.h
deleted file mode 100644 (file)
index 3425d59..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/* src/vm/array.h - Java array functions
-
-   Copyright (C) 2007
-   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 _VM_ARRAY_H
-#define _VM_ARRAY_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/global.h"
-#include "vm/primitive.h"
-
-
-/* array types ****************************************************************/
-
-/* CAUTION: Don't change the numerical values! These constants (with
-   the exception of ARRAYTYPE_OBJECT) are used as indices in the
-   primitive type table. */
-
-#define ARRAYTYPE_INT         PRIMITIVETYPE_INT
-#define ARRAYTYPE_LONG        PRIMITIVETYPE_LONG
-#define ARRAYTYPE_FLOAT       PRIMITIVETYPE_FLOAT
-#define ARRAYTYPE_DOUBLE      PRIMITIVETYPE_DOUBLE
-#define ARRAYTYPE_BYTE        PRIMITIVETYPE_BYTE
-#define ARRAYTYPE_CHAR        PRIMITIVETYPE_CHAR
-#define ARRAYTYPE_SHORT       PRIMITIVETYPE_SHORT
-#define ARRAYTYPE_BOOLEAN     PRIMITIVETYPE_BOOLEAN
-#define ARRAYTYPE_OBJECT      PRIMITIVETYPE_VOID     /* don't use as index! */
-
-
-/* function prototypes ********************************************************/
-
-java_handle_t *array_element_get(java_handle_t *a, int32_t index);
-void           array_element_set(java_handle_t *a, int32_t index, java_handle_t *o);
-
-imm_union      array_element_primitive_get(java_handle_t *a, int32_t index);
-void           array_element_primitive_set(java_handle_t *a, int32_t index, imm_union value);
-
-uint8_t        array_booleanarray_element_get(java_handle_booleanarray_t *a, int32_t index);
-int8_t         array_bytearray_element_get(java_handle_bytearray_t *a, int32_t index);
-uint16_t       array_chararray_element_get(java_handle_chararray_t *a, int32_t index);
-int16_t        array_shortarray_element_get(java_handle_shortarray_t *a, int32_t index);
-int32_t        array_intarray_element_get(java_handle_intarray_t *a, int32_t index);
-int64_t        array_longarray_element_get(java_handle_longarray_t *a, int32_t index);
-float          array_floatarray_element_get(java_handle_floatarray_t *a, int32_t index);
-double         array_doublearray_element_get(java_handle_doublearray_t *a, int32_t index);
-java_handle_t *array_objectarray_element_get(java_handle_objectarray_t *a, int32_t index);
-
-void           array_booleanarray_element_set(java_handle_booleanarray_t *a, int32_t index, uint8_t value);
-void           array_bytearray_element_set(java_handle_bytearray_t *a, int32_t index, int8_t value);
-void           array_chararray_element_set(java_handle_chararray_t *a, int32_t index, uint16_t value);
-void           array_shortarray_element_set(java_handle_shortarray_t *a, int32_t index, int16_t value);
-void           array_intarray_element_set(java_handle_intarray_t *a, int32_t index, int32_t value);
-void           array_longarray_element_set(java_handle_longarray_t *a, int32_t index, int64_t value);
-void           array_floatarray_element_set(java_handle_floatarray_t *a, int32_t index, float value);
-void           array_doublearray_element_set(java_handle_doublearray_t *a, int32_t index, double value);
-void           array_objectarray_element_set(java_handle_objectarray_t *a, int32_t index, java_handle_t *value);
-
-int32_t        array_length_get(java_handle_t *a);
-
-#endif /* _VM_ARRAY_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/array.hpp b/src/vm/array.hpp
new file mode 100644 (file)
index 0000000..86f1084
--- /dev/null
@@ -0,0 +1,107 @@
+/* src/vm/array.hpp - Java array functions
+
+   Copyright (C) 2007
+   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 _VM_ARRAY_HPP
+#define _VM_ARRAY_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/global.h"
+#include "vm/primitive.hpp"
+
+
+/* array types ****************************************************************/
+
+/* CAUTION: Don't change the numerical values! These constants (with
+   the exception of ARRAYTYPE_OBJECT) are used as indices in the
+   primitive type table. */
+
+#define ARRAYTYPE_INT         PRIMITIVETYPE_INT
+#define ARRAYTYPE_LONG        PRIMITIVETYPE_LONG
+#define ARRAYTYPE_FLOAT       PRIMITIVETYPE_FLOAT
+#define ARRAYTYPE_DOUBLE      PRIMITIVETYPE_DOUBLE
+#define ARRAYTYPE_BYTE        PRIMITIVETYPE_BYTE
+#define ARRAYTYPE_CHAR        PRIMITIVETYPE_CHAR
+#define ARRAYTYPE_SHORT       PRIMITIVETYPE_SHORT
+#define ARRAYTYPE_BOOLEAN     PRIMITIVETYPE_BOOLEAN
+#define ARRAYTYPE_OBJECT      PRIMITIVETYPE_VOID     /* don't use as index! */
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+java_handle_t *array_element_get(java_handle_t *a, int32_t index);
+void           array_element_set(java_handle_t *a, int32_t index, java_handle_t *o);
+
+imm_union      array_element_primitive_get(java_handle_t *a, int32_t index);
+void           array_element_primitive_set(java_handle_t *a, int32_t index, imm_union value);
+
+uint8_t        array_booleanarray_element_get(java_handle_booleanarray_t *a, int32_t index);
+int8_t         array_bytearray_element_get(java_handle_bytearray_t *a, int32_t index);
+uint16_t       array_chararray_element_get(java_handle_chararray_t *a, int32_t index);
+int16_t        array_shortarray_element_get(java_handle_shortarray_t *a, int32_t index);
+int32_t        array_intarray_element_get(java_handle_intarray_t *a, int32_t index);
+int64_t        array_longarray_element_get(java_handle_longarray_t *a, int32_t index);
+float          array_floatarray_element_get(java_handle_floatarray_t *a, int32_t index);
+double         array_doublearray_element_get(java_handle_doublearray_t *a, int32_t index);
+java_handle_t *array_objectarray_element_get(java_handle_objectarray_t *a, int32_t index);
+
+void           array_booleanarray_element_set(java_handle_booleanarray_t *a, int32_t index, uint8_t value);
+void           array_bytearray_element_set(java_handle_bytearray_t *a, int32_t index, int8_t value);
+void           array_chararray_element_set(java_handle_chararray_t *a, int32_t index, uint16_t value);
+void           array_shortarray_element_set(java_handle_shortarray_t *a, int32_t index, int16_t value);
+void           array_intarray_element_set(java_handle_intarray_t *a, int32_t index, int32_t value);
+void           array_longarray_element_set(java_handle_longarray_t *a, int32_t index, int64_t value);
+void           array_floatarray_element_set(java_handle_floatarray_t *a, int32_t index, float value);
+void           array_doublearray_element_set(java_handle_doublearray_t *a, int32_t index, double value);
+void           array_objectarray_element_set(java_handle_objectarray_t *a, int32_t index, java_handle_t *value);
+
+int32_t        array_length_get(java_handle_t *a);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _VM_ARRAY_HPP
+
+
+/*
+ * 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/assertion.c b/src/vm/assertion.c
deleted file mode 100644 (file)
index 6a1f0f6..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/* src/vm/assertion.c - assertion options
-
-   Copyright (C) 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 <stdint.h>
-#include <errno.h>
-
-#include "mm/memory.h"
-
-#include "toolbox/list.h"
-
-#include "vm/assertion.h"
-#include "vm/global.h"
-#include "vm/vm.h"
-
-#include "vmcore/system.h"
-
-
-/* -ea/-da options ************************************************************/
-
-list_t  *list_assertion_names     = (list_t *)NULL;
-int32_t  assertion_class_count    = 0;
-int32_t  assertion_package_count  = 0;
-bool     assertion_user_enabled   = false;
-bool     assertion_system_enabled = false;
-
-
-/* assertion_ea_da *************************************************************
-
-   Handle -ea:/-enableassertions: and -da:/-disableassertions: options.
-
-*******************************************************************************/
-
-void assertion_ea_da(const char *name, bool enabled)
-{
-       bool              package;
-       size_t            len;
-       char             *buf;
-       assertion_name_t *item;
-       int32_t           i;
-
-       if (name == NULL) {
-               assertion_user_enabled = enabled;
-               return;
-       }
-
-       package = false;
-       len     = system_strlen(name);
-
-       if (name[len - 1] == '/') {
-               return;
-       }
-
-       buf = system_strdup(name);
-
-       if (buf == NULL) {
-               vm_abort("assertion_ea_da: strdup failed: %s", strerror(errno));
-       }
-
-       if ((len > 2) && (strcmp(name + (len - 3), "...") == 0)) {
-               package = true;
-               assertion_package_count += 1;
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-               buf[len - 2] = '\0';
-               buf[len - 3] = '/';
-#else
-               buf[len - 3] = '\0';
-#endif
-       }
-       else {
-               assertion_class_count += 1;
-       }
-
-       len = system_strlen(buf);
-
-       for (i = 0; i < len; i++) {
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-               if (buf[i] == '.') {
-                       buf[i] = '/';
-               }
-#else
-               if (buf[i] == '/') {
-                       buf[i] = '.';
-               }
-#endif
-       }
-
-       item          = NEW(assertion_name_t);
-       item->name    = buf;
-       item->enabled = enabled;
-       item->package = package;
-
-       if (list_assertion_names == NULL) {
-               list_assertion_names = list_create(OFFSET(assertion_name_t, linkage));
-       }
-
-       list_add_last(list_assertion_names, item);
-}
-
-
-/*
- * 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/assertion.cpp b/src/vm/assertion.cpp
new file mode 100644 (file)
index 0000000..7252aa3
--- /dev/null
@@ -0,0 +1,134 @@
+/* src/vm/assertion.cpp - assertion options
+
+   Copyright (C) 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 <stdint.h>
+
+#include <cstddef>
+
+#include "mm/memory.h"
+
+#include "toolbox/list.hpp"
+
+#include "vm/assertion.hpp"
+#include "vm/global.h"
+#include "vm/os.hpp"
+
+
+/* -ea/-da options ************************************************************/
+
+List<assertion_name_t*>* list_assertion_names = NULL;
+int32_t  assertion_class_count    = 0;
+int32_t  assertion_package_count  = 0;
+bool     assertion_user_enabled   = false;
+bool     assertion_system_enabled = false;
+
+
+/* assertion_ea_da *************************************************************
+
+   Handle -ea:/-enableassertions: and -da:/-disableassertions: options.
+
+*******************************************************************************/
+
+void assertion_ea_da(const char *name, bool enabled)
+{
+       bool              package;
+       size_t            len;
+       char             *buf;
+       assertion_name_t *item;
+
+       if (name == NULL) {
+               assertion_user_enabled = enabled;
+               return;
+       }
+
+       package = false;
+       len     = os::strlen(name);
+
+       if (name[len - 1] == '/') {
+               return;
+       }
+
+       buf = os::strdup(name);
+
+       if (buf == NULL) {
+               os::abort_errno("assertion_ea_da: strdup failed");
+       }
+
+       if ((len > 2) && (strcmp(name + (len - 3), "...") == 0)) {
+               package = true;
+               assertion_package_count += 1;
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+               buf[len - 2] = '\0';
+               buf[len - 3] = '/';
+#else
+               buf[len - 3] = '\0';
+#endif
+       }
+       else {
+               assertion_class_count += 1;
+       }
+
+       len = os::strlen(buf);
+
+       for (size_t i = 0; i < len; i++) {
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+               if (buf[i] == '.') {
+                       buf[i] = '/';
+               }
+#else
+               if (buf[i] == '/') {
+                       buf[i] = '.';
+               }
+#endif
+       }
+
+       item          = NEW(assertion_name_t);
+       item->name    = buf;
+       item->enabled = enabled;
+       item->package = package;
+
+       if (list_assertion_names == NULL) {
+               list_assertion_names = new List<assertion_name_t*>();
+       }
+
+       list_assertion_names->push_back(item);
+}
+
+
+/*
+ * 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/assertion.h b/src/vm/assertion.h
deleted file mode 100644 (file)
index 4175bec..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/* src/vm/assertion.h - assertion options
-
-   Copyright (C) 2007
-   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 _ASSERTION_H
-#define _ASSERTION_H
-
-#include "config.h"
-#include "vm/global.h"
-#include "toolbox/list.h"
-
-#include <stdint.h>
-
-typedef struct assertion_name_t assertion_name_t;
-
-struct assertion_name_t {
-       char      *name;
-       bool       enabled;
-       bool       package;
-       listnode_t linkage;
-};
-
-/* -ea/-esa/-da/-dsa options **************************************************/
-
-extern list_t  *list_assertion_names;
-extern int32_t  assertion_class_count;
-extern int32_t  assertion_package_count;
-extern bool     assertion_user_enabled;
-extern bool     assertion_system_enabled;
-
-/* function prototypes ********************************************************/
-
-void assertion_ea_da(const char *name, bool enabled);
-
-#endif /* _ASSERTION_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/assertion.hpp b/src/vm/assertion.hpp
new file mode 100644 (file)
index 0000000..2840b55
--- /dev/null
@@ -0,0 +1,85 @@
+/* src/vm/assertion.hpp - assertion options
+
+   Copyright (C) 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 _ASSERTION_HPP
+#define _ASSERTION_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "toolbox/list.hpp"
+
+
+typedef struct assertion_name_t assertion_name_t;
+
+struct assertion_name_t {
+       char      *name;
+       bool       enabled;
+       bool       package;
+/*     listnode_t linkage; */
+};
+
+/* -ea/-esa/-da/-dsa options **************************************************/
+
+#ifdef __cplusplus
+extern List<assertion_name_t*>*   list_assertion_names;
+#else
+extern List*   list_assertion_names;
+#endif
+
+extern int32_t assertion_class_count;
+extern int32_t assertion_package_count;
+extern bool    assertion_user_enabled;
+extern bool    assertion_system_enabled;
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void assertion_ea_da(const char *name, bool enabled);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _ASSERTION_HPP
+
+
+/*
+ * 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/builtin.c b/src/vm/builtin.c
deleted file mode 100644 (file)
index a4fa268..0000000
+++ /dev/null
@@ -1,2378 +0,0 @@
-/* src/vm/builtin.c - functions for unsupported operations
-
-   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.
-
-   Contains C functions for JavaVM Instructions that cannot be
-   translated to machine language directly. Consequently, the
-   generated machine code for these instructions contains function
-   calls instead of machine instructions, using the C calling
-   convention.
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-
-#include "vm/types.h"
-
-#include "arch.h"
-#include "md-abi.h"
-
-#include "fdlibm/fdlibm.h"
-#if defined(__CYGWIN__) && defined(Bias)
-# undef Bias
-#endif
-
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-
-#include "threads/lock-common.h"
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-#include "toolbox/util.h"
-
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/cycles-stats.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/primitive.h"
-#include "vm/stringlocal.h"
-
-#include "vm/jit/asmpart.h"
-#include "vm/jit/trace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/linker.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/rt-timing.h"
-
-#if defined(ENABLE_VMLOG)
-#include <vmlog_cacao.h>
-#endif
-
-
-/* include builtin tables *****************************************************/
-
-#include "vm/builtintable.inc"
-
-
-CYCLES_STATS_DECLARE(builtin_new         ,100,5)
-CYCLES_STATS_DECLARE(builtin_overhead    , 80,1)
-
-
-/*============================================================================*/
-/* BUILTIN TABLE MANAGEMENT FUNCTIONS                                         */
-/*============================================================================*/
-
-/* builtintable_init ***********************************************************
-
-   Parse the descriptors of builtin functions and create the parsed
-   descriptors.
-
-*******************************************************************************/
-
-static bool builtintable_init(void)
-{
-       descriptor_pool    *descpool;
-       builtintable_entry *bte;
-       methodinfo         *m;
-       int32_t             dumpmarker;
-
-       /* mark start of dump memory area */
-
-       DMARKER;
-
-       /* create a new descriptor pool */
-
-       descpool = descriptor_pool_new(class_java_lang_Object);
-
-       /* add some entries we need */
-
-       if (!descriptor_pool_add_class(descpool, utf_java_lang_Object))
-               return false;
-
-       if (!descriptor_pool_add_class(descpool, utf_java_lang_Class))
-               return false;
-
-       /* first add all descriptors to the pool */
-
-       for (bte = builtintable_internal; bte->fp != NULL; bte++) {
-               bte->name       = utf_new_char(bte->cname);
-               bte->descriptor = utf_new_char(bte->cdescriptor);
-
-               if (!descriptor_pool_add(descpool, bte->descriptor, NULL)) {
-                       /* release dump area */
-
-                       DRELEASE;
-
-                       return false;
-               }
-       }
-
-       for (bte = builtintable_automatic; bte->fp != NULL; bte++) {
-               bte->descriptor = utf_new_char(bte->cdescriptor);
-
-               if (!descriptor_pool_add(descpool, bte->descriptor, NULL)) {
-                       DRELEASE;
-                       return false;
-               }
-       }
-
-       for (bte = builtintable_function; bte->fp != NULL; bte++) {
-               bte->classname  = utf_new_char(bte->cclassname);
-               bte->name       = utf_new_char(bte->cname);
-               bte->descriptor = utf_new_char(bte->cdescriptor);
-
-               if (!descriptor_pool_add(descpool, bte->descriptor, NULL)) {
-                       DRELEASE;
-                       return false;
-               }
-       }
-
-       /* create the class reference table */
-
-       (void) descriptor_pool_create_classrefs(descpool, NULL);
-
-       /* allocate space for the parsed descriptors */
-
-       descriptor_pool_alloc_parsed_descriptors(descpool);
-
-       /* Now parse all descriptors.  NOTE: builtin-functions are treated
-          like static methods (no `this' pointer). */
-
-       for (bte = builtintable_internal; bte->fp != NULL; bte++) {
-               bte->md =
-                       descriptor_pool_parse_method_descriptor(descpool,
-                                                                                                       bte->descriptor,
-                                                                                                       ACC_STATIC | ACC_METHOD_BUILTIN,
-                                                                                                       NULL);
-
-               /* generate a builtin stub if we need one */
-
-               if (bte->flags & BUILTINTABLE_FLAG_STUB) {
-                       m = method_new_builtin(bte);
-                       codegen_generate_stub_builtin(m, bte);
-               }
-       }
-
-       for (bte = builtintable_automatic; bte->fp != NULL; bte++) {
-               bte->md =
-                       descriptor_pool_parse_method_descriptor(descpool,
-                                                                                                       bte->descriptor,
-                                                                                                       ACC_STATIC | ACC_METHOD_BUILTIN,
-                                                                                                       NULL);
-
-               /* no stubs should be needed for this table */
-
-               assert(!bte->flags & BUILTINTABLE_FLAG_STUB);
-       }
-
-       for (bte = builtintable_function; bte->fp != NULL; bte++) {
-               bte->md =
-                       descriptor_pool_parse_method_descriptor(descpool,
-                                                                                                       bte->descriptor,
-                                                                                                       ACC_STATIC | ACC_METHOD_BUILTIN,
-                                                                                                       NULL);
-
-               /* generate a builtin stub if we need one */
-
-               if (bte->flags & BUILTINTABLE_FLAG_STUB) {
-                       m = method_new_builtin(bte);
-                       codegen_generate_stub_builtin(m, bte);
-               }
-       }
-
-       /* release dump area */
-
-       DRELEASE;
-
-       return true;
-}
-
-
-/* builtintable_comparator *****************************************************
-
-   qsort comparator for the automatic builtin table.
-
-*******************************************************************************/
-
-static int builtintable_comparator(const void *a, const void *b)
-{
-       builtintable_entry *bte1;
-       builtintable_entry *bte2;
-
-       bte1 = (builtintable_entry *) a;
-       bte2 = (builtintable_entry *) b;
-
-       return (bte1->opcode < bte2->opcode) ? -1 : (bte1->opcode > bte2->opcode);
-}
-
-
-/* builtintable_sort_automatic *************************************************
-
-   Sorts the automatic builtin table.
-
-*******************************************************************************/
-
-static void builtintable_sort_automatic(void)
-{
-       s4 entries;
-
-       /* calculate table size statically (`- 1' comment see builtintable.inc) */
-
-       entries = sizeof(builtintable_automatic) / sizeof(builtintable_entry) - 1;
-
-       qsort(builtintable_automatic, entries, sizeof(builtintable_entry),
-                 builtintable_comparator);
-}
-
-
-/* builtin_init ****************************************************************
-
-   Initialize the global table of builtin functions.
-
-*******************************************************************************/
-
-bool builtin_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("builtin_init");
-
-       /* initialize the builtin tables */
-
-       if (!builtintable_init())
-               return false;
-
-       /* sort builtin tables */
-
-       builtintable_sort_automatic();
-
-       return true;
-}
-
-
-/* builtintable_get_internal ***************************************************
-
-   Finds an entry in the builtintable for internal functions and
-   returns the a pointer to the structure.
-
-*******************************************************************************/
-
-builtintable_entry *builtintable_get_internal(functionptr fp)
-{
-       builtintable_entry *bte;
-
-       for (bte = builtintable_internal; bte->fp != NULL; bte++) {
-               if (bte->fp == fp)
-                       return bte;
-       }
-
-       return NULL;
-}
-
-
-/* builtintable_get_automatic **************************************************
-
-   Finds an entry in the builtintable for functions which are replaced
-   automatically and returns the a pointer to the structure.
-
-*******************************************************************************/
-
-builtintable_entry *builtintable_get_automatic(s4 opcode)
-{
-       builtintable_entry *first;
-       builtintable_entry *last;
-       builtintable_entry *middle;
-       s4                  half;
-       s4                  entries;
-
-       /* calculate table size statically (`- 1' comment see builtintable.inc) */
-
-       entries = sizeof(builtintable_automatic) / sizeof(builtintable_entry) - 1;
-
-       first = builtintable_automatic;
-       last = builtintable_automatic + entries;
-
-       while (entries > 0) {
-               half = entries / 2;
-               middle = first + half;
-
-               if (middle->opcode < opcode) {
-                       first = middle + 1;
-                       entries -= half + 1;
-               }
-               else
-                       entries = half;
-       }
-
-       return (first != last ? first : NULL);
-}
-
-
-/* builtintable_replace_function ***********************************************
-
-   XXX
-
-*******************************************************************************/
-
-#if defined(ENABLE_JIT)
-bool builtintable_replace_function(void *iptr_)
-{
-       constant_FMIref    *mr;
-       builtintable_entry *bte;
-       instruction        *iptr;
-
-       iptr = (instruction *) iptr_; /* twisti will kill me ;) */
-
-       /* get name and descriptor of the function */
-
-       switch (iptr->opc) {
-       case ICMD_INVOKESTATIC:
-               /* The instruction MUST be resolved, otherwise we run into
-                  lazy loading troubles.  Anyway, we should/can only replace
-                  very VM-close functions. */
-
-               if (INSTRUCTION_IS_UNRESOLVED(iptr))
-                       return false;
-
-               mr = iptr->sx.s23.s3.fmiref;
-               break;  
-
-       default:
-               return false;
-       }
-
-       /* search the function table */
-
-       for (bte = builtintable_function; bte->fp != NULL; bte++) {
-               if ((METHODREF_CLASSNAME(mr) == bte->classname) &&
-                       (mr->name                == bte->name) &&
-                       (mr->descriptor          == bte->descriptor)) {
-
-                       /* set the values in the instruction */
-
-                       iptr->opc           = bte->opcode;
-                       iptr->sx.s23.s3.bte = bte;
-
-                       if (bte->flags & BUILTINTABLE_FLAG_EXCEPTION)
-                               iptr->flags.bits |= INS_FLAG_CHECK;
-                       else
-                               iptr->flags.bits &= ~INS_FLAG_CHECK;
-
-                       return true;
-               }
-       }
-
-       return false;
-}
-#endif /* defined(ENABLE_JIT) */
-
-
-/*============================================================================*/
-/* INTERNAL BUILTIN FUNCTIONS                                                 */
-/*============================================================================*/
-
-/* builtin_instanceof **********************************************************
-
-   Checks if an object is an instance of some given class (or subclass
-   of that class). If class is an interface, checks if the interface
-   is implemented.
-
-   RETURN VALUE:
-     1......o is an instance of class or implements the interface
-     0......otherwise or if o == NULL
-
-   NOTE: This builtin can be called from NATIVE code only.
-
-*******************************************************************************/
-
-bool builtin_instanceof(java_handle_t *o, classinfo *class)
-{
-       classinfo *c;
-
-       if (o == NULL)
-               return 0;
-
-       LLNI_class_get(o, c);
-
-       return class_isanysubclass(c, class);
-}
-
-
-
-/* builtin_checkcast ***********************************************************
-
-   The same as builtin_instanceof but with the exception
-   that 1 is returned when (o == NULL).
-
-   NOTE: This builtin can be called from NATIVE code only.
-
-*******************************************************************************/
-
-bool builtin_checkcast(java_handle_t *o, classinfo *class)
-{
-       classinfo *c;
-
-       if (o == NULL)
-               return 1;
-
-       LLNI_class_get(o, c);
-
-       if (class_isanysubclass(c, class))
-               return 1;
-
-       return 0;
-}
-
-
-/* builtin_descriptorscompatible ***********************************************
-
-   Checks if two array type descriptors are assignment compatible.
-
-   RETURN VALUE:
-      1......target = desc is possible
-      0......otherwise
-                       
-*******************************************************************************/
-
-static bool builtin_descriptorscompatible(arraydescriptor *desc, arraydescriptor *target)
-{
-       if (desc == target)
-               return 1;
-
-       if (desc->arraytype != target->arraytype)
-               return 0;
-
-       if (desc->arraytype != ARRAYTYPE_OBJECT)
-               return 1;
-       
-       /* {both arrays are arrays of references} */
-
-       if (desc->dimension == target->dimension) {
-               if (!desc->elementvftbl)
-                       return 0;
-               /* an array which contains elements of interface types is
-           allowed to be casted to Object (JOWENN)*/
-
-               if ((desc->elementvftbl->baseval < 0) &&
-                       (target->elementvftbl->baseval == 1))
-                       return 1;
-
-               return class_isanysubclass(desc->elementvftbl->clazz,
-                                                                  target->elementvftbl->clazz);
-       }
-
-       if (desc->dimension < target->dimension)
-               return 0;
-
-       /* {desc has higher dimension than target} */
-
-       return class_isanysubclass(pseudo_class_Arraystub,
-                                                          target->elementvftbl->clazz);
-}
-
-
-/* builtin_arraycheckcast ******************************************************
-
-   Checks if an object is really a subtype of the requested array
-   type.  The object has to be an array to begin with. For simple
-   arrays (int, short, double, etc.) the types have to match exactly.
-   For arrays of objects, the type of elements in the array has to be
-   a subtype (or the same type) of the requested element type. For
-   arrays of arrays (which in turn can again be arrays of arrays), the
-   types at the lowest level have to satisfy the corresponding sub
-   class relation.
-
-   NOTE: This is a FAST builtin and can be called from JIT code only.
-
-*******************************************************************************/
-
-bool builtin_fast_arraycheckcast(java_object_t *o, classinfo *targetclass)
-{
-       arraydescriptor *desc;
-
-       if (o == NULL)
-               return 1;
-
-       desc = o->vftbl->arraydesc;
-
-       if (desc == NULL)
-               return 0;
-       return builtin_descriptorscompatible(desc, targetclass->vftbl->arraydesc);
-}
-
-
-/* builtin_fast_arrayinstanceof ************************************************
-
-   NOTE: This is a FAST builtin and can be called from JIT code only.
-
-*******************************************************************************/
-
-bool builtin_fast_arrayinstanceof(java_object_t *o, classinfo *targetclass)
-{
-       if (o == NULL)
-               return 0;
-
-       return builtin_fast_arraycheckcast(o, targetclass);
-}
-
-
-/* builtin_arrayinstanceof *****************************************************
-
-   NOTE: This builtin can be called from NATIVE code only.
-
-*******************************************************************************/
-
-bool builtin_arrayinstanceof(java_handle_t *h, classinfo *targetclass)
-{
-       bool result;
-
-       LLNI_CRITICAL_START;
-
-       result = builtin_fast_arrayinstanceof(LLNI_UNWRAP(h), targetclass);
-
-       LLNI_CRITICAL_END;
-
-       return result;
-}
-
-
-/* builtin_throw_exception *****************************************************
-
-   Sets the exception pointer with the thrown exception and prints some
-   debugging information.
-   
-   NOTE: This is a FAST builtin and can be called from JIT code,
-   or from asm_vm_call_method.
-
-*******************************************************************************/
-
-void *builtin_throw_exception(java_object_t *xptr)
-{
-#if !defined(NDEBUG)
-       /* print exception trace */
-
-       if (opt_TraceExceptions)
-               trace_exception_builtin(xptr);
-#endif /* !defined(NDEBUG) */
-
-       /* actually set the exception */
-
-       exceptions_set_exception(LLNI_QUICKWRAP(xptr));
-
-       /* Return a NULL pointer.  This is required for vm_call_method to
-          check for an exception.  This is for convenience. */
-
-       return NULL;
-}
-
-
-/* builtin_retrieve_exception **************************************************
-
-   Gets and clears the exception pointer of the current thread.
-
-   RETURN VALUE:
-      the exception object, or NULL if no exception was thrown.
-
-   NOTE: This is a FAST builtin and can be called from JIT code,
-   or from the signal handlers.
-
-*******************************************************************************/
-
-java_object_t *builtin_retrieve_exception(void)
-{
-       java_handle_t *h;
-       java_object_t *o;
-
-       /* actually get and clear the exception */
-
-       h = exceptions_get_and_clear_exception();
-       o = LLNI_UNWRAP(h);
-
-       return o;
-}
-
-
-/* builtin_canstore ************************************************************
-
-   Checks, if an object can be stored in an array.
-
-   RETURN VALUE:
-      1......possible
-      0......otherwise (throws an ArrayStoreException)
-
-   NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code.
-
-*******************************************************************************/
-
-bool builtin_canstore(java_handle_objectarray_t *oa, java_handle_t *o)
-{
-       bool result;
-
-       LLNI_CRITICAL_START;
-
-       result = builtin_fast_canstore(LLNI_DIRECT(oa), LLNI_UNWRAP(o));
-
-       LLNI_CRITICAL_END;
-
-       /* if not possible, throw an exception */
-
-       if (result == 0)
-               exceptions_throw_arraystoreexception();
-
-       return result;
-}
-
-#if USES_NEW_SUBTYPE
-/* fast_subtype_check **********************************************************
-
-   Checks if s is a subtype of t, using both the restricted subtype relation
-   and the overflow array (see Cliff Click and John Rose: Fast subtype checking
-   in the Hotspot JVM.)
-
-   RETURN VALUE:
-      1......s is a subtype of t.
-      0......otherwise
-
-*******************************************************************************/
-
-bool fast_subtype_check(struct _vftbl *s, struct _vftbl *t)
-{
-   if (s->subtype_display[t->subtype_depth] == t)
-       return true;
-   if (t->subtype_offset != OFFSET(vftbl_t, subtype_display[DISPLAY_SIZE]))
-       return false;
-   return s->subtype_depth >= t->subtype_depth && s->subtype_overflow[t->subtype_depth - DISPLAY_SIZE] == t;
-}
-#endif
-
-/* builtin_fast_canstore *******************************************************
-
-   Checks, if an object can be stored in an array.
-
-   RETURN VALUE:
-      1......possible
-      0......otherwise (no exception thrown!)
-
-   NOTE: This is a FAST builtin and can be called from JIT code only.
-
-*******************************************************************************/
-
-bool builtin_fast_canstore(java_objectarray_t *oa, java_object_t *o)
-{
-       arraydescriptor *desc;
-       arraydescriptor *valuedesc;
-       vftbl_t         *componentvftbl;
-       vftbl_t         *valuevftbl;
-       int32_t          baseval;
-       uint32_t         diffval;
-       bool             result;
-
-       if (o == NULL)
-               return 1;
-
-       /* The following is guaranteed (by verifier checks):
-        *
-        *     *) oa->...vftbl->arraydesc != NULL
-        *     *) oa->...vftbl->arraydesc->componentvftbl != NULL
-        *     *) o->vftbl is not an interface vftbl
-        */
-
-       desc           = oa->header.objheader.vftbl->arraydesc;
-       componentvftbl = desc->componentvftbl;
-       valuevftbl     = o->vftbl;
-       valuedesc      = valuevftbl->arraydesc;
-
-       if ((desc->dimension - 1) == 0) {
-               /* {oa is a one-dimensional array} */
-               /* {oa is an array of references} */
-               
-               if (valuevftbl == componentvftbl)
-                       return 1;
-
-               LOCK_CLASSRENUMBER_LOCK;
-
-               baseval = componentvftbl->baseval;
-
-               if (baseval <= 0) {
-                       /* an array of interface references */
-
-                       result = ((valuevftbl->interfacetablelength > -baseval) &&
-                                         (valuevftbl->interfacetable[baseval] != NULL));
-               }
-               else {
-#if USES_NEW_SUBTYPE
-                       result = fast_subtype_check(valuevftbl, componentvftbl);
-#else
-                       diffval = valuevftbl->baseval - componentvftbl->baseval;
-                       result  = diffval <= (uint32_t) componentvftbl->diffval;
-#endif
-               }
-
-               UNLOCK_CLASSRENUMBER_LOCK;
-       }
-       else if (valuedesc == NULL) {
-               /* {oa has dimension > 1} */
-               /* {componentvftbl->arraydesc != NULL} */
-
-               /* check if o is an array */
-
-               return 0;
-       }
-       else {
-               /* {o is an array} */
-
-               result = builtin_descriptorscompatible(valuedesc, componentvftbl->arraydesc);
-       }
-
-       /* return result */
-
-       return result;
-}
-
-
-/* This is an optimized version where a is guaranteed to be one-dimensional */
-bool builtin_fast_canstore_onedim(java_objectarray_t *a, java_object_t *o)
-{
-       arraydescriptor *desc;
-       vftbl_t         *elementvftbl;
-       vftbl_t         *valuevftbl;
-       int32_t          baseval;
-       uint32_t         diffval;
-       bool             result;
-       
-       if (o == NULL)
-               return 1;
-
-       /* The following is guaranteed (by verifier checks):
-        *
-        *     *) a->...vftbl->arraydesc != NULL
-        *     *) a->...vftbl->arraydesc->elementvftbl != NULL
-        *     *) a->...vftbl->arraydesc->dimension == 1
-        *     *) o->vftbl is not an interface vftbl
-        */
-
-       desc = a->header.objheader.vftbl->arraydesc;
-    elementvftbl = desc->elementvftbl;
-       valuevftbl = o->vftbl;
-
-       /* {a is a one-dimensional array} */
-       
-       if (valuevftbl == elementvftbl)
-               return 1;
-
-       LOCK_CLASSRENUMBER_LOCK;
-
-       baseval = elementvftbl->baseval;
-
-       if (baseval <= 0) {
-               /* an array of interface references */
-               result = ((valuevftbl->interfacetablelength > -baseval) &&
-                                 (valuevftbl->interfacetable[baseval] != NULL));
-       }
-       else {
-#if USES_NEW_SUBTYPE
-               result = fast_subtype_check(valuevftbl, elementvftbl);
-#else
-               diffval = valuevftbl->baseval - elementvftbl->baseval;
-               result  = diffval <= (uint32_t) elementvftbl->diffval;
-#endif
-       }
-
-       UNLOCK_CLASSRENUMBER_LOCK;
-
-       return result;
-}
-
-
-/* This is an optimized version where a is guaranteed to be a
- * one-dimensional array of a class type */
-bool builtin_fast_canstore_onedim_class(java_objectarray_t *a, java_object_t *o)
-{
-       vftbl_t  *elementvftbl;
-       vftbl_t  *valuevftbl;
-       uint32_t  diffval;
-       bool      result;
-       
-       if (o == NULL)
-               return 1;
-
-       /* The following is guaranteed (by verifier checks):
-        *
-        *     *) a->...vftbl->arraydesc != NULL
-        *     *) a->...vftbl->arraydesc->elementvftbl != NULL
-        *     *) a->...vftbl->arraydesc->elementvftbl is not an interface vftbl
-        *     *) a->...vftbl->arraydesc->dimension == 1
-        *     *) o->vftbl is not an interface vftbl
-        */
-
-    elementvftbl = a->header.objheader.vftbl->arraydesc->elementvftbl;
-       valuevftbl = o->vftbl;
-
-       /* {a is a one-dimensional array} */
-       
-       if (valuevftbl == elementvftbl)
-               return 1;
-
-       LOCK_CLASSRENUMBER_LOCK;
-
-#if USES_NEW_SUBTYPE
-       result = fast_subtype_check(valuevftbl, elementvftbl);
-#else
-       diffval = valuevftbl->baseval - elementvftbl->baseval;
-       result  = diffval <= (uint32_t) elementvftbl->diffval;
-#endif
-
-       UNLOCK_CLASSRENUMBER_LOCK;
-
-       return result;
-}
-
-
-/* builtin_new *****************************************************************
-
-   Creates a new instance of class c on the heap.
-
-   RETURN VALUE:
-      pointer to the object, or NULL if no memory is available
-
-   NOTE: This builtin can be called from NATIVE code only.
-
-*******************************************************************************/
-
-java_handle_t *builtin_new(classinfo *c)
-{
-       java_handle_t *o;
-#if defined(ENABLE_RT_TIMING)
-       struct timespec time_start, time_end;
-#endif
-#if defined(ENABLE_CYCLES_STATS)
-       u8 cycles_start, cycles_end;
-#endif
-
-       RT_TIMING_GET_TIME(time_start);
-       CYCLES_STATS_GET(cycles_start);
-
-       /* is the class loaded */
-
-       assert(c->state & CLASS_LOADED);
-
-       /* check if we can instantiate this class */
-
-       if (c->flags & ACC_ABSTRACT) {
-               exceptions_throw_instantiationerror(c);
-               return NULL;
-       }
-
-       /* is the class linked */
-
-       if (!(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return NULL;
-
-       if (!(c->state & CLASS_INITIALIZED)) {
-#if !defined(NDEBUG)
-               if (initverbose)
-                       log_message_class("Initialize class (from builtin_new): ", c);
-#endif
-
-               if (!initialize_class(c))
-                       return NULL;
-       }
-
-       o = heap_alloc(c->instancesize, c->flags & ACC_CLASS_HAS_POINTERS,
-                                  c->finalizer, true);
-
-       if (!o)
-               return NULL;
-
-#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES)
-       /* XXX this is only a dirty hack to make Boehm work with handles */
-
-       o = LLNI_WRAP((java_object_t *) o);
-#endif
-
-       LLNI_vftbl_direct(o) = c->vftbl;
-
-#if defined(ENABLE_THREADS)
-       lock_init_object_lock(LLNI_DIRECT(o));
-#endif
-
-       CYCLES_STATS_GET(cycles_end);
-       RT_TIMING_GET_TIME(time_end);
-
-       CYCLES_STATS_COUNT(builtin_new,cycles_end - cycles_start);
-       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_OBJECT);
-
-       return o;
-}
-
-
-/* builtin_java_new ************************************************************
-
-   NOTE: This is a SLOW builtin and can be called from JIT code only.
-
-*******************************************************************************/
-
-java_handle_t *builtin_java_new(java_handle_t *clazz)
-{
-       return builtin_new(LLNI_classinfo_unwrap(clazz));
-}
-
-
-/* builtin_fast_new ************************************************************
-
-   Creates a new instance of class c on the heap.
-
-   RETURN VALUE:
-      pointer to the object, or NULL if no fast return
-      is possible for any reason.
-
-   NOTE: This is a FAST builtin and can be called from JIT code only.
-
-*******************************************************************************/
-
-java_object_t *builtin_fast_new(classinfo *c)
-{
-       java_object_t *o;
-#if defined(ENABLE_RT_TIMING)
-       struct timespec time_start, time_end;
-#endif
-#if defined(ENABLE_CYCLES_STATS)
-       u8 cycles_start, cycles_end;
-#endif
-
-       RT_TIMING_GET_TIME(time_start);
-       CYCLES_STATS_GET(cycles_start);
-
-       /* is the class loaded */
-
-       assert(c->state & CLASS_LOADED);
-
-       /* check if we can instantiate this class */
-
-       if (c->flags & ACC_ABSTRACT)
-               return NULL;
-
-       /* is the class linked */
-
-       if (!(c->state & CLASS_LINKED))
-               return NULL;
-
-       if (!(c->state & CLASS_INITIALIZED))
-               return NULL;
-
-       o = heap_alloc(c->instancesize, c->flags & ACC_CLASS_HAS_POINTERS,
-                                  c->finalizer, false);
-
-       if (!o)
-               return NULL;
-
-       o->vftbl = c->vftbl;
-
-#if defined(ENABLE_THREADS)
-       lock_init_object_lock(o);
-#endif
-
-       CYCLES_STATS_GET(cycles_end);
-       RT_TIMING_GET_TIME(time_end);
-
-       CYCLES_STATS_COUNT(builtin_new,cycles_end - cycles_start);
-       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_OBJECT);
-
-       return o;
-}
-
-
-/* builtin_newarray ************************************************************
-
-   Creates an array with the given vftbl on the heap. This function
-   takes as class argument an array class.
-
-   RETURN VALUE:
-      pointer to the array or NULL if no memory is available
-
-   NOTE: This builtin can be called from NATIVE code only.
-
-*******************************************************************************/
-
-java_handle_t *builtin_newarray(int32_t size, classinfo *arrayclass)
-{
-       arraydescriptor *desc;
-       s4               dataoffset;
-       s4               componentsize;
-       s4               actualsize;
-       java_handle_t   *a;
-#if defined(ENABLE_RT_TIMING)
-       struct timespec time_start, time_end;
-#endif
-
-       RT_TIMING_GET_TIME(time_start);
-
-       desc          = arrayclass->vftbl->arraydesc;
-       dataoffset    = desc->dataoffset;
-       componentsize = desc->componentsize;
-
-       if (size < 0) {
-               exceptions_throw_negativearraysizeexception();
-               return NULL;
-       }
-
-       actualsize = dataoffset + size * componentsize;
-
-       /* check for overflow */
-
-       if (((u4) actualsize) < ((u4) size)) {
-               exceptions_throw_outofmemoryerror();
-               return NULL;
-       }
-
-       a = heap_alloc(actualsize, (desc->arraytype == ARRAYTYPE_OBJECT), NULL, true);
-
-       if (a == NULL)
-               return NULL;
-
-#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES)
-       /* XXX this is only a dirty hack to make Boehm work with handles */
-
-       a = LLNI_WRAP((java_object_t *) a);
-#endif
-
-       LLNI_vftbl_direct(a) = arrayclass->vftbl;
-
-#if defined(ENABLE_THREADS)
-       lock_init_object_lock(LLNI_DIRECT(a));
-#endif
-
-       LLNI_array_size(a) = size;
-
-       RT_TIMING_GET_TIME(time_end);
-       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_ARRAY);
-
-       return a;
-}
-
-
-/* builtin_java_newarray *******************************************************
-
-   NOTE: This is a SLOW builtin and can be called from JIT code only.
-
-*******************************************************************************/
-
-java_handle_t *builtin_java_newarray(int32_t size, java_handle_t *arrayclazz)
-{
-       return builtin_newarray(size, LLNI_classinfo_unwrap(arrayclazz));
-}
-
-
-/* builtin_anewarray ***********************************************************
-
-   Creates an array of references to the given class type on the heap.
-
-   RETURN VALUE:
-      pointer to the array or NULL if no memory is
-      available
-
-   NOTE: This builtin can be called from NATIVE code only.
-
-*******************************************************************************/
-
-java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass)
-{
-       classinfo *arrayclass;
-       
-       /* is class loaded */
-
-       assert(componentclass->state & CLASS_LOADED);
-
-       /* is class linked */
-
-       if (!(componentclass->state & CLASS_LINKED))
-               if (!link_class(componentclass))
-                       return NULL;
-
-       arrayclass = class_array_of(componentclass, true);
-
-       if (!arrayclass)
-               return NULL;
-
-       return (java_handle_objectarray_t *) builtin_newarray(size, arrayclass);
-}
-
-
-/* builtin_newarray_type ****************************************************
-
-   Creates an array of [type]s on the heap.
-       
-   RETURN VALUE:
-      pointer to the array or NULL if no memory is available
-
-   NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code.
-
-*******************************************************************************/
-
-#define BUILTIN_NEWARRAY_TYPE(type, arraytype)                             \
-java_handle_##type##array_t *builtin_newarray_##type(int32_t size)              \
-{                                                                          \
-       return (java_handle_##type##array_t *)                                 \
-               builtin_newarray(size, primitivetype_table[arraytype].arrayclass); \
-}
-
-BUILTIN_NEWARRAY_TYPE(boolean, ARRAYTYPE_BOOLEAN)
-BUILTIN_NEWARRAY_TYPE(byte,    ARRAYTYPE_BYTE)
-BUILTIN_NEWARRAY_TYPE(char,    ARRAYTYPE_CHAR)
-BUILTIN_NEWARRAY_TYPE(short,   ARRAYTYPE_SHORT)
-BUILTIN_NEWARRAY_TYPE(int,     ARRAYTYPE_INT)
-BUILTIN_NEWARRAY_TYPE(long,    ARRAYTYPE_LONG)
-BUILTIN_NEWARRAY_TYPE(float,   ARRAYTYPE_FLOAT)
-BUILTIN_NEWARRAY_TYPE(double,  ARRAYTYPE_DOUBLE)
-
-
-/* builtin_multianewarray_intern ***********************************************
-
-   Creates a multi-dimensional array on the heap. The dimensions are
-   passed in an array of longs.
-
-   ARGUMENTS:
-      n.............number of dimensions to create
-      arrayclass....the array class
-      dims..........array containing the size of each dimension to create
-
-   RETURN VALUE:
-      pointer to the array or NULL if no memory is available
-
-******************************************************************************/
-
-static java_handle_t *builtin_multianewarray_intern(int n,
-                                                                                                       classinfo *arrayclass,
-                                                                                                       long *dims)
-{
-       s4             size;
-       java_handle_t *a;
-       classinfo     *componentclass;
-       s4             i;
-
-       /* create this dimension */
-
-       size = (s4) dims[0];
-       a = builtin_newarray(size, arrayclass);
-
-       if (!a)
-               return NULL;
-
-       /* if this is the last dimension return */
-
-       if (!--n)
-               return a;
-
-       /* get the class of the components to create */
-
-       componentclass = arrayclass->vftbl->arraydesc->componentvftbl->clazz;
-
-       /* The verifier guarantees that the dimension count is in the range. */
-
-       /* create the component arrays */
-
-       for (i = 0; i < size; i++) {
-               java_handle_t *ea =
-#if defined(__MIPS__) && (SIZEOF_VOID_P == 4)
-                       /* we save an s4 to a s8 slot, 8-byte aligned */
-
-                       builtin_multianewarray_intern(n, componentclass, dims + 2);
-#else
-                       builtin_multianewarray_intern(n, componentclass, dims + 1);
-#endif
-
-               if (!ea)
-                       return NULL;
-
-               array_objectarray_element_set((java_handle_objectarray_t *) a, i, ea);
-       }
-
-       return a;
-}
-
-
-/* builtin_multianewarray ******************************************************
-
-   Wrapper for builtin_multianewarray_intern which checks all
-   dimensions before we start allocating.
-
-   NOTE: This is a SLOW builtin and can be called from JIT code only.
-
-******************************************************************************/
-
-java_handle_objectarray_t *builtin_multianewarray(int n,
-                                                                                                 java_handle_t *arrayclazz,
-                                                                                                 long *dims)
-{
-       classinfo *c;
-       s4         i;
-       s4         size;
-
-       /* check all dimensions before doing anything */
-
-       for (i = 0; i < n; i++) {
-#if defined(__MIPS__) && (SIZEOF_VOID_P == 4)
-               /* we save an s4 to a s8 slot, 8-byte aligned */
-               size = (s4) dims[i * 2];
-#else
-               size = (s4) dims[i];
-#endif
-
-               if (size < 0) {
-                       exceptions_throw_negativearraysizeexception();
-                       return NULL;
-               }
-       }
-
-       c = LLNI_classinfo_unwrap(arrayclazz);
-
-       /* now call the real function */
-
-       return (java_handle_objectarray_t *)
-               builtin_multianewarray_intern(n, c, dims);
-}
-
-
-/* builtin_verbosecall_enter ***************************************************
-
-   Print method call with arguments for -verbose:call.
-
-   XXX: Remove mew once all archs use the new tracer!
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-#ifdef TRACE_ARGS_NUM
-void builtin_verbosecall_enter(s8 a0, s8 a1,
-# if TRACE_ARGS_NUM >= 4
-                                                          s8 a2, s8 a3,
-# endif
-# if TRACE_ARGS_NUM >= 6
-                                                          s8 a4, s8 a5,
-# endif
-# if TRACE_ARGS_NUM == 8
-                                                          s8 a6, s8 a7,
-# endif
-                                                          methodinfo *m)
-{
-       log_text("builtin_verbosecall_enter: Do not call me anymore!");
-}
-#endif
-#endif /* !defined(NDEBUG) */
-
-
-/* builtin_verbosecall_exit ****************************************************
-
-   Print method exit for -verbose:call.
-
-   XXX: Remove mew once all archs use the new tracer!
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void builtin_verbosecall_exit(s8 l, double d, float f, methodinfo *m)
-{
-       log_text("builtin_verbosecall_exit: Do not call me anymore!");
-}
-#endif /* !defined(NDEBUG) */
-
-
-/*============================================================================*/
-/* MISCELLANEOUS MATHEMATICAL HELPER FUNCTIONS                                */
-/*============================================================================*/
-
-/*********** Functions for integer divisions *****************************
-       On some systems (eg. DEC ALPHA), integer division is not supported by the
-       CPU. These helper functions implement the missing functionality.
-
-******************************************************************************/
-
-#if !SUPPORT_DIVISION || defined(DISABLE_GC)
-s4 builtin_idiv(s4 a, s4 b)
-{
-       s4 c;
-
-       c = a / b;
-
-       return c;
-}
-
-s4 builtin_irem(s4 a, s4 b)
-{
-       s4 c;
-
-       c = a % b;
-
-       return c;
-}
-#endif /* !SUPPORT_DIVISION || defined(DISABLE_GC) */
-
-
-/* functions for long arithmetics **********************************************
-
-   On systems where 64 bit Integers are not supported by the CPU,
-   these functions are needed.
-
-******************************************************************************/
-
-#if !(SUPPORT_LONG && SUPPORT_LONG_ADD)
-s8 builtin_ladd(s8 a, s8 b)
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = a + b; 
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-
-s8 builtin_lsub(s8 a, s8 b)
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = a - b; 
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-
-s8 builtin_lneg(s8 a)
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = -a;
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-#endif /* !(SUPPORT_LONG && SUPPORT_LONG_ADD) */
-
-
-#if !(SUPPORT_LONG && SUPPORT_LONG_MUL)
-s8 builtin_lmul(s8 a, s8 b)
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = a * b; 
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-#endif /* !(SUPPORT_LONG && SUPPORT_LONG_MUL) */
-
-
-#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) || defined (DISABLE_GC)
-s8 builtin_ldiv(s8 a, s8 b)
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = a / b; 
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-
-s8 builtin_lrem(s8 a, s8 b)
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = a % b; 
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-#endif /* !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) */
-
-
-#if !(SUPPORT_LONG && SUPPORT_LONG_SHIFT)
-s8 builtin_lshl(s8 a, s4 b)
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = a << (b & 63);
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-
-s8 builtin_lshr(s8 a, s4 b)
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = a >> (b & 63);
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-
-s8 builtin_lushr(s8 a, s4 b)
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = ((u8) a) >> (b & 63);
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-#endif /* !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) */
-
-
-#if !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL)
-s8 builtin_land(s8 a, s8 b)
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = a & b; 
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-
-s8 builtin_lor(s8 a, s8 b)
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = a | b; 
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-
-s8 builtin_lxor(s8 a, s8 b) 
-{
-       s8 c;
-
-#if U8_AVAILABLE
-       c = a ^ b; 
-#else
-       c = builtin_i2l(0);
-#endif
-
-       return c;
-}
-#endif /* !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) */
-
-
-#if !(SUPPORT_LONG && SUPPORT_LONG_CMP)
-s4 builtin_lcmp(s8 a, s8 b)
-{ 
-#if U8_AVAILABLE
-       if (a < b)
-               return -1;
-
-       if (a > b)
-               return 1;
-
-       return 0;
-#else
-       return 0;
-#endif
-}
-#endif /* !(SUPPORT_LONG && SUPPORT_LONG_CMP) */
-
-
-/* functions for unsupported floating instructions ****************************/
-
-/* used to convert FLT_xxx defines into float values */
-
-static inline float intBitsToFloat(s4 i)
-{
-       imm_union imb;
-
-       imb.i = i;
-       return imb.f;
-}
-
-
-/* used to convert DBL_xxx defines into double values */
-
-static inline float longBitsToDouble(s8 l)
-{
-       imm_union imb;
-
-       imb.l = l;
-       return imb.d;
-}
-
-
-#if !SUPPORT_FLOAT
-float builtin_fadd(float a, float b)
-{
-       if (isnanf(a)) return intBitsToFloat(FLT_NAN);
-       if (isnanf(b)) return intBitsToFloat(FLT_NAN);
-       if (finitef(a)) {
-               if (finitef(b))
-                       return a + b;
-               else
-                       return b;
-       }
-       else {
-               if (finitef(b))
-                       return a;
-               else {
-                       if (copysignf(1.0, a) == copysignf(1.0, b))
-                               return a;
-                       else
-                               return intBitsToFloat(FLT_NAN);
-               }
-       }
-}
-
-
-float builtin_fsub(float a, float b)
-{
-       return builtin_fadd(a, builtin_fneg(b));
-}
-
-
-float builtin_fmul(float a, float b)
-{
-       if (isnanf(a)) return intBitsToFloat(FLT_NAN);
-       if (isnanf(b)) return intBitsToFloat(FLT_NAN);
-       if (finitef(a)) {
-               if (finitef(b)) return a * b;
-               else {
-                       if (a == 0) return intBitsToFloat(FLT_NAN);
-                       else return copysignf(b, copysignf(1.0, b)*a);
-               }
-       }
-       else {
-               if (finitef(b)) {
-                       if (b == 0) return intBitsToFloat(FLT_NAN);
-                       else return copysignf(a, copysignf(1.0, a)*b);
-               }
-               else {
-                       return copysignf(a, copysignf(1.0, a)*copysignf(1.0, b));
-               }
-       }
-}
-
-
-/* builtin_ddiv ****************************************************************
-
-   Implementation as described in VM Spec.
-
-*******************************************************************************/
-
-float builtin_fdiv(float a, float b)
-{
-       if (finitef(a)) {
-               if (finitef(b)) {
-                       /* If neither value1' nor value2' is NaN, the sign of the result */
-                       /* is positive if both values have the same sign, negative if the */
-                       /* values have different signs. */
-
-                       return a / b;
-
-               } else {
-                       if (isnanf(b)) {
-                               /* If either value1' or value2' is NaN, the result is NaN. */
-
-                               return intBitsToFloat(FLT_NAN);
-
-                       } else {
-                               /* Division of a finite value by an infinity results in a */
-                               /* signed zero, with the sign-producing rule just given. */
-
-                               /* is sign equal? */
-
-                               if (copysignf(1.0, a) == copysignf(1.0, b))
-                                       return 0.0;
-                               else
-                                       return -0.0;
-                       }
-               }
-
-       } else {
-               if (isnanf(a)) {
-                       /* If either value1' or value2' is NaN, the result is NaN. */
-
-                       return intBitsToFloat(FLT_NAN);
-
-               } else if (finitef(b)) {
-                       /* Division of an infinity by a finite value results in a signed */
-                       /* infinity, with the sign-producing rule just given. */
-
-                       /* is sign equal? */
-
-                       if (copysignf(1.0, a) == copysignf(1.0, b))
-                               return intBitsToFloat(FLT_POSINF);
-                       else
-                               return intBitsToFloat(FLT_NEGINF);
-
-               } else {
-                       /* Division of an infinity by an infinity results in NaN. */
-
-                       return intBitsToFloat(FLT_NAN);
-               }
-       }
-}
-
-
-float builtin_fneg(float a)
-{
-       if (isnanf(a)) return a;
-       else {
-               if (finitef(a)) return -a;
-               else return copysignf(a, -copysignf(1.0, a));
-       }
-}
-#endif /* !SUPPORT_FLOAT */
-
-
-#if !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP || defined(ENABLE_INTRP)
-s4 builtin_fcmpl(float a, float b)
-{
-       if (isnanf(a))
-               return -1;
-
-       if (isnanf(b))
-               return -1;
-
-       if (!finitef(a) || !finitef(b)) {
-               a = finitef(a) ? 0 : copysignf(1.0,     a);
-               b = finitef(b) ? 0 : copysignf(1.0, b);
-       }
-
-       if (a > b)
-               return 1;
-
-       if (a == b)
-               return 0;
-
-       return -1;
-}
-
-
-s4 builtin_fcmpg(float a, float b)
-{
-       if (isnanf(a)) return 1;
-       if (isnanf(b)) return 1;
-       if (!finitef(a) || !finitef(b)) {
-               a = finitef(a) ? 0 : copysignf(1.0, a);
-               b = finitef(b) ? 0 : copysignf(1.0, b);
-       }
-       if (a > b) return 1;
-       if (a == b) return 0;
-       return -1;
-}
-#endif /* !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP || defined(ENABLE_INTRP) */
-
-
-float builtin_frem(float a, float b)
-{
-       return fmodf(a, b);
-}
-
-
-/* functions for unsupported double instructions ******************************/
-
-#if !SUPPORT_DOUBLE
-double builtin_dadd(double a, double b)
-{
-       if (isnan(a)) return longBitsToDouble(DBL_NAN);
-       if (isnan(b)) return longBitsToDouble(DBL_NAN);
-       if (finite(a)) {
-               if (finite(b)) return a + b;
-               else return b;
-       }
-       else {
-               if (finite(b)) return a;
-               else {
-                       if (copysign(1.0, a)==copysign(1.0, b)) return a;
-                       else return longBitsToDouble(DBL_NAN);
-               }
-       }
-}
-
-
-double builtin_dsub(double a, double b)
-{
-       return builtin_dadd(a, builtin_dneg(b));
-}
-
-
-double builtin_dmul(double a, double b)
-{
-       if (isnan(a)) return longBitsToDouble(DBL_NAN);
-       if (isnan(b)) return longBitsToDouble(DBL_NAN);
-       if (finite(a)) {
-               if (finite(b)) return a * b;
-               else {
-                       if (a == 0) return longBitsToDouble(DBL_NAN);
-                       else return copysign(b, copysign(1.0, b) * a);
-               }
-       }
-       else {
-               if (finite(b)) {
-                       if (b == 0) return longBitsToDouble(DBL_NAN);
-                       else return copysign(a, copysign(1.0, a) * b);
-               }
-               else {
-                       return copysign(a, copysign(1.0, a) * copysign(1.0, b));
-               }
-       }
-}
-
-
-/* builtin_ddiv ****************************************************************
-
-   Implementation as described in VM Spec.
-
-*******************************************************************************/
-
-double builtin_ddiv(double a, double b)
-{
-       if (finite(a)) {
-               if (finite(b)) {
-                       /* If neither value1' nor value2' is NaN, the sign of the result */
-                       /* is positive if both values have the same sign, negative if the */
-                       /* values have different signs. */
-
-                       return a / b;
-
-               } else {
-                       if (isnan(b)) {
-                               /* If either value1' or value2' is NaN, the result is NaN. */
-
-                               return longBitsToDouble(DBL_NAN);
-
-                       } else {
-                               /* Division of a finite value by an infinity results in a */
-                               /* signed zero, with the sign-producing rule just given. */
-
-                               /* is sign equal? */
-
-                               if (copysign(1.0, a) == copysign(1.0, b))
-                                       return 0.0;
-                               else
-                                       return -0.0;
-                       }
-               }
-
-       } else {
-               if (isnan(a)) {
-                       /* If either value1' or value2' is NaN, the result is NaN. */
-
-                       return longBitsToDouble(DBL_NAN);
-
-               } else if (finite(b)) {
-                       /* Division of an infinity by a finite value results in a signed */
-                       /* infinity, with the sign-producing rule just given. */
-
-                       /* is sign equal? */
-
-                       if (copysign(1.0, a) == copysign(1.0, b))
-                               return longBitsToDouble(DBL_POSINF);
-                       else
-                               return longBitsToDouble(DBL_NEGINF);
-
-               } else {
-                       /* Division of an infinity by an infinity results in NaN. */
-
-                       return longBitsToDouble(DBL_NAN);
-               }
-       }
-}
-
-
-/* builtin_dneg ****************************************************************
-
-   Implemented as described in VM Spec.
-
-*******************************************************************************/
-
-double builtin_dneg(double a)
-{
-       if (isnan(a)) {
-               /* If the operand is NaN, the result is NaN (recall that NaN has no */
-               /* sign). */
-
-               return a;
-
-       } else {
-               if (finite(a)) {
-                       /* If the operand is a zero, the result is the zero of opposite */
-                       /* sign. */
-
-                       return -a;
-
-               } else {
-                       /* If the operand is an infinity, the result is the infinity of */
-                       /* opposite sign. */
-
-                       return copysign(a, -copysign(1.0, a));
-               }
-       }
-}
-#endif /* !SUPPORT_DOUBLE */
-
-
-#if !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP || defined(ENABLE_INTRP)
-s4 builtin_dcmpl(double a, double b)
-{
-       if (isnan(a))
-               return -1;
-
-       if (isnan(b))
-               return -1;
-
-       if (!finite(a) || !finite(b)) {
-               a = finite(a) ? 0 : copysign(1.0, a);
-               b = finite(b) ? 0 : copysign(1.0, b);
-       }
-
-       if (a > b)
-               return 1;
-
-       if (a == b)
-               return 0;
-
-       return -1;
-}
-
-
-s4 builtin_dcmpg(double a, double b)
-{
-       if (isnan(a))
-               return 1;
-
-       if (isnan(b))
-               return 1;
-
-       if (!finite(a) || !finite(b)) {
-               a = finite(a) ? 0 : copysign(1.0, a);
-               b = finite(b) ? 0 : copysign(1.0, b);
-       }
-
-       if (a > b)
-               return 1;
-
-       if (a == b)
-               return 0;
-
-       return -1;
-}
-#endif /* !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP || defined(ENABLE_INTRP) */
-
-
-double builtin_drem(double a, double b)
-{
-       return fmod(a, b);
-}
-
-
-/* conversion operations ******************************************************/
-
-#if 0
-s8 builtin_i2l(s4 i)
-{
-#if U8_AVAILABLE
-       return i;
-#else
-       s8 v;
-       v.high = 0;
-       v.low = i;
-       return v;
-#endif
-}
-
-s4 builtin_l2i(s8 l)
-{
-#if U8_AVAILABLE
-       return (s4) l;
-#else
-       return l.low;
-#endif
-}
-#endif
-
-
-#if !(SUPPORT_FLOAT && SUPPORT_I2F)
-float builtin_i2f(s4 a)
-{
-       float f = (float) a;
-       return f;
-}
-#endif /* !(SUPPORT_FLOAT && SUPPORT_I2F) */
-
-
-#if !(SUPPORT_DOUBLE && SUPPORT_I2D)
-double builtin_i2d(s4 a)
-{
-       double d = (double) a;
-       return d;
-}
-#endif /* !(SUPPORT_DOUBLE && SUPPORT_I2D) */
-
-
-#if !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F)
-float builtin_l2f(s8 a)
-{
-#if U8_AVAILABLE
-       float f = (float) a;
-       return f;
-#else
-       return 0.0;
-#endif
-}
-#endif /* !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F) */
-
-
-#if !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D)
-double builtin_l2d(s8 a)
-{
-#if U8_AVAILABLE
-       double d = (double) a;
-       return d;
-#else
-       return 0.0;
-#endif
-}
-#endif /* !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D) */
-
-
-#if !(SUPPORT_FLOAT && SUPPORT_F2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC)
-s4 builtin_f2i(float a) 
-{
-       s4 i;
-
-       i = builtin_d2i((double) a);
-
-       return i;
-
-       /*      float f;
-       
-               if (isnanf(a))
-               return 0;
-               if (finitef(a)) {
-               if (a > 2147483647)
-               return 2147483647;
-               if (a < (-2147483648))
-               return (-2147483648);
-               return (s4) a;
-               }
-               f = copysignf((float) 1.0, a);
-               if (f > 0)
-               return 2147483647;
-               return (-2147483648); */
-}
-#endif /* !(SUPPORT_FLOAT && SUPPORT_F2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) */
-
-
-#if !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L) || defined(DISABLE_GC)
-s8 builtin_f2l(float a)
-{
-       s8 l;
-
-       l = builtin_d2l((double) a);
-
-       return l;
-
-       /*      float f;
-       
-               if (finitef(a)) {
-               if (a > 9223372036854775807L)
-               return 9223372036854775807L;
-               if (a < (-9223372036854775808L))
-               return (-9223372036854775808L);
-               return (s8) a;
-               }
-               if (isnanf(a))
-               return 0;
-               f = copysignf((float) 1.0, a);
-               if (f > 0)
-               return 9223372036854775807L;
-               return (-9223372036854775808L); */
-}
-#endif /* !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L) */
-
-
-#if !(SUPPORT_DOUBLE && SUPPORT_D2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC)
-s4 builtin_d2i(double a) 
-{ 
-       double d;
-       
-       if (finite(a)) {
-               if (a >= 2147483647)
-                       return 2147483647;
-               if (a <= (-2147483647-1))
-                       return (-2147483647-1);
-               return (s4) a;
-       }
-       if (isnan(a))
-               return 0;
-       d = copysign(1.0, a);
-       if (d > 0)
-               return 2147483647;
-       return (-2147483647-1);
-}
-#endif /* !(SUPPORT_DOUBLE && SUPPORT_D2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) */
-
-
-#if !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L) || defined(DISABLE_GC)
-s8 builtin_d2l(double a)
-{
-       double d;
-       
-       if (finite(a)) {
-               if (a >= 9223372036854775807LL)
-                       return 9223372036854775807LL;
-               if (a <= (-9223372036854775807LL-1))
-                       return (-9223372036854775807LL-1);
-               return (s8) a;
-       }
-       if (isnan(a))
-               return 0;
-       d = copysign(1.0, a);
-       if (d > 0)
-               return 9223372036854775807LL;
-       return (-9223372036854775807LL-1);
-}
-#endif /* !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L) */
-
-
-#if !(SUPPORT_FLOAT && SUPPORT_DOUBLE)
-double builtin_f2d(float a)
-{
-       if (finitef(a)) return (double) a;
-       else {
-               if (isnanf(a))
-                       return longBitsToDouble(DBL_NAN);
-               else
-                       return copysign(longBitsToDouble(DBL_POSINF), (double) copysignf(1.0, a) );
-       }
-}
-
-float builtin_d2f(double a)
-{
-       if (finite(a))
-               return (float) a;
-       else {
-               if (isnan(a))
-                       return intBitsToFloat(FLT_NAN);
-               else
-                       return copysignf(intBitsToFloat(FLT_POSINF), (float) copysign(1.0, a));
-       }
-}
-#endif /* !(SUPPORT_FLOAT && SUPPORT_DOUBLE) */
-
-
-/*============================================================================*/
-/* AUTOMATICALLY REPLACED FUNCTIONS                                           */
-/*============================================================================*/
-
-/* builtin_arraycopy ***********************************************************
-
-   Builtin for java.lang.System.arraycopy.
-
-   NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code.
-
-*******************************************************************************/
-
-void builtin_arraycopy(java_handle_t *src, s4 srcStart,
-                                          java_handle_t *dest, s4 destStart, s4 len)
-{
-       arraydescriptor *sdesc;
-       arraydescriptor *ddesc;
-       s4               i;
-
-       if ((src == NULL) || (dest == NULL)) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       sdesc = LLNI_vftbl_direct(src)->arraydesc;
-       ddesc = LLNI_vftbl_direct(dest)->arraydesc;
-
-       if (!sdesc || !ddesc || (sdesc->arraytype != ddesc->arraytype)) {
-               exceptions_throw_arraystoreexception();
-               return;
-       }
-
-       /* we try to throw exception with the same message as SUN does */
-
-       if ((len < 0) || (srcStart < 0) || (destStart < 0) ||
-               (srcStart  + len < 0) || (srcStart  + len > LLNI_array_size(src)) ||
-               (destStart + len < 0) || (destStart + len > LLNI_array_size(dest))) {
-               exceptions_throw_arrayindexoutofboundsexception();
-               return;
-       }
-
-       if (sdesc->componentvftbl == ddesc->componentvftbl) {
-               /* We copy primitive values or references of exactly the same type */
-
-               s4 dataoffset = sdesc->dataoffset;
-               s4 componentsize = sdesc->componentsize;
-
-               LLNI_CRITICAL_START;
-
-               MMOVE(((u1 *) LLNI_DIRECT(dest)) + dataoffset + componentsize * destStart,
-                         ((u1 *) LLNI_DIRECT(src))  + dataoffset + componentsize * srcStart,
-                         u1, (size_t) len * componentsize);
-
-               LLNI_CRITICAL_END;
-       }
-       else {
-               /* We copy references of different type */
-
-               java_handle_objectarray_t *oas = (java_handle_objectarray_t *) src;
-               java_handle_objectarray_t *oad = (java_handle_objectarray_t *) dest;
-               if (destStart <= srcStart) {
-                       for (i = 0; i < len; i++) {
-                               java_handle_t *o;
-
-                               o = array_objectarray_element_get(oas, srcStart + i);
-
-                               if (!builtin_canstore(oad, o))
-                                       return;
-
-                               array_objectarray_element_set(oad, destStart + i, o);
-                       }
-               }
-               else {
-                       /* XXX this does not completely obey the specification!
-                          If an exception is thrown only the elements above the
-                          current index have been copied. The specification
-                          requires that only the elements *below* the current
-                          index have been copied before the throw. */
-
-                       for (i = len - 1; i >= 0; i--) {
-                               java_handle_t *o;
-
-                               o = array_objectarray_element_get(oas, srcStart + i);
-
-                               if (!builtin_canstore(oad, o))
-                                       return;
-
-                               array_objectarray_element_set(oad, destStart + i, o);
-                       }
-               }
-       }
-}
-
-
-/* builtin_nanotime ************************************************************
-
-   Return the current time in nanoseconds.
-
-*******************************************************************************/
-
-s8 builtin_nanotime(void)
-{
-       struct timeval tv;
-       s8             usecs;
-
-       if (gettimeofday(&tv, NULL) == -1)
-               vm_abort("gettimeofday failed: %s", strerror(errno));
-
-       usecs = (s8) tv.tv_sec * (1000 * 1000) + (s8) tv.tv_usec;
-
-       return usecs * 1000;
-}
-
-
-/* builtin_currenttimemillis ***************************************************
-
-   Return the current time in milliseconds.
-
-*******************************************************************************/
-
-s8 builtin_currenttimemillis(void)
-{
-       s8 msecs;
-
-       msecs = builtin_nanotime() / 1000 / 1000;
-
-       return msecs;
-}
-
-
-/* builtin_clone ***************************************************************
-
-   Function for cloning objects or arrays.
-
-   NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code.
-
-*******************************************************************************/
-
-java_handle_t *builtin_clone(void *env, java_handle_t *o)
-{
-       arraydescriptor *ad;
-       u4               size;
-       classinfo       *c;
-       java_handle_t   *co;                /* cloned object header               */
-
-       /* get the array descriptor */
-
-       ad = LLNI_vftbl_direct(o)->arraydesc;
-
-       /* we are cloning an array */
-
-       if (ad != NULL) {
-               size = ad->dataoffset + ad->componentsize * LLNI_array_size(o);
-        
-               co = heap_alloc(size, (ad->arraytype == ARRAYTYPE_OBJECT), NULL, true);
-
-               if (co == NULL)
-                       return NULL;
-
-#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES)
-               /* XXX this is only a dirty hack to make Boehm work with handles */
-
-               co = LLNI_WRAP((java_object_t *) co);
-#endif
-
-               LLNI_CRITICAL_START;
-
-               MCOPY(LLNI_DIRECT(co), LLNI_DIRECT(o), u1, size);
-
-#if defined(ENABLE_GC_CACAO)
-               heap_init_objectheader(LLNI_DIRECT(co), size);
-#endif
-
-#if defined(ENABLE_THREADS)
-               lock_init_object_lock(LLNI_DIRECT(co));
-#endif
-
-               LLNI_CRITICAL_END;
-
-               return co;
-       }
-    
-    /* we are cloning a non-array */
-
-    if (!builtin_instanceof(o, class_java_lang_Cloneable)) {
-        exceptions_throw_clonenotsupportedexception();
-        return NULL;
-    }
-
-       /* get the class of the object */
-
-       LLNI_class_get(o, c);
-
-       /* create new object */
-
-    co = builtin_new(c);
-
-    if (co == NULL)
-        return NULL;
-
-       LLNI_CRITICAL_START;
-
-       MCOPY(LLNI_DIRECT(co), LLNI_DIRECT(o), u1, c->instancesize);
-
-#if defined(ENABLE_GC_CACAO)
-       heap_init_objectheader(LLNI_DIRECT(co), c->instancesize);
-#endif
-
-#if defined(ENABLE_THREADS)
-       lock_init_object_lock(LLNI_DIRECT(co));
-#endif
-
-       LLNI_CRITICAL_END;
-
-    return co;
-}
-
-
-#if defined(ENABLE_CYCLES_STATS)
-void builtin_print_cycles_stats(FILE *file)
-{
-       fprintf(file,"builtin cylce count statistics:\n");
-
-       CYCLES_STATS_PRINT_OVERHEAD(builtin_overhead,file);
-       CYCLES_STATS_PRINT(builtin_new         ,file);
-
-       fprintf(file,"\n");
-}
-#endif /* defined(ENABLE_CYCLES_STATS) */
-
-
-#if defined(ENABLE_VMLOG)
-#define NDEBUG
-#include <vmlog_cacao.c>
-#endif
-
-
-/*
- * 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/builtin.h b/src/vm/builtin.h
deleted file mode 100644 (file)
index e310acd..0000000
+++ /dev/null
@@ -1,338 +0,0 @@
-/* src/vm/builtin.h - prototypes of builtin 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.
-
-*/
-
-
-#ifndef _BUILTIN_H
-#define _BUILTIN_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct builtintable_entry builtintable_entry;
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "arch.h"
-#include "md-abi.h"
-
-#include "toolbox/logging.h"
-
-#include "vmcore/utf8.h"
-
-
-/* define infinity for floating point numbers */
-
-#define FLT_NAN     0x7fc00000
-#define FLT_POSINF  0x7f800000
-#define FLT_NEGINF  0xff800000
-
-/* define infinity for double floating point numbers */
-
-#define DBL_NAN     0x7ff8000000000000LL
-#define DBL_POSINF  0x7ff0000000000000LL
-#define DBL_NEGINF  0xfff0000000000000LL
-
-
-/* float versions are not defined in GNU classpath's fdlibm */
-
-#define copysignf    copysign
-#define finitef      finite
-#define fmodf        fmod
-#define isnanf       isnan
-
-
-/* builtin functions table ****************************************************/
-
-struct builtintable_entry {
-       s4           opcode;                /* opcode which is replaced           */
-       u4           flags;                 /* e.g. check for exception           */
-       functionptr  fp;                    /* function pointer of builtin        */
-       u1          *stub;                  /* pointer to builtin stub code       */
-       char        *cclassname;            /* char name of the class             */
-       char        *cname;                 /* char name of the function          */
-       char        *cdescriptor;           /* char name of the descriptor        */
-       utf         *classname;             /* class of the function              */
-       utf         *name;                  /* name of the function               */
-       utf         *descriptor;            /* descriptor of the function         */
-       methoddesc  *md;
-};
-
-
-/* builtin table flag defines *************************************************/
-
-#define BUILTINTABLE_FLAG_STUB         0x0001 /* builtin needs a stub         */
-#define BUILTINTABLE_FLAG_EXCEPTION    0x0002 /* check for excepion on return */
-
-
-/* function prototypes ********************************************************/
-
-bool builtin_init(void);
-
-builtintable_entry *builtintable_get_internal(functionptr fp);
-builtintable_entry *builtintable_get_automatic(s4 opcode);
-
-bool builtintable_replace_function(void *iptr);
-
-
-/**********************************************************************/
-/* BUILTIN FUNCTIONS                                                  */
-/**********************************************************************/
-
-/* NOTE: Builtin functions which are used in the BUILTIN* opcodes must
- * have a BUILTIN_... macro defined as seen below. In code dealing
- * with the BUILTIN* opcodes the functions may only be addressed by
- * these macros, never by their actual name! (This helps to make this
- * code more portable.)
- *
- * C and assembler code which does not deal with the BUILTIN* opcodes,
- * can use the builtin functions normally (like all other functions).
- *
- * IMPORTANT:
- * For each builtin function which is used in a BUILTIN* opcode there
- * must be an entry in the builtin_desc table in jit/jit.c.
- *
- * Below each prototype is either the BUILTIN_ macro definition or a
- * comment specifiying that this function is not used in BUILTIN*
- * opcodes.
- *
- * (The BUILTIN* opcodes are ICMD_BUILTIN1, ICMD_BUILTIN2 and
- * ICMD_BUILTIN3.)
- */
-
-#if USES_NEW_SUBTYPE
-bool fast_subtype_check(struct _vftbl *, struct _vftbl *);
-#endif
-
-bool builtin_instanceof(java_handle_t *obj, classinfo *class);
-/* NOT AN OP */
-bool builtin_checkcast(java_handle_t *obj, classinfo *class);
-/* NOT AN OP */
-bool builtin_arrayinstanceof(java_handle_t *h, classinfo *targetclass);
-/* NOT AN OP */
-bool builtin_fast_arrayinstanceof(java_object_t *o, classinfo *targetclass);
-#define BUILTIN_arrayinstanceof (functionptr) builtin_fast_arrayinstanceof
-bool builtin_fast_arraycheckcast(java_object_t *o, classinfo *targetclass);
-#define BUILTIN_arraycheckcast (functionptr) builtin_fast_arraycheckcast
-
-bool builtin_canstore(java_handle_objectarray_t *oa, java_handle_t *o);
-/* NOT AN OP */
-bool builtin_fast_canstore(java_objectarray_t *oa, java_object_t *o);
-#define BUILTIN_FAST_canstore (functionptr) builtin_fast_canstore
-
-void *builtin_throw_exception(java_object_t *exception);
-/* NOT AN OP */
-java_object_t *builtin_retrieve_exception(void);
-/* NOT AN OP */
-
-java_handle_t *builtin_new(classinfo *c);
-/* NOT AN OP */
-java_handle_t *builtin_java_new(java_handle_t *c);
-#define BUILTIN_new (functionptr) builtin_java_new
-java_object_t *builtin_fast_new(classinfo *c);
-#define BUILTIN_FAST_new (functionptr) builtin_fast_new
-
-java_handle_t *builtin_newarray(int32_t size, classinfo *arrayclass);
-/* NOT AN OP */
-java_handle_t *builtin_java_newarray(int32_t size, java_handle_t *arrayclass);
-#define BUILTIN_newarray (functionptr) builtin_java_newarray
-
-java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass);
-/* NOT AN OP */
-
-java_handle_booleanarray_t *builtin_newarray_boolean(int32_t size);
-#define BUILTIN_newarray_boolean (functionptr) builtin_newarray_boolean
-java_handle_chararray_t *builtin_newarray_char(int32_t size);
-#define BUILTIN_newarray_char (functionptr) builtin_newarray_char
-java_handle_floatarray_t *builtin_newarray_float(int32_t size);
-#define BUILTIN_newarray_float (functionptr) builtin_newarray_float
-java_handle_doublearray_t *builtin_newarray_double(int32_t size);
-#define BUILTIN_newarray_double (functionptr) builtin_newarray_double
-java_handle_bytearray_t *builtin_newarray_byte(int32_t size);
-#define BUILTIN_newarray_byte (functionptr) builtin_newarray_byte
-java_handle_shortarray_t *builtin_newarray_short(int32_t size);
-#define BUILTIN_newarray_short (functionptr) builtin_newarray_short
-java_handle_intarray_t *builtin_newarray_int(int32_t size);
-#define BUILTIN_newarray_int (functionptr) builtin_newarray_int
-java_handle_longarray_t *builtin_newarray_long(int32_t size);
-#define BUILTIN_newarray_long (functionptr) builtin_newarray_long
-
-java_handle_objectarray_t *builtin_multianewarray(int n,
-                                                                                                 java_handle_t *arrayclass,
-                                                                                                 long *dims);
-#define BUILTIN_multianewarray (functionptr) builtin_multianewarray
-
-#if defined(TRACE_ARGS_NUM)
-void builtin_verbosecall_enter(s8 a0, s8 a1,
-# if TRACE_ARGS_NUM >= 4
-                                                          s8 a2, s8 a3,
-# endif
-# if TRACE_ARGS_NUM >= 6
-                                                          s8 a4, s8 a5,
-# endif
-# if TRACE_ARGS_NUM == 8
-                                                          s8 a6, s8 a7,
-# endif
-                                                          methodinfo *m);
-/* NOT AN OP */
-#endif /* defined(TRACE_ARGS_NUM) */
-
-void builtin_verbosecall_exit(s8 l, double d, float f, methodinfo *m);
-/* NOT AN OP */
-
-s4 builtin_idiv(s4 a, s4 b);
-#define BUILTIN_idiv (functionptr) builtin_idiv
-s4 builtin_irem(s4 a, s4 b);
-#define BUILTIN_irem (functionptr) builtin_irem
-
-s8 builtin_ladd(s8 a, s8 b);
-#define BUILTIN_ladd (functionptr) builtin_ladd
-s8 builtin_lsub(s8 a, s8 b);
-#define BUILTIN_lsub (functionptr) builtin_lsub
-s8 builtin_lmul(s8 a, s8 b);
-#define BUILTIN_lmul (functionptr) builtin_lmul
-
-s8 builtin_ldiv(s8 a, s8 b);
-#define BUILTIN_ldiv (functionptr) builtin_ldiv
-s8 builtin_lrem(s8 a, s8 b);
-#define BUILTIN_lrem (functionptr) builtin_lrem
-
-s8 builtin_lshl(s8 a, s4 b);
-#define BUILTIN_lshl (functionptr) builtin_lshl
-s8 builtin_lshr(s8 a, s4 b);
-#define BUILTIN_lshr (functionptr) builtin_lshr
-s8 builtin_lushr(s8 a, s4 b);
-#define BUILTIN_lushr (functionptr) builtin_lushr
-s8 builtin_land(s8 a, s8 b);
-#define BUILTIN_land (functionptr) builtin_land
-s8 builtin_lor(s8 a, s8 b);
-#define BUILTIN_lor (functionptr) builtin_lor
-s8 builtin_lxor(s8 a, s8 b);
-#define BUILTIN_lxor (functionptr) builtin_lxor
-s8 builtin_lneg(s8 a);
-#define BUILTIN_lneg (functionptr) builtin_lneg
-s4 builtin_lcmp(s8 a, s8 b);
-#define BUILTIN_lcmp (functionptr) builtin_lcmp
-
-float builtin_fadd(float a, float b);
-#define BUILTIN_fadd (functionptr) builtin_fadd
-float builtin_fsub(float a, float b);
-#define BUILTIN_fsub (functionptr) builtin_fsub
-float builtin_fmul(float a, float b);
-#define BUILTIN_fmul (functionptr) builtin_fmul
-float builtin_fdiv(float a, float b);
-#define BUILTIN_fdiv (functionptr) builtin_fdiv
-float builtin_fneg(float a);         
-#define BUILTIN_fneg (functionptr) builtin_fneg
-s4 builtin_fcmpl(float a, float b);  
-#define BUILTIN_fcmpl (functionptr) builtin_fcmpl
-s4 builtin_fcmpg(float a, float b);  
-#define BUILTIN_fcmpg (functionptr) builtin_fcmpg
-float builtin_frem(float a, float b);
-#define BUILTIN_frem (functionptr) builtin_frem
-
-double builtin_dadd(double a, double b);
-#define BUILTIN_dadd (functionptr) builtin_dadd
-double builtin_dsub(double a, double b);
-#define BUILTIN_dsub (functionptr) builtin_dsub
-double builtin_dmul(double a, double b);
-#define BUILTIN_dmul (functionptr) builtin_dmul
-double builtin_ddiv(double a, double b);
-#define BUILTIN_ddiv (functionptr) builtin_ddiv
-double builtin_dneg(double a);          
-#define BUILTIN_dneg (functionptr) builtin_dneg
-s4 builtin_dcmpl(double a, double b);   
-#define BUILTIN_dcmpl (functionptr) builtin_dcmpl
-s4 builtin_dcmpg(double a, double b);   
-#define BUILTIN_dcmpg (functionptr) builtin_dcmpg
-double builtin_drem(double a, double b);
-#define BUILTIN_drem (functionptr) builtin_drem
-
-s8       builtin_i2l(s4 i);
-/* NOT AN OP */
-float    builtin_i2f(s4 i);
-#define BUILTIN_i2f (functionptr) builtin_i2f
-double   builtin_i2d(s4 i);
-#define BUILTIN_i2d (functionptr) builtin_i2d
-s4       builtin_l2i(s8 l);
-/* NOT AN OP */
-float    builtin_l2f(s8 l);
-#define BUILTIN_l2f (functionptr) builtin_l2f
-double   builtin_l2d(s8 l);
-#define BUILTIN_l2d (functionptr) builtin_l2d
-
-s4       builtin_f2i(float a);
-#define BUILTIN_f2i (functionptr) builtin_f2i
-s4       asm_builtin_f2i(float a);
-/* NOT AN OP */
-s8       builtin_f2l(float a);
-#define BUILTIN_f2l (functionptr) builtin_f2l
-s8       asm_builtin_f2l(float a);
-/* NOT AN OP */
-
-double   builtin_f2d(float a);
-#define BUILTIN_f2d (functionptr) builtin_f2d
-
-s4       builtin_d2i(double a);
-#define BUILTIN_d2i (functionptr) builtin_d2i
-s4       asm_builtin_d2i(double a);
-/* NOT AN OP */
-s8       builtin_d2l(double a);
-#define BUILTIN_d2l (functionptr) builtin_d2l
-s8       asm_builtin_d2l(double a);
-/* NOT AN OP */
-
-float    builtin_d2f(double a);
-#define BUILTIN_d2f (functionptr) builtin_d2f
-
-java_handle_t *builtin_clone(void *env, java_handle_t *o);
-#define BUILTIN_clone (functionptr) builtin_clone
-
-void builtin_arraycopy(java_handle_t *src, s4 srcStart,
-                                          java_handle_t *dest, s4 destStart, s4 len);
-#define BUILTIN_arraycopy (functionptr) builtin_arraycopy
-
-s8 builtin_nanotime(void);
-s8 builtin_currenttimemillis(void);
-#define BUILTIN_currenttimemillis (functionptr) builtin_currenttimemillis
-
-#if defined(ENABLE_CYCLES_STATS)
-void builtin_print_cycles_stats(FILE *file);
-#endif
-
-#endif /* _BUILTIN_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/builtintable.inc b/src/vm/builtintable.inc
deleted file mode 100644 (file)
index 735c1de..0000000
+++ /dev/null
@@ -1,1076 +0,0 @@
-/* src/vm/builtintable.inc - tables of builtin 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 "arch.h"
-
-#include "threads/lock-common.h"
-
-#include "vm/builtin.h"
-
-#include "vm/jit/jit.h"
-
-
-/* internal and not automatically replaced functions **************************/
-
-static builtintable_entry builtintable_internal[] = {
-
-#if defined(__ALPHA__) || defined(DISABLE_GC)
-       {
-               ICMD_F2L,
-               0,
-               BUILTIN_f2l,
-               NULL,
-               NULL,
-               "f2l",
-               "(F)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_D2L,
-               0,
-               BUILTIN_d2l,
-               NULL,
-               NULL,
-               "d2l",
-               "(D)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_F2I,
-               0,
-               BUILTIN_f2i,
-               NULL,
-               NULL,
-               "f2i",
-               "(F)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_D2I,
-               0,
-               BUILTIN_d2i,
-               NULL,
-               NULL,
-               "d2i",
-               "(D)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-#if !SUPPORT_DIVISION || defined(DISABLE_GC)
-       {
-               ICMD_IDIV,
-               0,
-               BUILTIN_idiv,
-               NULL,
-               NULL,
-               "idiv",
-               "(II)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_IREM,
-               0,
-               BUILTIN_irem,
-               NULL,
-               NULL,
-               "irem",
-               "(II)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) || defined(DISABLE_GC)
-       {
-               ICMD_LDIV,
-               0,
-               BUILTIN_ldiv,
-               NULL,
-               NULL,
-               "ldiv",
-               "(JJ)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_LREM,
-               0,
-               BUILTIN_lrem,
-               NULL,
-               NULL,
-               "lrem",
-               "(JJ)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-       {
-               ICMD_FREM,
-               0,
-               BUILTIN_frem,
-               NULL,
-               NULL,
-               "frem",
-               "(FF)F",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_DREM,
-               0,
-               BUILTIN_drem,
-               NULL,
-               NULL,
-               "drem",
-               "(DD)D",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-
-
-       /* internal functions *****************************************************/
-
-       {
-               ICMD_NEW,
-               BUILTINTABLE_FLAG_STUB,
-               BUILTIN_new,
-               NULL,
-               NULL,
-               "new",
-               "(Ljava/lang/Class;)Ljava/lang/Object;",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_NEW,
-               0,
-               BUILTIN_FAST_new,
-               NULL,
-               NULL,
-               "fast-new",
-               "(Ljava/lang/Class;)Ljava/lang/Object;",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_ANEWARRAY,
-               BUILTINTABLE_FLAG_STUB,
-               BUILTIN_newarray,
-               NULL,
-               NULL,
-               "newarray",
-               "(ILjava/lang/Class;)[Ljava/lang/Object;",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_NEWARRAY,
-               BUILTINTABLE_FLAG_STUB,
-               BUILTIN_newarray_boolean,
-               NULL,
-               NULL,
-               "newarray_boolean",
-               "(I)[Z",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_NEWARRAY,
-               BUILTINTABLE_FLAG_STUB,
-               BUILTIN_newarray_byte,
-               NULL,
-               NULL,
-               "newarray_byte",
-               "(I)[B",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_NEWARRAY,
-               BUILTINTABLE_FLAG_STUB,
-               BUILTIN_newarray_char,
-               NULL,
-               NULL,
-               "newarray_char",
-               "(I)[C",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_NEWARRAY,
-               BUILTINTABLE_FLAG_STUB,
-               BUILTIN_newarray_short,
-               NULL,
-               NULL,
-               "newarray_short",
-               "(I)[S",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_NEWARRAY,
-               BUILTINTABLE_FLAG_STUB,
-               BUILTIN_newarray_int,
-               NULL,
-               NULL,
-               "newarray_int",
-               "(I)[I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_NEWARRAY,
-               BUILTINTABLE_FLAG_STUB,
-               BUILTIN_newarray_long,
-               NULL,
-               NULL,
-               "newarray_long",
-               "(I)[J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_NEWARRAY,
-               BUILTINTABLE_FLAG_STUB,
-               BUILTIN_newarray_float,
-               NULL,
-               NULL,
-               "newarray_float",
-               "(I)[F",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_NEWARRAY,
-               BUILTINTABLE_FLAG_STUB,
-               BUILTIN_newarray_double,
-               NULL,
-               NULL,
-               "newarray_double",
-               "(I)[D",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_MULTIANEWARRAY,
-               BUILTINTABLE_FLAG_STUB,
-               BUILTIN_multianewarray,
-               NULL,
-               NULL,
-               "multianewarray",
-               /* XXX it should be: "(ILjava/lang/Class;[I)[Ljava/lang/Object;", */
-               "(ILjava/lang/Class;I)[Ljava/lang/Object;",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_CHECKCAST,
-               0,
-               BUILTIN_arraycheckcast,
-               NULL,
-               NULL,
-               "arraycheckcast",
-               "([Ljava/lang/Object;[Ljava/lang/Object;)[Ljava/lang/Object;",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_INSTANCEOF,
-               0,
-               BUILTIN_arrayinstanceof,
-               NULL,
-               NULL,
-               "arrayinstanceof",
-               "([Ljava/lang/Object;[Ljava/lang/Object;)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_AASTORE,
-               0,
-               BUILTIN_FAST_canstore,
-               NULL,
-               NULL,
-               "fast-canstore",
-               "([Ljava/lang/Object;Ljava/lang/Object;)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-
-#if defined(ENABLE_THREADS)
-       {
-               ICMD_MONITORENTER,
-               BUILTINTABLE_FLAG_STUB,
-               LOCK_monitor_enter,
-               NULL,
-               NULL,
-               "monitorenter",
-               "(Ljava/lang/Object;)V",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_MONITOREXIT,
-               BUILTINTABLE_FLAG_STUB,
-               LOCK_monitor_exit,
-               NULL,
-               NULL,
-               "monitorexit",
-               "(Ljava/lang/Object;)V",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-
-       /* stop entry */
-
-       {
-               255,
-               0,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-};
-
-
-/* automatically replaced functions *******************************************/
-
-static builtintable_entry builtintable_automatic[] = {
-
-#if !(SUPPORT_LONG && SUPPORT_LONG_CMP)
-       {
-               ICMD_LCMP,
-               0,
-               BUILTIN_lcmp,
-               NULL,
-               NULL,
-               "lcmp",
-               "(JJ)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-#if !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL)
-       {
-               ICMD_LAND,
-               0,
-               BUILTIN_land,
-               NULL,
-               NULL,
-               "land",
-               "(JJ)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_LOR,
-               0,
-               BUILTIN_lor,
-               NULL,
-               NULL,
-               "lor",
-               "(JJ)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_LXOR,
-               0,
-               BUILTIN_lxor,
-               NULL,
-               NULL,
-               "lxor",
-               "(JJ)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif /* !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) */
-
-#if !(SUPPORT_LONG && SUPPORT_LONG_SHIFT)
-       {
-               ICMD_LSHL,
-               0,
-               BUILTIN_lshl,
-               NULL,
-               NULL,
-               "lshl",
-               "(JI)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_LSHR,
-               0,
-               BUILTIN_lshr,
-               NULL,
-               NULL,
-               "lshr",
-               "(JI)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_LUSHR,
-               0,
-               BUILTIN_lushr,
-               NULL,
-               NULL,
-               "lushr",
-               "(JI)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif /* !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) */
-
-#if !(SUPPORT_LONG && SUPPORT_LONG_ADD)
-       {
-               ICMD_LADD,
-               0,
-               BUILTIN_ladd,
-               NULL,
-               NULL,
-               "ladd",
-               "(JJ)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_LSUB,
-               0,
-               BUILTIN_lsub,
-               NULL,
-               NULL,
-               "lsub",
-               "(JJ)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_LNEG,
-               0,
-               BUILTIN_lneg,
-               NULL,
-               NULL,
-               "lneg",
-               "(J)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif /* !(SUPPORT_LONG && SUPPORT_LONG_ADD) */
-
-#if !(SUPPORT_LONG && SUPPORT_LONG_MUL)
-       {
-               ICMD_LMUL,
-               0,
-               BUILTIN_lmul,
-               NULL,
-               NULL,
-               "lmul",
-               "(JJ)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-#if !(SUPPORT_FLOAT && SUPPORT_I2F)
-       {
-               ICMD_I2F,
-               0,
-               BUILTIN_i2f,
-               NULL,
-               NULL,
-               "i2f",
-               "(I)F",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-#if !(SUPPORT_DOUBLE && SUPPORT_I2D)
-       {
-               ICMD_I2D,
-               0,
-               BUILTIN_i2d,
-               NULL,
-               NULL,
-               "i2d",
-               "(I)D",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-#if !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F)
-       {
-               ICMD_L2F,
-               0,
-               BUILTIN_l2f,
-               NULL,
-               NULL,
-               "l2f",
-               "(J)F",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-#if !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D)
-       {
-               ICMD_L2D,
-               0,
-               BUILTIN_l2d,
-               NULL,
-               NULL,
-               "l2d",
-               "(J)D",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-#if !(SUPPORT_FLOAT && SUPPORT_F2I)
-       {
-               ICMD_F2I,
-               0,
-               BUILTIN_f2i,
-               NULL,
-               NULL,
-               "f2i",
-               "(F)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-#if !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L)
-       {
-               ICMD_F2L,
-               0,
-               BUILTIN_f2l,
-               NULL,
-               NULL,
-               "f2l",
-               "(F)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-#if !(SUPPORT_DOUBLE && SUPPORT_D2I)
-       {
-               ICMD_D2I,
-               0,
-               BUILTIN_d2i,
-               NULL,
-               NULL,
-               "d2i",
-               "(D)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-#if !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L)
-       {
-               ICMD_D2L,
-               0,
-               BUILTIN_d2l,
-               NULL,
-               NULL,
-               "d2l",
-               "(D)J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-
-       /* float functions ********************************************************/
-
-#if !SUPPORT_FLOAT
-       {
-               ICMD_FADD,
-               0,
-               BUILTIN_fadd,
-               NULL,
-               NULL,
-               "fadd",
-               "(FF)F",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_FSUB,
-               0,
-               BUILTIN_fsub,
-               NULL,
-               NULL,
-               "fsub",
-               "(FF)F",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_FMUL,
-               0,
-               BUILTIN_fmul,
-               NULL,
-               NULL,
-               "fmul",
-               "(FF)F",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_FDIV,
-               0,
-               BUILTIN_fdiv,
-               NULL,
-               NULL,
-               "fdiv",
-               "(FF)F",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_FNEG,
-               0,
-               BUILTIN_fneg,
-               NULL,
-               NULL,
-               "fneg",
-               "(F)F",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif /* !SUPPORT_FLOAT */
-
-#if !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP
-       {
-               ICMD_FCMPL,
-               0,
-               BUILTIN_fcmpl,
-               NULL,
-               NULL,
-               "fcmpl",
-               "(FF)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_FCMPG,
-               0,
-               BUILTIN_fcmpg,
-               NULL,
-               NULL,
-               "fcmpg",
-               "(FF)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif /* !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP */
-
-
-       /* double functions *******************************************************/
-
-#if !SUPPORT_DOUBLE
-       {
-               ICMD_DADD,
-               0,
-               BUILTIN_dadd,
-               NULL,
-               NULL,
-               "dadd",
-               "(DD)D",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_DSUB,
-               0,
-               BUILTIN_dsub,
-               NULL,
-               NULL,
-               "dsub",
-               "(DD)D",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_DMUL,
-               0,
-               BUILTIN_dmul,
-               NULL,
-               NULL,
-               "dmul",
-               "(DD)D",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_DDIV,
-               0,
-               BUILTIN_ddiv,
-               NULL,
-               NULL,
-               "ddiv",
-               "(DD)D",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_DNEG,
-               0,
-               BUILTIN_dneg,
-               NULL,
-               NULL,
-               "dneg",
-               "(D)D",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif /* !SUPPORT_DOUBLE */
-
-#if !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP
-       {
-               ICMD_DCMPL,
-               0,
-               BUILTIN_dcmpl,
-               NULL,
-               NULL,
-               "dcmpl",
-               "(DD)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_DCMPG,
-               0,
-               BUILTIN_dcmpg,
-               NULL,
-               NULL,
-               "dcmpg",
-               "(DD)I",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif /* !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP */
-
-
-       /* float/double functions *************************************************/
-
-#if !(SUPPORT_FLOAT && SUPPORT_DOUBLE)
-       {
-               ICMD_F2D,
-               0,
-               BUILTIN_f2d,
-               NULL,
-               NULL,
-               "f2d",
-               "(F)D",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-       {
-               ICMD_D2F,
-               0,
-               BUILTIN_d2f,
-               NULL,
-               NULL,
-               "d2f",
-               "(D)F",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif /* !(SUPPORT_FLOAT && SUPPORT_DOUBLE) */
-
-
-       /* prevent a compiler warning if everything is supported (e.g. i386) */
-
-       {
-               255,
-               0,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-};
-
-
-/* automatically replaced functions *******************************************/
-
-static builtintable_entry builtintable_function[] = {
-#if defined(ENABLE_JIT)
-
-       /* java.lang.VMSystem.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V STATIC NATIVE */
-
-       {
-               ICMD_BUILTIN,
-               BUILTINTABLE_FLAG_STUB | BUILTINTABLE_FLAG_EXCEPTION,
-               BUILTIN_arraycopy,
-               NULL,
-               "java/lang/VMSystem",
-               "arraycopy",
-               "(Ljava/lang/Object;ILjava/lang/Object;II)V",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-
-       /* java.lang.System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V PUBLIC STATIC */
-
-#if 0
-       /* We disable this one until we have a fix for the stacktrace
-          issue. */
-
-       {
-               ICMD_BUILTIN,
-               BUILTINTABLE_FLAG_STUB | BUILTINTABLE_FLAG_EXCEPTION,
-               BUILTIN_arraycopy,
-               NULL,
-               "java/lang/System",
-               "arraycopy",
-               "(Ljava/lang/Object;ILjava/lang/Object;II)V",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-#endif
-
-       /* java.lang.VMSystem.currentTimeMillis()J PUBLIC STATIC */
-
-       {
-               ICMD_BUILTIN,
-               0,
-               BUILTIN_currenttimemillis,
-               NULL,
-               "java/lang/VMSystem",
-               "currentTimeMillis",
-               "()J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-
-       /* java.lang.System.currentTimeMillis()J PUBLIC STATIC */
-
-       {
-               ICMD_BUILTIN,
-               0,
-               BUILTIN_currenttimemillis,
-               NULL,
-               "java/lang/System",
-               "currentTimeMillis",
-               "()J",
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-
-#endif /* defined(ENABLE_JIT) */
-
-       /* stop entry */
-
-       {
-               255,
-               0,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-};
-
-
-/*
- * 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/class.cpp b/src/vm/class.cpp
new file mode 100644 (file)
index 0000000..0aa5f21
--- /dev/null
@@ -0,0 +1,2459 @@
+/* src/vm/class.cpp - class 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "arch.h"
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "threads/lock.hpp"
+#include "threads/mutex.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/array.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/classcache.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/linker.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/resolve.hpp"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#include "vm/suck.hpp"
+#include "vm/utf8.h"
+
+#include "vm/jit/asmpart.h"
+
+
+/* class_set_packagename *******************************************************
+
+   Derive the package name from the class name and store it in the
+   struct.
+
+   An internal package name consists of the package name plus the
+   trailing '/', e.g. "java/lang/".
+
+   For classes in the unnamed package, the package name is set to
+   NULL.
+
+*******************************************************************************/
+
+void class_set_packagename(classinfo *c)
+{
+       char *p;
+       char *start;
+
+       p     = UTF_END(c->name) - 1;
+       start = c->name->text;
+
+       if (c->name->text[0] == '[') {
+               /* Set packagename of arrays to the element's package. */
+
+               for (; *start == '['; start++);
+
+               /* Skip the 'L' in arrays of references. */
+
+               if (*start == 'L')
+                       start++;
+       }
+
+       /* Search for last '/'. */
+
+       for (; (p > start) && (*p != '/'); --p);
+
+       /* If we found a '/' we set the package name plus the trailing
+          '/'.  Otherwise we set the packagename to NULL. */
+
+       if (p > start)
+               c->packagename = utf_new(start, p - start + 1);
+       else
+               c->packagename = NULL;
+}
+
+
+/* class_create_classinfo ******************************************************
+
+   Create a new classinfo struct. The class name is set to the given utf *,
+   most other fields are initialized to zero.
+
+   Note: classname may be NULL. In this case a not-yet-named classinfo is
+         created. The name must be filled in later and class_set_packagename
+                must be called after that.
+
+*******************************************************************************/
+
+classinfo *class_create_classinfo(utf *classname)
+{
+       classinfo *c;
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_classinfo += sizeof(classinfo);
+#endif
+
+       /* we use a safe name for temporarily unnamed classes */
+
+       if (classname == NULL)
+               classname = utf_not_named_yet;
+
+#if !defined(NDEBUG)
+       if (initverbose)
+               log_message_utf("Creating class: ", classname);
+#endif
+
+#if !defined(ENABLE_GC_BOEHM)
+       c = (classinfo *) heap_alloc_uncollectable(sizeof(classinfo));
+       /*c = NEW(classinfo);
+       MZERO(c, classinfo, 1);*/
+#else
+       c = GCNEW_UNCOLLECTABLE(classinfo, 1);
+       /* GCNEW_UNCOLLECTABLE clears the allocated memory */
+#endif
+
+       c->name = classname;
+
+       /* Set the header.vftbl of all loaded classes to the one of
+       java.lang.Class, so Java code can use a class as object. */
+
+       if (class_java_lang_Class != NULL)
+               if (class_java_lang_Class->vftbl != NULL)
+                       c->object.header.vftbl = class_java_lang_Class->vftbl;
+
+#if defined(ENABLE_JAVASE)
+       /* check if the class is a reference class and flag it */
+
+       if (classname == utf_java_lang_ref_SoftReference) {
+               c->flags |= ACC_CLASS_REFERENCE_SOFT;
+       }
+       else if (classname == utf_java_lang_ref_WeakReference) {
+               c->flags |= ACC_CLASS_REFERENCE_WEAK;
+       }
+       else if (classname == utf_java_lang_ref_PhantomReference) {
+               c->flags |= ACC_CLASS_REFERENCE_PHANTOM;
+       }
+#endif
+
+       if (classname != utf_not_named_yet)
+               class_set_packagename(c);
+
+       c->object.header.lockword.init();
+
+       return c;
+}
+
+
+/* class_postset_header_vftbl **************************************************
+
+   Set the header.vftbl of all classes created before java.lang.Class
+   was linked.  This is necessary that Java code can use a class as
+   object.
+
+*******************************************************************************/
+
+void class_postset_header_vftbl(void)
+{
+       classinfo *c;
+       u4 slot;
+       classcache_name_entry *nmen;
+       classcache_class_entry *clsen;
+
+       assert(class_java_lang_Class);
+
+       for (slot = 0; slot < hashtable_classcache.size; slot++) {
+               nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
+
+               for (; nmen; nmen = nmen->hashlink) {
+                       /* iterate over all class entries */
+
+                       for (clsen = nmen->classes; clsen; clsen = clsen->next) {
+                               c = clsen->classobj;
+
+                               /* now set the the vftbl */
+
+                               if (c->object.header.vftbl == NULL)
+                                       c->object.header.vftbl = class_java_lang_Class->vftbl;
+                       }
+               }
+       }
+}
+
+/* class_define ****************************************************************
+
+   Calls the loader and defines a class in the VM.
+
+*******************************************************************************/
+
+classinfo *class_define(utf *name, classloader_t *cl, int32_t length, uint8_t *data, java_handle_t *pd)
+{
+       classinfo   *c;
+       classinfo   *r;
+       classbuffer *cb;
+
+       if (name != NULL) {
+               /* check if this class has already been defined */
+
+               c = classcache_lookup_defined_or_initiated(cl, name);
+
+               if (c != NULL) {
+                       exceptions_throw_linkageerror("duplicate class definition: ", c);
+                       return NULL;
+               }
+       } 
+
+       /* create a new classinfo struct */
+
+       c = class_create_classinfo(name);
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getloadingtime)
+               loadingtime_start();
+#endif
+
+       /* build a classbuffer with the given data */
+
+       cb = NEW(classbuffer);
+
+       cb->clazz = c;
+       cb->size  = length;
+       cb->data  = data;
+       cb->pos   = cb->data;
+
+       /* preset the defining classloader */
+
+       c->classloader = cl;
+
+       /* load the class from this buffer */
+
+       r = load_class_from_classbuffer(cb);
+
+       /* free memory */
+
+       FREE(cb, classbuffer);
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getloadingtime)
+               loadingtime_stop();
+#endif
+
+       if (r == NULL) {
+               /* If return value is NULL, we had a problem and the class is
+                  not loaded.  Now free the allocated memory, otherwise we
+                  could run into a DOS. */
+
+               class_free(c);
+
+               return NULL;
+       }
+
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       /* Store the protection domain. */
+
+       c->protectiondomain = pd;
+# endif
+#endif
+
+       /* Store the newly defined class in the class cache. This call
+          also checks whether a class of the same name has already been
+          defined by the same defining loader, and if so, replaces the
+          newly created class by the one defined earlier. */
+
+       /* Important: The classinfo given to classcache_store must be
+                     fully prepared because another thread may return
+                     this pointer after the lookup at to top of this
+                     function directly after the class cache lock has
+                     been released. */
+
+       c = classcache_store(cl, c, true);
+
+       return c;
+}
+
+
+/* class_load_attribute_sourcefile *********************************************
+
+   SourceFile_attribute {
+       u2 attribute_name_index;
+       u4 attribute_length;
+          u2 sourcefile_index;
+   }
+
+*******************************************************************************/
+
+static bool class_load_attribute_sourcefile(classbuffer *cb)
+{
+       classinfo *c;
+       u4         attribute_length;
+       u2         sourcefile_index;
+       utf       *sourcefile;
+
+       /* get classinfo */
+
+       c = cb->clazz;
+
+       /* check buffer size */
+
+       if (!suck_check_classbuffer_size(cb, 4 + 2))
+               return false;
+
+       /* check attribute length */
+
+       attribute_length = suck_u4(cb);
+
+       if (attribute_length != 2) {
+               exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute");
+               return false;
+       }
+
+       /* there can be no more than one SourceFile attribute */
+
+       if (c->sourcefile != NULL) {
+               exceptions_throw_classformaterror(c, "Multiple SourceFile attributes");
+               return false;
+       }
+
+       /* get sourcefile */
+
+       sourcefile_index = suck_u2(cb);
+       sourcefile = (utf*) class_getconstant(c, sourcefile_index, CONSTANT_Utf8);
+
+       if (sourcefile == NULL)
+               return false;
+
+       /* store sourcefile */
+
+       c->sourcefile = sourcefile;
+
+       return true;
+}
+
+
+/* class_load_attribute_enclosingmethod ****************************************
+
+   EnclosingMethod_attribute {
+       u2 attribute_name_index;
+       u4 attribute_length;
+          u2 class_index;
+          u2 method_index;
+   }
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+static bool class_load_attribute_enclosingmethod(classbuffer *cb)
+{
+       classinfo             *c;
+       u4                     attribute_length;
+       u2                     class_index;
+       u2                     method_index;
+       classref_or_classinfo  cr;
+       constant_nameandtype  *cn;
+
+       /* get classinfo */
+
+       c = cb->clazz;
+
+       /* check buffer size */
+
+       if (!suck_check_classbuffer_size(cb, 4 + 2 + 2))
+               return false;
+
+       /* check attribute length */
+
+       attribute_length = suck_u4(cb);
+
+       if (attribute_length != 4) {
+               exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute");
+               return false;
+       }
+
+       /* there can be no more than one EnclosingMethod attribute */
+
+       if (c->enclosingmethod != NULL) {
+               exceptions_throw_classformaterror(c, "Multiple EnclosingMethod attributes");
+               return false;
+       }
+
+       /* get class index */
+
+       class_index = suck_u2(cb);
+       cr.ref = (constant_classref*) innerclass_getconstant(c, class_index, CONSTANT_Class);
+
+       /* get method index */
+
+       method_index = suck_u2(cb);
+       cn = (constant_nameandtype*) innerclass_getconstant(c, method_index, CONSTANT_NameAndType);
+
+       /* store info in classinfo */
+
+       c->enclosingclass.any = cr.any;
+       c->enclosingmethod    = cn;
+
+       return true;
+}
+#endif /* defined(ENABLE_JAVASE) */
+
+
+/* class_load_attributes *******************************************************
+
+   Read attributes from ClassFile.
+
+   attribute_info {
+       u2 attribute_name_index;
+       u4 attribute_length;
+       u1 info[attribute_length];
+   }
+
+   InnerClasses_attribute {
+       u2 attribute_name_index;
+       u4 attribute_length;
+   }
+
+*******************************************************************************/
+
+bool class_load_attributes(classbuffer *cb)
+{
+       classinfo             *c;
+       uint16_t               attributes_count;
+       uint16_t               attribute_name_index;
+       utf                   *attribute_name;
+       innerclassinfo        *info;
+       classref_or_classinfo  inner;
+       classref_or_classinfo  outer;
+       utf                   *name;
+       uint16_t               flags;
+       int                    i, j;
+
+       c = cb->clazz;
+
+       /* get attributes count */
+
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       attributes_count = suck_u2(cb);
+
+       for (i = 0; i < attributes_count; i++) {
+               /* get attribute name */
+
+               if (!suck_check_classbuffer_size(cb, 2))
+                       return false;
+
+               attribute_name_index = suck_u2(cb);
+               attribute_name =
+                       (utf*) class_getconstant(c, attribute_name_index, CONSTANT_Utf8);
+
+               if (attribute_name == NULL)
+                       return false;
+
+               if (attribute_name == utf_InnerClasses) {
+                       /* InnerClasses */
+
+                       if (c->innerclass != NULL) {
+                               exceptions_throw_classformaterror(c, "Multiple InnerClasses attributes");
+                               return false;
+                       }
+                               
+                       if (!suck_check_classbuffer_size(cb, 4 + 2))
+                               return false;
+
+                       /* skip attribute length */
+                       suck_u4(cb);
+
+                       /* number of records */
+                       c->innerclasscount = suck_u2(cb);
+
+                       if (!suck_check_classbuffer_size(cb, (2 + 2 + 2 + 2) * c->innerclasscount))
+                               return false;
+
+                       /* allocate memory for innerclass structure */
+                       c->innerclass = MNEW(innerclassinfo, c->innerclasscount);
+
+                       for (j = 0; j < c->innerclasscount; j++) {
+                               /* The innerclass structure contains a class with an encoded
+                                  name, its defining scope, its simple name and a bitmask of
+                                  the access flags. */
+                                                               
+                               info = c->innerclass + j;
+
+                               inner.ref = (constant_classref*) innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class);
+                               outer.ref = (constant_classref*) innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class);
+                               name      = (utf*) innerclass_getconstant(c, suck_u2(cb), CONSTANT_Utf8);
+                               flags     = suck_u2(cb);
+
+                               /* If the current inner-class is the currently loaded
+                                  class check for some special flags. */
+
+                               if (inner.ref->name == c->name) {
+                                       /* If an inner-class is not a member, its
+                                          outer-class is NULL. */
+
+                                       if (outer.ref != NULL) {
+                                               c->flags |= ACC_CLASS_MEMBER;
+
+                                               /* A member class doesn't have an
+                                                  EnclosingMethod attribute, so set the
+                                                  enclosing-class to be the same as the
+                                                  declaring-class. */
+
+                                               c->declaringclass = outer;
+                                               c->enclosingclass = outer;
+                                       }
+
+                                       /* If an inner-class is anonymous, its name is
+                                          NULL. */
+
+                                       if (name == NULL)
+                                               c->flags |= ACC_CLASS_ANONYMOUS;
+                               }
+
+                               info->inner_class = inner;
+                               info->outer_class = outer;
+                               info->name        = name;
+                               info->flags       = flags;
+                       }
+               }
+               else if (attribute_name == utf_SourceFile) {
+                       /* SourceFile */
+
+                       if (!class_load_attribute_sourcefile(cb))
+                               return false;
+               }
+#if defined(ENABLE_JAVASE)
+               else if (attribute_name == utf_EnclosingMethod) {
+                       /* EnclosingMethod */
+
+                       if (!class_load_attribute_enclosingmethod(cb))
+                               return false;
+               }
+               else if (attribute_name == utf_Signature) {
+                       /* Signature */
+
+                       if (!loader_load_attribute_signature(cb, &(c->signature)))
+                               return false;
+               }
+#endif
+
+#if defined(ENABLE_ANNOTATIONS)
+               else if (attribute_name == utf_RuntimeVisibleAnnotations) {
+                       /* RuntimeVisibleAnnotations */
+                       if (!annotation_load_class_attribute_runtimevisibleannotations(cb))
+                               return false;
+               }
+               else if (attribute_name == utf_RuntimeInvisibleAnnotations) {
+                       /* RuntimeInvisibleAnnotations */
+                       if (!annotation_load_class_attribute_runtimeinvisibleannotations(cb))
+                               return false;
+               }
+#endif
+
+               else {
+                       /* unknown attribute */
+
+                       if (!loader_skip_attribute_body(cb))
+                               return false;
+               }
+       }
+
+       return true;
+}
+
+
+/* class_freepool **************************************************************
+
+       Frees all resources used by this classes Constant Pool.
+
+*******************************************************************************/
+
+static void class_freecpool(classinfo *c)
+{
+       u4 idx;
+       u4 tag;
+       void* info;
+       
+       if (c->cptags && c->cpinfos) {
+               for (idx = 0; idx < c->cpcount; idx++) {
+                       tag = c->cptags[idx];
+                       info = c->cpinfos[idx];
+               
+                       if (info != NULL) {
+                               switch (tag) {
+                               case CONSTANT_Fieldref:
+                               case CONSTANT_Methodref:
+                               case CONSTANT_InterfaceMethodref:
+                                       FREE(info, constant_FMIref);
+                                       break;
+                               case CONSTANT_Integer:
+                                       FREE(info, constant_integer);
+                                       break;
+                               case CONSTANT_Float:
+                                       FREE(info, constant_float);
+                                       break;
+                               case CONSTANT_Long:
+                                       FREE(info, constant_long);
+                                       break;
+                               case CONSTANT_Double:
+                                       FREE(info, constant_double);
+                                       break;
+                               case CONSTANT_NameAndType:
+                                       FREE(info, constant_nameandtype);
+                                       break;
+                               }
+                       }
+               }
+       }
+
+       if (c->cptags)
+               MFREE(c->cptags, u1, c->cpcount);
+
+       if (c->cpinfos)
+               MFREE(c->cpinfos, void*, c->cpcount);
+}
+
+
+/* class_getconstant ***********************************************************
+
+   Retrieves the value at position 'pos' of the constantpool of a
+   class. If the type of the value is other than 'ctype', an error is
+   thrown.
+
+*******************************************************************************/
+
+void* class_getconstant(classinfo *c, u4 pos, u4 ctype)
+{
+       /* check index and type of constantpool entry */
+       /* (pos == 0 is caught by type comparison) */
+
+       if ((pos >= c->cpcount) || (c->cptags[pos] != ctype)) {
+               exceptions_throw_classformaterror(c, "Illegal constant pool index");
+               return NULL;
+       }
+
+       return c->cpinfos[pos];
+}
+
+
+/* innerclass_getconstant ******************************************************
+
+   Like class_getconstant, but if cptags is ZERO, null is returned.
+       
+*******************************************************************************/
+
+void* innerclass_getconstant(classinfo *c, u4 pos, u4 ctype)
+{
+       /* invalid position in constantpool */
+
+       if (pos >= c->cpcount) {
+               exceptions_throw_classformaterror(c, "Illegal constant pool index");
+               return NULL;
+       }
+
+       /* constantpool entry of type 0 */      
+
+       if (c->cptags[pos] == 0)
+               return NULL;
+
+       /* check type of constantpool entry */
+
+       if (c->cptags[pos] != ctype) {
+               exceptions_throw_classformaterror(c, "Illegal constant pool index");
+               return NULL;
+       }
+               
+       return c->cpinfos[pos];
+}
+
+
+/* class_free ******************************************************************
+
+   Frees all resources used by the class.
+
+*******************************************************************************/
+
+void class_free(classinfo *c)
+{
+       s4 i;
+       vftbl_t *v;
+
+       class_freecpool(c);
+
+       if (c->interfaces != NULL)
+               MFREE(c->interfaces, classinfo*, c->interfacescount);
+
+       if (c->fields) {
+               for (i = 0; i < c->fieldscount; i++)
+                       field_free(&(c->fields[i]));
+               MFREE(c->fields, fieldinfo, c->fieldscount);
+       }
+       
+       if (c->methods) {
+               for (i = 0; i < c->methodscount; i++)
+                       method_free(&(c->methods[i]));
+               MFREE(c->methods, methodinfo, c->methodscount);
+       }
+
+       if ((v = c->vftbl) != NULL) {
+               if (v->arraydesc)
+                       mem_free(v->arraydesc,sizeof(arraydescriptor));
+               
+               for (i = 0; i < v->interfacetablelength; i++) {
+                       MFREE(v->interfacetable[-i], methodptr, v->interfacevftbllength[i]);
+               }
+               MFREE(v->interfacevftbllength, s4, v->interfacetablelength);
+
+               i = sizeof(vftbl_t) + sizeof(methodptr) * (v->vftbllength - 1) +
+                   sizeof(methodptr*) * (v->interfacetablelength -
+                                        (v->interfacetablelength > 0));
+               v = (vftbl_t*) (((methodptr*) v) -
+                                               (v->interfacetablelength - 1) * (v->interfacetablelength > 1));
+               mem_free(v, i);
+       }
+
+       if (c->innerclass)
+               MFREE(c->innerclass, innerclassinfo, c->innerclasscount);
+
+       /*      if (c->classvftbl)
+               mem_free(c->header.vftbl, sizeof(vftbl) + sizeof(methodptr)*(c->vftbl->vftbllength-1)); */
+       
+/*     GCFREE(c); */
+}
+
+
+/* get_array_class *************************************************************
+
+   Returns the array class with the given name for the given
+   classloader, or NULL if an exception occurred.
+
+   Note: This function does eager loading. 
+
+*******************************************************************************/
+
+static classinfo *get_array_class(utf *name,classloader_t *initloader,
+                                                                                       classloader_t *defloader,bool link)
+{
+       classinfo *c;
+       
+       /* lookup this class in the classcache */
+       c = classcache_lookup(initloader,name);
+       if (!c)
+               c = classcache_lookup_defined(defloader,name);
+
+       if (!c) {
+               /* we have to create it */
+               c = class_create_classinfo(name);
+               c = load_newly_created_array(c,initloader);
+               if (c == NULL)
+                       return NULL;
+       }
+
+       assert(c);
+       assert(c->state & CLASS_LOADED);
+       assert(c->classloader == defloader);
+
+       if (link && !(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return NULL;
+
+       assert(!link || (c->state & CLASS_LINKED));
+
+       return c;
+}
+
+
+/* class_array_of **************************************************************
+
+   Returns an array class with the given component class. The array
+   class is dynamically created if neccessary.
+
+*******************************************************************************/
+
+classinfo *class_array_of(classinfo *component, bool link)
+{
+       classloader_t     *cl;
+    s4                 namelen;
+    char              *namebuf;
+       utf               *u;
+       classinfo         *c;
+
+       cl = component->classloader;
+
+    /* Assemble the array class name */
+    namelen = component->name->blength;
+    
+    if (component->name->text[0] == '[') {
+        /* the component is itself an array */
+        namebuf = MNEW(char, namelen + 1);
+        namebuf[0] = '[';
+        MCOPY(namebuf + 1, component->name->text, char, namelen);
+        namelen++;
+    }
+       else {
+        /* the component is a non-array class */
+        namebuf = MNEW(char, namelen + 3);
+        namebuf[0] = '[';
+        namebuf[1] = 'L';
+        MCOPY(namebuf + 2, component->name->text, char, namelen);
+        namebuf[2 + namelen] = ';';
+        namelen += 3;
+    }
+
+       u = utf_new(namebuf, namelen);
+
+       MFREE(namebuf, char, namelen);
+
+       c = get_array_class(u, cl, cl, link);
+
+       return c;
+}
+
+
+/* class_multiarray_of *********************************************************
+
+   Returns an array class with the given dimension and element class.
+   The array class is dynamically created if neccessary.
+
+*******************************************************************************/
+
+classinfo *class_multiarray_of(s4 dim, classinfo *element, bool link)
+{
+    s4 namelen;
+    char *namebuf;
+       classinfo *c;
+
+       if (dim < 1) {
+               log_text("Invalid array dimension requested");
+               assert(0);
+       }
+
+    /* Assemble the array class name */
+    namelen = element->name->blength;
+    
+    if (element->name->text[0] == '[') {
+        /* the element is itself an array */
+        namebuf = MNEW(char, namelen + dim);
+        memcpy(namebuf + dim, element->name->text, namelen);
+        namelen += dim;
+    }
+    else {
+        /* the element is a non-array class */
+        namebuf = MNEW(char, namelen + 2 + dim);
+        namebuf[dim] = 'L';
+        memcpy(namebuf + dim + 1, element->name->text, namelen);
+        namelen += (2 + dim);
+        namebuf[namelen - 1] = ';';
+    }
+       memset(namebuf, '[', dim);
+
+       utf* u = utf_new(namebuf, namelen);
+
+       MFREE(namebuf, char, namelen);
+
+       c = get_array_class(u,
+                                               element->classloader,
+                                               element->classloader,
+                                               link);
+
+       return c;
+}
+
+
+/* class_lookup_classref *******************************************************
+
+   Looks up the constant_classref for a given classname in the classref
+   tables of a class.
+
+   IN:
+       cls..............the class containing the reference
+          name.............the name of the class refered to
+
+    RETURN VALUE:
+          a pointer to a constant_classref, or 
+          NULL if the reference was not found
+   
+*******************************************************************************/
+
+constant_classref *class_lookup_classref(classinfo *cls, utf *name)
+{
+       constant_classref *ref;
+       extra_classref *xref;
+       int count;
+
+       assert(cls);
+       assert(name);
+       assert(!cls->classrefcount || cls->classrefs);
+       
+       /* first search the main classref table */
+       count = cls->classrefcount;
+       ref = cls->classrefs;
+       for (; count; --count, ++ref)
+               if (ref->name == name)
+                       return ref;
+
+       /* next try the list of extra classrefs */
+       for (xref = cls->extclassrefs; xref; xref = xref->next) {
+               if (xref->classref.name == name)
+                       return &(xref->classref);
+       }
+
+       /* not found */
+       return NULL;
+}
+
+
+/* class_get_classref **********************************************************
+
+   Returns the constant_classref for a given classname.
+
+   IN:
+       cls..............the class containing the reference
+          name.............the name of the class refered to
+
+   RETURN VALUE:
+       a pointer to a constant_classref (never NULL)
+
+   NOTE:
+       The given name is not checked for validity!
+   
+*******************************************************************************/
+
+constant_classref *class_get_classref(classinfo *cls, utf *name)
+{
+       constant_classref *ref;
+       extra_classref *xref;
+
+       assert(cls);
+       assert(name);
+
+       ref = class_lookup_classref(cls,name);
+       if (ref)
+               return ref;
+
+       xref = NEW(extra_classref);
+       CLASSREF_INIT(xref->classref,cls,name);
+
+       xref->next = cls->extclassrefs;
+       cls->extclassrefs = xref;
+
+       return &(xref->classref);
+}
+
+
+/* class_get_self_classref *****************************************************
+
+   Returns the constant_classref to the class itself.
+
+   IN:
+       cls..............the class containing the reference
+
+   RETURN VALUE:
+       a pointer to a constant_classref (never NULL)
+
+*******************************************************************************/
+
+constant_classref *class_get_self_classref(classinfo *cls)
+{
+       /* XXX this should be done in a faster way. Maybe always make */
+       /* the classref of index 0 a self reference.                  */
+       return class_get_classref(cls,cls->name);
+}
+
+/* class_get_classref_multiarray_of ********************************************
+
+   Returns an array type reference with the given dimension and element class
+   reference.
+
+   IN:
+       dim..............the requested dimension
+                           dim must be in [1;255]. This is NOT checked!
+          ref..............the component class reference
+
+   RETURN VALUE:
+       a pointer to the class reference for the array type
+
+   NOTE:
+       The referer of `ref` is used as the referer for the new classref.
+
+*******************************************************************************/
+
+constant_classref *class_get_classref_multiarray_of(s4 dim, constant_classref *ref)
+{
+    s4 namelen;
+    char *namebuf;
+       constant_classref *cr;
+
+       assert(ref);
+       assert(dim >= 1 && dim <= 255);
+
+    /* Assemble the array class name */
+    namelen = ref->name->blength;
+    
+    if (ref->name->text[0] == '[') {
+        /* the element is itself an array */
+        namebuf = MNEW(char, namelen + dim);
+        memcpy(namebuf + dim, ref->name->text, namelen);
+        namelen += dim;
+    }
+    else {
+        /* the element is a non-array class */
+        namebuf = MNEW(char, namelen + 2 + dim);
+        namebuf[dim] = 'L';
+        memcpy(namebuf + dim + 1, ref->name->text, namelen);
+        namelen += (2 + dim);
+        namebuf[namelen - 1] = ';';
+    }
+       memset(namebuf, '[', dim);
+
+       utf* u = utf_new(namebuf, namelen);
+
+       MFREE(namebuf, char, namelen);
+
+    cr = class_get_classref(ref->referer, u);
+
+       return cr;
+}
+
+
+/* class_get_classref_component_of *********************************************
+
+   Returns the component classref of a given array type reference
+
+   IN:
+       ref..............the array type reference
+
+   RETURN VALUE:
+       a reference to the component class, or
+          NULL if `ref` is not an object array type reference
+
+   NOTE:
+       The referer of `ref` is used as the referer for the new classref.
+
+*******************************************************************************/
+
+constant_classref *class_get_classref_component_of(constant_classref *ref)
+{
+       s4 namelen;
+       char *name;
+       
+       assert(ref);
+
+       name = ref->name->text;
+       if (*name++ != '[')
+               return NULL;
+       
+       namelen = ref->name->blength - 1;
+       if (*name == 'L') {
+               name++;
+               namelen -= 2;
+       }
+       else if (*name != '[') {
+               return NULL;
+       }
+
+    return class_get_classref(ref->referer, utf_new(name, namelen));
+}
+
+
+/* class_findmethod ************************************************************
+       
+   Searches a 'classinfo' structure for a method having the given name
+   and descriptor. If descriptor is NULL, it is ignored.
+
+*******************************************************************************/
+
+methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc)
+{
+       methodinfo *m;
+       s4          i;
+
+       for (i = 0; i < c->methodscount; i++) {
+               m = &(c->methods[i]);
+
+               if ((m->name == name) && ((desc == NULL) || (m->descriptor == desc)))
+                       return m;
+       }
+
+       return NULL;
+}
+
+
+/* class_resolvemethod *********************************************************
+       
+   Searches a class and it's super classes for a method.
+
+   Superinterfaces are *not* searched.
+
+*******************************************************************************/
+
+methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *desc)
+{
+       methodinfo *m;
+
+       while (c) {
+               m = class_findmethod(c, name, desc);
+
+               if (m)
+                       return m;
+
+               /* JVM Specification bug: 
+
+                  It is important NOT to resolve special <init> and <clinit>
+                  methods to super classes or interfaces; yet, this is not
+                  explicited in the specification.  Section 5.4.3.3 should be
+                  updated appropriately.  */
+
+               if (name == utf_init || name == utf_clinit)
+                       return NULL;
+
+               c = c->super;
+       }
+
+       return NULL;
+}
+
+
+/* class_resolveinterfacemethod_intern *****************************************
+
+   Internally used helper function. Do not use this directly.
+
+*******************************************************************************/
+
+static methodinfo *class_resolveinterfacemethod_intern(classinfo *c,
+                                                                                                          utf *name, utf *desc)
+{
+       methodinfo *m;
+       s4          i;
+
+       /* try to find the method in the class */
+
+       m = class_findmethod(c, name, desc);
+
+       if (m != NULL)
+               return m;
+
+       /* No method found?  Try the super interfaces. */
+
+       for (i = 0; i < c->interfacescount; i++) {
+               m = class_resolveinterfacemethod_intern(c->interfaces[i], name, desc);
+
+               if (m != NULL)
+                       return m;
+       }
+
+       /* no method found */
+
+       return NULL;
+}
+
+
+/* class_resolveclassmethod ****************************************************
+       
+   Resolves a reference from REFERER to a method with NAME and DESC in
+   class C.
+
+   If the method cannot be resolved the return value is NULL. If
+   EXCEPT is true *exceptionptr is set, too.
+
+*******************************************************************************/
+
+methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *desc,
+                                                                        classinfo *referer, bool throwexception)
+{
+       classinfo  *cls;
+       methodinfo *m;
+       s4          i;
+
+/*     if (c->flags & ACC_INTERFACE) { */
+/*             if (throwexception) */
+/*                     *exceptionptr = */
+/*                             new_exception(string_java_lang_IncompatibleClassChangeError); */
+/*             return NULL; */
+/*     } */
+
+       /* try class c and its superclasses */
+
+       cls = c;
+
+       m = class_resolvemethod(cls, name, desc);
+
+       if (m != NULL)
+               goto found;
+
+       /* Try the super interfaces. */
+
+       for (i = 0; i < c->interfacescount; i++) {
+               m = class_resolveinterfacemethod_intern(c->interfaces[i], name, desc);
+
+               if (m != NULL)
+                       goto found;
+       }
+       
+       if (throwexception)
+               exceptions_throw_nosuchmethoderror(c, name, desc);
+
+       return NULL;
+
+ found:
+       if ((m->flags & ACC_ABSTRACT) && !(c->flags & ACC_ABSTRACT)) {
+               if (throwexception)
+                       exceptions_throw_abstractmethoderror();
+
+               return NULL;
+       }
+
+       /* XXX check access rights */
+
+       return m;
+}
+
+
+/* class_resolveinterfacemethod ************************************************
+
+   Resolves a reference from REFERER to a method with NAME and DESC in
+   interface C.
+
+   If the method cannot be resolved the return value is NULL. If
+   EXCEPT is true *exceptionptr is set, too.
+
+*******************************************************************************/
+
+methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *desc,
+                                                                                classinfo *referer, bool throwexception)
+{
+       methodinfo *mi;
+
+       if (!(c->flags & ACC_INTERFACE)) {
+               if (throwexception)
+                       exceptions_throw_incompatibleclasschangeerror(c, "Not an interface");
+
+               return NULL;
+       }
+
+       mi = class_resolveinterfacemethod_intern(c, name, desc);
+
+       if (mi != NULL)
+               return mi;
+
+       /* try class java.lang.Object */
+
+       mi = class_findmethod(class_java_lang_Object, name, desc);
+
+       if (mi != NULL)
+               return mi;
+
+       if (throwexception)
+               exceptions_throw_nosuchmethoderror(c, name, desc);
+
+       return NULL;
+}
+
+
+/* class_findfield *************************************************************
+       
+   Searches for field with specified name and type in a classinfo
+   structure. If no such field is found NULL is returned.
+
+*******************************************************************************/
+
+fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc)
+{
+       s4 i;
+
+       for (i = 0; i < c->fieldscount; i++)
+               if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc))
+                       return &(c->fields[i]);
+
+       if (c->super != NULL)
+               return class_findfield(c->super, name, desc);
+
+       return NULL;
+}
+
+
+/* class_findfield_approx ******************************************************
+       
+   Searches in 'classinfo'-structure for a field with the specified
+   name.
+
+*******************************************************************************/
+fieldinfo *class_findfield_by_name(classinfo* c, utf* name)
+{
+       for (int32_t i = 0; i < c->fieldscount; i++) {
+               fieldinfo* f = &(c->fields[i]);
+
+               if (f->name == name)
+                       return f;
+       }
+
+       // Field not found.
+       exceptions_throw_nosuchfielderror(c, name);
+       return NULL;
+}
+
+
+/****************** Function: class_resolvefield_int ***************************
+
+    This is an internally used helper function. Do not use this directly.
+
+       Tries to resolve a field having the given name and type.
+    If the field cannot be resolved, NULL is returned.
+
+*******************************************************************************/
+
+static fieldinfo *class_resolvefield_int(classinfo *c, utf *name, utf *desc)
+{
+       fieldinfo *fi;
+       s4         i;
+
+       /* search for field in class c */
+
+       for (i = 0; i < c->fieldscount; i++) { 
+               if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc)) {
+                       return &(c->fields[i]);
+               }
+    }
+
+       /* Try super interfaces recursively. */
+
+       for (i = 0; i < c->interfacescount; i++) {
+               fi = class_resolvefield_int(c->interfaces[i], name, desc);
+
+               if (fi != NULL)
+                       return fi;
+       }
+
+       /* Try super class. */
+
+       if (c->super != NULL)
+               return class_resolvefield_int(c->super, name, desc);
+
+       /* not found */
+
+       return NULL;
+}
+
+
+/********************* Function: class_resolvefield ***************************
+       
+       Resolves a reference from REFERER to a field with NAME and DESC in class C.
+
+    If the field cannot be resolved, an exception is thrown and the
+    return value is NULL.
+
+*******************************************************************************/
+
+fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc, classinfo *referer)
+{
+       fieldinfo *fi;
+
+       fi = class_resolvefield_int(c, name, desc);
+
+       if (!fi) {
+               exceptions_throw_nosuchfielderror(c, name);
+               return NULL;
+       }
+
+       /* XXX check access rights */
+
+       return fi;
+}
+
+
+/* class_issubclass ************************************************************
+
+   Checks if sub is a descendant of super.
+       
+*******************************************************************************/
+
+bool class_issubclass(classinfo *sub, classinfo *super)
+{
+       classinfo *c;
+
+       c = sub;
+
+       for (;;) {
+               /* We reached java/lang/Object and did not find the requested
+                  super class. */
+
+               if (c == NULL)
+                       return false;
+
+               /* We found the requested super class. */
+
+               if (c == super)
+                       return true;
+
+               c = c->super;
+       }
+}
+
+
+/* class_isanysubclass *********************************************************
+
+   Checks a subclass relation between two classes. Implemented
+   interfaces are interpreted as super classes.
+
+   Return value: 1 ... sub is subclass of super
+                 0 ... otherwise
+
+*******************************************************************************/
+
+bool class_isanysubclass(classinfo *sub, classinfo *super)
+{
+       uint32_t diffval;
+       bool     result;
+
+       /* This is the trivial case. */
+
+       if (sub == super)
+               return true;
+
+       /* Primitive classes are only subclasses of themselves. */
+
+       if (class_is_primitive(sub) || class_is_primitive(super))
+               return false;
+
+       /* Check for interfaces. */
+
+       if (super->flags & ACC_INTERFACE) {
+               result = (sub->vftbl->interfacetablelength > super->index) &&
+                       (sub->vftbl->interfacetable[-super->index] != NULL);
+       }
+       else {
+               /* java.lang.Object is the only super class of any
+                  interface. */
+
+               if (sub->flags & ACC_INTERFACE)
+                       return (super == class_java_lang_Object);
+
+#if USES_NEW_SUBTYPE
+               result = fast_subtype_check(sub->vftbl, super->vftbl);
+#else
+               LOCK_CLASSRENUMBER_LOCK;
+
+               diffval = sub->vftbl->baseval - super->vftbl->baseval;
+               result  = diffval <= (uint32_t) super->vftbl->diffval;
+
+               UNLOCK_CLASSRENUMBER_LOCK;
+#endif
+       }
+
+       return result;
+}
+
+
+/* class_is_assignable_from ****************************************************
+
+   Return whether an instance of the "from" class parameter would be
+   an instance of this class "to" as well.
+
+   ARGUMENTS:
+       to ..... class
+          from ... class
+
+   RETURN:
+       true .... is assignable
+          false ... is not assignable
+
+*******************************************************************************/
+
+bool class_is_assignable_from(classinfo *to, classinfo *from)
+{
+       if (!(to->state & CLASS_LINKED))
+               if (!link_class(to))
+                       return false;
+
+       if (!(from->state & CLASS_LINKED))
+               if (!link_class(from))
+                       return false;
+
+       return class_isanysubclass(from, to);
+}
+
+
+/* class_is_instance ***********************************************************
+
+   Return if the given Java object is an instance of the given class.
+
+   ARGUMENTS:
+       c ... class
+          h ... Java object
+
+   RETURN:
+       true .... is instance
+          false ... is not instance
+
+*******************************************************************************/
+
+bool class_is_instance(classinfo *c, java_handle_t *h)
+{
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return false;
+
+       return builtin_instanceof(h, c);
+}
+
+
+/* class_get_componenttype *****************************************************
+
+   Return the component class of the given class.  If the given class
+   is not an array, return NULL.
+
+*******************************************************************************/
+
+classinfo *class_get_componenttype(classinfo *c)
+{
+       classinfo       *component;
+       arraydescriptor *ad;
+       
+       /* XXX maybe we could find a way to do this without linking. */
+       /* This way should be safe and easy, however.                */
+
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return NULL;
+
+       ad = c->vftbl->arraydesc;
+       
+       if (ad == NULL)
+               return NULL;
+       
+       if (ad->arraytype == ARRAYTYPE_OBJECT)
+               component = ad->componentvftbl->clazz;
+       else
+               component = Primitive::get_class_by_type(ad->arraytype);
+               
+       return component;
+}
+
+
+/* class_get_declaredclasses ***************************************************
+
+   Return an array of declared classes of the given class.
+
+*******************************************************************************/
+
+java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOnly)
+{
+       classref_or_classinfo  inner;
+       classref_or_classinfo  outer;
+       utf                   *outername;
+       int                    declaredclasscount;  /* number of declared classes */
+       int                    pos;                     /* current declared class */
+       java_handle_objectarray_t *oa;               /* array of declared classes */
+       int                    i;
+       classinfo             *ic;
+
+       declaredclasscount = 0;
+
+       if (!class_is_primitive(c) && !class_is_array(c)) {
+               /* Determine number of declared classes. */
+
+               for (i = 0; i < c->innerclasscount; i++) {
+                       /* Get outer-class.  If the inner-class is not a member
+                          class, the outer-class is NULL. */
+
+                       outer = c->innerclass[i].outer_class;
+
+                       if (outer.any == NULL)
+                               continue;
+
+                       /* Check if outer-class is a classref or a real class and
+               get the class name from the structure. */
+
+                       outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name;
+
+                       /* Outer class is this class. */
+
+                       if ((outername == c->name) &&
+                               ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC)))
+                               declaredclasscount++;
+               }
+       }
+
+       /* Allocate Class[] and check for OOM. */
+
+       oa = builtin_anewarray(declaredclasscount, class_java_lang_Class);
+
+       if (oa == NULL)
+               return NULL;
+
+       for (i = 0, pos = 0; i < c->innerclasscount; i++) {
+               inner = c->innerclass[i].inner_class;
+               outer = c->innerclass[i].outer_class;
+
+               /* Get outer-class.  If the inner-class is not a member class,
+                  the outer-class is NULL. */
+
+               if (outer.any == NULL)
+                       continue;
+
+               /* Check if outer_class is a classref or a real class and get
+                  the class name from the structure. */
+
+               outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name;
+
+               /* Outer class is this class. */
+
+               if ((outername == c->name) &&
+                       ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC))) {
+
+                       ic = resolve_classref_or_classinfo_eager(inner, false);
+
+                       if (ic == NULL)
+                               return NULL;
+
+                       if (!(ic->state & CLASS_LINKED))
+                               if (!link_class(ic))
+                                       return NULL;
+
+                       LLNI_array_direct(oa, pos++) = (java_object_t *) ic;
+               }
+       }
+
+       return oa;
+}
+
+
+/**
+ * Return an array of declared constructors of the given class.
+ *
+ * @param c          class to get the constructors of
+ * @param publicOnly show only public fields
+ *
+ * @return array of java.lang.reflect.Constructor
+ */
+#if defined(ENABLE_JAVASE)
+java_handle_objectarray_t *class_get_declaredconstructors(classinfo *c, bool publicOnly)
+{
+       methodinfo*                m;
+       java_handle_objectarray_t* oa;
+       int                        count;
+       int                        index;
+       int                        i;
+
+       /* Determine number of constructors. */
+
+       count = 0;
+
+       for (i = 0; i < c->methodscount; i++) {
+               m = &(c->methods[i]);
+
+               if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) &&
+                       (m->name == utf_init))
+                       count++;
+       }
+
+       /* Create array of constructors. */
+
+       oa = builtin_anewarray(count, class_java_lang_reflect_Constructor);
+
+       if (oa == NULL)
+               return NULL;
+
+       /* Get the constructors and store them in the array. */
+
+       for (i = 0, index = 0; i < c->methodscount; i++) {
+               m = &(c->methods[i]);
+
+               if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) &&
+                       (m->name == utf_init)) {
+                       // Create a java.lang.reflect.Constructor object.
+
+                       java_lang_reflect_Constructor rc(m);
+
+                       /* Store object into array. */
+
+                       array_objectarray_element_set(oa, index, rc.get_handle());
+                       index++;
+               }
+       }
+
+       return oa;
+}
+#endif
+
+
+/* class_get_declaredfields ****************************************************
+
+   Return an array of declared fields of the given class.
+
+   ARGUMENTS:
+       c ............ class to get the fields of
+          publicOnly ... show only public fields
+
+   RETURN:
+       array of java.lang.reflect.Field
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+java_handle_objectarray_t *class_get_declaredfields(classinfo *c, bool publicOnly)
+{
+       java_handle_objectarray_t *oa;
+       fieldinfo                 *f;
+       int                        count;
+       int                        index;
+       int                        i;
+
+       /* Determine number of fields. */
+
+       count = 0;
+
+       for (i = 0; i < c->fieldscount; i++)
+               if ((c->fields[i].flags & ACC_PUBLIC) || (publicOnly == 0))
+                       count++;
+
+       /* Create array of fields. */
+
+       oa = builtin_anewarray(count, class_java_lang_reflect_Field);
+
+       if (oa == NULL)
+               return NULL;
+
+       /* Get the fields and store them in the array. */
+
+       for (i = 0, index = 0; i < c->fieldscount; i++) {
+               f = &(c->fields[i]);
+
+               if ((f->flags & ACC_PUBLIC) || (publicOnly == 0)) {
+                       // Create a java.lang.reflect.Field object.
+
+                       java_lang_reflect_Field rf(f);
+
+                       /* Store object into array. */
+
+                       array_objectarray_element_set(oa, index, rf.get_handle());
+                       index++;
+               }
+       }
+
+       return oa;
+}
+#endif
+
+
+/* class_get_declaredmethods ***************************************************
+
+   Return an array of declared methods of the given class.
+
+   ARGUMENTS:
+       c ............ class to get the methods of
+          publicOnly ... show only public methods
+
+   RETURN:
+       array of java.lang.reflect.Method
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+java_handle_objectarray_t *class_get_declaredmethods(classinfo *c, bool publicOnly)
+{
+       java_handle_objectarray_t *oa;         /* result: array of Method-objects */
+       methodinfo                *m;     /* the current method to be represented */
+       int                        count;
+       int                        index;
+       int                        i;
+
+       /* JOWENN: array classes do not declare methods according to mauve
+          test.  It should be considered, if we should return to my old
+          clone method overriding instead of declaring it as a member
+          function. */
+
+       if (class_is_array(c))
+               return builtin_anewarray(0, class_java_lang_reflect_Method);
+
+       /* Determine number of methods. */
+
+       count = 0;
+
+       for (i = 0; i < c->methodscount; i++) {
+               m = &(c->methods[i]);
+
+               if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) &&
+                       ((m->name != utf_init) && (m->name != utf_clinit)) &&
+                       !(m->flags & ACC_MIRANDA))
+                       count++;
+       }
+
+       /* Create array of methods. */
+
+       oa = builtin_anewarray(count, class_java_lang_reflect_Method);
+
+       if (oa == NULL)
+               return NULL;
+
+       /* Get the methods and store them in the array. */
+
+       for (i = 0, index = 0; i < c->methodscount; i++) {
+               m = &(c->methods[i]);
+
+               if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) && 
+                       ((m->name != utf_init) && (m->name != utf_clinit)) &&
+                       !(m->flags & ACC_MIRANDA)) {
+                       // Create java.lang.reflect.Method object.
+
+                       java_lang_reflect_Method rm(m);
+
+                       /* Store object into array. */
+
+                       array_objectarray_element_set(oa, index, rm.get_handle());
+                       index++;
+               }
+       }
+
+       return oa;
+}
+#endif
+
+
+/* class_get_declaringclass ****************************************************
+
+   If the class or interface given is a member of another class,
+   return the declaring class.  For array and primitive classes return
+   NULL.
+
+*******************************************************************************/
+
+classinfo *class_get_declaringclass(classinfo *c)
+{
+       classref_or_classinfo  cr;
+       classinfo             *dc;
+
+       /* Get declaring class. */
+
+       cr = c->declaringclass;
+
+       if (cr.any == NULL)
+               return NULL;
+
+       /* Resolve the class if necessary. */
+
+       if (IS_CLASSREF(cr)) {
+/*             dc = resolve_classref_eager(cr.ref); */
+               dc = resolve_classref_or_classinfo_eager(cr, true);
+
+               if (dc == NULL)
+                       return NULL;
+
+               /* Store the resolved class in the class structure. */
+
+               cr.cls = dc;
+       }
+
+       dc = cr.cls;
+
+       return dc;
+}
+
+
+/* class_get_enclosingclass ****************************************************
+
+   Return the enclosing class for the given class.
+
+*******************************************************************************/
+
+classinfo *class_get_enclosingclass(classinfo *c)
+{
+       classref_or_classinfo  cr;
+       classinfo             *ec;
+
+       /* Get enclosing class. */
+
+       cr = c->enclosingclass;
+
+       if (cr.any == NULL)
+               return NULL;
+
+       /* Resolve the class if necessary. */
+
+       if (IS_CLASSREF(cr)) {
+/*             ec = resolve_classref_eager(cr.ref); */
+               ec = resolve_classref_or_classinfo_eager(cr, true);
+
+               if (ec == NULL)
+                       return NULL;
+
+               /* Store the resolved class in the class structure. */
+
+               cr.cls = ec;
+       }
+
+       ec = cr.cls;
+
+       return ec;
+}
+
+
+/**
+ * Return the enclosing constructor as java.lang.reflect.Constructor
+ * object for the given class.
+ *
+ * @param c class to return the enclosing constructor for
+ *
+ * @return java.lang.reflect.Constructor object of the enclosing
+ * constructor
+ */
+#if defined(ENABLE_JAVASE)
+java_handle_t* class_get_enclosingconstructor(classinfo *c)
+{
+       methodinfo*    m;
+
+       m = class_get_enclosingmethod_raw(c);
+
+       if (m == NULL)
+               return NULL;
+
+       /* Check for <init>. */
+
+       if (m->name != utf_init)
+               return NULL;
+
+       // Create a java.lang.reflect.Constructor object.
+
+       java_lang_reflect_Constructor rc(m);
+
+       return rc.get_handle();
+}
+#endif
+
+
+/* class_get_enclosingmethod ***************************************************
+
+   Return the enclosing method for the given class.
+
+   IN:
+       c ... class to return the enclosing method for
+
+   RETURN:
+       methodinfo of the enclosing method
+
+*******************************************************************************/
+
+methodinfo *class_get_enclosingmethod_raw(classinfo *c)
+{
+       constant_nameandtype *cn;
+       classinfo            *ec;
+       methodinfo           *m;
+
+       /* get enclosing class and method */
+
+       ec = class_get_enclosingclass(c);
+       cn = c->enclosingmethod;
+
+       /* check for enclosing class and method */
+
+       if (ec == NULL)
+               return NULL;
+
+       if (cn == NULL)
+               return NULL;
+
+       /* find method in enclosing class */
+
+       m = class_findmethod(ec, cn->name, cn->descriptor);
+
+       if (m == NULL) {
+               exceptions_throw_internalerror("Enclosing method doesn't exist");
+               return NULL;
+       }
+
+       return m;
+}
+
+
+/**
+ * Return the enclosing method as java.lang.reflect.Method object for
+ * the given class.
+ *
+ * @param c class to return the enclosing method for
+ *
+ * @return java.lang.reflect.Method object of the enclosing method
+ */
+#if defined(ENABLE_JAVASE)
+java_handle_t* class_get_enclosingmethod(classinfo *c)
+{
+       methodinfo*    m;
+
+       m = class_get_enclosingmethod_raw(c);
+
+       if (m == NULL)
+               return NULL;
+
+       /* check for <init> */
+
+       if (m->name == utf_init)
+               return NULL;
+
+       // Create a java.lang.reflect.Method object.
+
+       java_lang_reflect_Method rm(m);
+
+       return rm.get_handle();
+}
+#endif
+
+
+/* class_get_interfaces ********************************************************
+
+   Return an array of interfaces of the given class.
+
+*******************************************************************************/
+
+java_handle_objectarray_t *class_get_interfaces(classinfo *c)
+{
+       classinfo                 *ic;
+       java_handle_objectarray_t *oa;
+       u4                         i;
+
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return NULL;
+
+       oa = builtin_anewarray(c->interfacescount, class_java_lang_Class);
+
+       if (oa == NULL)
+               return NULL;
+
+       for (i = 0; i < c->interfacescount; i++) {
+               ic = c->interfaces[i];
+
+               LLNI_array_direct(oa, i) = (java_object_t *) ic;
+       }
+
+       return oa;
+}
+
+
+/* class_get_annotations *******************************************************
+
+   Get the unparsed declared annotations in a byte array
+   of the given class.
+
+   IN:
+       c........the class of which the annotations should be returned
+
+   RETURN VALUE:
+       The unparsed declared annotations in a byte array
+       (or NULL if there aren't any).
+
+*******************************************************************************/
+
+java_handle_bytearray_t *class_get_annotations(classinfo *c)
+{
+#if defined(ENABLE_ANNOTATIONS)
+       java_handle_t *annotations; /* unparsed annotations */
+
+       LLNI_classinfo_field_get(c, annotations, annotations);
+
+       return (java_handle_bytearray_t*)annotations;
+#else
+       return NULL;
+#endif
+}
+
+
+/* class_get_modifiers *********************************************************
+
+   Get the modifier flags of the given class.
+
+   IN:
+       c....the class of which the modifier flags should be returned
+          ignoreInnerClassesAttrib
+   RETURN VALUE:
+       modifier flags
+
+*******************************************************************************/
+
+int32_t class_get_modifiers(classinfo *c, bool ignoreInnerClassesAttrib)
+{
+       classref_or_classinfo  inner;
+       classref_or_classinfo  outer;
+       utf                   *innername;
+       int                    i;
+
+       if (!ignoreInnerClassesAttrib && (c->innerclasscount != 0)) {
+               /* search for passed class as inner class */
+
+               for (i = 0; i < c->innerclasscount; i++) {
+                       inner = c->innerclass[i].inner_class;
+                       outer = c->innerclass[i].outer_class;
+
+                       /* Check if inner is a classref or a real class and get
+               the name of the structure */
+
+                       innername = IS_CLASSREF(inner) ? inner.ref->name : inner.cls->name;
+
+                       /* innerclass is this class */
+
+                       if (innername == c->name) {
+                               /* has the class actually an outer class? */
+
+                               if (outer.any)
+                                       /* return flags got from the outer class file */
+                                       return c->innerclass[i].flags & ACC_CLASS_REFLECT_MASK;
+                               else
+                                       return c->flags & ACC_CLASS_REFLECT_MASK;
+                       }
+               }
+       }
+
+       /* passed class is no inner class or it was not requested */
+
+       return c->flags & ACC_CLASS_REFLECT_MASK;
+}
+
+
+/* class_get_signature *********************************************************
+
+   Return the signature of the given class.  For array and primitive
+   classes return NULL.
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+utf *class_get_signature(classinfo *c)
+{
+       /* For array and primitive classes return NULL. */
+
+       if (class_is_array(c) || class_is_primitive(c))
+               return NULL;
+
+       return c->signature;
+}
+#endif
+
+
+/* class_printflags ************************************************************
+
+   Prints flags of a class.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void class_printflags(classinfo *c)
+{
+       if (c == NULL) {
+               printf("NULL");
+               return;
+       }
+
+       if (c->flags & ACC_PUBLIC)       printf(" PUBLIC");
+       if (c->flags & ACC_PRIVATE)      printf(" PRIVATE");
+       if (c->flags & ACC_PROTECTED)    printf(" PROTECTED");
+       if (c->flags & ACC_STATIC)       printf(" STATIC");
+       if (c->flags & ACC_FINAL)        printf(" FINAL");
+       if (c->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED");
+       if (c->flags & ACC_VOLATILE)     printf(" VOLATILE");
+       if (c->flags & ACC_TRANSIENT)    printf(" TRANSIENT");
+       if (c->flags & ACC_NATIVE)       printf(" NATIVE");
+       if (c->flags & ACC_INTERFACE)    printf(" INTERFACE");
+       if (c->flags & ACC_ABSTRACT)     printf(" ABSTRACT");
+}
+#endif
+
+
+/* class_print *****************************************************************
+
+   Prints classname plus flags.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void class_print(classinfo *c)
+{
+       if (c == NULL) {
+               printf("NULL");
+               return;
+       }
+
+       utf_display_printable_ascii(c->name);
+       class_printflags(c);
+}
+#endif
+
+
+/* class_classref_print ********************************************************
+
+   Prints classname plus referer class.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void class_classref_print(constant_classref *cr)
+{
+       if (cr == NULL) {
+               printf("NULL");
+               return;
+       }
+
+       utf_display_printable_ascii(cr->name);
+       printf("(ref.by ");
+       if (cr->referer)
+               class_print(cr->referer);
+       else
+               printf("NULL");
+       printf(")");
+}
+#endif
+
+
+/* class_println ***************************************************************
+
+   Prints classname plus flags and new line.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void class_println(classinfo *c)
+{
+       class_print(c);
+       printf("\n");
+}
+#endif
+
+
+/* class_classref_println ******************************************************
+
+   Prints classname plus referer class and new line.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void class_classref_println(constant_classref *cr)
+{
+       class_classref_print(cr);
+       printf("\n");
+}
+#endif
+
+
+/* class_classref_or_classinfo_print *******************************************
+
+   Prints classname plus referer class.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void class_classref_or_classinfo_print(classref_or_classinfo c)
+{
+       if (c.any == NULL) {
+               printf("(classref_or_classinfo) NULL");
+               return;
+       }
+       if (IS_CLASSREF(c))
+               class_classref_print(c.ref);
+       else
+               class_print(c.cls);
+}
+#endif
+
+
+/* class_classref_or_classinfo_println *****************************************
+
+   Prints classname plus referer class and a newline.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void class_classref_or_classinfo_println(classref_or_classinfo c)
+{
+       class_classref_or_classinfo_print(c);
+       printf("\n");
+}
+#endif
+
+
+/* class_showconstantpool ******************************************************
+
+   Dump the constant pool of the given class to stdout.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void class_showconstantpool (classinfo *c) 
+{
+       u4 i;
+       void* e;
+
+       printf ("---- dump of constant pool ----\n");
+
+       for (i=0; i<c->cpcount; i++) {
+               printf ("#%d:  ", (int) i);
+               
+               e = c -> cpinfos [i];
+               if (e) {
+                       
+                       switch (c -> cptags [i]) {
+                       case CONSTANT_Class:
+                               printf ("Classreference -> ");
+                               utf_display_printable_ascii ( ((constant_classref*)e) -> name );
+                               break;
+                       case CONSTANT_Fieldref:
+                               printf ("Fieldref -> ");
+                               field_fieldref_print((constant_FMIref *) e);
+                               break;
+                       case CONSTANT_Methodref:
+                               printf ("Methodref -> ");
+                               method_methodref_print((constant_FMIref *) e);
+                               break;
+                       case CONSTANT_InterfaceMethodref:
+                               printf ("InterfaceMethod -> ");
+                               method_methodref_print((constant_FMIref *) e);
+                               break;
+                       case CONSTANT_String:
+                               printf ("String -> ");
+                               utf_display_printable_ascii ((utf*) e);
+                               break;
+                       case CONSTANT_Integer:
+                               printf ("Integer -> %d", (int) ( ((constant_integer*)e) -> value) );
+                               break;
+                       case CONSTANT_Float:
+                               printf ("Float -> %f", ((constant_float*)e) -> value);
+                               break;
+                       case CONSTANT_Double:
+                               printf ("Double -> %f", ((constant_double*)e) -> value);
+                               break;
+                       case CONSTANT_Long:
+                               printf ("Long -> %ld", (long int) ((constant_long*)e) -> value);
+                               break;
+                       case CONSTANT_NameAndType:
+                               {
+                                       constant_nameandtype *cnt = (constant_nameandtype *) e;
+                                       printf ("NameAndType: ");
+                                       utf_display_printable_ascii (cnt->name);
+                                       printf (" ");
+                                       utf_display_printable_ascii (cnt->descriptor);
+                               }
+                               break;
+                       case CONSTANT_Utf8:
+                               printf ("Utf8 -> ");
+                               utf_display_printable_ascii ((utf*) e);
+                               break;
+                       default: 
+                               log_text("Invalid type of ConstantPool-Entry");
+                               assert(0);
+                       }
+               }
+
+               printf ("\n");
+       }
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* class_showmethods ***********************************************************
+
+   Dump info about the fields and methods of the given class to stdout.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void class_showmethods (classinfo *c)
+{
+       s4 i;
+       
+       printf("--------- Fields and Methods ----------------\n");
+       printf("Flags: ");
+       class_printflags(c);
+       printf("\n");
+
+       printf("This: ");
+       utf_display_printable_ascii(c->name);
+       printf("\n");
+
+       if (c->super) {
+               printf("Super: ");
+               utf_display_printable_ascii(c->super->name);
+               printf ("\n");
+       }
+
+       printf("Index: %d\n", c->index);
+       
+       printf("Interfaces:\n");        
+       for (i = 0; i < c->interfacescount; i++) {
+               printf("   ");
+               utf_display_printable_ascii(c->interfaces[i]->name);
+               printf (" (%d)\n", c->interfaces[i]->index);
+       }
+
+       printf("Fields:\n");
+       for (i = 0; i < c->fieldscount; i++)
+               field_println(&(c->fields[i]));
+
+       printf("Methods:\n");
+       for (i = 0; i < c->methodscount; i++) {
+               methodinfo *m = &(c->methods[i]);
+
+               if (!(m->flags & ACC_STATIC))
+                       printf("vftblindex: %d   ", m->vftblindex);
+
+               method_println(m);
+       }
+
+       printf ("Virtual function table:\n");
+       for (i = 0; i < c->vftbl->vftbllength; i++)
+               printf ("entry: %d,  %ld\n", i, (long int) (c->vftbl->table[i]));
+}
+#endif /* !defined(NDEBUG) */
+
+
+/*
+ * 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/class.hpp b/src/vm/class.hpp
new file mode 100644 (file)
index 0000000..d1584b1
--- /dev/null
@@ -0,0 +1,460 @@
+/* src/vm/class.hpp - class related functions 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 _CLASS_HPP
+#define _CLASS_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct classinfo      classinfo; 
+typedef struct innerclassinfo innerclassinfo;
+typedef struct extra_classref extra_classref;
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/types.h"
+
+#if defined(ENABLE_JAVASE)
+# include "vm/annotation.h"
+#endif
+
+#include "vm/field.hpp"
+#include "vm/global.h"
+#include "vm/linker.hpp"
+#include "vm/loader.hpp"
+#include "vm/method.hpp"
+#include "vm/references.h"
+#include "vm/string.hpp"
+#include "vm/utf8.h"
+
+
+/* class state defines ********************************************************/
+
+#define CLASS_LOADING         0x0001
+#define CLASS_LOADED          0x0002
+#define CLASS_LINKING         0x0004
+#define CLASS_LINKED          0x0008
+#define CLASS_INITIALIZING    0x0010
+#define CLASS_INITIALIZED     0x0020
+#define CLASS_ERROR           0x0040
+
+
+/* some macros ****************************************************************/
+
+#define CLASS_IS_OR_ALMOST_INITIALIZED(c) \
+    (((c)->state & CLASS_INITIALIZING) || ((c)->state & CLASS_INITIALIZED))
+
+
+/* classinfo ******************************************************************/
+
+/* We define this dummy structure of java_lang_Class so we can
+   bootstrap cacaoh without needing a java_lang_Class.h file.  Whether
+   the size of the dummy structure is big enough is checked during
+   runtime in vm_create. */
+
+typedef struct {
+       java_object_t      header;
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       intptr_t           padding[4];
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       intptr_t           padding[19];
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+       intptr_t           padding[3];
+#else
+# error unknown classpath configuration
+#endif
+} dummy_java_lang_Class;
+
+struct classinfo {                /* class structure                          */
+       dummy_java_lang_Class object;
+
+       s4          flags;            /* ACC flags                                */
+       utf        *name;             /* class name                               */
+
+       s4          cpcount;          /* number of entries in constant pool       */
+       u1         *cptags;           /* constant pool tags                       */
+       void*      *cpinfos;          /* pointer to constant pool info structures */
+
+       s4          classrefcount;    /* number of symbolic class references      */
+       constant_classref *classrefs; /* table of symbolic class references       */
+       extra_classref *extclassrefs; /* additional classrefs                     */
+       s4          parseddescsize;   /* size of the parsed descriptors block     */
+       u1         *parseddescs;      /* parsed descriptors                       */
+
+       classinfo  *super;            /* super class                              */
+       classinfo  *sub;              /* sub class pointer                        */
+       classinfo  *nextsub;          /* pointer to next class in sub class list  */
+
+       int32_t     interfacescount;  /* number of interfaces                     */
+       classinfo **interfaces;       /* super interfaces                         */
+
+       int32_t     fieldscount;      /* number of fields                         */
+       fieldinfo  *fields;           /* field table                              */
+
+       int32_t     methodscount;     /* number of methods                        */
+       methodinfo *methods;          /* method table                             */
+
+       s4          state;            /* current class state                      */
+       s4          index;            /* hierarchy depth (classes) or index       */
+                                     /* (interfaces)                             */
+       s4          instancesize;     /* size of an instance of this class        */
+
+       vftbl_t    *vftbl;            /* pointer to virtual function table        */
+
+       methodinfo *finalizer;        /* finalizer method                         */
+
+       u2          innerclasscount;  /* number of inner classes                  */
+       innerclassinfo *innerclass;
+
+       classref_or_classinfo  declaringclass;
+       classref_or_classinfo  enclosingclass;  /* enclosing class                */
+       constant_nameandtype  *enclosingmethod; /* enclosing method               */
+
+       utf        *packagename;      /* full name of the package                 */
+       utf        *sourcefile;       /* SourceFile attribute                     */
+#if defined(ENABLE_JAVASE)
+       utf        *signature;        /* Signature attribute                      */
+#if defined(ENABLE_ANNOTATIONS)
+       /* All the annotation attributes are NULL (and not a zero length array)   */
+       /* if there is nothing.                                                   */
+       java_object_t *annotations;   /* annotations of this class                */
+       
+       java_object_t *method_annotations; /* array of annotations of the methods */
+       java_object_t *method_parameterannotations; /* array of parameter         */
+                                     /* annotations of the methods               */
+       java_object_t *method_annotationdefaults; /* array of annotation default  */
+                                     /* values of the methods                    */
+
+       java_object_t *field_annotations; /* array of annotations of the fields   */
+
+#endif
+#endif
+       classloader_t *classloader;       /* NULL for bootstrap classloader         */
+
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       java_object_t      *protectiondomain;
+       java_objectarray_t *signers;
+# endif
+#endif
+};
+
+
+/* innerclassinfo *************************************************************/
+
+struct innerclassinfo {
+       classref_or_classinfo inner_class; /* inner class pointer                 */
+       classref_or_classinfo outer_class; /* outer class pointer                 */
+       utf                  *name;        /* innerclass name                     */
+       s4                    flags;       /* ACC flags                           */
+};
+
+
+/* extra_classref **************************************************************
+
+   for classrefs not occurring within descriptors
+
+*******************************************************************************/
+
+struct extra_classref {
+       extra_classref    *next;
+       constant_classref  classref;
+};
+
+
+/* inline functions ***********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Returns the classname of the class, where slashes ('/') are
+ * replaced by dots ('.').
+ *
+ * @param c class to get name of
+ * @return classname
+ */
+inline static java_handle_t* class_get_classname(classinfo* c)
+{
+       java_handle_t *s;
+
+       /* Create a java string. */
+
+       s = javastring_new_slash_to_dot(c->name);
+
+       return s;
+}
+
+
+/* class_is_primitive **********************************************************
+
+   Checks if the given class is a primitive class.
+
+*******************************************************************************/
+
+static inline bool class_is_primitive(classinfo *c)
+{
+       if (c->flags & ACC_CLASS_PRIMITIVE)
+               return true;
+
+       return false;
+}
+
+
+/* class_is_anonymousclass *****************************************************
+
+   Checks if the given class is an anonymous class.
+
+*******************************************************************************/
+
+static inline bool class_is_anonymousclass(classinfo *c)
+{
+       if (c->flags & ACC_CLASS_ANONYMOUS)
+               return true;
+
+       return false;
+}
+
+
+/* class_is_array **************************************************************
+
+   Checks if the given class is an array class.
+
+*******************************************************************************/
+
+static inline bool class_is_array(classinfo *c)
+{
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return false;
+
+       return (c->vftbl->arraydesc != NULL);
+}
+
+
+/* class_is_interface **********************************************************
+
+   Checks if the given class is an interface.
+
+*******************************************************************************/
+
+static inline bool class_is_interface(classinfo *c)
+{
+       if (c->flags & ACC_INTERFACE)
+               return true;
+
+       return false;
+}
+
+
+/* class_is_localclass *********************************************************
+
+   Checks if the given class is a local class.
+
+*******************************************************************************/
+
+static inline bool class_is_localclass(classinfo *c)
+{
+       if ((c->enclosingmethod != NULL) && !class_is_anonymousclass(c))
+               return true;
+
+       return false;
+}
+
+
+/* class_is_memberclass ********************************************************
+
+   Checks if the given class is a member class.
+
+*******************************************************************************/
+
+static inline bool class_is_memberclass(classinfo *c)
+{
+       if (c->flags & ACC_CLASS_MEMBER)
+               return true;
+
+       return false;
+}
+
+
+/* class_get_classloader *******************************************************
+
+   Return the classloader of the given class.
+
+*******************************************************************************/
+
+static inline classloader_t *class_get_classloader(classinfo *c)
+{
+       classloader_t *cl;
+
+       cl = c->classloader;
+
+       /* The classloader may be NULL. */
+
+       return cl;
+}
+
+
+/* class_get_superclass ********************************************************
+
+   Return the super class of the given class.
+
+*******************************************************************************/
+
+static inline classinfo *class_get_superclass(classinfo *c)
+{
+       /* For interfaces we return NULL. */
+
+       if (c->flags & ACC_INTERFACE)
+               return NULL;
+
+       /* For java/lang/Object, primitive-type and Void classes c->super
+          is NULL and we return NULL. */
+
+       return c->super;
+}
+
+
+/* function prototypes ********************************************************/
+
+classinfo *class_create_classinfo(utf *u);
+void       class_postset_header_vftbl(void);
+classinfo *class_define(utf *name, classloader_t *cl, int32_t length, uint8_t *data, java_handle_t *pd);
+void       class_set_packagename(classinfo *c);
+
+bool       class_load_attributes(classbuffer *cb);
+
+/* retrieve constantpool element */
+void* class_getconstant(classinfo *c, u4 pos, u4 ctype);
+void* innerclass_getconstant(classinfo *c, u4 pos, u4 ctype);
+
+/* frees all resources used by the class */
+void class_free(classinfo *);
+
+/* return an array class with the given component class */
+classinfo *class_array_of(classinfo *component,bool link);
+
+/* return an array class with the given dimension and element class */
+classinfo *class_multiarray_of(s4 dim, classinfo *element,bool link);
+
+/* return a classref for the given class name */
+/* (does a linear search!)                    */
+constant_classref *class_lookup_classref(classinfo *cls,utf *name);
+
+/* return a classref for the given class name */
+/* (does a linear search!)                    */
+constant_classref *class_get_classref(classinfo *cls,utf *name);
+
+/* return a classref to the class itself */
+/* (does a linear search!)                    */
+constant_classref *class_get_self_classref(classinfo *cls);
+
+/* return a classref for an array with the given dimension of with the */
+/* given component type */
+constant_classref *class_get_classref_multiarray_of(s4 dim,constant_classref *ref);
+
+/* return a classref for the component type of the given array type */
+constant_classref *class_get_classref_component_of(constant_classref *ref);
+
+/* get a class' field by name and descriptor */
+fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc);
+
+/* search 'classinfo'-structure for a field with the specified name */
+fieldinfo *class_findfield_by_name(classinfo *c, utf *name);
+
+/* search class for a field */
+fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc, classinfo *referer);
+
+/* search for a method with a specified name and descriptor */
+methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc);
+methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *dest);
+methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception);
+methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception);
+
+bool                       class_issubclass(classinfo *sub, classinfo *super);
+bool                       class_isanysubclass(classinfo *sub, classinfo *super);
+bool                       class_is_assignable_from(classinfo *to, classinfo *from);
+bool                       class_is_instance(classinfo *c, java_handle_t *h);
+
+classloader_t             *class_get_classloader(classinfo *c);
+classinfo                 *class_get_superclass(classinfo *c);
+classinfo                 *class_get_componenttype(classinfo *c);
+java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOnly);
+java_handle_objectarray_t *class_get_declaredconstructors(classinfo *c, bool publicOnly);
+java_handle_objectarray_t *class_get_declaredfields(classinfo *c, bool publicOnly);
+java_handle_objectarray_t *class_get_declaredmethods(classinfo *c, bool publicOnly);
+classinfo                 *class_get_declaringclass(classinfo *c);
+classinfo                 *class_get_enclosingclass(classinfo *c);
+java_handle_t*             class_get_enclosingconstructor(classinfo *c);
+methodinfo*                class_get_enclosingmethod_raw(classinfo *c);
+java_handle_t*             class_get_enclosingmethod(classinfo *c);
+java_handle_objectarray_t *class_get_interfaces(classinfo *c);
+java_handle_bytearray_t   *class_get_annotations(classinfo *c);
+int32_t                    class_get_modifiers(classinfo *c, bool ignoreInnerClassesAttrib);
+java_handle_t             *class_get_name(classinfo *c);
+
+#if defined(ENABLE_JAVASE)
+utf                       *class_get_signature(classinfo *c);
+#endif
+
+/* some debugging functions */
+
+#if !defined(NDEBUG)
+void class_printflags(classinfo *c);
+void class_print(classinfo *c);
+void class_println(classinfo *c);
+void class_classref_print(constant_classref *cr);
+void class_classref_println(constant_classref *cr);
+void class_classref_or_classinfo_print(classref_or_classinfo c);
+void class_classref_or_classinfo_println(classref_or_classinfo c);
+#endif
+
+/* debug purposes */
+void class_showmethods(classinfo *c);
+void class_showconstantpool(classinfo *c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CLASS_HPP */
+
+
+/*
+ * 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:
+ */
diff --git a/src/vm/classcache.cpp b/src/vm/classcache.cpp
new file mode 100644 (file)
index 0000000..93db61a
--- /dev/null
@@ -0,0 +1,1595 @@
+/* src/vm/classcache.cpp - loaded class cache and loading constraints
+
+   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 "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "threads/lock.hpp"
+#include "threads/mutex.hpp"
+
+#include "toolbox/hashtable.h"
+#include "toolbox/logging.h"
+
+#include "vm/classcache.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/options.h"
+#include "vm/utf8.h"
+
+
+/*************************************************************************
+
+  Class Cache
+
+  The classcache has two functions:
+  
+       1) caching the resolution of class references
+       2) storing and checking loading constraints
+
+  We will use the following terms in this description:
+
+       N          a class name: a utf string
+       (N,L)      a class reference with initiating loader L and class name N
+       C          a class (object): the result of resolving a reference (N,L)
+               We will write resultion as
+                               C = *(N,L)
+       (N,L1,L2)  a loading constraint indicating that (N,L1) and (N,L2) must
+                  resolve to the same class C. So (N,L1,L2) means
+                               *(N,L1) = *(N,L2)
+
+  The functions of the classcache require:
+
+    1) a mapping (N,L) |--> C for looking up prior resolution results.
+       2) storing the current set of loading constraints { (N,L1,L2) }
+
+  These functions can be rearranged like that:
+
+    a mapping N |--> (a mapping L |--> C or NULL, 
+                         a set of constraints {(L1,L2)})
+
+  Thus we can treat the mapping and constraints for each name N
+  separately. The implementation does this by keeping a hash table
+  mapping a name N to a `classcache_name_entry` which contains all
+  info with respect to N.
+
+  For a class name N we can define an equivalence relation ~N~ on
+  class loaders:
+
+       L1 ~N~ L2  <==>  *(N,L1) = *(N,L2)
+
+  A loading constraint (N,L1,L2) implies L1 ~N~ L2.
+
+  Also, if two references (N,L1) and (N,L2) resolve to the same class C
+  we have L1 ~N~ L2 because class loaders are required to return
+  consistent resolutions for a name N [XXX].
+
+  A `classcache_name_entry` keeps a set of tuples { (Cx,IL,CL) },
+  where
+               Cx...is a class C or NULL
+               IL...is the set of initiating loaders
+               CL...is the set of constrained loaders
+               
+  Such a tuple is called `classcache_class_entry` in the source code.
+
+  The following holds for each tuple (Cx,IL,CL):
+
+    .  (Cx is NULL) implies IL = {}.
+          
+       .  If Cx is a class, IL is the set of loaders that have been
+          recorded as initiating loaders for Cx. IL may be the
+          empty set {} in case Cx has already been defined but no
+          initiating loader has been recorded, yet.
+  
+    .  (IL u CL) is a subset of an equivalence class of ~N~.
+
+                (This means that all loaders in IL and CL must resolve
+                the name N to the same class.)
+
+  The following holds for the set of tuples { (Cx,IL,CL) }:
+
+    .  For a given class C there is at most one tuple with Cx = C
+          in the set. (There may be an arbitrary number of tuples
+          with Cx = NULL, however.)
+
+       .  For a given loader L there is at most one tuple with
+          L in (IL u CL).
+
+  The implementation stores sets of loaders as linked lists of
+  `classcache_loader_entry`s.
+
+  Comments about manipulating the classcache can be found in the
+  individual functions below.
+*************************************************************************/
+
+
+/* initial number of slots in the classcache hash table */
+#define CLASSCACHE_INIT_SIZE  2048
+
+/*============================================================================*/
+/* DEBUG HELPERS                                                              */
+/*============================================================================*/
+
+/* #define CLASSCACHE_VERBOSE */
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/*============================================================================*/
+/* STATISTICS                                                                 */
+/*============================================================================*/
+
+/*#define CLASSCACHE_STATS*/
+
+#ifdef CLASSCACHE_STATS
+static int stat_classnames_stored = 0;
+static int stat_classes_stored = 0;
+static int stat_trivial_constraints = 0;
+static int stat_nontriv_constraints = 0;
+static int stat_nontriv_constraints_both = 0;
+static int stat_nontriv_constraints_merged = 0;
+static int stat_nontriv_constraints_one = 0;
+static int stat_nontriv_constraints_none = 0;
+static int stat_new_loader_entry = 0;
+static int stat_merge_class_entries = 0;
+static int stat_merge_loader_entries = 0;
+static int stat_lookup = 0;
+static int stat_lookup_class_entry_checked = 0;
+static int stat_lookup_loader_checked = 0;
+static int stat_lookup_name = 0;
+static int stat_lookup_name_entry = 0;
+static int stat_lookup_name_notfound = 0;
+static int stat_lookup_new_name = 0;
+static int stat_lookup_new_name_entry = 0;
+static int stat_lookup_new_name_collisions = 0;
+static int stat_rehash_names = 0;
+static int stat_rehash_names_collisions = 0;
+
+#define CLASSCACHE_COUNT(cnt)  (cnt)++
+#define CLASSCACHE_COUNTIF(cond,cnt)  do{if(cond) (cnt)++;} while(0)
+
+void classcache_print_statistics(FILE *file) {
+       fprintf(file,"classnames stored   : %8d\n",stat_classnames_stored);
+       fprintf(file,"classes stored      : %8d\n",stat_classes_stored);
+       fprintf(file,"trivial constraints : %8d\n",stat_trivial_constraints);
+       fprintf(file,"non-triv constraints: %8d\n",stat_nontriv_constraints);
+       fprintf(file,"   both loaders rec.: %8d\n",stat_nontriv_constraints_both);
+       fprintf(file,"       merged       : %8d\n",stat_nontriv_constraints_merged);
+       fprintf(file,"   one loader rec.  : %8d\n",stat_nontriv_constraints_one);
+       fprintf(file,"   no loaders rec.  : %8d\n",stat_nontriv_constraints_none);
+       fprintf(file,"new loader entries  : %8d\n",stat_new_loader_entry);
+       fprintf(file,"merge class entries : %8d\n",stat_merge_class_entries);
+       fprintf(file,"merge loader entries: %8d\n",stat_merge_loader_entries);
+       fprintf(file,"lookups             : %8d\n",stat_lookup);
+       fprintf(file,"   class entries ckd: %8d\n",stat_lookup_class_entry_checked);
+       fprintf(file,"   loader checked   : %8d\n",stat_lookup_loader_checked);
+       fprintf(file,"lookup name         : %8d\n",stat_lookup_name);
+       fprintf(file,"   entries checked  : %8d\n",stat_lookup_name_entry);
+       fprintf(file,"   not found        : %8d\n",stat_lookup_name_notfound);
+       fprintf(file,"lookup (new) name   : %8d\n",stat_lookup_new_name);
+       fprintf(file,"   entries checked  : %8d\n",stat_lookup_new_name_entry);
+       fprintf(file,"   new collisions   : %8d\n",stat_lookup_new_name_collisions);
+       fprintf(file,"names rehashed      : %8d times\n",stat_rehash_names);
+       fprintf(file,"    collisions      : %8d\n",stat_rehash_names_collisions);
+}
+#else
+#define CLASSCACHE_COUNT(cnt)
+#define CLASSCACHE_COUNTIF(cond,cnt)
+#endif
+
+/*============================================================================*/
+/* THREAD-SAFE LOCKING                                                        */
+/*============================================================================*/
+
+       /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+       /* CAUTION: The static functions below are */
+       /*          NOT synchronized!              */
+       /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
+#if defined(ENABLE_THREADS)
+# define CLASSCACHE_LOCK()      classcache_hashtable_mutex->lock();
+# define CLASSCACHE_UNLOCK()    classcache_hashtable_mutex->unlock();
+#else
+# define CLASSCACHE_LOCK()
+# define CLASSCACHE_UNLOCK()
+#endif
+
+/*============================================================================*/
+/* GLOBAL VARIABLES                                                           */
+/*============================================================================*/
+
+hashtable hashtable_classcache;
+
+#if defined(ENABLE_THREADS)
+static Mutex *classcache_hashtable_mutex;
+#endif
+
+
+/*============================================================================*/
+/*                                                                            */
+/*============================================================================*/
+
+/* prototypes */
+
+static void classcache_free_class_entry(classcache_class_entry *clsen);
+static void classcache_remove_class_entry(classcache_name_entry *en,
+                                                                                 classcache_class_entry *clsen);
+
+/* hash function to use */
+
+#define CLASSCACHE_HASH utf_full_hashkey
+
+/* classcache_init *************************************************************
+   Initialize the class cache
+
+   Note: NOT synchronized!
+  
+*******************************************************************************/
+
+bool classcache_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("classcache_init");
+
+       /* create the hashtable */
+
+       hashtable_create(&hashtable_classcache, CLASSCACHE_INIT_SIZE);
+
+#if defined(ENABLE_THREADS)
+       /* create utf hashtable mutex */
+
+       classcache_hashtable_mutex = new Mutex();
+#endif
+
+       /* everything's ok */
+
+       return true;
+}
+
+/* classcache_new_loader_entry *************************************************
+   Create a new classcache_loader_entry struct
+   (internally used helper function)
+  
+   IN:
+       loader...........the ClassLoader object
+          next.............the next classcache_loader_entry
+
+   RETURN VALUE:
+       the new classcache_loader_entry
+  
+*******************************************************************************/
+
+static classcache_loader_entry * classcache_new_loader_entry(
+                                                                       classloader_t * loader,
+                                                                       classcache_loader_entry * next)
+{
+       classcache_loader_entry *lden;
+
+       lden = NEW(classcache_loader_entry);
+       lden->loader = loader;
+       lden->next = next;
+       CLASSCACHE_COUNT(stat_new_loader_entry);
+
+       return lden;
+}
+
+/* classcache_merge_loaders ****************************************************
+   Merge two lists of loaders into one
+   (internally used helper function)
+  
+   IN:
+       lista............first list (may be NULL)
+          listb............second list (may be NULL)
+
+   RETURN VALUE:
+       the merged list (may be NULL)
+
+   NOTE:
+       The lists given as arguments are destroyed!
+  
+*******************************************************************************/
+
+static classcache_loader_entry * classcache_merge_loaders(
+                                                                       classcache_loader_entry * lista,
+                                                                       classcache_loader_entry * listb)
+{
+       classcache_loader_entry *result;
+       classcache_loader_entry *ldenA;
+       classcache_loader_entry *ldenB;
+       classcache_loader_entry **chain;
+
+       CLASSCACHE_COUNT(stat_merge_loader_entries);
+
+       /* XXX This is a quadratic algorithm. If this ever
+        * becomes a problem, the loader lists should be
+        * stored as sorted lists and merged in linear time. */
+
+       result = NULL;
+       chain = &result;
+
+       for (ldenA = lista; ldenA; ldenA = ldenA->next) {
+
+               for (ldenB = listb; ldenB; ldenB = ldenB->next) {
+                       if (ldenB->loader == ldenA->loader)
+                               goto common_element;
+               }
+
+               /* this loader is only in lista */
+               *chain = ldenA;
+               chain = &(ldenA->next);
+
+         common_element:
+               /* XXX free the duplicated element */
+               ;
+       }
+
+       /* concat listb to the result */
+       *chain = listb;
+
+       return result;
+}
+
+/* classcache_merge_class_entries **********************************************
+   Merge two `classcache_class_entry`s into one.
+   (internally used helper function)
+  
+   IN:
+       en...............the classcache_name_entry containing both class entries
+       clsenA...........first class entry, will receive the result
+          clsenB...........second class entry
+
+   PRE-CONDITION:
+       Either both entries must have the same classobj, or one of them has
+          classobj == NULL.
+
+   NOTE:
+       clsenB is freed by this function!
+  
+*******************************************************************************/
+
+static void classcache_merge_class_entries(classcache_name_entry *en,
+                                                                                  classcache_class_entry *clsenA,
+                                                                                  classcache_class_entry *clsenB)
+{
+#ifdef CLASSCACHE_VERBOSE
+       char logbuffer[1024];
+#endif
+       
+       assert(en);
+       assert(clsenA);
+       assert(clsenB);
+       assert(!clsenA->classobj || !clsenB->classobj || clsenA->classobj == clsenB->classobj);
+
+#ifdef CLASSCACHE_VERBOSE
+       sprintf(logbuffer,"classcache_merge_class_entries(%p,%p->%p,%p->%p) ", 
+                       (void*)en,(void*)clsenA,(void*)clsenA->classobj,(void*)clsenB,(void*)clsenB->classobj);
+       if (clsenA->classobj)
+               utf_cat_classname(logbuffer, clsenA->classobj->name);
+       if (clsenB->classobj)
+               utf_cat_classname(logbuffer, clsenB->classobj->name);
+       log_println(logbuffer);
+#endif
+
+       CLASSCACHE_COUNT(stat_merge_class_entries);
+
+       /* clsenB will be merged into clsenA */
+       clsenA->loaders = classcache_merge_loaders(clsenA->loaders, clsenB->loaders);
+       clsenB->loaders = NULL; /* these have been freed or reused */
+
+       clsenA->constraints = classcache_merge_loaders(clsenA->constraints,
+                                                                                                  clsenB->constraints);
+       clsenB->constraints = NULL; /* these have been freed or reused */
+
+       if (!clsenA->classobj)
+               clsenA->classobj = clsenB->classobj;
+
+       /* remove clsenB from the list of class entries */
+       classcache_remove_class_entry(en, clsenB);
+}
+
+
+/* classcache_lookup_name ******************************************************
+   Lookup a name in the first level of the cache
+   (internally used helper function)
+   
+   IN:
+       name.............the name to look up
+  
+   RETURN VALUE:
+       a pointer to the classcache_name_entry for this name, or
+       null if no entry was found.
+          
+*******************************************************************************/
+
+static classcache_name_entry *classcache_lookup_name(utf *name)
+{
+       classcache_name_entry *c;           /* hash table element                 */
+       u4 key;                             /* hashkey computed from classname    */
+       u4 slot;                            /* slot in hashtable                  */
+
+       CLASSCACHE_COUNT(stat_lookup_name);
+
+       key  = CLASSCACHE_HASH(name->text, (u4) name->blength);
+       slot = key & (hashtable_classcache.size - 1);
+       c    = (classcache_name_entry*) hashtable_classcache.ptr[slot];
+
+       /* search external hash chain for the entry */
+
+       while (c) {
+               /* entry found in hashtable */
+               CLASSCACHE_COUNT(stat_lookup_name_entry);
+
+               if (c->name == name)
+                       return c;
+
+               c = c->hashlink;                    /* next element in external chain */
+       }
+
+       /* not found */
+
+       CLASSCACHE_COUNT(stat_lookup_name_notfound);
+       return NULL;
+}
+
+
+/* classcache_new_name *********************************************************
+   Return a classcache_name_entry for the given name. The entry is created
+   if it is not already in the cache.
+   (internally used helper function)
+   
+   IN:
+       name.............the name to look up / create an entry for
+  
+   RETURN VALUE:
+       a pointer to the classcache_name_entry for this name
+          
+*******************************************************************************/
+
+static classcache_name_entry *classcache_new_name(utf *name)
+{
+       classcache_name_entry *c;       /* hash table element */
+       u4 key;                                         /* hashkey computed from classname */
+       u4 slot;                                        /* slot in hashtable               */
+       u4 i;
+
+       CLASSCACHE_COUNT(stat_lookup_new_name);
+
+       key  = CLASSCACHE_HASH(name->text, (u4) name->blength);
+       slot = key & (hashtable_classcache.size - 1);
+       c    = (classcache_name_entry*) hashtable_classcache.ptr[slot];
+
+       /* search external hash chain for the entry */
+
+       while (c) {
+               /* entry found in hashtable */
+               CLASSCACHE_COUNT(stat_lookup_new_name_entry);
+
+               if (c->name == name)
+                       return c;
+
+               c = c->hashlink;                    /* next element in external chain */
+       }
+
+       /* location in hashtable found, create new entry */
+
+       c = NEW(classcache_name_entry);
+
+       c->name = name;
+       c->classes = NULL;
+
+       /* insert entry into hashtable */
+       c->hashlink = (classcache_name_entry *) hashtable_classcache.ptr[slot];
+       CLASSCACHE_COUNTIF(c->hashlink,stat_lookup_new_name_collisions);
+       hashtable_classcache.ptr[slot] = c;
+
+       /* update number of hashtable-entries */
+       hashtable_classcache.entries++;
+       CLASSCACHE_COUNT(stat_classnames_stored);
+
+       if ((hashtable_classcache.entries*2) > hashtable_classcache.size) {
+               /* reorganization of hashtable */ 
+
+               classcache_name_entry *c2;
+               hashtable newhash;              /* the new hashtable */
+
+               CLASSCACHE_COUNT(stat_rehash_names);
+
+               /* create new hashtable, double the size */
+
+               hashtable_create(&newhash, hashtable_classcache.size * 2);
+               newhash.entries = hashtable_classcache.entries;
+
+               /* transfer elements to new hashtable */
+
+               for (i = 0; i < hashtable_classcache.size; i++) {
+                       c2 = (classcache_name_entry *) hashtable_classcache.ptr[i];
+                       while (c2) {
+                               classcache_name_entry *nextc = c2->hashlink;
+                               u4 newslot =
+                                       (CLASSCACHE_HASH(c2->name->text, (u4) c2->name->blength)) & (newhash.size - 1);
+
+                               c2->hashlink = (classcache_name_entry *) newhash.ptr[newslot];
+                               CLASSCACHE_COUNTIF(c2->hashlink,stat_rehash_names_collisions);
+                               newhash.ptr[newslot] = c2;
+
+                               c2 = nextc;
+                       }
+               }
+
+               /* dispose old table */
+
+               MFREE(hashtable_classcache.ptr, void *, hashtable_classcache.size);
+               hashtable_classcache = newhash;
+       }
+
+       return c;
+}
+
+
+/* classcache_lookup ***********************************************************
+   Lookup a possibly loaded class
+  
+   IN:
+       initloader.......initiating loader for resolving the class name
+       classname........class name to look up
+  
+   RETURN VALUE:
+       The return value is a pointer to the cached class object,
+       or NULL, if the class is not in the cache.
+
+   Note: synchronized with global tablelock
+   
+*******************************************************************************/
+
+classinfo *classcache_lookup(classloader_t *initloader, utf *classname)
+{
+       classcache_name_entry *en;
+       classcache_class_entry *clsen;
+       classcache_loader_entry *lden;
+       classinfo *cls = NULL;
+
+       CLASSCACHE_LOCK();
+
+       CLASSCACHE_COUNT(stat_lookup);
+       en = classcache_lookup_name(classname);
+
+       if (en) {
+               /* iterate over all class entries */
+
+               for (clsen = en->classes; clsen; clsen = clsen->next) {
+                       CLASSCACHE_COUNT(stat_lookup_class_entry_checked);
+                       /* check if this entry has been loaded by initloader */
+
+                       for (lden = clsen->loaders; lden; lden = lden->next) {
+                               CLASSCACHE_COUNT(stat_lookup_loader_checked);
+                               if (lden->loader == initloader) {
+                                       /* found the loaded class entry */
+
+                                       assert(clsen->classobj);
+                                       cls = clsen->classobj;
+                                       goto found;
+                               }
+                       }
+               }
+       }
+
+  found:
+       CLASSCACHE_UNLOCK();
+       return cls;
+}
+
+
+/* classcache_lookup_defined ***************************************************
+   Lookup a class with the given name and defining loader
+  
+   IN:
+       defloader........defining loader
+       classname........class name
+  
+   RETURN VALUE:
+       The return value is a pointer to the cached class object,
+       or NULL, if the class is not in the cache.
+   
+*******************************************************************************/
+
+classinfo *classcache_lookup_defined(classloader_t *defloader, utf *classname)
+{
+       classcache_name_entry *en;
+       classcache_class_entry *clsen;
+       classinfo *cls = NULL;
+
+       CLASSCACHE_LOCK();
+
+       en = classcache_lookup_name(classname);
+
+       if (en) {
+               /* iterate over all class entries */
+               for (clsen = en->classes; clsen; clsen = clsen->next) {
+                       if (!clsen->classobj)
+                               continue;
+
+                       /* check if this entry has been defined by defloader */
+                       if (clsen->classobj->classloader == defloader) {
+                               cls = clsen->classobj;
+                               goto found;
+                       }
+               }
+       }
+
+  found:
+       CLASSCACHE_UNLOCK();
+       return cls;
+}
+
+
+/* classcache_lookup_defined_or_initiated **************************************
+   Lookup a class that has been defined or initiated by the given loader
+  
+   IN:
+       loader...........defining or initiating loader
+       classname........class name to look up
+  
+   RETURN VALUE:
+       The return value is a pointer to the cached class object,
+       or NULL, if the class is not in the cache.
+
+   Note: synchronized with global tablelock
+   
+*******************************************************************************/
+
+classinfo *classcache_lookup_defined_or_initiated(classloader_t *loader, 
+                                                                                                 utf *classname)
+{
+       classcache_name_entry *en;
+       classcache_class_entry *clsen;
+       classcache_loader_entry *lden;
+       classinfo *cls = NULL;
+
+       CLASSCACHE_LOCK();
+
+       en = classcache_lookup_name(classname);
+
+       if (en) {
+               /* iterate over all class entries */
+
+               for (clsen = en->classes; clsen; clsen = clsen->next) {
+
+                       /* check if this entry has been defined by loader */
+                       if (clsen->classobj && clsen->classobj->classloader == loader) {
+                               cls = clsen->classobj;
+                               goto found;
+                       }
+                       
+                       /* check if this entry has been initiated by loader */
+                       for (lden = clsen->loaders; lden; lden = lden->next) {
+                               if (lden->loader == loader) {
+                                       /* found the loaded class entry */
+
+                                       assert(clsen->classobj);
+                                       cls = clsen->classobj;
+                                       goto found;
+                               }
+                       }
+               }
+       }
+
+  found:
+       CLASSCACHE_UNLOCK();
+       return cls;
+}
+
+
+/* classcache_store ************************************************************
+   
+   Store a loaded class. If a class of the same name has already been stored
+   with the same initiating loader, then the given class CLS is freed (if
+   possible) and the previously stored class is returned.
+  
+   IN:
+       initloader.......initiating loader used to load the class
+                           (may be NULL indicating the bootstrap loader)
+       cls..............class object to cache
+          mayfree..........true if CLS may be freed in case another class is
+                           returned
+  
+   RETURN VALUE:
+       cls..............everything ok, the class was stored in the cache,
+          other classinfo..another class with the same (initloader,name) has been
+                           stored earlier. CLS has been freed[1] and the earlier
+                                               stored class is returned.
+       NULL.............an exception has been thrown.
+   
+   Note: synchronized with global tablelock
+
+   [1]...in case MAYFREE is true
+   
+*******************************************************************************/
+
+classinfo *classcache_store(classloader_t *initloader, classinfo *cls,
+                                                       bool mayfree)
+{
+       classcache_name_entry *en;
+       classcache_class_entry *clsen;
+       classcache_class_entry *clsenB;
+       classcache_loader_entry *lden;
+#ifdef CLASSCACHE_VERBOSE
+       char logbuffer[1024];
+#endif
+       
+       assert(cls);
+       assert(cls->state & CLASS_LOADED);
+
+       CLASSCACHE_LOCK();
+
+#ifdef CLASSCACHE_VERBOSE
+       sprintf(logbuffer,"classcache_store (%p,%d,%p=", (void*)initloader,mayfree,(void*)cls);
+       utf_cat_classname(logbuffer, cls->name);
+       strcat(logbuffer,")");
+       log_println(logbuffer);
+#endif
+
+       en = classcache_new_name(cls->name);
+
+       assert(en);
+
+       /* iterate over all class entries */
+       for (clsen = en->classes; clsen; clsen = clsen->next) {
+
+               /* check if this entry has already been loaded by initloader */
+               for (lden = clsen->loaders; lden; lden = lden->next) {
+                       if (lden->loader == initloader) {
+                          if (clsen->classobj != cls) {
+                                       /* A class with the same (initloader,name) pair has been stored already. */
+                                       /* We free the given class and return the earlier one.                   */
+#ifdef CLASSCACHE_VERBOSE
+                                       log_println("replacing %p with earlier loaded class %p",cls,clsen->classobj);
+#endif
+                                       assert(clsen->classobj);
+                                       if (mayfree)
+                                               class_free(cls);
+                                       cls = clsen->classobj;
+                          }
+                          goto return_success;
+                       }
+               }
+
+               /* {This entry has not been resolved with initloader} */
+
+               /* check if initloader is constrained to this entry */
+               for (lden = clsen->constraints; lden; lden = lden->next) {
+                       if (lden->loader == initloader) {
+                               /* we have to use this entry. check if it has been resolved */
+                               if (clsen->classobj) {
+                                       /* check if is has already been resolved to another class */
+                                       if (clsen->classobj != cls) {
+                                               /* a loading constraint is violated */
+                                               exceptions_throw_linkageerror("loading constraint violated: ", cls);
+                                               goto return_exception;
+                                       }
+
+                                       /* record initloader as initiating loader */
+                                       clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders);
+                                       goto return_success;
+                               }
+
+                               /* {this is the first resolution for this entry} */
+                               /* record initloader as initiating loader */
+                               clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders);
+
+                               /* maybe we can merge this entry with another one */
+                               for (clsenB = en->classes; clsenB; clsenB = clsenB->next) {
+                                       /* we dont want the entry that we have already */
+                                       if (clsenB->classobj == cls) {
+                                               /* this entry has the same classobj. let's merge them */
+                                               classcache_merge_class_entries(en,clsen,clsenB);
+                                               goto return_success;
+                                       }
+                               }
+
+                               /* record the loaded class object */
+                               clsen->classobj = cls;
+                               CLASSCACHE_COUNT(stat_classes_stored);
+
+                               /* done */
+                               goto return_success;
+                       }
+               }
+
+       }
+
+       /* {There is no class entry containing initloader as initiating 
+        *  or constrained loader.} */
+
+       /* we look for a class entry with the same classobj we want to store */
+       for (clsen = en->classes; clsen; clsen = clsen->next) {
+               if (clsen->classobj == cls) {
+                       /* this entry is about the same classobj. let's use it */
+                       /* check if this entry has already been loaded by initloader */
+                       for (lden = clsen->loaders; lden; lden = lden->next) {
+                               if (lden->loader == initloader)
+                                       goto return_success;
+                       }
+                       clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders);
+                       goto return_success;
+               }
+       }
+
+       /* create a new class entry for this class object with */
+       /* initiating loader initloader                        */
+
+       clsen = NEW(classcache_class_entry);
+       clsen->classobj = cls;
+       clsen->loaders = classcache_new_loader_entry(initloader, NULL);
+       clsen->constraints = NULL;
+
+       clsen->next = en->classes;
+       en->classes = clsen;
+       CLASSCACHE_COUNT(stat_classes_stored);
+
+  return_success:
+#ifdef CLASSCACHE_VERBOSE
+       classcache_debug_dump(stdout,cls->name);
+#endif
+       CLASSCACHE_UNLOCK();
+       return cls;
+
+  return_exception:
+       CLASSCACHE_UNLOCK();
+       return NULL;                            /* exception */
+}
+
+/* classcache_store_unique *****************************************************
+   
+   Store a loaded class as loaded by the bootstrap loader. This is a wrapper 
+   aroung classcache_store that throws an exception if a class with the same 
+   name has already been loaded by the bootstrap loader.
+
+   This function is used to register a few special classes during startup.
+   It should not be used otherwise.
+  
+   IN:
+       cls..............class object to cache
+  
+   RETURN VALUE:
+       true.............everything ok, the class was stored.
+       false............an exception has been thrown.
+   
+   Note: synchronized with global tablelock
+   
+*******************************************************************************/
+
+bool classcache_store_unique(classinfo *cls)
+{
+       classinfo *result;
+
+       result = classcache_store(NULL,cls,false);
+       if (result == NULL)
+               return false;
+
+       if (result != cls) {
+               exceptions_throw_internalerror("class already stored in the class cache");
+               return false;
+       }
+
+       return true;
+}
+
+/* classcache_store_defined ****************************************************
+   
+   Store a loaded class after it has been defined. If the class has already
+   been defined by the same defining loader in another thread, free the given
+   class and returned the one which has been defined earlier.
+  
+   IN:
+       cls..............class object to store. classloader must be set
+                           (classloader may be NULL, for bootloader)
+  
+   RETURN VALUE:
+       cls..............everything ok, the class was stored the cache,
+          other classinfo..the class had already been defined, CLS was freed, the
+                           class which was defined earlier is returned,
+       NULL.............an exception has been thrown.
+   
+*******************************************************************************/
+
+classinfo *classcache_store_defined(classinfo *cls)
+{
+       classcache_name_entry *en;
+       classcache_class_entry *clsen;
+#ifdef CLASSCACHE_VERBOSE
+       char logbuffer[1024];
+#endif
+
+       assert(cls);
+       assert(cls->state & CLASS_LOADED);
+
+       CLASSCACHE_LOCK();
+
+#ifdef CLASSCACHE_VERBOSE
+       sprintf(logbuffer,"classcache_store_defined (%p,", (void*)cls->classloader);
+       utf_cat_classname(logbuffer, cls->name);
+       strcat(logbuffer,")");
+       log_println(logbuffer);
+#endif
+
+       en = classcache_new_name(cls->name);
+
+       assert(en);
+
+       /* iterate over all class entries */
+       for (clsen = en->classes; clsen; clsen = clsen->next) {
+               
+               /* check if this class has been defined by the same classloader */
+               if (clsen->classobj && clsen->classobj->classloader == cls->classloader) {
+                       /* we found an earlier definition, delete the newer one */
+                       /* (if it is a different classinfo)                     */
+                       if (clsen->classobj != cls) {
+#ifdef CLASSCACHE_VERBOSE
+                               log_println("replacing %p with earlier defined class %p",cls,clsen->classobj);
+#endif
+                               class_free(cls);
+                               cls = clsen->classobj;
+                       }
+                       goto return_success;
+               }
+       }
+
+       /* create a new class entry for this class object */
+       /* the list of initiating loaders is empty at this point */
+
+       clsen = NEW(classcache_class_entry);
+       clsen->classobj = cls;
+       clsen->loaders = NULL;
+       clsen->constraints = NULL;
+
+       clsen->next = en->classes;
+       en->classes = clsen;
+       CLASSCACHE_COUNT(stat_classes_stored);
+
+return_success:
+#ifdef CLASSCACHE_VERBOSE
+       classcache_debug_dump(stdout,cls->name);
+#endif
+       CLASSCACHE_UNLOCK();
+       return cls;
+}
+
+/* classcache_find_loader ******************************************************
+   Find the class entry loaded by or constrained to a given loader
+   (internally used helper function)
+  
+   IN:
+       entry............the classcache_name_entry
+       loader...........the loader to look for
+  
+   RETURN VALUE:
+       the classcache_class_entry for the given loader, or
+          NULL if no entry was found
+   
+*******************************************************************************/
+
+static classcache_class_entry * classcache_find_loader(
+                                                                       classcache_name_entry * entry,
+                                                                       classloader_t * loader)
+{
+       classcache_class_entry *clsen;
+       classcache_loader_entry *lden;
+
+       assert(entry);
+
+       /* iterate over all class entries */
+       for (clsen = entry->classes; clsen; clsen = clsen->next) {
+
+               /* check if this entry has already been loaded by initloader */
+               for (lden = clsen->loaders; lden; lden = lden->next) {
+                       if (lden->loader == loader)
+                               return clsen;   /* found */
+               }
+
+               /* check if loader is constrained to this entry */
+               for (lden = clsen->constraints; lden; lden = lden->next) {
+                       if (lden->loader == loader)
+                               return clsen;   /* found */
+               }
+       }
+
+       /* not found */
+       return NULL;
+}
+
+/* classcache_free_class_entry *************************************************
+   Free the memory used by a class entry
+  
+   IN:
+       clsen............the classcache_class_entry to free  
+          
+*******************************************************************************/
+
+static void classcache_free_class_entry(classcache_class_entry * clsen)
+{
+       classcache_loader_entry *lden;
+       classcache_loader_entry *next;
+
+       assert(clsen);
+
+       for (lden = clsen->loaders; lden; lden = next) {
+               next = lden->next;
+               FREE(lden, classcache_loader_entry);
+       }
+       for (lden = clsen->constraints; lden; lden = next) {
+               next = lden->next;
+               FREE(lden, classcache_loader_entry);
+       }
+
+       FREE(clsen, classcache_class_entry);
+}
+
+/* classcache_remove_class_entry ***********************************************
+   Remove a classcache_class_entry from the list of possible resolution of
+   a name entry
+   (internally used helper function)
+  
+   IN:
+       entry............the classcache_name_entry
+       clsen............the classcache_class_entry to remove
+  
+*******************************************************************************/
+
+static void classcache_remove_class_entry(classcache_name_entry * entry,
+                                                                                 classcache_class_entry * clsen)
+{
+       classcache_class_entry **chain;
+
+       assert(entry);
+       assert(clsen);
+
+       chain = &(entry->classes);
+       while (*chain) {
+               if (*chain == clsen) {
+                       *chain = clsen->next;
+                       classcache_free_class_entry(clsen);
+                       return;
+               }
+               chain = &((*chain)->next);
+       }
+}
+
+/* classcache_free_name_entry **************************************************
+   Free the memory used by a name entry
+  
+   IN:
+       entry............the classcache_name_entry to free  
+          
+*******************************************************************************/
+
+static void classcache_free_name_entry(classcache_name_entry * entry)
+{
+       classcache_class_entry *clsen;
+       classcache_class_entry *next;
+
+       assert(entry);
+
+       for (clsen = entry->classes; clsen; clsen = next) {
+               next = clsen->next;
+               classcache_free_class_entry(clsen);
+       }
+
+       FREE(entry, classcache_name_entry);
+}
+
+/* classcache_free *************************************************************
+   Free the memory used by the class cache
+
+   NOTE:
+       The class cache may not be used any more after this call, except
+          when it is reinitialized with classcache_init.
+  
+   Note: NOT synchronized!
+  
+*******************************************************************************/
+
+void classcache_free(void)
+{
+       u4 slot;
+       classcache_name_entry *entry;
+       classcache_name_entry *next;
+
+       for (slot = 0; slot < hashtable_classcache.size; ++slot) {
+               for (entry = (classcache_name_entry *) hashtable_classcache.ptr[slot]; entry; entry = next) {
+                       next = entry->hashlink;
+                       classcache_free_name_entry(entry);
+               }
+       }
+
+       MFREE(hashtable_classcache.ptr, void*, hashtable_classcache.size);
+       hashtable_classcache.size = 0;
+       hashtable_classcache.entries = 0;
+       hashtable_classcache.ptr = NULL;
+}
+
+/* classcache_add_constraint ***************************************************
+   Add a loading constraint
+  
+   IN:
+       a................first initiating loader
+       b................second initiating loader
+       classname........class name
+  
+   RETURN VALUE:
+       true.............everything ok, the constraint has been added,
+       false............an exception has been thrown.
+   
+   Note: synchronized with global tablelock
+   
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+bool classcache_add_constraint(classloader_t * a,
+                                                          classloader_t * b,
+                                                          utf * classname)
+{
+       classcache_name_entry *en;
+       classcache_class_entry *clsenA;
+       classcache_class_entry *clsenB;
+
+       assert(classname);
+
+#ifdef CLASSCACHE_VERBOSE
+       log_start();
+       log_print("classcache_add_constraint(%p,%p,", (void *) a, (void *) b);
+       utf_fprint_printable_ascii_classname(stdout, classname);
+       log_print(")\n");
+       log_finish();
+#endif
+
+       /* a constraint with a == b is trivially satisfied */
+       if (a == b) {
+               CLASSCACHE_COUNT(stat_trivial_constraints);
+               return true;
+       }
+
+       CLASSCACHE_LOCK();
+
+       en = classcache_new_name(classname);
+
+       assert(en);
+       CLASSCACHE_COUNT(stat_nontriv_constraints);
+
+       /* find the entry loaded by / constrained to each loader */
+       clsenA = classcache_find_loader(en, a);
+       clsenB = classcache_find_loader(en, b);
+
+       if (clsenA && clsenB) {
+               /* { both loaders have corresponding entries } */
+               CLASSCACHE_COUNT(stat_nontriv_constraints_both);
+
+               /* if the entries are the same, the constraint is already recorded */
+               if (clsenA == clsenB)
+                       goto return_success;
+
+               /* check if the entries can be merged */
+               if (clsenA->classobj && clsenB->classobj
+                       && clsenA->classobj != clsenB->classobj) {
+                       /* no, the constraint is violated */
+                       exceptions_throw_linkageerror("loading constraint violated: ",
+                                                                                 clsenA->classobj);
+                       goto return_exception;
+               }
+
+               /* yes, merge the entries */
+               classcache_merge_class_entries(en,clsenA,clsenB);
+               CLASSCACHE_COUNT(stat_nontriv_constraints_merged);
+       }
+       else {
+               /* { at most one of the loaders has a corresponding entry } */
+
+               /* set clsenA to the single class entry we have */
+               if (!clsenA)
+                       clsenA = clsenB;
+
+               if (!clsenA) {
+                       /* { no loader has a corresponding entry } */
+                       CLASSCACHE_COUNT(stat_nontriv_constraints_none);
+
+                       /* create a new class entry with the constraint (a,b,en->name) */
+                       clsenA = NEW(classcache_class_entry);
+                       clsenA->classobj = NULL;
+                       clsenA->loaders = NULL;
+                       clsenA->constraints = classcache_new_loader_entry(b, NULL);
+                       clsenA->constraints = classcache_new_loader_entry(a, clsenA->constraints);
+
+                       clsenA->next = en->classes;
+                       en->classes = clsenA;
+               }
+               else {
+                       CLASSCACHE_COUNT(stat_nontriv_constraints_one);
+
+                       /* make b the loader that has no corresponding entry */
+                       if (clsenB)
+                               b = a;
+
+                       /* loader b must be added to entry clsenA */
+                       clsenA->constraints = classcache_new_loader_entry(b, clsenA->constraints);
+               }
+       }
+
+  return_success:
+       CLASSCACHE_UNLOCK();
+       return true;
+
+  return_exception:
+       CLASSCACHE_UNLOCK();
+       return false;                           /* exception */
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+/* classcache_add_constraints_for_params ***************************************
+   Add loading constraints for the parameters and return type of 
+   the given method.
+  
+   IN:
+       a................first initiating loader
+       b................second initiating loader
+       m................methodinfo 
+  
+   RETURN VALUE:
+       true.............everything ok, the constraints have been added,
+       false............an exception has been thrown.
+   
+   Note: synchronized with global tablelock
+   
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+bool classcache_add_constraints_for_params(classloader_t * a,
+                                                                                  classloader_t * b,
+                                                                                  methodinfo *m)
+{
+       methoddesc *md;
+       typedesc *td;
+       s4 i;
+
+       /* a constraint with a == b is trivially satisfied */
+
+       if (a == b) {
+               return true;
+       }
+
+       /* get the parsed descriptor */
+
+       assert(m);
+       md = m->parseddesc;
+       assert(md);
+
+       /* constrain the return type */
+
+       if (md->returntype.type == TYPE_ADR) {
+               if (!classcache_add_constraint(a, b, md->returntype.classref->name))
+                       return false; /* exception */
+       }
+
+       /* constrain each reference type used in the parameters */
+
+       td = md->paramtypes;
+       i = md->paramcount;
+       for (; i--; td++) {
+               if (td->type != TYPE_ADR)
+                       continue;
+
+               if (!classcache_add_constraint(a, b, td->classref->name))
+                       return false; /* exception */
+       }
+
+       /* everything ok */
+       return true;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+
+/* classcache_number_of_loaded_classes *****************************************
+
+   Counts the number of loaded classes and returns it.
+
+   Note: This function assumes that the CLASSCACHE_LOCK is held by the
+   caller!
+
+*******************************************************************************/
+
+static s4 classcache_number_of_loaded_classes(void)
+{
+       classcache_name_entry  *en;
+       classcache_class_entry *clsen;
+       s4                      number;
+       s4                      i;
+
+       /* initialize class counter */
+
+       number = 0;
+
+       for (i = 0; i < hashtable_classcache.size; i++) {
+               /* iterate over hashlink */
+
+               for (en = (classcache_name_entry*) hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) {
+                       /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */
+
+                       if (en->name->text[0] == '$')
+                               continue;
+
+                       /* iterate over classes with same name */
+
+                       for (clsen = en->classes; clsen != NULL; clsen = clsen->next) {
+                               /* get only loaded classes */
+
+                               if (clsen->classobj != NULL)
+                                       number++;
+                       }
+               }
+       }
+
+       return number;
+}
+
+
+/* classcache_get_loaded_class_count *******************************************
+
+   Counts the number of loaded classes and returns it.
+
+*******************************************************************************/
+
+s4 classcache_get_loaded_class_count(void)
+{
+       s4 count;
+
+       CLASSCACHE_LOCK();
+
+       count = classcache_number_of_loaded_classes();
+       
+       CLASSCACHE_UNLOCK();
+
+       return count;
+}
+
+
+/* classcache_get_loaded_classes ***********************************************
+
+   Returns an array of all loaded classes as array.  The array is
+   allocaed on the Java heap.
+
+*******************************************************************************/
+
+#if defined(ENABLE_JVMTI)
+void classcache_get_loaded_classes(s4 *class_count_ptr,
+                                                                  classinfo ***classes_ptr)
+{
+       classinfo              **classes;
+       s4                       class_count;
+       classcache_name_entry   *en;
+       classcache_class_entry  *clsen;
+       s4                       i;
+       s4                       j;
+
+       CLASSCACHE_LOCK();
+
+       /* get the number of loaded classes and allocate the array */
+
+       class_count = classcache_number_of_loaded_classes();
+
+       classes = GCMNEW(classinfo*, class_count);
+
+       /* look in every slot of the hashtable */
+
+       for (i = 0, j = 0; i < hashtable_classcache.size; i++) {
+               /* iterate over hashlink */
+
+               for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) {
+                       /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */
+
+                       if (en->name->text[0] == '$')
+                               continue;
+
+                       /* iterate over classes with same name */
+
+                       for (clsen = en->classes; clsen != NULL; clsen = clsen->next) {
+                               /* get only loaded classes */
+
+                               if (clsen->classobj != NULL) {
+                                       classes[j] = clsen->classobj;
+                                       j++;
+                               }
+                       }
+               }
+       }
+
+       /* pass the return values */
+
+       *class_count_ptr = class_count;
+       *classes_ptr     = classes;
+
+       CLASSCACHE_UNLOCK();
+}
+#endif /* defined(ENABLE_JVMTI) */
+
+
+/* classcache_foreach_loaded_class *********************************************
+
+   Calls the given function for each loaded class.
+
+*******************************************************************************/
+
+void classcache_foreach_loaded_class(classcache_foreach_functionptr_t func,
+                                                                        void *data)
+{
+       classcache_name_entry   *en;
+       classcache_class_entry  *clsen;
+       s4                       i;
+
+       CLASSCACHE_LOCK();
+
+       /* look in every slot of the hashtable */
+
+       for (i = 0; i < hashtable_classcache.size; i++) {
+               /* iterate over hashlink */
+
+               for (en = (classcache_name_entry*) hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) {
+                       /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */
+
+                       if (en->name->text[0] == '$')
+                               continue;
+
+                       /* iterate over classes with same name */
+
+                       for (clsen = en->classes; clsen != NULL; clsen = clsen->next) {
+                               /* get only loaded classes */
+
+                               if (clsen->classobj != NULL) {
+                                       (*func)(clsen->classobj, data);
+                               }
+                       }
+               }
+       }
+
+       CLASSCACHE_UNLOCK();
+}
+
+
+/*============================================================================*/
+/* DEBUG DUMPS                                                                */
+/*============================================================================*/
+
+/* classcache_debug_dump *******************************************************
+   Print the contents of the loaded class cache to a stream
+  
+   IN:
+       file.............output stream
+          only.............if != NULL, only print entries for this name
+                           (Currently we print also the rest of the hash chain to
+                                                get a feel for the average length of hash chains.)
+  
+   Note: synchronized with global tablelock
+   
+*******************************************************************************/
+
+#ifndef NDEBUG
+void classcache_debug_dump(FILE * file,utf *only)
+{
+       classcache_name_entry *c;
+       classcache_class_entry *clsen;
+       classcache_loader_entry *lden;
+       u4 slot;
+
+       CLASSCACHE_LOCK();
+
+       log_println("=== [loaded class cache] =====================================");
+       log_println("hash size   : %d", (int) hashtable_classcache.size);
+       log_println("hash entries: %d", (int) hashtable_classcache.entries);
+       log_println("");
+
+       if (only) {
+               c = classcache_lookup_name(only);
+               slot = 0; /* avoid compiler warning */
+               goto dump_it;
+       }
+
+       for (slot = 0; slot < hashtable_classcache.size; ++slot) {
+               c = (classcache_name_entry *) hashtable_classcache.ptr[slot];
+
+dump_it:
+               for (; c; c = c->hashlink) {
+                       utf_fprint_printable_ascii_classname(file, c->name);
+                       fprintf(file, "\n");
+
+                       /* iterate over all class entries */
+                       for (clsen = c->classes; clsen; clsen = clsen->next) {
+                               if (clsen->classobj) {
+                                       log_println("    loaded %p", (void *) clsen->classobj);
+                               }
+                               else {
+                                       log_println("    unresolved");
+                               }
+
+                               log_start();
+                               log_print("        loaders: ");
+                               for (lden = clsen->loaders; lden; lden = lden->next) {
+                                       log_print("<%p> %p ", (void *) lden, (void *) lden->loader);
+                               }
+                               log_finish();
+
+                               log_start();
+                               log_print("        constraints: ");
+                               for (lden = clsen->constraints; lden; lden = lden->next) {
+                                       log_print("<%p> %p ", (void *) lden, (void *) lden->loader);
+                               }
+                               log_finish();
+                       }
+               }
+
+               if (only)
+                       break;
+       }
+       fprintf(file, "\n==============================================================\n\n");
+
+       CLASSCACHE_UNLOCK();
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* NDEBUG */
+
+/*
+ * 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/classcache.hpp b/src/vm/classcache.hpp
new file mode 100644 (file)
index 0000000..aef65e2
--- /dev/null
@@ -0,0 +1,177 @@
+/* src/vm/classcache.hpp - loaded class cache and loading constraints
+
+   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 _CLASSCACHE_H
+#define _CLASSCACHE_H
+
+#include "config.h"
+
+#include "vm/types.h"
+
+#include <stdio.h>  /* for FILE */
+
+#include "toolbox/hashtable.h"
+
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/loader.hpp"
+#include "vm/references.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* forward declarations *******************************************************/
+
+typedef struct classcache_name_entry classcache_name_entry;
+typedef struct classcache_class_entry classcache_class_entry;
+typedef struct classcache_loader_entry classcache_loader_entry;
+
+/* global variables ***********************************************************/
+
+extern hashtable hashtable_classcache;
+
+
+/* structs ********************************************************************/
+
+/*----------------------------------------------------------------------------*/
+/* The Loaded Class Cache                                                     */
+/*                                                                            */
+/* The loaded class cache is implemented as a two-level data structure.       */
+/*                                                                            */
+/* The first level is a hash table indexed by class names. For each class     */
+/* name in the cache there is a classcache_name_entry, which collects all     */
+/* information about classes with this class name.                            */
+/*                                                                            */
+/* Second level: For each classcache_name_entry there is a list of            */
+/* classcache_class_entry:s representing the possible different resolutions   */
+/* of the class name.                                                         */
+/*                                                                            */
+/* A classcache_class_entry records the following:                            */
+/*                                                                            */
+/* - the loaded class object, if this entry has been resolved, otherwise NULL */
+/* - the list of initiating loaders which have resolved the class name to     */
+/*   this class object                                                        */
+/* - the list of initiating loaders which are constrained to resolve this     */
+/*   class name to this class object in the future                            */
+/*                                                                            */
+/* The classcache_class_entry:s approximate the equivalence classes created   */
+/* by the loading constraints and the equivalence of loaded classes.          */
+/*                                                                            */
+/* When a loading constraint (loaderA,loaderB,NAME) is added, then the        */
+/* classcache_class_entry:s for NAME containing loaderA and loaderB resp.     */
+/* must be merged into one entry. If this is impossible, because the entries  */
+/* have already been resolved to different class objects, then the constraint */
+/* is violated and an expception must be thrown.                              */
+/*----------------------------------------------------------------------------*/
+
+
+/* classcache_name_entry
+ *
+ * For each classname a classcache_name_entry struct is created.
+ */
+
+struct classcache_name_entry
+{
+       utf                     *name;        /* class name                       */
+       classcache_name_entry   *hashlink;    /* link for external chaining       */
+       classcache_class_entry  *classes;     /* equivalence classes for this name*/
+};
+
+struct classcache_class_entry
+{
+       classinfo               *classobj;    /* the loaded class object, or NULL */
+       classcache_loader_entry *loaders;
+       classcache_loader_entry *constraints;
+       classcache_class_entry  *next;        /* next class entry for same name   */
+};
+
+struct classcache_loader_entry
+{
+       classloader_t            *loader;     /* class loader object              */
+       classcache_loader_entry  *next;       /* next loader entry in the list    */
+};
+
+
+/* callback function type for  classcache_foreach_loaded_class */
+
+typedef void (*classcache_foreach_functionptr_t)(classinfo *, void *);
+
+
+/* function prototypes ********************************************************/
+
+/* initialize the loaded class cache */
+bool classcache_init(void);
+void classcache_free(void);
+
+classinfo * classcache_lookup(classloader_t *initloader,utf *classname);
+classinfo * classcache_lookup_defined(classloader_t *defloader,utf *classname);
+classinfo * classcache_lookup_defined_or_initiated(classloader_t *loader,utf *classname);
+
+bool classcache_store_unique(classinfo *cls);
+classinfo * classcache_store(classloader_t *initloader,classinfo *cls,bool mayfree);
+classinfo * classcache_store_defined(classinfo *cls);
+
+#if defined(ENABLE_VERIFIER)
+bool classcache_add_constraint(classloader_t *a,classloader_t *b,utf *classname);
+bool classcache_add_constraints_for_params(classloader_t *a,classloader_t *b,
+                                                                                  methodinfo *m);
+#endif
+
+s4 classcache_get_loaded_class_count(void);
+
+void classcache_foreach_loaded_class(classcache_foreach_functionptr_t func,
+                                                                        void *data);
+
+#if defined(ENABLE_JVMTI)
+void classcache_get_loaded_classes(s4 *class_count_ptr,
+                                                                  classinfo ***classes_ptr);
+#endif
+
+#ifndef NDEBUG
+void classcache_debug_dump(FILE *file,utf *only);
+#endif
+       
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CLASSCACHE_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/descriptor.c b/src/vm/descriptor.c
new file mode 100644 (file)
index 0000000..235154e
--- /dev/null
@@ -0,0 +1,1398 @@
+/* src/vm/descriptor.c - checking and parsing of field / method descriptors
+
+   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 "vm/types.h"
+
+#include "md-abi.h"
+
+#include "mm/memory.h"
+
+#include "vm/descriptor.h"
+#include "vm/exceptions.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/abi.h"
+
+
+/* constants (private to descriptor.c) ****************************************/
+
+/* initial number of entries for the classrefhash of a descriptor_pool */
+/* (currently the hash is never grown!) */
+#define CLASSREFHASH_INIT_SIZE  64
+
+/* initial number of entries for the descriptorhash of a descriptor_pool */
+/* (currently the hash is never grown!) */
+#define DESCRIPTORHASH_INIT_SIZE  128
+
+/* data structures (private to descriptor.c) **********************************/
+
+typedef struct classref_hash_entry classref_hash_entry;
+typedef struct descriptor_hash_entry descriptor_hash_entry;
+
+/* entry struct for the classrefhash of descriptor_pool */
+struct classref_hash_entry {
+       classref_hash_entry *hashlink;  /* for hash chaining            */
+       utf                 *name;      /* name of the class refered to */
+       u2                   index;     /* index into classref table    */
+};
+
+/* entry struct for the descriptorhash of descriptor_pool */
+struct descriptor_hash_entry {
+       descriptor_hash_entry *hashlink;
+       utf                   *desc;
+       parseddesc_t           parseddesc;
+       s2                     paramslots; /* number of params, LONG/DOUBLE counted as 2 */
+};
+
+
+/****************************************************************************/
+/* MACROS FOR DESCRIPTOR PARSING (private to descriptor.c)                  */
+/****************************************************************************/
+
+/* SKIP_FIELDDESCRIPTOR:
+ * utf_ptr must point to the first character of a field descriptor.
+ * After the macro call utf_ptr points to the first character after
+ * the field descriptor.
+ *
+ * CAUTION: This macro does not check for an unexpected end of the
+ * descriptor. Better use SKIP_FIELDDESCRIPTOR_SAFE.
+ */
+#define SKIP_FIELDDESCRIPTOR(utf_ptr)                                                  \
+       do { while (*(utf_ptr)=='[') (utf_ptr)++;                                       \
+               if (*(utf_ptr)++=='L')                                                                  \
+                       while(*(utf_ptr)++ != ';') /* skip */; } while(0)
+
+/* SKIP_FIELDDESCRIPTOR_SAFE:
+ * utf_ptr must point to the first character of a field descriptor.
+ * After the macro call utf_ptr points to the first character after
+ * the field descriptor.
+ *
+ * Input:
+ *     utf_ptr....points to first char of descriptor
+ *     end_ptr....points to first char after the end of the string
+ *     errorflag..must be initialized (to false) by the caller!
+ * Output:
+ *     utf_ptr....points to first char after the descriptor
+ *     errorflag..set to true if the string ended unexpectedly
+ */
+#define SKIP_FIELDDESCRIPTOR_SAFE(utf_ptr,end_ptr,errorflag)                   \
+       do { while ((utf_ptr) != (end_ptr) && *(utf_ptr)=='[') (utf_ptr)++;     \
+               if ((utf_ptr) == (end_ptr))                                                                             \
+                       (errorflag) = true;                                                                                     \
+               else                                                                                                                    \
+                       if (*(utf_ptr)++=='L') {                                                                        \
+                               while((utf_ptr) != (end_ptr) && *(utf_ptr)++ != ';')    \
+                                       /* skip */;                                                                                     \
+                               if ((utf_ptr)[-1] != ';')                                                               \
+                                       (errorflag) = true; }} while(0)
+
+
+/****************************************************************************/
+/* DEBUG HELPERS                                                            */
+/****************************************************************************/
+
+/*#define DESCRIPTOR_VERBOSE*/
+
+/****************************************************************************/
+/* FUNCTIONS                                                                */
+/****************************************************************************/
+
+/* descriptor_to_basic_type ****************************************************
+
+   Return the basic type to use for a value with this descriptor.
+
+   IN:
+       utf..............descriptor utf string
+
+   OUT:
+       A TYPE_* constant.
+
+   PRECONDITIONS:
+       This function assumes that the descriptor has passed 
+          descriptor_pool_add checks and that it does not start with '('.
+
+*******************************************************************************/
+
+int descriptor_to_basic_type(utf *descriptor)
+{
+       assert(descriptor->blength >= 1);
+       
+       switch (descriptor->text[0]) {
+       case 'Z':
+       case 'B':
+       case 'C':
+       case 'S':
+       case 'I':
+               return TYPE_INT;
+
+       case 'J':
+               return TYPE_LNG;
+
+       case 'F':
+               return TYPE_FLT;
+
+       case 'D':
+               return TYPE_DBL;
+
+       case 'L':
+       case '[':
+               return TYPE_ADR;
+
+       default:
+               vm_abort("descriptor_to_basic_type: invalid type %c",
+                                descriptor->text[0]);
+       }
+
+       /* keep the compiler happy */
+
+       return 0;
+}
+
+
+/* descriptor_typesize *********************************************************
+
+   Return the size in bytes needed for the given type.
+
+   IN:
+       td..............typedesc describing the type
+
+   OUT:
+       The number of bytes
+
+*******************************************************************************/
+
+int descriptor_typesize(typedesc *td)
+{
+       assert(td);
+
+       switch (td->type) {
+       case TYPE_INT:
+       case TYPE_FLT:
+               return 4;
+
+       case TYPE_LNG:
+       case TYPE_DBL:
+               return 8;
+
+       case TYPE_ADR:
+               return SIZEOF_VOID_P;
+
+       default:
+               vm_abort("descriptor_typesize: invalid type %d", td->type);
+       }
+
+       /* keep the compiler happy */
+
+       return 0;
+}
+
+
+/* name_from_descriptor ********************************************************
+
+   Return the class name indicated by the given descriptor
+   (Internally used helper function)
+
+   IN:
+       c................class containing the descriptor
+       utf_ptr..........first character of descriptor
+       end_ptr..........first character after the end of the string
+       mode.............a combination (binary or) of the following flags:
+
+               (Flags marked with * are the default settings.)
+
+               How to handle "V" descriptors:
+
+                            * DESCRIPTOR_VOID.....handle it like other primitive types
+                   DESCRIPTOR_NOVOID...treat it as an error
+
+               How to deal with extra characters after the end of the
+               descriptor:
+
+                            * DESCRIPTOR_NOCHECKEND...ignore (useful for parameter lists)
+                   DESCRIPTOR_CHECKEND.....treat them as an error
+
+   OUT:
+       *next............if non-NULL, *next is set to the first character after
+                        the descriptor. (Undefined if an error occurs.)
+       *name............set to the utf name of the class
+
+   RETURN VALUE:
+       true.............descriptor parsed successfully
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+#define DESCRIPTOR_VOID          0      /* default */
+#define DESCRIPTOR_NOVOID        0x0040
+#define DESCRIPTOR_NOCHECKEND    0      /* default */
+#define DESCRIPTOR_CHECKEND      0x1000
+
+static bool 
+name_from_descriptor(classinfo *c,
+                                        char *utf_ptr, char *end_ptr,
+                                        char **next, int mode, utf **name)
+{
+       char *start = utf_ptr;
+       bool error = false;
+
+       assert(c);
+       assert(utf_ptr);
+       assert(end_ptr);
+       assert(name);
+       
+       *name = NULL;           
+       SKIP_FIELDDESCRIPTOR_SAFE(utf_ptr, end_ptr, error);
+
+       if (mode & DESCRIPTOR_CHECKEND)
+               error |= (utf_ptr != end_ptr);
+       
+       if (!error) {
+               if (next) *next = utf_ptr;
+               
+               switch (*start) {
+                 case 'V':
+                         if (mode & DESCRIPTOR_NOVOID)
+                                 break;
+                         /* FALLTHROUGH! */
+                 case 'I':
+                 case 'J':
+                 case 'F':
+                 case 'D':
+                 case 'B':
+                 case 'C':
+                 case 'S':
+                 case 'Z':
+                         return true;
+                         
+                 case 'L':
+                         start++;
+                         utf_ptr--;
+                         /* FALLTHROUGH! */
+                 case '[':
+                         *name = utf_new(start, utf_ptr - start);
+                         return true;
+               }
+       }
+
+       exceptions_throw_classformaterror(c, "Invalid descriptor");
+       return false;
+}
+
+
+/* descriptor_to_typedesc ******************************************************
+   Parse the given type descriptor and fill a typedesc struct
+   (Internally used helper function)
+
+   IN:
+       pool.............the descriptor pool
+          utf_ptr..........points to first character of type descriptor
+          end_pos..........points after last character of the whole descriptor
+
+   OUT:
+       *next............set to next character after type descriptor
+          *d...............filled with parsed information
+
+   RETURN VALUE:
+       true.............parsing succeeded  
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+static bool
+descriptor_to_typedesc(descriptor_pool *pool, char *utf_ptr, char *end_pos,
+                                          char **next, typedesc *td)
+{
+       utf *name;
+       
+       if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, next, 0, &name))
+               return false;
+
+       if (name) {
+               /* a reference type */
+               td->type = TYPE_ADR;
+               td->primitivetype = TYPE_ADR;
+               td->arraydim = 0;
+               for (utf_ptr = name->text; *utf_ptr == '['; ++utf_ptr)
+                       td->arraydim++;
+               td->classref = descriptor_pool_lookup_classref(pool, name);
+
+       } else {
+               /* a primitive type */
+               switch (*utf_ptr) {
+               case 'B': 
+                       td->primitivetype = PRIMITIVETYPE_BYTE;
+                       td->type = TYPE_INT;
+                       break;
+               case 'C':
+                       td->primitivetype = PRIMITIVETYPE_CHAR;
+                       td->type = TYPE_INT;
+                       break;
+               case 'S':  
+                       td->primitivetype = PRIMITIVETYPE_SHORT;
+                       td->type = TYPE_INT;
+                       break;
+               case 'Z':
+                       td->primitivetype = PRIMITIVETYPE_BOOLEAN;
+                       td->type = TYPE_INT;
+                       break;
+               case 'I':
+                       td->primitivetype = PRIMITIVETYPE_INT;
+                       td->type = TYPE_INT;
+                       break;
+               case 'D':
+                       td->primitivetype = PRIMITIVETYPE_DOUBLE;
+                       td->type = TYPE_DBL;
+                       break;
+               case 'F':
+                       td->primitivetype = PRIMITIVETYPE_FLOAT;
+                       td->type = TYPE_FLT;
+                       break;
+               case 'J':
+                       td->primitivetype = PRIMITIVETYPE_LONG;
+                       td->type = TYPE_LNG;
+                       break;
+               case 'V':
+                       td->primitivetype = PRIMITIVETYPE_VOID;
+                       td->type = TYPE_VOID;
+                       break;
+               default:
+                       assert(false);
+               }
+
+               td->arraydim = 0;
+               td->classref = NULL;
+       }
+
+       return true;
+}
+
+
+/* descriptor_pool_new *********************************************************
+   Allocate a new descriptor_pool
+
+   IN:
+       referer..........class for which to create the pool
+
+   RETURN VALUE:
+       a pointer to the new descriptor_pool
+
+*******************************************************************************/
+
+descriptor_pool * 
+descriptor_pool_new(classinfo *referer)
+{
+       descriptor_pool *pool;
+       u4 hashsize;
+       u4 slot;
+
+       pool = DNEW(descriptor_pool);
+       assert(pool);
+
+       pool->referer = referer;
+       pool->fieldcount = 0;
+       pool->methodcount = 0;
+       pool->paramcount = 0;
+       pool->descriptorsize = 0;
+       pool->descriptors = NULL;
+       pool->descriptors_next = NULL;
+       pool->classrefs = NULL;
+       pool->descriptor_kind = NULL;
+       pool->descriptor_kind_next = NULL;
+
+       hashsize = CLASSREFHASH_INIT_SIZE;
+       pool->classrefhash.size = hashsize;
+       pool->classrefhash.entries = 0;
+       pool->classrefhash.ptr = DMNEW(void*, hashsize);
+       for (slot=0; slot<hashsize; ++slot)
+               pool->classrefhash.ptr[slot] = NULL;
+
+       hashsize = DESCRIPTORHASH_INIT_SIZE;
+       pool->descriptorhash.size = hashsize;
+       pool->descriptorhash.entries = 0;
+       pool->descriptorhash.ptr = DMNEW(void*, hashsize);
+       for (slot=0; slot<hashsize; ++slot)
+               pool->descriptorhash.ptr[slot] = NULL;
+
+       return pool;
+}
+
+
+/* descriptor_pool_add_class ***************************************************
+   Add the given class reference to the pool
+
+   IN:
+       pool.............the descriptor_pool
+          name.............the class reference to add
+
+   RETURN VALUE:
+       true.............reference has been added
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+bool 
+descriptor_pool_add_class(descriptor_pool *pool, utf *name)
+{
+       u4 key,slot;
+       classref_hash_entry *c;
+       
+       assert(pool);
+       assert(name);
+
+#ifdef DESCRIPTOR_VERBOSE
+       fprintf(stderr,"descriptor_pool_add_class(%p,",(void*)pool);
+       utf_fprint_printable_ascii(stderr,name);fprintf(stderr,")\n");
+#endif
+
+       /* find a place in the hashtable */
+
+       key = utf_hashkey(name->text, name->blength);
+       slot = key & (pool->classrefhash.size - 1);
+       c = (classref_hash_entry *) pool->classrefhash.ptr[slot];
+
+       while (c) {
+               if (c->name == name)
+                       return true; /* already stored */
+               c = c->hashlink;
+       }
+
+       /* check if the name is a valid classname */
+
+       if (!is_valid_name(name->text,UTF_END(name))) {
+               exceptions_throw_classformaterror(pool->referer, "Invalid class name");
+               return false; /* exception */
+       }
+
+       /* XXX check maximum array dimension */
+       
+       c = DNEW(classref_hash_entry);
+       c->name = name;
+       c->index = pool->classrefhash.entries++;
+       c->hashlink = (classref_hash_entry *) pool->classrefhash.ptr[slot];
+       pool->classrefhash.ptr[slot] = c;
+
+       return true;
+}
+
+
+/* descriptor_pool_add *********************************************************
+   Check the given descriptor and add it to the pool
+
+   IN:
+       pool.............the descriptor_pool
+          desc.............the descriptor to add. Maybe a field or method desc.
+
+   OUT:
+       *paramslots......if non-NULL, set to the number of parameters.
+                           LONG and DOUBLE are counted twice
+
+   RETURN VALUE:
+       true.............descriptor has been added
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+bool 
+descriptor_pool_add(descriptor_pool *pool, utf *desc, int *paramslots)
+{
+       u4 key,slot;
+       descriptor_hash_entry *d;
+       char *utf_ptr;
+       char *end_pos;
+       utf *name;
+       s4 argcount = 0;
+       
+#ifdef DESCRIPTOR_VERBOSE
+       fprintf(stderr,"descriptor_pool_add(%p,",(void*)pool);
+       utf_fprint_printable_ascii(stderr,desc);fprintf(stderr,")\n");
+#endif
+
+       assert(pool);
+       assert(desc);
+
+       /* find a place in the hashtable */
+
+       key = utf_hashkey(desc->text, desc->blength);
+       slot = key & (pool->descriptorhash.size - 1);
+       d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot];
+
+       /* Save all method descriptors in the hashtable, since the parsed         */
+       /* descriptor may vary between differenf methods (static vs. non-static). */
+
+       utf_ptr = desc->text;
+
+       if (*utf_ptr != '(') {
+               while (d) {
+                       if (d->desc == desc) {
+                               if (paramslots)
+                                       *paramslots = d->paramslots;
+                               return true; /* already stored */
+                       }
+                       d = d->hashlink;
+               }
+       }
+
+       /* add the descriptor to the pool */
+
+       d = DNEW(descriptor_hash_entry);
+       d->desc = desc;
+       d->parseddesc.any = NULL;
+       d->hashlink = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot];
+       pool->descriptorhash.ptr[slot] = d;
+
+       /* now check the descriptor */
+
+       end_pos = UTF_END(desc);
+       
+       if (*utf_ptr == '(') {
+               /* a method descriptor */
+
+               pool->methodcount++;
+               utf_ptr++;
+
+               /* check arguments */
+
+               while ((utf_ptr != end_pos) && (*utf_ptr != ')')) {
+                       pool->paramcount++;
+
+                       /* We cannot count the `this' argument here because
+                        * we don't know if the method is static. */
+
+                       if (*utf_ptr == 'J' || *utf_ptr == 'D')
+                               argcount += 2;
+                       else
+                               argcount++;
+
+                       if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, &utf_ptr,
+                                                                     DESCRIPTOR_NOVOID, &name))
+                               return false;
+
+                       if (name)
+                               if (!descriptor_pool_add_class(pool, name))
+                                       return false;
+               }
+
+               if (utf_ptr == end_pos) {
+                       exceptions_throw_classformaterror(pool->referer,
+                                                                                         "Missing ')' in method descriptor");
+                       return false;
+               }
+
+               utf_ptr++; /* skip ')' */
+
+               if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, NULL,
+                                                                 DESCRIPTOR_CHECKEND, &name))
+                       return false;
+
+               if (name)
+                       if (!descriptor_pool_add_class(pool,name))
+                               return false;
+
+               if (argcount > 255) {
+                       exceptions_throw_classformaterror(pool->referer,
+                                                                                         "Too many arguments in signature");
+                       return false;
+               }
+
+       } else {
+               /* a field descriptor */
+
+               pool->fieldcount++;
+               
+           if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, NULL,
+                                                         DESCRIPTOR_NOVOID | DESCRIPTOR_CHECKEND,
+                                                                 &name))
+                       return false;
+
+               if (name)
+                       if (!descriptor_pool_add_class(pool,name))
+                               return false;
+       }
+
+       d->paramslots = argcount;
+
+       if (paramslots)
+               *paramslots = argcount;
+
+       return true;
+}
+
+
+/* descriptor_pool_create_classrefs ********************************************
+   Create a table containing all the classrefs which were added to the pool
+
+   IN:
+       pool.............the descriptor_pool
+
+   OUT:
+       *count...........if count is non-NULL, this is set to the number
+                           of classrefs in the table
+
+   RETURN VALUE:
+       a pointer to the constant_classref table
+
+*******************************************************************************/
+
+constant_classref * 
+descriptor_pool_create_classrefs(descriptor_pool *pool, s4 *count)
+{
+       u4 nclasses;
+       u4 slot;
+       classref_hash_entry *c;
+       constant_classref *ref;
+       
+       assert(pool);
+
+       nclasses = pool->classrefhash.entries;
+       pool->classrefs = MNEW(constant_classref,nclasses);
+
+       /* fill the constant_classref structs */
+
+       for (slot = 0; slot < pool->classrefhash.size; ++slot) {
+               c = (classref_hash_entry *) pool->classrefhash.ptr[slot];
+               while (c) {
+                       ref = pool->classrefs + c->index;
+                       CLASSREF_INIT(*ref, pool->referer, c->name);
+                       c = c->hashlink;
+               }
+       }
+
+       if (count)
+               *count = nclasses;
+
+       return pool->classrefs;
+}
+
+
+/* descriptor_pool_lookup_classref *********************************************
+   Return the constant_classref for the given class name
+
+   IN:
+       pool.............the descriptor_pool
+          classname........name of the class to look up
+
+   RETURN VALUE:
+       a pointer to the constant_classref, or
+          NULL if an exception has been thrown
+
+*******************************************************************************/
+
+constant_classref * 
+descriptor_pool_lookup_classref(descriptor_pool *pool, utf *classname)
+{
+       u4 key,slot;
+       classref_hash_entry *c;
+
+       assert(pool);
+       assert(pool->classrefs);
+       assert(classname);
+
+       key = utf_hashkey(classname->text, classname->blength);
+       slot = key & (pool->classrefhash.size - 1);
+       c = (classref_hash_entry *) pool->classrefhash.ptr[slot];
+
+       while (c) {
+               if (c->name == classname)
+                       return pool->classrefs + c->index;
+               c = c->hashlink;
+       }
+
+       exceptions_throw_internalerror("Class reference not found in descriptor pool");
+       return NULL;
+}
+
+
+/* descriptor_pool_alloc_parsed_descriptors ************************************
+   Allocate space for the parsed descriptors
+
+   IN:
+       pool.............the descriptor_pool
+
+   NOTE:
+       This function must be called after all descriptors have been added
+          with descriptor_pool_add.
+
+*******************************************************************************/
+
+void 
+descriptor_pool_alloc_parsed_descriptors(descriptor_pool *pool)
+{
+       u4 size;
+       
+       assert(pool);
+
+       /* TWISTI: paramcount + 1: we don't know if the method is static or   */
+       /* not, i have no better solution yet.                                */
+
+       size =
+               pool->fieldcount * sizeof(typedesc) +
+               pool->methodcount * (sizeof(methoddesc) - sizeof(typedesc)) +
+               pool->paramcount * sizeof(typedesc) +
+               pool->methodcount * sizeof(typedesc);      /* possible `this' pointer */
+
+       pool->descriptorsize = size;
+       if (size) {
+               pool->descriptors = MNEW(u1, size);
+               pool->descriptors_next = pool->descriptors;
+       }
+
+       size = pool->fieldcount + pool->methodcount;
+       if (size) {
+               pool->descriptor_kind = DMNEW(u1, size);
+               pool->descriptor_kind_next = pool->descriptor_kind;
+       }
+}
+
+
+/* descriptor_pool_parse_field_descriptor **************************************
+   Parse the given field descriptor
+
+   IN:
+       pool.............the descriptor_pool
+          desc.............the field descriptor
+
+   RETURN VALUE:
+       a pointer to the parsed field descriptor, or
+          NULL if an exception has been thrown
+
+   NOTE:
+       descriptor_pool_alloc_parsed_descriptors must be called (once)
+       before this function is used.
+
+*******************************************************************************/
+
+typedesc * 
+descriptor_pool_parse_field_descriptor(descriptor_pool *pool, utf *desc)
+{
+       u4 key,slot;
+       descriptor_hash_entry *d;
+       typedesc *td;
+
+       assert(pool);
+       assert(pool->descriptors);
+       assert(pool->descriptors_next);
+
+       /* lookup the descriptor in the hashtable */
+
+       key = utf_hashkey(desc->text, desc->blength);
+       slot = key & (pool->descriptorhash.size - 1);
+       d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot];
+
+       while (d) {
+               if (d->desc == desc) {
+                       /* found */
+                       if (d->parseddesc.fd)
+                               return d->parseddesc.fd;
+                       break;
+               }
+               d = d->hashlink;
+       }
+
+       assert(d);
+       
+       if (desc->text[0] == '(') {
+               exceptions_throw_classformaterror(pool->referer,
+                                                                                 "Method descriptor used in field reference");
+               return NULL;
+       }
+
+       td = (typedesc *) pool->descriptors_next;
+       pool->descriptors_next += sizeof(typedesc);
+       
+       if (!descriptor_to_typedesc(pool, desc->text, UTF_END(desc), NULL, td))
+               return NULL;
+
+       *(pool->descriptor_kind_next++) = 'f';
+
+       d->parseddesc.fd = td;
+
+       return td;
+}
+
+
+/* descriptor_pool_parse_method_descriptor *************************************
+   Parse the given method descriptor
+
+   IN:
+       pool.............the descriptor_pool
+       desc.............the method descriptor
+       mflags...........the method flags
+          thisclass........classref to the class containing the method.
+                                               This is ignored if mflags contains ACC_STATIC.
+                                               The classref is stored for inserting the 'this' argument.
+
+   RETURN VALUE:
+       a pointer to the parsed method descriptor, or
+          NULL if an exception has been thrown
+
+   NOTE: 
+       descriptor_pool_alloc_parsed_descriptors must be called
+       (once) before this function is used.
+
+*******************************************************************************/
+
+methoddesc * 
+descriptor_pool_parse_method_descriptor(descriptor_pool *pool, utf *desc,
+                                                                               s4 mflags,constant_classref *thisclass)
+{
+       u4 key, slot;
+       descriptor_hash_entry *d;
+       methoddesc            *md;
+       typedesc              *td;
+       char *utf_ptr;
+       char *end_pos;
+       s2 paramcount = 0;
+       s2 paramslots = 0;
+
+#ifdef DESCRIPTOR_VERBOSE
+       fprintf(stderr,"descriptor_pool_parse_method_descriptor(%p,%d,%p,",
+                       (void*)pool,(int)mflags,(void*)thisclass);
+       utf_fprint_printable_ascii(stderr,desc); fprintf(stderr,")\n");
+#endif
+
+       assert(pool);
+       assert(pool->descriptors);
+       assert(pool->descriptors_next);
+
+       /* check that it is a method descriptor */
+       
+       if (desc->text[0] != '(') {
+               exceptions_throw_classformaterror(pool->referer,
+                                                                                 "Field descriptor used in method reference");
+               return NULL;
+       }
+
+       /* lookup the descriptor in the hashtable */
+
+       key = utf_hashkey(desc->text, desc->blength);
+       slot = key & (pool->descriptorhash.size - 1);
+       d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot];
+
+       /* find an un-parsed descriptor */
+
+       while (d) {
+               if (d->desc == desc)
+                       if (!d->parseddesc.md)
+                               break;
+               d = d->hashlink;
+       }
+
+       assert(d);
+
+       md = (methoddesc *) pool->descriptors_next;
+       pool->descriptors_next += sizeof(methoddesc) - sizeof(typedesc);
+
+       utf_ptr = desc->text + 1; /* skip '(' */
+       end_pos = UTF_END(desc);
+
+       td = md->paramtypes;
+
+       /* count the `this' pointer */
+
+       if ((mflags != ACC_UNDEF) && !(mflags & ACC_STATIC)) {
+               td->type = TYPE_ADR;
+               td->primitivetype = TYPE_ADR;
+               td->arraydim = 0;
+               td->classref = thisclass;
+
+               td++;
+               pool->descriptors_next += sizeof(typedesc);
+               paramcount++;
+               paramslots++;
+       }
+
+       while (*utf_ptr != ')') {
+               /* parse a parameter type */
+
+               if (!descriptor_to_typedesc(pool, utf_ptr, end_pos, &utf_ptr, td))
+                       return NULL;
+
+               if (IS_2_WORD_TYPE(td->type))
+                       paramslots++;
+               
+               td++;
+               pool->descriptors_next += sizeof(typedesc);
+               paramcount++;
+               paramslots++;
+       }
+       utf_ptr++; /* skip ')' */
+
+       /* Skip possible `this' pointer in paramtypes array to allow a possible   */
+       /* memory move later in parse.                                            */
+       /* We store the thisclass reference, so we can later correctly fill in    */
+       /* the parameter slot of the 'this' argument.                             */
+
+       if (mflags == ACC_UNDEF) {
+               td->classref = thisclass;
+               td++;
+               pool->descriptors_next += sizeof(typedesc);
+       }
+
+       /* parse return type */
+
+       if (!descriptor_to_typedesc(pool, utf_ptr, end_pos, NULL,
+                                                               &(md->returntype)))
+               return NULL;
+
+       md->paramcount = paramcount;
+       md->paramslots = paramslots;
+
+       /* If mflags != ACC_UNDEF we parse a real loaded method, so do
+          param prealloc.  Otherwise we do this in stack analysis. */
+
+       if (mflags != ACC_UNDEF) {
+               if (md->paramcount > 0) {
+                       /* allocate memory for params */
+
+                       md->params = MNEW(paramdesc, md->paramcount);
+               }
+               else {
+                       md->params = METHODDESC_NOPARAMS;
+               }
+
+               /* fill the paramdesc */
+               /* md_param_alloc has to be called if md->paramcount == 0,
+                  too, so it can make the reservation for the Linkage Area,
+                  Return Register... */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+               if (!opt_intrp)
+# endif
+                       {
+                               /* As builtin-functions are native functions, we have
+                                  to pre-allocate for the native ABI. */
+
+                               if (mflags & ACC_METHOD_BUILTIN)
+                                       md_param_alloc_native(md);
+                               else
+                                       md_param_alloc(md);
+                       }
+#endif
+       }
+       else {
+               /* params will be allocated later by
+                  descriptor_params_from_paramtypes if necessary */
+
+               md->params = NULL;
+       }
+
+       *(pool->descriptor_kind_next++) = 'm';
+
+       d->parseddesc.md = md;
+
+       return md;
+}
+
+/* descriptor_params_from_paramtypes *******************************************
+   Create the paramdescs for a method descriptor. This function is called
+   when we know whether the method is static or not. This function may only
+   be called once for each methoddesc, and only if md->params == NULL.
+
+   IN:
+       md...............the parsed method descriptor
+                           md->params MUST be NULL.
+          mflags...........the ACC_* access flags of the method. Only the
+                           ACC_STATIC bit is checked.
+                                               The value ACC_UNDEF is NOT allowed.
+
+   RETURN VALUE:
+       true.............the paramdescs were created successfully
+          false............an exception has been thrown
+
+   POSTCONDITION:
+       md->parms != NULL
+
+*******************************************************************************/
+
+bool descriptor_params_from_paramtypes(methoddesc *md, s4 mflags)
+{
+       typedesc *td;
+
+       assert(md);
+       assert(md->params == NULL);
+       assert(mflags != ACC_UNDEF);
+
+       td = md->paramtypes;
+
+       /* check for `this' pointer */
+
+       if (!(mflags & ACC_STATIC)) {
+               constant_classref *thisclass;
+
+               /* fetch class reference from reserved param slot */
+               thisclass = td[md->paramcount].classref;
+               assert(thisclass);
+
+               if (md->paramcount > 0) {
+                       /* shift param types by 1 argument */
+                       MMOVE(td + 1, td, typedesc, md->paramcount);
+               }
+
+               /* fill in first argument `this' */
+
+               td->type = TYPE_ADR;
+               td->primitivetype = TYPE_ADR;
+               td->arraydim = 0;
+               td->classref = thisclass;
+
+               md->paramcount++;
+               md->paramslots++;
+       }
+
+       /* if the method has params, process them */
+
+       if (md->paramcount > 0) {
+               /* allocate memory for params */
+
+               md->params = MNEW(paramdesc, md->paramcount);
+
+       } else {
+               md->params = METHODDESC_NOPARAMS;
+       }
+
+       /* fill the paramdesc */
+       /* md_param_alloc has to be called if md->paramcount == 0, too, so
+          it can make the reservation for the Linkage Area, Return
+          Register.. */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (!opt_intrp)
+# endif
+               {
+                       /* As builtin-functions are native functions, we have to
+                          pre-allocate for the native ABI. */
+
+                       if (mflags & ACC_METHOD_BUILTIN)
+                               md_param_alloc_native(md);
+                       else
+                               md_param_alloc(md);
+               }
+#endif
+
+       return true;
+}
+
+
+/* descriptor_pool_get_parsed_descriptors **************************************
+   Return a pointer to the block of parsed descriptors
+
+   IN:
+       pool.............the descriptor_pool
+
+   OUT:
+          *size............if size is non-NULL, this is set to the size of the
+                           parsed descriptor block (in u1)
+
+   RETURN VALUE:
+       a pointer to the block of parsed descriptors
+
+   NOTE:
+       descriptor_pool_alloc_parsed_descriptors must be called (once)
+       before this function is used.
+
+*******************************************************************************/
+
+void * 
+descriptor_pool_get_parsed_descriptors(descriptor_pool *pool, s4 *size)
+{
+       assert(pool);
+       assert((!pool->fieldcount && !pool->methodcount) || pool->descriptors);
+       
+       if (size)
+               *size = pool->descriptorsize;
+
+       return pool->descriptors;
+}
+
+
+/* descriptor_pool_get_sizes ***************************************************
+   Get the sizes of the class reference table and the parsed descriptors
+
+   IN:
+       pool.............the descriptor_pool
+
+   OUT:
+       *classrefsize....set to size of the class reference table
+          *descsize........set to size of the parsed descriptors
+
+   NOTE:
+       This function may only be called after both
+              descriptor_pool_create_classrefs, and
+                  descriptor_pool_alloc_parsed_descriptors
+          have been called.
+
+*******************************************************************************/
+
+void 
+descriptor_pool_get_sizes(descriptor_pool *pool, u4 *classrefsize, u4 *descsize)
+{
+       assert(pool);
+       assert((!pool->fieldcount && !pool->methodcount) || pool->descriptors);
+       assert(pool->classrefs);
+       assert(classrefsize);
+       assert(descsize);
+
+       *classrefsize = pool->classrefhash.entries * sizeof(constant_classref);
+       *descsize = pool->descriptorsize;
+}
+
+
+/****************************************************************************/
+/* DEBUG HELPERS                                                            */
+/****************************************************************************/
+
+#ifndef NDEBUG
+/* descriptor_debug_print_typedesc *********************************************
+   Print the given typedesc to the given stream
+
+   IN:
+          file.............stream to print to
+          d................the parsed descriptor
+
+*******************************************************************************/
+
+void 
+descriptor_debug_print_typedesc(FILE *file,typedesc *d)
+{
+       int ch;
+
+       if (!d) {
+               fprintf(file,"(typedesc *)NULL");
+               return;
+       }
+       
+       if (d->type == TYPE_ADR) {
+               if (d->classref)
+                       utf_fprint_printable_ascii(file,d->classref->name);
+               else
+                       fprintf(file,"<class=NULL>");
+       }
+       else {
+               switch (d->primitivetype) {
+                       case PRIMITIVETYPE_INT    : ch='I'; break;
+                       case PRIMITIVETYPE_CHAR   : ch='C'; break;
+                       case PRIMITIVETYPE_BYTE   : ch='B'; break;
+                       case PRIMITIVETYPE_SHORT  : ch='S'; break;
+                       case PRIMITIVETYPE_BOOLEAN: ch='Z'; break;
+                       case PRIMITIVETYPE_LONG   : ch='J'; break;
+                       case PRIMITIVETYPE_FLOAT  : ch='F'; break;
+                       case PRIMITIVETYPE_DOUBLE : ch='D'; break;
+                       case PRIMITIVETYPE_VOID   : ch='V'; break;
+                       default                   : ch='!';
+               }
+               fputc(ch,file);
+       }
+       if (d->arraydim)
+               fprintf(file,"[%d]",d->arraydim);
+}
+
+/* descriptor_debug_print_paramdesc ********************************************
+   Print the given paramdesc to the given stream
+
+   IN:
+          file.............stream to print to
+          d................the parameter descriptor
+
+*******************************************************************************/
+
+void
+descriptor_debug_print_paramdesc(FILE *file,paramdesc *d)
+{
+       if (!d) {
+               fprintf(file,"(paramdesc *)NULL");
+               return;
+       }
+       
+       if (d->inmemory) {
+               fprintf(file,"<m%d>",d->regoff);
+       }
+       else {
+               fprintf(file,"<r%d>",d->regoff);
+       }
+}
+
+/* descriptor_debug_print_methoddesc *******************************************
+   Print the given methoddesc to the given stream
+
+   IN:
+          file.............stream to print to
+          d................the parsed descriptor
+
+*******************************************************************************/
+
+void 
+descriptor_debug_print_methoddesc(FILE *file,methoddesc *d)
+{
+       int i;
+       
+       if (!d) {
+               fprintf(file,"(methoddesc *)NULL");
+               return;
+       }
+       
+       fputc('(',file);
+       for (i=0; i<d->paramcount; ++i) {
+               if (i)
+                       fputc(',',file);
+               descriptor_debug_print_typedesc(file,d->paramtypes + i);
+               if (d->params) {
+                       descriptor_debug_print_paramdesc(file,d->params + i);
+               }
+       }
+       if (d->params == METHODDESC_NOPARAMS)
+               fputs("<NOPARAMS>",file);
+       fputc(')',file);
+       descriptor_debug_print_typedesc(file,&(d->returntype));
+}
+
+/* descriptor_pool_debug_dump **************************************************
+   Print the state of the descriptor_pool to the given stream
+
+   IN:
+       pool.............the descriptor_pool
+          file.............stream to print to
+
+*******************************************************************************/
+
+void 
+descriptor_pool_debug_dump(descriptor_pool *pool,FILE *file)
+{
+       u4 slot;
+       u1 *pos;
+       u1 *kind;
+       u4 size;
+       
+       fprintf(file,"======[descriptor_pool for ");
+       utf_fprint_printable_ascii(file,pool->referer->name);
+       fprintf(file,"]======\n");
+
+       fprintf(file,"fieldcount:     %d\n",pool->fieldcount);
+       fprintf(file,"methodcount:    %d\n",pool->methodcount);
+       fprintf(file,"paramcount:     %d\n",pool->paramcount);
+       fprintf(file,"classrefcount:  %d\n",pool->classrefhash.entries);
+       fprintf(file,"descriptorsize: %d bytes\n",pool->descriptorsize);
+       fprintf(file,"classrefsize:   %d bytes\n",
+                       (int)(pool->classrefhash.entries * sizeof(constant_classref)));
+
+       fprintf(file,"class references:\n");
+       for (slot=0; slot<pool->classrefhash.size; ++slot) {
+               classref_hash_entry *c = (classref_hash_entry *) pool->classrefhash.ptr[slot];
+               while (c) {
+                       fprintf(file,"    %4d: ",c->index);
+                       utf_fprint_printable_ascii(file,c->name);
+                       fprintf(file,"\n");
+                       c = c->hashlink;
+               }
+       }
+
+       fprintf(file,"hashed descriptors:\n");
+       for (slot=0; slot<pool->descriptorhash.size; ++slot) {
+               descriptor_hash_entry *c = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot];
+               while (c) {
+                       fprintf(file,"    %p: ",c->parseddesc.any);
+                       utf_fprint_printable_ascii(file,c->desc);
+                       fprintf(file,"\n");
+                       c = c->hashlink;
+               }
+       }
+
+       fprintf(file,"descriptors:\n");
+       if (pool->descriptors) {
+               pos = pool->descriptors;
+               size = pool->descriptors_next - pool->descriptors;
+               fprintf(file,"    size: %d bytes\n",size);
+               
+               if (pool->descriptor_kind) {
+                       kind = pool->descriptor_kind;
+
+                       while (pos < (pool->descriptors + size)) {
+                               fprintf(file,"    %p: ",pos);
+                               switch (*kind++) {
+                                       case 'f':
+                                               descriptor_debug_print_typedesc(file,(typedesc*)pos);
+                                               pos += sizeof(typedesc);
+                                               break;
+                                       case 'm':
+                                               descriptor_debug_print_methoddesc(file,(methoddesc*)pos);
+                                               pos += ((methoddesc*)pos)->paramcount * sizeof(typedesc);
+                                               pos += sizeof(methoddesc) - sizeof(typedesc);
+                                               break;
+                                       default:
+                                               fprintf(file,"INVALID KIND");
+                               }
+                               fputc('\n',file);
+                       }
+               }
+               else {
+                       while (size >= sizeof(void*)) {
+                               fprintf(file,"    %p\n",*((void**)pos));
+                               pos += sizeof(void*);
+                               size -= sizeof(void*);
+                       }
+               }
+       }
+
+       fprintf(file,"==========================================================\n");
+}
+#endif /* !defined(NDEBUG) */
+
+/*
+ * 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/descriptor.h b/src/vm/descriptor.h
new file mode 100644 (file)
index 0000000..bf6c69e
--- /dev/null
@@ -0,0 +1,208 @@
+/* src/vm/descriptor.h - checking and parsing of field / method descriptors
+
+   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 _DESCRIPTOR_H
+#define _DESCRIPTOR_H
+
+/* forward typedefs ***********************************************************/
+
+typedef struct descriptor_pool descriptor_pool;
+typedef struct typedesc        typedesc;
+typedef struct paramdesc       paramdesc;
+typedef struct methoddesc      methoddesc;
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/types.h"
+
+#include "toolbox/hashtable.h"
+
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/method.hpp"
+#include "vm/references.h"
+#include "vm/utf8.h"
+
+#include "arch.h"              /* needed for HAS_ADDRESS_REGISTER_FILE */
+
+
+/* data structures ************************************************************/
+
+/*----------------------------------------------------------------------------*/
+/* Descriptor Pools                                                           */
+/*                                                                            */
+/* A descriptor_pool is a temporary data structure used during loading of     */
+/* a class. The descriptor_pool is used to allocate the table of              */
+/* constant_classrefs the class uses, and for parsing the field and method    */
+/* descriptors which occurr within the class. The inner workings of           */
+/* descriptor_pool are not important for outside code.                        */
+/*                                                                            */
+/* You use a descriptor_pool as follows:                                      */
+/*                                                                            */
+/* 1. create one with descriptor_pool_new                                     */
+/* 2. add all explicit class references with descriptor_pool_add_class        */
+/* 3. add all field/method descriptors with descriptor_pool_add               */
+/* 4. call descriptor_pool_create_classrefs                                   */
+/*    You can now lookup classrefs with descriptor_pool_lookup_classref       */
+/* 5. call descriptor_pool_alloc_parsed_descriptors                           */
+/* 6. for each field descriptor call descriptor_pool_parse_field_descriptor   */
+/*    for each method descriptor call descriptor_pool_parse_method_descriptor */
+/* 7. call descriptor_pool_get_parsed_descriptors                             */
+/*                                                                            */
+/* IMPORTANT: The descriptor_pool functions use DNEW and DMNEW for allocating */
+/*            memory which can be thrown away when the steps above have been  */
+/*            done.                                                           */
+/*----------------------------------------------------------------------------*/
+
+struct descriptor_pool {
+       classinfo         *referer;
+       u4                 fieldcount;
+       u4                 methodcount;
+       u4                 paramcount;
+       u4                 descriptorsize;
+       u1                *descriptors;
+       u1                *descriptors_next;
+       hashtable          descriptorhash;
+       constant_classref *classrefs;
+       hashtable          classrefhash;
+       u1                *descriptor_kind;       /* useful for debugging */
+       u1                *descriptor_kind_next;  /* useful for debugging */
+};
+
+
+/* data structures for parsed field/method descriptors ************************/
+
+struct typedesc {
+       constant_classref *classref;      /* class reference for TYPE_ADR types   */
+       u1                 type;          /* TYPE_??? constant [1]                */
+       u1                 primitivetype; /* (PRIMITIVE)TYPE_??? constant [2]     */
+       u1                 arraydim;      /* array dimension (0 if no array)      */
+};
+
+/* [1]...the type field contains the basic type used within the VM. So ints,  */
+/*       shorts, chars, bytes, booleans all have TYPE_INT.                    */
+/* [2]...the primitivetype field contains the declared type.                  */
+/*       So short is PRIMITIVETYPE_SHORT, char is PRIMITIVETYPE_CHAR.         */
+/*       For non-primitive types primitivetype is TYPE_ADR.                   */
+
+struct paramdesc {
+#if defined(__MIPS__)
+       u1   type;                  /* TYPE_??? of the register allocated         */
+#endif
+       bool     inmemory;          /* argument in register or on stack           */
+       uint32_t index;             /* index into argument register array         */
+       uint32_t regoff;            /* register index or stack offset             */
+};
+
+struct methoddesc {
+       s2         paramcount;      /* number of parameters                       */
+       s2         paramslots;      /* like above but LONG,DOUBLE count twice     */
+       s4         argintreguse;    /* number of used integer argument registers  */
+       s4         argfltreguse;    /* number of used float argument registers    */
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+       s4         argadrreguse;    /* number of used address registers */
+#endif
+       s4         memuse;          /* number of stack slots used                 */
+       paramdesc *params;          /* allocated parameter descriptions [3]       */
+       typedesc   returntype;      /* parsed descriptor of the return type       */
+       typedesc   paramtypes[1];   /* parameter types, variable length!          */
+};
+
+/* [3]...If params is NULL, the parameter descriptions have not yet been      */
+/*       allocated. In this case ___the possible 'this' pointer of the method */
+/*       is NOT counted in paramcount/paramslots and it is NOT included in    */
+/*       the paramtypes array___.                                             */
+/*       If params != NULL, the parameter descriptions have been              */
+/*       allocated, and the 'this' pointer of the method, if any, IS included.*/
+/*       In case the method has no parameters at all, the special value       */
+/*       METHODDESC_NO_PARAMS is used (see below).                            */
+
+/* METHODDESC_NO_PARAMS is a special value for the methoddesc.params field    */
+/* indicating that the method is a static method without any parameters.      */
+/* This special value must be != NULL and it may only be set if               */
+/* md->paramcount == 0.                                                       */
+
+#define METHODDESC_NOPARAMS  ((paramdesc*)1)
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+descriptor_pool * descriptor_pool_new(classinfo *referer);
+
+bool descriptor_pool_add_class(descriptor_pool *pool,utf *name);
+bool descriptor_pool_add(descriptor_pool *pool,utf *desc,int *paramslots);
+
+int  descriptor_to_basic_type(utf *desc);
+int  descriptor_typesize(typedesc *td);
+
+constant_classref * descriptor_pool_create_classrefs(descriptor_pool *pool,
+                                                                                                        s4 *count);
+constant_classref * descriptor_pool_lookup_classref(descriptor_pool *pool,utf *classname);
+
+void descriptor_pool_alloc_parsed_descriptors(descriptor_pool *pool);
+
+typedesc *descriptor_pool_parse_field_descriptor(descriptor_pool *pool, utf *desc);
+methoddesc *descriptor_pool_parse_method_descriptor(descriptor_pool *pool, utf *desc, s4 mflags,
+                                                                                                       constant_classref *thisclass);
+
+bool descriptor_params_from_paramtypes(methoddesc *md, s4 mflags);
+
+void *descriptor_pool_get_parsed_descriptors(descriptor_pool *pool, s4 *size);
+void descriptor_pool_get_sizes(descriptor_pool *pool, u4 *classrefsize,
+                                                          u4 *descsize);
+
+#ifndef NDEBUG
+void descriptor_debug_print_typedesc(FILE *file,typedesc *d);
+void descriptor_debug_print_methoddesc(FILE *file,methoddesc *d);
+void descriptor_debug_print_paramdesc(FILE *file,paramdesc *d);
+void descriptor_pool_debug_dump(descriptor_pool *pool, FILE *file);
+#endif /* !defined(NDEBUG) */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DESCRIPTOR_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/exceptions.c b/src/vm/exceptions.c
deleted file mode 100644 (file)
index d258329..0000000
+++ /dev/null
@@ -1,2105 +0,0 @@
-/* src/vm/exceptions.c - exception 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 <string.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-
-#include "vm/types.h"
-
-#include "md-abi.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Thread.h"
-#include "native/include/java_lang_Throwable.h"
-
-#include "threads/lock-common.h"
-#include "threads/thread.h"
-
-#include "toolbox/util.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/methodheader.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/show.h"
-#include "vm/jit/stacktrace.h"
-#include "vm/jit/trace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-#include "vmcore/system.h"
-
-#if defined(ENABLE_VMLOG)
-#include <vmlog_cacao.h>
-#endif
-
-
-/* for raising exceptions from native methods *********************************/
-
-#if !defined(ENABLE_THREADS)
-java_object_t *_no_threads_exceptionptr = NULL;
-#endif
-
-
-/* exceptions_get_exception ****************************************************
-
-   Returns the current exception pointer of the current thread.
-
-*******************************************************************************/
-
-java_handle_t *exceptions_get_exception(void)
-{
-       java_object_t *o;
-       java_handle_t *e;
-#if defined(ENABLE_THREADS)
-       threadobject  *t;
-
-       t = THREADOBJECT;
-#endif
-
-       /* Get the exception. */
-
-       LLNI_CRITICAL_START;
-
-#if defined(ENABLE_THREADS)
-       o = t->_exceptionptr;
-#else
-       o = _no_threads_exceptionptr;
-#endif
-
-       e = LLNI_WRAP(o);
-
-       LLNI_CRITICAL_END;
-
-       /* Return the exception. */
-
-       return e;
-}
-
-
-/* exceptions_set_exception ****************************************************
-
-   Sets the exception pointer of the current thread.
-
-*******************************************************************************/
-
-void exceptions_set_exception(java_handle_t *e)
-{
-       threadobject  *t;
-       java_object_t *o;
-
-#if defined(ENABLE_THREADS)
-       t = THREADOBJECT;
-#else
-       t = NULL;
-#endif
-
-       /* Set the exception. */
-
-       LLNI_CRITICAL_START;
-
-       o = LLNI_UNWRAP(e);
-
-#if !defined(NDEBUG)
-       if (opt_DebugExceptions) {
-               printf("[exceptions_set_exception  : t=%p, o=%p, class=",
-                          (void *) t, (void *) o);
-               class_print(o->vftbl->clazz);
-               printf("]\n");
-       }
-#endif
-
-#if defined(ENABLE_THREADS)
-       t->_exceptionptr = o;
-#else
-       _no_threads_exceptionptr = o;
-#endif
-
-       LLNI_CRITICAL_END;
-}
-
-
-/* exceptions_clear_exception **************************************************
-
-   Clears the current exception pointer of the current thread.
-
-*******************************************************************************/
-
-void exceptions_clear_exception(void)
-{
-       threadobject *t;
-
-#if defined(ENABLE_THREADS)
-       t = THREADOBJECT;
-#else
-       t = NULL;
-#endif
-
-       /* Set the exception. */
-
-#if !defined(NDEBUG)
-       if (opt_DebugExceptions) {
-               printf("[exceptions_clear_exception: t=%p]\n", (void *) t);
-       }
-#endif
-
-#if defined(ENABLE_THREADS)
-       t->_exceptionptr = NULL;
-#else
-       _no_threads_exceptionptr = NULL;
-#endif
-}
-
-
-/* exceptions_get_and_clear_exception ******************************************
-
-   Gets the exception pointer of the current thread and clears it.
-   This function may return NULL.
-
-*******************************************************************************/
-
-java_handle_t *exceptions_get_and_clear_exception(void)
-{
-       java_handle_t *o;
-
-       /* Get the exception... */
-
-       o = exceptions_get_exception();
-
-       /* ...and clear the exception if it is set. */
-
-       if (o != NULL)
-               exceptions_clear_exception();
-
-       /* return the exception */
-
-       return o;
-}
-
-
-/* exceptions_abort ************************************************************
-
-   Prints exception to be thrown and aborts.
-
-   IN:
-      classname....class name
-      message......exception message
-
-*******************************************************************************/
-
-static void exceptions_abort(utf *classname, utf *message)
-{
-       log_println("exception thrown while VM is initializing: ");
-
-       log_start();
-       utf_display_printable_ascii_classname(classname);
-
-       if (message != NULL) {
-               log_print(": ");
-               utf_display_printable_ascii_classname(message);
-       }
-
-       log_finish();
-
-       vm_abort("Aborting...");
-}
-
-
-/* exceptions_new_class_utf ****************************************************
-
-   Creates an exception object with the given class and initalizes it
-   with the given utf message.
-
-   IN:
-      c ......... exception class
-         message ... the message as an utf *
-
-   RETURN VALUE:
-     an exception pointer (in any case -- either it is the newly
-     created exception, or an exception thrown while trying to create
-     it).
-
-*******************************************************************************/
-
-static java_handle_t *exceptions_new_class_utf(classinfo *c, utf *message)
-{
-       java_handle_t *s;
-       java_handle_t *o;
-
-       if (vm_initializing) {
-               /* This can happen when global class variables are used which
-                  are not initialized yet. */
-
-               if (c == NULL)
-                       exceptions_abort(NULL, message);
-               else
-                       exceptions_abort(c->name, message);
-       }
-
-       s = javastring_new(message);
-
-       if (s == NULL)
-               return exceptions_get_exception();
-
-       o = native_new_and_init_string(c, s);
-
-       if (o == NULL)
-               return exceptions_get_exception();
-
-       return o;
-}
-
-
-/* exceptions_new_utf **********************************************************
-
-   Creates an exception object with the given name and initalizes it.
-
-   IN:
-      classname....class name in UTF-8
-
-*******************************************************************************/
-
-static java_handle_t *exceptions_new_utf(utf *classname)
-{
-       classinfo     *c;
-       java_handle_t *o;
-
-       if (vm_initializing)
-               exceptions_abort(classname, NULL);
-
-       c = load_class_bootstrap(classname);
-
-       if (c == NULL)
-               return exceptions_get_exception();
-
-       o = native_new_and_init(c);
-
-       if (o == NULL)
-               return exceptions_get_exception();
-
-       return o;
-}
-
-
-/* exceptions_new_utf_javastring ***********************************************
-
-   Creates an exception object with the given name and initalizes it
-   with the given java/lang/String message.
-
-   IN:
-      classname....class name in UTF-8
-         message......the message as a java.lang.String
-
-   RETURN VALUE:
-      an exception pointer (in any case -- either it is the newly created
-         exception, or an exception thrown while trying to create it).
-
-*******************************************************************************/
-
-static java_handle_t *exceptions_new_utf_javastring(utf *classname,
-                                                                                                       java_handle_t *message)
-{
-       java_handle_t *o;
-       classinfo     *c;
-   
-       if (vm_initializing)
-               exceptions_abort(classname, NULL);
-
-       c = load_class_bootstrap(classname);
-
-       if (c == NULL)
-               return exceptions_get_exception();
-
-       o = native_new_and_init_string(c, message);
-
-       if (o == NULL)
-               return exceptions_get_exception();
-
-       return o;
-}
-
-
-/* exceptions_new_utf_utf ******************************************************
-
-   Creates an exception object with the given name and initalizes it
-   with the given utf message.
-
-   IN:
-      classname....class name in UTF-8
-         message......the message as an utf *
-
-   RETURN VALUE:
-      an exception pointer (in any case -- either it is the newly created
-         exception, or an exception thrown while trying to create it).
-
-*******************************************************************************/
-
-static java_handle_t *exceptions_new_utf_utf(utf *classname, utf *message)
-{
-       classinfo     *c;
-       java_handle_t *o;
-
-       if (vm_initializing)
-               exceptions_abort(classname, message);
-
-       c = load_class_bootstrap(classname);
-
-       if (c == NULL)
-               return exceptions_get_exception();
-
-       o = exceptions_new_class_utf(c, message);
-
-       return o;
-}
-
-
-/* exceptions_throw_class_utf **************************************************
-
-   Creates an exception object with the given class, initalizes and
-   throws it with the given utf message.
-
-   IN:
-      c ......... exception class
-         message ... the message as an utf *
-
-*******************************************************************************/
-
-static void exceptions_throw_class_utf(classinfo *c, utf *message)
-{
-       java_handle_t *o;
-
-       o = exceptions_new_class_utf(c, message);
-
-       exceptions_set_exception(o);
-}
-
-
-/* exceptions_throw_utf ********************************************************
-
-   Creates an exception object with the given name, initalizes and
-   throws it.
-
-   IN:
-      classname....class name in UTF-8
-
-*******************************************************************************/
-
-static void exceptions_throw_utf(utf *classname)
-{
-       java_handle_t *o;
-
-       o = exceptions_new_utf(classname);
-
-       if (o == NULL)
-               return;
-
-       exceptions_set_exception(o);
-}
-
-
-/* exceptions_throw_utf_throwable **********************************************
-
-   Creates an exception object with the given name and initalizes it
-   with the given java/lang/Throwable exception.
-
-   IN:
-      classname....class name in UTF-8
-         cause........the given Throwable
-
-*******************************************************************************/
-
-static void exceptions_throw_utf_throwable(utf *classname,
-                                                                                  java_handle_t *cause)
-{
-       classinfo           *c;
-       java_handle_t       *o;
-       methodinfo          *m;
-       java_lang_Throwable *object;
-
-       if (vm_initializing)
-               exceptions_abort(classname, NULL);
-
-       object = (java_lang_Throwable *) cause;
-
-       c = load_class_bootstrap(classname);
-
-       if (c == NULL)
-               return;
-
-       /* create object */
-
-       o = builtin_new(c);
-       
-       if (o == NULL)
-               return;
-
-       /* call initializer */
-
-       m = class_resolveclassmethod(c,
-                                                                utf_init,
-                                                                utf_java_lang_Throwable__void,
-                                                                NULL,
-                                                                true);
-                                                     
-       if (m == NULL)
-               return;
-
-       (void) vm_call_method(m, o, cause);
-
-       exceptions_set_exception(o);
-}
-
-
-/* exceptions_throw_utf_exception **********************************************
-
-   Creates an exception object with the given name and initalizes it
-   with the given java/lang/Exception exception.
-
-   IN:
-      classname....class name in UTF-8
-         exception....the given Exception
-
-*******************************************************************************/
-
-static void exceptions_throw_utf_exception(utf *classname,
-                                                                                  java_handle_t *exception)
-{
-       classinfo     *c;
-       java_handle_t *o;
-       methodinfo    *m;
-
-       if (vm_initializing)
-               exceptions_abort(classname, NULL);
-
-       c = load_class_bootstrap(classname);
-
-       if (c == NULL)
-               return;
-
-       /* create object */
-
-       o = builtin_new(c);
-       
-       if (o == NULL)
-               return;
-
-       /* call initializer */
-
-       m = class_resolveclassmethod(c,
-                                                                utf_init,
-                                                                utf_java_lang_Exception__V,
-                                                                NULL,
-                                                                true);
-                                                     
-       if (m == NULL)
-               return;
-
-       (void) vm_call_method(m, o, exception);
-
-       exceptions_set_exception(o);
-}
-
-
-/* exceptions_throw_utf_cause **************************************************
-
-   Creates an exception object with the given name and initalizes it
-   with the given java/lang/Throwable exception with initCause.
-
-   IN:
-      classname....class name in UTF-8
-         cause........the given Throwable
-
-*******************************************************************************/
-
-static void exceptions_throw_utf_cause(utf *classname, java_handle_t *cause)
-{
-       classinfo           *c;
-       java_handle_t       *o;
-       methodinfo          *m;
-       java_lang_String    *s;
-       java_lang_Throwable *object;
-
-       if (vm_initializing)
-               exceptions_abort(classname, NULL);
-
-       object = (java_lang_Throwable *) cause;
-
-       c = load_class_bootstrap(classname);
-
-       if (c == NULL)
-               return;
-
-       /* create object */
-
-       o = builtin_new(c);
-       
-       if (o == NULL)
-               return;
-
-       /* call initializer */
-
-       m = class_resolveclassmethod(c,
-                                                                utf_init,
-                                                                utf_java_lang_String__void,
-                                                                NULL,
-                                                                true);
-                                                     
-       if (m == NULL)
-               return;
-
-       LLNI_field_get_ref(object, detailMessage, s);
-
-       (void) vm_call_method(m, o, s);
-
-       /* call initCause */
-
-       m = class_resolveclassmethod(c,
-                                                                utf_initCause,
-                                                                utf_java_lang_Throwable__java_lang_Throwable,
-                                                                NULL,
-                                                                true);
-
-       if (m == NULL)
-               return;
-
-       (void) vm_call_method(m, o, cause);
-
-       exceptions_set_exception(o);
-}
-
-
-/* exceptions_throw_utf_utf ****************************************************
-
-   Creates an exception object with the given name, initalizes and
-   throws it with the given utf message.
-
-   IN:
-      classname....class name in UTF-8
-         message......the message as an utf *
-
-*******************************************************************************/
-
-static void exceptions_throw_utf_utf(utf *classname, utf *message)
-{
-       java_handle_t *o;
-
-       o = exceptions_new_utf_utf(classname, message);
-
-       exceptions_set_exception(o);
-}
-
-
-/* exceptions_new_abstractmethoderror ****************************************
-
-   Generates a java.lang.AbstractMethodError for the VM.
-
-*******************************************************************************/
-
-java_handle_t *exceptions_new_abstractmethoderror(void)
-{
-       java_handle_t *o;
-
-       o = exceptions_new_utf(utf_java_lang_AbstractMethodError);
-
-       return o;
-}
-
-
-/* exceptions_new_error ********************************************************
-
-   Generates a java.lang.Error for the VM.
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVAME_CLDC1_1)
-static java_handle_t *exceptions_new_error(utf *message)
-{
-       java_handle_t *o;
-
-       o = exceptions_new_utf_utf(utf_java_lang_Error, message);
-
-       return o;
-}
-#endif
-
-
-/* exceptions_asm_new_abstractmethoderror **************************************
-
-   Generates a java.lang.AbstractMethodError for
-   asm_abstractmethoderror.
-
-*******************************************************************************/
-
-java_object_t *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra)
-{
-       stackframeinfo_t  sfi;
-       java_handle_t    *e;
-       java_object_t    *o;
-
-       /* Fill and add a stackframeinfo (XPC is equal to RA). */
-
-       stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra);
-
-       /* create the exception */
-
-#if defined(ENABLE_JAVASE)
-       e = exceptions_new_abstractmethoderror();
-#else
-       e = exceptions_new_error(utf_java_lang_AbstractMethodError);
-#endif
-
-       /* Remove the stackframeinfo. */
-
-       stacktrace_stackframeinfo_remove(&sfi);
-
-       /* unwrap the exception */
-       /* ATTENTION: do the this _after_ the stackframeinfo was removed */
-
-       o = LLNI_UNWRAP(e);
-
-       return o;
-}
-
-
-/* exceptions_new_arraystoreexception ******************************************
-
-   Generates a java.lang.ArrayStoreException for the VM.
-
-*******************************************************************************/
-
-java_handle_t *exceptions_new_arraystoreexception(void)
-{
-       java_handle_t *o;
-
-       o = exceptions_new_utf(utf_java_lang_ArrayStoreException);
-
-       return o;
-}
-
-
-/* exceptions_throw_abstractmethoderror ****************************************
-
-   Generates and throws a java.lang.AbstractMethodError for the VM.
-
-*******************************************************************************/
-
-void exceptions_throw_abstractmethoderror(void)
-{
-       exceptions_throw_utf(utf_java_lang_AbstractMethodError);
-}
-
-
-/* exceptions_throw_classcircularityerror **************************************
-
-   Generates and throws a java.lang.ClassCircularityError for the
-   classloader.
-
-   IN:
-      c....the class in which the error was found
-
-*******************************************************************************/
-
-void exceptions_throw_classcircularityerror(classinfo *c)
-{
-       exceptions_throw_utf_utf(utf_java_lang_ClassCircularityError, c->name);
-}
-
-
-/* exceptions_throw_classformaterror *******************************************
-
-   Generates and throws a java.lang.ClassFormatError for the VM.
-
-   IN:
-      c............the class in which the error was found
-         message......UTF-8 format string
-
-*******************************************************************************/
-
-void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
-{
-       char    *msg;
-       s4       msglen;
-       va_list  ap;
-       utf     *u;
-
-       /* calculate message length */
-
-       msglen = 0;
-
-       if (c != NULL)
-               msglen += utf_bytes(c->name) + strlen(" (");
-
-       va_start(ap, message);
-       msglen += get_variable_message_length(message, ap);
-       va_end(ap);
-
-       if (c != NULL)
-               msglen += strlen(")");
-
-       msglen += strlen("0");
-
-       /* allocate a buffer */
-
-       msg = MNEW(char, msglen);
-
-       /* print message into allocated buffer */
-
-       if (c != NULL) {
-               utf_copy_classname(msg, c->name);
-               strcat(msg, " (");
-       }
-
-       va_start(ap, message);
-       vsprintf(msg + strlen(msg), message, ap);
-       va_end(ap);
-
-       if (c != NULL)
-               strcat(msg, ")");
-
-       u = utf_new_char(msg);
-
-       /* free memory */
-
-       MFREE(msg, char, msglen);
-
-       /* throw exception */
-
-       exceptions_throw_utf_utf(utf_java_lang_ClassFormatError, u);
-}
-
-
-/* exceptions_throw_classnotfoundexception *************************************
-
-   Generates and throws a java.lang.ClassNotFoundException for the
-   VM.
-
-   IN:
-      name.........name of the class not found as a utf *
-
-*******************************************************************************/
-
-void exceptions_throw_classnotfoundexception(utf *name)
-{      
-       exceptions_throw_class_utf(class_java_lang_ClassNotFoundException, name);
-}
-
-
-/* exceptions_throw_noclassdeffounderror ***************************************
-
-   Generates and throws a java.lang.NoClassDefFoundError.
-
-   IN:
-      name.........name of the class not found as a utf *
-
-*******************************************************************************/
-
-void exceptions_throw_noclassdeffounderror(utf *name)
-{
-       exceptions_throw_utf_utf(utf_java_lang_NoClassDefFoundError, name);
-}
-
-
-/* exceptions_throw_noclassdeffounderror_cause *********************************
-
-   Generates and throws a java.lang.NoClassDefFoundError with the
-   given cause.
-
-*******************************************************************************/
-
-void exceptions_throw_noclassdeffounderror_cause(java_handle_t *cause)
-{
-       exceptions_throw_utf_cause(utf_java_lang_NoClassDefFoundError, cause);
-}
-
-
-/* exceptions_throw_noclassdeffounderror_wrong_name ****************************
-
-   Generates and throws a java.lang.NoClassDefFoundError with a
-   specific message:
-
-   IN:
-      name.........name of the class not found as a utf *
-
-*******************************************************************************/
-
-void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name)
-{
-       char *msg;
-       s4    msglen;
-       utf  *u;
-
-       msglen = utf_bytes(c->name) + strlen(" (wrong name: ") +
-               utf_bytes(name) + strlen(")") + strlen("0");
-
-       msg = MNEW(char, msglen);
-
-       utf_copy_classname(msg, c->name);
-       strcat(msg, " (wrong name: ");
-       utf_cat_classname(msg, name);
-       strcat(msg, ")");
-
-       u = utf_new_char(msg);
-
-       MFREE(msg, char, msglen);
-
-       exceptions_throw_noclassdeffounderror(u);
-}
-
-
-/* exceptions_throw_exceptionininitializererror ********************************
-
-   Generates and throws a java.lang.ExceptionInInitializerError for
-   the VM.
-
-   IN:
-      cause......cause exception object
-
-*******************************************************************************/
-
-void exceptions_throw_exceptionininitializererror(java_handle_t *cause)
-{
-       exceptions_throw_utf_throwable(utf_java_lang_ExceptionInInitializerError,
-                                                                  cause);
-}
-
-
-/* exceptions_throw_incompatibleclasschangeerror *******************************
-
-   Generates and throws a java.lang.IncompatibleClassChangeError for
-   the VM.
-
-   IN:
-      message......UTF-8 message format string
-
-*******************************************************************************/
-
-void exceptions_throw_incompatibleclasschangeerror(classinfo *c, const char *message)
-{
-       char *msg;
-       s4    msglen;
-       utf  *u;
-
-       /* calculate exception message length */
-
-       msglen = utf_bytes(c->name) + strlen(message) + strlen("0");
-
-       /* allocate memory */
-
-       msg = MNEW(char, msglen);
-
-       utf_copy_classname(msg, c->name);
-       strcat(msg, message);
-
-       u = utf_new_char(msg);
-
-       /* free memory */
-
-       MFREE(msg, char, msglen);
-
-       /* throw exception */
-
-       exceptions_throw_utf_utf(utf_java_lang_IncompatibleClassChangeError, u);
-}
-
-
-/* exceptions_throw_instantiationerror *****************************************
-
-   Generates and throws a java.lang.InstantiationError for the VM.
-
-*******************************************************************************/
-
-void exceptions_throw_instantiationerror(classinfo *c)
-{
-       exceptions_throw_utf_utf(utf_java_lang_InstantiationError, c->name);
-}
-
-
-/* exceptions_throw_internalerror **********************************************
-
-   Generates and throws a java.lang.InternalError for the VM.
-
-   IN:
-      message......UTF-8 message format string
-
-*******************************************************************************/
-
-void exceptions_throw_internalerror(const char *message, ...)
-{
-       va_list  ap;
-       char    *msg;
-       s4       msglen;
-       utf     *u;
-
-       /* calculate exception message length */
-
-       va_start(ap, message);
-       msglen = get_variable_message_length(message, ap);
-       va_end(ap);
-
-       /* allocate memory */
-
-       msg = MNEW(char, msglen);
-
-       /* generate message */
-
-       va_start(ap, message);
-       vsprintf(msg, message, ap);
-       va_end(ap);
-
-       u = utf_new_char(msg);
-
-       /* free memory */
-
-       MFREE(msg, char, msglen);
-
-       /* throw exception */
-
-       exceptions_throw_utf_utf(utf_java_lang_InternalError, u);
-}
-
-
-/* exceptions_throw_linkageerror ***********************************************
-
-   Generates and throws java.lang.LinkageError with an error message.
-
-   IN:
-      message......UTF-8 message
-         c............class related to the error. If this is != NULL
-                      the name of c is appended to the error message.
-
-*******************************************************************************/
-
-void exceptions_throw_linkageerror(const char *message, classinfo *c)
-{
-       utf  *u;
-       char *msg;
-       int   len;
-
-       /* calculate exception message length */
-
-       len = strlen(message) + 1;
-
-       if (c != NULL)
-               len += utf_bytes(c->name);
-               
-       /* allocate memory */
-
-       msg = MNEW(char, len);
-
-       /* generate message */
-
-       strcpy(msg, message);
-
-       if (c != NULL)
-               utf_cat_classname(msg, c->name);
-
-       u = utf_new_char(msg);
-
-       /* free memory */
-
-       MFREE(msg, char, len);
-
-       exceptions_throw_utf_utf(utf_java_lang_LinkageError, u);
-}
-
-
-/* exceptions_throw_nosuchfielderror *******************************************
-
-   Generates and throws a java.lang.NoSuchFieldError with an error
-   message.
-
-   IN:
-      c............class in which the field was not found
-         name.........name of the field
-
-*******************************************************************************/
-
-void exceptions_throw_nosuchfielderror(classinfo *c, utf *name)
-{
-       char *msg;
-       s4    msglen;
-       utf  *u;
-
-       /* calculate exception message length */
-
-       msglen = utf_bytes(c->name) + strlen(".") + utf_bytes(name) + strlen("0");
-
-       /* allocate memory */
-
-       msg = MNEW(char, msglen);
-
-       /* generate message */
-
-       utf_copy_classname(msg, c->name);
-       strcat(msg, ".");
-       utf_cat(msg, name);
-
-       u = utf_new_char(msg);
-
-       /* free memory */
-
-       MFREE(msg, char, msglen);
-
-       exceptions_throw_utf_utf(utf_java_lang_NoSuchFieldError, u);
-}
-
-
-/* exceptions_throw_nosuchmethoderror ******************************************
-
-   Generates and throws a java.lang.NoSuchMethodError with an error
-   message.
-
-   IN:
-      c............class in which the method was not found
-         name.........name of the method
-         desc.........descriptor of the method
-
-*******************************************************************************/
-
-void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc)
-{
-       char *msg;
-       s4    msglen;
-       utf  *u;
-
-       /* calculate exception message length */
-
-       msglen = utf_bytes(c->name) + strlen(".") + utf_bytes(name) +
-               utf_bytes(desc) + strlen("0");
-
-       /* allocate memory */
-
-       msg = MNEW(char, msglen);
-
-       /* generate message */
-
-       utf_copy_classname(msg, c->name);
-       strcat(msg, ".");
-       utf_cat(msg, name);
-       utf_cat(msg, desc);
-
-       u = utf_new_char(msg);
-
-       /* free memory */
-
-       MFREE(msg, char, msglen);
-
-#if defined(ENABLE_JAVASE)
-       exceptions_throw_utf_utf(utf_java_lang_NoSuchMethodError, u);
-#else
-       exceptions_throw_utf_utf(utf_java_lang_Error, u);
-#endif
-}
-
-
-/* exceptions_throw_outofmemoryerror *******************************************
-
-   Generates and throws an java.lang.OutOfMemoryError for the VM.
-
-*******************************************************************************/
-
-void exceptions_throw_outofmemoryerror(void)
-{
-       exceptions_throw_utf(utf_java_lang_OutOfMemoryError);
-}
-
-
-/* exceptions_throw_unsatisfiedlinkerror ***************************************
-
-   Generates and throws a java.lang.UnsatisfiedLinkError for the
-   classloader.
-
-   IN:
-         name......UTF-8 name string
-
-*******************************************************************************/
-
-void exceptions_throw_unsatisfiedlinkerror(utf *name)
-{
-#if defined(ENABLE_JAVASE)
-       exceptions_throw_utf_utf(utf_java_lang_UnsatisfiedLinkError, name);
-#else
-       exceptions_throw_utf_utf(utf_java_lang_Error, name);
-#endif
-}
-
-
-/* exceptions_throw_unsupportedclassversionerror *******************************
-
-   Generates and throws a java.lang.UnsupportedClassVersionError for
-   the classloader.
-
-   IN:
-      c............class in which the method was not found
-         message......UTF-8 format string
-
-*******************************************************************************/
-
-void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi)
-{
-       char *msg;
-    s4    msglen;
-       utf  *u;
-
-       /* calculate exception message length */
-
-       msglen =
-               utf_bytes(c->name) +
-               strlen(" (Unsupported major.minor version 00.0)") +
-               strlen("0");
-
-       /* allocate memory */
-
-       msg = MNEW(char, msglen);
-
-       /* generate message */
-
-       utf_copy_classname(msg, c->name);
-       sprintf(msg + strlen(msg), " (Unsupported major.minor version %d.%d)",
-                       ma, mi);
-
-       u = utf_new_char(msg);
-
-       /* free memory */
-
-       MFREE(msg, char, msglen);
-
-       /* throw exception */
-
-       exceptions_throw_utf_utf(utf_java_lang_UnsupportedClassVersionError, u);
-}
-
-
-/* exceptions_throw_verifyerror ************************************************
-
-   Generates and throws a java.lang.VerifyError for the JIT compiler.
-
-   IN:
-      m............method in which the error was found
-         message......UTF-8 format string
-
-*******************************************************************************/
-
-void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...)
-{
-       va_list  ap;
-       char    *msg;
-       s4       msglen;
-       utf     *u;
-
-       /* calculate exception message length */
-
-       msglen = 0;
-
-       if (m != NULL)
-               msglen =
-                       strlen("(class: ") + utf_bytes(m->clazz->name) +
-                       strlen(", method: ") + utf_bytes(m->name) +
-                       strlen(" signature: ") + utf_bytes(m->descriptor) +
-                       strlen(") ") + strlen("0");
-
-       va_start(ap, message);
-       msglen += get_variable_message_length(message, ap);
-       va_end(ap);
-
-       /* allocate memory */
-
-       msg = MNEW(char, msglen);
-
-       /* generate message */
-
-       if (m != NULL) {
-               strcpy(msg, "(class: ");
-               utf_cat_classname(msg, m->clazz->name);
-               strcat(msg, ", method: ");
-               utf_cat(msg, m->name);
-               strcat(msg, " signature: ");
-               utf_cat(msg, m->descriptor);
-               strcat(msg, ") ");
-       }
-
-       va_start(ap, message);
-       vsprintf(msg + strlen(msg), message, ap);
-       va_end(ap);
-
-       u = utf_new_char(msg);
-
-       /* free memory */
-
-       MFREE(msg, char, msglen);
-
-       /* throw exception */
-
-       exceptions_throw_utf_utf(utf_java_lang_VerifyError, u);
-}
-
-
-/* exceptions_throw_verifyerror_for_stack **************************************
-
-   throws a java.lang.VerifyError for an invalid stack slot type
-
-   IN:
-      m............method in which the error was found
-         type.........the expected type
-
-   RETURN VALUE:
-      an exception pointer (in any case -- either it is the newly created
-         exception, or an exception thrown while trying to create it).
-
-*******************************************************************************/
-
-void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type)
-{
-       char *msg;
-       s4    msglen;
-       char *typename;
-       utf  *u;
-
-       /* calculate exception message length */
-
-       msglen = 0;
-
-       if (m != NULL)
-               msglen = strlen("(class: ") + utf_bytes(m->clazz->name) +
-                       strlen(", method: ") + utf_bytes(m->name) +
-                       strlen(" signature: ") + utf_bytes(m->descriptor) +
-                       strlen(") Expecting to find longest-------typename on stack") 
-                       + strlen("0");
-
-       /* allocate memory */
-
-       msg = MNEW(char, msglen);
-
-       /* generate message */
-
-       if (m != NULL) {
-               strcpy(msg, "(class: ");
-               utf_cat_classname(msg, m->clazz->name);
-               strcat(msg, ", method: ");
-               utf_cat(msg, m->name);
-               strcat(msg, " signature: ");
-               utf_cat(msg, m->descriptor);
-               strcat(msg, ") ");
-       }
-       else {
-               msg[0] = 0;
-       }
-
-       strcat(msg, "Expecting to find ");
-
-       switch (type) {
-               case TYPE_INT: typename = "integer"; break;
-               case TYPE_LNG: typename = "long"; break;
-               case TYPE_FLT: typename = "float"; break;
-               case TYPE_DBL: typename = "double"; break;
-               case TYPE_ADR: typename = "object/array"; break;
-               case TYPE_RET: typename = "returnAddress"; break;
-               default:       typename = "<INVALID>"; assert(0); break;
-       }
-
-       strcat(msg, typename);
-       strcat(msg, " on stack");
-
-       u = utf_new_char(msg);
-
-       /* free memory */
-
-       MFREE(msg, char, msglen);
-
-       /* throw exception */
-
-       exceptions_throw_utf_utf(utf_java_lang_VerifyError, u);
-}
-
-
-/* exceptions_new_arithmeticexception ******************************************
-
-   Generates a java.lang.ArithmeticException for the JIT compiler.
-
-*******************************************************************************/
-
-java_handle_t *exceptions_new_arithmeticexception(void)
-{
-       java_handle_t *o;
-
-       o = exceptions_new_utf_utf(utf_java_lang_ArithmeticException,
-                                                          utf_division_by_zero);
-
-       return o;
-}
-
-
-/* exceptions_new_arrayindexoutofboundsexception *******************************
-
-   Generates a java.lang.ArrayIndexOutOfBoundsException for the VM
-   system.
-
-*******************************************************************************/
-
-java_handle_t *exceptions_new_arrayindexoutofboundsexception(s4 index)
-{
-       java_handle_t *o;
-       methodinfo    *m;
-       java_handle_t *s;
-
-       /* convert the index into a String, like Sun does */
-
-       m = class_resolveclassmethod(class_java_lang_String,
-                                                                utf_new_char("valueOf"),
-                                                                utf_new_char("(I)Ljava/lang/String;"),
-                                                                class_java_lang_Object,
-                                                                true);
-
-       if (m == NULL)
-               return exceptions_get_exception();
-
-       s = vm_call_method(m, NULL, index);
-
-       if (s == NULL)
-               return exceptions_get_exception();
-
-       o = exceptions_new_utf_javastring(utf_java_lang_ArrayIndexOutOfBoundsException,
-                                                                         s);
-
-       if (o == NULL)
-               return exceptions_get_exception();
-
-       return o;
-}
-
-
-/* exceptions_throw_arrayindexoutofboundsexception *****************************
-
-   Generates and throws a java.lang.ArrayIndexOutOfBoundsException for
-   the VM.
-
-*******************************************************************************/
-
-void exceptions_throw_arrayindexoutofboundsexception(void)
-{
-       exceptions_throw_utf(utf_java_lang_ArrayIndexOutOfBoundsException);
-}
-
-
-/* exceptions_throw_arraystoreexception ****************************************
-
-   Generates and throws a java.lang.ArrayStoreException for the VM.
-
-*******************************************************************************/
-
-void exceptions_throw_arraystoreexception(void)
-{
-       exceptions_throw_utf(utf_java_lang_ArrayStoreException);
-}
-
-
-/* exceptions_new_classcastexception *******************************************
-
-   Generates a java.lang.ClassCastException for the JIT compiler.
-
-*******************************************************************************/
-
-java_handle_t *exceptions_new_classcastexception(java_handle_t *o)
-{
-       java_handle_t *e;
-       classinfo     *c;
-       utf           *classname;
-
-       LLNI_class_get(o, c);
-
-       classname = c->name;
-
-       e = exceptions_new_utf_utf(utf_java_lang_ClassCastException, classname);
-
-       return e;
-}
-
-
-/* exceptions_throw_clonenotsupportedexception *********************************
-
-   Generates and throws a java.lang.CloneNotSupportedException for the
-   VM.
-
-*******************************************************************************/
-
-void exceptions_throw_clonenotsupportedexception(void)
-{
-       exceptions_throw_utf(utf_java_lang_CloneNotSupportedException);
-}
-
-
-/* exceptions_throw_illegalaccessexception *************************************
-
-   Generates and throws a java.lang.IllegalAccessException for the VM.
-
-*******************************************************************************/
-
-void exceptions_throw_illegalaccessexception(utf *message)
-{
-       exceptions_throw_utf_utf(utf_java_lang_IllegalAccessException, message);
-}
-
-
-/* exceptions_throw_illegalargumentexception ***********************************
-
-   Generates and throws a java.lang.IllegalArgumentException for the
-   VM.
-
-*******************************************************************************/
-
-void exceptions_throw_illegalargumentexception(void)
-{
-       exceptions_throw_utf(utf_java_lang_IllegalArgumentException);
-}
-
-
-/* exceptions_throw_illegalmonitorstateexception *******************************
-
-   Generates and throws a java.lang.IllegalMonitorStateException for
-   the VM.
-
-*******************************************************************************/
-
-void exceptions_throw_illegalmonitorstateexception(void)
-{
-       exceptions_throw_utf(utf_java_lang_IllegalMonitorStateException);
-}
-
-
-/* exceptions_throw_instantiationexception *************************************
-
-   Generates and throws a java.lang.InstantiationException for the VM.
-
-*******************************************************************************/
-
-void exceptions_throw_instantiationexception(classinfo *c)
-{
-       exceptions_throw_utf_utf(utf_java_lang_InstantiationException, c->name);
-}
-
-
-/* exceptions_throw_interruptedexception ***************************************
-
-   Generates and throws a java.lang.InterruptedException for the VM.
-
-*******************************************************************************/
-
-void exceptions_throw_interruptedexception(void)
-{
-       exceptions_throw_utf(utf_java_lang_InterruptedException);
-}
-
-
-/* exceptions_throw_invocationtargetexception **********************************
-
-   Generates and throws a java.lang.reflect.InvocationTargetException
-   for the VM.
-
-   IN:
-      cause......cause exception object
-
-*******************************************************************************/
-
-void exceptions_throw_invocationtargetexception(java_handle_t *cause)
-{
-       exceptions_throw_utf_throwable(utf_java_lang_reflect_InvocationTargetException,
-                                                                  cause);
-}
-
-
-/* exceptions_throw_negativearraysizeexception *********************************
-
-   Generates and throws a java.lang.NegativeArraySizeException for the
-   VM.
-
-*******************************************************************************/
-
-void exceptions_throw_negativearraysizeexception(void)
-{
-       exceptions_throw_utf(utf_java_lang_NegativeArraySizeException);
-}
-
-
-/* exceptions_new_nullpointerexception *****************************************
-
-   Generates a java.lang.NullPointerException for the VM system.
-
-*******************************************************************************/
-
-java_handle_t *exceptions_new_nullpointerexception(void)
-{
-       java_handle_t *o;
-
-       o = exceptions_new_utf(utf_java_lang_NullPointerException);
-
-       return o;
-}
-
-
-/* exceptions_throw_nullpointerexception ***************************************
-
-   Generates a java.lang.NullPointerException for the VM system and
-   throw it in the VM system.
-
-*******************************************************************************/
-
-void exceptions_throw_nullpointerexception(void)
-{
-       exceptions_throw_utf(utf_java_lang_NullPointerException);
-}
-
-
-/* exceptions_throw_privilegedactionexception **********************************
-
-   Generates and throws a java.security.PrivilegedActionException.
-
-*******************************************************************************/
-
-void exceptions_throw_privilegedactionexception(java_handle_t *exception)
-{
-       exceptions_throw_utf_exception(utf_java_security_PrivilegedActionException,
-                                                                  exception);
-}
-
-
-/* exceptions_throw_stringindexoutofboundsexception ****************************
-
-   Generates and throws a java.lang.StringIndexOutOfBoundsException
-   for the VM.
-
-*******************************************************************************/
-
-void exceptions_throw_stringindexoutofboundsexception(void)
-{
-       exceptions_throw_utf(utf_java_lang_StringIndexOutOfBoundsException);
-}
-
-
-/* exceptions_fillinstacktrace *************************************************
-
-   Calls the fillInStackTrace-method of the currently thrown
-   exception.
-
-*******************************************************************************/
-
-java_handle_t *exceptions_fillinstacktrace(void)
-{
-       java_handle_t *o;
-       classinfo     *c;
-       methodinfo    *m;
-
-       /* get exception */
-
-       o = exceptions_get_and_clear_exception();
-
-       assert(o);
-
-       /* resolve methodinfo pointer from exception object */
-
-       LLNI_class_get(o, c);
-
-#if defined(ENABLE_JAVASE)
-       m = class_resolvemethod(c,
-                                                       utf_fillInStackTrace,
-                                                       utf_void__java_lang_Throwable);
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-       m = class_resolvemethod(c,
-                                                       utf_fillInStackTrace,
-                                                       utf_void__void);
-#else
-#error IMPLEMENT ME!
-#endif
-
-       /* call function */
-
-       (void) vm_call_method(m, o);
-
-       /* return exception object */
-
-       return o;
-}
-
-
-/* exceptions_handle_exception *************************************************
-
-   Try to find an exception handler for the given exception and return it.
-   If no handler is found, exit the monitor of the method (if any)
-   and return NULL.
-
-   IN:
-      xptr.........the exception object
-         xpc..........PC of where the exception was thrown
-         pv...........Procedure Value of the current method
-         sp...........current stack pointer
-
-   RETURN VALUE:
-      the address of the first matching exception handler, or
-         NULL if no handler was found
-
-*******************************************************************************/
-
-#if defined(ENABLE_JIT)
-void *exceptions_handle_exception(java_object_t *xptro, void *xpc, void *pv, void *sp)
-{
-       stackframeinfo_t        sfi;
-       java_handle_t          *xptr;
-       methodinfo             *m;
-       codeinfo               *code;
-       exceptiontable_t       *et;
-       exceptiontable_entry_t *ete;
-       s4                      i;
-       classref_or_classinfo   cr;
-       classinfo              *c;
-#if defined(ENABLE_THREADS)
-       java_object_t          *o;
-#endif
-       void                   *result;
-
-#ifdef __S390__
-       /* Addresses are 31 bit integers */
-#      define ADDR_MASK(x) (void *) ((uintptr_t) (x) & 0x7FFFFFFF)
-#else
-#      define ADDR_MASK(x) (x)
-#endif
-
-       xptr = LLNI_WRAP(xptro);
-       xpc  = ADDR_MASK(xpc);
-
-       /* Fill and add a stackframeinfo (XPC is equal to RA). */
-
-       stacktrace_stackframeinfo_add(&sfi, pv, sp, xpc, xpc);
-
-       result = NULL;
-
-       /* Get the codeinfo for the current method. */
-
-       code = code_get_codeinfo_for_pv(pv);
-
-       /* Get the methodinfo pointer from the codeinfo pointer. For
-          asm_vm_call_method the codeinfo pointer is NULL and we simply
-          can return the proper exception handler. */
-
-       if (code == NULL) {
-               result = (void *) (uintptr_t) &asm_vm_call_method_exception_handler;
-               goto exceptions_handle_exception_return;
-       }
-
-       m = code->m;
-
-#if !defined(NDEBUG)
-       /* print exception trace */
-
-       if (opt_TraceExceptions)
-               trace_exception(LLNI_DIRECT(xptr), m, xpc);
-
-# if defined(ENABLE_VMLOG)
-       vmlog_cacao_throw(xptr);
-# endif
-#endif
-
-       /* Get the exception table. */
-
-       et = code->exceptiontable;
-
-       if (et != NULL) {
-       /* Iterate over all exception table entries. */
-
-       ete = et->entries;
-
-       for (i = 0; i < et->length; i++, ete++) {
-               /* is the xpc is the current catch range */
-
-               if ((ADDR_MASK(ete->startpc) <= xpc) && (xpc < ADDR_MASK(ete->endpc))) {
-                       cr = ete->catchtype;
-
-                       /* NULL catches everything */
-
-                       if (cr.any == NULL) {
-#if !defined(NDEBUG)
-                               /* Print stacktrace of exception when caught. */
-
-# if defined(ENABLE_VMLOG)
-                               vmlog_cacao_catch(xptr);
-# endif
-
-                               if (opt_TraceExceptions) {
-                                       exceptions_print_exception(xptr);
-                                       stacktrace_print_exception(xptr);
-                               }
-#endif
-
-                               result = ete->handlerpc;
-                               goto exceptions_handle_exception_return;
-                       }
-
-                       /* resolve or load/link the exception class */
-
-                       if (IS_CLASSREF(cr)) {
-                               /* The exception class reference is unresolved. */
-                               /* We have to do _eager_ resolving here. While the
-                                  class of the exception object is guaranteed to be
-                                  loaded, it may well have been loaded by a different
-                                  loader than the defining loader of m's class, which
-                                  is the one we must use to resolve the catch
-                                  class. Thus lazy resolving might fail, even if the
-                                  result of the resolution would be an already loaded
-                                  class. */
-
-                               c = resolve_classref_eager(cr.ref);
-
-                               if (c == NULL) {
-                                       /* Exception resolving the exception class, argh! */
-                                       goto exceptions_handle_exception_return;
-                               }
-
-                               /* Ok, we resolved it. Enter it in the table, so we
-                                  don't have to do this again. */
-                               /* XXX this write should be atomic. Is it? */
-
-                               ete->catchtype.cls = c;
-                       }
-                       else {
-                               c = cr.cls;
-
-                               /* XXX I don't think this case can ever happen. -Edwin */
-                               if (!(c->state & CLASS_LOADED))
-                                       /* use the methods' classloader */
-                                       if (!load_class_from_classloader(c->name,
-                                                                                                        m->clazz->classloader))
-                                               goto exceptions_handle_exception_return;
-
-                               /* XXX I think, if it is not linked, we can be sure
-                                  that the exception object is no (indirect) instance
-                                  of it, no?  -Edwin  */
-                               if (!(c->state & CLASS_LINKED))
-                                       if (!link_class(c))
-                                               goto exceptions_handle_exception_return;
-                       }
-
-                       /* is the thrown exception an instance of the catch class? */
-
-                       if (builtin_instanceof(xptr, c)) {
-#if !defined(NDEBUG)
-                               /* Print stacktrace of exception when caught. */
-
-# if defined(ENABLE_VMLOG)
-                               vmlog_cacao_catch(xptr);
-# endif
-
-                               if (opt_TraceExceptions) {
-                                       exceptions_print_exception(xptr);
-                                       stacktrace_print_exception(xptr);
-                               }
-#endif
-
-                               result = ete->handlerpc;
-                               goto exceptions_handle_exception_return;
-                       }
-               }
-       }
-       }
-
-#if defined(ENABLE_THREADS)
-       /* Is this method realization synchronized? */
-
-       if (code_is_synchronized(code)) {
-               /* Get synchronization object. */
-
-               o = *((java_object_t **) (((uintptr_t) sp) + code->synchronizedoffset));
-
-               assert(o != NULL);
-
-               lock_monitor_exit(LLNI_QUICKWRAP(o));
-       }
-#endif
-
-       /* none of the exceptions catch this one */
-
-#if !defined(NDEBUG)
-# if defined(ENABLE_VMLOG)
-       vmlog_cacao_unwnd_method(m);
-# endif
-
-# if defined(ENABLE_DEBUG_FILTER)
-       if (show_filters_test_verbosecall_exit(m)) {
-# endif
-
-       /* outdent the log message */
-
-       if (opt_verbosecall) {
-               if (TRACEJAVACALLINDENT)
-                       TRACEJAVACALLINDENT--;
-               else
-                       log_text("exceptions_handle_exception: WARNING: unmatched unindent");
-       }
-
-# if defined(ENABLE_DEBUG_FILTER)
-       }
-# endif
-#endif /* !defined(NDEBUG) */
-
-       result = NULL;
-
-exceptions_handle_exception_return:
-
-       /* Remove the stackframeinfo. */
-
-       stacktrace_stackframeinfo_remove(&sfi);
-
-       return result;
-}
-#endif /* defined(ENABLE_JIT) */
-
-
-/* exceptions_print_exception **************************************************
-
-   Prints an exception, the detail message and the cause, if
-   available, with CACAO internal functions to stdout.
-
-*******************************************************************************/
-
-void exceptions_print_exception(java_handle_t *xptr)
-{
-       java_lang_Throwable   *t;
-#if defined(ENABLE_JAVASE)
-       java_lang_Throwable   *cause;
-#endif
-       java_lang_String      *s;
-       classinfo             *c;
-       utf                   *u;
-
-       t = (java_lang_Throwable *) xptr;
-
-       if (t == NULL) {
-               puts("NULL\n");
-               return;
-       }
-
-#if defined(ENABLE_JAVASE)
-       LLNI_field_get_ref(t, cause, cause);
-#endif
-
-       /* print the root exception */
-
-       LLNI_class_get(t, c);
-       utf_display_printable_ascii_classname(c->name);
-
-       LLNI_field_get_ref(t, detailMessage, s);
-
-       if (s != NULL) {
-               u = javastring_toutf((java_handle_t *) s, false);
-
-               printf(": ");
-               utf_display_printable_ascii(u);
-       }
-
-       putc('\n', stdout);
-
-#if defined(ENABLE_JAVASE)
-       /* print the cause if available */
-
-       if ((cause != NULL) && (cause != t)) {
-               printf("Caused by: ");
-               
-               LLNI_class_get(cause, c);
-               utf_display_printable_ascii_classname(c->name);
-
-               LLNI_field_get_ref(cause, detailMessage, s);
-
-               if (s != NULL) {
-                       u = javastring_toutf((java_handle_t *) s, false);
-
-                       printf(": ");
-                       utf_display_printable_ascii(u);
-               }
-
-               putc('\n', stdout);
-       }
-#endif
-}
-
-
-/* exceptions_print_current_exception ******************************************
-
-   Prints the current pending exception, the detail message and the
-   cause, if available, with CACAO internal functions to stdout.
-
-*******************************************************************************/
-
-void exceptions_print_current_exception(void)
-{
-       java_handle_t *o;
-
-       o = exceptions_get_exception();
-
-       exceptions_print_exception(o);
-}
-
-
-/* exceptions_print_stacktrace *************************************************
-
-   Prints a pending exception with Throwable.printStackTrace().  If
-   there happens an exception during printStackTrace(), we print the
-   thrown exception and the original one.
-
-   NOTE: This function calls Java code.
-
-*******************************************************************************/
-
-void exceptions_print_stacktrace(void)
-{
-       java_handle_t    *e;
-       java_handle_t    *ne;
-       classinfo        *c;
-       methodinfo       *m;
-
-#if defined(ENABLE_THREADS)
-       threadobject     *t;
-       java_lang_Thread *to;
-#endif
-
-       /* Get and clear exception because we are calling Java code
-          again. */
-
-       e = exceptions_get_and_clear_exception();
-
-       if (e == NULL)
-               return;
-
-#if 0
-       /* FIXME Enable me. */
-       if (builtin_instanceof(e, class_java_lang_ThreadDeath)) {
-               /* Don't print anything if we are being killed. */
-       }
-       else
-#endif
-       {
-               /* Get the exception class. */
-
-               LLNI_class_get(e, c);
-
-               /* Find the printStackTrace() method. */
-
-               m = class_resolveclassmethod(c,
-                                                                        utf_printStackTrace,
-                                                                        utf_void__void,
-                                                                        class_java_lang_Object,
-                                                                        false);
-
-               if (m == NULL)
-                       vm_abort("exceptions_print_stacktrace: printStackTrace()V not found");
-
-               /* Print message. */
-
-               fprintf(stderr, "Exception ");
-
-#if defined(ENABLE_THREADS)
-               /* Print thread name.  We get the thread here explicitly as we
-                  need it afterwards. */
-
-               t  = thread_get_current();
-               to = (java_lang_Thread *) thread_get_object(t);
-
-               if (to != NULL) {
-                       fprintf(stderr, "in thread \"");
-                       thread_fprint_name(t, stderr);
-                       fprintf(stderr, "\" ");
-               }
-#endif
-
-               /* Print the stacktrace. */
-
-               if (builtin_instanceof(e, class_java_lang_Throwable)) {
-                       (void) vm_call_method(m, e);
-
-                       /* If this happens we are EXTREMLY out of memory or have a
-                          serious problem while printStackTrace.  But may be
-                          another exception, so print it. */
-
-                       ne = exceptions_get_exception();
-
-                       if (ne != NULL) {
-                               fprintf(stderr, "Exception while printStackTrace(): ");
-
-                               /* Print the current exception. */
-
-                               exceptions_print_exception(ne);
-                               stacktrace_print_exception(ne);
-
-                               /* Now print the original exception. */
-
-                               fprintf(stderr, "Original exception was: ");
-                               exceptions_print_exception(e);
-                               stacktrace_print_exception(e);
-                       }
-               }
-               else {
-                       fprintf(stderr, ". Uncaught exception of type ");
-#if !defined(NDEBUG)
-                       /* FIXME This prints to stdout. */
-                       class_print(c);
-#else
-                       fprintf(stderr, "UNKNOWN");
-#endif
-                       fprintf(stderr, ".");
-               }
-
-               fflush(stderr);
-       }
-}
-
-
-/*
- * 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/exceptions.cpp b/src/vm/exceptions.cpp
new file mode 100644 (file)
index 0000000..5f01f22
--- /dev/null
@@ -0,0 +1,2090 @@
+/* src/vm/exceptions.cpp - exception 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 <string.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+
+#include "vm/types.h"
+
+#include "md-abi.h"
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+#include "native/native.hpp"
+
+#include "threads/lock.hpp"
+#include "threads/thread.hpp"
+
+#include "toolbox/util.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/loader.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/os.hpp"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/methodheader.h"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/show.hpp"
+#include "vm/jit/stacktrace.hpp"
+#include "vm/jit/trace.hpp"
+
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
+
+// FIXME
+extern "C" {
+
+/* for raising exceptions from native methods *********************************/
+
+#if !defined(ENABLE_THREADS)
+java_object_t *_no_threads_exceptionptr = NULL;
+#endif
+
+
+/* exceptions_get_exception ****************************************************
+
+   Returns the current exception pointer of the current thread.
+
+*******************************************************************************/
+
+java_handle_t *exceptions_get_exception(void)
+{
+       java_object_t *o;
+       java_handle_t *e;
+#if defined(ENABLE_THREADS)
+       threadobject  *t;
+
+       t = THREADOBJECT;
+#endif
+
+       /* Get the exception. */
+
+       LLNI_CRITICAL_START;
+
+#if defined(ENABLE_THREADS)
+       o = t->_exceptionptr;
+#else
+       o = _no_threads_exceptionptr;
+#endif
+
+       e = LLNI_WRAP(o);
+
+       LLNI_CRITICAL_END;
+
+       /* Return the exception. */
+
+       return e;
+}
+
+
+/* exceptions_set_exception ****************************************************
+
+   Sets the exception pointer of the current thread.
+
+*******************************************************************************/
+
+void exceptions_set_exception(java_handle_t *e)
+{
+       threadobject  *t;
+       java_object_t *o;
+
+#if defined(ENABLE_THREADS)
+       t = THREADOBJECT;
+#else
+       t = NULL;
+#endif
+
+       /* Set the exception. */
+
+       LLNI_CRITICAL_START;
+
+       o = LLNI_UNWRAP(e);
+
+#if !defined(NDEBUG)
+       if (opt_DebugExceptions) {
+               printf("[exceptions_set_exception  : t=%p, o=%p, class=",
+                          (void *) t, (void *) o);
+               class_print(o->vftbl->clazz);
+               printf("]\n");
+       }
+#endif
+
+#if defined(ENABLE_THREADS)
+       t->_exceptionptr = o;
+#else
+       _no_threads_exceptionptr = o;
+#endif
+
+       LLNI_CRITICAL_END;
+}
+
+
+/* exceptions_clear_exception **************************************************
+
+   Clears the current exception pointer of the current thread.
+
+*******************************************************************************/
+
+void exceptions_clear_exception(void)
+{
+       threadobject *t;
+
+#if defined(ENABLE_THREADS)
+       t = THREADOBJECT;
+#else
+       t = NULL;
+#endif
+
+       /* Set the exception. */
+
+#if !defined(NDEBUG)
+       if (opt_DebugExceptions) {
+               printf("[exceptions_clear_exception: t=%p]\n", (void *) t);
+       }
+#endif
+
+#if defined(ENABLE_THREADS)
+       t->_exceptionptr = NULL;
+#else
+       _no_threads_exceptionptr = NULL;
+#endif
+}
+
+
+/* exceptions_get_and_clear_exception ******************************************
+
+   Gets the exception pointer of the current thread and clears it.
+   This function may return NULL.
+
+*******************************************************************************/
+
+java_handle_t *exceptions_get_and_clear_exception(void)
+{
+       java_handle_t *o;
+
+       /* Get the exception... */
+
+       o = exceptions_get_exception();
+
+       /* ...and clear the exception if it is set. */
+
+       if (o != NULL)
+               exceptions_clear_exception();
+
+       /* return the exception */
+
+       return o;
+}
+
+
+/* exceptions_abort ************************************************************
+
+   Prints exception to be thrown and aborts.
+
+   IN:
+      classname....class name
+      message......exception message
+
+*******************************************************************************/
+
+static void exceptions_abort(utf *classname, utf *message)
+{
+       log_println("exception thrown while VM is initializing: ");
+
+       log_start();
+       utf_display_printable_ascii_classname(classname);
+
+       if (message != NULL) {
+               log_print(": ");
+               utf_display_printable_ascii_classname(message);
+       }
+
+       log_finish();
+
+       os::abort("Aborting...");
+}
+
+
+/* exceptions_new_class_utf ****************************************************
+
+   Creates an exception object with the given class and initalizes it
+   with the given utf message.
+
+   IN:
+      c ......... exception class
+         message ... the message as an utf *
+
+   RETURN VALUE:
+     an exception pointer (in any case -- either it is the newly
+     created exception, or an exception thrown while trying to create
+     it).
+
+*******************************************************************************/
+
+static java_handle_t *exceptions_new_class_utf(classinfo *c, utf *message)
+{
+       java_handle_t *s;
+       java_handle_t *o;
+
+       if (VM::get_current()->is_initializing()) {
+               /* This can happen when global class variables are used which
+                  are not initialized yet. */
+
+               if (c == NULL)
+                       exceptions_abort(NULL, message);
+               else
+                       exceptions_abort(c->name, message);
+       }
+
+       s = javastring_new(message);
+
+       if (s == NULL)
+               return exceptions_get_exception();
+
+       o = native_new_and_init_string(c, s);
+
+       if (o == NULL)
+               return exceptions_get_exception();
+
+       return o;
+}
+
+
+/* exceptions_new_utf **********************************************************
+
+   Creates an exception object with the given name and initalizes it.
+
+   IN:
+      classname....class name in UTF-8
+
+*******************************************************************************/
+
+static java_handle_t *exceptions_new_utf(utf *classname)
+{
+       classinfo     *c;
+       java_handle_t *o;
+
+       if (VM::get_current()->is_initializing())
+               exceptions_abort(classname, NULL);
+
+       c = load_class_bootstrap(classname);
+
+       if (c == NULL)
+               return exceptions_get_exception();
+
+       o = native_new_and_init(c);
+
+       if (o == NULL)
+               return exceptions_get_exception();
+
+       return o;
+}
+
+
+/* exceptions_new_utf_javastring ***********************************************
+
+   Creates an exception object with the given name and initalizes it
+   with the given java/lang/String message.
+
+   IN:
+      classname....class name in UTF-8
+         message......the message as a java.lang.String
+
+   RETURN VALUE:
+      an exception pointer (in any case -- either it is the newly created
+         exception, or an exception thrown while trying to create it).
+
+*******************************************************************************/
+
+static java_handle_t *exceptions_new_utf_javastring(utf *classname,
+                                                                                                       java_handle_t *message)
+{
+       java_handle_t *o;
+       classinfo     *c;
+   
+       if (VM::get_current()->is_initializing())
+               exceptions_abort(classname, NULL);
+
+       c = load_class_bootstrap(classname);
+
+       if (c == NULL)
+               return exceptions_get_exception();
+
+       o = native_new_and_init_string(c, message);
+
+       if (o == NULL)
+               return exceptions_get_exception();
+
+       return o;
+}
+
+
+/* exceptions_new_utf_utf ******************************************************
+
+   Creates an exception object with the given name and initalizes it
+   with the given utf message.
+
+   IN:
+      classname....class name in UTF-8
+         message......the message as an utf *
+
+   RETURN VALUE:
+      an exception pointer (in any case -- either it is the newly created
+         exception, or an exception thrown while trying to create it).
+
+*******************************************************************************/
+
+static java_handle_t *exceptions_new_utf_utf(utf *classname, utf *message)
+{
+       classinfo     *c;
+       java_handle_t *o;
+
+       if (VM::get_current()->is_initializing())
+               exceptions_abort(classname, message);
+
+       c = load_class_bootstrap(classname);
+
+       if (c == NULL)
+               return exceptions_get_exception();
+
+       o = exceptions_new_class_utf(c, message);
+
+       return o;
+}
+
+
+/* exceptions_throw_class_utf **************************************************
+
+   Creates an exception object with the given class, initalizes and
+   throws it with the given utf message.
+
+   IN:
+      c ......... exception class
+         message ... the message as an utf *
+
+*******************************************************************************/
+
+static void exceptions_throw_class_utf(classinfo *c, utf *message)
+{
+       java_handle_t *o;
+
+       o = exceptions_new_class_utf(c, message);
+
+       exceptions_set_exception(o);
+}
+
+
+/* exceptions_throw_utf ********************************************************
+
+   Creates an exception object with the given name, initalizes and
+   throws it.
+
+   IN:
+      classname....class name in UTF-8
+
+*******************************************************************************/
+
+static void exceptions_throw_utf(utf *classname)
+{
+       java_handle_t *o;
+
+       o = exceptions_new_utf(classname);
+
+       if (o == NULL)
+               return;
+
+       exceptions_set_exception(o);
+}
+
+
+/* exceptions_throw_utf_throwable **********************************************
+
+   Creates an exception object with the given name and initalizes it
+   with the given java/lang/Throwable exception.
+
+   IN:
+      classname....class name in UTF-8
+         cause........the given Throwable
+
+*******************************************************************************/
+
+static void exceptions_throw_utf_throwable(utf *classname,
+                                                                                  java_handle_t *cause)
+{
+       classinfo           *c;
+       methodinfo          *m;
+
+       if (VM::get_current()->is_initializing())
+               exceptions_abort(classname, NULL);
+
+       java_lang_Throwable jlt(cause);
+
+       c = load_class_bootstrap(classname);
+
+       if (c == NULL)
+               return;
+
+       /* create object */
+
+       java_handle_t* h = builtin_new(c);
+
+       if (h == NULL)
+               return;
+
+       /* call initializer */
+
+       m = class_resolveclassmethod(c,
+                                                                utf_init,
+                                                                utf_java_lang_Throwable__void,
+                                                                NULL,
+                                                                true);
+                                                     
+       if (m == NULL)
+               return;
+
+       (void) vm_call_method(m, h, jlt.get_handle());
+
+       exceptions_set_exception(h);
+}
+
+
+/* exceptions_throw_utf_exception **********************************************
+
+   Creates an exception object with the given name and initalizes it
+   with the given java/lang/Exception exception.
+
+   IN:
+      classname....class name in UTF-8
+         exception....the given Exception
+
+*******************************************************************************/
+
+static void exceptions_throw_utf_exception(utf *classname,
+                                                                                  java_handle_t *exception)
+{
+       classinfo     *c;
+       java_handle_t *o;
+       methodinfo    *m;
+
+       if (VM::get_current()->is_initializing())
+               exceptions_abort(classname, NULL);
+
+       c = load_class_bootstrap(classname);
+
+       if (c == NULL)
+               return;
+
+       /* create object */
+
+       o = builtin_new(c);
+       
+       if (o == NULL)
+               return;
+
+       /* call initializer */
+
+       m = class_resolveclassmethod(c,
+                                                                utf_init,
+                                                                utf_java_lang_Exception__V,
+                                                                NULL,
+                                                                true);
+                                                     
+       if (m == NULL)
+               return;
+
+       (void) vm_call_method(m, o, exception);
+
+       exceptions_set_exception(o);
+}
+
+
+/* exceptions_throw_utf_cause **************************************************
+
+   Creates an exception object with the given name and initalizes it
+   with the given java/lang/Throwable exception with initCause.
+
+   IN:
+      classname....class name in UTF-8
+         cause........the given Throwable
+
+*******************************************************************************/
+
+static void exceptions_throw_utf_cause(utf *classname, java_handle_t *cause)
+{
+       if (VM::get_current()->is_initializing())
+               exceptions_abort(classname, NULL);
+
+       java_lang_Throwable jltcause(cause);
+
+       classinfo* c = load_class_bootstrap(classname);
+
+       if (c == NULL)
+               return;
+
+       /* create object */
+
+       java_handle_t* h = builtin_new(c);
+       
+       if (h == NULL)
+               return;
+
+       /* call initializer */
+
+       methodinfo* m = class_resolveclassmethod(c,
+                                                                                        utf_init,
+                                                                                        utf_java_lang_String__void,
+                                                                                        NULL,
+                                                                                        true);
+                                                     
+       if (m == NULL)
+               return;
+
+       (void) vm_call_method(m, h, jltcause.get_detailMessage());
+
+       /* call initCause */
+
+       m = class_resolveclassmethod(c,
+                                                                utf_initCause,
+                                                                utf_java_lang_Throwable__java_lang_Throwable,
+                                                                NULL,
+                                                                true);
+
+       if (m == NULL)
+               return;
+
+       (void) vm_call_method(m, h, jltcause.get_handle());
+
+       exceptions_set_exception(h);
+}
+
+
+/* exceptions_throw_utf_utf ****************************************************
+
+   Creates an exception object with the given name, initalizes and
+   throws it with the given utf message.
+
+   IN:
+      classname....class name in UTF-8
+         message......the message as an utf *
+
+*******************************************************************************/
+
+static void exceptions_throw_utf_utf(utf *classname, utf *message)
+{
+       java_handle_t *o;
+
+       o = exceptions_new_utf_utf(classname, message);
+
+       exceptions_set_exception(o);
+}
+
+
+/* exceptions_new_abstractmethoderror ****************************************
+
+   Generates a java.lang.AbstractMethodError for the VM.
+
+*******************************************************************************/
+
+java_handle_t *exceptions_new_abstractmethoderror(void)
+{
+       java_handle_t *o;
+
+       o = exceptions_new_utf(utf_java_lang_AbstractMethodError);
+
+       return o;
+}
+
+
+/* exceptions_new_error ********************************************************
+
+   Generates a java.lang.Error for the VM.
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVAME_CLDC1_1)
+static java_handle_t *exceptions_new_error(utf *message)
+{
+       java_handle_t *o;
+
+       o = exceptions_new_utf_utf(utf_java_lang_Error, message);
+
+       return o;
+}
+#endif
+
+
+/* exceptions_asm_new_abstractmethoderror **************************************
+
+   Generates a java.lang.AbstractMethodError for
+   asm_abstractmethoderror.
+
+*******************************************************************************/
+
+java_object_t *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra)
+{
+       stackframeinfo_t  sfi;
+       java_handle_t    *e;
+       java_object_t    *o;
+
+       /* Fill and add a stackframeinfo (XPC is equal to RA). */
+
+       stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra);
+
+       /* create the exception */
+
+#if defined(ENABLE_JAVASE)
+       e = exceptions_new_abstractmethoderror();
+#else
+       e = exceptions_new_error(utf_java_lang_AbstractMethodError);
+#endif
+
+       /* Remove the stackframeinfo. */
+
+       stacktrace_stackframeinfo_remove(&sfi);
+
+       /* unwrap the exception */
+       /* ATTENTION: do the this _after_ the stackframeinfo was removed */
+
+       o = LLNI_UNWRAP(e);
+
+       return o;
+}
+
+
+/* exceptions_new_arraystoreexception ******************************************
+
+   Generates a java.lang.ArrayStoreException for the VM.
+
+*******************************************************************************/
+
+java_handle_t *exceptions_new_arraystoreexception(void)
+{
+       java_handle_t *o;
+
+       o = exceptions_new_utf(utf_java_lang_ArrayStoreException);
+
+       return o;
+}
+
+
+/* exceptions_throw_abstractmethoderror ****************************************
+
+   Generates and throws a java.lang.AbstractMethodError for the VM.
+
+*******************************************************************************/
+
+void exceptions_throw_abstractmethoderror(void)
+{
+       exceptions_throw_utf(utf_java_lang_AbstractMethodError);
+}
+
+
+/* exceptions_throw_classcircularityerror **************************************
+
+   Generates and throws a java.lang.ClassCircularityError for the
+   classloader.
+
+   IN:
+      c....the class in which the error was found
+
+*******************************************************************************/
+
+void exceptions_throw_classcircularityerror(classinfo *c)
+{
+       exceptions_throw_utf_utf(utf_java_lang_ClassCircularityError, c->name);
+}
+
+
+/* exceptions_throw_classformaterror *******************************************
+
+   Generates and throws a java.lang.ClassFormatError for the VM.
+
+   IN:
+      c............the class in which the error was found
+         message......UTF-8 format string
+
+*******************************************************************************/
+
+void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
+{
+       char    *msg;
+       s4       msglen;
+       va_list  ap;
+       utf     *u;
+
+       /* calculate message length */
+
+       msglen = 0;
+
+       if (c != NULL)
+               msglen += utf_bytes(c->name) + strlen(" (");
+
+       va_start(ap, message);
+       msglen += get_variable_message_length(message, ap);
+       va_end(ap);
+
+       if (c != NULL)
+               msglen += strlen(")");
+
+       msglen += strlen("0");
+
+       /* allocate a buffer */
+
+       msg = MNEW(char, msglen);
+
+       /* print message into allocated buffer */
+
+       if (c != NULL) {
+               utf_copy_classname(msg, c->name);
+               strcat(msg, " (");
+       }
+
+       va_start(ap, message);
+       vsprintf(msg + strlen(msg), message, ap);
+       va_end(ap);
+
+       if (c != NULL)
+               strcat(msg, ")");
+
+       u = utf_new_char(msg);
+
+       /* free memory */
+
+       MFREE(msg, char, msglen);
+
+       /* throw exception */
+
+       exceptions_throw_utf_utf(utf_java_lang_ClassFormatError, u);
+}
+
+
+/* exceptions_throw_classnotfoundexception *************************************
+
+   Generates and throws a java.lang.ClassNotFoundException for the
+   VM.
+
+   IN:
+      name.........name of the class not found as a utf *
+
+*******************************************************************************/
+
+void exceptions_throw_classnotfoundexception(utf *name)
+{      
+       exceptions_throw_class_utf(class_java_lang_ClassNotFoundException, name);
+}
+
+
+/* exceptions_throw_noclassdeffounderror ***************************************
+
+   Generates and throws a java.lang.NoClassDefFoundError.
+
+   IN:
+      name.........name of the class not found as a utf *
+
+*******************************************************************************/
+
+void exceptions_throw_noclassdeffounderror(utf *name)
+{
+       exceptions_throw_utf_utf(utf_java_lang_NoClassDefFoundError, name);
+}
+
+
+/* exceptions_throw_noclassdeffounderror_cause *********************************
+
+   Generates and throws a java.lang.NoClassDefFoundError with the
+   given cause.
+
+*******************************************************************************/
+
+void exceptions_throw_noclassdeffounderror_cause(java_handle_t *cause)
+{
+       exceptions_throw_utf_cause(utf_java_lang_NoClassDefFoundError, cause);
+}
+
+
+/* exceptions_throw_noclassdeffounderror_wrong_name ****************************
+
+   Generates and throws a java.lang.NoClassDefFoundError with a
+   specific message:
+
+   IN:
+      name.........name of the class not found as a utf *
+
+*******************************************************************************/
+
+void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name)
+{
+       char *msg;
+       s4    msglen;
+       utf  *u;
+
+       msglen = utf_bytes(c->name) + strlen(" (wrong name: ") +
+               utf_bytes(name) + strlen(")") + strlen("0");
+
+       msg = MNEW(char, msglen);
+
+       utf_copy_classname(msg, c->name);
+       strcat(msg, " (wrong name: ");
+       utf_cat_classname(msg, name);
+       strcat(msg, ")");
+
+       u = utf_new_char(msg);
+
+       MFREE(msg, char, msglen);
+
+       exceptions_throw_noclassdeffounderror(u);
+}
+
+
+/* exceptions_throw_exceptionininitializererror ********************************
+
+   Generates and throws a java.lang.ExceptionInInitializerError for
+   the VM.
+
+   IN:
+      cause......cause exception object
+
+*******************************************************************************/
+
+void exceptions_throw_exceptionininitializererror(java_handle_t *cause)
+{
+       exceptions_throw_utf_throwable(utf_java_lang_ExceptionInInitializerError,
+                                                                  cause);
+}
+
+
+/* exceptions_throw_incompatibleclasschangeerror *******************************
+
+   Generates and throws a java.lang.IncompatibleClassChangeError for
+   the VM.
+
+   IN:
+      message......UTF-8 message format string
+
+*******************************************************************************/
+
+void exceptions_throw_incompatibleclasschangeerror(classinfo *c, const char *message)
+{
+       char *msg;
+       s4    msglen;
+       utf  *u;
+
+       /* calculate exception message length */
+
+       msglen = utf_bytes(c->name) + strlen(message) + strlen("0");
+
+       /* allocate memory */
+
+       msg = MNEW(char, msglen);
+
+       utf_copy_classname(msg, c->name);
+       strcat(msg, message);
+
+       u = utf_new_char(msg);
+
+       /* free memory */
+
+       MFREE(msg, char, msglen);
+
+       /* throw exception */
+
+       exceptions_throw_utf_utf(utf_java_lang_IncompatibleClassChangeError, u);
+}
+
+
+/* exceptions_throw_instantiationerror *****************************************
+
+   Generates and throws a java.lang.InstantiationError for the VM.
+
+*******************************************************************************/
+
+void exceptions_throw_instantiationerror(classinfo *c)
+{
+       exceptions_throw_utf_utf(utf_java_lang_InstantiationError, c->name);
+}
+
+
+/* exceptions_throw_internalerror **********************************************
+
+   Generates and throws a java.lang.InternalError for the VM.
+
+   IN:
+      message......UTF-8 message format string
+
+*******************************************************************************/
+
+void exceptions_throw_internalerror(const char *message, ...)
+{
+       va_list  ap;
+       char    *msg;
+       s4       msglen;
+       utf     *u;
+
+       /* calculate exception message length */
+
+       va_start(ap, message);
+       msglen = get_variable_message_length(message, ap);
+       va_end(ap);
+
+       /* allocate memory */
+
+       msg = MNEW(char, msglen);
+
+       /* generate message */
+
+       va_start(ap, message);
+       vsprintf(msg, message, ap);
+       va_end(ap);
+
+       u = utf_new_char(msg);
+
+       /* free memory */
+
+       MFREE(msg, char, msglen);
+
+       /* throw exception */
+
+       exceptions_throw_utf_utf(utf_java_lang_InternalError, u);
+}
+
+
+/* exceptions_throw_linkageerror ***********************************************
+
+   Generates and throws java.lang.LinkageError with an error message.
+
+   IN:
+      message......UTF-8 message
+         c............class related to the error. If this is != NULL
+                      the name of c is appended to the error message.
+
+*******************************************************************************/
+
+void exceptions_throw_linkageerror(const char *message, classinfo *c)
+{
+       utf  *u;
+       char *msg;
+       int   len;
+
+       /* calculate exception message length */
+
+       len = strlen(message) + 1;
+
+       if (c != NULL)
+               len += utf_bytes(c->name);
+               
+       /* allocate memory */
+
+       msg = MNEW(char, len);
+
+       /* generate message */
+
+       strcpy(msg, message);
+
+       if (c != NULL)
+               utf_cat_classname(msg, c->name);
+
+       u = utf_new_char(msg);
+
+       /* free memory */
+
+       MFREE(msg, char, len);
+
+       exceptions_throw_utf_utf(utf_java_lang_LinkageError, u);
+}
+
+
+/* exceptions_throw_nosuchfielderror *******************************************
+
+   Generates and throws a java.lang.NoSuchFieldError with an error
+   message.
+
+   IN:
+      c............class in which the field was not found
+         name.........name of the field
+
+*******************************************************************************/
+
+void exceptions_throw_nosuchfielderror(classinfo *c, utf *name)
+{
+       char *msg;
+       s4    msglen;
+       utf  *u;
+
+       /* calculate exception message length */
+
+       msglen = utf_bytes(c->name) + strlen(".") + utf_bytes(name) + strlen("0");
+
+       /* allocate memory */
+
+       msg = MNEW(char, msglen);
+
+       /* generate message */
+
+       utf_copy_classname(msg, c->name);
+       strcat(msg, ".");
+       utf_cat(msg, name);
+
+       u = utf_new_char(msg);
+
+       /* free memory */
+
+       MFREE(msg, char, msglen);
+
+       exceptions_throw_utf_utf(utf_java_lang_NoSuchFieldError, u);
+}
+
+
+/* exceptions_throw_nosuchmethoderror ******************************************
+
+   Generates and throws a java.lang.NoSuchMethodError with an error
+   message.
+
+   IN:
+      c............class in which the method was not found
+         name.........name of the method
+         desc.........descriptor of the method
+
+*******************************************************************************/
+
+void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc)
+{
+       char *msg;
+       s4    msglen;
+       utf  *u;
+
+       /* calculate exception message length */
+
+       msglen = utf_bytes(c->name) + strlen(".") + utf_bytes(name) +
+               utf_bytes(desc) + strlen("0");
+
+       /* allocate memory */
+
+       msg = MNEW(char, msglen);
+
+       /* generate message */
+
+       utf_copy_classname(msg, c->name);
+       strcat(msg, ".");
+       utf_cat(msg, name);
+       utf_cat(msg, desc);
+
+       u = utf_new_char(msg);
+
+       /* free memory */
+
+       MFREE(msg, char, msglen);
+
+#if defined(ENABLE_JAVASE)
+       exceptions_throw_utf_utf(utf_java_lang_NoSuchMethodError, u);
+#else
+       exceptions_throw_utf_utf(utf_java_lang_Error, u);
+#endif
+}
+
+
+/* exceptions_throw_outofmemoryerror *******************************************
+
+   Generates and throws an java.lang.OutOfMemoryError for the VM.
+
+*******************************************************************************/
+
+void exceptions_throw_outofmemoryerror(void)
+{
+       exceptions_throw_utf(utf_java_lang_OutOfMemoryError);
+}
+
+
+/* exceptions_throw_unsatisfiedlinkerror ***************************************
+
+   Generates and throws a java.lang.UnsatisfiedLinkError for the
+   classloader.
+
+   IN:
+         name......UTF-8 name string
+
+*******************************************************************************/
+
+void exceptions_throw_unsatisfiedlinkerror(utf *name)
+{
+#if defined(ENABLE_JAVASE)
+       exceptions_throw_utf_utf(utf_java_lang_UnsatisfiedLinkError, name);
+#else
+       exceptions_throw_utf_utf(utf_java_lang_Error, name);
+#endif
+}
+
+
+/* exceptions_throw_unsupportedclassversionerror *******************************
+
+   Generates and throws a java.lang.UnsupportedClassVersionError for
+   the classloader.
+
+   IN:
+      c............class in which the method was not found
+         message......UTF-8 format string
+
+*******************************************************************************/
+
+void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi)
+{
+       char *msg;
+    s4    msglen;
+       utf  *u;
+
+       /* calculate exception message length */
+
+       msglen =
+               utf_bytes(c->name) +
+               strlen(" (Unsupported major.minor version 00.0)") +
+               strlen("0");
+
+       /* allocate memory */
+
+       msg = MNEW(char, msglen);
+
+       /* generate message */
+
+       utf_copy_classname(msg, c->name);
+       sprintf(msg + strlen(msg), " (Unsupported major.minor version %d.%d)",
+                       ma, mi);
+
+       u = utf_new_char(msg);
+
+       /* free memory */
+
+       MFREE(msg, char, msglen);
+
+       /* throw exception */
+
+       exceptions_throw_utf_utf(utf_java_lang_UnsupportedClassVersionError, u);
+}
+
+
+/* exceptions_throw_verifyerror ************************************************
+
+   Generates and throws a java.lang.VerifyError for the JIT compiler.
+
+   IN:
+      m............method in which the error was found
+         message......UTF-8 format string
+
+*******************************************************************************/
+
+void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...)
+{
+       va_list  ap;
+       char    *msg;
+       s4       msglen;
+       utf     *u;
+
+       /* calculate exception message length */
+
+       msglen = 0;
+
+       if (m != NULL)
+               msglen =
+                       strlen("(class: ") + utf_bytes(m->clazz->name) +
+                       strlen(", method: ") + utf_bytes(m->name) +
+                       strlen(" signature: ") + utf_bytes(m->descriptor) +
+                       strlen(") ") + strlen("0");
+
+       va_start(ap, message);
+       msglen += get_variable_message_length(message, ap);
+       va_end(ap);
+
+       /* allocate memory */
+
+       msg = MNEW(char, msglen);
+
+       /* generate message */
+
+       if (m != NULL) {
+               strcpy(msg, "(class: ");
+               utf_cat_classname(msg, m->clazz->name);
+               strcat(msg, ", method: ");
+               utf_cat(msg, m->name);
+               strcat(msg, " signature: ");
+               utf_cat(msg, m->descriptor);
+               strcat(msg, ") ");
+       }
+
+       va_start(ap, message);
+       vsprintf(msg + strlen(msg), message, ap);
+       va_end(ap);
+
+       u = utf_new_char(msg);
+
+       /* free memory */
+
+       MFREE(msg, char, msglen);
+
+       /* throw exception */
+
+       exceptions_throw_utf_utf(utf_java_lang_VerifyError, u);
+}
+
+
+/* exceptions_throw_verifyerror_for_stack **************************************
+
+   throws a java.lang.VerifyError for an invalid stack slot type
+
+   IN:
+      m............method in which the error was found
+         type.........the expected type
+
+   RETURN VALUE:
+      an exception pointer (in any case -- either it is the newly created
+         exception, or an exception thrown while trying to create it).
+
+*******************************************************************************/
+
+void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type)
+{
+       char *msg;
+       s4    msglen;
+       utf  *u;
+
+       /* calculate exception message length */
+
+       msglen = 0;
+
+       if (m != NULL)
+               msglen = strlen("(class: ") + utf_bytes(m->clazz->name) +
+                       strlen(", method: ") + utf_bytes(m->name) +
+                       strlen(" signature: ") + utf_bytes(m->descriptor) +
+                       strlen(") Expecting to find longest-------typename on stack") 
+                       + strlen("0");
+
+       /* allocate memory */
+
+       msg = MNEW(char, msglen);
+
+       /* generate message */
+
+       if (m != NULL) {
+               strcpy(msg, "(class: ");
+               utf_cat_classname(msg, m->clazz->name);
+               strcat(msg, ", method: ");
+               utf_cat(msg, m->name);
+               strcat(msg, " signature: ");
+               utf_cat(msg, m->descriptor);
+               strcat(msg, ") ");
+       }
+       else {
+               msg[0] = 0;
+       }
+
+       strcat(msg, "Expecting to find ");
+
+       const char *name;
+
+       switch (type) {
+       case TYPE_INT: name = "integer";       break;
+       case TYPE_LNG: name = "long";          break;
+       case TYPE_FLT: name = "float";         break;
+       case TYPE_DBL: name = "double";        break;
+       case TYPE_ADR: name = "object/array";  break;
+       case TYPE_RET: name = "returnAddress"; break;
+       default:       name = "<INVALID>"; assert(0); break;
+       }
+
+       strcat(msg, name);
+       strcat(msg, " on stack");
+
+       u = utf_new_char(msg);
+
+       /* free memory */
+
+       MFREE(msg, char, msglen);
+
+       /* throw exception */
+
+       exceptions_throw_utf_utf(utf_java_lang_VerifyError, u);
+}
+
+
+/* exceptions_new_arithmeticexception ******************************************
+
+   Generates a java.lang.ArithmeticException for the JIT compiler.
+
+*******************************************************************************/
+
+java_handle_t *exceptions_new_arithmeticexception(void)
+{
+       java_handle_t *o;
+
+       o = exceptions_new_utf_utf(utf_java_lang_ArithmeticException,
+                                                          utf_division_by_zero);
+
+       return o;
+}
+
+
+/* exceptions_new_arrayindexoutofboundsexception *******************************
+
+   Generates a java.lang.ArrayIndexOutOfBoundsException for the VM
+   system.
+
+*******************************************************************************/
+
+java_handle_t *exceptions_new_arrayindexoutofboundsexception(s4 index)
+{
+       java_handle_t *o;
+       methodinfo    *m;
+       java_handle_t *s;
+
+       /* convert the index into a String, like Sun does */
+
+       m = class_resolveclassmethod(class_java_lang_String,
+                                                                utf_new_char("valueOf"),
+                                                                utf_new_char("(I)Ljava/lang/String;"),
+                                                                class_java_lang_Object,
+                                                                true);
+
+       if (m == NULL)
+               return exceptions_get_exception();
+
+       s = vm_call_method(m, NULL, index);
+
+       if (s == NULL)
+               return exceptions_get_exception();
+
+       o = exceptions_new_utf_javastring(utf_java_lang_ArrayIndexOutOfBoundsException,
+                                                                         s);
+
+       if (o == NULL)
+               return exceptions_get_exception();
+
+       return o;
+}
+
+
+/* exceptions_throw_arrayindexoutofboundsexception *****************************
+
+   Generates and throws a java.lang.ArrayIndexOutOfBoundsException for
+   the VM.
+
+*******************************************************************************/
+
+void exceptions_throw_arrayindexoutofboundsexception(void)
+{
+       exceptions_throw_utf(utf_java_lang_ArrayIndexOutOfBoundsException);
+}
+
+
+/* exceptions_throw_arraystoreexception ****************************************
+
+   Generates and throws a java.lang.ArrayStoreException for the VM.
+
+*******************************************************************************/
+
+void exceptions_throw_arraystoreexception(void)
+{
+       exceptions_throw_utf(utf_java_lang_ArrayStoreException);
+}
+
+
+/* exceptions_new_classcastexception *******************************************
+
+   Generates a java.lang.ClassCastException for the JIT compiler.
+
+*******************************************************************************/
+
+java_handle_t *exceptions_new_classcastexception(java_handle_t *o)
+{
+       java_handle_t *e;
+       classinfo     *c;
+       utf           *classname;
+
+       LLNI_class_get(o, c);
+
+       classname = c->name;
+
+       e = exceptions_new_utf_utf(utf_java_lang_ClassCastException, classname);
+
+       return e;
+}
+
+
+/* exceptions_throw_clonenotsupportedexception *********************************
+
+   Generates and throws a java.lang.CloneNotSupportedException for the
+   VM.
+
+*******************************************************************************/
+
+void exceptions_throw_clonenotsupportedexception(void)
+{
+       exceptions_throw_utf(utf_java_lang_CloneNotSupportedException);
+}
+
+
+/* exceptions_throw_illegalaccessexception *************************************
+
+   Generates and throws a java.lang.IllegalAccessException for the VM.
+
+*******************************************************************************/
+
+void exceptions_throw_illegalaccessexception(utf *message)
+{
+       exceptions_throw_utf_utf(utf_java_lang_IllegalAccessException, message);
+}
+
+
+/* exceptions_throw_illegalargumentexception ***********************************
+
+   Generates and throws a java.lang.IllegalArgumentException for the
+   VM.
+
+*******************************************************************************/
+
+void exceptions_throw_illegalargumentexception(void)
+{
+       exceptions_throw_utf(utf_java_lang_IllegalArgumentException);
+}
+
+
+/* exceptions_throw_illegalmonitorstateexception *******************************
+
+   Generates and throws a java.lang.IllegalMonitorStateException for
+   the VM.
+
+*******************************************************************************/
+
+void exceptions_throw_illegalmonitorstateexception(void)
+{
+       exceptions_throw_utf(utf_java_lang_IllegalMonitorStateException);
+}
+
+
+/* exceptions_throw_instantiationexception *************************************
+
+   Generates and throws a java.lang.InstantiationException for the VM.
+
+*******************************************************************************/
+
+void exceptions_throw_instantiationexception(classinfo *c)
+{
+       exceptions_throw_utf_utf(utf_java_lang_InstantiationException, c->name);
+}
+
+
+/* exceptions_throw_interruptedexception ***************************************
+
+   Generates and throws a java.lang.InterruptedException for the VM.
+
+*******************************************************************************/
+
+void exceptions_throw_interruptedexception(void)
+{
+       exceptions_throw_utf(utf_java_lang_InterruptedException);
+}
+
+
+/* exceptions_throw_invocationtargetexception **********************************
+
+   Generates and throws a java.lang.reflect.InvocationTargetException
+   for the VM.
+
+   IN:
+      cause......cause exception object
+
+*******************************************************************************/
+
+void exceptions_throw_invocationtargetexception(java_handle_t *cause)
+{
+       exceptions_throw_utf_throwable(utf_java_lang_reflect_InvocationTargetException,
+                                                                  cause);
+}
+
+
+/* exceptions_throw_negativearraysizeexception *********************************
+
+   Generates and throws a java.lang.NegativeArraySizeException for the
+   VM.
+
+*******************************************************************************/
+
+void exceptions_throw_negativearraysizeexception(void)
+{
+       exceptions_throw_utf(utf_java_lang_NegativeArraySizeException);
+}
+
+
+/* exceptions_new_nullpointerexception *****************************************
+
+   Generates a java.lang.NullPointerException for the VM system.
+
+*******************************************************************************/
+
+java_handle_t *exceptions_new_nullpointerexception(void)
+{
+       java_handle_t *o;
+
+       o = exceptions_new_utf(utf_java_lang_NullPointerException);
+
+       return o;
+}
+
+
+/* exceptions_throw_nullpointerexception ***************************************
+
+   Generates a java.lang.NullPointerException for the VM system and
+   throw it in the VM system.
+
+*******************************************************************************/
+
+void exceptions_throw_nullpointerexception(void)
+{
+       exceptions_throw_utf(utf_java_lang_NullPointerException);
+}
+
+
+/* exceptions_throw_privilegedactionexception **********************************
+
+   Generates and throws a java.security.PrivilegedActionException.
+
+*******************************************************************************/
+
+void exceptions_throw_privilegedactionexception(java_handle_t *exception)
+{
+       exceptions_throw_utf_exception(utf_java_security_PrivilegedActionException,
+                                                                  exception);
+}
+
+
+/* exceptions_throw_stringindexoutofboundsexception ****************************
+
+   Generates and throws a java.lang.StringIndexOutOfBoundsException
+   for the VM.
+
+*******************************************************************************/
+
+void exceptions_throw_stringindexoutofboundsexception(void)
+{
+       exceptions_throw_utf(utf_java_lang_StringIndexOutOfBoundsException);
+}
+
+
+/* exceptions_fillinstacktrace *************************************************
+
+   Calls the fillInStackTrace-method of the currently thrown
+   exception.
+
+*******************************************************************************/
+
+java_handle_t *exceptions_fillinstacktrace(void)
+{
+       java_handle_t *o;
+       classinfo     *c;
+       methodinfo    *m;
+
+       /* get exception */
+
+       o = exceptions_get_and_clear_exception();
+
+       assert(o);
+
+       /* resolve methodinfo pointer from exception object */
+
+       LLNI_class_get(o, c);
+
+#if defined(ENABLE_JAVASE)
+       m = class_resolvemethod(c,
+                                                       utf_fillInStackTrace,
+                                                       utf_void__java_lang_Throwable);
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+       m = class_resolvemethod(c,
+                                                       utf_fillInStackTrace,
+                                                       utf_void__void);
+#else
+#error IMPLEMENT ME!
+#endif
+
+       /* call function */
+
+       (void) vm_call_method(m, o);
+
+       /* return exception object */
+
+       return o;
+}
+
+
+/* exceptions_handle_exception *************************************************
+
+   Try to find an exception handler for the given exception and return it.
+   If no handler is found, exit the monitor of the method (if any)
+   and return NULL.
+
+   IN:
+      xptr.........the exception object
+         xpc..........PC of where the exception was thrown
+         pv...........Procedure Value of the current method
+         sp...........current stack pointer
+
+   RETURN VALUE:
+      the address of the first matching exception handler, or
+         NULL if no handler was found
+
+*******************************************************************************/
+
+#if defined(ENABLE_JIT)
+void *exceptions_handle_exception(java_object_t *xptro, void *xpc, void *pv, void *sp)
+{
+       stackframeinfo_t        sfi;
+       java_handle_t          *xptr;
+       methodinfo             *m;
+       codeinfo               *code;
+       exceptiontable_t       *et;
+       exceptiontable_entry_t *ete;
+       s4                      i;
+       classref_or_classinfo   cr;
+       classinfo              *c;
+#if defined(ENABLE_THREADS)
+       java_object_t          *o;
+#endif
+       void                   *result;
+
+#ifdef __S390__
+       /* Addresses are 31 bit integers */
+#      define ADDR_MASK(x) (void *) ((uintptr_t) (x) & 0x7FFFFFFF)
+#else
+#      define ADDR_MASK(x) (x)
+#endif
+
+       xptr = LLNI_WRAP(xptro);
+       xpc  = ADDR_MASK(xpc);
+
+       /* Fill and add a stackframeinfo (XPC is equal to RA). */
+
+       stacktrace_stackframeinfo_add(&sfi, pv, sp, xpc, xpc);
+
+       result = NULL;
+
+       /* Get the codeinfo for the current method. */
+
+       code = code_get_codeinfo_for_pv(pv);
+
+       /* Get the methodinfo pointer from the codeinfo pointer. For
+          asm_vm_call_method the codeinfo pointer is NULL and we simply
+          can return the proper exception handler. */
+
+       if (code == NULL) {
+               result = (void *) (uintptr_t) &asm_vm_call_method_exception_handler;
+               goto exceptions_handle_exception_return;
+       }
+
+       m = code->m;
+
+#if !defined(NDEBUG)
+       /* print exception trace */
+
+       if (opt_TraceExceptions)
+               trace_exception(LLNI_DIRECT(xptr), m, xpc);
+
+# if defined(ENABLE_VMLOG)
+       vmlog_cacao_throw(xptr);
+# endif
+#endif
+
+       /* Get the exception table. */
+
+       et = code->exceptiontable;
+
+       if (et != NULL) {
+       /* Iterate over all exception table entries. */
+
+       ete = et->entries;
+
+       for (i = 0; i < et->length; i++, ete++) {
+               /* is the xpc is the current catch range */
+
+               if ((ADDR_MASK(ete->startpc) <= xpc) && (xpc < ADDR_MASK(ete->endpc))) {
+                       cr = ete->catchtype;
+
+                       /* NULL catches everything */
+
+                       if (cr.any == NULL) {
+#if !defined(NDEBUG)
+                               /* Print stacktrace of exception when caught. */
+
+# if defined(ENABLE_VMLOG)
+                               vmlog_cacao_catch(xptr);
+# endif
+
+                               if (opt_TraceExceptions) {
+                                       exceptions_print_exception(xptr);
+                                       stacktrace_print_exception(xptr);
+                               }
+#endif
+
+                               result = ete->handlerpc;
+                               goto exceptions_handle_exception_return;
+                       }
+
+                       /* resolve or load/link the exception class */
+
+                       if (IS_CLASSREF(cr)) {
+                               /* The exception class reference is unresolved. */
+                               /* We have to do _eager_ resolving here. While the
+                                  class of the exception object is guaranteed to be
+                                  loaded, it may well have been loaded by a different
+                                  loader than the defining loader of m's class, which
+                                  is the one we must use to resolve the catch
+                                  class. Thus lazy resolving might fail, even if the
+                                  result of the resolution would be an already loaded
+                                  class. */
+
+                               c = resolve_classref_eager(cr.ref);
+
+                               if (c == NULL) {
+                                       /* Exception resolving the exception class, argh! */
+                                       goto exceptions_handle_exception_return;
+                               }
+
+                               /* Ok, we resolved it. Enter it in the table, so we
+                                  don't have to do this again. */
+                               /* XXX this write should be atomic. Is it? */
+
+                               ete->catchtype.cls = c;
+                       }
+                       else {
+                               c = cr.cls;
+
+                               /* XXX I don't think this case can ever happen. -Edwin */
+                               if (!(c->state & CLASS_LOADED))
+                                       /* use the methods' classloader */
+                                       if (!load_class_from_classloader(c->name,
+                                                                                                        m->clazz->classloader))
+                                               goto exceptions_handle_exception_return;
+
+                               /* XXX I think, if it is not linked, we can be sure
+                                  that the exception object is no (indirect) instance
+                                  of it, no?  -Edwin  */
+                               if (!(c->state & CLASS_LINKED))
+                                       if (!link_class(c))
+                                               goto exceptions_handle_exception_return;
+                       }
+
+                       /* is the thrown exception an instance of the catch class? */
+
+                       if (builtin_instanceof(xptr, c)) {
+#if !defined(NDEBUG)
+                               /* Print stacktrace of exception when caught. */
+
+# if defined(ENABLE_VMLOG)
+                               vmlog_cacao_catch(xptr);
+# endif
+
+                               if (opt_TraceExceptions) {
+                                       exceptions_print_exception(xptr);
+                                       stacktrace_print_exception(xptr);
+                               }
+#endif
+
+                               result = ete->handlerpc;
+                               goto exceptions_handle_exception_return;
+                       }
+               }
+       }
+       }
+
+#if defined(ENABLE_THREADS)
+       /* Is this method realization synchronized? */
+
+       if (code_is_synchronized(code)) {
+               /* Get synchronization object. */
+
+               o = *((java_object_t **) (((uintptr_t) sp) + code->synchronizedoffset));
+
+               assert(o != NULL);
+
+               lock_monitor_exit(LLNI_QUICKWRAP(o));
+       }
+#endif
+
+       /* none of the exceptions catch this one */
+
+#if !defined(NDEBUG)
+# if defined(ENABLE_VMLOG)
+       vmlog_cacao_unwnd_method(m);
+# endif
+
+# if defined(ENABLE_DEBUG_FILTER)
+       if (show_filters_test_verbosecall_exit(m)) {
+# endif
+
+       /* outdent the log message */
+
+       if (opt_verbosecall) {
+               if (TRACEJAVACALLINDENT)
+                       TRACEJAVACALLINDENT--;
+               else
+                       log_text("exceptions_handle_exception: WARNING: unmatched unindent");
+       }
+
+# if defined(ENABLE_DEBUG_FILTER)
+       }
+# endif
+#endif /* !defined(NDEBUG) */
+
+       result = NULL;
+
+exceptions_handle_exception_return:
+
+       /* Remove the stackframeinfo. */
+
+       stacktrace_stackframeinfo_remove(&sfi);
+
+       return result;
+}
+#endif /* defined(ENABLE_JIT) */
+
+
+/* exceptions_print_exception **************************************************
+
+   Prints an exception, the detail message and the cause, if
+   available, with CACAO internal functions to stdout.
+
+*******************************************************************************/
+
+void exceptions_print_exception(java_handle_t *xptr)
+{
+       java_lang_Throwable jlt(xptr);
+
+       if (jlt.is_null()) {
+               puts("NULL\n");
+               return;
+       }
+
+#if defined(ENABLE_JAVASE)
+       java_lang_Throwable jltcause(jlt.get_cause());
+#endif
+
+       /* print the root exception */
+
+       classinfo* c = jlt.get_Class();
+       utf_display_printable_ascii_classname(c->name);
+
+       java_lang_String jls(jlt.get_detailMessage());
+
+       if (!jls.is_null()) {
+               utf* u = javastring_toutf(jls.get_handle(), false);
+
+               printf(": ");
+               utf_display_printable_ascii(u);
+       }
+
+       putc('\n', stdout);
+
+#if defined(ENABLE_JAVASE)
+       /* print the cause if available */
+
+       // FIXME cause != t compare with operator override.
+       if ((!jltcause.is_null()) && (jltcause.get_handle() != jlt.get_handle())) {
+               printf("Caused by: ");
+
+               c = jltcause.get_Class();
+               utf_display_printable_ascii_classname(c->name);
+
+               java_lang_String jlscause(jlt.get_detailMessage());
+
+               if (jlscause.get_handle() != NULL) {
+                       utf* u = javastring_toutf(jlscause.get_handle(), false);
+
+                       printf(": ");
+                       utf_display_printable_ascii(u);
+               }
+
+               putc('\n', stdout);
+       }
+#endif
+}
+
+
+/* exceptions_print_current_exception ******************************************
+
+   Prints the current pending exception, the detail message and the
+   cause, if available, with CACAO internal functions to stdout.
+
+*******************************************************************************/
+
+void exceptions_print_current_exception(void)
+{
+       java_handle_t *o;
+
+       o = exceptions_get_exception();
+
+       exceptions_print_exception(o);
+}
+
+
+/* exceptions_print_stacktrace *************************************************
+
+   Prints a pending exception with Throwable.printStackTrace().  If
+   there happens an exception during printStackTrace(), we print the
+   thrown exception and the original one.
+
+   NOTE: This function calls Java code.
+
+*******************************************************************************/
+
+void exceptions_print_stacktrace(void)
+{
+       java_handle_t    *e;
+       java_handle_t    *ne;
+       classinfo        *c;
+       methodinfo       *m;
+
+#if defined(ENABLE_THREADS)
+       threadobject     *t;
+       java_lang_Thread *to;
+#endif
+
+       /* Get and clear exception because we are calling Java code
+          again. */
+
+       e = exceptions_get_and_clear_exception();
+
+       if (e == NULL)
+               return;
+
+#if 0
+       /* FIXME Enable me. */
+       if (builtin_instanceof(e, class_java_lang_ThreadDeath)) {
+               /* Don't print anything if we are being killed. */
+       }
+       else
+#endif
+       {
+               /* Get the exception class. */
+
+               LLNI_class_get(e, c);
+
+               /* Find the printStackTrace() method. */
+
+               m = class_resolveclassmethod(c,
+                                                                        utf_printStackTrace,
+                                                                        utf_void__void,
+                                                                        class_java_lang_Object,
+                                                                        false);
+
+               if (m == NULL)
+                       os::abort("exceptions_print_stacktrace: printStackTrace()V not found");
+
+               /* Print message. */
+
+               fprintf(stderr, "Exception ");
+
+#if defined(ENABLE_THREADS)
+               /* Print thread name.  We get the thread here explicitly as we
+                  need it afterwards. */
+
+               t  = thread_get_current();
+               to = (java_lang_Thread *) thread_get_object(t);
+
+               if (to != NULL) {
+                       fprintf(stderr, "in thread \"");
+                       thread_fprint_name(t, stderr);
+                       fprintf(stderr, "\" ");
+               }
+#endif
+
+               /* Print the stacktrace. */
+
+               if (builtin_instanceof(e, class_java_lang_Throwable)) {
+                       (void) vm_call_method(m, e);
+
+                       /* If this happens we are EXTREMLY out of memory or have a
+                          serious problem while printStackTrace.  But may be
+                          another exception, so print it. */
+
+                       ne = exceptions_get_exception();
+
+                       if (ne != NULL) {
+                               fprintf(stderr, "Exception while printStackTrace(): ");
+
+                               /* Print the current exception. */
+
+                               exceptions_print_exception(ne);
+                               stacktrace_print_exception(ne);
+
+                               /* Now print the original exception. */
+
+                               fprintf(stderr, "Original exception was: ");
+                               exceptions_print_exception(e);
+                               stacktrace_print_exception(e);
+                       }
+               }
+               else {
+                       fprintf(stderr, ". Uncaught exception of type ");
+#if !defined(NDEBUG)
+                       /* FIXME This prints to stdout. */
+                       class_print(c);
+#else
+                       fprintf(stderr, "UNKNOWN");
+#endif
+                       fprintf(stderr, ".");
+               }
+
+               fflush(stderr);
+       }
+}
+
+} // extern "C"
+
+
+/*
+ * 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/exceptions.h b/src/vm/exceptions.h
deleted file mode 100644 (file)
index 1aea660..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/* src/vm/exceptions.h - exception related functions prototypes
-
-   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 _EXCEPTIONS_H
-#define _EXCEPTIONS_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#include "vmcore/references.h"
-#include "vmcore/method.h"
-
-
-/* function prototypes ********************************************************/
-
-java_handle_t *exceptions_get_exception(void);
-void           exceptions_set_exception(java_handle_t *o);
-void           exceptions_clear_exception(void);
-java_handle_t *exceptions_get_and_clear_exception(void);
-
-
-/* functions to generate compiler exceptions */
-
-java_handle_t *exceptions_new_abstractmethoderror(void);
-java_object_t *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra);
-java_handle_t *exceptions_new_arraystoreexception(void);
-
-void exceptions_throw_abstractmethoderror(void);
-void exceptions_throw_classcircularityerror(classinfo *c);
-void exceptions_throw_classformaterror(classinfo *c, const char *message, ...);
-void exceptions_throw_classnotfoundexception(utf *name);
-void exceptions_throw_noclassdeffounderror(utf *name);
-void exceptions_throw_noclassdeffounderror_cause(java_handle_t *cause);
-void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name);
-void exceptions_throw_linkageerror(const char *message, classinfo *c);
-void exceptions_throw_nosuchfielderror(classinfo *c, utf *name);
-void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc);
-void exceptions_throw_exceptionininitializererror(java_handle_t *cause);
-void exceptions_throw_incompatibleclasschangeerror(classinfo *c,
-                                                                                                  const char *message);
-void exceptions_throw_instantiationerror(classinfo *c);
-void exceptions_throw_internalerror(const char *message, ...);
-void exceptions_throw_outofmemoryerror(void);
-void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...);
-void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type);
-void exceptions_throw_unsatisfiedlinkerror(utf *name);
-void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi);
-
-java_handle_t *exceptions_new_arithmeticexception(void);
-
-java_handle_t *exceptions_new_arrayindexoutofboundsexception(s4 index);
-void exceptions_throw_arrayindexoutofboundsexception(void);
-void exceptions_throw_arraystoreexception(void);
-
-java_handle_t *exceptions_new_classcastexception(java_handle_t *o);
-
-void exceptions_throw_clonenotsupportedexception(void);
-void exceptions_throw_illegalaccessexception(utf *message);
-void exceptions_throw_illegalargumentexception(void);
-void exceptions_throw_illegalmonitorstateexception(void);
-void exceptions_throw_interruptedexception(void);
-void exceptions_throw_instantiationexception(classinfo *c);
-void exceptions_throw_invocationtargetexception(java_handle_t *cause);
-void exceptions_throw_negativearraysizeexception(void);
-
-java_handle_t *exceptions_new_nullpointerexception(void);
-void exceptions_throw_nullpointerexception(void);
-void exceptions_throw_privilegedactionexception(java_handle_t *cause);
-void exceptions_throw_stringindexoutofboundsexception(void);
-
-java_handle_t *exceptions_fillinstacktrace(void);
-
-void exceptions_print_exception(java_handle_t *xptr);
-void exceptions_print_current_exception(void);
-void exceptions_print_stacktrace(void);
-
-#endif /* _EXCEPTIONS_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/exceptions.hpp b/src/vm/exceptions.hpp
new file mode 100644 (file)
index 0000000..564ffff
--- /dev/null
@@ -0,0 +1,123 @@
+/* src/vm/exceptions.hpp - exception related functions prototypes
+
+   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 _EXCEPTIONS_HPP
+#define _EXCEPTIONS_HPP
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/global.h"
+#include "vm/references.h"
+#include "vm/method.hpp"
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+java_handle_t *exceptions_get_exception(void);
+void           exceptions_set_exception(java_handle_t *o);
+void           exceptions_clear_exception(void);
+java_handle_t *exceptions_get_and_clear_exception(void);
+
+
+/* functions to generate compiler exceptions */
+
+java_handle_t *exceptions_new_abstractmethoderror(void);
+java_object_t *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra);
+java_handle_t *exceptions_new_arraystoreexception(void);
+
+void exceptions_throw_abstractmethoderror(void);
+void exceptions_throw_classcircularityerror(classinfo *c);
+void exceptions_throw_classformaterror(classinfo *c, const char *message, ...);
+void exceptions_throw_classnotfoundexception(utf *name);
+void exceptions_throw_noclassdeffounderror(utf *name);
+void exceptions_throw_noclassdeffounderror_cause(java_handle_t *cause);
+void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name);
+void exceptions_throw_linkageerror(const char *message, classinfo *c);
+void exceptions_throw_nosuchfielderror(classinfo *c, utf *name);
+void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc);
+void exceptions_throw_exceptionininitializererror(java_handle_t *cause);
+void exceptions_throw_incompatibleclasschangeerror(classinfo *c,
+                                                                                                  const char *message);
+void exceptions_throw_instantiationerror(classinfo *c);
+void exceptions_throw_internalerror(const char *message, ...);
+void exceptions_throw_outofmemoryerror(void);
+void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...);
+void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type);
+void exceptions_throw_unsatisfiedlinkerror(utf *name);
+void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi);
+
+java_handle_t *exceptions_new_arithmeticexception(void);
+
+java_handle_t *exceptions_new_arrayindexoutofboundsexception(s4 index);
+void exceptions_throw_arrayindexoutofboundsexception(void);
+void exceptions_throw_arraystoreexception(void);
+
+java_handle_t *exceptions_new_classcastexception(java_handle_t *o);
+
+void exceptions_throw_clonenotsupportedexception(void);
+void exceptions_throw_illegalaccessexception(utf *message);
+void exceptions_throw_illegalargumentexception(void);
+void exceptions_throw_illegalmonitorstateexception(void);
+void exceptions_throw_interruptedexception(void);
+void exceptions_throw_instantiationexception(classinfo *c);
+void exceptions_throw_invocationtargetexception(java_handle_t *cause);
+void exceptions_throw_negativearraysizeexception(void);
+
+java_handle_t *exceptions_new_nullpointerexception(void);
+void exceptions_throw_nullpointerexception(void);
+void exceptions_throw_privilegedactionexception(java_handle_t *cause);
+void exceptions_throw_stringindexoutofboundsexception(void);
+
+java_handle_t *exceptions_fillinstacktrace(void);
+
+void exceptions_print_exception(java_handle_t *xptr);
+void exceptions_print_current_exception(void);
+void exceptions_print_stacktrace(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _EXCEPTIONS_HPP
+
+
+/*
+ * 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/field.cpp b/src/vm/field.cpp
new file mode 100644 (file)
index 0000000..987217c
--- /dev/null
@@ -0,0 +1,561 @@
+/* src/vm/field.cpp - field 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 <stdint.h>
+#include <stdio.h>
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "vm/types.h"
+
+#include "vm/annotation.h"
+#include "vm/array.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/descriptor.h"
+#include "vm/exceptions.hpp"
+#include "vm/field.hpp"
+#include "vm/global.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/references.h"
+#include "vm/string.hpp"
+#include "vm/suck.hpp"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+
+/* field_load ******************************************************************
+
+   Load everything about a class field from the class file and fill a
+   fieldinfo structure.
+
+*******************************************************************************/
+
+#define field_load_NOVALUE  0xffffffff /* must be bigger than any u2 value! */
+
+bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool)
+{
+       classinfo *c;
+       u4 attrnum, i;
+       u4 pindex = field_load_NOVALUE;     /* constantvalue_index */
+       utf *u;
+
+       /* Get class. */
+
+       c = cb->clazz;
+
+       f->clazz = c;
+
+       /* Get access flags. */
+
+       if (!suck_check_classbuffer_size(cb, 2 + 2 + 2))
+               return false;
+
+       f->flags = suck_u2(cb);
+
+       /* Get name. */
+
+       if (!(u = (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
+               return false;
+
+       f->name = u;
+
+       /* Get descriptor. */
+
+       if (!(u = (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
+               return false;
+
+       f->descriptor = u;
+       f->parseddesc = NULL;
+
+       if (!descriptor_pool_add(descpool, u, NULL))
+               return false;
+
+       /* descriptor_pool_add accepts method descriptors, so we have to
+          check against them here before the call of
+          descriptor_to_basic_type below. */
+
+       if (u->text[0] == '(') {
+               exceptions_throw_classformaterror(c, "Method descriptor used for field");
+               return false;
+       }
+
+#ifdef ENABLE_VERIFIER
+       if (opt_verify) {
+               /* check name */
+               if (!is_valid_name_utf(f->name) || f->name->text[0] == '<') {
+                       exceptions_throw_classformaterror(c,
+                                                                                         "Illegal Field name \"%s\"",
+                                                                                         f->name->text);
+                       return false;
+               }
+
+               /* check flag consistency */
+               i = f->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED);
+
+               if ((i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) ||
+                       ((f->flags & (ACC_FINAL | ACC_VOLATILE)) == (ACC_FINAL | ACC_VOLATILE))) {
+                       exceptions_throw_classformaterror(c,
+                                                                                         "Illegal field modifiers: 0x%X",
+                                                                                         f->flags);
+                       return false;
+               }
+
+               if (c->flags & ACC_INTERFACE) {
+                       if (((f->flags & (ACC_STATIC | ACC_PUBLIC | ACC_FINAL))
+                               != (ACC_STATIC | ACC_PUBLIC | ACC_FINAL)) ||
+                               f->flags & ACC_TRANSIENT) {
+                               exceptions_throw_classformaterror(c,
+                                                                                                 "Illegal field modifiers: 0x%X",
+                                                                                                 f->flags);
+                               return false;
+                       }
+               }
+       }
+#endif /* ENABLE_VERIFIER */
+
+       /* data type */
+
+       f->type = descriptor_to_basic_type(f->descriptor);
+
+       /* For static-fields allocate memory for the value and set the
+          value to 0. */
+
+       if (f->flags & ACC_STATIC) {
+               switch (f->type) {
+               case TYPE_INT:
+               case TYPE_LNG:
+               case TYPE_FLT:
+               case TYPE_DBL:
+                       f->value = NEW(imm_union);
+                       break;
+
+               case TYPE_ADR:
+#if !defined(ENABLE_GC_BOEHM)
+                       f->value = NEW(imm_union);
+#else
+                       f->value = GCNEW_UNCOLLECTABLE(imm_union, 1);
+#endif
+                       break;
+
+               default:
+                       vm_abort("field_load: invalid field type %d", f->type);
+               }
+
+               /* Set the field to zero, for float and double fields set the
+                  correct 0.0 value. */
+
+               switch (f->type) {
+               case TYPE_INT:
+               case TYPE_LNG:
+               case TYPE_ADR:
+                       f->value->l = 0;
+                       break;
+
+               case TYPE_FLT:
+                       f->value->f = 0.0;
+                       break;
+
+               case TYPE_DBL:
+                       f->value->d = 0.0;
+                       break;
+               }
+       }
+       else {
+               /* For instance-fields set the offset to 0. */
+
+               f->offset = 0;
+
+               /* For final fields, which are not static, we need a value
+                  structure. */
+
+               if (f->flags & ACC_FINAL) {
+                       f->value = NEW(imm_union);
+                       /* XXX hack */
+                       f->value->l = 0;
+               }
+
+               switch (f->type) {
+               case TYPE_ADR:
+                       c->flags |= ACC_CLASS_HAS_POINTERS;
+                       break;
+               }
+       }
+
+       /* read attributes */
+
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       attrnum = suck_u2(cb);
+
+       for (i = 0; i < attrnum; i++) {
+               if (!suck_check_classbuffer_size(cb, 2))
+                       return false;
+
+               if (!(u = (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
+                       return false;
+
+               if (u == utf_ConstantValue) {
+                       if (!suck_check_classbuffer_size(cb, 4 + 2))
+                               return false;
+
+                       /* check attribute length */
+
+                       if (suck_u4(cb) != 2) {
+                               exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute");
+                               return false;
+                       }
+
+                       /* constant value attribute */
+
+                       if (pindex != field_load_NOVALUE) {
+                               exceptions_throw_classformaterror(c, "Multiple ConstantValue attributes");
+                               return false;
+                       }
+
+                       /* index of value in constantpool */
+
+                       pindex = suck_u2(cb);
+
+                       /* initialize field with value from constantpool */
+
+                       switch (f->type) {
+                       case TYPE_INT: {
+                               constant_integer *ci; 
+
+                               if (!(ci = (constant_integer*) class_getconstant(c, pindex, CONSTANT_Integer)))
+                                       return false;
+
+                               f->value->i = ci->value;
+                       }
+                       break;
+
+                       case TYPE_LNG: {
+                               constant_long *cl; 
+
+                               if (!(cl = (constant_long*) class_getconstant(c, pindex, CONSTANT_Long)))
+                                       return false;
+
+                               f->value->l = cl->value;
+                       }
+                       break;
+
+                       case TYPE_FLT: {
+                               constant_float *cf;
+
+                               if (!(cf = (constant_float*) class_getconstant(c, pindex, CONSTANT_Float)))
+                                       return false;
+
+                               f->value->f = cf->value;
+                       }
+                       break;
+
+                       case TYPE_DBL: {
+                               constant_double *cd;
+
+                               if (!(cd = (constant_double*) class_getconstant(c, pindex, CONSTANT_Double)))
+                                       return false;
+
+                               f->value->d = cd->value;
+                       }
+                       break;
+
+                       case TYPE_ADR:
+                               if (!(u = (utf*) class_getconstant(c, pindex, CONSTANT_String)))
+                                       return false;
+
+                               /* Create Java-string from compressed UTF8-string. */
+
+                               f->value->a = literalstring_new(u);
+                               break;
+
+                       default: 
+                               vm_abort("field_load: invalid field type %d", f->type);
+                       }
+               }
+#if defined(ENABLE_JAVASE)
+               else if (u == utf_Signature) {
+                       /* Signature */
+
+                       if (!loader_load_attribute_signature(cb, &(f->signature)))
+                               return false;
+               }
+
+#if defined(ENABLE_ANNOTATIONS)
+               else if (u == utf_RuntimeVisibleAnnotations) {
+                       /* RuntimeVisibleAnnotations */
+                       if (!annotation_load_field_attribute_runtimevisibleannotations(cb, f))
+                               return false;
+               }
+               else if (u == utf_RuntimeInvisibleAnnotations) {
+                       /* RuntimeInvisibleAnnotations */
+                       if (!annotation_load_field_attribute_runtimeinvisibleannotations(cb, f))
+                               return false;
+               }
+#endif
+#endif
+               else {
+                       /* unknown attribute */
+
+                       if (!loader_skip_attribute_body(cb))
+                               return false;
+               }
+       }
+
+       /* everything was ok */
+
+       return true;
+}
+
+
+/* field_get_type **************************************************************
+
+   Returns the type of the field as class.
+
+*******************************************************************************/
+
+classinfo *field_get_type(fieldinfo *f)
+{
+       typedesc  *td;
+       utf       *u;
+       classinfo *c;
+
+       td = f->parseddesc;
+
+       if (td->type == TYPE_ADR) {
+               assert(td->classref);
+
+               u = td->classref->name;
+
+               /* load the class of the field-type with the field's
+                  classloader */
+
+               c = load_class_from_classloader(u, f->clazz->classloader);
+       }
+       else {
+               c = Primitive::get_class_by_type(td->primitivetype);
+       }
+
+       return c;
+}
+
+
+/* field_free ******************************************************************
+
+   Frees a fields' resources.
+
+*******************************************************************************/
+
+void field_free(fieldinfo *f)
+{
+       /* free memory for fields which have a value */
+
+       if (f->value)
+#if defined(ENABLE_GC_BOEHM)
+               if (f->type != TYPE_ADR)
+#endif
+                       FREE(f->value, imm_union);
+}
+
+
+/* field_get_annotations ******************************************************
+
+   Get a fields' unparsed annotations in a byte array.
+
+   IN:
+       f........the field of which the annotations should be returned
+
+   RETURN VALUE:
+       The unparsed annotations in a byte array (or NULL if there aren't any).
+
+*******************************************************************************/
+
+java_handle_bytearray_t *field_get_annotations(fieldinfo *f)
+{
+#if defined(ENABLE_ANNOTATIONS)
+       classinfo               *c;           /* declaring class           */
+       int                      slot;        /* slot of this field        */
+       java_handle_bytearray_t *annotations; /* unparsed annotations      */
+       java_handle_t           *field_annotations;  /* array of unparsed  */
+                      /* annotations of all fields of the declaring class */
+
+       c           = f->clazz;
+       slot        = f - c->fields;
+       annotations = NULL;
+
+       LLNI_classinfo_field_get(c, field_annotations, field_annotations);
+
+       /* the field_annotations array might be shorter then the field
+        * count if the fields above a certain index have no annotations.
+        */
+       if (field_annotations != NULL &&
+               array_length_get(field_annotations) > slot) {
+               annotations = (java_handle_bytearray_t*)array_objectarray_element_get(
+                               (java_handle_objectarray_t*)field_annotations, slot);
+       }
+       
+       return annotations;
+#else
+       return NULL;
+#endif
+}
+
+
+/* field_printflags ************************************************************
+
+   (debugging only)
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void field_printflags(fieldinfo *f)
+{
+       if (f == NULL) {
+               printf("NULL");
+               return;
+       }
+
+       if (f->flags & ACC_PUBLIC)       printf(" PUBLIC");
+       if (f->flags & ACC_PRIVATE)      printf(" PRIVATE");
+       if (f->flags & ACC_PROTECTED)    printf(" PROTECTED");
+       if (f->flags & ACC_STATIC)       printf(" STATIC");
+       if (f->flags & ACC_FINAL)        printf(" FINAL");
+       if (f->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED");
+       if (f->flags & ACC_VOLATILE)     printf(" VOLATILE");
+       if (f->flags & ACC_TRANSIENT)    printf(" TRANSIENT");
+       if (f->flags & ACC_NATIVE)       printf(" NATIVE");
+       if (f->flags & ACC_INTERFACE)    printf(" INTERFACE");
+       if (f->flags & ACC_ABSTRACT)     printf(" ABSTRACT");
+}
+#endif
+
+
+/* field_print *****************************************************************
+
+   (debugging only)
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void field_print(fieldinfo *f)
+{
+       if (f == NULL) {
+               printf("(fieldinfo*)NULL");
+               return;
+       }
+
+       utf_display_printable_ascii_classname(f->clazz->name);
+       printf(".");
+       utf_display_printable_ascii(f->name);
+       printf(" ");
+       utf_display_printable_ascii(f->descriptor);     
+
+       field_printflags(f);
+
+       if (!(f->flags & ACC_STATIC)) {
+               printf(", offset: %d", f->offset);
+       }
+}
+#endif
+
+
+/* field_println ***************************************************************
+
+   (debugging only)
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void field_println(fieldinfo *f)
+{
+       field_print(f);
+       printf("\n");
+}
+#endif
+
+/* field_fieldref_print ********************************************************
+
+   (debugging only)
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void field_fieldref_print(constant_FMIref *fr)
+{
+       if (fr == NULL) {
+               printf("(constant_FMIref *)NULL");
+               return;
+       }
+
+       if (IS_FMIREF_RESOLVED(fr)) {
+               printf("<field> ");
+               field_print(fr->p.field);
+       }
+       else {
+               printf("<fieldref> ");
+               utf_display_printable_ascii_classname(fr->p.classref->name);
+               printf(".");
+               utf_display_printable_ascii(fr->name);
+               printf(" ");
+               utf_display_printable_ascii(fr->descriptor);
+       }
+}
+#endif
+
+/* field_fieldref_println ******************************************************
+
+   (debugging only)
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void field_fieldref_println(constant_FMIref *fr)
+{
+       field_fieldref_print(fr);
+       printf("\n");
+}
+#endif
+
+/*
+ * 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/field.hpp b/src/vm/field.hpp
new file mode 100644 (file)
index 0000000..a25d09e
--- /dev/null
@@ -0,0 +1,107 @@
+/* src/vm/field.hpp - field functions 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 _FIELD_HPP
+#define _FIELD_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct fieldinfo fieldinfo; 
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/descriptor.h"
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/loader.hpp"
+#include "vm/references.h"
+#include "vm/utf8.h"
+
+
+/* fieldinfo ******************************************************************/
+
+struct fieldinfo {           /* field of a class                                 */
+
+       /* CAUTION: The first field must be a pointer that is never the same      */
+       /*          value as CLASSREF_PSEUDO_VFTBL! This is used to check whether */
+       /*          a constant_FMIref has been resolved.                          */
+
+       classinfo *clazz;     /* needed by typechecker. Could be optimized        */
+                             /* away by using constant_FMIref instead of         */
+                             /* fieldinfo throughout the compiler.               */
+
+       s4         flags;     /* ACC flags                                        */
+       s4         type;      /* basic data type                                  */
+       utf       *name;      /* name of field                                    */
+       utf       *descriptor;/* JavaVM descriptor string of field                */
+       utf       *signature; /* Signature attribute string                       */
+       typedesc  *parseddesc;/* parsed descriptor                                */
+
+       int32_t    offset;    /* offset from start of object (instance variables) */
+       imm_union *value;     /* storage for static values (class variables)      */
+};
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool       field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool);
+classinfo *field_get_type(fieldinfo *f);
+void       field_free(fieldinfo *f);
+
+java_handle_bytearray_t *field_get_annotations(fieldinfo *f);
+
+#if !defined(NDEBUG)
+void field_printflags(fieldinfo *f);
+void field_print(fieldinfo *f);
+void field_println(fieldinfo *f);
+void field_fieldref_print(constant_FMIref *fr);
+void field_fieldref_println(constant_FMIref *fr);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FIELD_HPP */
+
+
+/*
+ * 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:
+ */
index 833efbfb127d02449d36c7d5c342e06e867df1d5..ea331ec96e9c12b7a51d2298d362f8c15ba3af0e 100644 (file)
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
-#include "threads/thread.h"
+#include "threads/condition.hpp"
+#include "threads/mutex.hpp"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/options.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
 
-#include "vmcore/options.h"
-
 
 /* global variables ***********************************************************/
 
 #if defined(ENABLE_THREADS)
-static java_object_t *lock_thread_finalizer;
+static Mutex     *finalizer_thread_mutex;
+static Condition *finalizer_thread_cond;
 #endif
 
 
@@ -63,9 +63,8 @@ bool finalizer_init(void)
        TRACESUBSYSTEMINITIALIZATION("finalizer_init");
 
 #if defined(ENABLE_THREADS)
-       lock_thread_finalizer = NEW(java_object_t);
-
-       LOCK_INIT_OBJECT_LOCK(lock_thread_finalizer);
+       finalizer_thread_mutex = Mutex_new();
+       finalizer_thread_cond  = Condition_new();
 #endif
 
        /* everything's ok */
@@ -86,17 +85,17 @@ bool finalizer_init(void)
 static void finalizer_thread(void)
 {
        while (true) {
-               /* get the lock on the finalizer lock object, so we can call wait */
+               /* get the lock on the finalizer mutex, so we can call wait */
 
-               LOCK_MONITOR_ENTER(lock_thread_finalizer);
+               Mutex_lock(finalizer_thread_mutex);
 
-               /* wait forever on that object till we are signaled */
+               /* wait forever on that condition till we are signaled */
        
-               LOCK_WAIT_FOREVER(lock_thread_finalizer);
+               Condition_wait(finalizer_thread_cond, finalizer_thread_mutex);
 
                /* leave the lock */
 
-               LOCK_MONITOR_EXIT(lock_thread_finalizer);
+               Mutex_unlock(finalizer_thread_mutex);
 
 #if !defined(NDEBUG)
                if (opt_DebugFinalizer)
@@ -156,15 +155,15 @@ void finalizer_notify(void)
 #if defined(ENABLE_THREADS)
        /* get the lock on the finalizer lock object, so we can call wait */
 
-       LOCK_MONITOR_ENTER(lock_thread_finalizer);
+       Mutex_lock(finalizer_thread_mutex);
 
        /* signal the finalizer thread */
-       
-       LOCK_NOTIFY(lock_thread_finalizer);
+
+       Condition_signal(finalizer_thread_cond);
 
        /* leave the lock */
 
-       LOCK_MONITOR_EXIT(lock_thread_finalizer);
+       Mutex_unlock(finalizer_thread_mutex);
 #else
        /* if we don't have threads, just run the finalizers */
 
index ca3682735d684e789419f0e440d66c8c0a92c0a8..04abf9ed0e791dd6988de54f38a2462d14057320 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/finalizer.h - finalizer linked list and thread header
 
-   Copyright (C) 1996-2005, 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) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
 */
 
 
 #define _FINALIZER_H
 
 #include "config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "vm/types.h"
 
 #include "vm/global.h"
@@ -47,6 +44,10 @@ bool finalizer_start_thread(void);
 void finalizer_notify(void);
 void finalizer_run(void *o, void *p);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _FINALIZER_H */
 
 
index 125eb3ff1096ff8e76fb1cdd82886dbfe1a21811..011d9b4a03e78ed78a64e8158fceada9e0ebcc9b 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "config.h"
 
+#include <stdbool.h>
 #include <stdint.h>
 
 #include "vm/types.h"
 
 /* additional data types ******************************************************/
 
-typedef void *voidptr;                  /* generic pointer                    */
 typedef void (*functionptr) (void);     /* generic function pointer           */
 typedef u1* methodptr;
 
-typedef unsigned int bool;              /* boolean data type                  */
-
-#define true         1
-#define false        0
-
 #if defined(ENABLE_SSA)
 /* immediate to get an addidional target Local Var Index */
 /* for IINC in Combination with SSA */
@@ -211,6 +206,10 @@ typedef struct java_objectarray_t java_objectarray_t;
 #define ACC_METHOD_IMPLEMENTED 0x00020000     /* there is an implementation   */
 #define ACC_METHOD_MONOMORPHIC 0x00040000     /* currently monomorphic method */
 #define ACC_METHOD_EA          0x00080000     /* method being escape analyzed */
+#define ACC_METHOD_MONOMORPHY_USED \
+                               0x00100000
+#define ACC_METHOD_PARENT_MONOMORPHY_USED \
+                               0x00200000
 
 
 /* data structures of the runtime system **************************************/
@@ -231,10 +230,12 @@ typedef struct java_objectarray_t java_objectarray_t;
 #define HDRFLAG_HASH_ATTACHED 0x20
 #define HDRFLAG_REFERENCING   0x40
 
+#include "threads/lockword.hpp"
+
 struct java_object_t {                 /* header for all objects              */
        struct _vftbl *vftbl;              /* pointer to virtual function table   */
 #if defined(ENABLE_THREADS)
-       uintptr_t      lockword;
+       Lockword       lockword;
 #endif
 #if defined(ENABLE_GC_CACAO)
        uintptr_t      hdrflags;           /* word containing the GC bits         */
@@ -327,6 +328,7 @@ typedef struct java_handle_t {
        java_object_t *heap_object;
 } java_handle_t;
 
+typedef struct java_handle_array_t        { java_array_t        *heap_object; } java_handle_array_t;
 typedef struct java_handle_objectarray_t  { java_objectarray_t  *heap_object; } java_handle_objectarray_t;
 typedef struct java_handle_booleanarray_t { java_booleanarray_t *heap_object; } java_handle_booleanarray_t;
 typedef struct java_handle_bytearray_t    { java_bytearray_t    *heap_object; } java_handle_bytearray_t;
@@ -338,6 +340,7 @@ typedef struct java_handle_floatarray_t   { java_floatarray_t   *heap_object; }
 typedef struct java_handle_doublearray_t  { java_doublearray_t  *heap_object; } java_handle_doublearray_t;
 #else
 typedef java_object_t       java_handle_t;
+typedef java_array_t        java_handle_array_t;
 typedef java_objectarray_t  java_handle_objectarray_t;
 typedef java_booleanarray_t java_handle_booleanarray_t;
 typedef java_bytearray_t    java_handle_bytearray_t;
diff --git a/src/vm/globals.cpp b/src/vm/globals.cpp
new file mode 100644 (file)
index 0000000..c29c90a
--- /dev/null
@@ -0,0 +1,124 @@
+/* src/vm/globals.cpp - global variables
+
+   Copyright (C) 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 <stdint.h>
+
+#include "vm/class.hpp"
+
+
+// Classes.
+
+/* Important system classes. */
+
+classinfo *class_java_lang_Object;
+classinfo *class_java_lang_Class;
+classinfo *class_java_lang_ClassLoader;
+classinfo *class_java_lang_Cloneable;
+classinfo *class_java_lang_SecurityManager;
+classinfo *class_java_lang_String;
+classinfo *class_java_lang_System;
+classinfo *class_java_lang_Thread;
+classinfo *class_java_lang_ThreadGroup;
+classinfo *class_java_lang_Throwable;
+classinfo *class_java_io_Serializable;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+classinfo *class_java_lang_VMSystem;
+classinfo *class_java_lang_VMThread;
+classinfo *class_java_lang_VMThrowable;
+#endif
+
+/* Important system exceptions. */
+
+classinfo *class_java_lang_Exception;
+classinfo *class_java_lang_ClassNotFoundException;
+classinfo *class_java_lang_RuntimeException;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+classinfo *class_sun_misc_Signal;
+classinfo *class_sun_reflect_MagicAccessorImpl;
+#endif
+
+#if defined(ENABLE_JAVASE)
+classinfo *class_java_lang_Void;
+#endif
+classinfo *class_java_lang_Boolean;
+classinfo *class_java_lang_Byte;
+classinfo *class_java_lang_Character;
+classinfo *class_java_lang_Short;
+classinfo *class_java_lang_Integer;
+classinfo *class_java_lang_Long;
+classinfo *class_java_lang_Float;
+classinfo *class_java_lang_Double;
+
+/* some classes which may be used more often */
+
+#if defined(ENABLE_JAVASE)
+classinfo *class_java_lang_StackTraceElement;
+classinfo *class_java_lang_reflect_Constructor;
+classinfo *class_java_lang_reflect_Field;
+classinfo *class_java_lang_reflect_Method;
+classinfo *class_java_security_PrivilegedAction;
+classinfo *class_java_util_Vector;
+classinfo *class_java_util_HashMap;
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+classinfo *class_java_lang_reflect_VMConstructor;
+classinfo *class_java_lang_reflect_VMField;
+classinfo *class_java_lang_reflect_VMMethod;
+# endif
+
+classinfo *arrayclass_java_lang_Object;
+
+# if defined(ENABLE_ANNOTATIONS)
+classinfo *class_sun_reflect_ConstantPool;
+#  if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+classinfo *class_sun_reflect_annotation_AnnotationParser;
+#  endif
+# endif
+#endif
+
+/* pseudo classes for the typechecker */
+
+classinfo *pseudo_class_Arraystub;
+classinfo *pseudo_class_Null;
+classinfo *pseudo_class_New;
+
+
+/*
+ * 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/globals.hpp b/src/vm/globals.hpp
new file mode 100644 (file)
index 0000000..3adf259
--- /dev/null
@@ -0,0 +1,160 @@
+/* src/vm/globals.hpp - global variables
+
+   Copyright (C) 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 _GLOBALS_HPP
+#define _GLOBALS_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/class.hpp"
+
+
+// FIXME For now we export them a C symbols.
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Classes.
+
+/* Important system classes. */
+
+extern classinfo *class_java_lang_Object;
+extern classinfo *class_java_lang_Class;
+extern classinfo *class_java_lang_ClassLoader;
+extern classinfo *class_java_lang_Cloneable;
+extern classinfo *class_java_lang_SecurityManager;
+extern classinfo *class_java_lang_String;
+extern classinfo *class_java_lang_System;
+extern classinfo *class_java_lang_Thread;
+extern classinfo *class_java_lang_ThreadGroup;
+extern classinfo *class_java_lang_Throwable;
+extern classinfo *class_java_io_Serializable;
+
+/* Important system exceptions. */
+
+extern classinfo *class_java_lang_Exception;
+extern classinfo *class_java_lang_ClassNotFoundException;
+extern classinfo *class_java_lang_RuntimeException;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+extern classinfo *class_java_lang_VMSystem;
+extern classinfo *class_java_lang_VMThread;
+extern classinfo *class_java_lang_VMThrowable;
+#endif
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+extern classinfo *class_sun_misc_Signal;
+extern classinfo *class_sun_reflect_MagicAccessorImpl;
+#endif
+
+#if defined(ENABLE_JAVASE)
+extern classinfo *class_java_lang_Void;
+#endif
+
+extern classinfo *class_java_lang_Boolean;
+extern classinfo *class_java_lang_Byte;
+extern classinfo *class_java_lang_Character;
+extern classinfo *class_java_lang_Short;
+extern classinfo *class_java_lang_Integer;
+extern classinfo *class_java_lang_Long;
+extern classinfo *class_java_lang_Float;
+extern classinfo *class_java_lang_Double;
+
+/* some classes which may be used more often */
+
+#if defined(ENABLE_JAVASE)
+extern classinfo *class_java_lang_StackTraceElement;
+extern classinfo *class_java_lang_reflect_Constructor;
+extern classinfo *class_java_lang_reflect_Field;
+extern classinfo *class_java_lang_reflect_Method;
+extern classinfo *class_java_security_PrivilegedAction;
+extern classinfo *class_java_util_Vector;
+extern classinfo *class_java_util_HashMap;
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+extern classinfo *class_java_lang_reflect_VMConstructor;
+extern classinfo *class_java_lang_reflect_VMField;
+extern classinfo *class_java_lang_reflect_VMMethod;
+# endif
+
+extern classinfo *arrayclass_java_lang_Object;
+
+# if defined(ENABLE_ANNOTATIONS)
+extern classinfo *class_sun_reflect_ConstantPool;
+#  if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+extern classinfo *class_sun_reflect_annotation_AnnotationParser;
+#  endif
+# endif
+#endif
+
+
+/* pseudo classes for the type checker ****************************************/
+
+/*
+ * pseudo_class_Arraystub
+ *     (extends Object implements Cloneable, java.io.Serializable)
+ *
+ *     If two arrays of incompatible component types are merged,
+ *     the resulting reference has no accessible components.
+ *     The result does, however, implement the interfaces Cloneable
+ *     and java.io.Serializable. This pseudo class is used internally
+ *     to represent such results. (They are *not* considered arrays!)
+ *
+ * pseudo_class_Null
+ *
+ *     This pseudo class is used internally to represent the
+ *     null type.
+ *
+ * pseudo_class_New
+ *
+ *     This pseudo class is used internally to represent the
+ *     the 'uninitialized object' type.
+ */
+
+extern classinfo *pseudo_class_Arraystub;
+extern classinfo *pseudo_class_Null;
+extern classinfo *pseudo_class_New;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _GLOBALS_HPP
+
+
+/*
+ * 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:
+ */
diff --git a/src/vm/initialize.c b/src/vm/initialize.c
deleted file mode 100644 (file)
index 6e0c108..0000000
+++ /dev/null
@@ -1,280 +0,0 @@
-/* src/vm/initialize.c - static class initializer 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 <string.h>
-
-#include "vm/types.h"
-
-#include "threads/lock-common.h"
-
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/asmpart.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
-
-/* private functions **********************************************************/
-
-static bool initialize_class_intern(classinfo *c);
-
-
-/* initialize_init *************************************************************
-
-   Initialize important system classes.
-
-*******************************************************************************/
-
-void initialize_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("initialize_init");
-
-#if defined(ENABLE_JAVASE)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       /* Nothing. */
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       if (!initialize_class(class_java_lang_String))
-               vm_abort("initialize_init: Initialization failed: java.lang.String");
-
-       if (!initialize_class(class_java_lang_System))
-               vm_abort("initialize_init: Initialization failed: java.lang.System");
-
-       if (!initialize_class(class_java_lang_ThreadGroup))
-               vm_abort("initialize_init: Initialization failed: java.lang.ThreadGroup");
-
-       if (!initialize_class(class_java_lang_Thread))
-               vm_abort("initialize_init: Initialization failed: java.lang.Thread");
-
-# else
-#  error unknown classpath configuration
-# endif
-
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-
-       /* Nothing. */
-
-#else
-# error unknown Java configuration
-#endif
-}
-
-/* initialize_class ************************************************************
-
-   In Java, every class can have a static initialization
-   function. This function has to be called BEFORE calling other
-   methods or accessing static variables.
-
-*******************************************************************************/
-
-bool initialize_class(classinfo *c)
-{
-       bool r;
-
-       if (!makeinitializations)
-               return true;
-
-       LOCK_MONITOR_ENTER(c);
-
-       /* maybe the class is already initalized or the current thread, which can
-          pass the monitor, is currently initalizing this class */
-
-       if (CLASS_IS_OR_ALMOST_INITIALIZED(c)) {
-               LOCK_MONITOR_EXIT(c);
-
-               return true;
-       }
-
-       /* if <clinit> throw an Error before, the class was marked with an
-       error and we have to throw a NoClassDefFoundError */
-
-       if (c->state & CLASS_ERROR) {
-               exceptions_throw_noclassdeffounderror(c->name);
-
-               LOCK_MONITOR_EXIT(c);
-
-               /* ...but return true, this is ok (mauve test) */
-
-               return true;
-       }
-
-       /* this initalizing run begins NOW */
-
-       c->state |= CLASS_INITIALIZING;
-
-       /* call the internal function */
-
-       r = initialize_class_intern(c);
-
-       /* if return value is not NULL everything was ok and the class is
-          initialized */
-
-       if (r)
-               c->state |= CLASS_INITIALIZED;
-
-       /* this initalizing run is done */
-
-       c->state &= ~CLASS_INITIALIZING;
-
-       LOCK_MONITOR_EXIT(c);
-
-       return r;
-}
-
-
-/* initialize_class_intern *****************************************************
-
-   This function MUST NOT be called directly, because of thread
-   <clinit> race conditions.
-
-*******************************************************************************/
-
-static bool initialize_class_intern(classinfo *c)
-{
-       methodinfo    *m;
-       java_handle_t *cause;
-       classinfo     *class;
-
-       /* maybe the class is not already linked */
-
-       if (!(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return false;
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               count_class_inits++;
-#endif
-
-       /* Initialize super class. */
-
-       if (c->super != NULL) {
-               if (!(c->super->state & CLASS_INITIALIZED)) {
-#if !defined(NDEBUG)
-                       if (initverbose)
-                               log_message_class_message_class("Initialize super class ",
-                                                                                               c->super,
-                                                                                               " from ",
-                                                                                               c);
-#endif
-
-                       if (!initialize_class(c->super))
-                               return false;
-               }
-       }
-
-       /* interfaces implemented need not to be initialized (VM Spec 2.17.4) */
-
-       m = class_findmethod(c, utf_clinit, utf_void__void);
-
-       if (m == NULL) {
-#if !defined(NDEBUG)
-               if (initverbose)
-                       log_message_class("Class has no static class initializer: ", c);
-#endif
-
-               return true;
-       }
-
-       /* Sun's and IBM's JVM don't care about the static flag */
-/*     if (!(m->flags & ACC_STATIC)) { */
-/*             log_text("Class initializer is not static!"); */
-
-#if !defined(NDEBUG)
-       if (initverbose)
-               log_message_class("Starting static class initializer for class: ", c);
-#endif
-
-       /* now call the initializer */
-
-       (void) vm_call_method(m, NULL);
-
-       /* we have an exception or error */
-
-       cause = exceptions_get_exception();
-
-       if (cause != NULL) {
-               /* class is NOT initialized and is marked with error */
-
-               c->state |= CLASS_ERROR;
-
-               /* Load java/lang/Exception for the instanceof check. */
-
-               class = load_class_bootstrap(utf_java_lang_Exception);
-
-               if (class == NULL)
-                       return false;
-
-               /* Is this an exception?  Yes, than wrap it. */
-
-               if (builtin_instanceof(cause, class)) {
-                       /* clear exception, because we are calling jit code again */
-
-                       exceptions_clear_exception();
-
-                       /* wrap the exception */
-
-                       exceptions_throw_exceptionininitializererror(cause);
-               }
-
-               return false;
-       }
-
-#if !defined(NDEBUG)
-       if (initverbose)
-               log_message_class("Finished static class initializer for class: ", c);
-#endif
-
-       return true;
-}
-
-
-/*
- * 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:
- */
diff --git a/src/vm/initialize.cpp b/src/vm/initialize.cpp
new file mode 100644 (file)
index 0000000..f2d5664
--- /dev/null
@@ -0,0 +1,279 @@
+/* src/vm/initialize.cpp - static class initializer 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 <string.h>
+
+#include "vm/types.h"
+
+#include "threads/lock.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/initialize.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/vm.hpp"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#include "vm/jit/asmpart.h"
+
+
+/* private functions **********************************************************/
+
+static bool initialize_class_intern(classinfo *c);
+
+
+/* initialize_init *************************************************************
+
+   Initialize important system classes.
+
+*******************************************************************************/
+
+void initialize_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("initialize_init");
+
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       /* Nothing. */
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       if (!initialize_class(class_java_lang_String))
+               vm_abort("initialize_init: Initialization failed: java.lang.String");
+
+       if (!initialize_class(class_java_lang_System))
+               vm_abort("initialize_init: Initialization failed: java.lang.System");
+
+       if (!initialize_class(class_java_lang_ThreadGroup))
+               vm_abort("initialize_init: Initialization failed: java.lang.ThreadGroup");
+
+       if (!initialize_class(class_java_lang_Thread))
+               vm_abort("initialize_init: Initialization failed: java.lang.Thread");
+
+# else
+#  error unknown classpath configuration
+# endif
+
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+
+       /* Nothing. */
+
+#else
+# error unknown Java configuration
+#endif
+}
+
+/* initialize_class ************************************************************
+
+   In Java, every class can have a static initialization
+   function. This function has to be called BEFORE calling other
+   methods or accessing static variables.
+
+*******************************************************************************/
+
+bool initialize_class(classinfo *c)
+{
+       bool r;
+
+       if (!makeinitializations)
+               return true;
+
+       LOCK_MONITOR_ENTER(c);
+
+       /* maybe the class is already initalized or the current thread, which can
+          pass the monitor, is currently initalizing this class */
+
+       if (CLASS_IS_OR_ALMOST_INITIALIZED(c)) {
+               LOCK_MONITOR_EXIT(c);
+
+               return true;
+       }
+
+       /* if <clinit> throw an Error before, the class was marked with an
+       error and we have to throw a NoClassDefFoundError */
+
+       if (c->state & CLASS_ERROR) {
+               exceptions_throw_noclassdeffounderror(c->name);
+
+               LOCK_MONITOR_EXIT(c);
+
+               /* ...but return true, this is ok (mauve test) */
+
+               return true;
+       }
+
+       /* this initalizing run begins NOW */
+
+       c->state |= CLASS_INITIALIZING;
+
+       /* call the internal function */
+
+       r = initialize_class_intern(c);
+
+       /* if return value is not NULL everything was ok and the class is
+          initialized */
+
+       if (r)
+               c->state |= CLASS_INITIALIZED;
+
+       /* this initalizing run is done */
+
+       c->state &= ~CLASS_INITIALIZING;
+
+       LOCK_MONITOR_EXIT(c);
+
+       return r;
+}
+
+
+/* initialize_class_intern *****************************************************
+
+   This function MUST NOT be called directly, because of thread
+   <clinit> race conditions.
+
+*******************************************************************************/
+
+static bool initialize_class_intern(classinfo *c)
+{
+       methodinfo    *m;
+       java_handle_t *cause;
+       classinfo     *clazz;
+
+       /* maybe the class is not already linked */
+
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return false;
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               count_class_inits++;
+#endif
+
+       /* Initialize super class. */
+
+       if (c->super != NULL) {
+               if (!(c->super->state & CLASS_INITIALIZED)) {
+#if !defined(NDEBUG)
+                       if (initverbose)
+                               log_message_class_message_class("Initialize super class ",
+                                                                                               c->super,
+                                                                                               " from ",
+                                                                                               c);
+#endif
+
+                       if (!initialize_class(c->super))
+                               return false;
+               }
+       }
+
+       /* interfaces implemented need not to be initialized (VM Spec 2.17.4) */
+
+       m = class_findmethod(c, utf_clinit, utf_void__void);
+
+       if (m == NULL) {
+#if !defined(NDEBUG)
+               if (initverbose)
+                       log_message_class("Class has no static class initializer: ", c);
+#endif
+
+               return true;
+       }
+
+       /* Sun's and IBM's JVM don't care about the static flag */
+/*     if (!(m->flags & ACC_STATIC)) { */
+/*             log_text("Class initializer is not static!"); */
+
+#if !defined(NDEBUG)
+       if (initverbose)
+               log_message_class("Starting static class initializer for class: ", c);
+#endif
+
+       /* now call the initializer */
+
+       (void) vm_call_method(m, NULL);
+
+       /* we have an exception or error */
+
+       cause = exceptions_get_exception();
+
+       if (cause != NULL) {
+               /* class is NOT initialized and is marked with error */
+
+               c->state |= CLASS_ERROR;
+
+               /* Load java/lang/Exception for the instanceof check. */
+
+               clazz = load_class_bootstrap(utf_java_lang_Exception);
+
+               if (clazz == NULL)
+                       return false;
+
+               /* Is this an exception?  Yes, than wrap it. */
+
+               if (builtin_instanceof(cause, clazz)) {
+                       /* clear exception, because we are calling jit code again */
+
+                       exceptions_clear_exception();
+
+                       /* wrap the exception */
+
+                       exceptions_throw_exceptionininitializererror(cause);
+               }
+
+               return false;
+       }
+
+#if !defined(NDEBUG)
+       if (initverbose)
+               log_message_class("Finished static class initializer for class: ", c);
+#endif
+
+       return true;
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/vm/initialize.h b/src/vm/initialize.h
deleted file mode 100644 (file)
index 431c1c8..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* src/vm/initialize.h - static class initializer 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.
-
-*/
-
-
-#ifndef _INITIALIZE_H
-#define _INITIALIZE_H
-
-#include "config.h"
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-
-
-/* function prototypes ********************************************************/
-
-void initialize_init(void);
-bool initialize_class(classinfo *c);
-
-#endif /* _INITIALIZE_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:
- */
diff --git a/src/vm/initialize.hpp b/src/vm/initialize.hpp
new file mode 100644 (file)
index 0000000..3dd48e5
--- /dev/null
@@ -0,0 +1,62 @@
+/* src/vm/initialize.hpp - static class initializer 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.
+
+*/
+
+
+#ifndef _INITIALIZE_HPP
+#define _INITIALIZE_HPP
+
+#include "config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "vm/class.hpp"
+#include "vm/global.h"
+
+
+/* function prototypes ********************************************************/
+
+void initialize_init(void);
+bool initialize_class(classinfo *c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _INITIALIZE_HPP */
+
+
+/*
+ * 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:
+ */
diff --git a/src/vm/javaobjects.cpp b/src/vm/javaobjects.cpp
new file mode 100644 (file)
index 0000000..b8a0d60
--- /dev/null
@@ -0,0 +1,137 @@
+/* src/vm/javaobjects.cpp - functions to create and access Java objects
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 <stdint.h>
+
+#include "native/vm/reflection.hpp"
+
+#include "vm/access.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/initialize.hpp"
+#include "vm/javaobjects.hpp"
+
+
+#if defined(ENABLE_JAVASE)
+
+/**
+ * Constructs a Java object with the given
+ * java.lang.reflect.Constructor.
+ *
+ * @param args     Constructor arguments.
+ *
+ * @return Handle to Java object.
+ */
+java_handle_t* java_lang_reflect_Constructor::new_instance(java_handle_objectarray_t* args)
+{
+       methodinfo* m = get_method();
+
+       // Should we bypass security the checks (AccessibleObject)?
+       if (get_override() == false) {
+               /* This method is always called like this:
+                      [0] java.lang.reflect.Constructor.constructNative (Native Method)
+                      [1] java.lang.reflect.Constructor.newInstance
+                      [2] <caller>
+               */
+
+               if (!access_check_method(m, 2))
+                       return NULL;
+       }
+
+       // Create a Java object.
+       java_handle_t* h = builtin_new(m->clazz);
+
+       if (h == NULL)
+               return NULL;
+        
+       // Call initializer.
+       (void) Reflection::invoke(m, h, args);
+
+       return h;
+}
+
+
+/**
+ * Invokes the given method.
+ *
+ * @param args Method arguments.
+ *
+ * @return return value of the method
+ */
+java_handle_t* java_lang_reflect_Method::invoke(java_handle_t* o, java_handle_objectarray_t* args)
+{
+       methodinfo* m = get_method();
+
+       // Should we bypass security the checks (AccessibleObject)?
+       if (get_override() == false) {
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+               /* This method is always called like this:
+                      [0] java.lang.reflect.Method.invokeNative (Native Method)
+                      [1] java.lang.reflect.Method.invoke (Method.java:329)
+                      [2] <caller>
+               */
+
+               if (!access_check_method(m, 2))
+                       return NULL;
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+               /* We only pass 1 here as stacktrace_get_caller_class, which
+                  is called from access_check_method, skips
+                  java.lang.reflect.Method.invoke(). */
+
+               if (!access_check_method(m, 1))
+                       return NULL;
+#else
+# error unknown classpath configuration
+#endif
+       }
+
+       // Check if method class is initialized.
+       if (!(m->clazz->state & CLASS_INITIALIZED))
+               if (!initialize_class(m->clazz))
+                       return NULL;
+
+       // Call the Java method.
+       java_handle_t* result = Reflection::invoke(m, o, args);
+
+       return result;
+}
+
+#endif // ENABLE_JAVASE
+
+
+/*
+ * 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:
+ */
diff --git a/src/vm/javaobjects.hpp b/src/vm/javaobjects.hpp
new file mode 100644 (file)
index 0000000..f530218
--- /dev/null
@@ -0,0 +1,2834 @@
+/* src/vm/javaobjects.hpp - functions to create and access Java objects
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _JAVAOBJECTS_HPP
+#define _JAVAOBJECTS_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "threads/atomic.hpp"
+
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/method.hpp"
+
+
+#ifdef __cplusplus
+
+/**
+ * This class provides low-level functions to access Java object
+ * instance fields.
+ *
+ * These functions do NOT take care about the GC critical section!
+ * Please use FieldAccess wherever possible.
+ */
+class RawFieldAccess {
+protected:
+       template<class T> static inline T    raw_get(void* address, const off_t offset);
+       template<class T> static inline void raw_set(void* address, const off_t offset, T value);
+};
+
+
+template<class T> inline T RawFieldAccess::raw_get(void* address, const off_t offset)
+{
+       T* p = (T*) (((uintptr_t) address) + offset);
+       return *p;
+}
+
+
+template<class T> inline void RawFieldAccess::raw_set(void* address, const off_t offset, T value)
+{
+       T* p = (T*) (((uintptr_t) address) + offset);
+       *p = value;
+}
+
+
+/**
+ * This classes provides functions to access Java object instance
+ * fields.  These functions enter a critical GC section before
+ * accessing the Java object throught the handle and leave it
+ * afterwards.
+ */
+class FieldAccess : private RawFieldAccess {
+public:
+       // Normal field accessors.
+       template<class T> static inline T    get(java_handle_t* h, const off_t offset);
+       template<class T> static inline void set(java_handle_t* h, const off_t offset, T value);
+
+       // Volatile field accessors.
+       template<class T> static inline T    get_volatile(java_handle_t* h, const off_t offset);
+       template<class T> static inline void set_volatile(java_handle_t* h, const off_t offset, T value);
+};
+
+
+template<class T> inline T FieldAccess::get(java_handle_t* h, const off_t offset)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       // XXX This should be _handle->get_object();
+       java_object_t* ho = LLNI_UNWRAP(h);
+       return raw_get<T>(ho, offset);
+}
+
+template<> inline java_handle_t* FieldAccess::get(java_handle_t* h, const off_t offset)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       // XXX This should be _handle->get_object();
+       java_object_t* o = LLNI_UNWRAP(h);
+       java_object_t* result = raw_get<java_object_t*>(o, offset);
+       return LLNI_WRAP(result);
+}      
+
+
+template<class T> inline void FieldAccess::set(java_handle_t* h, const off_t offset, T value)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       java_object_t* ho = LLNI_UNWRAP(h);
+       raw_set(ho, offset, value);
+}
+
+template<> inline void FieldAccess::set<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       // XXX This should be h->get_object();
+       java_object_t* o      = LLNI_UNWRAP(h);
+       java_object_t* ovalue = LLNI_UNWRAP(value);
+       raw_set(o, offset, ovalue);
+}
+
+
+template<class T> inline T FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       // XXX This should be _handle->get_object();
+       java_object_t* ho = LLNI_UNWRAP(h);
+       return raw_get<volatile T>(ho, offset);
+}
+
+template<> inline java_handle_t* FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       // XXX This should be _handle->get_object();
+       java_object_t* o = LLNI_UNWRAP(h);
+       java_object_t* result = (java_object_t*) raw_get<volatile java_object_t*>(o, offset);
+       return LLNI_WRAP(result);
+}      
+
+
+template<class T> inline void FieldAccess::set_volatile(java_handle_t* h, const off_t offset, T value)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       java_object_t* ho = LLNI_UNWRAP(h);
+       raw_set(ho, offset, (volatile T) value);
+
+       // Memory barrier for the Java Memory Model.
+       Atomic::memory_barrier();
+}
+
+template<> inline void FieldAccess::set_volatile<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       // XXX This should be h->get_object();
+       java_object_t* o      = LLNI_UNWRAP(h);
+       java_object_t* ovalue = LLNI_UNWRAP(value);
+       raw_set(o, offset, (volatile java_object_t*) ovalue);
+
+       // Memory barrier for the Java Memory Model.
+       Atomic::memory_barrier();
+}
+
+
+/**
+ * java/lang/Object
+ *
+ * Object layout:
+ *
+ * 0. object header
+ */
+class java_lang_Object {
+protected:
+       // Handle of Java object.
+       java_handle_t* _handle;
+
+public:
+       java_lang_Object() : _handle(NULL) {}
+       java_lang_Object(java_handle_t* h) : _handle(h) {}
+       virtual ~java_lang_Object() {}
+
+       // Getters.
+       virtual inline java_handle_t* get_handle  () const { return _handle; }
+       inline vftbl_t*               get_vftbl   () const;
+       inline classinfo*             get_Class   () const;
+       inline int32_t                get_hashcode() const;
+
+       inline bool is_null    () const;
+       inline bool is_non_null() const;
+};
+
+
+inline vftbl_t* java_lang_Object::get_vftbl() const
+{
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       // XXX This should be h->get_object();
+       java_object_t* o = LLNI_UNWRAP(_handle);
+       return o->vftbl;
+}
+
+inline classinfo* java_lang_Object::get_Class() const
+{
+       return get_vftbl()->clazz;
+}
+
+inline int32_t java_lang_Object::get_hashcode() const
+{
+#if defined(ENABLE_GC_CACAO)
+       return heap_get_hashcode(_handle);
+#else
+       // This function is inside a critical section.
+       GCCriticalSection cs;
+
+       // XXX This should be h->get_object();
+       java_object_t* o = LLNI_UNWRAP(_handle);
+       return (int32_t) (intptr_t) o;
+#endif
+}
+
+
+inline bool java_lang_Object::is_null() const
+{
+       return (_handle == NULL);
+}
+
+inline bool java_lang_Object::is_non_null() const
+{
+       return (_handle != NULL);
+}
+
+
+/**
+ * java/lang/Boolean
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. boolean value;
+ */
+class java_lang_Boolean : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+
+public:
+       java_lang_Boolean(java_handle_t* h) : java_lang_Object(h) {}
+
+       inline uint8_t get_value();
+       inline void    set_value(uint8_t value);
+};
+
+inline uint8_t java_lang_Boolean::get_value()
+{
+       return get<int32_t>(_handle, offset_value);
+}
+
+inline void java_lang_Boolean::set_value(uint8_t value)
+{
+       set(_handle, offset_value, (uint32_t) value);
+}
+
+
+/**
+ * java/lang/Byte
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. byte value;
+ */
+class java_lang_Byte : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+
+public:
+       java_lang_Byte(java_handle_t* h) : java_lang_Object(h) {}
+
+       inline int8_t get_value();
+       inline void   set_value(int8_t value);
+};
+
+inline int8_t java_lang_Byte::get_value()
+{
+       return get<int32_t>(_handle, offset_value);
+}
+
+inline void java_lang_Byte::set_value(int8_t value)
+{
+       set(_handle, offset_value, (int32_t) value);
+}
+
+
+/**
+ * java/lang/Character
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. char value;
+ */
+class java_lang_Character : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+
+public:
+       java_lang_Character(java_handle_t* h) : java_lang_Object(h) {}
+
+       inline uint16_t get_value();
+       inline void     set_value(uint16_t value);
+};
+
+inline uint16_t java_lang_Character::get_value()
+{
+       return get<int32_t>(_handle, offset_value);
+}
+
+inline void java_lang_Character::set_value(uint16_t value)
+{
+       set(_handle, offset_value, (uint32_t) value);
+}
+
+
+/**
+ * java/lang/Short
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. short value;
+ */
+class java_lang_Short : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+
+public:
+       java_lang_Short(java_handle_t* h) : java_lang_Object(h) {}
+
+       inline int16_t get_value();
+       inline void    set_value(int16_t value);
+};
+
+inline int16_t java_lang_Short::get_value()
+{
+       return get<int32_t>(_handle, offset_value);
+}
+
+inline void java_lang_Short::set_value(int16_t value)
+{
+       set(_handle, offset_value, (int32_t) value);
+}
+
+
+/**
+ * java/lang/Integer
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int value;
+ */
+class java_lang_Integer : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+
+public:
+       java_lang_Integer(java_handle_t* h) : java_lang_Object(h) {}
+
+       inline int32_t get_value();
+       inline void    set_value(int32_t value);
+};
+
+inline int32_t java_lang_Integer::get_value()
+{
+       return get<int32_t>(_handle, offset_value);
+}
+
+inline void java_lang_Integer::set_value(int32_t value)
+{
+       set(_handle, offset_value, value);
+}
+
+
+/**
+ * java/lang/Long
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. long value;
+ */
+class java_lang_Long : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
+
+public:
+       java_lang_Long(java_handle_t* h) : java_lang_Object(h) {}
+
+       inline int64_t get_value();
+       inline void    set_value(int64_t value);
+};
+
+inline int64_t java_lang_Long::get_value()
+{
+       return get<int64_t>(_handle, offset_value);
+}
+
+inline void java_lang_Long::set_value(int64_t value)
+{
+       set(_handle, offset_value, value);
+}
+
+
+/**
+ * java/lang/Float
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. float value;
+ */
+class java_lang_Float : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(float));
+
+public:
+       java_lang_Float(java_handle_t* h) : java_lang_Object(h) {}
+
+       inline float get_value();
+       inline void  set_value(float value);
+};
+
+inline float java_lang_Float::get_value()
+{
+       return get<float>(_handle, offset_value);
+}
+
+inline void java_lang_Float::set_value(float value)
+{
+       set(_handle, offset_value, value);
+}
+
+
+/**
+ * java/lang/Double
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. double value;
+ */
+class java_lang_Double : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(double));
+
+public:
+       java_lang_Double(java_handle_t* h) : java_lang_Object(h) {}
+
+       inline double get_value();
+       inline void   set_value(double value);
+};
+
+inline double java_lang_Double::get_value()
+{
+       return get<double>(_handle, offset_value);
+}
+
+inline void java_lang_Double::set_value(double value)
+{
+       set(_handle, offset_value, value);
+}
+
+
+#if defined(ENABLE_JAVASE)
+
+# if defined(ENABLE_ANNOTATIONS)
+/**
+ * OpenJDK sun/reflect/ConstantPool
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Object constantPoolOop;
+ */
+class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+
+public:
+       sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {}
+       sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop);
+
+       // Setters.
+       inline void set_constantPoolOop(classinfo* value);
+       inline void set_constantPoolOop(jclass value);
+};
+
+
+inline sun_reflect_ConstantPool::sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop) : java_lang_Object(h)
+{
+       set_constantPoolOop(constantPoolOop);
+}
+
+
+inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value)
+{
+       set(_handle, offset_constantPoolOop, value);
+}
+
+inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value)
+{
+       // XXX jclass is a boxed object.
+       set_constantPoolOop(LLNI_classinfo_unwrap(value));
+}
+# endif // ENABLE_ANNOTATIONS
+
+#endif // ENABLE_JAVASE
+
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+/**
+ * GNU Classpath java/lang/Class
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Object[]             signers;
+ * 2. java.security.ProtectionDomain pd;
+ * 3. java.lang.Object               vmdata;
+ * 4. java.lang.reflect.Constructor  constructor;
+ */
+class java_lang_Class : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_signers     = MEMORY_ALIGN(sizeof(java_object_t),          SIZEOF_VOID_P);
+       static const off_t offset_pd          = MEMORY_ALIGN(offset_signers + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_vmdata      = MEMORY_ALIGN(offset_pd      + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_constructor = MEMORY_ALIGN(offset_vmdata  + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+       java_lang_Class(java_handle_t* h) : java_lang_Object(h) {}
+
+       // Setters.
+       inline void set_pd(java_handle_t* value);
+};
+
+inline void java_lang_Class::set_pd(java_handle_t* value)
+{
+       set(_handle, offset_pd, value);
+}
+
+
+/**
+ * GNU Classpath java/lang/StackTraceElement
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.String fileName;
+ * 2. int              lineNumber;
+ * 3. java.lang.String declaringClass;
+ * 4. java.lang.String methodName;
+ * 5. boolean          isNative;
+ */
+class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_fileName       = MEMORY_ALIGN(sizeof(java_object_t),                   SIZEOF_VOID_P);
+       static const off_t offset_lineNumber     = MEMORY_ALIGN(offset_fileName       + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber     + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_methodName     = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_isNative       = MEMORY_ALIGN(offset_methodName     + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_StackTraceElement(java_handle_t* h, java_handle_t* fileName, int32_t lineNumber, java_handle_t* declaringClass, java_handle_t* methodName, uint8_t isNative);
+};
+
+inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* h, java_handle_t* fileName, int32_t lineNumber, java_handle_t* declaringClass, java_handle_t* methodName, uint8_t isNative) : java_lang_Object(h)
+{
+       java_lang_StackTraceElement((java_handle_t*) h);
+
+       set(_handle, offset_fileName,       fileName);
+       set(_handle, offset_lineNumber,     lineNumber);
+       set(_handle, offset_declaringClass, declaringClass);
+       set(_handle, offset_methodName,     methodName);
+       set(_handle, offset_isNative,       isNative);
+}
+
+
+/**
+ * GNU Classpath java/lang/String
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. char[] value;
+ * 2. int    count;
+ * 3. int    cachedHashCode;
+ * 4. int    offset;
+ */
+class java_lang_String : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value          = MEMORY_ALIGN(sizeof(java_object_t),                   SIZEOF_VOID_P);
+       static const off_t offset_count          = MEMORY_ALIGN(offset_value          + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count          + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_offset         = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t));
+
+public:
+       java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
+
+       // Getters.
+       inline java_handle_chararray_t* get_value () const;
+       inline int32_t                  get_count () const;
+       inline int32_t                  get_offset() const;
+
+       // Setters.
+       inline void set_value (java_handle_chararray_t* value);
+       inline void set_count (int32_t value);
+       inline void set_offset(int32_t value);
+};
+
+inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h)
+{
+       set_value(value);
+       set_count(count);
+       set_offset(offset);
+}
+
+inline java_handle_chararray_t* java_lang_String::get_value() const
+{
+       return get<java_handle_chararray_t*>(_handle, offset_value);
+}
+
+inline int32_t java_lang_String::get_count() const
+{
+       return get<int32_t>(_handle, offset_count);
+}
+
+inline int32_t java_lang_String::get_offset() const
+{
+       return get<int32_t>(_handle, offset_offset);
+}
+
+inline void java_lang_String::set_value(java_handle_chararray_t* value)
+{
+       set(_handle, offset_value, value);
+}
+
+inline void java_lang_String::set_count(int32_t value)
+{
+       set(_handle, offset_count, value);
+}
+
+inline void java_lang_String::set_offset(int32_t value)
+{
+       set(_handle, offset_offset, value);
+}
+
+
+/**
+ * GNU Classpath java/lang/Thread
+ *
+ * Object layout:
+ *
+ *  0. object header
+ *  1. java.lang.VMThread                        vmThread;
+ *  2. java.lang.ThreadGroup                     group;
+ *  3. java.lang.Runnable                        runnable;
+ *  4. java.lang.String                          name;
+ *  5. boolean                                   daemon;
+ *  6. int                                       priority;
+ *  7. long                                      stacksize;
+ *  8. java.lang.Throwable                       stillborn;
+ *  9. java.lang.ClassLoader                     contextClassLoader;
+ * 10. boolean                                   contextClassLoaderIsSystemClassLoader;
+ * 11. long                                      threadId;
+ * 12. java.lang.Object                          parkBlocker;
+ * 13. gnu.java.util.WeakIdentityHashMap         locals;
+ * 14. java_lang_Thread_UncaughtExceptionHandler exceptionHandler;
+ */
+class java_lang_Thread : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_vmThread                              = MEMORY_ALIGN(sizeof(java_object_t),                                          SIZEOF_VOID_P);
+       static const off_t offset_group                                 = MEMORY_ALIGN(offset_vmThread                              + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_runnable                              = MEMORY_ALIGN(offset_group                                 + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_name                                  = MEMORY_ALIGN(offset_runnable                              + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_daemon                                = MEMORY_ALIGN(offset_name                                  + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_priority                              = MEMORY_ALIGN(offset_daemon                                + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_stacksize                             = MEMORY_ALIGN(offset_priority                              + sizeof(int32_t), sizeof(int64_t));
+       static const off_t offset_stillborn                             = MEMORY_ALIGN(offset_stacksize                             + sizeof(int64_t), SIZEOF_VOID_P);
+       static const off_t offset_contextClassLoader                    = MEMORY_ALIGN(offset_stillborn                             + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_contextClassLoaderIsSystemClassLoader = MEMORY_ALIGN(offset_contextClassLoader                    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_threadId                              = MEMORY_ALIGN(offset_contextClassLoaderIsSystemClassLoader + sizeof(int32_t), sizeof(int64_t));
+       static const off_t offset_parkBlocker                           = MEMORY_ALIGN(offset_threadId                              + sizeof(int64_t), SIZEOF_VOID_P);
+       static const off_t offset_locals                                = MEMORY_ALIGN(offset_parkBlocker                           + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_exceptionHandler                      = MEMORY_ALIGN(offset_locals                                + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
+//     java_lang_Thread(threadobject* t);
+
+       // Getters.
+       inline java_handle_t* get_vmThread        () const;
+       inline java_handle_t* get_group           () const;
+       inline java_handle_t* get_name            () const;
+       inline int32_t        get_daemon          () const;
+       inline int32_t        get_priority        () const;
+       inline java_handle_t* get_exceptionHandler() const;
+
+       // Setters.
+       inline void set_group(java_handle_t* value);
+};
+
+
+// inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
+// {
+//     java_lang_Thread(thread_get_object(t));
+// }
+
+
+inline java_handle_t* java_lang_Thread::get_vmThread() const
+{
+       return get<java_handle_t*>(_handle, offset_vmThread);
+}
+
+inline java_handle_t* java_lang_Thread::get_group() const
+{
+       return get<java_handle_t*>(_handle, offset_group);
+}
+
+inline java_handle_t* java_lang_Thread::get_name() const
+{
+       return get<java_handle_t*>(_handle, offset_name);
+}
+
+inline int32_t java_lang_Thread::get_daemon() const
+{
+       return get<int32_t>(_handle, offset_daemon);
+}
+
+inline int32_t java_lang_Thread::get_priority() const
+{
+       return get<int32_t>(_handle, offset_priority);
+}
+
+inline java_handle_t* java_lang_Thread::get_exceptionHandler() const
+{
+       return get<java_handle_t*>(_handle, offset_exceptionHandler);
+}
+
+
+inline void java_lang_Thread::set_group(java_handle_t* value)
+{
+       set(_handle, offset_group, value);
+}
+
+
+/**
+ * GNU Classpath java/lang/VMThread
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Thread   thread;
+ * 2. boolean            running;
+ * 3. java.lang.VMThread vmdata;
+ */
+class java_lang_VMThread : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_thread  = MEMORY_ALIGN(sizeof(java_object_t),            SIZEOF_VOID_P);
+       static const off_t offset_running = MEMORY_ALIGN(offset_thread  + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_vmdata  = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P);
+
+public:
+       java_lang_VMThread(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata);
+
+       // Getters.
+       inline java_handle_t* get_thread() const;
+       inline threadobject*  get_vmdata() const;
+
+       // Setters.
+       inline void set_thread(java_handle_t* value);
+       inline void set_vmdata(threadobject* value);
+};
+
+
+inline java_lang_VMThread::java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata) : java_lang_Object(h)
+{
+       set_thread(thread);
+       set_vmdata(vmdata);
+}
+
+
+inline java_handle_t* java_lang_VMThread::get_thread() const
+{
+       return get<java_handle_t*>(_handle, offset_thread);
+}
+
+inline threadobject* java_lang_VMThread::get_vmdata() const
+{
+       return get<threadobject*>(_handle, offset_vmdata);
+}
+
+
+inline void java_lang_VMThread::set_thread(java_handle_t* value)
+{
+       set(_handle, offset_thread, value);
+}
+
+inline void java_lang_VMThread::set_vmdata(threadobject* value)
+{
+       set(_handle, offset_vmdata, value);
+}
+
+
+/**
+ * GNU Classpath java/lang/Throwable
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.String              detailMessage;
+ * 2. java.lang.Throwable           cause;
+ * 3. java.lang.StackTraceElement[] stackTrace;
+ * 4. java.lang.VMThrowable         vmState;
+ */
+class java_lang_Throwable : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t),                SIZEOF_VOID_P);
+       static const off_t offset_cause         = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_stackTrace    = MEMORY_ALIGN(offset_cause         + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_vmState       = MEMORY_ALIGN(offset_stackTrace    + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+       java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
+
+       // Getters.
+       inline java_handle_t* get_detailMessage() const;
+       inline java_handle_t* get_cause        () const;
+       inline java_handle_t* get_vmState      () const;
+};
+
+
+inline java_handle_t* java_lang_Throwable::get_detailMessage() const
+{
+       return get<java_handle_t*>(_handle, offset_detailMessage);
+}
+
+inline java_handle_t* java_lang_Throwable::get_cause() const
+{
+       return get<java_handle_t*>(_handle, offset_cause);
+}
+
+inline java_handle_t* java_lang_Throwable::get_vmState() const
+{
+       return get<java_handle_t*>(_handle, offset_vmState);
+}
+
+
+/**
+ * GNU Classpath java/lang/VMThrowable
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Object vmdata;
+ */
+class java_lang_VMThrowable : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+
+public:
+       java_lang_VMThrowable(java_handle_t* h) : java_lang_Object(h) {}
+
+       inline java_handle_bytearray_t* get_vmdata() const;
+       inline void                     set_vmdata(java_handle_bytearray_t* value);
+};
+
+
+inline java_handle_bytearray_t* java_lang_VMThrowable::get_vmdata() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_vmdata);
+}
+
+inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_vmdata, value);
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/VMConstructor
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Class               clazz;
+ * 2. int                           slot;
+ * 3. byte[]                        annotations;
+ * 4. byte[]                        parameterAnnotations;
+ * 5. java.util.Map                 declaredAnnotations;
+ * 6. java.lang.reflect.Constructor cons;
+ */
+class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_clazz                = MEMORY_ALIGN(sizeof(java_object_t),                         SIZEOF_VOID_P);
+       static const off_t offset_slot                 = MEMORY_ALIGN(offset_clazz                + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_annotations          = MEMORY_ALIGN(offset_slot                 + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_declaredAnnotations  = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_cons                 = MEMORY_ALIGN(offset_declaredAnnotations  + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_VMConstructor(methodinfo* m);
+
+       // Getters.
+       inline classinfo*               get_clazz               () const;
+       inline int32_t                  get_slot                () const;
+       inline java_handle_bytearray_t* get_annotations         () const;
+       inline java_handle_bytearray_t* get_parameterAnnotations() const;
+       inline java_handle_t*           get_declaredAnnotations () const;
+       inline java_handle_t*           get_cons                () const;
+
+       // Setters.
+       inline void set_clazz               (classinfo* value);
+       inline void set_slot                (int32_t value);
+       inline void set_annotations         (java_handle_bytearray_t* value);
+       inline void set_parameterAnnotations(java_handle_bytearray_t* value);
+       inline void set_declaredAnnotations (java_handle_t* value);
+       inline void set_cons                (java_handle_t* value);
+
+       // Convenience functions.
+       inline methodinfo* get_method();
+};
+
+
+inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(methodinfo* m)
+{
+       _handle = builtin_new(class_java_lang_reflect_VMConstructor);
+
+       if (is_null())
+               return;
+
+       int                      slot                 = m - m->clazz->methods;
+       java_handle_bytearray_t* annotations          = method_get_annotations(m);
+       java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
+
+       set_clazz(m->clazz);
+       set_slot(slot);
+       set_annotations(annotations);
+       set_parameterAnnotations(parameterAnnotations);
+}
+
+
+inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
+{
+       return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_VMConstructor::get_slot() const
+{
+       return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
+}
+
+inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
+{
+       return get<java_handle_t*>(_handle, offset_declaredAnnotations);
+}
+
+inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
+{
+       return get<java_handle_t*>(_handle, offset_cons);
+}
+
+inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
+{
+       set(_handle, offset_clazz, value);
+}
+
+inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
+{
+       set(_handle, offset_slot, value);
+}
+
+inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_annotations, value);
+}
+
+inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_parameterAnnotations, value);
+}
+
+inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
+{
+       set(_handle, offset_declaredAnnotations, value);
+}
+
+inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
+{
+       set(_handle, offset_cons, value);
+}
+
+inline methodinfo* java_lang_reflect_VMConstructor::get_method()
+{
+       classinfo*  c    = get_clazz();
+       int32_t     slot = get_slot();
+       methodinfo* m    = &(c->methods[slot]);
+       return m;
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/Constructor
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. boolean                                     flag;
+ * 2. gnu.java.lang.reflect.MethodSignatureParser p;
+ * 3. java.lang.reflect.VMConstructor             cons;
+ */
+class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t),         sizeof(int32_t));
+       static const off_t offset_p    = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_cons = MEMORY_ALIGN(offset_p    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Constructor(methodinfo* m);
+
+       java_handle_t* new_instance(java_handle_objectarray_t* args);
+
+       // Getters.
+       inline int32_t        get_flag() const;
+       inline java_handle_t* get_cons() const;
+
+       // Setters.
+       inline void set_cons(java_handle_t* value);
+
+       // Convenience functions.
+       inline methodinfo* get_method  () const;
+       inline int32_t     get_override() const;
+};
+
+
+inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
+{
+       java_lang_reflect_VMConstructor jlrvmc(m);
+
+       if (jlrvmc.is_null())
+               return;
+
+       _handle = builtin_new(class_java_lang_reflect_Constructor);
+
+       if (is_null())
+               return;
+
+       // Link the two Java objects.
+       set_cons(jlrvmc.get_handle());
+       jlrvmc.set_cons(get_handle());
+}
+
+
+inline int32_t java_lang_reflect_Constructor::get_flag() const
+{
+       return get<int32_t>(_handle, offset_flag);
+}
+
+inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
+{
+       return get<java_handle_t*>(_handle, offset_cons);
+}
+
+
+inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
+{
+       set(_handle, offset_cons, value);
+}
+
+
+inline methodinfo* java_lang_reflect_Constructor::get_method() const
+{
+       java_lang_reflect_VMConstructor jlrvmc(get_cons());
+       return jlrvmc.get_method();
+}
+
+inline int32_t java_lang_reflect_Constructor::get_override() const
+{
+       return get_flag();
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/VMField
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Class         clazz;
+ * 2. java.lang.String        name;
+ * 3. int                     slot;
+ * 4. byte[]                  annotations;
+ * 5. java.lang.Map           declaredAnnotations;
+ * 6. java.lang.reflect.Field f;
+ */
+class java_lang_reflect_VMField : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_clazz               = MEMORY_ALIGN(sizeof(java_object_t),                        SIZEOF_VOID_P);
+       static const off_t offset_name                = MEMORY_ALIGN(offset_clazz               + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_slot                = MEMORY_ALIGN(offset_name                + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_annotations         = MEMORY_ALIGN(offset_slot                + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations         + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_f                   = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_VMField(fieldinfo* f);
+
+       // Getters.
+       inline classinfo*               get_clazz              () const;
+       inline int32_t                  get_slot               () const;
+       inline java_handle_bytearray_t* get_annotations        () const;
+       inline java_handle_t*           get_declaredAnnotations() const;
+       inline java_handle_t*           get_f                  () const;
+
+       // Setters.
+       inline void set_clazz              (classinfo* value);
+       inline void set_name               (java_handle_t* value);
+       inline void set_slot               (int32_t value);
+       inline void set_annotations        (java_handle_bytearray_t* value);
+       inline void set_declaredAnnotations(java_handle_t* value);
+       inline void set_f                  (java_handle_t* value);
+
+       // Convenience functions.
+       inline fieldinfo* get_field() const;
+};
+
+
+inline java_lang_reflect_VMField::java_lang_reflect_VMField(fieldinfo* f)
+{
+       _handle = builtin_new(class_java_lang_reflect_VMField);
+
+       if (is_null())
+               return;
+
+       java_handle_t*           name        = javastring_intern(javastring_new(f->name));
+       int                      slot        = f - f->clazz->fields;
+       java_handle_bytearray_t* annotations = field_get_annotations(f);
+
+       set_clazz(f->clazz);
+       set_name(name);
+       set_slot(slot);
+       set_annotations(annotations);
+}
+
+
+inline classinfo* java_lang_reflect_VMField::get_clazz() const
+{
+       return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_VMField::get_slot() const
+{
+       return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMField::get_annotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+inline java_handle_t* java_lang_reflect_VMField::get_declaredAnnotations() const
+{
+       return get<java_handle_t*>(_handle, offset_declaredAnnotations);
+}
+
+inline java_handle_t* java_lang_reflect_VMField::get_f() const
+{
+       return get<java_handle_t*>(_handle, offset_f);
+}
+
+
+inline void java_lang_reflect_VMField::set_clazz(classinfo* value)
+{
+       set(_handle, offset_clazz, value);
+}
+
+inline void java_lang_reflect_VMField::set_name(java_handle_t* value)
+{
+       set(_handle, offset_name, value);
+}
+
+inline void java_lang_reflect_VMField::set_slot(int32_t value)
+{
+       set(_handle, offset_slot, value);
+}
+
+inline void java_lang_reflect_VMField::set_annotations(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_annotations, value);
+}
+
+inline void java_lang_reflect_VMField::set_declaredAnnotations(java_handle_t* value)
+{
+       set(_handle, offset_declaredAnnotations, value);
+}
+
+inline void java_lang_reflect_VMField::set_f(java_handle_t* value)
+{
+       set(_handle, offset_f, value);
+}
+
+inline fieldinfo* java_lang_reflect_VMField::get_field() const
+{
+       classinfo* c    = get_clazz();
+       int32_t    slot = get_slot();
+       fieldinfo* f    = &(c->fields[slot]);
+       return f;
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/Field
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. boolean                                    flag;
+ * 2. gnu.java.lang.reflect.FieldSignatureParser p;
+ * 3. java.lang.reflect.VMField                  f;
+ */
+class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t),         sizeof(int32_t));
+       static const off_t offset_p    = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_f    = MEMORY_ALIGN(offset_p    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Field(fieldinfo* f);
+
+       // Getters.
+       inline int32_t        get_flag() const;
+       inline java_handle_t* get_f() const;
+
+       // Setters.
+       inline void set_f(java_handle_t* value);
+
+       // Convenience functions.
+       inline fieldinfo* get_field() const;
+};
+
+
+inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
+{
+       java_lang_reflect_VMField jlrvmf(f);
+
+       if (jlrvmf.is_null())
+               return;
+
+       _handle = builtin_new(class_java_lang_reflect_Field);
+
+       if (is_null())
+               return;
+
+       // Link the two Java objects.
+       set_f(jlrvmf.get_handle());
+       jlrvmf.set_f(get_handle());
+}
+
+
+inline int32_t java_lang_reflect_Field::get_flag() const
+{
+       return get<int32_t>(_handle, offset_flag);
+}
+
+inline java_handle_t* java_lang_reflect_Field::get_f() const
+{
+       return get<java_handle_t*>(_handle, offset_f);
+}
+
+
+inline void java_lang_reflect_Field::set_f(java_handle_t* value)
+{
+       set(_handle, offset_f, value);
+}
+
+
+inline fieldinfo* java_lang_reflect_Field::get_field() const
+{
+       java_lang_reflect_VMField jlrvmf(get_f());
+       return jlrvmf.get_field();
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/VMMethod
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Class          clazz;
+ * 2. java.lang.String         name;
+ * 3. int                      slot;
+ * 4. byte[]                   annotations;
+ * 5. byte[]                   parameterAnnotations;
+ * 6. byte[]                   annotationDefault;
+ * 7. java.lang.Map            declaredAnnotations;
+ * 8. java.lang.reflect.Method m;
+ */
+class java_lang_reflect_VMMethod : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_clazz                = MEMORY_ALIGN(sizeof(java_object_t),                         SIZEOF_VOID_P);
+       static const off_t offset_name                 = MEMORY_ALIGN(offset_clazz                + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_slot                 = MEMORY_ALIGN(offset_name                 + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_annotations          = MEMORY_ALIGN(offset_slot                 + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_annotationDefault    = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_declaredAnnotations  = MEMORY_ALIGN(offset_annotationDefault    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_m                    = MEMORY_ALIGN(offset_declaredAnnotations  + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_VMMethod(methodinfo* m);
+
+       // Getters.
+       inline classinfo*               get_clazz               () const;
+       inline int32_t                  get_slot                () const;
+       inline java_handle_bytearray_t* get_annotations         () const;
+       inline java_handle_bytearray_t* get_parameterAnnotations() const;
+       inline java_handle_bytearray_t* get_annotationDefault   () const;
+       inline java_handle_t*           get_declaredAnnotations () const;
+       inline java_handle_t*           get_m                   () const;
+
+       // Setters.
+       inline void set_clazz               (classinfo* value);
+       inline void set_name                (java_handle_t* value);
+       inline void set_slot                (int32_t value);
+       inline void set_annotations         (java_handle_bytearray_t* value);
+       inline void set_parameterAnnotations(java_handle_bytearray_t* value);
+       inline void set_annotationDefault   (java_handle_bytearray_t* value);
+       inline void set_declaredAnnotations (java_handle_t* value);
+       inline void set_m                   (java_handle_t* value);
+
+       // Convenience functions.
+       inline methodinfo* get_method() const;
+};
+
+
+inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(methodinfo* m)
+{
+       _handle = builtin_new(class_java_lang_reflect_VMMethod);
+
+       if (is_null())
+               return;
+
+       java_handle_t*           name                 = javastring_intern(javastring_new(m->name));
+       int                      slot                 = m - m->clazz->methods;
+       java_handle_bytearray_t* annotations          = method_get_annotations(m);
+       java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
+       java_handle_bytearray_t* annotationDefault    = method_get_annotationdefault(m);
+
+       set_clazz(m->clazz);
+       set_name(name);
+       set_slot(slot);
+       set_annotations(annotations);
+       set_parameterAnnotations(parameterAnnotations);
+       set_annotationDefault(annotationDefault);
+}
+
+inline classinfo* java_lang_reflect_VMMethod::get_clazz() const
+{
+       return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_VMMethod::get_slot() const
+{
+       return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_parameterAnnotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotationDefault() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
+}
+
+inline java_handle_t* java_lang_reflect_VMMethod::get_declaredAnnotations() const
+{
+       return get<java_handle_t*>(_handle, offset_declaredAnnotations);
+}
+
+inline java_handle_t* java_lang_reflect_VMMethod::get_m() const
+{
+       return get<java_handle_t*>(_handle, offset_m);
+}
+
+inline void java_lang_reflect_VMMethod::set_clazz(classinfo* value)
+{
+       set(_handle, offset_clazz, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_name(java_handle_t* value)
+{
+       set(_handle, offset_name, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_slot(int32_t value)
+{
+       set(_handle, offset_slot, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_annotations(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_annotations, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_parameterAnnotations(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_parameterAnnotations, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_annotationDefault(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_annotationDefault, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_declaredAnnotations(java_handle_t* value)
+{
+       set(_handle, offset_declaredAnnotations, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_m(java_handle_t* value)
+{
+       set(_handle, offset_m, value);
+}
+
+inline methodinfo* java_lang_reflect_VMMethod::get_method() const
+{
+       classinfo*  c    = get_clazz();
+       int32_t     slot = get_slot();
+       methodinfo* m    = &(c->methods[slot]);
+       return m;
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/Method
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. boolean                                     flag;
+ * 2. gnu.java.lang.reflect.MethodSignatureParser p;
+ * 3. java.lang.reflect.VMMethod                  m;
+ */
+class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t),         sizeof(int32_t));
+       static const off_t offset_p    = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_m    = MEMORY_ALIGN(offset_p    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Method(methodinfo* m);
+
+       java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
+
+       // Getters.
+       inline int32_t        get_flag() const;
+       inline java_handle_t* get_m() const;
+
+       // Setters.
+       inline void set_m(java_handle_t* value);
+
+       // Convenience functions.
+       inline methodinfo* get_method  () const;
+       inline int32_t     get_override() const;
+};
+
+
+inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
+{
+       java_lang_reflect_VMMethod jlrvmm(m);
+
+       if (jlrvmm.is_null())
+               return;
+
+       _handle = builtin_new(class_java_lang_reflect_Method);
+
+       if (is_null())
+               return;
+
+       // Link the two Java objects.
+       set_m(jlrvmm.get_handle());
+       jlrvmm.set_m(get_handle());
+}
+
+
+inline int32_t java_lang_reflect_Method::get_flag() const
+{
+       return get<int32_t>(_handle, offset_flag);
+}
+
+inline java_handle_t* java_lang_reflect_Method::get_m() const
+{
+       return get<java_handle_t*>(_handle, offset_m);
+}
+
+
+inline void java_lang_reflect_Method::set_m(java_handle_t* value)
+{
+       set(_handle, offset_m, value);
+}
+
+
+inline methodinfo* java_lang_reflect_Method::get_method() const
+{
+       java_lang_reflect_VMMethod jlrvmm(get_m());
+       return jlrvmm.get_method();
+}
+
+inline int32_t java_lang_reflect_Method::get_override() const
+{
+       return get_flag();
+}
+
+
+/**
+ * GNU Classpath java/nio/Buffer
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int                   cap;
+ * 2. int                   limit;
+ * 3. int                   pos;
+ * 4. int                   mark;
+ * 5. gnu.classpath.Pointer address;
+ */
+class java_nio_Buffer : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_cap     = MEMORY_ALIGN(sizeof(java_object_t),          sizeof(int32_t));
+       static const off_t offset_limit   = MEMORY_ALIGN(offset_cap   + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_pos     = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_mark    = MEMORY_ALIGN(offset_pos   + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_address = MEMORY_ALIGN(offset_mark  + sizeof(int32_t), SIZEOF_VOID_P);
+
+public:
+       java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
+
+       // Getters.
+       inline int32_t get_cap() const;
+};
+
+inline int32_t java_nio_Buffer::get_cap() const
+{
+       return get<int32_t>(_handle, offset_cap);
+}
+
+
+/**
+ * GNU Classpath java/nio/DirectByteBufferImpl
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int                   cap;
+ * 2. int                   limit;
+ * 3. int                   pos;
+ * 4. int                   mark;
+ * 5. gnu.classpath.Pointer address;
+ * 6. java.nio.ByteOrder    endian;
+ * 7. byte[]                backing_buffer;
+ * 8. int                   array_offset;
+ * 9. java.lang.Object      owner;
+ */
+class java_nio_DirectByteBufferImpl : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_cap            = MEMORY_ALIGN(sizeof(java_object_t),                   sizeof(int32_t));
+       static const off_t offset_limit          = MEMORY_ALIGN(offset_cap            + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_pos            = MEMORY_ALIGN(offset_limit          + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_mark           = MEMORY_ALIGN(offset_pos            + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_address        = MEMORY_ALIGN(offset_mark           + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_endian         = MEMORY_ALIGN(offset_address        + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian         + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_array_offset   = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_owner          = MEMORY_ALIGN(offset_array_offset   + sizeof(int32_t), SIZEOF_VOID_P);
+
+public:
+       java_nio_DirectByteBufferImpl(java_handle_t* h) : java_lang_Object(h) {}
+
+       // Getters.
+       inline java_handle_t* get_address() const;
+};
+
+
+inline java_handle_t* java_nio_DirectByteBufferImpl::get_address() const
+{
+       return get<java_handle_t*>(_handle, offset_address);
+}
+
+
+/**
+ * GNU Classpath gnu/classpath/Pointer
+ *
+ * Actually there are two classes, gnu.classpath.Pointer32 and
+ * gnu.classpath.Pointer64, but we only define the abstract super
+ * class and use the int/long field as void* type.
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int/long data;
+ */
+class gnu_classpath_Pointer : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+
+public:
+       gnu_classpath_Pointer(java_handle_t* h) : java_lang_Object(h) {}
+       gnu_classpath_Pointer(java_handle_t* h, void* data);
+
+       // Setters.
+       inline void* get_data() const;
+
+       // Setters.
+       inline void set_data(void* value);
+};
+
+inline gnu_classpath_Pointer::gnu_classpath_Pointer(java_handle_t* h, void* data) : java_lang_Object(h)
+{
+       set_data(data);
+}
+
+inline void* gnu_classpath_Pointer::get_data() const
+{
+       return get<void*>(_handle, offset_data);
+}
+
+inline void gnu_classpath_Pointer::set_data(void* value)
+{
+       set(_handle, offset_data, value);
+}
+
+#endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
+
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+/**
+ * OpenJDK java/lang/AssertionStatusDirectives
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.String[] classes;
+ * 2. boolean[]          classEnabled;
+ * 3. java.lang.String[] packages;
+ * 4. boolean[]          packageEnabled;
+ * 5. boolean            deflt;
+ */
+class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_classes        = MEMORY_ALIGN(sizeof(java_object_t),                 SIZEOF_VOID_P);
+       static const off_t offset_classEnabled   = MEMORY_ALIGN(offset_classes        + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_packages       = MEMORY_ALIGN(offset_classEnabled   + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages       + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_deflt          = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t));
+
+public:
+       java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled);
+};
+
+inline java_lang_AssertionStatusDirectives::java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled)
+{
+       classinfo* c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
+
+       // FIXME Load the class at VM startup.
+       if (c == NULL)
+               return;
+
+       _handle = builtin_new(c);
+
+       if (is_null())
+               return;
+
+       set(_handle, offset_classes,        classes);
+       set(_handle, offset_classEnabled,   classEnabled);
+       set(_handle, offset_packages,       packages);
+       set(_handle, offset_packageEnabled, packageEnabled);
+}
+
+
+/**
+ * OpenJDK java/lang/StackTraceElement
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.String declaringClass;
+ * 2. java.lang.String methodName;
+ * 3. java.lang.String fileName;
+ * 4. int              lineNumber;
+ */
+class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_declaringClass = MEMORY_ALIGN(sizeof(java_object_t),                 SIZEOF_VOID_P);
+       static const off_t offset_methodName     = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_fileName       = MEMORY_ALIGN(offset_methodName     + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_lineNumber     = MEMORY_ALIGN(offset_fileName       + SIZEOF_VOID_P, sizeof(int32_t));
+
+public:
+       java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber);
+};
+
+inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber)
+{
+       _handle = builtin_new(class_java_lang_StackTraceElement);
+
+       if (is_null())
+               return;
+
+       set(_handle, offset_declaringClass, declaringClass);
+       set(_handle, offset_methodName,     methodName);
+       set(_handle, offset_fileName,       fileName);
+       set(_handle, offset_lineNumber,     lineNumber);
+}
+
+
+/**
+ * OpenJDK java/lang/String
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. char[] value;
+ * 2. int    offset;
+ * 3. int    count;
+ * 4. int    hash;
+ */
+class java_lang_String : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value  = MEMORY_ALIGN(sizeof(java_object_t),           SIZEOF_VOID_P);
+       static const off_t offset_offset = MEMORY_ALIGN(offset_value  + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_count  = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_hash   = MEMORY_ALIGN(offset_count  + sizeof(int32_t), sizeof(int32_t));
+
+public:
+       java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
+
+       // Getters.
+       inline java_handle_chararray_t* get_value () const;
+       inline int32_t                  get_offset() const;
+       inline int32_t                  get_count () const;
+
+       // Setters.
+       inline void set_value (java_handle_chararray_t* value);
+       inline void set_offset(int32_t value);
+       inline void set_count (int32_t value);
+};
+
+inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h)
+{
+       set_value(value);
+       set_offset(offset);
+       set_count(count);
+}
+
+inline java_handle_chararray_t* java_lang_String::get_value() const
+{
+       return get<java_handle_chararray_t*>(_handle, offset_value);
+}
+
+inline int32_t java_lang_String::get_offset() const
+{
+       return get<int32_t>(_handle, offset_offset);
+}
+
+inline int32_t java_lang_String::get_count() const
+{
+       return get<int32_t>(_handle, offset_count);
+}
+
+inline void java_lang_String::set_value(java_handle_chararray_t* value)
+{
+       set(_handle, offset_value, value);
+}
+
+inline void java_lang_String::set_offset(int32_t value)
+{
+       set(_handle, offset_offset, value);
+}
+
+inline void java_lang_String::set_count(int32_t value)
+{
+       set(_handle, offset_count, value);
+}
+
+
+/**
+ * OpenJDK java/lang/Thread
+ *
+ * Object layout:
+ *
+ * 0.  object header
+ * 1.  char[]                                    name;
+ * 2.  int                                       priority;
+ * 3.  java_lang_Thread                          threadQ;
+ * 4.  long                                      eetop;
+ * 5.  boolean                                   single_step;
+ * 6.  boolean                                   daemon;
+ * 7.  boolean                                   stillborn;
+ * 8.  java_lang_Runnable                        target;
+ * 9.  java_lang_ThreadGroup                     group;
+ * 10. java_lang_ClassLoader                     contextClassLoader;
+ * 11. java_security_AccessControlContext        inheritedAccessControlContext;
+ * 12. java_lang_ThreadLocal_ThreadLocalMap      threadLocals;
+ * 13. java_lang_ThreadLocal_ThreadLocalMap      inheritableThreadLocals;
+ * 14. long                                      stackSize;
+ * 15. long                                      nativeParkEventPointer;
+ * 16. long                                      tid;
+ * 17. int                                       threadStatus;
+ * 18. java_lang_Object                          parkBlocker;
+ * 19. sun_nio_ch_Interruptible                  blocker;
+ * 20. java_lang_Object                          blockerLock;
+ * 21. boolean                                   stopBeforeStart;
+ * 22. java_lang_Throwable                       throwableFromStop;
+ * 23. java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
+ */
+class java_lang_Thread : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_name                          = MEMORY_ALIGN(sizeof(java_object_t),                                  SIZEOF_VOID_P);
+       static const off_t offset_priority                      = MEMORY_ALIGN(offset_name                          + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_threadQ                       = MEMORY_ALIGN(offset_priority                      + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_eetop                         = MEMORY_ALIGN(offset_threadQ                       + SIZEOF_VOID_P,   sizeof(int64_t));
+       static const off_t offset_single_step                   = MEMORY_ALIGN(offset_eetop                         + sizeof(int64_t), sizeof(int32_t));
+       static const off_t offset_daemon                        = MEMORY_ALIGN(offset_single_step                   + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_stillborn                     = MEMORY_ALIGN(offset_daemon                        + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_target                        = MEMORY_ALIGN(offset_stillborn                     + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_group                         = MEMORY_ALIGN(offset_target                        + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_contextClassLoader            = MEMORY_ALIGN(offset_group                         + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_inheritedAccessControlContext = MEMORY_ALIGN(offset_contextClassLoader            + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_threadLocals                  = MEMORY_ALIGN(offset_inheritedAccessControlContext + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_inheritableThreadLocals       = MEMORY_ALIGN(offset_threadLocals                  + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_stackSize                     = MEMORY_ALIGN(offset_inheritableThreadLocals       + SIZEOF_VOID_P,   sizeof(int64_t));
+       static const off_t offset_nativeParkEventPointer        = MEMORY_ALIGN(offset_stackSize                     + sizeof(int64_t), sizeof(int64_t));
+       static const off_t offset_tid                           = MEMORY_ALIGN(offset_nativeParkEventPointer        + sizeof(int64_t), sizeof(int64_t));
+       static const off_t offset_threadStatus                  = MEMORY_ALIGN(offset_tid                           + sizeof(int64_t), sizeof(int32_t));
+       static const off_t offset_parkBlocker                   = MEMORY_ALIGN(offset_threadStatus                  + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_blocker                       = MEMORY_ALIGN(offset_parkBlocker                   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_blockerLock                   = MEMORY_ALIGN(offset_blocker                       + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_stopBeforeStart               = MEMORY_ALIGN(offset_blockerLock                   + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_throwableFromStop             = MEMORY_ALIGN(offset_stopBeforeStart               + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_uncaughtExceptionHandler      = MEMORY_ALIGN(offset_throwableFromStop             + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
+//     java_lang_Thread(threadobject* t);
+
+       // Getters.
+       inline int32_t        get_priority                () const;
+       inline int32_t        get_daemon                  () const;
+       inline java_handle_t* get_group                   () const;
+       inline java_handle_t* get_uncaughtExceptionHandler() const;
+
+       // Setters.
+       inline void set_priority(int32_t value);
+       inline void set_group   (java_handle_t* value);
+};
+
+
+inline int32_t java_lang_Thread::get_priority() const
+{
+       return get<int32_t>(_handle, offset_priority);
+}
+
+inline int32_t java_lang_Thread::get_daemon() const
+{
+       return get<int32_t>(_handle, offset_daemon);
+}
+
+inline java_handle_t* java_lang_Thread::get_group() const
+{
+       return get<java_handle_t*>(_handle, offset_group);
+}
+
+inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const
+{
+       return get<java_handle_t*>(_handle, offset_uncaughtExceptionHandler);
+}
+
+
+inline void java_lang_Thread::set_priority(int32_t value)
+{
+       set(_handle, offset_priority, value);
+}
+
+inline void java_lang_Thread::set_group(java_handle_t* value)
+{
+       set(_handle, offset_group, value);
+}
+
+
+
+/**
+ * OpenJDK java/lang/Throwable
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Object              backtrace;
+ * 2. java.lang.String              detailMessage;
+ * 3. java.lang.Throwable           cause;
+ * 4. java.lang.StackTraceElement[] stackTrace;
+ */
+class java_lang_Throwable : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_backtrace     = MEMORY_ALIGN(sizeof(java_object_t),                SIZEOF_VOID_P);
+       static const off_t offset_detailMessage = MEMORY_ALIGN(offset_backtrace     + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_cause         = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_stackTrace    = MEMORY_ALIGN(offset_cause         + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+       java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace);
+
+       // Getters.
+       inline java_handle_bytearray_t* get_backtrace    () const;
+       inline java_handle_t*           get_detailMessage() const;
+       inline java_handle_t*           get_cause        () const;
+
+       // Setters.
+       inline void set_backtrace(java_handle_bytearray_t* value);
+};
+
+
+inline java_lang_Throwable::java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace) : java_lang_Object(h)
+{
+       set_backtrace(backtrace);
+}
+
+
+inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
+}
+
+inline java_handle_t* java_lang_Throwable::get_detailMessage() const
+{
+       return get<java_handle_t*>(_handle, offset_detailMessage);
+}
+
+inline java_handle_t* java_lang_Throwable::get_cause() const
+{
+       return get<java_handle_t*>(_handle, offset_cause);
+}
+
+
+inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_backtrace, value);
+}
+
+
+/**
+ * OpenJDK java/lang/reflect/Constructor
+ *
+ * Object layout:
+ *
+ * 0.  object header
+ * 1.  boolean                                               override;
+ * 2.  java.lang.Class                                       clazz;
+ * 3.  int                                                   slot;
+ * 4.  java.lang.Class[]                                     parameterTypes;
+ * 5.  java.lang.Class[]                                     exceptionTypes;
+ * 6.  int                                                   modifiers;
+ * 7.  java.lang.String                                      signature;
+ * 8.  sun.reflect.generics.repository.ConstructorRepository genericInfo;
+ * 9.  byte[]                                                annotations;
+ * 10. byte[]                                                parameterAnnotations;
+ * 11. java.lang.Class                                       securityCheckCache;
+ * 12. sun.reflect.ConstructorAccessor                       constructorAccessor;
+ * 13. java.lang.reflect.Constructor                         root;
+ * 14. java.util.Map                                         declaredAnnotations;
+ */
+class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_override             = MEMORY_ALIGN(sizeof(java_object_t),                         sizeof(int32_t));
+       static const off_t offset_clazz                = MEMORY_ALIGN(offset_override             + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_slot                 = MEMORY_ALIGN(offset_clazz                + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_parameterTypes       = MEMORY_ALIGN(offset_slot                 + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_exceptionTypes       = MEMORY_ALIGN(offset_parameterTypes       + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_modifiers            = MEMORY_ALIGN(offset_exceptionTypes       + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_signature            = MEMORY_ALIGN(offset_modifiers            + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_genericInfo          = MEMORY_ALIGN(offset_signature            + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_annotations          = MEMORY_ALIGN(offset_genericInfo          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_securityCheckCache   = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_constructorAccessor  = MEMORY_ALIGN(offset_securityCheckCache   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_root                 = MEMORY_ALIGN(offset_constructorAccessor  + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_declaredAnnotations  = MEMORY_ALIGN(offset_root                 + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Constructor(methodinfo* m);
+
+       java_handle_t* new_instance(java_handle_objectarray_t* args);
+
+       // Getters.
+       inline int32_t                  get_override   () const;
+       inline classinfo*               get_clazz      () const;
+       inline int32_t                  get_slot       () const;
+       inline java_handle_bytearray_t* get_annotations() const;
+
+       // Setters.
+       inline void set_clazz               (classinfo* value);
+       inline void set_slot                (int32_t value);
+       inline void set_parameterTypes      (java_handle_objectarray_t* value);
+       inline void set_exceptionTypes      (java_handle_objectarray_t* value);
+       inline void set_modifiers           (int32_t value);
+       inline void set_signature           (java_handle_t* value);
+       inline void set_annotations         (java_handle_bytearray_t* value);
+       inline void set_parameterAnnotations(java_handle_bytearray_t* value);
+
+       // Convenience functions.
+       inline methodinfo* get_method();
+};
+
+
+inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
+{
+       _handle = builtin_new(class_java_lang_reflect_Constructor);
+
+       if (is_null())
+               return;
+
+       int                        slot                 = m - m->clazz->methods;
+       java_handle_objectarray_t* parameterTypes       = method_get_parametertypearray(m);
+       java_handle_objectarray_t* exceptionTypes       = method_get_exceptionarray(m);
+       java_handle_bytearray_t*   annotations          = method_get_annotations(m);
+       java_handle_bytearray_t*   parameterAnnotations = method_get_parameterannotations(m);
+
+       set_clazz(m->clazz);
+       set_slot(slot);
+       set_parameterTypes(parameterTypes);
+       set_exceptionTypes(exceptionTypes);
+       set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK);
+       set_signature(m->signature ? javastring_new(m->signature) : NULL);
+       set_annotations(annotations);
+       set_parameterAnnotations(parameterAnnotations);
+}
+
+
+inline int32_t java_lang_reflect_Constructor::get_override() const
+{
+       return get<int32_t>(_handle, offset_override);
+}
+
+inline classinfo* java_lang_reflect_Constructor::get_clazz() const
+{
+       return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_Constructor::get_slot() const
+{
+       return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+
+inline void java_lang_reflect_Constructor::set_clazz(classinfo* value)
+{
+       set(_handle, offset_clazz, value);
+}
+
+inline void java_lang_reflect_Constructor::set_slot(int32_t value)
+{
+       set(_handle, offset_slot, value);
+}
+
+inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value)
+{
+       set(_handle, offset_parameterTypes, value);
+}
+
+inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value)
+{
+       set(_handle, offset_exceptionTypes, value);
+}
+
+inline void java_lang_reflect_Constructor::set_modifiers(int32_t value)
+{
+       set(_handle, offset_modifiers, value);
+}
+
+inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value)
+{
+       set(_handle, offset_signature, value);
+}
+
+inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_annotations, value);
+}
+
+inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_parameterAnnotations, value);
+}
+
+
+inline methodinfo* java_lang_reflect_Constructor::get_method()
+{
+       classinfo*  c    = get_clazz();
+       int32_t     slot = get_slot();
+       methodinfo* m    = &(c->methods[slot]);
+       return m;
+}
+
+
+/**
+ * OpenJDK java/lang/reflect/Field
+ *
+ * Object layout:
+ *
+ * 0.  object header
+ * 1.  boolean                                         override;
+ * 2.  java.lang.Class                                 clazz;
+ * 3.  int                                             slot;
+ * 4.  java.lang.String                                name;
+ * 5.  java.lang.Class                                 type;
+ * 6.  int                                             modifiers;
+ * 7.  java.lang.String                                signature;
+ * 8.  sun.reflect.generics.repository.FieldRepository genericInfo;
+ * 9.  byte[]                                          annotations;
+ * 10. sun.reflect.FieldAccessor                       fieldAccessor;
+ * 11. sun.reflect.FieldAccessor                       overrideFieldAccessor;
+ * 12. java.lang.reflect.Field                         root;
+ * 13. java.lang.Class                                 securityCheckCache;
+ * 14. java.lang.Class                                 securityCheckTargetClassCache;
+ * 15. java.util.Map                                   declaredAnnotations;
+ */
+class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_override                      = MEMORY_ALIGN(sizeof(java_object_t),                                  sizeof(int32_t));
+       static const off_t offset_clazz                         = MEMORY_ALIGN(offset_override                      + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_slot                          = MEMORY_ALIGN(offset_clazz                         + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_name                          = MEMORY_ALIGN(offset_slot                          + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_type                          = MEMORY_ALIGN(offset_name                          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_modifiers                     = MEMORY_ALIGN(offset_type                          + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_signature                     = MEMORY_ALIGN(offset_modifiers                     + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_genericInfo                   = MEMORY_ALIGN(offset_signature                     + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_annotations                   = MEMORY_ALIGN(offset_genericInfo                   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_fieldAccessor                 = MEMORY_ALIGN(offset_annotations                   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_overrideFieldAccessor         = MEMORY_ALIGN(offset_fieldAccessor                 + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_root                          = MEMORY_ALIGN(offset_overrideFieldAccessor         + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_securityCheckCache            = MEMORY_ALIGN(offset_root                          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache            + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_declaredAnnotations           = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Field(fieldinfo* f);
+
+       // Getters.
+       inline int32_t                  get_override   () const;
+       inline classinfo*               get_clazz      () const;
+       inline int32_t                  get_slot       () const;
+       inline java_handle_bytearray_t* get_annotations() const;
+
+       // Setters.
+       inline void set_clazz      (classinfo* value);
+       inline void set_slot       (int32_t value);
+       inline void set_name       (java_handle_t* value);
+       inline void set_type       (classinfo* value);
+       inline void set_modifiers  (int32_t value);
+       inline void set_signature  (java_handle_t* value);
+       inline void set_annotations(java_handle_bytearray_t* value);
+
+       // Convenience functions.
+       inline fieldinfo* get_field() const;
+};
+
+
+inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
+{
+       _handle = builtin_new(class_java_lang_reflect_Field);
+
+       // OOME.
+       if (is_null())
+               return;
+
+       set_clazz(f->clazz);
+       set_slot(f - f->clazz->fields);
+       set_name(javastring_intern(javastring_new(f->name)));
+       set_type(field_get_type(f));
+       set_modifiers(f->flags);
+       set_signature(f->signature ? javastring_new(f->signature) : NULL);
+       set_annotations(field_get_annotations(f));
+}
+
+
+inline int32_t java_lang_reflect_Field::get_override() const
+{
+       return get<int32_t>(_handle, offset_override);
+}
+
+inline classinfo* java_lang_reflect_Field::get_clazz() const
+{
+       return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_Field::get_slot() const
+{
+       return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+
+inline void java_lang_reflect_Field::set_clazz(classinfo* value)
+{
+       set(_handle, offset_clazz, value);
+}
+
+inline void java_lang_reflect_Field::set_slot(int32_t value)
+{
+       set(_handle, offset_slot, value);
+}
+
+inline void java_lang_reflect_Field::set_name(java_handle_t* value)
+{
+       set(_handle, offset_name, value);
+}
+
+inline void java_lang_reflect_Field::set_type(classinfo* value)
+{
+       set(_handle, offset_type, value);
+}
+
+inline void java_lang_reflect_Field::set_modifiers(int32_t value)
+{
+       set(_handle, offset_modifiers, value);
+}
+
+inline void java_lang_reflect_Field::set_signature(java_handle_t* value)
+{
+       set(_handle, offset_signature, value);
+}
+
+inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_annotations, value);
+}
+
+
+inline fieldinfo* java_lang_reflect_Field::get_field() const
+{
+       classinfo* c    = get_clazz();
+       int32_t    slot = get_slot();
+       fieldinfo* f    = &(c->fields[slot]);
+       return f;
+}
+
+
+/**
+ * OpenJDK java/lang/reflect/Method
+ *
+ * Object layout:
+ *
+ * 0.  object header
+ * 1.  boolean                                               override;
+ * 2.  java.lang.Class                                       clazz;
+ * 3.  int                                                   slot;
+ * 4.  java.lang.String                                      name;
+ * 5.  java.lang.Class                                       returnType;
+ * 6.  java.lang.Class[]                                     parameterTypes;
+ * 7.  java.lang.Class[]                                     exceptionTypes;
+ * 8.  int                                                   modifiers;
+ * 9.  java.lang.String                                      signature;
+ * 10  sun.reflect.generics.repository.ConstructorRepository genericInfo;
+ * 11. byte[]                                                annotations;
+ * 12. byte[]                                                parameterAnnotations;
+ * 13. byte[]                                                annotationDefault;
+ * 14. sun.reflect.MethodAccessor                            methodAccessor;
+ * 15. java.lang.reflect.Method                              root;
+ * 16. java.lang.Class                                       securityCheckCache;
+ * 17. java.lang.Class                                       securityCheckTargetClassCache;
+ * 18. java.util.Map                                         declaredAnnotations;
+ */
+class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_override                      = MEMORY_ALIGN(sizeof(java_object_t),                                  sizeof(int32_t));
+       static const off_t offset_clazz                         = MEMORY_ALIGN(offset_override                      + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_slot                          = MEMORY_ALIGN(offset_clazz                         + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_name                          = MEMORY_ALIGN(offset_slot                          + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_returnType                    = MEMORY_ALIGN(offset_name                          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_parameterTypes                = MEMORY_ALIGN(offset_returnType                    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_exceptionTypes                = MEMORY_ALIGN(offset_parameterTypes                + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_modifiers                     = MEMORY_ALIGN(offset_exceptionTypes                + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_signature                     = MEMORY_ALIGN(offset_modifiers                     + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_genericInfo                   = MEMORY_ALIGN(offset_signature                     + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_annotations                   = MEMORY_ALIGN(offset_genericInfo                   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_parameterAnnotations          = MEMORY_ALIGN(offset_annotations                   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_annotationDefault             = MEMORY_ALIGN(offset_parameterAnnotations          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_methodAccessor                = MEMORY_ALIGN(offset_annotationDefault             + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_root                          = MEMORY_ALIGN(offset_methodAccessor                + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_securityCheckCache            = MEMORY_ALIGN(offset_root                          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache            + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_declaredAnnotations           = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Method(methodinfo* m);
+
+       java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
+
+       // Getters.
+       inline int32_t                  get_override            () const;
+       inline classinfo*               get_clazz               () const;
+       inline int32_t                  get_slot                () const;
+       inline java_handle_bytearray_t* get_annotations         () const;
+       inline java_handle_bytearray_t* get_parameterAnnotations() const;
+       inline java_handle_bytearray_t* get_annotationDefault   () const;
+
+       // Setters.
+
+       // Convenience functions.
+       inline methodinfo* get_method() const;
+};
+
+
+inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
+{
+       _handle = builtin_new(class_java_lang_reflect_Method);
+
+       if (is_null())
+               return;
+
+       set(_handle, offset_clazz,                m->clazz);
+       set(_handle, offset_slot,                 (int32_t) (m - m->clazz->methods)); // This cast is important (see PR100).
+       set(_handle, offset_name,                 javastring_intern(javastring_new(m->name)));
+       set(_handle, offset_returnType,           method_returntype_get(m));
+       set(_handle, offset_parameterTypes,       method_get_parametertypearray(m));
+       set(_handle, offset_exceptionTypes,       method_get_exceptionarray(m));
+       set(_handle, offset_modifiers,            (int32_t) (m->flags & ACC_CLASS_REFLECT_MASK));
+       set(_handle, offset_signature,            m->signature ? javastring_new(m->signature) : NULL);
+       set(_handle, offset_annotations,          method_get_annotations(m));
+       set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m));
+       set(_handle, offset_annotationDefault,    method_get_annotationdefault(m));
+}
+
+
+inline int32_t java_lang_reflect_Method::get_override() const
+{
+       return get<int32_t>(_handle, offset_override);
+}
+
+inline classinfo* java_lang_reflect_Method::get_clazz() const
+{
+       return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_Method::get_slot() const
+{
+       return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
+}
+
+
+inline methodinfo* java_lang_reflect_Method::get_method() const
+{
+       classinfo*  c    = get_clazz();
+       int32_t     slot = get_slot();
+       methodinfo* m    = &(c->methods[slot]);
+       return m;
+}
+
+
+/**
+ * OpenJDK java/nio/Buffer
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int  mark;
+ * 2. int  position;
+ * 3. int  limit;
+ * 4. int  capacity;
+ * 5. long address;
+ */
+class java_nio_Buffer : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_mark     = MEMORY_ALIGN(sizeof(java_object_t),          sizeof(int32_t));
+       static const off_t offset_position = MEMORY_ALIGN(offset_mark     + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_limit    = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_capacity = MEMORY_ALIGN(offset_limit    + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_address  = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t));
+
+public:
+       java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
+
+       // Getters.
+       inline void* get_address() const;
+};
+
+
+inline void* java_nio_Buffer::get_address() const
+{
+       return get<void*>(_handle, offset_address);
+}
+
+#endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
+
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+/**
+ * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. long   pointer;
+ * 2. int    position;
+ * 3. int    length;
+ */
+class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_pointer  = MEMORY_ALIGN(sizeof(java_object_t),             sizeof(int64_t));
+       static const off_t offset_position = MEMORY_ALIGN(offset_pointer  + sizeof(int64_t), sizeof(int32_t));
+       static const off_t offset_length   = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
+
+public:
+       com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {}
+       com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length);
+       com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd);
+
+       // Getters.
+       inline int64_t get_pointer () const;
+       inline int32_t get_position() const;
+       inline int32_t get_length  () const;
+
+       // Setters.
+       inline void set_pointer (int64_t value);
+       inline void set_position(int32_t value);
+       inline void set_length  (int32_t value);
+};
+
+
+inline com_sun_cldchi_jvm_FileDescriptor::com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length) : java_lang_Object(h)
+{
+       set_pointer(pointer);
+       set_position(position);
+       set_length(length);
+}
+
+inline com_sun_cldchi_jvm_FileDescriptor::com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd) : java_lang_Object(h)
+{
+       com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length());
+}
+
+
+inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const
+{
+       return get<int64_t>(_handle, offset_pointer);
+}
+
+inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const
+{
+       return get<int32_t>(_handle, offset_position);
+}
+
+inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const
+{
+       return get<int32_t>(_handle, offset_length);
+}
+
+
+inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value)
+{
+       set(_handle, offset_pointer, value);
+}
+
+inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value)
+{
+       set(_handle, offset_position, value);
+}
+
+inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value)
+{
+       set(_handle, offset_length, value);
+}
+
+
+/**
+ * CLDC 1.1 java/lang/String
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. char[] value;
+ * 2. int    offset;
+ * 3. int    count;
+ */
+class java_lang_String : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value  = MEMORY_ALIGN(sizeof(java_object_t),           SIZEOF_VOID_P);
+       static const off_t offset_offset = MEMORY_ALIGN(offset_value  + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_count  = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
+
+public:
+       java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
+
+       // Getters.
+       inline java_handle_chararray_t* get_value () const;
+       inline int32_t                  get_offset() const;
+       inline int32_t                  get_count () const;
+
+       // Setters.
+       inline void set_value (java_handle_chararray_t* value);
+       inline void set_offset(int32_t value);
+       inline void set_count (int32_t value);
+};
+
+
+inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h)
+{
+       set_value(value);
+       set_offset(offset);
+       set_count(count);
+}
+
+inline java_handle_chararray_t* java_lang_String::get_value() const
+{
+       return get<java_handle_chararray_t*>(_handle, offset_value);
+}
+
+inline int32_t java_lang_String::get_offset() const
+{
+       return get<int32_t>(_handle, offset_offset);
+}
+
+inline int32_t java_lang_String::get_count() const
+{
+       return get<int32_t>(_handle, offset_count);
+}
+
+inline void java_lang_String::set_value(java_handle_chararray_t* value)
+{
+       set(_handle, offset_value, value);
+}
+
+inline void java_lang_String::set_offset(int32_t value)
+{
+       set(_handle, offset_offset, value);
+}
+
+inline void java_lang_String::set_count(int32_t value)
+{
+       set(_handle, offset_count, value);
+}
+
+
+/**
+ * CLDC 1.1 java/lang/Thread
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int                priority;
+ * 2. java.lang.Runnable runnable;
+ * 3. java.lang.Object   vm_thread;
+ * 4. int                is_terminated;
+ * 5. int                is_stillborn;
+ * 6. char[]             name;
+ */
+class java_lang_Thread : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_priority      = MEMORY_ALIGN(sizeof(java_object_t),              sizeof(int32_t));
+       static const off_t offset_runnable      = MEMORY_ALIGN(offset_priority      + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_vm_thread     = MEMORY_ALIGN(offset_runnable      + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread     + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_is_stillborn  = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_name          = MEMORY_ALIGN(offset_is_stillborn  + sizeof(int32_t), SIZEOF_VOID_P);
+
+public:
+       java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
+//     java_lang_Thread(threadobject* t);
+
+       // Getters.
+       inline int32_t                  get_priority () const;
+       inline threadobject*            get_vm_thread() const;
+       inline java_handle_chararray_t* get_name     () const;
+
+       // Setters.
+       inline void set_vm_thread(threadobject* value);
+};
+
+
+// inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
+// {
+//     java_lang_Thread(thread_get_object(t));
+// }
+
+
+inline int32_t java_lang_Thread::get_priority() const
+{
+       return get<int32_t>(_handle, offset_priority);
+}
+
+inline threadobject* java_lang_Thread::get_vm_thread() const
+{
+       return get<threadobject*>(_handle, offset_vm_thread);
+}
+
+inline java_handle_chararray_t* java_lang_Thread::get_name() const
+{
+       return get<java_handle_chararray_t*>(_handle, offset_name);
+}
+
+
+inline void java_lang_Thread::set_vm_thread(threadobject* value)
+{
+       set(_handle, offset_vm_thread, value);
+}
+
+
+/**
+ * CLDC 1.1 java/lang/Throwable
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.String detailMessage;
+ * 2. java.lang.Object backtrace;
+ */
+class java_lang_Throwable : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t),                SIZEOF_VOID_P);
+       static const off_t offset_backtrace     = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+       java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
+
+       // Getters.
+       inline java_handle_t*           get_detailMessage() const;
+       inline java_handle_bytearray_t* get_backtrace    () const;
+
+       // Setters.
+       inline void set_backtrace(java_handle_bytearray_t* value);
+};
+
+
+inline java_handle_t* java_lang_Throwable::get_detailMessage() const
+{
+       return get<java_handle_t*>(_handle, offset_detailMessage);
+}
+
+inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
+}
+
+
+inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_backtrace, value);
+}
+
+#endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
+
+#endif
+
+#endif // _JAVAOBJECTS_HPP
+
+
+/*
+ * 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:
+ */
index 015a917ce6cc392c394ac03c84dfd99e8638e1cd..7da89972163e791d47096097842bd88912f20016 100644 (file)
@@ -103,7 +103,7 @@ REG_SOURCES = \
        reg.h
 
 REPLACE_SOURCES += \
-       replace.h
+       replace.hpp
 
 STACK_SOURCES = \
        stack.c \
@@ -116,7 +116,7 @@ endif
 
 if ENABLE_REPLACEMENT
 REPLACE_SOURCES += \
-       replace.c
+       replace.cpp
 endif
 
 if ENABLE_VERIFIER
@@ -127,6 +127,13 @@ VERIFIER_LIB = \
        verify/libverify.la
 endif
 
+if ENABLE_OPAGENT
+OPAGENT_SOURCES = \
+       oprofile-agent.cpp \
+       oprofile-agent.hpp
+
+endif
+
 if WITH_BINUTILS_DISASSEMBLER
 DISASS_SOURCES = disass-common.c
 endif
@@ -141,44 +148,49 @@ noinst_LTLIBRARIES = \
        libjit.la
 
 libjit_la_SOURCES = \
-       argument.c \
-       argument.h \
-       code.c \
-       code.h \
-       codegen-common.c \
-       codegen-common.h \
+       argument.cpp \
+       argument.hpp \
+       builtin.cpp \
+       builtin.hpp \
+       builtintable.inc \
+       code.cpp \
+       code.hpp \
+       codegen-common.cpp \
+       codegen-common.hpp \
        disass.h \
        $(DISASS_SOURCES) \
        dseg.c \
        dseg.h \
-       emit-common.c \
-       emit-common.h \
+       emit-common.cpp \
+       emit-common.hpp \
        exceptiontable.c \
        exceptiontable.h \
        executionstate.c \
        executionstate.h \
-       icmdtable.inc \
-       jit.c \
-       jit.h \
-       linenumbertable.c \
-       linenumbertable.h \
+       jit.cpp \
+       jit.hpp \
+       linenumbertable.cpp \
+       linenumbertable.hpp \
        methodtree.c \
        methodtree.h \
-       parse.c \
-       parse.h \
-       patcher-common.c \
-       patcher-common.h \
+       parse.cpp \
+       parse.hpp \
+       patcher-common.cpp \
+       patcher-common.hpp \
        $(RECOMPILE_SOURCES) \
        $(REG_SOURCES) \
        $(REPLACE_SOURCES) \
-       show.c \
-       show.h \
+       show.cpp \
+       show.hpp \
        $(STACK_SOURCES) \
-       stacktrace.c \
-       stacktrace.h \
-       trace.c \
-       trace.h \
-       $(TRAP_SOURCES)
+       stacktrace.cpp \
+       stacktrace.hpp \
+       stubs.cpp \
+       stubs.hpp \
+       trace.cpp \
+       trace.hpp \
+       $(TRAP_SOURCES) \
+       $(OPAGENT_SOURCES)
 
 libjit_la_SOURCES += \
        cfg.c \
index 6a84ade40945d8609617f94385de998e6a2232d8..2bd0e8b8b3af254500c39153d4ed046741be12eb 100644 (file)
@@ -32,7 +32,7 @@
 #include "arch.h"
 
 #include "vm/jit/abi-asm.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/stack.h"
 
 
@@ -64,6 +64,10 @@ extern const s4    abi_registers_float_temporary[];
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* machine dependent descriptor function */
 void md_param_alloc(methoddesc *md);
 void md_param_alloc_native(methoddesc *md);
@@ -71,6 +75,10 @@ void md_param_alloc_native(methoddesc *md);
 /* machine dependent return value handling function */
 void md_return_alloc(jitdata *jd, stackelement_t *stackslot);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _ABI_H */
 
 
index 5a0e1da95539354da4a5c092039ee7364de06f62..de94a0f44dec49e543d95311902a3a1898488ea5 100644 (file)
 #include "toolbox/logging.h"
 #include "toolbox/worklist.h"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/method.h"
-#include "vm/resolve.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/method.hpp"
+#include "vm/resolve.hpp"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/allocator/lsra.h"
 #include "vm/jit/allocator/liveness.h"
 
index 0ac20d24b929c59ad6b17e4b16b540b0bde8529f..bfe0e16662bf4ef9b86bf1cfe99063b58e75e062 100644 (file)
 #include "vm/types.h"
 
 #include "mm/memory.h"
+
 #include "toolbox/logging.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/resolve.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/resolve.hpp"
 #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"
 
@@ -1337,9 +1340,6 @@ void lsra_alloc(jitdata *jd, int *lifet, int lifetimecount, int *mem_use)
        struct freemem *fmem;
        struct stackslot *n;
        int lt_index;
-#ifdef HAS_4BYTE_STACKSLOT
-       struct freemem *fmem_2;
-#endif
        registerdata *rd;
        lsradata     *ls;
 
@@ -1349,11 +1349,6 @@ void lsra_alloc(jitdata *jd, int *lifet, int lifetimecount, int *mem_use)
        fmem = DNEW(struct freemem);
        fmem->off  = -1;
        fmem->next = NULL;
-#ifdef HAS_4BYTE_STACKSLOT
-       fmem_2=DNEW(struct freemem);
-       fmem_2->off  = -1;
-       fmem_2->next = NULL;
-#endif
 
        for (lt_index = 0; lt_index < lifetimecount; lt_index ++) {
                lt = &(ls->lifetime[lifet[lt_index]]);
@@ -1362,11 +1357,6 @@ void lsra_alloc(jitdata *jd, int *lifet, int lifetimecount, int *mem_use)
 #endif
                if (lt->reg == -1) {
                        flags = INMEMORY;
-#ifdef HAS_4BYTE_STACKSLOT
-                       if (IS_2_WORD_TYPE(lt->type))
-                               regoff = lsra_getmem(lt, fmem_2, mem_use);
-                       else
-#endif
                        regoff = lsra_getmem(lt, fmem, mem_use);
                } else {
                        flags  = lt->savedvar;
@@ -1408,17 +1398,7 @@ int lsra_getmem(struct lifetime *lt, struct freemem *fmem, int *mem_use)
 
        /* no Memory Slot allocated till now or all are still live */
        if ((fmem->next == NULL) || (fmem->next->end > lt->i_start)) {
-#ifdef HAS_4BYTE_STACKSLOT
-               if (IS_2_WORD_TYPE(lt->type))
-                       if ( (*mem_use)&1 ) /* align memory location for 2 Word Types */
-                               (*mem_use)++;
-               fm=lsra_getnewmem(mem_use);
-               if (IS_2_WORD_TYPE(lt->type))
-                       /* allocate a second following Slot for 2 Word Types */
-                       (*mem_use)++;
-#else
                fm=lsra_getnewmem(mem_use);
-#endif
        } else {
                /* Memoryslot free */
                fm = fmem->next;
@@ -1726,13 +1706,8 @@ void lsra_calc_lifetime_length(jitdata *jd) {
 
                        switch (lt->type) {
                        case TYPE_LNG:
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
-                               flags = 0;
-#else
                                flags = 1;
-#endif
                                break;
-
                        case TYPE_INT:
                        case TYPE_ADR:
                                flags=1;
index f8cbcab9dcb7ecbfe8b2922ac58528c0b57e5d1f..f852229bf0b426b63f880ffa5ba7d9ab80314d06 100644 (file)
 
 #include "mm/memory.h"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/resolve.h"
-#include "vm/stringlocal.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/resolve.hpp"
+#include "vm/string.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/reg.h"
-#include "vm/jit/show.h"
+#include "vm/jit/show.hpp"
 #include "vm/jit/allocator/simplereg.h"
 
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-
 
 #if 0
 #    define LOG(args) printf args
@@ -65,11 +64,7 @@ static void simplereg_allocate_temporaries(jitdata *jd);
 
 /* size of a stackslot used by the internal ABI */
 
-#if defined(HAS_4BYTE_STACKSLOT)
-# define SIZE_OF_STACKSLOT 4
-#else 
-# define SIZE_OF_STACKSLOT 8
-#endif
+#define SIZE_OF_STACKSLOT 8
 
 
 /* total number of registers */
@@ -208,44 +203,12 @@ static void simplereg_allocate_temporaries(jitdata *jd);
 #define NEW_MEM_SLOT(r)                                              \
     do {                                                             \
         (r) = rd->memuse * SIZE_OF_STACKSLOT;                        \
-        rd->memuse += memneeded + 1;                                 \
-    } while (0)
-
-#define NEW_MEM_SLOT_ALIGNED(r)                                      \
-    do {                                                             \
-        if ( (memneeded) && (rd->memuse & 1))                        \
-            rd->memuse++;                                            \
-        (r) = rd->memuse * SIZE_OF_STACKSLOT;                        \
-        rd->memuse += memneeded + 1;                                 \
-    } while (0)
-
-#define NEW_MEM_SLOT_ALIGNED_REUSE_PADDING(r)                        \
-    do {                                                             \
-        if ( (memneeded) && (rd->memuse & 1)) {                      \
-                       PUSH_BACK(rd->freemem, rd->freememtop, rd->memuse);      \
-            rd->memuse++;                                            \
-               }                                                            \
-        (r) = rd->memuse * SIZE_OF_STACKSLOT;                        \
-        rd->memuse += memneeded + 1;                                 \
+        rd->memuse += 1;                                             \
     } while (0)
 
-#if defined(ALIGN_LONGS_IN_MEMORY)
-#define NEW_MEM_SLOT_INT_LNG(r)  NEW_MEM_SLOT_ALIGNED(r)
-#else
 #define NEW_MEM_SLOT_INT_LNG(r)  NEW_MEM_SLOT(r)
-#endif
-
-#if defined(ALIGN_DOUBLES_IN_MEMORY)
-#define NEW_MEM_SLOT_FLT_DBL(r)  NEW_MEM_SLOT_ALIGNED(r)
-#else
 #define NEW_MEM_SLOT_FLT_DBL(r)  NEW_MEM_SLOT(r)
-#endif
-
-#if defined(ALIGN_LONGS_IN_MEMORY) || defined(ALIGN_DOUBLES_IN_MEMORY)
-#define NEW_MEM_SLOT_REUSE_PADDING(r)  NEW_MEM_SLOT_ALIGNED_REUSE_PADDING(r)
-#else
 #define NEW_MEM_SLOT_REUSE_PADDING(r)  NEW_MEM_SLOT(r)
-#endif
 
 
 /* macros for creating/freeing temporary variables ***************************/
@@ -283,9 +246,9 @@ static void simplereg_allocate_temporaries(jitdata *jd);
 /* regalloc ********************************************************************
 
    Does a simple register allocation.
-       
+
 *******************************************************************************/
-       
+
 bool regalloc(jitdata *jd)
 {
        /* There is a problem with the use of unused float argument
@@ -309,9 +272,9 @@ bool regalloc(jitdata *jd)
 /* simplereg_allocate_interfaces ***********************************************
 
    Allocates registers for all interface variables.
-       
+
 *******************************************************************************/
-       
+
 static void simplereg_allocate_interfaces(jitdata *jd)
 {
        methodinfo   *m;
@@ -322,9 +285,8 @@ static void simplereg_allocate_interfaces(jitdata *jd)
        int     s, t, tt, saved;
        int     intalloc, fltalloc; /* Remember allocated Register/Memory offset */
                        /* in case more vars are packed into this interface slot */
-       int             memneeded = 0;
-       /* Allocate LNG and DBL types first to ensure 2 memory slots or          */
-       /* registers on HAS_4BYTE_STACKSLOT architectures.                       */
+       /* Allocate LNG and DBL types first to ensure 2 registers                */
+       /* on some architectures.                                                */
        int     typeloop[] = { TYPE_LNG, TYPE_DBL, TYPE_INT, TYPE_FLT, TYPE_ADR };
        int     flags, regoff;
 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
@@ -389,10 +351,6 @@ static void simplereg_allocate_interfaces(jitdata *jd)
                        intregsneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
 #endif
 
-#if defined(HAS_4BYTE_STACKSLOT)
-                       memneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
-#endif
-
                        if (!saved) {
 #if defined(HAS_ADDRESS_REGISTER_FILE)
                                if (IS_ADR_TYPE(t)) {
@@ -562,9 +520,9 @@ static void simplereg_allocate_interfaces(jitdata *jd)
 /* simplereg_allocate_locals_leafmethod ****************************************
 
    Allocates registers for all local variables of a leafmethod.
-       
+
 *******************************************************************************/
-       
+
 static void simplereg_allocate_locals_leafmethod(jitdata *jd)
 {
        methodinfo   *m;
@@ -576,7 +534,6 @@ static void simplereg_allocate_locals_leafmethod(jitdata *jd)
        int     intalloc, fltalloc;
        varinfo *v;
        int     intregsneeded = 0;
-       int     memneeded = 0;
        int     typeloop[] = { TYPE_LNG, TYPE_DBL, TYPE_INT, TYPE_FLT, TYPE_ADR };
        int     fargcnt, iargcnt;
 #ifdef HAS_ADDRESS_REGISTER_FILE
@@ -609,9 +566,6 @@ static void simplereg_allocate_locals_leafmethod(jitdata *jd)
 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
                        intregsneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
 #endif
-#if defined(HAS_4BYTE_STACKSLOT)
-                       memneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
-#endif
 
                        /*
                         *  The order of
@@ -770,9 +724,9 @@ static void simplereg_allocate_locals_leafmethod(jitdata *jd)
 /* simplereg_allocate_locals ***************************************************
 
    Allocates registers for all local variables.
-       
+
 *******************************************************************************/
-       
+
 static void simplereg_allocate_locals(jitdata *jd)
 {
        codeinfo     *code;
@@ -782,7 +736,6 @@ static void simplereg_allocate_locals(jitdata *jd)
        int     s, t, tt, varindex;
        int     intalloc, fltalloc;
        varinfo *v;
-       int     memneeded = 0;
        int     typeloop[] = { TYPE_LNG, TYPE_DBL, TYPE_INT, TYPE_FLT, TYPE_ADR };
 #ifdef SUPPORT_COMBINE_INTEGER_REGISTERS
        s4 intregsneeded;
@@ -814,10 +767,6 @@ static void simplereg_allocate_locals(jitdata *jd)
                                intregsneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
 #endif
 
-#if defined(HAS_4BYTE_STACKSLOT)
-                               memneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
-#endif
-
 #ifdef HAS_ADDRESS_REGISTER_FILE
                                if (IS_ADR_TYPE(t)) {
                                        if (AVAIL_SAV_ADR) {
@@ -894,9 +843,6 @@ static void simplereg_init(jitdata *jd, registerdata *rd)
        int i;
 
        rd->freememtop = 0;
-#if defined(HAS_4BYTE_STACKSLOT)
-       rd->freememtop_2 = 0;
-#endif
 
        rd->freetmpinttop = 0;
        rd->freesavinttop = 0;
@@ -1011,7 +957,6 @@ static void simplereg_new_temp(jitdata *jd, s4 index)
 #ifdef SUPPORT_COMBINE_INTEGER_REGISTERS
        s4 intregsneeded;
 #endif
-       s4 memneeded;
        s4 tryagain;
        registerdata *rd;
        varinfo      *v;
@@ -1031,12 +976,6 @@ static void simplereg_new_temp(jitdata *jd, s4 index)
        intregsneeded = (IS_2_WORD_TYPE(v->type)) ? 1 : 0;
 #endif
 
-#if defined(HAS_4BYTE_STACKSLOT)
-       memneeded = (IS_2_WORD_TYPE(v->type)) ? 1 : 0;
-#else
-       memneeded = 0;
-#endif
-
        for(; tryagain; --tryagain) {
                if (tryagain == 1) {
                        if (!(v->flags & SAVEDVAR))
@@ -1157,15 +1096,10 @@ static void simplereg_new_temp(jitdata *jd, s4 index)
 
        v->flags |= INMEMORY;
 
-#if defined(HAS_4BYTE_STACKSLOT)
-       if ((memneeded == 1) && (rd->freememtop_2 > 0))
-               POP_BACK(rd->freemem_2, rd->freememtop_2, v->vv.regoff);
+       if (rd->freememtop > 0)
+               POP_BACK(rd->freemem, rd->freememtop, v->vv.regoff);
        else
-#endif /*defined(HAS_4BYTE_STACKSLOT) */
-               if ((memneeded == 0) && (rd->freememtop > 0))
-                       POP_BACK(rd->freemem, rd->freememtop, v->vv.regoff);
-               else
-                       NEW_MEM_SLOT_REUSE_PADDING(v->vv.regoff);
+               NEW_MEM_SLOT_REUSE_PADDING(v->vv.regoff);
 }
 
 
@@ -1213,13 +1147,7 @@ static void simplereg_free(registerdata *rd, s4 flags, s4 regoff, s4 type)
        }
 
        if (flags & INMEMORY) {
-#if defined(HAS_4BYTE_STACKSLOT)
-               if (IS_2_WORD_TYPE(type))
-                       PUSH_BACK(rd->freemem_2, rd->freememtop_2, regoff);
-               else 
-#endif
-                       PUSH_BACK(rd->freemem, rd->freememtop, regoff);
-
+               PUSH_BACK(rd->freemem, rd->freememtop, regoff);
                return;
        } 
 
index e7f2c44e7ecb38fc6f41aa2efbfbd52dc451f8bf..619a039515bb6c507ed554af03d02d022f9af0e1 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/allocator/simplereg.h - register allocator header
 
-   Copyright (C) 1996-2005, 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) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes: Christian Ullrich
-
 */
 
 
 
 #include "arch.h"
 
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/inline/inline.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/inline/inline.hpp"
 
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool regalloc(jitdata *jd);
 
 #if defined(ENABLE_STATISTICS)
 void simplereg_make_statistics(jitdata *jd);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _SIMPLE_REG_H */
 
 
index cd4e0f470162efcf4cae8b40bd4f9d8d9f8e978f..1424fc47a045b9960d3cc24ac043904115217d17 100644 (file)
@@ -34,9 +34,9 @@ LIBS =
 
 noinst_HEADERS = \
        arch.h \
-       machine-instr.h \
        \
-       md-asm.h
+       md-asm.h \
+       md-atomic.hpp
 
 noinst_LTLIBRARIES = libarch.la
 
@@ -55,6 +55,7 @@ libarch_la_SOURCES = \
        \
        md-abi.c \
        md-abi.h \
+       md-stubs.hpp \
        md-trap.h \
        md.c \
        md.h
index 8fdeed30fc7b300a04c2c0e082f500f922f806d5..186f1d1b98948fe7d76b125eda96bf85562cc4bb 100644 (file)
@@ -35,8 +35,6 @@
 
 /* define architecture features ***********************************************/
 
-#define U8_AVAILABLE                     1
-
 #define SUPPORT_DIVISION                 0
 #define SUPPORT_LONG                     1
 
index b05a8afcd100b2cbd5781f1c4baa6cd30d359e35..11fa64576c3f8564ce10b2caaa65a2fe9b977a0c 100644 (file)
@@ -54,9 +54,6 @@
 
        .globl asm_abstractmethoderror
 
-       .globl asm_compare_and_swap
-       .globl asm_memory_barrier
-
        .globl asm_md_init
        .globl asm_cacheflush
 
@@ -339,52 +336,6 @@ asm_abstractmethoderror:
        .end    asm_abstractmethoderror
 
 
-/* asm_compare_and_swap ********************************************************
-
-   Does an atomic compare and swap.  Required for the lock
-   implementation.
-
-   Atomically do the following: Check if the location still contains
-   `oldval`. If so, replace it by `newval` and return `oldval`.
-
-   RETURN VALUE:
-       the old value at *p
-
-   long compare_and_swap(volatile long *p, long oldval, long newval);
-
-*******************************************************************************/
-
-       .ent    asm_compare_and_swap
-
-asm_compare_and_swap:
-1:
-       ldq_l   v0,0(a0)
-       cmpeq   v0,a1,t0
-       beq     t0,2f
-       mov     a2,t0
-       stq_c   t0,0(a0)
-       beq     t0,1b
-2:
-       jmp     zero,(ra)
-
-       .end    asm_compare_and_swap
-
-
-/* asm_memory_barrier **********************************************************
-
-   A memory barrier for the Java Memory Model.
-
-*******************************************************************************/
-
-       .ent    asm_memory_barrier
-
-asm_memory_barrier:
-       mb
-       jmp     zero,(ra)
-
-       .end    asm_memory_barrier
-
-
 /* asm_md_init *****************************************************************
 
    Initialize machine dependent stuff.
index caa7834316708da6238f545c0ba192b67e2ee798..b136fd4dcaaefac36a11c63d4a751ac2f4c60b23 100644 (file)
 
 #include "mm/memory.h"
 
-#include "native/jni.h"
-#include "native/localref.h"
-#include "native/native.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/vm.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #if defined(ENABLE_SSA)
@@ -70,9 +71,6 @@
 # include "vm/jit/allocator/lsra.h"
 #endif
 
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
 
 /* codegen_emit ****************************************************************
 
@@ -1117,17 +1115,13 @@ bool codegen_emit(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
-                       if (opt_noieee) {
-                               M_FADD(s1, s2, d);
+                       if (d == s1 || d == s2) {
+                               M_FADDS(s1, s2, REG_FTMP3);
+                               M_TRAPB;
+                               M_FMOV(REG_FTMP3, d);
                        } else {
-                               if (d == s1 || d == s2) {
-                                       M_FADDS(s1, s2, REG_FTMP3);
-                                       M_TRAPB;
-                                       M_FMOV(REG_FTMP3, d);
-                               } else {
-                                       M_FADDS(s1, s2, d);
-                                       M_TRAPB;
-                               }
+                               M_FADDS(s1, s2, d);
+                               M_TRAPB;
                        }
                        emit_store_dst(jd, iptr, d);
                        break;
@@ -1137,17 +1131,13 @@ bool codegen_emit(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
-                       if (opt_noieee) {
-                               M_DADD(s1, s2, d);
+                       if (d == s1 || d == s2) {
+                               M_DADDS(s1, s2, REG_FTMP3);
+                               M_TRAPB;
+                               M_FMOV(REG_FTMP3, d);
                        } else {
-                               if (d == s1 || d == s2) {
-                                       M_DADDS(s1, s2, REG_FTMP3);
-                                       M_TRAPB;
-                                       M_FMOV(REG_FTMP3, d);
-                               } else {
-                                       M_DADDS(s1, s2, d);
-                                       M_TRAPB;
-                               }
+                               M_DADDS(s1, s2, d);
+                               M_TRAPB;
                        }
                        emit_store_dst(jd, iptr, d);
                        break;
@@ -1157,17 +1147,13 @@ bool codegen_emit(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
-                       if (opt_noieee) {
-                               M_FSUB(s1, s2, d);
+                       if (d == s1 || d == s2) {
+                               M_FSUBS(s1, s2, REG_FTMP3);
+                               M_TRAPB;
+                               M_FMOV(REG_FTMP3, d);
                        } else {
-                               if (d == s1 || d == s2) {
-                                       M_FSUBS(s1, s2, REG_FTMP3);
-                                       M_TRAPB;
-                                       M_FMOV(REG_FTMP3, d);
-                               } else {
-                                       M_FSUBS(s1, s2, d);
-                                       M_TRAPB;
-                               }
+                               M_FSUBS(s1, s2, d);
+                               M_TRAPB;
                        }
                        emit_store_dst(jd, iptr, d);
                        break;
@@ -1177,17 +1163,13 @@ bool codegen_emit(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
-                       if (opt_noieee) {
-                               M_DSUB(s1, s2, d);
+                       if (d == s1 || d == s2) {
+                               M_DSUBS(s1, s2, REG_FTMP3);
+                               M_TRAPB;
+                               M_FMOV(REG_FTMP3, d);
                        } else {
-                               if (d == s1 || d == s2) {
-                                       M_DSUBS(s1, s2, REG_FTMP3);
-                                       M_TRAPB;
-                                       M_FMOV(REG_FTMP3, d);
-                               } else {
-                                       M_DSUBS(s1, s2, d);
-                                       M_TRAPB;
-                               }
+                               M_DSUBS(s1, s2, d);
+                               M_TRAPB;
                        }
                        emit_store_dst(jd, iptr, d);
                        break;
@@ -1197,17 +1179,13 @@ bool codegen_emit(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
-                       if (opt_noieee) {
-                               M_FMUL(s1, s2, d);
+                       if (d == s1 || d == s2) {
+                               M_FMULS(s1, s2, REG_FTMP3);
+                               M_TRAPB;
+                               M_FMOV(REG_FTMP3, d);
                        } else {
-                               if (d == s1 || d == s2) {
-                                       M_FMULS(s1, s2, REG_FTMP3);
-                                       M_TRAPB;
-                                       M_FMOV(REG_FTMP3, d);
-                               } else {
-                                       M_FMULS(s1, s2, d);
-                                       M_TRAPB;
-                               }
+                               M_FMULS(s1, s2, d);
+                               M_TRAPB;
                        }
                        emit_store_dst(jd, iptr, d);
                        break;
@@ -1217,17 +1195,13 @@ bool codegen_emit(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
-                       if (opt_noieee) {
-                               M_DMUL(s1, s2, d);
+                       if (d == s1 || d == s2) {
+                               M_DMULS(s1, s2, REG_FTMP3);
+                               M_TRAPB;
+                               M_FMOV(REG_FTMP3, d);
                        } else {
-                               if (d == s1 || d == s2) {
-                                       M_DMULS(s1, s2, REG_FTMP3);
-                                       M_TRAPB;
-                                       M_FMOV(REG_FTMP3, d);
-                               } else {
-                                       M_DMULS(s1, s2, d);
-                                       M_TRAPB;
-                               }
+                               M_DMULS(s1, s2, d);
+                               M_TRAPB;
                        }
                        emit_store_dst(jd, iptr, d);
                        break;
@@ -1237,17 +1211,13 @@ bool codegen_emit(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
-                       if (opt_noieee) {
-                               M_FDIV(s1, s2, d);
+                       if (d == s1 || d == s2) {
+                               M_FDIVS(s1, s2, REG_FTMP3);
+                               M_TRAPB;
+                               M_FMOV(REG_FTMP3, d);
                        } else {
-                               if (d == s1 || d == s2) {
-                                       M_FDIVS(s1, s2, REG_FTMP3);
-                                       M_TRAPB;
-                                       M_FMOV(REG_FTMP3, d);
-                               } else {
-                                       M_FDIVS(s1, s2, d);
-                                       M_TRAPB;
-                               }
+                               M_FDIVS(s1, s2, d);
+                               M_TRAPB;
                        }
                        emit_store_dst(jd, iptr, d);
                        break;
@@ -1257,17 +1227,13 @@ bool codegen_emit(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
-                       if (opt_noieee) {
-                               M_DDIV(s1, s2, d);
+                       if (d == s1 || d == s2) {
+                               M_DDIVS(s1, s2, REG_FTMP3);
+                               M_TRAPB;
+                               M_FMOV(REG_FTMP3, d);
                        } else {
-                               if (d == s1 || d == s2) {
-                                       M_DDIVS(s1, s2, REG_FTMP3);
-                                       M_TRAPB;
-                                       M_FMOV(REG_FTMP3, d);
-                               } else {
-                                       M_DDIVS(s1, s2, d);
-                                       M_TRAPB;
-                               }
+                               M_DDIVS(s1, s2, d);
+                               M_TRAPB;
                        }
                        emit_store_dst(jd, iptr, d);
                        break;
@@ -1330,12 +1296,8 @@ bool codegen_emit(jitdata *jd)
 
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
-                       if (opt_noieee) {
-                               M_CVTDF(s1, d);
-                       } else {
-                               M_CVTDFS(s1, d);
-                               M_TRAPB;
-                       }
+                       M_CVTDFS(s1, d);
+                       M_TRAPB;
                        emit_store_dst(jd, iptr, d);
                        break;
                
@@ -1344,25 +1306,15 @@ bool codegen_emit(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
-                       if (opt_noieee) {
-                               M_LSUB_IMM(REG_ZERO, 1, d);
-                               M_FCMPEQ(s1, s2, REG_FTMP3);
-                               M_FBEQZ (REG_FTMP3, 1);        /* jump over next instructions */
-                               M_CLR   (d);
-                               M_FCMPLT(s2, s1, REG_FTMP3);
-                               M_FBEQZ (REG_FTMP3, 1);        /* jump over next instruction  */
-                               M_LADD_IMM(REG_ZERO, 1, d);
-                       } else {
-                               M_LSUB_IMM(REG_ZERO, 1, d);
-                               M_FCMPEQS(s1, s2, REG_FTMP3);
-                               M_TRAPB;
-                               M_FBEQZ (REG_FTMP3, 1);        /* jump over next instructions */
-                               M_CLR   (d);
-                               M_FCMPLTS(s2, s1, REG_FTMP3);
-                               M_TRAPB;
-                               M_FBEQZ (REG_FTMP3, 1);        /* jump over next instruction  */
-                               M_LADD_IMM(REG_ZERO, 1, d);
-                       }
+                       M_LSUB_IMM(REG_ZERO, 1, d);
+                       M_FCMPEQS(s1, s2, REG_FTMP3);
+                       M_TRAPB;
+                       M_FBEQZ (REG_FTMP3, 1);        /* jump over next instructions */
+                       M_CLR   (d);
+                       M_FCMPLTS(s2, s1, REG_FTMP3);
+                       M_TRAPB;
+                       M_FBEQZ (REG_FTMP3, 1);        /* jump over next instruction  */
+                       M_LADD_IMM(REG_ZERO, 1, d);
                        emit_store_dst(jd, iptr, d);
                        break;
                        
@@ -1371,25 +1323,15 @@ bool codegen_emit(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        s2 = emit_load_s2(jd, iptr, REG_FTMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
-                       if (opt_noieee) {
-                               M_LADD_IMM(REG_ZERO, 1, d);
-                               M_FCMPEQ(s1, s2, REG_FTMP3);
-                               M_FBEQZ (REG_FTMP3, 1);        /* jump over next instruction  */
-                               M_CLR   (d);
-                               M_FCMPLT(s1, s2, REG_FTMP3);
-                               M_FBEQZ (REG_FTMP3, 1);        /* jump over next instruction  */
-                               M_LSUB_IMM(REG_ZERO, 1, d);
-                       } else {
-                               M_LADD_IMM(REG_ZERO, 1, d);
-                               M_FCMPEQS(s1, s2, REG_FTMP3);
-                               M_TRAPB;
-                               M_FBEQZ (REG_FTMP3, 1);        /* jump over next instruction  */
-                               M_CLR   (d);
-                               M_FCMPLTS(s1, s2, REG_FTMP3);
-                               M_TRAPB;
-                               M_FBEQZ (REG_FTMP3, 1);        /* jump over next instruction  */
-                               M_LSUB_IMM(REG_ZERO, 1, d);
-                       }
+                       M_LADD_IMM(REG_ZERO, 1, d);
+                       M_FCMPEQS(s1, s2, REG_FTMP3);
+                       M_TRAPB;
+                       M_FBEQZ (REG_FTMP3, 1);        /* jump over next instruction  */
+                       M_CLR   (d);
+                       M_FCMPLTS(s1, s2, REG_FTMP3);
+                       M_TRAPB;
+                       M_FBEQZ (REG_FTMP3, 1);        /* jump over next instruction  */
+                       M_LSUB_IMM(REG_ZERO, 1, d);
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -3285,7 +3227,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
                /* put env into first argument register */
 
-               disp = dseg_add_address(cd, _Jv_env);
+               disp = dseg_add_address(cd, VM_get_jnienv());
                M_ALD(REG_A0, REG_PV, disp);
        }
 
index c43ba7b6d56574ea5e20fd3e402a99be17f594a3..17953240b186e95ed0f8fb61e39ec8ae4b3d7ceb 100644 (file)
@@ -1,9 +1,8 @@
 /* src/vm/jit/alpha/codegen.h - code generation macros and definitions for Alpha
 
-   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
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
 
    This file is part of CACAO.
 
@@ -31,7 +30,7 @@
 #include "config.h"
 #include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* additional functions and macros to generate code ***************************/
     } while (0)
 
 
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE    1 * 4
-
-
 /* macros to create code ******************************************************/
 
 /* M_MEM - memory instruction format *******************************************
         cd->mcodeptr += 4; \
     } while (0)
 
+#define M_OP3_GET_Opcode(x)             (          (((x) >> 26) & 0x3f  ))
+
 
 /* 3-address-floating-point-operation: M_FOP3 
      op .... opcode
 
 #define M_FBEQZ(fa,disp)        M_BRA (0x31,fa,disp)            /* br a == 0.0*/
 
-/* macros for special commands (see an Alpha-manual for description) **********/ 
+/* macros for special commands (see an Alpha-manual for description) **********/
 
 #define M_TRAPB                 M_MEM (0x18,0,0,0x0000)        /* trap barrier*/
 
 #define M_CMOVLE_IMM(a,b,c)     M_OP3 (0x11,0x64, a,b,c,1)     /* a<=0 ? c=b  */
 #define M_CMOVGT_IMM(a,b,c)     M_OP3 (0x11,0x66, a,b,c,1)     /* a> 0 ? c=b  */
 
+// 0x04 seems to be the first undefined instruction which does not
+// call PALcode.
+#define M_UNDEFINED             M_OP3(0x04, 0, 0, 0, 0, 0)
+
 /* macros for unused commands (see an Alpha-manual for description) ***********/
 
 #define M_ANDNOT(a,b,c,const)   M_OP3 (0x11,0x08, a,b,c,const) /* c = a &~ b  */
index f0d1b7c8967e54335b258afce0b2c0e1d0265fc5..8bf59e90e858c4fce000427a83bc9bb62b1c70b9 100644 (file)
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
+
+#include "vm/options.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/trace.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/options.h"
-
 
 /* emit_load *******************************************************************
 
@@ -446,11 +446,10 @@ uint32_t emit_trap(codegendata *cd)
        /* Get machine code which is patched back in later. The
           trap is 1 instruction word long. */
 
-       mcode = *((uint32_t *) cd->mcodeptr);
+       mcode = *((uint32_t*) cd->mcodeptr);
 
-       /* Destination register must not be REG_ZERO, because then no
-          SIGSEGV is thrown. */
-       M_ALD_INTERN(REG_RESULT, REG_ZERO, TRAP_PATCHER);
+       // Generate a SIGILL.
+       M_UNDEFINED;
 
        return mcode;
 }
index 10deba916971329c656e275b2405e1054bcedd78..e60626f3fabaff75554193c6a5b7560da4c5a62b 100644 (file)
@@ -1,9 +1,7 @@
-/* src/vm/jit/alpha/freebsd/md.c - machine dependent Alpha FreeBSD functions
+/* src/vm/jit/alpha/freebsd/md-os.c - machine dependent Alpha FreeBSD functions
 
-   Copyright (C) 1996-2005, 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) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
 */
 
 
 
 #include "vm/jit/alpha/md-abi.h"
 
-#include "vm/exceptions.h"
 #include "vm/global.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 #include "vm/jit/asmpart.h"
 
 
@@ -95,22 +85,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 }
 
 
-#if defined(ENABLE_THREADS)
-void thread_restartcriticalsection(ucontext_t *_uc)
-{
-       mcontext_t *_mc;
-       void       *critical;
-
-       _mc = &_uc->uc_mcontext;
-
-       critical = critical_find_restart_point((void *) _mc->mc_regs[R_PC]);
-
-       if (critical)
-               _mc->mc_regs[R_PC] = (ptrint) critical;
-}
-#endif
-
-
 /*
  * 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
index afe391d11b2b86b0abc946d0a0ff509ff7ff80e1..8e127a9fab4e3bae10487216f640ecdda617c28a 100644 (file)
@@ -2,6 +2,7 @@
 
    Copyright (C) 1996-2005, 2006, 2007, 2008
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
 
    This file is part of CACAO.
 
 #include "vm/jit/alpha/md.h"
 #include "vm/jit/alpha/md-abi.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
+#include "vm/jit/builtin.hpp"
 #include "vm/signallocal.h"
+#include "vm/os.hpp"
 
 #include "vm/jit/asmpart.h"
+#include "vm/jit/disass.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/stacktrace.h"
 #include "vm/jit/trap.h"
 
-#include "vmcore/system.h"
-
 
 /* md_signal_handler_sigsegv ***************************************************
 
@@ -70,7 +70,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        intptr_t        val;
        intptr_t        addr;
        int             type;
-       void           *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -114,43 +113,50 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
+}
 
-       switch (type) {
-       case TRAP_COMPILER:
-               if (p != NULL) {
-                       _mc->sc_regs[REG_PV] = (uintptr_t) p;
-                       _mc->sc_pc           = (uintptr_t) p;
-                       break;
-               }
 
-               /* Get and set the PV from the parent Java method. */
+/* md_signal_handler_sigill ****************************************************
 
-               pv = md_codegen_get_pv_from_pc(ra);
+   Illegal Instruction signal handler for hardware exception checks.
 
-               _mc->sc_regs[REG_PV] = (uintptr_t) pv;
+*******************************************************************************/
 
-               /* Get the exception object. */
+void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t* _uc = (ucontext_t*) _p;
+       mcontext_t* _mc = &_uc->uc_mcontext;
 
-               p = builtin_retrieve_exception();
+       void* pv  = (u1 *) _mc->sc_regs[REG_PV];
+       void* sp  = (u1 *) _mc->sc_regs[REG_SP];
+       void* ra  = (u1 *) _mc->sc_regs[REG_RA]; // RA is correct for leaf methods.
+       void* xpc = (u1 *) _mc->sc_pc;
 
-               assert(p != NULL);
+       // The PC points to the instruction after the illegal instruction.
+       xpc = (void*) (((uintptr_t) xpc) - 4);
 
-               /* fall-through */
+       // Get the exception-throwing instruction.
+       uint32_t mcode = *((uint32_t*) xpc);
 
-       case TRAP_PATCHER:
-               if (p == NULL)
-                       break;
+       int opcode = M_OP3_GET_Opcode(mcode);
 
-               /* fall-through */
-               
-       default:
-               _mc->sc_regs[REG_ITMP1_XPTR] = (uintptr_t) p;
-               _mc->sc_regs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
-               _mc->sc_pc                   = (uintptr_t) asm_handle_exception;
+       // Check for undefined instruction we use.
+       // TODO Check the whole instruction.
+       if (opcode != 0x4) {
+               log_println("md_signal_handler_sigill: Unknown illegal instruction %x at %p", mcode, xpc);
+#if defined(ENABLE_DISASSEMBLER)
+               (void) disassinstr(xpc);
+#endif
+               vm_abort("Aborting...");
        }
+
+       // This signal is always a patcher.
+       int      type = TRAP_PATCHER;
+       intptr_t val  = 0;
+
+       // Handle the trap.
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -237,7 +243,7 @@ void md_executionstate_read(executionstate_t *es, void *context)
         * the _mc->sc_fpregs[i] can cause invalid conversions. */
 
        assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs));
-       system_memcpy(&es->fltregs, &_mc->sc_fpregs, sizeof(_mc->sc_fpregs));
+       os_memcpy(&es->fltregs, &_mc->sc_fpregs, sizeof(_mc->sc_fpregs));
 }
 
 
@@ -265,7 +271,7 @@ void md_executionstate_write(executionstate_t *es, void *context)
         * the _mc->sc_fpregs[i] can cause invalid conversions. */
 
        assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs));
-       system_memcpy(&_mc->sc_fpregs, &es->fltregs, sizeof(_mc->sc_fpregs));
+       os_memcpy(&_mc->sc_fpregs, &es->fltregs, sizeof(_mc->sc_fpregs));
 
        /* write special registers */
        _mc->sc_pc           = (ptrint) es->pc;
@@ -275,32 +281,6 @@ void md_executionstate_write(executionstate_t *es, void *context)
 }
 
 
-/* md_critical_section_restart *************************************************
-
-   Search the critical sections tree for a matching section and set
-   the PC to the restart point, if necessary.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
-{
-       mcontext_t *_mc;
-       u1         *pc;
-       u1         *npc;
-
-       _mc = &_uc->uc_mcontext;
-
-       pc = (u1 *) _mc->sc_pc;
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL)
-               _mc->sc_pc = (ptrint) npc;
-}
-#endif
-
-
 /*
  * 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
diff --git a/src/vm/jit/alpha/machine-instr.h b/src/vm/jit/alpha/machine-instr.h
deleted file mode 100644 (file)
index 3d054e1..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef _MACHINE_INSTR_H
-#define _MACHINE_INSTR_H
-
-static inline long
-__attribute__ ((unused))
-compare_and_swap (volatile long *p, long oldval, long newval)
-{
-  long ret, temp;
-
-  __asm__ __volatile__ (
-    "1:\t"
-    "ldq_l  %0,%5\n\t"
-    "cmpeq  %0,%3,%2\n\t"
-    "beq    %2,2f\n\t"
-    "mov    %4,%2\n\t"
-    "stq_c  %2,%1\n\t"
-    "beq    %2,1b\n\t"
-    "2:\t"
-    : "=&r"(ret), "=m"(*p), "=&r"(temp)
-    : "r"(oldval), "r"(newval), "m"(*p));
-
-  return ret;
-}
-
-#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("wmb" : : : "memory");
-#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("mb" : : : "memory");
-#define MEMORY_BARRIER() __asm__ __volatile__ ( \
-               "mb" : : : "memory" );
-
-#endif
index 90189e17ae6d47338e9eedd43eb6fa902785ab18..496834761c646923fdd60750d8c98553d8ae80fd 100644 (file)
 
 #include "vm/jit/alpha/md-abi.h"
 
+#include "vm/descriptor.h"
 #include "vm/global.h"
 
 #include "vm/jit/abi.h"
 
-#include "vmcore/descriptor.h"
-
 
 /* register descripton array **************************************************/
 
diff --git a/src/vm/jit/alpha/md-atomic.hpp b/src/vm/jit/alpha/md-atomic.hpp
new file mode 100644 (file)
index 0000000..962852a
--- /dev/null
@@ -0,0 +1,152 @@
+/* src/vm/jit/alpha/atomic.hpp - Alpha atomic instructions
+
+   Copyright (C) 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 _MD_ATOMIC_HPP
+#define _MD_ATOMIC_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "threads/atomic.hpp"
+
+
+/**
+ * An atomic compare and swap for 32-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
+{
+       uint32_t temp;
+       uint32_t result;
+
+       __asm__ __volatile__ (
+               "1:                   \n"
+               "    ldl_l  %0,%5     \n"
+               "    cmpeq  %0,%3,%2  \n"
+               "    beq    %2,2f     \n"
+               "    mov    %4,%2     \n"
+               "    stl_c  %2,%1     \n"
+               "    beq    %2,1b     \n"
+               "2:                   \n"
+               : "=&r" (result), "=m" (*p), "=&r" (temp)
+               : "r" (oldval), "r" (newval), "m" (*p));
+
+       return result;
+}
+
+
+/**
+ * An atomic compare and swap for 64-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
+{
+       uint64_t temp;
+       uint64_t result;
+
+       __asm__ __volatile__ (
+               "1:                   \n"
+               "    ldq_l  %0,%5     \n"
+               "    cmpeq  %0,%3,%2  \n"
+               "    beq    %2,2f     \n"
+               "    mov    %4,%2     \n"
+               "    stq_c  %2,%1     \n"
+               "    beq    %2,1b     \n"
+               "2:                   \n"
+               : "=&r" (result), "=m" (*p), "=&r" (temp)
+               : "r" (oldval), "r" (newval), "m" (*p));
+
+       return result;
+}
+
+
+/**
+ * An atomic compare and swap for pointer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval)
+{
+       return (void*) compare_and_swap((volatile uint64_t*) p, (uint64_t) oldval, (uint64_t) newval);
+}
+
+
+/**
+ * A memory barrier.
+ */
+inline void Atomic::memory_barrier(void)
+{
+       __asm__ __volatile__ ("mb" : : : "memory");
+}
+
+
+/**
+ * A write memory barrier.
+ */
+inline void Atomic::write_memory_barrier(void)
+{
+       __asm__ __volatile__ ("wmb" : : : "memory");
+}
+
+
+/**
+ * An instruction barrier.
+ */
+inline void Atomic::instruction_barrier(void)
+{
+       __asm__ __volatile__ ("mb" : : : "memory");
+}
+
+#endif // _MD_ATOMIC_HPP
+
+
+/*
+ * 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/jit/alpha/md-stubs.hpp b/src/vm/jit/alpha/md-stubs.hpp
new file mode 100644 (file)
index 0000000..8ff379f
--- /dev/null
@@ -0,0 +1,56 @@
+/* src/vm/jit/alpha/md-stubs.hpp - Alpha JIT stubs
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on an Alpha architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+       return 1 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * 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 c932579dc7bc09ef7ca91bae707d391ab2622ca5..e6947d80eee0c47a352524fd3bf6fda6757ab60a 100644 (file)
@@ -58,6 +58,7 @@ enum {
        /* Don't use 8 (could be a normal load offset). */
 
        TRAP_COMPILER                       = 9,
+       TRAP_COUNTDOWN                      = 10,
        TRAP_END
 };
 
index 2958813c47ee7fad1d2dbb46fce1bce23dfbd051..9ad99b7474b6f982d1c66ea557be178a04f453a7 100644 (file)
@@ -39,7 +39,7 @@ extern void ieee_set_fp_control(unsigned long fp_control);
 #include "vm/jit/alpha/md.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/trap.h"
 
 
index 4899d8f9ffd15d347773cd52eb5a4575ff4f8d57..e939d3803677cc45c07092b70cbb23d87038db05 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/alpha/md.h - machine dependent Alpha functions
 
-   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.
 
 #include "vm/jit/alpha/codegen.h"
 
 #include "vm/global.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* global variables ***********************************************************/
index f990bbe99fdcac16251520844b4b0d69f25646fd..6d3c5fdf4d6697f33a7aa17da8a192359732f0d0 100644 (file)
 
 #include "mm/memory.h"
 
-#include "native/native.h"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/methodheader.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vmcore/references.h"
-#include "vm/resolve.h"
-
-
-#define PATCH_BACK_ORIGINAL_MCODE \
-       *((u4 *) pr->mpc) = (u4) pr->mcode; \
-    md_icacheflush(NULL, 0);
 
 
 /* patcher_patch_code **********************************************************
 
 *******************************************************************************/
 
-void patcher_patch_code(patchref_t *pr)
+void patcher_patch_code(patchref_tpr)
 {
-       PATCH_BACK_ORIGINAL_MCODE;
+       // Patch back original code.
+       *((uint32_t*) pr->mpc) = pr->mcode;
+
+       // Synchronize instruction cache.
+    md_icacheflush(NULL, 0);
 }
 
 
@@ -108,12 +104,13 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
        /* patch the classinfo pointer */
 
        *((ptrint *) datap) = (ptrint) c;
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -145,12 +142,13 @@ bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
        /* patch super class' vftbl */
 
        *((ptrint *) datap) = (ptrint) c->vftbl;
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -179,12 +177,13 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr)
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
        /* patch class flags */
 
        *((s4 *) datap) = (s4) c->flags;
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -221,12 +220,13 @@ bool patcher_get_putstatic(patchref_t *pr)
                if (!initialize_class(fi->clazz))
                        return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
        /* patch the field value's address */
 
        *((intptr_t *) datap) = (intptr_t) fi->value;
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -242,11 +242,9 @@ bool patcher_get_putstatic(patchref_t *pr)
 
 bool patcher_get_putfield(patchref_t *pr)
 {
-       u1               *ra;
        unresolved_field *uf;
        fieldinfo        *fi;
 
-       ra    = (u1 *)               pr->mpc;
        uf    = (unresolved_field *) pr->ref;
 
        /* get the fieldinfo */
@@ -254,18 +252,12 @@ bool patcher_get_putfield(patchref_t *pr)
        if (!(fi = resolve_field_eager(uf)))
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop */
-
-       if (opt_shownops)
-               ra = ra + 4;
-
        /* patch the field's offset into the instruction */
 
-       *((u4 *) ra) |= (s2) (fi->offset & 0x0000ffff);
+       pr->mcode |= (s2) (fi->offset & 0x0000ffff);
 
-       md_icacheflush(NULL, 0);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -297,12 +289,13 @@ bool patcher_invokestatic_special(patchref_t *pr)
        if (!(m = resolve_method_eager(um)))
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
        /* patch stubroutine */
 
        *((ptrint *) datap) = (ptrint) m->stubroutine;
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -334,13 +327,6 @@ bool patcher_invokevirtual(patchref_t *pr)
        if (!(m = resolve_method_eager(um)))
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop */
-
-       if (opt_shownops)
-               ra = ra + 4;
-
        /* patch vftbl index */
 
        *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, table[0]) +
@@ -348,6 +334,9 @@ bool patcher_invokevirtual(patchref_t *pr)
 
        md_icacheflush(NULL, 0);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -380,13 +369,6 @@ bool patcher_invokeinterface(patchref_t *pr)
        if (!(m = resolve_method_eager(um)))
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop */
-
-       if (opt_shownops)
-               ra = ra + 4;
-
        /* patch interfacetable index */
 
        *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
@@ -399,6 +381,9 @@ bool patcher_invokeinterface(patchref_t *pr)
 
        md_icacheflush(NULL, 0);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -432,13 +417,6 @@ bool patcher_checkcast_interface(patchref_t *pr)
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop */
-
-       if (opt_shownops)
-               ra = ra + 4;
-
        /* patch super class index */
 
        *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff);
@@ -448,6 +426,9 @@ bool patcher_checkcast_interface(patchref_t *pr)
 
        md_icacheflush(NULL, 0);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -481,13 +462,6 @@ bool patcher_instanceof_interface(patchref_t *pr)
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop */
-
-       if (opt_shownops)
-               ra = ra + 4;
-
        /* patch super class index */
 
        *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff);
@@ -497,6 +471,9 @@ bool patcher_instanceof_interface(patchref_t *pr)
 
        md_icacheflush(NULL, 0);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
diff --git a/src/vm/jit/argument.c b/src/vm/jit/argument.c
deleted file mode 100644 (file)
index 8705e6b..0000000
+++ /dev/null
@@ -1,773 +0,0 @@
-/* src/vm/jit/argument.c - argument passing from and to JIT methods
-
-   Copyright (C) 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
-
-   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 <stdint.h>
-
-#include "arch.h"
-
-#include "mm/memory.h"
-
-#include "native/llni.h"
-
-#include "vm/array.h"
-#include "vm/global.h"
-#include "vm/primitive.h"
-#include "vm/resolve.h"
-#include "vm/vm.h"
-
-#include "vm/jit/abi-asm.h"
-
-#include "vmcore/descriptor.h"
-#include "vmcore/method.h"
-
-
-/* argument_jitarray_load ******************************************************
-   Returns the argument specified by index from one of the passed arrays
-   and returns it.
-
-*******************************************************************************/
-
-imm_union argument_jitarray_load(methoddesc *md, int32_t index,
-                                                                uint64_t *arg_regs, uint64_t *stack)
-{
-       imm_union  ret;
-       paramdesc *pd;
-
-       pd = &md->params[index];
-
-       switch (md->paramtypes[index].type) {
-               case TYPE_INT:
-               case TYPE_ADR:
-                       if (pd->inmemory) {
-#if (SIZEOF_VOID_P == 8)
-                               ret.l = (int64_t)stack[pd->index];
-#else
-                               ret.l = *(int32_t *)(stack + pd->index);
-#endif
-                       } else {
-#if (SIZEOF_VOID_P == 8)
-                               ret.l = arg_regs[index];
-#else
-                               ret.l = *(int32_t *)(arg_regs + index);
-#endif
-                       }
-                       break;
-               case TYPE_LNG:
-                       if (pd->inmemory) {
-                               ret.l = (int64_t)stack[pd->index];
-                       } else {
-                               ret.l = (int64_t)arg_regs[index];
-                       }
-                       break;
-               case TYPE_FLT:
-                       if (pd->inmemory) {
-                               ret.l = (int64_t)stack[pd->index];
-                       } else {
-                               ret.l = (int64_t)arg_regs[index];
-                       }
-                       break;
-               case TYPE_DBL:
-                       if (pd->inmemory) {
-                               ret.l = (int64_t)stack[pd->index];
-                       } else {
-                               ret.l = (int64_t)arg_regs[index];
-                       }
-                       break;
-       }
-
-       return ret;
-}
-
-
-/* argument_jitarray_store *****************************************************
-   Stores the argument into one of the passed arrays at a slot specified
-   by index.
-
-*******************************************************************************/
-
-void argument_jitarray_store(methoddesc *md, int32_t index,
-                                                        uint64_t *arg_regs, uint64_t *stack,
-                                                        imm_union param)
-{
-       paramdesc *pd;
-
-       pd = &md->params[index];
-
-       switch (md->paramtypes[index].type) {
-               case TYPE_ADR:
-                       if (pd->inmemory) {
-#if (SIZEOF_VOID_P == 8)
-                               stack[pd->index] = param.l;
-#else
-                               assert(0);
-#endif
-                       } else {
-                               arg_regs[index] = param.l;
-                       }
-                       break;
-               default:
-                       vm_abort("argument_jitarray_store: type not implemented");
-                       break;
-       }
-}
-
-
-/* argument_jitreturn_load *****************************************************
-
-   Loads the proper return value form the return register and returns it.
-
-*******************************************************************************/
-
-imm_union argument_jitreturn_load(methoddesc *md, uint64_t *return_regs)
-{
-       imm_union ret;
-
-       switch (md->returntype.type) {
-               case TYPE_INT:
-               case TYPE_ADR:
-#if (SIZEOF_VOID_P == 8)
-                       ret.l = return_regs[0];
-#else
-                       ret.l = *(int32_t *)return_regs;
-#endif
-                       break;
-               case TYPE_LNG:
-                       ret.l = *(int64_t *)return_regs;
-                       break;
-               case TYPE_FLT:
-                       ret.l = *(int64_t *)return_regs;
-                       break;
-               case TYPE_DBL:
-                       ret.l = *(int64_t *)return_regs;
-                       break;
-       }
-
-       return ret;
-}
-
-
-/* argument_jitreturn_store ****************************************************
-
-   Stores the proper return value into the return registers.
-
-*******************************************************************************/
-
-void argument_jitreturn_store(methoddesc *md, uint64_t *return_regs, imm_union ret)
-{
-       switch (md->returntype.type) {
-               case TYPE_ADR:
-#if (SIZEOF_VOID_P == 8)
-                       return_regs[0] = ret.l;
-#else
-                       assert(0);
-#endif
-                       break;
-               default:
-                       vm_abort("argument_jitreturn_store: type not implemented");
-                       break;
-       }
-}
-
-
-/* argument_vmarray_store_int **************************************************
-
-   Helper function to store an integer into the argument array, taking
-   care of architecture specific issues.
-
-*******************************************************************************/
-
-static void argument_vmarray_store_int(uint64_t *array, paramdesc *pd, int32_t value)
-{
-       int32_t index;
-
-       if (!pd->inmemory) {
-               index        = pd->index;
-               array[index] = (int64_t) value;
-       }
-       else {
-               index        = ARG_CNT + pd->index;
-#if SIZEOF_VOID_P == 8
-               array[index] = (int64_t) value;
-#else
-# if WORDS_BIGENDIAN == 1
-               array[index] = ((int64_t) value) << 32;
-# else
-               array[index] = (int64_t) value;
-# endif
-#endif
-       }
-}
-
-
-/* argument_vmarray_store_lng **************************************************
-
-   Helper function to store a long into the argument array, taking
-   care of architecture specific issues.
-
-*******************************************************************************/
-
-static void argument_vmarray_store_lng(uint64_t *array, paramdesc *pd, int64_t value)
-{
-       int32_t index;
-
-#if SIZEOF_VOID_P == 8
-       if (!pd->inmemory)
-               index = pd->index;
-       else
-               index = ARG_CNT + pd->index;
-
-       array[index] = value;
-#else
-       if (!pd->inmemory) {
-               /* move low and high 32-bits into it's own argument slot */
-
-               index        = GET_LOW_REG(pd->index);
-               array[index] = value & 0x00000000ffffffff;
-
-               index        = GET_HIGH_REG(pd->index);
-               array[index] = value >> 32;
-       }
-       else {
-               index        = ARG_CNT + pd->index;
-               array[index] = value;
-       }
-#endif
-}
-
-
-/* argument_vmarray_store_flt **************************************************
-
-   Helper function to store a float into the argument array, taking
-   care of architecture specific issues.
-
-*******************************************************************************/
-
-static void argument_vmarray_store_flt(uint64_t *array, paramdesc *pd, uint64_t value)
-{
-       int32_t index;
-
-       if (!pd->inmemory) {
-#if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
-               index        = pd->index;
-#else
-               index        = INT_ARG_CNT + pd->index;
-#endif
-#if WORDS_BIGENDIAN == 1 && !defined(__POWERPC__) && !defined(__POWERPC64__) && !defined(__S390__)
-               array[index] = value >> 32;
-#else
-               array[index] = value;
-#endif
-       }
-       else {
-               index        = ARG_CNT + pd->index;
-#if defined(__SPARC_64__)
-               array[index] = value >> 32;
-#else
-               array[index] = value;
-#endif
-       }
-}
-
-
-/* argument_vmarray_store_dbl **************************************************
-
-   Helper function to store a double into the argument array, taking
-   care of architecture specific issues.
-
-*******************************************************************************/
-
-static void argument_vmarray_store_dbl(uint64_t *array, paramdesc *pd, uint64_t value)
-{
-       int32_t index;
-
-       if (!pd->inmemory) {
-#if SIZEOF_VOID_P != 8 && defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
-               index        = GET_LOW_REG(pd->index);
-               array[index] = value & 0x00000000ffffffff;
-
-               index        = GET_HIGH_REG(pd->index);
-               array[index] = value >> 32;
-#else
-               index        = INT_ARG_CNT + pd->index;
-               array[index] = value;
-#endif
-       }
-       else {
-               index        = ARG_CNT + pd->index;
-               array[index] = value;
-       }
-}
-
-
-/* argument_vmarray_store_adr **************************************************
-
-   Helper function to store an address into the argument array, taking
-   care of architecture specific issues.
-
-   ATTENTION: This function has to be used outside the nativeworld.
-
-*******************************************************************************/
-
-static void argument_vmarray_store_adr(uint64_t *array, paramdesc *pd, java_handle_t *h)
-{
-       void    *value;
-       int32_t  index;
-
-       /* Take the reference value out of the handle. */
-
-       value = LLNI_UNWRAP(h);
-
-       if (!pd->inmemory) {
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-               /* When the architecture has address registers, place them
-                  after integer and float registers. */
-
-               index        = INT_ARG_CNT + FLT_ARG_CNT + pd->index;
-#else
-               index        = pd->index;
-#endif
-               array[index] = (uint64_t) (intptr_t) value;
-       }
-       else {
-               index        = ARG_CNT + pd->index;
-#if SIZEOF_VOID_P == 8
-               array[index] = (uint64_t) (intptr_t) value;
-#else
-# if WORDS_BIGENDIAN == 1
-               array[index] = ((uint64_t) (intptr_t) value) << 32;
-# else
-               array[index] = (uint64_t) (intptr_t) value;
-# endif
-#endif
-       }
-}
-
-
-/* argument_vmarray_from_valist ************************************************
-
-   Creates an argument array which can be passed to asm_vm_call_method.
-   The array is created from the passed valist.
-
-   ATTENTION: This function has to be used outside the native world.
-
-*******************************************************************************/
-
-uint64_t *argument_vmarray_from_valist(methodinfo *m, java_handle_t *o, va_list ap)
-{
-       methoddesc *md;
-       paramdesc  *pd;
-       typedesc   *td;
-       uint64_t   *array;
-       int32_t     i;
-       imm_union   value;
-
-       /* get the descriptors */
-
-       md = m->parseddesc;
-       pd = md->params;
-       td = md->paramtypes;
-
-       /* allocate argument array */
-
-       array = DMNEW(uint64_t, INT_ARG_CNT + FLT_ARG_CNT + md->memuse);
-
-       /* if method is non-static fill first block and skip `this' pointer */
-
-       i = 0;
-
-       if (o != NULL) {
-               /* the `this' pointer */
-               argument_vmarray_store_adr(array, pd, o);
-
-               pd++;
-               td++;
-               i++;
-       } 
-
-       for (; i < md->paramcount; i++, pd++, td++) {
-               switch (td->type) {
-               case TYPE_INT:
-                       value.i = va_arg(ap, int32_t);
-                       argument_vmarray_store_int(array, pd, value.i);
-                       break;
-
-               case TYPE_LNG:
-                       value.l = va_arg(ap, int64_t);
-                       argument_vmarray_store_lng(array, pd, value.l);
-                       break;
-
-               case TYPE_FLT:
-#if defined(__ALPHA__) || defined(__POWERPC__) || defined(__POWERPC64__)
-                       /* This is required to load the correct float value in
-                          assembler code. */
-
-                       value.d = (double) va_arg(ap, double);
-#else
-                       value.f = (float) va_arg(ap, double);
-#endif
-                       argument_vmarray_store_flt(array, pd, value.l);
-                       break;
-
-               case TYPE_DBL:
-                       value.d = va_arg(ap, double);
-                       argument_vmarray_store_dbl(array, pd, value.l);
-                       break;
-
-               case TYPE_ADR: 
-                       value.a = va_arg(ap, void*);
-                       argument_vmarray_store_adr(array, pd, value.a);
-                       break;
-               }
-       }
-
-       return array;
-}
-
-
-/* argument_vmarray_from_jvalue ************************************************
-
-   Creates an argument array which can be passed to asm_vm_call_method.
-   The array is created from the passed jvalue array.
-
-   ATTENTION: This function has to be used outside the native world.
-
-*******************************************************************************/
-
-uint64_t *argument_vmarray_from_jvalue(methodinfo *m, java_handle_t *o,
-                                                                          const jvalue *args)
-{
-       methoddesc *md;
-       paramdesc  *pd;
-       typedesc   *td;
-       uint64_t   *array;
-       int32_t     i;
-       int32_t     j;
-
-       /* get the descriptors */
-
-       md = m->parseddesc;
-       pd = md->params;
-       td = md->paramtypes;
-
-       /* allocate argument array */
-
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-       array = DMNEW(uint64_t, INT_ARG_CNT + FLT_ARG_CNT + ADR_ARG_CNT + md->memuse);
-#else
-       array = DMNEW(uint64_t, INT_ARG_CNT + FLT_ARG_CNT + md->memuse);
-#endif
-
-       /* if method is non-static fill first block and skip `this' pointer */
-
-       i = 0;
-
-       if (o != NULL) {
-               /* the `this' pointer */
-               argument_vmarray_store_adr(array, pd, o);
-
-               pd++;
-               td++;
-               i++;
-       } 
-
-       for (j = 0; i < md->paramcount; i++, j++, pd++, td++) {
-               switch (td->decltype) {
-               case TYPE_INT:
-                       argument_vmarray_store_int(array, pd, args[j].i);
-                       break;
-
-               case TYPE_LNG:
-                       argument_vmarray_store_lng(array, pd, args[j].j);
-                       break;
-
-               case TYPE_FLT:
-                       argument_vmarray_store_flt(array, pd, args[j].j);
-                       break;
-
-               case TYPE_DBL:
-                       argument_vmarray_store_dbl(array, pd, args[j].j);
-                       break;
-
-               case TYPE_ADR: 
-                       argument_vmarray_store_adr(array, pd, (java_handle_t *) args[j].l);
-                       break;
-               }
-       }
-
-       return array;
-}
-
-
-/* argument_vmarray_from_objectarray *******************************************
-
-   Creates an argument array which can be passed to asm_vm_call_method.
-   The array is created from the passed objectarray of boxed values.
-
-   ATTENTION: This function has to be used outside the native world.
-
-   RETURN VALUE:
-      NULL.........indicates an error while creating the array
-      (-1).........no error, but an empty array
-      otherwise....array containing the argument values
-
-*******************************************************************************/
-
-uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
-                                                                                       java_handle_objectarray_t *params)
-{
-       methoddesc    *md;
-       paramdesc     *pd;
-       typedesc      *td;
-       uint64_t      *array;
-       java_handle_t *param;
-       classinfo     *c;
-       int            type;
-       int32_t        i;
-       int32_t        j;
-       imm_union      value;
-
-       /* get the descriptors */
-
-       md = m->parseddesc;
-       pd = md->params;
-       td = md->paramtypes;
-
-       /* allocate argument array */
-
-       array = DMNEW(uint64_t, INT_ARG_CNT + FLT_ARG_CNT + md->memuse);
-
-       /* The array can be NULL if we don't have any arguments to pass
-          and the architecture does not have any argument registers
-          (e.g. i386).  In that case we return (-1) to indicate
-          that no exception should be thrown */
-
-       if (array == NULL)
-               array = (uint64_t *)(-1);
-
-       /* if method is non-static fill first block and skip `this' pointer */
-
-       i = 0;
-
-       if (o != NULL) {
-               /* this pointer */
-               argument_vmarray_store_adr(array, pd, o);
-
-               pd++;
-               td++;
-               i++;
-       }
-
-       for (j = 0; i < md->paramcount; i++, j++, pd++, td++) {
-               /* XXX This function can throw an exception, which should not happend
-                  here, since we are outside the nativeworld. */
-               param = array_objectarray_element_get(params, j);
-
-               switch (td->type) {
-               case TYPE_INT:
-                       if (param == NULL)
-                               return NULL;
-
-                       /* convert the value according to its declared type */
-
-                       LLNI_class_get(param, c);
-                       type = primitive_type_get_by_wrapperclass(c);
-
-                       switch (td->decltype) {
-                       case PRIMITIVETYPE_BOOLEAN:
-                               switch (type) {
-                               case PRIMITIVETYPE_BOOLEAN:
-                                       /* This type is OK. */
-                                       break;
-                               default:
-                                       return NULL;
-                               }
-                               break;
-
-                       case PRIMITIVETYPE_BYTE:
-                               switch (type) {
-                               case PRIMITIVETYPE_BYTE:
-                                       /* This type is OK. */
-                                       break;
-                               default:
-                                       return NULL;
-                               }
-                               break;
-
-                       case PRIMITIVETYPE_CHAR:
-                               switch (type) {
-                               case PRIMITIVETYPE_CHAR:
-                                       /* This type is OK. */
-                                       break;
-                               default:
-                                       return NULL;
-                               }
-                               break;
-
-                       case PRIMITIVETYPE_SHORT:
-                               switch (type) {
-                               case PRIMITIVETYPE_BYTE:
-                               case PRIMITIVETYPE_SHORT:
-                                       /* These types are OK. */
-                                       break;
-                               default:
-                                       return NULL;
-                               }
-                               break;
-
-                       case PRIMITIVETYPE_INT:
-                               switch (type) {
-                               case PRIMITIVETYPE_BYTE:
-                               case PRIMITIVETYPE_SHORT:
-                               case PRIMITIVETYPE_INT:
-                                       /* These types are OK. */
-                                       break;
-                               default:
-                                       return NULL;
-                               }
-                               break;
-
-                       default:
-                               vm_abort("argument_vmarray_from_objectarray: invalid type %d",
-                                                td->decltype);
-                       }
-
-                       value = primitive_unbox(param);
-                       argument_vmarray_store_int(array, pd, value.i);
-                       break;
-
-               case TYPE_LNG:
-                       if (param == NULL)
-                               return NULL;
-
-                       LLNI_class_get(param, c);
-                       type = primitive_type_get_by_wrapperclass(c);
-
-                       assert(td->decltype == PRIMITIVETYPE_LONG);
-
-                       switch (type) {
-                       case PRIMITIVETYPE_BYTE:
-                       case PRIMITIVETYPE_SHORT:
-                       case PRIMITIVETYPE_INT:
-                       case PRIMITIVETYPE_LONG:
-                               /* These types are OK. */
-                               break;
-                       default:
-                               return NULL;
-                       }
-
-                       value = primitive_unbox(param);
-                       argument_vmarray_store_lng(array, pd, value.l);
-                       break;
-
-               case TYPE_FLT:
-                       if (param == NULL)
-                               return NULL;
-
-                       LLNI_class_get(param, c);
-                       type = primitive_type_get_by_wrapperclass(c);
-
-                       assert(td->decltype == PRIMITIVETYPE_FLOAT);
-
-                       switch (type) {
-                       case PRIMITIVETYPE_FLOAT:
-                               /* This type is OK. */
-                               break;
-                       default:
-                               return NULL;
-                       }
-
-                       value = primitive_unbox(param);
-                       argument_vmarray_store_flt(array, pd, value.l);
-                       break;
-
-               case TYPE_DBL:
-                       if (param == NULL)
-                               return NULL;
-
-                       LLNI_class_get(param, c);
-                       type = primitive_type_get_by_wrapperclass(c);
-
-                       assert(td->decltype == PRIMITIVETYPE_DOUBLE);
-
-                       switch (type) {
-                       case PRIMITIVETYPE_FLOAT:
-                       case PRIMITIVETYPE_DOUBLE:
-                               /* These types are OK. */
-                               break;
-                       default:
-                               return NULL;
-                       }
-
-                       value = primitive_unbox(param);
-                       argument_vmarray_store_dbl(array, pd, value.l);
-                       break;
-               
-               case TYPE_ADR:
-                       if (!resolve_class_from_typedesc(td, true, true, &c))
-                               return NULL;
-
-                       if (param != NULL) {
-                               if (td->arraydim > 0) {
-                                       if (!builtin_arrayinstanceof(param, c))
-                                               return NULL;
-                               }
-                               else {
-                                       if (!builtin_instanceof(param, c))
-                                               return NULL;
-                               }
-                       }
-
-                       argument_vmarray_store_adr(array, pd, param);
-                       break;
-
-               default:
-                       vm_abort("argument_vmarray_from_objectarray: invalid type %d", td->type);
-               }
-       }
-
-       return array;
-}
-
-
-/*
- * 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/jit/argument.cpp b/src/vm/jit/argument.cpp
new file mode 100644 (file)
index 0000000..a670883
--- /dev/null
@@ -0,0 +1,769 @@
+/* src/vm/jit/argument.cpp - argument passing from and to JIT methods
+
+   Copyright (C) 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 <stdint.h>
+
+#include "arch.h"
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "vm/array.hpp"
+#include "vm/descriptor.h"
+#include "vm/global.h"
+#include "vm/method.hpp"
+#include "vm/primitive.hpp"
+#include "vm/resolve.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/abi-asm.h"
+
+
+/* argument_jitarray_load ******************************************************
+   Returns the argument specified by index from one of the passed arrays
+   and returns it.
+
+*******************************************************************************/
+
+imm_union argument_jitarray_load(methoddesc *md, int32_t index,
+                                                                uint64_t *arg_regs, uint64_t *stack)
+{
+       imm_union  ret;
+       paramdesc *pd;
+
+       pd = &md->params[index];
+
+       switch (md->paramtypes[index].type) {
+               case TYPE_INT:
+               case TYPE_ADR:
+                       if (pd->inmemory) {
+#if (SIZEOF_VOID_P == 8)
+                               ret.l = (int64_t)stack[pd->index];
+#else
+                               ret.l = *(int32_t *)(stack + pd->index);
+#endif
+                       } else {
+#if (SIZEOF_VOID_P == 8)
+                               ret.l = arg_regs[index];
+#else
+                               ret.l = *(int32_t *)(arg_regs + index);
+#endif
+                       }
+                       break;
+               case TYPE_LNG:
+                       if (pd->inmemory) {
+                               ret.l = (int64_t)stack[pd->index];
+                       } else {
+                               ret.l = (int64_t)arg_regs[index];
+                       }
+                       break;
+               case TYPE_FLT:
+                       if (pd->inmemory) {
+                               ret.l = (int64_t)stack[pd->index];
+                       } else {
+                               ret.l = (int64_t)arg_regs[index];
+                       }
+                       break;
+               case TYPE_DBL:
+                       if (pd->inmemory) {
+                               ret.l = (int64_t)stack[pd->index];
+                       } else {
+                               ret.l = (int64_t)arg_regs[index];
+                       }
+                       break;
+       }
+
+       return ret;
+}
+
+
+/* argument_jitarray_store *****************************************************
+   Stores the argument into one of the passed arrays at a slot specified
+   by index.
+
+*******************************************************************************/
+
+void argument_jitarray_store(methoddesc *md, int32_t index,
+                                                        uint64_t *arg_regs, uint64_t *stack,
+                                                        imm_union param)
+{
+       paramdesc *pd;
+
+       pd = &md->params[index];
+
+       switch (md->paramtypes[index].type) {
+               case TYPE_ADR:
+                       if (pd->inmemory) {
+#if (SIZEOF_VOID_P == 8)
+                               stack[pd->index] = param.l;
+#else
+                               assert(0);
+#endif
+                       } else {
+                               arg_regs[index] = param.l;
+                       }
+                       break;
+               default:
+                       os::abort("argument_jitarray_store: type not implemented");
+                       break;
+       }
+}
+
+
+/* argument_jitreturn_load *****************************************************
+
+   Loads the proper return value form the return register and returns it.
+
+*******************************************************************************/
+
+imm_union argument_jitreturn_load(methoddesc *md, uint64_t *return_regs)
+{
+       imm_union ret;
+
+       switch (md->returntype.type) {
+               case TYPE_INT:
+               case TYPE_ADR:
+#if (SIZEOF_VOID_P == 8)
+                       ret.l = return_regs[0];
+#else
+                       ret.l = *(int32_t *)return_regs;
+#endif
+                       break;
+               case TYPE_LNG:
+                       ret.l = *(int64_t *)return_regs;
+                       break;
+               case TYPE_FLT:
+                       ret.l = *(int64_t *)return_regs;
+                       break;
+               case TYPE_DBL:
+                       ret.l = *(int64_t *)return_regs;
+                       break;
+       }
+
+       return ret;
+}
+
+
+/* argument_jitreturn_store ****************************************************
+
+   Stores the proper return value into the return registers.
+
+*******************************************************************************/
+
+void argument_jitreturn_store(methoddesc *md, uint64_t *return_regs, imm_union ret)
+{
+       switch (md->returntype.type) {
+               case TYPE_ADR:
+#if (SIZEOF_VOID_P == 8)
+                       return_regs[0] = ret.l;
+#else
+                       assert(0);
+#endif
+                       break;
+               default:
+                       os::abort("argument_jitreturn_store: type not implemented");
+                       break;
+       }
+}
+
+
+/* argument_vmarray_store_int **************************************************
+
+   Helper function to store an integer into the argument array, taking
+   care of architecture specific issues.
+
+*******************************************************************************/
+
+static void argument_vmarray_store_int(uint64_t *array, paramdesc *pd, int32_t value)
+{
+       int32_t index;
+
+       if (!pd->inmemory) {
+               index        = pd->index;
+               array[index] = (int64_t) value;
+       }
+       else {
+               index        = ARG_CNT + pd->index;
+#if SIZEOF_VOID_P == 8
+               array[index] = (int64_t) value;
+#else
+# if WORDS_BIGENDIAN == 1
+               array[index] = ((int64_t) value) << 32;
+# else
+               array[index] = (int64_t) value;
+# endif
+#endif
+       }
+}
+
+
+/* argument_vmarray_store_lng **************************************************
+
+   Helper function to store a long into the argument array, taking
+   care of architecture specific issues.
+
+*******************************************************************************/
+
+static void argument_vmarray_store_lng(uint64_t *array, paramdesc *pd, int64_t value)
+{
+       int32_t index;
+
+#if SIZEOF_VOID_P == 8
+       if (!pd->inmemory)
+               index = pd->index;
+       else
+               index = ARG_CNT + pd->index;
+
+       array[index] = value;
+#else
+       if (!pd->inmemory) {
+               /* move low and high 32-bits into it's own argument slot */
+
+               index        = GET_LOW_REG(pd->index);
+               array[index] = value & 0x00000000ffffffff;
+
+               index        = GET_HIGH_REG(pd->index);
+               array[index] = value >> 32;
+       }
+       else {
+               index        = ARG_CNT + pd->index;
+               array[index] = value;
+       }
+#endif
+}
+
+
+/* argument_vmarray_store_flt **************************************************
+
+   Helper function to store a float into the argument array, taking
+   care of architecture specific issues.
+
+*******************************************************************************/
+
+static void argument_vmarray_store_flt(uint64_t *array, paramdesc *pd, uint64_t value)
+{
+       int32_t index;
+
+       if (!pd->inmemory) {
+#if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
+               index        = pd->index;
+#else
+               index        = INT_ARG_CNT + pd->index;
+#endif
+#if WORDS_BIGENDIAN == 1 && !defined(__POWERPC__) && !defined(__POWERPC64__) && !defined(__S390__)
+               array[index] = value >> 32;
+#else
+               array[index] = value;
+#endif
+       }
+       else {
+               index        = ARG_CNT + pd->index;
+#if defined(__SPARC_64__)
+               array[index] = value >> 32;
+#else
+               array[index] = value;
+#endif
+       }
+}
+
+
+/* argument_vmarray_store_dbl **************************************************
+
+   Helper function to store a double into the argument array, taking
+   care of architecture specific issues.
+
+*******************************************************************************/
+
+static void argument_vmarray_store_dbl(uint64_t *array, paramdesc *pd, uint64_t value)
+{
+       int32_t index;
+
+       if (!pd->inmemory) {
+#if SIZEOF_VOID_P != 8 && defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
+               index        = GET_LOW_REG(pd->index);
+               array[index] = value & 0x00000000ffffffff;
+
+               index        = GET_HIGH_REG(pd->index);
+               array[index] = value >> 32;
+#else
+               index        = INT_ARG_CNT + pd->index;
+               array[index] = value;
+#endif
+       }
+       else {
+               index        = ARG_CNT + pd->index;
+               array[index] = value;
+       }
+}
+
+
+/* argument_vmarray_store_adr **************************************************
+
+   Helper function to store an address into the argument array, taking
+   care of architecture specific issues.
+
+   ATTENTION: This function has to be used outside the nativeworld.
+
+*******************************************************************************/
+
+static void argument_vmarray_store_adr(uint64_t *array, paramdesc *pd, java_handle_t *h)
+{
+       void    *value;
+       int32_t  index;
+
+       /* Take the reference value out of the handle. */
+
+       value = LLNI_UNWRAP(h);
+
+       if (!pd->inmemory) {
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+               /* When the architecture has address registers, place them
+                  after integer and float registers. */
+
+               index        = INT_ARG_CNT + FLT_ARG_CNT + pd->index;
+#else
+               index        = pd->index;
+#endif
+               array[index] = (uint64_t) (intptr_t) value;
+       }
+       else {
+               index        = ARG_CNT + pd->index;
+#if SIZEOF_VOID_P == 8
+               array[index] = (uint64_t) (intptr_t) value;
+#else
+# if WORDS_BIGENDIAN == 1
+               array[index] = ((uint64_t) (intptr_t) value) << 32;
+# else
+               array[index] = (uint64_t) (intptr_t) value;
+# endif
+#endif
+       }
+}
+
+
+/* argument_vmarray_from_valist ************************************************
+
+   Creates an argument array which can be passed to asm_vm_call_method.
+   The array is created from the passed valist.
+
+   ATTENTION: This function has to be used outside the native world.
+
+*******************************************************************************/
+
+uint64_t *argument_vmarray_from_valist(methodinfo *m, java_handle_t *o, va_list ap)
+{
+       methoddesc *md;
+       paramdesc  *pd;
+       typedesc   *td;
+       uint64_t   *array;
+       int32_t     i;
+       imm_union   value;
+
+       /* get the descriptors */
+
+       md = m->parseddesc;
+       pd = md->params;
+       td = md->paramtypes;
+
+       // Allocate argument array.
+       array = (uint64_t*) DumpMemory::allocate(sizeof(uint64_t) * (INT_ARG_CNT + FLT_ARG_CNT + md->memuse));
+
+       /* if method is non-static fill first block and skip `this' pointer */
+
+       i = 0;
+
+       if (o != NULL) {
+               /* the `this' pointer */
+               argument_vmarray_store_adr(array, pd, o);
+
+               pd++;
+               td++;
+               i++;
+       } 
+
+       for (; i < md->paramcount; i++, pd++, td++) {
+               switch (td->type) {
+               case TYPE_INT:
+                       value.i = va_arg(ap, int32_t);
+                       argument_vmarray_store_int(array, pd, value.i);
+                       break;
+
+               case TYPE_LNG:
+                       value.l = va_arg(ap, int64_t);
+                       argument_vmarray_store_lng(array, pd, value.l);
+                       break;
+
+               case TYPE_FLT:
+#if defined(__ALPHA__) || defined(__POWERPC__) || defined(__POWERPC64__)
+                       /* This is required to load the correct float value in
+                          assembler code. */
+
+                       value.d = (double) va_arg(ap, double);
+#else
+                       value.f = (float) va_arg(ap, double);
+#endif
+                       argument_vmarray_store_flt(array, pd, value.l);
+                       break;
+
+               case TYPE_DBL:
+                       value.d = va_arg(ap, double);
+                       argument_vmarray_store_dbl(array, pd, value.l);
+                       break;
+
+               case TYPE_ADR: 
+                       value.a = va_arg(ap, void*);
+                       argument_vmarray_store_adr(array, pd, static_cast<java_handle_t*>(value.a));
+                       break;
+               }
+       }
+
+       return array;
+}
+
+
+/* argument_vmarray_from_jvalue ************************************************
+
+   Creates an argument array which can be passed to asm_vm_call_method.
+   The array is created from the passed jvalue array.
+
+   ATTENTION: This function has to be used outside the native world.
+
+*******************************************************************************/
+
+uint64_t *argument_vmarray_from_jvalue(methodinfo *m, java_handle_t *o,
+                                                                          const jvalue *args)
+{
+       methoddesc *md;
+       paramdesc  *pd;
+       typedesc   *td;
+       uint64_t   *array;
+       int32_t     i;
+       int32_t     j;
+
+       /* get the descriptors */
+
+       md = m->parseddesc;
+       pd = md->params;
+       td = md->paramtypes;
+
+       /* allocate argument array */
+
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+       array = (uint64_t*) DumpMemory::allocate(sizeof(uint64_t) * (INT_ARG_CNT + FLT_ARG_CNT + ADR_ARG_CNT + md->memuse));
+#else
+       array = (uint64_t*) DumpMemory::allocate(sizeof(uint64_t) * (INT_ARG_CNT + FLT_ARG_CNT + md->memuse));
+#endif
+
+       /* if method is non-static fill first block and skip `this' pointer */
+
+       i = 0;
+
+       if (o != NULL) {
+               /* the `this' pointer */
+               argument_vmarray_store_adr(array, pd, o);
+
+               pd++;
+               td++;
+               i++;
+       } 
+
+       for (j = 0; i < md->paramcount; i++, j++, pd++, td++) {
+               switch (td->primitivetype) {
+               case TYPE_INT:
+                       argument_vmarray_store_int(array, pd, args[j].i);
+                       break;
+
+               case TYPE_LNG:
+                       argument_vmarray_store_lng(array, pd, args[j].j);
+                       break;
+
+               case TYPE_FLT:
+                       argument_vmarray_store_flt(array, pd, args[j].j);
+                       break;
+
+               case TYPE_DBL:
+                       argument_vmarray_store_dbl(array, pd, args[j].j);
+                       break;
+
+               case TYPE_ADR: 
+                       argument_vmarray_store_adr(array, pd, (java_handle_t *) args[j].l);
+                       break;
+               }
+       }
+
+       return array;
+}
+
+
+/* argument_vmarray_from_objectarray *******************************************
+
+   Creates an argument array which can be passed to asm_vm_call_method.
+   The array is created from the passed objectarray of boxed values.
+
+   ATTENTION: This function has to be used outside the native world.
+
+   RETURN VALUE:
+      NULL.........indicates an error while creating the array
+      (-1).........no error, but an empty array
+      otherwise....array containing the argument values
+
+*******************************************************************************/
+
+uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
+                                                                                       java_handle_objectarray_t *params)
+{
+       methoddesc    *md;
+       paramdesc     *pd;
+       typedesc      *td;
+       uint64_t      *array;
+       java_handle_t *param;
+       classinfo     *c;
+       int            type;
+       int32_t        i;
+       int32_t        j;
+       imm_union      value;
+
+       /* get the descriptors */
+
+       md = m->parseddesc;
+       pd = md->params;
+       td = md->paramtypes;
+
+       /* allocate argument array */
+
+       array = (uint64_t*) DumpMemory::allocate(sizeof(uint64_t) * (INT_ARG_CNT + FLT_ARG_CNT + md->memuse));
+
+       /* The array can be NULL if we don't have any arguments to pass
+          and the architecture does not have any argument registers
+          (e.g. i386).  In that case we return (-1) to indicate
+          that no exception should be thrown */
+
+       if (array == NULL)
+               array = (uint64_t *)(-1);
+
+       /* if method is non-static fill first block and skip `this' pointer */
+
+       i = 0;
+
+       if (o != NULL) {
+               /* this pointer */
+               argument_vmarray_store_adr(array, pd, o);
+
+               pd++;
+               td++;
+               i++;
+       }
+
+       for (j = 0; i < md->paramcount; i++, j++, pd++, td++) {
+               /* XXX This function can throw an exception, which should not happend
+                  here, since we are outside the nativeworld. */
+               param = array_objectarray_element_get(params, j);
+
+               switch (td->type) {
+               case TYPE_INT:
+                       if (param == NULL)
+                               return NULL;
+
+                       /* convert the value according to its declared type */
+
+                       LLNI_class_get(param, c);
+                       type = Primitive::get_type_by_wrapperclass(c);
+
+                       switch (td->primitivetype) {
+                       case PRIMITIVETYPE_BOOLEAN:
+                               switch (type) {
+                               case PRIMITIVETYPE_BOOLEAN:
+                                       /* This type is OK. */
+                                       break;
+                               default:
+                                       return NULL;
+                               }
+                               break;
+
+                       case PRIMITIVETYPE_BYTE:
+                               switch (type) {
+                               case PRIMITIVETYPE_BYTE:
+                                       /* This type is OK. */
+                                       break;
+                               default:
+                                       return NULL;
+                               }
+                               break;
+
+                       case PRIMITIVETYPE_CHAR:
+                               switch (type) {
+                               case PRIMITIVETYPE_CHAR:
+                                       /* This type is OK. */
+                                       break;
+                               default:
+                                       return NULL;
+                               }
+                               break;
+
+                       case PRIMITIVETYPE_SHORT:
+                               switch (type) {
+                               case PRIMITIVETYPE_BYTE:
+                               case PRIMITIVETYPE_SHORT:
+                                       /* These types are OK. */
+                                       break;
+                               default:
+                                       return NULL;
+                               }
+                               break;
+
+                       case PRIMITIVETYPE_INT:
+                               switch (type) {
+                               case PRIMITIVETYPE_BYTE:
+                               case PRIMITIVETYPE_SHORT:
+                               case PRIMITIVETYPE_INT:
+                                       /* These types are OK. */
+                                       break;
+                               default:
+                                       return NULL;
+                               }
+                               break;
+
+                       default:
+                               os::abort("argument_vmarray_from_objectarray: invalid type %d",
+                                                td->primitivetype);
+                       }
+
+                       value = Primitive::unbox(param);
+                       argument_vmarray_store_int(array, pd, value.i);
+                       break;
+
+               case TYPE_LNG:
+                       if (param == NULL)
+                               return NULL;
+
+                       LLNI_class_get(param, c);
+                       type = Primitive::get_type_by_wrapperclass(c);
+
+                       assert(td->primitivetype == PRIMITIVETYPE_LONG);
+
+                       switch (type) {
+                       case PRIMITIVETYPE_BYTE:
+                       case PRIMITIVETYPE_SHORT:
+                       case PRIMITIVETYPE_INT:
+                       case PRIMITIVETYPE_LONG:
+                               /* These types are OK. */
+                               break;
+                       default:
+                               return NULL;
+                       }
+
+                       value = Primitive::unbox(param);
+                       argument_vmarray_store_lng(array, pd, value.l);
+                       break;
+
+               case TYPE_FLT:
+                       if (param == NULL)
+                               return NULL;
+
+                       LLNI_class_get(param, c);
+                       type = Primitive::get_type_by_wrapperclass(c);
+
+                       assert(td->primitivetype == PRIMITIVETYPE_FLOAT);
+
+                       switch (type) {
+                       case PRIMITIVETYPE_FLOAT:
+                               /* This type is OK. */
+                               break;
+                       default:
+                               return NULL;
+                       }
+
+                       value = Primitive::unbox(param);
+                       argument_vmarray_store_flt(array, pd, value.l);
+                       break;
+
+               case TYPE_DBL:
+                       if (param == NULL)
+                               return NULL;
+
+                       LLNI_class_get(param, c);
+                       type = Primitive::get_type_by_wrapperclass(c);
+
+                       assert(td->primitivetype == PRIMITIVETYPE_DOUBLE);
+
+                       switch (type) {
+                       case PRIMITIVETYPE_FLOAT:
+                       case PRIMITIVETYPE_DOUBLE:
+                               /* These types are OK. */
+                               break;
+                       default:
+                               return NULL;
+                       }
+
+                       value = Primitive::unbox(param);
+                       argument_vmarray_store_dbl(array, pd, value.l);
+                       break;
+               
+               case TYPE_ADR:
+                       if (!resolve_class_from_typedesc(td, true, true, &c))
+                               return NULL;
+
+                       if (param != NULL) {
+                               if (td->arraydim > 0) {
+                                       if (!builtin_arrayinstanceof(param, c))
+                                               return NULL;
+                               }
+                               else {
+                                       if (!builtin_instanceof(param, c))
+                                               return NULL;
+                               }
+                       }
+
+                       argument_vmarray_store_adr(array, pd, param);
+                       break;
+
+               default:
+                       os::abort("argument_vmarray_from_objectarray: invalid type %d", td->type);
+               }
+       }
+
+       return array;
+}
+
+
+/*
+ * 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/jit/argument.h b/src/vm/jit/argument.h
deleted file mode 100644 (file)
index 3c1c53c..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/* src/vm/jit/argument.h - argument passing from and to JIT methods
-
-   Copyright (C) 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
-
-   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 _VM_JIT_ARGUMENT_H
-#define _VM_JIT_ARGUMENT_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/global.h"
-
-
-/* function prototypes ********************************************************/
-
-imm_union argument_jitarray_load(methoddesc *md, int32_t index,
-                                                                uint64_t *arg_regs, uint64_t *stack);
-void      argument_jitarray_store(methoddesc *md, int32_t index,
-                                                                 uint64_t *arg_regs, uint64_t *stack,
-                                                                 imm_union param);
-
-imm_union argument_jitreturn_load(methoddesc *md, uint64_t *return_regs);
-void      argument_jitreturn_store(methoddesc *md, uint64_t *return_regs,
-                                                                  imm_union ret);
-
-uint64_t *argument_vmarray_from_valist(methodinfo *m, java_handle_t *o,
-                                                                          va_list ap);
-uint64_t *argument_vmarray_from_jvalue(methodinfo *m, java_handle_t *o,
-                                                                          const jvalue *args);
-uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
-                                                                                       java_handle_objectarray_t *params);
-
-#endif /* _VM_JIT_ARGUMENT_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/jit/argument.hpp b/src/vm/jit/argument.hpp
new file mode 100644 (file)
index 0000000..29c4136
--- /dev/null
@@ -0,0 +1,71 @@
+/* src/vm/jit/argument.hpp - argument passing from and to JIT methods
+
+   Copyright (C) 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 _VM_JIT_ARGUMENT_HPP
+#define _VM_JIT_ARGUMENT_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/global.h"
+#include "vm/method.hpp"
+
+
+/* function prototypes ********************************************************/
+
+imm_union argument_jitarray_load(methoddesc *md, int32_t index,
+                                                                uint64_t *arg_regs, uint64_t *stack);
+void      argument_jitarray_store(methoddesc *md, int32_t index,
+                                                                 uint64_t *arg_regs, uint64_t *stack,
+                                                                 imm_union param);
+
+imm_union argument_jitreturn_load(methoddesc *md, uint64_t *return_regs);
+void      argument_jitreturn_store(methoddesc *md, uint64_t *return_regs,
+                                                                  imm_union ret);
+
+uint64_t *argument_vmarray_from_valist(methodinfo *m, java_handle_t *o,
+                                                                          va_list ap);
+uint64_t *argument_vmarray_from_jvalue(methodinfo *m, java_handle_t *o,
+                                                                          const jvalue *args);
+uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
+                                                                                       java_handle_objectarray_t *params);
+
+#endif // _VM_JIT_ARGUMENT_HPP
+
+
+/*
+ * 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 5955ff12e0797bfd625b540da05f9c45f97af159..169c28ad96a410880f0a75c72e3acb86503b2580 100644 (file)
@@ -31,8 +31,8 @@ AM_CCASFLAGS = $(AM_CPPFLAGS)
 
 noinst_HEADERS = \
        arch.h \
-       machine-instr.h \
-       md-asm.h
+       md-asm.h \
+       md-atomic.hpp
 
 noinst_LTLIBRARIES = libarch.la
 
@@ -51,6 +51,7 @@ libarch_la_SOURCES = \
        \
        md-abi.c \
        md-abi.h \
+       md-stubs.hpp \
        md-trap.h \
        md.c \
        md.h
index a1175a355be9e7d26b6ff0eca08f7396311a97ea..b8bdeeb82146e6a32689ff012a7283426abb3067 100644 (file)
 #ifndef _ARCH_H
 #define _ARCH_H
 
+#define JIT_COMPILER_VIA_SIGNAL
+
 #include "config.h"
 
 
 /* define architecture features ***********************************************/
 
-#define U8_AVAILABLE                     1
-
 #define SUPPORT_DIVISION                 0
 #define SUPPORT_LONG                     1
 
index 88dfc8f74d3a3c2e503018aba1ae986ed98c4034..7786ab160be30e6a4ba9b07f8fa39a69393557a7 100644 (file)
@@ -47,8 +47,6 @@
        .globl asm_vm_call_method_exception_handler
        .globl asm_vm_call_method_end
 
-       .globl asm_call_jit_compiler
-
        .globl asm_handle_exception
        .globl asm_handle_nat_exception
 
@@ -78,8 +76,8 @@
 asm_vm_call_method:
 asm_vm_call_method_int:
 asm_vm_call_method_long:
-/* asm_vm_call_method_float:
-asm_vm_call_method_double: */
+asm_vm_call_method_float:
+asm_vm_call_method_double:
        SAVE_SCRATCH_REGISTERS            /* save our personal scratch regs   */
        stmfd sp!, {v1}                   /* V1 is used to remember SP        */
        str   a0, [sp, #-4]!              /* store methods entrypoint         */
@@ -134,66 +132,9 @@ asm_vm_call_method_exception_handler:
        ldmfd sp!, {v1}
        RESTORE_SCRATCH_REGS_AND_RETURN   /* return to caller, restore regs   */
 
-asm_vm_call_method_float:
-       mov a0,#0x51
-       b asm_debug
-asm_vm_call_method_double:
-       mov a0,#0x52
-       b asm_debug
-
 asm_vm_call_method_end:
 
 
-/****************** function asm_call_jit_compiler *****************************
-*                                                                              *
-*   Invokes the compiler for untranslated JavaVM methods.                      *
-*   What this method does:                                                     *
-*    - save args and LR                                                        *
-*    - fire up jit_compile (pass methodinfo pointer)                           *
-*    - try to find out where to write back the new method pointer              *
-*    - restore args and LR                                                     *
-*    - check for exceptions                                                    *
-*    - eventually write back new method pointer                                *
-*    - call jit code (wich will then return to caller)                         *
-*                                                                              *
-*   These methods can call us: codegen_compilerstub & asm_calljavafunction     *
-*   ATTENTION: use REG_ITMP1 to pass methodinfo pointer to me!                 *
-*                                                                              *
-*******************************************************************************/
-
-#define MYSTACKSIZE (6*4)
-
-asm_call_jit_compiler:
-       SAVE_ARGUMENT_REGISTERS             /* save our argument registers & LR   */
-       sub   sp, sp, #4                    /* keep stack 8-byte aligned          */
-
-       mov   a0, itmp1                     /* pass methodinfo pointer            */
-       mov   a1, mptr                      /* pass method pointer                */
-       add   a2, sp, #MYSTACKSIZE          /* pass Java sp                       */
-       mov   a3, lr                        /* pass Java RA (correct for leafs)   */
-       bl    jit_asm_compile
-       mov   itmp1, res1                   /* save pointer to new jit-code       */
-
-       tst   itmp1,itmp1                   /* check for exeption                 */
-       beq   L_asm_call_jit_compiler_exception
-
-       add   sp, sp, #4                    /* keep stack 8-byte aligned          */
-       RESTORE_ARGUMENT_REGISTERS          /* load our argument registers & LR   */
-
-       mov   ip, itmp1
-       mov   pc, ip                        /* call jit-code                      */
-
-L_asm_call_jit_compiler_exception:
-       bl    exceptions_get_and_clear_exception
-       mov   xptr, res1                    /* get exception                      */
-
-       add   sp, sp, #4                    /* keep stack 8-byte aligned          */
-       RESTORE_ARGUMENT_REGISTERS          /* load LR                            */
-
-       sub   xpc, lr, #4                   /* xpc = instruction that called us   */
-       b     asm_handle_nat_exception
-
-
 /********************* function asm_handle_exception ***************************
 *                                                                              *
 *   This function handles an exception. It does not use the usual calling      *
index 00a37a24206fb919ebe14e382dd6f2a6148977ae..4b86e510f050e22bf584c9850842b51fb17c4a26 100644 (file)
 
 #include "mm/memory.h"
 
-#include "native/localref.h"
-#include "native/native.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/vm.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/methodheader.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
 
 #if defined(ENABLE_LSRA)
 #include "vm/jit/allocator/lsra.h"
 #endif
 
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
 
 /* codegen_emit ****************************************************************
 
@@ -1014,7 +1013,12 @@ bool codegen_emit(jitdata *jd)
 
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+#if defined(__VFP_FP__)
+                       M_FMSR(s1, d);
+                       M_CVTIF(d, d);
+#else
                        M_CVTIF(s1, d);
+#endif
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -1022,7 +1026,12 @@ bool codegen_emit(jitdata *jd)
 
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+#if defined(__VFP_FP__)
+                       M_FMSR(s1, d);
+                       M_CVTID(d, d);
+#else
                        M_CVTID(s1, d);
+#endif
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -1030,9 +1039,12 @@ bool codegen_emit(jitdata *jd)
 
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+#if defined(__VFP_FP__)
+                       M_CVTFI(s1, REG_FTMP2);
+                       M_FMRS(REG_FTMP2, d);
+#else
                        /* this uses round towards zero, as Java likes it */
                        M_CVTFI(s1, d);
-#if !defined(__VFP_FP__)
                        /* this checks for NaN; to return zero as Java likes it */
                        M_FCMP(s1, 0x8);
                        M_MOVVS_IMM(0, d);
@@ -1044,9 +1056,12 @@ bool codegen_emit(jitdata *jd)
 
                        s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+#if defined(__VFP_FP__)
+                       M_CVTDI(s1, REG_FTMP2);
+                       M_FMRS(REG_FTMP2, d);
+#else
                        /* this uses round towards zero, as Java likes it */
                        M_CVTDI(s1, d);
-#if !defined(__VFP_FP__)
                        /* this checks for NaN; to return zero as Java likes it */
                        M_DCMP(s1, 0x8);
                        M_MOVVS_IMM(0, d);
@@ -2402,9 +2417,6 @@ bool codegen_emit(jitdata *jd)
                                superindex = super->index;
                        }
 
-                               if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                                       CODEGEN_CRITICAL_SECTION_NEW;
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                        /* if class is not resolved, check which code to call */
@@ -2508,16 +2520,12 @@ bool codegen_emit(jitdata *jd)
                                M_LDR_INTERN(REG_ITMP2, s1, OFFSET(java_object_t, vftbl));
                                M_DSEG_LOAD(REG_ITMP3, disp);
 
-                               CODEGEN_CRITICAL_SECTION_START;
-
                                M_LDR_INTERN(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                M_LDR_INTERN(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, baseval));
                                M_SUB(REG_ITMP2, REG_ITMP2, REG_ITMP3);
                                M_DSEG_LOAD(REG_ITMP3, disp);
                                M_LDR_INTERN(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval));
 
-                               CODEGEN_CRITICAL_SECTION_END;
-
                                M_CMP(REG_ITMP2, REG_ITMP3);
                                emit_classcast_check(cd, iptr, BRANCH_UGT, 0, s1);
 
@@ -2582,9 +2590,6 @@ bool codegen_emit(jitdata *jd)
                                superindex = super->index;
                        }
 
-                       if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                               CODEGEN_CRITICAL_SECTION_NEW;
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
@@ -2707,14 +2712,10 @@ bool codegen_emit(jitdata *jd)
                                M_LDR_INTERN(REG_ITMP1, s1, OFFSET(java_object_t, vftbl));
                                M_DSEG_LOAD(REG_ITMP2, disp);
 
-                               CODEGEN_CRITICAL_SECTION_START;
-
                                M_LDR_INTERN(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                M_LDR_INTERN(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                M_LDR_INTERN(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 
-                               CODEGEN_CRITICAL_SECTION_END;
-
                                M_SUB(REG_ITMP1, REG_ITMP1, REG_ITMP3);
                                M_CMP(REG_ITMP1, REG_ITMP2);
                                /* If d == REG_ITMP2, then it's destroyed */
@@ -2825,29 +2826,6 @@ bool codegen_emit(jitdata *jd)
 }
 
 
-/* codegen_emit_stub_compiler **************************************************
-
-   Emits a stub routine which calls the compiler.
-       
-*******************************************************************************/
-
-void codegen_emit_stub_compiler(jitdata *jd)
-{
-       methodinfo  *m;
-       codegendata *cd;
-
-       /* get required compiler data */
-
-       m  = jd->m;
-       cd = jd->cd;
-
-       /* code for the stub */
-
-       M_LDR_INTERN(REG_ITMP1, REG_PC, -(2 * 4 + 2 * SIZEOF_VOID_P));
-       M_LDR_INTERN(REG_PC, REG_PC, -(3 * 4 + 3 * SIZEOF_VOID_P));
-}
-
-
 /* codegen_emit_stub_native ****************************************************
 
    Emits a stub routine which calls a native method.
@@ -3001,7 +2979,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
                /* put env into first argument register */
 
-               disp = dseg_add_address(cd, _Jv_env);
+               disp = dseg_add_address(cd, VM_get_jnienv());
                M_DSEG_LOAD(REG_A0, disp);
        }
 
index fc7dee7e3af79d52e7dba065e6ef728e7e374883..b57d26cb229286f0579dfb68d3ef4954699715c5 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/arm/codegen.h - code generation macros and definitions for ARM
 
-   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.
 
     } while (0)
 
 
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE    2 * 4
-
-
 /* lazy debugger **************************************************************/
 
 #if !defined(NDEBUG)
@@ -650,6 +643,7 @@ void asm_debug_intern(int a1, int a2, int a3, int a4);
 #if !defined(ENABLE_SOFTFLOAT)
 
 #if defined(__VFP_FP__)
+
 #define M_FADD(a,b,d)      M_CPDP(UNCOND,0,1,1,0,10,0,0,0,d,a,b)/* d = a +  b */
 #define M_FSUB(a,b,d)      M_CPDP(UNCOND,0,1,1,1,10,0,0,0,d,a,b)/* d = a -  b */
 #define M_FMUL(a,b,d)      M_CPDP(UNCOND,0,1,0,0,10,0,0,0,d,a,b)/* d = a *  b */
@@ -671,8 +665,8 @@ void asm_debug_intern(int a1, int a2, int a3, int a4);
 #define M_CVTFD(a,d)       M_CPDP(UNCOND,1,1,1,1,10,0,1,0,d,0x7,a)
 #define M_CVTIF(a,d)       M_CPDP(UNCOND,1,1,1,1,10,0,1,0,d,0x8,a)
 #define M_CVTID(a,d)       M_CPDP(UNCOND,1,1,1,1,11,0,1,0,d,0x8,a)
-#define M_CVTFI(a,d)       M_CPDP(UNCOND,1,1,1,1,10,0,1,0,d,0xc,a)
-#define M_CVTDI(a,d)       M_CPDP(UNCOND,1,1,1,1,11,0,1,0,d,0xc,a)
+#define M_CVTFI(a,d)       M_CPDP(UNCOND,1,1,1,1,10,0,1,0,d,0xd,a) // ftosis
+#define M_CVTDI(a,d)       M_CPDP(UNCOND,1,1,1,1,11,0,1,0,d,0xd,a) // ftosid
 
 #define M_FMSTAT           M_CPRT(UNCOND,0x07,1,10,0,0x1,0xf)
 
@@ -682,7 +676,9 @@ void asm_debug_intern(int a1, int a2, int a3, int a4);
 #define M_FMRDL(Fa,b)      M_CPRT(UNCOND,0x00,1,11,0,Fa,b)
 #define M_FMDHR(a,Fb)      M_CPRT(UNCOND,0x01,0,11,0,Fb,a)
 #define M_FMRDH(Fa,b)      M_CPRT(UNCOND,0x01,1,11,0,Fa,b)
+
 #else
+
 #define M_FADD(a,b,d)      M_CPDOS(UNCOND,0x00,0,d,a,b)         /* d = a +  b */
 #define M_FSUB(a,b,d)      M_CPDOS(UNCOND,0x02,0,d,a,b)         /* d = a -  b */
 #define M_FMUL(a,b,d)      M_CPDOS(UNCOND,0x01,0,d,a,b)         /* d = a *  b */
@@ -708,6 +704,7 @@ void asm_debug_intern(int a1, int a2, int a3, int a4);
 #define M_CVTID(a,d)       M_CPRTD(UNCOND,0,a,d,0)              /* d = (float) a */
 #define M_CVTFI(a,d)       M_CPRTI(UNCOND,1,d,0,a)              /* d = (int)   a */
 #define M_CVTDI(a,d)       M_CPRTI(UNCOND,1,d,0,a)              /* d = (int)   a */
+
 #endif
 
 
@@ -1103,15 +1100,22 @@ do { \
 /* M_RECOMPUTE_PV:
    used to recompute our PV (we use the IP for this) out of the current PC
    ATTENTION: if you change this, you have to look at other functions as well!
-   Following things depend on it: asm_call_jit_compiler(); codegen_findmethod();
+   Following things depend on it: md_codegen_get_pv_from_pc();
 */
 #define M_RECOMPUTE_PV(disp) \
        disp += 8; /* we use PC relative addr.  */ \
        assert((disp & 0x03) == 0); \
        assert(disp >= 0 && disp <= 0x03ffffff); \
-       M_SUB_IMM(REG_PV, REG_PC, IMM_ROTL(disp >> 2, 1)); \
-       if (disp > 0x000003ff) M_SUB_IMM(REG_PV, REG_PV, IMM_ROTL(disp >> 10, 5)); \
-       if (disp > 0x0003ffff) M_SUB_IMM(REG_PV, REG_PV, IMM_ROTL(disp >> 18, 9)); \
+       if (disp > 0x0003ffff) { \
+               M_SUB_IMM(REG_PV, REG_PC, IMM_ROTL(disp >> 18, 9)); \
+               M_SUB_IMM(REG_PV, REG_PV, IMM_ROTL(disp >> 10, 5)); \
+               M_SUB_IMM(REG_PV, REG_PV, IMM_ROTL(disp >> 2, 1)); \
+       } else if (disp > 0x000003ff) { \
+               M_SUB_IMM(REG_PV, REG_PC, IMM_ROTL(disp >> 10, 5)); \
+               M_SUB_IMM(REG_PV, REG_PV, IMM_ROTL(disp >> 2, 1)); \
+       } else { \
+               M_SUB_IMM(REG_PV, REG_PC, IMM_ROTL(disp >> 2, 1)); \
+       }
 
 /* M_INTMOVE:
    generates an integer-move from register a to b.
index 293731cfc473c70f509f46f2cbaf1f5fe3e475f9..a30de77364a166ce0da50c490da268a9341e4e6c 100644 (file)
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/exceptions.h"
 #include "vm/global.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/trace.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
 
 #include "toolbox/logging.h" /* XXX for debugging only */
@@ -574,6 +573,18 @@ void emit_exception_check(codegendata *cd, instruction *iptr)
 }
 
 
+/* emit_trap_compiler **********************************************************
+
+   Emit a trap instruction which calls the JIT compiler.
+
+*******************************************************************************/
+
+void emit_trap_compiler(codegendata *cd)
+{
+       M_TRAP(REG_METHODPTR, TRAP_COMPILER);
+}
+
+
 /* emit_trap *******************************************************************
 
    Emit a trap instruction and return the original machine code.
index 37aaabcdc46f8a151b9b4a7624faf3e6873825fd..1b1142e5a39b7f94a3f30881bfc6f5b182c8d5d8 100644 (file)
@@ -2,6 +2,7 @@
 
    Copyright (C) 1996-2005, 2006, 2007, 2008
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
 
    This file is part of CACAO.
 
 
 #include <stdint.h>
 
-#include "vm/types.h"
-
-#include "vm/jit/disass.h"
-
-#include "vm/jit/arm/md-abi.h"
-
 #define ucontext broken_glibc_ucontext
 #define ucontext_t broken_glibc_ucontext_t
 #include <ucontext.h>
@@ -49,16 +44,21 @@ typedef struct ucontext {
 
 #define scontext_t struct sigcontext
 
-#include "threads/thread.h"
+#include "vm/types.h"
+
+#include "vm/jit/arm/md.h"
+#include "vm/jit/arm/md-abi.h"
+
+#include "threads/thread.hpp"
 
-#include "vm/exceptions.h"
+#include "vm/os.hpp"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
+#include "vm/jit/disass.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/trap.h"
 
 
@@ -80,7 +80,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        intptr_t        addr;
        int             type;
        intptr_t        val;
-       void           *p;
 
        _uc = (ucontext_t*) _p;
        _sc = &_uc->uc_mcontext;
@@ -108,13 +107,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* set registers */
-
-       _sc->arm_r10 = (uintptr_t) p;
-       _sc->arm_fp  = (uintptr_t) xpc;
-       _sc->arm_pc  = (uintptr_t) asm_handle_exception;
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -126,57 +119,50 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
 void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
 {
-       ucontext_t     *_uc;
-       scontext_t     *_sc;
-       u1             *pv;
-       u1             *sp;
-       u1             *ra;
-       u1             *xpc;
-       u4              mcode;
-       int             type;
-       intptr_t        val;
-       void           *p;
-
-       _uc = (ucontext_t*) _p;
-       _sc = &_uc->uc_mcontext;
+       ucontext_t* _uc = (ucontext_t*) _p;
+       scontext_t* _sc = &_uc->uc_mcontext;
 
        /* ATTENTION: glibc included messed up kernel headers we needed a
           workaround for the ucontext structure. */
 
-       pv  = (u1 *) _sc->arm_ip;
-       sp  = (u1 *) _sc->arm_sp;
-       ra  = (u1 *) _sc->arm_lr;                    /* this is correct for leafs */
-       xpc = (u1 *) _sc->arm_pc;
-
-       /* get exception-throwing instruction */
-
-       mcode = *((u4 *) xpc);
-
-       /* check for undefined instruction we use */
-
-       if ((mcode & 0x0ff000f0) != 0x07f000f0) {
-               log_println("md_signal_handler_sigill: unknown illegal instruction: inst=%x", mcode);
+       void* pv  = (void*) _sc->arm_ip;
+       void* sp  = (void*) _sc->arm_sp;
+       void* ra  = (void*) _sc->arm_lr; // The RA is correct for leaf methods.
+       void* xpc = (void*) _sc->arm_pc;
+
+       // Get the exception-throwing instruction.
+       uint32_t mcode = *((uint32_t*) xpc);
+
+       // Check if the trap instruction is valid.
+       // TODO Move this into patcher_handler.
+       if (patcher_is_valid_trap_instruction_at(xpc) == false) {
+               // Check if the PC has been patched during our way to this
+               // signal handler (see PR85).
+               // NOTE: ARM uses SIGILL for other traps too, but it's OK to
+               // do this check anyway because it will fail.
+               if (patcher_is_patched_at(xpc) == true)
+                       return;
+
+               // We have a problem...
+               log_println("md_signal_handler_sigill: Unknown illegal instruction 0x%x at 0x%x", mcode, xpc);
 #if defined(ENABLE_DISASSEMBLER)
-               DISASSINSTR(xpc);
+               (void) disassinstr(xpc);
 #endif
                vm_abort("Aborting...");
        }
 
-       type = (mcode >> 8) & 0x0fff;
-       val  = *((s4 *) _sc + OFFSET(scontext_t, arm_r0)/4 + (mcode & 0x0f));
-
-       /* Handle the trap. */
-
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
+       int      type = (mcode >> 8) & 0x0fff;
+       intptr_t val  = *((int32_t*) _sc + OFFSET(scontext_t, arm_r0)/4 + (mcode & 0x0f));
 
-       /* set registers if we have an exception, continue execution
-          otherwise (this is needed for patchers to work) */
+       if (type == TRAP_COMPILER) {
+               /* The XPC is the RA minus 4, because the RA points to the
+                  instruction after the call. */
 
-       if (p != NULL) {
-               _sc->arm_r10 = (uintptr_t) p;
-               _sc->arm_fp  = (uintptr_t) xpc;
-               _sc->arm_pc  = (uintptr_t) asm_handle_exception;
+               xpc = (void*) (((uintptr_t) ra) - 4);
        }
+
+       // Handle the trap.
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -241,33 +227,32 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
  */
 void md_executionstate_read(executionstate_t *es, void *context)
 {
-       vm_abort("md_executionstate_read: IMPLEMENT ME!");
-
-#if 0
        ucontext_t *_uc;
-       mcontext_t *_mc;
+       scontext_t *_sc;
        int         i;
 
        _uc = (ucontext_t *) context;
-       _mc = &_uc->uc_mcontext;
+       _sc = &_uc->uc_mcontext;
+
+       /* ATTENTION: glibc included messed up kernel headers we needed a
+          workaround for the ucontext structure. */
 
        /* read special registers */
-       es->pc = (u1 *) _mc->sc_pc;
-       es->sp = (u1 *) _mc->sc_regs[REG_SP];
-       es->pv = (u1 *) _mc->sc_regs[REG_PV];
-       es->ra = (u1 *) _mc->sc_regs[REG_RA];
+
+       es->pc = (u1 *) _sc->arm_pc;
+       es->sp = (u1 *) _sc->arm_sp;
+       es->pv = (u1 *) _sc->arm_ip;
+       es->ra = (u1 *) _sc->arm_lr;
 
        /* read integer registers */
+
        for (i = 0; i < INT_REG_CNT; i++)
-               es->intregs[i] = _mc->sc_regs[i];
+               es->intregs[i] = *((int32_t*) _sc + OFFSET(scontext_t, arm_r0)/4 + i);
 
        /* read float registers */
-       /* Do not use the assignment operator '=', as the type of
-        * the _mc->sc_fpregs[i] can cause invalid conversions. */
 
-       assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs));
-       system_memcpy(&es->fltregs, &_mc->sc_fpregs, sizeof(_mc->sc_fpregs));
-#endif
+       for (i = 0; i < FLT_REG_CNT; i++)
+               es->fltregs[i] = 0xdeadbeefdeadbeefULL;
 }
 
 
@@ -279,60 +264,28 @@ void md_executionstate_read(executionstate_t *es, void *context)
  */
 void md_executionstate_write(executionstate_t *es, void *context)
 {
-       vm_abort("md_executionstate_write: IMPLEMENT ME!");
-
-#if 0
        ucontext_t *_uc;
-       mcontext_t *_mc;
+       scontext_t *_sc;
        int         i;
 
        _uc = (ucontext_t *) context;
-       _mc = &_uc->uc_mcontext;
+       _sc = &_uc->uc_mcontext;
 
-       /* write integer registers */
-       for (i = 0; i < INT_REG_CNT; i++)
-               _mc->sc_regs[i] = es->intregs[i];
+       /* ATTENTION: glibc included messed up kernel headers we needed a
+          workaround for the ucontext structure. */
 
-       /* write float registers */
-       /* Do not use the assignment operator '=', as the type of
-        * the _mc->sc_fpregs[i] can cause invalid conversions. */
+       /* write integer registers */
 
-       assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs));
-       system_memcpy(&_mc->sc_fpregs, &es->fltregs, sizeof(_mc->sc_fpregs));
+       for (i = 0; i < INT_REG_CNT; i++)
+               *((int32_t*) _sc + OFFSET(scontext_t, arm_r0)/4 + i) = es->intregs[i];
 
        /* write special registers */
-       _mc->sc_pc           = (ptrint) es->pc;
-       _mc->sc_regs[REG_SP] = (ptrint) es->sp;
-       _mc->sc_regs[REG_PV] = (ptrint) es->pv;
-       _mc->sc_regs[REG_RA] = (ptrint) es->ra;
-#endif
-}
-
-
-/* md_critical_section_restart *************************************************
-
-   Search the critical sections tree for a matching section and set
-   the PC to the restart point, if necessary.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
-{
-       scontext_t *_sc;
-       u1         *pc;
-       u1         *npc;
-
-       _sc = &_uc->uc_mcontext;
 
-       pc = (u1 *) _sc->arm_pc;
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL)
-               _sc->arm_pc = (ptrint) npc;
+       _sc->arm_pc = (ptrint) es->pc;
+       _sc->arm_sp = (ptrint) es->sp;
+       _sc->arm_ip = (ptrint) es->pv;
+       _sc->arm_lr = (ptrint) es->ra;
 }
-#endif
 
 
 /*
diff --git a/src/vm/jit/arm/machine-instr.h b/src/vm/jit/arm/machine-instr.h
deleted file mode 100644 (file)
index 82fba29..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef _MACHINE_INSTR_H
-#define _MACHINE_INSTR_H
-
-static inline long compare_and_swap(long *p, long oldval, long newval)
-{
-       long ret, temp;
-       /*dolog("compare_and_swap(%p [%d], %d, %d)", p, *p, oldval, newval);*/
-
-       /* TODO: improve this one! */
-       __asm__ __volatile__ (
-               "1:\t"
-               "ldr   %0,[%2]\n\t"
-               "cmp   %0,%4\n\t"
-               "bne   2f\n\t"
-               "swp   %1,%3,[%2]\n\t"
-               "cmp   %1,%0\n\t"
-               "swpne %0,%1,[%2]\n\t"
-               "bne   1b\n\t"
-               "2:"
-               : "=&r" (ret), "=&r" (temp)
-               : "r" (p), "r" (newval), "r" (oldval)
-               : "cc", "memory"
-       );
-
-       /*dolog("compare_and_swap() return=%d mem=%d", ret, *p);*/
-       return ret;
-}
-
-#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory");
-#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("" : : : "memory");
-#define MEMORY_BARRIER() __asm__ __volatile__ ("" : : : "memory" );
-
-#endif
index b10d45665a84181304360d564ac1b6afadb580eb..bdf6a14f918d2debb0234f7a15315cfef23a0531 100644 (file)
 
 #include "vm/jit/arm/md-abi.h"
 
+#include "vm/descriptor.h"
 #include "vm/global.h"
 
 #include "vm/jit/abi.h"
 
-#include "vmcore/descriptor.h"
-
 
 /* register descripton array **************************************************/
 
diff --git a/src/vm/jit/arm/md-atomic.hpp b/src/vm/jit/arm/md-atomic.hpp
new file mode 100644 (file)
index 0000000..81f0a39
--- /dev/null
@@ -0,0 +1,141 @@
+/* src/vm/jit/arm/atomic.hpp - ARM atomic instructions
+
+   Copyright (C) 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 _MD_ATOMIC_HPP
+#define _MD_ATOMIC_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "threads/atomic.hpp"
+
+
+/**
+ * An atomic compare and swap for 32-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
+{
+       uint32_t result;
+       uint32_t temp;
+
+       /* TODO: improve this one! */
+       __asm__ __volatile__ (
+               "1:\t"
+               "ldr   %0,[%2]\n\t"
+               "cmp   %0,%4\n\t"
+               "bne   2f\n\t"
+               "swp   %1,%3,[%2]\n\t"
+               "cmp   %1,%0\n\t"
+               "swpne %0,%1,[%2]\n\t"
+               "bne   1b\n\t"
+               "2:"
+               : "=&r" (result), "=&r" (temp)
+               : "r" (p), "r" (newval), "r" (oldval)
+               : "cc", "memory"
+       );
+
+       return result;
+}
+
+
+/**
+ * An atomic compare and swap for 64-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
+{
+       return generic_compare_and_swap(p, oldval, newval);
+}
+
+
+/**
+ * An atomic compare and swap for pointer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval)
+{
+       return (void*) compare_and_swap((volatile uint32_t*) p, (uint32_t) oldval, (uint32_t) newval);
+}
+
+
+/**
+ * A memory barrier.
+ */
+inline void Atomic::memory_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+
+/**
+ * A write memory barrier.
+ */
+inline void Atomic::write_memory_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+
+/**
+ * An instruction barrier.
+ */
+inline void Atomic::instruction_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+#endif // _MD_ATOMIC_HPP
+
+
+/*
+ * 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/jit/arm/md-stubs.hpp b/src/vm/jit/arm/md-stubs.hpp
new file mode 100644 (file)
index 0000000..1fb1147
--- /dev/null
@@ -0,0 +1,56 @@
+/* src/vm/jit/arm/md-stubs.hpp - ARM JIT stubs
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on an ARM architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+       return 2 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * 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 7992441b2e9be6a00aa414c8279b6f13c212e267..c94a8f73c553e4a6a0826b429c13d6e9a6ba4113 100644 (file)
@@ -50,7 +50,8 @@ enum {
        TRAP_ClassCastException             = 5,
        TRAP_CHECK_EXCEPTION                = 6,
        TRAP_PATCHER                        = 7,
-       TRAP_COMPILER                       = 8
+       TRAP_COMPILER                       = 8,
+       TRAP_COUNTDOWN                      = 9
 };
 
 #endif /* _MD_TRAP_H */
index d37b3a710cee1487c052c05e0b45191d0932b519..b150f1a14831499f59267ff14222b67708e1627d 100644 (file)
@@ -1,9 +1,7 @@
-/* src/vm/jit/arm/md.c - machine dependent Arm functions
+/* src/vm/jit/arm/md.c - machine dependent ARM functions
 
-   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.
 
@@ -138,6 +136,17 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
 }
 
 
+/**
+ * Patch the given replacement point.
+ */
+#if defined(ENABLE_REPLACEMENT)
+void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert)
+{
+       vm_abort("md_patch_replacement_point: IMPLEMENT ME!");
+}
+#endif
+
+
 /*
  * 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
index 04774df4e7d4ee3a35702442474ba72d8ba59163..9ce156470118f432c10e3919b93da57270615ef0 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/arm/md.h - machine dependent Arm functions
 
-   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.
 
@@ -36,7 +34,7 @@
 #include "vm/types.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* md_stacktrace_get_returnaddress *********************************************
@@ -66,32 +64,42 @@ inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframe
 
 *******************************************************************************/
 
-inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
+inline static void* md_codegen_get_pv_from_pc(void* ra)
 {
-       u1 *pv;
-       u4  mcode1, mcode2, mcode3;
+       uint32_t* pc;
+       uintptr_t pv;
+       uint32_t mcode;
+       int mcode_idx;
 
-       pv = ra;
+       pc = (uint32_t*) ra;
+       pv = (uintptr_t) ra;
 
        /* this can either be a RECOMPUTE_IP in JIT code or a fake in asm_calljavafunction */
-       mcode1 = *((u4*) ra);
-       if ((mcode1 & 0xffffff00) == 0xe24fcf00 /*sub ip,pc,#__*/)
-               pv -= (s4) ((mcode1 & 0x000000ff) <<  2);
-       else if ((mcode1 & 0xffffff00) == 0xe24fc000 /*sub ip,pc,#__*/)
-               pv -= (s4) (mcode1 & 0x000000ff);
+       mcode_idx = 0;
+       mcode = pc[0];
+
+       /* if this was shifted by 18 bits, we have to load additional instructions */
+       if ((mcode & 0xfff0ff00) == 0xe240c700 /*sub ip,??,#__*/) {
+               pv -= (uintptr_t) ((mcode & 0x000000ff) << 18);
+               mcode = pc[++mcode_idx];
+       }
+
+       /* if this was shifted by 10 bits, we have to load additional instructions */
+       if ((mcode & 0xfff0ff00) == 0xe240cb00 /*sub ip,??,#__*/) {
+               pv -= (uintptr_t) ((mcode & 0x000000ff) << 10);
+               mcode = pc[++mcode_idx];
+       }
+
+       /* this is the default path with just one instruction, shifted by 2 or no bits */
+       if ((mcode & 0xfff0ff00) == 0xe240cf00 /*sub ip,??,#__*/)
+               pv -= (uintptr_t) ((mcode & 0x000000ff) << 2);
+       else if ((mcode & 0xffffff00) == 0xe24fc000 /*sub ip,pc,#__*/)
+               pv -= (uintptr_t) (mcode & 0x000000ff);
        else {
                /* if this happens, we got an unexpected instruction at (*ra) */
-               vm_abort("Unable to find method: %p (instr=%x)", ra, mcode1);
+               vm_abort("Unable to find method: %p (instr=%x)", ra, mcode);
        }
 
-       /* if we have a RECOMPUTE_IP there can be more than one instruction */
-       mcode2 = *((u4*) (ra + 4));
-       mcode3 = *((u4*) (ra + 8));
-       if ((mcode2 & 0xffffff00) == 0xe24ccb00 /*sub ip,ip,#__*/)
-               pv -= (s4) ((mcode2 & 0x000000ff) << 10);
-       if ((mcode3 & 0xffffff00) == 0xe24cc700 /*sub ip,ip,#__*/)
-               pv -= (s4) ((mcode3 & 0x000000ff) << 18);
-
        /* we used PC-relative adressing; but now it is LR-relative */
        pv += 8;
 
@@ -99,7 +107,7 @@ inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
        /* we check this by looking up the IsLeaf field, which has to be boolean */
 /*     assert( *((s4*)pv-8) == (s4)true || *((s4*)pv-8) == (s4)false );  */
 
-       return pv;
+       return (void*) pv;
 }
 
 
index 84e8287c502cb4a1b5f509a1e77f70daa1462aef..36f0adfc328d561a9f6fbfa6b313d002f982011b 100644 (file)
@@ -2,6 +2,7 @@
 
    Copyright (C) 1996-2005, 2006, 2007, 2008
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
 
    This file is part of CACAO.
 
 
 #include "mm/memory.h"
 
-#include "native/native.h"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/patcher-common.hpp"
 
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vmcore/references.h"
-#include "vm/resolve.h"
-
-
-#define PATCH_BACK_ORIGINAL_MCODE \
-    *((u4 *) pr->mpc) = (u4) pr->mcode; \
-    md_icacheflush((u1 *) pr->mpc, 1 * 4);
 
 #define gen_resolveload(inst,offset) \
        assert((offset) >= -0x0fff && (offset) <= 0x0fff); \
 
 void patcher_patch_code(patchref_t *pr)
 {
-       PATCH_BACK_ORIGINAL_MCODE;
+    *((uint32_t*) pr->mpc) = (uint32_t) pr->mcode;
+    md_icacheflush((void*) pr->mpc, 1 * 4);
+}
+
+
+/**
+ * Check if the trap instruction at the given PC is valid.
+ *
+ * @param pc Program counter.
+ *
+ * @return true if valid, false otherwise.
+ */
+bool patcher_is_valid_trap_instruction_at(void* pc)
+{
+       uint32_t mcode = *((uint32_t*) pc);
+
+       // Check for the undefined instruction we use.
+       if ((mcode & 0x0ff000f0) != 0x07f000f0) {
+               return false;
+       }
+
+       return true;
 }
 
 
@@ -88,31 +105,25 @@ void patcher_patch_code(patchref_t *pr)
 
 bool patcher_get_putstatic(patchref_t *pr)
 {
-       unresolved_field *uf;
-       u1               *datap;
-       fieldinfo        *fi;
+       unresolved_field* uf    = (unresolved_field *) pr->ref;
+       uintptr_t*        datap = (uintptr_t*)         pr->datap;
 
-       /* get stuff from the stack */
+       // Resolve the field.
+       fieldinfo* fi = resolve_field_eager(uf);
 
-       uf    = (unresolved_field *) pr->ref;
-       datap = (u1 *)               pr->datap;
-
-       /* get the fieldinfo */
-
-       if (!(fi = resolve_field_eager(uf)))
+       if (fi == NULL)
                return false;
 
-       /* check if the field's class is initialized */
-
+       // Check if the field's class is initialized.
        if (!(fi->clazz->state & CLASS_INITIALIZED))
                if (!initialize_class(fi->clazz))
                        return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
+       // Patch the field value's address.
+       *datap = (uintptr_t) fi->value;
 
-       /* patch the field value's address */
-
-       *((intptr_t *) datap) = (intptr_t) fi->value;
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -129,29 +140,16 @@ bool patcher_get_putstatic(patchref_t *pr)
 
 bool patcher_get_putfield(patchref_t *pr)
 {
-       u1                *ra;
-       u4                 mcode;
-       unresolved_field  *uf;
-       fieldinfo         *fi;
-
-       /* get stuff from the stack */
-       ra    = (u1*)                 pr->mpc;
-       mcode =                       pr->mcode;
-       uf    = (unresolved_field*)   pr->ref;
+       uint32_t*         pc = (uint32_t*)         pr->mpc;
+       unresolved_field* uf = (unresolved_field*) pr->ref;
 
-       /* get the fieldinfo */
+       // Resolve the field.
+       fieldinfo* fi = resolve_field_eager(uf);
 
-       if (!(fi = resolve_field_eager(uf)))
+       if (fi == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop */
-
-       if (opt_shownops)
-               ra = ra + 1 * 4;
-
-       /* patch the field's offset into the instruction */
+       // Patch the field's offset into the instruction.
 
        switch(fi->type) {
        case TYPE_ADR:
@@ -160,7 +158,7 @@ bool patcher_get_putfield(patchref_t *pr)
        case TYPE_FLT:
 #endif
                assert(fi->offset <= 0x0fff);
-               *((u4 *) (ra + 0 * 4)) |= (fi->offset & 0x0fff);
+               pr->mcode |= (fi->offset & 0x0fff);
                break;
 
        case TYPE_LNG:
@@ -168,23 +166,25 @@ bool patcher_get_putfield(patchref_t *pr)
        case TYPE_DBL:
 #endif
                assert((fi->offset + 4) <= 0x0fff);
-               *((u4 *) (ra + 0 * 4)) |= ((fi->offset + 0) & 0x0fff);
-               *((u4 *) (ra + 1 * 4)) &= 0xfffff000;
-               *((u4 *) (ra + 1 * 4)) |= ((fi->offset + 4) & 0x0fff);
+               pr->mcode |= ((fi->offset + 0) & 0x0fff);
+               pc[1] &= 0xfffff000;
+               pc[1] |= ((fi->offset + 4) & 0x0fff);
                break;
 
 #if !defined(ENABLE_SOFTFLOAT)
        case TYPE_FLT:
        case TYPE_DBL:
                assert(fi->offset <= 0x03ff);
-               *((u4 *) (ra + 0 * 4)) |= ((fi->offset >> 2) & 0x00ff);
+               pr->mcode |= ((fi->offset >> 2) & 0x00ff);
                break;
 #endif
        }
 
-       /* synchronize instruction cache */
+       // Synchronize instruction cache.
+       md_icacheflush(pc, 2 * 4);
 
-       md_icacheflush(ra, 2 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -217,25 +217,20 @@ bool patcher_get_putfield(patchref_t *pr)
 
 bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
 {
-       constant_classref *cr;
-       u1                *datap;
-       classinfo         *c;
-
-       /* get stuff from the stack */
+       constant_classref* cr    = (constant_classref *) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)          pr->datap;
 
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       /* get the classinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch the classinfo pointer */
+       // Patch the classinfo pointer.
+       *datap = (uintptr_t) c;
 
-       *((ptrint *) datap) = (ptrint) c;
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -254,25 +249,20 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
 
 bool patcher_invokestatic_special(patchref_t *pr)
 {
-       unresolved_method *um;
-       u1                *datap;
-       methodinfo        *m;
-
-       /* get stuff from the stack */
+       unresolved_method* um    = (unresolved_method*) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)         pr->datap;
 
-       um    = (unresolved_method*) pr->ref;
-       datap = (u1 *)               pr->datap;
+       // Reolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       /* get the methodinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch stubroutine */
+       // Patch stubroutine.
+       *datap = (uintptr_t) m->stubroutine;
 
-       *((ptrint *) datap) = (ptrint) m->stubroutine;
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -292,34 +282,23 @@ bool patcher_invokestatic_special(patchref_t *pr)
 
 bool patcher_invokevirtual(patchref_t *pr)
 {
-       u1                *ra;
-       unresolved_method *um;
-       methodinfo        *m;
-
-       /* get stuff from the stack */
+       uint32_t*          pc = (uint32_t*)           pr->mpc;
+       unresolved_method* um = (unresolved_method *) pr->ref;
 
-       ra = (u1 *)                pr->mpc;
-       um = (unresolved_method *) pr->ref;
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       /* get the methodinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop */
-
-       if (opt_shownops)
-               ra = ra + 1 * 4;
+       // Patch vftbl index.
+       gen_resolveload(pc[1], (int32_t) (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex));
 
-       /* patch vftbl index */
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 1, 1 * 4);
 
-       gen_resolveload(*((s4 *) (ra + 1 * 4)), (s4) (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex));
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra + 1 * 4, 1 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -341,38 +320,26 @@ bool patcher_invokevirtual(patchref_t *pr)
 
 bool patcher_invokeinterface(patchref_t *pr)
 {
-       u1                *ra;
-       unresolved_method *um;
-       methodinfo        *m;
-
-       /* get stuff from the stack */
+       uint32_t*          pc = (uint32_t*)           pr->mpc;
+       unresolved_method* um = (unresolved_method *) pr->ref;
 
-       ra = (u1 *)                pr->mpc;
-       um = (unresolved_method *) pr->ref;
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       /* get the methodinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop */
-
-       if (opt_shownops)
-               ra = ra + 1 * 4;
+       // Patch interfacetable index.
+       gen_resolveload(pc[1], (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr*) * m->clazz->index));
 
-       /* patch interfacetable index */
+       // Patch method offset.
+       gen_resolveload(pc[2], (int32_t) (sizeof(methodptr) * (m - m->clazz->methods)));
 
-       gen_resolveload(*((s4 *) (ra + 1 * 4)), (s4) (OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr*) * m->clazz->index));
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 1, 2 * 4);
 
-       /* patch method offset */
-
-       gen_resolveload(*((s4 *) (ra + 2 * 4)), (s4) (sizeof(methodptr) * (m - m->clazz->methods)));
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra + 1 * 4, 2 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -388,25 +355,20 @@ bool patcher_invokeinterface(patchref_t *pr)
 
 bool patcher_resolve_classref_to_flags(patchref_t *pr)
 {
-       constant_classref *cr;
-       u1                *datap;
-       classinfo         *c;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       int32_t*           datap = (int32_t*)           pr->datap;
 
-       /* get stuff from the stack */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
-
-       /* get the classinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch class flags */
+       // Patch class flags.
+       *datap = (int32_t) c->flags;
 
-       *((s4 *) datap) = (s4) c->flags;
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -422,25 +384,20 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr)
 
 bool patcher_resolve_classref_to_index(patchref_t *pr)
 {
-       constant_classref *cr;
-       u1                *datap;
-       classinfo         *c;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       int32_t*           datap = (int32_t*)           pr->datap;
 
-       /* get stuff from the stack */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
-
-       /* get the classinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch super class index */
+       // Patch super class index.
+       *datap = (int32_t) c->index;
 
-       *((s4 *) datap) = (s4) c->index;
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -456,25 +413,21 @@ bool patcher_resolve_classref_to_index(patchref_t *pr)
 
 bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
 {
-       constant_classref *cr;
-       u1                *datap;
-       classinfo         *c;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)         pr->datap;
 
-       /* get stuff from the stack */
+       // Resolve the class.
 
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
+       classinfo* c = resolve_classref_eager(cr);
 
-       /* get the classinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch super class' vftbl */
+       // Patch super class' vftbl.
+       *datap = (uintptr_t) c->vftbl;
 
-       *((ptrint *) datap) = (ptrint) c->vftbl;
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
index 8dea3aacc2030445d82d8c60fa3ee7e9cf8b4ec9..9ea6f4da5c97ce6efaca10364e1e50a84fb40d84 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/asmpart.h - prototypes for machine specfic functions
 
-   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.
 
 
 #include "vm/types.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/critical.h"
-#endif
-
 #include "vm/global.h"
-#include "vm/vm.h"
-
-#include "vmcore/linker.h"
+#include "vm/vm.hpp"
 
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* machine dependent initialization */
 s4   asm_md_init(void);
 
@@ -103,11 +99,8 @@ void intrp_asm_abstractmethoderror(void);
 /* wrapper for code patching functions */
 void asm_patcher_wrapper(void);
 
-long asm_compare_and_swap(volatile long *p, long oldval, long newval);
-void asm_memory_barrier(void);
-
 /* cache flush function */
-void asm_cacheflush(u1 *addr, s4 nbytes);
+void asm_cacheflush(void* addr, int nbytes);
 
 u8 asm_get_cycle_count(void);
 
@@ -117,6 +110,10 @@ void *md_asm_codegen_get_pv_from_pc(void *ra);
 void asm_escape_check(java_object_t *obj);
 #endif
 
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
 #endif /* _ASMPART_H */
 
 
diff --git a/src/vm/jit/builtin.cpp b/src/vm/jit/builtin.cpp
new file mode 100644 (file)
index 0000000..f2c1a5f
--- /dev/null
@@ -0,0 +1,2374 @@
+/* src/vm/jit/builtin.cpp - functions for unsupported operations
+
+   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.
+
+   Contains C functions for JavaVM Instructions that cannot be
+   translated to machine language directly. Consequently, the
+   generated machine code for these instructions contains function
+   calls instead of machine instructions, using the C calling
+   convention.
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+#include "vm/types.h"
+
+#include "arch.h"
+#include "md-abi.h"
+
+#include "fdlibm/fdlibm.h"
+#if defined(__CYGWIN__) && defined(Bias)
+# undef Bias
+#endif
+
+#include "mm/gc.hpp"
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "threads/lock.hpp"
+#include "threads/mutex.hpp"
+#include "threads/thread.hpp"
+
+#include "toolbox/logging.h"
+#include "toolbox/util.h"
+
+#include "vm/array.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/cycles-stats.h"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/initialize.hpp"
+#include "vm/linker.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/rt-timing.h"
+#include "vm/string.hpp"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/stubs.hpp"
+#include "vm/jit/trace.hpp"
+
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
+
+/* include builtin tables *****************************************************/
+
+#include "vm/jit/builtintable.inc"
+
+
+CYCLES_STATS_DECLARE(builtin_new         ,100,5)
+CYCLES_STATS_DECLARE(builtin_overhead    , 80,1)
+
+
+/*============================================================================*/
+/* BUILTIN TABLE MANAGEMENT FUNCTIONS                                         */
+/*============================================================================*/
+
+/* builtintable_init ***********************************************************
+
+   Parse the descriptors of builtin functions and create the parsed
+   descriptors.
+
+*******************************************************************************/
+
+static bool builtintable_init(void)
+{
+       descriptor_pool    *descpool;
+       builtintable_entry *bte;
+       methodinfo         *m;
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       /* create a new descriptor pool */
+
+       descpool = descriptor_pool_new(class_java_lang_Object);
+
+       /* add some entries we need */
+
+       if (!descriptor_pool_add_class(descpool, utf_java_lang_Object))
+               return false;
+
+       if (!descriptor_pool_add_class(descpool, utf_java_lang_Class))
+               return false;
+
+       /* first add all descriptors to the pool */
+
+       for (bte = builtintable_internal; bte->fp != NULL; bte++) {
+               bte->name       = utf_new_char(bte->cname);
+               bte->descriptor = utf_new_char(bte->cdescriptor);
+
+               if (!descriptor_pool_add(descpool, bte->descriptor, NULL))
+                       return false;
+       }
+
+       for (bte = builtintable_automatic; bte->fp != NULL; bte++) {
+               bte->descriptor = utf_new_char(bte->cdescriptor);
+
+               if (!descriptor_pool_add(descpool, bte->descriptor, NULL))
+                       return false;
+       }
+
+       for (bte = builtintable_function; bte->fp != NULL; bte++) {
+               bte->classname  = utf_new_char(bte->cclassname);
+               bte->name       = utf_new_char(bte->cname);
+               bte->descriptor = utf_new_char(bte->cdescriptor);
+
+               if (!descriptor_pool_add(descpool, bte->descriptor, NULL))
+                       return false;
+       }
+
+       /* create the class reference table */
+
+       (void) descriptor_pool_create_classrefs(descpool, NULL);
+
+       /* allocate space for the parsed descriptors */
+
+       descriptor_pool_alloc_parsed_descriptors(descpool);
+
+       /* Now parse all descriptors.  NOTE: builtin-functions are treated
+          like static methods (no `this' pointer). */
+
+       for (bte = builtintable_internal; bte->fp != NULL; bte++) {
+               bte->md =
+                       descriptor_pool_parse_method_descriptor(descpool,
+                                                                                                       bte->descriptor,
+                                                                                                       ACC_STATIC | ACC_METHOD_BUILTIN,
+                                                                                                       NULL);
+
+               /* generate a builtin stub if we need one */
+
+               if (bte->flags & BUILTINTABLE_FLAG_STUB) {
+                       m = method_new_builtin(bte);
+                       BuiltinStub::generate(m, bte);
+               }
+       }
+
+       for (bte = builtintable_automatic; bte->fp != NULL; bte++) {
+               bte->md =
+                       descriptor_pool_parse_method_descriptor(descpool,
+                                                                                                       bte->descriptor,
+                                                                                                       ACC_STATIC | ACC_METHOD_BUILTIN,
+                                                                                                       NULL);
+
+               /* no stubs should be needed for this table */
+
+               assert(!bte->flags & BUILTINTABLE_FLAG_STUB);
+       }
+
+       for (bte = builtintable_function; bte->fp != NULL; bte++) {
+               bte->md =
+                       descriptor_pool_parse_method_descriptor(descpool,
+                                                                                                       bte->descriptor,
+                                                                                                       ACC_STATIC | ACC_METHOD_BUILTIN,
+                                                                                                       NULL);
+
+               /* generate a builtin stub if we need one */
+
+               if (bte->flags & BUILTINTABLE_FLAG_STUB) {
+                       m = method_new_builtin(bte);
+                       BuiltinStub::generate(m, bte);
+               }
+       }
+
+       return true;
+}
+
+
+/* builtintable_comparator *****************************************************
+
+   qsort comparator for the automatic builtin table.
+
+*******************************************************************************/
+
+static int builtintable_comparator(const void *a, const void *b)
+{
+       builtintable_entry *bte1;
+       builtintable_entry *bte2;
+
+       bte1 = (builtintable_entry *) a;
+       bte2 = (builtintable_entry *) b;
+
+       return (bte1->opcode < bte2->opcode) ? -1 : (bte1->opcode > bte2->opcode);
+}
+
+
+/* builtintable_sort_automatic *************************************************
+
+   Sorts the automatic builtin table.
+
+*******************************************************************************/
+
+static void builtintable_sort_automatic(void)
+{
+       s4 entries;
+
+       /* calculate table size statically (`- 1' comment see builtintable.inc) */
+
+       entries = sizeof(builtintable_automatic) / sizeof(builtintable_entry) - 1;
+
+       qsort(builtintable_automatic, entries, sizeof(builtintable_entry),
+                 builtintable_comparator);
+}
+
+
+/* builtin_init ****************************************************************
+
+   Initialize the global table of builtin functions.
+
+*******************************************************************************/
+
+bool builtin_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("builtin_init");
+
+       /* initialize the builtin tables */
+
+       if (!builtintable_init())
+               return false;
+
+       /* sort builtin tables */
+
+       builtintable_sort_automatic();
+
+       return true;
+}
+
+
+/* builtintable_get_internal ***************************************************
+
+   Finds an entry in the builtintable for internal functions and
+   returns the a pointer to the structure.
+
+*******************************************************************************/
+
+builtintable_entry *builtintable_get_internal(functionptr fp)
+{
+       builtintable_entry *bte;
+
+       for (bte = builtintable_internal; bte->fp != NULL; bte++) {
+               if (bte->fp == fp)
+                       return bte;
+       }
+
+       return NULL;
+}
+
+
+/* builtintable_get_automatic **************************************************
+
+   Finds an entry in the builtintable for functions which are replaced
+   automatically and returns the a pointer to the structure.
+
+*******************************************************************************/
+
+builtintable_entry *builtintable_get_automatic(s4 opcode)
+{
+       builtintable_entry *first;
+       builtintable_entry *last;
+       builtintable_entry *middle;
+       s4                  half;
+       s4                  entries;
+
+       /* calculate table size statically (`- 1' comment see builtintable.inc) */
+
+       entries = sizeof(builtintable_automatic) / sizeof(builtintable_entry) - 1;
+
+       first = builtintable_automatic;
+       last = builtintable_automatic + entries;
+
+       while (entries > 0) {
+               half = entries / 2;
+               middle = first + half;
+
+               if (middle->opcode < opcode) {
+                       first = middle + 1;
+                       entries -= half + 1;
+               }
+               else
+                       entries = half;
+       }
+
+       return (first != last ? first : NULL);
+}
+
+
+/* builtintable_replace_function ***********************************************
+
+   XXX
+
+*******************************************************************************/
+
+#if defined(ENABLE_JIT)
+bool builtintable_replace_function(void *iptr_)
+{
+       constant_FMIref    *mr;
+       builtintable_entry *bte;
+       instruction        *iptr;
+
+       iptr = (instruction *) iptr_; /* twisti will kill me ;) */
+
+       /* get name and descriptor of the function */
+
+       switch (iptr->opc) {
+       case ICMD_INVOKESTATIC:
+               /* The instruction MUST be resolved, otherwise we run into
+                  lazy loading troubles.  Anyway, we should/can only replace
+                  very VM-close functions. */
+
+               if (INSTRUCTION_IS_UNRESOLVED(iptr))
+                       return false;
+
+               mr = iptr->sx.s23.s3.fmiref;
+               break;  
+
+       default:
+               return false;
+       }
+
+       /* search the function table */
+
+       for (bte = builtintable_function; bte->fp != NULL; bte++) {
+               if ((METHODREF_CLASSNAME(mr) == bte->classname) &&
+                       (mr->name                == bte->name) &&
+                       (mr->descriptor          == bte->descriptor)) {
+
+                       /* set the values in the instruction */
+
+                       iptr->opc           = bte->opcode;
+                       iptr->sx.s23.s3.bte = bte;
+
+                       if (bte->flags & BUILTINTABLE_FLAG_EXCEPTION)
+                               iptr->flags.bits |= INS_FLAG_CHECK;
+                       else
+                               iptr->flags.bits &= ~INS_FLAG_CHECK;
+
+                       return true;
+               }
+       }
+
+       return false;
+}
+#endif /* defined(ENABLE_JIT) */
+
+
+/*============================================================================*/
+/* INTERNAL BUILTIN FUNCTIONS                                                 */
+/*============================================================================*/
+
+/* builtin_instanceof **********************************************************
+
+   Checks if an object is an instance of some given class (or subclass
+   of that class). If class is an interface, checks if the interface
+   is implemented.
+
+   RETURN VALUE:
+     1......o is an instance of class or implements the interface
+     0......otherwise or if o == NULL
+
+   NOTE: This builtin can be called from NATIVE code only.
+
+*******************************************************************************/
+
+bool builtin_instanceof(java_handle_t *o, classinfo *c)
+{
+       classinfo *oc;
+
+       if (o == NULL)
+               return 0;
+
+       LLNI_class_get(o, oc);
+
+       return class_isanysubclass(oc, c);
+}
+
+
+
+/* builtin_checkcast ***********************************************************
+
+   The same as builtin_instanceof but with the exception
+   that 1 is returned when (o == NULL).
+
+   NOTE: This builtin can be called from NATIVE code only.
+
+*******************************************************************************/
+
+bool builtin_checkcast(java_handle_t *o, classinfo *c)
+{
+       classinfo *oc;
+
+       if (o == NULL)
+               return 1;
+
+       LLNI_class_get(o, oc);
+
+       if (class_isanysubclass(oc, c))
+               return 1;
+
+       return 0;
+}
+
+
+/* builtin_descriptorscompatible ***********************************************
+
+   Checks if two array type descriptors are assignment compatible.
+
+   RETURN VALUE:
+      1......target = desc is possible
+      0......otherwise
+                       
+*******************************************************************************/
+
+static bool builtin_descriptorscompatible(arraydescriptor *desc, arraydescriptor *target)
+{
+       if (desc == target)
+               return 1;
+
+       if (desc->arraytype != target->arraytype)
+               return 0;
+
+       if (desc->arraytype != ARRAYTYPE_OBJECT)
+               return 1;
+       
+       /* {both arrays are arrays of references} */
+
+       if (desc->dimension == target->dimension) {
+               if (!desc->elementvftbl)
+                       return 0;
+               /* an array which contains elements of interface types is
+           allowed to be casted to Object (JOWENN)*/
+
+               if ((desc->elementvftbl->baseval < 0) &&
+                       (target->elementvftbl->baseval == 1))
+                       return 1;
+
+               return class_isanysubclass(desc->elementvftbl->clazz,
+                                                                  target->elementvftbl->clazz);
+       }
+
+       if (desc->dimension < target->dimension)
+               return 0;
+
+       /* {desc has higher dimension than target} */
+
+       return class_isanysubclass(pseudo_class_Arraystub,
+                                                          target->elementvftbl->clazz);
+}
+
+
+/* builtin_arraycheckcast ******************************************************
+
+   Checks if an object is really a subtype of the requested array
+   type.  The object has to be an array to begin with. For simple
+   arrays (int, short, double, etc.) the types have to match exactly.
+   For arrays of objects, the type of elements in the array has to be
+   a subtype (or the same type) of the requested element type. For
+   arrays of arrays (which in turn can again be arrays of arrays), the
+   types at the lowest level have to satisfy the corresponding sub
+   class relation.
+
+   NOTE: This is a FAST builtin and can be called from JIT code only.
+
+*******************************************************************************/
+
+bool builtin_fast_arraycheckcast(java_object_t *o, classinfo *targetclass)
+{
+       arraydescriptor *desc;
+
+       if (o == NULL)
+               return 1;
+
+       desc = o->vftbl->arraydesc;
+
+       if (desc == NULL)
+               return 0;
+       return builtin_descriptorscompatible(desc, targetclass->vftbl->arraydesc);
+}
+
+
+/* builtin_fast_arrayinstanceof ************************************************
+
+   NOTE: This is a FAST builtin and can be called from JIT code only.
+
+*******************************************************************************/
+
+bool builtin_fast_arrayinstanceof(java_object_t *o, classinfo *targetclass)
+{
+       if (o == NULL)
+               return 0;
+
+       return builtin_fast_arraycheckcast(o, targetclass);
+}
+
+
+/* builtin_arrayinstanceof *****************************************************
+
+   NOTE: This builtin can be called from NATIVE code only.
+
+*******************************************************************************/
+
+bool builtin_arrayinstanceof(java_handle_t *h, classinfo *targetclass)
+{
+       bool result;
+
+       LLNI_CRITICAL_START;
+
+       result = builtin_fast_arrayinstanceof(LLNI_UNWRAP(h), targetclass);
+
+       LLNI_CRITICAL_END;
+
+       return result;
+}
+
+
+/* builtin_throw_exception *****************************************************
+
+   Sets the exception pointer with the thrown exception and prints some
+   debugging information.
+   
+   NOTE: This is a FAST builtin and can be called from JIT code,
+   or from asm_vm_call_method.
+
+*******************************************************************************/
+
+void *builtin_throw_exception(java_object_t *xptr)
+{
+#if !defined(NDEBUG)
+       /* print exception trace */
+
+       if (opt_TraceExceptions)
+               trace_exception_builtin(xptr);
+#endif /* !defined(NDEBUG) */
+
+       /* actually set the exception */
+
+       exceptions_set_exception(LLNI_QUICKWRAP(xptr));
+
+       /* Return a NULL pointer.  This is required for vm_call_method to
+          check for an exception.  This is for convenience. */
+
+       return NULL;
+}
+
+
+/* builtin_retrieve_exception **************************************************
+
+   Gets and clears the exception pointer of the current thread.
+
+   RETURN VALUE:
+      the exception object, or NULL if no exception was thrown.
+
+   NOTE: This is a FAST builtin and can be called from JIT code,
+   or from the signal handlers.
+
+*******************************************************************************/
+
+java_object_t *builtin_retrieve_exception(void)
+{
+       java_handle_t *h;
+       java_object_t *o;
+
+       /* actually get and clear the exception */
+
+       h = exceptions_get_and_clear_exception();
+       o = LLNI_UNWRAP(h);
+
+       return o;
+}
+
+
+/* builtin_canstore ************************************************************
+
+   Checks, if an object can be stored in an array.
+
+   RETURN VALUE:
+      1......possible
+      0......otherwise (throws an ArrayStoreException)
+
+   NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code.
+
+*******************************************************************************/
+
+bool builtin_canstore(java_handle_objectarray_t *oa, java_handle_t *o)
+{
+       bool result;
+
+       LLNI_CRITICAL_START;
+
+       result = builtin_fast_canstore(LLNI_DIRECT(oa), LLNI_UNWRAP(o));
+
+       LLNI_CRITICAL_END;
+
+       /* if not possible, throw an exception */
+
+       if (result == 0)
+               exceptions_throw_arraystoreexception();
+
+       return result;
+}
+
+#if USES_NEW_SUBTYPE
+/* fast_subtype_check **********************************************************
+
+   Checks if s is a subtype of t, using both the restricted subtype relation
+   and the overflow array (see Cliff Click and John Rose: Fast subtype checking
+   in the Hotspot JVM.)
+
+   RETURN VALUE:
+      1......s is a subtype of t.
+      0......otherwise
+
+*******************************************************************************/
+
+bool fast_subtype_check(struct _vftbl *s, struct _vftbl *t)
+{
+   if (s->subtype_display[t->subtype_depth] == t)
+       return true;
+   if (t->subtype_offset != OFFSET(vftbl_t, subtype_display[DISPLAY_SIZE]))
+       return false;
+   return s->subtype_depth >= t->subtype_depth && s->subtype_overflow[t->subtype_depth - DISPLAY_SIZE] == t;
+}
+#endif
+
+/* builtin_fast_canstore *******************************************************
+
+   Checks, if an object can be stored in an array.
+
+   RETURN VALUE:
+      1......possible
+      0......otherwise (no exception thrown!)
+
+   NOTE: This is a FAST builtin and can be called from JIT code only.
+
+*******************************************************************************/
+
+bool builtin_fast_canstore(java_objectarray_t *oa, java_object_t *o)
+{
+       arraydescriptor *desc;
+       arraydescriptor *valuedesc;
+       vftbl_t         *componentvftbl;
+       vftbl_t         *valuevftbl;
+       int32_t          baseval;
+       uint32_t         diffval;
+       bool             result;
+
+       if (o == NULL)
+               return 1;
+
+       /* The following is guaranteed (by verifier checks):
+        *
+        *     *) oa->...vftbl->arraydesc != NULL
+        *     *) oa->...vftbl->arraydesc->componentvftbl != NULL
+        *     *) o->vftbl is not an interface vftbl
+        */
+
+       desc           = oa->header.objheader.vftbl->arraydesc;
+       componentvftbl = desc->componentvftbl;
+       valuevftbl     = o->vftbl;
+       valuedesc      = valuevftbl->arraydesc;
+
+       if ((desc->dimension - 1) == 0) {
+               /* {oa is a one-dimensional array} */
+               /* {oa is an array of references} */
+               
+               if (valuevftbl == componentvftbl)
+                       return 1;
+
+               LOCK_CLASSRENUMBER_LOCK;
+
+               baseval = componentvftbl->baseval;
+
+               if (baseval <= 0) {
+                       /* an array of interface references */
+
+                       result = ((valuevftbl->interfacetablelength > -baseval) &&
+                                         (valuevftbl->interfacetable[baseval] != NULL));
+               }
+               else {
+#if USES_NEW_SUBTYPE
+                       result = fast_subtype_check(valuevftbl, componentvftbl);
+#else
+                       diffval = valuevftbl->baseval - componentvftbl->baseval;
+                       result  = diffval <= (uint32_t) componentvftbl->diffval;
+#endif
+               }
+
+               UNLOCK_CLASSRENUMBER_LOCK;
+       }
+       else if (valuedesc == NULL) {
+               /* {oa has dimension > 1} */
+               /* {componentvftbl->arraydesc != NULL} */
+
+               /* check if o is an array */
+
+               return 0;
+       }
+       else {
+               /* {o is an array} */
+
+               result = builtin_descriptorscompatible(valuedesc, componentvftbl->arraydesc);
+       }
+
+       /* return result */
+
+       return result;
+}
+
+
+/* This is an optimized version where a is guaranteed to be one-dimensional */
+bool builtin_fast_canstore_onedim(java_objectarray_t *a, java_object_t *o)
+{
+       arraydescriptor *desc;
+       vftbl_t         *elementvftbl;
+       vftbl_t         *valuevftbl;
+       int32_t          baseval;
+       uint32_t         diffval;
+       bool             result;
+       
+       if (o == NULL)
+               return 1;
+
+       /* The following is guaranteed (by verifier checks):
+        *
+        *     *) a->...vftbl->arraydesc != NULL
+        *     *) a->...vftbl->arraydesc->elementvftbl != NULL
+        *     *) a->...vftbl->arraydesc->dimension == 1
+        *     *) o->vftbl is not an interface vftbl
+        */
+
+       desc = a->header.objheader.vftbl->arraydesc;
+    elementvftbl = desc->elementvftbl;
+       valuevftbl = o->vftbl;
+
+       /* {a is a one-dimensional array} */
+       
+       if (valuevftbl == elementvftbl)
+               return 1;
+
+       LOCK_CLASSRENUMBER_LOCK;
+
+       baseval = elementvftbl->baseval;
+
+       if (baseval <= 0) {
+               /* an array of interface references */
+               result = ((valuevftbl->interfacetablelength > -baseval) &&
+                                 (valuevftbl->interfacetable[baseval] != NULL));
+       }
+       else {
+#if USES_NEW_SUBTYPE
+               result = fast_subtype_check(valuevftbl, elementvftbl);
+#else
+               diffval = valuevftbl->baseval - elementvftbl->baseval;
+               result  = diffval <= (uint32_t) elementvftbl->diffval;
+#endif
+       }
+
+       UNLOCK_CLASSRENUMBER_LOCK;
+
+       return result;
+}
+
+
+/* This is an optimized version where a is guaranteed to be a
+ * one-dimensional array of a class type */
+bool builtin_fast_canstore_onedim_class(java_objectarray_t *a, java_object_t *o)
+{
+       vftbl_t  *elementvftbl;
+       vftbl_t  *valuevftbl;
+       uint32_t  diffval;
+       bool      result;
+       
+       if (o == NULL)
+               return 1;
+
+       /* The following is guaranteed (by verifier checks):
+        *
+        *     *) a->...vftbl->arraydesc != NULL
+        *     *) a->...vftbl->arraydesc->elementvftbl != NULL
+        *     *) a->...vftbl->arraydesc->elementvftbl is not an interface vftbl
+        *     *) a->...vftbl->arraydesc->dimension == 1
+        *     *) o->vftbl is not an interface vftbl
+        */
+
+    elementvftbl = a->header.objheader.vftbl->arraydesc->elementvftbl;
+       valuevftbl = o->vftbl;
+
+       /* {a is a one-dimensional array} */
+       
+       if (valuevftbl == elementvftbl)
+               return 1;
+
+       LOCK_CLASSRENUMBER_LOCK;
+
+#if USES_NEW_SUBTYPE
+       result = fast_subtype_check(valuevftbl, elementvftbl);
+#else
+       diffval = valuevftbl->baseval - elementvftbl->baseval;
+       result  = diffval <= (uint32_t) elementvftbl->diffval;
+#endif
+
+       UNLOCK_CLASSRENUMBER_LOCK;
+
+       return result;
+}
+
+
+/* builtin_new *****************************************************************
+
+   Creates a new instance of class c on the heap.
+
+   RETURN VALUE:
+      pointer to the object, or NULL if no memory is available
+
+   NOTE: This builtin can be called from NATIVE code only.
+
+*******************************************************************************/
+
+java_handle_t *builtin_new(classinfo *c)
+{
+       java_handle_t *o;
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_end;
+#endif
+#if defined(ENABLE_CYCLES_STATS)
+       u8 cycles_start, cycles_end;
+#endif
+
+       RT_TIMING_GET_TIME(time_start);
+       CYCLES_STATS_GET(cycles_start);
+
+       /* is the class loaded */
+
+       assert(c->state & CLASS_LOADED);
+
+       /* check if we can instantiate this class */
+
+       if (c->flags & ACC_ABSTRACT) {
+               exceptions_throw_instantiationerror(c);
+               return NULL;
+       }
+
+       /* is the class linked */
+
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return NULL;
+
+       if (!(c->state & CLASS_INITIALIZED)) {
+#if !defined(NDEBUG)
+               if (initverbose)
+                       log_message_class("Initialize class (from builtin_new): ", c);
+#endif
+
+               if (!initialize_class(c))
+                       return NULL;
+       }
+
+       o = (java_handle_t*) heap_alloc(c->instancesize, c->flags & ACC_CLASS_HAS_POINTERS,
+                                                                       c->finalizer, true);
+
+       if (!o)
+               return NULL;
+
+#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES)
+       /* XXX this is only a dirty hack to make Boehm work with handles */
+
+       o = LLNI_WRAP((java_object_t *) o);
+#endif
+
+       LLNI_vftbl_direct(o) = c->vftbl;
+
+#if defined(ENABLE_THREADS)
+       LLNI_DIRECT(o)->lockword.init();
+#endif
+
+       CYCLES_STATS_GET(cycles_end);
+       RT_TIMING_GET_TIME(time_end);
+
+       CYCLES_STATS_COUNT(builtin_new,cycles_end - cycles_start);
+       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_OBJECT);
+
+       return o;
+}
+
+#if defined(ENABLE_ESCAPE_REASON)
+java_handle_t *builtin_escape_reason_new(classinfo *c) {
+       print_escape_reasons();
+       return builtin_java_new(c);
+}
+#endif
+
+#if defined(ENABLE_TLH)
+java_handle_t *builtin_tlh_new(classinfo *c)
+{
+       java_handle_t *o;
+# if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_end;
+# endif
+# if defined(ENABLE_CYCLES_STATS)
+       u8 cycles_start, cycles_end;
+# endif
+
+       RT_TIMING_GET_TIME(time_start);
+       CYCLES_STATS_GET(cycles_start);
+
+       /* is the class loaded */
+
+       assert(c->state & CLASS_LOADED);
+
+       /* check if we can instantiate this class */
+
+       if (c->flags & ACC_ABSTRACT) {
+               exceptions_throw_instantiationerror(c);
+               return NULL;
+       }
+
+       /* is the class linked */
+
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return NULL;
+
+       if (!(c->state & CLASS_INITIALIZED)) {
+# if !defined(NDEBUG)
+               if (initverbose)
+                       log_message_class("Initialize class (from builtin_new): ", c);
+# endif
+
+               if (!initialize_class(c))
+                       return NULL;
+       }
+
+       /*
+       o = tlh_alloc(&(THREADOBJECT->tlh), c->instancesize);
+       */
+       o = NULL;
+
+       if (o == NULL) {
+               o = (java_handle_t*) heap_alloc(c->instancesize, c->flags & ACC_CLASS_HAS_POINTERS,
+                                                                               c->finalizer, true);
+       }
+
+       if (!o)
+               return NULL;
+
+# if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES)
+       /* XXX this is only a dirty hack to make Boehm work with handles */
+
+       o = LLNI_WRAP((java_object_t *) o);
+# endif
+
+       LLNI_vftbl_direct(o) = c->vftbl;
+
+# if defined(ENABLE_THREADS)
+       LLNI_DIRECT(o)->lockword.init();
+# endif
+
+       CYCLES_STATS_GET(cycles_end);
+       RT_TIMING_GET_TIME(time_end);
+
+/*
+       CYCLES_STATS_COUNT(builtin_new,cycles_end - cycles_start);
+       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_OBJECT);
+*/
+
+       return o;
+}
+#endif
+
+
+/* builtin_java_new ************************************************************
+
+   NOTE: This is a SLOW builtin and can be called from JIT code only.
+
+*******************************************************************************/
+
+java_handle_t *builtin_java_new(java_handle_t *clazz)
+{
+       return builtin_new(LLNI_classinfo_unwrap(clazz));
+}
+
+
+/* builtin_fast_new ************************************************************
+
+   Creates a new instance of class c on the heap.
+
+   RETURN VALUE:
+      pointer to the object, or NULL if no fast return
+      is possible for any reason.
+
+   NOTE: This is a FAST builtin and can be called from JIT code only.
+
+*******************************************************************************/
+
+java_object_t *builtin_fast_new(classinfo *c)
+{
+       java_object_t *o;
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_end;
+#endif
+#if defined(ENABLE_CYCLES_STATS)
+       u8 cycles_start, cycles_end;
+#endif
+
+       RT_TIMING_GET_TIME(time_start);
+       CYCLES_STATS_GET(cycles_start);
+
+       /* is the class loaded */
+
+       assert(c->state & CLASS_LOADED);
+
+       /* check if we can instantiate this class */
+
+       if (c->flags & ACC_ABSTRACT)
+               return NULL;
+
+       /* is the class linked */
+
+       if (!(c->state & CLASS_LINKED))
+               return NULL;
+
+       if (!(c->state & CLASS_INITIALIZED))
+               return NULL;
+
+       o = (java_handle_t*) heap_alloc(c->instancesize, c->flags & ACC_CLASS_HAS_POINTERS,
+                                                                       c->finalizer, false);
+
+       if (!o)
+               return NULL;
+
+       o->vftbl = c->vftbl;
+
+#if defined(ENABLE_THREADS)
+       LLNI_DIRECT(o)->lockword.init();
+#endif
+
+       CYCLES_STATS_GET(cycles_end);
+       RT_TIMING_GET_TIME(time_end);
+
+       CYCLES_STATS_COUNT(builtin_new,cycles_end - cycles_start);
+       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_OBJECT);
+
+       return o;
+}
+
+
+/* builtin_newarray ************************************************************
+
+   Creates an array with the given vftbl on the heap. This function
+   takes as class argument an array class.
+
+   RETURN VALUE:
+      pointer to the array or NULL if no memory is available
+
+   NOTE: This builtin can be called from NATIVE code only.
+
+*******************************************************************************/
+
+java_handle_t *builtin_newarray(int32_t size, classinfo *arrayclass)
+{
+       arraydescriptor *desc;
+       s4               dataoffset;
+       s4               componentsize;
+       s4               actualsize;
+       java_handle_t   *a;
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_end;
+#endif
+
+       RT_TIMING_GET_TIME(time_start);
+
+       desc          = arrayclass->vftbl->arraydesc;
+       dataoffset    = desc->dataoffset;
+       componentsize = desc->componentsize;
+
+       if (size < 0) {
+               exceptions_throw_negativearraysizeexception();
+               return NULL;
+       }
+
+       actualsize = dataoffset + size * componentsize;
+
+       /* check for overflow */
+
+       if (((u4) actualsize) < ((u4) size)) {
+               exceptions_throw_outofmemoryerror();
+               return NULL;
+       }
+
+       a = (java_handle_t*) heap_alloc(actualsize, (desc->arraytype == ARRAYTYPE_OBJECT), NULL, true);
+
+       if (a == NULL)
+               return NULL;
+
+#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES)
+       /* XXX this is only a dirty hack to make Boehm work with handles */
+
+       a = LLNI_WRAP((java_object_t *) a);
+#endif
+
+       LLNI_vftbl_direct(a) = arrayclass->vftbl;
+
+#if defined(ENABLE_THREADS)
+       LLNI_DIRECT(a)->lockword.init();
+#endif
+
+       LLNI_array_size(a) = size;
+
+       RT_TIMING_GET_TIME(time_end);
+       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_ARRAY);
+
+       return a;
+}
+
+
+/* builtin_java_newarray *******************************************************
+
+   NOTE: This is a SLOW builtin and can be called from JIT code only.
+
+*******************************************************************************/
+
+java_handle_t *builtin_java_newarray(int32_t size, java_handle_t *arrayclazz)
+{
+       return builtin_newarray(size, LLNI_classinfo_unwrap(arrayclazz));
+}
+
+
+/* builtin_anewarray ***********************************************************
+
+   Creates an array of references to the given class type on the heap.
+
+   RETURN VALUE:
+      pointer to the array or NULL if no memory is
+      available
+
+   NOTE: This builtin can be called from NATIVE code only.
+
+*******************************************************************************/
+
+java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass)
+{
+       classinfo *arrayclass;
+       
+       /* is class loaded */
+
+       assert(componentclass->state & CLASS_LOADED);
+
+       /* is class linked */
+
+       if (!(componentclass->state & CLASS_LINKED))
+               if (!link_class(componentclass))
+                       return NULL;
+
+       arrayclass = class_array_of(componentclass, true);
+
+       if (!arrayclass)
+               return NULL;
+
+       return (java_handle_objectarray_t *) builtin_newarray(size, arrayclass);
+}
+
+
+/* builtin_newarray_type ****************************************************
+
+   Creates an array of [type]s on the heap.
+       
+   RETURN VALUE:
+      pointer to the array or NULL if no memory is available
+
+   NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code.
+
+*******************************************************************************/
+
+#define BUILTIN_NEWARRAY_TYPE(type, arraytype)                             \
+java_handle_##type##array_t *builtin_newarray_##type(int32_t size)              \
+{                                                                          \
+       return (java_handle_##type##array_t *)                                 \
+               builtin_newarray(size, primitivetype_table[arraytype].arrayclass); \
+}
+
+BUILTIN_NEWARRAY_TYPE(boolean, ARRAYTYPE_BOOLEAN)
+BUILTIN_NEWARRAY_TYPE(byte,    ARRAYTYPE_BYTE)
+BUILTIN_NEWARRAY_TYPE(char,    ARRAYTYPE_CHAR)
+BUILTIN_NEWARRAY_TYPE(short,   ARRAYTYPE_SHORT)
+BUILTIN_NEWARRAY_TYPE(int,     ARRAYTYPE_INT)
+BUILTIN_NEWARRAY_TYPE(long,    ARRAYTYPE_LONG)
+BUILTIN_NEWARRAY_TYPE(float,   ARRAYTYPE_FLOAT)
+BUILTIN_NEWARRAY_TYPE(double,  ARRAYTYPE_DOUBLE)
+
+
+/* builtin_multianewarray_intern ***********************************************
+
+   Creates a multi-dimensional array on the heap. The dimensions are
+   passed in an array of longs.
+
+   ARGUMENTS:
+      n.............number of dimensions to create
+      arrayclass....the array class
+      dims..........array containing the size of each dimension to create
+
+   RETURN VALUE:
+      pointer to the array or NULL if no memory is available
+
+******************************************************************************/
+
+static java_handle_t *builtin_multianewarray_intern(int n,
+                                                                                                       classinfo *arrayclass,
+                                                                                                       long *dims)
+{
+       s4             size;
+       java_handle_t *a;
+       classinfo     *componentclass;
+       s4             i;
+
+       /* create this dimension */
+
+       size = (s4) dims[0];
+       a = builtin_newarray(size, arrayclass);
+
+       if (!a)
+               return NULL;
+
+       /* if this is the last dimension return */
+
+       if (!--n)
+               return a;
+
+       /* get the class of the components to create */
+
+       componentclass = arrayclass->vftbl->arraydesc->componentvftbl->clazz;
+
+       /* The verifier guarantees that the dimension count is in the range. */
+
+       /* create the component arrays */
+
+       for (i = 0; i < size; i++) {
+               java_handle_t *ea =
+#if defined(__MIPS__) && (SIZEOF_VOID_P == 4)
+                       /* we save an s4 to a s8 slot, 8-byte aligned */
+
+                       builtin_multianewarray_intern(n, componentclass, dims + 2);
+#else
+                       builtin_multianewarray_intern(n, componentclass, dims + 1);
+#endif
+
+               if (!ea)
+                       return NULL;
+
+               array_objectarray_element_set((java_handle_objectarray_t *) a, i, ea);
+       }
+
+       return a;
+}
+
+
+/* builtin_multianewarray ******************************************************
+
+   Wrapper for builtin_multianewarray_intern which checks all
+   dimensions before we start allocating.
+
+   NOTE: This is a SLOW builtin and can be called from JIT code only.
+
+******************************************************************************/
+
+java_handle_objectarray_t *builtin_multianewarray(int n,
+                                                                                                 java_handle_t *arrayclazz,
+                                                                                                 long *dims)
+{
+       classinfo *c;
+       s4         i;
+       s4         size;
+
+       /* check all dimensions before doing anything */
+
+       for (i = 0; i < n; i++) {
+#if defined(__MIPS__) && (SIZEOF_VOID_P == 4)
+               /* we save an s4 to a s8 slot, 8-byte aligned */
+               size = (s4) dims[i * 2];
+#else
+               size = (s4) dims[i];
+#endif
+
+               if (size < 0) {
+                       exceptions_throw_negativearraysizeexception();
+                       return NULL;
+               }
+       }
+
+       c = LLNI_classinfo_unwrap(arrayclazz);
+
+       /* now call the real function */
+
+       return (java_handle_objectarray_t *)
+               builtin_multianewarray_intern(n, c, dims);
+}
+
+
+/* builtin_verbosecall_enter ***************************************************
+
+   Print method call with arguments for -verbose:call.
+
+   XXX: Remove mew once all archs use the new tracer!
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+#ifdef TRACE_ARGS_NUM
+void builtin_verbosecall_enter(s8 a0, s8 a1,
+# if TRACE_ARGS_NUM >= 4
+                                                          s8 a2, s8 a3,
+# endif
+# if TRACE_ARGS_NUM >= 6
+                                                          s8 a4, s8 a5,
+# endif
+# if TRACE_ARGS_NUM == 8
+                                                          s8 a6, s8 a7,
+# endif
+                                                          methodinfo *m)
+{
+       log_text("builtin_verbosecall_enter: Do not call me anymore!");
+}
+#endif
+#endif /* !defined(NDEBUG) */
+
+
+/* builtin_verbosecall_exit ****************************************************
+
+   Print method exit for -verbose:call.
+
+   XXX: Remove mew once all archs use the new tracer!
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void builtin_verbosecall_exit(s8 l, double d, float f, methodinfo *m)
+{
+       log_text("builtin_verbosecall_exit: Do not call me anymore!");
+}
+#endif /* !defined(NDEBUG) */
+
+
+/*============================================================================*/
+/* MISCELLANEOUS MATHEMATICAL HELPER FUNCTIONS                                */
+/*============================================================================*/
+
+/*********** Functions for integer divisions *****************************
+       On some systems (eg. DEC ALPHA), integer division is not supported by the
+       CPU. These helper functions implement the missing functionality.
+
+******************************************************************************/
+
+#if !SUPPORT_DIVISION || defined(DISABLE_GC)
+s4 builtin_idiv(s4 a, s4 b)
+{
+       s4 c;
+
+       c = a / b;
+
+       return c;
+}
+
+s4 builtin_irem(s4 a, s4 b)
+{
+       s4 c;
+
+       c = a % b;
+
+       return c;
+}
+#endif /* !SUPPORT_DIVISION || defined(DISABLE_GC) */
+
+
+/* functions for long arithmetics **********************************************
+
+   On systems where 64 bit Integers are not supported by the CPU,
+   these functions are needed.
+
+******************************************************************************/
+
+#if !(SUPPORT_LONG && SUPPORT_LONG_ADD)
+s8 builtin_ladd(s8 a, s8 b)
+{
+       s8 c;
+
+       c = a + b; 
+
+       return c;
+}
+
+s8 builtin_lsub(s8 a, s8 b)
+{
+       s8 c;
+
+       c = a - b; 
+
+       return c;
+}
+
+s8 builtin_lneg(s8 a)
+{
+       s8 c;
+
+       c = -a;
+
+       return c;
+}
+#endif /* !(SUPPORT_LONG && SUPPORT_LONG_ADD) */
+
+
+#if !(SUPPORT_LONG && SUPPORT_LONG_MUL)
+s8 builtin_lmul(s8 a, s8 b)
+{
+       s8 c;
+
+       c = a * b; 
+
+       return c;
+}
+#endif /* !(SUPPORT_LONG && SUPPORT_LONG_MUL) */
+
+
+#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) || defined (DISABLE_GC)
+s8 builtin_ldiv(s8 a, s8 b)
+{
+       s8 c;
+
+       c = a / b; 
+
+       return c;
+}
+
+s8 builtin_lrem(s8 a, s8 b)
+{
+       s8 c;
+
+       c = a % b; 
+
+       return c;
+}
+#endif /* !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) */
+
+
+#if !(SUPPORT_LONG && SUPPORT_LONG_SHIFT)
+s8 builtin_lshl(s8 a, s4 b)
+{
+       s8 c;
+
+       c = a << (b & 63);
+
+       return c;
+}
+
+s8 builtin_lshr(s8 a, s4 b)
+{
+       s8 c;
+
+       c = a >> (b & 63);
+
+       return c;
+}
+
+s8 builtin_lushr(s8 a, s4 b)
+{
+       s8 c;
+
+       c = ((u8) a) >> (b & 63);
+
+       return c;
+}
+#endif /* !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) */
+
+
+#if !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL)
+s8 builtin_land(s8 a, s8 b)
+{
+       s8 c;
+
+       c = a & b; 
+
+       return c;
+}
+
+s8 builtin_lor(s8 a, s8 b)
+{
+       s8 c;
+
+       c = a | b; 
+
+       return c;
+}
+
+s8 builtin_lxor(s8 a, s8 b) 
+{
+       s8 c;
+
+       c = a ^ b; 
+
+       return c;
+}
+#endif /* !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) */
+
+
+#if !(SUPPORT_LONG && SUPPORT_LONG_CMP)
+s4 builtin_lcmp(s8 a, s8 b)
+{ 
+       if (a < b)
+               return -1;
+
+       if (a > b)
+               return 1;
+
+       return 0;
+}
+#endif /* !(SUPPORT_LONG && SUPPORT_LONG_CMP) */
+
+
+/* functions for unsupported floating instructions ****************************/
+
+/* used to convert FLT_xxx defines into float values */
+
+static inline float intBitsToFloat(s4 i)
+{
+       imm_union imb;
+
+       imb.i = i;
+       return imb.f;
+}
+
+
+/* used to convert DBL_xxx defines into double values */
+
+static inline float longBitsToDouble(s8 l)
+{
+       imm_union imb;
+
+       imb.l = l;
+       return imb.d;
+}
+
+
+#if !SUPPORT_FLOAT
+float builtin_fadd(float a, float b)
+{
+       if (isnanf(a)) return intBitsToFloat(FLT_NAN);
+       if (isnanf(b)) return intBitsToFloat(FLT_NAN);
+       if (finitef(a)) {
+               if (finitef(b))
+                       return a + b;
+               else
+                       return b;
+       }
+       else {
+               if (finitef(b))
+                       return a;
+               else {
+                       if (copysignf(1.0, a) == copysignf(1.0, b))
+                               return a;
+                       else
+                               return intBitsToFloat(FLT_NAN);
+               }
+       }
+}
+
+
+float builtin_fsub(float a, float b)
+{
+       return builtin_fadd(a, builtin_fneg(b));
+}
+
+
+float builtin_fmul(float a, float b)
+{
+       if (isnanf(a)) return intBitsToFloat(FLT_NAN);
+       if (isnanf(b)) return intBitsToFloat(FLT_NAN);
+       if (finitef(a)) {
+               if (finitef(b)) return a * b;
+               else {
+                       if (a == 0) return intBitsToFloat(FLT_NAN);
+                       else return copysignf(b, copysignf(1.0, b)*a);
+               }
+       }
+       else {
+               if (finitef(b)) {
+                       if (b == 0) return intBitsToFloat(FLT_NAN);
+                       else return copysignf(a, copysignf(1.0, a)*b);
+               }
+               else {
+                       return copysignf(a, copysignf(1.0, a)*copysignf(1.0, b));
+               }
+       }
+}
+
+
+/* builtin_ddiv ****************************************************************
+
+   Implementation as described in VM Spec.
+
+*******************************************************************************/
+
+float builtin_fdiv(float a, float b)
+{
+       if (finitef(a)) {
+               if (finitef(b)) {
+                       /* If neither value1' nor value2' is NaN, the sign of the result */
+                       /* is positive if both values have the same sign, negative if the */
+                       /* values have different signs. */
+
+                       return a / b;
+
+               } else {
+                       if (isnanf(b)) {
+                               /* If either value1' or value2' is NaN, the result is NaN. */
+
+                               return intBitsToFloat(FLT_NAN);
+
+                       } else {
+                               /* Division of a finite value by an infinity results in a */
+                               /* signed zero, with the sign-producing rule just given. */
+
+                               /* is sign equal? */
+
+                               if (copysignf(1.0, a) == copysignf(1.0, b))
+                                       return 0.0;
+                               else
+                                       return -0.0;
+                       }
+               }
+
+       } else {
+               if (isnanf(a)) {
+                       /* If either value1' or value2' is NaN, the result is NaN. */
+
+                       return intBitsToFloat(FLT_NAN);
+
+               } else if (finitef(b)) {
+                       /* Division of an infinity by a finite value results in a signed */
+                       /* infinity, with the sign-producing rule just given. */
+
+                       /* is sign equal? */
+
+                       if (copysignf(1.0, a) == copysignf(1.0, b))
+                               return intBitsToFloat(FLT_POSINF);
+                       else
+                               return intBitsToFloat(FLT_NEGINF);
+
+               } else {
+                       /* Division of an infinity by an infinity results in NaN. */
+
+                       return intBitsToFloat(FLT_NAN);
+               }
+       }
+}
+
+
+float builtin_fneg(float a)
+{
+       if (isnanf(a)) return a;
+       else {
+               if (finitef(a)) return -a;
+               else return copysignf(a, -copysignf(1.0, a));
+       }
+}
+#endif /* !SUPPORT_FLOAT */
+
+
+#if !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP || defined(ENABLE_INTRP)
+s4 builtin_fcmpl(float a, float b)
+{
+       if (isnanf(a))
+               return -1;
+
+       if (isnanf(b))
+               return -1;
+
+       if (!finitef(a) || !finitef(b)) {
+               a = finitef(a) ? 0 : copysignf(1.0,     a);
+               b = finitef(b) ? 0 : copysignf(1.0, b);
+       }
+
+       if (a > b)
+               return 1;
+
+       if (a == b)
+               return 0;
+
+       return -1;
+}
+
+
+s4 builtin_fcmpg(float a, float b)
+{
+       if (isnanf(a)) return 1;
+       if (isnanf(b)) return 1;
+       if (!finitef(a) || !finitef(b)) {
+               a = finitef(a) ? 0 : copysignf(1.0, a);
+               b = finitef(b) ? 0 : copysignf(1.0, b);
+       }
+       if (a > b) return 1;
+       if (a == b) return 0;
+       return -1;
+}
+#endif /* !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP || defined(ENABLE_INTRP) */
+
+
+float builtin_frem(float a, float b)
+{
+       return fmodf(a, b);
+}
+
+
+/* functions for unsupported double instructions ******************************/
+
+#if !SUPPORT_DOUBLE
+double builtin_dadd(double a, double b)
+{
+       if (isnan(a)) return longBitsToDouble(DBL_NAN);
+       if (isnan(b)) return longBitsToDouble(DBL_NAN);
+       if (finite(a)) {
+               if (finite(b)) return a + b;
+               else return b;
+       }
+       else {
+               if (finite(b)) return a;
+               else {
+                       if (copysign(1.0, a)==copysign(1.0, b)) return a;
+                       else return longBitsToDouble(DBL_NAN);
+               }
+       }
+}
+
+
+double builtin_dsub(double a, double b)
+{
+       return builtin_dadd(a, builtin_dneg(b));
+}
+
+
+double builtin_dmul(double a, double b)
+{
+       if (isnan(a)) return longBitsToDouble(DBL_NAN);
+       if (isnan(b)) return longBitsToDouble(DBL_NAN);
+       if (finite(a)) {
+               if (finite(b)) return a * b;
+               else {
+                       if (a == 0) return longBitsToDouble(DBL_NAN);
+                       else return copysign(b, copysign(1.0, b) * a);
+               }
+       }
+       else {
+               if (finite(b)) {
+                       if (b == 0) return longBitsToDouble(DBL_NAN);
+                       else return copysign(a, copysign(1.0, a) * b);
+               }
+               else {
+                       return copysign(a, copysign(1.0, a) * copysign(1.0, b));
+               }
+       }
+}
+
+
+/* builtin_ddiv ****************************************************************
+
+   Implementation as described in VM Spec.
+
+*******************************************************************************/
+
+double builtin_ddiv(double a, double b)
+{
+       if (finite(a)) {
+               if (finite(b)) {
+                       /* If neither value1' nor value2' is NaN, the sign of the result */
+                       /* is positive if both values have the same sign, negative if the */
+                       /* values have different signs. */
+
+                       return a / b;
+
+               } else {
+                       if (isnan(b)) {
+                               /* If either value1' or value2' is NaN, the result is NaN. */
+
+                               return longBitsToDouble(DBL_NAN);
+
+                       } else {
+                               /* Division of a finite value by an infinity results in a */
+                               /* signed zero, with the sign-producing rule just given. */
+
+                               /* is sign equal? */
+
+                               if (copysign(1.0, a) == copysign(1.0, b))
+                                       return 0.0;
+                               else
+                                       return -0.0;
+                       }
+               }
+
+       } else {
+               if (isnan(a)) {
+                       /* If either value1' or value2' is NaN, the result is NaN. */
+
+                       return longBitsToDouble(DBL_NAN);
+
+               } else if (finite(b)) {
+                       /* Division of an infinity by a finite value results in a signed */
+                       /* infinity, with the sign-producing rule just given. */
+
+                       /* is sign equal? */
+
+                       if (copysign(1.0, a) == copysign(1.0, b))
+                               return longBitsToDouble(DBL_POSINF);
+                       else
+                               return longBitsToDouble(DBL_NEGINF);
+
+               } else {
+                       /* Division of an infinity by an infinity results in NaN. */
+
+                       return longBitsToDouble(DBL_NAN);
+               }
+       }
+}
+
+
+/* builtin_dneg ****************************************************************
+
+   Implemented as described in VM Spec.
+
+*******************************************************************************/
+
+double builtin_dneg(double a)
+{
+       if (isnan(a)) {
+               /* If the operand is NaN, the result is NaN (recall that NaN has no */
+               /* sign). */
+
+               return a;
+
+       } else {
+               if (finite(a)) {
+                       /* If the operand is a zero, the result is the zero of opposite */
+                       /* sign. */
+
+                       return -a;
+
+               } else {
+                       /* If the operand is an infinity, the result is the infinity of */
+                       /* opposite sign. */
+
+                       return copysign(a, -copysign(1.0, a));
+               }
+       }
+}
+#endif /* !SUPPORT_DOUBLE */
+
+
+#if !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP || defined(ENABLE_INTRP)
+s4 builtin_dcmpl(double a, double b)
+{
+       if (isnan(a))
+               return -1;
+
+       if (isnan(b))
+               return -1;
+
+       if (!finite(a) || !finite(b)) {
+               a = finite(a) ? 0 : copysign(1.0, a);
+               b = finite(b) ? 0 : copysign(1.0, b);
+       }
+
+       if (a > b)
+               return 1;
+
+       if (a == b)
+               return 0;
+
+       return -1;
+}
+
+
+s4 builtin_dcmpg(double a, double b)
+{
+       if (isnan(a))
+               return 1;
+
+       if (isnan(b))
+               return 1;
+
+       if (!finite(a) || !finite(b)) {
+               a = finite(a) ? 0 : copysign(1.0, a);
+               b = finite(b) ? 0 : copysign(1.0, b);
+       }
+
+       if (a > b)
+               return 1;
+
+       if (a == b)
+               return 0;
+
+       return -1;
+}
+#endif /* !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP || defined(ENABLE_INTRP) */
+
+
+double builtin_drem(double a, double b)
+{
+       return fmod(a, b);
+}
+
+
+/* conversion operations ******************************************************/
+
+#if !(SUPPORT_FLOAT && SUPPORT_I2F)
+float builtin_i2f(s4 a)
+{
+       float f = (float) a;
+       return f;
+}
+#endif /* !(SUPPORT_FLOAT && SUPPORT_I2F) */
+
+
+#if !(SUPPORT_DOUBLE && SUPPORT_I2D)
+double builtin_i2d(s4 a)
+{
+       double d = (double) a;
+       return d;
+}
+#endif /* !(SUPPORT_DOUBLE && SUPPORT_I2D) */
+
+
+#if !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F)
+float builtin_l2f(s8 a)
+{
+       float f = (float) a;
+       return f;
+}
+#endif /* !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F) */
+
+
+#if !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D)
+double builtin_l2d(s8 a)
+{
+       double d = (double) a;
+       return d;
+}
+#endif /* !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D) */
+
+
+#if !(SUPPORT_FLOAT && SUPPORT_F2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC)
+s4 builtin_f2i(float a) 
+{
+       s4 i;
+
+       i = builtin_d2i((double) a);
+
+       return i;
+
+       /*      float f;
+       
+               if (isnanf(a))
+               return 0;
+               if (finitef(a)) {
+               if (a > 2147483647)
+               return 2147483647;
+               if (a < (-2147483648))
+               return (-2147483648);
+               return (s4) a;
+               }
+               f = copysignf((float) 1.0, a);
+               if (f > 0)
+               return 2147483647;
+               return (-2147483648); */
+}
+#endif /* !(SUPPORT_FLOAT && SUPPORT_F2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) */
+
+
+#if !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L) || defined(DISABLE_GC)
+s8 builtin_f2l(float a)
+{
+       s8 l;
+
+       l = builtin_d2l((double) a);
+
+       return l;
+
+       /*      float f;
+       
+               if (finitef(a)) {
+               if (a > 9223372036854775807L)
+               return 9223372036854775807L;
+               if (a < (-9223372036854775808L))
+               return (-9223372036854775808L);
+               return (s8) a;
+               }
+               if (isnanf(a))
+               return 0;
+               f = copysignf((float) 1.0, a);
+               if (f > 0)
+               return 9223372036854775807L;
+               return (-9223372036854775808L); */
+}
+#endif /* !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L) */
+
+
+#if !(SUPPORT_DOUBLE && SUPPORT_D2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC)
+s4 builtin_d2i(double a) 
+{ 
+       double d;
+       
+       if (finite(a)) {
+               if (a >= 2147483647)
+                       return 2147483647;
+               if (a <= (-2147483647-1))
+                       return (-2147483647-1);
+               return (s4) a;
+       }
+       if (isnan(a))
+               return 0;
+       d = copysign(1.0, a);
+       if (d > 0)
+               return 2147483647;
+       return (-2147483647-1);
+}
+#endif /* !(SUPPORT_DOUBLE && SUPPORT_D2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) */
+
+
+#if !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L) || defined(DISABLE_GC)
+s8 builtin_d2l(double a)
+{
+       double d;
+       
+       if (finite(a)) {
+               if (a >= 9223372036854775807LL)
+                       return 9223372036854775807LL;
+               if (a <= (-9223372036854775807LL-1))
+                       return (-9223372036854775807LL-1);
+               return (s8) a;
+       }
+       if (isnan(a))
+               return 0;
+       d = copysign(1.0, a);
+       if (d > 0)
+               return 9223372036854775807LL;
+       return (-9223372036854775807LL-1);
+}
+#endif /* !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L) */
+
+
+#if !(SUPPORT_FLOAT && SUPPORT_DOUBLE)
+double builtin_f2d(float a)
+{
+       if (finitef(a)) return (double) a;
+       else {
+               if (isnanf(a))
+                       return longBitsToDouble(DBL_NAN);
+               else
+                       return copysign(longBitsToDouble(DBL_POSINF), (double) copysignf(1.0, a) );
+       }
+}
+
+float builtin_d2f(double a)
+{
+       if (finite(a))
+               return (float) a;
+       else {
+               if (isnan(a))
+                       return intBitsToFloat(FLT_NAN);
+               else
+                       return copysignf(intBitsToFloat(FLT_POSINF), (float) copysign(1.0, a));
+       }
+}
+#endif /* !(SUPPORT_FLOAT && SUPPORT_DOUBLE) */
+
+
+/*============================================================================*/
+/* AUTOMATICALLY REPLACED FUNCTIONS                                           */
+/*============================================================================*/
+
+/* builtin_arraycopy ***********************************************************
+
+   Builtin for java.lang.System.arraycopy.
+
+   NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code.
+
+*******************************************************************************/
+
+void builtin_arraycopy(java_handle_t *src, s4 srcStart,
+                                          java_handle_t *dest, s4 destStart, s4 len)
+{
+       arraydescriptor *sdesc;
+       arraydescriptor *ddesc;
+       s4               i;
+
+       if ((src == NULL) || (dest == NULL)) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       sdesc = LLNI_vftbl_direct(src)->arraydesc;
+       ddesc = LLNI_vftbl_direct(dest)->arraydesc;
+
+       if (!sdesc || !ddesc || (sdesc->arraytype != ddesc->arraytype)) {
+               exceptions_throw_arraystoreexception();
+               return;
+       }
+
+       // Check if offsets and length are positive.
+       if ((srcStart < 0) || (destStart < 0) || (len < 0)) {
+               exceptions_throw_arrayindexoutofboundsexception();
+               return;
+       }
+
+       // Check if ranges are valid.
+       if ((((uint32_t) srcStart  + (uint32_t) len) > (uint32_t) LLNI_array_size(src)) ||
+               (((uint32_t) destStart + (uint32_t) len) > (uint32_t) LLNI_array_size(dest))) {
+               exceptions_throw_arrayindexoutofboundsexception();
+               return;
+       }
+
+       // Special case.
+       if (len == 0) {
+               return;
+       }
+
+       if (sdesc->componentvftbl == ddesc->componentvftbl) {
+               /* We copy primitive values or references of exactly the same type */
+
+               s4 dataoffset = sdesc->dataoffset;
+               s4 componentsize = sdesc->componentsize;
+
+               LLNI_CRITICAL_START;
+
+               MMOVE(((u1 *) LLNI_DIRECT(dest)) + dataoffset + componentsize * destStart,
+                         ((u1 *) LLNI_DIRECT(src))  + dataoffset + componentsize * srcStart,
+                         u1, (size_t) len * componentsize);
+
+               LLNI_CRITICAL_END;
+       }
+       else {
+               /* We copy references of different type */
+
+               java_handle_objectarray_t *oas = (java_handle_objectarray_t *) src;
+               java_handle_objectarray_t *oad = (java_handle_objectarray_t *) dest;
+               if (destStart <= srcStart) {
+                       for (i = 0; i < len; i++) {
+                               java_handle_t *o;
+
+                               o = array_objectarray_element_get(oas, srcStart + i);
+
+                               if (!builtin_canstore(oad, o))
+                                       return;
+
+                               array_objectarray_element_set(oad, destStart + i, o);
+                       }
+               }
+               else {
+                       /* XXX this does not completely obey the specification!
+                          If an exception is thrown only the elements above the
+                          current index have been copied. The specification
+                          requires that only the elements *below* the current
+                          index have been copied before the throw. */
+
+                       for (i = len - 1; i >= 0; i--) {
+                               java_handle_t *o;
+
+                               o = array_objectarray_element_get(oas, srcStart + i);
+
+                               if (!builtin_canstore(oad, o))
+                                       return;
+
+                               array_objectarray_element_set(oad, destStart + i, o);
+                       }
+               }
+       }
+}
+
+
+/* builtin_nanotime ************************************************************
+
+   Return the current time in nanoseconds.
+
+*******************************************************************************/
+
+s8 builtin_nanotime(void)
+{
+       struct timeval tv;
+       s8             usecs;
+
+       if (gettimeofday(&tv, NULL) == -1)
+               vm_abort("gettimeofday failed: %s", strerror(errno));
+
+       usecs = (s8) tv.tv_sec * (1000 * 1000) + (s8) tv.tv_usec;
+
+       return usecs * 1000;
+}
+
+
+/* builtin_currenttimemillis ***************************************************
+
+   Return the current time in milliseconds.
+
+*******************************************************************************/
+
+s8 builtin_currenttimemillis(void)
+{
+       s8 msecs;
+
+       msecs = builtin_nanotime() / 1000 / 1000;
+
+       return msecs;
+}
+
+
+/* builtin_clone ***************************************************************
+
+   Function for cloning objects or arrays.
+
+   NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code.
+
+*******************************************************************************/
+
+java_handle_t *builtin_clone(void *env, java_handle_t *o)
+{
+       arraydescriptor *ad;
+       u4               size;
+       classinfo       *c;
+       java_handle_t   *co;                /* cloned object header               */
+
+       /* get the array descriptor */
+
+       ad = LLNI_vftbl_direct(o)->arraydesc;
+
+       /* we are cloning an array */
+
+       if (ad != NULL) {
+               size = ad->dataoffset + ad->componentsize * LLNI_array_size(o);
+        
+               co = (java_handle_t*) heap_alloc(size, (ad->arraytype == ARRAYTYPE_OBJECT), NULL, true);
+
+               if (co == NULL)
+                       return NULL;
+
+#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES)
+               /* XXX this is only a dirty hack to make Boehm work with handles */
+
+               co = LLNI_WRAP((java_object_t *) co);
+#endif
+
+               LLNI_CRITICAL_START;
+
+               MCOPY(LLNI_DIRECT(co), LLNI_DIRECT(o), u1, size);
+
+#if defined(ENABLE_GC_CACAO)
+               heap_init_objectheader(LLNI_DIRECT(co), size);
+#endif
+
+#if defined(ENABLE_THREADS)
+               LLNI_DIRECT(co)->lockword.init();
+#endif
+
+               LLNI_CRITICAL_END;
+
+               return co;
+       }
+    
+    /* we are cloning a non-array */
+
+    if (!builtin_instanceof(o, class_java_lang_Cloneable)) {
+        exceptions_throw_clonenotsupportedexception();
+        return NULL;
+    }
+
+       /* get the class of the object */
+
+       LLNI_class_get(o, c);
+
+       /* create new object */
+
+    co = builtin_new(c);
+
+    if (co == NULL)
+        return NULL;
+
+       LLNI_CRITICAL_START;
+
+       MCOPY(LLNI_DIRECT(co), LLNI_DIRECT(o), u1, c->instancesize);
+
+#if defined(ENABLE_GC_CACAO)
+       heap_init_objectheader(LLNI_DIRECT(co), c->instancesize);
+#endif
+
+#if defined(ENABLE_THREADS)
+       LLNI_DIRECT(co)->lockword.init();
+#endif
+
+       LLNI_CRITICAL_END;
+
+    return co;
+}
+
+
+#if defined(ENABLE_CYCLES_STATS)
+void builtin_print_cycles_stats(FILE *file)
+{
+       fprintf(file,"builtin cylce count statistics:\n");
+
+       CYCLES_STATS_PRINT_OVERHEAD(builtin_overhead,file);
+       CYCLES_STATS_PRINT(builtin_new         ,file);
+
+       fprintf(file,"\n");
+}
+#endif /* defined(ENABLE_CYCLES_STATS) */
+
+
+#if defined(ENABLE_VMLOG)
+#define NDEBUG
+#include <vmlog_cacao.c>
+#endif
+
+
+/*
+ * 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/jit/builtin.hpp b/src/vm/jit/builtin.hpp
new file mode 100644 (file)
index 0000000..eb2d80e
--- /dev/null
@@ -0,0 +1,354 @@
+/* src/vm/jit/builtin.hpp - prototypes of builtin 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.
+
+*/
+
+
+#ifndef _BUILTIN_HPP
+#define _BUILTIN_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct builtintable_entry builtintable_entry;
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "arch.h"
+#include "md-abi.h"
+
+#include "toolbox/logging.h"
+
+#include "vm/descriptor.h"
+#include "vm/utf8.h"
+
+
+/* define infinity for floating point numbers */
+
+#define FLT_NAN     0x7fc00000
+#define FLT_POSINF  0x7f800000
+#define FLT_NEGINF  0xff800000
+
+/* define infinity for double floating point numbers */
+
+#define DBL_NAN     0x7ff8000000000000LL
+#define DBL_POSINF  0x7ff0000000000000LL
+#define DBL_NEGINF  0xfff0000000000000LL
+
+
+/* float versions are not defined in GNU classpath's fdlibm */
+
+#define copysignf    copysign
+#define finitef      finite
+#define fmodf        fmod
+#define isnanf       isnan
+
+
+/* builtin functions table ****************************************************/
+
+struct builtintable_entry {
+       s4           opcode;                /* opcode which is replaced           */
+       u4           flags;                 /* e.g. check for exception           */
+       functionptr  fp;                    /* function pointer of builtin        */
+       u1          *stub;                  /* pointer to builtin stub code       */
+       const char*  cclassname;            /* char name of the class             */
+       const char*  cname;                 /* char name of the function          */
+       const char*  cdescriptor;           /* char name of the descriptor        */
+       utf         *classname;             /* class of the function              */
+       utf         *name;                  /* name of the function               */
+       utf         *descriptor;            /* descriptor of the function         */
+       methoddesc  *md;
+};
+
+
+/* builtin table flag defines *************************************************/
+
+#define BUILTINTABLE_FLAG_STUB         0x0001 /* builtin needs a stub         */
+#define BUILTINTABLE_FLAG_EXCEPTION    0x0002 /* check for excepion on return */
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool builtin_init(void);
+
+builtintable_entry *builtintable_get_internal(functionptr fp);
+builtintable_entry *builtintable_get_automatic(s4 opcode);
+
+bool builtintable_replace_function(void *iptr);
+
+
+/**********************************************************************/
+/* BUILTIN FUNCTIONS                                                  */
+/**********************************************************************/
+
+/* NOTE: Builtin functions which are used in the BUILTIN* opcodes must
+ * have a BUILTIN_... macro defined as seen below. In code dealing
+ * with the BUILTIN* opcodes the functions may only be addressed by
+ * these macros, never by their actual name! (This helps to make this
+ * code more portable.)
+ *
+ * C and assembler code which does not deal with the BUILTIN* opcodes,
+ * can use the builtin functions normally (like all other functions).
+ *
+ * IMPORTANT:
+ * For each builtin function which is used in a BUILTIN* opcode there
+ * must be an entry in the builtin_desc table in jit/jit.c.
+ *
+ * Below each prototype is either the BUILTIN_ macro definition or a
+ * comment specifiying that this function is not used in BUILTIN*
+ * opcodes.
+ *
+ * (The BUILTIN* opcodes are ICMD_BUILTIN1, ICMD_BUILTIN2 and
+ * ICMD_BUILTIN3.)
+ */
+
+#if USES_NEW_SUBTYPE
+bool fast_subtype_check(struct _vftbl *, struct _vftbl *);
+#endif
+
+bool builtin_instanceof(java_handle_t *obj, classinfo *c);
+/* NOT AN OP */
+bool builtin_checkcast(java_handle_t *obj, classinfo *c);
+/* NOT AN OP */
+bool builtin_arrayinstanceof(java_handle_t *h, classinfo *targetclass);
+/* NOT AN OP */
+bool builtin_fast_arrayinstanceof(java_object_t *o, classinfo *targetclass);
+#define BUILTIN_arrayinstanceof (functionptr) builtin_fast_arrayinstanceof
+bool builtin_fast_arraycheckcast(java_object_t *o, classinfo *targetclass);
+#define BUILTIN_arraycheckcast (functionptr) builtin_fast_arraycheckcast
+
+bool builtin_canstore(java_handle_objectarray_t *oa, java_handle_t *o);
+/* NOT AN OP */
+bool builtin_fast_canstore(java_objectarray_t *oa, java_object_t *o);
+#define BUILTIN_FAST_canstore (functionptr) builtin_fast_canstore
+
+void *builtin_throw_exception(java_object_t *exception);
+/* NOT AN OP */
+java_object_t *builtin_retrieve_exception(void);
+/* NOT AN OP */
+
+java_handle_t *builtin_new(classinfo *c);
+/* NOT AN OP */
+java_handle_t *builtin_java_new(java_handle_t *c);
+#define BUILTIN_new (functionptr) builtin_java_new
+
+#if defined(ENABLE_TLH)
+#define BUILTIN_tlh_new (functionptr) builtin_tlh_new
+java_handle_t *builtin_tlh_new(classinfo *c);
+#endif
+
+#if defined(ENABLE_ESCAPE_REASON)
+#define BUILTIN_escape_reason_new (functionptr)builtin_escape_reason_new
+java_handle_t *builtin_escape_reason_new(classinfo *c);
+#endif
+
+java_object_t *builtin_fast_new(classinfo *c);
+#define BUILTIN_FAST_new (functionptr) builtin_fast_new
+
+java_handle_t *builtin_newarray(int32_t size, classinfo *arrayclass);
+/* NOT AN OP */
+java_handle_t *builtin_java_newarray(int32_t size, java_handle_t *arrayclass);
+#define BUILTIN_newarray (functionptr) builtin_java_newarray
+
+java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass);
+/* NOT AN OP */
+
+java_handle_booleanarray_t *builtin_newarray_boolean(int32_t size);
+#define BUILTIN_newarray_boolean (functionptr) builtin_newarray_boolean
+java_handle_chararray_t *builtin_newarray_char(int32_t size);
+#define BUILTIN_newarray_char (functionptr) builtin_newarray_char
+java_handle_floatarray_t *builtin_newarray_float(int32_t size);
+#define BUILTIN_newarray_float (functionptr) builtin_newarray_float
+java_handle_doublearray_t *builtin_newarray_double(int32_t size);
+#define BUILTIN_newarray_double (functionptr) builtin_newarray_double
+java_handle_bytearray_t *builtin_newarray_byte(int32_t size);
+#define BUILTIN_newarray_byte (functionptr) builtin_newarray_byte
+java_handle_shortarray_t *builtin_newarray_short(int32_t size);
+#define BUILTIN_newarray_short (functionptr) builtin_newarray_short
+java_handle_intarray_t *builtin_newarray_int(int32_t size);
+#define BUILTIN_newarray_int (functionptr) builtin_newarray_int
+java_handle_longarray_t *builtin_newarray_long(int32_t size);
+#define BUILTIN_newarray_long (functionptr) builtin_newarray_long
+
+java_handle_objectarray_t *builtin_multianewarray(int n,
+                                                                                                 java_handle_t *arrayclass,
+                                                                                                 long *dims);
+#define BUILTIN_multianewarray (functionptr) builtin_multianewarray
+
+#if defined(TRACE_ARGS_NUM)
+void builtin_verbosecall_enter(s8 a0, s8 a1,
+# if TRACE_ARGS_NUM >= 4
+                                                          s8 a2, s8 a3,
+# endif
+# if TRACE_ARGS_NUM >= 6
+                                                          s8 a4, s8 a5,
+# endif
+# if TRACE_ARGS_NUM == 8
+                                                          s8 a6, s8 a7,
+# endif
+                                                          methodinfo *m);
+/* NOT AN OP */
+#endif /* defined(TRACE_ARGS_NUM) */
+
+void builtin_verbosecall_exit(s8 l, double d, float f, methodinfo *m);
+/* NOT AN OP */
+
+s4 builtin_idiv(s4 a, s4 b);
+#define BUILTIN_idiv (functionptr) builtin_idiv
+s4 builtin_irem(s4 a, s4 b);
+#define BUILTIN_irem (functionptr) builtin_irem
+
+s8 builtin_ladd(s8 a, s8 b);
+#define BUILTIN_ladd (functionptr) builtin_ladd
+s8 builtin_lsub(s8 a, s8 b);
+#define BUILTIN_lsub (functionptr) builtin_lsub
+s8 builtin_lmul(s8 a, s8 b);
+#define BUILTIN_lmul (functionptr) builtin_lmul
+
+s8 builtin_ldiv(s8 a, s8 b);
+#define BUILTIN_ldiv (functionptr) builtin_ldiv
+s8 builtin_lrem(s8 a, s8 b);
+#define BUILTIN_lrem (functionptr) builtin_lrem
+
+s8 builtin_lshl(s8 a, s4 b);
+#define BUILTIN_lshl (functionptr) builtin_lshl
+s8 builtin_lshr(s8 a, s4 b);
+#define BUILTIN_lshr (functionptr) builtin_lshr
+s8 builtin_lushr(s8 a, s4 b);
+#define BUILTIN_lushr (functionptr) builtin_lushr
+s8 builtin_land(s8 a, s8 b);
+#define BUILTIN_land (functionptr) builtin_land
+s8 builtin_lor(s8 a, s8 b);
+#define BUILTIN_lor (functionptr) builtin_lor
+s8 builtin_lxor(s8 a, s8 b);
+#define BUILTIN_lxor (functionptr) builtin_lxor
+s8 builtin_lneg(s8 a);
+#define BUILTIN_lneg (functionptr) builtin_lneg
+s4 builtin_lcmp(s8 a, s8 b);
+#define BUILTIN_lcmp (functionptr) builtin_lcmp
+
+float builtin_fadd(float a, float b);
+#define BUILTIN_fadd (functionptr) builtin_fadd
+float builtin_fsub(float a, float b);
+#define BUILTIN_fsub (functionptr) builtin_fsub
+float builtin_fmul(float a, float b);
+#define BUILTIN_fmul (functionptr) builtin_fmul
+float builtin_fdiv(float a, float b);
+#define BUILTIN_fdiv (functionptr) builtin_fdiv
+float builtin_fneg(float a);         
+#define BUILTIN_fneg (functionptr) builtin_fneg
+s4 builtin_fcmpl(float a, float b);  
+#define BUILTIN_fcmpl (functionptr) builtin_fcmpl
+s4 builtin_fcmpg(float a, float b);  
+#define BUILTIN_fcmpg (functionptr) builtin_fcmpg
+float builtin_frem(float a, float b);
+#define BUILTIN_frem (functionptr) builtin_frem
+
+double builtin_dadd(double a, double b);
+#define BUILTIN_dadd (functionptr) builtin_dadd
+double builtin_dsub(double a, double b);
+#define BUILTIN_dsub (functionptr) builtin_dsub
+double builtin_dmul(double a, double b);
+#define BUILTIN_dmul (functionptr) builtin_dmul
+double builtin_ddiv(double a, double b);
+#define BUILTIN_ddiv (functionptr) builtin_ddiv
+double builtin_dneg(double a);          
+#define BUILTIN_dneg (functionptr) builtin_dneg
+s4 builtin_dcmpl(double a, double b);   
+#define BUILTIN_dcmpl (functionptr) builtin_dcmpl
+s4 builtin_dcmpg(double a, double b);   
+#define BUILTIN_dcmpg (functionptr) builtin_dcmpg
+double builtin_drem(double a, double b);
+#define BUILTIN_drem (functionptr) builtin_drem
+
+float    builtin_i2f(s4 i);
+#define BUILTIN_i2f (functionptr) builtin_i2f
+double   builtin_i2d(s4 i);
+#define BUILTIN_i2d (functionptr) builtin_i2d
+float    builtin_l2f(s8 l);
+#define BUILTIN_l2f (functionptr) builtin_l2f
+double   builtin_l2d(s8 l);
+#define BUILTIN_l2d (functionptr) builtin_l2d
+
+s4       builtin_f2i(float a);
+#define BUILTIN_f2i (functionptr) builtin_f2i
+s4       asm_builtin_f2i(float a);
+/* NOT AN OP */
+s8       builtin_f2l(float a);
+#define BUILTIN_f2l (functionptr) builtin_f2l
+s8       asm_builtin_f2l(float a);
+/* NOT AN OP */
+
+double   builtin_f2d(float a);
+#define BUILTIN_f2d (functionptr) builtin_f2d
+
+s4       builtin_d2i(double a);
+#define BUILTIN_d2i (functionptr) builtin_d2i
+s4       asm_builtin_d2i(double a);
+/* NOT AN OP */
+s8       builtin_d2l(double a);
+#define BUILTIN_d2l (functionptr) builtin_d2l
+s8       asm_builtin_d2l(double a);
+/* NOT AN OP */
+
+float    builtin_d2f(double a);
+#define BUILTIN_d2f (functionptr) builtin_d2f
+
+java_handle_t *builtin_clone(void *env, java_handle_t *o);
+#define BUILTIN_clone (functionptr) builtin_clone
+
+void builtin_arraycopy(java_handle_t *src, s4 srcStart,
+                                          java_handle_t *dest, s4 destStart, s4 len);
+#define BUILTIN_arraycopy (functionptr) builtin_arraycopy
+
+s8 builtin_nanotime(void);
+s8 builtin_currenttimemillis(void);
+#define BUILTIN_currenttimemillis (functionptr) builtin_currenttimemillis
+
+#if defined(ENABLE_CYCLES_STATS)
+void builtin_print_cycles_stats(FILE *file);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _BUILTIN_HPP
+
+
+/*
+ * 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/jit/builtintable.inc b/src/vm/jit/builtintable.inc
new file mode 100644 (file)
index 0000000..30807db
--- /dev/null
@@ -0,0 +1,1108 @@
+/* src/vm/jit/builtintable.inc - tables of builtin 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 "arch.h"
+
+#include "threads/lock.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/jit/jit.hpp"
+
+
+/* internal and not automatically replaced functions **************************/
+
+static builtintable_entry builtintable_internal[] = {
+
+#if defined(__ALPHA__) || defined(DISABLE_GC)
+       {
+               ICMD_F2L,
+               0,
+               BUILTIN_f2l,
+               NULL,
+               NULL,
+               "f2l",
+               "(F)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_D2L,
+               0,
+               BUILTIN_d2l,
+               NULL,
+               NULL,
+               "d2l",
+               "(D)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_F2I,
+               0,
+               BUILTIN_f2i,
+               NULL,
+               NULL,
+               "f2i",
+               "(F)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_D2I,
+               0,
+               BUILTIN_d2i,
+               NULL,
+               NULL,
+               "d2i",
+               "(D)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if !SUPPORT_DIVISION || defined(DISABLE_GC)
+       {
+               ICMD_IDIV,
+               0,
+               BUILTIN_idiv,
+               NULL,
+               NULL,
+               "idiv",
+               "(II)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_IREM,
+               0,
+               BUILTIN_irem,
+               NULL,
+               NULL,
+               "irem",
+               "(II)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) || defined(DISABLE_GC)
+       {
+               ICMD_LDIV,
+               0,
+               BUILTIN_ldiv,
+               NULL,
+               NULL,
+               "ldiv",
+               "(JJ)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_LREM,
+               0,
+               BUILTIN_lrem,
+               NULL,
+               NULL,
+               "lrem",
+               "(JJ)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+       {
+               ICMD_FREM,
+               0,
+               BUILTIN_frem,
+               NULL,
+               NULL,
+               "frem",
+               "(FF)F",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_DREM,
+               0,
+               BUILTIN_drem,
+               NULL,
+               NULL,
+               "drem",
+               "(DD)D",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+
+
+       /* internal functions *****************************************************/
+
+       {
+               ICMD_NEW,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_new,
+               NULL,
+               NULL,
+               "new",
+               "(Ljava/lang/Class;)Ljava/lang/Object;",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+
+#if defined(ENABLE_TLH)
+       {
+               ICMD_NEW,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_tlh_new,
+               NULL,
+               NULL,
+               "tlh_new",
+               "(Ljava/lang/Class;)Ljava/lang/Object;",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if defined(ENABLE_ESCAPE_REASON)
+       {
+               ICMD_NEW,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_escape_reason_new,
+               NULL,
+               NULL,
+               "escape_reason_new",
+               "(Ljava/lang/Class;)Ljava/lang/Object;",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+       {
+               ICMD_NEW,
+               0,
+               BUILTIN_FAST_new,
+               NULL,
+               NULL,
+               "fast-new",
+               "(Ljava/lang/Class;)Ljava/lang/Object;",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_ANEWARRAY,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_newarray,
+               NULL,
+               NULL,
+               "newarray",
+               "(ILjava/lang/Class;)[Ljava/lang/Object;",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_NEWARRAY,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_newarray_boolean,
+               NULL,
+               NULL,
+               "newarray_boolean",
+               "(I)[Z",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_NEWARRAY,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_newarray_byte,
+               NULL,
+               NULL,
+               "newarray_byte",
+               "(I)[B",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_NEWARRAY,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_newarray_char,
+               NULL,
+               NULL,
+               "newarray_char",
+               "(I)[C",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_NEWARRAY,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_newarray_short,
+               NULL,
+               NULL,
+               "newarray_short",
+               "(I)[S",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_NEWARRAY,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_newarray_int,
+               NULL,
+               NULL,
+               "newarray_int",
+               "(I)[I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_NEWARRAY,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_newarray_long,
+               NULL,
+               NULL,
+               "newarray_long",
+               "(I)[J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_NEWARRAY,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_newarray_float,
+               NULL,
+               NULL,
+               "newarray_float",
+               "(I)[F",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_NEWARRAY,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_newarray_double,
+               NULL,
+               NULL,
+               "newarray_double",
+               "(I)[D",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_MULTIANEWARRAY,
+               BUILTINTABLE_FLAG_STUB,
+               BUILTIN_multianewarray,
+               NULL,
+               NULL,
+               "multianewarray",
+               /* XXX it should be: "(ILjava/lang/Class;[I)[Ljava/lang/Object;", */
+               "(ILjava/lang/Class;I)[Ljava/lang/Object;",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_CHECKCAST,
+               0,
+               BUILTIN_arraycheckcast,
+               NULL,
+               NULL,
+               "arraycheckcast",
+               "([Ljava/lang/Object;[Ljava/lang/Object;)[Ljava/lang/Object;",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_INSTANCEOF,
+               0,
+               BUILTIN_arrayinstanceof,
+               NULL,
+               NULL,
+               "arrayinstanceof",
+               "([Ljava/lang/Object;[Ljava/lang/Object;)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_AASTORE,
+               0,
+               BUILTIN_FAST_canstore,
+               NULL,
+               NULL,
+               "fast-canstore",
+               "([Ljava/lang/Object;Ljava/lang/Object;)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+
+#if defined(ENABLE_THREADS)
+       {
+               ICMD_MONITORENTER,
+               BUILTINTABLE_FLAG_STUB,
+               LOCK_monitor_enter,
+               NULL,
+               NULL,
+               "monitorenter",
+               "(Ljava/lang/Object;)V",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_MONITOREXIT,
+               BUILTINTABLE_FLAG_STUB,
+               LOCK_monitor_exit,
+               NULL,
+               NULL,
+               "monitorexit",
+               "(Ljava/lang/Object;)V",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+
+       /* stop entry */
+
+       {
+               255,
+               0,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+};
+
+
+/* automatically replaced functions *******************************************/
+
+static builtintable_entry builtintable_automatic[] = {
+
+#if !(SUPPORT_LONG && SUPPORT_LONG_CMP)
+       {
+               ICMD_LCMP,
+               0,
+               BUILTIN_lcmp,
+               NULL,
+               NULL,
+               "lcmp",
+               "(JJ)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL)
+       {
+               ICMD_LAND,
+               0,
+               BUILTIN_land,
+               NULL,
+               NULL,
+               "land",
+               "(JJ)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_LOR,
+               0,
+               BUILTIN_lor,
+               NULL,
+               NULL,
+               "lor",
+               "(JJ)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_LXOR,
+               0,
+               BUILTIN_lxor,
+               NULL,
+               NULL,
+               "lxor",
+               "(JJ)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif /* !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) */
+
+#if !(SUPPORT_LONG && SUPPORT_LONG_SHIFT)
+       {
+               ICMD_LSHL,
+               0,
+               BUILTIN_lshl,
+               NULL,
+               NULL,
+               "lshl",
+               "(JI)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_LSHR,
+               0,
+               BUILTIN_lshr,
+               NULL,
+               NULL,
+               "lshr",
+               "(JI)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_LUSHR,
+               0,
+               BUILTIN_lushr,
+               NULL,
+               NULL,
+               "lushr",
+               "(JI)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif /* !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) */
+
+#if !(SUPPORT_LONG && SUPPORT_LONG_ADD)
+       {
+               ICMD_LADD,
+               0,
+               BUILTIN_ladd,
+               NULL,
+               NULL,
+               "ladd",
+               "(JJ)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_LSUB,
+               0,
+               BUILTIN_lsub,
+               NULL,
+               NULL,
+               "lsub",
+               "(JJ)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_LNEG,
+               0,
+               BUILTIN_lneg,
+               NULL,
+               NULL,
+               "lneg",
+               "(J)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif /* !(SUPPORT_LONG && SUPPORT_LONG_ADD) */
+
+#if !(SUPPORT_LONG && SUPPORT_LONG_MUL)
+       {
+               ICMD_LMUL,
+               0,
+               BUILTIN_lmul,
+               NULL,
+               NULL,
+               "lmul",
+               "(JJ)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if !(SUPPORT_FLOAT && SUPPORT_I2F)
+       {
+               ICMD_I2F,
+               0,
+               BUILTIN_i2f,
+               NULL,
+               NULL,
+               "i2f",
+               "(I)F",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if !(SUPPORT_DOUBLE && SUPPORT_I2D)
+       {
+               ICMD_I2D,
+               0,
+               BUILTIN_i2d,
+               NULL,
+               NULL,
+               "i2d",
+               "(I)D",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F)
+       {
+               ICMD_L2F,
+               0,
+               BUILTIN_l2f,
+               NULL,
+               NULL,
+               "l2f",
+               "(J)F",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D)
+       {
+               ICMD_L2D,
+               0,
+               BUILTIN_l2d,
+               NULL,
+               NULL,
+               "l2d",
+               "(J)D",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if !(SUPPORT_FLOAT && SUPPORT_F2I)
+       {
+               ICMD_F2I,
+               0,
+               BUILTIN_f2i,
+               NULL,
+               NULL,
+               "f2i",
+               "(F)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L)
+       {
+               ICMD_F2L,
+               0,
+               BUILTIN_f2l,
+               NULL,
+               NULL,
+               "f2l",
+               "(F)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if !(SUPPORT_DOUBLE && SUPPORT_D2I)
+       {
+               ICMD_D2I,
+               0,
+               BUILTIN_d2i,
+               NULL,
+               NULL,
+               "d2i",
+               "(D)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+#if !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L)
+       {
+               ICMD_D2L,
+               0,
+               BUILTIN_d2l,
+               NULL,
+               NULL,
+               "d2l",
+               "(D)J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+
+       /* float functions ********************************************************/
+
+#if !SUPPORT_FLOAT
+       {
+               ICMD_FADD,
+               0,
+               BUILTIN_fadd,
+               NULL,
+               NULL,
+               "fadd",
+               "(FF)F",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_FSUB,
+               0,
+               BUILTIN_fsub,
+               NULL,
+               NULL,
+               "fsub",
+               "(FF)F",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_FMUL,
+               0,
+               BUILTIN_fmul,
+               NULL,
+               NULL,
+               "fmul",
+               "(FF)F",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_FDIV,
+               0,
+               BUILTIN_fdiv,
+               NULL,
+               NULL,
+               "fdiv",
+               "(FF)F",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_FNEG,
+               0,
+               BUILTIN_fneg,
+               NULL,
+               NULL,
+               "fneg",
+               "(F)F",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif /* !SUPPORT_FLOAT */
+
+#if !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP
+       {
+               ICMD_FCMPL,
+               0,
+               BUILTIN_fcmpl,
+               NULL,
+               NULL,
+               "fcmpl",
+               "(FF)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_FCMPG,
+               0,
+               BUILTIN_fcmpg,
+               NULL,
+               NULL,
+               "fcmpg",
+               "(FF)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif /* !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP */
+
+
+       /* double functions *******************************************************/
+
+#if !SUPPORT_DOUBLE
+       {
+               ICMD_DADD,
+               0,
+               BUILTIN_dadd,
+               NULL,
+               NULL,
+               "dadd",
+               "(DD)D",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_DSUB,
+               0,
+               BUILTIN_dsub,
+               NULL,
+               NULL,
+               "dsub",
+               "(DD)D",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_DMUL,
+               0,
+               BUILTIN_dmul,
+               NULL,
+               NULL,
+               "dmul",
+               "(DD)D",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_DDIV,
+               0,
+               BUILTIN_ddiv,
+               NULL,
+               NULL,
+               "ddiv",
+               "(DD)D",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_DNEG,
+               0,
+               BUILTIN_dneg,
+               NULL,
+               NULL,
+               "dneg",
+               "(D)D",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif /* !SUPPORT_DOUBLE */
+
+#if !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP
+       {
+               ICMD_DCMPL,
+               0,
+               BUILTIN_dcmpl,
+               NULL,
+               NULL,
+               "dcmpl",
+               "(DD)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_DCMPG,
+               0,
+               BUILTIN_dcmpg,
+               NULL,
+               NULL,
+               "dcmpg",
+               "(DD)I",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif /* !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP */
+
+
+       /* float/double functions *************************************************/
+
+#if !(SUPPORT_FLOAT && SUPPORT_DOUBLE)
+       {
+               ICMD_F2D,
+               0,
+               BUILTIN_f2d,
+               NULL,
+               NULL,
+               "f2d",
+               "(F)D",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+       {
+               ICMD_D2F,
+               0,
+               BUILTIN_d2f,
+               NULL,
+               NULL,
+               "d2f",
+               "(D)F",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif /* !(SUPPORT_FLOAT && SUPPORT_DOUBLE) */
+
+
+       /* prevent a compiler warning if everything is supported (e.g. i386) */
+
+       {
+               255,
+               0,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+};
+
+
+/* automatically replaced functions *******************************************/
+
+static builtintable_entry builtintable_function[] = {
+#if defined(ENABLE_JIT)
+
+       /* java.lang.VMSystem.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V STATIC NATIVE */
+
+       {
+               ICMD_BUILTIN,
+               BUILTINTABLE_FLAG_STUB | BUILTINTABLE_FLAG_EXCEPTION,
+               BUILTIN_arraycopy,
+               NULL,
+               "java/lang/VMSystem",
+               "arraycopy",
+               "(Ljava/lang/Object;ILjava/lang/Object;II)V",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+
+       /* java.lang.System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V PUBLIC STATIC */
+
+#if 0
+       /* We disable this one until we have a fix for the stacktrace
+          issue. */
+
+       {
+               ICMD_BUILTIN,
+               BUILTINTABLE_FLAG_STUB | BUILTINTABLE_FLAG_EXCEPTION,
+               BUILTIN_arraycopy,
+               NULL,
+               "java/lang/System",
+               "arraycopy",
+               "(Ljava/lang/Object;ILjava/lang/Object;II)V",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+#endif
+
+       /* java.lang.VMSystem.currentTimeMillis()J PUBLIC STATIC */
+
+       {
+               ICMD_BUILTIN,
+               0,
+               BUILTIN_currenttimemillis,
+               NULL,
+               "java/lang/VMSystem",
+               "currentTimeMillis",
+               "()J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+
+       /* java.lang.System.currentTimeMillis()J PUBLIC STATIC */
+
+       {
+               ICMD_BUILTIN,
+               0,
+               BUILTIN_currenttimemillis,
+               NULL,
+               "java/lang/System",
+               "currentTimeMillis",
+               "()J",
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+
+#endif /* defined(ENABLE_JIT) */
+
+       /* stop entry */
+
+       {
+               255,
+               0,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       },
+};
+
+
+/*
+ * 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 652e200970461fc6d6531c460f30a62cd6935182..4772b95f2f71d984b7cb776122ff305233e7527e 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "vm/global.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/stack.h"
 
 
@@ -501,6 +501,21 @@ void cfg_add_root(jitdata *jd) {
        }
 }
 
+void cfg_remove_root(jitdata *jd) {
+       basicblock *root, *zero, *it;
+
+       root = jd->basicblocks;
+       zero = root->next;
+
+       zero->predecessorcount -= 1;
+
+       jd->basicblocks = zero;
+
+       for (it = zero; it; it = it->next) {
+               it->nr -= 1;
+       }
+}
+
 #if defined(ENABLE_SSA)
 
 static void cfg_eliminate_edges_to_unreachable(jitdata *jd);
index a82b75ad7036f4b3a9ed619c013743f642712df8..a9d787a11a05242913f5b55c1beee45bcd0c5886 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/cfg.h - build a control-flow graph
 
-   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,
-   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.
 
@@ -32,7 +30,7 @@
 
 #include "vm/global.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* defines ********************************************************************/
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool cfg_build(jitdata *jd);
 
 void cfg_add_root(jitdata *jd);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _CFG_H */
 
 
diff --git a/src/vm/jit/code.c b/src/vm/jit/code.c
deleted file mode 100644 (file)
index 3bdc467..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-/* src/vm/jit/code.c - codeinfo struct for representing compiled code
-
-   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 <stdint.h>
-
-#include "arch.h"
-
-#include "mm/memory.h"
-
-#include "vm/vm.h"
-
-#include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/methodtree.h"
-
-#include "vmcore/options.h"
-
-
-/* code_init *******************************************************************
-
-   Initialize the code-subsystem.
-
-*******************************************************************************/
-
-void code_init(void)
-{
-       /* Check if offset of codeinfo.m == 0 (see comment in code.h). */
-
-       if (OFFSET(codeinfo, m) != 0)
-               vm_abort("code_init: offset of codeinfo.m != 0: %d != 0", OFFSET(codeinfo, m));
-}
-
-
-/* code_codeinfo_new ***********************************************************
-
-   Create a new codeinfo for the given method.
-   
-   IN:
-       m................method to create a new codeinfo for
-
-   The following fields are set in codeinfo:
-       m
-       patchers
-
-   RETURN VALUE:
-       a new, initialized codeinfo, or
-          NULL if an exception occurred.
-  
-*******************************************************************************/
-
-codeinfo *code_codeinfo_new(methodinfo *m)
-{
-       codeinfo *code;
-
-       code = NEW(codeinfo);
-
-       code->m = m;
-
-       patcher_list_create(code);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_codeinfo += sizeof(codeinfo);
-#endif
-
-       return code;
-}
-
-
-/* code_find_codeinfo_for_pc ***************************************************
-
-   Return the codeinfo for the compilation unit that contains the
-   given PC.
-
-   ARGUMENTS:
-       pc...............machine code position
-
-   RETURN VALUE:
-       the codeinfo * for the given PC
-
-*******************************************************************************/
-
-codeinfo *code_find_codeinfo_for_pc(void *pc)
-{
-       void *pv;
-
-       pv = methodtree_find(pc);
-
-       return code_get_codeinfo_for_pv(pv);
-}
-
-
-/* code_find_codeinfo_for_pc ***************************************************
-
-   Return the codeinfo for the compilation unit that contains the
-   given PC. This method does not check the return value and is used
-   by the GC.
-
-   IN:
-       pc...............machine code position
-
-   RETURN VALUE:
-       the codeinfo * for the given PC, or NULL
-
-*******************************************************************************/
-
-codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc)
-{
-       void *pv;
-
-       pv = methodtree_find_nocheck(pc);
-
-       if (pv == NULL)
-               return NULL;
-
-       return code_get_codeinfo_for_pv(pv);
-}
-
-
-/* code_get_methodinfo_for_pv **************************************************
-
-   Return the methodinfo for the given PV.
-
-   IN:
-       pv...............PV
-
-   RETURN VALUE:
-       the methodinfo *
-
-*******************************************************************************/
-
-methodinfo *code_get_methodinfo_for_pv(void *pv)
-{
-       codeinfo *code;
-
-       code = code_get_codeinfo_for_pv(pv);
-
-       /* This is the case for asm_vm_call_method. */
-
-       if (code == NULL)
-               return NULL;
-
-       return code->m;
-}
-
-
-/* code_get_sync_slot_count ****************************************************
-
-   Return the number of stack slots used for storing the synchronized object
-   (and the return value around lock_monitor_exit calls) by the given code.
-   
-   IN:
-       code.............the codeinfo of the code in question
-                           (must be != NULL)
-
-   RETURN VALUE:
-       the number of stack slots used for synchronization
-  
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-int code_get_sync_slot_count(codeinfo *code)
-{
-#ifdef ENABLE_THREADS
-       int count;
-       
-       assert(code);
-
-       if (!checksync)
-               return 0;
-
-       if (!code_is_synchronized(code))
-               return 0;
-
-       count = 1;
-
-#ifdef HAS_4BYTE_STACKSLOT
-       /* long and double need 2 4-byte slots */
-       if (IS_2_WORD_TYPE(code->m->parseddesc->returntype.type))
-               count++;
-#endif
-
-#if defined(__POWERPC__)
-       /* powerpc needs an extra slot */
-       count++;
-#endif
-
-       return count;
-
-#else /* !ENABLE_THREADS */
-       
-       return 0;
-
-#endif /* ENABLE_THREADS */
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
-/* code_codeinfo_free **********************************************************
-
-   Free the memory used by a codeinfo.
-   
-   IN:
-       code.............the codeinfo to free
-
-*******************************************************************************/
-
-void code_codeinfo_free(codeinfo *code)
-{
-       if (code == NULL)
-               return;
-
-       if (code->mcode != NULL)
-               CFREE((void *) (ptrint) code->mcode, code->mcodelength);
-
-       patcher_list_free(code);
-
-#if defined(ENABLE_REPLACEMENT)
-       replace_free_replacement_points(code);
-#endif
-
-       FREE(code, codeinfo);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_codeinfo -= sizeof(codeinfo);
-#endif
-}
-
-
-/* code_free_code_of_method ****************************************************
-
-   Free all codeinfos of the given method
-   
-   IN:
-       m................the method of which the codeinfos are to be freed
-
-*******************************************************************************/
-
-void code_free_code_of_method(methodinfo *m)
-{
-       codeinfo *nextcode;
-       codeinfo *code;
-
-       if (!m)
-               return;
-       
-       nextcode = m->code;
-       while (nextcode) {
-               code = nextcode;
-               nextcode = code->prev;
-               code_codeinfo_free(code);
-       }
-
-       m->code = NULL;
-}
-
-/*
- * 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/jit/code.cpp b/src/vm/jit/code.cpp
new file mode 100644 (file)
index 0000000..b39852d
--- /dev/null
@@ -0,0 +1,289 @@
+/* src/vm/jit/code.cpp - codeinfo struct for representing compiled code
+
+   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 <stdint.h>
+
+#include "arch.h"
+
+#include "mm/memory.h"
+
+#include "vm/options.h"
+#include "vm/vm.hpp"
+
+#include "vm/jit/code.hpp"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/methodtree.h"
+
+
+/* code_init *******************************************************************
+
+   Initialize the code-subsystem.
+
+*******************************************************************************/
+
+void code_init(void)
+{
+       /* Check if offset of codeinfo.m == 0 (see comment in code.h). */
+
+       if (OFFSET(codeinfo, m) != 0)
+               vm_abort("code_init: offset of codeinfo.m != 0: %d != 0", OFFSET(codeinfo, m));
+}
+
+
+/* code_codeinfo_new ***********************************************************
+
+   Create a new codeinfo for the given method.
+   
+   IN:
+       m................method to create a new codeinfo for
+
+   The following fields are set in codeinfo:
+       m
+       patchers
+
+   RETURN VALUE:
+       a new, initialized codeinfo, or
+          NULL if an exception occurred.
+  
+*******************************************************************************/
+
+codeinfo *code_codeinfo_new(methodinfo *m)
+{
+       codeinfo *code;
+
+       code = NEW(codeinfo);
+
+       code->m = m;
+
+       patcher_list_create(code);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_codeinfo += sizeof(codeinfo);
+#endif
+
+       return code;
+}
+
+
+/* code_find_codeinfo_for_pc ***************************************************
+
+   Return the codeinfo for the compilation unit that contains the
+   given PC.
+
+   ARGUMENTS:
+       pc...............machine code position
+
+   RETURN VALUE:
+       the codeinfo * for the given PC
+
+*******************************************************************************/
+
+codeinfo *code_find_codeinfo_for_pc(void *pc)
+{
+       void *pv;
+
+       pv = methodtree_find(pc);
+
+       return code_get_codeinfo_for_pv(pv);
+}
+
+
+/* code_find_codeinfo_for_pc ***************************************************
+
+   Return the codeinfo for the compilation unit that contains the
+   given PC. This method does not check the return value and is used
+   by the GC.
+
+   IN:
+       pc...............machine code position
+
+   RETURN VALUE:
+       the codeinfo * for the given PC, or NULL
+
+*******************************************************************************/
+
+codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc)
+{
+       void *pv;
+
+       pv = methodtree_find_nocheck(pc);
+
+       if (pv == NULL)
+               return NULL;
+
+       return code_get_codeinfo_for_pv(pv);
+}
+
+
+/* code_get_methodinfo_for_pv **************************************************
+
+   Return the methodinfo for the given PV.
+
+   IN:
+       pv...............PV
+
+   RETURN VALUE:
+       the methodinfo *
+
+*******************************************************************************/
+
+methodinfo *code_get_methodinfo_for_pv(void *pv)
+{
+       codeinfo *code;
+
+       code = code_get_codeinfo_for_pv(pv);
+
+       /* This is the case for asm_vm_call_method. */
+
+       if (code == NULL)
+               return NULL;
+
+       return code->m;
+}
+
+
+/* code_get_sync_slot_count ****************************************************
+
+   Return the number of stack slots used for storing the synchronized object
+   (and the return value around lock_monitor_exit calls) by the given code.
+   
+   IN:
+       code.............the codeinfo of the code in question
+                           (must be != NULL)
+
+   RETURN VALUE:
+       the number of stack slots used for synchronization
+  
+*******************************************************************************/
+
+#if defined(ENABLE_REPLACEMENT)
+int code_get_sync_slot_count(codeinfo *code)
+{
+#ifdef ENABLE_THREADS
+       int count;
+       
+       assert(code);
+
+       if (!checksync)
+               return 0;
+
+       if (!code_is_synchronized(code))
+               return 0;
+
+       count = 1;
+
+#if defined(__POWERPC__)
+       /* powerpc needs an extra slot */
+       count++;
+#endif
+
+       return count;
+
+#else /* !ENABLE_THREADS */
+       
+       return 0;
+
+#endif /* ENABLE_THREADS */
+}
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+
+/* code_codeinfo_free **********************************************************
+
+   Free the memory used by a codeinfo.
+   
+   IN:
+       code.............the codeinfo to free
+
+*******************************************************************************/
+
+void code_codeinfo_free(codeinfo *code)
+{
+       if (code == NULL)
+               return;
+
+       if (code->mcode != NULL)
+               CFREE((void *) (ptrint) code->mcode, code->mcodelength);
+
+       patcher_list_free(code);
+
+#if defined(ENABLE_REPLACEMENT)
+       replace_free_replacement_points(code);
+#endif
+
+       FREE(code, codeinfo);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_codeinfo -= sizeof(codeinfo);
+#endif
+}
+
+
+/* code_free_code_of_method ****************************************************
+
+   Free all codeinfos of the given method
+   
+   IN:
+       m................the method of which the codeinfos are to be freed
+
+*******************************************************************************/
+
+void code_free_code_of_method(methodinfo *m)
+{
+       codeinfo *nextcode;
+       codeinfo *code;
+
+       if (!m)
+               return;
+       
+       nextcode = m->code;
+       while (nextcode) {
+               code = nextcode;
+               nextcode = code->prev;
+               code_codeinfo_free(code);
+       }
+
+       m->code = NULL;
+}
+
+/*
+ * 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/jit/code.h b/src/vm/jit/code.h
deleted file mode 100644 (file)
index adff257..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/* src/vm/jit/code.h - codeinfo struct for representing compiled code
-
-   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 _CODE_H
-#define _CODE_H
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "toolbox/list.h"
-
-#include "vm/global.h"
-
-#include "vm/jit/exceptiontable.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/methodheader.h"
-#include "vm/jit/replace.h"
-
-#include "vmcore/method.h"
-
-
-/* constants ******************************************************************/
-
-#define CODE_FLAG_INVALID         0x0001
-#define CODE_FLAG_LEAFMETHOD      0x0002
-#define CODE_FLAG_SYNCHRONIZED    0x0004
-
-
-/* codeinfo *******************************************************************
-
-   A codeinfo represents a particular realization of a method in
-   machine code.
-
-   ATTENTION: The methodinfo entry in the code-structure MUST have the
-   offset 0, otherwise we have a problem in our compiler stub. This is
-   checked with an assert in code_init().
-
-*******************************************************************************/
-
-struct codeinfo {
-       methodinfo   *m;                    /* method this is a realization of    */
-       codeinfo     *prev;                 /* previous codeinfo of this method   */
-
-       uint32_t      flags;                /* OR of CODE_FLAG_ constants         */
-
-       u1            optlevel;             /* optimization level of this code    */
-       s4            basicblockcount;      /* number of basic blocks             */
-
-       int32_t       synchronizedoffset;   /* stack offset of synchronized obj.  */
-
-       /* machine code */
-       u1           *mcode;                /* pointer to machine code            */
-       u1           *entrypoint;           /* machine code entry point           */
-       s4            mcodelength;          /* length of generated machine code   */
-
-       exceptiontable_t  *exceptiontable;
-       linenumbertable_t *linenumbertable;
-
-       /* patcher list */
-       list_t       *patchers;
-
-       /* replacement */                                   
-       s4            stackframesize;       /* size of the stackframe in slots    */
-
-#if defined(ENABLE_REPLACEMENT)
-       rplpoint     *rplpoints;            /* replacement points                 */
-       rplalloc     *regalloc;             /* register allocation info           */
-       s4            rplpointcount;        /* number of replacement points       */
-       s4            globalcount;          /* number of global allocations       */
-       s4            regalloccount;        /* number of total allocations        */
-       s4            memuse;               /* number of arg + local slots        */
-       u1            savedintcount;        /* number of callee saved int regs    */
-       u1            savedfltcount;        /* number of callee saved flt regs    */
-# if defined(HAS_ADDRESS_REGISTER_FILE)
-       u1            savedadrcount;        /* number of callee saved adr regs    */
-# endif
-       u1           *savedmcode;           /* saved code under patches           */
-#endif
-
-#if defined(ENABLE_PROFILING)
-       u4            frequency;            /* number of method invocations       */
-       u4           *bbfrequency;                  
-       s8            cycles;               /* number of cpu cycles               */
-#endif
-};
-
-
-/* inline functions ***********************************************************/
-
-/* code_xxx_invalid ************************************************************
-
-   Functions for CODE_FLAG_INVALID.
-
-*******************************************************************************/
-
-inline static int code_is_invalid(codeinfo *code)
-{
-       return (code->flags & CODE_FLAG_INVALID);
-}
-
-inline static void code_flag_invalid(codeinfo *code)
-{
-       code->flags |= CODE_FLAG_INVALID;
-}
-
-inline static void code_unflag_invalid(codeinfo *code)
-{
-       code->flags &= ~CODE_FLAG_INVALID;
-}
-
-
-/* code_xxx_leafmethod *********************************************************
-
-   Functions for CODE_FLAG_LEAFMETHOD.
-
-*******************************************************************************/
-
-inline static int code_is_leafmethod(codeinfo *code)
-{
-       return (code->flags & CODE_FLAG_LEAFMETHOD);
-}
-
-inline static void code_flag_leafmethod(codeinfo *code)
-{
-       code->flags |= CODE_FLAG_LEAFMETHOD;
-}
-
-inline static void code_unflag_leafmethod(codeinfo *code)
-{
-       code->flags &= ~CODE_FLAG_LEAFMETHOD;
-}
-
-
-/* code_xxx_synchronized *******************************************************
-
-   Functions for CODE_FLAG_SYNCHRONIZED.
-
-*******************************************************************************/
-
-inline static int code_is_synchronized(codeinfo *code)
-{
-       return (code->flags & CODE_FLAG_SYNCHRONIZED);
-}
-
-inline static void code_flag_synchronized(codeinfo *code)
-{
-       code->flags |= CODE_FLAG_SYNCHRONIZED;
-}
-
-inline static void code_unflag_synchronized(codeinfo *code)
-{
-       code->flags &= ~CODE_FLAG_SYNCHRONIZED;
-}
-
-
-/* code_get_codeinfo_for_pv ****************************************************
-
-   Return the codeinfo for the given PV.
-
-   IN:
-       pv...............PV
-
-   RETURN VALUE:
-       the codeinfo *
-
-*******************************************************************************/
-
-inline static codeinfo *code_get_codeinfo_for_pv(void *pv)
-{
-       codeinfo *code;
-
-       assert(pv != NULL);
-
-       code = *((codeinfo **) (((uintptr_t) pv) + CodeinfoPointer));
-
-       return code;
-}
-
-
-/* function prototypes ********************************************************/
-
-void code_init(void);
-
-codeinfo *code_codeinfo_new(methodinfo *m);
-void code_codeinfo_free(codeinfo *code);
-
-codeinfo *code_find_codeinfo_for_pc(void *pc);
-codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc);
-
-methodinfo *code_get_methodinfo_for_pv(void *pv);
-
-#if defined(ENABLE_REPLACEMENT)
-int code_get_sync_slot_count(codeinfo *code);
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-void code_free_code_of_method(methodinfo *m);
-
-#endif /* _CODE_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/jit/code.hpp b/src/vm/jit/code.hpp
new file mode 100644 (file)
index 0000000..0cbf0a2
--- /dev/null
@@ -0,0 +1,252 @@
+/* src/vm/jit/code.hpp - codeinfo struct for representing compiled code
+
+   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 _CODE_HPP
+#define _CODE_HPP
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "vm/types.h"
+
+#include "toolbox/list.hpp"
+
+#include "vm/global.h"
+#include "vm/method.hpp"
+
+#include "vm/jit/exceptiontable.h"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/methodheader.h"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
+
+
+/* constants ******************************************************************/
+
+#define CODE_FLAG_INVALID         0x0001
+#define CODE_FLAG_LEAFMETHOD      0x0002
+#define CODE_FLAG_SYNCHRONIZED    0x0004
+#define CODE_FLAG_TLH             0x0008
+
+
+/* codeinfo *******************************************************************
+
+   A codeinfo represents a particular realization of a method in
+   machine code.
+
+   ATTENTION: The methodinfo entry in the code-structure MUST have the
+   offset 0, otherwise we have a problem in our compiler stub. This is
+   checked with an assert in code_init().
+
+*******************************************************************************/
+
+struct codeinfo {
+       methodinfo   *m;                    /* method this is a realization of    */
+       codeinfo     *prev;                 /* previous codeinfo of this method   */
+
+       uint32_t      flags;                /* OR of CODE_FLAG_ constants         */
+
+       u1            optlevel;             /* optimization level of this code    */
+       s4            basicblockcount;      /* number of basic blocks             */
+
+       int32_t       synchronizedoffset;   /* stack offset of synchronized obj.  */
+
+       /* machine code */
+       u1           *mcode;                /* pointer to machine code            */
+       u1           *entrypoint;           /* machine code entry point           */
+       s4            mcodelength;          /* length of generated machine code   */
+
+       exceptiontable_t  *exceptiontable;
+       LinenumberTable* linenumbertable;
+
+       /* patcher list */
+#ifdef __cplusplus
+       List<patchref_t>* patchers;
+#else
+       List*         patchers;
+#endif
+
+       /* replacement */                                   
+       s4            stackframesize;       /* size of the stackframe in slots    */
+
+#if defined(ENABLE_REPLACEMENT)
+       rplpoint     *rplpoints;            /* replacement points                 */
+       rplalloc     *regalloc;             /* register allocation info           */
+       s4            rplpointcount;        /* number of replacement points       */
+       s4            globalcount;          /* number of global allocations       */
+       s4            regalloccount;        /* number of total allocations        */
+       s4            memuse;               /* number of arg + local slots        */
+       u1            savedintcount;        /* number of callee saved int regs    */
+       u1            savedfltcount;        /* number of callee saved flt regs    */
+# if defined(HAS_ADDRESS_REGISTER_FILE)
+       u1            savedadrcount;        /* number of callee saved adr regs    */
+# endif
+       u1           *savedmcode;           /* saved code under patches           */
+#endif
+
+#if defined(ENABLE_PROFILING)
+       u4            frequency;            /* number of method invocations       */
+       u4           *bbfrequency;                  
+       s8            cycles;               /* number of cpu cycles               */
+#endif
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* inline functions ***********************************************************/
+
+/* code_xxx_invalid ************************************************************
+
+   Functions for CODE_FLAG_INVALID.
+
+*******************************************************************************/
+
+inline static int code_is_invalid(codeinfo *code)
+{
+       return (code->flags & CODE_FLAG_INVALID);
+}
+
+inline static void code_flag_invalid(codeinfo *code)
+{
+       code->flags |= CODE_FLAG_INVALID;
+}
+
+inline static void code_unflag_invalid(codeinfo *code)
+{
+       code->flags &= ~CODE_FLAG_INVALID;
+}
+
+
+/* code_xxx_leafmethod *********************************************************
+
+   Functions for CODE_FLAG_LEAFMETHOD.
+
+*******************************************************************************/
+
+inline static int code_is_leafmethod(codeinfo *code)
+{
+       return (code->flags & CODE_FLAG_LEAFMETHOD);
+}
+
+inline static void code_flag_leafmethod(codeinfo *code)
+{
+       code->flags |= CODE_FLAG_LEAFMETHOD;
+}
+
+inline static void code_unflag_leafmethod(codeinfo *code)
+{
+       code->flags &= ~CODE_FLAG_LEAFMETHOD;
+}
+
+
+/* code_xxx_synchronized *******************************************************
+
+   Functions for CODE_FLAG_SYNCHRONIZED.
+
+*******************************************************************************/
+
+inline static int code_is_synchronized(codeinfo *code)
+{
+       return (code->flags & CODE_FLAG_SYNCHRONIZED);
+}
+
+inline static void code_flag_synchronized(codeinfo *code)
+{
+       code->flags |= CODE_FLAG_SYNCHRONIZED;
+}
+
+inline static void code_unflag_synchronized(codeinfo *code)
+{
+       code->flags &= ~CODE_FLAG_SYNCHRONIZED;
+}
+
+
+/* code_get_codeinfo_for_pv ****************************************************
+
+   Return the codeinfo for the given PV.
+
+   IN:
+       pv...............PV
+
+   RETURN VALUE:
+       the codeinfo *
+
+*******************************************************************************/
+
+inline static codeinfo *code_get_codeinfo_for_pv(void *pv)
+{
+       codeinfo *code;
+
+       assert(pv != NULL);
+
+       code = *((codeinfo **) (((uintptr_t) pv) + CodeinfoPointer));
+
+       return code;
+}
+
+
+/* function prototypes ********************************************************/
+
+void code_init(void);
+
+codeinfo *code_codeinfo_new(methodinfo *m);
+void code_codeinfo_free(codeinfo *code);
+
+codeinfo *code_find_codeinfo_for_pc(void *pc);
+codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc);
+
+methodinfo *code_get_methodinfo_for_pv(void *pv);
+
+#if defined(ENABLE_REPLACEMENT)
+int code_get_sync_slot_count(codeinfo *code);
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+void code_free_code_of_method(methodinfo *m);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _CODE_HPP
+
+
+/*
+ * 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/jit/codegen-common.c b/src/vm/jit/codegen-common.c
deleted file mode 100644 (file)
index 045a44c..0000000
+++ /dev/null
@@ -1,1657 +0,0 @@
-/* src/vm/jit/codegen-common.c - architecture independent code generator stuff
-
-   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.
-
-   All functions assume the following code area / data area layout:
-
-   +-----------+
-   |           |
-   | code area | code area grows to higher addresses
-   |           |
-   +-----------+ <-- start of procedure
-   |           |
-   | data area | data area grows to lower addresses
-   |           |
-   +-----------+
-
-   The functions first write into a temporary code/data area allocated by
-   "codegen_init". "codegen_finish" copies the code and data area into permanent
-   memory. All functions writing values into the data area return the offset
-   relative the begin of the code area (start of procedure).   
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "codegen.h"
-#include "md.h"
-#include "md-abi.h"
-
-#include "mm/memory.h"
-
-#include "toolbox/avl.h"
-#include "toolbox/list.h"
-#include "toolbox/logging.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/localref.h"
-#include "native/native.h"
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-# include "native/include/java_lang_Object.h"
-# include "native/include/java_lang_String.h"           /* required by j.l.CL */
-# include "native/include/java_nio_ByteBuffer.h"        /* required by j.l.CL */
-# include "native/include/java_lang_ClassLoader.h"
-#endif
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-# include "native/include/java_lang_String.h"
-#endif
-
-#include "native/include/java_lang_Class.h"
-
-#include "threads/thread.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-
-#include "vm/jit/abi.h"
-#include "vm/jit/asmpart.h"
-#include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
-
-#if defined(ENABLE_DISASSEMBLER)
-# include "vm/jit/disass.h"
-#endif
-
-#include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/methodheader.h"
-#include "vm/jit/methodtree.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/replace.h"
-#if defined(ENABLE_SSA)
-# include "vm/jit/optimizing/lsra.h"
-# include "vm/jit/optimizing/ssa.h"
-#endif
-#include "vm/jit/stacktrace.h"
-#include "vm/jit/trace.h"
-
-#if defined(ENABLE_INTRP)
-#include "vm/jit/intrp/intrp.h"
-#endif
-
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-
-# include "vmcore/statistics.h"
-
-#if defined(ENABLE_VMLOG)
-#include <vmlog_cacao.h>
-#endif
-
-#include "show.h"
-
-
-/* codegen_init ****************************************************************
-
-   TODO
-
-*******************************************************************************/
-
-void codegen_init(void)
-{
-}
-
-
-/* codegen_setup ***************************************************************
-
-   Allocates and initialises code area, data area and references.
-
-*******************************************************************************/
-
-void codegen_setup(jitdata *jd)
-{
-       methodinfo  *m;
-       codegendata *cd;
-
-       /* get required compiler data */
-
-       m  = jd->m;
-       cd = jd->cd;
-
-       /* initialize members */
-
-       cd->flags        = 0;
-
-       cd->mcodebase    = DMNEW(u1, MCODEINITSIZE);
-       cd->mcodeend     = cd->mcodebase + MCODEINITSIZE;
-       cd->mcodesize    = MCODEINITSIZE;
-
-       /* initialize mcode variables */
-
-       cd->mcodeptr     = cd->mcodebase;
-       cd->lastmcodeptr = cd->mcodebase;
-
-#if defined(ENABLE_INTRP)
-       /* native dynamic superinstructions variables */
-
-       if (opt_intrp) {
-               cd->ncodebase = DMNEW(u1, NCODEINITSIZE);
-               cd->ncodesize = NCODEINITSIZE;
-
-               /* initialize ncode variables */
-       
-               cd->ncodeptr = cd->ncodebase;
-
-               cd->lastinstwithoutdispatch = ~0; /* no inst without dispatch */
-               cd->superstarts = NULL;
-       }
-#endif
-
-       cd->dseg           = NULL;
-       cd->dseglen        = 0;
-
-       cd->jumpreferences = NULL;
-
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
-       cd->datareferences = NULL;
-#endif
-
-       cd->brancheslabel  = list_create_dump(OFFSET(branch_label_ref_t, linkage));
-       cd->listcritical   = list_create_dump(OFFSET(critical_section_ref_t, linkage));
-       cd->linenumbers    = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage));
-}
-
-
-/* codegen_reset ***************************************************************
-
-   Resets the codegen data structure so we can recompile the method.
-
-*******************************************************************************/
-
-static void codegen_reset(jitdata *jd)
-{
-       codeinfo    *code;
-       codegendata *cd;
-       basicblock  *bptr;
-
-       /* get required compiler data */
-
-       code = jd->code;
-       cd   = jd->cd;
-
-       /* reset error flag */
-
-       cd->flags          &= ~CODEGENDATA_FLAG_ERROR;
-
-       /* reset some members, we reuse the code memory already allocated
-          as this should have almost the correct size */
-
-       cd->mcodeptr        = cd->mcodebase;
-       cd->lastmcodeptr    = cd->mcodebase;
-
-       cd->dseg            = NULL;
-       cd->dseglen         = 0;
-
-       cd->jumpreferences  = NULL;
-
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
-       cd->datareferences  = NULL;
-#endif
-
-       cd->brancheslabel   = list_create_dump(OFFSET(branch_label_ref_t, linkage));
-       cd->listcritical    = list_create_dump(OFFSET(critical_section_ref_t, linkage));
-       cd->linenumbers     = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage));
-       
-       /* We need to clear the mpc and the branch references from all
-          basic blocks as they will definitely change. */
-
-       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
-               bptr->mpc        = -1;
-               bptr->branchrefs = NULL;
-       }
-
-       /* We need to clear all the patcher references from the codeinfo
-          since they all will be regenerated */
-
-       patcher_list_reset(code);
-
-#if defined(ENABLE_REPLACEMENT)
-       code->rplpoints     = NULL;
-       code->rplpointcount = 0;
-       code->regalloc      = NULL;
-       code->regalloccount = 0;
-       code->globalcount   = 0;
-#endif
-}
-
-
-/* codegen_generate ************************************************************
-
-   Generates the code for the currently compiled method.
-
-*******************************************************************************/
-
-bool codegen_generate(jitdata *jd)
-{
-       codegendata *cd;
-
-       /* get required compiler data */
-
-       cd = jd->cd;
-
-       /* call the machine-dependent code generation function */
-
-       if (!codegen_emit(jd))
-               return false;
-
-       /* check for an error */
-
-       if (CODEGENDATA_HAS_FLAG_ERROR(cd)) {
-               /* check for long-branches flag, if it is set we recompile the
-                  method */
-
-#if !defined(NDEBUG)
-        if (compileverbose)
-            log_message_method("Re-generating code: ", jd->m);
-#endif
-
-               /* XXX maybe we should tag long-branches-methods for recompilation */
-
-               if (CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) {
-                       /* we have to reset the codegendata structure first */
-
-                       codegen_reset(jd);
-
-                       /* and restart the compiler run */
-
-                       if (!codegen_emit(jd))
-                               return false;
-               }
-               else {
-                       vm_abort("codegen_generate: unknown error occurred during codegen_emit: flags=%x\n", cd->flags);
-               }
-
-#if !defined(NDEBUG)
-        if (compileverbose)
-            log_message_method("Re-generating code done: ", jd->m);
-#endif
-       }
-
-       /* reallocate the memory and finish the code generation */
-
-       codegen_finish(jd);
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* codegen_close ***************************************************************
-
-   TODO
-
-*******************************************************************************/
-
-void codegen_close(void)
-{
-       /* TODO: release avl tree on i386 and x86_64 */
-}
-
-
-/* codegen_increase ************************************************************
-
-   Doubles code area.
-
-*******************************************************************************/
-
-void codegen_increase(codegendata *cd)
-{
-       u1 *oldmcodebase;
-
-       /* save old mcodebase pointer */
-
-       oldmcodebase = cd->mcodebase;
-
-       /* reallocate to new, doubled memory */
-
-       cd->mcodebase = DMREALLOC(cd->mcodebase,
-                                                         u1,
-                                                         cd->mcodesize,
-                                                         cd->mcodesize * 2);
-       cd->mcodesize *= 2;
-       cd->mcodeend   = cd->mcodebase + cd->mcodesize;
-
-       /* set new mcodeptr */
-
-       cd->mcodeptr = cd->mcodebase + (cd->mcodeptr - oldmcodebase);
-
-#if defined(__I386__) || defined(__MIPS__) || defined(__X86_64__) || defined(__M68K__) || defined(ENABLE_INTRP) \
- || defined(__SPARC_64__)
-       /* adjust the pointer to the last patcher position */
-
-       if (cd->lastmcodeptr != NULL)
-               cd->lastmcodeptr = cd->mcodebase + (cd->lastmcodeptr - oldmcodebase);
-#endif
-}
-
-
-/* codegen_ncode_increase ******************************************************
-
-   Doubles code area.
-
-*******************************************************************************/
-
-#if defined(ENABLE_INTRP)
-u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr)
-{
-       u1 *oldncodebase;
-
-       /* save old ncodebase pointer */
-
-       oldncodebase = cd->ncodebase;
-
-       /* reallocate to new, doubled memory */
-
-       cd->ncodebase = DMREALLOC(cd->ncodebase,
-                                                         u1,
-                                                         cd->ncodesize,
-                                                         cd->ncodesize * 2);
-       cd->ncodesize *= 2;
-
-       /* return the new ncodeptr */
-
-       return (cd->ncodebase + (ncodeptr - oldncodebase));
-}
-#endif
-
-
-/* codegen_add_branch_ref ******************************************************
-
-   Prepends an branch to the list.
-
-*******************************************************************************/
-
-void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options)
-{
-       branchref *br;
-       s4         branchmpc;
-
-       STATISTICS(count_branches_unresolved++);
-
-       /* calculate the mpc of the branch instruction */
-
-       branchmpc = cd->mcodeptr - cd->mcodebase;
-
-       br = DNEW(branchref);
-
-       br->branchmpc = branchmpc;
-       br->condition = condition;
-       br->reg       = reg;
-       br->options   = options;
-       br->next      = target->branchrefs;
-
-       target->branchrefs = br;
-}
-
-
-/* codegen_resolve_branchrefs **************************************************
-
-   Resolves and patches the branch references of a given basic block.
-
-*******************************************************************************/
-
-void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr)
-{
-       branchref *br;
-       u1        *mcodeptr;
-
-       /* Save the mcodeptr because in the branch emitting functions
-          we generate code somewhere inside already generated code,
-          but we're still in the actual code generation phase. */
-
-       mcodeptr = cd->mcodeptr;
-
-       /* just to make sure */
-
-       assert(bptr->mpc >= 0);
-
-       for (br = bptr->branchrefs; br != NULL; br = br->next) {
-               /* temporary set the mcodeptr */
-
-               cd->mcodeptr = cd->mcodebase + br->branchmpc;
-
-               /* emit_bccz and emit_branch emit the correct code, even if we
-                  pass condition == BRANCH_UNCONDITIONAL or reg == -1. */
-
-               emit_bccz(cd, bptr, br->condition, br->reg, br->options);
-       }
-
-       /* restore mcodeptr */
-
-       cd->mcodeptr = mcodeptr;
-}
-
-
-/* codegen_branch_label_add ****************************************************
-
-   Append an branch to the label-branch list.
-
-*******************************************************************************/
-
-void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options)
-{
-       list_t             *l;
-       branch_label_ref_t *br;
-       s4                  mpc;
-
-       /* Get the label list. */
-
-       l = cd->brancheslabel;
-       
-       /* calculate the current mpc */
-
-       mpc = cd->mcodeptr - cd->mcodebase;
-
-       br = DNEW(branch_label_ref_t);
-
-       br->mpc       = mpc;
-       br->label     = label;
-       br->condition = condition;
-       br->reg       = reg;
-       br->options   = options;
-
-       /* Add the branch to the list. */
-
-       list_add_last(l, br);
-}
-
-
-/* codegen_critical_section_new ************************************************
-
-   Allocates a new critical-section reference and adds it to the
-   critical-section list.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void codegen_critical_section_new(codegendata *cd)
-{
-       list_t                 *l;
-       critical_section_ref_t *csr;
-       s4                      mpc;
-
-       /* Get the critical section list. */
-
-       l = cd->listcritical;
-       
-       /* calculate the current mpc */
-
-       mpc = cd->mcodeptr - cd->mcodebase;
-
-       csr = DNEW(critical_section_ref_t);
-
-       /* We only can set restart right now, as start and end are set by
-          the following, corresponding functions. */
-
-       csr->start   = -1;
-       csr->end     = -1;
-       csr->restart = mpc;
-
-       /* Add the branch to the list. */
-
-       list_add_last(l, csr);
-}
-#endif
-
-
-/* codegen_critical_section_start **********************************************
-
-   Set the start-point of the current critical section (which is the
-   last element of the list).
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void codegen_critical_section_start(codegendata *cd)
-{
-       list_t                 *l;
-       critical_section_ref_t *csr;
-       s4                      mpc;
-
-       /* Get the critical section list. */
-
-       l = cd->listcritical;
-       
-       /* calculate the current mpc */
-
-       mpc = cd->mcodeptr - cd->mcodebase;
-
-       /* Get the current critical section. */
-
-       csr = list_last(l);
-
-       /* set the start point */
-
-       assert(csr->start == -1);
-
-       csr->start = mpc;
-}
-#endif
-
-
-/* codegen_critical_section_end ************************************************
-
-   Set the end-point of the current critical section (which is the
-   last element of the list).
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void codegen_critical_section_end(codegendata *cd)
-{
-       list_t                 *l;
-       critical_section_ref_t *csr;
-       s4                      mpc;
-
-       /* Get the critical section list. */
-
-       l = cd->listcritical;
-       
-       /* calculate the current mpc */
-
-       mpc = cd->mcodeptr - cd->mcodebase;
-
-       /* Get the current critical section. */
-
-       csr = list_last(l);
-
-       /* set the end point */
-
-       assert(csr->end == -1);
-
-       csr->end = mpc;
-}
-#endif
-
-
-/* codegen_critical_section_finish *********************************************
-
-   Finish the critical sections, create the critical section nodes for
-   the AVL tree and insert them into the tree.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-static void codegen_critical_section_finish(jitdata *jd)
-{
-       codeinfo    *code;
-       codegendata *cd;
-       list_t                  *l;
-       critical_section_ref_t  *csr;
-       critical_section_node_t *csn;
-
-       /* get required compiler data */
-
-       code = jd->code;
-       cd   = jd->cd;
-
-       /* Get the critical section list. */
-
-       l = cd->listcritical;
-
-       /* iterate over all critical sections */
-
-       for (csr = list_first(l); csr != NULL; csr = list_next(l, csr)) {
-               /* check if all points are set */
-
-               assert(csr->start   != -1);
-               assert(csr->end     != -1);
-               assert(csr->restart != -1);
-
-               /* allocate tree node */
-
-               csn = NEW(critical_section_node_t);
-
-               csn->start   = code->entrypoint + csr->start;
-               csn->end     = code->entrypoint + csr->end;
-               csn->restart = code->entrypoint + csr->restart;
-
-               /* insert into the tree */
-
-               critical_section_register(csn);
-       }
-}
-#endif
-
-
-/* codegen_set_replacement_point_notrap ****************************************
-
-   Record the position of a non-trappable replacement point.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-#if !defined(NDEBUG)
-void codegen_set_replacement_point_notrap(codegendata *cd, s4 type)
-#else
-void codegen_set_replacement_point_notrap(codegendata *cd)
-#endif
-{
-       assert(cd->replacementpoint);
-       assert(cd->replacementpoint->type == type);
-       assert(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP);
-
-       cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
-
-       cd->replacementpoint++;
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
-/* codegen_set_replacement_point ***********************************************
-
-   Record the position of a trappable replacement point.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-#if !defined(NDEBUG)
-void codegen_set_replacement_point(codegendata *cd, s4 type)
-#else
-void codegen_set_replacement_point(codegendata *cd)
-#endif
-{
-       assert(cd->replacementpoint);
-       assert(cd->replacementpoint->type == type);
-       assert(!(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP));
-
-       cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
-
-       cd->replacementpoint++;
-
-#if !defined(NDEBUG)
-       /* XXX actually we should use an own REPLACEMENT_NOPS here! */
-       if (opt_TestReplacement)
-               PATCHER_NOPS;
-#endif
-
-       /* XXX assert(cd->lastmcodeptr <= cd->mcodeptr); */
-
-       cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE;
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
-/* codegen_finish **************************************************************
-
-   Finishes the code generation. A new memory, large enough for both
-   data and code, is allocated and data and code are copied together
-   to their final layout, unresolved jumps are resolved, ...
-
-*******************************************************************************/
-
-void codegen_finish(jitdata *jd)
-{
-       codeinfo    *code;
-       codegendata *cd;
-       s4           mcodelen;
-#if defined(ENABLE_INTRP)
-       s4           ncodelen;
-#endif
-       s4           alignedmcodelen;
-       jumpref     *jr;
-       u1          *epoint;
-       s4           alignedlen;
-
-       /* get required compiler data */
-
-       code = jd->code;
-       cd   = jd->cd;
-
-       /* prevent compiler warning */
-
-#if defined(ENABLE_INTRP)
-       ncodelen = 0;
-#endif
-
-       /* calculate the code length */
-
-       mcodelen = (s4) (cd->mcodeptr - cd->mcodebase);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat) {
-               count_code_len += mcodelen;
-               count_data_len += cd->dseglen;
-       }
-#endif
-
-       alignedmcodelen = MEMORY_ALIGN(mcodelen, MAX_ALIGN);
-
-#if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               ncodelen = cd->ncodeptr - cd->ncodebase;
-       else {
-               ncodelen = 0; /* avoid compiler warning */
-       }
-#endif
-
-       cd->dseglen = MEMORY_ALIGN(cd->dseglen, MAX_ALIGN);
-       alignedlen = alignedmcodelen + cd->dseglen;
-
-#if defined(ENABLE_INTRP)
-       if (opt_intrp) {
-               alignedlen += ncodelen;
-       }
-#endif
-
-       /* allocate new memory */
-
-       code->mcodelength = mcodelen + cd->dseglen;
-       code->mcode       = CNEW(u1, alignedlen);
-
-       /* set the entrypoint of the method */
-       
-       assert(code->entrypoint == NULL);
-       code->entrypoint = epoint = (code->mcode + cd->dseglen);
-
-       /* fill the data segment (code->entrypoint must already be set!) */
-
-       dseg_finish(jd);
-
-       /* copy code to the new location */
-
-       MCOPY((void *) code->entrypoint, cd->mcodebase, u1, mcodelen);
-
-#if defined(ENABLE_INTRP)
-       /* relocate native dynamic superinstruction code (if any) */
-
-       if (opt_intrp) {
-               cd->mcodebase = code->entrypoint;
-
-               if (ncodelen > 0) {
-                       u1 *ncodebase = code->mcode + cd->dseglen + alignedmcodelen;
-
-                       MCOPY((void *) ncodebase, cd->ncodebase, u1, ncodelen);
-
-                       /* flush the instruction and data caches */
-
-                       md_cacheflush(ncodebase, ncodelen);
-
-                       /* set some cd variables for dynamic_super_rerwite */
-
-                       cd->ncodebase = ncodebase;
-
-               } else {
-                       cd->ncodebase = NULL;
-               }
-
-               dynamic_super_rewrite(cd);
-       }
-#endif
-
-       /* Create the exception table. */
-
-       exceptiontable_create(jd);
-
-       /* Create the linenumber table. */
-
-       linenumbertable_create(jd);
-
-       /* jump table resolving */
-
-       for (jr = cd->jumpreferences; jr != NULL; jr = jr->next)
-               *((functionptr *) ((ptrint) epoint + jr->tablepos)) =
-                       (functionptr) ((ptrint) epoint + (ptrint) jr->target->mpc);
-
-       /* patcher resolving */
-
-       patcher_resolve(jd);
-
-#if defined(ENABLE_REPLACEMENT)
-       /* replacement point resolving */
-       {
-               int i;
-               rplpoint *rp;
-
-               rp = code->rplpoints;
-               for (i=0; i<code->rplpointcount; ++i, ++rp) {
-                       rp->pc = (u1*) ((ptrint) epoint + (ptrint) rp->pc);
-               }
-       }
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-       /* Insert method into methodtree to find the entrypoint. */
-
-       methodtree_insert(code->entrypoint, code->entrypoint + mcodelen);
-
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
-       /* resolve data segment references */
-
-       dseg_resolve_datareferences(jd);
-#endif
-
-#if defined(ENABLE_THREADS)
-       /* create cirtical sections */
-
-       codegen_critical_section_finish(jd);
-#endif
-
-       /* flush the instruction and data caches */
-
-       md_cacheflush(code->mcode, code->mcodelength);
-}
-
-
-/* codegen_generate_stub_compiler **********************************************
-
-   Wrapper for codegen_emit_stub_compiler.
-
-   Returns:
-       pointer to the compiler stub code.
-
-*******************************************************************************/
-
-u1 *codegen_generate_stub_compiler(methodinfo *m)
-{
-       jitdata     *jd;
-       codegendata *cd;
-       ptrint      *d;                     /* pointer to data memory             */
-       u1          *c;                     /* pointer to code memory             */
-       int32_t      dumpmarker;
-
-       /* mark dump memory */
-
-       DMARKER;
-
-       /* allocate required data structures */
-
-       jd = DNEW(jitdata);
-
-       jd->m     = m;
-       jd->cd    = DNEW(codegendata);
-       jd->flags = 0;
-
-       /* get required compiler data */
-
-       cd = jd->cd;
-
-#if !defined(JIT_COMPILER_VIA_SIGNAL)
-       /* allocate code memory */
-
-       c = CNEW(u1, 3 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE);
-
-       /* set pointers correctly */
-
-       d = (ptrint *) c;
-
-       cd->mcodebase = c;
-
-       c = c + 3 * SIZEOF_VOID_P;
-       cd->mcodeptr = c;
-
-       /* NOTE: The codeinfo pointer is actually a pointer to the
-          methodinfo (this fakes a codeinfo structure). */
-
-       d[0] = (ptrint) asm_call_jit_compiler;
-       d[1] = (ptrint) m;
-       d[2] = (ptrint) &d[1];                                    /* fake code->m */
-
-       /* call the emit function */
-
-       codegen_emit_stub_compiler(jd);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               count_cstub_len += 3 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE;
-#endif
-
-       /* flush caches */
-
-       md_cacheflush(cd->mcodebase, 3 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE);
-#else
-       /* Allocate code memory. */
-
-       c = CNEW(uint8_t, 2 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE);
-
-       /* Set pointers correctly. */
-
-       d = (ptrint *) c;
-
-       cd->mcodebase = c;
-
-       c = c + 2 * SIZEOF_VOID_P;
-       cd->mcodeptr = c;
-
-       /* NOTE: The codeinfo pointer is actually a pointer to the
-          methodinfo (this fakes a codeinfo structure). */
-
-       d[0] = (ptrint) m;
-       d[1] = (ptrint) &d[0];                                    /* fake code->m */
-
-       /* Emit the trap instruction. */
-
-       emit_trap_compiler(cd);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               count_cstub_len += 2 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE;
-#endif
-
-       /* Flush caches. */
-
-       md_cacheflush(cd->mcodebase, 2 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE);
-#endif
-
-       /* release dump memory */
-
-       DRELEASE;
-
-       /* return native stub code */
-
-       return c;
-}
-
-
-/* codegen_generate_stub_builtin ***********************************************
-
-   Wrapper for codegen_emit_stub_native.
-
-*******************************************************************************/
-
-void codegen_generate_stub_builtin(methodinfo *m, builtintable_entry *bte)
-{
-       jitdata  *jd;
-       codeinfo *code;
-       int       skipparams;
-       int32_t   dumpmarker;
-
-       /* mark dump memory */
-
-       DMARKER;
-
-       /* Create JIT data structure. */
-
-       jd = jit_jitdata_new(m);
-
-       /* Get required compiler data. */
-
-       code = jd->code;
-
-       /* Stubs are non-leaf methods. */
-
-       code_unflag_leafmethod(code);
-
-       /* setup code generation stuff */
-
-       codegen_setup(jd);
-
-       /* Set the number of native arguments we need to skip. */
-
-       skipparams = 0;
-
-       /* generate the code */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (!opt_intrp) {
-# endif
-               assert(bte->fp != NULL);
-               codegen_emit_stub_native(jd, bte->md, bte->fp, skipparams);
-# if defined(ENABLE_INTRP)
-       }
-# endif
-#endif
-
-       /* reallocate the memory and finish the code generation */
-
-       codegen_finish(jd);
-
-       /* set the stub entry point in the builtin table */
-
-       bte->stub = code->entrypoint;
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_stub_native += code->mcodelength;
-#endif
-
-#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
-       /* disassemble native stub */
-
-       if (opt_DisassembleStubs) {
-               codegen_disassemble_stub(m,
-                                                                (u1 *) (ptrint) code->entrypoint,
-                                                                (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen));
-
-               /* show data segment */
-
-               if (opt_showddatasegment)
-                       dseg_display(jd);
-       }
-#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */
-
-       /* release memory */
-
-       DRELEASE;
-}
-
-
-/* codegen_generate_stub_native ************************************************
-
-   Wrapper for codegen_emit_stub_native.
-
-   Returns:
-       the codeinfo representing the stub code.
-
-*******************************************************************************/
-
-codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f)
-{
-       jitdata     *jd;
-       codeinfo    *code;
-       methoddesc  *md;
-       methoddesc  *nmd;       
-       int          skipparams;
-       int32_t      dumpmarker;
-
-       /* mark dump memory */
-
-       DMARKER;
-
-       /* Create JIT data structure. */
-
-       jd = jit_jitdata_new(m);
-
-       /* Get required compiler data. */
-
-       code = jd->code;
-
-       /* Stubs are non-leaf methods. */
-
-       code_unflag_leafmethod(code);
-
-       /* set the flags for the current JIT run */
-
-#if defined(ENABLE_PROFILING)
-       if (opt_prof)
-               jd->flags |= JITDATA_FLAG_INSTRUMENT;
-#endif
-
-       if (opt_verbosecall)
-               jd->flags |= JITDATA_FLAG_VERBOSECALL;
-
-       /* setup code generation stuff */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (!opt_intrp)
-# endif
-               reg_setup(jd);
-#endif
-
-       codegen_setup(jd);
-
-       /* create new method descriptor with additional native parameters */
-
-       md = m->parseddesc;
-
-       /* Set the number of native arguments we need to skip. */
-
-       if (m->flags & ACC_STATIC)
-               skipparams = 2;
-       else
-               skipparams = 1;
-       
-       nmd = (methoddesc *) DMNEW(u1, sizeof(methoddesc) - sizeof(typedesc) +
-                                                          md->paramcount * sizeof(typedesc) +
-                                                          skipparams * sizeof(typedesc));
-
-       nmd->paramcount = md->paramcount + skipparams;
-
-       nmd->params = DMNEW(paramdesc, nmd->paramcount);
-
-       nmd->paramtypes[0].type = TYPE_ADR; /* add environment pointer            */
-
-       if (m->flags & ACC_STATIC)
-               nmd->paramtypes[1].type = TYPE_ADR; /* add class pointer              */
-
-       MCOPY(nmd->paramtypes + skipparams, md->paramtypes, typedesc,
-                 md->paramcount);
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (!opt_intrp)
-# endif
-               /* pre-allocate the arguments for the native ABI */
-
-               md_param_alloc_native(nmd);
-#endif
-
-       /* generate the code */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               intrp_createnativestub(f, jd, nmd);
-       else
-# endif
-               codegen_emit_stub_native(jd, nmd, f, skipparams);
-#else
-       intrp_createnativestub(f, jd, nmd);
-#endif
-
-       /* reallocate the memory and finish the code generation */
-
-       codegen_finish(jd);
-
-#if defined(ENABLE_STATISTICS)
-       /* must be done after codegen_finish() */
-
-       if (opt_stat)
-               size_stub_native += code->mcodelength;
-#endif
-
-#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
-       /* disassemble native stub */
-
-       if (opt_DisassembleStubs) {
-# if defined(ENABLE_DEBUG_FILTER)
-               if (m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
-# endif
-               {
-                       codegen_disassemble_stub(m,
-                                                                        (u1 *) (ptrint) code->entrypoint,
-                                                                        (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen));
-
-                       /* show data segment */
-
-                       if (opt_showddatasegment)
-                               dseg_display(jd);
-               }
-       }
-#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */
-
-       /* release memory */
-
-       DRELEASE;
-
-       /* return native stub code */
-
-       return code;
-}
-
-
-/* codegen_disassemble_nativestub **********************************************
-
-   Disassembles the generated builtin or native stub.
-
-*******************************************************************************/
-
-#if defined(ENABLE_DISASSEMBLER)
-void codegen_disassemble_stub(methodinfo *m, u1 *start, u1 *end)
-{
-       printf("Stub code: ");
-       if (m->clazz != NULL)
-               utf_fprint_printable_ascii_classname(stdout, m->clazz->name);
-       else
-               printf("NULL");
-       printf(".");
-       utf_fprint_printable_ascii(stdout, m->name);
-       utf_fprint_printable_ascii(stdout, m->descriptor);
-       printf("\nLength: %d\n\n", (s4) (end - start));
-
-       DISASSEMBLE(start, end);
-}
-#endif
-
-
-/* codegen_start_native_call ***************************************************
-
-   Prepares the stuff required for a native (JNI) function call:
-
-   - adds a stackframe info structure to the chain, for stacktraces
-   - prepares the local references table on the stack
-
-   The layout of the native stub stackframe should look like this:
-
-   +---------------------------+ <- java SP (of parent Java function)
-   | return address            |
-   +---------------------------+ <- data SP
-   |                           |
-   | stackframe info structure |
-   |                           |
-   +---------------------------+
-   |                           |
-   | local references table    |
-   |                           |
-   +---------------------------+
-   |                           |
-   | saved registers (if any)  |
-   |                           |
-   +---------------------------+
-   |                           |
-   | arguments (if any)        |
-   |                           |
-   +---------------------------+ <- current SP (native stub)
-
-*******************************************************************************/
-
-java_handle_t *codegen_start_native_call(u1 *sp, u1 *pv)
-{
-       stackframeinfo_t *sfi;
-       localref_table   *lrt;
-       methodinfo       *m;
-       int32_t           framesize;
-
-       uint8_t  *datasp;
-       uint8_t  *javasp;
-       uint64_t *arg_regs;
-       uint64_t *arg_stack;
-
-       STATISTICS(count_calls_java_to_native++);
-
-       /* Get the methodinfo. */
-
-       m = code_get_methodinfo_for_pv(pv);
-
-       assert(m);
-
-       framesize = *((int32_t *) (pv + FrameSize));
-
-       assert(framesize >= sizeof(stackframeinfo_t) + sizeof(localref_table));
-
-       /* calculate needed values */
-
-#if defined(__ALPHA__) || defined(__ARM__)
-       datasp    = sp + framesize - SIZEOF_VOID_P;
-       javasp    = sp + framesize;
-       arg_regs  = (uint64_t *) sp;
-       arg_stack = (uint64_t *) javasp;
-#elif defined(__MIPS__)
-       /* MIPS always uses 8 bytes to store the RA */
-       datasp    = sp + framesize - 8;
-       javasp    = sp + framesize;
-#elif defined(__S390__)
-       datasp    = sp + framesize - 8;
-       javasp    = sp + framesize;
-       arg_regs  = (uint64_t *) (sp + 96);
-       arg_stack = (uint64_t *) javasp;
-#elif defined(__I386__) || defined(__M68K__) || defined(__X86_64__)
-       datasp    = sp + framesize;
-       javasp    = sp + framesize + SIZEOF_VOID_P;
-       arg_regs  = (uint64_t *) sp;
-       arg_stack = (uint64_t *) javasp;
-#elif defined(__POWERPC__)
-       datasp    = sp + framesize;
-       javasp    = sp + framesize;
-       arg_regs  = (uint64_t *) (sp + LA_SIZE + 4 * SIZEOF_VOID_P);
-       arg_stack = (uint64_t *) javasp;
-#elif defined(__POWERPC64__)
-       datasp    = sp + framesize;
-       javasp    = sp + framesize;
-       arg_regs  = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 4 * SIZEOF_VOID_P);
-       arg_stack = (uint64_t *) javasp;
-#else
-       /* XXX is was unable to do this port for SPARC64, sorry. (-michi) */
-       /* XXX maybe we need to pass the RA as argument there */
-       vm_abort("codegen_start_native_call: unsupported architecture");
-#endif
-
-       /* get data structures from stack */
-
-       sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t));
-       lrt = (localref_table *)   (datasp - sizeof(stackframeinfo_t) - 
-                                                               sizeof(localref_table));
-
-#if defined(ENABLE_JNI)
-       /* add current JNI local references table to this thread */
-
-       localref_table_add(lrt);
-#endif
-
-#if !defined(NDEBUG)
-# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
-       /* print the call-trace if necesarry */
-       /* BEFORE: filling the local reference table */
-
-       if (opt_TraceJavaCalls)
-               trace_java_call_enter(m, arg_regs, arg_stack);
-# endif
-#endif
-
-#if defined(ENABLE_HANDLES)
-       /* place all references into the local reference table */
-       /* BEFORE: creating stackframeinfo */
-
-       localref_native_enter(m, arg_regs, arg_stack);
-#endif
-
-       /* Add a stackframeinfo for this native method.  We don't have RA
-          and XPC here.  These are determined in
-          stacktrace_stackframeinfo_add. */
-
-       stacktrace_stackframeinfo_add(sfi, pv, sp, NULL, NULL);
-
-       /* Return a wrapped classinfo for static methods. */
-
-       if (m->flags & ACC_STATIC)
-               return (java_handle_t *) LLNI_classinfo_wrap(m->clazz);
-       else
-               return NULL;
-}
-
-
-/* codegen_finish_native_call **************************************************
-
-   Removes the stuff required for a native (JNI) function call.
-   Additionally it checks for an exceptions and in case, get the
-   exception object and clear the pointer.
-
-*******************************************************************************/
-
-java_object_t *codegen_finish_native_call(u1 *sp, u1 *pv)
-{
-       stackframeinfo_t *sfi;
-       java_handle_t    *e;
-       java_object_t    *o;
-       codeinfo         *code;
-       methodinfo       *m;
-       int32_t           framesize;
-
-       uint8_t  *datasp;
-       uint64_t *ret_regs;
-
-       /* get information from method header */
-
-       code = code_get_codeinfo_for_pv(pv);
-
-       framesize = *((int32_t *) (pv + FrameSize));
-
-       assert(code);
-
-       /* get the methodinfo */
-
-       m = code->m;
-       assert(m);
-
-       /* calculate needed values */
-
-#if defined(__ALPHA__) || defined(__ARM__)
-       datasp   = sp + framesize - SIZEOF_VOID_P;
-       ret_regs = (uint64_t *) sp;
-#elif defined(__MIPS__)
-       /* MIPS always uses 8 bytes to store the RA */
-       datasp   = sp + framesize - 8;
-#elif defined(__S390__)
-       datasp   = sp + framesize - 8;
-       ret_regs = (uint64_t *) (sp + 96);
-#elif defined(__I386__)
-       datasp   = sp + framesize;
-       ret_regs = (uint64_t *) (sp + 2 * SIZEOF_VOID_P);
-#elif defined(__M68K__)
-       datasp   = sp + framesize;
-       ret_regs = (uint64_t *) (sp + 2 * 8);
-#elif defined(__X86_64__)
-       datasp   = sp + framesize;
-       ret_regs = (uint64_t *) sp;
-#elif defined(__POWERPC__)
-       datasp   = sp + framesize;
-       ret_regs = (uint64_t *) (sp + LA_SIZE + 2 * SIZEOF_VOID_P);
-#elif defined(__POWERPC64__)
-       datasp   = sp + framesize;
-       ret_regs = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 2 * SIZEOF_VOID_P);
-#else
-       vm_abort("codegen_finish_native_call: unsupported architecture");
-#endif
-
-       /* get data structures from stack */
-
-       sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t));
-
-       /* Remove current stackframeinfo from chain. */
-
-       stacktrace_stackframeinfo_remove(sfi);
-
-#if defined(ENABLE_HANDLES)
-       /* unwrap the return value from the local reference table */
-       /* AFTER: removing the stackframeinfo */
-       /* BEFORE: releasing the local reference table */
-
-       localref_native_exit(m, ret_regs);
-#endif
-
-       /* get and unwrap the exception */
-       /* AFTER: removing the stackframe info */
-       /* BEFORE: releasing the local reference table */
-
-       e = exceptions_get_and_clear_exception();
-       o = LLNI_UNWRAP(e);
-
-#if defined(ENABLE_JNI)
-       /* release JNI local references table for this thread */
-
-       localref_frame_pop_all();
-       localref_table_remove();
-#endif
-
-#if !defined(NDEBUG)
-# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
-       /* print the call-trace if necesarry */
-       /* AFTER: unwrapping the return value */
-
-       if (opt_TraceJavaCalls)
-               trace_java_call_exit(m, ret_regs);
-# endif
-#endif
-
-       return o;
-}
-
-
-/* removecompilerstub **********************************************************
-
-   Deletes a compilerstub from memory (simply by freeing it).
-
-*******************************************************************************/
-
-void removecompilerstub(u1 *stub)
-{
-       /* pass size 1 to keep the intern function happy */
-
-       CFREE((void *) stub, 1);
-}
-
-
-/* removenativestub ************************************************************
-
-   Removes a previously created native-stub from memory.
-    
-*******************************************************************************/
-
-void removenativestub(u1 *stub)
-{
-       /* pass size 1 to keep the intern function happy */
-
-       CFREE((void *) stub, 1);
-}
-
-
-/* codegen_reg_of_var **********************************************************
-
-   This function determines a register, to which the result of an
-   operation should go, when it is ultimatively intended to store the
-   result in pseudoregister v.  If v is assigned to an actual
-   register, this register will be returned.  Otherwise (when v is
-   spilled) this function returns tempregnum.  If not already done,
-   regoff and flags are set in the stack location.
-       
-*******************************************************************************/
-
-s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum)
-{
-       if (!(v->flags & INMEMORY))
-               return v->vv.regoff;
-
-       return tempregnum;
-}
-
-
-/* codegen_reg_of_dst **********************************************************
-
-   This function determines a register, to which the result of an
-   operation should go, when it is ultimatively intended to store the
-   result in iptr->dst.var.  If dst.var is assigned to an actual
-   register, this register will be returned.  Otherwise (when it is
-   spilled) this function returns tempregnum.  If not already done,
-   regoff and flags are set in the stack location.
-       
-*******************************************************************************/
-
-s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum)
-{
-       return codegen_reg_of_var(iptr->opc, VAROP(iptr->dst), tempregnum);
-}
-
-
-/* codegen_emit_phi_moves ****************************************************
-
-   Emits phi moves at the end of the basicblock.
-
-*******************************************************************************/
-
-#if defined(ENABLE_SSA)
-void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr)
-{
-       int lt_d,lt_s,i;
-       lsradata *ls;
-       codegendata *cd;
-       varinfo *s, *d;
-       instruction tmp_i;
-
-       cd = jd->cd;
-       ls = jd->ls;
-
-       MCODECHECK(512);
-
-       /* Moves from phi functions with highest indices have to be */
-       /* inserted first, since this is the order as is used for   */
-       /* conflict resolution */
-
-       for(i = ls->num_phi_moves[bptr->nr] - 1; i >= 0 ; i--) {
-               lt_d = ls->phi_moves[bptr->nr][i][0];
-               lt_s = ls->phi_moves[bptr->nr][i][1];
-#if defined(SSA_DEBUG_VERBOSE)
-               if (compileverbose)
-                       printf("BB %3i Move %3i <- %3i ", bptr->nr, lt_d, lt_s);
-#endif
-               if (lt_s == UNUSED) {
-#if defined(SSA_DEBUG_VERBOSE)
-               if (compileverbose)
-                       printf(" ... not processed \n");
-#endif
-                       continue;
-               }
-                       
-               d = VAR(ls->lifetime[lt_d].v_index);
-               s = VAR(ls->lifetime[lt_s].v_index);
-               
-
-               if (d->type == -1) {
-#if defined(SSA_DEBUG_VERBOSE)
-                       if (compileverbose)
-                               printf("...returning - phi lifetimes where joined\n");
-#endif
-                       continue;
-               }
-
-               if (s->type == -1) {
-#if defined(SSA_DEBUG_VERBOSE)
-                       if (compileverbose)
-                               printf("...returning - phi lifetimes where joined\n");
-#endif
-                       continue;
-               }
-
-               tmp_i.opc = 0;
-               tmp_i.s1.varindex = ls->lifetime[lt_s].v_index;
-               tmp_i.dst.varindex = ls->lifetime[lt_d].v_index;
-               emit_copy(jd, &tmp_i);
-
-#if defined(SSA_DEBUG_VERBOSE)
-               if (compileverbose) {
-                       if (IS_INMEMORY(d->flags) && IS_INMEMORY(s->flags)) {
-                               /* mem -> mem */
-                               printf("M%3i <- M%3i",d->vv.regoff,s->vv.regoff);
-                       }
-                       else if (IS_INMEMORY(s->flags)) {
-                               /* mem -> reg */
-                               printf("R%3i <- M%3i",d->vv.regoff,s->vv.regoff);
-                       }
-                       else if (IS_INMEMORY(d->flags)) {
-                               /* reg -> mem */
-                               printf("M%3i <- R%3i",d->vv.regoff,s->vv.regoff);
-                       }
-                       else {
-                               /* reg -> reg */
-                               printf("R%3i <- R%3i",d->vv.regoff,s->vv.regoff);
-                       }
-                       printf("\n");
-               }
-#endif /* defined(SSA_DEBUG_VERBOSE) */
-       }
-}
-#endif /* defined(ENABLE_SSA) */
-
-
-/* REMOVEME When we have exception handling in C. */
-
-void *md_asm_codegen_get_pv_from_pc(void *ra)
-{
-       return md_codegen_get_pv_from_pc(ra);
-}
-
-
-/*
- * 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/jit/codegen-common.cpp b/src/vm/jit/codegen-common.cpp
new file mode 100644 (file)
index 0000000..dd1768e
--- /dev/null
@@ -0,0 +1,1081 @@
+/* src/vm/jit/codegen-common.cpp - architecture independent code generator stuff
+
+   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.
+
+   All functions assume the following code area / data area layout:
+
+   +-----------+
+   |           |
+   | code area | code area grows to higher addresses
+   |           |
+   +-----------+ <-- start of procedure
+   |           |
+   | data area | data area grows to lower addresses
+   |           |
+   +-----------+
+
+   The functions first write into a temporary code/data area allocated by
+   "codegen_init". "codegen_finish" copies the code and data area into permanent
+   memory. All functions writing values into the data area return the offset
+   relative the begin of the code area (start of procedure).   
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "codegen.h"
+#include "md.h"
+#include "md-abi.h"
+
+#include "mm/memory.h"
+
+#include "toolbox/avl.h"
+#include "toolbox/list.hpp"
+#include "toolbox/logging.h"
+
+#include "native/llni.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
+
+#include "threads/thread.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/string.hpp"
+
+# include "vm/statistics.h"
+
+
+#include "vm/jit/abi.h"
+#include "vm/jit/asmpart.h"
+#include "vm/jit/code.hpp"
+#include "vm/jit/codegen-common.hpp"
+
+#if defined(ENABLE_DISASSEMBLER)
+# include "vm/jit/disass.h"
+#endif
+
+#include "vm/jit/dseg.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/methodheader.h"
+#include "vm/jit/methodtree.h"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
+#if defined(ENABLE_SSA)
+# include "vm/jit/optimizing/lsra.h"
+# include "vm/jit/optimizing/ssa.h"
+#endif
+#include "vm/jit/stacktrace.hpp"
+#include "vm/jit/trace.hpp"
+
+#if defined(ENABLE_INTRP)
+#include "vm/jit/intrp/intrp.h"
+#endif
+
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
+#include "show.hpp"
+
+
+/* codegen_init ****************************************************************
+
+   TODO
+
+*******************************************************************************/
+
+void codegen_init(void)
+{
+}
+
+
+/* codegen_setup ***************************************************************
+
+   Allocates and initialises code area, data area and references.
+
+*******************************************************************************/
+
+void codegen_setup(jitdata *jd)
+{
+       methodinfo  *m;
+       codegendata *cd;
+
+       /* get required compiler data */
+
+       m  = jd->m;
+       cd = jd->cd;
+
+       /* initialize members */
+
+       // Set flags as requested.
+       if (opt_AlwaysEmitLongBranches) {
+               cd->flags = CODEGENDATA_FLAG_LONGBRANCHES;
+       }
+       else {
+               cd->flags = 0;
+       }
+
+       cd->mcodebase    = (u1*) DumpMemory::allocate(MCODEINITSIZE);
+       cd->mcodeend     = cd->mcodebase + MCODEINITSIZE;
+       cd->mcodesize    = MCODEINITSIZE;
+
+       /* initialize mcode variables */
+
+       cd->mcodeptr     = cd->mcodebase;
+       cd->lastmcodeptr = cd->mcodebase;
+
+#if defined(ENABLE_INTRP)
+       /* native dynamic superinstructions variables */
+
+       if (opt_intrp) {
+               cd->ncodebase = (u1*) DumpMemory::allocate(NCODEINITSIZE);
+               cd->ncodesize = NCODEINITSIZE;
+
+               /* initialize ncode variables */
+       
+               cd->ncodeptr = cd->ncodebase;
+
+               cd->lastinstwithoutdispatch = ~0; /* no inst without dispatch */
+               cd->superstarts = NULL;
+       }
+#endif
+
+       cd->dseg           = NULL;
+       cd->dseglen        = 0;
+
+       cd->jumpreferences = NULL;
+
+#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
+       cd->datareferences = NULL;
+#endif
+
+       cd->brancheslabel  = new DumpList<branch_label_ref_t*>();
+       cd->linenumbers    = new DumpList<Linenumber>();
+}
+
+
+/* codegen_reset ***************************************************************
+
+   Resets the codegen data structure so we can recompile the method.
+
+*******************************************************************************/
+
+static void codegen_reset(jitdata *jd)
+{
+       codeinfo    *code;
+       codegendata *cd;
+       basicblock  *bptr;
+
+       /* get required compiler data */
+
+       code = jd->code;
+       cd   = jd->cd;
+
+       /* reset error flag */
+
+       cd->flags          &= ~CODEGENDATA_FLAG_ERROR;
+
+       /* reset some members, we reuse the code memory already allocated
+          as this should have almost the correct size */
+
+       cd->mcodeptr        = cd->mcodebase;
+       cd->lastmcodeptr    = cd->mcodebase;
+
+       cd->dseg            = NULL;
+       cd->dseglen         = 0;
+
+       cd->jumpreferences  = NULL;
+
+#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
+       cd->datareferences  = NULL;
+#endif
+
+       cd->brancheslabel   = new DumpList<branch_label_ref_t*>();
+       cd->linenumbers     = new DumpList<Linenumber>();
+       
+       /* We need to clear the mpc and the branch references from all
+          basic blocks as they will definitely change. */
+
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
+               bptr->mpc        = -1;
+               bptr->branchrefs = NULL;
+       }
+
+       /* We need to clear all the patcher references from the codeinfo
+          since they all will be regenerated */
+
+       patcher_list_reset(code);
+
+#if defined(ENABLE_REPLACEMENT)
+       code->rplpoints     = NULL;
+       code->rplpointcount = 0;
+       code->regalloc      = NULL;
+       code->regalloccount = 0;
+       code->globalcount   = 0;
+#endif
+}
+
+
+/* codegen_generate ************************************************************
+
+   Generates the code for the currently compiled method.
+
+*******************************************************************************/
+
+bool codegen_generate(jitdata *jd)
+{
+       codegendata *cd;
+
+       /* get required compiler data */
+
+       cd = jd->cd;
+
+       /* call the machine-dependent code generation function */
+
+       if (!codegen_emit(jd))
+               return false;
+
+       /* check for an error */
+
+       if (CODEGENDATA_HAS_FLAG_ERROR(cd)) {
+               /* check for long-branches flag, if it is set we recompile the
+                  method */
+
+#if !defined(NDEBUG)
+        if (compileverbose)
+            log_message_method("Re-generating code: ", jd->m);
+#endif
+
+               /* XXX maybe we should tag long-branches-methods for recompilation */
+
+               if (CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) {
+                       /* we have to reset the codegendata structure first */
+
+                       codegen_reset(jd);
+
+                       /* and restart the compiler run */
+
+                       if (!codegen_emit(jd))
+                               return false;
+               }
+               else {
+                       vm_abort("codegen_generate: unknown error occurred during codegen_emit: flags=%x\n", cd->flags);
+               }
+
+#if !defined(NDEBUG)
+        if (compileverbose)
+            log_message_method("Re-generating code done: ", jd->m);
+#endif
+       }
+
+       /* reallocate the memory and finish the code generation */
+
+       codegen_finish(jd);
+
+       /* everything's ok */
+
+       return true;
+}
+
+
+/* codegen_close ***************************************************************
+
+   TODO
+
+*******************************************************************************/
+
+void codegen_close(void)
+{
+       /* TODO: release avl tree on i386 and x86_64 */
+}
+
+
+/* codegen_increase ************************************************************
+
+   Doubles code area.
+
+*******************************************************************************/
+
+void codegen_increase(codegendata *cd)
+{
+       u1 *oldmcodebase;
+
+       /* save old mcodebase pointer */
+
+       oldmcodebase = cd->mcodebase;
+
+       /* reallocate to new, doubled memory */
+
+       cd->mcodebase = (u1*) DumpMemory::reallocate(cd->mcodebase,
+                                                                                                cd->mcodesize,
+                                                                                                cd->mcodesize * 2);
+       cd->mcodesize *= 2;
+       cd->mcodeend   = cd->mcodebase + cd->mcodesize;
+
+       /* set new mcodeptr */
+
+       cd->mcodeptr = cd->mcodebase + (cd->mcodeptr - oldmcodebase);
+
+#if defined(__I386__) || defined(__MIPS__) || defined(__X86_64__) || defined(__M68K__) || defined(ENABLE_INTRP) \
+ || defined(__SPARC_64__)
+       /* adjust the pointer to the last patcher position */
+
+       if (cd->lastmcodeptr != NULL)
+               cd->lastmcodeptr = cd->mcodebase + (cd->lastmcodeptr - oldmcodebase);
+#endif
+}
+
+
+/* codegen_ncode_increase ******************************************************
+
+   Doubles code area.
+
+*******************************************************************************/
+
+#if defined(ENABLE_INTRP)
+u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr)
+{
+       u1 *oldncodebase;
+
+       /* save old ncodebase pointer */
+
+       oldncodebase = cd->ncodebase;
+
+       /* reallocate to new, doubled memory */
+
+       cd->ncodebase = DMREALLOC(cd->ncodebase,
+                                                         u1,
+                                                         cd->ncodesize,
+                                                         cd->ncodesize * 2);
+       cd->ncodesize *= 2;
+
+       /* return the new ncodeptr */
+
+       return (cd->ncodebase + (ncodeptr - oldncodebase));
+}
+#endif
+
+
+/* codegen_add_branch_ref ******************************************************
+
+   Prepends an branch to the list.
+
+*******************************************************************************/
+
+void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options)
+{
+       branchref *br;
+       s4         branchmpc;
+
+       STATISTICS(count_branches_unresolved++);
+
+       /* calculate the mpc of the branch instruction */
+
+       branchmpc = cd->mcodeptr - cd->mcodebase;
+
+       br = (branchref*) DumpMemory::allocate(sizeof(branchref));
+
+       br->branchmpc = branchmpc;
+       br->condition = condition;
+       br->reg       = reg;
+       br->options   = options;
+       br->next      = target->branchrefs;
+
+       target->branchrefs = br;
+}
+
+
+/* codegen_resolve_branchrefs **************************************************
+
+   Resolves and patches the branch references of a given basic block.
+
+*******************************************************************************/
+
+void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr)
+{
+       branchref *br;
+       u1        *mcodeptr;
+
+       /* Save the mcodeptr because in the branch emitting functions
+          we generate code somewhere inside already generated code,
+          but we're still in the actual code generation phase. */
+
+       mcodeptr = cd->mcodeptr;
+
+       /* just to make sure */
+
+       assert(bptr->mpc >= 0);
+
+       for (br = bptr->branchrefs; br != NULL; br = br->next) {
+               /* temporary set the mcodeptr */
+
+               cd->mcodeptr = cd->mcodebase + br->branchmpc;
+
+               /* emit_bccz and emit_branch emit the correct code, even if we
+                  pass condition == BRANCH_UNCONDITIONAL or reg == -1. */
+
+               emit_bccz(cd, bptr, br->condition, br->reg, br->options);
+       }
+
+       /* restore mcodeptr */
+
+       cd->mcodeptr = mcodeptr;
+}
+
+
+/* codegen_branch_label_add ****************************************************
+
+   Append an branch to the label-branch list.
+
+*******************************************************************************/
+
+void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options)
+{
+       // Calculate the current mpc.
+       int32_t mpc = cd->mcodeptr - cd->mcodebase;
+
+       branch_label_ref_t* br = (branch_label_ref_t*) DumpMemory::allocate(sizeof(branch_label_ref_t));
+
+       br->mpc       = mpc;
+       br->label     = label;
+       br->condition = condition;
+       br->reg       = reg;
+       br->options   = options;
+
+       // Add the branch to the list.
+       cd->brancheslabel->push_back(br);
+}
+
+
+/* codegen_set_replacement_point_notrap ****************************************
+
+   Record the position of a non-trappable replacement point.
+
+*******************************************************************************/
+
+#if defined(ENABLE_REPLACEMENT)
+#if !defined(NDEBUG)
+void codegen_set_replacement_point_notrap(codegendata *cd, s4 type)
+#else
+void codegen_set_replacement_point_notrap(codegendata *cd)
+#endif
+{
+       assert(cd->replacementpoint);
+       assert(cd->replacementpoint->type == type);
+       assert(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP);
+
+       cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
+
+       cd->replacementpoint++;
+}
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+
+/* codegen_set_replacement_point ***********************************************
+
+   Record the position of a trappable replacement point.
+
+*******************************************************************************/
+
+#if defined(ENABLE_REPLACEMENT)
+#if !defined(NDEBUG)
+void codegen_set_replacement_point(codegendata *cd, s4 type)
+#else
+void codegen_set_replacement_point(codegendata *cd)
+#endif
+{
+       assert(cd->replacementpoint);
+       assert(cd->replacementpoint->type == type);
+       assert(!(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP));
+
+       cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
+
+       cd->replacementpoint++;
+
+#if !defined(NDEBUG)
+       /* XXX actually we should use an own REPLACEMENT_NOPS here! */
+       if (opt_TestReplacement)
+               PATCHER_NOPS;
+#endif
+
+       /* XXX assert(cd->lastmcodeptr <= cd->mcodeptr); */
+
+       cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE;
+}
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+
+/* codegen_finish **************************************************************
+
+   Finishes the code generation. A new memory, large enough for both
+   data and code, is allocated and data and code are copied together
+   to their final layout, unresolved jumps are resolved, ...
+
+*******************************************************************************/
+
+void codegen_finish(jitdata *jd)
+{
+       codeinfo    *code;
+       codegendata *cd;
+       s4           mcodelen;
+#if defined(ENABLE_INTRP)
+       s4           ncodelen;
+#endif
+       s4           alignedmcodelen;
+       jumpref     *jr;
+       u1          *epoint;
+       s4           alignedlen;
+
+       /* get required compiler data */
+
+       code = jd->code;
+       cd   = jd->cd;
+
+       /* prevent compiler warning */
+
+#if defined(ENABLE_INTRP)
+       ncodelen = 0;
+#endif
+
+       /* calculate the code length */
+
+       mcodelen = (s4) (cd->mcodeptr - cd->mcodebase);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat) {
+               count_code_len += mcodelen;
+               count_data_len += cd->dseglen;
+       }
+#endif
+
+       alignedmcodelen = MEMORY_ALIGN(mcodelen, MAX_ALIGN);
+
+#if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               ncodelen = cd->ncodeptr - cd->ncodebase;
+       else {
+               ncodelen = 0; /* avoid compiler warning */
+       }
+#endif
+
+       cd->dseglen = MEMORY_ALIGN(cd->dseglen, MAX_ALIGN);
+       alignedlen = alignedmcodelen + cd->dseglen;
+
+#if defined(ENABLE_INTRP)
+       if (opt_intrp) {
+               alignedlen += ncodelen;
+       }
+#endif
+
+       /* allocate new memory */
+
+       code->mcodelength = mcodelen + cd->dseglen;
+       code->mcode       = CNEW(u1, alignedlen);
+
+       /* set the entrypoint of the method */
+       
+       assert(code->entrypoint == NULL);
+       code->entrypoint = epoint = (code->mcode + cd->dseglen);
+
+       /* fill the data segment (code->entrypoint must already be set!) */
+
+       dseg_finish(jd);
+
+       /* copy code to the new location */
+
+       MCOPY((void *) code->entrypoint, cd->mcodebase, u1, mcodelen);
+
+#if defined(ENABLE_INTRP)
+       /* relocate native dynamic superinstruction code (if any) */
+
+       if (opt_intrp) {
+               cd->mcodebase = code->entrypoint;
+
+               if (ncodelen > 0) {
+                       u1 *ncodebase = code->mcode + cd->dseglen + alignedmcodelen;
+
+                       MCOPY((void *) ncodebase, cd->ncodebase, u1, ncodelen);
+
+                       /* flush the instruction and data caches */
+
+                       md_cacheflush(ncodebase, ncodelen);
+
+                       /* set some cd variables for dynamic_super_rerwite */
+
+                       cd->ncodebase = ncodebase;
+
+               } else {
+                       cd->ncodebase = NULL;
+               }
+
+               dynamic_super_rewrite(cd);
+       }
+#endif
+
+       /* Create the exception table. */
+
+       exceptiontable_create(jd);
+
+       /* Create the linenumber table. */
+
+       code->linenumbertable = new LinenumberTable(jd);
+
+       /* jump table resolving */
+
+       for (jr = cd->jumpreferences; jr != NULL; jr = jr->next)
+               *((functionptr *) ((ptrint) epoint + jr->tablepos)) =
+                       (functionptr) ((ptrint) epoint + (ptrint) jr->target->mpc);
+
+       /* patcher resolving */
+
+       patcher_resolve(jd);
+
+#if defined(ENABLE_REPLACEMENT)
+       /* replacement point resolving */
+       {
+               int i;
+               rplpoint *rp;
+
+               rp = code->rplpoints;
+               for (i=0; i<code->rplpointcount; ++i, ++rp) {
+                       rp->pc = (u1*) ((ptrint) epoint + (ptrint) rp->pc);
+               }
+       }
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+       /* Insert method into methodtree to find the entrypoint. */
+
+       methodtree_insert(code->entrypoint, code->entrypoint + mcodelen);
+
+#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
+       /* resolve data segment references */
+
+       dseg_resolve_datareferences(jd);
+#endif
+
+       /* flush the instruction and data caches */
+
+       md_cacheflush(code->mcode, code->mcodelength);
+}
+
+
+/* codegen_start_native_call ***************************************************
+
+   Prepares the stuff required for a native (JNI) function call:
+
+   - adds a stackframe info structure to the chain, for stacktraces
+   - prepares the local references table on the stack
+
+   The layout of the native stub stackframe should look like this:
+
+   +---------------------------+ <- java SP (of parent Java function)
+   | return address            |
+   +---------------------------+ <- data SP
+   |                           |
+   | stackframe info structure |
+   |                           |
+   +---------------------------+
+   |                           |
+   | local references table    |
+   |                           |
+   +---------------------------+
+   |                           |
+   | saved registers (if any)  |
+   |                           |
+   +---------------------------+
+   |                           |
+   | arguments (if any)        |
+   |                           |
+   +---------------------------+ <- current SP (native stub)
+
+*******************************************************************************/
+
+java_handle_t *codegen_start_native_call(u1 *sp, u1 *pv)
+{
+       stackframeinfo_t *sfi;
+       localref_table   *lrt;
+       methodinfo       *m;
+       int32_t           framesize;
+
+       uint8_t  *datasp;
+       uint8_t  *javasp;
+       uint64_t *arg_regs;
+       uint64_t *arg_stack;
+
+       STATISTICS(count_calls_java_to_native++);
+
+       /* Get the methodinfo. */
+
+       m = code_get_methodinfo_for_pv(pv);
+
+       assert(m);
+
+       framesize = *((int32_t *) (pv + FrameSize));
+
+       assert(framesize >= (int32_t) (sizeof(stackframeinfo_t) + sizeof(localref_table)));
+
+       /* calculate needed values */
+
+#if defined(__ALPHA__) || defined(__ARM__)
+       datasp    = sp + framesize - SIZEOF_VOID_P;
+       javasp    = sp + framesize;
+       arg_regs  = (uint64_t *) sp;
+       arg_stack = (uint64_t *) javasp;
+#elif defined(__MIPS__)
+       /* MIPS always uses 8 bytes to store the RA */
+       datasp    = sp + framesize - 8;
+       javasp    = sp + framesize;
+#elif defined(__S390__)
+       datasp    = sp + framesize - 8;
+       javasp    = sp + framesize;
+       arg_regs  = (uint64_t *) (sp + 96);
+       arg_stack = (uint64_t *) javasp;
+#elif defined(__I386__) || defined(__M68K__) || defined(__X86_64__)
+       datasp    = sp + framesize;
+       javasp    = sp + framesize + SIZEOF_VOID_P;
+       arg_regs  = (uint64_t *) sp;
+       arg_stack = (uint64_t *) javasp;
+#elif defined(__POWERPC__)
+       datasp    = sp + framesize;
+       javasp    = sp + framesize;
+       arg_regs  = (uint64_t *) (sp + LA_SIZE + 4 * SIZEOF_VOID_P);
+       arg_stack = (uint64_t *) javasp;
+#elif defined(__POWERPC64__)
+       datasp    = sp + framesize;
+       javasp    = sp + framesize;
+       arg_regs  = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 4 * SIZEOF_VOID_P);
+       arg_stack = (uint64_t *) javasp;
+#else
+       /* XXX is was unable to do this port for SPARC64, sorry. (-michi) */
+       /* XXX maybe we need to pass the RA as argument there */
+       vm_abort("codegen_start_native_call: unsupported architecture");
+#endif
+
+       /* get data structures from stack */
+
+       sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t));
+       lrt = (localref_table *)   (datasp - sizeof(stackframeinfo_t) - 
+                                                               sizeof(localref_table));
+
+#if defined(ENABLE_JNI)
+       /* add current JNI local references table to this thread */
+
+       localref_table_add(lrt);
+#endif
+
+#if !defined(NDEBUG)
+# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
+       /* print the call-trace if necesarry */
+       /* BEFORE: filling the local reference table */
+
+       if (opt_TraceJavaCalls)
+               trace_java_call_enter(m, arg_regs, arg_stack);
+# endif
+#endif
+
+#if defined(ENABLE_HANDLES)
+       /* place all references into the local reference table */
+       /* BEFORE: creating stackframeinfo */
+
+       localref_native_enter(m, arg_regs, arg_stack);
+#endif
+
+       /* Add a stackframeinfo for this native method.  We don't have RA
+          and XPC here.  These are determined in
+          stacktrace_stackframeinfo_add. */
+
+       stacktrace_stackframeinfo_add(sfi, pv, sp, NULL, NULL);
+
+       /* Return a wrapped classinfo for static methods. */
+
+       if (m->flags & ACC_STATIC)
+               return (java_handle_t *) LLNI_classinfo_wrap(m->clazz);
+       else
+               return NULL;
+}
+
+
+/* codegen_finish_native_call **************************************************
+
+   Removes the stuff required for a native (JNI) function call.
+   Additionally it checks for an exceptions and in case, get the
+   exception object and clear the pointer.
+
+*******************************************************************************/
+
+java_object_t *codegen_finish_native_call(u1 *sp, u1 *pv)
+{
+       stackframeinfo_t *sfi;
+       java_handle_t    *e;
+       java_object_t    *o;
+       codeinfo         *code;
+       methodinfo       *m;
+       int32_t           framesize;
+
+       uint8_t  *datasp;
+       uint64_t *ret_regs;
+
+       /* get information from method header */
+
+       code = code_get_codeinfo_for_pv(pv);
+
+       framesize = *((int32_t *) (pv + FrameSize));
+
+       assert(code);
+
+       /* get the methodinfo */
+
+       m = code->m;
+       assert(m);
+
+       /* calculate needed values */
+
+#if defined(__ALPHA__) || defined(__ARM__)
+       datasp   = sp + framesize - SIZEOF_VOID_P;
+       ret_regs = (uint64_t *) sp;
+#elif defined(__MIPS__)
+       /* MIPS always uses 8 bytes to store the RA */
+       datasp   = sp + framesize - 8;
+#elif defined(__S390__)
+       datasp   = sp + framesize - 8;
+       ret_regs = (uint64_t *) (sp + 96);
+#elif defined(__I386__)
+       datasp   = sp + framesize;
+       ret_regs = (uint64_t *) (sp + 2 * SIZEOF_VOID_P);
+#elif defined(__M68K__)
+       datasp   = sp + framesize;
+       ret_regs = (uint64_t *) (sp + 2 * 8);
+#elif defined(__X86_64__)
+       datasp   = sp + framesize;
+       ret_regs = (uint64_t *) sp;
+#elif defined(__POWERPC__)
+       datasp   = sp + framesize;
+       ret_regs = (uint64_t *) (sp + LA_SIZE + 2 * SIZEOF_VOID_P);
+#elif defined(__POWERPC64__)
+       datasp   = sp + framesize;
+       ret_regs = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 2 * SIZEOF_VOID_P);
+#else
+       vm_abort("codegen_finish_native_call: unsupported architecture");
+#endif
+
+       /* get data structures from stack */
+
+       sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t));
+
+       /* Remove current stackframeinfo from chain. */
+
+       stacktrace_stackframeinfo_remove(sfi);
+
+#if defined(ENABLE_HANDLES)
+       /* unwrap the return value from the local reference table */
+       /* AFTER: removing the stackframeinfo */
+       /* BEFORE: releasing the local reference table */
+
+       localref_native_exit(m, ret_regs);
+#endif
+
+       /* get and unwrap the exception */
+       /* AFTER: removing the stackframe info */
+       /* BEFORE: releasing the local reference table */
+
+       e = exceptions_get_and_clear_exception();
+       o = LLNI_UNWRAP(e);
+
+#if defined(ENABLE_JNI)
+       /* release JNI local references table for this thread */
+
+       localref_frame_pop_all();
+       localref_table_remove();
+#endif
+
+#if !defined(NDEBUG)
+# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
+       /* print the call-trace if necesarry */
+       /* AFTER: unwrapping the return value */
+
+       if (opt_TraceJavaCalls)
+               trace_java_call_exit(m, ret_regs);
+# endif
+#endif
+
+       return o;
+}
+
+
+/* codegen_reg_of_var **********************************************************
+
+   This function determines a register, to which the result of an
+   operation should go, when it is ultimatively intended to store the
+   result in pseudoregister v.  If v is assigned to an actual
+   register, this register will be returned.  Otherwise (when v is
+   spilled) this function returns tempregnum.  If not already done,
+   regoff and flags are set in the stack location.
+       
+*******************************************************************************/
+
+s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum)
+{
+       if (!(v->flags & INMEMORY))
+               return v->vv.regoff;
+
+       return tempregnum;
+}
+
+
+/* codegen_reg_of_dst **********************************************************
+
+   This function determines a register, to which the result of an
+   operation should go, when it is ultimatively intended to store the
+   result in iptr->dst.var.  If dst.var is assigned to an actual
+   register, this register will be returned.  Otherwise (when it is
+   spilled) this function returns tempregnum.  If not already done,
+   regoff and flags are set in the stack location.
+       
+*******************************************************************************/
+
+s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum)
+{
+       return codegen_reg_of_var(iptr->opc, VAROP(iptr->dst), tempregnum);
+}
+
+
+/* codegen_emit_phi_moves ****************************************************
+
+   Emits phi moves at the end of the basicblock.
+
+*******************************************************************************/
+
+#if defined(ENABLE_SSA)
+void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr)
+{
+       int lt_d,lt_s,i;
+       lsradata *ls;
+       codegendata *cd;
+       varinfo *s, *d;
+       instruction tmp_i;
+
+       cd = jd->cd;
+       ls = jd->ls;
+
+       MCODECHECK(512);
+
+       /* Moves from phi functions with highest indices have to be */
+       /* inserted first, since this is the order as is used for   */
+       /* conflict resolution */
+
+       for(i = ls->num_phi_moves[bptr->nr] - 1; i >= 0 ; i--) {
+               lt_d = ls->phi_moves[bptr->nr][i][0];
+               lt_s = ls->phi_moves[bptr->nr][i][1];
+#if defined(SSA_DEBUG_VERBOSE)
+               if (compileverbose)
+                       printf("BB %3i Move %3i <- %3i ", bptr->nr, lt_d, lt_s);
+#endif
+               if (lt_s == UNUSED) {
+#if defined(SSA_DEBUG_VERBOSE)
+               if (compileverbose)
+                       printf(" ... not processed \n");
+#endif
+                       continue;
+               }
+                       
+               d = VAR(ls->lifetime[lt_d].v_index);
+               s = VAR(ls->lifetime[lt_s].v_index);
+               
+
+               if (d->type == -1) {
+#if defined(SSA_DEBUG_VERBOSE)
+                       if (compileverbose)
+                               printf("...returning - phi lifetimes where joined\n");
+#endif
+                       continue;
+               }
+
+               if (s->type == -1) {
+#if defined(SSA_DEBUG_VERBOSE)
+                       if (compileverbose)
+                               printf("...returning - phi lifetimes where joined\n");
+#endif
+                       continue;
+               }
+
+               tmp_i.opc = 0;
+               tmp_i.s1.varindex = ls->lifetime[lt_s].v_index;
+               tmp_i.dst.varindex = ls->lifetime[lt_d].v_index;
+               emit_copy(jd, &tmp_i);
+
+#if defined(SSA_DEBUG_VERBOSE)
+               if (compileverbose) {
+                       if (IS_INMEMORY(d->flags) && IS_INMEMORY(s->flags)) {
+                               /* mem -> mem */
+                               printf("M%3i <- M%3i",d->vv.regoff,s->vv.regoff);
+                       }
+                       else if (IS_INMEMORY(s->flags)) {
+                               /* mem -> reg */
+                               printf("R%3i <- M%3i",d->vv.regoff,s->vv.regoff);
+                       }
+                       else if (IS_INMEMORY(d->flags)) {
+                               /* reg -> mem */
+                               printf("M%3i <- R%3i",d->vv.regoff,s->vv.regoff);
+                       }
+                       else {
+                               /* reg -> reg */
+                               printf("R%3i <- R%3i",d->vv.regoff,s->vv.regoff);
+                       }
+                       printf("\n");
+               }
+#endif /* defined(SSA_DEBUG_VERBOSE) */
+       }
+}
+#endif /* defined(ENABLE_SSA) */
+
+
+/* REMOVEME When we have exception handling in C. */
+
+void *md_asm_codegen_get_pv_from_pc(void *ra)
+{
+       return md_codegen_get_pv_from_pc(ra);
+}
+
+
+/*
+ * 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/jit/codegen-common.h b/src/vm/jit/codegen-common.h
deleted file mode 100644 (file)
index cf1ad7d..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-/* src/vm/jit/codegen-common.h - architecture independent code generator stuff
-
-   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
-
-   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 _CODEGEN_COMMON_H
-#define _CODEGEN_COMMON_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct codegendata            codegendata;
-typedef struct branchref              branchref;
-typedef struct branch_label_ref_t     branch_label_ref_t;
-typedef struct critical_section_ref_t critical_section_ref_t;
-typedef struct jumpref                jumpref;
-typedef struct dataref                dataref;
-typedef struct exceptionref           exceptionref;
-typedef struct linenumberref          linenumberref;
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/builtin.h"
-#include "vm/global.h"
-
-#include "vm/jit/dseg.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/reg.h"
-#include "vm/jit/code.h"
-#include "vm/jit/replace.h"
-
-#include "vmcore/descriptor.h"
-#include "vmcore/method.h"
-#include "vmcore/references.h"
-
-
-#define MCODEINITSIZE (1<<15)       /* 32 Kbyte code area initialization size */
-#define DSEGINITSIZE  (1<<12)       /*  4 Kbyte data area initialization size */
-
-#define NCODEINITSIZE (1<<15)       /* 32 Kbyte code area initialization size */
-
-
-/* Register Pack/Unpack Macros ************************************************/
-
-/* ATTENTION: Don't change the order where low and high bits are
-   stored! At least mips32 relies in one case on that order. */
-
-#define PACK_REGS(low,high) \
-    ( (((high) & 0x0000ffff) << 16) | ((low) & 0x0000ffff) )
-
-#define GET_LOW_REG(a)      ((a) & 0x0000ffff)
-#define GET_HIGH_REG(a)    (((a) & 0xffff0000) >> 16)
-
-
-/* branch conditions **********************************************************/
-
-#define BRANCH_UNCONDITIONAL    -1
-
-#define BRANCH_EQ               (ICMD_IFEQ - ICMD_IFEQ)
-#define BRANCH_NE               (ICMD_IFNE - ICMD_IFEQ)
-#define BRANCH_LT               (ICMD_IFLT - ICMD_IFEQ)
-#define BRANCH_GE               (ICMD_IFGE - ICMD_IFEQ)
-#define BRANCH_GT               (ICMD_IFGT - ICMD_IFEQ)
-#define BRANCH_LE               (ICMD_IFLE - ICMD_IFEQ)
-
-#define BRANCH_ULT              256
-#define BRANCH_ULE              257
-#define BRANCH_UGE              258
-#define BRANCH_UGT              259
-
-#define BRANCH_NAN              260
-
-
-/* common branch options ******************************************************/
-
-#define BRANCH_OPT_NONE         0
-
-
-/* codegendata ****************************************************************/
-
-struct codegendata {
-       u4              flags;          /* code generator flags                   */
-       u1             *mcodebase;      /* base pointer of code area              */
-       u1             *mcodeend;       /* pointer to end of code area            */
-       s4              mcodesize;      /* complete size of code area (bytes)     */
-       u1             *mcodeptr;       /* code generation pointer                */
-       u1             *lastmcodeptr;   /* last patcher position of basic block   */
-
-#if defined(ENABLE_INTRP)
-       u1             *ncodebase;      /* base pointer of native code area       */
-       s4              ncodesize;      /* complete size of native code area      */
-       u1             *ncodeptr;       /* native code generation pointer         */
-
-       u4              lastinstwithoutdispatch; /* ~0 if there was a dispatch    */
-
-       s4              lastpatcheroffset; /* -1 if current super has no patcher  */
-       s4              dynsuperm;      /* offsets of start of current dynamic ...*/
-       s4              dynsupern;      /* ... superinstruction starts            */
-       struct superstart *superstarts; /* list of supers without patchers        */
-#endif
-
-       dsegentry      *dseg;           /* chain of data segment entries          */
-       s4              dseglen;        /* used size of data area (bytes)         */
-                                    /* data area grows from top to bottom     */
-
-       jumpref        *jumpreferences; /* list of jumptable target addresses     */
-
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) || defined(__S390__)
-       dataref        *datareferences; /* list of data segment references        */
-#endif
-
-       list_t         *brancheslabel;
-       list_t         *listcritical;   /* list of critical sections              */
-       list_t         *linenumbers;    /* list of line numbers                   */
-
-       methodinfo     *method;
-
-       s4              stackframesize;    /* stackframe size of this method      */
-
-#if defined(ENABLE_REPLACEMENT)
-       rplpoint       *replacementpoint;  /* current replacement point           */
-#endif
-};
-
-
-#define CODEGENDATA_FLAG_ERROR           0x00000001
-#define CODEGENDATA_FLAG_LONGBRANCHES    0x00000002
-
-
-#define CODEGENDATA_HAS_FLAG_ERROR(cd) \
-    ((cd)->flags & CODEGENDATA_FLAG_ERROR)
-
-#define CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd) \
-    ((cd)->flags & CODEGENDATA_FLAG_LONGBRANCHES)
-
-
-/* branchref *****************************************************************/
-
-struct branchref {
-       s4         branchmpc;       /* patching position in code segment          */
-       s4         condition;       /* conditional branch condition               */
-       s4         reg;             /* register number to check                   */
-       u4         options;         /* branch options                             */
-       branchref *next;            /* next element in branchref list             */
-};
-
-
-/* branch_label_ref_t *********************************************************/
-
-struct branch_label_ref_t {
-       s4         mpc;             /* position in code segment                   */
-       s4         label;           /* label number                               */
-       s4         condition;       /* conditional branch condition               */
-       s4         reg;             /* register number to check                   */
-       u4         options;         /* branch options                             */
-       listnode_t linkage;
-};
-
-
-/* critical_section_ref_t *****************************************************/
-
-struct critical_section_ref_t {
-       s4         start;           /* relative offset to method entry-point      */
-       s4         end;
-       s4         restart;
-       listnode_t linkage;
-};
-
-
-/* jumpref ********************************************************************/
-
-struct jumpref {
-       s4          tablepos;       /* patching position in data segment          */
-       basicblock *target;         /* target basic block                         */
-       jumpref    *next;           /* next element in jumpref list               */
-};
-
-
-/* dataref ********************************************************************/
-
-struct dataref {
-       s4       datapos;           /* patching position in generated code        */
-       dataref *next;              /* next element in dataref list               */
-};
-
-
-/* linenumberref **************************************************************/
-
-struct linenumberref {
-       s4             tablepos;    /* patching position in data segment          */
-       s4             linenumber;  /* line number, used for inserting into the   */
-                                   /* table and for validity checking            */
-                                   /* -1......start of inlined body              */
-                                   /* -2......end of inlined body                */
-                                   /* <= -3...special entry with methodinfo *    */
-                                                               /* (see doc/inlining_stacktrace.txt)          */
-       ptrint         targetmpc;   /* machine code program counter of first      */
-                                   /* instruction for given line                 */
-                                                               /* NOTE: for linenumber <= -3 this is a the   */
-                                   /* (methodinfo *) of the inlined method       */
-       linenumberref *next;        /* next element in linenumberref list         */
-};
-
-
-/* function prototypes ********************************************************/
-
-void codegen_init(void);
-void codegen_setup(jitdata *jd);
-
-bool codegen_generate(jitdata *jd);
-bool codegen_emit(jitdata *jd);
-
-#if defined(ENABLE_INTRP)
-bool intrp_codegen(jitdata *jd);
-#endif
-
-void codegen_close(void);
-
-void codegen_increase(codegendata *cd);
-
-#if defined(ENABLE_INTRP)
-u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr);
-#endif
-
-void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options);
-void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr);
-
-void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options);
-
-#if defined(ENABLE_REPLACEMENT)
-#if !defined(NDEBUG)
-void codegen_set_replacement_point_notrap(codegendata *cd, s4 type);
-void codegen_set_replacement_point(codegendata *cd, s4 type);
-#else
-void codegen_set_replacement_point_notrap(codegendata *cd);
-void codegen_set_replacement_point(codegendata *cd);
-#endif
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-void codegen_finish(jitdata *jd);
-
-#if defined(ENABLE_DISASSEMBLER)
-void codegen_disassemble_stub(methodinfo *m, u1 *start, u1 *end);
-#endif
-
-/* stub functions */
-
-u1       *codegen_generate_stub_compiler(methodinfo *m);
-void      codegen_generate_stub_builtin(methodinfo *m, builtintable_entry *bte);
-codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f);
-
-#if !defined(JIT_COMPILER_VIA_SIGNAL)
-void      codegen_emit_stub_compiler(jitdata *jd);
-#endif
-void      codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int skipparams);
-
-#if defined(ENABLE_INTRP)
-u1 *intrp_createcompilerstub(methodinfo *m);
-u1 *intrp_createnativestub(functionptr f, jitdata *jd, methoddesc *md);
-#endif
-
-void removecompilerstub(u1 *stub);
-void removenativestub(u1 *stub);
-
-java_handle_t *codegen_start_native_call(u1 *currentsp, u1 *pv);
-java_object_t *codegen_finish_native_call(u1 *currentsp, u1 *pv);
-
-s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum);
-s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum);
-
-#if defined(ENABLE_THREADS)
-void codegen_critical_section_new(codegendata *cd);
-void codegen_critical_section_start(codegendata *cd);
-void codegen_critical_section_end(codegendata *cd);
-
-# define CODEGEN_CRITICAL_SECTION_NEW      codegen_critical_section_new(cd)
-# define CODEGEN_CRITICAL_SECTION_START    codegen_critical_section_start(cd)
-# define CODEGEN_CRITICAL_SECTION_END      codegen_critical_section_end(cd)
-#else
-# define CODEGEN_CRITICAL_SECTION_NEW      /* no-op */
-# define CODEGEN_CRITICAL_SECTION_START    /* no-op */
-# define CODEGEN_CRITICAL_SECTION_END      /* no-op */
-#endif
-
-#if defined(ENABLE_SSA)
-void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr);
-#endif
-
-#endif /* _CODEGEN_COMMON_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/jit/codegen-common.hpp b/src/vm/jit/codegen-common.hpp
new file mode 100644 (file)
index 0000000..98a7142
--- /dev/null
@@ -0,0 +1,276 @@
+/* src/vm/jit/codegen-common.hpp - architecture independent code generator stuff
+
+   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 _CODEGEN_COMMON_HPP
+#define _CODEGEN_COMMON_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct codegendata            codegendata;
+typedef struct branchref              branchref;
+typedef struct branch_label_ref_t     branch_label_ref_t;
+typedef struct jumpref                jumpref;
+typedef struct dataref                dataref;
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "toolbox/list.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/descriptor.h"
+#include "vm/global.h"
+#include "vm/method.hpp"
+#include "vm/references.h"
+
+#include "vm/jit/dseg.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/reg.h"
+#include "vm/jit/code.hpp"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/replace.hpp"
+
+
+#define MCODEINITSIZE (1<<15)       /* 32 Kbyte code area initialization size */
+#define DSEGINITSIZE  (1<<12)       /*  4 Kbyte data area initialization size */
+
+#define NCODEINITSIZE (1<<15)       /* 32 Kbyte code area initialization size */
+
+
+/* Register Pack/Unpack Macros ************************************************/
+
+/* ATTENTION: Don't change the order where low and high bits are
+   stored! At least mips32 relies in one case on that order. */
+
+#define PACK_REGS(low,high) \
+    ( (((high) & 0x0000ffff) << 16) | ((low) & 0x0000ffff) )
+
+#define GET_LOW_REG(a)      ((a) & 0x0000ffff)
+#define GET_HIGH_REG(a)    (((a) & 0xffff0000) >> 16)
+
+
+/* branch conditions **********************************************************/
+
+#define BRANCH_UNCONDITIONAL    -1
+
+#define BRANCH_EQ               (ICMD_IFEQ - ICMD_IFEQ)
+#define BRANCH_NE               (ICMD_IFNE - ICMD_IFEQ)
+#define BRANCH_LT               (ICMD_IFLT - ICMD_IFEQ)
+#define BRANCH_GE               (ICMD_IFGE - ICMD_IFEQ)
+#define BRANCH_GT               (ICMD_IFGT - ICMD_IFEQ)
+#define BRANCH_LE               (ICMD_IFLE - ICMD_IFEQ)
+
+#define BRANCH_ULT              256
+#define BRANCH_ULE              257
+#define BRANCH_UGE              258
+#define BRANCH_UGT              259
+
+#define BRANCH_NAN              260
+
+
+/* common branch options ******************************************************/
+
+#define BRANCH_OPT_NONE         0
+
+
+/* codegendata ****************************************************************/
+
+struct codegendata {
+       u4              flags;          /* code generator flags                   */
+       u1             *mcodebase;      /* base pointer of code area              */
+       u1             *mcodeend;       /* pointer to end of code area            */
+       s4              mcodesize;      /* complete size of code area (bytes)     */
+       u1             *mcodeptr;       /* code generation pointer                */
+       u1             *lastmcodeptr;   /* last patcher position of basic block   */
+
+#if defined(ENABLE_INTRP)
+       u1             *ncodebase;      /* base pointer of native code area       */
+       s4              ncodesize;      /* complete size of native code area      */
+       u1             *ncodeptr;       /* native code generation pointer         */
+
+       u4              lastinstwithoutdispatch; /* ~0 if there was a dispatch    */
+
+       s4              lastpatcheroffset; /* -1 if current super has no patcher  */
+       s4              dynsuperm;      /* offsets of start of current dynamic ...*/
+       s4              dynsupern;      /* ... superinstruction starts            */
+       struct superstart *superstarts; /* list of supers without patchers        */
+#endif
+
+       dsegentry      *dseg;           /* chain of data segment entries          */
+       s4              dseglen;        /* used size of data area (bytes)         */
+                                    /* data area grows from top to bottom     */
+
+       jumpref        *jumpreferences; /* list of jumptable target addresses     */
+
+#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) || defined(__S390__)
+       dataref        *datareferences; /* list of data segment references        */
+#endif
+
+#ifdef __cplusplus
+       DumpList<branch_label_ref_t*>* brancheslabel;
+       DumpList<Linenumber>* linenumbers; ///< List of line numbers.
+#else
+       // REMOVEME
+       DumpList* brancheslabel;
+       DumpList* linenumbers;
+#endif
+
+       methodinfo     *method;
+
+       s4              stackframesize;    /* stackframe size of this method      */
+
+#if defined(ENABLE_REPLACEMENT)
+       rplpoint       *replacementpoint;  /* current replacement point           */
+#endif
+};
+
+
+#define CODEGENDATA_FLAG_ERROR           0x00000001
+#define CODEGENDATA_FLAG_LONGBRANCHES    0x00000002
+
+
+#define CODEGENDATA_HAS_FLAG_ERROR(cd) \
+    ((cd)->flags & CODEGENDATA_FLAG_ERROR)
+
+#define CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd) \
+    ((cd)->flags & CODEGENDATA_FLAG_LONGBRANCHES)
+
+
+/* branchref *****************************************************************/
+
+struct branchref {
+       s4         branchmpc;       /* patching position in code segment          */
+       s4         condition;       /* conditional branch condition               */
+       s4         reg;             /* register number to check                   */
+       u4         options;         /* branch options                             */
+       branchref *next;            /* next element in branchref list             */
+};
+
+
+/* branch_label_ref_t *********************************************************/
+
+struct branch_label_ref_t {
+       s4         mpc;             /* position in code segment                   */
+       s4         label;           /* label number                               */
+       s4         condition;       /* conditional branch condition               */
+       s4         reg;             /* register number to check                   */
+       u4         options;         /* branch options                             */
+/*     listnode_t linkage; */
+};
+
+
+/* jumpref ********************************************************************/
+
+struct jumpref {
+       s4          tablepos;       /* patching position in data segment          */
+       basicblock *target;         /* target basic block                         */
+       jumpref    *next;           /* next element in jumpref list               */
+};
+
+
+/* dataref ********************************************************************/
+
+struct dataref {
+       s4       datapos;           /* patching position in generated code        */
+       dataref *next;              /* next element in dataref list               */
+};
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void codegen_init(void);
+void codegen_setup(jitdata *jd);
+
+bool codegen_generate(jitdata *jd);
+bool codegen_emit(jitdata *jd);
+
+#if defined(ENABLE_INTRP)
+bool intrp_codegen(jitdata *jd);
+#endif
+
+void codegen_close(void);
+
+void codegen_increase(codegendata *cd);
+
+#if defined(ENABLE_INTRP)
+u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr);
+#endif
+
+void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options);
+void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr);
+
+void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options);
+
+#if defined(ENABLE_REPLACEMENT)
+#if !defined(NDEBUG)
+void codegen_set_replacement_point_notrap(codegendata *cd, s4 type);
+void codegen_set_replacement_point(codegendata *cd, s4 type);
+#else
+void codegen_set_replacement_point_notrap(codegendata *cd);
+void codegen_set_replacement_point(codegendata *cd);
+#endif
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+void codegen_finish(jitdata *jd);
+
+java_handle_t *codegen_start_native_call(u1 *currentsp, u1 *pv);
+java_object_t *codegen_finish_native_call(u1 *currentsp, u1 *pv);
+
+s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum);
+s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum);
+
+#if defined(ENABLE_SSA)
+void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr);
+#endif
+
+// REMOVEME
+void codegen_emit_stub_compiler(jitdata *jd);
+void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int skipparams);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _CODEGEN_COMMON_HPP
+
+
+/*
+ * 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 3b2280a9faf7e0a804e90579fb20446e40cb4538..02eae59e06e2207bea4593e53f873186a017633f 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/disass.h - disassembler header
 
-   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.
 
@@ -48,9 +46,9 @@
 #define DISASSINSTR(code) \
     do { \
         if (opt_intrp) \
-            (code) = intrp_disassinstr((code)); \
+            (code) = intrp_disassinstr((u1*) (code));  \
         else \
-            (code) = disassinstr((code)); \
+            (code) = disassinstr((u1*) (code));        \
     } while (0)
 
 #define DISASSEMBLE(start,end) \
@@ -64,7 +62,7 @@
 # else /* defined(ENABLE_INTRP) */
 
 #define DISASSINSTR(code) \
-    (code) = disassinstr((code))
+    (code) = disassinstr((u1*) (code))
 
 #define DISASSEMBLE(start,end) \
     disassemble((start), (end))
@@ -73,7 +71,7 @@
 #else /* defined(ENABLE_JIT) */
 
 #define DISASSINSTR(code) \
-    (code) = intrp_disassinstr((code))
+    (code) = intrp_disassinstr((u1*) (code))
 
 #define DISASSEMBLE(start,end) \
     intrp_disassemble((start), (end))
@@ -96,6 +94,10 @@ extern s4   disass_len;
 
 /* function prototypes *******************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if defined(ENABLE_JIT)
 void disassemble(u1 *start, u1 *end);
 #endif
@@ -117,9 +119,13 @@ u1 *intrp_disassinstr(u1 *code);
 void intrp_disassemble(u1 *start, u1 *end);
 #endif
 
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
 #endif /* defined(ENABLE_DISASSEMBLER) */
 
-#endif /* _DISASS_H */
+#endif // _DISASS_H
 
 
 /*
index 7d80a965f4c7550660bee4e085887a7f5cc075a3..b66da4bd4c3ed83bfe60b8ffedcbe78056ab76cc 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/dseg.c - data segment handling stuff
 
-   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.
 
 
 #include "mm/memory.h"
 
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/methodheader.h"
+#include "vm/options.h"
 
-#include "vmcore/options.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/methodheader.h"
 
 
 /* dseg_finish *****************************************************************
index 68c1564ae3c17a359bab30594b6a274eb9baf61a..a18a6b135a89861e87836bd335081f4d7b5fe638 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/dseg.c - data segment handling stuff
 
-   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.
 
@@ -36,12 +34,10 @@ typedef struct dsegentry dsegentry;
 #include "config.h"
 #include "vm/types.h"
 
-#include "toolbox/list.h"
+#include "vm/references.h"
 
-#include "vm/jit/jit.h"
-#include "vm/jit/codegen-common.h"
-
-#include "vmcore/references.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* convenience macros *********************************************************/
@@ -66,6 +62,10 @@ struct dsegentry {
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void dseg_finish(jitdata *jd);
 
 s4 dseg_add_unique_s4(codegendata *cd, s4 value);
@@ -92,6 +92,10 @@ void dseg_resolve_datareferences(jitdata *jd);
 void dseg_display(jitdata *jd);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _DSEG_H */
 
 
diff --git a/src/vm/jit/emit-common.c b/src/vm/jit/emit-common.c
deleted file mode 100644 (file)
index 6acf886..0000000
+++ /dev/null
@@ -1,736 +0,0 @@
-/* src/vm/jit/emit-common.c - common code emitter functions
-
-   Copyright (C) 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 <stdint.h>
-
-#include "vm/types.h"
-
-#include "arch.h"
-#include "codegen.h"
-
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
-
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-
-
-/* emit_load_s1 ****************************************************************
-
-   Emits a possible load of the first source operand.
-
-*******************************************************************************/
-
-s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg)
-{
-       varinfo *src;
-       s4       reg;
-
-       src = VAROP(iptr->s1);
-
-       reg = emit_load(jd, iptr, src, tempreg);
-
-       return reg;
-}
-
-
-/* emit_load_s2 ****************************************************************
-
-   Emits a possible load of the second source operand.
-
-*******************************************************************************/
-
-s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg)
-{
-       varinfo *src;
-       s4       reg;
-
-       src = VAROP(iptr->sx.s23.s2);
-
-       reg = emit_load(jd, iptr, src, tempreg);
-
-       return reg;
-}
-
-
-/* emit_load_s3 ****************************************************************
-
-   Emits a possible load of the third source operand.
-
-*******************************************************************************/
-
-s4 emit_load_s3(jitdata *jd, instruction *iptr, s4 tempreg)
-{
-       varinfo *src;
-       s4       reg;
-
-       src = VAROP(iptr->sx.s23.s3);
-
-       reg = emit_load(jd, iptr, src, tempreg);
-
-       return reg;
-}
-
-
-/* emit_load_s1_low ************************************************************
-
-   Emits a possible load of the low 32-bits of the first long source
-   operand.
-
-*******************************************************************************/
-
-#if SIZEOF_VOID_P == 4
-s4 emit_load_s1_low(jitdata *jd, instruction *iptr, s4 tempreg)
-{
-       varinfo *src;
-       s4       reg;
-
-       src = VAROP(iptr->s1);
-
-       reg = emit_load_low(jd, iptr, src, tempreg);
-
-       return reg;
-}
-#endif
-
-
-/* emit_load_s2_low ************************************************************
-
-   Emits a possible load of the low 32-bits of the second long source
-   operand.
-
-*******************************************************************************/
-
-#if SIZEOF_VOID_P == 4
-s4 emit_load_s2_low(jitdata *jd, instruction *iptr, s4 tempreg)
-{
-       varinfo *src;
-       s4       reg;
-
-       src = VAROP(iptr->sx.s23.s2);
-
-       reg = emit_load_low(jd, iptr, src, tempreg);
-
-       return reg;
-}
-#endif
-
-
-/* emit_load_s3_low ************************************************************
-
-   Emits a possible load of the low 32-bits of the third long source
-   operand.
-
-*******************************************************************************/
-
-#if SIZEOF_VOID_P == 4
-s4 emit_load_s3_low(jitdata *jd, instruction *iptr, s4 tempreg)
-{
-       varinfo *src;
-       s4       reg;
-
-       src = VAROP(iptr->sx.s23.s3);
-
-       reg = emit_load_low(jd, iptr, src, tempreg);
-
-       return reg;
-}
-#endif
-
-
-/* emit_load_s1_high ***********************************************************
-
-   Emits a possible load of the high 32-bits of the first long source
-   operand.
-
-*******************************************************************************/
-
-#if SIZEOF_VOID_P == 4
-s4 emit_load_s1_high(jitdata *jd, instruction *iptr, s4 tempreg)
-{
-       varinfo *src;
-       s4       reg;
-
-       src = VAROP(iptr->s1);
-
-       reg = emit_load_high(jd, iptr, src, tempreg);
-
-       return reg;
-}
-#endif
-
-
-/* emit_load_s2_high ***********************************************************
-
-   Emits a possible load of the high 32-bits of the second long source
-   operand.
-
-*******************************************************************************/
-
-#if SIZEOF_VOID_P == 4
-s4 emit_load_s2_high(jitdata *jd, instruction *iptr, s4 tempreg)
-{
-       varinfo *src;
-       s4       reg;
-
-       src = VAROP(iptr->sx.s23.s2);
-
-       reg = emit_load_high(jd, iptr, src, tempreg);
-
-       return reg;
-}
-#endif
-
-
-/* emit_load_s3_high ***********************************************************
-
-   Emits a possible load of the high 32-bits of the third long source
-   operand.
-
-*******************************************************************************/
-
-#if SIZEOF_VOID_P == 4
-s4 emit_load_s3_high(jitdata *jd, instruction *iptr, s4 tempreg)
-{
-       varinfo *src;
-       s4       reg;
-
-       src = VAROP(iptr->sx.s23.s3);
-
-       reg = emit_load_high(jd, iptr, src, tempreg);
-
-       return reg;
-}
-#endif
-
-
-/* emit_store_dst **************************************************************
-
-   This function generates the code to store the result of an
-   operation back into a spilled pseudo-variable.  If the
-   pseudo-variable has not been spilled in the first place, this
-   function will generate nothing.
-    
-*******************************************************************************/
-
-void emit_store_dst(jitdata *jd, instruction *iptr, s4 d)
-{
-       emit_store(jd, iptr, VAROP(iptr->dst), d);
-}
-
-
-/* emit_patcher_traps **********************************************************
-
-   Generates the code for the patcher traps.
-
-*******************************************************************************/
-
-void emit_patcher_traps(jitdata *jd)
-{
-       codegendata *cd;
-       codeinfo    *code;
-       patchref_t  *pr;
-       u1          *savedmcodeptr;
-       u1          *tmpmcodeptr;
-       uint32_t     mcode;
-
-       /* get required compiler data */
-
-       cd   = jd->cd;
-       code = jd->code;
-
-       /* generate patcher traps code */
-
-       for (pr = list_first(code->patchers); pr != NULL; pr = list_next(code->patchers, pr)) {
-
-               /* Calculate the patch position where the original machine
-                  code is located and the trap should be placed. */
-
-               tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
-
-               /* Patch in the trap to call the signal handler (done at
-                  compile time). */
-
-               savedmcodeptr = cd->mcodeptr;   /* save current mcodeptr          */
-               cd->mcodeptr  = tmpmcodeptr;    /* set mcodeptr to patch position */
-
-               mcode = emit_trap(cd);
-
-               cd->mcodeptr = savedmcodeptr;   /* restore the current mcodeptr   */
-
-               /* Remember the original machine code which is patched
-                  back in later (done at runtime). */
-
-               pr->mcode = mcode;
-       }
-}
-
-
-/* emit_bccz *******************************************************************
-
-   Emit conditional and unconditional branch instructions on integer
-   regiseters.
-
-*******************************************************************************/
-
-void emit_bccz(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options)
-{
-       s4 branchmpc;
-       s4 disp;
-
-       /* Target basic block already has an PC, so we can generate the
-          branch immediately. */
-
-       if ((target->mpc >= 0)) {
-               STATISTICS(count_branches_resolved++);
-
-               /* calculate the mpc of the branch instruction */
-
-               branchmpc = cd->mcodeptr - cd->mcodebase;
-               disp      = target->mpc - branchmpc;
-
-#if defined(ENABLE_STATISTICS)
-               count_emit_branch++;
-               if ((int8_t)disp == disp)  count_emit_branch_8bit++; 
-               else if ((int16_t)disp == disp) count_emit_branch_16bit++;
-               else if ((int32_t)disp == disp) count_emit_branch_32bit++;
-# if SIZEOF_VOID_P == 8
-               else if ((int64_t)disp == disp) count_emit_branch_64bit++;
-# endif
-#endif
-
-               emit_branch(cd, disp, condition, reg, options);
-       }
-       else {
-               /* current mcodeptr is the correct position,
-                  afterwards emit the NOPs */
-
-               codegen_add_branch_ref(cd, target, condition, reg, options);
-
-               /* generate NOPs as placeholder for branch code */
-
-               BRANCH_NOPS;
-       }
-}
-
-
-/* emit_bcc ********************************************************************
-
-   Emit conditional and unconditional branch instructions on condition
-   codes.
-
-*******************************************************************************/
-
-void emit_bcc(codegendata *cd, basicblock *target, s4 condition, u4 options)
-{
-       emit_bccz(cd, target, condition, -1, options);
-}
-
-
-/* emit_br *********************************************************************
-
-   Wrapper for unconditional branches.
-
-*******************************************************************************/
-
-void emit_br(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_UNCONDITIONAL, BRANCH_OPT_NONE);
-}
-
-
-/* emit_bxxz *******************************************************************
-
-   Wrappers for branches on one integer register.
-
-*******************************************************************************/
-
-#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER
-
-void emit_beqz(codegendata *cd, basicblock *target, s4 reg)
-{
-       emit_bccz(cd, target, BRANCH_EQ, reg, BRANCH_OPT_NONE);
-}
-
-void emit_bnez(codegendata *cd, basicblock *target, s4 reg)
-{
-       emit_bccz(cd, target, BRANCH_NE, reg, BRANCH_OPT_NONE);
-}
-
-void emit_bltz(codegendata *cd, basicblock *target, s4 reg)
-{
-       emit_bccz(cd, target, BRANCH_LT, reg, BRANCH_OPT_NONE);
-}
-
-void emit_bgez(codegendata *cd, basicblock *target, s4 reg)
-{
-       emit_bccz(cd, target, BRANCH_GE, reg, BRANCH_OPT_NONE);
-}
-
-void emit_bgtz(codegendata *cd, basicblock *target, s4 reg)
-{
-       emit_bccz(cd, target, BRANCH_GT, reg, BRANCH_OPT_NONE);
-}
-
-void emit_blez(codegendata *cd, basicblock *target, s4 reg)
-{
-       emit_bccz(cd, target, BRANCH_LE, reg, BRANCH_OPT_NONE);
-}
-
-#endif /* SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER */
-
-
-/* emit_bxx ********************************************************************
-
-   Wrappers for branches on two integer registers.
-
-   We use PACK_REGS here, so we don't have to change the branchref
-   data structure and the emit_bccz function.
-
-*******************************************************************************/
-
-#if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS
-
-void emit_beq(codegendata *cd, basicblock *target, s4 s1, s4 s2)
-{
-       emit_bccz(cd, target, BRANCH_EQ, PACK_REGS(s1, s2), BRANCH_OPT_NONE);
-}
-
-void emit_bne(codegendata *cd, basicblock *target, s4 s1, s4 s2)
-{
-       emit_bccz(cd, target, BRANCH_NE, PACK_REGS(s1, s2), BRANCH_OPT_NONE);
-}
-
-#endif /* SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS */
-
-
-/* emit_bxx ********************************************************************
-
-   Wrappers for branches on condition codes.
-
-*******************************************************************************/
-
-#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER
-
-void emit_beq(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_EQ, BRANCH_OPT_NONE);
-}
-
-void emit_bne(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_NE, BRANCH_OPT_NONE);
-}
-
-void emit_blt(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_LT, BRANCH_OPT_NONE);
-}
-
-void emit_bge(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_GE, BRANCH_OPT_NONE);
-}
-
-void emit_bgt(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_GT, BRANCH_OPT_NONE);
-}
-
-void emit_ble(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_LE, BRANCH_OPT_NONE);
-}
-
-#if SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS
-void emit_bult(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_ULT, BRANCH_OPT_NONE);
-}
-
-void emit_bule(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_ULE, BRANCH_OPT_NONE);
-}
-
-void emit_buge(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_UGE, BRANCH_OPT_NONE);
-}
-
-void emit_bugt(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_UGT, BRANCH_OPT_NONE);
-}
-#endif
-
-#if defined(__POWERPC__) || defined(__POWERPC64__)
-void emit_bnan(codegendata *cd, basicblock *target)
-{
-       emit_bcc(cd, target, BRANCH_NAN, BRANCH_OPT_NONE);
-}
-#endif
-
-#endif /* SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER */
-
-
-/* emit_label_bccz *************************************************************
-
-   Emit a branch to a label.  Possibly emit the branch, if it is a
-   backward branch.
-
-*******************************************************************************/
-
-void emit_label_bccz(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options)
-{
-       list_t             *list;
-       branch_label_ref_t *br;
-       s4                  mpc;
-       s4                  disp;
-
-       /* get the label list */
-
-       list = cd->brancheslabel;
-
-       /* search if the label is already in the list */
-
-       for (br = list_first(list); br != NULL; br = list_next(list, br)) {
-               /* is this entry the correct label? */
-
-               if (br->label == label)
-                       break;
-       }
-
-       if (br == NULL) {
-               /* current mcodeptr is the correct position,
-                  afterwards emit the NOPs */
-
-               codegen_branch_label_add(cd, label, condition, reg, options);
-
-               /* generate NOPs as placeholder for branch code */
-
-               BRANCH_NOPS;
-               return;
-       }
-
-       /* Branch reference was found. */
-
-       /* calculate the mpc of the branch instruction */
-
-       mpc  = cd->mcodeptr - cd->mcodebase;
-       disp = br->mpc - mpc;
-
-#if defined(ENABLE_STATISTICS)
-       count_emit_branch++;
-       if ((int8_t)disp == disp)  count_emit_branch_8bit++; 
-       else if ((int16_t)disp == disp) count_emit_branch_16bit++;
-       else if ((int32_t)disp == disp) count_emit_branch_32bit++;
-# if SIZEOF_VOID_P == 8
-       else if ((int64_t)disp == disp) count_emit_branch_64bit++;
-# endif
-#endif
-
-       emit_branch(cd, disp, condition, reg, options);
-
-       /* now remove the branch reference */
-
-       list_remove(list, br);
-}
-
-
-/* emit_label ******************************************************************
-
-   Emit a label for a branch.  Possibly emit the branch, if it is a
-   forward branch.
-
-*******************************************************************************/
-
-void emit_label(codegendata *cd, s4 label)
-{
-       list_t             *list;
-       branch_label_ref_t *br;
-       s4                  mpc;
-       s4                  disp;
-       u1                 *mcodeptr;
-
-       /* get the label list */
-
-       list = cd->brancheslabel;
-
-       /* search if the label is already in the list */
-
-       for (br = list_first(list); br != NULL; br = list_next(list, br)) {
-               /* is this entry the correct label? */
-
-               if (br->label == label)
-                       break;
-       }
-
-       if (br == NULL) {
-               /* No branch reference found, add the label to the list (use
-                  invalid values for condition and register). */
-
-               codegen_branch_label_add(cd, label, -1, -1, BRANCH_OPT_NONE );
-               return;
-       }
-
-       /* Branch reference was found. */
-
-       /* calculate the mpc of the branch instruction */
-
-       mpc  = cd->mcodeptr - cd->mcodebase;
-       disp = mpc - br->mpc;
-
-       /* temporary set the mcodeptr */
-
-       mcodeptr     = cd->mcodeptr;
-       cd->mcodeptr = cd->mcodebase + br->mpc;
-
-#if defined(ENABLE_STATISTICS)
-       count_emit_branch++;
-       if ((int8_t)disp == disp)  count_emit_branch_8bit++; 
-       else if ((int16_t)disp == disp) count_emit_branch_16bit++;
-       else if ((int32_t)disp == disp) count_emit_branch_32bit++;
-# if SIZEOF_VOID_P == 8
-       else if ((int64_t)disp == disp) count_emit_branch_64bit++;
-# endif
-#endif
-
-       emit_branch(cd, disp, br->condition, br->reg, br->options);
-
-       /* restore mcodeptr */
-
-       cd->mcodeptr = mcodeptr;
-
-       /* now remove the branch reference */
-
-       list_remove(list, br);
-}
-
-
-/* emit_label_bcc **************************************************************
-
-   Emit conditional and unconditional label-branch instructions on
-   condition codes.
-
-*******************************************************************************/
-
-void emit_label_bcc(codegendata *cd, s4 label, s4 condition, u4 options)
-{
-       emit_label_bccz(cd, label, condition, -1, options);
-}
-
-
-/* emit_label_br ***************************************************************
-
-   Wrapper for unconditional label-branches.
-
-*******************************************************************************/
-
-void emit_label_br(codegendata *cd, s4 label)
-{
-       emit_label_bcc(cd, label, BRANCH_UNCONDITIONAL, BRANCH_OPT_NONE);
-}
-
-
-/* emit_label_bxxz *************************************************************
-
-   Wrappers for label-branches on one integer register.
-
-*******************************************************************************/
-
-#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER
-
-void emit_label_beqz(codegendata *cd, s4 label, s4 reg)
-{
-       emit_label_bccz(cd, label, BRANCH_EQ, reg, BRANCH_OPT_NONE);
-}
-
-void emit_label_bnez(codegendata *cd, s4 label, s4 reg)
-{
-       emit_label_bccz(cd, label, BRANCH_NE, reg, BRANCH_OPT_NONE);
-}
-
-#endif /* SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER */
-
-
-/* emit_label_bxx **************************************************************
-
-   Wrappers for label-branches on condition codes.
-
-*******************************************************************************/
-
-#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER
-
-void emit_label_beq(codegendata *cd, s4 label)
-{
-       emit_label_bcc(cd, label, BRANCH_EQ, BRANCH_OPT_NONE);
-}
-
-void emit_label_bne(codegendata *cd, s4 label)
-{
-       emit_label_bcc(cd, label, BRANCH_NE, BRANCH_OPT_NONE);
-}
-
-void emit_label_blt(codegendata *cd, s4 label)
-{
-       emit_label_bcc(cd, label, BRANCH_LT, BRANCH_OPT_NONE);
-}
-
-void emit_label_bge(codegendata *cd, s4 label)
-{
-       emit_label_bcc(cd, label, BRANCH_GE, BRANCH_OPT_NONE);
-}
-
-void emit_label_bgt(codegendata *cd, s4 label)
-{
-       emit_label_bcc(cd, label, BRANCH_GT, BRANCH_OPT_NONE);
-}
-
-void emit_label_ble(codegendata *cd, s4 label)
-{
-       emit_label_bcc(cd, label, BRANCH_LE, BRANCH_OPT_NONE);
-}
-
-#endif /* SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER */
-
-
-/*
- * 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/jit/emit-common.cpp b/src/vm/jit/emit-common.cpp
new file mode 100644 (file)
index 0000000..370a64b
--- /dev/null
@@ -0,0 +1,754 @@
+/* src/vm/jit/emit-common.cpp - common code emitter functions
+
+   Copyright (C) 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 <stdint.h>
+
+#include <algorithm>
+
+#include "vm/types.h"
+
+#include "arch.h"
+#include "codegen.h"
+
+#include "toolbox/list.hpp"
+
+#include "vm/options.h"
+#include "vm/statistics.h"
+
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/patcher-common.hpp"
+
+
+/* emit_load_s1 ****************************************************************
+
+   Emits a possible load of the first source operand.
+
+*******************************************************************************/
+
+s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg)
+{
+       varinfo *src;
+       s4       reg;
+
+       src = VAROP(iptr->s1);
+
+       reg = emit_load(jd, iptr, src, tempreg);
+
+       return reg;
+}
+
+
+/* emit_load_s2 ****************************************************************
+
+   Emits a possible load of the second source operand.
+
+*******************************************************************************/
+
+s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg)
+{
+       varinfo *src;
+       s4       reg;
+
+       src = VAROP(iptr->sx.s23.s2);
+
+       reg = emit_load(jd, iptr, src, tempreg);
+
+       return reg;
+}
+
+
+/* emit_load_s3 ****************************************************************
+
+   Emits a possible load of the third source operand.
+
+*******************************************************************************/
+
+s4 emit_load_s3(jitdata *jd, instruction *iptr, s4 tempreg)
+{
+       varinfo *src;
+       s4       reg;
+
+       src = VAROP(iptr->sx.s23.s3);
+
+       reg = emit_load(jd, iptr, src, tempreg);
+
+       return reg;
+}
+
+
+/* emit_load_s1_low ************************************************************
+
+   Emits a possible load of the low 32-bits of the first long source
+   operand.
+
+*******************************************************************************/
+
+#if SIZEOF_VOID_P == 4
+s4 emit_load_s1_low(jitdata *jd, instruction *iptr, s4 tempreg)
+{
+       varinfo *src;
+       s4       reg;
+
+       src = VAROP(iptr->s1);
+
+       reg = emit_load_low(jd, iptr, src, tempreg);
+
+       return reg;
+}
+#endif
+
+
+/* emit_load_s2_low ************************************************************
+
+   Emits a possible load of the low 32-bits of the second long source
+   operand.
+
+*******************************************************************************/
+
+#if SIZEOF_VOID_P == 4
+s4 emit_load_s2_low(jitdata *jd, instruction *iptr, s4 tempreg)
+{
+       varinfo *src;
+       s4       reg;
+
+       src = VAROP(iptr->sx.s23.s2);
+
+       reg = emit_load_low(jd, iptr, src, tempreg);
+
+       return reg;
+}
+#endif
+
+
+/* emit_load_s3_low ************************************************************
+
+   Emits a possible load of the low 32-bits of the third long source
+   operand.
+
+*******************************************************************************/
+
+#if SIZEOF_VOID_P == 4
+s4 emit_load_s3_low(jitdata *jd, instruction *iptr, s4 tempreg)
+{
+       varinfo *src;
+       s4       reg;
+
+       src = VAROP(iptr->sx.s23.s3);
+
+       reg = emit_load_low(jd, iptr, src, tempreg);
+
+       return reg;
+}
+#endif
+
+
+/* emit_load_s1_high ***********************************************************
+
+   Emits a possible load of the high 32-bits of the first long source
+   operand.
+
+*******************************************************************************/
+
+#if SIZEOF_VOID_P == 4
+s4 emit_load_s1_high(jitdata *jd, instruction *iptr, s4 tempreg)
+{
+       varinfo *src;
+       s4       reg;
+
+       src = VAROP(iptr->s1);
+
+       reg = emit_load_high(jd, iptr, src, tempreg);
+
+       return reg;
+}
+#endif
+
+
+/* emit_load_s2_high ***********************************************************
+
+   Emits a possible load of the high 32-bits of the second long source
+   operand.
+
+*******************************************************************************/
+
+#if SIZEOF_VOID_P == 4
+s4 emit_load_s2_high(jitdata *jd, instruction *iptr, s4 tempreg)
+{
+       varinfo *src;
+       s4       reg;
+
+       src = VAROP(iptr->sx.s23.s2);
+
+       reg = emit_load_high(jd, iptr, src, tempreg);
+
+       return reg;
+}
+#endif
+
+
+/* emit_load_s3_high ***********************************************************
+
+   Emits a possible load of the high 32-bits of the third long source
+   operand.
+
+*******************************************************************************/
+
+#if SIZEOF_VOID_P == 4
+s4 emit_load_s3_high(jitdata *jd, instruction *iptr, s4 tempreg)
+{
+       varinfo *src;
+       s4       reg;
+
+       src = VAROP(iptr->sx.s23.s3);
+
+       reg = emit_load_high(jd, iptr, src, tempreg);
+
+       return reg;
+}
+#endif
+
+
+/* emit_store_dst **************************************************************
+
+   This function generates the code to store the result of an
+   operation back into a spilled pseudo-variable.  If the
+   pseudo-variable has not been spilled in the first place, this
+   function will generate nothing.
+    
+*******************************************************************************/
+
+void emit_store_dst(jitdata *jd, instruction *iptr, s4 d)
+{
+       emit_store(jd, iptr, VAROP(iptr->dst), d);
+}
+
+
+/* emit_patcher_traps **********************************************************
+
+   Generates the code for the patcher traps.
+
+*******************************************************************************/
+
+void emit_patcher_traps(jitdata *jd)
+{
+       codegendata *cd;
+       codeinfo    *code;
+       u1          *savedmcodeptr;
+       u1          *tmpmcodeptr;
+       uint32_t     mcode;
+
+       /* get required compiler data */
+
+       cd   = jd->cd;
+       code = jd->code;
+
+       // Generate patcher traps code.
+       for (List<patchref_t>::iterator it = code->patchers->begin(); it != code->patchers->end(); it++) {
+               patchref_t& pr = *it;
+
+               /* Calculate the patch position where the original machine
+                  code is located and the trap should be placed. */
+
+               tmpmcodeptr = (u1 *) (cd->mcodebase + pr.mpc);
+
+               /* Patch in the trap to call the signal handler (done at
+                  compile time). */
+
+               savedmcodeptr = cd->mcodeptr;   /* save current mcodeptr          */
+               cd->mcodeptr  = tmpmcodeptr;    /* set mcodeptr to patch position */
+
+               mcode = emit_trap(cd);
+
+               cd->mcodeptr = savedmcodeptr;   /* restore the current mcodeptr   */
+
+               /* Remember the original machine code which is patched
+                  back in later (done at runtime). */
+
+               pr.mcode = mcode;
+       }
+}
+
+
+/* emit_bccz *******************************************************************
+
+   Emit conditional and unconditional branch instructions on integer
+   regiseters.
+
+*******************************************************************************/
+
+void emit_bccz(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options)
+{
+       s4 branchmpc;
+       s4 disp;
+
+       /* Target basic block already has an PC, so we can generate the
+          branch immediately. */
+
+       if ((target->mpc >= 0)) {
+               STATISTICS(count_branches_resolved++);
+
+               /* calculate the mpc of the branch instruction */
+
+               branchmpc = cd->mcodeptr - cd->mcodebase;
+               disp      = target->mpc - branchmpc;
+
+#if defined(ENABLE_STATISTICS)
+               count_emit_branch++;
+               if ((int8_t)disp == disp)  count_emit_branch_8bit++; 
+               else if ((int16_t)disp == disp) count_emit_branch_16bit++;
+               else if ((int32_t)disp == disp) count_emit_branch_32bit++;
+# if SIZEOF_VOID_P == 8
+               else if ((int64_t)disp == disp) count_emit_branch_64bit++;
+# endif
+#endif
+
+               emit_branch(cd, disp, condition, reg, options);
+       }
+       else {
+               /* current mcodeptr is the correct position,
+                  afterwards emit the NOPs */
+
+               codegen_add_branch_ref(cd, target, condition, reg, options);
+
+               /* generate NOPs as placeholder for branch code */
+
+               BRANCH_NOPS;
+       }
+}
+
+
+/* emit_bcc ********************************************************************
+
+   Emit conditional and unconditional branch instructions on condition
+   codes.
+
+*******************************************************************************/
+
+void emit_bcc(codegendata *cd, basicblock *target, s4 condition, u4 options)
+{
+       emit_bccz(cd, target, condition, -1, options);
+}
+
+
+/* emit_br *********************************************************************
+
+   Wrapper for unconditional branches.
+
+*******************************************************************************/
+
+void emit_br(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_UNCONDITIONAL, BRANCH_OPT_NONE);
+}
+
+
+/* emit_bxxz *******************************************************************
+
+   Wrappers for branches on one integer register.
+
+*******************************************************************************/
+
+#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER
+
+void emit_beqz(codegendata *cd, basicblock *target, s4 reg)
+{
+       emit_bccz(cd, target, BRANCH_EQ, reg, BRANCH_OPT_NONE);
+}
+
+void emit_bnez(codegendata *cd, basicblock *target, s4 reg)
+{
+       emit_bccz(cd, target, BRANCH_NE, reg, BRANCH_OPT_NONE);
+}
+
+void emit_bltz(codegendata *cd, basicblock *target, s4 reg)
+{
+       emit_bccz(cd, target, BRANCH_LT, reg, BRANCH_OPT_NONE);
+}
+
+void emit_bgez(codegendata *cd, basicblock *target, s4 reg)
+{
+       emit_bccz(cd, target, BRANCH_GE, reg, BRANCH_OPT_NONE);
+}
+
+void emit_bgtz(codegendata *cd, basicblock *target, s4 reg)
+{
+       emit_bccz(cd, target, BRANCH_GT, reg, BRANCH_OPT_NONE);
+}
+
+void emit_blez(codegendata *cd, basicblock *target, s4 reg)
+{
+       emit_bccz(cd, target, BRANCH_LE, reg, BRANCH_OPT_NONE);
+}
+
+#endif /* SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER */
+
+
+/* emit_bxx ********************************************************************
+
+   Wrappers for branches on two integer registers.
+
+   We use PACK_REGS here, so we don't have to change the branchref
+   data structure and the emit_bccz function.
+
+*******************************************************************************/
+
+#if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS
+
+void emit_beq(codegendata *cd, basicblock *target, s4 s1, s4 s2)
+{
+       emit_bccz(cd, target, BRANCH_EQ, PACK_REGS(s1, s2), BRANCH_OPT_NONE);
+}
+
+void emit_bne(codegendata *cd, basicblock *target, s4 s1, s4 s2)
+{
+       emit_bccz(cd, target, BRANCH_NE, PACK_REGS(s1, s2), BRANCH_OPT_NONE);
+}
+
+#endif /* SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS */
+
+
+/* emit_bxx ********************************************************************
+
+   Wrappers for branches on condition codes.
+
+*******************************************************************************/
+
+#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER
+
+void emit_beq(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_EQ, BRANCH_OPT_NONE);
+}
+
+void emit_bne(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_NE, BRANCH_OPT_NONE);
+}
+
+void emit_blt(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_LT, BRANCH_OPT_NONE);
+}
+
+void emit_bge(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_GE, BRANCH_OPT_NONE);
+}
+
+void emit_bgt(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_GT, BRANCH_OPT_NONE);
+}
+
+void emit_ble(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_LE, BRANCH_OPT_NONE);
+}
+
+#if SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS
+void emit_bult(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_ULT, BRANCH_OPT_NONE);
+}
+
+void emit_bule(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_ULE, BRANCH_OPT_NONE);
+}
+
+void emit_buge(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_UGE, BRANCH_OPT_NONE);
+}
+
+void emit_bugt(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_UGT, BRANCH_OPT_NONE);
+}
+#endif
+
+#if defined(__POWERPC__) || defined(__POWERPC64__)
+void emit_bnan(codegendata *cd, basicblock *target)
+{
+       emit_bcc(cd, target, BRANCH_NAN, BRANCH_OPT_NONE);
+}
+#endif
+
+#endif /* SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER */
+
+
+/* emit_label_bccz *************************************************************
+
+   Emit a branch to a label.  Possibly emit the branch, if it is a
+   backward branch.
+
+*******************************************************************************/
+
+void emit_label_bccz(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options)
+{
+       // Search if the label is already in the list.
+       DumpList<branch_label_ref_t*>::iterator it;
+       for (it = cd->brancheslabel->begin(); it != cd->brancheslabel->end(); it++) {
+               branch_label_ref_t* br = *it;
+
+               /* is this entry the correct label? */
+
+               if (br->label == label)
+                       break;
+       }
+
+       if (it == cd->brancheslabel->end()) {
+               /* current mcodeptr is the correct position,
+                  afterwards emit the NOPs */
+
+               codegen_branch_label_add(cd, label, condition, reg, options);
+
+               /* generate NOPs as placeholder for branch code */
+
+               BRANCH_NOPS;
+               return;
+       }
+
+       // Branch reference was found.
+       branch_label_ref_t* br = *it;
+
+       /* calculate the mpc of the branch instruction */
+
+       int32_t mpc  = cd->mcodeptr - cd->mcodebase;
+       int32_t disp = br->mpc - mpc;
+
+#if defined(ENABLE_STATISTICS)
+       count_emit_branch++;
+       if ((int8_t)disp == disp)  count_emit_branch_8bit++; 
+       else if ((int16_t)disp == disp) count_emit_branch_16bit++;
+       else if ((int32_t)disp == disp) count_emit_branch_32bit++;
+# if SIZEOF_VOID_P == 8
+       else if ((int64_t)disp == disp) count_emit_branch_64bit++;
+# endif
+#endif
+
+       emit_branch(cd, disp, condition, reg, options);
+
+       // Now remove the branch reference.
+       cd->brancheslabel->remove(br);
+}
+
+
+/* emit_label ******************************************************************
+
+   Emit a label for a branch.  Possibly emit the branch, if it is a
+   forward branch.
+
+*******************************************************************************/
+
+void emit_label(codegendata *cd, s4 label)
+{
+       u1* mcodeptr;
+
+       // Search if the label is already in the list.
+       DumpList<branch_label_ref_t*>::iterator it;
+       for (it = cd->brancheslabel->begin(); it != cd->brancheslabel->end(); it++) {
+               branch_label_ref_t* br = *it;
+
+               /* is this entry the correct label? */
+
+               if (br->label == label)
+                       break;
+       }
+
+       if (it == cd->brancheslabel->end()) {
+               /* No branch reference found, add the label to the list (use
+                  invalid values for condition and register). */
+
+               codegen_branch_label_add(cd, label, -1, -1, BRANCH_OPT_NONE );
+               return;
+       }
+
+       // Branch reference was found.
+       branch_label_ref_t* br = *it;
+
+       // Calculate the mpc of the branch instruction.
+       int32_t mpc  = cd->mcodeptr - cd->mcodebase;
+       int32_t disp = mpc - br->mpc;
+
+       /* temporary set the mcodeptr */
+
+       mcodeptr     = cd->mcodeptr;
+       cd->mcodeptr = cd->mcodebase + br->mpc;
+
+#if defined(ENABLE_STATISTICS)
+       count_emit_branch++;
+       if ((int8_t)disp == disp)  count_emit_branch_8bit++; 
+       else if ((int16_t)disp == disp) count_emit_branch_16bit++;
+       else if ((int32_t)disp == disp) count_emit_branch_32bit++;
+# if SIZEOF_VOID_P == 8
+       else if ((int64_t)disp == disp) count_emit_branch_64bit++;
+# endif
+#endif
+
+       emit_branch(cd, disp, br->condition, br->reg, br->options);
+
+       /* restore mcodeptr */
+
+       cd->mcodeptr = mcodeptr;
+
+       // Now remove the branch reference.
+       cd->brancheslabel->remove(br);
+}
+
+
+/* emit_label_bcc **************************************************************
+
+   Emit conditional and unconditional label-branch instructions on
+   condition codes.
+
+*******************************************************************************/
+
+void emit_label_bcc(codegendata *cd, s4 label, s4 condition, u4 options)
+{
+       emit_label_bccz(cd, label, condition, -1, options);
+}
+
+
+/* emit_label_br ***************************************************************
+
+   Wrapper for unconditional label-branches.
+
+*******************************************************************************/
+
+void emit_label_br(codegendata *cd, s4 label)
+{
+       emit_label_bcc(cd, label, BRANCH_UNCONDITIONAL, BRANCH_OPT_NONE);
+}
+
+
+/* emit_label_bxxz *************************************************************
+
+   Wrappers for label-branches on one integer register.
+
+*******************************************************************************/
+
+#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER
+
+void emit_label_beqz(codegendata* cd, int label, int reg)
+{
+       emit_label_bccz(cd, label, BRANCH_EQ, reg, BRANCH_OPT_NONE);
+}
+
+void emit_label_bnez(codegendata* cd, int label, int reg)
+{
+       emit_label_bccz(cd, label, BRANCH_NE, reg, BRANCH_OPT_NONE);
+}
+
+void emit_label_bltz(codegendata* cd, int label, int reg)
+{
+       emit_label_bccz(cd, label, BRANCH_LT, reg, BRANCH_OPT_NONE);
+}
+
+void emit_label_bgtz(codegendata* cd, int label, int reg)
+{
+       emit_label_bccz(cd, label, BRANCH_GT, reg, BRANCH_OPT_NONE);
+}
+
+#endif /* SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER */
+
+
+/* emit_label_bxx **************************************************************
+
+   Wrappers for label-branches on two integer registers.
+
+   We use PACK_REGS here, so we don't have to change the branchref
+   data structure and the emit_bccz function.
+
+*******************************************************************************/
+
+#if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS
+
+void emit_label_bne(codegendata* cd, int label, int s1, int s2)
+{
+       emit_label_bccz(cd, label, BRANCH_NE, PACK_REGS(s1, s2), BRANCH_OPT_NONE);
+}
+
+#endif /* SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS */
+
+
+/* emit_label_bxx **************************************************************
+
+   Wrappers for label-branches on condition codes.
+
+*******************************************************************************/
+
+#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER
+
+void emit_label_beq(codegendata *cd, s4 label)
+{
+       emit_label_bcc(cd, label, BRANCH_EQ, BRANCH_OPT_NONE);
+}
+
+void emit_label_bne(codegendata *cd, s4 label)
+{
+       emit_label_bcc(cd, label, BRANCH_NE, BRANCH_OPT_NONE);
+}
+
+void emit_label_blt(codegendata *cd, s4 label)
+{
+       emit_label_bcc(cd, label, BRANCH_LT, BRANCH_OPT_NONE);
+}
+
+void emit_label_bge(codegendata *cd, s4 label)
+{
+       emit_label_bcc(cd, label, BRANCH_GE, BRANCH_OPT_NONE);
+}
+
+void emit_label_bgt(codegendata *cd, s4 label)
+{
+       emit_label_bcc(cd, label, BRANCH_GT, BRANCH_OPT_NONE);
+}
+
+void emit_label_ble(codegendata *cd, s4 label)
+{
+       emit_label_bcc(cd, label, BRANCH_LE, BRANCH_OPT_NONE);
+}
+
+#endif /* SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER */
+
+
+/*
+ * 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/jit/emit-common.h b/src/vm/jit/emit-common.h
deleted file mode 100644 (file)
index f99969c..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/* src/vm/jit/emit-common.h - common code emitter functions
-
-   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
-
-   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 _EMIT_COMMON_H
-#define _EMIT_COMMON_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "arch.h"
-
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
-
-
-/* branch labels **************************************************************/
-
-#define BRANCH_LABEL_1    1
-#define BRANCH_LABEL_2    2
-#define BRANCH_LABEL_3    3
-#define BRANCH_LABEL_4    4
-#define BRANCH_LABEL_5    5
-#define BRANCH_LABEL_6    6
-#define BRANCH_LABEL_7    7
-#define BRANCH_LABEL_8    8
-#define BRANCH_LABEL_9    9
-#define BRANCH_LABEL_10  10
-
-
-/* constant range macros ******************************************************/
-
-#if SIZEOF_VOID_P == 8
-
-# define IS_IMM8(c) \
-    (((s8) (c) >= -128) && ((s8) (c) <= 127))
-
-# define IS_IMM32(c) \
-    (((s8) (c) >= (-2147483647-1)) && ((s8) (c) <= 2147483647))
-
-#else
-
-# define IS_IMM8(c) \
-    (((s4) (c) >= -128) && ((s4) (c) <= 127))
-
-# define IS_IMM16(c) \
-    (((s4) (c) >= -32768) && ((s4) (c) <= 32767))
-
-#endif
-
-
-/* code generation functions **************************************************/
-
-s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg);
-s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg);
-s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg);
-s4 emit_load_s3(jitdata *jd, instruction *iptr, s4 tempreg);
-
-#if SIZEOF_VOID_P == 4
-s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg);
-s4 emit_load_s1_low(jitdata *jd, instruction *iptr, s4 tempreg);
-s4 emit_load_s2_low(jitdata *jd, instruction *iptr, s4 tempreg);
-s4 emit_load_s3_low(jitdata *jd, instruction *iptr, s4 tempreg);
-
-s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg);
-s4 emit_load_s1_high(jitdata *jd, instruction *iptr, s4 tempreg);
-s4 emit_load_s2_high(jitdata *jd, instruction *iptr, s4 tempreg);
-s4 emit_load_s3_high(jitdata *jd, instruction *iptr, s4 tempreg);
-#endif
-
-void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d);
-void emit_store_dst(jitdata *jd, instruction *iptr, s4 d);
-
-#if SIZEOF_VOID_P == 4
-void emit_store_low(jitdata *jd, instruction *iptr, varinfo *dst, s4 d);
-void emit_store_high(jitdata *jd, instruction *iptr, varinfo *dst, s4 d);
-#endif
-
-void emit_copy(jitdata *jd, instruction *iptr);
-
-void emit_iconst(codegendata *cd, s4 d, s4 value);
-void emit_lconst(codegendata *cd, s4 d, s8 value);
-
-/* branch-emitting functions */
-void emit_bccz(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options);
-void emit_bcc(codegendata *cd, basicblock *target, s4 condition, u4 options);
-
-/* wrapper for unconditional branches */
-void emit_br(codegendata *cd, basicblock *target);
-
-/* wrappers for branches on one integer register */
-
-#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER
-void emit_beqz(codegendata *cd, basicblock *target, s4 reg);
-void emit_bnez(codegendata *cd, basicblock *target, s4 reg);
-void emit_bltz(codegendata *cd, basicblock *target, s4 reg);
-void emit_bgez(codegendata *cd, basicblock *target, s4 reg);
-void emit_bgtz(codegendata *cd, basicblock *target, s4 reg);
-void emit_blez(codegendata *cd, basicblock *target, s4 reg);
-#endif
-
-/* wrappers for branches on two integer registers */
-
-#if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS
-void emit_beq(codegendata *cd, basicblock *target, s4 s1, s4 s2);
-void emit_bne(codegendata *cd, basicblock *target, s4 s1, s4 s2);
-#endif
-
-/* wrappers for branches on condition codes */
-
-#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER
-void emit_beq(codegendata *cd, basicblock *target);
-void emit_bne(codegendata *cd, basicblock *target);
-void emit_blt(codegendata *cd, basicblock *target);
-void emit_bge(codegendata *cd, basicblock *target);
-void emit_bgt(codegendata *cd, basicblock *target);
-void emit_ble(codegendata *cd, basicblock *target);
-#endif
-
-#if SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS
-void emit_bult(codegendata *cd, basicblock *target);
-void emit_bule(codegendata *cd, basicblock *target);
-void emit_buge(codegendata *cd, basicblock *target);
-void emit_bugt(codegendata *cd, basicblock *target);
-#endif
-
-#if defined(__POWERPC__) || defined(__POWERPC64__)
-void emit_bnan(codegendata *cd, basicblock *target);
-#endif
-
-/* label-branches */
-void emit_label_bccz(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options);
-void emit_label(codegendata *cd, s4 label);
-void emit_label_bcc(codegendata *cd, s4 label, s4 condition, u4 options);
-
-void emit_label_br(codegendata *cd, s4 label);
-
-#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER
-void emit_label_beqz(codegendata *cd, s4 label, s4 reg);
-void emit_label_bnez(codegendata *cd, s4 label, s4 reg);
-#endif
-
-#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER
-void emit_label_beq(codegendata *cd, s4 label);
-void emit_label_bne(codegendata *cd, s4 label);
-void emit_label_blt(codegendata *cd, s4 label);
-void emit_label_bge(codegendata *cd, s4 label);
-void emit_label_bgt(codegendata *cd, s4 label);
-void emit_label_ble(codegendata *cd, s4 label);
-#endif
-
-/* machine dependent branch-emitting function */
-void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 options);
-
-void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg);
-void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1, s4 s2);
-void emit_arraystore_check(codegendata *cd, instruction *iptr);
-void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 reg, s4 s1);
-void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg);
-void emit_exception_check(codegendata *cd, instruction *iptr);
-
-void emit_trap_compiler(codegendata *cd);
-uint32_t emit_trap(codegendata *cd);
-
-void emit_patcher_traps(jitdata *jd);
-
-void emit_verbosecall_enter(jitdata *jd);
-void emit_verbosecall_exit(jitdata *jd);
-
-#endif /* _EMIT_COMMON_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/jit/emit-common.hpp b/src/vm/jit/emit-common.hpp
new file mode 100644 (file)
index 0000000..611eca4
--- /dev/null
@@ -0,0 +1,221 @@
+/* src/vm/jit/emit-common.hpp - common code emitter functions
+
+   Copyright (C) 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 _EMIT_COMMON_H
+#define _EMIT_COMMON_H
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "arch.h"
+
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/jit.hpp"
+
+
+/* branch labels **************************************************************/
+
+#define BRANCH_LABEL_1    1
+#define BRANCH_LABEL_2    2
+#define BRANCH_LABEL_3    3
+#define BRANCH_LABEL_4    4
+#define BRANCH_LABEL_5    5
+#define BRANCH_LABEL_6    6
+#define BRANCH_LABEL_7    7
+#define BRANCH_LABEL_8    8
+#define BRANCH_LABEL_9    9
+#define BRANCH_LABEL_10  10
+
+
+/* constant range macros ******************************************************/
+
+#if SIZEOF_VOID_P == 8
+
+# define IS_IMM8(c) \
+    (((s8) (c) >= -128) && ((s8) (c) <= 127))
+
+# define IS_IMM32(c) \
+    (((s8) (c) >= (-2147483647-1)) && ((s8) (c) <= 2147483647))
+
+#else
+
+# define IS_IMM8(c) \
+    (((s4) (c) >= -128) && ((s4) (c) <= 127))
+
+# define IS_IMM16(c) \
+    (((s4) (c) >= -32768) && ((s4) (c) <= 32767))
+
+#endif
+
+
+/* code generation functions **************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg);
+s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg);
+s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg);
+s4 emit_load_s3(jitdata *jd, instruction *iptr, s4 tempreg);
+
+#if SIZEOF_VOID_P == 4
+s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg);
+s4 emit_load_s1_low(jitdata *jd, instruction *iptr, s4 tempreg);
+s4 emit_load_s2_low(jitdata *jd, instruction *iptr, s4 tempreg);
+s4 emit_load_s3_low(jitdata *jd, instruction *iptr, s4 tempreg);
+
+s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg);
+s4 emit_load_s1_high(jitdata *jd, instruction *iptr, s4 tempreg);
+s4 emit_load_s2_high(jitdata *jd, instruction *iptr, s4 tempreg);
+s4 emit_load_s3_high(jitdata *jd, instruction *iptr, s4 tempreg);
+#endif
+
+void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d);
+void emit_store_dst(jitdata *jd, instruction *iptr, s4 d);
+
+#if SIZEOF_VOID_P == 4
+void emit_store_low(jitdata *jd, instruction *iptr, varinfo *dst, s4 d);
+void emit_store_high(jitdata *jd, instruction *iptr, varinfo *dst, s4 d);
+#endif
+
+void emit_copy(jitdata *jd, instruction *iptr);
+
+void emit_iconst(codegendata *cd, s4 d, s4 value);
+void emit_lconst(codegendata *cd, s4 d, s8 value);
+
+/* branch-emitting functions */
+void emit_bccz(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options);
+void emit_bcc(codegendata *cd, basicblock *target, s4 condition, u4 options);
+
+/* wrapper for unconditional branches */
+void emit_br(codegendata *cd, basicblock *target);
+
+/* wrappers for branches on one integer register */
+
+#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER
+void emit_beqz(codegendata *cd, basicblock *target, s4 reg);
+void emit_bnez(codegendata *cd, basicblock *target, s4 reg);
+void emit_bltz(codegendata *cd, basicblock *target, s4 reg);
+void emit_bgez(codegendata *cd, basicblock *target, s4 reg);
+void emit_bgtz(codegendata *cd, basicblock *target, s4 reg);
+void emit_blez(codegendata *cd, basicblock *target, s4 reg);
+#endif
+
+/* wrappers for branches on two integer registers */
+
+#if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS
+void emit_beq(codegendata *cd, basicblock *target, s4 s1, s4 s2);
+void emit_bne(codegendata *cd, basicblock *target, s4 s1, s4 s2);
+#endif
+
+/* wrappers for branches on condition codes */
+
+#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER
+void emit_beq(codegendata *cd, basicblock *target);
+void emit_bne(codegendata *cd, basicblock *target);
+void emit_blt(codegendata *cd, basicblock *target);
+void emit_bge(codegendata *cd, basicblock *target);
+void emit_bgt(codegendata *cd, basicblock *target);
+void emit_ble(codegendata *cd, basicblock *target);
+#endif
+
+#if SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS
+void emit_bult(codegendata *cd, basicblock *target);
+void emit_bule(codegendata *cd, basicblock *target);
+void emit_buge(codegendata *cd, basicblock *target);
+void emit_bugt(codegendata *cd, basicblock *target);
+#endif
+
+#if defined(__POWERPC__) || defined(__POWERPC64__)
+void emit_bnan(codegendata *cd, basicblock *target);
+#endif
+
+/* label-branches */
+void emit_label_bccz(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options);
+void emit_label(codegendata *cd, s4 label);
+void emit_label_bcc(codegendata *cd, s4 label, s4 condition, u4 options);
+
+void emit_label_br(codegendata *cd, s4 label);
+
+#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER
+void emit_label_beqz(codegendata* cd, int label, int reg);
+void emit_label_bnez(codegendata* cd, int label, int reg);
+void emit_label_bltz(codegendata* cd, int label, int reg);
+void emit_label_bgtz(codegendata* cd, int label, int reg);
+#endif
+
+#if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS
+void emit_label_bne(codegendata* cd, int label, int s1, int s2);
+#endif
+
+#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER
+void emit_label_beq(codegendata *cd, s4 label);
+void emit_label_bne(codegendata *cd, s4 label);
+void emit_label_blt(codegendata *cd, s4 label);
+void emit_label_bge(codegendata *cd, s4 label);
+void emit_label_bgt(codegendata *cd, s4 label);
+void emit_label_ble(codegendata *cd, s4 label);
+#endif
+
+/* machine dependent branch-emitting function */
+void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 options);
+
+void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg);
+void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1, s4 s2);
+void emit_arraystore_check(codegendata *cd, instruction *iptr);
+void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 reg, s4 s1);
+void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg);
+void emit_exception_check(codegendata *cd, instruction *iptr);
+
+void emit_trap_compiler(codegendata *cd);
+void emit_trap_countdown(codegendata *cd, s4 *counter);
+uint32_t emit_trap(codegendata *cd);
+
+void emit_patcher_traps(jitdata *jd);
+
+void emit_verbosecall_enter(jitdata *jd);
+void emit_verbosecall_exit(jitdata *jd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _EMIT_COMMON_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 102f455149a7ace0650b50342fb1bb954cb68b73..9130543d24762d806416a9e9774bd7369b3ddd33 100644 (file)
@@ -30,9 +30,9 @@
 
 #include "mm/memory.h"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/exceptiontable.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* exceptiontable_create *******************************************************
index 903b250f26125de9c673263c0243cab151b384d9..d4733aefba4de85cef912646b7d053c0932e511a 100644 (file)
@@ -36,8 +36,8 @@ typedef struct exceptiontable_entry_t exceptiontable_entry_t;
 
 #include <stdint.h>
 
-#include "vm/jit/code.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/code.hpp"
+#include "vm/jit/jit.hpp"
 
 
 /* exceptiontable_t ***********************************************************/
@@ -60,6 +60,10 @@ struct exceptiontable_entry_t {
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void exceptiontable_create(jitdata *jd);
 void exceptiontable_free(codeinfo *code);
 
@@ -67,6 +71,10 @@ void exceptiontable_free(codeinfo *code);
 void exceptiontable_print(codeinfo *code);
 #endif
 
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
 #endif /* _EXCEPTIONTABLE_H */
 
 
index 34153a63033c78b878c1b29c776b05d4971ef64c..cfcac31c3dc4e1a5b114b35a39427448dd0e9948 100644 (file)
 
 #include "md-abi.h"
 
+#include "vm/descriptor.h"
+#include "vm/os.hpp"
+
 #include "vm/jit/abi.h"
 #include "vm/jit/executionstate.h"
 
-#include "vmcore/descriptor.h"
-#include "vmcore/system.h"
-
 
 /* executionstate_sanity_check *************************************************
 
@@ -66,13 +66,13 @@ void executionstate_sanity_check(void *context)
 
        /* keep a copy of (a prefix of) the context for reference */
 
-       system_memcpy(&reference, context, MINIMUM_CONTEXT_SIZE);
+       os_memcpy(&reference, context, MINIMUM_CONTEXT_SIZE);
 
        /* different poisons */
 
-       system_memset(&es1, 0xc9, sizeof(executionstate_t));
-       system_memset(&es2, 0xb5, sizeof(executionstate_t));
-       system_memset(&es3, 0x6f, sizeof(executionstate_t));
+       os_memset(&es1, 0xc9, sizeof(executionstate_t));
+       os_memset(&es2, 0xb5, sizeof(executionstate_t));
+       os_memset(&es3, 0x6f, sizeof(executionstate_t));
 
        md_executionstate_read(&es1, context);
 
@@ -221,11 +221,7 @@ void executionstate_println(executionstate_t *es)
                        if (i%4 == 0)
                                printf("\n\t\t");
                        printf("M%02d%c", i, (i >= slots) ? '(' : ' ');
-#ifdef HAS_4BYTE_STACKSLOT
-                       printf("%08lx",(unsigned long)*sp++);
-#else
                        printf("%016llx",(unsigned long long)*sp++);
-#endif
                        printf("%c", (i >= slots) ? ')' : ' ');
                }
                printf("\n");
index 46211e722eecceb90767ddf30597a3bc174aea6b..59e14ea4be23ef7e8ce7c6c47e12e0feff8842f5 100644 (file)
@@ -38,7 +38,7 @@ typedef struct executionstate_t executionstate_t;
 #include "arch.h"
 #include "md-abi.h"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 
 
 /* executionstate_t ************************************************************
@@ -68,6 +68,10 @@ struct executionstate_t {
 
 /* prototypes *****************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if !defined(NDEBUG)
 void executionstate_sanity_check(void *context);
 void executionstate_println(executionstate_t *es);
@@ -78,6 +82,10 @@ void executionstate_println(executionstate_t *es);
 void md_executionstate_read(executionstate_t *es, void *ucontext);
 void md_executionstate_write(executionstate_t *es, void *ucontext);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _EXECUTIONSTATE_H */
 
 
index 0adf031286e8a9cf89c1a263b7b312ae905e2968..044070caf81ba6a780d7ca8040367fb3bf121bb4 100644 (file)
@@ -25,7 +25,8 @@ DIST_SUBDIRS = \
        cygwin \
        darwin \
        freebsd \
-       linux
+       linux \
+       solaris
 
 SUBDIRS = $(OS_DIR)
 
@@ -36,7 +37,7 @@ LIBS =
 
 noinst_HEADERS = \
        arch.h \
-       machine-instr.h
+       md-atomic.hpp
 
 noinst_LTLIBRARIES = \
        libarch.la
@@ -57,6 +58,7 @@ libarch_la_SOURCES = \
        \
        md-abi.c \
        md-abi.h \
+       md-stubs.hpp \
        md-trap.h \
        md.c \
        md.h
index ec23f8cd0da4863edb19b09abc4975a839690b01..a154f54cc6b8ba2eb0d6b5795ccfb8f04a915348 100644 (file)
@@ -46,8 +46,6 @@
 
 /* define architecture features ***********************************************/
 
-#define U8_AVAILABLE                     1
-
 #define SUPPORT_DIVISION                 1
 #define SUPPORT_LONG                     1
 
index 83682c7c62d0e2bc764b85bbb27dbb91becf3a36..a367f37aa4a05b5cd11801c2ca5a16bacd01d923 100644 (file)
 #include "vm/jit/i386/emit.h"
 
 #include "mm/memory.h"
-#include "native/jni.h"
-#include "native/localref.h"
-#include "native/native.h"
 
-#include "threads/lock-common.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "threads/lock.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/primitive.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #if defined(ENABLE_SSA)
 # include "vm/jit/allocator/lsra.h"
 #endif
 
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/utf8.h"
-
 
 /* codegen_emit ****************************************************************
 
@@ -408,9 +406,7 @@ bool codegen_emit(jitdata *jd)
                if (bptr->bitflags & BBFLAG_REPLACEMENT) {
                        if (cd->replacementpoint[-1].flags & RPLPOINT_FLAG_COUNTDOWN) {
                                MCODECHECK(32);
-                               disp = (s4) &(m->hitcountdown);
-                               M_ISUB_IMM_MEMABS(1, disp);
-                               M_BS(0);
+                               emit_trap_countdown(cd, &(m->hitcountdown));
                        }
                }
 #endif
@@ -2225,7 +2221,7 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_PUTSTATIC:  /* ..., value  ==> ...                          */
-
+                       
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                uf        = iptr->sx.s23.s3.uf;
                                fieldtype = uf->fieldref->parseddesc.fd->type;
@@ -2891,6 +2887,21 @@ nowperformreturn:
 
                        bte = iptr->sx.s23.s3.bte;
                        md = bte->md;
+
+#if defined(ENABLE_ESCAPE_REASON)
+                       if (bte->fp == BUILTIN_escape_reason_new) {
+                               void set_escape_reasons(void *);
+                               M_ASUB_IMM(8, REG_SP);
+                               M_MOV_IMM(iptr->escape_reasons, REG_ITMP1);
+                               M_AST(EDX, REG_SP, 4);
+                               M_AST(REG_ITMP1, REG_SP, 0);
+                               M_MOV_IMM(set_escape_reasons, REG_ITMP1);
+                               M_CALL(REG_ITMP1);
+                               M_ALD(EDX, REG_SP, 4);
+                               M_AADD_IMM(8, REG_SP);
+                       }
+#endif
+
                        goto gen_method;
 
                case ICMD_INVOKESTATIC: /* ..., [arg1, [arg2 ...]] ==> ...            */
@@ -3670,7 +3681,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
                /* put env into first argument */
 
-               M_AST_IMM(_Jv_env, REG_SP, 0 * 4);
+               M_AST_IMM(VM_get_jnienv(), REG_SP, 0 * 4);
        }
 
        /* Call the native function. */
@@ -3686,7 +3697,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
        switch (md->returntype.type) {
        case TYPE_INT:
        case TYPE_ADR:
-               switch (md->returntype.decltype) {
+               switch (md->returntype.primitivetype) {
                case PRIMITIVETYPE_BOOLEAN:
                        M_BZEXT(REG_RESULT, REG_RESULT);
                        break;
index 6ee339cfde3e18a5d8d32f63efdc4aa1fed2f44f..ef28c246583b33a92fcc18363a20281d8f8e91ba 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/i386/codegen.h - code generation macros and definitions for i386
 
-   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.
 
@@ -33,7 +31,7 @@
 
 #include "vm/jit/i386/emit.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 #if defined(ENABLE_LSRA)
     } while (0)
 
 
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE    6
-
-
 /* macros to create code ******************************************************/
 
 #define M_BYTE1(a) \
index bd96c8bdd83663a5a93a466901af407ef86cd8f1..e35e6f6a18ca1dca37200e53b182f85c3234923a 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/i386/cygwin/md-os.c - machine dependent i386 Windows functions
 
-   Copyright (C) 1996-2005, 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) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Michael Starzinger
-
-   Changes:
-
 */
 
 
 
 #include "vm/types.h"
 
-#include "vm/exceptions.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
 
 
 /* md_signal_handler_sigsegv ***************************************************
@@ -73,14 +62,6 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
 }
 
 
-#if defined(ENABLE_THREADS)
-void thread_restartcriticalsection(ucontext_t *uc)
-{
-       assert(0);
-}
-#endif
-
-
 /*
  * 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
index 9ad6dc6814db1f18daa8a4abcf0cb66643a35500..87157e5009984fac885e9903971efb261fd67628 100644 (file)
 #include "vm/jit/i386/codegen.h"
 #include "vm/jit/i386/md.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
+#include "vm/jit/builtin.hpp"
 #include "vm/global.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #include "vm/jit/i386/codegen.h"
@@ -65,50 +64,49 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        u1                  *sp;
        u1                  *ra;
        u1                  *xpc;
-    u1                   opc;
-    u1                   mod;
-    u1                   rm;
-    int                  d;
-    int32_t              disp;
+       u1                   opc;
+       u1                   mod;
+       u1                   rm;
+       int                  d;
+       int32_t              disp;
        intptr_t             val;
-    int                  type;
-    void                *p;
-       java_object_t       *o;
+       int                  type;
+       void                *p;
 
        _uc = (ucontext_t *) _p;
        _mc = _uc->uc_mcontext;
-       _ss = &_mc->ss;
+       _ss = &_mc->__ss;
 
-    pv  = NULL;                 /* is resolved during stackframeinfo creation */
-       sp  = (u1 *) _ss->esp;
-       xpc = (u1 *) _ss->eip;
-    ra  = xpc;                              /* return address is equal to XPC */
+       pv  = NULL;                 /* is resolved during stackframeinfo creation */
+       sp  = (u1 *) _ss->__esp;
+       xpc = (u1 *) _ss->__eip;
+       ra  = xpc;                              /* return address is equal to XPC */
 
-    /* get exception-throwing instruction */
+       /* get exception-throwing instruction */
 
-    opc = M_ALD_MEM_GET_OPC(xpc);
-    mod = M_ALD_MEM_GET_MOD(xpc);
-    rm  = M_ALD_MEM_GET_RM(xpc);
+       opc = M_ALD_MEM_GET_OPC(xpc);
+       mod = M_ALD_MEM_GET_MOD(xpc);
+       rm  = M_ALD_MEM_GET_RM(xpc);
 
-    /* for values see emit_mov_mem_reg and emit_mem */
+       /* for values see emit_mov_mem_reg and emit_mem */
 
-    if ((opc == 0x8b) && (mod == 0) && (rm == 5)) {
-        /* this was a hardware-exception */
+       if ((opc == 0x8b) && (mod == 0) && (rm == 5)) {
+               /* this was a hardware-exception */
 
-        d    = M_ALD_MEM_GET_REG(xpc);
-        disp = M_ALD_MEM_GET_DISP(xpc);
+               d    = M_ALD_MEM_GET_REG(xpc);
+               disp = M_ALD_MEM_GET_DISP(xpc);
 
-        /* we use the exception type as load displacement */
+               /* we use the exception type as load displacement */
 
-        type = disp;
+               type = disp;
 
-        val = (d == 0) ? _ss->eax :
-            ((d == 1) ? _ss->ecx :
-            ((d == 2) ? _ss->edx :
-            ((d == 3) ? _ss->ebx :
-            ((d == 4) ? _ss->esp :
-            ((d == 5) ? _ss->ebp :
-            ((d == 6) ? _ss->esi : _ss->edi))))));
+               val = (d == 0) ? _ss->__eax :
+                       ((d == 1) ? _ss->__ecx :
+                       ((d == 2) ? _ss->__edx :
+                       ((d == 3) ? _ss->__ebx :
+                       ((d == 4) ? _ss->__esp :
+                       ((d == 5) ? _ss->__ebp :
+                       ((d == 6) ? _ss->__esi : _ss->__edi))))));
 
                if (type == TRAP_COMPILER) {
                        /* The PV from the compiler stub is equal to the XPC. */
@@ -129,12 +127,12 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
                        xpc = ra - 2;
                } 
-    }
-    else {
-        /* this was a normal NPE */
+       }
+       else {
+               /* this was a normal NPE */
 
-        type = TRAP_NullPointerException;
-    }
+               type = TRAP_NullPointerException;
+       }
 
        /* Handle the trap. */
 
@@ -143,24 +141,10 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        /* Set registers. */
 
        if (type == TRAP_COMPILER) {
-               if (p == NULL) { 
-                       o = builtin_retrieve_exception();
-
-                       _ss->esp = (uintptr_t) sp;    /* Remove RA from stack. */
-
-                       _ss->eax = (uintptr_t) o;
-                       _ss->ecx = (uintptr_t) xpc;            /* REG_ITMP2_XPC */
-                       _ss->eip = (uintptr_t) asm_handle_exception;
-               }
-               else {
-                       _ss->eip = (uintptr_t) p;
+               if (p == NULL) {
+                       _ss->__esp = (uintptr_t) sp;  /* Remove RA from stack. */
                }
        }
-       else {
-               _ss->eax = (uintptr_t) p;
-               _ss->ecx = (uintptr_t) xpc;            /* REG_ITMP2_XPC */
-               _ss->eip = (uintptr_t) asm_handle_exception;
-       }
 }
 
 
@@ -175,39 +159,32 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
 {
        ucontext_t          *_uc;
        mcontext_t           _mc;
-    u1                  *pv;
+       u1                  *pv;
        i386_thread_state_t *_ss;
        u1                  *sp;
        u1                  *ra;
        u1                  *xpc;
-    int                  type;
-    intptr_t             val;
-    void                *p;
+       int                  type;
+       intptr_t             val;
 
 
        _uc = (ucontext_t *) _p;
        _mc = _uc->uc_mcontext;
-       _ss = &_mc->ss;
+       _ss = &_mc->__ss;
 
-    pv  = NULL;                 /* is resolved during stackframeinfo creation */
-       sp  = (u1 *) _ss->esp;
-       xpc = (u1 *) _ss->eip;
+       pv  = NULL;                 /* is resolved during stackframeinfo creation */
+       sp  = (u1 *) _ss->__esp;
+       xpc = (u1 *) _ss->__eip;
        ra  = xpc;                          /* return address is equal to xpc     */
 
-    /* This is an ArithmeticException */
+       /* This is an ArithmeticException */
 
-    type = TRAP_ArithmeticException;
-    val  = 0;
+       type = TRAP_ArithmeticException;
+       val  = 0;
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-    _ss->eax = (uintptr_t) p;
-       _ss->ecx = (uintptr_t) xpc;            /* REG_ITMP2_XPC */
-       _ss->eip = (uintptr_t) asm_handle_exception;
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -229,9 +206,9 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 
        _uc = (ucontext_t *) _p;
        _mc = _uc->uc_mcontext;
-       _ss = &_mc->ss;
+       _ss = &_mc->__ss;
 
-       pc = (u1 *) _ss->eip;
+       pc = (u1 *) _ss->__eip;
 
        t->pc = pc;
 }
@@ -254,16 +231,15 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
        u1                  *xpc;
        int                  type;
        intptr_t             val;
-       void                *p;
 
 
        _uc = (ucontext_t *) _p;
        _mc = _uc->uc_mcontext;
-       _ss = &_mc->ss;
+       _ss = &_mc->__ss;
 
        pv  = NULL;                 /* is resolved during stackframeinfo creation */
-       sp  = (u1 *) _ss->esp;
-       xpc = (u1 *) _ss->eip;
+       sp  = (u1 *) _ss->__esp;
+       xpc = (u1 *) _ss->__eip;
        ra  = xpc;                          /* return address is equal to xpc     */
 
        type = TRAP_PATCHER;
@@ -271,15 +247,7 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-       if (p != NULL) {
-               _ss->eax = (uintptr_t) p;
-               _ss->ecx = (uintptr_t) xpc;            /* REG_ITMP2_XPC */
-               _ss->eip = (uintptr_t) asm_handle_exception;
-       }
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 /* md_executionstate_read ******************************************************
@@ -297,22 +265,22 @@ void md_executionstate_read(executionstate_t *es, void *context)
 
        _uc = (ucontext_t *) context;
        _mc = _uc->uc_mcontext;
-       _ss = &_mc->ss;
+       _ss = &_mc->__ss;
 
        /* read special registers */
-       es->pc = (u1 *) _ss->eip;
-       es->sp = (u1 *) _ss->esp;
+       es->pc = (u1 *) _ss->__eip;
+       es->sp = (u1 *) _ss->__esp;
        es->pv = NULL;                   /* pv must be looked up via AVL tree */
 
        /* read integer registers */
        for (i = 0; i < INT_REG_CNT; i++)
-               es->intregs[i] = (i == 0) ? _ss->eax :
-                       ((i == 1) ? _ss->ecx :
-                       ((i == 2) ? _ss->edx :
-                       ((i == 3) ? _ss->ebx :
-                       ((i == 4) ? _ss->esp :
-                       ((i == 5) ? _ss->ebp :
-                       ((i == 6) ? _ss->esi : _ss->edi))))));
+               es->intregs[i] = (i == 0) ? _ss->__eax :
+                       ((i == 1) ? _ss->__ecx :
+                       ((i == 2) ? _ss->__edx :
+                       ((i == 3) ? _ss->__ebx :
+                       ((i == 4) ? _ss->__esp :
+                       ((i == 5) ? _ss->__ebp :
+                       ((i == 6) ? _ss->__esi : _ss->__edi))))));
 
        /* read float registers */
        for (i = 0; i < FLT_REG_CNT; i++)
@@ -335,50 +303,22 @@ void md_executionstate_write(executionstate_t *es, void *context)
 
        _uc = (ucontext_t *) context;
        _mc = _uc->uc_mcontext;
-       _ss = &_mc->ss;
+       _ss = &_mc->__ss;
 
        /* write integer registers */
        for (i = 0; i < INT_REG_CNT; i++)
-               *((i == 0) ? &_ss->eax :
-                 ((i == 1) ? &_ss->ecx :
-                 ((i == 2) ? &_ss->edx :
-                 ((i == 3) ? &_ss->ebx :
-                 ((i == 4) ? &_ss->esp :
-                 ((i == 5) ? &_ss->ebp :
-                 ((i == 6) ? &_ss->esi : &_ss->edi))))))) = es->intregs[i];
+               *((i == 0) ? &_ss->__eax :
+                ((i == 1) ? &_ss->__ecx :
+                ((i == 2) ? &_ss->__edx :
+                ((i == 3) ? &_ss->__ebx :
+                ((i == 4) ? &_ss->__esp :
+                ((i == 5) ? &_ss->__ebp :
+                ((i == 6) ? &_ss->__esi : &_ss->__edi))))))) = es->intregs[i];
 
        /* write special registers */
-       _ss->eip = (ptrint) es->pc;
-       _ss->esp = (ptrint) es->sp;
-}
-
-
-/* md_critical_section_restart *************************************************
-
-   Search the critical sections tree for a matching section and set
-   the PC to the restart point, if necessary.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void thread_restartcriticalsection(ucontext_t *_uc)
-{
-       mcontext_t           _mc;
-       i386_thread_state_t *_ss;
-       u1                  *pc;
-       void                *rpc;
-
-       _mc = _uc->uc_mcontext;
-       _ss = &_mc->ss;
-
-       pc = (u1 *) _ss->eip;
-
-       rpc = critical_find_restart_point(pc);
-
-       if (rpc != NULL)
-               _ss->eip = (ptrint) rpc;
+       _ss->__eip = (ptrint) es->pc;
+       _ss->__esp = (ptrint) es->sp;
 }
-#endif
 
 
 /*
index 8703bd2c17aca011acf93156bcc1379654677e74..d7140291a69a36eb02f0ad3c28563c7d14053561 100644 (file)
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/exceptions.h"
+#include "vm/options.h"
+#include "vm/statistics.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/trace.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-
 
 /* emit_load ******************************************************************
 
@@ -523,6 +521,20 @@ void emit_trap_compiler(codegendata *cd)
        M_ALD_MEM(REG_METHODPTR, TRAP_COMPILER);
 }
 
+/* emit_trap_countdown *********************************************************
+
+   Emit a countdown trap.
+
+   counter....absolute address of the counter variable
+
+*******************************************************************************/
+
+void emit_trap_countdown(codegendata *cd, s4 *counter)
+{
+       M_ISUB_IMM_MEMABS(1, (s4) counter);
+       M_BNS(6);
+       M_ALD_MEM(REG_METHODPTR, TRAP_COUNTDOWN);
+}
 
 /* emit_trap *******************************************************************
 
index a7c0d0c88101eabbfcc726a7183d2b5a43c02981..a99eaeeb386c471a5b496f9b3ba67d2c9860ce0f 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "vm/types.h"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 #define REG_AL       0
index 4eebf69877da4a0e589657b06a81982089c15989..9a1dc9d5eaedd2ac8ec652d873bfcc4e297b54d1 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/i386/freebsd/md-os.c - machine dependent i386 FreeBSD functions
 
-   Copyright (C) 1996-2005, 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) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
 */
 
 
 #include "config.h"
 
+#include <stdint.h>
 #include <ucontext.h>
 
-#include "vm/jit/i386/md-abi.h"
+#include "vm/types.h"
 
-#include "vm/exceptions.h"
+#include "vm/jit/i386/codegen.h"
+#include "vm/jit/i386/md.h"
+
+#include "threads/thread.hpp"
+
+#include "vm/jit/builtin.hpp"
 #include "vm/signallocal.h"
+
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/executionstate.h"
+#include "vm/jit/stacktrace.hpp"
+#include "vm/jit/trap.h"
 
 
 /* md_signal_handler_sigsegv ***************************************************
 
-   NullPointerException signal handler for hardware null pointer
-   check.
+   Signal handler for hardware exceptions.
 
 *******************************************************************************/
 
 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 {
-       ucontext_t *_uc;
-       mcontext_t *_mc;
-       u1         *sp;
-       u1         *ra;
-       u1         *xpc;
+       ucontext_t     *_uc;
+       mcontext_t     *_mc;
+       u1             *pv;
+       u1             *sp;
+       u1             *ra;
+       u1             *xpc;
+       u1              opc;
+       u1              mod;
+       u1              rm;
+       s4              d;
+       s4              disp;
+       ptrint          val;
+       s4              type;
+       void           *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
-       
+
+       pv  = NULL;                 /* is resolved during stackframeinfo creation */
        sp  = (u1 *) _mc->mc_esp;
        xpc = (u1 *) _mc->mc_eip;
-       ra  = xpc;                          /* return address is equal to xpc     */
+       ra  = xpc;                              /* return address is equal to XPC */
+
+       /* get exception-throwing instruction */
+
+       opc = M_ALD_MEM_GET_OPC(xpc);
+       mod = M_ALD_MEM_GET_MOD(xpc);
+       rm  = M_ALD_MEM_GET_RM(xpc);
+
+       /* for values see emit_mov_mem_reg and emit_mem */
+
+       if ((opc == 0x8b) && (mod == 0) && (rm == 5)) {
+               /* this was a hardware-exception */
+
+               d    = M_ALD_MEM_GET_REG(xpc);
+               disp = M_ALD_MEM_GET_DISP(xpc);
+
+               /* we use the exception type as load displacement */
+
+               type = disp;
+
+               switch (d) {
+               case EAX:
+                       val = _mc->mc_eax;
+                       break;
+               case ECX:
+                       val = _mc->mc_ecx;
+                       break;
+               case EDX:
+                       val = _mc->mc_edx;
+                       break;
+               case EBX:
+                       val = _mc->mc_ebx;
+                       break;
+               case ESP:
+                       val = _mc->mc_esp;
+                       break;
+               case EBP:
+                       val = _mc->mc_ebp;
+                       break;
+               case ESI:
+                       val = _mc->mc_esi;
+                       break;
+               case EDI:
+                       val = _mc->mc_edi;
+                       break;
+               default:
+                       vm_abort("md_signal_handler_sigsegv: Unkown register %d", d);
+               }
+
+               if (type == TRAP_COMPILER) {
+                       /* The PV from the compiler stub is equal to the XPC. */
+
+                       pv = xpc;
+
+                       /* We use a framesize of zero here because the call pushed
+                          the return addres onto the stack. */
+
+                       ra = md_stacktrace_get_returnaddress(sp, 0);
 
-       _mc->mc_eax =
-               (ptrint) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
-       
-       _mc->mc_ecx = (ptrint) xpc;                              /* REG_ITMP2_XPC */
-       _mc->mc_eip = (ptrint) asm_handle_exception;
+                       /* Skip the RA on the stack. */
+
+                       sp = sp + 1 * SIZEOF_VOID_P;
+
+                       /* The XPC is the RA minus 2, because the RA points to the
+                          instruction after the call. */
+
+                       xpc = ra - 2;
+               }
+       }
+       else {
+               /* this was a normal NPE */
+
+               type = TRAP_NullPointerException;
+               val  = 0;
+       }
+
+       /* Handle the trap. */
+
+       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
+
+       /* Set registers. */
+
+       if (type == TRAP_COMPILER) {
+               if (p == NULL) {
+                       _mc->mc_esp = (uintptr_t) sp; // Remove RA from stack.
+               }
+       }
 }
 
 
@@ -82,40 +172,180 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
 void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
 {
-       ucontext_t *_uc;
-       mcontext_t *_mc;
-       u1         *sp;
-       u1         *ra;
-       u1         *xpc;
+       ucontext_t     *_uc;
+       mcontext_t     *_mc;
+       u1             *pv;
+       u1             *sp;
+       u1             *ra;
+       u1             *xpc;
+       s4              type;
+       ptrint          val;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
 
+       pv  = NULL;                 /* is resolved during stackframeinfo creation */
        sp  = (u1 *) _mc->mc_esp;
        xpc = (u1 *) _mc->mc_eip;
        ra  = xpc;                          /* return address is equal to xpc     */
 
-       _mc->mc_eax =
-               (ptrint) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
-       
-       _mc->mc_ecx = (ptrint) xpc;                              /* REG_ITMP2_XPC */
-       _mc->mc_eip = (ptrint) asm_handle_exception;
+       /* This is an ArithmeticException. */
+
+       type = TRAP_ArithmeticException;
+       val  = 0;
+
+       /* Handle the trap. */
+
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
+}
+
+
+/* md_signal_handler_sigill ****************************************************
+
+   Signal handler for hardware patcher traps (ud2).
+
+*******************************************************************************/
+
+void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t        *_uc;
+       mcontext_t        *_mc;
+       u1                *pv;
+       u1                *sp;
+       u1                *ra;
+       u1                *xpc;
+       s4                 type;
+       ptrint             val;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       pv  = NULL;                 /* is resolved during stackframeinfo creation */
+       sp  = (u1 *) _mc->mc_esp;
+       xpc = (u1 *) _mc->mc_eip;
+       ra  = xpc;                            /* return address is equal to xpc   */
+
+       type = TRAP_PATCHER;
+       val  = 0;
+
+       /* Handle the trap. */
+
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
+}
+
+
+/* md_signal_handler_sigusr1 ***************************************************
+
+   Signal handler for suspending threads.
+
+*******************************************************************************/
+
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+void md_signal_handler_sigusr1(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t *_uc;
+       mcontext_t *_mc;
+       u1         *pc;
+       u1         *sp;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       /* get the PC and SP for this thread */
+       pc = (u1 *) _mc->mc_eip;
+       sp = (u1 *) _mc->mc_esp;
+
+       /* now suspend the current thread */
+       threads_suspend_ack(pc, sp);
 }
+#endif
 
 
+/* md_signal_handler_sigusr2 ***************************************************
+
+   Signal handler for profiling sampling.
+
+*******************************************************************************/
+
 #if defined(ENABLE_THREADS)
-void thread_restartcriticalsection(ucontext_t *uc)
+void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 {
-       void *critical;
+       threadobject *t;
+       ucontext_t   *_uc;
+       mcontext_t   *_mc;
+       u1           *pc;
+
+       t = THREADOBJECT;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
 
-       critical = critical_find_restart_point((void *) uc->uc_mcontext.mc_eip);
+       pc = (u1 *) _mc->mc_eip;
 
-       if (critical)
-               uc->uc_mcontext.mc_eip = (ptrint) critical;
+       t->pc = pc;
 }
 #endif
 
 
+/* md_executionstate_read ******************************************************
+
+   Read the given context into an executionstate for Replacement.
+
+*******************************************************************************/
+
+void md_executionstate_read(executionstate_t* es, void* context)
+{
+       ucontext_t* _uc = (ucontext_t*) context;
+       mcontext_t* _mc = &_uc->uc_mcontext;
+
+       // Read special registers.
+       es->pc = (u1 *) _mc->mc_eip;
+       es->sp = (u1 *) _mc->mc_esp;
+       es->pv = NULL;                   /* pv must be looked up via AVL tree */
+
+       // Read integer registers.
+       es->intregs[EAX] = _mc->mc_eax;
+       es->intregs[ECX] = _mc->mc_ecx;
+       es->intregs[EDX] = _mc->mc_edx;
+       es->intregs[EBX] = _mc->mc_ebx;
+       es->intregs[ESP] = _mc->mc_esp;
+       es->intregs[EBP] = _mc->mc_ebp;
+       es->intregs[ESI] = _mc->mc_esi;
+       es->intregs[EDI] = _mc->mc_edi;
+
+       // Read float registers.
+       for (int i = 0; i < FLT_REG_CNT; i++)
+               es->fltregs[i] = 0xdeadbeefdeadbeefULL;
+}
+
+
+/* md_executionstate_write *****************************************************
+
+   Write the given executionstate back to the context for Replacement.
+
+*******************************************************************************/
+
+void md_executionstate_write(executionstate_t* es, void* context)
+{
+       ucontext_t* _uc = (ucontext_t*) context;
+       mcontext_t* _mc = &_uc->uc_mcontext;
+
+       // Write integer registers.
+       _mc->mc_eax = es->intregs[EAX];
+       _mc->mc_ecx = es->intregs[ECX];
+       _mc->mc_edx = es->intregs[EDX];
+       _mc->mc_ebx = es->intregs[EBX];
+       _mc->mc_esp = es->intregs[ESP];
+       _mc->mc_ebp = es->intregs[EBP];
+       _mc->mc_esi = es->intregs[ESI];
+       _mc->mc_edi = es->intregs[EDI];
+
+       // Write special registers.
+       _mc->mc_eip = (uintptr_t) es->pc;
+       _mc->mc_esp = (uintptr_t) es->sp;
+}
+
+
 /*
  * 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
index 17630b05143dd0f437031b94877eb7efdf9e2c9b..f046f37d6cfbddacd0746d1706ec511cf416d36c 100644 (file)
 #include "vm/jit/i386/codegen.h"
 #include "vm/jit/i386/md.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
+#include "vm/jit/builtin.hpp"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 
@@ -69,7 +68,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        ptrint          val;
        s4              type;
        void           *p;
-       java_object_t  *o;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -139,23 +137,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        if (type == TRAP_COMPILER) {
                if (p == NULL) {
-                       o = builtin_retrieve_exception();
-
                        _mc->gregs[REG_ESP] = (uintptr_t) sp;    /* Remove RA from stack. */
-
-                       _mc->gregs[REG_EAX] = (uintptr_t) o;
-                       _mc->gregs[REG_ECX] = (uintptr_t) xpc;           /* REG_ITMP2_XPC */
-                       _mc->gregs[REG_EIP] = (uintptr_t) asm_handle_exception;
-               }
-               else {
-                       _mc->gregs[REG_EIP] = (uintptr_t) p;
                }
        }
-       else {
-               _mc->gregs[REG_EAX] = (uintptr_t) p;
-               _mc->gregs[REG_ECX] = (uintptr_t) xpc;               /* REG_ITMP2_XPC */
-               _mc->gregs[REG_EIP] = (uintptr_t) asm_handle_exception;
-       }
 }
 
 
@@ -176,7 +160,6 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
        u1             *xpc;
        s4              type;
        ptrint          val;
-       void           *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -193,13 +176,7 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-       _mc->gregs[REG_EAX] = (uintptr_t) p;
-       _mc->gregs[REG_ECX] = (uintptr_t) xpc;                   /* REG_ITMP2_XPC */
-       _mc->gregs[REG_EIP] = (uintptr_t) asm_handle_exception;
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -219,7 +196,6 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
        u1                *xpc;
        s4                 type;
        ptrint             val;
-       void              *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -234,15 +210,7 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-       if (p != NULL) {
-               _mc->gregs[REG_EAX] = (uintptr_t) p;
-               _mc->gregs[REG_ECX] = (uintptr_t) xpc;               /* REG_ITMP2_XPC */
-               _mc->gregs[REG_EIP] = (uintptr_t) asm_handle_exception;
-       }
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -354,32 +322,6 @@ void md_executionstate_write(executionstate_t *es, void *context)
 }
 
 
-/* md_critical_section_restart *************************************************
-
-   Search the critical sections tree for a matching section and set
-   the PC to the restart point, if necessary.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
-{
-       mcontext_t *_mc;
-       u1         *pc;
-       u1         *npc;
-
-       _mc = &_uc->uc_mcontext;
-
-       pc = (u1 *) _mc->gregs[REG_EIP];
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL)
-               _mc->gregs[REG_EIP] = (ptrint) npc;
-}
-#endif
-
-
 /*
  * 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
diff --git a/src/vm/jit/i386/machine-instr.h b/src/vm/jit/i386/machine-instr.h
deleted file mode 100644 (file)
index 1499e96..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef _MACHINE_INSTR_H
-#define _MACHINE_INSTR_H
-
-static inline long
-__attribute__ ((unused))
-compare_and_swap (volatile long *p, long oldval, long newval)
-{
-  long ret;
-
-  __asm__ __volatile__ ("lock; cmpxchgl %2, %1"
-                        : "=a" (ret), "=m" (*p)
-                        : "r" (newval), "m" (*p), "0" (oldval));
-  return ret;
-}
-
-#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory");
-#define MEMORY_BARRIER_AFTER_ATOMIC() /* nothing */
-#define MEMORY_BARRIER() __asm__ __volatile__ ( \
-               "lock; add $0, 0(%%esp)" : : : "memory" );
-
-#endif
index f4d9f4c66cc2dafe337d057741f35c0ccff7ce12..dbaf089b81d80c4ba3f5b02f8ae5e0f0bcda1b70 100644 (file)
 
 #include "vm/jit/i386/md-abi.h"
 
+#include "vm/descriptor.h"
 #include "vm/global.h"
 
 #include "vm/jit/abi.h"
 
-#include "vmcore/descriptor.h"
-
 
 /* register descripton - array ************************************************/
 
diff --git a/src/vm/jit/i386/md-atomic.hpp b/src/vm/jit/i386/md-atomic.hpp
new file mode 100644 (file)
index 0000000..d6ea3d7
--- /dev/null
@@ -0,0 +1,129 @@
+/* src/vm/jit/i386/atomic.hpp - i386 atomic instructions
+
+   Copyright (C) 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 _MD_ATOMIC_HPP
+#define _MD_ATOMIC_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "threads/atomic.hpp"
+
+
+/**
+ * An atomic compare and swap for 32-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
+{
+       uint32_t result;
+
+       __asm__ __volatile__ ("lock; cmpxchgl %2, %1"
+                                                 : "=a" (result), "=m" (*p)
+                                                 : "r" (newval), "m" (*p), "0" (oldval));
+
+       return result;
+}
+
+
+/**
+ * An atomic compare and swap for 64-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
+{
+#warning Should we use cmpxchg8b or a generic version?
+       return generic_compare_and_swap(p, oldval, newval);
+}
+
+
+/**
+ * An atomic compare and swap for pointer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval)
+{
+       return (void*) compare_and_swap((volatile uint32_t*) p, (uint32_t) oldval, (uint32_t) newval);
+}
+
+
+/**
+ * A memory barrier.
+ */
+inline void Atomic::memory_barrier(void)
+{
+       __asm__ __volatile__ ("lock; add $0, 0(%%esp)" : : : "memory" );
+}
+
+
+/**
+ * A write memory barrier.
+ */
+inline void Atomic::write_memory_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+
+/**
+ * An instruction barrier.
+ */
+inline void Atomic::instruction_barrier(void)
+{
+       // Nothing.
+}
+
+#endif // _MD_ATOMIC_HPP
+
+
+/*
+ * 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/jit/i386/md-stubs.hpp b/src/vm/jit/i386/md-stubs.hpp
new file mode 100644 (file)
index 0000000..c5ccf43
--- /dev/null
@@ -0,0 +1,56 @@
+/* src/vm/jit/i386/md-stubs.hpp - i386 JIT stubs
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on an i386 architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+       return 6;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * 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 0c39650967eae2db07d0c9449b5e361b9cdae55f..52e6a0067ce0d74777e664f73cfc85da4c757e65 100644 (file)
@@ -1,4 +1,4 @@
-/* src/vm/jit/x86_64/md-trap.h - i386 hardware traps
+/* src/vm/jit/i386/md-trap.h - i386 hardware traps
 
    Copyright (C) 2008
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
@@ -58,6 +58,7 @@ enum {
        /* Don't use 8 (could be a normal load offset). */
 
        TRAP_COMPILER                       = 9,
+       TRAP_COUNTDOWN                      = 10,
        TRAP_END
 };
 
index 48664ef1fddd22e7084106164fcab40f35011947..191cddabd02cdb6d88b8b99a1b62b38dd6598c02 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/i386/md.c - machine dependent i386 functions
 
-   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.
 
 #include "vm/types.h"
 
 #include "vm/global.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* md_init *********************************************************************
index 568f8e934d0115ac9bb15754eedc4e32cbb2346e..562736be4f66d47c4fb2fd343d16a7d75a525a48 100644 (file)
@@ -31,7 +31,7 @@
 #include <assert.h>
 #include <stdint.h>
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/methodtree.h"
 
 
@@ -85,7 +85,8 @@ inline static void *md_codegen_get_pv_from_pc(void *ra)
 
 inline static void md_cacheflush(void *addr, int nbytes)
 {
-       /* do nothing */
+       // Compiler optimization barrier (see PR97).
+       __asm__ __volatile__ ("" : : : "memory");
 }
 
 
@@ -97,7 +98,8 @@ inline static void md_cacheflush(void *addr, int nbytes)
 
 inline static void md_icacheflush(void *addr, int nbytes)
 {
-       /* do nothing */
+       // Compiler optimization barrier (see PR97).
+       __asm__ __volatile__ ("" : : : "memory");
 }
 
 
@@ -109,7 +111,8 @@ inline static void md_icacheflush(void *addr, int nbytes)
 
 inline static void md_dcacheflush(void *addr, int nbytes)
 {
-       /* do nothing */
+       // Compiler optimization barrier (see PR97).
+       __asm__ __volatile__ ("" : : : "memory");
 }
 
 #endif /* _VM_JIT_I386_MD_H */
index 13506172df5fc54f99492123794673c7276ebd0c..3eecac97ed221fe0b0a2956aef2876cd1ab686b1 100644 (file)
 #include "vm/types.h"
 
 #include "vm/jit/i386/codegen.h"
+#include "vm/jit/i386/md.h"
 
 #include "mm/memory.h"
 
-#include "native/native.h"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
 
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/patcher-common.hpp"
 
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vm/resolve.h"
-#include "vmcore/references.h"
 
-
-#define PATCH_BACK_ORIGINAL_MCODE *((u2 *) pr->mpc) = (u2) pr->mcode
+#define PATCH_BACK_ORIGINAL_MCODE                                                      \
+       do {                                                                                                    \
+               *((uint16_t*) pr->mpc) = (uint16_t) pr->mcode;          \
+               md_icacheflush((void*) pr->mpc, PATCHER_CALL_SIZE);     \
+       } while (0)
 
 
 /* patcher_patch_code **********************************************************
@@ -97,11 +99,6 @@ bool patcher_get_putstatic(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch the field value's address */
 
        *((intptr_t *) (ra + 1)) = (intptr_t) fi->value;
@@ -137,11 +134,6 @@ bool patcher_getfield(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch the field's offset */
 
        *((u4 *) (ra + 2)) = (u4) (fi->offset);
@@ -182,11 +174,6 @@ bool patcher_putfield(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch the field's offset */
 
        if (fi->type != TYPE_LNG) {
@@ -234,11 +221,6 @@ bool patcher_putfieldconst(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch the field's offset */
 
        if (!IS_2_WORD_TYPE(fi->type)) {
@@ -287,11 +269,6 @@ bool patcher_aconst(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch the classinfo pointer */
 
        *((ptrint *) (ra + 1)) = (ptrint) c;
@@ -333,11 +310,6 @@ bool patcher_builtin_multianewarray(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch the classinfo pointer */
 
        *((ptrint *) (ra + 7 + 4)) = (ptrint) c;
@@ -375,11 +347,6 @@ bool patcher_builtin_arraycheckcast(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch the classinfo pointer */
 
        *((ptrint *) (ra + 4)) = (ptrint) c;
@@ -420,11 +387,6 @@ bool patcher_invokestatic_special(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch stubroutine */
 
        *((ptrint *) (ra + 1)) = (ptrint) m->stubroutine;
@@ -462,11 +424,6 @@ bool patcher_invokevirtual(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch vftbl index */
 
        *((s4 *) (ra + 2 + 2)) = (s4) (OFFSET(vftbl_t, table[0]) +
@@ -506,11 +463,6 @@ bool patcher_invokeinterface(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch interfacetable index */
 
        *((s4 *) (ra + 2 + 2)) = (s4) (OFFSET(vftbl_t, interfacetable[0]) -
@@ -552,11 +504,6 @@ bool patcher_checkcast_instanceof_flags(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch class flags */
 
        *((s4 *) (ra + 1)) = (s4) c->flags;
@@ -597,11 +544,6 @@ bool patcher_checkcast_interface(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch super class index */
 
        *((s4 *) (ra + 6 + 2)) = (s4) c->index;
@@ -645,11 +587,6 @@ bool patcher_instanceof_interface(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch super class index */
 
        *((s4 *) (ra + 6 + 2)) = (s4) c->index;
@@ -693,11 +630,6 @@ bool patcher_checkcast_class(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch super class' vftbl */
 
        *((ptrint *) (ra + 1)) = (ptrint) c->vftbl;
@@ -736,11 +668,6 @@ bool patcher_instanceof_class(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch super class' vftbl */
 
        *((ptrint *) (ra + 1)) = (ptrint) c->vftbl;
diff --git a/src/vm/jit/i386/solaris/Makefile.am b/src/vm/jit/i386/solaris/Makefile.am
new file mode 100644 (file)
index 0000000..aa9595b
--- /dev/null
@@ -0,0 +1,44 @@
+## src/vm/jit/i386/solaris/Makefile.am
+##
+## Copyright (C) 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.
+
+
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_builddir)/src
+
+LIBS =
+
+noinst_HEADERS = \
+       md-asm.h
+
+noinst_LTLIBRARIES = \
+       libmd.la
+
+libmd_la_SOURCES = \
+       md-os.c
+
+
+## Local variables:
+## mode: Makefile
+## indent-tabs-mode: t
+## c-basic-offset: 4
+## tab-width: 8
+## compile-command: "automake --add-missing"
+## End:
diff --git a/src/vm/jit/i386/solaris/md-asm.h b/src/vm/jit/i386/solaris/md-asm.h
new file mode 100644 (file)
index 0000000..8a2a5fe
--- /dev/null
@@ -0,0 +1,82 @@
+/* src/vm/jit/i386/solaris/md-asm.h - assembler defines for i386 ABI
+
+   Copyright (C) 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 _MD_ASM_H
+#define _MD_ASM_H
+
+/* register defines ***********************************************************/
+
+#define v0       %eax
+#define itmp1    v0
+
+#define itmp2    %ecx
+#define itmp3    %edx
+
+#define t0       %ebx
+
+#define sp       %esp
+#define s0       %ebp
+#define s1       %esi
+#define s2       %edi
+
+#define bp       s0
+
+#define itmp1b   %al
+
+#define xptr     itmp1
+#define xpc      itmp2
+#define mptr     itmp2
+
+
+/* save and restore macros ****************************************************/
+
+#define SAVE_ARGUMENT_REGISTERS(off) \
+    /* no argument registers */
+
+#define SAVE_TEMPORARY_REGISTERS(off) \
+       mov     t0,(0+(off))*4(sp) ;
+
+
+#define RESTORE_ARGUMENT_REGISTERS(off) \
+    /* no argument registers */
+
+#define RESTORE_TEMPORARY_REGISTERS(off) \
+       mov     (0+(off))*4(sp),t0 ;
+
+#endif /* _MD_ASM_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:
+ */
diff --git a/src/vm/jit/i386/solaris/md-os.c b/src/vm/jit/i386/solaris/md-os.c
new file mode 100644 (file)
index 0000000..67363ec
--- /dev/null
@@ -0,0 +1,334 @@
+/* src/vm/jit/i386/solaris/md-os.c - machine dependent i386 Solaris functions
+
+   Copyright (C) 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 <stdint.h>
+#include <ucontext.h>
+
+#include "vm/types.h"
+
+#include "vm/jit/i386/codegen.h"
+#include "vm/jit/i386/md.h"
+
+#include "threads/thread.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/signallocal.h"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/executionstate.h"
+#include "vm/jit/stacktrace.hpp"
+#include "vm/jit/trap.h"
+
+
+/* md_signal_handler_sigsegv ***************************************************
+
+   Signal handler for hardware exceptions.
+
+*******************************************************************************/
+
+void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t     *_uc;
+       mcontext_t     *_mc;
+       u1             *pv;
+       u1             *sp;
+       u1             *ra;
+       u1             *xpc;
+       u1              opc;
+       u1              mod;
+       u1              rm;
+       s4              d;
+       s4              disp;
+       ptrint          val;
+       s4              type;
+       void           *p;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       pv  = NULL;                 /* is resolved during stackframeinfo creation */
+       sp  = (u1 *) _mc->gregs[ESP];
+       xpc = (u1 *) _mc->gregs[EIP];
+       ra  = xpc;                              /* return address is equal to XPC */
+
+       /* get exception-throwing instruction */
+
+       opc = M_ALD_MEM_GET_OPC(xpc);
+       mod = M_ALD_MEM_GET_MOD(xpc);
+       rm  = M_ALD_MEM_GET_RM(xpc);
+
+       /* for values see emit_mov_mem_reg and emit_mem */
+
+       if ((opc == 0x8b) && (mod == 0) && (rm == 5)) {
+               /* this was a hardware-exception */
+
+               d    = M_ALD_MEM_GET_REG(xpc);
+               disp = M_ALD_MEM_GET_DISP(xpc);
+
+               /* we use the exception type as load displacement */
+
+               type = disp;
+
+               /* ATTENTION: The _mc->gregs layout is completely crazy!  The
+                  registers are reversed starting with number 4 for REG_EDI
+                  (see /usr/include/sys/ucontext.h).  We have to convert that
+                  here. */
+
+               val = _mc->gregs[EAX - d];
+
+               if (type == TRAP_COMPILER) {
+                       /* The PV from the compiler stub is equal to the XPC. */
+
+                       pv = xpc;
+
+                       /* We use a framesize of zero here because the call pushed
+                          the return addres onto the stack. */
+
+                       ra = md_stacktrace_get_returnaddress(sp, 0);
+
+                       /* Skip the RA on the stack. */
+
+                       sp = sp + 1 * SIZEOF_VOID_P;
+
+                       /* The XPC is the RA minus 2, because the RA points to the
+                          instruction after the call. */
+
+                       xpc = ra - 2;
+               }
+       }
+       else {
+               /* this was a normal NPE */
+
+               type = TRAP_NullPointerException;
+               val  = 0;
+       }
+
+       /* Handle the trap. */
+
+       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
+
+       /* Set registers. */
+
+       if (type == TRAP_COMPILER) {
+               if (p == NULL) {
+                       _mc->gregs[ESP] = (uintptr_t) sp;    /* Remove RA from stack. */
+               }
+       }
+}
+
+
+/* md_signal_handler_sigfpe ****************************************************
+
+   ArithmeticException signal handler for hardware divide by zero
+   check.
+
+*******************************************************************************/
+
+void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t *_uc;
+       mcontext_t *_mc;
+       u1         *pv;
+       u1         *sp;
+       u1         *ra;
+       u1         *xpc;
+       s4          type;
+       ptrint      val;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       pv  = NULL;                 /* is resolved during stackframeinfo creation */
+       sp  = (u1 *) _mc->gregs[ESP];
+       xpc = (u1 *) _mc->gregs[EIP];
+       ra  = xpc;                          /* return address is equal to xpc     */
+
+       /* This is an ArithmeticException. */
+
+       type = TRAP_ArithmeticException;
+       val  = 0;
+
+       /* Handle the trap. */
+
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
+}
+
+
+/* md_signal_handler_sigill ****************************************************
+
+   Signal handler for hardware patcher traps (ud2).
+
+*******************************************************************************/
+
+void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t *_uc;
+       mcontext_t *_mc;
+       u1         *pv;
+       u1         *sp;
+       u1         *ra;
+       u1         *xpc;
+       s4          type;
+       ptrint      val;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       pv  = NULL;                 /* is resolved during stackframeinfo creation */
+       sp  = (u1 *) _mc->gregs[ESP];
+       xpc = (u1 *) _mc->gregs[EIP];
+       ra  = xpc;                            /* return address is equal to xpc   */
+
+       type = TRAP_PATCHER;
+       val  = 0;
+
+       /* Handle the trap. */
+
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
+}
+
+
+/* md_signal_handler_sigusr1 ***************************************************
+
+   Signal handler for suspending threads.
+
+*******************************************************************************/
+
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+void md_signal_handler_sigusr1(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t *_uc;
+       mcontext_t *_mc;
+       u1         *pc;
+       u1         *sp;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       /* get the PC and SP for this thread */
+       pc = (u1 *) _mc->gregs[EIP];
+       sp = (u1 *) _mc->gregs[ESP];
+
+       /* now suspend the current thread */
+       threads_suspend_ack(pc, sp);
+}
+#endif
+
+
+/* md_signal_handler_sigusr2 ***************************************************
+
+   Signal handler for profiling sampling.
+
+*******************************************************************************/
+
+#if defined(ENABLE_THREADS)
+void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
+{
+       threadobject *t;
+       ucontext_t   *_uc;
+       mcontext_t   *_mc;
+       u1           *pc;
+
+       t = THREADOBJECT;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       pc = (u1 *) _mc->gregs[EIP];
+
+       t->pc = pc;
+}
+#endif
+
+
+/* md_executionstate_read ******************************************************
+
+   Read the given context into an executionstate for Replacement.
+
+*******************************************************************************/
+
+void md_executionstate_read(executionstate_t *es, void *context)
+{
+       ucontext_t *_uc;
+       mcontext_t *_mc;
+       s4          i;
+
+       _uc = (ucontext_t *) context;
+       _mc = &_uc->uc_mcontext;
+
+       /* read special registers */
+       es->pc = (u1 *) _mc->gregs[EIP];
+       es->sp = (u1 *) _mc->gregs[ESP];
+       es->pv = NULL;                   /* pv must be looked up via AVL tree */
+
+       /* read integer registers */
+       for (i = 0; i < INT_REG_CNT; i++)
+               es->intregs[i] = _mc->gregs[EAX - i];
+
+       /* read float registers */
+       for (i = 0; i < FLT_REG_CNT; i++)
+               es->fltregs[i] = 0xdeadbeefdeadbeefULL;
+}
+
+
+/* md_executionstate_write *****************************************************
+
+   Write the given executionstate back to the context for Replacement.
+
+*******************************************************************************/
+
+void md_executionstate_write(executionstate_t *es, void *context)
+{
+       ucontext_t *_uc;
+       mcontext_t *_mc;
+       s4          i;
+
+       _uc = (ucontext_t *) context;
+       _mc = &_uc->uc_mcontext;
+
+       /* write integer registers */
+       for (i = 0; i < INT_REG_CNT; i++)
+               _mc->gregs[EAX - i] = es->intregs[i];
+
+       /* write special registers */
+       _mc->gregs[EIP] = (ptrint) es->pc;
+       _mc->gregs[ESP] = (ptrint) es->sp;
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/vm/jit/icmdtable.inc b/src/vm/jit/icmdtable.inc
deleted file mode 100644 (file)
index 4b0639c..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-/*** The ICMD Table ***/
-
-/* IMPORTANT: This file must be in a fixed format, as it is both included in */
-/* src/vm/jit/jit.c, and parsed by src/vm/jit/verify/generate.pl!            */
-/*                                                                           */
-/* The comments at the start of the line and inside the braces are           */
-/* significant. If you want to add a comment to an ICMD, do that after the   */
-/* comma, or brace, at the end of the line.                                  */
-/*                                                                           */
-/* The format is as follows (slashes reversed for obvious reasons):          */
-/*                                                                           */
-/* \*#*\ { N( name )  data-flow, control-flow, flags \* stage (action) *\ }  */
-/*                                                                           */
-/*  ^^^                                                                      */
-/* opcode                                                                    */
-/*                                                                           */
-/* where                                                                     */
-/*     opcode...........is the opcode number (decimal)                       */
-/*     name.............is the quoted name without the ICMD_ prefix          */
-/*     data-flow........is one of the DF_ constants (see jit.h)              */
-/*     control-flow.....is one of the CF_ constants (see jit.h)              */
-/*     flags............is 0 or a |-combination of                           */
-/*                          PEI........may throw an exception                */
-/*                          CALLS......needs saved registers (calls out)     */
-/*                          *_CALLS....see jit.h for architecture specific   */
-/*                                     constants to put here                 */
-/*                                                                           */
-/*     stage............is either empty, or one of                           */
-/*                          --         ICMD is not used anywhere after parse */
-/*                          -S         ICMD is eliminated by stack_analyse   */
-/*                          S+         ICMD is introduced by stack_analyse   */
-/*                                                                           */
-/*     action...........is the stack action of the ICMD in the notation      */
-/*                      instack--outstack, TOS being rightmost.              */
-/*                                                                           */
-/*                      Valid type characters are                            */
-/*                          I, L, F, D, and A      the basic types           */
-/*                          1                      a category 1 type         */
-/*                          2                      a category 2 type         */
-/*                          .                      variable number of slots  */
-/*                                                                           */
-/*                      Whitespace is not allowed within the action.         */
-/*                                                                           */
-/*                      Some ICMDs may have several variants. In this case   */
-/*                      the action is build by joining the individual        */
-/*                      actions of the variants with |.                      */
-/*                                                                           */
-/*                                                                           */
-/* CAUTION: Do not use preprocessor directives in this file! They will       */
-/*          confuse the generator.                                           */
-/*                                                                           */
-
-
-/*  0*/ {N("NOP            ") DF_0_TO_0 , CF_NORMAL, 0              /*    (--)                 */},
-/*  1*/ {N("ACONST         ") DF_0_TO_1 , CF_NORMAL, PEI            /*    (--A)                */},
-/*  2*/ {N("CHECKNULL      ") DF_1_TO_1 , CF_NORMAL, PEI            /*    (A--A)               */},
-/*  3*/ {N("ICONST         ") DF_0_TO_1 , CF_NORMAL, 0              /*    (--I)                */},
-/*  4*/ {N("UNDEF4         ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*  5*/ {N("IDIVPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/*  6*/ {N("LDIVPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/*  7*/ {N("UNDEF7         ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*  8*/ {N("UNDEF8         ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*  9*/ {N("LCONST         ") DF_0_TO_1 , CF_NORMAL, 0              /*    (--L)                */},
-/* 10*/ {N("LCMPCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--I)               */},
-/* 11*/ {N("FCONST         ") DF_0_TO_1 , CF_NORMAL, 0              /*    (--F)                */},
-/* 12*/ {N("UNDEF12        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 13*/ {N("UNDEF13        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 14*/ {N("DCONST         ") DF_0_TO_1 , CF_NORMAL, 0              /*    (--D)                */},
-/* 15*/ {N("COPY           ") DF_COPY   , CF_NORMAL, 0              /* S+ (1--1)               */},
-/* 16*/ {N("MOVE           ") DF_MOVE   , CF_NORMAL, 0              /* S+ (1--1)               */},
-/* 17*/ {N("UNDEF17        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 18*/ {N("UNDEF18        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 19*/ {N("UNDEF19        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 20*/ {N("UNDEF20        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 21*/ {N("ILOAD          ") DF_LOAD   , CF_NORMAL, 0              /*    (--I)                */},
-/* 22*/ {N("LLOAD          ") DF_LOAD   , CF_NORMAL, 0              /*    (--L)                */},
-/* 23*/ {N("FLOAD          ") DF_LOAD   , CF_NORMAL, 0              /*    (--F)                */},
-/* 24*/ {N("DLOAD          ") DF_LOAD   , CF_NORMAL, 0              /*    (--D)                */},
-/* 25*/ {N("ALOAD          ") DF_LOAD   , CF_NORMAL, 0              /*    (--A)                */},
-/* 26*/ {N("IADDCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/* 27*/ {N("ISUBCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/* 28*/ {N("IMULCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/* 29*/ {N("IANDCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/* 30*/ {N("IORCONST       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/* 31*/ {N("IXORCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/* 32*/ {N("ISHLCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/* 33*/ {N("ISHRCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/* 34*/ {N("IUSHRCONST     ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/* 35*/ {N("IREMPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/* 36*/ {N("LADDCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/* 37*/ {N("LSUBCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/* 38*/ {N("LMULCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/* 39*/ {N("LANDCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/* 40*/ {N("LORCONST       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/* 41*/ {N("LXORCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/* 42*/ {N("LSHLCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/* 43*/ {N("LSHRCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/* 44*/ {N("LUSHRCONST     ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/* 45*/ {N("LREMPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/* 46*/ {N("IALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--I)              */},
-/* 47*/ {N("LALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--L)              */},
-/* 48*/ {N("FALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--F)              */},
-/* 49*/ {N("DALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--D)              */},
-/* 50*/ {N("AALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--A)              */},
-/* 51*/ {N("BALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--I)              */},
-/* 52*/ {N("CALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--I)              */},
-/* 53*/ {N("SALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--I)              */},
-/* 54*/ {N("ISTORE         ") DF_STORE  , CF_NORMAL, 0              /*    (I--)                */},
-/* 55*/ {N("LSTORE         ") DF_STORE  , CF_NORMAL, 0              /*    (L--)                */},
-/* 56*/ {N("FSTORE         ") DF_STORE  , CF_NORMAL, 0              /*    (F--)                */},
-/* 57*/ {N("DSTORE         ") DF_STORE  , CF_NORMAL, 0              /*    (D--)                */},
-/* 58*/ {N("ASTORE         ") DF_STORE  , CF_NORMAL, 0              /*    (A--|R--)            */},
-/* 59*/ {N("IF_LEQ         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
-/* 60*/ {N("IF_LNE         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
-/* 61*/ {N("IF_LLT         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
-/* 62*/ {N("IF_LGE         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
-/* 63*/ {N("IF_LGT         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
-/* 64*/ {N("IF_LLE         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
-/* 65*/ {N("IF_LCMPEQ      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
-/* 66*/ {N("IF_LCMPNE      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
-/* 67*/ {N("IF_LCMPLT      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
-/* 68*/ {N("IF_LCMPGE      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
-/* 69*/ {N("IF_LCMPGT      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
-/* 70*/ {N("IF_LCMPLE      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
-/* 71*/ {N("UNDEF71        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 72*/ {N("UNDEF72        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 73*/ {N("UNDEF73        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 74*/ {N("UNDEF74        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 75*/ {N("UNDEF75        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 76*/ {N("UNDEF76        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 77*/ {N("UNDEF77        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 78*/ {N("UNDEF78        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/* 79*/ {N("IASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AII--)              */},
-/* 80*/ {N("LASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AIL--)              */},
-/* 81*/ {N("FASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AIF--)              */},
-/* 82*/ {N("DASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AID--)              */},
-/* 83*/ {N("AASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI|CALLS      /*    (AIA--)              */},
-/* 84*/ {N("BASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AII--)              */},
-/* 85*/ {N("CASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AII--)              */},
-/* 86*/ {N("SASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AII--)              */},
-/* 87*/ {N("POP            ") DF_POP    , CF_NORMAL, 0              /*    (1--)                */},
-/* 88*/ {N("POP2           ") DF_POP2   , CF_NORMAL, 0              /*    (11--|2--)           */},
-/* 89*/ {N("DUP            ") DF_DUP    , CF_NORMAL, 0              /* -S (1--11)              */},
-/* 90*/ {N("DUP_X1         ") DF_DUP_X1 , CF_NORMAL, 0              /* -S (11--111)            */},
-/* 91*/ {N("DUP_X2         ") DF_DUP_X2 , CF_NORMAL, 0              /* -S (111--1111|21--121)  */},
-/* 92*/ {N("DUP2           ") DF_DUP2   , CF_NORMAL, 0              /* -S (11--1111|2--22)     */},
-/* 93*/ {N("DUP2_X1        ") DF_DUP2_X1, CF_NORMAL, 0              /* -S (111--11111|12--212) */},
-/* 94*/ {N("DUP2_X2        ") DF_DUP2_X2, CF_NORMAL, 0              /* -S (1111--111111|112--2112|22--222|211--11211) */},
-/* 95*/ {N("SWAP           ") DF_SWAP   , CF_NORMAL, 0              /* -S (11--11)             */},
-/* 96*/ {N("IADD           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
-/* 97*/ {N("LADD           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
-/* 98*/ {N("FADD           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--F)              */},
-/* 99*/ {N("DADD           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--D)              */},
-/*100*/ {N("ISUB           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
-/*101*/ {N("LSUB           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
-/*102*/ {N("FSUB           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--F)              */},
-/*103*/ {N("DSUB           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--D)              */},
-/*104*/ {N("IMUL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
-/*105*/ {N("LMUL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
-/*106*/ {N("FMUL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--F)              */},
-/*107*/ {N("DMUL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--D)              */},
-/*108*/ {N("IDIV           ") DF_2_TO_1 , CF_NORMAL, PEI|IDIV_CALLS /*    (II--I)              */},
-/*109*/ {N("LDIV           ") DF_2_TO_1 , CF_NORMAL, PEI|LDIV_CALLS /*    (LL--L)              */},
-/*110*/ {N("FDIV           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--F)              */},
-/*111*/ {N("DDIV           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--D)              */},
-/*112*/ {N("IREM           ") DF_2_TO_1 , CF_NORMAL, PEI|IDIV_CALLS /*    (II--I)              */},
-/*113*/ {N("LREM           ") DF_2_TO_1 , CF_NORMAL, PEI|LDIV_CALLS /*    (LL--L)              */},
-/*114*/ {N("FREM           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--F)              */},
-/*115*/ {N("DREM           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--D)              */},
-/*116*/ {N("INEG           ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--I)               */},
-/*117*/ {N("LNEG           ") DF_1_TO_1 , CF_NORMAL, 0              /*    (L--L)               */},
-/*118*/ {N("FNEG           ") DF_1_TO_1 , CF_NORMAL, 0              /*    (F--F)               */},
-/*119*/ {N("DNEG           ") DF_1_TO_1 , CF_NORMAL, 0              /*    (D--D)               */},
-/*120*/ {N("ISHL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
-/*121*/ {N("LSHL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LI--L)              */},
-/*122*/ {N("ISHR           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
-/*123*/ {N("LSHR           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LI--L)              */},
-/*124*/ {N("IUSHR          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
-/*125*/ {N("LUSHR          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LI--L)              */},
-/*126*/ {N("IAND           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
-/*127*/ {N("LAND           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
-/*128*/ {N("IOR            ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
-/*129*/ {N("LOR            ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
-/*130*/ {N("IXOR           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
-/*131*/ {N("LXOR           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
-/*132*/ {N("IINC           ") DF_IINC   , CF_NORMAL, 0              /*    (--)                 */},
-/*133*/ {N("I2L            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--L)               */},
-/*134*/ {N("I2F            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--F)               */},
-/*135*/ {N("I2D            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--D)               */},
-/*136*/ {N("L2I            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (L--I)               */},
-/*137*/ {N("L2F            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (L--F)               */},
-/*138*/ {N("L2D            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (L--D)               */},
-/*139*/ {N("F2I            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (F--I)               */},
-/*140*/ {N("F2L            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (F--L)               */},
-/*141*/ {N("F2D            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (F--D)               */},
-/*142*/ {N("D2I            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (D--I)               */},
-/*143*/ {N("D2L            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (D--L)               */},
-/*144*/ {N("D2F            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (D--F)               */},
-/*145*/ {N("INT2BYTE       ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--I)               */},
-/*146*/ {N("INT2CHAR       ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--I)               */},
-/*147*/ {N("INT2SHORT      ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--I)               */},
-/*148*/ {N("LCMP           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--I)              */},
-/*149*/ {N("FCMPL          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--I)              */},
-/*150*/ {N("FCMPG          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--I)              */},
-/*151*/ {N("DCMPL          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--I)              */},
-/*152*/ {N("DCMPG          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--I)              */},
-/*153*/ {N("IFEQ           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
-/*154*/ {N("IFNE           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
-/*155*/ {N("IFLT           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
-/*156*/ {N("IFGE           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
-/*157*/ {N("IFGT           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
-/*158*/ {N("IFLE           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
-/*159*/ {N("IF_ICMPEQ      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
-/*160*/ {N("IF_ICMPNE      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
-/*161*/ {N("IF_ICMPLT      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
-/*162*/ {N("IF_ICMPGE      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
-/*163*/ {N("IF_ICMPGT      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
-/*164*/ {N("IF_ICMPLE      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
-/*165*/ {N("IF_ACMPEQ      ") DF_2_TO_0 , CF_IF    , 0              /*    (AA--)               */},
-/*166*/ {N("IF_ACMPNE      ") DF_2_TO_0 , CF_IF    , 0              /*    (AA--)               */},
-/*167*/ {N("GOTO           ") DF_0_TO_0 , CF_GOTO  , 0              /*    (--)                 */},
-/*168*/ {N("JSR            ") DF_0_TO_1 , CF_JSR   , 0              /*    (--R)                */},
-/*169*/ {N("RET            ") DF_0_TO_0 , CF_RET   , 0              /*    (--)                 */},
-/*170*/ {N("TABLESWITCH    ") DF_1_TO_0 , CF_TABLE , 0              /*    (I--)                */},
-/*171*/ {N("LOOKUPSWITCH   ") DF_1_TO_0 , CF_LOOKUP, 0              /*    (I--)                */},
-/*172*/ {N("IRETURN        ") DF_1_TO_0 , CF_END   , 0              /*    (I--)                */},
-/*173*/ {N("LRETURN        ") DF_1_TO_0 , CF_END   , 0              /*    (L--)                */},
-/*174*/ {N("FRETURN        ") DF_1_TO_0 , CF_END   , 0              /*    (F--)                */},
-/*175*/ {N("DRETURN        ") DF_1_TO_0 , CF_END   , 0              /*    (D--)                */},
-/*176*/ {N("ARETURN        ") DF_1_TO_0 , CF_END   , PEI            /*    (A--)                */},
-/*177*/ {N("RETURN         ") DF_0_TO_0 , CF_END   , 0              /*    (--)                 */},
-/*178*/ {N("GETSTATIC      ") DF_0_TO_1 , CF_NORMAL, PEI            /*    (--1|--2)            */},
-/*179*/ {N("PUTSTATIC      ") DF_1_TO_0 , CF_NORMAL, PEI            /*    (1--|2--)            */},
-/*180*/ {N("GETFIELD       ") DF_1_TO_1 , CF_NORMAL, PEI            /*    (A--1|A--2)          */},
-/*181*/ {N("PUTFIELD       ") DF_2_TO_0 , CF_NORMAL, PEI            /*    (A1--|A2--)          */},
-/*182*/ {N("INVOKEVIRTUAL  ") DF_INVOKE , CF_NORMAL, PEI|CALLS      /*    (.--1|.--2|.--)      */},
-/*183*/ {N("INVOKESPECIAL  ") DF_INVOKE , CF_NORMAL, PEI|CALLS      /*    (.--1|.--2|.--)      */},
-/*184*/ {N("INVOKESTATIC   ") DF_INVOKE , CF_NORMAL, PEI|CALLS      /*    (.--1|.--2|.--)      */},
-/*185*/ {N("INVOKEINTERFACE") DF_INVOKE , CF_NORMAL, PEI|CALLS      /*    (.--1|.--2|.--)      */},
-/*186*/ {N("UNDEF186       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*187*/ {N("NEW            ") DF_0_TO_1 , CF_NORMAL, PEI            /* -- (--A)                */},
-/*188*/ {N("NEWARRAY       ") DF_0_TO_1 , CF_NORMAL, PEI            /* -- (--A)                */},
-/*189*/ {N("ANEWARRAY      ") DF_0_TO_1 , CF_NORMAL, PEI            /* -- (--A)                */},
-/*190*/ {N("ARRAYLENGTH    ") DF_1_TO_1 , CF_NORMAL, PEI            /*    (A--I)               */},
-/*191*/ {N("ATHROW         ") DF_1_TO_0 , CF_END   , PEI            /*    (A--)                */},
-/*192*/ {N("CHECKCAST      ") DF_1_TO_1 , CF_NORMAL, PEI|CALLS      /*    (A--A)               */},
-/*193*/ {N("INSTANCEOF     ") DF_1_TO_1 , CF_NORMAL, PEI|CALLS      /*    (A--I)               */},
-/*194*/ {N("MONITORENTER   ") DF_1_TO_0 , CF_NORMAL, PEI|CALLS      /* -- (A--)                */},
-/*195*/ {N("MONITOREXIT    ") DF_1_TO_0 , CF_NORMAL, PEI|CALLS      /* -- (A--)                */},
-/*196*/ {N("UNDEF196       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*197*/ {N("MULTIANEWARRAY ") DF_N_TO_1 , CF_NORMAL, PEI|CALLS      /*    (.--A)               */},
-/*198*/ {N("IFNULL         ") DF_1_TO_0 , CF_IF    , 0              /*    (A--)                */},
-/*199*/ {N("IFNONNULL      ") DF_1_TO_0 , CF_IF    , 0              /*    (A--)                */},
-/*200*/ {N("UNDEF200       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*201*/ {N("UNDEF201       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*202*/ {N("UNDEF202       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*203*/ {N("UNDEF203       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*204*/ {N("IASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
-/*205*/ {N("LASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
-/*206*/ {N("FASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
-/*207*/ {N("DASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
-/*208*/ {N("AASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
-/*209*/ {N("BASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
-/*210*/ {N("CASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
-/*211*/ {N("SASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
-/*212*/ {N("PUTSTATICCONST ") DF_0_TO_0 , CF_NORMAL, PEI            /* S+ (--)                 */},
-/*213*/ {N("PUTFIELDCONST  ") DF_1_TO_0 , CF_NORMAL, PEI            /* S+ (A--)                */},
-/*214*/ {N("IMULPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
-/*215*/ {N("LMULPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
-/*216*/ {N("IF_FCMPEQ      ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*217*/ {N("IF_FCMPNE      ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*218*/ {N("IF_FCMPL_LT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*219*/ {N("IF_FCMPL_GE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*220*/ {N("IF_FCMPL_GT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*221*/ {N("IF_FCMPL_LE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*222*/ {N("IF_FCMPG_LT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*223*/ {N("IF_FCMPG_GE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*224*/ {N("IF_FCMPG_GT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*225*/ {N("IF_FCMPG_LE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*226*/ {N("IF_DCMPEQ      ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*227*/ {N("IF_DCMPNE      ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*228*/ {N("IF_DCMPL_LT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*229*/ {N("IF_DCMPL_GE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*230*/ {N("IF_DCMPL_GT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*231*/ {N("IF_DCMPL_LE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*232*/ {N("IF_DCMPG_LT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*233*/ {N("IF_DCMPG_GE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*234*/ {N("IF_DCMPG_GT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*235*/ {N("IF_DCMPG_LE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
-/*236*/ {N("UNDEF236       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*237*/ {N("UNDEF237       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*238*/ {N("UNDEF238       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*239*/ {N("UNDEF239       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*240*/ {N("UNDEF240       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*241*/ {N("UNDEF241       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*242*/ {N("UNDEF242       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*243*/ {N("UNDEF243       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*244*/ {N("UNDEF244       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*245*/ {N("UNDEF245       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*246*/ {N("UNDEF246       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*247*/ {N("UNDEF247       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*248*/ {N("UNDEF248       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*249*/ {N("GETEXCEPTION   ") DF_0_TO_1 , CF_NORMAL, 0              /* -- ()                   */},
-/*250*/ {N("PHI            ") DF_N_TO_1 , CF_NORMAL, 0              /* -- ()                   */},
-/*251*/ {N("INLINE_START   ") DF_0_TO_0 , CF_NORMAL, 0              /* S+ (--)                 */},
-/*252*/ {N("INLINE_END     ") DF_0_TO_0 , CF_NORMAL, 0              /* S+ (--)                 */},
-/*253*/ {N("INLINE_BODY    ") DF_0_TO_0 , CF_NORMAL, 0              /* S+ (--)                 */},
-/*254*/ {N("UNDEF254       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*255*/ {N("BUILTIN        ") DF_BUILTIN, CF_NORMAL, PEI|CALLS      /*    (.--1|.--2|.--)      */}
-
index 8b46e133284226aa11fffb07bd6e6b8ac2b1e63f..e3ca1468f4926c13255d4f298680792ec78bf527 100644 (file)
@@ -31,8 +31,8 @@ noinst_LTLIBRARIES = \
        libinline.la
 
 libinline_la_SOURCES = \
-       inline.c \
-       inline.h \
+       inline.cpp \
+       inline.hpp \
        inline_debug.inc
 
 
diff --git a/src/vm/jit/inline/inline.c b/src/vm/jit/inline/inline.c
deleted file mode 100644 (file)
index 210d945..0000000
+++ /dev/null
@@ -1,3240 +0,0 @@
-/* src/vm/jit/inline/inline.c - method inlining
-
-   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 <limits.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "threads/lock-common.h"
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-#include "vm/global.h"
-#include "vm/initialize.h"
-
-#include "vm/jit/jit.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/reg.h"
-#include "vm/jit/show.h"
-#include "vm/jit/stack.h"
-
-#include "vm/jit/inline/inline.h"
-#include "vm/jit/loop/loop.h"
-
-#include "vm/jit/verify/typecheck.h"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-
-
-/* algorithm tuning constants *************************************************/
-
-/* Algorithm Selection                                                        */
-/* Define exactly one of the following three to select the inlining           */
-/* heuristics.                                                                */
-
-/*#define INLINE_DEPTH_FIRST*/
-/*#define INLINE_BREADTH_FIRST*/
-#define INLINE_KNAPSACK
-
-/* Parameters for knapsack heuristics:                                        */
-
-#if defined(INLINE_KNAPSACK)
-
-#define INLINE_COUNTDOWN_INIT       1000
-#define INLINE_COST_OFFSET          -16
-#define INLINE_COST_BUDGET          100
-/*#define INLINE_WEIGHT_BUDGET        5.0*/
-/*#define INLINE_ADD_NEGATIVE_TO_BUDGET*/
-/*#define INLINE_MAX_DEPTH            3*/
-/*#define INLINE_DIVIDE_COST_BY_FREQ */
-
-#endif
-
-/* Parameters for depth-first heuristics:                                     */
-
-#if defined(INLINE_DEPTH_FIRST)
-
-#define INLINE_MAX_DEPTH            3
-#define INLINE_MAX_BLOCK_EXPANSION  10
-/*#define INLINE_MAX_ICMD_EXPANSION  10*/
-/*#define INLINE_CANCEL_ON_THRESHOLD*/
-
-#endif
-
-/* Parameters for breadth-first heuristics:                                   */
-
-#if defined(INLINE_BREADTH_FIRST)
-
-/*#define INLINE_MAX_BLOCK_EXPANSION  10*/
-#define INLINE_MAX_ICMD_EXPANSION  5
-
-#endif
-
-
-/* debugging ******************************************************************/
-
-#if !defined(NDEBUG)
-#define INLINE_VERBOSE
-#define DOLOG(code)       do{ if (opt_TraceInlining >= 2) { code; } }while(0)
-#define DOLOG_SHORT(code) do{ if (opt_TraceInlining >= 1) { code; } }while(0)
-#else
-#define DOLOG(code)
-#endif
-
-#if defined(ENABLE_VERIFIER) && !defined(NDEBUG)
-/* Define this to verify the resulting code after inlining.                 */
-/* Note: This is only useful for development and may require patches to the */
-/*       verifier code.                                                     */
-/* #define INLINE_VERIFY_RESULT */
-#endif
-
-
-/* types **********************************************************************/
-
-typedef struct inline_node inline_node;
-typedef struct inline_target_ref inline_target_ref;
-typedef struct inline_context inline_context;
-typedef struct inline_block_map inline_block_map;
-typedef struct inline_site inline_site;
-typedef struct inline_candidate inline_candidate;
-
-struct inline_node {
-       inline_context *ctx;
-
-       jitdata *jd;
-       methodinfo *m;
-       inline_node *children;
-       inline_node *next;                             /* next node at this depth */
-       inline_node *prev;                             /* prev node at this depth */
-       int depth;                                  /* inlining depth, 0 for root */
-
-       /* info about the call site (if depth > 0)*/
-       inline_node *parent;                /* node of the caller (NULL for root) */
-       basicblock *callerblock;         /* original block containing the INVOKE* */
-       instruction *callerins;               /* the original INVOKE* instruction */
-       s4 callerpc;
-       s4 *n_passthroughvars;
-       int n_passthroughcount;
-       int n_selfpassthroughcount;  /* # of pass-through vars of the call itself */
-       exception_entry **o_handlers;
-       int n_handlercount;                 /* # of handlers protecting this call */
-       int n_resultlocal;
-       int synclocal;                    /* variable used for synchr., or UNUSED */
-       bool isstatic;                                   /* this is a static call */
-
-       bool blockbefore;                  /* block boundary before inlined body? */
-       bool blockafter;                   /* block boundary after inlined body?  */
-
-       /* info about the callee */
-       int localsoffset;
-       int prolog_instructioncount;         /* # of ICMDs in the inlining prolog */
-       int epilog_instructioncount;         /* # of ICMDs in the inlining epilog */
-       int extra_instructioncount;
-       int extra_exceptiontablelength;   /* # of extra handlers to put in caller */
-       bool synchronize;                /* do we have to synchronize enter/exit? */
-       basicblock *handler_monitorexit;     /* handler for synchronized inlinees */
-       s4 *varmap;
-
-       /* cumulative values */
-       int cumul_instructioncount;  /* ICMDs in this node and its children       */
-       int cumul_basicblockcount;   /* BBs started by this node and its children */
-       int cumul_basicblockcount_root;  /* BBs that have to be added to the root */
-                                        /* node if this node is inlined          */
-       int cumul_blockmapcount;
-       int cumul_maxlocals;
-       int cumul_exceptiontablelength;
-
-       /* output */
-       instruction *inlined_iinstr;
-       instruction *inlined_iinstr_cursor;
-       basicblock *inlined_basicblocks;
-       basicblock *inlined_basicblocks_cursor;
-
-       /* register data */
-       registerdata *regdata;
-
-       /* temporary */
-       inline_target_ref *refs;
-       instruction *inline_start_instruction;
-       s4 *javalocals;
-
-       /* XXX debug */
-       char *indent;
-       int debugnr;
-};
-
-struct inline_target_ref {
-       inline_target_ref *next;
-       union {
-               basicblock **block;
-               s4 *nr;
-       } ref;
-       basicblock *target;
-       bool isnumber;
-};
-
-struct inline_block_map {
-       inline_node *iln;
-       basicblock *o_block;
-       basicblock *n_block;
-};
-
-struct inline_context {
-       inline_node *master;
-
-       jitdata *resultjd;
-
-       inline_candidate *candidates;
-
-       int next_block_number;
-       inline_block_map *blockmap;
-       int blockmap_index;
-
-       int maxinoutdepth;
-
-       bool stopped;
-
-       int next_debugnr; /* XXX debug */
-};
-
-struct inline_site {
-       bool              speculative;  /* true, if inlining would be speculative */
-       bool              inlined;      /* true, if this site has been inlined    */
-
-       basicblock       *bptr;         /* basic block containing the call site   */
-       instruction      *iptr;         /* the invocation instruction             */
-       exception_entry **handlers;     /* active handlers at the call site       */
-       s4                nhandlers;    /* number of active handlers              */
-       s4                pc;           /* PC of the invocation instruction       */
-};
-
-struct inline_candidate {
-       inline_candidate *next;
-       int freq;
-       int cost;
-       double weight;
-       inline_node *caller;
-       methodinfo *callee;
-       inline_site site;
-};
-
-
-/* prototypes *****************************************************************/
-
-static bool inline_analyse_code(inline_node *iln);
-static void inline_post_process(jitdata *jd);
-
-
-/* debug helpers **************************************************************/
-
-#if !defined(NDEBUG)
-#include "inline_debug.inc"
-#endif
-
-
-/* statistics *****************************************************************/
-
-/*#define INLINE_STATISTICS*/
-
-#if !defined(NDEBUG)
-#define INLINE_STATISTICS
-#endif
-
-#if defined(INLINE_STATISTICS)
-int inline_stat_roots = 0;
-int inline_stat_roots_transformed = 0;
-int inline_stat_inlined_nodes = 0;
-int inline_stat_max_depth = 0;
-
-void inline_print_stats()
-{
-       printf("inlining statistics:\n");
-       printf("    roots analysed   : %d\n", inline_stat_roots);
-       printf("    roots transformed: %d\n", inline_stat_roots_transformed);
-       printf("    inlined nodes    : %d\n", inline_stat_inlined_nodes);
-       printf("    max depth        : %d\n", inline_stat_max_depth);
-}
-#endif
-
-
-/* compilation of callees *****************************************************/
-
-static bool inline_jit_compile_intern(jitdata *jd)
-{
-       methodinfo *m;
-
-       /* XXX should share code with jit.c */
-
-       assert(jd);
-
-       /* XXX initialize the static function's class */
-
-       m = jd->m;
-
-       /* call the compiler passes ***********************************************/
-
-       /* call parse pass */
-
-       DOLOG( log_message_class("Parsing ", m->clazz) );
-       if (!parse(jd)) {
-               return false;
-       }
-
-       /* call stack analysis pass */
-
-       if (!stack_analyse(jd)) {
-               return false;
-       }
-
-       return true;
-}
-
-
-static bool inline_jit_compile(inline_node *iln)
-{
-       bool                r;
-       methodinfo         *m;
-       jitdata            *jd;
-
-       /* XXX should share code with jit.c */
-
-       assert(iln);
-       m = iln->m;
-       assert(m);
-
-       /* enter a monitor on the method */
-
-       LOCK_MONITOR_ENTER(m);
-
-       /* allocate jitdata structure and fill it */
-
-       jd = jit_jitdata_new(m);
-       iln->jd = jd;
-
-       jd->flags = 0; /* XXX */
-
-       /* initialize the register allocator */
-
-       reg_setup(jd);
-
-       /* setup the codegendata memory */
-
-       /* XXX do a pseudo setup */
-       jd->cd = DNEW(codegendata);
-       MZERO(jd->cd, codegendata, 1);
-       jd->cd->method = m;
-       /* XXX uses too much dump memory codegen_setup(jd); */
-
-       /* now call internal compile function */
-
-       r = inline_jit_compile_intern(jd);
-
-       if (r) {
-               iln->regdata = jd->rd;
-       }
-
-       /* free some memory */
-#if 0
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (!opt_intrp)
-# endif
-               codegen_free(jd);
-#endif
-
-#endif
-
-       /* leave the monitor */
-
-       LOCK_MONITOR_EXIT(m);
-
-       return r;
-}
-
-
-/* inlining tree handling *****************************************************/
-
-static void inline_insert_inline_node(inline_node *parent, inline_node *child)
-{
-       inline_node *first;
-       inline_node *succ;
-
-       assert(parent && child);
-
-       child->parent = parent;
-
-       child->debugnr = parent->ctx->next_debugnr++; /* XXX debug */
-
-       first = parent->children;
-       if (!first) {
-               /* insert as only node */
-               parent->children = child;
-               child->next = child;
-               child->prev = child;
-               return;
-       }
-
-       /* {there is at least one child already there} */
-
-       /* XXX is this search necessary, or could we always add at the end? */
-
-       succ = first;
-       while (succ->callerpc < child->callerpc) {
-               succ = succ->next;
-               if (succ == first) {
-                       /* insert as last node */
-                       child->prev = first->prev;
-                       child->next = first;
-                       child->prev->next = child;
-                       child->next->prev = child;
-                       return;
-               }
-       }
-
-       assert(succ->callerpc > child->callerpc);
-
-       /* insert before succ */
-
-       child->prev = succ->prev;
-       child->next = succ;
-       child->prev->next = child;
-       child->next->prev = child;
-
-       if (parent->children == succ)
-               parent->children = child;
-}
-
-
-static void inline_remove_inline_node(inline_node *parent, inline_node *child)
-{
-       assert(parent);
-       assert(child);
-       assert(child->parent == parent);
-
-       if (child->prev == child) {
-               /* remove the only child node */
-               parent->children = NULL;
-       }
-       else {
-               child->prev->next = child->next;
-               child->next->prev = child->prev;
-
-               if (parent->children == child)
-                       parent->children = child->next;
-       }
-}
-
-
-/* inlining candidate handling ************************************************/
-
-#if defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST)
-static void inline_add_candidate(inline_context *ctx,
-                                                                inline_node *caller,
-                                                                methodinfo *callee,
-                                                                inline_site *site)
-{
-       inline_candidate **link;
-       inline_candidate *cand;
-
-       cand = DNEW(inline_candidate);
-#if defined(INLINE_DIVIDE_COST_BY_FREQ)
-       cand->freq = INLINE_COUNTDOWN_INIT - callee->hitcountdown;
-       if (cand->freq < 1)
-#endif
-               cand->freq = 1;
-#if defined(INLINE_KNAPSACK)
-       cand->cost = callee->jcodelength + INLINE_COST_OFFSET;
-#endif
-#if defined(INLINE_BREADTH_FIRST)
-       cand->cost = caller->depth;
-#endif
-       cand->caller = caller;
-       cand->callee = callee;
-       cand->site = *site;
-
-       cand->weight = (double)cand->cost / cand->freq;
-
-       for (link = &(ctx->candidates); ; link = &((*link)->next)) {
-               if (!*link || (*link)->weight > cand->weight) {
-                       cand->next = *link;
-                       *link = cand;
-                       break;
-               }
-       }
-}
-#endif /* defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST) */
-
-#if defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST)
-static inline_candidate * inline_pick_best_candidate(inline_context *ctx)
-{
-       inline_candidate *cand;
-
-       cand = ctx->candidates;
-
-       if (cand)
-               ctx->candidates = cand->next;
-
-       return cand;
-}
-#endif /* defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST) */
-
-#if !defined(NDEBUG) && (defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST))
-static void inline_candidate_println(inline_candidate *cand)
-{
-       printf("%10g (%5d / %5d) depth %2d ",
-                       cand->weight, cand->cost, cand->freq, cand->caller->depth + 1);
-       method_println(cand->callee);
-}
-#endif /* !defined(NDEBUG) && (defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST)) */
-
-
-#if !defined(NDEBUG) && (defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST))
-static void inline_candidates_println(inline_context *ctx)
-{
-       inline_candidate *cand;
-
-       for (cand = ctx->candidates; cand != NULL; cand = cand->next) {
-               printf("    ");
-               inline_candidate_println(cand);
-       }
-}
-#endif /* !defined(NDEBUG) && (defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST)) */
-
-
-/* variable handling **********************************************************/
-
-static s4 inline_new_variable(jitdata *jd, s4 type, s4 flags)
-{
-       s4 index;
-       s4 newcount;
-
-       index = jd->vartop++;
-       if (index >= jd->varcount) {
-               newcount = jd->vartop * 2; /* XXX */
-               jd->var = DMREALLOC(jd->var, varinfo, jd->varcount, newcount);
-               MZERO(jd->var + jd->varcount, varinfo, (newcount - jd->varcount));
-               jd->varcount = newcount;
-       }
-
-       jd->var[index].type = type;
-       jd->var[index].flags = flags;
-
-       return index;
-}
-
-
-static s4 inline_new_variable_clone(jitdata *jd, jitdata *origjd, s4 origidx)
-{
-       varinfo *v;
-       s4       newidx;
-
-       v = &(origjd->var[origidx]);
-
-       newidx = inline_new_variable(jd, v->type, v->flags);
-
-       jd->var[newidx].vv = v->vv;
-
-       return newidx;
-}
-
-
-static s4 inline_new_temp_variable(jitdata *jd, s4 type)
-{
-       return inline_new_variable(jd, type, 0);
-}
-
-
-static s4 inline_translate_variable(jitdata *jd, jitdata *origjd, s4 *varmap, s4 index)
-{
-       s4 idx;
-
-       idx = varmap[index];
-
-       if (idx < 0) {
-               idx = inline_new_variable_clone(jd, origjd, index);
-               varmap[index] = idx;
-       }
-
-       return idx;
-}
-
-
-static s4 *create_variable_map(inline_node *callee)
-{
-       s4 *varmap;
-       s4 i, t;
-       s4 varindex;
-       s4 n_javaindex;
-       s4 avail;
-       varinfo *v;
-
-       /* create the variable mapping */
-
-       varmap = DMNEW(s4, callee->jd->varcount);
-       for (i=0; i<callee->jd->varcount; ++i)
-               varmap[i] = -1;
-
-       /* translate local variables */
-
-       for (i=0; i<callee->m->maxlocals; ++i) {
-               for (t=0; t<5; ++t) {
-                       varindex = callee->jd->local_map[5*i + t];
-                       if (varindex == UNUSED)
-                               continue;
-
-                       v = &(callee->jd->var[varindex]);
-                       assert(v->type == t || v->type == TYPE_VOID); /* XXX stack leaves VOID */
-                       v->type = t; /* XXX restore if it is TYPE_VOID */
-
-                       avail = callee->ctx->resultjd->local_map[5*(callee->localsoffset + i) + t];
-
-                       if (avail == UNUSED) {
-                               avail = inline_new_variable_clone(callee->ctx->resultjd, callee->jd, varindex);
-                               callee->ctx->resultjd->local_map[5*(callee->localsoffset + i) + t] = avail;
-                       }
-
-                       varmap[varindex] = avail;
-               }
-       }
-
-       /* for synchronized instance methods we need an extra local */
-
-       if (callee->synchronize && !(callee->m->flags & ACC_STATIC)) {
-               n_javaindex = callee->localsoffset - 1;
-               assert(n_javaindex >= 0);
-               assert(callee->parent);
-               assert(n_javaindex == callee->parent->localsoffset + callee->parent->m->maxlocals);
-
-               avail = callee->ctx->resultjd->local_map[5*n_javaindex + TYPE_ADR];
-
-               if (avail == UNUSED) {
-                       avail = inline_new_variable(callee->ctx->resultjd, TYPE_ADR, 0);
-                       callee->ctx->resultjd->local_map[5*n_javaindex + TYPE_ADR] = avail;
-               }
-
-               callee->synclocal = avail;
-       }
-       else {
-               callee->synclocal = UNUSED;
-       }
-
-       return varmap;
-}
-
-
-/* basic block translation ****************************************************/
-
-#define INLINE_RETURN_REFERENCE(callee)  \
-       ( (basicblock *) (ptrint) (0x333 + (callee)->depth) )
-
-
-static void inline_add_block_reference(inline_node *iln, basicblock **blockp)
-{
-       inline_target_ref *ref;
-
-       ref = DNEW(inline_target_ref);
-       ref->ref.block = blockp;
-       ref->isnumber = false;
-       ref->next = iln->refs;
-       iln->refs = ref;
-}
-
-
-#if 0
-static void inline_add_blocknr_reference(inline_node *iln, s4 *nrp)
-{
-       inline_target_ref *ref;
-
-       ref = DNEW(inline_target_ref);
-       ref->ref.nr = nrp;
-       ref->isnumber = true;
-       ref->next = iln->refs;
-       iln->refs = ref;
-}
-#endif
-
-
-static void inline_block_translation(inline_node *iln, basicblock *o_bptr, basicblock *n_bptr)
-{
-       inline_context *ctx;
-
-       ctx = iln->ctx;
-       assert(ctx->blockmap_index < ctx->master->cumul_blockmapcount);
-
-       ctx->blockmap[ctx->blockmap_index].iln = iln;
-       ctx->blockmap[ctx->blockmap_index].o_block = o_bptr;
-       ctx->blockmap[ctx->blockmap_index].n_block = n_bptr;
-
-       ctx->blockmap_index++;
-}
-
-
-static basicblock * inline_map_block(inline_node *iln,
-                                                                        basicblock *o_block,
-                                                                        inline_node *targetiln)
-{
-       inline_block_map *bm;
-       inline_block_map *bmend;
-
-       assert(iln);
-       assert(targetiln);
-
-       if (!o_block)
-               return NULL;
-
-       bm = iln->ctx->blockmap;
-       bmend = bm + iln->ctx->blockmap_index;
-
-       while (bm < bmend) {
-               assert(bm->iln && bm->o_block && bm->n_block);
-               if (bm->o_block == o_block && bm->iln == targetiln)
-                       return bm->n_block;
-               bm++;
-       }
-
-       assert(false);
-       return NULL; /* not reached */
-}
-
-
-static void inline_resolve_block_refs(inline_target_ref **refs,
-                                                                         basicblock *o_bptr,
-                                                                         basicblock *n_bptr,
-                                                                         bool returnref)
-{
-       inline_target_ref *ref;
-       inline_target_ref *prev;
-
-       prev = NULL;
-       for (ref = *refs; ref != NULL; ref = ref->next) {
-               if (ref->isnumber && !returnref) {
-                       if (*(ref->ref.nr) == JAVALOCAL_FROM_RETADDR(o_bptr->nr)) {
-                               *(ref->ref.nr) = JAVALOCAL_FROM_RETADDR(n_bptr->nr);
-                               goto remove_ref;
-                       }
-               }
-               else {
-                       if (*(ref->ref.block) == o_bptr) {
-                               *(ref->ref.block) = n_bptr;
-                               goto remove_ref;
-                       }
-               }
-
-               /* skip this ref */
-
-               prev = ref;
-               continue;
-
-remove_ref:
-               /* remove this ref */
-
-               if (prev) {
-                       prev->next = ref->next;
-               }
-               else {
-                       *refs = ref->next;
-               }
-       }
-}
-
-
-/* basic block creation *******************************************************/
-
-static basicblock * create_block(inline_node *container,
-                                                                inline_node *iln,
-                                                                inline_node *inner,
-                                                                int indepth)
-{
-       basicblock  *n_bptr;
-       inline_node *outer;
-       s4           i;
-       s4           depth;
-       s4           varidx;
-       s4           newvaridx;
-
-       assert(container);
-       assert(iln);
-       assert(inner);
-       assert(indepth >= 0);
-
-       n_bptr = container->inlined_basicblocks_cursor++;
-       assert(n_bptr);
-       assert((n_bptr - container->inlined_basicblocks) < container->cumul_basicblockcount);
-
-       BASICBLOCK_INIT(n_bptr, iln->m);
-
-       n_bptr->iinstr = container->inlined_iinstr_cursor;
-       n_bptr->next = n_bptr + 1;
-       n_bptr->nr = container->ctx->next_block_number++;
-       n_bptr->indepth = indepth;
-       n_bptr->flags = BBFINISHED; /* XXX */
-
-       /* set the inlineinfo of the new block */
-
-       if (iln->inline_start_instruction)
-               n_bptr->inlineinfo = iln->inline_start_instruction->sx.s23.s3.inlineinfo;
-
-       if (indepth > container->ctx->maxinoutdepth)
-               container->ctx->maxinoutdepth = indepth;
-
-       if (indepth) {
-               n_bptr->invars = DMNEW(s4, indepth);
-
-
-               for (i=0; i<indepth; ++i)
-                       n_bptr->invars[i] = -1; /* XXX debug */
-
-               /* pass-through variables enter the block */
-
-               outer = inner->parent;
-               while (outer != NULL) {
-                       depth = outer->n_passthroughcount;
-
-                       assert(depth + inner->n_selfpassthroughcount <= indepth);
-
-                       for (i=0; i<inner->n_selfpassthroughcount; ++i) {
-                               varidx = inner->n_passthroughvars[i];
-                               newvaridx =
-                                       inline_new_variable_clone(container->ctx->resultjd,
-                                                                                         outer->jd,
-                                                                                         varidx);
-                               n_bptr->invars[depth + i] = newvaridx;
-                               outer->varmap[varidx] = newvaridx;
-                       }
-                       inner = outer;
-                       outer = outer->parent;
-               }
-       }
-       else {
-               n_bptr->invars = NULL;
-       }
-
-       /* XXX for the verifier. should not be here */
-
-       {
-               varinfo *dv;
-
-               dv = DMNEW(varinfo, iln->ctx->resultjd->localcount + VERIFIER_EXTRA_LOCALS);
-               MZERO(dv, varinfo,  iln->ctx->resultjd->localcount + VERIFIER_EXTRA_LOCALS);
-               n_bptr->inlocals = dv;
-       }
-
-       return n_bptr;
-}
-
-
-static s4 *translate_javalocals(inline_node *iln, s4 *javalocals)
-{
-       s4 *jl;
-       s4 i, j;
-
-       jl = DMNEW(s4, iln->jd->maxlocals);
-
-       for (i=0; i<iln->jd->maxlocals; ++i) {
-               j = javalocals[i];
-               if (j > UNUSED)
-                       j = inline_translate_variable(iln->ctx->resultjd, iln->jd, iln->varmap, j);
-               jl[i] = j;
-
-#if 0
-               if (j < UNUSED) {
-                       /* an encoded returnAddress value - must be relocated */
-                       inline_add_blocknr_reference(iln, &(jl[i]));
-               }
-#endif
-       }
-
-       return jl;
-}
-
-
-static basicblock * create_body_block(inline_node *iln,
-                                                                         basicblock *o_bptr, s4 *varmap)
-{
-       basicblock *n_bptr;
-       s4 i;
-
-       n_bptr = create_block(iln, iln, iln,
-                                                 o_bptr->indepth + iln->n_passthroughcount);
-
-       n_bptr->type = o_bptr->type;
-       n_bptr->flags = o_bptr->flags;
-       n_bptr->bitflags = o_bptr->bitflags;
-
-       /* resolve references to this block */
-
-       inline_resolve_block_refs(&(iln->refs), o_bptr, n_bptr, false);
-
-       /* translate the invars of the original block */
-
-       for (i=0; i<o_bptr->indepth; ++i) {
-               n_bptr->invars[iln->n_passthroughcount + i] =
-                       inline_translate_variable(iln->ctx->resultjd, iln->jd,
-                               varmap,
-                               o_bptr->invars[i]);
-       }
-
-       /* translate javalocals info (not for dead code) */
-
-       if (n_bptr->flags >= BBREACHED)
-               n_bptr->javalocals = translate_javalocals(iln, o_bptr->javalocals);
-
-       return n_bptr;
-}
-
-
-static basicblock * create_epilog_block(inline_node *caller, inline_node *callee, s4 *varmap)
-{
-       basicblock *n_bptr;
-       s4 retcount;
-       s4 idx;
-
-       /* number of return variables */
-
-       retcount = (callee->n_resultlocal == -1
-                               && callee->m->parseddesc->returntype.type != TYPE_VOID) ? 1 : 0;
-
-       /* start the epilog block */
-
-       n_bptr = create_block(caller, caller, callee,
-                                                 callee->n_passthroughcount + retcount);
-
-       /* resolve references to the return block */
-
-       inline_resolve_block_refs(&(callee->refs),
-                                                         INLINE_RETURN_REFERENCE(callee),
-                                                         n_bptr,
-                                                         true);
-
-       /* return variable */
-
-       if (retcount) {
-               idx = inline_new_variable(caller->ctx->resultjd,
-                          callee->m->parseddesc->returntype.type, 0 /* XXX */);
-               n_bptr->invars[callee->n_passthroughcount] = idx;
-               varmap[callee->callerins->dst.varindex] = idx;
-       }
-
-       /* set javalocals */
-
-       n_bptr->javalocals = DMNEW(s4, caller->jd->maxlocals);
-       MCOPY(n_bptr->javalocals, caller->javalocals, s4, caller->jd->maxlocals);
-
-       /* set block flags & type */
-
-       n_bptr->flags = /* XXX original block flags */ BBFINISHED;
-       n_bptr->type = BBTYPE_STD;
-
-       return n_bptr;
-}
-
-
-static void close_block(inline_node *iln, inline_node *inner, basicblock *n_bptr, s4 outdepth)
-{
-       inline_node *outer;
-       s4           i;
-       s4           depth;
-       s4           varidx;
-
-       n_bptr->outdepth = outdepth;
-       n_bptr->outvars = DMNEW(s4, outdepth);
-
-       for (i=0; i<outdepth; ++i)
-               n_bptr->outvars[i] = 0; /* XXX debug */
-
-       if (outdepth > iln->ctx->maxinoutdepth)
-               iln->ctx->maxinoutdepth = outdepth;
-
-       /* pass-through variables leave the block */
-
-       outer = inner->parent;
-       while (outer != NULL) {
-               depth = outer->n_passthroughcount;
-
-               assert(depth + inner->n_selfpassthroughcount <= outdepth);
-
-               for (i=0; i<inner->n_selfpassthroughcount; ++i) {
-                       varidx = inner->n_passthroughvars[i];
-                       n_bptr->outvars[depth + i] =
-                               inline_translate_variable(iln->ctx->resultjd,
-                                                                                 outer->jd,
-                                                                                 outer->varmap,
-                                                                                 varidx);
-               }
-               inner = outer;
-               outer = outer->parent;
-       }
-}
-
-
-static void close_prolog_block(inline_node *iln,
-                                                          basicblock *n_bptr,
-                                                          inline_node *nextcall)
-{
-       /* XXX add original outvars! */
-       close_block(iln, nextcall, n_bptr, nextcall->n_passthroughcount);
-
-       /* pass-through variables */
-
-       DOLOG( printf("closed prolog block:\n");
-                  show_basicblock(iln->ctx->resultjd, n_bptr, SHOW_STACK); );
-}
-
-
-static void close_body_block(inline_node *iln,
-                                                        basicblock *n_bptr,
-                                                        basicblock *o_bptr,
-                                                        s4 *varmap,
-                                                        s4 retcount,
-                                                        s4 retidx)
-{
-       s4 i;
-
-       close_block(iln, iln, n_bptr, iln->n_passthroughcount + o_bptr->outdepth + retcount);
-
-       /* translate the outvars of the original block */
-
-       /* XXX reuse code */
-       for (i=0; i<o_bptr->outdepth; ++i) {
-               n_bptr->outvars[iln->n_passthroughcount + i] =
-                       inline_translate_variable(iln->ctx->resultjd, iln->jd, varmap,
-                                       o_bptr->outvars[i]);
-       }
-
-       /* set the return variable, if any */
-
-       if (retcount) {
-               assert(retidx >= 0);
-               n_bptr->outvars[iln->n_passthroughcount + o_bptr->outdepth] = retidx;
-       }
-}
-
-
-/* inlined code generation ****************************************************/
-
-static instruction * inline_instruction(inline_node *iln,
-                                                                               s4 opcode,
-                                                                               instruction *o_iptr)
-{
-       instruction *n_iptr;
-
-       n_iptr = (iln->inlined_iinstr_cursor++);
-       assert((n_iptr - iln->inlined_iinstr) < iln->cumul_instructioncount);
-
-       n_iptr->opc = opcode;
-       n_iptr->flags.bits = o_iptr->flags.bits & INS_FLAG_ID_MASK;
-       n_iptr->line = o_iptr->line;
-
-       return n_iptr;
-}
-
-static void inline_generate_sync_builtin(inline_node *iln,
-                                                                                inline_node *callee,
-                                                                                instruction *o_iptr,
-                                                                                s4 instancevar,
-                                                                                functionptr func)
-{
-       int          syncvar;
-       instruction *n_ins;
-
-       if (callee->m->flags & ACC_STATIC) {
-               /* ACONST */
-               syncvar = inline_new_temp_variable(iln->ctx->resultjd, TYPE_ADR);
-
-               n_ins = inline_instruction(iln, ICMD_ACONST, o_iptr);
-               n_ins->sx.val.c.cls = callee->m->clazz;
-               n_ins->dst.varindex = syncvar;
-               n_ins->flags.bits |= INS_FLAG_CLASS;
-       }
-       else {
-               syncvar = instancevar;
-       }
-
-       assert(syncvar != UNUSED);
-
-       /* MONITORENTER / MONITOREXIT */
-
-       n_ins = inline_instruction(iln, ICMD_BUILTIN, o_iptr);
-       n_ins->sx.s23.s3.bte = builtintable_get_internal(func);
-       n_ins->s1.argcount = 1; /* XXX add through-vars */
-       n_ins->sx.s23.s2.args = DMNEW(s4, 1);
-       n_ins->sx.s23.s2.args[0] = syncvar;
-}
-
-static s4 emit_inlining_prolog(inline_node *iln,
-                                                          inline_node *callee,
-                                                          instruction *o_iptr,
-                                                          s4 *varmap)
-{
-       methodinfo *calleem;
-       methoddesc *md;
-       int i;
-       int localindex;
-       int type;
-       instruction *n_ins;
-       insinfo_inline *insinfo;
-       s4 varindex;
-
-       assert(iln && callee && o_iptr);
-
-       calleem = callee->m;
-       md = calleem->parseddesc;
-
-       /* INLINE_START instruction */
-
-       n_ins = inline_instruction(iln, ICMD_INLINE_START, o_iptr);
-
-       insinfo = DNEW(insinfo_inline);
-       insinfo->method = callee->m;
-       insinfo->outer = iln->m;
-       insinfo->synclocal = callee->synclocal;
-       insinfo->synchronize = callee->synchronize;
-       insinfo->javalocals_start = NULL;
-       insinfo->javalocals_end = NULL;
-
-       /* info about stack vars live at the INLINE_START */
-
-       insinfo->throughcount = callee->n_passthroughcount;
-       insinfo->paramcount = md->paramcount;
-       insinfo->stackvarscount = o_iptr->s1.argcount;
-       insinfo->stackvars = DMNEW(s4, insinfo->stackvarscount);
-       for (i=0; i<insinfo->stackvarscount; ++i)
-               insinfo->stackvars[i] = iln->varmap[o_iptr->sx.s23.s2.args[i]];
-
-       /* info about the surrounding inlining */
-
-       if (iln->inline_start_instruction)
-               insinfo->parent = iln->inline_start_instruction->sx.s23.s3.inlineinfo;
-       else
-               insinfo->parent = NULL;
-
-       /* finish the INLINE_START instruction */
-
-       n_ins->sx.s23.s3.inlineinfo = insinfo;
-       callee->inline_start_instruction = n_ins;
-
-       DOLOG( printf("%sprolog: ", iln->indent);
-                  show_icmd(iln->ctx->resultjd, n_ins, false, SHOW_STACK); printf("\n"); );
-
-       /* handle parameters for the inlined callee */
-
-       localindex = callee->localsoffset + md->paramslots;
-
-       for (i=md->paramcount-1; i>=0; --i) {
-               assert(iln);
-
-               type = md->paramtypes[i].type;
-
-               localindex -= IS_2_WORD_TYPE(type) ? 2 : 1;
-               assert(callee->regdata);
-
-               /* translate the argument variable */
-
-               varindex = varmap[o_iptr->sx.s23.s2.args[i]];
-               assert(varindex != UNUSED);
-
-               /* remove preallocation from the argument variable */
-
-               iln->ctx->resultjd->var[varindex].flags &= ~(PREALLOC | INMEMORY);
-
-               /* check the instance slot against NULL */
-               /* we don't need that for <init> methods, as the verifier  */
-               /* ensures that they are only called for an uninit. object */
-               /* (which may not be NULL).                                */
-
-               if (!callee->isstatic && i == 0 && calleem->name != utf_init) {
-                       assert(type == TYPE_ADR);
-                       n_ins = inline_instruction(iln, ICMD_CHECKNULL, o_iptr);
-                       n_ins->s1.varindex = varindex;
-                       n_ins->dst.varindex = n_ins->s1.varindex;
-               }
-
-               /* store argument into local variable of inlined callee */
-
-               if (callee->jd->local_map[5*(localindex - callee->localsoffset) + type] != UNUSED)
-               {
-                       /* this value is used in the callee */
-
-                       if (i == 0 && callee->synclocal != UNUSED) {
-                               /* we also need it for synchronization, so copy it */
-                               assert(type == TYPE_ADR);
-                               n_ins = inline_instruction(iln, ICMD_COPY, o_iptr);
-                       }
-                       else {
-                               n_ins = inline_instruction(iln, ICMD_ISTORE + type, o_iptr);
-                               n_ins->sx.s23.s3.javaindex = UNUSED;
-                       }
-                       n_ins->s1.varindex = varindex;
-                       n_ins->dst.varindex = iln->ctx->resultjd->local_map[5*localindex + type];
-                       assert(n_ins->dst.varindex != UNUSED);
-               }
-               else if (i == 0 && callee->synclocal != UNUSED) {
-                       /* the value is not used inside the callee, but we need it for */
-                       /* synchronization                                             */
-                       /* XXX In this case it actually makes no sense to create a     */
-                       /*     separate synchronization variable.                      */
-
-                       n_ins = inline_instruction(iln, ICMD_NOP, o_iptr);
-               }
-               else {
-                       /* this value is not used, pop it */
-
-                       n_ins = inline_instruction(iln, ICMD_POP, o_iptr);
-                       n_ins->s1.varindex = varindex;
-               }
-
-               DOLOG( printf("%sprolog: ", iln->indent);
-                          show_icmd(iln->ctx->resultjd, n_ins, false, SHOW_STACK); printf("\n"); );
-       }
-
-       /* COPY for synchronized instance methods */
-
-       if (callee->synclocal != UNUSED) {
-               n_ins = inline_instruction(iln, ICMD_COPY, o_iptr);
-               n_ins->s1.varindex = varmap[o_iptr->sx.s23.s2.args[0]];
-               n_ins->dst.varindex = callee->synclocal;
-
-               assert(n_ins->s1.varindex != UNUSED);
-       }
-
-       if (callee->synchronize) {
-               inline_generate_sync_builtin(iln, callee, o_iptr,
-                                                                        (callee->isstatic) ? UNUSED : varmap[o_iptr->sx.s23.s2.args[0]],
-                                                                        LOCK_monitor_enter);
-       }
-
-       /* INLINE_BODY instruction */
-
-       n_ins = inline_instruction(iln, ICMD_INLINE_BODY, callee->jd->basicblocks[0].iinstr);
-       n_ins->sx.s23.s3.inlineinfo = insinfo;
-
-       return 0; /* XXX */
-}
-
-
-static void emit_inlining_epilog(inline_node *iln, inline_node *callee, instruction *o_iptr)
-{
-       instruction *n_ins;
-       s4          *jl;
-
-       assert(iln && callee && o_iptr);
-       assert(callee->inline_start_instruction);
-
-       if (callee->synchronize) {
-               inline_generate_sync_builtin(iln, callee, o_iptr,
-                                                                        callee->synclocal,
-                                                                        LOCK_monitor_exit);
-       }
-
-       /* INLINE_END instruction */
-
-       n_ins = inline_instruction(iln, ICMD_INLINE_END, o_iptr);
-       n_ins->sx.s23.s3.inlineinfo = callee->inline_start_instruction->sx.s23.s3.inlineinfo;
-
-       /* set the javalocals */
-
-       jl = DMNEW(s4, iln->jd->maxlocals);
-       MCOPY(jl, iln->javalocals, s4, iln->jd->maxlocals);
-       n_ins->sx.s23.s3.inlineinfo->javalocals_end = jl;
-
-       DOLOG( printf("%sepilog: ", iln->indent);
-                  show_icmd(iln->ctx->resultjd, n_ins, false, SHOW_STACK); printf("\n"); );
-}
-
-
-#define TRANSLATE_VAROP(vo)  \
-       n_iptr->vo.varindex = inline_translate_variable(jd, origjd, varmap, n_iptr->vo.varindex)
-
-
-static void inline_clone_instruction(inline_node *iln,
-                                                                        jitdata *jd,
-                                                                        jitdata *origjd,
-                                                                        s4 *varmap,
-                                                                        instruction *o_iptr,
-                                                                        instruction *n_iptr)
-{
-       icmdtable_entry_t *icmdt;
-       builtintable_entry *bte;
-       methoddesc *md;
-       s4 i, j;
-       branch_target_t *table;
-       lookup_target_t *lookup;
-       inline_node *scope;
-
-       *n_iptr = *o_iptr;
-
-       icmdt = &(icmd_table[o_iptr->opc]);
-
-       switch (icmdt->dataflow) {
-               case DF_0_TO_0:
-                       break;
-
-               case DF_3_TO_0:
-                       TRANSLATE_VAROP(sx.s23.s3);
-               case DF_2_TO_0:
-                       TRANSLATE_VAROP(sx.s23.s2);
-               case DF_1_TO_0:
-                       TRANSLATE_VAROP(s1);
-                       break;
-
-               case DF_2_TO_1:
-                       TRANSLATE_VAROP(sx.s23.s2);
-               case DF_1_TO_1:
-               case DF_COPY:
-               case DF_MOVE:
-                       TRANSLATE_VAROP(s1);
-               case DF_0_TO_1:
-                       TRANSLATE_VAROP(dst);
-                       break;
-
-               case DF_N_TO_1:
-                       n_iptr->sx.s23.s2.args = DMNEW(s4, n_iptr->s1.argcount);
-                       for (i=0; i<n_iptr->s1.argcount; ++i) {
-                               n_iptr->sx.s23.s2.args[i] =
-                                       inline_translate_variable(jd, origjd, varmap,
-                                                       o_iptr->sx.s23.s2.args[i]);
-                       }
-                       TRANSLATE_VAROP(dst);
-                       break;
-
-               case DF_INVOKE:
-                       INSTRUCTION_GET_METHODDESC(n_iptr, md);
-clone_call:
-                       n_iptr->s1.argcount += iln->n_passthroughcount;
-                       n_iptr->sx.s23.s2.args = DMNEW(s4, n_iptr->s1.argcount);
-                       for (i=0; i<o_iptr->s1.argcount; ++i) {
-                               n_iptr->sx.s23.s2.args[i] =
-                                       inline_translate_variable(jd, origjd, varmap,
-                                                       o_iptr->sx.s23.s2.args[i]);
-                       }
-                       for (scope = iln; scope != NULL; scope = scope->parent) {
-                               for (j = 0; j < scope->n_selfpassthroughcount; ++j) {
-                                       n_iptr->sx.s23.s2.args[i++] =
-                                               scope->parent->varmap[scope->n_passthroughvars[j]];
-                               }
-                       }
-                       if (md->returntype.type != TYPE_VOID)
-                               TRANSLATE_VAROP(dst);
-                       break;
-
-               case DF_BUILTIN:
-                       bte = n_iptr->sx.s23.s3.bte;
-                       md = bte->md;
-                       goto clone_call;
-
-               default:
-                       assert(0);
-       }
-
-       switch (icmdt->controlflow) {
-               case CF_RET:
-                       TRANSLATE_VAROP(s1); /* XXX should be handled by data-flow */
-                       /* FALLTHROUGH */
-               case CF_IF:
-               case CF_GOTO:
-                       inline_add_block_reference(iln, &(n_iptr->dst.block));
-                       break;
-
-               case CF_JSR:
-                       inline_add_block_reference(iln, &(n_iptr->sx.s23.s3.jsrtarget.block));
-                       break;
-
-               case CF_TABLE:
-                       i = n_iptr->sx.s23.s3.tablehigh - n_iptr->sx.s23.s2.tablelow + 1 + 1 /* default */;
-
-                       table = DMNEW(branch_target_t, i);
-                       MCOPY(table, o_iptr->dst.table, branch_target_t, i);
-                       n_iptr->dst.table = table;
-
-                       while (--i >= 0) {
-                               inline_add_block_reference(iln, &(table->block));
-                               table++;
-                       }
-                       break;
-
-               case CF_LOOKUP:
-                       inline_add_block_reference(iln, &(n_iptr->sx.s23.s3.lookupdefault.block));
-
-                       i = n_iptr->sx.s23.s2.lookupcount;
-                       lookup = DMNEW(lookup_target_t, i);
-                       MCOPY(lookup, o_iptr->dst.lookup, lookup_target_t, i);
-                       n_iptr->dst.lookup = lookup;
-
-                       while (--i >= 0) {
-                               inline_add_block_reference(iln, &(lookup->target.block));
-                               lookup++;
-                       }
-                       break;
-       }
-
-       /* XXX move this to dataflow section? */
-
-       switch (n_iptr->opc) {
-               case ICMD_ASTORE:
-#if 0
-                       if (n_iptr->flags.bits & INS_FLAG_RETADDR)
-                               inline_add_blocknr_reference(iln, &(n_iptr->sx.s23.s2.retaddrnr));
-#endif
-                       /* FALLTHROUGH! */
-               case ICMD_ISTORE:
-               case ICMD_LSTORE:
-               case ICMD_FSTORE:
-               case ICMD_DSTORE:
-                       stack_javalocals_store(n_iptr, iln->javalocals);
-                       break;
-       }
-}
-
-
-static void inline_rewrite_method(inline_node *iln)
-{
-       basicblock *o_bptr;
-       s4 len;
-       instruction *o_iptr;
-       instruction *n_iptr;
-       inline_node *nextcall;
-       basicblock *n_bptr;
-       inline_block_map *bm;
-       int i;
-       int icount;
-       jitdata *resultjd;
-       jitdata *origjd;
-       char indent[100]; /* XXX debug */
-       s4 retcount;
-       s4 retidx;
-
-       assert(iln);
-
-       resultjd = iln->ctx->resultjd;
-       origjd = iln->jd;
-
-       n_bptr = NULL;
-       nextcall = iln->children;
-
-       /* XXX debug */
-       for (i=0; i<iln->depth; ++i)
-               indent[i] = '\t';
-       indent[i] = 0;
-       iln->indent = indent;
-
-       DOLOG( printf("%srewriting: ", indent); method_println(iln->m);
-                  printf("%s(passthrough: %d+%d)\n",
-                               indent, iln->n_passthroughcount - iln->n_selfpassthroughcount,
-                               iln->n_passthroughcount); );
-
-       /* set memory cursors */
-
-       iln->inlined_iinstr_cursor = iln->inlined_iinstr;
-       iln->inlined_basicblocks_cursor = iln->inlined_basicblocks;
-
-       /* allocate temporary buffers */
-
-       iln->javalocals = DMNEW(s4, iln->jd->maxlocals);
-
-       /* loop over basic blocks */
-
-       o_bptr = iln->jd->basicblocks;
-       for (; o_bptr; o_bptr = o_bptr->next) {
-
-               if (o_bptr->flags < BBREACHED) {
-
-                       /* ignore the dummy end block */
-
-                       if (o_bptr->icount == 0 && o_bptr->next == NULL) {
-                               /* enter the following block as translation, for exception handler ranges */
-                               inline_block_translation(iln, o_bptr, iln->inlined_basicblocks_cursor);
-                               continue;
-                       }
-
-                       DOLOG(
-                       printf("%s* skipping old L%03d (flags=%d, type=%d, oid=%d) of ",
-                                       indent,
-                                       o_bptr->nr, o_bptr->flags, o_bptr->type,
-                                       o_bptr->indepth);
-                       method_println(iln->m);
-                       );
-
-                       n_bptr = create_body_block(iln, o_bptr, iln->varmap);
-
-                       /* enter it in the blockmap */
-
-                       inline_block_translation(iln, o_bptr, n_bptr);
-
-                       close_body_block(iln, n_bptr, o_bptr, iln->varmap, 0, -1);
-                       continue;
-               }
-
-               len = o_bptr->icount;
-               o_iptr = o_bptr->iinstr;
-
-               DOLOG(
-               printf("%s* rewriting old L%03d (flags=%d, type=%d, oid=%d) of ",
-                               indent,
-                               o_bptr->nr, o_bptr->flags, o_bptr->type,
-                               o_bptr->indepth);
-               method_println(iln->m);
-               show_basicblock(iln->jd, o_bptr, SHOW_STACK);
-               );
-
-               if (iln->blockbefore || o_bptr != iln->jd->basicblocks) {
-                       /* create an inlined clone of this block */
-
-                       n_bptr = create_body_block(iln, o_bptr, iln->varmap);
-                       icount = 0;
-
-                       /* enter it in the blockmap */
-
-                       inline_block_translation(iln, o_bptr, n_bptr);
-
-                       /* initialize the javalocals */
-
-                       MCOPY(iln->javalocals, n_bptr->javalocals, s4, iln->jd->maxlocals);
-               }
-               else {
-                       s4 *jl;
-
-                       /* continue caller block */
-
-                       n_bptr = iln->inlined_basicblocks_cursor - 1;
-                       icount = n_bptr->icount;
-
-                       /* translate the javalocals */
-
-                       jl = translate_javalocals(iln, o_bptr->javalocals);
-                       iln->inline_start_instruction->sx.s23.s3.inlineinfo->javalocals_start = jl;
-
-                       MCOPY(iln->javalocals, jl, s4, iln->jd->maxlocals);
-               }
-
-               /* iterate over the ICMDs of this block */
-
-               retcount = 0;
-               retidx = UNUSED;
-
-               while (--len >= 0) {
-
-                       DOLOG( fputs(indent, stdout); show_icmd(iln->jd, o_iptr, false,  SHOW_STACK);
-                                  printf("\n") );
-
-                       /* handle calls that will be inlined */
-
-                       if (nextcall && o_iptr == nextcall->callerins) {
-
-                               /* write the inlining prolog */
-
-                               (void) emit_inlining_prolog(iln, nextcall, o_iptr, iln->varmap);
-                               icount += nextcall->prolog_instructioncount;
-
-                               /* end current block, or glue blocks together */
-
-                               n_bptr->icount = icount;
-
-                               if (nextcall->blockbefore) {
-                                       close_prolog_block(iln, n_bptr, nextcall);
-                               }
-                               else {
-                                       /* XXX */
-                               }
-
-                               /* check if the result is a local variable */
-
-                               if (nextcall->m->parseddesc->returntype.type != TYPE_VOID
-                                               && o_iptr->dst.varindex < iln->jd->localcount)
-                               {
-                                       nextcall->n_resultlocal = iln->varmap[o_iptr->dst.varindex];
-                               }
-                               else
-                                       nextcall->n_resultlocal = -1;
-
-                               /* set memory pointers in the callee */
-
-                               nextcall->inlined_iinstr = iln->inlined_iinstr_cursor;
-                               nextcall->inlined_basicblocks = iln->inlined_basicblocks_cursor;
-
-                               /* recurse */
-
-                               DOLOG( printf("%sentering inline ", indent);
-                                          show_icmd(origjd, o_iptr, false, SHOW_STACK); printf("\n") );
-
-                               inline_rewrite_method(nextcall);
-
-                               DOLOG( printf("%sleaving inline ", indent);
-                                          show_icmd(origjd, o_iptr, false, SHOW_STACK); printf("\n") );
-
-                               /* update memory cursors */
-
-                               assert(nextcall->inlined_iinstr_cursor
-                                               <= iln->inlined_iinstr_cursor + nextcall->cumul_instructioncount);
-                               assert(nextcall->inlined_basicblocks_cursor
-                                               == iln->inlined_basicblocks_cursor + nextcall->cumul_basicblockcount);
-                               iln->inlined_iinstr_cursor = nextcall->inlined_iinstr_cursor;
-                               iln->inlined_basicblocks_cursor = nextcall->inlined_basicblocks_cursor;
-
-                               /* start new block, or glue blocks together */
-
-                               if (nextcall->blockafter) {
-                                       n_bptr = create_epilog_block(iln, nextcall, iln->varmap);
-                                       icount = 0;
-                               }
-                               else {
-                                       n_bptr = iln->inlined_basicblocks_cursor - 1;
-                                       icount = n_bptr->icount;
-                                       /* XXX */
-                               }
-
-                               /* emit inlining epilog */
-
-                               emit_inlining_epilog(iln, nextcall, o_iptr);
-                               icount += nextcall->epilog_instructioncount;
-
-                               /* proceed to next call */
-
-                               nextcall = nextcall->next;
-                       }
-                       else {
-                               n_iptr = (iln->inlined_iinstr_cursor++);
-                               assert((n_iptr - iln->inlined_iinstr) < iln->cumul_instructioncount);
-
-                               switch (o_iptr->opc) {
-                                       case ICMD_RETURN:
-                                               if (iln->depth == 0)
-                                                       goto default_clone;
-                                               goto return_tail;
-
-                                       case ICMD_IRETURN:
-                                       case ICMD_ARETURN:
-                                       case ICMD_LRETURN:
-                                       case ICMD_FRETURN:
-                                       case ICMD_DRETURN:
-                                               if (iln->depth == 0)
-                                                       goto default_clone;
-                                               retcount = 1;
-                                               retidx = iln->varmap[o_iptr->s1.varindex];
-                                               if (iln->n_resultlocal != -1) {
-                                                       /* store result in a local variable */
-
-                                                       DOLOG( printf("USING RESULTLOCAL %d\n", iln->n_resultlocal); );
-                                                       /* This relies on the same sequence of types for */
-                                                       /* ?STORE and ?RETURN opcodes.                   */
-                                                       n_iptr->opc = ICMD_ISTORE + (o_iptr->opc - ICMD_IRETURN);
-                                                       n_iptr->s1.varindex = retidx;
-                                                       n_iptr->dst.varindex = iln->n_resultlocal;
-                                                       n_iptr->sx.s23.s3.javaindex = UNUSED; /* XXX set real javaindex? */
-
-                                                       retcount = 0;
-                                                       retidx = UNUSED;
-
-                                                       n_iptr = (iln->inlined_iinstr_cursor++);
-                                                       assert((n_iptr - iln->inlined_iinstr) < iln->cumul_instructioncount);
-                                                       icount++;
-                                               }
-                                               else if ((retidx < resultjd->localcount && iln->blockafter)
-                                                               || !iln->blockafter) /* XXX do we really always need the MOVE? */
-                                               {
-                                                       /* local must not become outvar, insert a MOVE */
-
-                                                       n_iptr->opc = ICMD_MOVE;
-                                                       n_iptr->s1.varindex = retidx;
-                                                       retidx = inline_new_temp_variable(resultjd,
-                                                                                                                         resultjd->var[retidx].type);
-                                                       n_iptr->dst.varindex = retidx;
-
-                                                       n_iptr = (iln->inlined_iinstr_cursor++);
-                                                       assert((n_iptr - iln->inlined_iinstr) < iln->cumul_instructioncount);
-                                                       icount++;
-                                               }
-return_tail:
-                                               if (iln->blockafter) {
-                                                       n_iptr->opc = ICMD_GOTO;
-                                                       n_iptr->dst.block = INLINE_RETURN_REFERENCE(iln);
-                                                       inline_add_block_reference(iln, &(n_iptr->dst.block));
-                                               }
-                                               else {
-                                                       n_iptr->opc = ICMD_NOP;
-                                               }
-                                               break;
-#if 0
-                                               if (o_bptr->next == NULL || (o_bptr->next->icount==0 && o_bptr->next->next == NULL)) {
-                                                       n_iptr->opc = ICMD_NOP;
-                                                       break;
-                                               }
-                                               goto default_clone;
-                                               break;
-#endif
-
-                                       default:
-default_clone:
-                                               inline_clone_instruction(iln, resultjd, iln->jd, iln->varmap, o_iptr, n_iptr);
-                               }
-
-                               DOLOG( fputs(indent, stdout); show_icmd(resultjd, n_iptr, false, SHOW_STACK);
-                                          printf("\n"););
-
-                               icount++;
-                       }
-
-                       o_iptr++;
-               }
-
-               /* end of basic block */
-
-               if (iln->blockafter || (o_bptr->next && o_bptr->next->next)) {
-                       close_body_block(iln, n_bptr, o_bptr, iln->varmap, retcount, retidx);
-                       n_bptr->icount = icount;
-
-                       DOLOG( printf("closed body block:\n");
-                                  show_basicblock(resultjd, n_bptr, SHOW_STACK); );
-               }
-               else {
-                       n_bptr->icount = icount;
-                       assert(iln->parent);
-                       if (retidx != UNUSED)
-                               iln->parent->varmap[iln->callerins->dst.varindex] = retidx;
-               }
-       }
-
-       bm = iln->ctx->blockmap;
-       for (i=0; i<iln->ctx->blockmap_index; ++i, ++bm) {
-               assert(bm->iln && bm->o_block && bm->n_block);
-               if (bm->iln == iln)
-                       inline_resolve_block_refs(&(iln->refs), bm->o_block, bm->n_block, false);
-       }
-
-#if !defined(NDEBUG)
-       if (iln->refs) {
-               inline_target_ref *ref;
-               ref = iln->refs;
-               while (ref) {
-                       if (!iln->depth || ref->isnumber || *(ref->ref.block) != INLINE_RETURN_REFERENCE(iln)) {
-                               DOLOG( printf("XXX REMAINING REF at depth %d: %p\n", iln->depth,
-                                          (void*)*(ref->ref.block)) );
-                               assert(false);
-                       }
-                       ref = ref->next;
-               }
-       }
-#endif
-}
-
-
-static exception_entry * inline_exception_tables(inline_node *iln,
-                                                                                                exception_entry *n_extable,
-                                                                                                exception_entry **prevextable)
-{
-       inline_node *child;
-       inline_node *scope;
-       exception_entry *et;
-
-       assert(iln);
-       assert(n_extable);
-       assert(prevextable);
-
-       child = iln->children;
-       if (child) {
-               do {
-                       n_extable = inline_exception_tables(child, n_extable, prevextable);
-                       child = child->next;
-               } while (child != iln->children);
-       }
-
-       et = iln->jd->exceptiontable;
-       for (; et != NULL; et = et->down) {
-               assert(et);
-               MZERO(n_extable, exception_entry, 1);
-               n_extable->start     = inline_map_block(iln, et->start  , iln);
-               n_extable->end       = inline_map_block(iln, et->end    , iln);
-               n_extable->handler   = inline_map_block(iln, et->handler, iln);
-               n_extable->catchtype = et->catchtype;
-
-               if (*prevextable) {
-                       (*prevextable)->down = n_extable;
-               }
-               *prevextable = n_extable;
-
-               n_extable++;
-       }
-
-       if (iln->handler_monitorexit) {
-               exception_entry **activehandlers;
-
-               MZERO(n_extable, exception_entry, 1);
-               n_extable->start   = iln->inlined_basicblocks;
-               n_extable->end     = iln->inlined_basicblocks_cursor;
-               n_extable->handler = iln->handler_monitorexit;
-               n_extable->catchtype.any = NULL; /* finally */
-
-               if (*prevextable) {
-                       (*prevextable)->down = n_extable;
-               }
-               *prevextable = n_extable;
-
-               n_extable++;
-
-               /* We have to protect the created handler with the same handlers */
-               /* that protect the method body itself.                          */
-
-               for (scope = iln; scope->parent != NULL; scope = scope->parent) {
-
-                       activehandlers = scope->o_handlers;
-                       assert(activehandlers);
-
-                       while (*activehandlers) {
-
-                               assert(scope->parent);
-
-                               MZERO(n_extable, exception_entry, 1);
-                               n_extable->start     = iln->handler_monitorexit;
-                               n_extable->end       = iln->handler_monitorexit + 1; /* XXX ok in this case? */
-                               n_extable->handler   = inline_map_block(scope->parent,
-                                                                                                               (*activehandlers)->handler,
-                                                                                                               scope->parent);
-                               n_extable->catchtype = (*activehandlers)->catchtype;
-
-                               if (*prevextable) {
-                                       (*prevextable)->down = n_extable;
-                               }
-                               *prevextable = n_extable;
-
-                               n_extable++;
-                               activehandlers++;
-                       }
-               }
-       }
-
-       return n_extable;
-}
-
-
-static void inline_locals(inline_node *iln)
-{
-       inline_node *child;
-
-       assert(iln);
-
-       iln->varmap = create_variable_map(iln);
-
-       child = iln->children;
-       if (child) {
-               do {
-                       inline_locals(child);
-                       child = child->next;
-               } while (child != iln->children);
-       }
-
-       if (iln->regdata->memuse > iln->ctx->resultjd->rd->memuse)
-               iln->ctx->resultjd->rd->memuse = iln->regdata->memuse;
-       if (iln->regdata->argintreguse > iln->ctx->resultjd->rd->argintreguse)
-               iln->ctx->resultjd->rd->argintreguse = iln->regdata->argintreguse;
-       if (iln->regdata->argfltreguse > iln->ctx->resultjd->rd->argfltreguse)
-               iln->ctx->resultjd->rd->argfltreguse = iln->regdata->argfltreguse;
-}
-
-
-static void inline_interface_variables(inline_node *iln)
-{
-       basicblock *bptr;
-       jitdata *resultjd;
-       s4 i;
-       varinfo *v;
-
-       resultjd = iln->ctx->resultjd;
-
-       resultjd->interface_map = DMNEW(interface_info, 5*iln->ctx->maxinoutdepth);
-       for (i=0; i<5*iln->ctx->maxinoutdepth; ++i)
-               resultjd->interface_map[i].flags = UNUSED;
-
-       for (bptr = resultjd->basicblocks; bptr != NULL; bptr = bptr->next) {
-               assert(bptr->indepth  <= iln->ctx->maxinoutdepth);
-               assert(bptr->outdepth <= iln->ctx->maxinoutdepth);
-
-               for (i=0; i<bptr->indepth; ++i) {
-                       v = &(resultjd->var[bptr->invars[i]]);
-                       v->flags |= INOUT;
-                       if (v->type == TYPE_RET)
-                               v->flags |= PREALLOC;
-                       else
-                               v->flags &= ~PREALLOC;
-                       v->flags &= ~INMEMORY;
-                       assert(bptr->invars[i] >= resultjd->localcount);
-
-                       if (resultjd->interface_map[5*i + v->type].flags == UNUSED) {
-                               resultjd->interface_map[5*i + v->type].flags = v->flags;
-                       }
-                       else {
-                               resultjd->interface_map[5*i + v->type].flags |= v->flags;
-                       }
-               }
-
-               for (i=0; i<bptr->outdepth; ++i) {
-                       v = &(resultjd->var[bptr->outvars[i]]);
-                       v->flags |= INOUT;
-                       if (v->type == TYPE_RET)
-                               v->flags |= PREALLOC;
-                       else
-                               v->flags &= ~PREALLOC;
-                       v->flags &= ~INMEMORY;
-                       assert(bptr->outvars[i] >= resultjd->localcount);
-
-                       if (resultjd->interface_map[5*i + v->type].flags == UNUSED) {
-                               resultjd->interface_map[5*i + v->type].flags = v->flags;
-                       }
-                       else {
-                               resultjd->interface_map[5*i + v->type].flags |= v->flags;
-                       }
-               }
-       }
-}
-
-
-static void inline_write_exception_handlers(inline_node *master, inline_node *iln)
-{
-       basicblock *n_bptr;
-       instruction *n_ins;
-       inline_node *child;
-       builtintable_entry *bte;
-       s4 exvar;
-       s4 syncvar;
-       s4 i;
-
-       child = iln->children;
-       if (child) {
-               do {
-                       inline_write_exception_handlers(master, child);
-                       child = child->next;
-               } while (child != iln->children);
-       }
-
-       if (iln->synchronize) {
-               /* create the monitorexit handler */
-               n_bptr = create_block(master, iln, iln,
-                                                         iln->n_passthroughcount + 1);
-               n_bptr->type = BBTYPE_EXH;
-               n_bptr->flags = BBFINISHED;
-
-               exvar = inline_new_variable(master->ctx->resultjd, TYPE_ADR, 0);
-               n_bptr->invars[iln->n_passthroughcount] = exvar;
-
-               iln->handler_monitorexit = n_bptr;
-
-               /* ACONST / ALOAD */
-
-               n_ins = master->inlined_iinstr_cursor++;
-               if (iln->m->flags & ACC_STATIC) {
-                       n_ins->opc = ICMD_ACONST;
-                       n_ins->sx.val.c.cls = iln->m->clazz;
-                       n_ins->flags.bits = INS_FLAG_CLASS;
-               }
-               else {
-                       n_ins->opc = ICMD_ALOAD;
-                       n_ins->s1.varindex = iln->synclocal;
-                       assert(n_ins->s1.varindex != UNUSED);
-               }
-               /* XXX could be PREALLOCed for  builtin call */
-               syncvar = inline_new_variable(master->ctx->resultjd, TYPE_ADR, 0);
-               n_ins->dst.varindex = syncvar;
-               n_ins->line = 0;
-
-               /* MONITOREXIT */
-
-               bte = builtintable_get_internal(LOCK_monitor_exit);
-
-               n_ins = master->inlined_iinstr_cursor++;
-               n_ins->opc = ICMD_BUILTIN;
-               n_ins->s1.argcount = 1 + iln->n_passthroughcount + 1;
-               n_ins->sx.s23.s2.args = DMNEW(s4, n_ins->s1.argcount);
-               n_ins->sx.s23.s2.args[0] = syncvar;
-               for (i=0; i < iln->n_passthroughcount + 1; ++i) {
-                       n_ins->sx.s23.s2.args[1 + i] = n_bptr->invars[i];
-               }
-               n_ins->sx.s23.s3.bte = bte;
-               n_ins->line = 0;
-
-               /* ATHROW */
-
-               n_ins = master->inlined_iinstr_cursor++;
-               n_ins->opc = ICMD_ATHROW;
-               n_ins->flags.bits = 0;
-               n_ins->s1.varindex = exvar;
-               n_ins->line = 0;
-
-               /* close basic block */
-
-               close_block(iln, iln, n_bptr, iln->n_passthroughcount);
-               n_bptr->icount = 3;
-       }
-}
-
-
-/* second pass driver *********************************************************/
-
-static bool inline_transform(inline_node *iln, jitdata *jd)
-{
-       instruction *n_ins;
-       basicblock *n_bb;
-       basicblock *n_bptr;
-       exception_entry *n_ext;
-       exception_entry *prevext;
-       codegendata *n_cd;
-       jitdata *n_jd;
-       s4 i;
-#if defined(INLINE_VERIFY_RESULT)
-       static int debug_verify_inlined_code = 1;
-#endif
-#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
-       static int debug_counter = 0;
-#endif
-
-       DOLOG( dump_inline_tree(iln, 0); );
-
-       assert(iln && jd);
-
-       n_ins = DMNEW(instruction, iln->cumul_instructioncount);
-       MZERO(n_ins, instruction, iln->cumul_instructioncount);
-       iln->inlined_iinstr = n_ins;
-
-       n_bb = DMNEW(basicblock, iln->cumul_basicblockcount);
-       MZERO(n_bb, basicblock, iln->cumul_basicblockcount);
-       iln->inlined_basicblocks = n_bb;
-
-       iln->ctx->blockmap = DMNEW(inline_block_map, iln->cumul_blockmapcount);
-
-       n_jd = jit_jitdata_new(iln->m);
-       n_jd->flags = jd->flags;
-       n_jd->code->optlevel = jd->code->optlevel;
-       iln->ctx->resultjd = n_jd;
-
-       reg_setup(n_jd);
-
-       /* create the local_map */
-
-       n_jd->local_map = DMNEW(s4, 5*iln->cumul_maxlocals);
-       for (i=0; i<5*iln->cumul_maxlocals; ++i)
-               n_jd->local_map[i] = UNUSED;
-
-       /* create / coalesce local variables */
-
-       n_jd->varcount = 0;
-       n_jd->vartop = 0;
-       n_jd->var = NULL;
-
-       inline_locals(iln);
-
-       n_jd->localcount = n_jd->vartop;
-
-       /* extra variables for verification (debugging) */
-
-#if defined(INLINE_VERIFY_RESULT)
-       if (debug_verify_inlined_code) {
-               n_jd->vartop   += VERIFIER_EXTRA_LOCALS + VERIFIER_EXTRA_VARS + 100 /* XXX m->maxstack */;
-               if (n_jd->vartop > n_jd->varcount) {
-                       /* XXX why? */
-                       n_jd->var = DMREALLOC(n_jd->var, varinfo, n_jd->varcount, n_jd->vartop);
-                       n_jd->varcount = n_jd->vartop;
-               }
-       }
-#endif /* defined(INLINE_VERIFY_RESULT) */
-
-       /* write inlined code */
-
-       inline_rewrite_method(iln);
-
-       /* create exception handlers */
-
-       inline_write_exception_handlers(iln, iln);
-
-       /* write the dummy end block */
-
-       n_bptr = create_block(iln, iln, iln, 0);
-       n_bptr->flags = BBUNDEF;
-       n_bptr->type = BBTYPE_STD;
-
-       /* store created code in jitdata */
-
-       n_jd->basicblocks = iln->inlined_basicblocks;
-       n_jd->instructioncount = iln->cumul_instructioncount;
-       n_jd->instructions = iln->inlined_iinstr;
-
-       /* link the basic blocks (dummy end block is not counted) */
-
-       n_jd->basicblockcount = (iln->inlined_basicblocks_cursor - iln->inlined_basicblocks) - 1;
-       for (i=0; i<n_jd->basicblockcount + 1; ++i)
-               n_jd->basicblocks[i].next = &(n_jd->basicblocks[i+1]);
-       if (i)
-               n_jd->basicblocks[i-1].next = NULL;
-
-       /* check basicblock numbers */
-
-#if !defined(NDEBUG)
-       jit_check_basicblock_numbers(n_jd);
-#endif
-
-       /* create the exception table */
-
-       if (iln->cumul_exceptiontablelength) {
-               exception_entry *tableend;
-
-               n_ext = DMNEW(exception_entry, iln->cumul_exceptiontablelength);
-               prevext = NULL;
-               tableend = inline_exception_tables(iln, n_ext, &prevext);
-               assert(tableend == n_ext + iln->cumul_exceptiontablelength);
-               if (prevext)
-                       prevext->down = NULL;
-
-               n_jd->exceptiontablelength = iln->cumul_exceptiontablelength;
-               n_jd->exceptiontable = n_ext;
-       }
-       else {
-               n_ext = NULL;
-       }
-
-       /*******************************************************************************/
-
-       n_cd = n_jd->cd;
-       memcpy(n_cd, jd->cd, sizeof(codegendata));
-
-       n_cd->method = NULL; /* XXX */
-       n_jd->maxlocals = iln->cumul_maxlocals;
-       n_jd->maxinterfaces = iln->ctx->maxinoutdepth;
-
-       inline_post_process(n_jd);
-
-       inline_interface_variables(iln);
-
-       /* for debugging, verify the inlined result */
-
-#if defined(INLINE_VERIFY_RESULT)
-       if (debug_verify_inlined_code) {
-               debug_verify_inlined_code = 0;
-               DOLOG( printf("VERIFYING INLINED RESULT...\n"); fflush(stdout); );
-               if (!typecheck(n_jd)) {
-                       exceptions_clear_exception();
-                       DOLOG( printf("XXX INLINED RESULT DID NOT PASS VERIFIER XXX\n") );
-                       return false;
-               }
-               else {
-                       DOLOG( printf("VERIFICATION PASSED.\n") );
-               }
-               debug_verify_inlined_code = 1;
-       }
-#endif /* defined(INLINE_VERIFY_RESULT) */
-
-       /* we need bigger free memory stacks (XXX these should not be allocated in reg_setup) */
-
-       n_jd->rd->freemem = DMNEW(s4, iln->ctx->maxinoutdepth + 1000) /* XXX max vars/block */;
-#if defined(HAS_4BYTE_STACKSLOT)
-       n_jd->rd->freemem_2 = DMNEW(s4, iln->ctx->maxinoutdepth + 1000) /* XXX max vars/block */;
-#endif
-
-#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
-       if (   (n_jd->instructioncount >= opt_InlineMinSize)
-               && (n_jd->instructioncount <= opt_InlineMaxSize))
-       {
-          if (debug_counter < opt_InlineCount)
-#endif /* defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) */
-          {
-                       /* install the inlined result */
-
-                       *jd->code = *n_jd->code;
-                       n_jd->code = jd->code;
-                       *jd = *n_jd;
-
-                       /* statistics and logging */
-
-#if !defined(NDEBUG)
-                       inline_stat_roots++;
-
-                       DOLOG_SHORT(
-                       printf("==== %d.INLINE ==================================================================\n",
-                               debug_counter);
-                       printf("\ninline tree:\n");
-                       dump_inline_tree(iln, 0);
-                       n_jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE | JITDATA_FLAG_SHOWDISASSEMBLE;
-                       /* debug_dump_inlined_code(iln, n_method, n_cd, n_rd); */
-                       printf("-------- DONE -----------------------------------------------------------\n");
-                       fflush(stdout);
-                       );
-#endif
-          }
-
-#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
-               debug_counter++;
-       }
-#endif
-       return true;
-}
-
-
-/******************************************************************************/
-/* FIRST PASS: build inlining tree                                            */
-/******************************************************************************/
-
-
-/* inline_pre_parse_heuristics *************************************************
-
-   Perform heuristic checks whether a call site should be inlined.
-   These checks are evaluated before the callee has been parsed and analysed.
-
-   IN:
-       caller...........inlining node of the caller
-          callee...........the called method
-          site.............information on the call site
-
-   RETURN VALUE:
-       true........consider for inlining
-          false.......don't inline
-
-*******************************************************************************/
-
-static bool inline_pre_parse_heuristics(const inline_node *caller,
-                                                                               const methodinfo *callee,
-                                                                               inline_site *site)
-{
-#if defined(INLINE_MAX_DEPTH)
-       if (caller->depth >= INLINE_MAX_DEPTH)
-               return false;
-#endif
-
-       return true;
-}
-
-
-/* inline_post_parse_heuristics ************************************************
-
-   Perform heuristic checks whether a call site should be inlined.
-   These checks are evaluated after the callee has been parsed and analysed.
-
-   IN:
-       caller...........inlining node of the caller (const)
-          callee...........the called method (const)
-
-   RETURN VALUE:
-          true........consider for inlining
-          false.......don't inline
-
-*******************************************************************************/
-
-static bool inline_post_parse_heuristics(const inline_node *caller,
-                                                                                const inline_node *callee)
-{
-       return true;
-}
-
-
-/* inline_afterwards_heuristics ************************************************
-
-   Perform heuristic checks whether a call site should be inlined.
-   These checks are evaluated after the inlining plan for the callee has
-   been made.
-
-   IN:
-       caller...........inlining node of the caller (const)
-          callee...........the called method (const)
-
-   RETURN VALUE:
-          true........consider for inlining
-          false.......don't inline
-
-*******************************************************************************/
-
-static bool inline_afterwards_heuristics(const inline_node *caller,
-                                                                                const inline_node *callee)
-{
-       inline_node *cumulator;
-
-#if defined(INLINE_DEPTH_FIRST)
-       cumulator = caller;
-#else
-       cumulator = caller->ctx->master;
-#endif
-
-       if (0
-#if defined(INLINE_MAX_BLOCK_EXPANSION)
-               || (cumulator->cumul_basicblockcount + callee->cumul_basicblockcount
-                       > INLINE_MAX_BLOCK_EXPANSION*caller->ctx->master->jd->basicblockcount)
-#endif
-#if defined(INLINE_MAX_ICMD_EXPANSION)
-               || (cumulator->cumul_instructioncount + callee->cumul_instructioncount
-                       > INLINE_MAX_ICMD_EXPANSION*caller->ctx->master->jd->instructioncount)
-#endif
-          )
-       {
-               return false;
-       }
-
-       return true;
-}
-
-
-/* inline_is_monomorphic *******************************************************
-
-   Check if the given call site can be proven to be monomorphic.
-
-   IN:
-          callee...........the called method
-          call.............the invocation instruction
-
-   OUT:
-       site->speculative.....flags whether the inlining is speculative
-                                (only defined if return value is true)
-
-   RETURN VALUE:
-       true if the call site is (currently) monomorphic,
-          false if not or unknown
-
-*******************************************************************************/
-
-static bool inline_is_monomorphic(const methodinfo *callee,
-                                                                 const instruction *call,
-                                                                 inline_site *site)
-{
-       if ((callee->flags & (ACC_STATIC | ACC_FINAL | ACC_PRIVATE)
-                               || call->opc == ICMD_INVOKESPECIAL))
-       {
-               site->speculative = false;
-               return true;
-       }
-
-       /* XXX search single implementation for abstract monomorphics */
-
-       if ((callee->flags & (ACC_METHOD_MONOMORPHIC | ACC_METHOD_IMPLEMENTED
-                                       | ACC_ABSTRACT))
-                       == (ACC_METHOD_MONOMORPHIC | ACC_METHOD_IMPLEMENTED))
-       {
-               if (1) {
-                       DOLOG( printf("SPECULATIVE INLINE: "); method_println((methodinfo*)callee); );
-                       site->speculative = true;
-
-                       return true;
-               }
-       }
-
-       /* possibly polymorphic call site */
-
-       return false;
-}
-
-
-/* inline_can_inline ***********************************************************
-
-   Check if inlining of the given call site is possible.
-
-   IN:
-       caller...........inlining node of the caller
-          callee...........the called method
-          call.............the invocation instruction
-
-   OUT:
-       site->speculative.....flags whether the inlining is speculative
-                                (only defined if return value is true)
-
-   RETURN VALUE:
-       true if inlining is possible, false if not
-
-*******************************************************************************/
-
-static bool inline_can_inline(const inline_node *caller,
-                                                         const methodinfo *callee,
-                                                         const instruction *call,
-                                                         inline_site *site)
-{
-       const inline_node *active;
-
-       /* cannot inline native methods */
-
-       if (callee->flags & ACC_NATIVE)
-               return false;
-
-       /* cannot inline possibly polymorphic calls */
-
-       if (!inline_is_monomorphic(callee, call, site))
-               return false;
-
-       /* cannot inline recursive calls */
-
-       for (active = caller; active; active = active->parent) {
-               if (callee == active->m) {
-                       DOLOG( printf("RECURSIVE!\n") );
-                       return false;
-               }
-       }
-
-       /* inlining is possible */
-
-       return true;
-}
-
-
-/* inline_create_callee_node ***************************************************
-
-   Create an inlining node for the given callee.
-
-   IN:
-          caller...........inlining node of the caller (const)
-          callee...........the called method
-
-   RETURN VALUE:
-       the new inlining node
-
-*******************************************************************************/
-
-static inline_node * inline_create_callee_node(const inline_node *caller,
-                                                                                          methodinfo *callee)
-{
-       inline_node *cn;              /* the callee inline_node */
-
-       cn = DNEW(inline_node);
-       MZERO(cn, inline_node, 1);
-
-       cn->depth = caller->depth + 1;
-       cn->ctx = caller->ctx;
-       cn->m = callee;
-       cn->synchronize = (callee->flags & ACC_SYNCHRONIZED);
-       cn->isstatic = (callee->flags & ACC_STATIC);
-
-       return cn;
-}
-
-
-/* inline_set_callee_properties ************************************************
-
-   Set properties of the inlined call site.
-
-   IN:
-       caller...........inlining node of the caller (const)
-          cn...............the called method
-          site.............info about the call site (const)
-
-   OUT:
-       *cn..............has the properties set
-
-*******************************************************************************/
-
-static void inline_set_callee_properties(const inline_node *caller,
-                                                                                inline_node *cn,
-                                                                                const inline_site *site)
-{
-       s4           argi;
-       s4           i, j;
-       basicblock  *bptr;
-
-       /* set info about the call site */
-
-       cn->callerblock = site->bptr;
-       cn->callerins = site->iptr;
-       cn->callerpc = site->pc;
-       cn->o_handlers = site->handlers;
-       cn->n_handlercount = caller->n_handlercount + site->nhandlers;
-
-       /* determine if we need basic block boundaries before/after */
-
-       cn->blockbefore = false;
-       cn->blockafter = false;
-
-       if (cn->jd->branchtoentry)
-               cn->blockbefore = true;
-
-       if (cn->jd->branchtoend)
-               cn->blockafter = true;
-
-       if (cn->jd->returncount > 1)
-               cn->blockafter = true;
-
-       /* XXX make safer and reusable (maybe store last real block) */
-       for (bptr = cn->jd->basicblocks; bptr && bptr->next && bptr->next->next; bptr = bptr->next)
-               ;
-
-       if (cn->jd->returnblock != bptr)
-               cn->blockafter = true;
-
-       /* info about the callee */
-
-       cn->localsoffset = caller->localsoffset + caller->m->maxlocals;
-       cn->prolog_instructioncount = cn->m->parseddesc->paramcount + 2;
-       cn->epilog_instructioncount = 1; /* INLINE_END */
-       cn->extra_instructioncount = 0;
-
-       /* we need a CHECKNULL for instance methods, except for <init> */
-
-       if (!cn->isstatic && cn->m->name != utf_init)
-               cn->prolog_instructioncount += 1;
-
-       /* deal with synchronized callees */
-
-       if (cn->synchronize) {
-               methoddesc         *md;
-               builtintable_entry *bte;
-
-               /* we need basic block boundaries because of the handler */
-
-               cn->blockbefore = true;
-               cn->blockafter = true;
-
-               /* for synchronized static methods                 */
-               /* we need an ACONST, MONITORENTER in the prolog   */
-               /* and ACONST, MONITOREXIT in the epilog           */
-
-               /* for synchronized instance methods               */
-               /* we need an COPY, MONITORENTER in the prolog     */
-               /* and MONITOREXIT in the epilog                   */
-
-               if (cn->isstatic) {
-                       cn->prolog_instructioncount += 2;
-                       cn->epilog_instructioncount += 2;
-               }
-               else {
-                       cn->prolog_instructioncount += 2;
-                       cn->epilog_instructioncount += 1;
-                       cn->localsoffset += 1;
-               }
-
-               /* and exception handler */
-               /* ALOAD, builtin_monitorexit, ATHROW */
-
-               cn->extra_instructioncount += 3;
-
-               /* exception table entries */
-
-               cn->extra_exceptiontablelength = 1 + cn->n_handlercount;
-
-               /* add exception handler block */
-
-               cn->cumul_basicblockcount_root++;
-
-               /* we must call the builtins */
-
-               bte = builtintable_get_internal(LOCK_monitor_enter);
-               md = bte->md;
-               if (md->memuse > cn->regdata->memuse)
-                       cn->regdata->memuse = md->memuse;
-               if (md->argintreguse > cn->regdata->argintreguse)
-                       cn->regdata->argintreguse = md->argintreguse;
-
-               bte = builtintable_get_internal(LOCK_monitor_exit);
-               md = bte->md;
-               if (md->memuse > cn->regdata->memuse)
-                       cn->regdata->memuse = md->memuse;
-               if (md->argintreguse > cn->regdata->argintreguse)
-                       cn->regdata->argintreguse = md->argintreguse;
-       }
-
-       /* determine pass-through variables */
-
-       i = site->iptr->s1.argcount - cn->m->parseddesc->paramcount; /* max # of pass-though vars */
-
-       cn->n_passthroughvars = DMNEW(s4, i);
-       j = 0;
-       for (argi = site->iptr->s1.argcount - 1; argi >= cn->m->parseddesc->paramcount; --argi) {
-               s4 idx = site->iptr->sx.s23.s2.args[argi];
-               if (idx >= caller->jd->localcount) {
-                       cn->n_passthroughvars[j] = idx;
-                       j++;
-               }
-               else {
-                       DOLOG( printf("PASSING THROUGH LOCAL VARIABLE %d\n", idx); );
-               }
-       }
-       assert(j <= i);
-       cn->n_selfpassthroughcount = j;
-       cn->n_passthroughcount = caller->n_passthroughcount + cn->n_selfpassthroughcount;
-}
-
-
-/* inline_cumulate_counters ****************************************************
-
-   Cumulate counters after a node has been decided to become inlined.
-
-   IN:
-       caller...........inlining node of the caller
-          callee...........inlining node of the callee (const)
-
-   OUT:
-       *caller..........gets cumulated values added
-
-*******************************************************************************/
-
-static void inline_cumulate_counters(inline_node *caller,
-                                                                        const inline_node *cn)
-{
-       caller->cumul_instructioncount += cn->prolog_instructioncount;
-       caller->cumul_instructioncount += cn->epilog_instructioncount;
-       caller->cumul_instructioncount += cn->extra_instructioncount;
-       caller->cumul_instructioncount += cn->cumul_instructioncount - 1 /*invoke*/;
-
-       caller->cumul_basicblockcount += cn->cumul_basicblockcount;
-       caller->cumul_basicblockcount_root += cn->cumul_basicblockcount_root;
-       caller->cumul_blockmapcount += cn->cumul_blockmapcount;
-       caller->cumul_exceptiontablelength += cn->cumul_exceptiontablelength;
-       caller->cumul_exceptiontablelength += cn->extra_exceptiontablelength;
-
-       if (cn->cumul_maxlocals > caller->cumul_maxlocals)
-               caller->cumul_maxlocals = cn->cumul_maxlocals;
-
-       /* XXX extra block after inlined call */
-       if (cn->blockafter) {
-               caller->cumul_basicblockcount += 1;
-               caller->cumul_blockmapcount += 1;
-       }
-}
-
-
-/* inline_analyse_callee *******************************************************
-
-   Analyse an inlining candidate callee.
-
-   IN:
-       caller...........inlining node of the caller
-          callee...........the called method
-          site.............info about the call site
-
-   OUT:
-       site->inlined....true if the callee has been selected for inlining
-
-   RETURN VALUE:
-       the inline node of the callee, or
-       NULL if an error has occurred (don't use the inlining plan in this case)
-
-*******************************************************************************/
-
-static inline_node * inline_analyse_callee(inline_node *caller,
-                                                                                  methodinfo *callee,
-                                                                                  inline_site *site)
-{
-       inline_node *cn;              /* the callee inline_node */
-
-       /* create an inline tree node */
-
-       cn = inline_create_callee_node(caller, callee);
-
-       /* get the intermediate representation of the callee */
-
-       if (!inline_jit_compile(cn))
-               return NULL;
-
-       /* evaluate heuristics after parsing the callee */
-
-       if (!inline_post_parse_heuristics(caller, cn))
-               return cn;
-
-       /* the call site will be inlined */
-
-       site->inlined = true;
-
-       /* set info about the call site */
-
-       inline_set_callee_properties(caller, cn, site);
-
-       /* insert the node into the inline tree */
-
-       inline_insert_inline_node(caller, cn);
-
-       /* analyse recursively */
-
-       if (!inline_analyse_code(cn))
-               return NULL;
-
-       if (!inline_afterwards_heuristics(caller, cn)) {
-#if defined(INLINE_CANCEL_ON_THRESHOLD)
-               return NULL;
-#else
-               inline_remove_inline_node(caller, cn);
-               caller->ctx->stopped = true;
-               site->inlined = false;
-               return cn;
-#endif
-       }
-
-       /* cumulate counters */
-
-#if defined(INLINE_DEPTH_FIRST)
-       inline_cumulate_counters(caller, cn);
-#endif
-
-#if defined(INLINE_BREADTH_FIRST)
-       while (caller) {
-               inline_cumulate_counters(caller, cn);
-               caller = caller->parent;
-       }
-#endif
-
-       return cn;
-}
-
-
-/* inline_process_candidate ****************************************************
-
-   Process a selected inlining candidate.
-
-   IN:
-       cand.............the candidate
-
-   RETURN VALUE:
-       true........everything ok
-          false.......an error has occurred, don't use the plan
-
-*******************************************************************************/
-
-static bool inline_process_candidate(inline_candidate *cand)
-{
-       inline_node *cn;
-
-       cn = inline_analyse_callee(cand->caller,
-                                                          cand->callee,
-                                                          &(cand->site));
-
-       if (!cn)
-               return false;
-
-       if (!cand->site.inlined)
-               return true;
-
-       /* store assumptions */
-
-       if (cand->site.speculative)
-               method_add_assumption_monomorphic(cand->callee, cand->caller->ctx->master->m);
-
-       return true;
-}
-
-
-/* inline_analyse_code *********************************************************
-
-   Analyse the intermediate code of the given inlining node.
-
-   IN:
-       iln..............the inlining node
-
-   OUT:
-       *iln.............the inlining plan
-
-   RETURN VALUE:
-       true........everything ok
-          false.......an error has occurred, don't use the plan
-
-*******************************************************************************/
-
-static bool inline_analyse_code(inline_node *iln)
-{
-       methodinfo *m;
-       basicblock *bptr;
-       s4 len;
-       instruction *iptr;
-       methodinfo *callee;
-       exception_entry **handlers;
-       exception_entry *ex;
-       s4 nhandlers;
-       s4 blockendpc;
-       jitdata *mjd;
-       inline_site site;
-
-       assert(iln);
-
-       m = iln->m;
-       mjd = iln->jd;
-
-       /* initialize cumulative counters */
-
-       iln->cumul_maxlocals = iln->localsoffset + m->maxlocals;
-       iln->cumul_exceptiontablelength += mjd->exceptiontablelength;
-
-       /* iterate over basic blocks */
-
-       blockendpc = 0;
-
-       for (bptr = mjd->basicblocks; bptr; bptr = bptr->next) {
-
-               /* count the block */
-               /* ignore dummy end blocks (but count them for the blockmap) */
-
-               iln->cumul_blockmapcount++;
-               if ((bptr != mjd->basicblocks || iln->blockbefore)
-                               &&
-                       (bptr->icount > 0 || bptr->next != NULL))
-                       iln->cumul_basicblockcount++;
-
-               /* skip dead code */
-
-               if (bptr->flags < BBREACHED)
-                       continue;
-
-               /* allocate the buffer of active exception handlers */
-               /* XXX this wastes some memory, but probably it does not matter */
-
-               handlers = DMNEW(exception_entry*, mjd->exceptiontablelength + 1);
-
-               /* determine the active exception handlers for this block     */
-               /* XXX maybe the handlers of a block should be part of our IR */
-               /* XXX this should share code with the type checkers          */
-               nhandlers = 0;
-               for (ex = mjd->exceptiontable; ex ; ex = ex->down) {
-                       if ((ex->start->nr <= bptr->nr) && (ex->end->nr > bptr->nr)) {
-                               handlers[nhandlers++] = ex;
-                       }
-               }
-               handlers[nhandlers] = NULL;
-
-               len = bptr->icount;
-               iptr = bptr->iinstr;
-
-               blockendpc += len;
-               iln->cumul_instructioncount += len;
-
-               /* iterate over the instructions of the block */
-
-               for (; --len >= 0; ++iptr) {
-
-                       switch (iptr->opc) {
-                               case ICMD_INVOKEVIRTUAL:
-                               case ICMD_INVOKESPECIAL:
-                               case ICMD_INVOKESTATIC:
-                               case ICMD_INVOKEINTERFACE:
-
-                                       if (!INSTRUCTION_IS_UNRESOLVED(iptr) && !iln->ctx->stopped) {
-                                               callee = iptr->sx.s23.s3.fmiref->p.method;
-
-                                               if (inline_can_inline(iln, callee, iptr, &site)) {
-                                                       site.inlined = false;
-                                                       site.bptr = bptr;
-                                                       site.iptr = iptr;
-                                                       site.pc = blockendpc - len - 1;
-                                                       site.handlers = handlers;
-                                                       site.nhandlers = nhandlers;
-
-                                                       if (inline_pre_parse_heuristics(iln, callee, &site)) {
-#if defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST)
-                                                               inline_add_candidate(iln->ctx, iln, callee, &site);
-#else
-                                                               inline_candidate cand;
-                                                               cand.caller = iln;
-                                                               cand.callee = callee;
-                                                               cand.site   = site;
-
-                                                               if (!inline_process_candidate(&cand))
-                                                                       return false;
-#endif
-                                                       }
-                                               }
-                                       }
-                                       break;
-
-                               case ICMD_RETURN:
-                               case ICMD_IRETURN:
-                               case ICMD_ARETURN:
-                               case ICMD_LRETURN:
-                               case ICMD_FRETURN:
-                               case ICMD_DRETURN:
-                                       /* extra ICMD_MOVE may be necessary */
-                                       iln->cumul_instructioncount++;
-                                       break;
-                       }
-               }
-
-               /* end of basic block */
-       }
-
-       return true;
-}
-
-
-static void inline_cumulate_counters_recursive(inline_node *iln)
-{
-       inline_node *child;
-
-       child = iln->children;
-       if (child) {
-               do {
-                       inline_cumulate_counters_recursive(child);
-                       inline_cumulate_counters(iln, child);
-                       child = child->next;
-               } while (child != iln->children);
-       }
-}
-
-
-/* inline_make_inlining_plan ***************************************************
-
-   Make an inlining plan for the given root node
-
-   IN:
-       iln..............the root node
-
-   OUT:
-       *iln.............the inlining plan
-
-   RETURN VALUE:
-       true........everything ok
-          false.......an error has occurred, don't use the plan
-
-*******************************************************************************/
-
-#if defined(INLINE_KNAPSACK)
-static bool inline_make_inlining_plan(inline_node *iln)
-{
-       inline_candidate *cand;
-#if defined(INLINE_COST_BUDGET)
-       s4 budget = INLINE_COST_BUDGET;
-#   define BUDGETMEMBER cost
-#endif
-#if defined(INLINE_WEIGHT_BUDGET)
-       double budget = INLINE_WEIGHT_BUDGET;
-#   define BUDGETMEMBER weight
-#endif
-
-       inline_analyse_code(iln);
-
-       DOLOG( printf("candidates in "); method_println(iln->m);
-                  inline_candidates_println(iln->ctx); );
-
-       while ((cand = inline_pick_best_candidate(iln->ctx)) != NULL)
-       {
-               if (cand->BUDGETMEMBER <= budget) {
-                       DOLOG( printf("    picking: "); inline_candidate_println(cand); );
-
-                       if (!inline_process_candidate(cand))
-                               return false;
-
-#if !defined(INLINE_ADD_NEGATIVE_TO_BUDGET)
-                       if (cand->BUDGETMEMBER > 0)
-#endif
-                               budget -= cand->BUDGETMEMBER;
-               }
-       }
-
-       inline_cumulate_counters_recursive(iln);
-
-       return true;
-}
-#endif /* defined(INLINE_KNAPSACK) */
-
-
-#if defined(INLINE_DEPTH_FIRST)
-static bool inline_make_inlining_plan(inline_node *iln)
-{
-       return inline_analyse_code(iln);
-}
-#endif /* defined(INLINE_DEPTH_FIRST) */
-
-
-#if defined(INLINE_BREADTH_FIRST)
-static bool inline_make_inlining_plan(inline_node *iln)
-{
-       inline_candidate *cand;
-
-       inline_analyse_code(iln);
-
-       DOLOG( printf("candidates in "); method_println(iln->m);
-                  inline_candidates_println(iln->ctx); );
-
-       while (!iln->ctx->stopped
-                  && (cand = inline_pick_best_candidate(iln->ctx)) != NULL)
-       {
-               DOLOG( printf("    picking: "); inline_candidate_println(cand); );
-
-               if (!inline_process_candidate(cand))
-                       return false;
-       }
-
-       return true;
-}
-#endif /* defined(INLINE_BREADTH_FIRST) */
-
-
-/* statistics *****************************************************************/
-
-#if defined(INLINE_STATISTICS)
-static void inline_gather_statistics_recursive(inline_node *iln)
-{
-       inline_node *child;
-
-       inline_stat_inlined_nodes++;
-
-       if (iln->depth > inline_stat_max_depth)
-               inline_stat_max_depth++;
-
-       child = iln->children;
-       if (child) {
-               do {
-                       inline_gather_statistics_recursive(child);
-                       child = child->next;
-               } while (child != iln->children);
-       }
-}
-#endif /* defined(INLINE_STATISTICS) */
-
-
-#if defined(INLINE_STATISTICS)
-static void inline_gather_statistics(inline_node *iln)
-{
-       inline_stat_roots_transformed++;
-
-       inline_gather_statistics_recursive(iln);
-}
-#endif /* defined(INLINE_STATISTICS) */
-
-
-/* post processing ************************************************************/
-
-#define POSTPROCESS_SRC(varindex)  live[varindex]--
-#define POSTPROCESS_DST(varindex)  live[varindex]++
-
-#define POSTPROCESS_SRCOP(s)  POSTPROCESS_SRC(iptr->s.varindex)
-#define POSTPROCESS_DSTOP(d)  POSTPROCESS_DST(iptr->d.varindex)
-
-#define MARKSAVED(varindex)  jd->var[varindex].flags |= SAVEDVAR
-
-#define MARK_ALL_SAVED                                               \
-    do {                                                             \
-        for (i=0; i<jd->vartop; ++i)                                 \
-            if (live[i])                                             \
-                MARKSAVED(i);                                        \
-    } while (0)
-
-static void inline_post_process(jitdata *jd)
-{
-       codeinfo   *code;
-       basicblock *bptr;
-       instruction *iptr;
-       instruction *iend;
-       s4 i;
-       icmdtable_entry_t *icmdt;
-       s4 *live;
-       methoddesc *md;
-       builtintable_entry *bte;
-
-       /* Get required compiler data. */
-
-       code = jd->code;
-
-       /* reset the SAVEDVAR flag of all variables */
-
-       for (i=0; i<jd->vartop; ++i)
-               jd->var[i].flags &= ~SAVEDVAR;
-
-       /* allocate the life counters */
-
-       live = DMNEW(s4, jd->vartop);
-       MZERO(live, s4, jd->vartop);
-
-       /* iterate over all basic blocks */
-
-       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
-               if (bptr->flags < BBREACHED)
-                       continue;
-
-               /* make invars live */
-
-               for (i=0; i<bptr->indepth; ++i)
-                       POSTPROCESS_DST(bptr->invars[i]);
-
-               iptr = bptr->iinstr;
-               iend = iptr + bptr->icount;
-
-               for (; iptr < iend; ++iptr) {
-
-                       icmdt = &(icmd_table[iptr->opc]);
-
-                       switch (icmdt->dataflow) {
-                               case DF_3_TO_0:
-                                       POSTPROCESS_SRCOP(sx.s23.s3);
-                               case DF_2_TO_0:
-                                       POSTPROCESS_SRCOP(sx.s23.s2);
-                               case DF_1_TO_0:
-                                       POSTPROCESS_SRCOP(s1);
-                               case DF_0_TO_0:
-                                       if (icmdt->flags & ICMDTABLE_CALLS) {
-                                               code_unflag_leafmethod(code);
-                                               MARK_ALL_SAVED;
-                                       }
-                                       break;
-
-                               case DF_2_TO_1:
-                                       POSTPROCESS_SRCOP(sx.s23.s2);
-                               case DF_1_TO_1:
-                               case DF_MOVE:
-                                       POSTPROCESS_SRCOP(s1);
-                               case DF_0_TO_1:
-                                       if (icmdt->flags & ICMDTABLE_CALLS) {
-                                               code_unflag_leafmethod(code);
-                                               MARK_ALL_SAVED;
-                                       }
-                               case DF_COPY:
-                                       POSTPROCESS_DSTOP(dst);
-                                       break;
-
-                               case DF_N_TO_1:
-                                       for (i=0; i<iptr->s1.argcount; ++i) {
-                                               POSTPROCESS_SRC(iptr->sx.s23.s2.args[i]);
-                                       }
-                                       if (icmdt->flags & ICMDTABLE_CALLS) {
-                                               code_unflag_leafmethod(code);
-                                               MARK_ALL_SAVED;
-                                       }
-                                       POSTPROCESS_DSTOP(dst);
-                                       break;
-
-                               case DF_INVOKE:
-                                       INSTRUCTION_GET_METHODDESC(iptr, md);
-               post_process_call:
-                                       code_unflag_leafmethod(code);
-                                       for (i=0; i<md->paramcount; ++i) {
-                                               POSTPROCESS_SRC(iptr->sx.s23.s2.args[i]);
-                                       }
-                                       for (; i<iptr->s1.argcount; ++i) {
-                                               MARKSAVED(iptr->sx.s23.s2.args[i]);
-                                       }
-                                       if (md->returntype.type != TYPE_VOID)
-                                               POSTPROCESS_DSTOP(dst);
-                                       break;
-
-                               case DF_BUILTIN:
-                                       bte = iptr->sx.s23.s3.bte;
-                                       md = bte->md;
-                                       goto post_process_call;
-
-                               default:
-                                       assert(0);
-                       }
-
-               } /* end instruction loop */
-
-               /* consume outvars */
-
-               for (i=0; i<bptr->outdepth; ++i)
-                       POSTPROCESS_SRC(bptr->outvars[i]);
-
-#if !defined(NDEBUG)
-               for (i=jd->localcount; i < jd->vartop; ++i)
-                       assert(live[i] == 0);
-#endif
-
-       } /* end basic block loop */
-}
-
-
-/* inline_create_root_node *****************************************************
-
-   Create the root node of the inlining tree.
-
-   IN:
-          jd...............the current jitdata of the root method
-
-   RETURN VALUE:
-       the root node of the inlining tree
-
-*******************************************************************************/
-
-static inline_node * inline_create_root_node(jitdata *jd)
-{
-       inline_node *iln;
-
-       iln = DNEW(inline_node);
-       MZERO(iln, inline_node, 1);
-
-       iln->m = jd->m;
-       iln->jd = jd;
-       iln->regdata = jd->rd;
-
-       iln->blockbefore = true;
-       iln->blockafter = true;
-
-       iln->cumul_instructioncount = 0;
-       iln->cumul_basicblockcount = 1 /* dummy end block */;
-
-       /* create inlining context */
-
-       iln->ctx = DNEW(inline_context);
-       MZERO(iln->ctx, inline_context, 1);
-       iln->ctx->master = iln;
-       iln->ctx->next_debugnr = 1; /* XXX debug */
-
-       return iln;
-}
-
-
-/******************************************************************************/
-/* MAIN DRIVER FUNCTION                                                       */
-/******************************************************************************/
-
-bool inline_inline(jitdata *jd)
-{
-       inline_node *iln;
-
-       DOLOG( printf("==== INLINE ==================================================================\n");
-                  show_method(jd, SHOW_STACK); );
-
-#if defined(INLINE_STATISTICS)
-       inline_stat_roots++;
-#endif
-
-       iln = inline_create_root_node(jd);
-
-       if (inline_make_inlining_plan(iln)) {
-
-               /* add blocks to the root node */
-
-               iln->cumul_basicblockcount += iln->cumul_basicblockcount_root;
-               iln->cumul_blockmapcount   += iln->cumul_basicblockcount_root;
-
-               DOLOG( printf("==== INLINE TRANSFORM ========================================================\n"); );
-
-               if (iln->children)
-                       inline_transform(iln, jd);
-
-#if defined(INLINE_STATISTICS)
-               inline_gather_statistics(iln);
-#endif
-       }
-
-       DOLOG( printf("-------- DONE -----------------------------------------------------------\n");
-                  fflush(stdout); );
-
-       return true;
-}
-
-/*
- * 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/jit/inline/inline.cpp b/src/vm/jit/inline/inline.cpp
new file mode 100644 (file)
index 0000000..73c8667
--- /dev/null
@@ -0,0 +1,3244 @@
+/* src/vm/jit/inline/inline.c - method inlining
+
+   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 <limits.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "threads/lock.hpp"
+#include "threads/mutex.hpp"
+#include "threads/thread.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/initialize.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/statistics.h"
+
+#include "vm/jit/jit.hpp"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/reg.h"
+#include "vm/jit/show.hpp"
+#include "vm/jit/stack.h"
+
+#include "vm/jit/inline/inline.hpp"
+#include "vm/jit/loop/loop.h"
+
+#include "vm/jit/verify/typecheck.hpp"
+
+
+/* algorithm tuning constants *************************************************/
+
+/* Algorithm Selection                                                        */
+/* Define exactly one of the following three to select the inlining           */
+/* heuristics.                                                                */
+
+/*#define INLINE_DEPTH_FIRST*/
+/*#define INLINE_BREADTH_FIRST*/
+#define INLINE_KNAPSACK
+
+/* Parameters for knapsack heuristics:                                        */
+
+#if defined(INLINE_KNAPSACK)
+
+#define INLINE_COUNTDOWN_INIT       1000
+#define INLINE_COST_OFFSET          -16
+#define INLINE_COST_BUDGET          100
+/*#define INLINE_WEIGHT_BUDGET        5.0*/
+/*#define INLINE_ADD_NEGATIVE_TO_BUDGET*/
+/*#define INLINE_MAX_DEPTH            3*/
+/*#define INLINE_DIVIDE_COST_BY_FREQ */
+
+#endif
+
+/* Parameters for depth-first heuristics:                                     */
+
+#if defined(INLINE_DEPTH_FIRST)
+
+#define INLINE_MAX_DEPTH            3
+#define INLINE_MAX_BLOCK_EXPANSION  10
+/*#define INLINE_MAX_ICMD_EXPANSION  10*/
+/*#define INLINE_CANCEL_ON_THRESHOLD*/
+
+#endif
+
+/* Parameters for breadth-first heuristics:                                   */
+
+#if defined(INLINE_BREADTH_FIRST)
+
+/*#define INLINE_MAX_BLOCK_EXPANSION  10*/
+#define INLINE_MAX_ICMD_EXPANSION  5
+
+#endif
+
+
+/* debugging ******************************************************************/
+
+#if !defined(NDEBUG)
+#define INLINE_VERBOSE
+#define DOLOG(code)       do{ if (opt_TraceInlining >= 2) { code; } }while(0)
+#define DOLOG_SHORT(code) do{ if (opt_TraceInlining >= 1) { code; } }while(0)
+#else
+#define DOLOG(code)
+#endif
+
+#if defined(ENABLE_VERIFIER) && !defined(NDEBUG)
+/* Define this to verify the resulting code after inlining.                 */
+/* Note: This is only useful for development and may require patches to the */
+/*       verifier code.                                                     */
+/* #define INLINE_VERIFY_RESULT */
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* types **********************************************************************/
+
+typedef struct inline_node inline_node;
+typedef struct inline_target_ref inline_target_ref;
+typedef struct inline_context inline_context;
+typedef struct inline_block_map inline_block_map;
+typedef struct inline_site inline_site;
+typedef struct inline_candidate inline_candidate;
+
+struct inline_node {
+       inline_context *ctx;
+
+       jitdata *jd;
+       methodinfo *m;
+       inline_node *children;
+       inline_node *next;                             /* next node at this depth */
+       inline_node *prev;                             /* prev node at this depth */
+       int depth;                                  /* inlining depth, 0 for root */
+
+       /* info about the call site (if depth > 0)*/
+       inline_node *parent;                /* node of the caller (NULL for root) */
+       basicblock *callerblock;         /* original block containing the INVOKE* */
+       instruction *callerins;               /* the original INVOKE* instruction */
+       s4 callerpc;
+       s4 *n_passthroughvars;
+       int n_passthroughcount;
+       int n_selfpassthroughcount;  /* # of pass-through vars of the call itself */
+       exception_entry **o_handlers;
+       int n_handlercount;                 /* # of handlers protecting this call */
+       int n_resultlocal;
+       int synclocal;                    /* variable used for synchr., or UNUSED */
+       bool isstatic;                                   /* this is a static call */
+
+       bool blockbefore;                  /* block boundary before inlined body? */
+       bool blockafter;                   /* block boundary after inlined body?  */
+
+       /* info about the callee */
+       int localsoffset;
+       int prolog_instructioncount;         /* # of ICMDs in the inlining prolog */
+       int epilog_instructioncount;         /* # of ICMDs in the inlining epilog */
+       int extra_instructioncount;
+       int extra_exceptiontablelength;   /* # of extra handlers to put in caller */
+       bool synchronize;                /* do we have to synchronize enter/exit? */
+       basicblock *handler_monitorexit;     /* handler for synchronized inlinees */
+       s4 *varmap;
+
+       /* cumulative values */
+       int cumul_instructioncount;  /* ICMDs in this node and its children       */
+       int cumul_basicblockcount;   /* BBs started by this node and its children */
+       int cumul_basicblockcount_root;  /* BBs that have to be added to the root */
+                                        /* node if this node is inlined          */
+       int cumul_blockmapcount;
+       int cumul_maxlocals;
+       int cumul_exceptiontablelength;
+
+       /* output */
+       instruction *inlined_iinstr;
+       instruction *inlined_iinstr_cursor;
+       basicblock *inlined_basicblocks;
+       basicblock *inlined_basicblocks_cursor;
+
+       /* register data */
+       registerdata *regdata;
+
+       /* temporary */
+       inline_target_ref *refs;
+       instruction *inline_start_instruction;
+       s4 *javalocals;
+
+       /* XXX debug */
+       char *indent;
+       int debugnr;
+};
+
+struct inline_target_ref {
+       inline_target_ref *next;
+       union {
+               basicblock **block;
+               s4 *nr;
+       } ref;
+       basicblock *target;
+       bool isnumber;
+};
+
+struct inline_block_map {
+       inline_node *iln;
+       basicblock *o_block;
+       basicblock *n_block;
+};
+
+struct inline_context {
+       inline_node *master;
+
+       jitdata *resultjd;
+
+       inline_candidate *candidates;
+
+       int next_block_number;
+       inline_block_map *blockmap;
+       int blockmap_index;
+
+       int maxinoutdepth;
+
+       bool stopped;
+
+       int next_debugnr; /* XXX debug */
+};
+
+struct inline_site {
+       bool              speculative;  /* true, if inlining would be speculative */
+       bool              inlined;      /* true, if this site has been inlined    */
+
+       basicblock       *bptr;         /* basic block containing the call site   */
+       instruction      *iptr;         /* the invocation instruction             */
+       exception_entry **handlers;     /* active handlers at the call site       */
+       s4                nhandlers;    /* number of active handlers              */
+       s4                pc;           /* PC of the invocation instruction       */
+};
+
+struct inline_candidate {
+       inline_candidate *next;
+       int freq;
+       int cost;
+       double weight;
+       inline_node *caller;
+       methodinfo *callee;
+       inline_site site;
+};
+
+
+/* prototypes *****************************************************************/
+
+static bool inline_analyse_code(inline_node *iln);
+static void inline_post_process(jitdata *jd);
+
+
+/* debug helpers **************************************************************/
+
+#if !defined(NDEBUG)
+#include "inline_debug.inc"
+#endif
+
+
+/* statistics *****************************************************************/
+
+/*#define INLINE_STATISTICS*/
+
+#if !defined(NDEBUG)
+#define INLINE_STATISTICS
+#endif
+
+#if defined(INLINE_STATISTICS)
+int inline_stat_roots = 0;
+int inline_stat_roots_transformed = 0;
+int inline_stat_inlined_nodes = 0;
+int inline_stat_max_depth = 0;
+
+void inline_print_stats()
+{
+       printf("inlining statistics:\n");
+       printf("    roots analysed   : %d\n", inline_stat_roots);
+       printf("    roots transformed: %d\n", inline_stat_roots_transformed);
+       printf("    inlined nodes    : %d\n", inline_stat_inlined_nodes);
+       printf("    max depth        : %d\n", inline_stat_max_depth);
+}
+#endif
+
+
+/* compilation of callees *****************************************************/
+
+static bool inline_jit_compile_intern(jitdata *jd)
+{
+       methodinfo *m;
+
+       /* XXX should share code with jit.c */
+
+       assert(jd);
+
+       /* XXX initialize the static function's class */
+
+       m = jd->m;
+
+       /* call the compiler passes ***********************************************/
+
+       /* call parse pass */
+
+       DOLOG( log_message_class("Parsing ", m->clazz) );
+       if (!parse(jd)) {
+               return false;
+       }
+
+       /* call stack analysis pass */
+
+       if (!stack_analyse(jd)) {
+               return false;
+       }
+
+       return true;
+}
+
+
+static bool inline_jit_compile(inline_node *iln)
+{
+       bool                r;
+       methodinfo         *m;
+       jitdata            *jd;
+
+       /* XXX should share code with jit.c */
+
+       assert(iln);
+       m = iln->m;
+       assert(m);
+
+       /* enter a monitor on the method */
+
+       m->mutex->lock();
+
+       /* allocate jitdata structure and fill it */
+
+       jd = jit_jitdata_new(m);
+       iln->jd = jd;
+
+       jd->flags = 0; /* XXX */
+
+       /* initialize the register allocator */
+
+       reg_setup(jd);
+
+       /* setup the codegendata memory */
+
+       /* XXX do a pseudo setup */
+       jd->cd = (codegendata*) DumpMemory::allocate(sizeof(codegendata));
+       MZERO(jd->cd, codegendata, 1);
+       jd->cd->method = m;
+       /* XXX uses too much dump memory codegen_setup(jd); */
+
+       /* now call internal compile function */
+
+       r = inline_jit_compile_intern(jd);
+
+       if (r) {
+               iln->regdata = jd->rd;
+       }
+
+       /* free some memory */
+#if 0
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (!opt_intrp)
+# endif
+               codegen_free(jd);
+#endif
+
+#endif
+
+       /* leave the monitor */
+
+       m->mutex->unlock();
+
+       return r;
+}
+
+
+/* inlining tree handling *****************************************************/
+
+static void inline_insert_inline_node(inline_node *parent, inline_node *child)
+{
+       inline_node *first;
+       inline_node *succ;
+
+       assert(parent && child);
+
+       child->parent = parent;
+
+       child->debugnr = parent->ctx->next_debugnr++; /* XXX debug */
+
+       first = parent->children;
+       if (!first) {
+               /* insert as only node */
+               parent->children = child;
+               child->next = child;
+               child->prev = child;
+               return;
+       }
+
+       /* {there is at least one child already there} */
+
+       /* XXX is this search necessary, or could we always add at the end? */
+
+       succ = first;
+       while (succ->callerpc < child->callerpc) {
+               succ = succ->next;
+               if (succ == first) {
+                       /* insert as last node */
+                       child->prev = first->prev;
+                       child->next = first;
+                       child->prev->next = child;
+                       child->next->prev = child;
+                       return;
+               }
+       }
+
+       assert(succ->callerpc > child->callerpc);
+
+       /* insert before succ */
+
+       child->prev = succ->prev;
+       child->next = succ;
+       child->prev->next = child;
+       child->next->prev = child;
+
+       if (parent->children == succ)
+               parent->children = child;
+}
+
+
+static void inline_remove_inline_node(inline_node *parent, inline_node *child)
+{
+       assert(parent);
+       assert(child);
+       assert(child->parent == parent);
+
+       if (child->prev == child) {
+               /* remove the only child node */
+               parent->children = NULL;
+       }
+       else {
+               child->prev->next = child->next;
+               child->next->prev = child->prev;
+
+               if (parent->children == child)
+                       parent->children = child->next;
+       }
+}
+
+
+/* inlining candidate handling ************************************************/
+
+#if defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST)
+static void inline_add_candidate(inline_context *ctx,
+                                                                inline_node *caller,
+                                                                methodinfo *callee,
+                                                                inline_site *site)
+{
+       inline_candidate **link;
+       inline_candidate *cand;
+
+       cand = (inline_candidate*) DumpMemory::allocate(sizeof(inline_candidate));
+#if defined(INLINE_DIVIDE_COST_BY_FREQ)
+       cand->freq = INLINE_COUNTDOWN_INIT - callee->hitcountdown;
+       if (cand->freq < 1)
+#endif
+               cand->freq = 1;
+#if defined(INLINE_KNAPSACK)
+       cand->cost = callee->jcodelength + INLINE_COST_OFFSET;
+#endif
+#if defined(INLINE_BREADTH_FIRST)
+       cand->cost = caller->depth;
+#endif
+       cand->caller = caller;
+       cand->callee = callee;
+       cand->site = *site;
+
+       cand->weight = (double)cand->cost / cand->freq;
+
+       for (link = &(ctx->candidates); ; link = &((*link)->next)) {
+               if (!*link || (*link)->weight > cand->weight) {
+                       cand->next = *link;
+                       *link = cand;
+                       break;
+               }
+       }
+}
+#endif /* defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST) */
+
+#if defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST)
+static inline_candidate * inline_pick_best_candidate(inline_context *ctx)
+{
+       inline_candidate *cand;
+
+       cand = ctx->candidates;
+
+       if (cand)
+               ctx->candidates = cand->next;
+
+       return cand;
+}
+#endif /* defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST) */
+
+#if !defined(NDEBUG) && (defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST))
+static void inline_candidate_println(inline_candidate *cand)
+{
+       printf("%10g (%5d / %5d) depth %2d ",
+                       cand->weight, cand->cost, cand->freq, cand->caller->depth + 1);
+       method_println(cand->callee);
+}
+#endif /* !defined(NDEBUG) && (defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST)) */
+
+
+#if !defined(NDEBUG) && (defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST))
+static void inline_candidates_println(inline_context *ctx)
+{
+       inline_candidate *cand;
+
+       for (cand = ctx->candidates; cand != NULL; cand = cand->next) {
+               printf("    ");
+               inline_candidate_println(cand);
+       }
+}
+#endif /* !defined(NDEBUG) && (defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST)) */
+
+
+/* variable handling **********************************************************/
+
+static s4 inline_new_variable(jitdata *jd, s4 type, s4 flags)
+{
+       s4 index;
+       s4 newcount;
+
+       index = jd->vartop++;
+       if (index >= jd->varcount) {
+               newcount = jd->vartop * 2; /* XXX */
+               jd->var = (varinfo*) DumpMemory::reallocate(jd->var, sizeof(varinfo) * jd->varcount, sizeof(varinfo) * newcount);
+               MZERO(jd->var + jd->varcount, varinfo, (newcount - jd->varcount));
+               jd->varcount = newcount;
+       }
+
+       jd->var[index].type = type;
+       jd->var[index].flags = flags;
+
+       return index;
+}
+
+
+static s4 inline_new_variable_clone(jitdata *jd, jitdata *origjd, s4 origidx)
+{
+       varinfo *v;
+       s4       newidx;
+
+       v = &(origjd->var[origidx]);
+
+       newidx = inline_new_variable(jd, v->type, v->flags);
+
+       jd->var[newidx].vv = v->vv;
+
+       return newidx;
+}
+
+
+static s4 inline_new_temp_variable(jitdata *jd, s4 type)
+{
+       return inline_new_variable(jd, type, 0);
+}
+
+
+static s4 inline_translate_variable(jitdata *jd, jitdata *origjd, s4 *varmap, s4 index)
+{
+       s4 idx;
+
+       idx = varmap[index];
+
+       if (idx < 0) {
+               idx = inline_new_variable_clone(jd, origjd, index);
+               varmap[index] = idx;
+       }
+
+       return idx;
+}
+
+
+static s4 *create_variable_map(inline_node *callee)
+{
+       s4 *varmap;
+       s4 i, t;
+       s4 varindex;
+       s4 n_javaindex;
+       s4 avail;
+       varinfo *v;
+
+       /* create the variable mapping */
+
+       varmap = (s4*) DumpMemory::allocate(sizeof(s4) * callee->jd->varcount);
+       for (i=0; i<callee->jd->varcount; ++i)
+               varmap[i] = -1;
+
+       /* translate local variables */
+
+       for (i=0; i<callee->m->maxlocals; ++i) {
+               for (t=0; t<5; ++t) {
+                       varindex = callee->jd->local_map[5*i + t];
+                       if (varindex == UNUSED)
+                               continue;
+
+                       v = &(callee->jd->var[varindex]);
+                       assert(v->type == t || v->type == TYPE_VOID); /* XXX stack leaves VOID */
+                       v->type = t; /* XXX restore if it is TYPE_VOID */
+
+                       avail = callee->ctx->resultjd->local_map[5*(callee->localsoffset + i) + t];
+
+                       if (avail == UNUSED) {
+                               avail = inline_new_variable_clone(callee->ctx->resultjd, callee->jd, varindex);
+                               callee->ctx->resultjd->local_map[5*(callee->localsoffset + i) + t] = avail;
+                       }
+
+                       varmap[varindex] = avail;
+               }
+       }
+
+       /* for synchronized instance methods we need an extra local */
+
+       if (callee->synchronize && !(callee->m->flags & ACC_STATIC)) {
+               n_javaindex = callee->localsoffset - 1;
+               assert(n_javaindex >= 0);
+               assert(callee->parent);
+               assert(n_javaindex == callee->parent->localsoffset + callee->parent->m->maxlocals);
+
+               avail = callee->ctx->resultjd->local_map[5*n_javaindex + TYPE_ADR];
+
+               if (avail == UNUSED) {
+                       avail = inline_new_variable(callee->ctx->resultjd, TYPE_ADR, 0);
+                       callee->ctx->resultjd->local_map[5*n_javaindex + TYPE_ADR] = avail;
+               }
+
+               callee->synclocal = avail;
+       }
+       else {
+               callee->synclocal = UNUSED;
+       }
+
+       return varmap;
+}
+
+
+/* basic block translation ****************************************************/
+
+#define INLINE_RETURN_REFERENCE(callee)  \
+       ( (basicblock *) (ptrint) (0x333 + (callee)->depth) )
+
+
+static void inline_add_block_reference(inline_node *iln, basicblock **blockp)
+{
+       inline_target_ref *ref;
+
+       ref = (inline_target_ref*) DumpMemory::allocate(sizeof(inline_target_ref));
+       ref->ref.block = blockp;
+       ref->isnumber = false;
+       ref->next = iln->refs;
+       iln->refs = ref;
+}
+
+
+#if 0
+static void inline_add_blocknr_reference(inline_node *iln, s4 *nrp)
+{
+       inline_target_ref *ref;
+
+       ref = (inline_target_ref*) DumpMemory::allocate(inline_target_ref);
+       ref->ref.nr = nrp;
+       ref->isnumber = true;
+       ref->next = iln->refs;
+       iln->refs = ref;
+}
+#endif
+
+
+static void inline_block_translation(inline_node *iln, basicblock *o_bptr, basicblock *n_bptr)
+{
+       inline_context *ctx;
+
+       ctx = iln->ctx;
+       assert(ctx->blockmap_index < ctx->master->cumul_blockmapcount);
+
+       ctx->blockmap[ctx->blockmap_index].iln = iln;
+       ctx->blockmap[ctx->blockmap_index].o_block = o_bptr;
+       ctx->blockmap[ctx->blockmap_index].n_block = n_bptr;
+
+       ctx->blockmap_index++;
+}
+
+
+static basicblock * inline_map_block(inline_node *iln,
+                                                                        basicblock *o_block,
+                                                                        inline_node *targetiln)
+{
+       inline_block_map *bm;
+       inline_block_map *bmend;
+
+       assert(iln);
+       assert(targetiln);
+
+       if (!o_block)
+               return NULL;
+
+       bm = iln->ctx->blockmap;
+       bmend = bm + iln->ctx->blockmap_index;
+
+       while (bm < bmend) {
+               assert(bm->iln && bm->o_block && bm->n_block);
+               if (bm->o_block == o_block && bm->iln == targetiln)
+                       return bm->n_block;
+               bm++;
+       }
+
+       assert(false);
+       return NULL; /* not reached */
+}
+
+
+static void inline_resolve_block_refs(inline_target_ref **refs,
+                                                                         basicblock *o_bptr,
+                                                                         basicblock *n_bptr,
+                                                                         bool returnref)
+{
+       inline_target_ref *ref;
+       inline_target_ref *prev;
+
+       prev = NULL;
+       for (ref = *refs; ref != NULL; ref = ref->next) {
+               if (ref->isnumber && !returnref) {
+                       if (*(ref->ref.nr) == JAVALOCAL_FROM_RETADDR(o_bptr->nr)) {
+                               *(ref->ref.nr) = JAVALOCAL_FROM_RETADDR(n_bptr->nr);
+                               goto remove_ref;
+                       }
+               }
+               else {
+                       if (*(ref->ref.block) == o_bptr) {
+                               *(ref->ref.block) = n_bptr;
+                               goto remove_ref;
+                       }
+               }
+
+               /* skip this ref */
+
+               prev = ref;
+               continue;
+
+remove_ref:
+               /* remove this ref */
+
+               if (prev) {
+                       prev->next = ref->next;
+               }
+               else {
+                       *refs = ref->next;
+               }
+       }
+}
+
+
+/* basic block creation *******************************************************/
+
+static basicblock * create_block(inline_node *container,
+                                                                inline_node *iln,
+                                                                inline_node *inner,
+                                                                int indepth)
+{
+       basicblock  *n_bptr;
+       inline_node *outer;
+       s4           i;
+       s4           depth;
+       s4           varidx;
+       s4           newvaridx;
+
+       assert(container);
+       assert(iln);
+       assert(inner);
+       assert(indepth >= 0);
+
+       n_bptr = container->inlined_basicblocks_cursor++;
+       assert(n_bptr);
+       assert((n_bptr - container->inlined_basicblocks) < container->cumul_basicblockcount);
+
+       BASICBLOCK_INIT(n_bptr, iln->m);
+
+       n_bptr->iinstr = container->inlined_iinstr_cursor;
+       n_bptr->next = n_bptr + 1;
+       n_bptr->nr = container->ctx->next_block_number++;
+       n_bptr->indepth = indepth;
+       n_bptr->flags = BBFINISHED; /* XXX */
+
+       /* set the inlineinfo of the new block */
+
+       if (iln->inline_start_instruction)
+               n_bptr->inlineinfo = iln->inline_start_instruction->sx.s23.s3.inlineinfo;
+
+       if (indepth > container->ctx->maxinoutdepth)
+               container->ctx->maxinoutdepth = indepth;
+
+       if (indepth) {
+               n_bptr->invars = (s4*) DumpMemory::allocate(sizeof(s4) * indepth);
+
+
+               for (i=0; i<indepth; ++i)
+                       n_bptr->invars[i] = -1; /* XXX debug */
+
+               /* pass-through variables enter the block */
+
+               outer = inner->parent;
+               while (outer != NULL) {
+                       depth = outer->n_passthroughcount;
+
+                       assert(depth + inner->n_selfpassthroughcount <= indepth);
+
+                       for (i=0; i<inner->n_selfpassthroughcount; ++i) {
+                               varidx = inner->n_passthroughvars[i];
+                               newvaridx =
+                                       inline_new_variable_clone(container->ctx->resultjd,
+                                                                                         outer->jd,
+                                                                                         varidx);
+                               n_bptr->invars[depth + i] = newvaridx;
+                               outer->varmap[varidx] = newvaridx;
+                       }
+                       inner = outer;
+                       outer = outer->parent;
+               }
+       }
+       else {
+               n_bptr->invars = NULL;
+       }
+
+       /* XXX for the verifier. should not be here */
+
+       {
+               varinfo *dv;
+
+               dv = (varinfo*) DumpMemory::allocate(sizeof(varinfo) * (iln->ctx->resultjd->localcount + VERIFIER_EXTRA_LOCALS));
+               MZERO(dv, varinfo,  iln->ctx->resultjd->localcount + VERIFIER_EXTRA_LOCALS);
+               n_bptr->inlocals = dv;
+       }
+
+       return n_bptr;
+}
+
+
+static s4 *translate_javalocals(inline_node *iln, s4 *javalocals)
+{
+       s4 *jl;
+       s4 i, j;
+
+       jl = (s4*) DumpMemory::allocate(sizeof(s4) * iln->jd->maxlocals);
+
+       for (i=0; i<iln->jd->maxlocals; ++i) {
+               j = javalocals[i];
+               if (j > UNUSED)
+                       j = inline_translate_variable(iln->ctx->resultjd, iln->jd, iln->varmap, j);
+               jl[i] = j;
+
+#if 0
+               if (j < UNUSED) {
+                       /* an encoded returnAddress value - must be relocated */
+                       inline_add_blocknr_reference(iln, &(jl[i]));
+               }
+#endif
+       }
+
+       return jl;
+}
+
+
+static basicblock * create_body_block(inline_node *iln,
+                                                                         basicblock *o_bptr, s4 *varmap)
+{
+       basicblock *n_bptr;
+       s4 i;
+
+       n_bptr = create_block(iln, iln, iln,
+                                                 o_bptr->indepth + iln->n_passthroughcount);
+
+       n_bptr->type = o_bptr->type;
+       n_bptr->flags = o_bptr->flags;
+       n_bptr->bitflags = o_bptr->bitflags;
+
+       /* resolve references to this block */
+
+       inline_resolve_block_refs(&(iln->refs), o_bptr, n_bptr, false);
+
+       /* translate the invars of the original block */
+
+       for (i=0; i<o_bptr->indepth; ++i) {
+               n_bptr->invars[iln->n_passthroughcount + i] =
+                       inline_translate_variable(iln->ctx->resultjd, iln->jd,
+                               varmap,
+                               o_bptr->invars[i]);
+       }
+
+       /* translate javalocals info (not for dead code) */
+
+       if (n_bptr->flags >= BBREACHED)
+               n_bptr->javalocals = translate_javalocals(iln, o_bptr->javalocals);
+
+       return n_bptr;
+}
+
+
+static basicblock * create_epilog_block(inline_node *caller, inline_node *callee, s4 *varmap)
+{
+       basicblock *n_bptr;
+       s4 retcount;
+       s4 idx;
+
+       /* number of return variables */
+
+       retcount = (callee->n_resultlocal == -1
+                               && callee->m->parseddesc->returntype.type != TYPE_VOID) ? 1 : 0;
+
+       /* start the epilog block */
+
+       n_bptr = create_block(caller, caller, callee,
+                                                 callee->n_passthroughcount + retcount);
+
+       /* resolve references to the return block */
+
+       inline_resolve_block_refs(&(callee->refs),
+                                                         INLINE_RETURN_REFERENCE(callee),
+                                                         n_bptr,
+                                                         true);
+
+       /* return variable */
+
+       if (retcount) {
+               idx = inline_new_variable(caller->ctx->resultjd,
+                          callee->m->parseddesc->returntype.type, 0 /* XXX */);
+               n_bptr->invars[callee->n_passthroughcount] = idx;
+               varmap[callee->callerins->dst.varindex] = idx;
+       }
+
+       /* set javalocals */
+
+       n_bptr->javalocals = (s4*) DumpMemory::allocate(sizeof(s4) * caller->jd->maxlocals);
+       MCOPY(n_bptr->javalocals, caller->javalocals, s4, caller->jd->maxlocals);
+
+       /* set block flags & type */
+
+       n_bptr->flags = /* XXX original block flags */ BBFINISHED;
+       n_bptr->type = BBTYPE_STD;
+
+       return n_bptr;
+}
+
+
+static void close_block(inline_node *iln, inline_node *inner, basicblock *n_bptr, s4 outdepth)
+{
+       inline_node *outer;
+       s4           i;
+       s4           depth;
+       s4           varidx;
+
+       n_bptr->outdepth = outdepth;
+       n_bptr->outvars = (s4*) DumpMemory::allocate(sizeof(s4) * outdepth);
+
+       for (i=0; i<outdepth; ++i)
+               n_bptr->outvars[i] = 0; /* XXX debug */
+
+       if (outdepth > iln->ctx->maxinoutdepth)
+               iln->ctx->maxinoutdepth = outdepth;
+
+       /* pass-through variables leave the block */
+
+       outer = inner->parent;
+       while (outer != NULL) {
+               depth = outer->n_passthroughcount;
+
+               assert(depth + inner->n_selfpassthroughcount <= outdepth);
+
+               for (i=0; i<inner->n_selfpassthroughcount; ++i) {
+                       varidx = inner->n_passthroughvars[i];
+                       n_bptr->outvars[depth + i] =
+                               inline_translate_variable(iln->ctx->resultjd,
+                                                                                 outer->jd,
+                                                                                 outer->varmap,
+                                                                                 varidx);
+               }
+               inner = outer;
+               outer = outer->parent;
+       }
+}
+
+
+static void close_prolog_block(inline_node *iln,
+                                                          basicblock *n_bptr,
+                                                          inline_node *nextcall)
+{
+       /* XXX add original outvars! */
+       close_block(iln, nextcall, n_bptr, nextcall->n_passthroughcount);
+
+       /* pass-through variables */
+
+       DOLOG( printf("closed prolog block:\n");
+                  show_basicblock(iln->ctx->resultjd, n_bptr, SHOW_STACK); );
+}
+
+
+static void close_body_block(inline_node *iln,
+                                                        basicblock *n_bptr,
+                                                        basicblock *o_bptr,
+                                                        s4 *varmap,
+                                                        s4 retcount,
+                                                        s4 retidx)
+{
+       s4 i;
+
+       close_block(iln, iln, n_bptr, iln->n_passthroughcount + o_bptr->outdepth + retcount);
+
+       /* translate the outvars of the original block */
+
+       /* XXX reuse code */
+       for (i=0; i<o_bptr->outdepth; ++i) {
+               n_bptr->outvars[iln->n_passthroughcount + i] =
+                       inline_translate_variable(iln->ctx->resultjd, iln->jd, varmap,
+                                       o_bptr->outvars[i]);
+       }
+
+       /* set the return variable, if any */
+
+       if (retcount) {
+               assert(retidx >= 0);
+               n_bptr->outvars[iln->n_passthroughcount + o_bptr->outdepth] = retidx;
+       }
+}
+
+
+/* inlined code generation ****************************************************/
+
+static instruction * inline_instruction(inline_node *iln,
+                                                                               s4 opcode,
+                                                                               instruction *o_iptr)
+{
+       instruction *n_iptr;
+
+       n_iptr = (iln->inlined_iinstr_cursor++);
+       assert((n_iptr - iln->inlined_iinstr) < iln->cumul_instructioncount);
+
+       n_iptr->opc = opcode;
+       n_iptr->flags.bits = o_iptr->flags.bits & INS_FLAG_ID_MASK;
+       n_iptr->line = o_iptr->line;
+
+       return n_iptr;
+}
+
+static void inline_generate_sync_builtin(inline_node *iln,
+                                                                                inline_node *callee,
+                                                                                instruction *o_iptr,
+                                                                                s4 instancevar,
+                                                                                functionptr func)
+{
+       int          syncvar;
+       instruction *n_ins;
+
+       if (callee->m->flags & ACC_STATIC) {
+               /* ACONST */
+               syncvar = inline_new_temp_variable(iln->ctx->resultjd, TYPE_ADR);
+
+               n_ins = inline_instruction(iln, ICMD_ACONST, o_iptr);
+               n_ins->sx.val.c.cls = callee->m->clazz;
+               n_ins->dst.varindex = syncvar;
+               n_ins->flags.bits |= INS_FLAG_CLASS;
+       }
+       else {
+               syncvar = instancevar;
+       }
+
+       assert(syncvar != UNUSED);
+
+       /* MONITORENTER / MONITOREXIT */
+
+       n_ins = inline_instruction(iln, ICMD_BUILTIN, o_iptr);
+       n_ins->sx.s23.s3.bte = builtintable_get_internal(func);
+       n_ins->s1.argcount = 1; /* XXX add through-vars */
+       n_ins->sx.s23.s2.args = (s4*) DumpMemory::allocate(sizeof(s4));
+       n_ins->sx.s23.s2.args[0] = syncvar;
+}
+
+static s4 emit_inlining_prolog(inline_node *iln,
+                                                          inline_node *callee,
+                                                          instruction *o_iptr,
+                                                          s4 *varmap)
+{
+       methodinfo *calleem;
+       methoddesc *md;
+       int i;
+       int localindex;
+       int type;
+       instruction *n_ins;
+       insinfo_inline *insinfo;
+       s4 varindex;
+
+       assert(iln && callee && o_iptr);
+
+       calleem = callee->m;
+       md = calleem->parseddesc;
+
+       /* INLINE_START instruction */
+
+       n_ins = inline_instruction(iln, ICMD_INLINE_START, o_iptr);
+
+       insinfo = (insinfo_inline*) DumpMemory::allocate(sizeof(insinfo_inline));
+       insinfo->method = callee->m;
+       insinfo->outer = iln->m;
+       insinfo->synclocal = callee->synclocal;
+       insinfo->synchronize = callee->synchronize;
+       insinfo->javalocals_start = NULL;
+       insinfo->javalocals_end = NULL;
+
+       /* info about stack vars live at the INLINE_START */
+
+       insinfo->throughcount = callee->n_passthroughcount;
+       insinfo->paramcount = md->paramcount;
+       insinfo->stackvarscount = o_iptr->s1.argcount;
+       insinfo->stackvars = (s4*) DumpMemory::allocate(sizeof(s4) * insinfo->stackvarscount);
+       for (i=0; i<insinfo->stackvarscount; ++i)
+               insinfo->stackvars[i] = iln->varmap[o_iptr->sx.s23.s2.args[i]];
+
+       /* info about the surrounding inlining */
+
+       if (iln->inline_start_instruction)
+               insinfo->parent = iln->inline_start_instruction->sx.s23.s3.inlineinfo;
+       else
+               insinfo->parent = NULL;
+
+       /* finish the INLINE_START instruction */
+
+       n_ins->sx.s23.s3.inlineinfo = insinfo;
+       callee->inline_start_instruction = n_ins;
+
+       DOLOG( printf("%sprolog: ", iln->indent);
+                  show_icmd(iln->ctx->resultjd, n_ins, false, SHOW_STACK); printf("\n"); );
+
+       /* handle parameters for the inlined callee */
+
+       localindex = callee->localsoffset + md->paramslots;
+
+       for (i=md->paramcount-1; i>=0; --i) {
+               assert(iln);
+
+               type = md->paramtypes[i].type;
+
+               localindex -= IS_2_WORD_TYPE(type) ? 2 : 1;
+               assert(callee->regdata);
+
+               /* translate the argument variable */
+
+               varindex = varmap[o_iptr->sx.s23.s2.args[i]];
+               assert(varindex != UNUSED);
+
+               /* remove preallocation from the argument variable */
+
+               iln->ctx->resultjd->var[varindex].flags &= ~(PREALLOC | INMEMORY);
+
+               /* check the instance slot against NULL */
+               /* we don't need that for <init> methods, as the verifier  */
+               /* ensures that they are only called for an uninit. object */
+               /* (which may not be NULL).                                */
+
+               if (!callee->isstatic && i == 0 && calleem->name != utf_init) {
+                       assert(type == TYPE_ADR);
+                       n_ins = inline_instruction(iln, ICMD_CHECKNULL, o_iptr);
+                       n_ins->s1.varindex = varindex;
+                       n_ins->dst.varindex = n_ins->s1.varindex;
+               }
+
+               /* store argument into local variable of inlined callee */
+
+               if (callee->jd->local_map[5*(localindex - callee->localsoffset) + type] != UNUSED)
+               {
+                       /* this value is used in the callee */
+
+                       if (i == 0 && callee->synclocal != UNUSED) {
+                               /* we also need it for synchronization, so copy it */
+                               assert(type == TYPE_ADR);
+                               n_ins = inline_instruction(iln, ICMD_COPY, o_iptr);
+                       }
+                       else {
+                               n_ins = inline_instruction(iln, ICMD_ISTORE + type, o_iptr);
+                               n_ins->sx.s23.s3.javaindex = UNUSED;
+                       }
+                       n_ins->s1.varindex = varindex;
+                       n_ins->dst.varindex = iln->ctx->resultjd->local_map[5*localindex + type];
+                       assert(n_ins->dst.varindex != UNUSED);
+               }
+               else if (i == 0 && callee->synclocal != UNUSED) {
+                       /* the value is not used inside the callee, but we need it for */
+                       /* synchronization                                             */
+                       /* XXX In this case it actually makes no sense to create a     */
+                       /*     separate synchronization variable.                      */
+
+                       n_ins = inline_instruction(iln, ICMD_NOP, o_iptr);
+               }
+               else {
+                       /* this value is not used, pop it */
+
+                       n_ins = inline_instruction(iln, ICMD_POP, o_iptr);
+                       n_ins->s1.varindex = varindex;
+               }
+
+               DOLOG( printf("%sprolog: ", iln->indent);
+                          show_icmd(iln->ctx->resultjd, n_ins, false, SHOW_STACK); printf("\n"); );
+       }
+
+       /* COPY for synchronized instance methods */
+
+       if (callee->synclocal != UNUSED) {
+               n_ins = inline_instruction(iln, ICMD_COPY, o_iptr);
+               n_ins->s1.varindex = varmap[o_iptr->sx.s23.s2.args[0]];
+               n_ins->dst.varindex = callee->synclocal;
+
+               assert(n_ins->s1.varindex != UNUSED);
+       }
+
+       if (callee->synchronize) {
+               inline_generate_sync_builtin(iln, callee, o_iptr,
+                                                                        (callee->isstatic) ? UNUSED : varmap[o_iptr->sx.s23.s2.args[0]],
+                                                                        LOCK_monitor_enter);
+       }
+
+       /* INLINE_BODY instruction */
+
+       n_ins = inline_instruction(iln, ICMD_INLINE_BODY, callee->jd->basicblocks[0].iinstr);
+       n_ins->sx.s23.s3.inlineinfo = insinfo;
+
+       return 0; /* XXX */
+}
+
+
+static void emit_inlining_epilog(inline_node *iln, inline_node *callee, instruction *o_iptr)
+{
+       instruction *n_ins;
+       s4          *jl;
+
+       assert(iln && callee && o_iptr);
+       assert(callee->inline_start_instruction);
+
+       if (callee->synchronize) {
+               inline_generate_sync_builtin(iln, callee, o_iptr,
+                                                                        callee->synclocal,
+                                                                        LOCK_monitor_exit);
+       }
+
+       /* INLINE_END instruction */
+
+       n_ins = inline_instruction(iln, ICMD_INLINE_END, o_iptr);
+       n_ins->sx.s23.s3.inlineinfo = callee->inline_start_instruction->sx.s23.s3.inlineinfo;
+
+       /* set the javalocals */
+
+       jl = (s4*) DumpMemory::allocate(sizeof(s4) * iln->jd->maxlocals);
+       MCOPY(jl, iln->javalocals, s4, iln->jd->maxlocals);
+       n_ins->sx.s23.s3.inlineinfo->javalocals_end = jl;
+
+       DOLOG( printf("%sepilog: ", iln->indent);
+                  show_icmd(iln->ctx->resultjd, n_ins, false, SHOW_STACK); printf("\n"); );
+}
+
+
+#define TRANSLATE_VAROP(vo)  \
+       n_iptr->vo.varindex = inline_translate_variable(jd, origjd, varmap, n_iptr->vo.varindex)
+
+
+static void inline_clone_instruction(inline_node *iln,
+                                                                        jitdata *jd,
+                                                                        jitdata *origjd,
+                                                                        s4 *varmap,
+                                                                        instruction *o_iptr,
+                                                                        instruction *n_iptr)
+{
+       icmdtable_entry_t *icmdt;
+       builtintable_entry *bte;
+       methoddesc *md;
+       s4 i, j;
+       branch_target_t *table;
+       lookup_target_t *lookup;
+       inline_node *scope;
+
+       *n_iptr = *o_iptr;
+
+       icmdt = &(icmd_table[o_iptr->opc]);
+
+       switch (icmdt->dataflow) {
+               case DF_0_TO_0:
+                       break;
+
+               case DF_3_TO_0:
+                       TRANSLATE_VAROP(sx.s23.s3);
+               case DF_2_TO_0:
+                       TRANSLATE_VAROP(sx.s23.s2);
+               case DF_1_TO_0:
+                       TRANSLATE_VAROP(s1);
+                       break;
+
+               case DF_2_TO_1:
+                       TRANSLATE_VAROP(sx.s23.s2);
+               case DF_1_TO_1:
+               case DF_COPY:
+               case DF_MOVE:
+                       TRANSLATE_VAROP(s1);
+               case DF_0_TO_1:
+                       TRANSLATE_VAROP(dst);
+                       break;
+
+               case DF_N_TO_1:
+                       n_iptr->sx.s23.s2.args = (s4*) DumpMemory::allocate(sizeof(s4) * n_iptr->s1.argcount);
+                       for (i=0; i<n_iptr->s1.argcount; ++i) {
+                               n_iptr->sx.s23.s2.args[i] =
+                                       inline_translate_variable(jd, origjd, varmap,
+                                                       o_iptr->sx.s23.s2.args[i]);
+                       }
+                       TRANSLATE_VAROP(dst);
+                       break;
+
+               case DF_INVOKE:
+                       INSTRUCTION_GET_METHODDESC(n_iptr, md);
+clone_call:
+                       n_iptr->s1.argcount += iln->n_passthroughcount;
+                       n_iptr->sx.s23.s2.args = (s4*) DumpMemory::allocate(sizeof(s4) * n_iptr->s1.argcount);
+                       for (i=0; i<o_iptr->s1.argcount; ++i) {
+                               n_iptr->sx.s23.s2.args[i] =
+                                       inline_translate_variable(jd, origjd, varmap,
+                                                       o_iptr->sx.s23.s2.args[i]);
+                       }
+                       for (scope = iln; scope != NULL; scope = scope->parent) {
+                               for (j = 0; j < scope->n_selfpassthroughcount; ++j) {
+                                       n_iptr->sx.s23.s2.args[i++] =
+                                               scope->parent->varmap[scope->n_passthroughvars[j]];
+                               }
+                       }
+                       if (md->returntype.type != TYPE_VOID)
+                               TRANSLATE_VAROP(dst);
+                       break;
+
+               case DF_BUILTIN:
+                       bte = n_iptr->sx.s23.s3.bte;
+                       md = bte->md;
+                       goto clone_call;
+
+               default:
+                       assert(0);
+       }
+
+       switch (icmdt->controlflow) {
+               case CF_RET:
+                       TRANSLATE_VAROP(s1); /* XXX should be handled by data-flow */
+                       /* FALLTHROUGH */
+               case CF_IF:
+               case CF_GOTO:
+                       inline_add_block_reference(iln, &(n_iptr->dst.block));
+                       break;
+
+               case CF_JSR:
+                       inline_add_block_reference(iln, &(n_iptr->sx.s23.s3.jsrtarget.block));
+                       break;
+
+               case CF_TABLE:
+                       i = n_iptr->sx.s23.s3.tablehigh - n_iptr->sx.s23.s2.tablelow + 1 + 1 /* default */;
+
+                       table = (branch_target_t*) DumpMemory::allocate(sizeof(branch_target_t) *  i);
+                       MCOPY(table, o_iptr->dst.table, branch_target_t, i);
+                       n_iptr->dst.table = table;
+
+                       while (--i >= 0) {
+                               inline_add_block_reference(iln, &(table->block));
+                               table++;
+                       }
+                       break;
+
+               case CF_LOOKUP:
+                       inline_add_block_reference(iln, &(n_iptr->sx.s23.s3.lookupdefault.block));
+
+                       i = n_iptr->sx.s23.s2.lookupcount;
+                       lookup = (lookup_target_t*) DumpMemory::allocate(sizeof(lookup_target_t) * i);
+                       MCOPY(lookup, o_iptr->dst.lookup, lookup_target_t, i);
+                       n_iptr->dst.lookup = lookup;
+
+                       while (--i >= 0) {
+                               inline_add_block_reference(iln, &(lookup->target.block));
+                               lookup++;
+                       }
+                       break;
+       }
+
+       /* XXX move this to dataflow section? */
+
+       switch (n_iptr->opc) {
+               case ICMD_ASTORE:
+#if 0
+                       if (n_iptr->flags.bits & INS_FLAG_RETADDR)
+                               inline_add_blocknr_reference(iln, &(n_iptr->sx.s23.s2.retaddrnr));
+#endif
+                       /* FALLTHROUGH! */
+               case ICMD_ISTORE:
+               case ICMD_LSTORE:
+               case ICMD_FSTORE:
+               case ICMD_DSTORE:
+                       stack_javalocals_store(n_iptr, iln->javalocals);
+                       break;
+       }
+}
+
+
+static void inline_rewrite_method(inline_node *iln)
+{
+       basicblock *o_bptr;
+       s4 len;
+       instruction *o_iptr;
+       instruction *n_iptr;
+       inline_node *nextcall;
+       basicblock *n_bptr;
+       inline_block_map *bm;
+       int i;
+       int icount;
+       jitdata *resultjd;
+       jitdata *origjd;
+       char indent[100]; /* XXX debug */
+       s4 retcount;
+       s4 retidx;
+
+       assert(iln);
+
+       resultjd = iln->ctx->resultjd;
+       origjd = iln->jd;
+
+       n_bptr = NULL;
+       nextcall = iln->children;
+
+       /* XXX debug */
+       for (i=0; i<iln->depth; ++i)
+               indent[i] = '\t';
+       indent[i] = 0;
+       iln->indent = indent;
+
+       DOLOG( printf("%srewriting: ", indent); method_println(iln->m);
+                  printf("%s(passthrough: %d+%d)\n",
+                               indent, iln->n_passthroughcount - iln->n_selfpassthroughcount,
+                               iln->n_passthroughcount); );
+
+       /* set memory cursors */
+
+       iln->inlined_iinstr_cursor = iln->inlined_iinstr;
+       iln->inlined_basicblocks_cursor = iln->inlined_basicblocks;
+
+       /* allocate temporary buffers */
+
+       iln->javalocals = (s4*) DumpMemory::allocate(sizeof(s4) * iln->jd->maxlocals);
+
+       /* loop over basic blocks */
+
+       o_bptr = iln->jd->basicblocks;
+       for (; o_bptr; o_bptr = o_bptr->next) {
+
+               if (o_bptr->flags < BBREACHED) {
+
+                       /* ignore the dummy end block */
+
+                       if (o_bptr->icount == 0 && o_bptr->next == NULL) {
+                               /* enter the following block as translation, for exception handler ranges */
+                               inline_block_translation(iln, o_bptr, iln->inlined_basicblocks_cursor);
+                               continue;
+                       }
+
+                       DOLOG(
+                       printf("%s* skipping old L%03d (flags=%d, type=%d, oid=%d) of ",
+                                       indent,
+                                       o_bptr->nr, o_bptr->flags, o_bptr->type,
+                                       o_bptr->indepth);
+                       method_println(iln->m);
+                       );
+
+                       n_bptr = create_body_block(iln, o_bptr, iln->varmap);
+
+                       /* enter it in the blockmap */
+
+                       inline_block_translation(iln, o_bptr, n_bptr);
+
+                       close_body_block(iln, n_bptr, o_bptr, iln->varmap, 0, -1);
+                       continue;
+               }
+
+               len = o_bptr->icount;
+               o_iptr = o_bptr->iinstr;
+
+               DOLOG(
+               printf("%s* rewriting old L%03d (flags=%d, type=%d, oid=%d) of ",
+                               indent,
+                               o_bptr->nr, o_bptr->flags, o_bptr->type,
+                               o_bptr->indepth);
+               method_println(iln->m);
+               show_basicblock(iln->jd, o_bptr, SHOW_STACK);
+               );
+
+               if (iln->blockbefore || o_bptr != iln->jd->basicblocks) {
+                       /* create an inlined clone of this block */
+
+                       n_bptr = create_body_block(iln, o_bptr, iln->varmap);
+                       icount = 0;
+
+                       /* enter it in the blockmap */
+
+                       inline_block_translation(iln, o_bptr, n_bptr);
+
+                       /* initialize the javalocals */
+
+                       MCOPY(iln->javalocals, n_bptr->javalocals, s4, iln->jd->maxlocals);
+               }
+               else {
+                       s4 *jl;
+
+                       /* continue caller block */
+
+                       n_bptr = iln->inlined_basicblocks_cursor - 1;
+                       icount = n_bptr->icount;
+
+                       /* translate the javalocals */
+
+                       jl = translate_javalocals(iln, o_bptr->javalocals);
+                       iln->inline_start_instruction->sx.s23.s3.inlineinfo->javalocals_start = jl;
+
+                       MCOPY(iln->javalocals, jl, s4, iln->jd->maxlocals);
+               }
+
+               /* iterate over the ICMDs of this block */
+
+               retcount = 0;
+               retidx = UNUSED;
+
+               while (--len >= 0) {
+
+                       DOLOG( fputs(indent, stdout); show_icmd(iln->jd, o_iptr, false,  SHOW_STACK);
+                                  printf("\n") );
+
+                       /* handle calls that will be inlined */
+
+                       if (nextcall && o_iptr == nextcall->callerins) {
+
+                               /* write the inlining prolog */
+
+                               (void) emit_inlining_prolog(iln, nextcall, o_iptr, iln->varmap);
+                               icount += nextcall->prolog_instructioncount;
+
+                               /* end current block, or glue blocks together */
+
+                               n_bptr->icount = icount;
+
+                               if (nextcall->blockbefore) {
+                                       close_prolog_block(iln, n_bptr, nextcall);
+                               }
+                               else {
+                                       /* XXX */
+                               }
+
+                               /* check if the result is a local variable */
+
+                               if (nextcall->m->parseddesc->returntype.type != TYPE_VOID
+                                               && o_iptr->dst.varindex < iln->jd->localcount)
+                               {
+                                       nextcall->n_resultlocal = iln->varmap[o_iptr->dst.varindex];
+                               }
+                               else
+                                       nextcall->n_resultlocal = -1;
+
+                               /* set memory pointers in the callee */
+
+                               nextcall->inlined_iinstr = iln->inlined_iinstr_cursor;
+                               nextcall->inlined_basicblocks = iln->inlined_basicblocks_cursor;
+
+                               /* recurse */
+
+                               DOLOG( printf("%sentering inline ", indent);
+                                          show_icmd(origjd, o_iptr, false, SHOW_STACK); printf("\n") );
+
+                               inline_rewrite_method(nextcall);
+
+                               DOLOG( printf("%sleaving inline ", indent);
+                                          show_icmd(origjd, o_iptr, false, SHOW_STACK); printf("\n") );
+
+                               /* update memory cursors */
+
+                               assert(nextcall->inlined_iinstr_cursor
+                                               <= iln->inlined_iinstr_cursor + nextcall->cumul_instructioncount);
+                               assert(nextcall->inlined_basicblocks_cursor
+                                               == iln->inlined_basicblocks_cursor + nextcall->cumul_basicblockcount);
+                               iln->inlined_iinstr_cursor = nextcall->inlined_iinstr_cursor;
+                               iln->inlined_basicblocks_cursor = nextcall->inlined_basicblocks_cursor;
+
+                               /* start new block, or glue blocks together */
+
+                               if (nextcall->blockafter) {
+                                       n_bptr = create_epilog_block(iln, nextcall, iln->varmap);
+                                       icount = 0;
+                               }
+                               else {
+                                       n_bptr = iln->inlined_basicblocks_cursor - 1;
+                                       icount = n_bptr->icount;
+                                       /* XXX */
+                               }
+
+                               /* emit inlining epilog */
+
+                               emit_inlining_epilog(iln, nextcall, o_iptr);
+                               icount += nextcall->epilog_instructioncount;
+
+                               /* proceed to next call */
+
+                               nextcall = nextcall->next;
+                       }
+                       else {
+                               n_iptr = (iln->inlined_iinstr_cursor++);
+                               assert((n_iptr - iln->inlined_iinstr) < iln->cumul_instructioncount);
+
+                               switch (o_iptr->opc) {
+                                       case ICMD_RETURN:
+                                               if (iln->depth == 0)
+                                                       goto default_clone;
+                                               goto return_tail;
+
+                                       case ICMD_IRETURN:
+                                       case ICMD_ARETURN:
+                                       case ICMD_LRETURN:
+                                       case ICMD_FRETURN:
+                                       case ICMD_DRETURN:
+                                               if (iln->depth == 0)
+                                                       goto default_clone;
+                                               retcount = 1;
+                                               retidx = iln->varmap[o_iptr->s1.varindex];
+                                               if (iln->n_resultlocal != -1) {
+                                                       /* store result in a local variable */
+
+                                                       DOLOG( printf("USING RESULTLOCAL %d\n", iln->n_resultlocal); );
+                                                       /* This relies on the same sequence of types for */
+                                                       /* ?STORE and ?RETURN opcodes.                   */
+                                                       n_iptr->opc = ICMD_ISTORE + (o_iptr->opc - ICMD_IRETURN);
+                                                       n_iptr->s1.varindex = retidx;
+                                                       n_iptr->dst.varindex = iln->n_resultlocal;
+                                                       n_iptr->sx.s23.s3.javaindex = UNUSED; /* XXX set real javaindex? */
+
+                                                       retcount = 0;
+                                                       retidx = UNUSED;
+
+                                                       n_iptr = (iln->inlined_iinstr_cursor++);
+                                                       assert((n_iptr - iln->inlined_iinstr) < iln->cumul_instructioncount);
+                                                       icount++;
+                                               }
+                                               else if ((retidx < resultjd->localcount && iln->blockafter)
+                                                               || !iln->blockafter) /* XXX do we really always need the MOVE? */
+                                               {
+                                                       /* local must not become outvar, insert a MOVE */
+
+                                                       n_iptr->opc = ICMD_MOVE;
+                                                       n_iptr->s1.varindex = retidx;
+                                                       retidx = inline_new_temp_variable(resultjd,
+                                                                                                                         resultjd->var[retidx].type);
+                                                       n_iptr->dst.varindex = retidx;
+
+                                                       n_iptr = (iln->inlined_iinstr_cursor++);
+                                                       assert((n_iptr - iln->inlined_iinstr) < iln->cumul_instructioncount);
+                                                       icount++;
+                                               }
+return_tail:
+                                               if (iln->blockafter) {
+                                                       n_iptr->opc = ICMD_GOTO;
+                                                       n_iptr->dst.block = INLINE_RETURN_REFERENCE(iln);
+                                                       inline_add_block_reference(iln, &(n_iptr->dst.block));
+                                               }
+                                               else {
+                                                       n_iptr->opc = ICMD_NOP;
+                                               }
+                                               break;
+#if 0
+                                               if (o_bptr->next == NULL || (o_bptr->next->icount==0 && o_bptr->next->next == NULL)) {
+                                                       n_iptr->opc = ICMD_NOP;
+                                                       break;
+                                               }
+                                               goto default_clone;
+                                               break;
+#endif
+
+                                       default:
+default_clone:
+                                               inline_clone_instruction(iln, resultjd, iln->jd, iln->varmap, o_iptr, n_iptr);
+                               }
+
+                               DOLOG( fputs(indent, stdout); show_icmd(resultjd, n_iptr, false, SHOW_STACK);
+                                          printf("\n"););
+
+                               icount++;
+                       }
+
+                       o_iptr++;
+               }
+
+               /* end of basic block */
+
+               if (iln->blockafter || (o_bptr->next && o_bptr->next->next)) {
+                       close_body_block(iln, n_bptr, o_bptr, iln->varmap, retcount, retidx);
+                       n_bptr->icount = icount;
+
+                       DOLOG( printf("closed body block:\n");
+                                  show_basicblock(resultjd, n_bptr, SHOW_STACK); );
+               }
+               else {
+                       n_bptr->icount = icount;
+                       assert(iln->parent);
+                       if (retidx != UNUSED)
+                               iln->parent->varmap[iln->callerins->dst.varindex] = retidx;
+               }
+       }
+
+       bm = iln->ctx->blockmap;
+       for (i=0; i<iln->ctx->blockmap_index; ++i, ++bm) {
+               assert(bm->iln && bm->o_block && bm->n_block);
+               if (bm->iln == iln)
+                       inline_resolve_block_refs(&(iln->refs), bm->o_block, bm->n_block, false);
+       }
+
+#if !defined(NDEBUG)
+       if (iln->refs) {
+               inline_target_ref *ref;
+               ref = iln->refs;
+               while (ref) {
+                       if (!iln->depth || ref->isnumber || *(ref->ref.block) != INLINE_RETURN_REFERENCE(iln)) {
+                               DOLOG( printf("XXX REMAINING REF at depth %d: %p\n", iln->depth,
+                                          (void*)*(ref->ref.block)) );
+                               assert(false);
+                       }
+                       ref = ref->next;
+               }
+       }
+#endif
+}
+
+
+static exception_entry * inline_exception_tables(inline_node *iln,
+                                                                                                exception_entry *n_extable,
+                                                                                                exception_entry **prevextable)
+{
+       inline_node *child;
+       inline_node *scope;
+       exception_entry *et;
+
+       assert(iln);
+       assert(n_extable);
+       assert(prevextable);
+
+       child = iln->children;
+       if (child) {
+               do {
+                       n_extable = inline_exception_tables(child, n_extable, prevextable);
+                       child = child->next;
+               } while (child != iln->children);
+       }
+
+       et = iln->jd->exceptiontable;
+       for (; et != NULL; et = et->down) {
+               assert(et);
+               MZERO(n_extable, exception_entry, 1);
+               n_extable->start     = inline_map_block(iln, et->start  , iln);
+               n_extable->end       = inline_map_block(iln, et->end    , iln);
+               n_extable->handler   = inline_map_block(iln, et->handler, iln);
+               n_extable->catchtype = et->catchtype;
+
+               if (*prevextable) {
+                       (*prevextable)->down = n_extable;
+               }
+               *prevextable = n_extable;
+
+               n_extable++;
+       }
+
+       if (iln->handler_monitorexit) {
+               exception_entry **activehandlers;
+
+               MZERO(n_extable, exception_entry, 1);
+               n_extable->start   = iln->inlined_basicblocks;
+               n_extable->end     = iln->inlined_basicblocks_cursor;
+               n_extable->handler = iln->handler_monitorexit;
+               n_extable->catchtype.any = NULL; /* finally */
+
+               if (*prevextable) {
+                       (*prevextable)->down = n_extable;
+               }
+               *prevextable = n_extable;
+
+               n_extable++;
+
+               /* We have to protect the created handler with the same handlers */
+               /* that protect the method body itself.                          */
+
+               for (scope = iln; scope->parent != NULL; scope = scope->parent) {
+
+                       activehandlers = scope->o_handlers;
+                       assert(activehandlers);
+
+                       while (*activehandlers) {
+
+                               assert(scope->parent);
+
+                               MZERO(n_extable, exception_entry, 1);
+                               n_extable->start     = iln->handler_monitorexit;
+                               n_extable->end       = iln->handler_monitorexit + 1; /* XXX ok in this case? */
+                               n_extable->handler   = inline_map_block(scope->parent,
+                                                                                                               (*activehandlers)->handler,
+                                                                                                               scope->parent);
+                               n_extable->catchtype = (*activehandlers)->catchtype;
+
+                               if (*prevextable) {
+                                       (*prevextable)->down = n_extable;
+                               }
+                               *prevextable = n_extable;
+
+                               n_extable++;
+                               activehandlers++;
+                       }
+               }
+       }
+
+       return n_extable;
+}
+
+
+static void inline_locals(inline_node *iln)
+{
+       inline_node *child;
+
+       assert(iln);
+
+       iln->varmap = create_variable_map(iln);
+
+       child = iln->children;
+       if (child) {
+               do {
+                       inline_locals(child);
+                       child = child->next;
+               } while (child != iln->children);
+       }
+
+       if (iln->regdata->memuse > iln->ctx->resultjd->rd->memuse)
+               iln->ctx->resultjd->rd->memuse = iln->regdata->memuse;
+       if (iln->regdata->argintreguse > iln->ctx->resultjd->rd->argintreguse)
+               iln->ctx->resultjd->rd->argintreguse = iln->regdata->argintreguse;
+       if (iln->regdata->argfltreguse > iln->ctx->resultjd->rd->argfltreguse)
+               iln->ctx->resultjd->rd->argfltreguse = iln->regdata->argfltreguse;
+}
+
+
+static void inline_interface_variables(inline_node *iln)
+{
+       basicblock *bptr;
+       jitdata *resultjd;
+       s4 i;
+       varinfo *v;
+
+       resultjd = iln->ctx->resultjd;
+
+       resultjd->interface_map = (interface_info*) DumpMemory::allocate(sizeof(interface_info) * 5 * iln->ctx->maxinoutdepth);
+       for (i=0; i<5*iln->ctx->maxinoutdepth; ++i)
+               resultjd->interface_map[i].flags = UNUSED;
+
+       for (bptr = resultjd->basicblocks; bptr != NULL; bptr = bptr->next) {
+               assert(bptr->indepth  <= iln->ctx->maxinoutdepth);
+               assert(bptr->outdepth <= iln->ctx->maxinoutdepth);
+
+               for (i=0; i<bptr->indepth; ++i) {
+                       v = &(resultjd->var[bptr->invars[i]]);
+                       v->flags |= INOUT;
+                       if (v->type == TYPE_RET)
+                               v->flags |= PREALLOC;
+                       else
+                               v->flags &= ~PREALLOC;
+                       v->flags &= ~INMEMORY;
+                       assert(bptr->invars[i] >= resultjd->localcount);
+
+                       if (resultjd->interface_map[5*i + v->type].flags == UNUSED) {
+                               resultjd->interface_map[5*i + v->type].flags = v->flags;
+                       }
+                       else {
+                               resultjd->interface_map[5*i + v->type].flags |= v->flags;
+                       }
+               }
+
+               for (i=0; i<bptr->outdepth; ++i) {
+                       v = &(resultjd->var[bptr->outvars[i]]);
+                       v->flags |= INOUT;
+                       if (v->type == TYPE_RET)
+                               v->flags |= PREALLOC;
+                       else
+                               v->flags &= ~PREALLOC;
+                       v->flags &= ~INMEMORY;
+                       assert(bptr->outvars[i] >= resultjd->localcount);
+
+                       if (resultjd->interface_map[5*i + v->type].flags == UNUSED) {
+                               resultjd->interface_map[5*i + v->type].flags = v->flags;
+                       }
+                       else {
+                               resultjd->interface_map[5*i + v->type].flags |= v->flags;
+                       }
+               }
+       }
+}
+
+
+static void inline_write_exception_handlers(inline_node *master, inline_node *iln)
+{
+       basicblock *n_bptr;
+       instruction *n_ins;
+       inline_node *child;
+       builtintable_entry *bte;
+       s4 exvar;
+       s4 syncvar;
+       s4 i;
+
+       child = iln->children;
+       if (child) {
+               do {
+                       inline_write_exception_handlers(master, child);
+                       child = child->next;
+               } while (child != iln->children);
+       }
+
+       if (iln->synchronize) {
+               /* create the monitorexit handler */
+               n_bptr = create_block(master, iln, iln,
+                                                         iln->n_passthroughcount + 1);
+               n_bptr->type = BBTYPE_EXH;
+               n_bptr->flags = BBFINISHED;
+
+               exvar = inline_new_variable(master->ctx->resultjd, TYPE_ADR, 0);
+               n_bptr->invars[iln->n_passthroughcount] = exvar;
+
+               iln->handler_monitorexit = n_bptr;
+
+               /* ACONST / ALOAD */
+
+               n_ins = master->inlined_iinstr_cursor++;
+               if (iln->m->flags & ACC_STATIC) {
+                       n_ins->opc = ICMD_ACONST;
+                       n_ins->sx.val.c.cls = iln->m->clazz;
+                       n_ins->flags.bits = INS_FLAG_CLASS;
+               }
+               else {
+                       n_ins->opc = ICMD_ALOAD;
+                       n_ins->s1.varindex = iln->synclocal;
+                       assert(n_ins->s1.varindex != UNUSED);
+               }
+               /* XXX could be PREALLOCed for  builtin call */
+               syncvar = inline_new_variable(master->ctx->resultjd, TYPE_ADR, 0);
+               n_ins->dst.varindex = syncvar;
+               n_ins->line = 0;
+
+               /* MONITOREXIT */
+
+               bte = builtintable_get_internal(LOCK_monitor_exit);
+
+               n_ins = master->inlined_iinstr_cursor++;
+               n_ins->opc = ICMD_BUILTIN;
+               n_ins->s1.argcount = 1 + iln->n_passthroughcount + 1;
+               n_ins->sx.s23.s2.args = (s4*) DumpMemory::allocate(sizeof(s4) * n_ins->s1.argcount);
+               n_ins->sx.s23.s2.args[0] = syncvar;
+               for (i=0; i < iln->n_passthroughcount + 1; ++i) {
+                       n_ins->sx.s23.s2.args[1 + i] = n_bptr->invars[i];
+               }
+               n_ins->sx.s23.s3.bte = bte;
+               n_ins->line = 0;
+
+               /* ATHROW */
+
+               n_ins = master->inlined_iinstr_cursor++;
+               n_ins->opc = ICMD_ATHROW;
+               n_ins->flags.bits = 0;
+               n_ins->s1.varindex = exvar;
+               n_ins->line = 0;
+
+               /* close basic block */
+
+               close_block(iln, iln, n_bptr, iln->n_passthroughcount);
+               n_bptr->icount = 3;
+       }
+}
+
+
+/* second pass driver *********************************************************/
+
+static bool inline_transform(inline_node *iln, jitdata *jd)
+{
+       instruction *n_ins;
+       basicblock *n_bb;
+       basicblock *n_bptr;
+       exception_entry *n_ext;
+       exception_entry *prevext;
+       codegendata *n_cd;
+       jitdata *n_jd;
+       s4 i;
+#if defined(INLINE_VERIFY_RESULT)
+       static int debug_verify_inlined_code = 1;
+#endif
+#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
+       static int debug_counter = 0;
+#endif
+
+       DOLOG( dump_inline_tree(iln, 0); );
+
+       assert(iln && jd);
+
+       n_ins = (instruction*) DumpMemory::allocate(sizeof(instruction) * iln->cumul_instructioncount);
+       MZERO(n_ins, instruction, iln->cumul_instructioncount);
+       iln->inlined_iinstr = n_ins;
+
+       n_bb = (basicblock*) DumpMemory::allocate(sizeof(basicblock) * iln->cumul_basicblockcount);
+       MZERO(n_bb, basicblock, iln->cumul_basicblockcount);
+       iln->inlined_basicblocks = n_bb;
+
+       iln->ctx->blockmap = (inline_block_map*) DumpMemory::allocate(sizeof(inline_block_map) * iln->cumul_blockmapcount);
+
+       n_jd = jit_jitdata_new(iln->m);
+       n_jd->flags = jd->flags;
+       n_jd->code->optlevel = jd->code->optlevel;
+       iln->ctx->resultjd = n_jd;
+
+       reg_setup(n_jd);
+
+       /* create the local_map */
+
+       n_jd->local_map = (s4*) DumpMemory::allocate(sizeof(s4) *  5 * iln->cumul_maxlocals);
+       for (i=0; i<5*iln->cumul_maxlocals; ++i)
+               n_jd->local_map[i] = UNUSED;
+
+       /* create / coalesce local variables */
+
+       n_jd->varcount = 0;
+       n_jd->vartop = 0;
+       n_jd->var = NULL;
+
+       inline_locals(iln);
+
+       n_jd->localcount = n_jd->vartop;
+
+       /* extra variables for verification (debugging) */
+
+#if defined(INLINE_VERIFY_RESULT)
+       if (debug_verify_inlined_code) {
+               n_jd->vartop   += VERIFIER_EXTRA_LOCALS + VERIFIER_EXTRA_VARS + 100 /* XXX m->maxstack */;
+               if (n_jd->vartop > n_jd->varcount) {
+                       /* XXX why? */
+                       n_jd->var = (varinfo*) DumpMemory::realloc(n_jd->var, sizeof(varinfo) * n_jd->varcount, sizeof(varinfo) * n_jd->vartop);
+                       n_jd->varcount = n_jd->vartop;
+               }
+       }
+#endif /* defined(INLINE_VERIFY_RESULT) */
+
+       /* write inlined code */
+
+       inline_rewrite_method(iln);
+
+       /* create exception handlers */
+
+       inline_write_exception_handlers(iln, iln);
+
+       /* write the dummy end block */
+
+       n_bptr = create_block(iln, iln, iln, 0);
+       n_bptr->flags = BBUNDEF;
+       n_bptr->type = BBTYPE_STD;
+
+       /* store created code in jitdata */
+
+       n_jd->basicblocks = iln->inlined_basicblocks;
+       n_jd->instructioncount = iln->cumul_instructioncount;
+       n_jd->instructions = iln->inlined_iinstr;
+
+       /* link the basic blocks (dummy end block is not counted) */
+
+       n_jd->basicblockcount = (iln->inlined_basicblocks_cursor - iln->inlined_basicblocks) - 1;
+       for (i=0; i<n_jd->basicblockcount + 1; ++i)
+               n_jd->basicblocks[i].next = &(n_jd->basicblocks[i+1]);
+       if (i)
+               n_jd->basicblocks[i-1].next = NULL;
+
+       /* check basicblock numbers */
+
+#if !defined(NDEBUG)
+       jit_check_basicblock_numbers(n_jd);
+#endif
+
+       /* create the exception table */
+
+       if (iln->cumul_exceptiontablelength) {
+               exception_entry *tableend;
+
+               n_ext = (exception_entry*) DumpMemory::allocate(sizeof(exception_entry) * iln->cumul_exceptiontablelength);
+               prevext = NULL;
+               tableend = inline_exception_tables(iln, n_ext, &prevext);
+               assert(tableend == n_ext + iln->cumul_exceptiontablelength);
+               if (prevext)
+                       prevext->down = NULL;
+
+               n_jd->exceptiontablelength = iln->cumul_exceptiontablelength;
+               n_jd->exceptiontable = n_ext;
+       }
+       else {
+               n_ext = NULL;
+       }
+
+       /*******************************************************************************/
+
+       n_cd = n_jd->cd;
+       memcpy(n_cd, jd->cd, sizeof(codegendata));
+
+       n_cd->method = NULL; /* XXX */
+       n_jd->maxlocals = iln->cumul_maxlocals;
+       n_jd->maxinterfaces = iln->ctx->maxinoutdepth;
+
+       inline_post_process(n_jd);
+
+       inline_interface_variables(iln);
+
+       /* for debugging, verify the inlined result */
+
+#if defined(INLINE_VERIFY_RESULT)
+       if (debug_verify_inlined_code) {
+               debug_verify_inlined_code = 0;
+               DOLOG( printf("VERIFYING INLINED RESULT...\n"); fflush(stdout); );
+               if (!typecheck(n_jd)) {
+                       exceptions_clear_exception();
+                       DOLOG( printf("XXX INLINED RESULT DID NOT PASS VERIFIER XXX\n") );
+                       return false;
+               }
+               else {
+                       DOLOG( printf("VERIFICATION PASSED.\n") );
+               }
+               debug_verify_inlined_code = 1;
+       }
+#endif /* defined(INLINE_VERIFY_RESULT) */
+
+       /* we need bigger free memory stacks (XXX these should not be allocated in reg_setup) */
+
+       n_jd->rd->freemem = (s4*) DumpMemory::allocate(sizeof(s4) * (iln->ctx->maxinoutdepth + 1000)) /* XXX max vars/block */;
+
+#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
+       if (   (n_jd->instructioncount >= opt_InlineMinSize)
+               && (n_jd->instructioncount <= opt_InlineMaxSize))
+       {
+          if (debug_counter < opt_InlineCount)
+#endif /* defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) */
+          {
+                       /* install the inlined result */
+
+                       *jd->code = *n_jd->code;
+                       n_jd->code = jd->code;
+                       *jd = *n_jd;
+
+                       /* statistics and logging */
+
+#if !defined(NDEBUG)
+                       inline_stat_roots++;
+
+                       DOLOG_SHORT(
+                       printf("==== %d.INLINE ==================================================================\n",
+                               debug_counter);
+                       printf("\ninline tree:\n");
+                       dump_inline_tree(iln, 0);
+                       n_jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE | JITDATA_FLAG_SHOWDISASSEMBLE;
+                       /* debug_dump_inlined_code(iln, n_method, n_cd, n_rd); */
+                       printf("-------- DONE -----------------------------------------------------------\n");
+                       fflush(stdout);
+                       );
+#endif
+          }
+
+#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
+               debug_counter++;
+       }
+#endif
+       return true;
+}
+
+
+/******************************************************************************/
+/* FIRST PASS: build inlining tree                                            */
+/******************************************************************************/
+
+
+/* inline_pre_parse_heuristics *************************************************
+
+   Perform heuristic checks whether a call site should be inlined.
+   These checks are evaluated before the callee has been parsed and analysed.
+
+   IN:
+       caller...........inlining node of the caller
+          callee...........the called method
+          site.............information on the call site
+
+   RETURN VALUE:
+       true........consider for inlining
+          false.......don't inline
+
+*******************************************************************************/
+
+static bool inline_pre_parse_heuristics(const inline_node *caller,
+                                                                               const methodinfo *callee,
+                                                                               inline_site *site)
+{
+#if defined(INLINE_MAX_DEPTH)
+       if (caller->depth >= INLINE_MAX_DEPTH)
+               return false;
+#endif
+
+       return true;
+}
+
+
+/* inline_post_parse_heuristics ************************************************
+
+   Perform heuristic checks whether a call site should be inlined.
+   These checks are evaluated after the callee has been parsed and analysed.
+
+   IN:
+       caller...........inlining node of the caller (const)
+          callee...........the called method (const)
+
+   RETURN VALUE:
+          true........consider for inlining
+          false.......don't inline
+
+*******************************************************************************/
+
+static bool inline_post_parse_heuristics(const inline_node *caller,
+                                                                                const inline_node *callee)
+{
+       return true;
+}
+
+
+/* inline_afterwards_heuristics ************************************************
+
+   Perform heuristic checks whether a call site should be inlined.
+   These checks are evaluated after the inlining plan for the callee has
+   been made.
+
+   IN:
+       caller...........inlining node of the caller (const)
+          callee...........the called method (const)
+
+   RETURN VALUE:
+          true........consider for inlining
+          false.......don't inline
+
+*******************************************************************************/
+
+static bool inline_afterwards_heuristics(const inline_node *caller,
+                                                                                const inline_node *callee)
+{
+       inline_node *cumulator;
+
+#if defined(INLINE_DEPTH_FIRST)
+       cumulator = caller;
+#else
+       cumulator = caller->ctx->master;
+#endif
+
+       if (0
+#if defined(INLINE_MAX_BLOCK_EXPANSION)
+               || (cumulator->cumul_basicblockcount + callee->cumul_basicblockcount
+                       > INLINE_MAX_BLOCK_EXPANSION*caller->ctx->master->jd->basicblockcount)
+#endif
+#if defined(INLINE_MAX_ICMD_EXPANSION)
+               || (cumulator->cumul_instructioncount + callee->cumul_instructioncount
+                       > INLINE_MAX_ICMD_EXPANSION*caller->ctx->master->jd->instructioncount)
+#endif
+          )
+       {
+               return false;
+       }
+
+       return true;
+}
+
+
+/* inline_is_monomorphic *******************************************************
+
+   Check if the given call site can be proven to be monomorphic.
+
+   IN:
+          callee...........the called method
+          call.............the invocation instruction
+
+   OUT:
+       site->speculative.....flags whether the inlining is speculative
+                                (only defined if return value is true)
+
+   RETURN VALUE:
+       true if the call site is (currently) monomorphic,
+          false if not or unknown
+
+*******************************************************************************/
+
+static bool inline_is_monomorphic(const methodinfo *callee,
+                                                                 const instruction *call,
+                                                                 inline_site *site)
+{
+       if ((callee->flags & (ACC_STATIC | ACC_FINAL | ACC_PRIVATE)
+                               || call->opc == ICMD_INVOKESPECIAL))
+       {
+               site->speculative = false;
+               return true;
+       }
+
+       /* XXX search single implementation for abstract monomorphics */
+
+       if ((callee->flags & (ACC_METHOD_MONOMORPHIC | ACC_METHOD_IMPLEMENTED
+                                       | ACC_ABSTRACT))
+                       == (ACC_METHOD_MONOMORPHIC | ACC_METHOD_IMPLEMENTED))
+       {
+               if (1) {
+                       DOLOG( printf("SPECULATIVE INLINE: "); method_println((methodinfo*)callee); );
+                       site->speculative = true;
+
+                       return true;
+               }
+       }
+
+       /* possibly polymorphic call site */
+
+       return false;
+}
+
+
+/* inline_can_inline ***********************************************************
+
+   Check if inlining of the given call site is possible.
+
+   IN:
+       caller...........inlining node of the caller
+          callee...........the called method
+          call.............the invocation instruction
+
+   OUT:
+       site->speculative.....flags whether the inlining is speculative
+                                (only defined if return value is true)
+
+   RETURN VALUE:
+       true if inlining is possible, false if not
+
+*******************************************************************************/
+
+static bool inline_can_inline(const inline_node *caller,
+                                                         const methodinfo *callee,
+                                                         const instruction *call,
+                                                         inline_site *site)
+{
+       const inline_node *active;
+
+       /* cannot inline native methods */
+
+       if (callee->flags & ACC_NATIVE)
+               return false;
+
+       /* cannot inline possibly polymorphic calls */
+
+       if (!inline_is_monomorphic(callee, call, site))
+               return false;
+
+       /* cannot inline recursive calls */
+
+       for (active = caller; active; active = active->parent) {
+               if (callee == active->m) {
+                       DOLOG( printf("RECURSIVE!\n") );
+                       return false;
+               }
+       }
+
+       /* inlining is possible */
+
+       return true;
+}
+
+
+/* inline_create_callee_node ***************************************************
+
+   Create an inlining node for the given callee.
+
+   IN:
+          caller...........inlining node of the caller (const)
+          callee...........the called method
+
+   RETURN VALUE:
+       the new inlining node
+
+*******************************************************************************/
+
+static inline_node * inline_create_callee_node(const inline_node *caller,
+                                                                                          methodinfo *callee)
+{
+       inline_node *cn;              /* the callee inline_node */
+
+       cn = (inline_node*) DumpMemory::allocate(sizeof(inline_node));
+       MZERO(cn, inline_node, 1);
+
+       cn->depth = caller->depth + 1;
+       cn->ctx = caller->ctx;
+       cn->m = callee;
+       cn->synchronize = (callee->flags & ACC_SYNCHRONIZED);
+       cn->isstatic = (callee->flags & ACC_STATIC);
+
+       return cn;
+}
+
+
+/* inline_set_callee_properties ************************************************
+
+   Set properties of the inlined call site.
+
+   IN:
+       caller...........inlining node of the caller (const)
+          cn...............the called method
+          site.............info about the call site (const)
+
+   OUT:
+       *cn..............has the properties set
+
+*******************************************************************************/
+
+static void inline_set_callee_properties(const inline_node *caller,
+                                                                                inline_node *cn,
+                                                                                const inline_site *site)
+{
+       s4           argi;
+       s4           i, j;
+       basicblock  *bptr;
+
+       /* set info about the call site */
+
+       cn->callerblock = site->bptr;
+       cn->callerins = site->iptr;
+       cn->callerpc = site->pc;
+       cn->o_handlers = site->handlers;
+       cn->n_handlercount = caller->n_handlercount + site->nhandlers;
+
+       /* determine if we need basic block boundaries before/after */
+
+       cn->blockbefore = false;
+       cn->blockafter = false;
+
+       if (cn->jd->branchtoentry)
+               cn->blockbefore = true;
+
+       if (cn->jd->branchtoend)
+               cn->blockafter = true;
+
+       if (cn->jd->returncount > 1)
+               cn->blockafter = true;
+
+       /* XXX make safer and reusable (maybe store last real block) */
+       for (bptr = cn->jd->basicblocks; bptr && bptr->next && bptr->next->next; bptr = bptr->next)
+               ;
+
+       if (cn->jd->returnblock != bptr)
+               cn->blockafter = true;
+
+       /* info about the callee */
+
+       cn->localsoffset = caller->localsoffset + caller->m->maxlocals;
+       cn->prolog_instructioncount = cn->m->parseddesc->paramcount + 2;
+       cn->epilog_instructioncount = 1; /* INLINE_END */
+       cn->extra_instructioncount = 0;
+
+       /* we need a CHECKNULL for instance methods, except for <init> */
+
+       if (!cn->isstatic && cn->m->name != utf_init)
+               cn->prolog_instructioncount += 1;
+
+       /* deal with synchronized callees */
+
+       if (cn->synchronize) {
+               methoddesc         *md;
+               builtintable_entry *bte;
+
+               /* we need basic block boundaries because of the handler */
+
+               cn->blockbefore = true;
+               cn->blockafter = true;
+
+               /* for synchronized static methods                 */
+               /* we need an ACONST, MONITORENTER in the prolog   */
+               /* and ACONST, MONITOREXIT in the epilog           */
+
+               /* for synchronized instance methods               */
+               /* we need an COPY, MONITORENTER in the prolog     */
+               /* and MONITOREXIT in the epilog                   */
+
+               if (cn->isstatic) {
+                       cn->prolog_instructioncount += 2;
+                       cn->epilog_instructioncount += 2;
+               }
+               else {
+                       cn->prolog_instructioncount += 2;
+                       cn->epilog_instructioncount += 1;
+                       cn->localsoffset += 1;
+               }
+
+               /* and exception handler */
+               /* ALOAD, builtin_monitorexit, ATHROW */
+
+               cn->extra_instructioncount += 3;
+
+               /* exception table entries */
+
+               cn->extra_exceptiontablelength = 1 + cn->n_handlercount;
+
+               /* add exception handler block */
+
+               cn->cumul_basicblockcount_root++;
+
+               /* we must call the builtins */
+
+               bte = builtintable_get_internal(LOCK_monitor_enter);
+               md = bte->md;
+               if (md->memuse > cn->regdata->memuse)
+                       cn->regdata->memuse = md->memuse;
+               if (md->argintreguse > cn->regdata->argintreguse)
+                       cn->regdata->argintreguse = md->argintreguse;
+
+               bte = builtintable_get_internal(LOCK_monitor_exit);
+               md = bte->md;
+               if (md->memuse > cn->regdata->memuse)
+                       cn->regdata->memuse = md->memuse;
+               if (md->argintreguse > cn->regdata->argintreguse)
+                       cn->regdata->argintreguse = md->argintreguse;
+       }
+
+       /* determine pass-through variables */
+
+       i = site->iptr->s1.argcount - cn->m->parseddesc->paramcount; /* max # of pass-though vars */
+
+       cn->n_passthroughvars = (s4*) DumpMemory::allocate(sizeof(s4) * i);
+       j = 0;
+       for (argi = site->iptr->s1.argcount - 1; argi >= cn->m->parseddesc->paramcount; --argi) {
+               s4 idx = site->iptr->sx.s23.s2.args[argi];
+               if (idx >= caller->jd->localcount) {
+                       cn->n_passthroughvars[j] = idx;
+                       j++;
+               }
+               else {
+                       DOLOG( printf("PASSING THROUGH LOCAL VARIABLE %d\n", idx); );
+               }
+       }
+       assert(j <= i);
+       cn->n_selfpassthroughcount = j;
+       cn->n_passthroughcount = caller->n_passthroughcount + cn->n_selfpassthroughcount;
+}
+
+
+/* inline_cumulate_counters ****************************************************
+
+   Cumulate counters after a node has been decided to become inlined.
+
+   IN:
+       caller...........inlining node of the caller
+          callee...........inlining node of the callee (const)
+
+   OUT:
+       *caller..........gets cumulated values added
+
+*******************************************************************************/
+
+static void inline_cumulate_counters(inline_node *caller,
+                                                                        const inline_node *cn)
+{
+       caller->cumul_instructioncount += cn->prolog_instructioncount;
+       caller->cumul_instructioncount += cn->epilog_instructioncount;
+       caller->cumul_instructioncount += cn->extra_instructioncount;
+       caller->cumul_instructioncount += cn->cumul_instructioncount - 1 /*invoke*/;
+
+       caller->cumul_basicblockcount += cn->cumul_basicblockcount;
+       caller->cumul_basicblockcount_root += cn->cumul_basicblockcount_root;
+       caller->cumul_blockmapcount += cn->cumul_blockmapcount;
+       caller->cumul_exceptiontablelength += cn->cumul_exceptiontablelength;
+       caller->cumul_exceptiontablelength += cn->extra_exceptiontablelength;
+
+       if (cn->cumul_maxlocals > caller->cumul_maxlocals)
+               caller->cumul_maxlocals = cn->cumul_maxlocals;
+
+       /* XXX extra block after inlined call */
+       if (cn->blockafter) {
+               caller->cumul_basicblockcount += 1;
+               caller->cumul_blockmapcount += 1;
+       }
+}
+
+
+/* inline_analyse_callee *******************************************************
+
+   Analyse an inlining candidate callee.
+
+   IN:
+       caller...........inlining node of the caller
+          callee...........the called method
+          site.............info about the call site
+
+   OUT:
+       site->inlined....true if the callee has been selected for inlining
+
+   RETURN VALUE:
+       the inline node of the callee, or
+       NULL if an error has occurred (don't use the inlining plan in this case)
+
+*******************************************************************************/
+
+static inline_node * inline_analyse_callee(inline_node *caller,
+                                                                                  methodinfo *callee,
+                                                                                  inline_site *site)
+{
+       inline_node *cn;              /* the callee inline_node */
+
+       /* create an inline tree node */
+
+       cn = inline_create_callee_node(caller, callee);
+
+       /* get the intermediate representation of the callee */
+
+       if (!inline_jit_compile(cn))
+               return NULL;
+
+       /* evaluate heuristics after parsing the callee */
+
+       if (!inline_post_parse_heuristics(caller, cn))
+               return cn;
+
+       /* the call site will be inlined */
+
+       site->inlined = true;
+
+       /* set info about the call site */
+
+       inline_set_callee_properties(caller, cn, site);
+
+       /* insert the node into the inline tree */
+
+       inline_insert_inline_node(caller, cn);
+
+       /* analyse recursively */
+
+       if (!inline_analyse_code(cn))
+               return NULL;
+
+       if (!inline_afterwards_heuristics(caller, cn)) {
+#if defined(INLINE_CANCEL_ON_THRESHOLD)
+               return NULL;
+#else
+               inline_remove_inline_node(caller, cn);
+               caller->ctx->stopped = true;
+               site->inlined = false;
+               return cn;
+#endif
+       }
+
+       /* cumulate counters */
+
+#if defined(INLINE_DEPTH_FIRST)
+       inline_cumulate_counters(caller, cn);
+#endif
+
+#if defined(INLINE_BREADTH_FIRST)
+       while (caller) {
+               inline_cumulate_counters(caller, cn);
+               caller = caller->parent;
+       }
+#endif
+
+       return cn;
+}
+
+
+/* inline_process_candidate ****************************************************
+
+   Process a selected inlining candidate.
+
+   IN:
+       cand.............the candidate
+
+   RETURN VALUE:
+       true........everything ok
+          false.......an error has occurred, don't use the plan
+
+*******************************************************************************/
+
+static bool inline_process_candidate(inline_candidate *cand)
+{
+       inline_node *cn;
+
+       cn = inline_analyse_callee(cand->caller,
+                                                          cand->callee,
+                                                          &(cand->site));
+
+       if (!cn)
+               return false;
+
+       if (!cand->site.inlined)
+               return true;
+
+       /* store assumptions */
+
+       if (cand->site.speculative)
+               method_add_assumption_monomorphic(cand->callee, cand->caller->ctx->master->m);
+
+       return true;
+}
+
+
+/* inline_analyse_code *********************************************************
+
+   Analyse the intermediate code of the given inlining node.
+
+   IN:
+       iln..............the inlining node
+
+   OUT:
+       *iln.............the inlining plan
+
+   RETURN VALUE:
+       true........everything ok
+          false.......an error has occurred, don't use the plan
+
+*******************************************************************************/
+
+static bool inline_analyse_code(inline_node *iln)
+{
+       methodinfo *m;
+       basicblock *bptr;
+       s4 len;
+       instruction *iptr;
+       methodinfo *callee;
+       exception_entry **handlers;
+       exception_entry *ex;
+       s4 nhandlers;
+       s4 blockendpc;
+       jitdata *mjd;
+       inline_site site;
+
+       assert(iln);
+
+       m = iln->m;
+       mjd = iln->jd;
+
+       /* initialize cumulative counters */
+
+       iln->cumul_maxlocals = iln->localsoffset + m->maxlocals;
+       iln->cumul_exceptiontablelength += mjd->exceptiontablelength;
+
+       /* iterate over basic blocks */
+
+       blockendpc = 0;
+
+       for (bptr = mjd->basicblocks; bptr; bptr = bptr->next) {
+
+               /* count the block */
+               /* ignore dummy end blocks (but count them for the blockmap) */
+
+               iln->cumul_blockmapcount++;
+               if ((bptr != mjd->basicblocks || iln->blockbefore)
+                               &&
+                       (bptr->icount > 0 || bptr->next != NULL))
+                       iln->cumul_basicblockcount++;
+
+               /* skip dead code */
+
+               if (bptr->flags < BBREACHED)
+                       continue;
+
+               /* allocate the buffer of active exception handlers */
+               /* XXX this wastes some memory, but probably it does not matter */
+
+               handlers = (exception_entry**) DumpMemory::allocate(sizeof(exception_entry*) * (mjd->exceptiontablelength + 1));
+
+               /* determine the active exception handlers for this block     */
+               /* XXX maybe the handlers of a block should be part of our IR */
+               /* XXX this should share code with the type checkers          */
+               nhandlers = 0;
+               for (ex = mjd->exceptiontable; ex ; ex = ex->down) {
+                       if ((ex->start->nr <= bptr->nr) && (ex->end->nr > bptr->nr)) {
+                               handlers[nhandlers++] = ex;
+                       }
+               }
+               handlers[nhandlers] = NULL;
+
+               len = bptr->icount;
+               iptr = bptr->iinstr;
+
+               blockendpc += len;
+               iln->cumul_instructioncount += len;
+
+               /* iterate over the instructions of the block */
+
+               for (; --len >= 0; ++iptr) {
+
+                       switch (iptr->opc) {
+                               case ICMD_INVOKEVIRTUAL:
+                               case ICMD_INVOKESPECIAL:
+                               case ICMD_INVOKESTATIC:
+                               case ICMD_INVOKEINTERFACE:
+
+                                       if (!INSTRUCTION_IS_UNRESOLVED(iptr) && !iln->ctx->stopped) {
+                                               callee = iptr->sx.s23.s3.fmiref->p.method;
+
+                                               if (inline_can_inline(iln, callee, iptr, &site)) {
+                                                       site.inlined = false;
+                                                       site.bptr = bptr;
+                                                       site.iptr = iptr;
+                                                       site.pc = blockendpc - len - 1;
+                                                       site.handlers = handlers;
+                                                       site.nhandlers = nhandlers;
+
+                                                       if (inline_pre_parse_heuristics(iln, callee, &site)) {
+#if defined(INLINE_KNAPSACK) || defined(INLINE_BREADTH_FIRST)
+                                                               inline_add_candidate(iln->ctx, iln, callee, &site);
+#else
+                                                               inline_candidate cand;
+                                                               cand.caller = iln;
+                                                               cand.callee = callee;
+                                                               cand.site   = site;
+
+                                                               if (!inline_process_candidate(&cand))
+                                                                       return false;
+#endif
+                                                       }
+                                               }
+                                       }
+                                       break;
+
+                               case ICMD_RETURN:
+                               case ICMD_IRETURN:
+                               case ICMD_ARETURN:
+                               case ICMD_LRETURN:
+                               case ICMD_FRETURN:
+                               case ICMD_DRETURN:
+                                       /* extra ICMD_MOVE may be necessary */
+                                       iln->cumul_instructioncount++;
+                                       break;
+                       }
+               }
+
+               /* end of basic block */
+       }
+
+       return true;
+}
+
+
+static void inline_cumulate_counters_recursive(inline_node *iln)
+{
+       inline_node *child;
+
+       child = iln->children;
+       if (child) {
+               do {
+                       inline_cumulate_counters_recursive(child);
+                       inline_cumulate_counters(iln, child);
+                       child = child->next;
+               } while (child != iln->children);
+       }
+}
+
+
+/* inline_make_inlining_plan ***************************************************
+
+   Make an inlining plan for the given root node
+
+   IN:
+       iln..............the root node
+
+   OUT:
+       *iln.............the inlining plan
+
+   RETURN VALUE:
+       true........everything ok
+          false.......an error has occurred, don't use the plan
+
+*******************************************************************************/
+
+#if defined(INLINE_KNAPSACK)
+static bool inline_make_inlining_plan(inline_node *iln)
+{
+       inline_candidate *cand;
+#if defined(INLINE_COST_BUDGET)
+       s4 budget = INLINE_COST_BUDGET;
+#   define BUDGETMEMBER cost
+#endif
+#if defined(INLINE_WEIGHT_BUDGET)
+       double budget = INLINE_WEIGHT_BUDGET;
+#   define BUDGETMEMBER weight
+#endif
+
+       inline_analyse_code(iln);
+
+       DOLOG( printf("candidates in "); method_println(iln->m);
+                  inline_candidates_println(iln->ctx); );
+
+       while ((cand = inline_pick_best_candidate(iln->ctx)) != NULL)
+       {
+               if (cand->BUDGETMEMBER <= budget) {
+                       DOLOG( printf("    picking: "); inline_candidate_println(cand); );
+
+                       if (!inline_process_candidate(cand))
+                               return false;
+
+#if !defined(INLINE_ADD_NEGATIVE_TO_BUDGET)
+                       if (cand->BUDGETMEMBER > 0)
+#endif
+                               budget -= cand->BUDGETMEMBER;
+               }
+       }
+
+       inline_cumulate_counters_recursive(iln);
+
+       return true;
+}
+#endif /* defined(INLINE_KNAPSACK) */
+
+
+#if defined(INLINE_DEPTH_FIRST)
+static bool inline_make_inlining_plan(inline_node *iln)
+{
+       return inline_analyse_code(iln);
+}
+#endif /* defined(INLINE_DEPTH_FIRST) */
+
+
+#if defined(INLINE_BREADTH_FIRST)
+static bool inline_make_inlining_plan(inline_node *iln)
+{
+       inline_candidate *cand;
+
+       inline_analyse_code(iln);
+
+       DOLOG( printf("candidates in "); method_println(iln->m);
+                  inline_candidates_println(iln->ctx); );
+
+       while (!iln->ctx->stopped
+                  && (cand = inline_pick_best_candidate(iln->ctx)) != NULL)
+       {
+               DOLOG( printf("    picking: "); inline_candidate_println(cand); );
+
+               if (!inline_process_candidate(cand))
+                       return false;
+       }
+
+       return true;
+}
+#endif /* defined(INLINE_BREADTH_FIRST) */
+
+
+/* statistics *****************************************************************/
+
+#if defined(INLINE_STATISTICS)
+static void inline_gather_statistics_recursive(inline_node *iln)
+{
+       inline_node *child;
+
+       inline_stat_inlined_nodes++;
+
+       if (iln->depth > inline_stat_max_depth)
+               inline_stat_max_depth++;
+
+       child = iln->children;
+       if (child) {
+               do {
+                       inline_gather_statistics_recursive(child);
+                       child = child->next;
+               } while (child != iln->children);
+       }
+}
+#endif /* defined(INLINE_STATISTICS) */
+
+
+#if defined(INLINE_STATISTICS)
+static void inline_gather_statistics(inline_node *iln)
+{
+       inline_stat_roots_transformed++;
+
+       inline_gather_statistics_recursive(iln);
+}
+#endif /* defined(INLINE_STATISTICS) */
+
+
+/* post processing ************************************************************/
+
+#define POSTPROCESS_SRC(varindex)  live[varindex]--
+#define POSTPROCESS_DST(varindex)  live[varindex]++
+
+#define POSTPROCESS_SRCOP(s)  POSTPROCESS_SRC(iptr->s.varindex)
+#define POSTPROCESS_DSTOP(d)  POSTPROCESS_DST(iptr->d.varindex)
+
+#define MARKSAVED(varindex)  jd->var[varindex].flags |= SAVEDVAR
+
+#define MARK_ALL_SAVED                                               \
+    do {                                                             \
+        for (i=0; i<jd->vartop; ++i)                                 \
+            if (live[i])                                             \
+                MARKSAVED(i);                                        \
+    } while (0)
+
+static void inline_post_process(jitdata *jd)
+{
+       codeinfo   *code;
+       basicblock *bptr;
+       instruction *iptr;
+       instruction *iend;
+       s4 i;
+       icmdtable_entry_t *icmdt;
+       s4 *live;
+       methoddesc *md;
+       builtintable_entry *bte;
+
+       /* Get required compiler data. */
+
+       code = jd->code;
+
+       /* reset the SAVEDVAR flag of all variables */
+
+       for (i=0; i<jd->vartop; ++i)
+               jd->var[i].flags &= ~SAVEDVAR;
+
+       /* allocate the life counters */
+
+       live = (s4*) DumpMemory::allocate(sizeof(s4) * jd->vartop);
+       MZERO(live, s4, jd->vartop);
+
+       /* iterate over all basic blocks */
+
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
+               if (bptr->flags < BBREACHED)
+                       continue;
+
+               /* make invars live */
+
+               for (i=0; i<bptr->indepth; ++i)
+                       POSTPROCESS_DST(bptr->invars[i]);
+
+               iptr = bptr->iinstr;
+               iend = iptr + bptr->icount;
+
+               for (; iptr < iend; ++iptr) {
+
+                       icmdt = &(icmd_table[iptr->opc]);
+
+                       switch (icmdt->dataflow) {
+                               case DF_3_TO_0:
+                                       POSTPROCESS_SRCOP(sx.s23.s3);
+                               case DF_2_TO_0:
+                                       POSTPROCESS_SRCOP(sx.s23.s2);
+                               case DF_1_TO_0:
+                                       POSTPROCESS_SRCOP(s1);
+                               case DF_0_TO_0:
+                                       if (icmdt->flags & ICMDTABLE_CALLS) {
+                                               code_unflag_leafmethod(code);
+                                               MARK_ALL_SAVED;
+                                       }
+                                       break;
+
+                               case DF_2_TO_1:
+                                       POSTPROCESS_SRCOP(sx.s23.s2);
+                               case DF_1_TO_1:
+                               case DF_MOVE:
+                                       POSTPROCESS_SRCOP(s1);
+                               case DF_0_TO_1:
+                                       if (icmdt->flags & ICMDTABLE_CALLS) {
+                                               code_unflag_leafmethod(code);
+                                               MARK_ALL_SAVED;
+                                       }
+                               case DF_COPY:
+                                       POSTPROCESS_DSTOP(dst);
+                                       break;
+
+                               case DF_N_TO_1:
+                                       for (i=0; i<iptr->s1.argcount; ++i) {
+                                               POSTPROCESS_SRC(iptr->sx.s23.s2.args[i]);
+                                       }
+                                       if (icmdt->flags & ICMDTABLE_CALLS) {
+                                               code_unflag_leafmethod(code);
+                                               MARK_ALL_SAVED;
+                                       }
+                                       POSTPROCESS_DSTOP(dst);
+                                       break;
+
+                               case DF_INVOKE:
+                                       INSTRUCTION_GET_METHODDESC(iptr, md);
+               post_process_call:
+                                       code_unflag_leafmethod(code);
+                                       for (i=0; i<md->paramcount; ++i) {
+                                               POSTPROCESS_SRC(iptr->sx.s23.s2.args[i]);
+                                       }
+                                       for (; i<iptr->s1.argcount; ++i) {
+                                               MARKSAVED(iptr->sx.s23.s2.args[i]);
+                                       }
+                                       if (md->returntype.type != TYPE_VOID)
+                                               POSTPROCESS_DSTOP(dst);
+                                       break;
+
+                               case DF_BUILTIN:
+                                       bte = iptr->sx.s23.s3.bte;
+                                       md = bte->md;
+                                       goto post_process_call;
+
+                               default:
+                                       assert(0);
+                       }
+
+               } /* end instruction loop */
+
+               /* consume outvars */
+
+               for (i=0; i<bptr->outdepth; ++i)
+                       POSTPROCESS_SRC(bptr->outvars[i]);
+
+#if !defined(NDEBUG)
+               for (i=jd->localcount; i < jd->vartop; ++i)
+                       assert(live[i] == 0);
+#endif
+
+       } /* end basic block loop */
+}
+
+
+/* inline_create_root_node *****************************************************
+
+   Create the root node of the inlining tree.
+
+   IN:
+          jd...............the current jitdata of the root method
+
+   RETURN VALUE:
+       the root node of the inlining tree
+
+*******************************************************************************/
+
+static inline_node * inline_create_root_node(jitdata *jd)
+{
+       inline_node *iln;
+
+       iln = (inline_node*) DumpMemory::allocate(sizeof(inline_node));
+       MZERO(iln, inline_node, 1);
+
+       iln->m = jd->m;
+       iln->jd = jd;
+       iln->regdata = jd->rd;
+
+       iln->blockbefore = true;
+       iln->blockafter = true;
+
+       iln->cumul_instructioncount = 0;
+       iln->cumul_basicblockcount = 1 /* dummy end block */;
+
+       /* create inlining context */
+
+       iln->ctx = (inline_context*) DumpMemory::allocate(sizeof(inline_context));
+       MZERO(iln->ctx, inline_context, 1);
+       iln->ctx->master = iln;
+       iln->ctx->next_debugnr = 1; /* XXX debug */
+
+       return iln;
+}
+
+
+/******************************************************************************/
+/* MAIN DRIVER FUNCTION                                                       */
+/******************************************************************************/
+
+bool inline_inline(jitdata *jd)
+{
+       inline_node *iln;
+
+       DOLOG( printf("==== INLINE ==================================================================\n");
+                  show_method(jd, SHOW_STACK); );
+
+#if defined(INLINE_STATISTICS)
+       inline_stat_roots++;
+#endif
+
+       iln = inline_create_root_node(jd);
+
+       if (inline_make_inlining_plan(iln)) {
+
+               /* add blocks to the root node */
+
+               iln->cumul_basicblockcount += iln->cumul_basicblockcount_root;
+               iln->cumul_blockmapcount   += iln->cumul_basicblockcount_root;
+
+               DOLOG( printf("==== INLINE TRANSFORM ========================================================\n"); );
+
+               if (iln->children)
+                       inline_transform(iln, jd);
+
+#if defined(INLINE_STATISTICS)
+               inline_gather_statistics(iln);
+#endif
+       }
+
+       DOLOG( printf("-------- DONE -----------------------------------------------------------\n");
+                  fflush(stdout); );
+
+       return true;
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+/*
+ * 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/jit/inline/inline.h b/src/vm/jit/inline/inline.h
deleted file mode 100644 (file)
index cdd41ee..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* src/vm/jit/inline/inline.h - code inliner
-
-   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
-
-   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 _INLINE_H
-#define _INLINE_H
-
-#include "config.h"
-
-#include "vm/global.h"
-
-#include "vm/jit/jit.h"
-
-
-/* function prototypes ********************************************************/
-
-bool inline_inline(jitdata *jd);
-
-#endif /* _INLINE_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/jit/inline/inline.hpp b/src/vm/jit/inline/inline.hpp
new file mode 100644 (file)
index 0000000..373de8f
--- /dev/null
@@ -0,0 +1,62 @@
+/* src/vm/jit/inline/inline.h - code inliner
+
+   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 _INLINE_H
+#define _INLINE_H
+
+#include "config.h"
+
+#include <stdbool.h>
+
+#include "vm/jit/jit.hpp"
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool inline_inline(jitdata *jd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _INLINE_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 d0d7fd91010252675902156d3c960d07dc93f46d..0598774c7e2774b9f93cdb14f2a6d31d01166037 100644 (file)
@@ -30,9 +30,7 @@ EXTRA_DIST = \
        java.vmg \
        gray.fs \
        prims2x.fs \
-       vmgenx \
-       \
-       $(BUILT_SOURCES)
+       vmgenx
 
 noinst_HEADERS = \
        engine.c
@@ -57,7 +55,7 @@ libintrp_la_SOURCES = \
        codegen.c \
        codegen.h \
        disasm.c \
-       disass.c \
+       disass.cpp \
        dynamic-super.c \
        engine1.c \
        engine2.c \
index 6bba262c8a44dad463058bf077ab57534ee1ce34..dc31a95d3026280f8106ed5f35b2999ad77256e6 100644 (file)
 
 #include "arch.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/linker.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/methodheader.h"
 
 #include "vm/jit/intrp/intrp.h"
 
-#include "vmcore/class.h"
-#include "vmcore/linker.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
 #if defined(ENABLE_VMLOG)
 #include <vmlog_cacao.h>
 #endif
index 6fe3cc7270a935a532f0651a0c7e09e188b727e7..4fbca4a70d15856dfe575b7af0675374fcef8cea 100644 (file)
 
 #include "mm/memory.h"
 
-#include "native/native.h"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/options.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/parse.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/parse.hpp"
 #include "vm/jit/patcher.h"
 #include "vm/jit/stack.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/options.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 #define gen_branch(_inst) { \
@@ -2085,7 +2083,7 @@ Cell *nativecall(functionptr f, methodinfo *m, Cell *sp, Inst *ra, Cell *fp, u1
                assert(false);
        }
 
-       av_ptr(alist, _Jv_JNIEnv *, _Jv_env);
+       av_ptr(alist, _Jv_JNIEnv *, VM_get_jnienv());
 
        if (m->flags & ACC_STATIC)
                av_ptr(alist, classinfo *, m->clazz);
@@ -2150,7 +2148,7 @@ Cell *nativecall(functionptr f, methodinfo *m, Cell *sp, Inst *ra, Cell *fp, u1
 
        /* pass env pointer */
 
-       penv = (_Jv_JNIEnv *) _Jv_env;
+       penv = (_Jv_JNIEnv *) VM_get_jnienv();
        *pvalues++ = &penv;
 
        /* for static methods, pass class pointer */
diff --git a/src/vm/jit/intrp/disass.c b/src/vm/jit/intrp/disass.c
deleted file mode 100644 (file)
index 4219f00..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-/* src/vm/jit/intrp/disass.c - disassembler wrapper for interpreter
-
-   Copyright (C) 1996-2005, 2006, 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 <stdio.h>
-
-#include "vm/types.h"
-
-#include "vm/jit/intrp/intrp.h"
-
-
-/* function disassinstr ********************************************************
-
-       outputs a disassembler listing of one machine code instruction on 'stdout'
-       c:   instructions machine code
-
-*******************************************************************************/
-
-u1 *intrp_disassinstr(u1 *code)
-{
-       FILE *savedout;
-       u1   *r;
-
-       savedout = vm_out;
-       vm_out = stdout;
-       r = (u1 *) vm_disassemble_inst((Inst *) code, vm_prim);
-       vm_out = savedout;
-
-       return r;
-}
-
-
-/* function disassemble ********************************************************
-
-       outputs a disassembler listing of some machine code on 'stdout'
-       code: pointer to first instruction
-       len:  code size (number of instructions * 4)
-
-*******************************************************************************/
-
-void intrp_disassemble(u1 *start, u1 *end)
-{
-       FILE *savedout;
-
-       printf("  --- disassembler listing ---\n");
-       savedout = vm_out;
-       vm_out = stdout;
-       vm_disassemble((Inst *) start, (Inst *) end, vm_prim);
-       vm_out = savedout;
-}
-
-
-void printarg_ui      (u4                 ui      )
-{
-       fprintf(vm_out, "%ud", ui);
-}
-
-void printarg_v       (Cell               v       )
-{
-       fprintf(vm_out, "%lld", (long long)v);
-}
-
-void printarg_Cell    (Cell               x       )
-{
-       fprintf(vm_out, "%lld", (long long)x);
-}
-
-
-void printarg_b       (s4                 b       )
-{
-       fprintf(vm_out, "%d", b);
-}
-
-void printarg_s       (s4                 s       )
-{
-       fprintf(vm_out, "%d", s);
-}
-
-void printarg_i       (s4                 i       )
-{
-       fprintf(vm_out, "%d", i);
-}
-
-void printarg_l       (s8                 l       )
-{
-       fprintf(vm_out, "%lld", (long long)l);
-}
-
-void printarg_f       (float              f       )
-{
-       fprintf(vm_out, "%f", (double)f);
-}
-
-void printarg_d       (double             d       )
-{
-       fprintf(vm_out, "%f", d);
-}
-
-void printarg_aRef    (java_objectheader *aRef    )
-{
-       fprintf(vm_out, "obj: %p", (void *)aRef);
-}
-
-void printarg_aArray  (java_arrayheader * aArray  )
-{
-       fprintf(vm_out, "array %p", (void *)aArray);
-}
-
-void printarg_aaTarget(Inst **            aaTarget)
-{
-       if (aaTarget) {
-               methodinfo *m=((methodinfo **)aaTarget)[3];
-               printarg_am(m);
-       } else
-               fprintf(vm_out, "NULL");
-}
-
-void printarg_aClass  (classinfo *        aClass  )
-{
-       if (aClass)
-               utf_fprint_printable_ascii_classname(vm_out, aClass->name);
-       else
-               fprintf(vm_out, "NULL");
-}
-
-void printarg_acr     (constant_classref *acr     )
-{
-       fprintf(vm_out, "cr: %p", (void *)acr);
-}
-
-void printarg_addr    (u1 *               addr    )
-{
-       fprintf(vm_out, "%p", (void *)addr);
-}
-
-void printarg_af      (functionptr        af      )
-{
-       fprintf(vm_out, "f: %p", (void *)af);
-}
-
-void printarg_afi     (fieldinfo *        afi      )
-{
-       if (afi) {
-               utf_fprint_printable_ascii_classname(vm_out, afi->clazz->name);
-               fprintf(vm_out, ".");
-               utf_fprint_printable_ascii(vm_out, afi->name);
-               utf_fprint_printable_ascii(vm_out, afi->descriptor);
-       } else
-               fprintf(vm_out, "fi=NULL");
-}
-
-void printarg_am      (methodinfo *       am      )
-{
-       if (am) {
-               utf_fprint_printable_ascii_classname(vm_out, am->clazz->name);
-               fprintf(vm_out, ".");
-               utf_fprint_printable_ascii(vm_out, am->name);
-               utf_fprint_printable_ascii(vm_out, am->descriptor);
-       } else
-               fprintf(vm_out, "m=NULL");
-}
-
-void printarg_acell   (Cell *             acell   )
-{
-       fprintf(vm_out, "%p", (void *)acell);
-}
-
-void printarg_ainst   (Inst *             ainst   )
-{
-       fprintf(vm_out, "%p", (void *)ainst);
-}
-
-void printarg_auf     (unresolved_field * auf     )
-{
-       if (auf) {
-               utf_fprint_printable_ascii(vm_out, auf->fieldref->name);
-               fprintf(vm_out, " (type ");
-               utf_fprint_printable_ascii(vm_out, auf->fieldref->descriptor);
-               fprintf(vm_out, ")");
-       } else
-               fprintf(vm_out, "NULL");
-}
-
-void printarg_aum     (unresolved_method *aum     )
-{
-       if (aum) {
-               utf_fprint_printable_ascii_classname(vm_out, METHODREF_CLASSNAME(aum->methodref));
-               fprintf(vm_out, ".");
-               utf_fprint_printable_ascii(vm_out, aum->methodref->name);
-               utf_fprint_printable_ascii(vm_out, aum->methodref->descriptor);
-       } else
-               fprintf(vm_out, "NULL");
-}
-
-void printarg_avftbl  (vftbl_t *          avftbl  )
-{
-       if (avftbl) {
-               fprintf(vm_out, "vftbl: ");
-               utf_fprint_printable_ascii_classname(vm_out, avftbl->class->name);
-       } else
-               fprintf(vm_out, "NULL");
-}
-
-
-/*
- * 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/jit/intrp/disass.cpp b/src/vm/jit/intrp/disass.cpp
new file mode 100644 (file)
index 0000000..f2b74ef
--- /dev/null
@@ -0,0 +1,240 @@
+/* src/vm/jit/intrp/disass.c - disassembler wrapper for interpreter
+
+   Copyright (C) 1996-2005, 2006, 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 <stdio.h>
+
+#include "vm/types.h"
+
+#include "vm/jit/intrp/intrp.h"
+
+
+/* function disassinstr ********************************************************
+
+       outputs a disassembler listing of one machine code instruction on 'stdout'
+       c:   instructions machine code
+
+*******************************************************************************/
+
+u1 *intrp_disassinstr(u1 *code)
+{
+       FILE *savedout;
+       u1   *r;
+
+       savedout = vm_out;
+       vm_out = stdout;
+       r = (u1 *) vm_disassemble_inst((Inst *) code, vm_prim);
+       vm_out = savedout;
+
+       return r;
+}
+
+
+/* function disassemble ********************************************************
+
+       outputs a disassembler listing of some machine code on 'stdout'
+       code: pointer to first instruction
+       len:  code size (number of instructions * 4)
+
+*******************************************************************************/
+
+void intrp_disassemble(u1 *start, u1 *end)
+{
+       FILE *savedout;
+
+       printf("  --- disassembler listing ---\n");
+       savedout = vm_out;
+       vm_out = stdout;
+       vm_disassemble((Inst *) start, (Inst *) end, vm_prim);
+       vm_out = savedout;
+}
+
+
+void printarg_ui      (u4                 ui      )
+{
+       fprintf(vm_out, "%ud", ui);
+}
+
+void printarg_v       (Cell               v       )
+{
+       fprintf(vm_out, "%lld", (long long)v);
+}
+
+void printarg_Cell    (Cell               x       )
+{
+       fprintf(vm_out, "%lld", (long long)x);
+}
+
+
+void printarg_b       (s4                 b       )
+{
+       fprintf(vm_out, "%d", b);
+}
+
+void printarg_s       (s4                 s       )
+{
+       fprintf(vm_out, "%d", s);
+}
+
+void printarg_i       (s4                 i       )
+{
+       fprintf(vm_out, "%d", i);
+}
+
+void printarg_l       (s8                 l       )
+{
+       fprintf(vm_out, "%lld", (long long)l);
+}
+
+void printarg_f       (float              f       )
+{
+       fprintf(vm_out, "%f", (double)f);
+}
+
+void printarg_d       (double             d       )
+{
+       fprintf(vm_out, "%f", d);
+}
+
+void printarg_aRef    (java_objectheader *aRef    )
+{
+       fprintf(vm_out, "obj: %p", (void *)aRef);
+}
+
+void printarg_aArray  (java_arrayheader * aArray  )
+{
+       fprintf(vm_out, "array %p", (void *)aArray);
+}
+
+void printarg_aaTarget(Inst **            aaTarget)
+{
+       if (aaTarget) {
+               methodinfo *m=((methodinfo **)aaTarget)[3];
+               printarg_am(m);
+       } else
+               fprintf(vm_out, "NULL");
+}
+
+void printarg_aClass  (classinfo *        aClass  )
+{
+       if (aClass)
+               utf_fprint_printable_ascii_classname(vm_out, aClass->name);
+       else
+               fprintf(vm_out, "NULL");
+}
+
+void printarg_acr     (constant_classref *acr     )
+{
+       fprintf(vm_out, "cr: %p", (void *)acr);
+}
+
+void printarg_addr    (u1 *               addr    )
+{
+       fprintf(vm_out, "%p", (void *)addr);
+}
+
+void printarg_af      (functionptr        af      )
+{
+       fprintf(vm_out, "f: %p", (void *)af);
+}
+
+void printarg_afi     (fieldinfo *        afi      )
+{
+       if (afi) {
+               utf_fprint_printable_ascii_classname(vm_out, afi->clazz->name);
+               fprintf(vm_out, ".");
+               utf_fprint_printable_ascii(vm_out, afi->name);
+               utf_fprint_printable_ascii(vm_out, afi->descriptor);
+       } else
+               fprintf(vm_out, "fi=NULL");
+}
+
+void printarg_am      (methodinfo *       am      )
+{
+       if (am) {
+               utf_fprint_printable_ascii_classname(vm_out, am->clazz->name);
+               fprintf(vm_out, ".");
+               utf_fprint_printable_ascii(vm_out, am->name);
+               utf_fprint_printable_ascii(vm_out, am->descriptor);
+       } else
+               fprintf(vm_out, "m=NULL");
+}
+
+void printarg_acell   (Cell *             acell   )
+{
+       fprintf(vm_out, "%p", (void *)acell);
+}
+
+void printarg_ainst   (Inst *             ainst   )
+{
+       fprintf(vm_out, "%p", (void *)ainst);
+}
+
+void printarg_auf     (unresolved_field * auf     )
+{
+       if (auf) {
+               utf_fprint_printable_ascii(vm_out, auf->fieldref->name);
+               fprintf(vm_out, " (type ");
+               utf_fprint_printable_ascii(vm_out, auf->fieldref->descriptor);
+               fprintf(vm_out, ")");
+       } else
+               fprintf(vm_out, "NULL");
+}
+
+void printarg_aum     (unresolved_method *aum     )
+{
+       if (aum) {
+               utf_fprint_printable_ascii_classname(vm_out, METHODREF_CLASSNAME(aum->methodref));
+               fprintf(vm_out, ".");
+               utf_fprint_printable_ascii(vm_out, aum->methodref->name);
+               utf_fprint_printable_ascii(vm_out, aum->methodref->descriptor);
+       } else
+               fprintf(vm_out, "NULL");
+}
+
+void printarg_avftbl  (vftbl_t *          avftbl  )
+{
+       if (avftbl) {
+               fprintf(vm_out, "vftbl: ");
+               utf_fprint_printable_ascii_classname(vm_out, avftbl->class->name);
+       } else
+               fprintf(vm_out, "NULL");
+}
+
+
+/*
+ * 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 d735aa3c6182b83f6df1d55190279981314856f1..78f75df0204b50835800cfbf1058069c7e1998d5 100644 (file)
@@ -3,10 +3,8 @@
    Copyright (C) 1995,1996,1997,1998,2000,2003,2004 Free Software Foundation, Inc.
    Taken from Gforth.
 
-   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.
 
@@ -24,6 +22,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
+
 */
 
 
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
 #include "toolbox/hashtable.h"
 #include "toolbox/logging.h"
 
+#include "vm/options.h"
+
 #include "vm/jit/disass.h"
 #include "vm/jit/intrp/intrp.h"
 
-#include "vmcore/options.h"
-
 
 s4 no_super=0;   /* option: just use replication, but no dynamic superinsts */
 
index 1e98d1e8bd821851d763ef412fe99f57145774a2..a09239243c2e1b46069a6a370a0cfcefe7d92e5e 100644 (file)
 
 #include "mm/memory.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
 
 #include "vm/jit/methodheader.h"
 #include "vm/jit/patcher.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 #if defined(ENABLE_THREADS)
-# ifndef USE_FAKE_ATOMIC_INSTRUCTIONS
-#  include "machine-instr.h"
-# else
-#  include "threads/posix/generic-primitives.h"
-# endif
+# include "threads/atomic.hpp"
 #endif
 
 #if !defined(STORE_ORDER_BARRIER) && !defined(ENABLE_THREADS)
index c4e988201eab15b97ef0c81c2fc49db147684526..6b3b60e400fcf478545cca2ba74748b525884c28 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/intrp/intrp.h - definitions for Interpreter
 
-   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.
 
@@ -46,15 +44,14 @@ typedef s8 Cell;
 typedef s4 Cell;
 #endif
 
+#include "vm/class.hpp"
 #include "vm/global.h"
+#include "vm/linker.hpp"
+#include "vm/method.hpp"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
 
-#include "vm/jit/codegen-common.h"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/references.h"
-#include "vm/resolve.h"
-#include "vmcore/linker.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 typedef void *Label;
index a8f7107b24cc446510260953ff71047c1b45dac7..518c757b167aa39bdd85e7b37ad561993d5679f5 100644 (file)
 
 #include "mm/memory.h"
 
-#include "native/native.h"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/initialize.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/patcher.h"
 
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vm/resolve.h"
-#include "vmcore/references.h"
-
 
 /* patcher_get_putstatic *******************************************************
 
index a190f35045711020722f19a7021215b1473651f2..a22bc3403add5cc3ce819c1feb3607f7010366d1 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "vm/jit/intrp/intrp.h"
 
-#include "vmcore/options.h"
+#include "vm/options.h"
 
 
 /* the numbers in this struct are primitive indices */
index 4417c43b675053e01d9c1cf9d80d85d186b95a33..ecfdab36526bc077bc0845b9d761a55b17e1111c 100644 (file)
@@ -1,6 +1,6 @@
 ## src/vm/jit/ir/Makefile.am
 ##
-## Copyright (C) 2007
+## Copyright (C) 2007, 2008
 ## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 ##
 ## This file is part of CACAO.
@@ -20,7 +20,6 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 
-## Process this file with automake to produce Makefile.in
 
 AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR)
 
@@ -31,7 +30,12 @@ noinst_LTLIBRARIES = \
 
 libir_la_SOURCES = \
        bytecode.c \
-       bytecode.h
+       bytecode.h \
+       icmd.cpp \
+       icmd.hpp \
+       icmdtable.inc \
+       instruction.cpp \
+       instruction.hpp
 
 
 ## Local variables:
diff --git a/src/vm/jit/ir/icmd.cpp b/src/vm/jit/ir/icmd.cpp
new file mode 100644 (file)
index 0000000..d0c5057
--- /dev/null
@@ -0,0 +1,79 @@
+/* src/vm/jit/ir/icmd.cpp - Intermediate Commands
+
+   Copyright (C) 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 <stdint.h>
+
+#include "vm/jit/ir/icmd.hpp"
+
+
+/* the ICMD table ************************************************************/
+
+#if !defined(NDEBUG)
+#define N(name)  name,
+#else
+#define N(name)
+#endif
+
+/* abbreviations for flags */
+
+#define PEI     ICMDTABLE_PEI
+#define CALLS   ICMDTABLE_CALLS
+
+/* some machine dependent values */
+
+#if SUPPORT_DIVISION
+#define IDIV_CALLS  0
+#else
+#define IDIV_CALLS  ICMDTABLE_CALLS
+#endif
+
+#if (SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
+#define LDIV_CALLS  0
+#else
+#define LDIV_CALLS  ICMDTABLE_CALLS
+#endif
+
+/* include the actual table */
+
+icmdtable_entry_t icmd_table[256] = {
+#include "vm/jit/ir/icmdtable.inc"
+};
+
+
+/*
+ * 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/jit/ir/icmd.hpp b/src/vm/jit/ir/icmd.hpp
new file mode 100644 (file)
index 0000000..34557be
--- /dev/null
@@ -0,0 +1,418 @@
+/* src/vm/jit/ir/icmd.hpp - Intermediate Commands
+
+   Copyright (C) 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 _ICMD_HPP
+#define _ICMD_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/jit/ir/bytecode.h"
+
+
+// JavaVM operation codes (sorted).
+enum {
+       ICMD_NOP               = BC_nop,
+
+       ICMD_ACONST            = BC_aconst_null,
+
+       ICMD_CHECKNULL         = 2,
+
+       ICMD_ICONST            = BC_iconst_0,
+
+       /* 3 */
+       /* 4 */
+
+       ICMD_IDIVPOW2          = 5,
+       ICMD_LDIVPOW2          = 6,
+
+       /* 7 */
+       /* 8 */
+
+       ICMD_LCONST            = BC_lconst_0,
+
+       ICMD_LCMPCONST         = 10,
+
+       ICMD_FCONST            = BC_fconst_0,
+
+       /* 12 */
+       /* 13 */
+
+       ICMD_DCONST            = BC_dconst_0,
+
+       ICMD_COPY              = 15,
+       ICMD_MOVE              = 16,
+
+       /* 17 */
+       /* 18 */
+       /* 19 */
+       /* 20 */
+
+       /* Order of LOAD instructions must be equal to order of TYPE_*
+          defines. */
+
+       ICMD_ILOAD            = BC_iload,
+       ICMD_LLOAD            = BC_lload,
+       ICMD_FLOAD            = BC_fload,
+       ICMD_DLOAD            = BC_dload,
+       ICMD_ALOAD            = BC_aload,
+
+       ICMD_IADDCONST        = 26,
+       ICMD_ISUBCONST        = 27,
+       ICMD_IMULCONST        = 28,
+       ICMD_IANDCONST        = 29,
+       ICMD_IORCONST         = 30,
+       ICMD_IXORCONST        = 31,
+
+       ICMD_ISHLCONST        = 32,
+       ICMD_ISHRCONST        = 33,
+       ICMD_IUSHRCONST       = 34,
+
+       ICMD_IREMPOW2         = 35,
+
+       ICMD_LADDCONST        = 36,
+       ICMD_LSUBCONST        = 37,
+       ICMD_LMULCONST        = 38,
+       ICMD_LANDCONST        = 39,
+       ICMD_LORCONST         = 40,
+       ICMD_LXORCONST        = 41,
+
+       ICMD_LSHLCONST        = 42,
+       ICMD_LSHRCONST        = 43,
+       ICMD_LUSHRCONST       = 44,
+
+       ICMD_LREMPOW2         = 45,
+
+       ICMD_IALOAD           = BC_iaload,
+       ICMD_LALOAD           = BC_laload,
+       ICMD_FALOAD           = BC_faload,
+       ICMD_DALOAD           = BC_daload,
+       ICMD_AALOAD           = BC_aaload,
+       ICMD_BALOAD           = BC_baload,
+       ICMD_CALOAD           = BC_caload,
+       ICMD_SALOAD           = BC_saload,
+
+       /* Order of STORE instructions must be equal to order of TYPE_*
+          defines. */
+
+       ICMD_ISTORE           = BC_istore,
+       ICMD_LSTORE           = BC_lstore,
+       ICMD_FSTORE           = BC_fstore,
+       ICMD_DSTORE           = BC_dstore,
+       ICMD_ASTORE           = BC_astore,
+
+       ICMD_IF_LEQ           = 59,
+       ICMD_IF_LNE           = 60,
+       ICMD_IF_LLT           = 61,
+       ICMD_IF_LGE           = 62,
+       ICMD_IF_LGT           = 63,
+       ICMD_IF_LLE           = 64,
+
+       ICMD_IF_LCMPEQ        = 65,
+       ICMD_IF_LCMPNE        = 66,
+       ICMD_IF_LCMPLT        = 67,
+       ICMD_IF_LCMPGE        = 68,
+       ICMD_IF_LCMPGT        = 69,
+       ICMD_IF_LCMPLE        = 70,
+
+       /* 71 */
+       /* 72 */
+       /* 73 */
+       /* 74 */
+       /* 75 */
+       /* 76 */
+       /* 77 */
+       /* 78 */
+
+       ICMD_IASTORE          = BC_iastore,
+       ICMD_LASTORE          = BC_lastore,
+       ICMD_FASTORE          = BC_fastore,
+       ICMD_DASTORE          = BC_dastore,
+       ICMD_AASTORE          = BC_aastore,
+       ICMD_BASTORE          = BC_bastore,
+       ICMD_CASTORE          = BC_castore,
+       ICMD_SASTORE          = BC_sastore,
+
+       ICMD_POP              = BC_pop,
+       ICMD_POP2             = BC_pop2,
+       ICMD_DUP              = BC_dup,
+       ICMD_DUP_X1           = BC_dup_x1,
+       ICMD_DUP_X2           = BC_dup_x2,
+       ICMD_DUP2             = BC_dup2,
+       ICMD_DUP2_X1          = BC_dup2_x1,
+       ICMD_DUP2_X2          = BC_dup2_x2,
+       ICMD_SWAP             = BC_swap,
+
+       ICMD_IADD             = BC_iadd,
+       ICMD_LADD             = BC_ladd,
+       ICMD_FADD             = BC_fadd,
+       ICMD_DADD             = BC_dadd,
+
+       ICMD_ISUB             = BC_isub,
+       ICMD_LSUB             = BC_lsub,
+       ICMD_FSUB             = BC_fsub,
+       ICMD_DSUB             = BC_dsub,
+
+       ICMD_IMUL             = BC_imul,
+       ICMD_LMUL             = BC_lmul,
+       ICMD_FMUL             = BC_fmul,
+       ICMD_DMUL             = BC_dmul,
+
+       ICMD_IDIV             = BC_idiv,
+       ICMD_LDIV             = BC_ldiv,
+       ICMD_FDIV             = BC_fdiv,
+       ICMD_DDIV             = BC_ddiv,
+
+       ICMD_IREM             = BC_irem,
+       ICMD_LREM             = BC_lrem,
+       ICMD_FREM             = BC_frem,
+       ICMD_DREM             = BC_drem,
+
+       ICMD_INEG             = BC_ineg,
+       ICMD_LNEG             = BC_lneg,
+       ICMD_FNEG             = BC_fneg,
+       ICMD_DNEG             = BC_dneg,
+
+       ICMD_ISHL             = BC_ishl,
+       ICMD_LSHL             = BC_lshl,
+       ICMD_ISHR             = BC_ishr,
+       ICMD_LSHR             = BC_lshr,
+       ICMD_IUSHR            = BC_iushr,
+       ICMD_LUSHR            = BC_lushr,
+
+       ICMD_IAND             = BC_iand,
+       ICMD_LAND             = BC_land,
+       ICMD_IOR              = BC_ior,
+       ICMD_LOR              = BC_lor,
+       ICMD_IXOR             = BC_ixor,
+       ICMD_LXOR             = BC_lxor,
+
+       ICMD_IINC             = BC_iinc,
+
+       ICMD_I2L              = BC_i2l,
+       ICMD_I2F              = BC_i2f,
+       ICMD_I2D              = BC_i2d,
+       ICMD_L2I              = BC_l2i,
+       ICMD_L2F              = BC_l2f,
+       ICMD_L2D              = BC_l2d,
+       ICMD_F2I              = BC_f2i,
+       ICMD_F2L              = BC_f2l,
+       ICMD_F2D              = BC_f2d,
+       ICMD_D2I              = BC_d2i,
+       ICMD_D2L              = BC_d2l,
+       ICMD_D2F              = BC_d2f,
+
+       ICMD_INT2BYTE         = BC_int2byte,
+       ICMD_INT2CHAR         = BC_int2char,
+       ICMD_INT2SHORT        = BC_int2short,
+
+       ICMD_LCMP             = BC_lcmp,
+       ICMD_FCMPL            = BC_fcmpl,
+       ICMD_FCMPG            = BC_fcmpg,
+       ICMD_DCMPL            = BC_dcmpl,
+       ICMD_DCMPG            = BC_dcmpg,
+
+       ICMD_IFEQ             = BC_ifeq,
+       ICMD_IFNE             = BC_ifne,
+       ICMD_IFLT             = BC_iflt,
+       ICMD_IFGE             = BC_ifge,
+       ICMD_IFGT             = BC_ifgt,
+       ICMD_IFLE             = BC_ifle,
+
+       ICMD_IF_ICMPEQ        = BC_if_icmpeq,
+       ICMD_IF_ICMPNE        = BC_if_icmpne,
+       ICMD_IF_ICMPLT        = BC_if_icmplt,
+       ICMD_IF_ICMPGE        = BC_if_icmpge,
+       ICMD_IF_ICMPGT        = BC_if_icmpgt,
+       ICMD_IF_ICMPLE        = BC_if_icmple,
+       ICMD_IF_ACMPEQ        = BC_if_acmpeq,
+       ICMD_IF_ACMPNE        = BC_if_acmpne,
+
+       ICMD_GOTO             = BC_goto,
+       ICMD_JSR              = BC_jsr,
+       ICMD_RET              = BC_ret,
+
+       ICMD_TABLESWITCH      = BC_tableswitch,
+       ICMD_LOOKUPSWITCH     = BC_lookupswitch,
+
+       ICMD_IRETURN          = BC_ireturn,
+       ICMD_LRETURN          = BC_lreturn,
+       ICMD_FRETURN          = BC_freturn,
+       ICMD_DRETURN          = BC_dreturn,
+       ICMD_ARETURN          = BC_areturn,
+       ICMD_RETURN           = BC_return,
+
+       ICMD_GETSTATIC        = BC_getstatic,
+       ICMD_PUTSTATIC        = BC_putstatic,
+       ICMD_GETFIELD         = BC_getfield,
+       ICMD_PUTFIELD         = BC_putfield,
+
+       ICMD_INVOKEVIRTUAL    = BC_invokevirtual,
+       ICMD_INVOKESPECIAL    = BC_invokespecial,
+       ICMD_INVOKESTATIC     = BC_invokestatic,
+       ICMD_INVOKEINTERFACE  = BC_invokeinterface,
+
+       /* 186 */
+
+       ICMD_NEW              = BC_new,
+       ICMD_NEWARRAY         = BC_newarray,
+       ICMD_ANEWARRAY        = BC_anewarray,
+
+       ICMD_ARRAYLENGTH      = BC_arraylength,
+
+       ICMD_ATHROW           = BC_athrow,
+
+       ICMD_CHECKCAST        = BC_checkcast,
+       ICMD_INSTANCEOF       = BC_instanceof,
+
+       ICMD_MONITORENTER     = BC_monitorenter,
+       ICMD_MONITOREXIT      = BC_monitorexit,
+
+       /* 196 */
+
+       ICMD_MULTIANEWARRAY   = BC_multianewarray,
+
+       ICMD_IFNULL           = BC_ifnull,
+       ICMD_IFNONNULL        = BC_ifnonnull,
+
+       /* 200 */
+       /* 201 */
+       /* 202 */
+
+       ICMD_IASTORECONST     = 204,
+       ICMD_LASTORECONST     = 205,
+       ICMD_FASTORECONST     = 206,
+       ICMD_DASTORECONST     = 207,
+       ICMD_AASTORECONST     = 208,
+       ICMD_BASTORECONST     = 209,
+       ICMD_CASTORECONST     = 210,
+       ICMD_SASTORECONST     = 211,
+
+       ICMD_PUTSTATICCONST   = 212,
+       ICMD_PUTFIELDCONST    = 213,
+
+       ICMD_IMULPOW2         = 214,
+       ICMD_LMULPOW2         = 215,
+
+       ICMD_GETEXCEPTION     = 249,
+       ICMD_PHI              = 250,
+
+       ICMD_INLINE_START     = 251,        /* instruction before inlined method  */
+       ICMD_INLINE_END       = 252,        /* instruction after inlined method   */
+       ICMD_INLINE_BODY      = 253,        /* start of inlined body              */
+
+       ICMD_BUILTIN          = 255         /* internal opcode                    */
+};
+
+
+/* data-flow constants for the ICMD table ************************************/
+
+#define DF_0_TO_0      0
+#define DF_1_TO_0      1
+#define DF_2_TO_0      2
+#define DF_3_TO_0      3
+
+#define DF_DST_BASE    4      /* from this value on, iptr->dst is a variable */
+
+#define DF_0_TO_1      (DF_DST_BASE + 0)
+#define DF_1_TO_1      (DF_DST_BASE + 1)
+#define DF_2_TO_1      (DF_DST_BASE + 2)
+#define DF_3_TO_1      (DF_DST_BASE + 3)
+#define DF_N_TO_1      (DF_DST_BASE + 4)
+
+#define DF_INVOKE      (DF_DST_BASE + 5)
+#define DF_BUILTIN     (DF_DST_BASE + 6)
+
+#define DF_COPY        (DF_DST_BASE + 7)
+#define DF_MOVE        (DF_DST_BASE + 8)
+
+#define DF_DUP         -1
+#define DF_DUP_X1      -1
+#define DF_DUP_X2      -1
+#define DF_DUP2        -1
+#define DF_DUP2_X1     -1
+#define DF_DUP2_X2     -1
+#define DF_SWAP        -1
+
+/* special data-flow recognized by verify/generate.pl: */
+#define DF_LOAD        DF_COPY
+#define DF_STORE       DF_MOVE
+#define DF_IINC        DF_1_TO_1
+#define DF_POP         DF_1_TO_0
+#define DF_POP2        DF_2_TO_0
+
+
+// Control-flow constants for the ICMD table.
+#define CF_NORMAL      0
+#define CF_IF          1
+
+#define CF_END_BASE    2  /* from here on, they mark the end of a superblock */
+
+#define CF_END         (CF_END_BASE + 0)
+#define CF_GOTO        (CF_END_BASE + 1)
+#define CF_TABLE       (CF_END_BASE + 2)
+#define CF_LOOKUP      (CF_END_BASE + 3)
+#define CF_JSR         (CF_END_BASE + 4)
+#define CF_RET         (CF_END_BASE + 5)
+
+
+// Flag constants for the ICMD table.
+#define ICMDTABLE_PEI    0x0001               /* ICMD may throw an exception */
+#define ICMDTABLE_CALLS  0x0002     /* needs registers to be saved, may call */
+
+
+// ICMD table entry.
+typedef struct icmdtable_entry_t icmdtable_entry_t;
+
+struct icmdtable_entry_t {
+#if !defined(NDEBUG)
+       const char* name;                           /* name, without ICMD_ prefix */
+#endif
+       int32_t dataflow;                            /* a DF_ constant, see above */
+       int32_t controlflow;                         /* a CF_ constant, see above */
+       int32_t flags;                       /* a combination of ICMDTABLE_ flags */
+};
+
+
+// The ICMD table.
+extern icmdtable_entry_t icmd_table[256];
+
+#endif // _ICMD_HPP
+
+
+/*
+ * 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/jit/ir/icmdtable.inc b/src/vm/jit/ir/icmdtable.inc
new file mode 100644 (file)
index 0000000..4b0639c
--- /dev/null
@@ -0,0 +1,310 @@
+/*** The ICMD Table ***/
+
+/* IMPORTANT: This file must be in a fixed format, as it is both included in */
+/* src/vm/jit/jit.c, and parsed by src/vm/jit/verify/generate.pl!            */
+/*                                                                           */
+/* The comments at the start of the line and inside the braces are           */
+/* significant. If you want to add a comment to an ICMD, do that after the   */
+/* comma, or brace, at the end of the line.                                  */
+/*                                                                           */
+/* The format is as follows (slashes reversed for obvious reasons):          */
+/*                                                                           */
+/* \*#*\ { N( name )  data-flow, control-flow, flags \* stage (action) *\ }  */
+/*                                                                           */
+/*  ^^^                                                                      */
+/* opcode                                                                    */
+/*                                                                           */
+/* where                                                                     */
+/*     opcode...........is the opcode number (decimal)                       */
+/*     name.............is the quoted name without the ICMD_ prefix          */
+/*     data-flow........is one of the DF_ constants (see jit.h)              */
+/*     control-flow.....is one of the CF_ constants (see jit.h)              */
+/*     flags............is 0 or a |-combination of                           */
+/*                          PEI........may throw an exception                */
+/*                          CALLS......needs saved registers (calls out)     */
+/*                          *_CALLS....see jit.h for architecture specific   */
+/*                                     constants to put here                 */
+/*                                                                           */
+/*     stage............is either empty, or one of                           */
+/*                          --         ICMD is not used anywhere after parse */
+/*                          -S         ICMD is eliminated by stack_analyse   */
+/*                          S+         ICMD is introduced by stack_analyse   */
+/*                                                                           */
+/*     action...........is the stack action of the ICMD in the notation      */
+/*                      instack--outstack, TOS being rightmost.              */
+/*                                                                           */
+/*                      Valid type characters are                            */
+/*                          I, L, F, D, and A      the basic types           */
+/*                          1                      a category 1 type         */
+/*                          2                      a category 2 type         */
+/*                          .                      variable number of slots  */
+/*                                                                           */
+/*                      Whitespace is not allowed within the action.         */
+/*                                                                           */
+/*                      Some ICMDs may have several variants. In this case   */
+/*                      the action is build by joining the individual        */
+/*                      actions of the variants with |.                      */
+/*                                                                           */
+/*                                                                           */
+/* CAUTION: Do not use preprocessor directives in this file! They will       */
+/*          confuse the generator.                                           */
+/*                                                                           */
+
+
+/*  0*/ {N("NOP            ") DF_0_TO_0 , CF_NORMAL, 0              /*    (--)                 */},
+/*  1*/ {N("ACONST         ") DF_0_TO_1 , CF_NORMAL, PEI            /*    (--A)                */},
+/*  2*/ {N("CHECKNULL      ") DF_1_TO_1 , CF_NORMAL, PEI            /*    (A--A)               */},
+/*  3*/ {N("ICONST         ") DF_0_TO_1 , CF_NORMAL, 0              /*    (--I)                */},
+/*  4*/ {N("UNDEF4         ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*  5*/ {N("IDIVPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/*  6*/ {N("LDIVPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/*  7*/ {N("UNDEF7         ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*  8*/ {N("UNDEF8         ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*  9*/ {N("LCONST         ") DF_0_TO_1 , CF_NORMAL, 0              /*    (--L)                */},
+/* 10*/ {N("LCMPCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--I)               */},
+/* 11*/ {N("FCONST         ") DF_0_TO_1 , CF_NORMAL, 0              /*    (--F)                */},
+/* 12*/ {N("UNDEF12        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 13*/ {N("UNDEF13        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 14*/ {N("DCONST         ") DF_0_TO_1 , CF_NORMAL, 0              /*    (--D)                */},
+/* 15*/ {N("COPY           ") DF_COPY   , CF_NORMAL, 0              /* S+ (1--1)               */},
+/* 16*/ {N("MOVE           ") DF_MOVE   , CF_NORMAL, 0              /* S+ (1--1)               */},
+/* 17*/ {N("UNDEF17        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 18*/ {N("UNDEF18        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 19*/ {N("UNDEF19        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 20*/ {N("UNDEF20        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 21*/ {N("ILOAD          ") DF_LOAD   , CF_NORMAL, 0              /*    (--I)                */},
+/* 22*/ {N("LLOAD          ") DF_LOAD   , CF_NORMAL, 0              /*    (--L)                */},
+/* 23*/ {N("FLOAD          ") DF_LOAD   , CF_NORMAL, 0              /*    (--F)                */},
+/* 24*/ {N("DLOAD          ") DF_LOAD   , CF_NORMAL, 0              /*    (--D)                */},
+/* 25*/ {N("ALOAD          ") DF_LOAD   , CF_NORMAL, 0              /*    (--A)                */},
+/* 26*/ {N("IADDCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/* 27*/ {N("ISUBCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/* 28*/ {N("IMULCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/* 29*/ {N("IANDCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/* 30*/ {N("IORCONST       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/* 31*/ {N("IXORCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/* 32*/ {N("ISHLCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/* 33*/ {N("ISHRCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/* 34*/ {N("IUSHRCONST     ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/* 35*/ {N("IREMPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/* 36*/ {N("LADDCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/* 37*/ {N("LSUBCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/* 38*/ {N("LMULCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/* 39*/ {N("LANDCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/* 40*/ {N("LORCONST       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/* 41*/ {N("LXORCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/* 42*/ {N("LSHLCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/* 43*/ {N("LSHRCONST      ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/* 44*/ {N("LUSHRCONST     ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/* 45*/ {N("LREMPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/* 46*/ {N("IALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--I)              */},
+/* 47*/ {N("LALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--L)              */},
+/* 48*/ {N("FALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--F)              */},
+/* 49*/ {N("DALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--D)              */},
+/* 50*/ {N("AALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--A)              */},
+/* 51*/ {N("BALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--I)              */},
+/* 52*/ {N("CALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--I)              */},
+/* 53*/ {N("SALOAD         ") DF_2_TO_1 , CF_NORMAL, PEI            /*    (AI--I)              */},
+/* 54*/ {N("ISTORE         ") DF_STORE  , CF_NORMAL, 0              /*    (I--)                */},
+/* 55*/ {N("LSTORE         ") DF_STORE  , CF_NORMAL, 0              /*    (L--)                */},
+/* 56*/ {N("FSTORE         ") DF_STORE  , CF_NORMAL, 0              /*    (F--)                */},
+/* 57*/ {N("DSTORE         ") DF_STORE  , CF_NORMAL, 0              /*    (D--)                */},
+/* 58*/ {N("ASTORE         ") DF_STORE  , CF_NORMAL, 0              /*    (A--|R--)            */},
+/* 59*/ {N("IF_LEQ         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
+/* 60*/ {N("IF_LNE         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
+/* 61*/ {N("IF_LLT         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
+/* 62*/ {N("IF_LGE         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
+/* 63*/ {N("IF_LGT         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
+/* 64*/ {N("IF_LLE         ") DF_1_TO_0 , CF_IF    , 0              /* S+ (L--)                */},
+/* 65*/ {N("IF_LCMPEQ      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
+/* 66*/ {N("IF_LCMPNE      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
+/* 67*/ {N("IF_LCMPLT      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
+/* 68*/ {N("IF_LCMPGE      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
+/* 69*/ {N("IF_LCMPGT      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
+/* 70*/ {N("IF_LCMPLE      ") DF_2_TO_0 , CF_IF    , 0              /* S+ (LL--)               */},
+/* 71*/ {N("UNDEF71        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 72*/ {N("UNDEF72        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 73*/ {N("UNDEF73        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 74*/ {N("UNDEF74        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 75*/ {N("UNDEF75        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 76*/ {N("UNDEF76        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 77*/ {N("UNDEF77        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 78*/ {N("UNDEF78        ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/* 79*/ {N("IASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AII--)              */},
+/* 80*/ {N("LASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AIL--)              */},
+/* 81*/ {N("FASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AIF--)              */},
+/* 82*/ {N("DASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AID--)              */},
+/* 83*/ {N("AASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI|CALLS      /*    (AIA--)              */},
+/* 84*/ {N("BASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AII--)              */},
+/* 85*/ {N("CASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AII--)              */},
+/* 86*/ {N("SASTORE        ") DF_3_TO_0 , CF_NORMAL, PEI            /*    (AII--)              */},
+/* 87*/ {N("POP            ") DF_POP    , CF_NORMAL, 0              /*    (1--)                */},
+/* 88*/ {N("POP2           ") DF_POP2   , CF_NORMAL, 0              /*    (11--|2--)           */},
+/* 89*/ {N("DUP            ") DF_DUP    , CF_NORMAL, 0              /* -S (1--11)              */},
+/* 90*/ {N("DUP_X1         ") DF_DUP_X1 , CF_NORMAL, 0              /* -S (11--111)            */},
+/* 91*/ {N("DUP_X2         ") DF_DUP_X2 , CF_NORMAL, 0              /* -S (111--1111|21--121)  */},
+/* 92*/ {N("DUP2           ") DF_DUP2   , CF_NORMAL, 0              /* -S (11--1111|2--22)     */},
+/* 93*/ {N("DUP2_X1        ") DF_DUP2_X1, CF_NORMAL, 0              /* -S (111--11111|12--212) */},
+/* 94*/ {N("DUP2_X2        ") DF_DUP2_X2, CF_NORMAL, 0              /* -S (1111--111111|112--2112|22--222|211--11211) */},
+/* 95*/ {N("SWAP           ") DF_SWAP   , CF_NORMAL, 0              /* -S (11--11)             */},
+/* 96*/ {N("IADD           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
+/* 97*/ {N("LADD           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
+/* 98*/ {N("FADD           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--F)              */},
+/* 99*/ {N("DADD           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--D)              */},
+/*100*/ {N("ISUB           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
+/*101*/ {N("LSUB           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
+/*102*/ {N("FSUB           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--F)              */},
+/*103*/ {N("DSUB           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--D)              */},
+/*104*/ {N("IMUL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
+/*105*/ {N("LMUL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
+/*106*/ {N("FMUL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--F)              */},
+/*107*/ {N("DMUL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--D)              */},
+/*108*/ {N("IDIV           ") DF_2_TO_1 , CF_NORMAL, PEI|IDIV_CALLS /*    (II--I)              */},
+/*109*/ {N("LDIV           ") DF_2_TO_1 , CF_NORMAL, PEI|LDIV_CALLS /*    (LL--L)              */},
+/*110*/ {N("FDIV           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--F)              */},
+/*111*/ {N("DDIV           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--D)              */},
+/*112*/ {N("IREM           ") DF_2_TO_1 , CF_NORMAL, PEI|IDIV_CALLS /*    (II--I)              */},
+/*113*/ {N("LREM           ") DF_2_TO_1 , CF_NORMAL, PEI|LDIV_CALLS /*    (LL--L)              */},
+/*114*/ {N("FREM           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--F)              */},
+/*115*/ {N("DREM           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--D)              */},
+/*116*/ {N("INEG           ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--I)               */},
+/*117*/ {N("LNEG           ") DF_1_TO_1 , CF_NORMAL, 0              /*    (L--L)               */},
+/*118*/ {N("FNEG           ") DF_1_TO_1 , CF_NORMAL, 0              /*    (F--F)               */},
+/*119*/ {N("DNEG           ") DF_1_TO_1 , CF_NORMAL, 0              /*    (D--D)               */},
+/*120*/ {N("ISHL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
+/*121*/ {N("LSHL           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LI--L)              */},
+/*122*/ {N("ISHR           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
+/*123*/ {N("LSHR           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LI--L)              */},
+/*124*/ {N("IUSHR          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
+/*125*/ {N("LUSHR          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LI--L)              */},
+/*126*/ {N("IAND           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
+/*127*/ {N("LAND           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
+/*128*/ {N("IOR            ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
+/*129*/ {N("LOR            ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
+/*130*/ {N("IXOR           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (II--I)              */},
+/*131*/ {N("LXOR           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--L)              */},
+/*132*/ {N("IINC           ") DF_IINC   , CF_NORMAL, 0              /*    (--)                 */},
+/*133*/ {N("I2L            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--L)               */},
+/*134*/ {N("I2F            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--F)               */},
+/*135*/ {N("I2D            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--D)               */},
+/*136*/ {N("L2I            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (L--I)               */},
+/*137*/ {N("L2F            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (L--F)               */},
+/*138*/ {N("L2D            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (L--D)               */},
+/*139*/ {N("F2I            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (F--I)               */},
+/*140*/ {N("F2L            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (F--L)               */},
+/*141*/ {N("F2D            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (F--D)               */},
+/*142*/ {N("D2I            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (D--I)               */},
+/*143*/ {N("D2L            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (D--L)               */},
+/*144*/ {N("D2F            ") DF_1_TO_1 , CF_NORMAL, 0              /*    (D--F)               */},
+/*145*/ {N("INT2BYTE       ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--I)               */},
+/*146*/ {N("INT2CHAR       ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--I)               */},
+/*147*/ {N("INT2SHORT      ") DF_1_TO_1 , CF_NORMAL, 0              /*    (I--I)               */},
+/*148*/ {N("LCMP           ") DF_2_TO_1 , CF_NORMAL, 0              /*    (LL--I)              */},
+/*149*/ {N("FCMPL          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--I)              */},
+/*150*/ {N("FCMPG          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (FF--I)              */},
+/*151*/ {N("DCMPL          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--I)              */},
+/*152*/ {N("DCMPG          ") DF_2_TO_1 , CF_NORMAL, 0              /*    (DD--I)              */},
+/*153*/ {N("IFEQ           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
+/*154*/ {N("IFNE           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
+/*155*/ {N("IFLT           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
+/*156*/ {N("IFGE           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
+/*157*/ {N("IFGT           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
+/*158*/ {N("IFLE           ") DF_1_TO_0 , CF_IF    , 0              /*    (I--)                */},
+/*159*/ {N("IF_ICMPEQ      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
+/*160*/ {N("IF_ICMPNE      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
+/*161*/ {N("IF_ICMPLT      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
+/*162*/ {N("IF_ICMPGE      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
+/*163*/ {N("IF_ICMPGT      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
+/*164*/ {N("IF_ICMPLE      ") DF_2_TO_0 , CF_IF    , 0              /*    (II--)               */},
+/*165*/ {N("IF_ACMPEQ      ") DF_2_TO_0 , CF_IF    , 0              /*    (AA--)               */},
+/*166*/ {N("IF_ACMPNE      ") DF_2_TO_0 , CF_IF    , 0              /*    (AA--)               */},
+/*167*/ {N("GOTO           ") DF_0_TO_0 , CF_GOTO  , 0              /*    (--)                 */},
+/*168*/ {N("JSR            ") DF_0_TO_1 , CF_JSR   , 0              /*    (--R)                */},
+/*169*/ {N("RET            ") DF_0_TO_0 , CF_RET   , 0              /*    (--)                 */},
+/*170*/ {N("TABLESWITCH    ") DF_1_TO_0 , CF_TABLE , 0              /*    (I--)                */},
+/*171*/ {N("LOOKUPSWITCH   ") DF_1_TO_0 , CF_LOOKUP, 0              /*    (I--)                */},
+/*172*/ {N("IRETURN        ") DF_1_TO_0 , CF_END   , 0              /*    (I--)                */},
+/*173*/ {N("LRETURN        ") DF_1_TO_0 , CF_END   , 0              /*    (L--)                */},
+/*174*/ {N("FRETURN        ") DF_1_TO_0 , CF_END   , 0              /*    (F--)                */},
+/*175*/ {N("DRETURN        ") DF_1_TO_0 , CF_END   , 0              /*    (D--)                */},
+/*176*/ {N("ARETURN        ") DF_1_TO_0 , CF_END   , PEI            /*    (A--)                */},
+/*177*/ {N("RETURN         ") DF_0_TO_0 , CF_END   , 0              /*    (--)                 */},
+/*178*/ {N("GETSTATIC      ") DF_0_TO_1 , CF_NORMAL, PEI            /*    (--1|--2)            */},
+/*179*/ {N("PUTSTATIC      ") DF_1_TO_0 , CF_NORMAL, PEI            /*    (1--|2--)            */},
+/*180*/ {N("GETFIELD       ") DF_1_TO_1 , CF_NORMAL, PEI            /*    (A--1|A--2)          */},
+/*181*/ {N("PUTFIELD       ") DF_2_TO_0 , CF_NORMAL, PEI            /*    (A1--|A2--)          */},
+/*182*/ {N("INVOKEVIRTUAL  ") DF_INVOKE , CF_NORMAL, PEI|CALLS      /*    (.--1|.--2|.--)      */},
+/*183*/ {N("INVOKESPECIAL  ") DF_INVOKE , CF_NORMAL, PEI|CALLS      /*    (.--1|.--2|.--)      */},
+/*184*/ {N("INVOKESTATIC   ") DF_INVOKE , CF_NORMAL, PEI|CALLS      /*    (.--1|.--2|.--)      */},
+/*185*/ {N("INVOKEINTERFACE") DF_INVOKE , CF_NORMAL, PEI|CALLS      /*    (.--1|.--2|.--)      */},
+/*186*/ {N("UNDEF186       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*187*/ {N("NEW            ") DF_0_TO_1 , CF_NORMAL, PEI            /* -- (--A)                */},
+/*188*/ {N("NEWARRAY       ") DF_0_TO_1 , CF_NORMAL, PEI            /* -- (--A)                */},
+/*189*/ {N("ANEWARRAY      ") DF_0_TO_1 , CF_NORMAL, PEI            /* -- (--A)                */},
+/*190*/ {N("ARRAYLENGTH    ") DF_1_TO_1 , CF_NORMAL, PEI            /*    (A--I)               */},
+/*191*/ {N("ATHROW         ") DF_1_TO_0 , CF_END   , PEI            /*    (A--)                */},
+/*192*/ {N("CHECKCAST      ") DF_1_TO_1 , CF_NORMAL, PEI|CALLS      /*    (A--A)               */},
+/*193*/ {N("INSTANCEOF     ") DF_1_TO_1 , CF_NORMAL, PEI|CALLS      /*    (A--I)               */},
+/*194*/ {N("MONITORENTER   ") DF_1_TO_0 , CF_NORMAL, PEI|CALLS      /* -- (A--)                */},
+/*195*/ {N("MONITOREXIT    ") DF_1_TO_0 , CF_NORMAL, PEI|CALLS      /* -- (A--)                */},
+/*196*/ {N("UNDEF196       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*197*/ {N("MULTIANEWARRAY ") DF_N_TO_1 , CF_NORMAL, PEI|CALLS      /*    (.--A)               */},
+/*198*/ {N("IFNULL         ") DF_1_TO_0 , CF_IF    , 0              /*    (A--)                */},
+/*199*/ {N("IFNONNULL      ") DF_1_TO_0 , CF_IF    , 0              /*    (A--)                */},
+/*200*/ {N("UNDEF200       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*201*/ {N("UNDEF201       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*202*/ {N("UNDEF202       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*203*/ {N("UNDEF203       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*204*/ {N("IASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
+/*205*/ {N("LASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
+/*206*/ {N("FASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
+/*207*/ {N("DASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
+/*208*/ {N("AASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
+/*209*/ {N("BASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
+/*210*/ {N("CASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
+/*211*/ {N("SASTORECONST   ") DF_2_TO_0 , CF_NORMAL, PEI            /* S+ (AI--)               */},
+/*212*/ {N("PUTSTATICCONST ") DF_0_TO_0 , CF_NORMAL, PEI            /* S+ (--)                 */},
+/*213*/ {N("PUTFIELDCONST  ") DF_1_TO_0 , CF_NORMAL, PEI            /* S+ (A--)                */},
+/*214*/ {N("IMULPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (I--I)               */},
+/*215*/ {N("LMULPOW2       ") DF_1_TO_1 , CF_NORMAL, 0              /* S+ (L--L)               */},
+/*216*/ {N("IF_FCMPEQ      ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*217*/ {N("IF_FCMPNE      ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*218*/ {N("IF_FCMPL_LT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*219*/ {N("IF_FCMPL_GE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*220*/ {N("IF_FCMPL_GT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*221*/ {N("IF_FCMPL_LE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*222*/ {N("IF_FCMPG_LT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*223*/ {N("IF_FCMPG_GE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*224*/ {N("IF_FCMPG_GT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*225*/ {N("IF_FCMPG_LE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*226*/ {N("IF_DCMPEQ      ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*227*/ {N("IF_DCMPNE      ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*228*/ {N("IF_DCMPL_LT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*229*/ {N("IF_DCMPL_GE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*230*/ {N("IF_DCMPL_GT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*231*/ {N("IF_DCMPL_LE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*232*/ {N("IF_DCMPG_LT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*233*/ {N("IF_DCMPG_GE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*234*/ {N("IF_DCMPG_GT    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*235*/ {N("IF_DCMPG_LE    ") DF_0_TO_0 , CF_IF    , 0              /* -- ()                   */},
+/*236*/ {N("UNDEF236       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*237*/ {N("UNDEF237       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*238*/ {N("UNDEF238       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*239*/ {N("UNDEF239       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*240*/ {N("UNDEF240       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*241*/ {N("UNDEF241       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*242*/ {N("UNDEF242       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*243*/ {N("UNDEF243       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*244*/ {N("UNDEF244       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*245*/ {N("UNDEF245       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*246*/ {N("UNDEF246       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*247*/ {N("UNDEF247       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*248*/ {N("UNDEF248       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*249*/ {N("GETEXCEPTION   ") DF_0_TO_1 , CF_NORMAL, 0              /* -- ()                   */},
+/*250*/ {N("PHI            ") DF_N_TO_1 , CF_NORMAL, 0              /* -- ()                   */},
+/*251*/ {N("INLINE_START   ") DF_0_TO_0 , CF_NORMAL, 0              /* S+ (--)                 */},
+/*252*/ {N("INLINE_END     ") DF_0_TO_0 , CF_NORMAL, 0              /* S+ (--)                 */},
+/*253*/ {N("INLINE_BODY    ") DF_0_TO_0 , CF_NORMAL, 0              /* S+ (--)                 */},
+/*254*/ {N("UNDEF254       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*255*/ {N("BUILTIN        ") DF_BUILTIN, CF_NORMAL, PEI|CALLS      /*    (.--1|.--2|.--)      */}
+
diff --git a/src/vm/jit/ir/instruction.cpp b/src/vm/jit/ir/instruction.cpp
new file mode 100644 (file)
index 0000000..9be1a6f
--- /dev/null
@@ -0,0 +1,66 @@
+/* src/vm/jit/ir/instruction.cpp - IR instruction
+
+   Copyright (C) 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 <stdint.h>
+
+#include "vm/descriptor.h"
+
+#include "vm/jit/ir/instruction.hpp"
+
+
+// REMOVEME
+extern "C" {
+
+methoddesc* instruction_call_site(const instruction* iptr)
+{
+       if (iptr->opc == ICMD_BUILTIN) {
+               return iptr->sx.s23.s3.bte->md;
+       }
+       else if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
+               return iptr->sx.s23.s3.um->methodref->parseddesc.md;
+       }
+       else {
+               return iptr->sx.s23.s3.fmiref->p.method->parseddesc;
+       }
+}
+
+}
+
+
+/*
+ * 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/jit/ir/instruction.hpp b/src/vm/jit/ir/instruction.hpp
new file mode 100644 (file)
index 0000000..c9f3e30
--- /dev/null
@@ -0,0 +1,277 @@
+/* src/vm/jit/ir/instruction.hpp - IR instruction
+
+   Copyright (C) 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 _INSTRUCTION_HPP
+#define _INSTRUCTION_HPP
+
+// Forward typedefs.
+typedef struct instruction instruction;
+typedef struct insinfo_inline insinfo_inline;
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/descriptor.h"
+
+#include "vm/jit/jit.hpp"
+#include "vm/jit/replace.hpp"
+
+#include "vm/jit/ir/icmd.hpp"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Instruction structure.
+
+/* branch_target_t: used in TABLESWITCH tables */
+
+typedef union {
+    int32_t                    insindex; /* used in parse                     */
+    basicblock                *block;    /* valid after parse                 */
+} branch_target_t;
+
+/* lookup_target_t: used in LOOKUPSWITCH tables */
+
+typedef struct {
+    int32_t                    value;    /* case value                        */
+    branch_target_t            target;   /* branch target, see above          */
+} lookup_target_t;
+
+/*** s1 operand ***/
+
+typedef union {
+       int32_t                    varindex;
+       int32_t                    argcount;
+} s1_operand_t;
+
+/*** s2 operand ***/
+
+typedef union {
+       int32_t                    varindex;
+       int32_t                   *args;
+    classref_or_classinfo      c;
+    unresolved_class          *uc;
+    uintptr_t                  constval;         /* for PUT*CONST             */
+    int32_t                    tablelow;         /* for TABLESWITCH           */
+    uint32_t                   lookupcount;      /* for LOOKUPSWITCH          */
+       int32_t                    retaddrnr;        /* for ASTORE                */
+       instruction              **iargs;            /* for PHI                   */
+} s2_operand_t;
+
+/*** s3 operand ***/
+
+typedef union {
+       int32_t                    varindex;
+    uintptr_t                  constval;
+    classref_or_classinfo      c;
+    constant_FMIref           *fmiref;
+    unresolved_method         *um;
+    unresolved_field          *uf;
+    insinfo_inline            *inlineinfo;       /* for INLINE_START/END      */
+    int32_t                    tablehigh;        /* for TABLESWITCH           */
+    branch_target_t            lookupdefault;    /* for LOOKUPSWITCH          */
+    branch_target_t            jsrtarget;        /* for JSR                   */
+       int32_t                    javaindex;        /* for *STORE                */
+    struct builtintable_entry *bte;
+} s3_operand_t;
+
+/*** val operand ***/
+
+typedef union {
+    int32_t                   i;
+    int64_t                   l;
+    float                     f;
+    double                    d;
+    void                     *anyptr;
+    java_handle_t            *stringconst;       /* for ACONST with string    */
+    classref_or_classinfo     c;                 /* for ACONST with class     */
+} val_operand_t;
+
+/*** dst operand ***/
+
+typedef union {
+       int32_t                    varindex;
+    basicblock                *block;       /* valid after parse              */
+    branch_target_t           *table;       /* for TABLESWITCH                */
+    lookup_target_t           *lookup;      /* for LOOKUPSWITCH               */
+    int32_t                    insindex;    /* used in parse                  */
+} dst_operand_t;
+
+/*** flags (32 bits) ***/
+
+#define INS_FLAG_BASICBLOCK    0x01    /* marks a basic block start           */
+#define INS_FLAG_UNRESOLVED    0x02    /* contains unresolved field/meth/class*/
+#define INS_FLAG_CLASS         0x04    /* for ACONST, PUT*CONST with class    */
+#define INS_FLAG_ARRAY         0x08    /* for CHECKCAST/INSTANCEOF with array */
+#define INS_FLAG_CHECK         0x10    /* for *ALOAD|*ASTORE: check index     */
+                                       /* for BUILTIN: check exception        */
+#define INS_FLAG_KILL_PREV     0x04    /* for *STORE, invalidate prev local   */
+#define INS_FLAG_KILL_NEXT     0x08    /* for *STORE, invalidate next local   */
+#define INS_FLAG_RETADDR       0x10    /* for ASTORE: op is a returnAddress   */
+
+#define INS_FLAG_ID_SHIFT      5
+#define INS_FLAG_ID_MASK       (~0 << INS_FLAG_ID_SHIFT)
+
+typedef union {
+    u4                  bits;
+} flags_operand_t;
+
+
+// Instruction.
+
+/* The instruction format for the intermediate representation: */
+
+struct instruction {
+    u2                      opc;    /* opcode       */
+    u2                      line;   /* line number  */
+#if SIZEOF_VOID_P == 8
+    flags_operand_t         flags;  /* 4 bytes      */
+#endif
+    s1_operand_t            s1;     /* pointer-size */
+    union {
+        struct {
+            s2_operand_t    s2;     /* pointer-size */
+            s3_operand_t    s3;     /* pointer-size */
+        } s23;                      /*     XOR      */
+        val_operand_t       val;    /*  long-size   */
+    } sx;
+    dst_operand_t           dst;    /* pointer-size */
+#if SIZEOF_VOID_P == 4
+    flags_operand_t         flags;  /* 4 bytes      */
+#endif
+#if defined(ENABLE_ESCAPE_REASON)
+       void *escape_reasons;
+#endif
+};
+
+
+#define INSTRUCTION_STARTS_BASICBLOCK(iptr) \
+       ((iptr)->flags.bits & INS_FLAG_BASICBLOCK)
+
+#define INSTRUCTION_IS_RESOLVED(iptr) \
+       (!((iptr)->flags.bits & INS_FLAG_UNRESOLVED))
+
+#define INSTRUCTION_IS_UNRESOLVED(iptr) \
+       ((iptr)->flags.bits & INS_FLAG_UNRESOLVED)
+
+#define INSTRUCTION_MUST_CHECK(iptr) \
+       ((iptr)->flags.bits & INS_FLAG_CHECK)
+
+#define INSTRUCTION_GET_FIELDREF(iptr,fref) \
+       do { \
+               if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
+                       fref = iptr->sx.s23.s3.uf->fieldref; \
+               else \
+                       fref = iptr->sx.s23.s3.fmiref; \
+       } while (0)
+
+#define INSTRUCTION_GET_METHODREF(iptr,mref) \
+       do { \
+               if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
+                       mref = iptr->sx.s23.s3.um->methodref; \
+               else \
+                       mref = iptr->sx.s23.s3.fmiref; \
+       } while (0)
+
+#define INSTRUCTION_GET_METHODDESC(iptr, md) \
+       do { \
+               if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
+                       md = iptr->sx.s23.s3.um->methodref->parseddesc.md; \
+               else \
+                       md = iptr->sx.s23.s3.fmiref->parseddesc.md; \
+       } while (0)
+
+
+/* additional info structs for special instructions ***************************/
+
+/* for ICMD_INLINE_START and ICMD_INLINE_END */
+
+struct insinfo_inline {
+       /* fields copied from the inlining tree ----------------------------------*/
+       insinfo_inline *parent;     /* insinfo of the surrounding inlining, if any*/
+       methodinfo     *method;     /* the inlined method starting/ending here    */
+       methodinfo     *outer;      /* the outer method suspended/resumed here    */
+       int32_t         synclocal;      /* local index used for synchronization   */
+       bool            synchronize;    /* true if synchronization is needed      */
+       int32_t         throughcount;   /* total # of pass-through variables      */
+       int32_t         paramcount;     /* number of parameters of original call  */
+       int32_t         stackvarscount; /* source stackdepth at INLINE_START      */
+       int32_t        *stackvars;      /* stack vars at INLINE_START             */
+
+       /* fields set by inlining ------------------------------------------------*/
+       int32_t    *javalocals_start; /* javalocals at start of inlined body      */
+       int32_t    *javalocals_end;   /* javalocals after inlined body            */
+
+       /* fields set by replacement point creation ------------------------------*/
+#if defined(ENABLE_REPLACEMENT)
+       rplpoint   *rp;             /* replacement point at INLINE_START          */
+#endif
+
+       /* fields set by the codegen ---------------------------------------------*/
+       int32_t     startmpc;       /* machine code offset of start of inlining   */
+};
+
+
+/* Additional instruction accessors */
+
+methoddesc* instruction_call_site(const instruction* iptr);
+
+static inline bool instruction_has_dst(const instruction* iptr)
+{
+       if (
+               (icmd_table[iptr->opc].dataflow == DF_INVOKE) ||
+               (icmd_table[iptr->opc].dataflow == DF_BUILTIN)
+               ) {
+               return instruction_call_site(iptr)->returntype.type != TYPE_VOID;
+       }
+       else {
+               return icmd_table[iptr->opc].dataflow >= DF_DST_BASE;
+       }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _INSTRUCTION_HPP
+
+
+/*
+ * 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/jit/jit.c b/src/vm/jit/jit.c
deleted file mode 100644 (file)
index e6f17c2..0000000
+++ /dev/null
@@ -1,1215 +0,0 @@
-/* src/vm/jit/jit.c - calls the code generation 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 <stdint.h>
-
-#include "vm/types.h"
-
-#include "md.h"
-
-#include "mm/memory.h"
-
-#include "native/native.h"
-
-#include "toolbox/logging.h"
-
-#include "threads/lock-common.h"
-
-#include "vm/global.h"
-#include "vm/initialize.h"
-
-#include "vm/jit/asmpart.h"
-
-#include "vm/jit/cfg.h"
-
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/disass.h"
-#include "vm/jit/dseg.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/reg.h"
-
-#include "vm/jit/show.h"
-#include "vm/jit/stack.h"
-
-#include "vm/jit/allocator/simplereg.h"
-#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
-# include "vm/jit/allocator/lsra.h"
-#endif
-
-#if defined(ENABLE_SSA)
-# include "vm/jit/optimizing/lsra.h"
-# include "vm/jit/optimizing/ssa.h"
-#endif
-
-#if defined(ENABLE_INLINING)
-# include "vm/jit/inline/inline.h"
-#endif
-
-#include "vm/jit/ir/bytecode.h"
-
-#include "vm/jit/loop/analyze.h"
-#include "vm/jit/loop/graph.h"
-#include "vm/jit/loop/loop.h"
-
-#if defined(ENABLE_IFCONV)
-# include "vm/jit/optimizing/ifconv.h"
-#endif
-
-#include "vm/jit/optimizing/reorder.h"
-
-#if defined(ENABLE_PYTHON)
-# include "vm/jit/python.h"
-#endif
-
-#include "vm/jit/verify/typecheck.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-#include "vmcore/rt-timing.h"
-#include "vmcore/statistics.h"
-
-
-/* debug macros ***************************************************************/
-
-#if !defined(NDEBUG)
-#define DEBUG_JIT_COMPILEVERBOSE(x)                            \
-    do {                                                                               \
-        if (compileverbose) {                                  \
-            log_message_method(x, m);                  \
-        }                                                                              \
-    } while (0)
-#else
-#define DEBUG_JIT_COMPILEVERBOSE(x)    /* nothing */
-#endif
-
-#if !defined(NDEBUG)
-# define TRACECOMPILERCALLS()                                                          \
-       do {                                                                                                    \
-               if (opt_TraceCompilerCalls) {                                           \
-                       log_start();                                                                    \
-                       log_print("[JIT compiler started: method=");    \
-                       method_print(m);                                                                \
-                       log_print("]");                                                                 \
-                       log_finish();                                                                   \
-               }                                                                                                       \
-       } while (0)
-#else
-# define TRACECOMPILERCALLS()
-#endif
-
-
-/* the ICMD table ************************************************************/
-
-#if !defined(NDEBUG)
-#define N(name)  name,
-#else
-#define N(name)
-#endif
-
-/* abbreviations for flags */
-
-#define PEI     ICMDTABLE_PEI
-#define CALLS   ICMDTABLE_CALLS
-
-/* some machine dependent values */
-
-#if SUPPORT_DIVISION
-#define IDIV_CALLS  0
-#else
-#define IDIV_CALLS  ICMDTABLE_CALLS
-#endif
-
-#if (SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
-#define LDIV_CALLS  0
-#else
-#define LDIV_CALLS  ICMDTABLE_CALLS
-#endif
-
-/* include the actual table */
-
-icmdtable_entry_t icmd_table[256] = {
-#include <vm/jit/icmdtable.inc>
-};
-
-#undef N
-#undef PEI
-#undef CALLS
-
-/* XXX hack until the old "PEI" definition is removed */
-#define PEI 1
-
-
-/* jit_init ********************************************************************
-
-   Initializes the JIT subsystem.
-
-*******************************************************************************/
-
-void jit_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("jit_init");
-
-#if defined(ENABLE_JIT)
-       /* initialize stack analysis subsystem */
-
-       (void) stack_init();
-#endif
-
-       /* initialize show subsystem */
-
-#if !defined(NDEBUG)
-       (void) show_init();
-#endif
-
-       /* initialize codegen subsystem */
-
-       codegen_init();
-
-       /* initialize code subsystem */
-
-       (void) code_init();
-
-       /* Machine dependent initialization. */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               intrp_md_init();
-       else
-# endif
-               md_init();
-#else
-       intrp_md_init();
-#endif
-}
-
-
-/* jit_close *******************************************************************
-
-   Close the JIT subsystem.
-
-*******************************************************************************/
-
-void jit_close(void)
-{
-       /* do nothing */
-}
-
-
-/* dummy function, used when there is no JavaVM code available                */
-
-static u1 *do_nothing_function(void)
-{
-       return NULL;
-}
-
-
-/* jit_jitdata_new *************************************************************
-
-   Allocates and initalizes a new jitdata structure.
-
-*******************************************************************************/
-
-jitdata *jit_jitdata_new(methodinfo *m)
-{
-       jitdata  *jd;
-       codeinfo *code;
-
-       /* allocate jitdata structure and fill it */
-
-       jd = DNEW(jitdata);
-
-       jd->m     = m;
-       jd->cd    = DNEW(codegendata);
-       jd->rd    = DNEW(registerdata);
-#if defined(ENABLE_LOOP)
-       jd->ld    = DNEW(loopdata);
-#endif
-
-       /* Allocate codeinfo memory from the heap as we need to keep them. */
-
-       code = code_codeinfo_new(m);
-
-       /* Set codeinfo flags. */
-
-#if defined(ENABLE_THREADS)
-       if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               code_flag_synchronized(code);
-
-       if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               code_unflag_leafmethod(code);
-       else
-#endif
-               code_flag_leafmethod(code);
-
-       /* initialize variables */
-
-       jd->code                 = code;
-       jd->flags                = 0;
-       jd->exceptiontable       = NULL;
-       jd->exceptiontablelength = 0;
-       jd->returncount          = 0;
-       jd->branchtoentry        = false;
-       jd->branchtoend          = false;
-       jd->returncount          = 0;
-       jd->returnblock          = NULL;
-       jd->maxlocals            = m->maxlocals;
-
-       return jd;
-}
-
-
-/* jit_compile *****************************************************************
-
-   Translates one method to machine code.
-
-*******************************************************************************/
-
-static u1 *jit_compile_intern(jitdata *jd);
-
-u1 *jit_compile(methodinfo *m)
-{
-       u1      *r;
-       jitdata *jd;
-       int32_t  dumpmarker;
-
-       STATISTICS(count_jit_calls++);
-
-       /* Initialize the static function's class. */
-
-       /* ATTENTION: This MUST be done before the method lock is aquired,
-          otherwise we could run into a deadlock with <clinit>'s that
-          call static methods of it's own class. */
-
-       if ((m->flags & ACC_STATIC) && !(m->clazz->state & CLASS_INITIALIZED)) {
-#if !defined(NDEBUG)
-               if (initverbose)
-                       log_message_class("Initialize class ", m->clazz);
-#endif
-
-               if (!initialize_class(m->clazz))
-                       return NULL;
-
-               /* check if the method has been compiled during initialization */
-
-               if ((m->code != NULL) && (m->code->entrypoint != NULL))
-                       return m->code->entrypoint;
-       }
-
-       /* enter a monitor on the method */
-
-       LOCK_MONITOR_ENTER(m);
-
-       /* if method has been already compiled return immediately */
-
-       if (m->code != NULL) {
-               LOCK_MONITOR_EXIT(m);
-
-               assert(m->code->entrypoint);
-               return m->code->entrypoint;
-       }
-
-       TRACECOMPILERCALLS();
-
-       STATISTICS(count_methods++);
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getcompilingtime)
-               compilingtime_start();
-#endif
-
-       /* mark start of dump memory area */
-
-       DMARKER;
-
-       /* create jitdata structure */
-
-       jd = jit_jitdata_new(m);
-
-       /* set the flags for the current JIT run */
-
-       jd->flags = JITDATA_FLAG_PARSE;
-
-#if defined(ENABLE_VERIFIER)
-       if (opt_verify)
-               jd->flags |= JITDATA_FLAG_VERIFY;
-#endif
-
-#if defined(ENABLE_PROFILING)
-       if (opt_prof)
-               jd->flags |= JITDATA_FLAG_INSTRUMENT;
-#endif
-
-#if defined(ENABLE_IFCONV)
-       if (opt_ifconv)
-               jd->flags |= JITDATA_FLAG_IFCONV;
-#endif
-
-#if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG)
-       if (opt_Inline && opt_InlineAll)
-               jd->flags |= JITDATA_FLAG_INLINE;
-#endif
-
-       if (opt_showintermediate)
-               jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
-
-       if (opt_showdisassemble)
-               jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
-
-       if (opt_verbosecall)
-               jd->flags |= JITDATA_FLAG_VERBOSECALL;
-
-#if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING)
-       if (opt_Inline)
-               jd->flags |= JITDATA_FLAG_COUNTDOWN;
-#endif
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (!opt_intrp)
-# endif
-               /* initialize the register allocator */
-       {
-               reg_setup(jd);
-       }
-#endif
-
-       /* setup the codegendata memory */
-
-       codegen_setup(jd);
-
-       /* now call internal compile function */
-
-       r = jit_compile_intern(jd);
-
-       if (r == NULL) {
-               /* We had an exception! Finish stuff here if necessary. */
-
-               /* release codeinfo */
-
-               code_codeinfo_free(jd->code);
-
-#if defined(ENABLE_PROFILING)
-               /* Release memory for basic block profiling information. */
-
-               if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
-                       if (jd->code->bbfrequency != NULL)
-                               MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount);
-#endif
-       }
-       else {
-               DEBUG_JIT_COMPILEVERBOSE("Running: ");
-       }
-
-       /* release dump area */
-
-       DRELEASE;
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getcompilingtime)
-               compilingtime_stop();
-#endif
-
-       /* leave the monitor */
-
-       LOCK_MONITOR_EXIT(m);
-
-       /* return pointer to the methods entry point */
-
-       return r;
-}
-
-
-/* jit_recompile ***************************************************************
-
-   Recompiles a Java method.
-
-*******************************************************************************/
-
-u1 *jit_recompile(methodinfo *m)
-{
-       u1      *r;
-       jitdata *jd;
-       u1       optlevel;
-       int32_t  dumpmarker;
-
-       /* check for max. optimization level */
-
-       optlevel = (m->code) ? m->code->optlevel : 0;
-
-#if 0
-       if (optlevel == 1) {
-/*             log_message_method("not recompiling: ", m); */
-               return NULL;
-       }
-#endif
-
-       DEBUG_JIT_COMPILEVERBOSE("Recompiling start: ");
-
-       STATISTICS(count_jit_calls++);
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getcompilingtime)
-               compilingtime_start();
-#endif
-
-       /* mark start of dump memory area */
-
-       DMARKER;
-
-       /* create jitdata structure */
-
-       jd = jit_jitdata_new(m);
-
-       /* set the current optimization level to the previous one plus 1 */
-
-       jd->code->optlevel = optlevel + 1;
-
-       /* get the optimization flags for the current JIT run */
-
-#if defined(ENABLE_VERIFIER)
-       jd->flags |= JITDATA_FLAG_VERIFY;
-#endif
-
-       /* jd->flags |= JITDATA_FLAG_REORDER; */
-       if (opt_showintermediate)
-               jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
-       if (opt_showdisassemble)
-               jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
-       if (opt_verbosecall)
-               jd->flags |= JITDATA_FLAG_VERBOSECALL;
-
-#if defined(ENABLE_INLINING)
-       if (opt_Inline)
-               jd->flags |= JITDATA_FLAG_INLINE;
-#endif
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (!opt_intrp)
-# endif
-               /* initialize the register allocator */
-
-               reg_setup(jd);
-#endif
-
-       /* setup the codegendata memory */
-
-       codegen_setup(jd);
-
-       /* now call internal compile function */
-
-       r = jit_compile_intern(jd);
-
-       if (r == NULL) {
-               /* We had an exception! Finish stuff here if necessary. */
-
-               /* release codeinfo */
-
-               code_codeinfo_free(jd->code);
-       }
-
-       /* release dump area */
-
-       DRELEASE;
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getcompilingtime)
-               compilingtime_stop();
-#endif
-
-       DEBUG_JIT_COMPILEVERBOSE("Recompiling done: ");
-
-       /* return pointer to the methods entry point */
-
-       return r;
-}
-
-#if defined(ENABLE_PM_HACKS)
-#include "vm/jit/jit_pm_1.inc"
-#endif
-
-/* jit_compile_intern **********************************************************
-
-   Static internal function which does the actual compilation.
-
-*******************************************************************************/
-
-static u1 *jit_compile_intern(jitdata *jd)
-{
-       methodinfo  *m;
-       codegendata *cd;
-       codeinfo    *code;
-
-#if defined(ENABLE_RT_TIMING)
-       struct timespec time_start,time_checks,time_parse,time_stack,
-                                       time_typecheck,time_loop,time_ifconv,time_alloc,
-                                       time_codegen;
-#endif
-       
-       RT_TIMING_GET_TIME(time_start);
-
-       /* get required compiler data */
-
-#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
-       jd->ls = NULL;
-#endif
-       m    = jd->m;
-       code = jd->code;
-       cd   = jd->cd;
-       
-#if defined(ENABLE_DEBUG_FILTER)
-       show_filters_apply(jd->m);
-#endif
-
-       /* Handle native methods and create a native stub. */
-
-       if (m->flags & ACC_NATIVE) {
-               functionptr f;
-
-               f = native_method_resolve(m);
-
-               if (f == NULL)
-                       return NULL;
-
-               code = codegen_generate_stub_native(m, f);
-
-               /* Native methods are never recompiled. */
-               
-               assert(!m->code);
-
-               m->code = code;
-               
-               return code->entrypoint;
-       }
-
-       /* if there is no javacode, print error message and return empty method   */
-
-       if (m->jcode == NULL) {
-               DEBUG_JIT_COMPILEVERBOSE("No code given for: ");
-
-               code->entrypoint = (u1 *) (ptrint) do_nothing_function;
-               m->code = code;
-
-               return code->entrypoint;        /* return empty method                */
-       }
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat) {
-               count_javacodesize += m->jcodelength + 18;
-               count_tryblocks    += jd->exceptiontablelength;
-               count_javaexcsize  += jd->exceptiontablelength * SIZEOF_VOID_P;
-       }
-#endif
-
-       RT_TIMING_GET_TIME(time_checks);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       /* Code for Sun's OpenJDK (see
-          hotspot/src/share/vm/classfile/verifier.cpp
-          (Verifier::is_eligible_for_verification)): Don't verify
-          dynamically-generated bytecodes. */
-
-# if defined(ENABLE_VERIFIER)
-       if (class_issubclass(m->clazz, class_sun_reflect_MagicAccessorImpl))
-               jd->flags &= ~JITDATA_FLAG_VERIFY;
-# endif
-#endif
-
-       /* call the compiler passes ***********************************************/
-
-       DEBUG_JIT_COMPILEVERBOSE("Parsing: ");
-
-       /* call parse pass */
-
-       if (!parse(jd)) {
-               DEBUG_JIT_COMPILEVERBOSE("Exception while parsing: ");
-
-               return NULL;
-       }
-       RT_TIMING_GET_TIME(time_parse);
-
-       DEBUG_JIT_COMPILEVERBOSE("Parsing done: ");
-       
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (!opt_intrp) {
-# endif
-               DEBUG_JIT_COMPILEVERBOSE("Analysing: ");
-
-               /* call stack analysis pass */
-
-               if (!stack_analyse(jd)) {
-                       DEBUG_JIT_COMPILEVERBOSE("Exception while analysing: ");
-
-                       return NULL;
-               }
-               RT_TIMING_GET_TIME(time_stack);
-
-               DEBUG_JIT_COMPILEVERBOSE("Analysing done: ");
-
-#ifdef ENABLE_VERIFIER
-               if (JITDATA_HAS_FLAG_VERIFY(jd)) {
-                       DEBUG_JIT_COMPILEVERBOSE("Typechecking: ");
-
-                       /* call typecheck pass */
-                       if (!typecheck(jd)) {
-                               DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: ");
-
-                               return NULL;
-                       }
-
-                       DEBUG_JIT_COMPILEVERBOSE("Typechecking done: ");
-               }
-#endif
-               RT_TIMING_GET_TIME(time_typecheck);
-
-#if defined(ENABLE_SSA)
-               if (opt_lsra) {
-                       fix_exception_handlers(jd);
-               }
-#endif
-
-               /* Build the CFG.  This has to be done after stack_analyse, as
-                  there happens the JSR elimination. */
-
-               if (!cfg_build(jd))
-                       return NULL;
-
-#if defined(ENABLE_LOOP)
-               if (opt_loops) {
-                       depthFirst(jd);
-                       analyseGraph(jd);
-                       optimize_loops(jd);
-                       jit_renumber_basicblocks(jd);
-               }
-#endif
-               RT_TIMING_GET_TIME(time_loop);
-
-#if defined(ENABLE_IFCONV)
-               if (JITDATA_HAS_FLAG_IFCONV(jd)) {
-                       if (!ifconv_static(jd))
-                               return NULL;
-                       jit_renumber_basicblocks(jd);
-               }
-#endif
-               RT_TIMING_GET_TIME(time_ifconv);
-
-               /* inlining */
-
-#if defined(ENABLE_INLINING)
-               if (JITDATA_HAS_FLAG_INLINE(jd)) {
-                       if (!inline_inline(jd))
-                               return NULL;
-               }
-#endif
-
-#if defined(ENABLE_PROFILING)
-               /* Basic block reordering.  I think this should be done after
-                  if-conversion, as we could lose the ability to do the
-                  if-conversion. */
-
-               if (JITDATA_HAS_FLAG_REORDER(jd)) {
-                       if (!reorder(jd))
-                               return NULL;
-                       jit_renumber_basicblocks(jd);
-               }
-#endif
-
-#if defined(ENABLE_PM_HACKS)
-#include "vm/jit/jit_pm_2.inc"
-#endif
-               DEBUG_JIT_COMPILEVERBOSE("Allocating registers: ");
-
-#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
-               /* allocate registers */
-               if (opt_lsra) {
-                       if (!lsra(jd))
-                               return NULL;
-
-                       STATISTICS(count_methods_allocated_by_lsra++);
-
-               } else
-# endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */
-#if defined(ENABLE_SSA)
-               /* allocate registers */
-               if (
-                       (opt_lsra) 
-                       /*&& strncmp(jd->m->name->text, "banana", 6) == 0*/
-                       /*&& jd->exceptiontablelength == 0*/
-               ) {
-                       /* printf("=== %s ===\n", jd->m->name->text); */
-                       jd->ls = DNEW(lsradata);
-                       jd->ls = NULL;
-                       ssa(jd);
-                       /*lsra(jd);*/ regalloc(jd);
-                       eliminate_subbasicblocks(jd);
-                       STATISTICS(count_methods_allocated_by_lsra++);
-
-               } else
-# endif /* defined(ENABLE_SSA) */
-               {
-                       STATISTICS(count_locals_conflicts += (jd->maxlocals - 1) * (jd->maxlocals));
-
-                       regalloc(jd);
-               }
-
-               STATISTICS(simplereg_make_statistics(jd));
-
-               DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: ");
-# if defined(ENABLE_INTRP)
-       }
-# endif
-#endif /* defined(ENABLE_JIT) */
-       RT_TIMING_GET_TIME(time_alloc);
-
-#if defined(ENABLE_PROFILING)
-       /* Allocate memory for basic block profiling information. This
-          _must_ be done after loop optimization and register allocation,
-          since they can change the basic block count. */
-
-       if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
-               code->bbfrequency = MNEW(u4, jd->basicblockcount);
-#endif
-
-       DEBUG_JIT_COMPILEVERBOSE("Generating code: ");
-
-       /* now generate the machine code */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp) {
-#if defined(ENABLE_VERIFIER)
-               if (opt_verify) {
-                       DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): ");
-
-                       if (!typecheck_stackbased(jd)) {
-                               DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): ");
-                               return NULL;
-                       }
-               }
-#endif
-               if (!intrp_codegen(jd)) {
-                       DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
-
-                       return NULL;
-               }
-       } else
-# endif
-               {
-                       if (!codegen_generate(jd)) {
-                               DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
-
-                               return NULL;
-                       }
-               }
-#else
-       if (!intrp_codegen(jd)) {
-               DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
-
-               return NULL;
-       }
-#endif
-       RT_TIMING_GET_TIME(time_codegen);
-
-       DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
-
-#if !defined(NDEBUG) && defined(ENABLE_REPLACEMENT)
-       /* activate replacement points inside newly created code */
-
-       if (opt_TestReplacement)
-               replace_activate_replacement_points(code, false);
-#endif
-
-#if !defined(NDEBUG)
-#if defined(ENABLE_DEBUG_FILTER)
-       if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
-#endif
-       {
-               /* intermediate and assembly code listings */
-               
-               if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
-                       show_method(jd, SHOW_CODE);
-               }
-               else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
-# if defined(ENABLE_DISASSEMBLER)
-                       DISASSEMBLE(code->entrypoint,
-                                               code->entrypoint + (code->mcodelength - cd->dseglen));
-# endif
-               }
-
-               if (opt_showddatasegment)
-                       dseg_display(jd);
-       }
-#endif
-
-       /* switch to the newly generated code */
-
-       assert(code);
-       assert(code->entrypoint);
-
-       /* add the current compile version to the methodinfo */
-
-       code->prev = m->code;
-       m->code = code;
-
-       RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS);
-       RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE);
-       RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK);
-       RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK);
-       RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP);
-       RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC);
-       RT_TIMING_TIME_DIFF(time_alloc,time_codegen,RT_TIMING_JIT_CODEGEN);
-       RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL);
-
-       /* return pointer to the methods entry point */
-
-       return code->entrypoint;
-} 
-
-
-/* jit_invalidate_code *********************************************************
-
-   Mark the compiled code of the given method as invalid and take care that
-   it is replaced if necessary.
-
-   XXX Not fully implemented, yet.
-
-*******************************************************************************/
-
-void jit_invalidate_code(methodinfo *m)
-{
-       codeinfo *code;
-
-       code = m->code;
-
-       if (code == NULL || code_is_invalid(code))
-               return;
-
-       code_flag_invalid(code);
-
-       /* activate mappable replacement points */
-
-#if defined(ENABLE_REPLACEMENT)
-       replace_activate_replacement_points(code, true);
-#else
-       vm_abort("invalidating code only works with ENABLE_REPLACEMENT");
-#endif
-}
-
-
-/* jit_request_optimization ****************************************************
-
-   Request optimization of the given method. If the code of the method is
-   unoptimized, it will be invalidated, so the next jit_get_current_code(m)
-   triggers an optimized recompilation.
-   If the method is already optimized, this function does nothing.
-
-   IN:
-       m................the method
-
-*******************************************************************************/
-
-void jit_request_optimization(methodinfo *m)
-{
-       codeinfo *code;
-
-       code = m->code;
-
-       if (code && code->optlevel == 0)
-               jit_invalidate_code(m);
-}
-
-
-/* jit_get_current_code ********************************************************
-
-   Get the currently valid code for the given method. If there is no valid
-   code, (re)compile the method.
-
-   IN:
-       m................the method
-
-   RETURN VALUE:
-       the codeinfo* for the current code, or
-          NULL if an exception has been thrown during recompilation.
-
-*******************************************************************************/
-
-codeinfo *jit_get_current_code(methodinfo *m)
-{
-       assert(m);
-
-       /* if we have valid code, return it */
-
-       if (m->code && !code_is_invalid(m->code))
-               return m->code;
-
-       /* otherwise: recompile */
-
-       if (!jit_recompile(m))
-               return NULL;
-
-       assert(m->code);
-
-       return m->code;
-}
-
-
-/* jit_asm_compile *************************************************************
-
-   This method is called from asm_vm_call_method and does:
-
-     - create stackframe info for exceptions
-     - compile the method
-     - patch the entrypoint of the method into the calculated address in
-       the JIT code
-     - flushes the instruction cache.
-
-*******************************************************************************/
-
-#if defined(ENABLE_JIT)
-#if !defined(JIT_COMPILER_VIA_SIGNAL)
-u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra)
-{
-       stackframeinfo_t  sfi;
-       u1               *entrypoint;
-       u1               *pa;
-       ptrint           *p;
-
-       /* create the stackframeinfo (subtract 1 from RA as it points to the */
-       /* instruction after the call)                                       */
-
-       stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra-1);
-
-       /* actually compile the method */
-
-       entrypoint = jit_compile(m);
-
-       /* remove the stackframeinfo */
-
-       stacktrace_stackframeinfo_remove(&sfi);
-
-       /* there was a problem during compilation */
-
-       if (entrypoint == NULL)
-               return NULL;
-
-       /* get the method patch address */
-
-       pa = md_jit_method_patch_address(sfi.pv, (void *) ra, mptr);
-
-       /* patch the method entry point */
-
-       p = (ptrint *) pa;
-
-       *p = (ptrint) entrypoint;
-
-       /* flush the instruction cache */
-
-       md_icacheflush(pa, SIZEOF_VOID_P);
-
-       return entrypoint;
-}
-#endif
-
-/* jit_compile_handle **********************************************************
-
-   This method is called from the appropriate signal handler which
-   handles compiler-traps and does the following:
-
-     - compile the method
-     - patch the entrypoint of the method into the calculated address in
-       the JIT code
-     - flush the instruction cache
-
-*******************************************************************************/
-
-void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
-{
-       void      *newpv;                               /* new compiled method PV */
-       void      *pa;                                           /* patch address */
-       uintptr_t *p;                                      /* convenience pointer */
-
-       /* Compile the method. */
-
-       newpv = jit_compile(m);
-
-       /* There was a problem during compilation. */
-
-       if (newpv == NULL)
-               return NULL;
-
-       /* Get the method patch address. */
-
-       pa = md_jit_method_patch_address(pv, ra, mptr);
-
-       /* Patch the method entry point. */
-
-       p = (uintptr_t *) pa;
-
-       *p = (uintptr_t) newpv;
-
-       /* Flush both caches. */
-
-       md_cacheflush(pa, SIZEOF_VOID_P);
-
-       return newpv;
-}
-#endif /* defined(ENABLE_JIT) */
-
-
-/* jit_complement_condition ****************************************************
-
-   Returns the complement of the passed conditional instruction.
-
-   We use the order of the different conditions, e.g.:
-
-   ICMD_IFEQ         153
-   ICMD_IFNE         154
-
-   If the passed opcode is odd, we simply add 1 to get the complement.
-   If the opcode is even, we subtract 1.
-
-   Exception:
-
-   ICMD_IFNULL       198
-   ICMD_IFNONNULL    199
-
-*******************************************************************************/
-
-s4 jit_complement_condition(s4 opcode)
-{
-       switch (opcode) {
-       case ICMD_IFNULL:
-               return ICMD_IFNONNULL;
-
-       case ICMD_IFNONNULL:
-               return ICMD_IFNULL;
-
-       default:
-               /* check if opcode is odd */
-
-               if (opcode & 0x1)
-                       return opcode + 1;
-               else
-                       return opcode - 1;
-       }
-}
-
-
-/* jit_renumber_basicblocks ****************************************************
-
-   Set the ->nr of all blocks so it increases when traversing ->next.
-
-   IN:
-       jitdata..........the current jitdata
-
-*******************************************************************************/
-
-void jit_renumber_basicblocks(jitdata *jd)
-{
-       s4          nr;
-       basicblock *bptr;
-
-       nr = 0;
-       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
-               bptr->nr = nr++;
-       }
-
-       /* we have one block more than jd->basicblockcount (the end marker) */
-
-       assert(nr == jd->basicblockcount + 1);
-}
-
-
-/* jit_check_basicblock_numbers ************************************************
-
-   Assert that the ->nr of the first block is zero and increases by 1 each
-   time ->next is traversed.
-   This function should be called before any analysis that relies on
-   the basicblock numbers.
-
-   IN:
-       jitdata..........the current jitdata
-
-   NOTE: Aborts with an assertion if the condition is not met!
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void jit_check_basicblock_numbers(jitdata *jd)
-{
-       s4          nr;
-       basicblock *bptr;
-
-       nr = 0;
-       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
-               assert(bptr->nr == nr);
-               nr++;
-       }
-
-       /* we have one block more than jd->basicblockcount (the end marker) */
-
-       assert(nr == jd->basicblockcount + 1);
-}
-#endif /* !defined(NDEBUG) */
-
-methoddesc *instruction_call_site(const instruction *iptr) {
-       if (iptr->opc == ICMD_BUILTIN) {
-               return iptr->sx.s23.s3.bte->md;
-       } else if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
-               return iptr->sx.s23.s3.um->methodref->parseddesc.md;
-       } else {
-               return iptr->sx.s23.s3.fmiref->p.method->parseddesc;
-       }
-}
-
-/*
- * 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/jit/jit.cpp b/src/vm/jit/jit.cpp
new file mode 100644 (file)
index 0000000..baaf590
--- /dev/null
@@ -0,0 +1,1178 @@
+/* src/vm/jit/jit.cpp - Just-In-Time compiler
+
+   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 <stdint.h>
+
+#include "vm/types.h"
+
+#include "md.h"
+
+#include "mm/memory.h"
+
+#include "native/native.hpp"
+
+#include "toolbox/logging.h"
+
+#include "threads/mutex.hpp"
+
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/initialize.hpp"
+#include "vm/loader.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/rt-timing.h"
+#include "vm/statistics.h"
+
+#include "vm/jit/asmpart.h"
+
+#include "vm/jit/cfg.h"
+
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/disass.h"
+#include "vm/jit/dseg.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/reg.h"
+
+#include "vm/jit/show.hpp"
+#include "vm/jit/stack.h"
+#include "vm/jit/stubs.hpp"
+
+#if defined(ENABLE_OPAGENT)
+#include "vm/jit/oprofile-agent.hpp"
+#endif
+
+#include "vm/jit/allocator/simplereg.h"
+#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
+# include "vm/jit/allocator/lsra.h"
+#endif
+
+#if defined(ENABLE_SSA)
+# include "vm/jit/optimizing/lsra.h"
+# include "vm/jit/optimizing/ssa.h"
+#endif
+
+#if defined(ENABLE_INLINING)
+# include "vm/jit/inline/inline.hpp"
+#endif
+
+#include "vm/jit/ir/bytecode.h"
+
+#include "vm/jit/loop/analyze.h"
+#include "vm/jit/loop/graph.h"
+#include "vm/jit/loop/loop.h"
+
+#if defined(ENABLE_IFCONV)
+# include "vm/jit/optimizing/ifconv.h"
+#endif
+
+#include "vm/jit/optimizing/reorder.h"
+
+#if defined(ENABLE_PYTHON)
+# include "vm/jit/python.h"
+#endif
+
+#include "vm/jit/verify/typecheck.hpp"
+
+
+/* debug macros ***************************************************************/
+
+#if !defined(NDEBUG)
+#define DEBUG_JIT_COMPILEVERBOSE(x)                            \
+    do {                                                                               \
+        if (compileverbose) {                                  \
+            log_message_method(x, m);                  \
+        }                                                                              \
+    } while (0)
+#else
+#define DEBUG_JIT_COMPILEVERBOSE(x)    /* nothing */
+#endif
+
+#if !defined(NDEBUG)
+# define TRACECOMPILERCALLS()                                                          \
+       do {                                                                                                    \
+               if (opt_TraceCompilerCalls) {                                           \
+                       log_start();                                                                    \
+                       log_print("[JIT compiler started: method=");    \
+                       method_print(m);                                                                \
+                       log_print("]");                                                                 \
+                       log_finish();                                                                   \
+               }                                                                                                       \
+       } while (0)
+#else
+# define TRACECOMPILERCALLS()
+#endif
+
+
+/* jit_init ********************************************************************
+
+   Initializes the JIT subsystem.
+
+*******************************************************************************/
+
+void jit_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("jit_init");
+
+#if defined(ENABLE_JIT)
+       /* initialize stack analysis subsystem */
+
+       (void) stack_init();
+#endif
+
+       /* initialize show subsystem */
+
+#if !defined(NDEBUG)
+       (void) show_init();
+#endif
+
+       /* initialize codegen subsystem */
+
+       codegen_init();
+
+       /* initialize code subsystem */
+
+       (void) code_init();
+
+       /* Machine dependent initialization. */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               intrp_md_init();
+       else
+# endif
+               md_init();
+#else
+       intrp_md_init();
+#endif
+
+#if defined(ENABLE_OPAGENT)
+       if (opt_EnableOpagent)
+               OprofileAgent::initialize();
+#endif
+}
+
+
+/* jit_close *******************************************************************
+
+   Close the JIT subsystem.
+
+*******************************************************************************/
+
+void jit_close(void)
+{
+#if defined(ENABLE_OPAGENT)
+       if (opt_EnableOpagent)
+               OprofileAgent::close();
+#endif
+}
+
+
+/* dummy function, used when there is no JavaVM code available                */
+
+static u1 *do_nothing_function(void)
+{
+       return NULL;
+}
+
+
+/* jit_jitdata_new *************************************************************
+
+   Allocates and initalizes a new jitdata structure.
+
+*******************************************************************************/
+
+jitdata *jit_jitdata_new(methodinfo *m)
+{
+       jitdata  *jd;
+       codeinfo *code;
+
+       /* allocate jitdata structure and fill it */
+
+       jd = (jitdata*) DumpMemory::allocate(sizeof(jitdata));
+
+       jd->m     = m;
+       jd->cd    = (codegendata*) DumpMemory::allocate(sizeof(codegendata));
+       jd->rd    = (registerdata*) DumpMemory::allocate(sizeof(registerdata));
+#if defined(ENABLE_LOOP)
+       jd->ld    = (loopdata*) DumpMemory::allocate(sizeof(loopdata));
+#endif
+
+       /* Allocate codeinfo memory from the heap as we need to keep them. */
+
+       code = code_codeinfo_new(m);
+
+       /* Set codeinfo flags. */
+
+#if defined(ENABLE_THREADS)
+       if (checksync && (m->flags & ACC_SYNCHRONIZED))
+               code_flag_synchronized(code);
+
+       if (checksync && (m->flags & ACC_SYNCHRONIZED))
+               code_unflag_leafmethod(code);
+       else
+#endif
+               code_flag_leafmethod(code);
+
+       /* initialize variables */
+
+       jd->code                 = code;
+       jd->flags                = 0;
+       jd->exceptiontable       = NULL;
+       jd->exceptiontablelength = 0;
+       jd->returncount          = 0;
+       jd->branchtoentry        = false;
+       jd->branchtoend          = false;
+       jd->returncount          = 0;
+       jd->returnblock          = NULL;
+       jd->maxlocals            = m->maxlocals;
+
+       return jd;
+}
+
+
+/* jit_compile *****************************************************************
+
+   Translates one method to machine code.
+
+*******************************************************************************/
+
+static u1 *jit_compile_intern(jitdata *jd);
+
+u1 *jit_compile(methodinfo *m)
+{
+       u1      *r;
+       jitdata *jd;
+
+       STATISTICS(count_jit_calls++);
+
+       /* Initialize the static function's class. */
+
+       /* ATTENTION: This MUST be done before the method lock is aquired,
+          otherwise we could run into a deadlock with <clinit>'s that
+          call static methods of it's own class. */
+
+       if ((m->flags & ACC_STATIC) && !(m->clazz->state & CLASS_INITIALIZED)) {
+#if !defined(NDEBUG)
+               if (initverbose)
+                       log_message_class("Initialize class ", m->clazz);
+#endif
+
+               if (!initialize_class(m->clazz))
+                       return NULL;
+
+               /* check if the method has been compiled during initialization */
+
+               if ((m->code != NULL) && (m->code->entrypoint != NULL))
+                       return m->code->entrypoint;
+       }
+
+       /* enter a monitor on the method */
+
+       m->mutex->lock();
+
+       /* if method has been already compiled return immediately */
+
+       if (m->code != NULL) {
+               m->mutex->unlock();
+
+               assert(m->code->entrypoint);
+               return m->code->entrypoint;
+       }
+
+       TRACECOMPILERCALLS();
+
+       STATISTICS(count_methods++);
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getcompilingtime)
+               compilingtime_start();
+#endif
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       /* create jitdata structure */
+
+       jd = jit_jitdata_new(m);
+
+       /* set the flags for the current JIT run */
+
+       jd->flags = JITDATA_FLAG_PARSE;
+
+#if defined(ENABLE_VERIFIER)
+       if (opt_verify)
+               jd->flags |= JITDATA_FLAG_VERIFY;
+#endif
+
+#if defined(ENABLE_PROFILING)
+       if (opt_prof)
+               jd->flags |= JITDATA_FLAG_INSTRUMENT;
+#endif
+
+#if defined(ENABLE_IFCONV)
+       if (opt_ifconv)
+               jd->flags |= JITDATA_FLAG_IFCONV;
+#endif
+
+#if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG)
+       if (opt_Inline && opt_InlineAll)
+               jd->flags |= JITDATA_FLAG_INLINE;
+#endif
+
+       if (opt_showintermediate)
+               jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
+
+       if (opt_showdisassemble)
+               jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
+
+       if (opt_verbosecall)
+               jd->flags |= JITDATA_FLAG_VERBOSECALL;
+
+#if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING)
+       if (opt_Inline && (jd->m->hitcountdown > 0) && (jd->code->optlevel == 0)) {
+               jd->flags |= JITDATA_FLAG_COUNTDOWN;
+       }
+#endif
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (!opt_intrp)
+# endif
+               /* initialize the register allocator */
+       {
+               reg_setup(jd);
+       }
+#endif
+
+       /* setup the codegendata memory */
+
+       codegen_setup(jd);
+
+       /* now call internal compile function */
+
+       r = jit_compile_intern(jd);
+
+       if (r == NULL) {
+               /* We had an exception! Finish stuff here if necessary. */
+
+               /* release codeinfo */
+
+               code_codeinfo_free(jd->code);
+
+#if defined(ENABLE_PROFILING)
+               /* Release memory for basic block profiling information. */
+
+               if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
+                       if (jd->code->bbfrequency != NULL)
+                               MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount);
+#endif
+       }
+       else {
+               DEBUG_JIT_COMPILEVERBOSE("Running: ");
+       }
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getcompilingtime)
+               compilingtime_stop();
+#endif
+
+#if defined(ENABLE_OPAGENT)
+       if (opt_EnableOpagent)
+               OprofileAgent::newmethod(m);
+#endif
+
+       /* leave the monitor */
+
+       m->mutex->unlock();
+
+       /* return pointer to the methods entry point */
+
+       return r;
+}
+
+
+/* jit_recompile ***************************************************************
+
+   Recompiles a Java method.
+
+*******************************************************************************/
+
+u1 *jit_recompile(methodinfo *m)
+{
+       u1      *r;
+       jitdata *jd;
+       u1       optlevel;
+
+       /* check for max. optimization level */
+
+       optlevel = (m->code) ? m->code->optlevel : 0;
+
+#if 0
+       if (optlevel == 1) {
+/*             log_message_method("not recompiling: ", m); */
+               return NULL;
+       }
+#endif
+
+       DEBUG_JIT_COMPILEVERBOSE("Recompiling start: ");
+
+       STATISTICS(count_jit_calls++);
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getcompilingtime)
+               compilingtime_start();
+#endif
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       /* create jitdata structure */
+
+       jd = jit_jitdata_new(m);
+
+       /* set the current optimization level to the previous one plus 1 */
+
+       jd->code->optlevel = optlevel + 1;
+
+       /* get the optimization flags for the current JIT run */
+
+#if defined(ENABLE_VERIFIER)
+       jd->flags |= JITDATA_FLAG_VERIFY;
+#endif
+
+       /* jd->flags |= JITDATA_FLAG_REORDER; */
+       if (opt_showintermediate)
+               jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
+       if (opt_showdisassemble)
+               jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
+       if (opt_verbosecall)
+               jd->flags |= JITDATA_FLAG_VERBOSECALL;
+
+#if defined(ENABLE_INLINING)
+       if (opt_Inline)
+               jd->flags |= JITDATA_FLAG_INLINE;
+#endif
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (!opt_intrp)
+# endif
+               /* initialize the register allocator */
+
+               reg_setup(jd);
+#endif
+
+       /* setup the codegendata memory */
+
+       codegen_setup(jd);
+
+       /* now call internal compile function */
+
+       r = jit_compile_intern(jd);
+
+       if (r == NULL) {
+               /* We had an exception! Finish stuff here if necessary. */
+
+               /* release codeinfo */
+
+               code_codeinfo_free(jd->code);
+       }
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getcompilingtime)
+               compilingtime_stop();
+#endif
+
+#if defined(ENABLE_OPAGENT)
+       if (opt_EnableOpagent)
+               OprofileAgent::newmethod(m);
+#endif
+
+       DEBUG_JIT_COMPILEVERBOSE("Recompiling done: ");
+
+       /* return pointer to the methods entry point */
+
+       return r;
+}
+
+#if defined(ENABLE_PM_HACKS)
+#include "vm/jit/jit_pm_1.inc"
+#endif
+
+/* jit_compile_intern **********************************************************
+
+   Static internal function which does the actual compilation.
+
+*******************************************************************************/
+
+static u1 *jit_compile_intern(jitdata *jd)
+{
+       methodinfo  *m;
+       codegendata *cd;
+       codeinfo    *code;
+
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start,time_checks,time_parse,time_stack,
+                                       time_typecheck,time_loop,time_ifconv,time_alloc,
+                                       time_codegen;
+#endif
+       
+       RT_TIMING_GET_TIME(time_start);
+
+       /* get required compiler data */
+
+#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
+       jd->ls = NULL;
+#endif
+       m    = jd->m;
+       code = jd->code;
+       cd   = jd->cd;
+       
+#if defined(ENABLE_DEBUG_FILTER)
+       show_filters_apply(jd->m);
+#endif
+
+       // Handle native methods and create a native stub.
+       if (m->flags & ACC_NATIVE) {
+               NativeMethods& nm = VM::get_current()->get_nativemethods();
+               void* f = nm.resolve_method(m);
+
+               if (f == NULL)
+                       return NULL;
+
+               code = NativeStub::generate(m, (functionptr) f);
+
+               /* Native methods are never recompiled. */
+               
+               assert(!m->code);
+
+               m->code = code;
+               
+               return code->entrypoint;
+       }
+
+       /* if there is no javacode, print error message and return empty method   */
+
+       if (m->jcode == NULL) {
+               DEBUG_JIT_COMPILEVERBOSE("No code given for: ");
+
+               code->entrypoint = (u1 *) (ptrint) do_nothing_function;
+               m->code = code;
+
+               return code->entrypoint;        /* return empty method                */
+       }
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat) {
+               count_javacodesize += m->jcodelength + 18;
+               count_tryblocks    += jd->exceptiontablelength;
+               count_javaexcsize  += jd->exceptiontablelength * SIZEOF_VOID_P;
+       }
+#endif
+
+       RT_TIMING_GET_TIME(time_checks);
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       /* Code for Sun's OpenJDK (see
+          hotspot/src/share/vm/classfile/verifier.cpp
+          (Verifier::is_eligible_for_verification)): Don't verify
+          dynamically-generated bytecodes. */
+
+# if defined(ENABLE_VERIFIER)
+       if (class_issubclass(m->clazz, class_sun_reflect_MagicAccessorImpl))
+               jd->flags &= ~JITDATA_FLAG_VERIFY;
+# endif
+#endif
+
+       /* call the compiler passes ***********************************************/
+
+       DEBUG_JIT_COMPILEVERBOSE("Parsing: ");
+
+       /* call parse pass */
+
+       if (!parse(jd)) {
+               DEBUG_JIT_COMPILEVERBOSE("Exception while parsing: ");
+
+               return NULL;
+       }
+       RT_TIMING_GET_TIME(time_parse);
+
+       DEBUG_JIT_COMPILEVERBOSE("Parsing done: ");
+       
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (!opt_intrp) {
+# endif
+               DEBUG_JIT_COMPILEVERBOSE("Analysing: ");
+
+               /* call stack analysis pass */
+
+               if (!stack_analyse(jd)) {
+                       DEBUG_JIT_COMPILEVERBOSE("Exception while analysing: ");
+
+                       return NULL;
+               }
+               RT_TIMING_GET_TIME(time_stack);
+
+               DEBUG_JIT_COMPILEVERBOSE("Analysing done: ");
+
+#ifdef ENABLE_VERIFIER
+               if (JITDATA_HAS_FLAG_VERIFY(jd)) {
+                       DEBUG_JIT_COMPILEVERBOSE("Typechecking: ");
+
+                       /* call typecheck pass */
+                       if (!typecheck(jd)) {
+                               DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: ");
+
+                               return NULL;
+                       }
+
+                       DEBUG_JIT_COMPILEVERBOSE("Typechecking done: ");
+               }
+#endif
+               RT_TIMING_GET_TIME(time_typecheck);
+
+#if defined(ENABLE_LOOP)
+               if (opt_loops) {
+                       depthFirst(jd);
+                       analyseGraph(jd);
+                       optimize_loops(jd);
+                       jit_renumber_basicblocks(jd);
+               }
+#endif
+               RT_TIMING_GET_TIME(time_loop);
+
+#if defined(ENABLE_IFCONV)
+               if (JITDATA_HAS_FLAG_IFCONV(jd)) {
+                       if (!ifconv_static(jd))
+                               return NULL;
+                       jit_renumber_basicblocks(jd);
+               }
+#endif
+               RT_TIMING_GET_TIME(time_ifconv);
+
+               /* inlining */
+
+#if defined(ENABLE_INLINING) && (!defined(ENABLE_ESCAPE) || 1)
+               if (JITDATA_HAS_FLAG_INLINE(jd)) {
+                       if (!inline_inline(jd))
+                               return NULL;
+               }
+#endif
+
+#if defined(ENABLE_SSA)
+               if (opt_lsra) {
+                       fix_exception_handlers(jd);
+               }
+#endif
+
+               /* Build the CFG.  This has to be done after stack_analyse, as
+                  there happens the JSR elimination. */
+
+               if (!cfg_build(jd))
+                       return NULL;
+
+#if defined(ENABLE_PROFILING)
+               /* Basic block reordering.  I think this should be done after
+                  if-conversion, as we could lose the ability to do the
+                  if-conversion. */
+
+               if (JITDATA_HAS_FLAG_REORDER(jd)) {
+                       if (!reorder(jd))
+                               return NULL;
+                       jit_renumber_basicblocks(jd);
+               }
+#endif
+
+#if defined(ENABLE_PM_HACKS)
+#include "vm/jit/jit_pm_2.inc"
+#endif
+               DEBUG_JIT_COMPILEVERBOSE("Allocating registers: ");
+
+#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
+               /* allocate registers */
+               if (opt_lsra) {
+                       if (!lsra(jd))
+                               return NULL;
+
+                       STATISTICS(count_methods_allocated_by_lsra++);
+
+               } else
+# endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */
+#if defined(ENABLE_SSA)
+               /* allocate registers */
+               if (
+                       (opt_lsra &&
+                       jd->code->optlevel > 0) 
+                       /* strncmp(jd->m->name->text, "hottie", 6) == 0*/
+                       /*&& jd->exceptiontablelength == 0*/
+               ) {
+                       /*printf("=== %s ===\n", jd->m->name->text);*/
+                       jd->ls = (lsradata*) DumpMemory::allocate(sizeof(lsradata));
+                       jd->ls = NULL;
+                       ssa(jd);
+                       /*lsra(jd);*/ regalloc(jd);
+                       /*eliminate_subbasicblocks(jd);*/
+                       STATISTICS(count_methods_allocated_by_lsra++);
+
+               } else
+# endif /* defined(ENABLE_SSA) */
+               {
+                       STATISTICS(count_locals_conflicts += (jd->maxlocals - 1) * (jd->maxlocals));
+
+                       regalloc(jd);
+               }
+
+               STATISTICS(simplereg_make_statistics(jd));
+
+               DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: ");
+# if defined(ENABLE_INTRP)
+       }
+# endif
+#endif /* defined(ENABLE_JIT) */
+       RT_TIMING_GET_TIME(time_alloc);
+
+#if defined(ENABLE_PROFILING)
+       /* Allocate memory for basic block profiling information. This
+          _must_ be done after loop optimization and register allocation,
+          since they can change the basic block count. */
+
+       if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
+               code->bbfrequency = MNEW(u4, jd->basicblockcount);
+#endif
+
+       DEBUG_JIT_COMPILEVERBOSE("Generating code: ");
+
+       /* now generate the machine code */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (opt_intrp) {
+#if defined(ENABLE_VERIFIER)
+               if (opt_verify) {
+                       DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): ");
+
+                       if (!typecheck_stackbased(jd)) {
+                               DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): ");
+                               return NULL;
+                       }
+               }
+#endif
+               if (!intrp_codegen(jd)) {
+                       DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
+
+                       return NULL;
+               }
+       } else
+# endif
+               {
+                       if (!codegen_generate(jd)) {
+                               DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
+
+                               return NULL;
+                       }
+               }
+#else
+       if (!intrp_codegen(jd)) {
+               DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
+
+               return NULL;
+       }
+#endif
+       RT_TIMING_GET_TIME(time_codegen);
+
+       DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
+
+#if !defined(NDEBUG) && defined(ENABLE_REPLACEMENT)
+       /* activate replacement points inside newly created code */
+
+       if (opt_TestReplacement)
+               replace_activate_replacement_points(code, false);
+#endif
+
+#if !defined(NDEBUG)
+#if defined(ENABLE_DEBUG_FILTER)
+       if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
+#endif
+       {
+               /* intermediate and assembly code listings */
+               
+               if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
+                       show_method(jd, SHOW_CODE);
+               }
+               else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
+# if defined(ENABLE_DISASSEMBLER)
+                       DISASSEMBLE(code->entrypoint,
+                                               code->entrypoint + (code->mcodelength - cd->dseglen));
+# endif
+               }
+
+               if (opt_showddatasegment)
+                       dseg_display(jd);
+       }
+#endif
+
+       /* switch to the newly generated code */
+
+       assert(code);
+       assert(code->entrypoint);
+
+       /* add the current compile version to the methodinfo */
+
+       code->prev = m->code;
+       m->code = code;
+
+       RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS);
+       RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE);
+       RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK);
+       RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK);
+       RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP);
+       RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC);
+       RT_TIMING_TIME_DIFF(time_alloc,time_codegen,RT_TIMING_JIT_CODEGEN);
+       RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL);
+
+       /* return pointer to the methods entry point */
+
+       return code->entrypoint;
+} 
+
+
+/* jit_invalidate_code *********************************************************
+
+   Mark the compiled code of the given method as invalid and take care that
+   it is replaced if necessary.
+
+   XXX Not fully implemented, yet.
+
+*******************************************************************************/
+
+void jit_invalidate_code(methodinfo *m)
+{
+       codeinfo *code;
+
+       code = m->code;
+
+       if (code == NULL || code_is_invalid(code))
+               return;
+
+       code_flag_invalid(code);
+
+       /* activate mappable replacement points */
+
+#if defined(ENABLE_REPLACEMENT)
+       replace_activate_replacement_points(code, true);
+#else
+       vm_abort("invalidating code only works with ENABLE_REPLACEMENT");
+#endif
+}
+
+
+/* jit_request_optimization ****************************************************
+
+   Request optimization of the given method. If the code of the method is
+   unoptimized, it will be invalidated, so the next jit_get_current_code(m)
+   triggers an optimized recompilation.
+   If the method is already optimized, this function does nothing.
+
+   IN:
+       m................the method
+
+*******************************************************************************/
+
+void jit_request_optimization(methodinfo *m)
+{
+       codeinfo *code;
+
+       code = m->code;
+
+       if (code && code->optlevel == 0)
+               jit_invalidate_code(m);
+}
+
+
+/* jit_get_current_code ********************************************************
+
+   Get the currently valid code for the given method. If there is no valid
+   code, (re)compile the method.
+
+   IN:
+       m................the method
+
+   RETURN VALUE:
+       the codeinfo* for the current code, or
+          NULL if an exception has been thrown during recompilation.
+
+*******************************************************************************/
+
+codeinfo *jit_get_current_code(methodinfo *m)
+{
+       assert(m);
+
+       /* if we have valid code, return it */
+
+       if (m->code && !code_is_invalid(m->code))
+               return m->code;
+
+       /* otherwise: recompile */
+
+       if (!jit_recompile(m))
+               return NULL;
+
+       assert(m->code);
+
+       return m->code;
+}
+
+
+/* jit_asm_compile *************************************************************
+
+   This method is called from asm_vm_call_method and does:
+
+     - create stackframe info for exceptions
+     - compile the method
+     - patch the entrypoint of the method into the calculated address in
+       the JIT code
+     - flushes the instruction cache.
+
+*******************************************************************************/
+
+#if defined(ENABLE_JIT)
+#if !defined(JIT_COMPILER_VIA_SIGNAL)
+extern "C" {
+void* jit_asm_compile(methodinfo *m, void* mptr, void* sp, void* ra)
+{
+       stackframeinfo_t  sfi;
+       void             *entrypoint;
+       void             *pa;
+       uintptr_t        *p;
+
+       /* create the stackframeinfo (subtract 1 from RA as it points to the */
+       /* instruction after the call)                                       */
+
+       stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ((uint8_t*) ra) - 1);
+
+       /* actually compile the method */
+
+       entrypoint = jit_compile(m);
+
+       /* remove the stackframeinfo */
+
+       stacktrace_stackframeinfo_remove(&sfi);
+
+       /* there was a problem during compilation */
+
+       if (entrypoint == NULL)
+               return NULL;
+
+       /* get the method patch address */
+
+       pa = md_jit_method_patch_address(sfi.pv, (void *) ra, mptr);
+
+       /* patch the method entry point */
+
+       p = (uintptr_t*) pa;
+
+       *p = (uintptr_t) entrypoint;
+
+       /* flush the instruction cache */
+
+       md_icacheflush(pa, SIZEOF_VOID_P);
+
+       return entrypoint;
+}
+}
+#endif
+
+/* jit_compile_handle **********************************************************
+
+   This method is called from the appropriate signal handler which
+   handles compiler-traps and does the following:
+
+     - compile the method
+     - patch the entrypoint of the method into the calculated address in
+       the JIT code
+     - flush the instruction cache
+
+*******************************************************************************/
+
+void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
+{
+       void      *newpv;                               /* new compiled method PV */
+       void      *pa;                                           /* patch address */
+       uintptr_t *p;                                      /* convenience pointer */
+
+       /* Compile the method. */
+
+       newpv = jit_compile(m);
+
+       /* There was a problem during compilation. */
+
+       if (newpv == NULL)
+               return NULL;
+
+       /* Get the method patch address. */
+
+       pa = md_jit_method_patch_address(pv, ra, mptr);
+
+       /* Patch the method entry point. */
+
+       p = (uintptr_t *) pa;
+
+       *p = (uintptr_t) newpv;
+
+       /* Flush both caches. */
+
+       md_cacheflush(pa, SIZEOF_VOID_P);
+
+       return newpv;
+}
+#endif /* defined(ENABLE_JIT) */
+
+
+/* jit_complement_condition ****************************************************
+
+   Returns the complement of the passed conditional instruction.
+
+   We use the order of the different conditions, e.g.:
+
+   ICMD_IFEQ         153
+   ICMD_IFNE         154
+
+   If the passed opcode is odd, we simply add 1 to get the complement.
+   If the opcode is even, we subtract 1.
+
+   Exception:
+
+   ICMD_IFNULL       198
+   ICMD_IFNONNULL    199
+
+*******************************************************************************/
+
+s4 jit_complement_condition(s4 opcode)
+{
+       switch (opcode) {
+       case ICMD_IFNULL:
+               return ICMD_IFNONNULL;
+
+       case ICMD_IFNONNULL:
+               return ICMD_IFNULL;
+
+       default:
+               /* check if opcode is odd */
+
+               if (opcode & 0x1)
+                       return opcode + 1;
+               else
+                       return opcode - 1;
+       }
+}
+
+
+/* jit_renumber_basicblocks ****************************************************
+
+   Set the ->nr of all blocks so it increases when traversing ->next.
+
+   IN:
+       jitdata..........the current jitdata
+
+*******************************************************************************/
+
+void jit_renumber_basicblocks(jitdata *jd)
+{
+       s4          nr;
+       basicblock *bptr;
+
+       nr = 0;
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
+               bptr->nr = nr++;
+       }
+
+       /* we have one block more than jd->basicblockcount (the end marker) */
+
+       assert(nr == jd->basicblockcount + 1);
+}
+
+
+/* jit_check_basicblock_numbers ************************************************
+
+   Assert that the ->nr of the first block is zero and increases by 1 each
+   time ->next is traversed.
+   This function should be called before any analysis that relies on
+   the basicblock numbers.
+
+   IN:
+       jitdata..........the current jitdata
+
+   NOTE: Aborts with an assertion if the condition is not met!
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void jit_check_basicblock_numbers(jitdata *jd)
+{
+       s4          nr;
+       basicblock *bptr;
+
+       nr = 0;
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
+               assert(bptr->nr == nr);
+               nr++;
+       }
+
+       /* we have one block more than jd->basicblockcount (the end marker) */
+
+       assert(nr == jd->basicblockcount + 1);
+}
+#endif /* !defined(NDEBUG) */
+
+
+/*
+ * 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/jit/jit.h b/src/vm/jit/jit.h
deleted file mode 100644 (file)
index 448f0cc..0000000
+++ /dev/null
@@ -1,1059 +0,0 @@
-/* src/vm/jit/jit.h - code generation 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 _JIT_H
-#define _JIT_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct jitdata jitdata;
-typedef struct basicblock basicblock;
-typedef struct instruction instruction;
-typedef struct insinfo_inline insinfo_inline;
-typedef struct exception_entry exception_entry;
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "toolbox/chain.h"
-
-#include "vm/global.h"
-#include "vm/resolve.h"
-
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stack.h"
-#include "vm/jit/stacktrace.h"
-
-#if defined(ENABLE_INLINING)
-# include "vm/jit/inline/inline.h"
-#endif
-
-#include "vm/jit/ir/bytecode.h"
-
-#if defined(ENABLE_LOOP)
-# include "vm/jit/loop/loop.h"
-#endif
-#if defined(ENABLE_SSA) 
-# include "vm/jit/optimizing/lsra.h"
-#endif
-#if defined(ENABLE_LSRA)
-# include "vm/jit/allocator/lsra.h"
-#endif
-
-#include "vm/jit/verify/typeinfo.h"
-
-#include "vmcore/method.h"
-#include "vmcore/references.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
-
-/* common jit/codegen macros **************************************************/
-
-#if defined(ENABLE_STATISTICS)
-# define COUNT(x)        (x)++
-# define COUNT_SPILLS             /* use COUNT_(READ|WRITE)_SPILLS instead */
-# define COUNT_READ_SPILLS(var) \
-       switch(var->type) { \
-       case TYPE_FLT: count_spills_read_flt++; break; \
-       case TYPE_DBL: count_spills_read_dbl++; break; \
-       default: count_spills_read_ila++; break; \
-       }
-
-# define COUNT_WRITE_SPILLS(var) \
-       switch(var->type) { \
-       case TYPE_FLT: count_spills_write_flt++; break; \
-       case TYPE_DBL: count_spills_write_dbl++; break; \
-       default: count_spills_write_ila++; break; \
-       }
-
-#else
-# define COUNT(x)                /* nothing */
-# define COUNT_SPILLS            /* nothing */
-# define COUNT_READ_SPILLS(x)    /* nothing */
-# define COUNT_WRITE_SPILLS(x)   /* nothing */
-#endif
-
-typedef struct interface_info interface_info;
-
-struct interface_info {
-       s4 flags;
-       s4 regoff;
-};
-
-
-/* jitdata ********************************************************************/
-
-struct jitdata {
-       methodinfo      *m;               /* methodinfo of the method compiled    */
-       codeinfo        *code;
-       codegendata     *cd;
-       registerdata    *rd;
-#if defined(ENABLE_LOOP)
-       loopdata        *ld;
-#endif
-#if defined(ENABLE_SSA) || defined(ENABLE_LSRA)
-       lsradata        *ls;
-#endif
-
-       u4               flags;           /* contains JIT compiler flags          */
-
-       instruction     *instructions;    /* ICMDs, valid between parse and stack */
-       basicblock      *basicblocks;     /* start of basic block list            */
-       stackelement_t  *stack;           /* XXX should become stack.c internal   */
-       s4               instructioncount;/* XXX remove this?                     */
-       s4               basicblockcount; /* number of basic blocks               */
-       s4               stackcount;      /* number of stackelements to allocate  */
-                                      /* (passed from parse to stack)         */
-
-       varinfo         *var;             /* array of variables                   */
-       s4               vartop;          /* next free index in var array         */
-
-       s4               varcount;        /* number of variables in var array     */
-       s4               localcount;      /* number of locals at start of var ar. */
-    s4              *local_map;       /* map for renaming (de-coallescing)    */
-                                        /* locals and keeping the coalescing info for simplereg. */
-                        /* local_map[javaindex * 5 + type] =                     */
-                        /*     >= 0......index into jd->var, or                  */
-                                        /*     UNUSED....this (javaindex,type) pair is not used  */
-
-       s4              *reverselocalmap; /* map from CACAO varindex to javaindex */
-                                         /* (varindex must be < localcount)      */
-
-       s4               maxlocals;       /* max. number of javalocals            */
-
-       interface_info  *interface_map;   /* interface variables (for simplereg)  */
-       s4               maxinterfaces;   /* max. number of interface variables   */
-
-       s4               exceptiontablelength; /* exceptiontable length           */
-       exception_entry *exceptiontable;       /* the exceptiontable              */
-
-       basicblock      *returnblock;          /* block containing the *RETURN    */
-                                              /* (only use if returncount==1)    */
-       s4               returncount;          /* number of return instructions   */
-       bool             branchtoentry;        /* true if first block is a target */
-       bool             branchtoend;          /* true if end dummy is a target   */
-};
-
-#define FOR_EACH_BASICBLOCK(jd, it) \
-       for ((it) = (jd)->basicblocks; (it) != NULL; (it) = (it)->next)
-
-#define UNUSED                     -1
-
-#define JITDATA_FLAG_PARSE               0x00000001
-#define JITDATA_FLAG_VERIFY              0x00000002
-
-#define JITDATA_FLAG_INSTRUMENT          0x00000004
-
-#define JITDATA_FLAG_IFCONV              0x00000008
-#define JITDATA_FLAG_REORDER             0x00000010
-#define JITDATA_FLAG_INLINE              0x00000020
-
-#define JITDATA_FLAG_COUNTDOWN           0x00000100
-
-#define JITDATA_FLAG_SHOWINTERMEDIATE    0x20000000
-#define JITDATA_FLAG_SHOWDISASSEMBLE     0x40000000
-#define JITDATA_FLAG_VERBOSECALL         0x80000000
-
-
-#define JITDATA_HAS_FLAG_PARSE(jd) \
-    ((jd)->flags & JITDATA_FLAG_PARSE)
-
-#define JITDATA_HAS_FLAG_VERIFY(jd) \
-    ((jd)->flags & JITDATA_FLAG_VERIFY)
-
-#define JITDATA_HAS_FLAG_INSTRUMENT(jd) \
-    ((jd)->flags & JITDATA_FLAG_INSTRUMENT)
-
-#define JITDATA_HAS_FLAG_IFCONV(jd) \
-    ((jd)->flags & JITDATA_FLAG_IFCONV)
-
-#define JITDATA_HAS_FLAG_REORDER(jd) \
-    ((jd)->flags & JITDATA_FLAG_REORDER)
-
-#define JITDATA_HAS_FLAG_INLINE(jd) \
-    ((jd)->flags & JITDATA_FLAG_INLINE)
-
-#define JITDATA_HAS_FLAG_COUNTDOWN(jd) \
-    ((jd)->flags & JITDATA_FLAG_COUNTDOWN)
-
-#define JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd) \
-    ((jd)->flags & JITDATA_FLAG_SHOWINTERMEDIATE)
-
-#define JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) \
-    ((jd)->flags & JITDATA_FLAG_SHOWDISASSEMBLE)
-
-#define JITDATA_HAS_FLAG_VERBOSECALL(jd) \
-    ((jd)->flags & JITDATA_FLAG_VERBOSECALL)
-
-
-/* exception_entry ************************************************************/
-
-struct exception_entry {
-       basicblock           *start;
-       basicblock           *end;
-       basicblock           *handler;
-       classref_or_classinfo catchtype; /* catchtype of exc. (NULL == catchall)  */
-       exception_entry      *next;      /* next in list of exceptions when       */
-                                                                        /* loops are copied                      */
-       exception_entry      *down;      /* next exception_entry                  */
-};
-
-
-/* macros for accessing variables *********************************************
-   Use VAROP for s1, s2, s3 and dst operands (eg. VAROP(iptr->s1)),
-   use VAR if you have the variable index (eg. VAR(iptr->sx.s23.s2.args[0])).
-
-******************************************************************************/
-
-#define VAROP(v) (jd->var + (v).varindex)
-#define VAR(i)   (jd->var + (i))
-
-static inline bool var_is_local(const jitdata *jd, s4 i) {
-       return (i < jd->localcount);
-}
-
-static inline bool var_is_prealloc(const jitdata *jd, s4 i) {
-       return ((i >= jd->localcount) && (jd->var[i].flags & PREALLOC));
-}
-
-static inline bool var_is_inout(const jitdata *jd, s4 i) {
-       const varinfo *v = jd->var + i;
-       return (
-               (i >= jd->localcount) && (
-                       (!(v->flags & PREALLOC) && (v->flags & INOUT)) ||
-                       /* special case of TYPE_RET, used with JSR */
-                       ((v->flags & PREALLOC) && (v->flags & INOUT) && (v->type == TYPE_RET))
-               )
-       );
-}
-
-static inline bool var_is_temp(const jitdata *jd, s4 i) {
-       const varinfo *v = jd->var + i;
-       return ((i >= jd->localcount) && !(v->flags & PREALLOC) && !(v->flags & INOUT));
-}
-
-static inline bool var_is_saved(const jitdata *jd, s4 i) {
-       return (jd->var[i].flags & SAVEDVAR);
-}
-
-
-/**************************** instruction structure ***************************/
-
-/* branch_target_t: used in TABLESWITCH tables */
-
-typedef union {
-    s4                         insindex; /* used in parse                     */
-    basicblock                *block;    /* valid after parse                 */
-} branch_target_t;
-
-/* lookup_target_t: used in LOOKUPSWITCH tables */
-
-typedef struct {
-    s4                         value;    /* case value                        */
-    branch_target_t            target;   /* branch target, see above          */
-} lookup_target_t;
-
-/*** s1 operand ***/
-
-typedef union {
-       s4                         varindex;
-    s4                         argcount;
-} s1_operand_t;
-
-/*** s2 operand ***/
-
-typedef union {
-       s4                         varindex;
-       s4                        *args;
-    classref_or_classinfo      c;
-    unresolved_class          *uc;
-    ptrint                     constval;         /* for PUT*CONST             */
-    s4                         tablelow;         /* for TABLESWITCH           */
-    u4                         lookupcount;      /* for LOOKUPSWITCH          */
-       s4                         retaddrnr;        /* for ASTORE                */
-       instruction              **iargs;            /* for PHI                   */
-} s2_operand_t;
-
-/*** s3 operand ***/
-
-typedef union {
-       s4                         varindex;
-    ptrint                     constval;
-    classref_or_classinfo      c;
-    constant_FMIref           *fmiref;
-    unresolved_method         *um;
-    unresolved_field          *uf;
-    insinfo_inline            *inlineinfo;       /* for INLINE_START/END      */
-    s4                         tablehigh;        /* for TABLESWITCH           */
-    branch_target_t            lookupdefault;    /* for LOOKUPSWITCH          */
-    branch_target_t            jsrtarget;        /* for JSR                   */
-       s4                         javaindex;        /* for *STORE                */
-    struct builtintable_entry *bte;
-} s3_operand_t;
-
-/*** val operand ***/
-
-typedef union {
-    s4                        i;
-    s8                        l;
-    float                     f;
-    double                    d;
-    void                     *anyptr;
-    java_handle_t            *stringconst;       /* for ACONST with string    */
-    classref_or_classinfo     c;                 /* for ACONST with class     */
-} val_operand_t;
-
-/*** dst operand ***/
-
-typedef union {
-       s4                         varindex;
-    basicblock                *block;       /* valid after parse              */
-    branch_target_t           *table;       /* for TABLESWITCH                */
-    lookup_target_t           *lookup;      /* for LOOKUPSWITCH               */
-    s4                         insindex;    /* used in parse                  */
-} dst_operand_t;
-
-/*** flags (32 bits) ***/
-
-#define INS_FLAG_BASICBLOCK    0x01    /* marks a basic block start           */
-#define INS_FLAG_UNRESOLVED    0x02    /* contains unresolved field/meth/class*/
-#define INS_FLAG_CLASS         0x04    /* for ACONST, PUT*CONST with class    */
-#define INS_FLAG_ARRAY         0x08    /* for CHECKCAST/INSTANCEOF with array */
-#define INS_FLAG_CHECK         0x10    /* for *ALOAD|*ASTORE: check index     */
-                                       /* for BUILTIN: check exception        */
-#define INS_FLAG_KILL_PREV     0x04    /* for *STORE, invalidate prev local   */
-#define INS_FLAG_KILL_NEXT     0x08    /* for *STORE, invalidate next local   */
-#define INS_FLAG_RETADDR       0x10    /* for ASTORE: op is a returnAddress   */
-
-#define INS_FLAG_ID_SHIFT      5
-#define INS_FLAG_ID_MASK       (~0 << INS_FLAG_ID_SHIFT)
-
-typedef union {
-    u4                  bits;
-} flags_operand_t;
-
-/*** instruction ***/
-
-/* The instruction format for the intermediate representation: */
-
-struct instruction {
-    u2                      opc;    /* opcode       */
-    u2                      line;   /* line number  */
-#if SIZEOF_VOID_P == 8
-    flags_operand_t         flags;  /* 4 bytes      */
-#endif
-    s1_operand_t            s1;     /* pointer-size */
-    union {
-        struct {
-            s2_operand_t    s2;     /* pointer-size */
-            s3_operand_t    s3;     /* pointer-size */
-        } s23;                      /*     XOR      */
-        val_operand_t       val;    /*  long-size   */
-    } sx;
-    dst_operand_t           dst;    /* pointer-size */
-#if SIZEOF_VOID_P == 4
-    flags_operand_t         flags;  /* 4 bytes      */
-#endif
-};
-
-
-#define INSTRUCTION_STARTS_BASICBLOCK(iptr) \
-       ((iptr)->flags.bits & INS_FLAG_BASICBLOCK)
-
-#define INSTRUCTION_IS_RESOLVED(iptr) \
-       (!((iptr)->flags.bits & INS_FLAG_UNRESOLVED))
-
-#define INSTRUCTION_IS_UNRESOLVED(iptr) \
-       ((iptr)->flags.bits & INS_FLAG_UNRESOLVED)
-
-#define INSTRUCTION_MUST_CHECK(iptr) \
-       ((iptr)->flags.bits & INS_FLAG_CHECK)
-
-#define INSTRUCTION_GET_FIELDREF(iptr,fref) \
-       do { \
-               if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
-                       fref = iptr->sx.s23.s3.uf->fieldref; \
-               else \
-                       fref = iptr->sx.s23.s3.fmiref; \
-       } while (0)
-
-#define INSTRUCTION_GET_METHODREF(iptr,mref) \
-       do { \
-               if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
-                       mref = iptr->sx.s23.s3.um->methodref; \
-               else \
-                       mref = iptr->sx.s23.s3.fmiref; \
-       } while (0)
-
-#define INSTRUCTION_GET_METHODDESC(iptr, md) \
-       do { \
-               if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
-                       md = iptr->sx.s23.s3.um->methodref->parseddesc.md; \
-               else \
-                       md = iptr->sx.s23.s3.fmiref->parseddesc.md; \
-       } while (0)
-
-/* additional info structs for special instructions ***************************/
-
-/* for ICMD_INLINE_START and ICMD_INLINE_END */
-
-struct insinfo_inline {
-       /* fields copied from the inlining tree ----------------------------------*/
-       insinfo_inline *parent;     /* insinfo of the surrounding inlining, if any*/
-       methodinfo     *method;     /* the inlined method starting/ending here    */
-       methodinfo     *outer;      /* the outer method suspended/resumed here    */
-       s4              synclocal;      /* local index used for synchronization   */
-       bool            synchronize;    /* true if synchronization is needed      */
-       s4              throughcount;   /* total # of pass-through variables      */
-       s4              paramcount;     /* number of parameters of original call  */
-       s4              stackvarscount; /* source stackdepth at INLINE_START      */
-       s4             *stackvars;      /* stack vars at INLINE_START             */
-
-       /* fields set by inlining ------------------------------------------------*/
-       s4         *javalocals_start; /* javalocals at start of inlined body      */
-       s4         *javalocals_end;   /* javalocals after inlined body            */
-
-       /* fields set by replacement point creation ------------------------------*/
-#if defined(ENABLE_REPLACEMENT)
-       rplpoint   *rp;             /* replacement point at INLINE_START          */
-#endif
-
-       /* fields set by the codegen ---------------------------------------------*/
-       s4          startmpc;       /* machine code offset of start of inlining   */
-};
-
-
-/* basicblock *****************************************************************/
-
-/* flags */
-
-#define BBDELETED            -2
-#define BBUNDEF              -1
-#define BBREACHED            0
-#define BBFINISHED           1
-
-#define BBTYPECHECK_UNDEF    2
-#define BBTYPECHECK_REACHED  3
-
-#define BBTYPE_STD           0  /* standard basic block type                  */
-#define BBTYPE_EXH           1  /* exception handler basic block type         */
-#define BBTYPE_SBR           2  /* subroutine basic block type                */
-
-#define BBFLAG_REPLACEMENT   0x01  /* put a replacement point at the start    */
-
-/* XXX basicblock wastes quite a lot of memory by having four flag fields     */
-/* (flags, bitflags, type and lflags). Probably the last three could be       */
-/* combined without loss of efficiency. The first one could be combined with  */
-/* the others by using bitfields.                                             */
-
-/* XXX "flags" should probably be called "state", as it is an integer state   */
-
-struct basicblock {
-       s4            nr;           /* basic block number                         */
-       s4            flags;        /* used during stack analysis, init with -1   */
-       s4            bitflags;     /* OR of BBFLAG_... constants, init with 0    */
-       s4            type;         /* basic block type (std, xhandler, subroutine*/
-       s4            lflags;       /* used during loop copying, init with 0      */
-
-       s4            icount;       /* number of intermediate code instructions   */
-       instruction  *iinstr;       /* pointer to intermediate code instructions  */
-
-       varinfo      *inlocals;     /* copy of locals on block entry              */
-       s4           *javalocals;   /* map from java locals to cacao variables[+] */
-       s4           *invars;       /* array of in-variables at begin of block    */
-       s4           *outvars;      /* array of out-variables at end of block     */
-       s4            indepth;      /* stack depth at begin of basic block        */
-       s4            outdepth;     /* stack depth end of basic block             */
-       s4            varstart;     /* index of first non-invar block variable    */
-       s4            varcount;     /* number of non-invar block variables        */
-
-       s4            predecessorcount;
-       s4            successorcount;
-       basicblock  **predecessors; /* array of predecessor basic blocks          */
-       basicblock  **successors;   /* array of successor basic blocks            */
-
-       branchref    *branchrefs;   /* list of branches to be patched             */
-
-       basicblock   *next;         /* used to build a BB list (instead of array) */
-       basicblock   *copied_to;    /* points to the copy of this basic block     */
-                                /* when loop nodes are copied                 */
-       basicblock   *original;     /* block of which this block is a clone       */
-                                   /* NULL for the original block itself         */
-       methodinfo   *method;       /* method this block belongs to               */
-       insinfo_inline *inlineinfo; /* inlineinfo for the start of this block     */
-
-       s4            mpc;          /* machine code pc at start of block          */
-
-       /* TODO: those fields are probably usefull for other passes as well. */
-
-#if defined(ENABLE_SSA)         
-       basicblock   *idom;         /* Immediate dominator, parent in dominator tree */
-       basicblock  **domsuccessors;/* Children in dominator tree                 */
-       s4            domsuccessorcount;
-
-       basicblock  **domfrontier;  /* Dominance frontier                         */
-       s4            domfrontiercount;
-
-       basicblock  **exhandlers;   /* Exception handlers for this block */
-       s4            exhandlercount;
-       basicblock  **expredecessors; /* Blocks this block is exception handler for */
-       s4            expredecessorcount;
-       s4            exouts;       /* Number of exceptional exits */
-
-       instruction  *phis;         /* Phi functions */
-       s4            phicount;     /* Number of phi functions */
-
-       void         *vp;           /* Freely used by different passes            */
-#endif
-};
-
-#define FOR_EACH_SUCCESSOR(bptr, it) \
-       for ((it) = (bptr)->successors; (it) != (bptr)->successors + (bptr)->successorcount; ++(it))
-
-#define FOR_EACH_PREDECESSOR(bptr, it) \
-       for ( \
-               (it) = (bptr)->predecessors; \
-               (it) != (bptr)->predecessors + ((bptr)->predecessorcount < 0 ? 0 : (bptr)->predecessorcount); \
-               ++(it) \
-       )
-
-#define FOR_EACH_INSTRUCTION(bptr, it) \
-       for ((it) = (bptr)->iinstr; (it) != (bptr)->iinstr + (bptr)->icount; ++(it))
-
-#if defined(ENABLE_SSA)
-
-#define FOR_EACH_EXHANDLER(bptr, it) \
-       for ((it) = (bptr)->exhandlers; (it) != (bptr)->exhandlers + (bptr)->exhandlercount; ++(it))
-
-#define FOR_EACH_EXPREDECESSOR(bptr, it) \
-       for ((it) = (bptr)->expredecessors; (it) != (bptr)->expredecessors + (bptr)->expredecessorcount; ++(it))
-
-#endif
-
-/* [+]...the javalocals array: This array is indexed by the javaindex (the    */
-/*       local variable index ocurring in the original bytecode). An element  */
-/*       javalocals[javaindex] encodes where to find the contents of the      */
-/*       original variable at this point in the program.                      */
-/*       There are three cases for javalocals[javaindex]:                     */
-/*           >= 0.......it's an index into the jd->var array, where the       */
-/*                      CACAO variable corresponding to the original local    */
-/*                      can be found.                                         */
-/*           UNUSED.....the original variable is not live at this point       */
-/*           < UNUSED...the original variable contains a returnAddress at     */
-/*                      this point. The number of the block to return to can  */
-/*                      be calculated using RETADDR_FROM_JAVALOCAL:           */
-/*                                                                            */
-/*                      javalocals[javaindex] == JAVALOCAL_FROM_RETADDR(nr)   */
-/*                      RETADDR_FROM_JAVALOCAL(javalocals[javaindex]) == nr   */
-
-#define JAVALOCAL_FROM_RETADDR(nr)  (UNUSED - (1 + (nr)))
-#define RETADDR_FROM_JAVALOCAL(jl)  (UNUSED - (1 + (jl)))
-
-
-/* Macro for initializing newly allocated basic block's. It does not
-   need to zero fields, as we zero out the whole basic block array. */
-
-#define BASICBLOCK_INIT(bptr,m)                        \
-       do {                                               \
-               bptr->mpc    = -1;                             \
-               bptr->flags  = -1;                             \
-               bptr->type   = BBTYPE_STD;                     \
-               bptr->method = (m);                            \
-       } while (0)
-
-static inline bool basicblock_reached(const basicblock *bptr) {
-       return (bptr->flags >= BBREACHED);
-}
-
-/* data-flow constants for the ICMD table ************************************/
-
-#define DF_0_TO_0      0
-#define DF_1_TO_0      1
-#define DF_2_TO_0      2
-#define DF_3_TO_0      3
-
-#define DF_DST_BASE    4      /* from this value on, iptr->dst is a variable */
-
-#define DF_0_TO_1      (DF_DST_BASE + 0)
-#define DF_1_TO_1      (DF_DST_BASE + 1)
-#define DF_2_TO_1      (DF_DST_BASE + 2)
-#define DF_3_TO_1      (DF_DST_BASE + 3)
-#define DF_N_TO_1      (DF_DST_BASE + 4)
-
-#define DF_INVOKE      (DF_DST_BASE + 5)
-#define DF_BUILTIN     (DF_DST_BASE + 6)
-
-#define DF_COPY        (DF_DST_BASE + 7)
-#define DF_MOVE        (DF_DST_BASE + 8)
-
-#define DF_DUP         -1
-#define DF_DUP_X1      -1
-#define DF_DUP_X2      -1
-#define DF_DUP2        -1
-#define DF_DUP2_X1     -1
-#define DF_DUP2_X2     -1
-#define DF_SWAP        -1
-
-/* special data-flow recognized by verify/generate.pl: */
-#define DF_LOAD        DF_COPY
-#define DF_STORE       DF_MOVE
-#define DF_IINC        DF_1_TO_1
-#define DF_POP         DF_1_TO_0
-#define DF_POP2        DF_2_TO_0
-
-
-/* control-flow constants for the ICMD table *********************************/
-
-#define CF_NORMAL      0
-#define CF_IF          1
-
-#define CF_END_BASE    2  /* from here on, they mark the end of a superblock */
-
-#define CF_END         (CF_END_BASE + 0)
-#define CF_GOTO        (CF_END_BASE + 1)
-#define CF_TABLE       (CF_END_BASE + 2)
-#define CF_LOOKUP      (CF_END_BASE + 3)
-#define CF_JSR         (CF_END_BASE + 4)
-#define CF_RET         (CF_END_BASE + 5)
-
-
-/* flag constants for the ICMD table *****************************************/
-
-#define ICMDTABLE_PEI    0x0001               /* ICMD may throw an exception */
-#define ICMDTABLE_CALLS  0x0002     /* needs registers to be saved, may call */
-
-
-/* ICMD table entry **********************************************************/
-
-typedef struct icmdtable_entry_t icmdtable_entry_t;
-
-struct icmdtable_entry_t {
-#if !defined(NDEBUG)
-       char *name;                                /* name, without ICMD_ prefix */
-#endif
-       s4    dataflow;                             /* a DF_ constant, see above */
-       s4    controlflow;                          /* a CF_ constant, see above */
-       s4    flags;                        /* a combination of ICMDTABLE_ flags */
-};
-
-
-/* the ICMD table ************************************************************/
-
-extern icmdtable_entry_t icmd_table[256];
-
-
-/********** JavaVM operation codes (sorted) and instruction lengths ***********/
-
-enum {
-       ICMD_NOP               = BC_nop,
-
-       ICMD_ACONST            = BC_aconst_null,
-
-       ICMD_CHECKNULL         = 2,
-
-       ICMD_ICONST            = BC_iconst_0,
-
-       /* 3 */
-       /* 4 */
-
-       ICMD_IDIVPOW2          = 5,
-       ICMD_LDIVPOW2          = 6,
-
-       /* 7 */
-       /* 8 */
-
-       ICMD_LCONST            = BC_lconst_0,
-
-       ICMD_LCMPCONST         = 10,
-
-       ICMD_FCONST            = BC_fconst_0,
-
-       /* 12 */
-       /* 13 */
-
-       ICMD_DCONST            = BC_dconst_0,
-
-       ICMD_COPY              = 15,
-       ICMD_MOVE              = 16,
-
-       /* 17 */
-       /* 18 */
-       /* 19 */
-       /* 20 */
-
-       /* Order of LOAD instructions must be equal to order of TYPE_*
-          defines. */
-
-       ICMD_ILOAD            = BC_iload,
-       ICMD_LLOAD            = BC_lload,
-       ICMD_FLOAD            = BC_fload,
-       ICMD_DLOAD            = BC_dload,
-       ICMD_ALOAD            = BC_aload,
-
-       ICMD_IADDCONST        = 26,
-       ICMD_ISUBCONST        = 27,
-       ICMD_IMULCONST        = 28,
-       ICMD_IANDCONST        = 29,
-       ICMD_IORCONST         = 30,
-       ICMD_IXORCONST        = 31,
-
-       ICMD_ISHLCONST        = 32,
-       ICMD_ISHRCONST        = 33,
-       ICMD_IUSHRCONST       = 34,
-
-       ICMD_IREMPOW2         = 35,
-
-       ICMD_LADDCONST        = 36,
-       ICMD_LSUBCONST        = 37,
-       ICMD_LMULCONST        = 38,
-       ICMD_LANDCONST        = 39,
-       ICMD_LORCONST         = 40,
-       ICMD_LXORCONST        = 41,
-
-       ICMD_LSHLCONST        = 42,
-       ICMD_LSHRCONST        = 43,
-       ICMD_LUSHRCONST       = 44,
-
-       ICMD_LREMPOW2         = 45,
-
-       ICMD_IALOAD           = BC_iaload,
-       ICMD_LALOAD           = BC_laload,
-       ICMD_FALOAD           = BC_faload,
-       ICMD_DALOAD           = BC_daload,
-       ICMD_AALOAD           = BC_aaload,
-       ICMD_BALOAD           = BC_baload,
-       ICMD_CALOAD           = BC_caload,
-       ICMD_SALOAD           = BC_saload,
-
-       /* Order of STORE instructions must be equal to order of TYPE_*
-          defines. */
-
-       ICMD_ISTORE           = BC_istore,
-       ICMD_LSTORE           = BC_lstore,
-       ICMD_FSTORE           = BC_fstore,
-       ICMD_DSTORE           = BC_dstore,
-       ICMD_ASTORE           = BC_astore,
-
-       ICMD_IF_LEQ           = 59,
-       ICMD_IF_LNE           = 60,
-       ICMD_IF_LLT           = 61,
-       ICMD_IF_LGE           = 62,
-       ICMD_IF_LGT           = 63,
-       ICMD_IF_LLE           = 64,
-
-       ICMD_IF_LCMPEQ        = 65,
-       ICMD_IF_LCMPNE        = 66,
-       ICMD_IF_LCMPLT        = 67,
-       ICMD_IF_LCMPGE        = 68,
-       ICMD_IF_LCMPGT        = 69,
-       ICMD_IF_LCMPLE        = 70,
-
-       /* 71 */
-       /* 72 */
-       /* 73 */
-       /* 74 */
-       /* 75 */
-       /* 76 */
-       /* 77 */
-       /* 78 */
-
-       ICMD_IASTORE          = BC_iastore,
-       ICMD_LASTORE          = BC_lastore,
-       ICMD_FASTORE          = BC_fastore,
-       ICMD_DASTORE          = BC_dastore,
-       ICMD_AASTORE          = BC_aastore,
-       ICMD_BASTORE          = BC_bastore,
-       ICMD_CASTORE          = BC_castore,
-       ICMD_SASTORE          = BC_sastore,
-
-       ICMD_POP              = BC_pop,
-       ICMD_POP2             = BC_pop2,
-       ICMD_DUP              = BC_dup,
-       ICMD_DUP_X1           = BC_dup_x1,
-       ICMD_DUP_X2           = BC_dup_x2,
-       ICMD_DUP2             = BC_dup2,
-       ICMD_DUP2_X1          = BC_dup2_x1,
-       ICMD_DUP2_X2          = BC_dup2_x2,
-       ICMD_SWAP             = BC_swap,
-
-       ICMD_IADD             = BC_iadd,
-       ICMD_LADD             = BC_ladd,
-       ICMD_FADD             = BC_fadd,
-       ICMD_DADD             = BC_dadd,
-
-       ICMD_ISUB             = BC_isub,
-       ICMD_LSUB             = BC_lsub,
-       ICMD_FSUB             = BC_fsub,
-       ICMD_DSUB             = BC_dsub,
-
-       ICMD_IMUL             = BC_imul,
-       ICMD_LMUL             = BC_lmul,
-       ICMD_FMUL             = BC_fmul,
-       ICMD_DMUL             = BC_dmul,
-
-       ICMD_IDIV             = BC_idiv,
-       ICMD_LDIV             = BC_ldiv,
-       ICMD_FDIV             = BC_fdiv,
-       ICMD_DDIV             = BC_ddiv,
-
-       ICMD_IREM             = BC_irem,
-       ICMD_LREM             = BC_lrem,
-       ICMD_FREM             = BC_frem,
-       ICMD_DREM             = BC_drem,
-
-       ICMD_INEG             = BC_ineg,
-       ICMD_LNEG             = BC_lneg,
-       ICMD_FNEG             = BC_fneg,
-       ICMD_DNEG             = BC_dneg,
-
-       ICMD_ISHL             = BC_ishl,
-       ICMD_LSHL             = BC_lshl,
-       ICMD_ISHR             = BC_ishr,
-       ICMD_LSHR             = BC_lshr,
-       ICMD_IUSHR            = BC_iushr,
-       ICMD_LUSHR            = BC_lushr,
-
-       ICMD_IAND             = BC_iand,
-       ICMD_LAND             = BC_land,
-       ICMD_IOR              = BC_ior,
-       ICMD_LOR              = BC_lor,
-       ICMD_IXOR             = BC_ixor,
-       ICMD_LXOR             = BC_lxor,
-
-       ICMD_IINC             = BC_iinc,
-
-       ICMD_I2L              = BC_i2l,
-       ICMD_I2F              = BC_i2f,
-       ICMD_I2D              = BC_i2d,
-       ICMD_L2I              = BC_l2i,
-       ICMD_L2F              = BC_l2f,
-       ICMD_L2D              = BC_l2d,
-       ICMD_F2I              = BC_f2i,
-       ICMD_F2L              = BC_f2l,
-       ICMD_F2D              = BC_f2d,
-       ICMD_D2I              = BC_d2i,
-       ICMD_D2L              = BC_d2l,
-       ICMD_D2F              = BC_d2f,
-
-       ICMD_INT2BYTE         = BC_int2byte,
-       ICMD_INT2CHAR         = BC_int2char,
-       ICMD_INT2SHORT        = BC_int2short,
-
-       ICMD_LCMP             = BC_lcmp,
-       ICMD_FCMPL            = BC_fcmpl,
-       ICMD_FCMPG            = BC_fcmpg,
-       ICMD_DCMPL            = BC_dcmpl,
-       ICMD_DCMPG            = BC_dcmpg,
-
-       ICMD_IFEQ             = BC_ifeq,
-       ICMD_IFNE             = BC_ifne,
-       ICMD_IFLT             = BC_iflt,
-       ICMD_IFGE             = BC_ifge,
-       ICMD_IFGT             = BC_ifgt,
-       ICMD_IFLE             = BC_ifle,
-
-       ICMD_IF_ICMPEQ        = BC_if_icmpeq,
-       ICMD_IF_ICMPNE        = BC_if_icmpne,
-       ICMD_IF_ICMPLT        = BC_if_icmplt,
-       ICMD_IF_ICMPGE        = BC_if_icmpge,
-       ICMD_IF_ICMPGT        = BC_if_icmpgt,
-       ICMD_IF_ICMPLE        = BC_if_icmple,
-       ICMD_IF_ACMPEQ        = BC_if_acmpeq,
-       ICMD_IF_ACMPNE        = BC_if_acmpne,
-
-       ICMD_GOTO             = BC_goto,
-       ICMD_JSR              = BC_jsr,
-       ICMD_RET              = BC_ret,
-
-       ICMD_TABLESWITCH      = BC_tableswitch,
-       ICMD_LOOKUPSWITCH     = BC_lookupswitch,
-
-       ICMD_IRETURN          = BC_ireturn,
-       ICMD_LRETURN          = BC_lreturn,
-       ICMD_FRETURN          = BC_freturn,
-       ICMD_DRETURN          = BC_dreturn,
-       ICMD_ARETURN          = BC_areturn,
-       ICMD_RETURN           = BC_return,
-
-       ICMD_GETSTATIC        = BC_getstatic,
-       ICMD_PUTSTATIC        = BC_putstatic,
-       ICMD_GETFIELD         = BC_getfield,
-       ICMD_PUTFIELD         = BC_putfield,
-
-       ICMD_INVOKEVIRTUAL    = BC_invokevirtual,
-       ICMD_INVOKESPECIAL    = BC_invokespecial,
-       ICMD_INVOKESTATIC     = BC_invokestatic,
-       ICMD_INVOKEINTERFACE  = BC_invokeinterface,
-
-       /* 186 */
-
-       ICMD_NEW              = BC_new,
-       ICMD_NEWARRAY         = BC_newarray,
-       ICMD_ANEWARRAY        = BC_anewarray,
-
-       ICMD_ARRAYLENGTH      = BC_arraylength,
-
-       ICMD_ATHROW           = BC_athrow,
-
-       ICMD_CHECKCAST        = BC_checkcast,
-       ICMD_INSTANCEOF       = BC_instanceof,
-
-       ICMD_MONITORENTER     = BC_monitorenter,
-       ICMD_MONITOREXIT      = BC_monitorexit,
-
-       /* 196 */
-
-       ICMD_MULTIANEWARRAY   = BC_multianewarray,
-
-       ICMD_IFNULL           = BC_ifnull,
-       ICMD_IFNONNULL        = BC_ifnonnull,
-
-       /* 200 */
-       /* 201 */
-       /* 202 */
-
-       ICMD_IASTORECONST     = 204,
-       ICMD_LASTORECONST     = 205,
-       ICMD_FASTORECONST     = 206,
-       ICMD_DASTORECONST     = 207,
-       ICMD_AASTORECONST     = 208,
-       ICMD_BASTORECONST     = 209,
-       ICMD_CASTORECONST     = 210,
-       ICMD_SASTORECONST     = 211,
-
-       ICMD_PUTSTATICCONST   = 212,
-       ICMD_PUTFIELDCONST    = 213,
-
-       ICMD_IMULPOW2         = 214,
-       ICMD_LMULPOW2         = 215,
-
-       ICMD_GETEXCEPTION     = 249,
-       ICMD_PHI              = 250,
-
-       ICMD_INLINE_START     = 251,        /* instruction before inlined method  */
-       ICMD_INLINE_END       = 252,        /* instruction after inlined method   */
-       ICMD_INLINE_BODY      = 253,        /* start of inlined body              */
-
-       ICMD_BUILTIN          = 255         /* internal opcode                    */
-};
-
-/* Additional instruction accessors */
-
-methoddesc *instruction_call_site(const instruction *iptr);
-
-static inline bool instruction_has_dst(const instruction *iptr) {
-       if (
-               (icmd_table[iptr->opc].dataflow == DF_INVOKE) ||
-               (icmd_table[iptr->opc].dataflow == DF_BUILTIN)
-               ) {
-               return instruction_call_site(iptr)->returntype.type != TYPE_VOID;
-       } else {
-               return icmd_table[iptr->opc].dataflow >= DF_DST_BASE;
-       }
-}
-
-/***************************** register types *********************************/
-
-#define REG_RES   0         /* reserved register for OS or code generator     */
-#define REG_RET   1         /* return value register                          */
-#define REG_EXC   2         /* exception value register                       */
-#define REG_SAV   3         /* (callee) saved register                        */
-#define REG_TMP   4         /* scratch temporary register (caller saved)      */
-#define REG_ARG   5         /* argument register (caller saved)               */
-
-#define REG_END   -1        /* last entry in tables                           */
-#define PARAMMODE_NUMBERED  0 
-#define PARAMMODE_STUFFED   1
-
-
-/* function prototypes ********************************************************/
-
-/* compiler initialisation */
-void jit_init(void);
-
-/* compiler finalisation */
-void jit_close(void);
-
-/* create a new jitdata */
-jitdata *jit_jitdata_new(methodinfo *m);
-
-/* compile a method with jit compiler */
-u1 *jit_compile(methodinfo *m);
-u1 *jit_recompile(methodinfo *m);
-
-void jit_invalidate_code(methodinfo *m);
-codeinfo *jit_get_current_code(methodinfo *m);
-void jit_request_optimization(methodinfo *m);
-
-/* patch the method entrypoint */
-#if !defined(JIT_COMPILER_VIA_SIGNAL)
-u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra);
-#endif
-void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr);
-
-s4 jit_complement_condition(s4 opcode);
-
-void jit_renumber_basicblocks(jitdata *jd);
-#if !defined(NDEBUG)
-void jit_check_basicblock_numbers(jitdata *jd);
-#endif
-
-
-/* machine dependent functions ************************************************/
-
-#if defined(ENABLE_JIT)
-void md_init(void);
-#endif
-
-#if defined(ENABLE_INTRP)
-void intrp_md_init(void);
-#endif
-
-void *md_jit_method_patch_address(void *pv, void *ra, void *mptr);
-
-#endif /* _JIT_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/jit/jit.hpp b/src/vm/jit/jit.hpp
new file mode 100644 (file)
index 0000000..6aab885
--- /dev/null
@@ -0,0 +1,495 @@
+/* src/vm/jit/jit.hpp - Just-In-Time compiler
+
+   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 _JIT_HPP
+#define _JIT_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct jitdata jitdata;
+typedef struct basicblock basicblock;
+typedef struct exception_entry exception_entry;
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/global.h"
+#include "vm/method.hpp"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/reg.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stack.h"
+#include "vm/jit/stacktrace.hpp"
+
+#if defined(ENABLE_INLINING)
+# include "vm/jit/inline/inline.hpp"
+#endif
+
+#include "vm/jit/ir/bytecode.h"
+#include "vm/jit/ir/instruction.hpp"
+
+#if defined(ENABLE_LOOP)
+# include "vm/jit/loop/loop.h"
+#endif
+#if defined(ENABLE_SSA) 
+# include "vm/jit/optimizing/lsra.h"
+#endif
+#if defined(ENABLE_LSRA)
+# include "vm/jit/allocator/lsra.h"
+#endif
+
+#include "vm/jit/verify/typeinfo.hpp"
+
+
+/* common jit/codegen macros **************************************************/
+
+#if defined(ENABLE_STATISTICS)
+# define COUNT(x)        (x)++
+# define COUNT_SPILLS             /* use COUNT_(READ|WRITE)_SPILLS instead */
+# define COUNT_READ_SPILLS(var) \
+       switch(var->type) { \
+       case TYPE_FLT: count_spills_read_flt++; break; \
+       case TYPE_DBL: count_spills_read_dbl++; break; \
+       default: count_spills_read_ila++; break; \
+       }
+
+# define COUNT_WRITE_SPILLS(var) \
+       switch(var->type) { \
+       case TYPE_FLT: count_spills_write_flt++; break; \
+       case TYPE_DBL: count_spills_write_dbl++; break; \
+       default: count_spills_write_ila++; break; \
+       }
+
+#else
+# define COUNT(x)                /* nothing */
+# define COUNT_SPILLS            /* nothing */
+# define COUNT_READ_SPILLS(x)    /* nothing */
+# define COUNT_WRITE_SPILLS(x)   /* nothing */
+#endif
+
+typedef struct interface_info interface_info;
+
+struct interface_info {
+       s4 flags;
+       s4 regoff;
+};
+
+
+/* jitdata ********************************************************************/
+
+struct jitdata {
+       methodinfo      *m;               /* methodinfo of the method compiled    */
+       codeinfo        *code;
+       codegendata     *cd;
+       registerdata    *rd;
+#if defined(ENABLE_LOOP)
+       loopdata        *ld;
+#endif
+#if defined(ENABLE_SSA) || defined(ENABLE_LSRA)
+       lsradata        *ls;
+#endif
+
+       u4               flags;           /* contains JIT compiler flags          */
+
+       instruction     *instructions;    /* ICMDs, valid between parse and stack */
+       basicblock      *basicblocks;     /* start of basic block list            */
+       stackelement_t  *stack;           /* XXX should become stack.c internal   */
+       s4               instructioncount;/* XXX remove this?                     */
+       s4               basicblockcount; /* number of basic blocks               */
+       s4               stackcount;      /* number of stackelements to allocate  */
+                                      /* (passed from parse to stack)         */
+
+       varinfo         *var;             /* array of variables                   */
+       s4               vartop;          /* next free index in var array         */
+
+       s4               varcount;        /* number of variables in var array     */
+       s4               localcount;      /* number of locals at start of var ar. */
+    s4              *local_map;       /* map for renaming (de-coallescing)    */
+                                        /* locals and keeping the coalescing info for simplereg. */
+                        /* local_map[javaindex * 5 + type] =                     */
+                        /*     >= 0......index into jd->var, or                  */
+                                        /*     UNUSED....this (javaindex,type) pair is not used  */
+
+       s4              *reverselocalmap; /* map from CACAO varindex to javaindex */
+                                         /* (varindex must be < localcount)      */
+
+       s4               maxlocals;       /* max. number of javalocals            */
+
+       interface_info  *interface_map;   /* interface variables (for simplereg)  */
+       s4               maxinterfaces;   /* max. number of interface variables   */
+
+       s4               exceptiontablelength; /* exceptiontable length           */
+       exception_entry *exceptiontable;       /* the exceptiontable              */
+
+       basicblock      *returnblock;          /* block containing the *RETURN    */
+                                              /* (only use if returncount==1)    */
+       s4               returncount;          /* number of return instructions   */
+       bool             branchtoentry;        /* true if first block is a target */
+       bool             branchtoend;          /* true if end dummy is a target   */
+};
+
+#define FOR_EACH_BASICBLOCK(jd, it) \
+       for ((it) = (jd)->basicblocks; (it) != NULL; (it) = (it)->next)
+
+#define UNUSED                     -1
+
+#define JITDATA_FLAG_PARSE               0x00000001
+#define JITDATA_FLAG_VERIFY              0x00000002
+
+#define JITDATA_FLAG_INSTRUMENT          0x00000004
+
+#define JITDATA_FLAG_IFCONV              0x00000008
+#define JITDATA_FLAG_REORDER             0x00000010
+#define JITDATA_FLAG_INLINE              0x00000020
+
+#define JITDATA_FLAG_COUNTDOWN           0x00000100
+
+#define JITDATA_FLAG_SHOWINTERMEDIATE    0x20000000
+#define JITDATA_FLAG_SHOWDISASSEMBLE     0x40000000
+#define JITDATA_FLAG_VERBOSECALL         0x80000000
+
+
+#define JITDATA_HAS_FLAG_PARSE(jd) \
+    ((jd)->flags & JITDATA_FLAG_PARSE)
+
+#define JITDATA_HAS_FLAG_VERIFY(jd) \
+    ((jd)->flags & JITDATA_FLAG_VERIFY)
+
+#define JITDATA_HAS_FLAG_INSTRUMENT(jd) \
+    ((jd)->flags & JITDATA_FLAG_INSTRUMENT)
+
+#define JITDATA_HAS_FLAG_IFCONV(jd) \
+    ((jd)->flags & JITDATA_FLAG_IFCONV)
+
+#define JITDATA_HAS_FLAG_REORDER(jd) \
+    ((jd)->flags & JITDATA_FLAG_REORDER)
+
+#define JITDATA_HAS_FLAG_INLINE(jd) \
+    ((jd)->flags & JITDATA_FLAG_INLINE)
+
+#define JITDATA_HAS_FLAG_COUNTDOWN(jd) \
+    ((jd)->flags & JITDATA_FLAG_COUNTDOWN)
+
+#define JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd) \
+    ((jd)->flags & JITDATA_FLAG_SHOWINTERMEDIATE)
+
+#define JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) \
+    ((jd)->flags & JITDATA_FLAG_SHOWDISASSEMBLE)
+
+#define JITDATA_HAS_FLAG_VERBOSECALL(jd) \
+    ((jd)->flags & JITDATA_FLAG_VERBOSECALL)
+
+
+/* exception_entry ************************************************************/
+
+struct exception_entry {
+       basicblock           *start;
+       basicblock           *end;
+       basicblock           *handler;
+       classref_or_classinfo catchtype; /* catchtype of exc. (NULL == catchall)  */
+       exception_entry      *next;      /* next in list of exceptions when       */
+                                                                        /* loops are copied                      */
+       exception_entry      *down;      /* next exception_entry                  */
+};
+
+
+/* macros for accessing variables *********************************************
+   Use VAROP for s1, s2, s3 and dst operands (eg. VAROP(iptr->s1)),
+   use VAR if you have the variable index (eg. VAR(iptr->sx.s23.s2.args[0])).
+
+******************************************************************************/
+
+#define VAROP(v) (jd->var + (v).varindex)
+#define VAR(i)   (jd->var + (i))
+
+static inline bool var_is_local(const jitdata *jd, s4 i) {
+       return (i < jd->localcount);
+}
+
+static inline bool var_is_prealloc(const jitdata *jd, s4 i) {
+       return ((i >= jd->localcount) && (jd->var[i].flags & PREALLOC));
+}
+
+static inline bool var_is_inout(const jitdata *jd, s4 i) {
+       const varinfo *v = jd->var + i;
+       return (
+               (i >= jd->localcount) && (
+                       (!(v->flags & PREALLOC) && (v->flags & INOUT)) ||
+                       /* special case of TYPE_RET, used with JSR */
+                       ((v->flags & PREALLOC) && (v->flags & INOUT) && (v->type == TYPE_RET))
+               )
+       );
+}
+
+static inline bool var_is_temp(const jitdata *jd, s4 i) {
+       const varinfo *v = jd->var + i;
+       return ((i >= jd->localcount) && !(v->flags & PREALLOC) && !(v->flags & INOUT));
+}
+
+static inline bool var_is_saved(const jitdata *jd, s4 i) {
+       return (jd->var[i].flags & SAVEDVAR);
+}
+
+
+/* basicblock *****************************************************************/
+
+/* flags */
+
+#define BBDELETED            -2
+#define BBUNDEF              -1
+#define BBREACHED            0
+#define BBFINISHED           1
+
+#define BBTYPECHECK_UNDEF    2
+#define BBTYPECHECK_REACHED  3
+
+#define BBTYPE_STD           0  /* standard basic block type                  */
+#define BBTYPE_EXH           1  /* exception handler basic block type         */
+#define BBTYPE_SBR           2  /* subroutine basic block type                */
+
+#define BBFLAG_REPLACEMENT   0x01  /* put a replacement point at the start    */
+
+/* XXX basicblock wastes quite a lot of memory by having four flag fields     */
+/* (flags, bitflags, type and lflags). Probably the last three could be       */
+/* combined without loss of efficiency. The first one could be combined with  */
+/* the others by using bitfields.                                             */
+
+/* XXX "flags" should probably be called "state", as it is an integer state   */
+
+struct basicblock {
+       s4            nr;           /* basic block number                         */
+       s4            flags;        /* used during stack analysis, init with -1   */
+       s4            bitflags;     /* OR of BBFLAG_... constants, init with 0    */
+       s4            type;         /* basic block type (std, xhandler, subroutine*/
+       s4            lflags;       /* used during loop copying, init with 0      */
+
+       s4            icount;       /* number of intermediate code instructions   */
+       instruction  *iinstr;       /* pointer to intermediate code instructions  */
+
+       varinfo      *inlocals;     /* copy of locals on block entry              */
+       s4           *javalocals;   /* map from java locals to cacao variables[+] */
+       s4           *invars;       /* array of in-variables at begin of block    */
+       s4           *outvars;      /* array of out-variables at end of block     */
+       s4            indepth;      /* stack depth at begin of basic block        */
+       s4            outdepth;     /* stack depth end of basic block             */
+       s4            varstart;     /* index of first non-invar block variable    */
+       s4            varcount;     /* number of non-invar block variables        */
+
+       s4            predecessorcount;
+       s4            successorcount;
+       basicblock  **predecessors; /* array of predecessor basic blocks          */
+       basicblock  **successors;   /* array of successor basic blocks            */
+
+       branchref    *branchrefs;   /* list of branches to be patched             */
+
+       basicblock   *next;         /* used to build a BB list (instead of array) */
+       basicblock   *copied_to;    /* points to the copy of this basic block     */
+                                /* when loop nodes are copied                 */
+       basicblock   *original;     /* block of which this block is a clone       */
+                                   /* NULL for the original block itself         */
+       methodinfo   *method;       /* method this block belongs to               */
+       insinfo_inline *inlineinfo; /* inlineinfo for the start of this block     */
+
+       s4            mpc;          /* machine code pc at start of block          */
+
+       /* TODO: those fields are probably usefull for other passes as well. */
+
+#if defined(ENABLE_SSA)         
+       basicblock   *idom;         /* Immediate dominator, parent in dominator tree */
+       basicblock  **domsuccessors;/* Children in dominator tree                 */
+       s4            domsuccessorcount;
+
+       basicblock  **domfrontier;  /* Dominance frontier                         */
+       s4            domfrontiercount;
+
+       basicblock  **exhandlers;   /* Exception handlers for this block */
+       s4            exhandlercount;
+       basicblock  **expredecessors; /* Blocks this block is exception handler for */
+       s4            expredecessorcount;
+       s4            exouts;       /* Number of exceptional exits */
+
+       instruction  *phis;         /* Phi functions */
+       s4            phicount;     /* Number of phi functions */
+
+       void         *vp;           /* Freely used by different passes            */
+#endif
+};
+
+#define FOR_EACH_SUCCESSOR(bptr, it) \
+       for ((it) = (bptr)->successors; (it) != (bptr)->successors + (bptr)->successorcount; ++(it))
+
+#define FOR_EACH_PREDECESSOR(bptr, it) \
+       for ( \
+               (it) = (bptr)->predecessors; \
+               (it) != (bptr)->predecessors + ((bptr)->predecessorcount < 0 ? 0 : (bptr)->predecessorcount); \
+               ++(it) \
+       )
+
+#define FOR_EACH_INSTRUCTION(bptr, it) \
+       for ((it) = (bptr)->iinstr; (it) != (bptr)->iinstr + (bptr)->icount; ++(it))
+
+#define FOR_EACH_INSTRUCTION_REV(bptr, it) \
+       for ((it) = (bptr)->iinstr + (bptr)->icount - 1; (it) != (bptr)->iinstr - 1; --(it))
+
+#if defined(ENABLE_SSA)
+
+#define FOR_EACH_EXHANDLER(bptr, it) \
+       for ((it) = (bptr)->exhandlers; (it) != (bptr)->exhandlers + (bptr)->exhandlercount; ++(it))
+
+#define FOR_EACH_EXPREDECESSOR(bptr, it) \
+       for ((it) = (bptr)->expredecessors; (it) != (bptr)->expredecessors + (bptr)->expredecessorcount; ++(it))
+
+#endif
+
+/* [+]...the javalocals array: This array is indexed by the javaindex (the    */
+/*       local variable index ocurring in the original bytecode). An element  */
+/*       javalocals[javaindex] encodes where to find the contents of the      */
+/*       original variable at this point in the program.                      */
+/*       There are three cases for javalocals[javaindex]:                     */
+/*           >= 0.......it's an index into the jd->var array, where the       */
+/*                      CACAO variable corresponding to the original local    */
+/*                      can be found.                                         */
+/*           UNUSED.....the original variable is not live at this point       */
+/*           < UNUSED...the original variable contains a returnAddress at     */
+/*                      this point. The number of the block to return to can  */
+/*                      be calculated using RETADDR_FROM_JAVALOCAL:           */
+/*                                                                            */
+/*                      javalocals[javaindex] == JAVALOCAL_FROM_RETADDR(nr)   */
+/*                      RETADDR_FROM_JAVALOCAL(javalocals[javaindex]) == nr   */
+
+#define JAVALOCAL_FROM_RETADDR(nr)  (UNUSED - (1 + (nr)))
+#define RETADDR_FROM_JAVALOCAL(jl)  (UNUSED - (1 + (jl)))
+
+
+/* Macro for initializing newly allocated basic block's. It does not
+   need to zero fields, as we zero out the whole basic block array. */
+
+#define BASICBLOCK_INIT(bptr,m)                        \
+       do {                                               \
+               bptr->mpc    = -1;                             \
+               bptr->flags  = -1;                             \
+               bptr->type   = BBTYPE_STD;                     \
+               bptr->method = (m);                            \
+       } while (0)
+
+static inline bool basicblock_reached(const basicblock *bptr) {
+       return (bptr->flags >= BBREACHED);
+}
+
+
+
+/***************************** register types *********************************/
+
+#define REG_RES   0         /* reserved register for OS or code generator     */
+#define REG_RET   1         /* return value register                          */
+#define REG_EXC   2         /* exception value register                       */
+#define REG_SAV   3         /* (callee) saved register                        */
+#define REG_TMP   4         /* scratch temporary register (caller saved)      */
+#define REG_ARG   5         /* argument register (caller saved)               */
+
+#define REG_END   -1        /* last entry in tables                           */
+#define PARAMMODE_NUMBERED  0 
+#define PARAMMODE_STUFFED   1
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* compiler initialisation */
+void jit_init(void);
+
+/* compiler finalisation */
+void jit_close(void);
+
+/* create a new jitdata */
+jitdata *jit_jitdata_new(methodinfo *m);
+
+/* compile a method with jit compiler */
+u1 *jit_compile(methodinfo *m);
+u1 *jit_recompile(methodinfo *m);
+
+void jit_invalidate_code(methodinfo *m);
+codeinfo *jit_get_current_code(methodinfo *m);
+void jit_request_optimization(methodinfo *m);
+
+/* patch the method entrypoint */
+#if !defined(JIT_COMPILER_VIA_SIGNAL)
+void *jit_asm_compile(methodinfo *m, void* mptr, void* sp, void* ra);
+#endif
+void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr);
+
+s4 jit_complement_condition(s4 opcode);
+
+void jit_renumber_basicblocks(jitdata *jd);
+#if !defined(NDEBUG)
+void jit_check_basicblock_numbers(jitdata *jd);
+#endif
+
+
+/* machine dependent functions ************************************************/
+
+#if defined(ENABLE_JIT)
+void md_init(void);
+#endif
+
+#if defined(ENABLE_INTRP)
+void intrp_md_init(void);
+#endif
+
+void *md_jit_method_patch_address(void *pv, void *ra, void *mptr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _JIT_HPP
+
+
+/*
+ * 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/jit/linenumbertable.c b/src/vm/jit/linenumbertable.c
deleted file mode 100644 (file)
index 835fea3..0000000
+++ /dev/null
@@ -1,339 +0,0 @@
-/* src/vm/jit/linenumbertable.c - linenumber handling stuff
-
-   Copyright (C) 2007
-   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 <stdint.h>
-
-#include "mm/memory.h"
-
-#include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/linenumbertable.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/options.h"
-# include "vmcore/statistics.h"
-#endif
-
-#if defined(__S390__)
-#  define ADDR_MASK(type, x) ((type)((uintptr_t)(x) & 0x7FFFFFFF))
-#else
-#  define ADDR_MASK(type, x) (x)
-#endif
-
-/* linenumbertable_create ******************************************************
-
-   Creates the linenumber table.  We allocate an array and store the
-   linenumber entry in reverse-order, so we can search the correct
-   linenumber more easily.
-
-*******************************************************************************/
-
-void linenumbertable_create(jitdata *jd)
-{
-       codeinfo                     *code;
-       codegendata                  *cd;
-       linenumbertable_t            *lnt;
-       linenumbertable_entry_t      *lnte;
-       list_t                       *l;
-       linenumbertable_list_entry_t *le;
-       uint8_t                      *pv;
-       void                         *pc;
-
-       /* Get required compiler data. */
-
-       code = jd->code;
-       cd   = jd->cd;
-
-       /* Don't allocate a linenumber table if we don't need one. */
-
-       l = cd->linenumbers;
-
-       if (l->size == 0)
-               return;
-
-       /* Allocate the linenumber table and the entries array. */
-
-       lnt  = NEW(linenumbertable_t);
-       lnte = MNEW(linenumbertable_entry_t, l->size);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat) {
-               count_linenumbertable++;
-
-               size_linenumbertable +=
-                       sizeof(linenumbertable_t) +
-                       sizeof(linenumbertable_entry_t) * l->size;
-       }
-#endif
-
-       /* Fill the linenumber table. */
-
-       lnt->length  = l->size;
-       lnt->entries = lnte;
-
-       /* Fill the linenumber table entries in reverse order, so the
-          search can be forward. */
-
-       /* FIXME I only made this change to prevent a problem when moving
-          to C++. This should be changed back when this file has
-          converted to C++. */
-
-       pv = ADDR_MASK(uint8_t *, code->entrypoint);
-
-       for (le = list_first(l); le != NULL; le = list_next(l, le), lnte++) {
-               /* If the entry contains an mcode pointer (normal case),
-                  resolve it (see doc/inlining_stacktrace.txt for
-                  details). */
-
-               if (le->linenumber >= -2)
-                       pc = pv + le->mpc;
-               else
-                       pc = (void *) le->mpc;
-
-               /* Fill the linenumber table entry. */
-
-               lnte->linenumber = le->linenumber;
-               lnte->pc         = pc;
-       }
-
-       /* Store the linenumber table in the codeinfo. */
-
-       code->linenumbertable = lnt;
-}
-
-
-/* linenumbertable_list_entry_add **********************************************
-
-   Add a line number reference.
-
-   IN:
-      cd.............current codegen data
-      linenumber.....number of line that starts with the given mcodeptr
-
-*******************************************************************************/
-
-void linenumbertable_list_entry_add(codegendata *cd, int32_t linenumber)
-{
-       linenumbertable_list_entry_t *le;
-
-       le = DNEW(linenumbertable_list_entry_t);
-
-       le->linenumber = linenumber;
-       le->mpc        = cd->mcodeptr - cd->mcodebase;
-
-       list_add_first(cd->linenumbers, le);
-}
-
-
-/* linenumbertable_list_entry_add_inline_start *********************************
-
-   Add a marker to the line number table indicating the start of an
-   inlined method body. (see doc/inlining_stacktrace.txt)
-
-   IN:
-      cd ..... current codegen data
-      iptr ... the ICMD_INLINE_BODY instruction
-
-*******************************************************************************/
-
-void linenumbertable_list_entry_add_inline_start(codegendata *cd, instruction *iptr)
-{
-       linenumbertable_list_entry_t *le;
-       insinfo_inline               *insinfo;
-       uintptr_t                     mpc;
-
-       le = DNEW(linenumbertable_list_entry_t);
-
-       le->linenumber = (-2); /* marks start of inlined method */
-       le->mpc        = (mpc = cd->mcodeptr - cd->mcodebase);
-
-       list_add_first(cd->linenumbers, le);
-
-       insinfo = iptr->sx.s23.s3.inlineinfo;
-
-       insinfo->startmpc = mpc; /* store for corresponding INLINE_END */
-}
-
-
-/* linenumbertable_list_entry_add_inline_end ***********************************
-
-   Add a marker to the line number table indicating the end of an
-   inlined method body. (see doc/inlining_stacktrace.txt)
-
-   IN:
-      cd ..... current codegen data
-      iptr ... the ICMD_INLINE_END instruction
-
-   Note:
-      iptr->method must point to the inlined callee.
-
-*******************************************************************************/
-
-void linenumbertable_list_entry_add_inline_end(codegendata *cd, instruction *iptr)
-{
-       linenumbertable_list_entry_t *le;
-       insinfo_inline               *insinfo;
-
-       insinfo = iptr->sx.s23.s3.inlineinfo;
-
-       assert(insinfo);
-
-       le = DNEW(linenumbertable_list_entry_t);
-
-       /* special entry containing the methodinfo * */
-       le->linenumber = (-3) - iptr->line;
-       le->mpc        = (uintptr_t) insinfo->method;
-
-       list_add_first(cd->linenumbers, le);
-
-       le = DNEW(linenumbertable_list_entry_t);
-
-       /* end marker with PC of start of body */
-       le->linenumber = (-1);
-       le->mpc        = insinfo->startmpc;
-
-       list_add_first(cd->linenumbers, le);
-}
-
-
-/* linenumbertable_linenumber_for_pc_intern ************************************
-
-   This function search the line number table for the line
-   corresponding to a given pc. The function recurses for inlined
-   methods.
-
-*******************************************************************************/
-
-static s4 linenumbertable_linenumber_for_pc_intern(methodinfo **pm, linenumbertable_entry_t *lnte, int32_t lntsize, void *pc)
-{
-       linenumbertable_entry_t *lntinline;   /* special entry for inlined method */
-
-       pc = ADDR_MASK(void *, pc);
-
-       for (; lntsize > 0; lntsize--, lnte++) {
-               /* Note: In case of inlining this may actually compare the pc
-                  against a methodinfo *, yielding a non-sensical
-                  result. This is no problem, however, as we ignore such
-                  entries in the switch below. This way we optimize for the
-                  common case (ie. a real pc in lntentry->pc). */
-
-               if (pc >= lnte->pc) {
-                       /* did we reach the current line? */
-
-                       if (lnte->linenumber >= 0)
-                               return lnte->linenumber;
-
-                       /* we found a special inline entry (see
-                          doc/inlining_stacktrace.txt for details */
-
-                       switch (lnte->linenumber) {
-                       case -1: 
-                               /* begin of inlined method (ie. INLINE_END
-                                  instruction) */
-
-                               lntinline = --lnte;            /* get entry with methodinfo * */
-                               lnte--;                        /* skip the special entry      */
-                               lntsize -= 2;
-
-                               /* search inside the inlined method */
-
-                               if (linenumbertable_linenumber_for_pc_intern(pm, lnte, lntsize, pc)) {
-                                       /* the inlined method contained the pc */
-
-                                       *pm = (methodinfo *) lntinline->pc;
-
-                                       assert(lntinline->linenumber <= -3);
-
-                                       return (-3) - lntinline->linenumber;
-                               }
-
-                               /* pc was not in inlined method, continue search.
-                                  Entries inside the inlined method will be skipped
-                                  because their lntentry->pc is higher than pc.  */
-                               break;
-
-                       case -2: 
-                               /* end of inlined method */
-
-                               return 0;
-
-                               /* default: is only reached for an -3-line entry after
-                                  a skipped -2 entry. We can safely ignore it and
-                                  continue searching.  */
-                       }
-               }
-       }
-
-       /* PC not found. */
-
-       return 0;
-}
-
-
-/* linenumbertable_linenumber_for_pc *******************************************
-
-   A wrapper for linenumbertable_linenumber_for_pc_intern.
-
-   NOTE: We have a intern version because the function is called
-   recursively for inlined methods.
-
-*******************************************************************************/
-
-int32_t linenumbertable_linenumber_for_pc(methodinfo **pm, codeinfo *code, void *pc)
-{
-       linenumbertable_t *lnt;
-       int32_t            linenumber;
-
-       /* Get line number table. */
-
-       lnt = code->linenumbertable;
-
-       if (lnt == NULL)
-               return 0;
-
-       /* Get the line number. */
-
-       linenumber = linenumbertable_linenumber_for_pc_intern(pm, lnt->entries, lnt->length, pc);
-
-       return linenumber;
-}
-
-
-/*
- * 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/jit/linenumbertable.cpp b/src/vm/jit/linenumbertable.cpp
new file mode 100644 (file)
index 0000000..379f6de
--- /dev/null
@@ -0,0 +1,256 @@
+/* src/vm/jit/linenumbertable.cpp - linenumber handling stuff
+
+   Copyright (C) 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 <stdint.h>
+
+#include <algorithm>
+
+#include "mm/memory.h"
+
+#include "toolbox/list.hpp"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/options.h"
+# include "vm/statistics.h"
+#endif
+
+#include "vm/jit/code.hpp"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/linenumbertable.hpp"
+
+
+#if defined(__S390__)
+#  define ADDR_MASK(type, x) ((type)((uintptr_t)(x) & 0x7FFFFFFF))
+#else
+#  define ADDR_MASK(type, x) (x)
+#endif
+
+
+/**
+ * Resolve the linenumber.
+ *
+ * If the entry contains an mcode pointer (normal case), resolve it
+ * (see doc/inlining_stacktrace.txt for details).
+ *
+ * @param code Code structure.
+ */
+void Linenumber::resolve(const codeinfo* code)
+{
+       void* pv = ADDR_MASK(void*, code->entrypoint);
+
+       // TODO Use constant.
+       if (_linenumber >= -2)
+               _pc = (void*) ((uintptr_t) pv + (uintptr_t) _pc);
+}
+
+
+/**
+ * Creates a linenumber table.
+ *
+ * We allocate an array and store the linenumber entry in
+ * reverse-order, so we can search the correct linenumber more easily.
+ *
+ * @param jd JIT data.
+ */
+LinenumberTable::LinenumberTable(jitdata* jd) : _linenumbers(jd->cd->linenumbers->begin(), jd->cd->linenumbers->end())
+{
+       // Get required compiler data.
+       codeinfo* code = jd->code;
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat) {
+               count_linenumbertable++;
+
+               size_linenumbertable +=
+                       sizeof(LinenumberTable) +
+                       sizeof(Linenumber) * _linenumbers.size();
+       }
+#endif
+
+       // Resolve all linenumbers in the vector.
+       (void) for_each(_linenumbers.begin(), _linenumbers.end(), std::bind2nd(LinenumberResolver(), code));
+}
+
+
+/**
+ * Search the the line number table for the line corresponding to a
+ * given program counter.
+ *
+ * @param pc Program counter.
+ *
+ * @return Line number.
+ */
+int32_t LinenumberTable::find(methodinfo **pm, void* pc)
+{
+       void* maskpc = ADDR_MASK(void*, pc);
+
+       std::vector<Linenumber>::iterator it = find_if(_linenumbers.begin(), _linenumbers.end(), std::bind2nd(comparator(), maskpc));
+
+       // No matching entry found.
+       if (it == _linenumbers.end())
+               return 0;
+
+       Linenumber& ln = *it;
+       int32_t linenumber = ln.get_linenumber();
+
+       // Check for linenumber entry type.
+       if (linenumber < 0) {
+               os::abort("FIX ME!");
+
+#if 0
+               // We found a special inline entry (see
+               // doc/inlining_stacktrace.txt for details).
+               switch (linenumber) {
+               case -1:
+                       // Begin of an inlined method (ie. INLINE_END instruction.
+                       lntinline = --lnte;            /* get entry with methodinfo * */
+                       lnte--;                        /* skip the special entry      */
+
+                       /* search inside the inlined method */
+
+                       if (linenumbertable_linenumber_for_pc_intern(pm, lnte, lntsize, pc)) {
+                               /* the inlined method contained the pc */
+
+                               *pm = (methodinfo *) lntinline->pc;
+
+                               assert(lntinline->linenumber <= -3);
+
+                               return (-3) - lntinline->linenumber;
+                       }
+
+                       /* pc was not in inlined method, continue search.
+                          Entries inside the inlined method will be skipped
+                          because their lntentry->pc is higher than pc.  */
+                       break;
+
+               case -2: 
+                       /* end of inlined method */
+
+                       return 0;
+
+                       /* default: is only reached for an -3-line entry after
+                          a skipped -2 entry. We can safely ignore it and
+                          continue searching.  */
+               }
+#endif
+       }
+
+       // Normal linenumber entry, return it.
+       return linenumber;
+}
+
+
+/* linenumbertable_list_entry_add **********************************************
+
+   Add a line number reference.
+
+   IN:
+      cd.............current codegen data
+      linenumber.....number of line that starts with the given mcodeptr
+
+*******************************************************************************/
+
+void linenumbertable_list_entry_add(codegendata *cd, int32_t linenumber)
+{
+       void* pc = (void*) (cd->mcodeptr - cd->mcodebase);
+       Linenumber ln(linenumber, pc);
+
+       cd->linenumbers->push_front(ln);
+}
+
+
+/* linenumbertable_list_entry_add_inline_start *********************************
+
+   Add a marker to the line number table indicating the start of an
+   inlined method body. (see doc/inlining_stacktrace.txt)
+
+   IN:
+      cd ..... current codegen data
+      iptr ... the ICMD_INLINE_BODY instruction
+
+*******************************************************************************/
+
+void linenumbertable_list_entry_add_inline_start(codegendata *cd, instruction *iptr)
+{
+       void* pc = (void*) (cd->mcodeptr - cd->mcodebase);
+
+       Linenumber ln(-2 /* marks start of inlined method */, pc);
+
+       cd->linenumbers->push_front(ln);
+
+       insinfo_inline* insinfo = iptr->sx.s23.s3.inlineinfo;
+       insinfo->startmpc = (int32_t) (uintptr_t) pc; /* store for corresponding INLINE_END */
+}
+
+
+/* linenumbertable_list_entry_add_inline_end ***********************************
+
+   Add a marker to the line number table indicating the end of an
+   inlined method body. (see doc/inlining_stacktrace.txt)
+
+   IN:
+      cd ..... current codegen data
+      iptr ... the ICMD_INLINE_END instruction
+
+   Note:
+      iptr->method must point to the inlined callee.
+
+*******************************************************************************/
+
+void linenumbertable_list_entry_add_inline_end(codegendata *cd, instruction *iptr)
+{
+       insinfo_inline* insinfo = iptr->sx.s23.s3.inlineinfo;
+
+       // Sanity check.
+       assert(insinfo);
+
+       // Special entry containing the methodinfo.
+       Linenumber ln((-3) - iptr->line, insinfo->method);
+
+       cd->linenumbers->push_front(ln);
+
+       // End marker with PC of start of body.
+       Linenumber lne(-1, (void*) insinfo->startmpc);
+
+       cd->linenumbers->push_front(lne);
+}
+
+
+/*
+ * 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/jit/linenumbertable.h b/src/vm/jit/linenumbertable.h
deleted file mode 100644 (file)
index 925cf24..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* src/vm/jit/linenumbertable.h - linenumber table
-
-   Copyright (C) 2007
-   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 _LINENUMBERTABLE_H
-#define _LINENUMBERTABLE_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct linenumbertable_t            linenumbertable_t;
-typedef struct linenumbertable_entry_t      linenumbertable_entry_t;
-typedef struct linenumbertable_list_entry_t linenumbertable_list_entry_t;
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "toolbox/list.h"
-
-#include "vm/jit/jit.h"
-#include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
-
-#include "vmcore/method.h"
-
-
-/* linenumbertable_t **********************************************************/
-
-struct linenumbertable_t {
-       int32_t                  length;    /* length of the entries array        */
-       linenumbertable_entry_t *entries;   /* actual linenumber entries          */
-};
-
-
-/* linenumbertable_entry_t *****************************************************
-
-   NOTE: See doc/inlining_stacktrace.txt for special meanings of line
-   and pc.
-
-*******************************************************************************/
-
-struct linenumbertable_entry_t {
-       int32_t  linenumber;                /* linenumber of this entry           */
-       void    *pc;                        /* PC where this linenumber starts    */
-};
-
-
-/* linenumbertable_list_entry_t ***********************************************/
-
-struct linenumbertable_list_entry_t {
-       int32_t    linenumber;      /* line number, used for inserting into the   */
-                                   /* table and for validity checking            */
-                                   /* -1......start of inlined body              */
-                                   /* -2......end of inlined body                */
-                                   /* <= -3...special entry with methodinfo *    */
-                                                               /* (see doc/inlining_stacktrace.txt)          */
-       ptrint     mpc;             /* machine code program counter of first      */
-                                   /* instruction for given line                 */
-                                   /* NOTE: for linenumber <= -3 this is a the   */
-                                   /* (methodinfo *) of the inlined method       */
-       listnode_t linkage;
-};
-
-
-/* function prototypes ********************************************************/
-
-void    linenumbertable_create(jitdata *jd);
-
-void    linenumbertable_list_entry_add(codegendata *cd, int32_t linenumber);
-void    linenumbertable_list_entry_add_inline_start(codegendata *cd, instruction *iptr);
-void    linenumbertable_list_entry_add_inline_end(codegendata *cd, instruction *iptr);
-
-int32_t linenumbertable_linenumber_for_pc(methodinfo **pm, codeinfo *code, void *pc);
-
-#endif /* _LINENUMBERTABLE_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/jit/linenumbertable.hpp b/src/vm/jit/linenumbertable.hpp
new file mode 100644 (file)
index 0000000..1fa5440
--- /dev/null
@@ -0,0 +1,145 @@
+/* src/vm/jit/linenumbertable.hpp - linenumber table
+
+   Copyright (C) 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 _LINENUMBERTABLE_HPP
+#define _LINENUMBERTABLE_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+#include <functional>
+#include <vector>
+#endif
+
+#include "toolbox/list.hpp"
+
+#include "vm/method.hpp"
+
+#include "vm/jit/jit.hpp"
+#include "vm/jit/code.hpp"
+
+#include "vm/jit/ir/instruction.hpp"
+
+
+#ifdef __cplusplus
+
+/**
+ * Represents a Java line number.
+ */
+class Linenumber {
+private:
+       // TODO Add constants.
+       /* -1......start of inlined body              */
+       /* -2......end of inlined body                */
+       /* <= -3...special entry with methodinfo *    */
+       /* (see doc/inlining_stacktrace.txt)          */
+
+       int32_t _linenumber;
+       void*   _pc;
+
+public:
+       Linenumber(int32_t linenumber, void* pc) : _linenumber(linenumber), _pc(pc) {}
+
+       inline int32_t get_linenumber() const { return _linenumber; }
+       inline void*   get_pc        () const { return _pc; }
+
+       void resolve(const codeinfo* code);
+};
+
+
+/**
+ * Unary function to resolve Linenumber objects.
+ */
+class LinenumberResolver : public std::binary_function<Linenumber, codeinfo*, void> {
+public:
+       // Unary resolve function.
+       void operator() (Linenumber& ln, const codeinfo* code) const
+       {
+               ln.resolve(code);
+       }
+};
+
+
+/**
+ * Linenumber table of a Java method.
+ */
+class LinenumberTable {
+private:
+       std::vector<Linenumber> _linenumbers;
+
+       // Comparator class.
+       class comparator : public std::binary_function<Linenumber, void*, bool> {
+       public:
+               bool operator() (const Linenumber& ln, const void* pc) const
+               {
+                       return (pc >= ln.get_pc());
+               }
+       };
+
+public:
+       LinenumberTable(jitdata* jd);
+       ~LinenumberTable();
+
+       int32_t find(methodinfo **pm, void* pc);
+};
+
+#else
+
+typedef struct LinenumberTable LinenumberTable;
+
+#endif
+
+#include "vm/jit/codegen-common.hpp"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void    linenumbertable_list_entry_add(codegendata *cd, int32_t linenumber);
+void    linenumbertable_list_entry_add_inline_start(codegendata *cd, instruction *iptr);
+void    linenumbertable_list_entry_add_inline_end(codegendata *cd, instruction *iptr);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _LINENUMBERTABLE_HPP
+
+
+/*
+ * 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 43a7dad53c6e7c8558b960f94509082155f61706..211e492bde7e519dbeb908ffbeac72f5714d2c5a 100644 (file)
@@ -35,7 +35,7 @@
 #include "mm/memory.h"
 #include "toolbox/logging.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/stack.h"
 
 #include "vm/jit/loop/analyze.h"
index d8fbc5e0196904fef374d279455e8c6f5169d3f0..5b6650b2460413f140ab9b1e05d655088bee9dc0 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "config.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* function prototypes ********************************************************/
index 09cd21d5384dca04ab91ecc15a5570d94a83763d..91f580d4bdcf3a21cfdbad0d4ac9a610df44bc66 100644 (file)
@@ -38,7 +38,7 @@
 
 #include "mm/memory.h"
 #include "toolbox/logging.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/loop/graph.h"
 #include "vm/jit/loop/loop.h"
 
index ff3beb1f530d3cbae3725bccfe5b9b1d67ecd43c..320ceb582be797ba9f511dce9d3e8fe6bf4da8f1 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/loop/graph.h - control flow graph header
 
    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
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -31,9 +29,9 @@
 #include "config.h"
 #include "vm/types.h"
 
-#include "vm/jit/loop/loop.h"
+#include "vm/method.hpp"
 
-#include "vmcore/method.h"
+#include "vm/jit/loop/loop.h"
 
 
 /* function prototypes ********************************************************/
index e817f02ba0dc012836bb7d64f915f5bdc9fe4986..56d4ee09ffd0cf9f9b3ac7d722471b09209b49c3 100644 (file)
@@ -43,7 +43,7 @@
 #include "mm/memory.h"
 #include "toolbox/logging.h"
 #include "vm/global.h" 
-#include "vm/jit/jit.h"        
+#include "vm/jit/jit.hpp"      
 #include "vm/jit/loop/loop.h"
 #include "vm/jit/loop/graph.h"
 #include "vm/jit/loop/tracing.h"
index 881fc746a7ae8b13050a9785a5b20737dc468288..11080de743d04406f007582b8a6c00c9ce0f0422 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/loop/loop.h - array bound removal header
 
-   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.
 
 #include "vm/types.h"
 
 #include "vm/global.h"
+#include "vm/method.hpp"
 
-#include "vm/jit/jit.h"
-
-#include "vmcore/method.h"
+#include "vm/jit/jit.hpp"
 
 
 /*     Different types for struct Trace                                                                                */
index 13df1e949bc33f7854deb4d3e7771a603546fe02..b2e295e6bae6245347f063701aec4752b2108eb9 100644 (file)
@@ -35,8 +35,8 @@
 
 
 #include "mm/memory.h"
-#include "vm/builtin.h"
-#include "vm/resolve.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/resolve.hpp"
 #include "vm/jit/loop/loop.h"
 #include "vm/jit/loop/tracing.h"
 
index d506be50e45d59500dcbf01dad8314599b70e2cd..fe4653be221cba35b10f2c2c7ae923c73c0a142f 100644 (file)
@@ -33,7 +33,7 @@
 #ifndef _TRACING_H
 #define _TRACING_H
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 typedef struct Trace Trace;
index eb3c1f4aca3e7e711a278df17f2b0d655600ab87..85da92d0836156c14b7e58d42d36fdf182d8f04a 100644 (file)
@@ -33,7 +33,7 @@ LIBS =
 
 noinst_HEADERS = \
        arch.h \
-       machine-instr.h
+       md-atomic.hpp
 
 noinst_LTLIBRARIES = \
        libarch.la
@@ -51,6 +51,7 @@ libarch_la_SOURCES = \
        emit.c \
        patcher.c \
        \
+       md-stubs.hpp \
        md-trap.h \
        md.c \
        md.h
index 7441e256d7cb04f7b1c2a552f6c904e04e0c62d1..5498aabeebe0dceaa445a0469e51e0491ac73140 100644 (file)
@@ -33,8 +33,6 @@
 
 /* define architecture features ***********************************************/
 
-#define U8_AVAILABLE                     1
-
 #define SUPPORT_DIVISION                 1
 #define SUPPORT_LONG                     1
 
index 41bd7c7f7f83e459c527546e81fe368a01bbdf8b..a6ad45abeef0244cfe0ed521ba3f4dd8acdce5fb 100644 (file)
 #include "vm/jit/m68k/emit.h"
 
 #include "mm/memory.h"
-#include "native/jni.h"
-#include "native/localref.h"
-#include "native/native.h"
 
-#include "threads/lock-common.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "threads/lock.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/abi.h"
-#include "vm/jit/parse.h"
+#include "vm/jit/parse.hpp"
 #include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/utf8.h"
-
 
 bool codegen_emit(jitdata *jd) 
 {      
@@ -1994,9 +1992,6 @@ nowperformreturn:
                                superindex = super->index;
                        }
                        
-                       if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                               CODEGEN_CRITICAL_SECTION_NEW;
-
                        s1 = emit_load_s1(jd, iptr, REG_ATMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
@@ -2060,14 +2055,10 @@ nowperformreturn:
 
                                M_ALD(REG_ATMP1, s1, OFFSET(java_object_t, vftbl));
 
-                               CODEGEN_CRITICAL_SECTION_START;
-
                                M_ILD(REG_ITMP1, REG_ATMP1, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP3, REG_ATMP2, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP2, REG_ATMP2, OFFSET(vftbl_t, diffval));
 
-                               CODEGEN_CRITICAL_SECTION_END;
-
                                M_ISUB(REG_ITMP3, REG_ITMP1);
                                M_ICMP(REG_ITMP2, REG_ITMP1);
                                M_BHI(4);
@@ -2119,9 +2110,6 @@ nowperformreturn:
                                        superindex = super->index;
                                }
 
-                               if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                                       CODEGEN_CRITICAL_SECTION_NEW;
-
                                s1 = emit_load_s1(jd, iptr, REG_ATMP1);
                                assert(VAROP(iptr->s1)->type == TYPE_ADR);
 
@@ -2181,14 +2169,10 @@ nowperformreturn:
 
                                        M_ALD(REG_ATMP2, s1, OFFSET(java_object_t, vftbl));
 
-                                       CODEGEN_CRITICAL_SECTION_START;
-
                                        M_ILD(REG_ITMP3, REG_ATMP2, OFFSET(vftbl_t, baseval));  /* REG_ITMP3 == sub->vftbl->baseval */
                                        M_ILD(REG_ITMP1, REG_ATMP3, OFFSET(vftbl_t, baseval));
                                        M_ILD(REG_ITMP2, REG_ATMP3, OFFSET(vftbl_t, diffval));
 
-                                       CODEGEN_CRITICAL_SECTION_END;
-
                                        M_ISUB(REG_ITMP1, REG_ITMP3);
                                        M_ICMP(REG_ITMP2, REG_ITMP3);   /* XXX was CMPU */
 
@@ -2455,7 +2439,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
                        M_AST(REG_ATMP3, REG_SP, 1 * 4);
 
                /* env ist first argument */
-               M_AMOV_IMM(_Jv_env, REG_ATMP1);
+               M_AMOV_IMM(VM_get_jnienv(), REG_ATMP1);
                M_AST(REG_ATMP1, REG_SP, 0 * 4);
        }
 
index 689dd9b6a64b9ed3873809bcae88796ed0a54ab8..0cb13d0fa215b61b8bb80eb7088e1586b4c96466 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/m68k/codegen.h
 
-   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.
 
 #define PATCHER_NOPS \
        do { M_TPFL; M_TPF; M_TPF } while (0);
 
-#define PATCHER_CALL_SIZE      (3*2)
-
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE (2+2)
+#define PATCHER_CALL_SIZE      2
 
 
 /* coldfire instruction format:
index 0b48ac636c1af9d0872cc588e17954fd0e7466a9..81fc1288f2d5ac61e799535cf29cbfecaccc7ccd 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/m68k/emit.c
 
-   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.
 
 
 #include "mm/memory.h"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/trace.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
 
 
index 778c700bf71c06c59f987ffe4adb6b61e990adf7..c0358ea8d3a661d3e33a6d65c9abd9b4acacb8ae 100644 (file)
@@ -30,8 +30,8 @@
 #include "config.h"
 
 #include "vm/types.h"
-#include "vm/vm.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/vm.hpp"
+#include "vm/jit/codegen-common.hpp"
 
 void emit_mov_imm_reg (codegendata *cd, s4 imm, s4 dreg);
 void emit_mov_imm_areg(codegendata *cd, s4 imm, s4 dreg);
index 444f55c97edbeecc184ff9100fc27ebce2e86f60..21c54f56df80fc82f908b20d5cde9446d842ff3f 100644 (file)
@@ -28,9 +28,8 @@
 #include "vm/jit/m68k/md.h"
 #include "vm/jit/m68k/linux/md-abi.h"
 
-#include "vm/exceptions.h"
 #include "vm/signallocal.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/trap.h"
diff --git a/src/vm/jit/m68k/machine-instr.h b/src/vm/jit/m68k/machine-instr.h
deleted file mode 100644 (file)
index 021e723..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* src/vm/jit/m68k/machine-instr.h  
-
-   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
-
-   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 _MACHINE_INSTR_H
-#define _MACHINE_INSTR_H
-
-static inline long compare_and_swap(long *p, long oldval, long newval)
-{
-       /* XXX, coldifre has no atomic compare and swap instrcution */
-       #warning "compare_and_swap is not atmically"
-       if (*p == oldval)       {
-               *p = newval;
-               return oldval;
-       } 
-       return *p;
-}
-
-
-#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory");
-#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("" : : : "memory");
-#define MEMORY_BARRIER() __asm__ __volatile__ ( "" : : : "memory" );
-
-#endif
-
-
-/*
- * 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/jit/m68k/md-atomic.hpp b/src/vm/jit/m68k/md-atomic.hpp
new file mode 100644 (file)
index 0000000..ad5d4d2
--- /dev/null
@@ -0,0 +1,122 @@
+/* src/vm/jit/m68k/md-atomic.hpp - m68k atomic instructions
+
+   Copyright (C) 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 _MD_ATOMIC_HPP
+#define _MD_ATOMIC_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "threads/atomic.hpp"
+
+
+/**
+ * An atomic compare and swap for 32-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
+{
+       return generic_compare_and_swap(p, oldval, newval);
+}
+
+
+/**
+ * An atomic compare and swap for 64-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
+{
+       return generic_compare_and_swap(p, oldval, newval);
+}
+
+
+/**
+ * An atomic compare and swap for pointer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval)
+{
+       return generic_compare_and_swap(p, oldval, newval);
+}
+
+
+/**
+ * A memory barrier.
+ */
+inline void Atomic::memory_barrier(void)
+{
+       generic_memory_barrier();
+}
+
+
+/**
+ * A write memory barrier.
+ */
+inline void Atomic::write_memory_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+
+/**
+ * An instruction barrier.
+ */
+inline void Atomic::instruction_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+#endif // _MD_ATOMIC_HPP
+
+
+/*
+ * 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/jit/m68k/md-stubs.hpp b/src/vm/jit/m68k/md-stubs.hpp
new file mode 100644 (file)
index 0000000..e7f84f6
--- /dev/null
@@ -0,0 +1,56 @@
+/* src/vm/jit/m68k/md-stubs.hpp - m68k JIT stubs
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a m68k architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+       return 2 + 2;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * 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 69a15a3158c8ddbdc3a9464b02d6f8c5cd224c35..0e5fcca3c25b1338292dbc4af522d360a1460579 100644 (file)
@@ -48,7 +48,8 @@ enum {
        TRAP_ClassCastException             = 5,
        TRAP_CHECK_EXCEPTION                = 6,
        TRAP_PATCHER                        = 7,
-       TRAP_COMPILER                       = 8
+       TRAP_COMPILER                       = 8,
+       TRAP_COUNTDOWN                      = 9
 };
 
 #endif /* _MD_TRAP_H */
index 9fb12da0c144ba32773430e615448de7fc377bd5..071a195303ee1705de9dd1295bd30c7e4c8de5d8 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "vm/types.h"
 
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 
 /*
index bc64f4c73587868764b66054f8b02db2dbde342b..5514cc4b885b87ba0c3d5111058a262d8010f7d7 100644 (file)
@@ -33,7 +33,7 @@
 #include <assert.h>
 #include <stdint.h>
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/methodtree.h"
 
 
index 71607c7f42010a38a489cde522f59c4533c31759..186e7dcdf20bc490cf5d3d9bafa21a99d2d74e05 100644 (file)
 #include "vm/jit/m68k/md.h"
 
 #include "mm/memory.h"
-#include "native/native.h"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/resolve.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vmcore/references.h"
+#include "vm/jit/patcher-common.hpp"
 
 #include "codegen.h"
 
@@ -133,9 +130,6 @@ bool patcher_invokevirtual(patchref_t *pr)
        /* patch back original code */
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* if we show NOPs, we have to skip them */
-       if (opt_shownops) ra += PATCHER_CALL_SIZE;
-
        assert( *((u2*)(ra+8)) == 0x286b);
 
        /* patch vftbl index */
@@ -176,9 +170,6 @@ bool patcher_invokestatic_special(patchref_t *pr)
        /* patch back original code */
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* patch stubroutine */
-       if (opt_shownops) disp += PATCHER_CALL_SIZE;
-
        *((ptrint *) (disp+2)) = (ptrint) m->stubroutine;
 
        /* synchronize inst cache */
@@ -212,7 +203,6 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
        PATCH_BACK_ORIGINAL_MCODE;
 
        /* patch the classinfo pointer */
-       if (opt_shownops) disp += PATCHER_CALL_SIZE;
        *((ptrint *) (disp+2)) = (ptrint) c;
 
        /* synchronize inst cache */
@@ -251,7 +241,6 @@ bool patcher_get_putstatic(patchref_t *pr)
        md_icacheflush(pr->mpc, 2);
 
        /* patch the field value's address */
-       if (opt_shownops) disp += PATCHER_CALL_SIZE;
        assert(*((uint16_t*)(disp)) == 0x247c);
        *((intptr_t *) (disp+2)) = (intptr_t) fi->value;
 
@@ -286,9 +275,6 @@ bool patcher_get_putfield(patchref_t *pr)
        PATCH_BACK_ORIGINAL_MCODE;
        md_icacheflush(pr->mpc, 2);
 
-       /* if we show NOPs, we have to skip them */
-       if (opt_shownops) ra += PATCHER_CALL_SIZE;
-
        /* patch the field's offset */
        if (IS_LNG_TYPE(fi->type)) {
                /*
@@ -374,7 +360,6 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr)
        md_icacheflush(pr->mpc, 2);
 
        /* patch class flags */
-       if (opt_shownops) disp += PATCHER_CALL_SIZE;
        assert( (*((u2*)(disp)) == 0x263c) || (*((u2*)(disp)) == 0x283c) );
        *((s4 *) (disp + 2)) = (s4) c->flags;
 
@@ -418,7 +403,6 @@ bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
        md_icacheflush(pr->mpc, 2);
 
        /* patch super class' vftbl */
-       if (opt_shownops) disp += PATCHER_CALL_SIZE;
        assert( (*((u2*)disp) == 0x287c) || (*((u2*)disp)== 0x267c) );
 
        *((s4 *) (disp+2)) = (s4) c->vftbl;
@@ -463,9 +447,6 @@ bool patcher_instanceof_interface(patchref_t *pr)
        PATCH_BACK_ORIGINAL_MCODE;
        md_icacheflush(pr->mpc, 2);
 
-       /* if we show NOPs, we have to skip them */
-       if (opt_shownops) ra += PATCHER_CALL_SIZE;
-               
        /* patch super class index */
        disp = -(c->index);
        assert( *((u2*)(ra + 8)) == 0xd8bc );
@@ -517,9 +498,6 @@ bool patcher_checkcast_interface(patchref_t *pr)
        PATCH_BACK_ORIGINAL_MCODE;
        md_icacheflush(pr->mpc, 2);
 
-       /* if we show NOPs, we have to skip them */
-       if (opt_shownops) ra += PATCHER_CALL_SIZE;
-
        /* patch super class index */
        disp = -(c->index);
        assert ( *((u2 *)(ra + 8)) == 0xd8bc );
@@ -562,7 +540,6 @@ bool patcher_resolve_native_function(patchref_t *pr)
        md_icacheflush(pr->mpc, 2);
 
        /* patch native function pointer */
-       if (opt_shownops) disp += PATCHER_CALL_SIZE;
        *((ptrint *) (disp + 2)) = (ptrint) f;
 
        /* synchronize data cache */
@@ -604,7 +581,6 @@ bool patcher_invokeinterface(patchref_t *pr)
        md_icacheflush(pr->mpc, 2);
 
        /* if we show NOPs, we have to skip them */
-       if (opt_shownops) ra += PATCHER_CALL_SIZE;
        assert( *((uint32_t*)ra) == 0x246f0000 );
 
        /* patch interfacetable index (first #0) */
@@ -623,6 +599,8 @@ bool patcher_invokeinterface(patchref_t *pr)
 
        return true;
 }
+
+
 /*
  * 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
index 262804ecb52002501a11a405510061e29fd867c4..0cb513794b8f5998e0979b414544f812b6356bea 100644 (file)
 
 #include "mm/memory.h"
 
-#include "threads/thread.h"
-
 #include "toolbox/avl.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/methodtree.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* methodtree_element *********************************************************/
index e2be2204399c89bf16504d76319aae2944a89888..eef8d3fcaa17ea514528c31c3b8a74b0e19d0921 100644 (file)
 
 #include <stdint.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "toolbox/avl.h"
 
 
@@ -40,6 +44,10 @@ void  methodtree_insert(void *startpc, void *endpc);
 void *methodtree_find(void *pc);
 void *methodtree_find_nocheck(void *pc);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _METHODTREE_H */
 
 
index ce07cde79a90340b974fd6520b4ca34534e201ea..751957ff1fe7be62abad0efcd7bea12a2830425f 100644 (file)
@@ -35,9 +35,9 @@ LIBS =
 
 noinst_HEADERS = \
        arch.h \
-       machine-instr.h \
        \
-       md-asm.h
+       md-asm.h \
+       md-atomic.hpp
 
 noinst_LTLIBRARIES = \
        libarch.la
@@ -57,6 +57,7 @@ libarch_la_SOURCES = \
        \
        md-abi.c \
        md-abi.h \
+       md-stubs.hpp \
        md-trap.h \
        md.c \
        md.h
index a6c4864d90395ed70f244e5a958ab28c62393c7e..e2ed877694cd5993a90e5f7b22e2e2a6c1a49faf 100644 (file)
@@ -35,8 +35,6 @@
 
 /* define architecture features ***********************************************/
 
-#define U8_AVAILABLE                     1
-
 #if SIZEOF_VOID_P == 8
 
 #define SUPPORT_DIVISION                 1
index 2a3b5fc0c8120b8de35efcec2397af1855400cc3..73732e6c633c1132f565994df8c1401b9620cb53 100644 (file)
@@ -51,8 +51,6 @@
 
        .globl asm_abstractmethoderror
 
-       .globl compare_and_swap
-
 
 /* asm_vm_call_method **********************************************************
 *                                                                              *
@@ -423,16 +421,16 @@ ex_int2:
        l.d     fs1,-3*8(t1)
        l.d     fs2,-2*8(t1)
        l.d     fs3,-1*8(t1)
-#else /* SIZEOF_VOID_P == 8 */
+#else
 # if !defined(ENABLE_SOFT_FLOAT)
-       l.d     fs0,-4*8(t1)
-       l.d     fs1,-3*8(t1)
-       l.d     fs2,-2*8(t1)
-       l.d     fs3,-1*8(t1)
-       l.d     fs4,-1*8(t1)
+       l.d     fs0,-6*8(t1)
+       l.d     fs1,-5*8(t1)
+       l.d     fs2,-4*8(t1)
+       l.d     fs3,-3*8(t1)
+       l.d     fs4,-2*8(t1)
        l.d     fs5,-1*8(t1)
-# endif /* !defined(ENABLE_SOFT_FLOAT) */
-#endif /* SIZEOF_VOID_P == 8 */
+# endif
+#endif
 
 ex_flt2:
        lw      t1,FrameSize(pv)            /* get frame size                     */
@@ -466,40 +464,6 @@ asm_abstractmethoderror:
        .end    asm_abstractmethoderror
 
 
-       .ent    compare_and_swap
-
-compare_and_swap:
-1:
-#if defined(__GNUC__)
-       .set mips2
-#endif
-       all     v0,0(a0)
-#if defined(__GNUC__)
-       .set mips0
-#endif
-       bne     v0,a1,2f
-       move    t0,a2
-#if defined(__GNUC__)
-       .set mips2
-#endif
-       asc     t0,0(a0)
-#if defined(__GNUC__)
-       .set mips0
-#endif
-       beqz    t0,1b
-2:
-#if defined(__GNUC__)
-       .set mips2
-#endif
-       sync
-#if defined(__GNUC__)
-       .set mips0
-#endif
-       j       ra
-
-       .end    compare_and_swap
-
-
 /* disable exec-stacks ********************************************************/
 
 #if defined(__linux__) && defined(__ELF__)
index cbb334513e2a6c18c17280cd72c742d045bc5a9b..e81137a706df83df1b9f9581ae93a76d7d8efd1a 100644 (file)
 
 #include "mm/memory.h"
 
-#include "native/localref.h"
-#include "native/native.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/vm.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/options.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
+#include "vm/jit/replace.hpp"
 #include "vm/jit/trap.h"
 
 #if defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
 #endif
 
-#include "vmcore/class.h"
-#include "vmcore/options.h"
-
 
 /* codegen_emit ****************************************************************
 
@@ -1404,13 +1403,13 @@ bool codegen_emit(jitdata *jd)
                        M_CMPLT(s1, s2, REG_ITMP3);
                        M_CMPLT(s2, s1, REG_ITMP1);
                        M_ISUB(REG_ITMP1, REG_ITMP3, d);
-                       M_BNEZ(d, 4);
-                       M_NOP;
+                       emit_label_bnez(cd, BRANCH_LABEL_1, d);
                        s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
                        M_CMPULT(s1, s2, REG_ITMP3);
                        M_CMPULT(s2, s1, REG_ITMP1);
                        M_ISUB(REG_ITMP1, REG_ITMP3, d);
+                       emit_label(cd, BRANCH_LABEL_1);
 #endif
                        emit_store_dst(jd, iptr, d);
                        break;
@@ -2431,12 +2430,12 @@ bool codegen_emit(jitdata *jd)
                                ICONST(REG_ITMP2, iptr->sx.val.l >> 32);
                                M_CMPLT(s1, REG_ITMP2, REG_ITMP3);
                                emit_bnez(cd, iptr->dst.block, REG_ITMP3);
+                               emit_label_bne(cd, BRANCH_LABEL_1, s1, REG_ITMP2);
                                s2 = emit_load_s1_low(jd, iptr, REG_ITMP3);
-                               M_BNE(s1, REG_ITMP2, 5); /* XXX */
-                               M_NOP;
                                ICONST(REG_ITMP2, iptr->sx.val.l & 0xffffffff);
                                M_CMPULT(s2, REG_ITMP2, REG_ITMP3);
                                emit_bnez(cd, iptr->dst.block, REG_ITMP3);
+                               emit_label(cd, BRANCH_LABEL_1);
                        }
 #endif
                        break;
@@ -2461,22 +2460,22 @@ bool codegen_emit(jitdata *jd)
 #else
                        if (iptr->sx.val.l == 0) {
                                s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
-                               M_BGTZ(GET_HIGH_REG(s1), 5); /* XXX */
-                               M_NOP;
+                               emit_label_bgtz(cd, BRANCH_LABEL_1, GET_HIGH_REG(s1));
                                emit_bltz(cd, iptr->dst.block, GET_HIGH_REG(s1));
-                               emit_beqz(cd, iptr->dst.block, GET_LOW_REG(s1));
+                               emit_beqz(cd, iptr->dst.block, GET_LOW_REG(s1));        
+                               emit_label(cd, BRANCH_LABEL_1);
                        }
                        else {
                                s1 = emit_load_s1_high(jd, iptr, REG_ITMP1);
                                ICONST(REG_ITMP2, iptr->sx.val.l >> 32);
                                M_CMPLT(s1, REG_ITMP2, REG_ITMP3);
                                emit_bnez(cd, iptr->dst.block, REG_ITMP3);
+                               emit_label_bne(cd, BRANCH_LABEL_1, s1, REG_ITMP2);
                                s2 = emit_load_s1_low(jd, iptr, REG_ITMP3);
-                               M_BNE(s1, REG_ITMP2, 5); /* XXX */
-                               M_NOP;
                                ICONST(REG_ITMP2, iptr->sx.val.l & 0xffffffff);
                                M_CMPUGT(s2, REG_ITMP2, REG_ITMP3);
                                emit_beqz(cd, iptr->dst.block, REG_ITMP3);
+                               emit_label(cd, BRANCH_LABEL_1);
                        }
 #endif
                        break;
@@ -2531,21 +2530,21 @@ bool codegen_emit(jitdata *jd)
                        if (iptr->sx.val.l == 0) {
                                s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
                                emit_bgtz(cd, iptr->dst.block, GET_HIGH_REG(s1));
-                               M_BLTZ(GET_HIGH_REG(s1), 3); /* XXX */
-                               M_NOP;
+                               emit_label_bltz(cd, BRANCH_LABEL_1, GET_HIGH_REG(s1));
                                emit_bnez(cd, iptr->dst.block, GET_LOW_REG(s1));
+                               emit_label(cd, BRANCH_LABEL_1);
                        }
                        else {
                                s1 = emit_load_s1_high(jd, iptr, REG_ITMP1);
                                ICONST(REG_ITMP2, iptr->sx.val.l >> 32);
                                M_CMPGT(s1, REG_ITMP2, REG_ITMP3);
                                emit_bnez(cd, iptr->dst.block, REG_ITMP3);
+                               emit_label_bne(cd, BRANCH_LABEL_1, s1, REG_ITMP2);
                                s2 = emit_load_s1_low(jd, iptr, REG_ITMP3);
-                               M_BNE(s1, REG_ITMP2, 5); /* XXX */
-                               M_NOP;
                                ICONST(REG_ITMP2, iptr->sx.val.l & 0xffffffff);
                                M_CMPUGT(s2, REG_ITMP2, REG_ITMP3);
                                emit_bnez(cd, iptr->dst.block, REG_ITMP3);
+                               emit_label(cd, BRANCH_LABEL_1);
                        }
 #endif
                        break;
@@ -2577,12 +2576,12 @@ bool codegen_emit(jitdata *jd)
                                ICONST(REG_ITMP2, iptr->sx.val.l >> 32);
                                M_CMPGT(s1, REG_ITMP2, REG_ITMP3);
                                emit_bnez(cd, iptr->dst.block, REG_ITMP3);
+                               emit_label_bne(cd, BRANCH_LABEL_1, s1, REG_ITMP2);
                                s2 = emit_load_s1_low(jd, iptr, REG_ITMP3);
-                               M_BNE(s1, REG_ITMP2, 5); /* XXX */
-                               M_NOP;
                                ICONST(REG_ITMP2, iptr->sx.val.l & 0xffffffff);
                                M_CMPULT(s2, REG_ITMP2, REG_ITMP3);
                                emit_beqz(cd, iptr->dst.block, REG_ITMP3);
+                               emit_label(cd, BRANCH_LABEL_1);
                        }
 #endif
                        break;
@@ -2604,11 +2603,11 @@ bool codegen_emit(jitdata *jd)
 
                        s1 = emit_load_s1_high(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2_high(jd, iptr, REG_ITMP2);
-                       M_BNE(s1, s2, 3); /* XXX TWISTI: uff, that is a problem */
-                       M_NOP;
+                       emit_label_bne(cd, BRANCH_LABEL_1, s1, s2);
                        s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
                        emit_beq(cd, iptr->dst.block, s1, s2);
+                       emit_label(cd, BRANCH_LABEL_1);
                        break;
 #endif
 
@@ -2655,13 +2654,12 @@ bool codegen_emit(jitdata *jd)
                        M_CMPLT(s1, s2, REG_ITMP3);
                        emit_bnez(cd, iptr->dst.block, REG_ITMP3);
                        M_CMPGT(s1, s2, REG_ITMP3);
-                       /* load low-bits before the branch, so we know the distance */
+                       emit_label_bnez(cd, BRANCH_LABEL_1, REG_ITMP3);
                        s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
-                       M_BNEZ(REG_ITMP3, 4); /* XXX */
-                       M_NOP;
                        M_CMPULT(s1, s2, REG_ITMP3);
                        emit_bnez(cd, iptr->dst.block, REG_ITMP3);
+                       emit_label(cd, BRANCH_LABEL_1);
                        break;
 #endif
 
@@ -2684,13 +2682,12 @@ bool codegen_emit(jitdata *jd)
                        M_CMPGT(s1, s2, REG_ITMP3);
                        emit_bnez(cd, iptr->dst.block, REG_ITMP3);
                        M_CMPLT(s1, s2, REG_ITMP3);
-                       /* load low-bits before the branch, so we know the distance */
+                       emit_label_bnez(cd, BRANCH_LABEL_1, REG_ITMP3);
                        s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
-                       M_BNEZ(REG_ITMP3, 4); /* XXX */
-                       M_NOP;
                        M_CMPUGT(s1, s2, REG_ITMP3);
                        emit_bnez(cd, iptr->dst.block, REG_ITMP3);
+                       emit_label(cd, BRANCH_LABEL_1);
                        break;
 #endif
 
@@ -2713,13 +2710,12 @@ bool codegen_emit(jitdata *jd)
                        M_CMPLT(s1, s2, REG_ITMP3);
                        emit_bnez(cd, iptr->dst.block, REG_ITMP3);
                        M_CMPGT(s1, s2, REG_ITMP3);
-                       /* load low-bits before the branch, so we know the distance */
+                       emit_label_bnez(cd, BRANCH_LABEL_1, REG_ITMP3);
                        s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
-                       M_BNEZ(REG_ITMP3, 4); /* XXX */
-                       M_NOP;
                        M_CMPUGT(s1, s2, REG_ITMP3);
                        emit_beqz(cd, iptr->dst.block, REG_ITMP3);
+                       emit_label(cd, BRANCH_LABEL_1);
                        break;
 #endif
 
@@ -2742,13 +2738,12 @@ bool codegen_emit(jitdata *jd)
                        M_CMPGT(s1, s2, REG_ITMP3);
                        emit_bnez(cd, iptr->dst.block, REG_ITMP3);
                        M_CMPLT(s1, s2, REG_ITMP3);
-                       /* load low-bits before the branch, so we know the distance */
+                       emit_label_bnez(cd, BRANCH_LABEL_1, REG_ITMP3);
                        s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2_low(jd, iptr, REG_ITMP2);
-                       M_BNEZ(REG_ITMP3, 4); /* XXX */
-                       M_NOP;
                        M_CMPULT(s1, s2, REG_ITMP3);
                        emit_beqz(cd, iptr->dst.block, REG_ITMP3);
+                       emit_label(cd, BRANCH_LABEL_1);
                        break;
 #endif
 
@@ -3236,9 +3231,6 @@ gen_method:
                                        superindex = super->index;
                                }
                        
-                               if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                                       CODEGEN_CRITICAL_SECTION_NEW;
-
                                s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                                /* if class is not resolved, check which code to call */
@@ -3309,8 +3301,6 @@ gen_method:
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl));
                                        M_ALD(REG_ITMP3, REG_PV, disp);
 
-                                       CODEGEN_CRITICAL_SECTION_START;
-
                                        M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                        /*                              if (s1 != REG_ITMP1) { */
                                        /*                                      M_ILD(REG_ITMP1, REG_ITMP3, OFFSET(vftbl_t, baseval)); */
@@ -3325,8 +3315,6 @@ gen_method:
                                        M_ALD(REG_ITMP3, REG_PV, disp);
                                        M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval));
 
-                                       CODEGEN_CRITICAL_SECTION_END;
-
                                        /*                              } */
                                        M_CMPULT(REG_ITMP3, REG_ITMP2, REG_ITMP3);
                                        emit_classcast_check(cd, iptr, ICMD_IFNE, REG_ITMP3, s1);
@@ -3391,9 +3379,6 @@ gen_method:
                                superindex = super->index;
                        }
                        
-                       if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                               CODEGEN_CRITICAL_SECTION_NEW;
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
@@ -3471,14 +3456,10 @@ gen_method:
                                M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl));
                                M_ALD(REG_ITMP2, REG_PV, disp);
 
-                               CODEGEN_CRITICAL_SECTION_START;
-
                                M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 
-                               CODEGEN_CRITICAL_SECTION_END;
-
                                M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1); 
                                M_CMPULT(REG_ITMP2, REG_ITMP1, d);
                                M_XOR_IMM(d, 1, d);
@@ -3885,7 +3866,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
                /* put env into first argument register */
 
-               disp = dseg_add_address(cd, _Jv_env);
+               disp = dseg_add_address(cd, VM_get_jnienv());
                M_ALD(REG_A0, REG_PV, disp);
        }
 
index c759180bf28316a2f11b141726422f52f07c8cd9..f1819f84887019bfde43a03560182b44a9a74603 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/mips/codegen.h - code generation macros and definitions for MIPS
 
-   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.
 
@@ -31,7 +29,7 @@
 #include "config.h"
 #include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* additional functions and macros to generate code ***************************/
     } while (0)
 
 
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE    1 * 4
-
-
 /* macros to create code ******************************************************/
 
 /* code generation macros operands:
 
 /* macros for all used commands (see a MIPS-manual for description) ***********/
 
+#define M_RESERVED              M_RTYPE(0x3b, 0, 0, 0, 0, 0)
+
 /* load/store macros use the form OPERATION(source/dest, base, offset)        */
 
 #define M_LDA(a,b,disp) \
index a8a7e225f0e1d6cf83a67cf46e0dab43c5cc00db..fb41435ebd8bf88e3c02f9827346a2d2d3765c7f 100644 (file)
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h" /* XXX for gen_resolvebranch */
+#include "vm/jit/builtin.hpp"
+#include "vm/options.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/replace.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/options.h"
-
 
 /* emit_load *******************************************************************
 
@@ -381,20 +378,15 @@ void emit_lconst(codegendata *cd, s4 d, s8 value)
 
 void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 opt)
 {
-       s4 checkdisp;
-       s4 branchdisp;
-
-       /* calculate the different displacements */
-
-       checkdisp  = (disp - 4);
-       branchdisp = (disp - 4) >> 2;
+       // Calculate the displacements.
+       int32_t checkdisp  = (disp - 4);
+       int32_t branchdisp = (disp - 4) >> 2;
 
        /* check which branch to generate */
 
        if (condition == BRANCH_UNCONDITIONAL) {
-               /* check displacement for overflow */
-
-               if ((checkdisp < (s4) 0xffff8000) || (checkdisp > (s4) 0x00007fff)) {
+               // Check displacement for overflow.
+               if (opt_AlwaysEmitLongBranches || ((checkdisp < (int32_t) 0xffff8000) || (checkdisp > (int32_t) 0x00007fff))) {
                        /* if the long-branches flag isn't set yet, do it */
 
                        if (!CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) {
@@ -402,7 +394,20 @@ void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 opt)
                                                          CODEGENDATA_FLAG_LONGBRANCHES);
                        }
 
-                       vm_abort("emit_branch: emit unconditional long-branch code");
+                       // Calculate the offset relative to PV.
+                       int32_t currentrpc = cd->mcodeptr - cd->mcodebase;
+                       int32_t offset     = currentrpc + disp;
+
+                       // Sanity check.
+                       assert(offset % 4 == 0);
+
+                       // Do the long-branch.
+                       M_LUI(REG_ITMP3, offset >> 16);
+                       M_OR_IMM(REG_ITMP3, offset, REG_ITMP3);
+                       M_AADD(REG_PV, REG_ITMP3, REG_ITMP3);
+                       M_JMP(REG_ITMP3);
+                       M_NOP;
+                       M_NOP; // This nop is to have 6 instructions (see BRANCH_NOPS).
                }
                else {
                        M_BR(branchdisp);
@@ -410,9 +415,8 @@ void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 opt)
                }
        }
        else {
-               /* and displacement for overflow */
-
-               if ((checkdisp < (s4) 0xffff8000) || (checkdisp > (s4) 0x00007fff)) {
+               // Check displacement for overflow.
+               if (opt_AlwaysEmitLongBranches || ((checkdisp < (int32_t) 0xffff8000) || (checkdisp > (int32_t) 0x00007fff))) {
                        /* if the long-branches flag isn't set yet, do it */
 
                        if (!CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) {
@@ -420,6 +424,14 @@ void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 opt)
                                                          CODEGENDATA_FLAG_LONGBRANCHES);
                        }
 
+                       // Calculate the offset relative to PV before we generate
+                       // new code.
+                       int32_t currentrpc = cd->mcodeptr - cd->mcodebase;
+                       int32_t offset     = currentrpc + disp;
+
+                       // Sanity check.
+                       assert(offset % 4 == 0);
+
                        switch (condition) {
                        case BRANCH_EQ:
                                M_BNE(GET_HIGH_REG(reg), GET_LOW_REG(reg), 5);
@@ -443,15 +455,16 @@ void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 opt)
                                vm_abort("emit_branch: unknown condition %d", condition);
                        }
 
-                       /* The actual branch code which is over-jumped (NOTE: we
-                          don't use a branch delay slot here). */
+                       // The actual branch code which is over-jumped.  NOTE: We
+                       // don't use a branch delay slot for the conditional
+                       // branch.
 
-                       M_LUI(REG_ITMP3, branchdisp >> 16);
-                       M_OR_IMM(REG_ITMP3, branchdisp, REG_ITMP3);
+                       // Do the long-branch.
+                       M_LUI(REG_ITMP3, offset >> 16);
+                       M_OR_IMM(REG_ITMP3, offset, REG_ITMP3);
                        M_AADD(REG_PV, REG_ITMP3, REG_ITMP3);
                        M_JMP(REG_ITMP3);
                        M_NOP;
-
                }
                else {
                        switch (condition) {
@@ -618,14 +631,11 @@ void emit_trap_compiler(codegendata *cd)
 
 uint32_t emit_trap(codegendata *cd)
 {
-       uint32_t mcode;
-
-       /* Get machine code which is patched back in later. The
-          trap is 1 instruction word long. */
-
-       mcode = *((uint32_t *) cd->mcodeptr);
+       // Get machine code which is patched back in later. The trap is 1
+       // instruction word long.
+       uint32_t mcode = *((uint32_t*) cd->mcodeptr);
 
-       M_ALD_INTERN(REG_ZERO, REG_ZERO, TRAP_PATCHER);
+       M_RESERVED;
 
        return mcode;
 }
index d14fb611e8f98bcd8f8dfd66b2b7c1327cf1f2f3..39117af25e977df19bae4686bfbf16433def1c09 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/mips/irix/md-os.c - machine dependent MIPS IRIX functions
 
-   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.
 
 #include "vm/jit/mips/codegen.h"
 #include "vm/jit/mips/md-abi.h"
 
-#include "mm/gc-common.h"
+#include "mm/gc.hpp"
 
 #include "vm/global.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* md_init *********************************************************************
@@ -145,34 +141,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 }
 
 
-/* md_critical_section_restart *************************************************
-
-   Search the critical sections tree for a matching section and set
-   the PC to the restart point, if necessary.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
-{
-       mcontext_t *_mc;
-       u1         *pc;
-       u1         *npc;
-
-       _mc = &_uc->uc_mcontext;
-
-       pc = (u1 *) _mc->gregs[CTX_EPC];
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL) {
-               log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc);
-               _mc->gregs[CTX_EPC] = (ptrint) npc;
-       }
-}
-#endif
-
-
 /*
  * 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
index aebc1666aba9a0d16f8d1db30cecc62d0b8d3feb..f7b6601de5b8556c29b47905d88115ebc1df5156 100644 (file)
 #include "vm/jit/mips/md.h"
 #include "vm/jit/mips/md-abi.h"
 
-#include "mm/gc-common.h"
+#include "mm/gc.hpp"
 #include "mm/memory.h"
 
-#include "vm/exceptions.h"
 #include "vm/signallocal.h"
+#include "vm/os.hpp"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/stacktrace.h"
 #include "vm/jit/trap.h"
 
 
@@ -216,28 +215,71 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
                /* fall-through */
 
-       case TRAP_PATCHER:
-               if (p == NULL) {
-                       /* We set the PC again because the cause may have changed
-                          the XPC. */
+       default:
+               _gregs[REG_ITMP1_XPTR] = (uintptr_t) p;
+               _gregs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
+#if defined(__UCLIBC__)
+               _gregs[CTX_EPC]        = (uintptr_t) asm_handle_exception;
+#else
+               _mc->pc                = (uintptr_t) asm_handle_exception;
+#endif
+       }
+}
+
+
+/**
+ * Signal handler for patcher calls.
+ */
+void md_signal_handler_sigill(int sig, siginfo_t* siginfo, void* _p)
+{
+       ucontext_t* _uc = (struct ucontext *) _p;
+       mcontext_t* _mc = &_uc->uc_mcontext;
+       greg_t* _gregs;
 
 #if defined(__UCLIBC__)
-                       _gregs[CTX_EPC] = (uintptr_t) xpc;
+       _gregs = _mc->gpregs;
+#else  
+       _gregs = _mc->gregs;
+#endif
+
+       // In glibc's ucontext.h the registers are defined as long long
+       // int, even for MIPS32, so we cast them.  This is not the case
+       // for uClibc.
+       void* pv  = (void*) (uintptr_t) _gregs[REG_PV];
+       void* sp  = (void*) (uintptr_t) _gregs[REG_SP];
+       void* ra  = (void*) (uintptr_t) _gregs[REG_RA]; // The RA is correct for leaf methods.
+
+#if defined(__UCLIBC__)
+       void* xpc = (void*) (uintptr_t) _gregs[CTX_EPC];
 #else
-                       _mc->pc         = (uintptr_t) xpc;
+       void* xpc = (void*) (uintptr_t) _mc->pc;
 #endif
-                       break;
-               }
 
-               /* fall-through */
-               
-       default:
+       // This signal is always a patcher.
+       int      type = TRAP_PATCHER;
+       intptr_t val  = 0;
+
+       // Handle the trap.
+       void* p = trap_handle(type, val, pv, sp, ra, xpc, _p);
+
+       // Set registers if we have an exception, continue execution
+       // otherwise.
+       if (p != NULL) {
                _gregs[REG_ITMP1_XPTR] = (uintptr_t) p;
                _gregs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
 #if defined(__UCLIBC__)
                _gregs[CTX_EPC]        = (uintptr_t) asm_handle_exception;
 #else
                _mc->pc                = (uintptr_t) asm_handle_exception;
+#endif
+       }
+       else {
+               // We set the PC again because the cause may have changed the
+               // XPC.
+#if defined(__UCLIBC__)
+               _gregs[CTX_EPC] = (uintptr_t) xpc;
+#else
+               _mc->pc         = (uintptr_t) xpc;
 #endif
        }
 }
@@ -305,7 +347,7 @@ void md_executionstate_read(executionstate_t* es, void* context)
           _mc->fpregs[i] can cause invalid conversions. */
 
        assert(sizeof(_mc->fpregs.fp_r) == sizeof(es->fltregs));
-       system_memcpy(&es->fltregs, &_mc->fpregs.fp_r, sizeof(_mc->fpregs.fp_r));
+       os_memcpy(&es->fltregs, &_mc->fpregs.fp_r, sizeof(_mc->fpregs.fp_r));
 }
 
 
@@ -338,7 +380,7 @@ void md_executionstate_write(executionstate_t* es, void* context)
           _mc->fpregs[i] can cause invalid conversions. */
 
        assert(sizeof(_mc->fpregs.fp_r) == sizeof(es->fltregs));
-       system_memcpy(&_mc->fpregs.fp_r, &es->fltregs, sizeof(_mc->fpregs.fp_r));
+       os_memcpy(&_mc->fpregs.fp_r, &es->fltregs, sizeof(_mc->fpregs.fp_r));
 
        /* Write special registers. */
 
@@ -354,41 +396,6 @@ void md_executionstate_write(executionstate_t* es, void* context)
 }
 
 
-/* md_critical_section_restart *************************************************
-
-   Search the critical sections tree for a matching section and set
-   the PC to the restart point, if necessary.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
-{
-       mcontext_t *_mc;
-       u1         *pc;
-       u1         *npc;
-
-       _mc = &_uc->uc_mcontext;
-
-#if defined(__UCLIBC__)
-       pc = (u1 *) (ptrint) _mc->gpregs[CTX_EPC];
-#else
-       pc = (u1 *) (ptrint) _mc->pc;
-#endif
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL) {
-#if defined(__UCLIBC__)
-               _mc->gpregs[CTX_EPC] = (ptrint) npc;
-#else
-               _mc->pc              = (ptrint) npc;
-#endif
-       }
-}
-#endif
-
-
 /*
  * 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
diff --git a/src/vm/jit/mips/machine-instr.h b/src/vm/jit/mips/machine-instr.h
deleted file mode 100644 (file)
index 848a164..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef _MACHINE_INSTR_H
-#define _MACHINE_INSTR_H
-
-#if 0
-
-/* If anyone wants to compile with gcc, use this section.
- * It is not usable with the MIPSPro compiler.
- *
- * It is outdated, too.
- */ 
-
-static inline int
-__attribute__ ((unused))
-compare_and_swap (volatile long *p, long oldval, long newval)
-{
-  long ret, temp;
-
-  __asm__ __volatile__
-    ("1:\n\t"
-     ".set  push\n\t"
-     ".set  mips2\n\t"
-     "lld   %1,%5\n\t"
-     "move  %0,$0\n\t"
-     "bne   %1,%3,2f\n\t"
-     "move  %0,%4\n\t"
-     "scd   %0,%2\n\t"
-     ".set  pop\n\t"
-     "beqz  %0,1b\n"
-     "2:\n\t"
-     : "=&r" (ret), "=&r" (temp), "=m" (*p)
-     : "r" (oldval), "r" (newval), "m" (*p)
-     : "memory");
-
-  return ret;
-}
-
-#else
-
-long compare_and_swap (long *p, long oldval, long newval);
-
-#define STORE_ORDER_BARRIER()
-#define MEMORY_BARRIER_AFTER_ATOMIC()
-#define MEMORY_BARRIER()
-
-#endif
-#endif
index 256fa4717a8fe25180125c2e63ffe8ec469dd426..3b4be869c9e99f15e01b652a88f55dc2246e4276 100644 (file)
 
 #include "mm/memory.h"
 
+#include "vm/descriptor.h"
 #include "vm/global.h"
+#include "vm/method.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/stack.h"
 
-#include "vmcore/descriptor.h"
-#include "vmcore/method.h"
-
 
 /* register descripton array **************************************************/
 
diff --git a/src/vm/jit/mips/md-atomic.hpp b/src/vm/jit/mips/md-atomic.hpp
new file mode 100644 (file)
index 0000000..5cf0a3e
--- /dev/null
@@ -0,0 +1,166 @@
+/* src/vm/jit/mips/atomic.hpp - MIPS atomic instructions
+
+   Copyright (C) 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 _MD_ATOMIC_HPP
+#define _MD_ATOMIC_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "threads/atomic.hpp"
+
+
+/**
+ * An atomic compare and swap for 32-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
+{
+       uint32_t result;
+       uint32_t temp;
+
+       __asm__ __volatile__ (
+               "    .set  push      \n"
+               "    .set  mips2     \n"
+               "1:                  \n"
+               "    ll    %0,%5     \n"
+               "    bne   %0,%3,2f  \n"
+               "    move  %1,%4     \n"
+               "    sc    %1,%2     \n"
+               "    .set  pop       \n"
+               "    beqz  %1,1b     \n"
+               "2:                  \n"
+               : "=&r" (result), "=&r" (temp), "=m" (*p)
+               : "r" (oldval), "r" (newval), "m" (*p)
+               : "memory");
+
+       return result;
+}
+
+
+/**
+ * An atomic compare and swap for 64-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
+{
+#if SIZEOF_VOID_P == 8
+       uint64_t result;
+       uint64_t temp;
+
+       __asm__ __volatile__ (
+               "    .set  push      \n"
+               "    .set  mips2     \n"
+               "1:                  \n"
+               "    lld   %0,%5     \n"
+               "    bne   %0,%3,2f  \n"
+               "    move  %1,%4     \n"
+               "    scd   %1,%2     \n"
+               "    .set  pop       \n"
+               "    beqz  %1,1b     \n"
+               "2:                  \n"
+               : "=&r" (result), "=&r" (temp), "=m" (*p)
+               : "r" (oldval), "r" (newval), "m" (*p)
+               : "memory");
+
+       return result;
+#else
+       return generic_compare_and_swap(p, oldval, newval);
+#endif
+}
+
+
+/**
+ * An atomic compare and swap for pointer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval)
+{
+#if SIZEOF_VOID_P == 8
+       return (void*) compare_and_swap((volatile uint64_t*) p, (uint64_t) oldval, (uint64_t) newval);
+#else
+       return (void*) compare_and_swap((volatile uint32_t*) p, (uint32_t) oldval, (uint32_t) newval);
+#endif
+}
+
+
+/**
+ * A memory barrier.
+ */
+inline void Atomic::memory_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+
+/**
+ * A write memory barrier.
+ */
+inline void Atomic::write_memory_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+
+/**
+ * An instruction barrier.
+ */
+inline void Atomic::instruction_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+#endif // _MD_ATOMIC_HPP
+
+
+/*
+ * 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/jit/mips/md-stubs.hpp b/src/vm/jit/mips/md-stubs.hpp
new file mode 100644 (file)
index 0000000..7451d76
--- /dev/null
@@ -0,0 +1,56 @@
+/* src/vm/jit/mips/md-stubs.hpp - MIPS JIT stubs
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a MIPS architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+       return 1 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * 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 9fca702ef11d8d14dcdb5171c9eb62a23a62fa14..9ea8bd5c6350190601980e3f65ead85962566e5a 100644 (file)
@@ -53,12 +53,15 @@ enum {
 
        TRAP_ClassCastException             = 5,
        TRAP_CHECK_EXCEPTION                = 6,
-       TRAP_PATCHER                        = 7,
+       TRAP_COMPILER                       = 7,
 
        /* Don't use 8 (could be a normal load offset). */
 
-       TRAP_COMPILER                       = 9,
-       TRAP_END
+       TRAP_COUNTDOWN                      = 9,
+       TRAP_END,
+
+       // This is handled via SIGILL.
+       TRAP_PATCHER                        = 99 // A large number.
 };
 
 #endif /* _MD_TRAP_H */
index 61e5113ee000d5382eff5ba3e8a61d9b59413556..6a83c92da84516d42e7cbce2bf635b4c12416333 100644 (file)
@@ -35,9 +35,9 @@
 #include "vm/jit/mips/md.h"
 
 #include "vm/global.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* md_jit_method_patch_address *************************************************
index fc70b19bddbcbc9b229c9bdd1780f37f1a648207..100be5e306f3b2fa006624ca76270654f7d09028 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/mips/md.h - machine dependent MIPS functions
 
-   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.
 
@@ -37,7 +35,7 @@
 
 #include "vm/types.h"
 
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 
 /* md_stacktrace_get_returnaddress *********************************************
@@ -70,28 +68,28 @@ inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframe
 
 *******************************************************************************/
 
-inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
+inline static void* md_codegen_get_pv_from_pc(void* ra)
 {
-       u1 *pv;
-       u4  mcode;
-       s4  offset;
+       int32_t offset;
+
+       uint32_t* pc = (uint32_t*) ra;
 
        /* get the offset of the instructions */
 
        /* get first instruction word after jump */
 
-       mcode = *((u4 *) ra);
+       uint32_t mcode = pc[0];
 
        /* check if we have 2 instructions (lui, daddiu) */
 
        if ((mcode >> 16) == 0x3c19) {
                /* get displacement of first instruction (lui) */
 
-               offset = (s4) (mcode << 16);
+               offset = (int32_t) (mcode << 16);
 
                /* get displacement of second instruction (daddiu) */
 
-               mcode = *((u4 *) (ra + 1 * 4));
+               mcode = pc[1];
 
 #if SIZEOF_VOID_P == 8
                assert((mcode >> 16) == 0x6739);
@@ -99,25 +97,23 @@ inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
                assert((mcode >> 16) == 0x2739);
 #endif
 
-               offset += (s2) (mcode & 0x0000ffff);
+               offset += (int16_t) (mcode & 0x0000ffff);
        }
        else {
                /* get offset of first instruction (daddiu) */
 
-               mcode = *((u4 *) ra);
-
 #if SIZEOF_VOID_P == 8
                assert((mcode >> 16) == 0x67fe);
 #else
                assert((mcode >> 16) == 0x27fe);
 #endif
 
-               offset = (s2) (mcode & 0x0000ffff);
+               offset = (int16_t) (mcode & 0x0000ffff);
        }
 
        /* calculate PV via RA + offset */
 
-       pv = ra + offset;
+       void* pv = (void*) (((uintptr_t) ra) + offset);
 
        return pv;
 }
index ef4f476b778cfda22773a1b01e5323a007735af3..a5a5785b11810fa80ac1a1a8d2e5090f669822bb 100644 (file)
 #include <assert.h>
 #include <stdint.h>
 
-#include "vm/types.h"
-
 #include "vm/jit/mips/codegen.h"
 #include "vm/jit/mips/md.h"
 
 #include "mm/memory.h"
 
-#include "native/native.h"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/patcher-common.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vm/resolve.h"
-#include "vmcore/references.h"
-
-
-#define PATCH_BACK_ORIGINAL_MCODE \
-       *((u4 *) pr->mpc) = (u4) pr->mcode; \
-       md_icacheflush((u1 *) pr->mpc, PATCHER_CALL_SIZE);
+#include "vm/jit/patcher-common.hpp"
 
 
 /* patcher_patch_code **********************************************************
@@ -64,7 +55,8 @@
 
 void patcher_patch_code(patchref_t *pr)
 {
-       PATCH_BACK_ORIGINAL_MCODE;
+       *((uint32_t*) pr->mpc) = (uint32_t) pr->mcode;
+       md_icacheflush((void*) pr->mpc, PATCHER_CALL_SIZE);
 }
 
 
@@ -80,36 +72,29 @@ void patcher_patch_code(patchref_t *pr)
 
 bool patcher_get_putstatic(patchref_t *pr)
 {
-       unresolved_field *uf;
-       u1               *datap;
-       fieldinfo        *fi;
-
-       /* get stuff from the stack */
+       unresolved_field* uf    = (unresolved_field *) pr->ref;
+       uintptr_t*        datap = (uintptr_t*)         pr->datap;
 
-       uf    = (unresolved_field *) pr->ref;
-       datap = (u1 *)               pr->datap;
+       // Resolve the field.
+       fieldinfo* fi = resolve_field_eager(uf);
 
-       /* get the fieldinfo */
-
-       if (!(fi = resolve_field_eager(uf)))
+       if (fi == NULL)
                return false;
 
-       /* check if the field's class is initialized */
-
+       // Check if the field's class is initialized.
        if (!(fi->clazz->state & CLASS_INITIALIZED))
                if (!initialize_class(fi->clazz))
                        return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch the field value's address */
-
-       *((intptr_t *) datap) = (intptr_t) fi->value;
-
-       /* synchronize data cache */
+       // Patch the field value's address.
+       *datap = (uintptr_t) fi->value;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -125,46 +110,41 @@ bool patcher_get_putstatic(patchref_t *pr)
 
 bool patcher_get_putfield(patchref_t *pr)
 {
-       u1               *ra;
-       unresolved_field *uf;
-       fieldinfo        *fi;
-
-       /* get stuff from the stack */
-
-       ra = (u1 *)               pr->mpc;
-       uf = (unresolved_field *) pr->ref;
+       uint32_t*         pc = (uint32_t*)         pr->mpc;
+       unresolved_field* uf = (unresolved_field*) pr->ref;
 
-       /* get the fieldinfo */
+       // Resolve the field.
+       fieldinfo* fi = resolve_field_eager(uf);
 
-       if (!(fi = resolve_field_eager(uf)))
+       if (fi == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
 #if SIZEOF_VOID_P == 4
        if (IS_LNG_TYPE(fi->type)) {
 # if WORDS_BIGENDIAN == 1
-               /* ATTENTION: order of these instructions depend on M_LLD_INTERN */
-               *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
-               *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
+               // ATTENTION: order of these instructions depend on M_LLD_INTERN.
+               // The first instruction is patched back later.
+               pr->mcode |= (int16_t) ((fi->offset + 0) & 0x0000ffff);
+               pc[1]     |= (int16_t) ((fi->offset + 4) & 0x0000ffff);
 # else
-               /* ATTENTION: order of these instructions depend on M_LLD_INTERN */
-               *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
-               *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
+               // ATTENTION: order of these instructions depend on M_LLD_INTERN.
+               // The first instruction is patched back later.
+               pr->mcode |= (int16_t) ((fi->offset + 4) & 0x0000ffff);
+               pc[1]     |= (int16_t) ((fi->offset + 0) & 0x0000ffff);
 # endif
        }
        else
 #endif
-               *((u4 *) (ra + 0 * 4)) |= (s2) (fi->offset & 0x0000ffff);
+       {
+               // The instruction is patched back later.
+               pr->mcode |= (int16_t) (fi->offset & 0x0000ffff);
+       }
 
-       /* synchronize instruction cache */
+       // Synchronize instruction cache.
+       md_icacheflush(pc, 2 * 4);
 
-       md_icacheflush(ra, 2 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -198,30 +178,24 @@ bool patcher_get_putfield(patchref_t *pr)
 
 bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
 {
-       constant_classref *cr;
-       u1                *datap;
-       classinfo         *c;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)         pr->datap;
 
-       /* get stuff from the stack */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
-
-       /* get the classinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch the classinfo pointer */
-
-       *((intptr_t *) datap) = (intptr_t) c;
-
-       /* synchronize data cache */
+       // Patch the class.
+       *datap = (uintptr_t) c;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -239,30 +213,24 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
 
 bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
 {
-       constant_classref *cr;
-       u1                *datap;
-       classinfo         *c;
-
-       /* get stuff from the stack */
-
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
+       constant_classref* cr    = (constant_classref *) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)          pr->datap;
 
-       /* get the fieldinfo */
+       // Resolve the field.
+       classinfo* c = resolve_classref_eager(cr);
 
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch super class' vftbl */
-
-       *((intptr_t *) datap) = (intptr_t) c->vftbl;
-
-       /* synchronize data cache */
+       // Patch super class' vftbl.
+       *datap = (uintptr_t) c->vftbl;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -281,30 +249,24 @@ bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
 
 bool patcher_resolve_classref_to_flags(patchref_t *pr)
 {
-       constant_classref *cr;
-       u1                *datap;
-       classinfo         *c;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       int32_t*           datap = (int32_t*)           pr->datap;
 
-       /* get stuff from the stack */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
-
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch class flags */
-
-       *((int32_t *) datap) = (int32_t) c->flags;
-
-       /* synchronize data cache */
+       // Patch class flags.
+       *datap = (int32_t) c->flags;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, sizeof(int32_t));
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -322,30 +284,24 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr)
 
 bool patcher_invokestatic_special(patchref_t *pr)
 {
-       unresolved_method *um;
-       u1                *datap;
-       methodinfo        *m;
-
-       /* get stuff from the stack */
+       unresolved_method* um    = (unresolved_method*) pr->ref;
+       void**             datap = (void*)              pr->datap;
 
-       um    = (unresolved_method *) pr->ref;
-       datap = (u1 *)                pr->datap;
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       /* get the fieldinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch stubroutine */
-
-       *((ptrint *) datap) = (ptrint) m->stubroutine;
-
-       /* synchronize data cache */
+       // Patch stubroutine.
+       *datap = (void*) m->stubroutine;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -364,36 +320,23 @@ bool patcher_invokestatic_special(patchref_t *pr)
 
 bool patcher_invokevirtual(patchref_t *pr)
 {
-       u1                *ra;
-       unresolved_method *um;
-       methodinfo        *m;
-
-       /* get stuff from the stack */
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       unresolved_method* um = (unresolved_method*) pr->ref;
 
-       ra = (u1 *)                pr->mpc;
-       um = (unresolved_method *) pr->ref;
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       /* get the fieldinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
-       /* patch vftbl index */
+       // Patch vftbl index.
+       pc[1] |= (int32_t) ((OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex) & 0x0000ffff);
 
-       *((s4 *) (ra + 1 * 4)) |=
-               (s4) ((OFFSET(vftbl_t, table[0]) +
-                          sizeof(methodptr) * m->vftblindex) & 0x0000ffff);
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 1, 1 * 4);
 
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra + 1 * 4, 1 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -414,41 +357,26 @@ bool patcher_invokevirtual(patchref_t *pr)
 
 bool patcher_invokeinterface(patchref_t *pr)
 {
-       u1                *ra;
-       unresolved_method *um;
-       methodinfo        *m;
-
-       /* get stuff from the stack */
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       unresolved_method* um = (unresolved_method*) pr->ref;
 
-       ra = (u1 *)                pr->mpc;
-       um = (unresolved_method *) pr->ref;
+       // Resovlve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       /* get the fieldinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
+       // Patch interfacetable index.
+       pc[1] |= (int32_t) ((OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr*) * m->clazz->index) & 0x0000ffff);
 
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
+       // Patch method offset.
+       pc[2] |= (int32_t) ((sizeof(methodptr) * (m - m->clazz->methods)) & 0x0000ffff);
 
-       /* patch interfacetable index */
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 1, 2 * 4);
 
-       *((s4 *) (ra + 1 * 4)) |=
-               (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
-                          sizeof(methodptr*) * m->clazz->index) & 0x0000ffff);
-
-       /* patch method offset */
-
-       *((s4 *) (ra + 2 * 4)) |=
-               (s4) ((sizeof(methodptr) * (m - m->clazz->methods)) & 0x0000ffff);
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra + 1 * 4, 2 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -470,39 +398,24 @@ bool patcher_invokeinterface(patchref_t *pr)
 
 bool patcher_checkcast_interface(patchref_t *pr)
 {
-       u1                *ra;
-       constant_classref *cr;
-       classinfo         *c;
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       constant_classref* cr = (constant_classref*) pr->ref;
 
-       /* get stuff from the stack */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       ra = (u1 *)                pr->mpc;
-       cr = (constant_classref *) pr->ref;
-
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
+       // Patch super class index.
+       pc[2] |= (int32_t) (-(c->index) & 0x0000ffff);
+       pc[6] |= (int32_t) ((OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*)) & 0x0000ffff);
 
-       /* patch super class index */
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 2, 5 * 4);
 
-       *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff);
-       /*      *((s4 *) (ra + 5 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) - */
-       /*                                                                       c->index * sizeof(methodptr*)) & 0x0000ffff); */
-       *((s4 *) (ra + 6 * 4)) |=
-               (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
-                          c->index * sizeof(methodptr*)) & 0x0000ffff);
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra + 2 * 4, 5 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -524,37 +437,24 @@ bool patcher_checkcast_interface(patchref_t *pr)
 
 bool patcher_instanceof_interface(patchref_t *pr)
 {
-       u1                *ra;
-       constant_classref *cr;
-       classinfo         *c;
-
-       /* get stuff from the stack */
-
-       ra = (u1 *)                pr->mpc;
-       cr = (constant_classref *) pr->ref;
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       constant_classref* cr = (constant_classref*) pr->ref;
 
-       /* get the fieldinfo */
+       // Resolve the method.
+       classinfo* c = resolve_classref_eager(cr);
 
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
-       /* patch super class index */
-
-       *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff);
-       *((s4 *) (ra + 5 * 4)) |=
-               (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
-                          c->index * sizeof(methodptr*)) & 0x0000ffff);
+       // Patch super class index.
+       pc[2] |= (int32_t) (-(c->index) & 0x0000ffff);
+       pc[5] |= (int32_t) ((OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*)) & 0x0000ffff);
 
-       /* synchronize instruction cache */
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 2, 4 * 4);
 
-       md_icacheflush(ra + 2 * 4, 4 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
index a28d2d1bcd6ef71f644f8e0020b63d177c461240..fa352116becda5c4287eda97f5986fdd76f89833 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/mips/uclinux/md-os.c - machine dependent MIPS uClinux functions
 
-   Copyright (C) 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) 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -32,7 +30,7 @@
 
 #include "vm/types.h"
 
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 
 /* md_init *********************************************************************
@@ -71,21 +69,6 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 }
 
 
-/* md_critical_section_restart *************************************************
-
-   Search the critical sections tree for a matching section and set
-   the PC to the restart point, if necessary.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
-{
-       vm_abort("md_critical_section_restart: IMPLEMENT ME!");
-}
-#endif
-
-
 /*
  * 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
diff --git a/src/vm/jit/oprofile-agent.cpp b/src/vm/jit/oprofile-agent.cpp
new file mode 100644 (file)
index 0000000..36e97a7
--- /dev/null
@@ -0,0 +1,108 @@
+/* src/vm/jit/oprofile-agent.cpp - oprofile agent implementation
+
+   Copyright (C) 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 "mm/memory.h"
+
+#include "vm/jit/code.hpp"
+#include "vm/jit/oprofile-agent.hpp"
+
+#include <string.h>
+
+/* static fields **************************************************************/
+op_agent_t OprofileAgent::_handle = 0;
+
+/**
+ * Initializes the OprofileAgent system.
+ *
+ */
+/* void OprofileAgent_initialize() */
+void OprofileAgent::initialize(void)
+{
+       _handle = op_open_agent();
+       if (!_handle)
+               vm_abort_errno("unable to open opagent handle:");
+}
+
+/**
+ * Reports the given method to oprofile.
+ *
+ * This has to be done once per JIT compilation step for a specific method.
+ *
+ * @param m Method to register.
+ */
+/* void OprofileAgent_newmethod(methodinfo *m) */
+void OprofileAgent::newmethod(methodinfo *m)
+{
+       unsigned int real_length = (unsigned int) m->code->mcodelength -
+               (unsigned int) (m->code->entrypoint - m->code->mcode);
+
+       char *buf;
+       s4    len;
+
+       len = utf_bytes(m->clazz->name) + strlen(".") +
+                utf_bytes(m->name) + utf_bytes(m->descriptor) + strlen("0");
+
+       buf = MNEW(char, len);
+
+       utf_copy_classname(buf, m->clazz->name);
+       strcat(buf, ".");
+       utf_cat(buf, m->name);
+       utf_cat(buf, m->descriptor);
+
+       if (_handle)
+               op_write_native_code(_handle, buf,
+                       (uint64_t) (ptrint) m->code->entrypoint,
+                       (const void *) m->code->entrypoint,
+                       real_length);
+
+       MFREE(buf, char, len);
+}
+
+/**
+ * Shuts down the OprofileAgent system.
+ *
+ */
+/* void OprofileAgent_close() */
+void OprofileAgent::close()
+{
+       if (_handle)
+               op_close_agent(_handle);
+
+       _handle = 0;
+}
+
+/*
+ * 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:
+ */
diff --git a/src/vm/jit/oprofile-agent.hpp b/src/vm/jit/oprofile-agent.hpp
new file mode 100644 (file)
index 0000000..59d4250
--- /dev/null
@@ -0,0 +1,65 @@
+/* src/vm/jit/oprofile-agent.hpp - oprofile agent implementation
+
+   Copyright (C) 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 _OPROFILE_AGENT_HPP
+#define _OPROFILE_AGENT_HPP
+
+#include "config.h"
+
+extern "C" {
+
+#include "vm/method.hpp"
+#include <opagent.h>
+
+}
+
+class OprofileAgent
+{
+       static op_agent_t _handle;
+
+public:
+       static void initialize();
+
+       static void newmethod(methodinfo *);
+
+       static void close();
+};
+
+#endif /* _OPROFILE_AGENT_HPP */
+
+
+/*
+ * 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 b7c937c13cec6cf9c5c3476d9433de7330937387..d725afc4dcab935461547a33580796c7f889250c 100644 (file)
@@ -1,9 +1,7 @@
 ## src/vm/jit/optimizing/Makefile.am
 ##
-## 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.
 ##
@@ -44,9 +42,9 @@ REORDER_SOURCES = \
 endif
 
 if ENABLE_THREADS
-RECOMPILE_SOURCES = \
-       recompile.c \
-       recompile.h
+RECOMPILER_SOURCES = \
+       recompiler.cpp \
+       recompiler.hpp
 endif
 
 if ENABLE_SSA
@@ -61,8 +59,8 @@ SSA_SOURCES = \
        ssa_rename.h \
        graph.c \
        graph.h \
-       dominators.c \
-       dominators.h \
+       dominators.cpp \
+       dominators.hpp \
        lifetimes.c \
        lifetimes.h \
        ssa2.c \
@@ -82,7 +80,7 @@ noinst_LTLIBRARIES = \
 liboptimizing_la_SOURCES = \
        $(IFCONV_SOURCES) \
        $(PROFILE_SOURCES) \
-       $(RECOMPILE_SOURCES) \
+       $(RECOMPILER_SOURCES) \
        $(REORDER_SOURCES) \
        $(SSA_SOURCES) \
        $(ESCAPE_SOURCES)
index 22fb1f2810f7ec0d9abbef087a5d153d69564849..2d7044bc65b3ef3acfb74f60638e876275658180 100644 (file)
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
+
 */
 
-#include "mm/dumpmemory.h"
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "mm/dumpmemory.hpp"
 #include "mm/memory.h"
 
 #include "toolbox/bitvector.h"
 
+#include "vm/class.hpp"
+#include "vm/descriptor.h"
 #include "vm/global.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
+
 #include "vm/jit/ir/bytecode.h"
 #include "vm/jit/optimizing/escape.h"
-#include "vm/resolve.h"
-
-#include "vmcore/class.h"
-#include "vmcore/descriptor.h"
-#include "vmcore/references.h"
 
 #include <assert.h>
 #include <stdarg.h>
@@ -118,15 +124,10 @@ typedef struct {
        op_stack_slot_t *ptr;
        op_stack_slot_t *bottom;
        unsigned max;
+       bool *perror_flag;
 } op_stack_t;
 
-#define stack_assert_position(stack, pos) \
-       do { \
-               assert((stack)->elements <= (pos)); \
-               assert((pos) < (stack)->end); \
-       } while (0)
-
-static void op_stack_init(op_stack_t *stack, unsigned max) {
+static void op_stack_init(op_stack_t *stack, unsigned max, bool *perror_flag) {
        op_stack_slot_t *it;
 
        stack->elements = DMNEW(op_stack_slot_t, max * 2);
@@ -140,6 +141,27 @@ static void op_stack_init(op_stack_t *stack, unsigned max) {
 
        stack->ptr = stack->start;
        stack->bottom = stack->start;
+
+       stack->perror_flag = perror_flag;
+}
+
+static void op_stack_set_error(op_stack_t *stack) {
+       *(stack->perror_flag) = true;
+#if BC_ESCAPE_VERBOSE
+       printf("%s: error.\n", __FUNCTION__);
+#endif
+}
+
+static bool op_stack_test_position(op_stack_t *stack, op_stack_slot_t *pos) {
+       if (!(stack->elements <= pos)) {
+               op_stack_set_error(stack);
+               return false;
+       } else if (!(pos < stack->end)) {
+               op_stack_set_error(stack);
+               return false;
+       } else {
+               return true;
+       }
 }
 
 static void op_stack_reset(op_stack_t *stack) {
@@ -160,7 +182,9 @@ static void op_stack_reset(op_stack_t *stack) {
 static op_stack_slot_t op_stack_pop(op_stack_t *stack) {
        op_stack_slot_t ret;
        stack->ptr -= 1;
-       stack_assert_position(stack, stack->ptr);
+       if (! op_stack_test_position(stack, stack->ptr)) {
+               return OP_STACK_SLOT_UNKNOWN;
+       }
        ret = *(stack->ptr);
        if (stack->ptr < stack->bottom) {
                stack->bottom = stack->ptr;
@@ -169,19 +193,24 @@ static op_stack_slot_t op_stack_pop(op_stack_t *stack) {
 }
 
 static void op_stack_push(op_stack_t *stack, op_stack_slot_t element) {
-       stack_assert_position(stack, stack->ptr);
-       *(stack->ptr) = element;
-       stack->ptr += 1;
+       if (op_stack_test_position(stack, stack->ptr)) {
+               *(stack->ptr) = element;
+               stack->ptr += 1;
+       }
 }
 
 static op_stack_slot_t op_stack_get(const op_stack_t *stack, int offset) {
-       stack_assert_position(stack, stack->ptr - offset);
-       return *(stack->ptr - offset);
+       if (op_stack_test_position(stack, stack->ptr - offset)) {
+               return *(stack->ptr - offset);
+       } else {
+               return OP_STACK_SLOT_UNKNOWN;
+       }
 }
 
 static void op_stack_set(op_stack_t *stack, int offset, op_stack_slot_t value) {
-       stack_assert_position(stack, stack->ptr - offset);
-       *(stack->ptr - offset) = value;
+       if (op_stack_test_position(stack, stack->ptr - offset)) {
+               *(stack->ptr - offset) = value;
+       }
 }
 
 static inline void op_stack_push_unknown(op_stack_t *stack) {
@@ -301,13 +330,22 @@ typedef struct {
        u1 *pos;
        u1 *instruction_start;
        s4 offset;
+       bool *perror_flag;
 } jcode_t;
 
-static void jcode_init(jcode_t *jc, u1 *start, s4 length, s4 offset) {
+static void jcode_init(jcode_t *jc, u1 *start, s4 length, s4 offset, bool *perror_flag) {
        jc->start = start;
        jc->end = jc->start + length;
        jc->pos = jc->start;
        jc->offset = offset;
+       jc->perror_flag = perror_flag;
+}
+
+static void jcode_set_error(jcode_t *jc) {
+       *(jc->perror_flag) = true;
+#if BC_ESCAPE_VERBOSE
+       printf("%s: error.\n", __FUNCTION__);
+#endif
 }
 
 static void jcode_move_to_index(jcode_t *jc, s4 index) {
@@ -347,38 +385,56 @@ static s4 jcode_get_index(const jcode_t *jc) {
        return jc->offset + (jc->pos - jc->start);
 }
 
-#define jcode_assert_has_bytes(jc, n) \
-       assert((jc->pos + n) <= jc->end)
+bool jcode_test_has_bytes(jcode_t *jc, s4 n) {
+       if ((jc->pos + n) <= jc->end) {
+               return true;
+       } else {
+               jcode_set_error(jc);
+               return false;
+       }
+}
 
 static u1 jcode_get_u1(jcode_t *jc) {
        u1 ret;
-       jcode_assert_has_bytes(jc, 1);
-       ret = jc->pos[0];
-       jc->pos += 1;
+       if (jcode_test_has_bytes(jc, 1)) {
+               ret = jc->pos[0];
+               jc->pos += 1;
+       } else {
+               ret = 0;
+       }
        return ret;
 }
 
 static s2 jcode_get_s2(jcode_t *jc) {
        s2 ret;
-       jcode_assert_has_bytes(jc, 2);
-       ret = (jc->pos[0] << 8) | (jc->pos[1]);
-       jc->pos += 2;
+       if (jcode_test_has_bytes(jc, 2)) {
+               ret = (jc->pos[0] << 8) | (jc->pos[1]);
+               jc->pos += 2;
+       } else {
+               ret = 0;
+       }
        return ret;
 }
 
 static u2 jcode_get_u2(jcode_t *jc) {
        u2 ret;
-       jcode_assert_has_bytes(jc, 2);
-       ret = (jc->pos[0] << 8) | (jc->pos[1]);
-       jc->pos += 2;
+       if (jcode_test_has_bytes(jc, 2)) {
+               ret = (jc->pos[0] << 8) | (jc->pos[1]);
+               jc->pos += 2;
+       } else {
+               ret = 0;
+       }
        return ret;
 }
 
 static s4 jcode_get_s4(jcode_t *jc) {
        s4 ret;
-       jcode_assert_has_bytes(jc, 4);
-       ret = (jc->pos[0] << 24) | (jc->pos[1] << 16) | (jc->pos[2] << 8) | (jc->pos[3]);
-       jc->pos += 4;
+       if (jcode_test_has_bytes(jc, 4)) {
+               ret = (jc->pos[0] << 24) | (jc->pos[1] << 16) | (jc->pos[2] << 8) | (jc->pos[3]);
+               jc->pos += 4;
+       } else {
+               ret = 0;
+       }
        return ret;
 }
 
@@ -394,7 +450,9 @@ static s4 jcode_get_branch_target_wide(jcode_t *jc) {
 
 static s4 jcode_get_fall_through_target(jcode_t *jc) {
        int length = bytecode[*jc->instruction_start].length;
-       assert(length > 0);
+       if (length <= 0) {
+               jcode_set_error(jc);
+       }
        return jc->offset + (jc->instruction_start - jc->start) + length;
 }
 
@@ -420,6 +478,8 @@ typedef struct {
        bool verbose;
 #endif
        int depth;
+
+       bool fatal_error;
 } bc_escape_analysis_t;
 
 static void bc_escape_analysis_perform_intern(methodinfo *m, int depth);
@@ -430,13 +490,13 @@ static void bc_escape_analysis_init(bc_escape_analysis_t *be, methodinfo *m, boo
        int a;
        u1 *ite;
        u1 t;
-       int ret_adr;
        unsigned n;
+       int ret_val_is_adr;
 
        be->method = m;
 
        be->stack = DNEW(op_stack_t);
-       op_stack_init(be->stack, m->maxstack);
+       op_stack_init(be->stack, m->maxstack, &(be->fatal_error));
 
        be->basicblocks = DNEW(basicblock_work_list_t);
        basicblock_work_list_init(be->basicblocks);
@@ -464,27 +524,28 @@ static void bc_escape_analysis_init(bc_escape_analysis_t *be, methodinfo *m, boo
 
        assert(l == be->local_to_adr_param_size);
 
-       /* Determine whether return type is address */
-
-       ret_adr = m->parseddesc->returntype.type == TYPE_ADR ? 1 : 0;
+       ret_val_is_adr = m->parseddesc->returntype.type == TYPE_ADR ? 1 : 0;
 
        /* Allocate param_escape on heap. */
 
        be->param_escape_size = a;
-       n = a + ret_adr;
+       n = a + ret_val_is_adr;
 
        if (n == 0) {
                /* Use some non-NULL value. */
                be->param_escape = (u1 *)1;
        } else {
                be->param_escape = MNEW(u1, n);
+               be->param_escape += ret_val_is_adr;
        }
 
        for (ite = be->param_escape; ite != be->param_escape + n; ++ite) {
-               *ite = (u1)ESCAPE_NONE;
+               *ite = escape_state_to_u1(ESCAPE_NONE);
        }
 
-       be->param_escape += ret_adr;
+       if (ret_val_is_adr) {
+               be->param_escape[-1] = escape_state_to_u1(ESCAPE_NONE);
+       }
 
        be->adr_param_dirty = DNEW(bit_vector_t);
        bit_vector_init(be->adr_param_dirty, a);
@@ -499,6 +560,8 @@ static void bc_escape_analysis_init(bc_escape_analysis_t *be, methodinfo *m, boo
 #endif
 
        be->depth = depth;
+
+       be->fatal_error = false;
 }
 
 static void bc_escape_analysis_branch_target(bc_escape_analysis_t *be, s4 branch_target) {
@@ -524,8 +587,8 @@ static void bc_escape_analysis_adjust_state(
                                   parameters. */
 
                                if (
-                                       old < ESCAPE_GLOBAL_THROUGH_METHOD && 
-                                       escape_state >= ESCAPE_GLOBAL_THROUGH_METHOD
+                                       old < ESCAPE_GLOBAL && 
+                                       escape_state >= ESCAPE_GLOBAL
                                ) {
                                        be->non_escaping_adr_params -= 1;
                                }
@@ -550,16 +613,17 @@ static void bc_escape_analysis_dirty_2(bc_escape_analysis_t *be, s4 local) {
        bc_escape_analysis_dirty(be, local + 1);
 }
 
-static void bc_escape_analyisis_returned(bc_escape_analysis_t *be, op_stack_slot_t value) {
+static void bc_escape_analysis_returned(bc_escape_analysis_t *be, op_stack_slot_t value) {
        if (op_stack_slot_is_param(value)) {
                /* A parameter is returned, mark it as being returned. */
                bit_vector_set(be->adr_param_returned, value.index);
-       } else if (op_stack_slot_is_unknown(value)) {
-               /* An untracked value is returned.
-                  Conservatively asume a globally escaping value is returned. */
+               /* The escape state of the return value will be adjusted later. */
+       } else {
+               /* Adjust escape state of return value. */
                if (be->method->parseddesc->returntype.type == TYPE_ADR) {
-                       be->param_escape[-1] = (u1)ESCAPE_GLOBAL;
+                       be->param_escape[-1] = escape_state_to_u1(ESCAPE_GLOBAL);
                }
+               bc_escape_analysis_adjust_state(be, value, ESCAPE_GLOBAL);
        }
 }
 
@@ -589,6 +653,25 @@ value_category_t bc_escape_analysis_value_category(bc_escape_analysis_t *be, s4
        }
 }
 
+static void bc_escape_analysis_push_return_value(
+       bc_escape_analysis_t *be,
+       methoddesc *md
+) {
+       switch (md->returntype.type) {
+               case TYPE_LNG:
+               case TYPE_DBL:
+                       op_stack_push_unknown(be->stack);
+                       op_stack_push_unknown(be->stack);
+                       break;
+               case TYPE_VOID:
+                       /* Do nothing */
+                       break;
+               default:
+                       op_stack_push_unknown(be->stack);
+                       break;
+       }
+}
+
 static void bc_escape_analysis_adjust_invoke_parameters(
        bc_escape_analysis_t *be,
        methodinfo *mi
@@ -597,6 +680,8 @@ static void bc_escape_analysis_adjust_invoke_parameters(
        methoddesc *md = mi->parseddesc;
        u1 *paramescape = mi->paramescape;
        s4 stack_depth = md->paramslots;
+       unsigned num_params_returned = 0;
+       op_stack_slot_t param_returned;
 
        /* Process parameters. 
         * The first parameter is at the highest depth on the stack.
@@ -605,10 +690,14 @@ static void bc_escape_analysis_adjust_invoke_parameters(
        for (i = 0; i < md->paramcount; ++i) {
                switch (md->paramtypes[i].type) {
                        case TYPE_ADR:
+                               if (*paramescape & 0x80) {
+                                       num_params_returned += 1;
+                                       param_returned = op_stack_get(be->stack, stack_depth);
+                               }
                                bc_escape_analysis_adjust_state(
                                        be,
                                        op_stack_get(be->stack, stack_depth),
-                                       (escape_state_t)*(paramescape++)
+                                       escape_state_from_u1(*paramescape++)
                                );
                                stack_depth -= 1;
                                break;
@@ -627,7 +716,20 @@ static void bc_escape_analysis_adjust_invoke_parameters(
        for (i = 0; i < md->paramslots; ++i) {
                op_stack_pop(be->stack);
        }
+       
+       /* Push return value. */
 
+       if (md->returntype.type == TYPE_ADR) {
+               if ((num_params_returned == 1) && (mi->paramescape[-1] < ESCAPE_GLOBAL)) {
+                       /* Only a single argument can be returned by the method,
+                          and the retun value does not escape otherwise. */
+                       op_stack_push(be->stack, param_returned);
+               } else {
+                       op_stack_push_unknown(be->stack);
+               }
+       } else {
+               bc_escape_analysis_push_return_value(be, md);
+       }
 }
 
 static void bc_escape_analysis_escape_invoke_parameters(
@@ -638,6 +740,8 @@ static void bc_escape_analysis_escape_invoke_parameters(
        for (i = 0; i < md->paramslots; ++i) {
                bc_escape_analysis_adjust_state(be, op_stack_pop(be->stack), ESCAPE_GLOBAL);
        }
+
+       bc_escape_analysis_push_return_value(be, md);
 }
 
 static void bc_escape_analysis_parse_invoke(bc_escape_analysis_t *be, jcode_t *jc) {
@@ -713,7 +817,7 @@ static void bc_escape_analysis_parse_invoke(bc_escape_analysis_t *be, jcode_t *j
           or recurse into callee. 
           Otherwise we must assume, that all parameters escape. */
 
-       if (mi != NULL) {
+       if (mi != NULL && escape_is_monomorphic(be->method, mi)) {
 
                if (mi->paramescape == NULL) {
                        bc_escape_analysis_perform_intern(mi, be->depth + 1);
@@ -730,20 +834,6 @@ static void bc_escape_analysis_parse_invoke(bc_escape_analysis_t *be, jcode_t *j
        } else {
                bc_escape_analysis_escape_invoke_parameters(be, md);
        }
-
-       switch (md->returntype.type) {
-               case TYPE_LNG:
-               case TYPE_DBL:
-                       op_stack_push_unknown(be->stack);
-                       op_stack_push_unknown(be->stack);
-                       break;
-               case TYPE_VOID:
-                       /* Do nothing */
-                       break;
-               default:
-                       op_stack_push_unknown(be->stack);
-                       break;
-       }
 }
 
 static void bc_escape_analysis_parse_tableswitch(
@@ -825,7 +915,7 @@ static void bc_escape_analysis_process_basicblock(bc_escape_analysis_t *be, jcod
        /* TODO end if all parameters escape */
        /* TODO move code into process_instruction or the like */
 
-       while ((! jcode_end(jc)) && (! bb_end)) {
+       while ((! jcode_end(jc)) && (! bb_end) && (! be->fatal_error)) {
 
                jcode_record_instruction_start(jc);
 
@@ -1390,7 +1480,7 @@ static void bc_escape_analysis_process_basicblock(bc_escape_analysis_t *be, jcod
 
                        case BC_areturn:
                                /* FIXME */
-                               bc_escape_analyisis_returned(be, op_stack_pop(be->stack));
+                               bc_escape_analysis_returned(be, op_stack_pop(be->stack));
                                bb_end = true;
                                break;
 
@@ -1593,7 +1683,7 @@ static void bc_escape_analysis_process_basicblock(bc_escape_analysis_t *be, jcod
        }
 #endif
 
-       while (! op_stack_is_empty(be->stack)) {
+       while ((! op_stack_is_empty(be->stack)) && (! be->fatal_error)) {
 #if BC_ESCAPE_VERBOSE
                if (be->verbose) {
                        dprintf(be->depth, "Stack element: ");
@@ -1609,10 +1699,19 @@ static void bc_escape_analysis_process_basicblock(bc_escape_analysis_t *be, jcod
                }
 #endif
        }
+
+       if (be->fatal_error) {
+#if BC_ESCAPE_VERBOSE
+               if (be->verbose) {
+                       printf("Fatal error while processing basic block. Aborting.\n");
+               }
+#endif
+               assert(0);
+       }
 }
 
 static void    bc_escape_analysis_adjust_return_value(bc_escape_analysis_t *be) {
-       escape_state_t e, pe;
+       escape_state_t re, pe;
        int i;
 
        /* Only calculate, if return value is of type address. */
@@ -1621,22 +1720,20 @@ static void     bc_escape_analysis_adjust_return_value(bc_escape_analysis_t *be) {
                return ;
        }
 
-       /* Get current escape state of return value. */
-
-       e = (escape_state_t)be->param_escape[-1];
-
        /* If a parameter can be returned, adjust to its escape state. */
 
        for (i = 0; i < be->param_escape_size; ++i) {
                if (bit_vector_get(be->adr_param_returned, i)) {
-                       pe = (escape_state_t)be->param_escape[i];
-                       if (pe > e) {
-                               e = pe;
+                       be->param_escape[i] |= 0x80;
+
+                       pe = escape_state_from_u1(be->param_escape[i]);
+                       re = escape_state_from_u1(be->param_escape[-1]);
+                       
+                       if (pe > re) {
+                               be->param_escape[-1] = escape_state_to_u1(pe);
                        }
                }
        }
-
-       be->param_escape[-1] = (u1)e;
 }
 
 static void bc_escape_analysis_analyze(bc_escape_analysis_t *be) {
@@ -1664,7 +1761,8 @@ static void bc_escape_analysis_analyze(bc_escape_analysis_t *be) {
                &jc,
                be->method->jcode,
                be->method->jcodelength,
-               0
+               0,
+               &(be->fatal_error)
        );
 
        /* Process basicblock by basicblock. */
@@ -1702,6 +1800,10 @@ static void bc_escape_analysis_perform_intern(methodinfo *m, int depth) {
        }
 #endif
 
+       if (depth >= 3) {
+               return;
+       }
+
        if (m->paramescape != NULL) {
 #if BC_ESCAPE_VERBOSE
                if (verbose) {  
@@ -1729,7 +1831,14 @@ static void bc_escape_analysis_perform_intern(methodinfo *m, int depth) {
                return;
        }
 
-       /* TODO threshold */
+       if (m->jcodelength > 250) {
+#if BC_ESCAPE_VERBOSE
+               if (verbose) {
+                       dprintf(depth, "Bytecode too long: %d.\n", m->jcodelength);
+               }
+#endif
+               return;
+       }
 
        be = DNEW(bc_escape_analysis_t);
        bc_escape_analysis_init(be, m, verbose, depth);
diff --git a/src/vm/jit/optimizing/dominators.c b/src/vm/jit/optimizing/dominators.c
deleted file mode 100644 (file)
index 3fcf46f..0000000
+++ /dev/null
@@ -1,654 +0,0 @@
-/* src/vm/jit/optimizing/dominators.c - dominators and dominance frontier
-
-   Copyright (C) 2005, 2006, 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., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
-
-*/
-
-
-#include "mm/memory.h"
-
-#include "toolbox/bitvector.h"
-
-#include "vm/jit/jit.h"
-
-#include "vm/jit/optimizing/graph.h"
-#include "vm/jit/optimizing/dominators.h"
-
-/* function prototypes */
-void dom_Dominators_init(dominatordata *dd, int basicblockcount);
-#ifdef DOM_DEBUG_CHECK
-int dom_AncestorWithLowestSemi(dominatordata *dd, int v, int basicblockcount);
-void dom_Link(dominatordata *dd, int p, int n, int basicblockcount);
-void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N,
-                        int basicblockcount);
-#else
-int dom_AncestorWithLowestSemi(dominatordata *dd, int v);
-void dom_Link(dominatordata *dd, int p, int n);
-void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N);
-#endif
-
-/*************************************
-Calculate Dominators
-*************************************/
-dominatordata *compute_Dominators(graphdata *gd, int basicblockcount) {
-       int i,j,n,N,p,s,s_,v,y;
-       graphiterator iter;
-       dominatordata *dd;
-
-       dd = DNEW(dominatordata);
-
-       dom_Dominators_init(dd, basicblockcount);
-       
-       N=0;
-
-       /* 1 ist the root node of the method                    */
-       /* 0 is the artificial parent, where locals are set to their parameters */
-       dom_DFS(gd, dd, -1, 0, &N
-#ifdef DOM_DEBUG_CHECK
-                       ,basicblockcount
-#endif
-                       );
-
-       for(i = N-1; i > 0; i--) {
-               _DOM_CHECK_BOUNDS(i, 0, basicblockcount);
-               n = dd->vertex[i];
-               _DOM_CHECK_BOUNDS(n, 0, basicblockcount);
-               p = dd->parent[n];
-               s = p;
-               j = graph_get_first_predecessor(gd, n, &iter);
-               for (; j != -1; j = graph_get_next(&iter)) {
-               _DOM_CHECK_BOUNDS(j, 0, basicblockcount);
-                       if (dd->dfnum[j] <= dd->dfnum[n])
-                               s_ = j;
-                       else
-                               s_ = dd->semi[dom_AncestorWithLowestSemi(dd, j
-#ifdef DOM_DEBUG_CHECK
-                                                                                                                ,basicblockcount
-#endif
-                                                                                                                )];
-               _DOM_CHECK_BOUNDS(s_, 0, basicblockcount);
-               _DOM_CHECK_BOUNDS(s, 0, basicblockcount);
-                       if (dd->dfnum[s_] < dd->dfnum[s])
-                               s = s_;
-               }
-               dd->semi[n] = s;
-               _DOM_CHECK_BOUNDS(dd->num_bucket[s], 0, basicblockcount);
-               dd->bucket[s][dd->num_bucket[s]] = n;
-               dd->num_bucket[s]++;
-               dom_Link(dd, p, n
-#ifdef DOM_DEBUG_CHECK
-                                , basicblockcount
-#endif
-                                );
-               _DOM_CHECK_BOUNDS(p, 0, basicblockcount);
-               for(j = 0; j < dd->num_bucket[p]; j++) {
-               _DOM_CHECK_BOUNDS(j, 0, basicblockcount);
-                       v = dd->bucket[p][j];
-                       y = dom_AncestorWithLowestSemi(dd, v
-#ifdef DOM_DEBUG_CHECK
-                                                                                  , basicblockcount
-#endif
-                                                                                  );
-               _DOM_CHECK_BOUNDS(y, 0, basicblockcount);
-               _DOM_CHECK_BOUNDS(v, 0, basicblockcount);
-           if (dd->semi[y] == dd->semi[v])
-                               dd->idom[v] = p;
-                       else
-                               dd->samedom[v] = y;
-               }
-               dd->num_bucket[p] = 0;
-       }
-       for(i = 1; i < N; i++) {
-               n = dd->vertex[i];
-               _DOM_CHECK_BOUNDS(n, 0, basicblockcount);
-           if (dd->samedom[n] != -1) {
-                       _DOM_CHECK_BOUNDS(dd->samedom[n], 0, basicblockcount);
-                       dd->idom[n] = dd->idom[dd->samedom[n]];
-               }
-       }
-       return dd;
-}
-
-/********************************************
-compute Dominace Frontier
-********************************************/
-void computeDF(graphdata *gd, dominatordata *dd, int basicblockcount, int n) {
-       int c,i,j;
-       bool *_S;
-       graphiterator iter;
-
-       _S = DMNEW(bool, basicblockcount);
-       for(i = 0; i < basicblockcount; i++)
-               _S[i] = false;
-       i = graph_get_first_successor(gd, n, &iter);
-       for (; i != -1; i = graph_get_next(&iter)) {
-               _DOM_CHECK_BOUNDS(i, 0, basicblockcount);
-               if (dd->idom[i] != n)
-                       _S[i] = true;
-       }
-       for(c=0; c < basicblockcount; c++) {
-               if (dd->idom[c] == n) {
-                       computeDF(gd, dd, basicblockcount, c);
-                       for(j=0; j < dd->num_DF[c]; j++) {
-               _DOM_CHECK_BOUNDS(dd->DF[c][j], 0, basicblockcount);
-                   if (n != dd->idom[dd->DF[c][j]])
-                                       /* n does not dominate DF[c][j] -> traverse idom list? */
-                                       _S[dd->DF[c][j]] = true;
-                       }
-               }
-       }
-       for(i = 0; i < basicblockcount; i++)
-               if (_S[i]) {
-               _DOM_CHECK_BOUNDS(dd->num_DF[n], 0, basicblockcount);
-                       dd->DF[n][dd->num_DF[n]] = i;
-                       dd->num_DF[n]++;
-               }
-}
-
-
-void dom_Dominators_init(dominatordata *dd, int basicblockcount) {
-       int i;
-
-       dd->dfnum  = DMNEW(int, basicblockcount);
-       dd->vertex = DMNEW(int, basicblockcount);
-       dd->parent = DMNEW(int, basicblockcount);
-       dd->semi   = DMNEW(int, basicblockcount);
-       dd->ancestor = DMNEW(int, basicblockcount);
-       dd->idom     = DMNEW(int, basicblockcount);
-       dd->samedom  = DMNEW(int, basicblockcount);
-       dd->bucket   = DMNEW(int*, basicblockcount);
-       dd->num_bucket = DMNEW(int, basicblockcount);
-       dd->DF       = DMNEW(int*, basicblockcount);
-       dd->num_DF   = DMNEW(int, basicblockcount);
-       dd->best     = DMNEW(int, basicblockcount);
-       for (i=0; i < basicblockcount; i++) {
-               dd->dfnum[i] = -1;
-               dd->semi[i] = dd->ancestor[i] = dd->idom[i] = dd->samedom[i] = -1;
-               dd->num_bucket[i] = 0;
-               dd->bucket[i] = DMNEW(int, basicblockcount);
-               dd->num_DF[i] = 0;
-               dd->DF[i] = DMNEW(int, basicblockcount);
-       }
-}
-
-/**************************************
-Create Depth First Spanning Tree
-**************************************/
-#ifdef DOM_DEBUG_CHECK
-void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N,
-                        int basicblockcount) {
-#else
-void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N) {
-#endif
-    int i;
-       graphiterator iter;
-
-       _DOM_CHECK_BOUNDS(n,0,basicblockcount);
-       if (dd->dfnum[n] == -1) { /* not visited till now? */
-               dd->dfnum[n] = *N;
-               _DOM_CHECK_BOUNDS(*N,0,basicblockcount);
-               dd->vertex[*N] = n;
-               dd->parent[n] = p;
-               (*N)++;
-               i = graph_get_first_successor(gd, n, &iter);
-               for (; i != -1; i = graph_get_next(&iter)) {
-                       dom_DFS(gd, dd, n, i, N
-#ifdef DOM_DEBUG_CHECK
-                                       , basicblockcount
-#endif
-                                       );
-               }
-       }
-}
-
-#ifdef DOM_DEBUG_CHECK
-int dom_AncestorWithLowestSemi(dominatordata *dd, int v, int basicblockcount) {
-#else
-int dom_AncestorWithLowestSemi(dominatordata *dd, int v) {
-#endif
-       int a,b;
-
-       _DOM_CHECK_BOUNDS(v, 0, basicblockcount);
-       a = dd->ancestor[v];
-       _DOM_CHECK_BOUNDS(a,0,basicblockcount);
-       if (dd->ancestor[a] != -1) {
-               b = dom_AncestorWithLowestSemi(dd, a
-#ifdef DOM_DEBUG_CHECK
-                                                                          , basicblockcount
-#endif
-                                                                          );
-               dd->ancestor[v] = dd->ancestor[a];
-               _DOM_CHECK_BOUNDS(b,0,basicblockcount);
-               _DOM_CHECK_BOUNDS(dd->best[v],0,basicblockcount);
-               _DOM_CHECK_BOUNDS(dd->semi[dd->best[v]],0,basicblockcount);
-               if (dd->dfnum[dd->semi[b]] < dd->dfnum[dd->semi[dd->best[v]]])
-                       dd->best[v] = b;
-       }
-       return dd->best[v];
-}
-
-#ifdef DOM_DEBUG_CHECK
-void dom_Link(dominatordata *dd, int p, int n, int basicblockcount) {
-#else
-void dom_Link(dominatordata *dd, int p, int n) {
-#endif
-       _DOM_CHECK_BOUNDS(n,0,basicblockcount);
-       dd->ancestor[n] = p;
-       dd->best[n] = n;
-}
-
-/*********************************************************/
-
-typedef struct basicblock_info basicblock_info;
-
-struct basicblock_info {
-       basicblock *bb;
-       int dfnum;
-       basicblock_info *parent;
-       basicblock_info *semi;
-       basicblock_info *ancestor;
-       basicblock_info *best;
-       basicblock_info *idom;
-       basicblock_info *samedom;
-       basicblock_info **bucket;
-       unsigned bucketcount;
-};
-
-typedef struct dominator_tree_info dominator_tree_info;
-
-struct dominator_tree_info {
-       jitdata *jd;
-       basicblock_info *basicblocks;
-       basicblock_info **df_map;
-       unsigned df_counter;
-};
-
-static dominator_tree_info *dominator_tree_init(jitdata *jd) {
-       dominator_tree_info *di;
-       basicblock *itb;
-       basicblock_info *iti;
-
-       di = DNEW(dominator_tree_info);
-
-       di->jd = jd;
-
-       di->basicblocks = DMNEW(basicblock_info, jd->basicblockcount);
-       MZERO(di->basicblocks, basicblock_info, jd->basicblockcount);
-       
-       for (iti = di->basicblocks; iti != di->basicblocks + jd->basicblockcount; ++iti) {
-               iti->dfnum = -1;
-               iti->bucket = DMNEW(basicblock_info *, jd->basicblockcount);
-               iti->bucketcount = 0;
-       }
-
-       for (itb = jd->basicblocks; itb; itb = itb->next) {
-               di->basicblocks[itb->nr].bb = itb;
-       }
-
-       di->df_map = DMNEW(basicblock_info *, jd->basicblockcount);
-       MZERO(di->df_map, basicblock_info *, jd->basicblockcount);
-
-       di->df_counter = 0;
-
-       return di;
-}
-
-inline basicblock_info *dominator_tree_get_basicblock(dominator_tree_info *di, basicblock *bb) {
-       return di->basicblocks + bb->nr;
-}
-
-static void dominator_tree_depth_first_search(
-       dominator_tree_info *di, basicblock_info *parent, basicblock_info *node
-) {
-       basicblock **it;
-
-       if (node->dfnum == -1) {
-
-               node->dfnum = di->df_counter;
-               node->parent = parent;
-               di->df_map[di->df_counter] = node;
-               di->df_counter += 1;
-
-               for (it = node->bb->successors; it != node->bb->successors + node->bb->successorcount; ++it) {
-                       dominator_tree_depth_first_search(
-                               di, node, 
-                               dominator_tree_get_basicblock(di, *it)
-                       );
-               }
-       }
-}
-
-void dominator_tree_link(dominator_tree_info *di, basicblock_info *parent, basicblock_info *node) {
-       node->ancestor = parent;
-       node->best = node;
-}
-
-basicblock_info *dominator_tree_ancestor_with_lowest_semi(
-       dominator_tree_info *di, basicblock_info *node
-) {
-       basicblock_info *a, *b;
-
-       a = node->ancestor;
-
-       if (a->ancestor != NULL) {
-               b = dominator_tree_ancestor_with_lowest_semi(di, a);
-               node->ancestor = a->ancestor;
-               if (b->semi->dfnum < node->best->semi->dfnum) {
-                       node->best = b;
-               }
-       }
-
-       return node->best;
-}
-
-void dominator_tree_build_intern(jitdata *jd) {
-       
-       dominator_tree_info *di;
-       basicblock_info *node;
-       basicblock_info *semicand;
-       basicblock_info *pred;
-       basicblock **itb;
-       basicblock_info **itii;
-       basicblock_info *v, *y;
-       int i;
-
-       di = dominator_tree_init(jd);
-
-       dominator_tree_depth_first_search(di, NULL, dominator_tree_get_basicblock(di, jd->basicblocks));
-
-       for (i = di->df_counter - 1; i >= 1; --i) {
-               node = di->df_map[i];
-
-               node->semi = node->parent;
-
-               for (
-                       itb = node->bb->predecessors; 
-                       itb != node->bb->predecessors + node->bb->predecessorcount; 
-                       ++itb
-               ) {
-
-                       pred = dominator_tree_get_basicblock(di, *itb);
-
-                       if (pred->dfnum <= node->dfnum) {
-                               semicand = pred;
-                       } else {
-                               semicand = dominator_tree_ancestor_with_lowest_semi(di, pred)->semi;
-                       }
-
-                       if (semicand->dfnum < node->semi->dfnum) {
-                               node->semi = semicand;
-                       }
-               }
-
-               node->semi->bucket[node->semi->bucketcount] = node;
-               node->semi->bucketcount += 1;
-
-               dominator_tree_link(di, node->parent, node);
-
-               for (itii = node->parent->bucket; itii != node->parent->bucket + node->parent->bucketcount; ++itii) {
-                       v = *itii;
-                       y = dominator_tree_ancestor_with_lowest_semi(di, v);
-                       if (y->semi == v->semi) {
-                               v->idom = node->parent;
-                       } else {
-                               v->samedom = y;
-                       }
-               }
-
-               node->parent->bucketcount = 0;
-       }
-
-       for (i = 1; i < di->df_counter; ++i) {
-               node = di->df_map[i];
-               if (node->samedom) {
-                       node->idom = node->samedom->idom;
-               }
-
-               node->bb->idom = node->idom->bb;
-               node->idom->bb->domsuccessorcount += 1;
-       }
-}
-
-void dominator_tree_link_children(jitdata *jd) {
-       basicblock *bb;
-       int32_t ds;
-       /* basicblock number => current number of successors */
-       unsigned *numsuccessors;
-
-       /* Allocate memory for successors */
-
-       for (bb = jd->basicblocks; bb; bb = bb->next) {
-               if (bb->domsuccessorcount > 0) {
-                       bb->domsuccessors = DMNEW(basicblock *, bb->domsuccessorcount);
-               }
-       }
-
-       /* Allocate memory for per basic block counter of successors */
-
-       ds = dumpmemory_marker();
-       numsuccessors = DMNEW(unsigned, jd->basicblockcount);
-       MZERO(numsuccessors, unsigned, jd->basicblockcount);
-
-       /* Link immediate dominators with successors */
-
-       for (bb = jd->basicblocks; bb; bb = bb->next) {
-               if (bb->idom) {
-                       bb->idom->domsuccessors[numsuccessors[bb->idom->nr]] = bb;
-                       numsuccessors[bb->idom->nr] += 1;
-               }
-       }
-
-       /* Free memory */
-
-       dumpmemory_release(ds);
-}
-
-bool dominator_tree_build(jitdata *jd) {
-       int32_t ds;
-       
-       ds = dumpmemory_marker();
-       dominator_tree_build_intern(jd);
-       dumpmemory_release(ds);
-
-       dominator_tree_link_children(jd);
-
-       return true;
-}
-
-typedef struct dominance_frontier_item dominance_frontier_item;
-
-struct dominance_frontier_item {
-       basicblock *bb;
-       dominance_frontier_item *next;
-};
-
-typedef struct dominance_frontier_list dominance_frontier_list;
-
-struct dominance_frontier_list {
-       dominance_frontier_item *first;
-       unsigned count;
-};
-
-void dominance_frontier_list_add(dominance_frontier_list *list, basicblock *bb) {
-       dominance_frontier_item *item;
-       
-       for (item = list->first; item; item = item->next) {
-               if (item->bb == bb) return;
-       }
-
-       item = DNEW(dominance_frontier_item);
-       item->bb = bb;
-       item->next = list->first;
-       list->first = item;
-       list->count += 1;
-}
-
-typedef struct dominance_frontier_info dominance_frontier_info;
-
-struct dominance_frontier_info {
-       jitdata *jd;
-       dominance_frontier_list *map;
-};
-
-dominance_frontier_info *dominance_frontier_init(jitdata *jd) {
-       dominance_frontier_info *dfi = DNEW(dominance_frontier_info);
-
-       dfi->jd = jd;
-
-       dfi->map = DMNEW(dominance_frontier_list, jd->basicblockcount);
-       MZERO(dfi->map, dominance_frontier_list, jd->basicblockcount);
-
-       return dfi;
-}
-
-bool dominance_frontier_dominates(basicblock *d, basicblock *x) {
-       x = x->idom;
-
-       while (x != NULL) {
-               if (x == d) {
-                       return true;
-               }
-               x = x->idom;
-       }
-
-       return false;
-}
-
-void dominance_frontier_for_block(dominance_frontier_info *dfi, basicblock *b) {
-       basicblock **it;
-       dominance_frontier_item *itdf;
-       dominance_frontier_list s = { NULL, 0 };
-
-       for (it = b->successors; it != b->successors + b->successorcount; ++it) {
-               if ((*it)->idom != b) {
-                       dominance_frontier_list_add(&s, *it);
-               }
-       }
-
-       for (it = b->domsuccessors; it != b->domsuccessors + b->domsuccessorcount; ++it) {
-               dominance_frontier_for_block(dfi, *it);
-               for (itdf = dfi->map[(*it)->nr].first; itdf; itdf = itdf->next) {
-                       if (! dominance_frontier_dominates(b, itdf->bb)) {
-                               dominance_frontier_list_add(&s, itdf->bb);
-                       }
-               }
-       }
-
-       dfi->map[b->nr] = s;
-}
-
-void dominance_frontier_store(dominance_frontier_info *dfi) {
-       basicblock *bb;
-       dominance_frontier_item *itdf;
-       basicblock **itout;
-
-       for (bb = dfi->jd->basicblocks; bb; bb = bb->next) {
-               if (bb->nr < dfi->jd->basicblockcount) {
-                       if (dfi->map[bb->nr].count > 0) {
-                               bb->domfrontiercount = dfi->map[bb->nr].count;
-                               itout = bb->domfrontier = DMNEW(basicblock *, bb->domfrontiercount);
-                               for (itdf = dfi->map[bb->nr].first; itdf; itdf = itdf->next) {
-                                       *itout = itdf->bb;
-                                       itout += 1;
-                               }
-                       }
-               }
-       }
-}
-
-bool dominance_frontier_build(jitdata *jd) {
-       int32_t ds = dumpmemory_marker();
-
-       dominance_frontier_info *dfi = dominance_frontier_init(jd);
-       dominance_frontier_for_block(dfi, jd->basicblocks);
-       dominance_frontier_store(dfi);
-}
-
-#include "vm/jit/show.h"
-#include "vm/jit/python.h"
-
-extern void graph_add_edge( graphdata *gd, int from, int to );
-
-void dominator_tree_validate(jitdata *jd, dominatordata *_dd) {
-       int32_t ds = dumpmemory_marker();
-       graphdata *gd;
-       int i, j;
-       basicblock *bptr, **it;
-       dominatordata *dd;
-       int *itnr;
-       bool found;
-
-       fprintf(stderr, "%s/%s: \n", jd->m->clazz->name->text, jd->m->name->text);
-       gd = graph_init(jd->basicblockcount);
-
-       for (bptr = jd->basicblocks; bptr; bptr = bptr->next) {
-               for (it = bptr->successors; it != bptr->successors + bptr->successorcount; ++it) {
-                       graph_add_edge(gd, bptr->nr, (*it)->nr);
-               }
-       }
-
-       dd = compute_Dominators(gd, jd->basicblockcount);
-
-       for (bptr = jd->basicblocks; bptr; bptr = bptr->next) {
-               if (bptr->flags >= BBREACHED) {
-                       if (bptr->idom == NULL) {
-                               if (!(dd->idom[bptr->nr] == -1)) {
-                                       printf("-- %d %d\n", dd->idom[bptr->nr], bptr->nr);
-                                       assert(0);
-                               }
-                       } else {
-                               assert(dd->idom[bptr->nr] == bptr->idom->nr);
-                       }
-               }
-       }
-
-       computeDF(gd, dd, jd->basicblockcount, 0);
-
-       for (bptr = jd->basicblocks; bptr; bptr = bptr->next) {
-               if (bptr->flags >= BBREACHED) {
-                       assert(bptr->domfrontiercount == dd->num_DF[bptr->nr]);
-                       for (itnr = dd->DF[bptr->nr]; itnr != dd->DF[bptr->nr] + dd->num_DF[bptr->nr]; ++itnr) {
-                               found = false;
-                               for (it = bptr->domfrontier; it != bptr->domfrontier + bptr->domfrontiercount; ++it) {
-                                       if ((*it)->nr == *itnr) {
-                                               found =true; break;
-                                       }
-                               }
-                               assert(found);
-                       }
-               }
-       }
-
-       dumpmemory_release(ds);
-}
-
-/*
- * 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:
- */
diff --git a/src/vm/jit/optimizing/dominators.cpp b/src/vm/jit/optimizing/dominators.cpp
new file mode 100644 (file)
index 0000000..9fe830b
--- /dev/null
@@ -0,0 +1,657 @@
+/* src/vm/jit/optimizing/dominators.cpp - dominators and dominance frontier
+
+   Copyright (C) 2005, 2006, 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., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.
+
+*/
+
+
+#include "config.h"
+
+#include "config.h"
+
+#include "mm/memory.h"
+
+#include "toolbox/bitvector.h"
+
+#include "vm/jit/jit.hpp"
+
+#include "vm/jit/optimizing/graph.h"
+#include "vm/jit/optimizing/dominators.hpp"
+
+
+/* function prototypes */
+void dom_Dominators_init(dominatordata *dd, int basicblockcount);
+#ifdef DOM_DEBUG_CHECK
+int dom_AncestorWithLowestSemi(dominatordata *dd, int v, int basicblockcount);
+void dom_Link(dominatordata *dd, int p, int n, int basicblockcount);
+void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N,
+                        int basicblockcount);
+#else
+int dom_AncestorWithLowestSemi(dominatordata *dd, int v);
+void dom_Link(dominatordata *dd, int p, int n);
+void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N);
+#endif
+
+/*************************************
+Calculate Dominators
+*************************************/
+dominatordata *compute_Dominators(graphdata *gd, int basicblockcount) {
+       int i,j,n,N,p,s,s_,v,y;
+       graphiterator iter;
+       dominatordata *dd;
+
+       dd = (dominatordata*) DumpMemory::allocate(sizeof(dominatordata));
+
+       dom_Dominators_init(dd, basicblockcount);
+       
+       N=0;
+
+       /* 1 ist the root node of the method                    */
+       /* 0 is the artificial parent, where locals are set to their parameters */
+       dom_DFS(gd, dd, -1, 0, &N
+#ifdef DOM_DEBUG_CHECK
+                       ,basicblockcount
+#endif
+                       );
+
+       for(i = N-1; i > 0; i--) {
+               _DOM_CHECK_BOUNDS(i, 0, basicblockcount);
+               n = dd->vertex[i];
+               _DOM_CHECK_BOUNDS(n, 0, basicblockcount);
+               p = dd->parent[n];
+               s = p;
+               j = graph_get_first_predecessor(gd, n, &iter);
+               for (; j != -1; j = graph_get_next(&iter)) {
+               _DOM_CHECK_BOUNDS(j, 0, basicblockcount);
+                       if (dd->dfnum[j] <= dd->dfnum[n])
+                               s_ = j;
+                       else
+                               s_ = dd->semi[dom_AncestorWithLowestSemi(dd, j
+#ifdef DOM_DEBUG_CHECK
+                                                                                                                ,basicblockcount
+#endif
+                                                                                                                )];
+               _DOM_CHECK_BOUNDS(s_, 0, basicblockcount);
+               _DOM_CHECK_BOUNDS(s, 0, basicblockcount);
+                       if (dd->dfnum[s_] < dd->dfnum[s])
+                               s = s_;
+               }
+               dd->semi[n] = s;
+               _DOM_CHECK_BOUNDS(dd->num_bucket[s], 0, basicblockcount);
+               dd->bucket[s][dd->num_bucket[s]] = n;
+               dd->num_bucket[s]++;
+               dom_Link(dd, p, n
+#ifdef DOM_DEBUG_CHECK
+                                , basicblockcount
+#endif
+                                );
+               _DOM_CHECK_BOUNDS(p, 0, basicblockcount);
+               for(j = 0; j < dd->num_bucket[p]; j++) {
+               _DOM_CHECK_BOUNDS(j, 0, basicblockcount);
+                       v = dd->bucket[p][j];
+                       y = dom_AncestorWithLowestSemi(dd, v
+#ifdef DOM_DEBUG_CHECK
+                                                                                  , basicblockcount
+#endif
+                                                                                  );
+               _DOM_CHECK_BOUNDS(y, 0, basicblockcount);
+               _DOM_CHECK_BOUNDS(v, 0, basicblockcount);
+           if (dd->semi[y] == dd->semi[v])
+                               dd->idom[v] = p;
+                       else
+                               dd->samedom[v] = y;
+               }
+               dd->num_bucket[p] = 0;
+       }
+       for(i = 1; i < N; i++) {
+               n = dd->vertex[i];
+               _DOM_CHECK_BOUNDS(n, 0, basicblockcount);
+           if (dd->samedom[n] != -1) {
+                       _DOM_CHECK_BOUNDS(dd->samedom[n], 0, basicblockcount);
+                       dd->idom[n] = dd->idom[dd->samedom[n]];
+               }
+       }
+       return dd;
+}
+
+/********************************************
+compute Dominace Frontier
+********************************************/
+void computeDF(graphdata *gd, dominatordata *dd, int basicblockcount, int n) {
+       int c,i,j;
+       bool *_S;
+       graphiterator iter;
+
+       _S = (bool*) DumpMemory::allocate(sizeof(bool) * basicblockcount);
+       for(i = 0; i < basicblockcount; i++)
+               _S[i] = false;
+       i = graph_get_first_successor(gd, n, &iter);
+       for (; i != -1; i = graph_get_next(&iter)) {
+               _DOM_CHECK_BOUNDS(i, 0, basicblockcount);
+               if (dd->idom[i] != n)
+                       _S[i] = true;
+       }
+       for(c=0; c < basicblockcount; c++) {
+               if (dd->idom[c] == n) {
+                       computeDF(gd, dd, basicblockcount, c);
+                       for(j=0; j < dd->num_DF[c]; j++) {
+               _DOM_CHECK_BOUNDS(dd->DF[c][j], 0, basicblockcount);
+                   if (n != dd->idom[dd->DF[c][j]])
+                                       /* n does not dominate DF[c][j] -> traverse idom list? */
+                                       _S[dd->DF[c][j]] = true;
+                       }
+               }
+       }
+       for(i = 0; i < basicblockcount; i++)
+               if (_S[i]) {
+               _DOM_CHECK_BOUNDS(dd->num_DF[n], 0, basicblockcount);
+                       dd->DF[n][dd->num_DF[n]] = i;
+                       dd->num_DF[n]++;
+               }
+}
+
+
+void dom_Dominators_init(dominatordata *dd, int basicblockcount) {
+       int i;
+
+       dd->dfnum      = (int*)  DumpMemory::allocate(sizeof(int) * basicblockcount);
+       dd->vertex     = (int*)  DumpMemory::allocate(sizeof(int) * basicblockcount);
+       dd->parent     = (int*)  DumpMemory::allocate(sizeof(int) * basicblockcount);
+       dd->semi       = (int*)  DumpMemory::allocate(sizeof(int) * basicblockcount);
+       dd->ancestor   = (int*)  DumpMemory::allocate(sizeof(int) * basicblockcount);
+       dd->idom       = (int*)  DumpMemory::allocate(sizeof(int) * basicblockcount);
+       dd->samedom    = (int*)  DumpMemory::allocate(sizeof(int) * basicblockcount);
+       dd->bucket     = (int**) DumpMemory::allocate(sizeof(int*) * basicblockcount);
+       dd->num_bucket = (int*)  DumpMemory::allocate(sizeof(int) * basicblockcount);
+       dd->DF         = (int**) DumpMemory::allocate(sizeof(int*) * basicblockcount);
+       dd->num_DF     = (int*)  DumpMemory::allocate(sizeof(int) * basicblockcount);
+       dd->best       = (int*)  DumpMemory::allocate(sizeof(int) * basicblockcount);
+       for (i=0; i < basicblockcount; i++) {
+               dd->dfnum[i] = -1;
+               dd->semi[i] = dd->ancestor[i] = dd->idom[i] = dd->samedom[i] = -1;
+               dd->num_bucket[i] = 0;
+               dd->bucket[i] = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount);
+               dd->num_DF[i] = 0;
+               dd->DF[i] = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount);
+       }
+}
+
+/**************************************
+Create Depth First Spanning Tree
+**************************************/
+#ifdef DOM_DEBUG_CHECK
+void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N,
+                        int basicblockcount) {
+#else
+void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N) {
+#endif
+    int i;
+       graphiterator iter;
+
+       _DOM_CHECK_BOUNDS(n,0,basicblockcount);
+       if (dd->dfnum[n] == -1) { /* not visited till now? */
+               dd->dfnum[n] = *N;
+               _DOM_CHECK_BOUNDS(*N,0,basicblockcount);
+               dd->vertex[*N] = n;
+               dd->parent[n] = p;
+               (*N)++;
+               i = graph_get_first_successor(gd, n, &iter);
+               for (; i != -1; i = graph_get_next(&iter)) {
+                       dom_DFS(gd, dd, n, i, N
+#ifdef DOM_DEBUG_CHECK
+                                       , basicblockcount
+#endif
+                                       );
+               }
+       }
+}
+
+#ifdef DOM_DEBUG_CHECK
+int dom_AncestorWithLowestSemi(dominatordata *dd, int v, int basicblockcount) {
+#else
+int dom_AncestorWithLowestSemi(dominatordata *dd, int v) {
+#endif
+       int a,b;
+
+       _DOM_CHECK_BOUNDS(v, 0, basicblockcount);
+       a = dd->ancestor[v];
+       _DOM_CHECK_BOUNDS(a,0,basicblockcount);
+       if (dd->ancestor[a] != -1) {
+               b = dom_AncestorWithLowestSemi(dd, a
+#ifdef DOM_DEBUG_CHECK
+                                                                          , basicblockcount
+#endif
+                                                                          );
+               dd->ancestor[v] = dd->ancestor[a];
+               _DOM_CHECK_BOUNDS(b,0,basicblockcount);
+               _DOM_CHECK_BOUNDS(dd->best[v],0,basicblockcount);
+               _DOM_CHECK_BOUNDS(dd->semi[dd->best[v]],0,basicblockcount);
+               if (dd->dfnum[dd->semi[b]] < dd->dfnum[dd->semi[dd->best[v]]])
+                       dd->best[v] = b;
+       }
+       return dd->best[v];
+}
+
+#ifdef DOM_DEBUG_CHECK
+void dom_Link(dominatordata *dd, int p, int n, int basicblockcount) {
+#else
+void dom_Link(dominatordata *dd, int p, int n) {
+#endif
+       _DOM_CHECK_BOUNDS(n,0,basicblockcount);
+       dd->ancestor[n] = p;
+       dd->best[n] = n;
+}
+
+/*********************************************************/
+
+typedef struct basicblock_info basicblock_info;
+
+struct basicblock_info {
+       basicblock *bb;
+       int dfnum;
+       basicblock_info *parent;
+       basicblock_info *semi;
+       basicblock_info *ancestor;
+       basicblock_info *best;
+       basicblock_info *idom;
+       basicblock_info *samedom;
+       basicblock_info **bucket;
+       unsigned bucketcount;
+};
+
+typedef struct dominator_tree_info dominator_tree_info;
+
+struct dominator_tree_info {
+       jitdata *jd;
+       basicblock_info *basicblocks;
+       basicblock_info **df_map;
+       unsigned df_counter;
+};
+
+static dominator_tree_info *dominator_tree_init(jitdata *jd) {
+       dominator_tree_info *di;
+       basicblock *itb;
+       basicblock_info *iti;
+
+       di = (dominator_tree_info*) DumpMemory::allocate(sizeof(dominator_tree_info));
+
+       di->jd = jd;
+
+       di->basicblocks = (basicblock_info*) DumpMemory::allocate(sizeof(basicblock_info) * jd->basicblockcount);
+       MZERO(di->basicblocks, basicblock_info, jd->basicblockcount);
+       
+       for (iti = di->basicblocks; iti != di->basicblocks + jd->basicblockcount; ++iti) {
+               iti->dfnum = -1;
+               iti->bucket = (basicblock_info**) DumpMemory::allocate(sizeof(basicblock_info*) * jd->basicblockcount);
+               iti->bucketcount = 0;
+       }
+
+       for (itb = jd->basicblocks; itb; itb = itb->next) {
+               di->basicblocks[itb->nr].bb = itb;
+       }
+
+       di->df_map = (basicblock_info**) DumpMemory::allocate(sizeof(basicblock_info*) * jd->basicblockcount);
+       MZERO(di->df_map, basicblock_info *, jd->basicblockcount);
+
+       di->df_counter = 0;
+
+       return di;
+}
+
+static inline basicblock_info *dominator_tree_get_basicblock(dominator_tree_info *di, basicblock *bb) {
+       return di->basicblocks + bb->nr;
+}
+
+static void dominator_tree_depth_first_search(
+       dominator_tree_info *di, basicblock_info *parent, basicblock_info *node
+) {
+       basicblock **it;
+
+       if (node->dfnum == -1) {
+
+               node->dfnum = di->df_counter;
+               node->parent = parent;
+               di->df_map[di->df_counter] = node;
+               di->df_counter += 1;
+
+               for (it = node->bb->successors; it != node->bb->successors + node->bb->successorcount; ++it) {
+                       dominator_tree_depth_first_search(
+                               di, node, 
+                               dominator_tree_get_basicblock(di, *it)
+                       );
+               }
+       }
+}
+
+void dominator_tree_link(dominator_tree_info *di, basicblock_info *parent, basicblock_info *node) {
+       node->ancestor = parent;
+       node->best = node;
+}
+
+basicblock_info *dominator_tree_ancestor_with_lowest_semi(
+       dominator_tree_info *di, basicblock_info *node
+) {
+       basicblock_info *a, *b;
+
+       a = node->ancestor;
+
+       if (a->ancestor != NULL) {
+               b = dominator_tree_ancestor_with_lowest_semi(di, a);
+               node->ancestor = a->ancestor;
+               if (b->semi->dfnum < node->best->semi->dfnum) {
+                       node->best = b;
+               }
+       }
+
+       return node->best;
+}
+
+void dominator_tree_build_intern(jitdata *jd) {
+       
+       dominator_tree_info *di;
+       basicblock_info *node;
+       basicblock_info *semicand;
+       basicblock_info *pred;
+       basicblock **itb;
+       basicblock_info **itii;
+       basicblock_info *v, *y;
+       int i;
+
+       di = dominator_tree_init(jd);
+
+       dominator_tree_depth_first_search(di, NULL, dominator_tree_get_basicblock(di, jd->basicblocks));
+
+       for (i = di->df_counter - 1; i >= 1; --i) {
+               node = di->df_map[i];
+
+               node->semi = node->parent;
+
+               for (
+                       itb = node->bb->predecessors; 
+                       itb != node->bb->predecessors + node->bb->predecessorcount; 
+                       ++itb
+               ) {
+
+                       pred = dominator_tree_get_basicblock(di, *itb);
+
+                       if (pred->dfnum <= node->dfnum) {
+                               semicand = pred;
+                       } else {
+                               semicand = dominator_tree_ancestor_with_lowest_semi(di, pred)->semi;
+                       }
+
+                       if (semicand->dfnum < node->semi->dfnum) {
+                               node->semi = semicand;
+                       }
+               }
+
+               node->semi->bucket[node->semi->bucketcount] = node;
+               node->semi->bucketcount += 1;
+
+               dominator_tree_link(di, node->parent, node);
+
+               for (itii = node->parent->bucket; itii != node->parent->bucket + node->parent->bucketcount; ++itii) {
+                       v = *itii;
+                       y = dominator_tree_ancestor_with_lowest_semi(di, v);
+                       if (y->semi == v->semi) {
+                               v->idom = node->parent;
+                       } else {
+                               v->samedom = y;
+                       }
+               }
+
+               node->parent->bucketcount = 0;
+       }
+
+       for (i = 1; i < di->df_counter; ++i) {
+               node = di->df_map[i];
+               if (node->samedom) {
+                       node->idom = node->samedom->idom;
+               }
+
+               node->bb->idom = node->idom->bb;
+               node->idom->bb->domsuccessorcount += 1;
+       }
+}
+
+void dominator_tree_link_children(jitdata *jd) {
+       basicblock *bb;
+       /* basicblock number => current number of successors */
+       unsigned *numsuccessors;
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       /* Allocate memory for successors */
+
+       for (bb = jd->basicblocks; bb; bb = bb->next) {
+               if (bb->domsuccessorcount > 0) {
+                       bb->domsuccessors = (basicblock**) DumpMemory::allocate(sizeof(basicblock*) * bb->domsuccessorcount);
+               }
+       }
+
+       /* Allocate memory for per basic block counter of successors */
+
+       numsuccessors = (unsigned*) DumpMemory::allocate(sizeof(unsigned) * jd->basicblockcount);
+       MZERO(numsuccessors, unsigned, jd->basicblockcount);
+
+       /* Link immediate dominators with successors */
+
+       for (bb = jd->basicblocks; bb; bb = bb->next) {
+               if (bb->idom) {
+                       bb->idom->domsuccessors[numsuccessors[bb->idom->nr]] = bb;
+                       numsuccessors[bb->idom->nr] += 1;
+               }
+       }
+}
+
+bool dominator_tree_build(jitdata *jd) {
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       dominator_tree_build_intern(jd);
+
+       dominator_tree_link_children(jd);
+
+       return true;
+}
+
+typedef struct dominance_frontier_item dominance_frontier_item;
+
+struct dominance_frontier_item {
+       basicblock *bb;
+       dominance_frontier_item *next;
+};
+
+typedef struct dominance_frontier_list dominance_frontier_list;
+
+struct dominance_frontier_list {
+       dominance_frontier_item *first;
+       unsigned count;
+};
+
+void dominance_frontier_list_add(dominance_frontier_list *list, basicblock *bb) {
+       dominance_frontier_item *item;
+       
+       for (item = list->first; item; item = item->next) {
+               if (item->bb == bb) return;
+       }
+
+       item = (dominance_frontier_item*) DumpMemory::allocate(sizeof(dominance_frontier_item));
+       item->bb = bb;
+       item->next = list->first;
+       list->first = item;
+       list->count += 1;
+}
+
+typedef struct dominance_frontier_info dominance_frontier_info;
+
+struct dominance_frontier_info {
+       jitdata *jd;
+       dominance_frontier_list *map;
+};
+
+dominance_frontier_info *dominance_frontier_init(jitdata *jd) {
+       dominance_frontier_info *dfi = (dominance_frontier_info*) DumpMemory::allocate(sizeof(dominance_frontier_info));
+
+       dfi->jd = jd;
+
+       dfi->map = (dominance_frontier_list*) DumpMemory::allocate(sizeof(dominance_frontier_list) * jd->basicblockcount);
+       MZERO(dfi->map, dominance_frontier_list, jd->basicblockcount);
+
+       return dfi;
+}
+
+bool dominance_frontier_dominates(basicblock *d, basicblock *x) {
+       x = x->idom;
+
+       while (x != NULL) {
+               if (x == d) {
+                       return true;
+               }
+               x = x->idom;
+       }
+
+       return false;
+}
+
+void dominance_frontier_for_block(dominance_frontier_info *dfi, basicblock *b) {
+       basicblock **it;
+       dominance_frontier_item *itdf;
+       dominance_frontier_list s = { NULL, 0 };
+
+       for (it = b->successors; it != b->successors + b->successorcount; ++it) {
+               if ((*it)->idom != b) {
+                       dominance_frontier_list_add(&s, *it);
+               }
+       }
+
+       for (it = b->domsuccessors; it != b->domsuccessors + b->domsuccessorcount; ++it) {
+               dominance_frontier_for_block(dfi, *it);
+               for (itdf = dfi->map[(*it)->nr].first; itdf; itdf = itdf->next) {
+                       if (! dominance_frontier_dominates(b, itdf->bb)) {
+                               dominance_frontier_list_add(&s, itdf->bb);
+                       }
+               }
+       }
+
+       dfi->map[b->nr] = s;
+}
+
+void dominance_frontier_store(dominance_frontier_info *dfi) {
+       basicblock *bb;
+       dominance_frontier_item *itdf;
+       basicblock **itout;
+
+       for (bb = dfi->jd->basicblocks; bb; bb = bb->next) {
+               if (bb->nr < dfi->jd->basicblockcount) {
+                       if (dfi->map[bb->nr].count > 0) {
+                               bb->domfrontiercount = dfi->map[bb->nr].count;
+                               itout = bb->domfrontier = (basicblock**) DumpMemory::allocate(sizeof(basicblock*) * bb->domfrontiercount);
+                               for (itdf = dfi->map[bb->nr].first; itdf; itdf = itdf->next) {
+                                       *itout = itdf->bb;
+                                       itout += 1;
+                               }
+                       }
+               }
+       }
+}
+
+bool dominance_frontier_build(jitdata *jd) {
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       dominance_frontier_info *dfi = dominance_frontier_init(jd);
+       dominance_frontier_for_block(dfi, jd->basicblocks);
+       dominance_frontier_store(dfi);
+}
+
+#include "vm/jit/show.hpp"
+#include "vm/jit/python.h"
+
+extern "C" void graph_add_edge( graphdata *gd, int from, int to );
+
+void dominator_tree_validate(jitdata *jd, dominatordata *_dd) {
+       graphdata *gd;
+       int i, j;
+       basicblock *bptr, **it;
+       dominatordata *dd;
+       int *itnr;
+       bool found;
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       fprintf(stderr, "%s/%s: \n", jd->m->clazz->name->text, jd->m->name->text);
+       gd = graph_init(jd->basicblockcount);
+
+       for (bptr = jd->basicblocks; bptr; bptr = bptr->next) {
+               for (it = bptr->successors; it != bptr->successors + bptr->successorcount; ++it) {
+                       graph_add_edge(gd, bptr->nr, (*it)->nr);
+               }
+       }
+
+       dd = compute_Dominators(gd, jd->basicblockcount);
+
+       for (bptr = jd->basicblocks; bptr; bptr = bptr->next) {
+               if (bptr->flags >= BBREACHED) {
+                       if (bptr->idom == NULL) {
+                               if (!(dd->idom[bptr->nr] == -1)) {
+                                       printf("-- %d %d\n", dd->idom[bptr->nr], bptr->nr);
+                                       assert(0);
+                               }
+                       } else {
+                               assert(dd->idom[bptr->nr] == bptr->idom->nr);
+                       }
+               }
+       }
+
+       computeDF(gd, dd, jd->basicblockcount, 0);
+
+       for (bptr = jd->basicblocks; bptr; bptr = bptr->next) {
+               if (bptr->flags >= BBREACHED) {
+                       assert(bptr->domfrontiercount == dd->num_DF[bptr->nr]);
+                       for (itnr = dd->DF[bptr->nr]; itnr != dd->DF[bptr->nr] + dd->num_DF[bptr->nr]; ++itnr) {
+                               found = false;
+                               for (it = bptr->domfrontier; it != bptr->domfrontier + bptr->domfrontiercount; ++it) {
+                                       if ((*it)->nr == *itnr) {
+                                               found =true; break;
+                                       }
+                               }
+                               assert(found);
+                       }
+               }
+       }
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/vm/jit/optimizing/dominators.h b/src/vm/jit/optimizing/dominators.h
deleted file mode 100644 (file)
index 376b78e..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* src/vm/jit/optimizing/dominators.h - Dominators and Dominance Frontier header
-
-   Copyright (C) 2005, 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
-
-   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., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
-
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Christian Ullrich
-
-
-*/
-
-
-#ifndef _DOMINATORS_H
-#define _DOMINATORS_H
-
-#include "vm/jit/optimizing/graph.h"
-
-#if !defined(NDEBUG)
-# include <assert.h>
-/* # define DOM_DEBUG_CHECK */
-# define DOM_DEBUG_VERBOSE
-#endif
-
-#ifdef DOM_DEBUG_CHECK
-# define _DOM_CHECK_BOUNDS(i,l,h) assert( ((i) >= (l)) && ((i) < (h)));
-# define _DOM_ASSERT(a) assert((a));
-#else
-# define _DOM_CHECK_BOUNDS(i,l,h)
-# define _DOM_ASSERT(a)
-#endif
-
-struct dominatordata {
-       int *dfnum;           /* [0..ls->basicblockcount[ */
-       int *vertex;          /* [0..ls->basicblockcount[ */
-       int *parent;          /* [0..ls->basicblockcount[ */
-       int *semi;            /* [0..ls->basicblockcount[ */
-       int *ancestor;        /* [0..ls->basicblockcount[ */
-       int *idom;            /* [0..ls->basicblockcount[ */
-       int *samedom;         /* [0..ls->basicblockcount[ */
-       int **bucket;         /* [0..ls->basicblockcount[[0..ls->bbc[ */
-       int *num_bucket;      /* [0..ls->basicblockcount[ */
-       int *best;            /* [0..ls->basicblockcount[ */
-       int **DF;             /* [0..ls->basicblockcount[[0..ls->bbc[ */
-       int *num_DF;          /* [0..ls->basicblockcount[ */
-};     
-
-typedef struct dominatordata dominatordata;
-
-/* function prototypes */
-dominatordata *compute_Dominators(graphdata *gd, int basicblockcount);
-void computeDF(graphdata *gd, dominatordata *dd, int basicblockcount, int n);
-
-/* ............................... */
-
-bool dominator_tree_build(jitdata *jd);
-
-bool dominance_frontier_build(jitdata *jd);
-
-void dominator_tree_validate(jitdata *jd, dominatordata *dd);
-
-#endif /* _DOMINATORS_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:
- */
diff --git a/src/vm/jit/optimizing/dominators.hpp b/src/vm/jit/optimizing/dominators.hpp
new file mode 100644 (file)
index 0000000..bd7df65
--- /dev/null
@@ -0,0 +1,99 @@
+/* src/vm/jit/optimizing/dominators.hpp - Dominators and Dominance Frontier header
+
+   Copyright (C) 2005, 2006, 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., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.
+
+*/
+
+
+#ifndef _DOMINATORS_HPP
+#define _DOMINATORS_HPP
+
+#include "config.h"
+
+#include "vm/jit/optimizing/graph.h"
+
+#if !defined(NDEBUG)
+# include <assert.h>
+/* # define DOM_DEBUG_CHECK */
+# define DOM_DEBUG_VERBOSE
+#endif
+
+#ifdef DOM_DEBUG_CHECK
+# define _DOM_CHECK_BOUNDS(i,l,h) assert( ((i) >= (l)) && ((i) < (h)));
+# define _DOM_ASSERT(a) assert((a));
+#else
+# define _DOM_CHECK_BOUNDS(i,l,h)
+# define _DOM_ASSERT(a)
+#endif
+
+struct dominatordata {
+       int *dfnum;           /* [0..ls->basicblockcount[ */
+       int *vertex;          /* [0..ls->basicblockcount[ */
+       int *parent;          /* [0..ls->basicblockcount[ */
+       int *semi;            /* [0..ls->basicblockcount[ */
+       int *ancestor;        /* [0..ls->basicblockcount[ */
+       int *idom;            /* [0..ls->basicblockcount[ */
+       int *samedom;         /* [0..ls->basicblockcount[ */
+       int **bucket;         /* [0..ls->basicblockcount[[0..ls->bbc[ */
+       int *num_bucket;      /* [0..ls->basicblockcount[ */
+       int *best;            /* [0..ls->basicblockcount[ */
+       int **DF;             /* [0..ls->basicblockcount[[0..ls->bbc[ */
+       int *num_DF;          /* [0..ls->basicblockcount[ */
+};     
+
+typedef struct dominatordata dominatordata;
+
+/* function prototypes */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+dominatordata *compute_Dominators(graphdata *gd, int basicblockcount);
+void computeDF(graphdata *gd, dominatordata *dd, int basicblockcount, int n);
+
+/* ............................... */
+
+bool dominator_tree_build(jitdata *jd);
+
+bool dominance_frontier_build(jitdata *jd);
+
+void dominator_tree_validate(jitdata *jd, dominatordata *dd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _DOMINATORS_HPP
+
+
+/*
+ * 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:
+ */
index b1c0679d584720036e7d81704fc7d160c5d62cfd..329ba02f066e6bd6f8b1971c0771483a9d3c950a 100644 (file)
@@ -1,4 +1,4 @@
-/* src/vm/optimizing/escape.c
+/* src/vm/jit/optimizing/escape.c
 
    Copyright (C) 2008
    CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
+
 */
 
-#include "vm/jit/jit.h"
-#include "vmcore/class.h"
+
+#include "config.h"
+
+#include "vm/class.hpp"
+#include "vm/classcache.hpp"
+
+#include "vm/jit/jit.hpp"
 #include "vm/jit/optimizing/escape.h"
 
+#include <stdarg.h>
+
+#if defined(ENABLE_ESCAPE_REASON)
+#define ENABLE_REASON
+#endif
+
+#if defined(ENABLE_REASON)
+#define I2(why, tov, es) escape_analysis_record_reason(e, why, iptr, tov, es);
+#else
+#define I2(why, tov, es)
+#endif
+#define I(why, to, from) I2(why, instruction_ ## to (iptr), escape_analysis_get_state(e, instruction_ ## from (iptr)))
+#define E2(why, var) I2(why, var, ESCAPE_GLOBAL)
+#define E(why, which) E2(why, instruction_ ## which (iptr))
+
+typedef enum {
+       RED = 31,
+       GREEN,
+       YELLOW,
+       BLUE,
+       MAGENTA,
+       CYAN,
+       WHITE,
+       COLOR_END
+} color_t;
+
+#define ENABLE_COLOR
+
+static void color_start(color_t color) {
+#if defined(ENABLE_COLOR)
+       if (RED <= color && color < COLOR_END) {
+               printf("\033[%dm", color);
+       }
+#endif
+}
+
+static void color_end() {
+#if defined(ENABLE_COLOR)
+       printf("\033[m");
+       fflush(stdout);
+#endif
+}
+
+static void color_printf(color_t color, const char *fmt, ...) {
+       va_list ap;
+       color_start(color);
+       va_start(ap, fmt);
+       vprintf(fmt, ap);
+       va_end(ap);
+       color_end();
+}
+
+
 /*** escape_state *************************************************************/
 
 const char *escape_state_to_string(escape_state_t escape_state) {
@@ -33,7 +92,7 @@ const char *escape_state_to_string(escape_state_t escape_state) {
                str(ESCAPE_UNKNOWN)
                str(ESCAPE_NONE)
                str(ESCAPE_METHOD)
-               str(ESCAPE_GLOBAL_THROUGH_METHOD)
+               str(ESCAPE_METHOD_RETURN)
                str(ESCAPE_GLOBAL)
                default: return "???";
        }
@@ -150,6 +209,8 @@ typedef struct {
 
        instruction_list_t *allocations;
        instruction_list_t *getfields;
+       instruction_list_t *monitors;
+       instruction_list_t *returns;
 
        struct var_extra **var;
 
@@ -274,12 +335,25 @@ void dependenCy_list_import(dependency_list_t *dl, dependency_list_t *other) {
 
 /*** var_extra ***************************************************************/
 
+#if defined(ENABLE_REASON)
+typedef struct reason {
+       const char *why;
+       instruction *iptr;
+       struct reason *next;
+} reason_t;
+#endif
+
 typedef struct var_extra {
        instruction *allocation;
        escape_state_t escape_state;
        s4 representant;
        dependency_list_t *dependency_list;
-       bool is_arg; /* TODO optimize */
+       unsigned contains_arg:1;
+       unsigned contains_only_args:1;
+       /*signed adr_arg_num:30;*/
+#if defined(ENABLE_REASON)
+       reason_t *reasons;
+#endif
 } var_extra_t;
 
 static void var_extra_init(var_extra_t *ve) {
@@ -287,7 +361,12 @@ static void var_extra_init(var_extra_t *ve) {
        ve->escape_state = ESCAPE_NONE;
        ve->representant = -1;
        ve->dependency_list = NULL;
-       ve->is_arg = false;
+       ve->contains_arg = false;
+       ve->contains_only_args = false;
+       /*ve->adr_arg_num = -1;*/
+#if defined(ENABLE_REASON)
+       ve->reasons = NULL;
+#endif
 }
 
 static inline var_extra_t *var_extra_get_no_alloc(const escape_analysis_t *e, s4 var) {
@@ -371,18 +450,41 @@ static void escape_analysis_init(escape_analysis_t *e, jitdata *jd) {
        e->getfields = DNEW(instruction_list_t);
        instruction_list_init(e->getfields);
 
+       e->monitors = DNEW(instruction_list_t);
+       instruction_list_init(e->monitors);
+
+       e->returns = DNEW(instruction_list_t);
+       instruction_list_init(e->returns);
+
        e->var = DMNEW(var_extra_t *, jd->vartop);
        MZERO(e->var, var_extra_t *, jd->vartop);
 
        e->adr_args_count = 0;
 
-       e->verbose = (
-               strcmp(e->jd->m->clazz->name->text, "gnu/java/util/regex/RESyntax") == 0 
-               && strcmp(e->jd->m->name->text, "<clinit>") == 0
-       );
        e->verbose = 1;
+       e->verbose = strcmp(jd->m->name->text, "<init>") == 0;
+       e->verbose = getenv("EV") != NULL;
 }
 
+#if defined(ENABLE_REASON)
+static void escape_analysis_record_reason(escape_analysis_t *e, const char *why, instruction *iptr, s4 var, escape_state_t es) {
+       var_extra_t *ve;
+       reason_t *re;
+       if (es == ESCAPE_GLOBAL || es == ESCAPE_METHOD_RETURN) {
+               var = var_extra_get_representant(e, var);
+               ve = var_extra_get(e, var);
+               re = NEW(reason_t);
+               re->why = why;
+               re->iptr= iptr;
+               re->next = ve->reasons;
+               ve->reasons = re;
+               if (e->verbose) {
+                       printf("%d escapes because %s\n", var, why);
+               }
+       }
+}
+#endif
+
 static void escape_analysis_set_allocation(escape_analysis_t *e, s4 var, instruction *iptr) {
        var_extra_get(e, var)->allocation = iptr;
 }
@@ -396,12 +498,38 @@ static instruction *escape_analysis_get_allocation(const escape_analysis_t *e, s
        return ve->allocation;
 }
 
-static void escape_analysis_set_is_argument(escape_analysis_t *e, s4 var) {
-       var_extra_get(e, var)->is_arg = true;
+static void escape_analysis_set_contains_argument(escape_analysis_t *e, s4 var) {
+       var = var_extra_get_representant(e, var);
+       var_extra_get(e, var)->contains_arg = true;
+}
+
+static bool escape_analysis_get_contains_argument(escape_analysis_t *e, s4 var) {
+       var = var_extra_get_representant(e, var);
+       return var_extra_get(e, var)->contains_arg;
+}
+
+static void escape_analysis_set_contains_only_arguments(escape_analysis_t *e, s4 var) {
+       var = var_extra_get_representant(e, var);
+       var_extra_get(e, var)->contains_only_args = true;
+}
+
+static bool escape_analysis_get_contains_only_arguments(escape_analysis_t *e, s4 var) {
+       var = var_extra_get_representant(e, var);
+       return var_extra_get(e, var)->contains_only_args;
+}
+
+/*
+static void escape_analysis_set_adr_arg_num(escape_analysis_t *e, s4 var, s4 num) {
+       var_extra_get(e, var)->adr_arg_num = num;
+}
+
+static s4 escape_analysis_get_adr_arg_num(escape_analysis_t *e, s4 var) {
+       return var_extra_get(e, var)->adr_arg_num;
 }
+*/
 
-static bool escape_analysis_get_is_argument(escape_analysis_t *e, s4 var) {
-       return var_extra_get(e, var)->is_arg;
+static bool escape_analysis_in_same_set(escape_analysis_t *e, s4 var1, s4 var2) {
+       return var_extra_get_representant(e, var1) == var_extra_get_representant(e, var2);
 }
 
 static void escape_analysis_ensure_state(escape_analysis_t *e, s4 var, escape_state_t escape_state) {
@@ -432,6 +560,10 @@ static void escape_analysis_ensure_state(escape_analysis_t *e, s4 var, escape_st
                                        dependency_list_item_get_dependency(it),
                                        escape_state
                                );
+                               {
+                               instruction *iptr = NULL;
+                               I2("propagated by dependency", dependency_list_item_get_dependency(it), escape_state);
+                               }
                        }
                }
        }
@@ -441,12 +573,6 @@ static escape_state_t escape_analysis_get_state(escape_analysis_t *e, s4 var) {
        return var_extra_get_escape_state(e, var);
 }
 
-#define escape_analysis_assert_has_escape(e, var) \
-       assert( \
-               var_extra_get_no_alloc(e, var) && \
-               (var_extra_get_no_alloc(e, var)->escape_state > ESCAPE_UNKNOWN) \
-       )
-
 static classinfo *escape_analysis_classinfo_in_var(escape_analysis_t *e, s4 var) {
        instruction *iptr = escape_analysis_get_allocation(e, var);
 
@@ -484,6 +610,8 @@ static void escape_analysis_merge(escape_analysis_t *e, s4 var1, s4 var2) {
                return;
        }
 
+       if (e->verbose) printf("Merging (%d,%d)\n", var1, var2);
+
        ve1 = var_extra_get(e, var1);
        ve2 = var_extra_get(e, var2);
 
@@ -496,10 +624,10 @@ static void escape_analysis_merge(escape_analysis_t *e, s4 var1, s4 var2) {
 
        ve2->representant = var1;
 
-       /* Adjust is_argument to logical or. */
+       /* Adjust is_arg to logical or. */
        
-       has_become_arg = ve1->is_arg != ve2->is_arg;
-       ve1->is_arg = ve1->is_arg || ve2->is_arg;
+       has_become_arg = ve1->contains_arg != ve2->contains_arg;
+       ve1->contains_arg = ve1->contains_arg || ve2->contains_arg;
 
        if (e->verbose && has_become_arg) printf("(%d,%d) has become arg.\n", var1, var2);
 
@@ -521,8 +649,35 @@ static void escape_analysis_merge(escape_analysis_t *e, s4 var1, s4 var2) {
                                dependency_list_item_get_dependency(itd),
                                ESCAPE_GLOBAL
                        );
+                       {
+                       instruction *iptr = NULL;
+                       E2("has become arg", dependency_list_item_get_dependency(itd));
+                       }
+               }
+       }
+
+       /* Adjust contains_only_args to logical and. */
+
+       ve1->contains_only_args = ve1->contains_only_args && ve2->contains_only_args;
+
+       /* Adjust address argument number contained in this var. */
+
+       /*
+       if (ve1->adr_arg_num != ve2->adr_arg_num) {
+               ve1->adr_arg_num = -1;
+       }
+       */
+#if defined(ENABLE_REASON)
+       if (ve1->reasons) {
+               reason_t *re = ve1->reasons;
+               while (re->next != NULL) {
+                       re = re->next;
                }
+               re->next = ve2->reasons;
+       } else {
+               ve1->reasons = ve2->reasons;
        }
+#endif
 }
 
 static void escape_analysis_add_dependency(escape_analysis_t *e, instruction *store) {
@@ -534,7 +689,9 @@ static void escape_analysis_add_dependency(escape_analysis_t *e, instruction *st
        dependency_list_add(dl, store);
 
        if (e->verbose) {
-               printf("dependency_list_add\n");
+               printf("dependency_list_add: %d.dependency_list.add( { ", obj);
+               show_icmd(e->jd, store, 0, 3);
+               printf(" } )\n"); 
        }
 }
 
@@ -545,12 +702,16 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio
        u1 *paramescape;
        unsigned i;
        instruction **iarg;
-       constant_FMIref *fmi;
        methodinfo *mi;
-       resolve_result_t result;
+       escape_state_t es;
+       const char *why;
 
        if (e->verbose) {
-               printf("processing %s@%d\n", icmd_table[iptr->opc].name, iptr->line);
+               color_start(CYAN);
+               printf("%d: ", iptr->line);
+               show_icmd(e->jd, iptr, 0, 3);
+               color_end();
+               printf("\n");
        }
 
        switch (instruction_get_opcode(iptr)) {
@@ -568,46 +729,51 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio
 
                        if (c == NULL) {
                                escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL);
-                               if (e->verbose) printf("1\n");
+                               E("unresolved class", dst)
                        } else if (c->finalizer != NULL) {
                                escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL);
-                               if (e->verbose) printf("3\n");
+                               E("finalizer", dst)
                        } else {
                                escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_NONE);
-                               if (e->verbose) printf("2\n");
                        }
 
                        instruction_list_add(e->allocations, iptr);
 
                        break;
 
+               case ICMD_MONITORENTER:
+               case ICMD_MONITOREXIT:
+               
+                       instruction_list_add(e->monitors, iptr);
+
+                       break;
+
                case ICMD_NEWARRAY:
                case ICMD_ANEWARRAY:
                        
                        escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL);
                        escape_analysis_set_allocation(e, instruction_dst(iptr), iptr);
                        instruction_list_add(e->allocations, iptr);
-
+                       E("untracked array", dst)
                        break;
 
                case ICMD_PUTSTATIC:
                        if (instruction_field_type(iptr) == TYPE_ADR) {
-                               /*
-                               escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                               */
                                escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_GLOBAL);
+                               E("putstatic", s1)
                        }
                        break;
 
                case ICMD_PUTFIELD:
                        if (instruction_field_type(iptr) == TYPE_ADR) {
-                               /*
-                               escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                               escape_analysis_assert_has_escape(e, instruction_s2(iptr));
-                               */
-                               if (escape_analysis_get_is_argument(e, instruction_s1(iptr))) {
+                               if (escape_analysis_get_contains_argument(e, instruction_s1(iptr))) {
                                        escape_analysis_ensure_state(e, instruction_s2(iptr), ESCAPE_GLOBAL);
+                                       /* If s1 is currently not an argument, but can contain one later because
+                                          of a phi function, the merge function takes care to make all
+                                          dependencies escape globally. */
+                                       E("putfield into argument", s2)
                                } else {
+                                       I("putfield inherit", s2, s1);
                                        escape_analysis_ensure_state(e, instruction_s2(iptr), escape_analysis_get_state(e, instruction_s1(iptr)));
                                        escape_analysis_add_dependency(e, iptr);
                                }
@@ -615,13 +781,13 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio
                        break;
 
                case ICMD_AASTORE:
-                       /*
-                       escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                       escape_analysis_assert_has_escape(e, instruction_s3(iptr));
-                       */
-                       if (escape_analysis_get_is_argument(e, instruction_s1(iptr))) {
+                       if (escape_analysis_get_contains_argument(e, instruction_s1(iptr))) {
+                               if (e->verbose) printf("Contains argument.\n");
                                escape_analysis_ensure_state(e, instruction_s3(iptr), ESCAPE_GLOBAL);
+                               E("aastore into argument", s3)
                        } else {
+                               if (e->verbose) printf("Contains no argument.\n");
+                               I("aastore", s3, s1)
                                escape_analysis_ensure_state(e, instruction_s3(iptr), escape_analysis_get_state(e, instruction_s1(iptr)));
                                escape_analysis_add_dependency(e, iptr);
                        }
@@ -630,22 +796,21 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio
                case ICMD_GETSTATIC:
                        if (instruction_field_type(iptr) == TYPE_ADR) {
                                escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL);
+                               E("loaded from static var", dst)
                                escape_analysis_set_allocation(e, instruction_dst(iptr), iptr);
                        }
                        break;
 
                case ICMD_GETFIELD:
                        if (instruction_field_type(iptr) == TYPE_ADR) {
-                               /*
-                               escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                               */
 
-                               if (escape_analysis_get_is_argument(e, instruction_s1(iptr))) {
+                               if (escape_analysis_get_contains_argument(e, instruction_s1(iptr))) {
                                        /* Fields loaded from arguments escape globally.
                                           x = arg.foo;
                                           x.bar = y;
                                           => y escapes globally. */
                                        escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL);
+                                       E("loaded from arg", dst)
                                } else {
                                        escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_NONE);
                                }
@@ -657,19 +822,15 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio
                        break;
 
                case ICMD_ARRAYLENGTH:
-                       /*
-                       escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                       */
+                       escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD);
                        break;
 
                case ICMD_AALOAD:
-                       /*
-                       escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                       */
 
-                       if (escape_analysis_get_is_argument(e, instruction_s1(iptr))) {
+                       if (escape_analysis_get_contains_argument(e, instruction_s1(iptr))) {
                                /* If store into argument, escapes globally. See ICMD_GETFIELD. */
                                escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL);
+                               E("aaload from argument", dst)
                        } else {
                                escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_NONE);
                        }
@@ -681,36 +842,27 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio
 
                case ICMD_IF_ACMPEQ:
                case ICMD_IF_ACMPNE:
-                       /*
-                       escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                       escape_analysis_assert_has_escape(e, instruction_s2(iptr));
-                       */
                        escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD);
                        escape_analysis_ensure_state(e, instruction_s2(iptr), ESCAPE_METHOD);
                        break;
 
                case ICMD_IFNULL:
                case ICMD_IFNONNULL:
+                       escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD);
+                       break;
+
                case ICMD_CHECKNULL:
-                       /*
-                       escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                       */
                        escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD);
+                       escape_analysis_merge(e, instruction_s1(iptr), instruction_dst(iptr));
                        break;
 
                case ICMD_CHECKCAST:
-                       /*
-                       escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                       */
                        escape_analysis_merge(e, instruction_s1(iptr), instruction_dst(iptr));
                        escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD);
                        escape_analysis_set_allocation(e, instruction_dst(iptr), iptr);
                        break;
 
                case ICMD_INSTANCEOF:
-                       /*
-                       escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                       */
                        escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD);
                        break;
 
@@ -721,15 +873,25 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio
                        count = instruction_arg_count(iptr);
                        mi = instruction_local_methodinfo(iptr);
                        paramescape = NULL;
+                       why = "???";
 
                        if (mi != NULL) {
                                /* If the method could be resolved, it already is. */
                                paramescape = mi->paramescape;
 
+                               if (e->verbose) {
+                                       if (paramescape) {
+                                               printf("Paramescape for callee available.\n");
+                                       }
+                               }
+
+                               if (paramescape) why = "Available param escape";
+
                                if (paramescape == NULL) {
                                        if (e->verbose) {
                                                printf("BC escape analyzing callee.\n");
                                        }
+                                       why = "BC param escape";
                                        bc_escape_analysis_perform(mi);
                                        paramescape = mi->paramescape;
                                }
@@ -737,26 +899,66 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio
                                if (e->verbose) {
                                        printf("Unresolved callee.\n");
                                }
+                               why = "Unresolved callee";
+                       }
+
+                       if (iptr->opc == ICMD_INVOKEVIRTUAL || iptr->opc == ICMD_INVOKEINTERFACE) {
+                               if (mi != NULL && !escape_is_monomorphic(e->jd->m, mi)) {
+                                       if (e->verbose) {
+                                               printf("Not monomorphic.\n");
+                                       }
+                                       why = "Polymorphic";
+                                       paramescape = NULL;
+                               }
                        }
 
+                       /* Set the escape state of the return value.
+                          This is: global if we down have information of the callee, or the callee
+                          supplied escape state. */
+
+                       if (instruction_return_type(iptr) == TYPE_ADR) {
+                               if (paramescape == NULL) {
+                                       escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL);
+                                       E(why, dst);
+                               } else {
+                                       es = escape_state_from_u1(paramescape[-1]);
+                                       I2(why, instruction_dst(iptr), es)
+                                       escape_analysis_ensure_state(e, instruction_dst(iptr), es);
+                               }
+                               escape_analysis_set_allocation(e, instruction_dst(iptr), iptr);
+                       }
+                       
                        for (i = 0; i < count; ++i) {
                                if (instruction_arg_type(iptr, i) == TYPE_ADR) {
 
-                                       /*
-                                       escape_analysis_assert_has_escape(e, instruction_arg(iptr, i));
-                                       */
                                        if (paramescape == NULL) {
                                                escape_analysis_ensure_state(
                                                        e, 
                                                        instruction_arg(iptr, i), 
-                                                       instruction_local_methodinfo(iptr) && instruction_local_methodinfo(iptr)->jcode ?
-                                                               ESCAPE_GLOBAL_THROUGH_METHOD :
-                                                               ESCAPE_GLOBAL
+                                                       ESCAPE_GLOBAL
                                                );
-                                       } else if ((escape_state_t)*paramescape < ESCAPE_METHOD) {
-                                               escape_analysis_ensure_state(e, instruction_arg(iptr, i), ESCAPE_METHOD);
+                                               E2(why, instruction_arg(iptr, i));
+                                       } else if (escape_state_from_u1(*paramescape) <= ESCAPE_METHOD) {
+                                               es = escape_state_from_u1(*paramescape);
+
+                                               if (es < ESCAPE_METHOD) {
+                                                       es = ESCAPE_METHOD;
+                                               }
+
+                                               I2(why, instruction_arg(iptr, i), es);
+                                               escape_analysis_ensure_state(e, instruction_arg(iptr, i), es);
+
+                                               if (*paramescape & 0x80) {
+                                                       /* Parameter can be returned from method.
+                                                          This creates an alias to the retur value.
+                                                          If the return value escapes, the ES of the parameter needs 
+                                                          to be adjusted. */
+                                                       escape_analysis_merge(e, instruction_arg(iptr, i), instruction_dst(iptr));
+                                                       I2("return alias", instruction_arg(iptr, i), instruction_dst(iptr));
+                                               }
                                        } else {
-                                               escape_analysis_ensure_state(e, instruction_arg(iptr, i), (escape_state_t)*paramescape);
+                                               escape_analysis_ensure_state(e, instruction_arg(iptr, i), ESCAPE_GLOBAL);
+                                               E2(why, instruction_arg(iptr, i));
                                        }
 
                                        if (paramescape != NULL) {
@@ -765,25 +967,20 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio
                                }
                        }
 
-                       if (instruction_return_type(iptr) == TYPE_ADR) {
-                               escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_NONE);
-                               escape_analysis_set_allocation(e, instruction_dst(iptr), iptr);
-                       }
-
                        break;
 
                case ICMD_ATHROW:
-                       /*
-                       escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                       */
                        escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_GLOBAL);
+                       E("throw", s1)
                        break;
 
                case ICMD_ARETURN:
-                       /*
-                       escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                       */
-                       escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_GLOBAL);
+                       /* If we return only arguments, the return value escapes only the method.
+                          ESCAPE_METHOD for now, and check later, if a different value than an
+                          argument is possibly returned. */
+                       escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD_RETURN);
+                       E("return", s1)
+                       instruction_list_add(e->returns, iptr);
                        break;
 
                case ICMD_ALOAD:
@@ -791,9 +988,6 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio
                case ICMD_MOVE:
                case ICMD_COPY:
                        if (instruction_dst_type(iptr, jd) == TYPE_ADR) {
-                               /*
-                               escape_analysis_assert_has_escape(e, instruction_s1(iptr));
-                               */
                                escape_analysis_merge(e, instruction_s1(iptr), instruction_dst(iptr));
                                escape_analysis_set_allocation(e, instruction_dst(iptr), iptr);
                        }
@@ -821,6 +1015,10 @@ static void escape_analysis_process_instructions(escape_analysis_t *e) {
 
        FOR_EACH_BASICBLOCK(e->jd, bptr) {
 
+               if (e->verbose) {
+                       color_printf(CYAN, "=== BB %d ===\n", bptr->nr);        
+               }
+
                for (iptr = bptr->phis; iptr != bptr->phis + bptr->phicount; ++iptr) {
                        escape_analysis_process_instruction(e, iptr);
                }
@@ -832,12 +1030,30 @@ static void escape_analysis_process_instructions(escape_analysis_t *e) {
        }
 }
 
+static void escape_analysis_post_process_returns(escape_analysis_t *e) {
+       instruction_list_item_t *iti;
+       instruction *iptr;
+
+       if (e->verbose) printf("Post processing returns:\n");
+
+       FOR_EACH_INSTRUCTION_LIST(e->getfields, iti) {
+               iptr = iti->instr;
+
+               if (! escape_analysis_get_contains_only_arguments(e, instruction_s1(iptr))) {
+                       escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_GLOBAL);
+                       E("return of not argument", s1)
+               }
+       }
+}
+
 static void escape_analysis_post_process_getfields(escape_analysis_t *e) {
        instruction_list_item_t *iti;
        dependency_list_item_t *itd;
        instruction *iptr;
        dependency_list_t *dl;
 
+       if (e->verbose) printf("Post processing getfields:\n");
+
        FOR_EACH_INSTRUCTION_LIST(e->getfields, iti) {
 
                iptr = iti->instr;
@@ -860,6 +1076,7 @@ static void escape_analysis_post_process_getfields(escape_analysis_t *e) {
                                                dependency_list_item_get_dependency(itd),
                                                escape_analysis_get_state(e, instruction_dst(iptr))
                                        );
+                                       I2("post process getfield", dependency_list_item_get_dependency(itd), escape_analysis_get_state(e, instruction_dst(iptr)));
                                }
                        }
                }
@@ -867,44 +1084,59 @@ static void escape_analysis_post_process_getfields(escape_analysis_t *e) {
        }
 }
 
-static void display_allocation(escape_analysis_t *e, const char *prefix, const instruction *iptr, escape_state_t es) {
-       const char *cl = "WTF";
-       classinfo *c;
+static void escape_analysis_mark_monitors(escape_analysis_t *e) {
+       instruction_list_item_t *iti;
+       instruction *iptr;
+
+       FOR_EACH_INSTRUCTION_LIST(e->monitors, iti) {
+               iptr = iti->instr;
 
-       if (instruction_get_opcode(iptr) == ICMD_NEW) {
-               c = escape_analysis_classinfo_in_var(e, instruction_arg(iptr, 0));
-               if (c) {
-                       cl = c->name->text;
+               /* TODO if argument does not escape, mark. */
+               if (escape_analysis_get_state(e, instruction_arg(iptr, 0)) != ESCAPE_GLOBAL) {
+                       if (e->verbose) {
+                               printf("Monitor on thread local object!\n");
+                       }
                }
        }
-       
-
-       printf(
-               " %s %s %s: %s %s @%d %s\n", 
-               prefix,
-               e->jd->m->clazz->name->text,
-               e->jd->m->name->text,
-               icmd_table[iptr->opc].name,
-               cl,
-               iptr->line,
-               escape_state_to_string(es)
-       );
 }
 
 static void escape_analysis_mark_allocations(escape_analysis_t *e) {
        instruction_list_item_t *iti;
+       instruction *iptr;
        escape_state_t es;
-/*
        FOR_EACH_INSTRUCTION_LIST(e->allocations, iti) {
-               es = escape_analysis_get_state(e, instruction_dst(iti->instr));
-               if (es < ESCAPE_GLOBAL_THROUGH_METHOD) {
-                       display_allocation(e, "****", iti->instr, es);
+               iptr = iti->instr;
+               es = escape_analysis_get_state(e, instruction_dst(iptr));
+
+#if defined(ENABLE_REASON)
+               if (instruction_get_opcode(iptr) == ICMD_NEW) {
+                       var_extra_t *ve;
+                       iptr->sx.s23.s3.bte = builtintable_get_internal(BUILTIN_escape_reason_new);
+                       ve = var_extra_get(e, var_extra_get_representant(e, instruction_dst(iptr)));
+                       iptr->escape_reasons = ve->reasons;
+                       if (es < ESCAPE_METHOD_RETURN) {
+                               assert(!ve->reasons);
+                               reason_t *r = NEW(reason_t);
+                               r->why = "No escape\n";
+                               r->iptr = NULL;
+                               r->next = NULL;
+                               iptr->escape_reasons = r;
+                       } else {
+                               assert(iptr->escape_reasons);
+                       }
                }
-               if (es == ESCAPE_GLOBAL_THROUGH_METHOD) {
-                       display_allocation(e, "!!!!", iti->instr, es);
+#endif
+
+/*
+               if (instruction_get_opcode(iptr) == ICMD_NEW) {
+                       es = escape_analysis_get_state(e, instruction_dst(iptr));
+                       if (es < ESCAPE_METHOD_RETURN) {
+                               iptr->sx.s23.s3.bte = builtintable_get_internal(BUILTIN_tlh_new);
+                               e->jd->code->flags |= CODE_FLAG_TLH;
+                       }
                }
-       }
 */
+       }
 }
 
 static void escape_analysis_process_arguments(escape_analysis_t *e) {
@@ -922,7 +1154,9 @@ static void escape_analysis_process_arguments(escape_analysis_t *e) {
                if (t == TYPE_ADR) {
                        if (varindex != UNUSED) {
                                escape_analysis_ensure_state(e, varindex, ESCAPE_NONE);
-                               escape_analysis_set_is_argument(e, varindex);
+                               escape_analysis_set_contains_argument(e, varindex);
+                               escape_analysis_set_contains_only_arguments(e, varindex);
+                               /*escape_analysis_set_adr_arg_num(e, varindex, e->adr_args_count);*/
                        }
                        e->adr_args_count += 1;
                }
@@ -937,11 +1171,18 @@ static void escape_analysis_export_arguments(escape_analysis_t *e) {
        s4 varindex;
        methoddesc *md;
        u1 *paramescape;
+       instruction_list_item_t *iti;
+       instruction *iptr;
+       escape_state_t es, re;
+       int ret_val_is_adr;
        
        md = e->jd->m->parseddesc;
 
-       paramescape = MNEW(u1, e->adr_args_count);
-       e->jd->m->paramescape = paramescape;
+       ret_val_is_adr = (md->returntype.type == TYPE_ADR) ? 1 : 0;
+
+       paramescape = MNEW(u1, e->adr_args_count + ret_val_is_adr);
+
+       e->jd->m->paramescape = paramescape + ret_val_is_adr;
 
        for (p = 0, l = 0; p < md->paramcount; ++p) {
                t = md->paramtypes[p].type;
@@ -950,16 +1191,59 @@ static void escape_analysis_export_arguments(escape_analysis_t *e) {
                        if (varindex == UNUSED) {
                                *paramescape = (u1)ESCAPE_NONE;
                        } else {
-                               *paramescape = (u1)escape_analysis_get_state(e, varindex);
-                       }
-                       if (e->verbose) {
-                               printf("adr parameter %d: %s\n", p, escape_state_to_string((escape_state_t)*paramescape));
+                               es = escape_analysis_get_state(e, varindex);
+
+                               if (es == ESCAPE_METHOD_RETURN) {
+                                       *paramescape = escape_state_to_u1(ESCAPE_METHOD) | 0x80;
+                                       if (e->verbose) {
+                                               printf("non-escaping adr parameter returned: %d\n", p);
+                                       }
+                               } else {
+                                       *paramescape = escape_state_to_u1(es);
+                               }
+
                        }
                        paramescape += 1;
                }
                l += IS_2_WORD_TYPE(t) ? 2 : 1;
        }
+
+       if (ret_val_is_adr) {
+               /* Calculate escape state of return value as maximum escape state of all
+                  values returned. */
+
+               re = ESCAPE_NONE;
+
+               FOR_EACH_INSTRUCTION_LIST(e->returns, iti) {
+                       iptr = iti->instr;
+                       es = escape_analysis_get_state(e, instruction_s1(iptr));
+
+                       if (es > re) {
+                               re = es;
+                       }
+               }
+
+               e->jd->m->paramescape[-1] = escape_state_to_u1(re);
+       }
+}
+
+#if defined(ENABLE_REASON)
+void print_escape_reasons() {
+       reason_t *re = THREADOBJECT->escape_reasons;
+
+       fprintf(stderr, "DYN_REASON");
+       
+       for (; re; re = re->next) {
+               fprintf(stderr,":%s", re->why);
+       }
+
+       fprintf(stderr, "\n");
+}
+
+void set_escape_reasons(void *vp) {
+       THREADOBJECT->escape_reasons = vp;
 }
+#endif
 
 static void escape_analysis_display(escape_analysis_t *e) {
        instruction_list_item_t *iti;
@@ -968,13 +1252,26 @@ static void escape_analysis_display(escape_analysis_t *e) {
 
        FOR_EACH_INSTRUCTION_LIST(e->allocations, iti) {
                iptr = iti->instr;
-               ve = var_extra_get(e, instruction_dst(iptr));
+               ve = var_extra_get(e, var_extra_get_representant(e, instruction_dst(iptr)));
+               show_icmd(e->jd, iptr-1, 0, 3);
+               printf("\n");
+               show_icmd(e->jd, iptr, 0, 3);
+               printf("\n");
                printf(
-                       "%s@%d: %s\n", 
+                       "%s@%d: --%s-- %d\n\n", 
                        icmd_table[iptr->opc].name, 
                        iptr->line, 
-                       escape_state_to_string(ve->escape_state)
+                       escape_state_to_string(ve->escape_state),
+                       ve->representant
                );
+#if defined(ENABLE_REASON)
+               {
+                       reason_t *re;
+                       for (re = ve->reasons; re; re = re->next) {
+                               printf("ESCAPE_REASON: %s\n", re->why);
+                       }
+               }
+#endif
        }
 }
 
@@ -983,25 +1280,72 @@ void escape_analysis_perform(jitdata *jd) {
 
        jd->m->flags |= ACC_METHOD_EA;
 
-       /*bc_escape_analysis_perform(jd->m);*/
-
        e = DNEW(escape_analysis_t);
        escape_analysis_init(e, jd);
 
        if (e->verbose) 
-               printf("==== %s/%s ====\n", e->jd->m->clazz->name->text, e->jd->m->name->text);
+               color_printf(RED, "\n\n==== %s/%s ====\n\n", e->jd->m->clazz->name->text, e->jd->m->name->text);
                
-       /*fprintf(stderr, ".");*/
-
        escape_analysis_process_arguments(e);
        escape_analysis_process_instructions(e);
        escape_analysis_post_process_getfields(e);
+       escape_analysis_post_process_returns(e);
+
        escape_analysis_export_arguments(e);
        if (e->verbose) escape_analysis_display(e);
+
+       if (e->verbose) {
+               int i, j, r;
+               for (i = 0; i < jd->vartop; ++i) {
+                       r = var_extra_get_representant(e, i);
+                       if (i == r) {
+                               printf("EES of %d: ", i);
+                               for (j = 0; j < jd->vartop; ++j) {
+                                       if (var_extra_get_representant(e, j) == r) {
+                                               printf("%d, ", j);
+                                       }
+                               }
+                               printf("\n");
+                       }
+               }
+               printf("\n");
+       }
+
        escape_analysis_mark_allocations(e);
+       escape_analysis_mark_monitors(e);
 
        jd->m->flags &= ~ACC_METHOD_EA;
 }
 
 void escape_analysis_escape_check(void *vp) {
 }
+
+/*** monomorphic *************************************************************/
+
+bool escape_is_monomorphic(methodinfo *caller, methodinfo *callee) {
+
+       /* Non-speculative case */
+
+       if (callee->flags & (ACC_STATIC | ACC_FINAL | ACC_PRIVATE)) {
+               return true;
+       }
+
+       if (
+               (callee->flags & (ACC_METHOD_MONOMORPHIC | ACC_METHOD_IMPLEMENTED| ACC_ABSTRACT))
+               == (ACC_METHOD_MONOMORPHIC | ACC_METHOD_IMPLEMENTED)
+       ) {
+
+               /* Mark that we have used the information about monomorphy. */
+
+               callee->flags |= ACC_METHOD_MONOMORPHY_USED;
+
+               /* We assume the callee is monomorphic. */
+
+               method_add_assumption_monomorphic(caller, callee);
+
+               return true;
+       }
+
+       return false;
+}
+
index 2f427fa31b6c2faf245a3748704b98485e62e234..b682be498492bbbf80213cd39b05355e2fd8a3b2 100644 (file)
 #ifndef _VM_JIT_OPTIMIZING_ESCAPE_H
 #define _VM_JIT_OPTIMIZING_ESCAPE_H
 
-#include "vm/jit/jit.h"
-#include "vmcore/method.h"
+#include "vm/jit/jit.hpp"
+#include "vm/method.hpp"
 
 typedef enum {
        ESCAPE_UNKNOWN,
        ESCAPE_NONE,
        ESCAPE_METHOD,
-       ESCAPE_GLOBAL_THROUGH_METHOD,
+       ESCAPE_METHOD_RETURN,
        ESCAPE_GLOBAL
 } escape_state_t;
 
+static inline escape_state_t escape_state_from_u1(u1 x) {
+       return (escape_state_t)(x & ~0x80);
+}
+
+static inline u1 escape_state_to_u1(escape_state_t x) {
+       return (u1)x;
+}
+
 void escape_analysis_perform(jitdata *jd);
 
 void escape_analysis_escape_check(void *vp);
 
 void bc_escape_analysis_perform(methodinfo *m);
 
+bool escape_is_monomorphic(methodinfo *caller, methodinfo *callee);
+
 #endif
index 9ffe18468e47f1721b733c4f75e9b2ead3d8af2b..fdde38c0c9fa9ff75a0b245758ccaf3f9e69cce7 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/optimizing/graph.c - CFG
 
-   Copyright (C) 2005, 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) 2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    02111-1307, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Christian Ullrich
-
-   $Id: graph.c$
-
 */
 
 #include <stdlib.h>
 
 #include "toolbox/bitvector.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #include "vm/jit/optimizing/lsra.h"
 #include "vm/jit/optimizing/ssa.h"
 #include "vm/jit/optimizing/graph.h"
 
 #ifdef GRAPH_DEBUG_VERBOSE
-#include "vmcore/options.h"
+#include "vm/options.h"
 #endif
 
 /* Helpers for graph_make_cfg */
index 12ad79381d988df044227004e16566caa8a6bf1c..088eb45683f815abdb4ff07e9059b778970df629 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/optimizing/graph.h - control flow graph header
 
-   Copyright (C) 2005, 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) 2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    02111-1307, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Christian Ullrich
-
-
 */
 
 
 #ifndef _LSRA_GRAPH_H
 #define _LSRA_GRAPH_H
 
+#include "config.h"
+
 #include "vm/jit/optimizing/lsra.h"
 
 #if !defined(NDEBUG)
@@ -77,6 +72,11 @@ typedef struct graph_element graph_element;
 typedef graph_element *graphiterator;
 
 /* function prototypes */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void transform_BB(jitdata *, graphdata *gd);
 graphdata *graph_init(int basicblockcount);
                                             /* Generate the CFG */
@@ -90,6 +90,9 @@ int graph_get_num_successor(graphdata *gd, int b_index);
 bool graph_has_multiple_successors( graphdata *gd, int b_index);
 bool graph_has_multiple_predecessors( graphdata *gd, int b_index);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _LSRA_GRAPH_H */
 
index bfaef14a792812d1e8d9c44f17ce89b2e0deb34e..9b292e64e4c72497e3eadfbc5401164cf79697be 100644 (file)
@@ -1,9 +1,7 @@
-/* src/vm/jit/ifconv/ifconv.c - if-conversion
+/* src/vm/jit/optimizing/ifconv.c - if-conversion
 
-   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.
 
 
 #include "vm/types.h"
 
-#include "vm/vm.h"
+#include "vm/method.hpp"
+#include "vm/vm.hpp"
 
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
-#include "vm/jit/show.h"
-
-#include "vmcore/method.h"
+#include "vm/jit/show.hpp"
 
 
 /* patterns for a total number of 3 instructions ******************************/
index 3fe01878dc4677519a6cbfdf29b3f998b9968330..92c32f6c4dff5396af37e4213a1002f72903ec25 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/optimizing/ifconv.h - if-conversion
 
-   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.
 
 #define _IFCONV_H
 
 #include "config.h"
-#include "vm/types.h"
 
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/reg.h"
+#include <stdbool.h>
 
-#include "vmcore/method.h"
+#include "vm/jit/jit.hpp"
 
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool ifconv_static(jitdata *jd);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _IFCONV_H */
 
 
index 54b9732d47b8afed16047b3d453a36a32089a6a5..8abc257417b2040f789d205e178d9a2db701f732 100644 (file)
@@ -1,4 +1,4 @@
-/* src/vm/jit/lsra.inc - lifetime anaylsis
+/* src/vm/jit/optimizing/lifetimes.c - lifetime anaylsis
 
    Copyright (C) 2005, 2006, 2008
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
@@ -23,6 +23,8 @@
 */
 
 
+#include "config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 
 #include "toolbox/bitvector.h"
 #include "toolbox/worklist.h"
 
-#include "vm/builtin.h"
-#include "vm/resolve.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/resolve.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/string.hpp"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #include "vm/jit/optimizing/graph.h"
 #include "vm/jit/optimizing/lsra.h"
@@ -44,7 +46,7 @@
 #include "vm/jit/optimizing/lifetimes.h"
 
 #ifdef LT_DEBUG_VERBOSE
-#include "vmcore/options.h"
+#include "vm/options.h"
 #endif
 
 #include <time.h>
index 08f4ae6ca6489ed2c50f6efe76d82d5e59f29b60..94655cf97ae2a35e1548a27a13687f9262bcf459 100644 (file)
@@ -26,7 +26,9 @@
 #ifndef _LIFETIMES_H
 #define _LIFETIMES_H
 
-#include "vm/jit/optimizing/dominators.h"
+#include "config.h"
+
+#include "vm/jit/optimizing/dominators.hpp"
 
 #if !defined(NDEBUG)
 # include <assert.h>
index 3b2006772c6721b117d8feddd03204237f1f91c2..5ea6e55d1b46cf7a14cd8f3237cec715788c69b2 100644 (file)
 
 #include "toolbox/bitvector.h"
 
-#include "vmcore/statistics.h"
-#include "vmcore/options.h"
-#include "vmcore/method.h"
+#include "vm/statistics.h"
+#include "vm/options.h"
+#include "vm/method.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/reg.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #include "vm/jit/optimizing/graph.h"
 #include "vm/jit/optimizing/lifetimes.h"
@@ -538,9 +538,6 @@ void lsra_alloc(jitdata *jd, int *lifet, int lifetimecount, int *mem_use)
        struct lifetime *lt;
        struct freemem *fmem;
        int lt_index;
-#ifdef HAS_4BYTE_STACKSLOT
-       struct freemem *fmem_2;
-#endif
        methodinfo *m;
        registerdata *rd;
        lsradata *ls;
@@ -552,11 +549,6 @@ void lsra_alloc(jitdata *jd, int *lifet, int lifetimecount, int *mem_use)
        fmem=DNEW(struct freemem);
        fmem->off=-1;
        fmem->next=NULL;
-#ifdef HAS_4BYTE_STACKSLOT
-       fmem_2=DNEW(struct freemem);
-       fmem_2->off=-1;
-       fmem_2->next=NULL;
-#endif
 
        for (lt_index = 0; lt_index < lifetimecount; lt_index ++) {
                lt = ls->lifetime + lifet[lt_index];
@@ -565,11 +557,6 @@ void lsra_alloc(jitdata *jd, int *lifet, int lifetimecount, int *mem_use)
 #endif
                if (lt->regoff == -1) {
                        flags = INMEMORY;
-#ifdef HAS_4BYTE_STACKSLOT
-                       if (IS_2_WORD_TYPE(lt->type))
-                               regoff = lsra_getmem(lt, fmem_2, mem_use);
-                       else
-#endif
                        regoff = lsra_getmem(lt, fmem, mem_use);
                } else {
                        flags = lt->savedvar;
@@ -589,17 +576,7 @@ int lsra_getmem(struct lifetime *lt, struct freemem *fmem, int *mem_use)
        /* no memmory allocated till now, or all other are still live */
        if ((fmem->next == NULL) || (fmem->next->end > lt->i_start)) {
 /*     if (1) { */
-#ifdef HAS_4BYTE_STACKSLOT
-               if (IS_2_WORD_TYPE(lt->type))
-                       if ( (*mem_use)&1 ) /* align memory location for 2 Word Types */
-                               (*mem_use)++;
                fm=lsra_getnewmem(mem_use);
-               if (IS_2_WORD_TYPE(lt->type))
-                       /* allocate a second following Slot for 2 Word Types */
-                       (*mem_use)++;
-#else
-               fm=lsra_getnewmem(mem_use);
-#endif
        } else {
                /* Speicherstelle frei */
                fm=fmem->next;
@@ -934,7 +911,7 @@ void lsra_calc_lifetime_length(jitdata *jd)
 
                        switch (lt->type) {
                        case TYPE_LNG:
-#if (defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)) || defined (__I386__)
+#if defined (__I386__)
                                flags = 0;
 #else
                                flags = 1;
index 319b2289a7fe41f03d8b9a561b1e641c10740c58..e397be6021bf31dc2313016d4226fadc7191a265 100644 (file)
 
 #include "mm/memory.h"
 
-#include "threads/threadlist.h"
-#include "threads/thread.h"
+#include "threads/threadlist.hpp"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
-#include "vm/stringlocal.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/classcache.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/string.hpp"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/methodtree.h"
 
-#include "vm/jit/optimizing/recompile.h"
-
-#include "vmcore/class.h"
-#include "vmcore/classcache.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
+#include "vm/jit/optimizing/recompiler.hpp"
 
 
 /* profile_init ****************************************************************
@@ -93,13 +92,12 @@ static void profile_thread(void)
                threads_sleep(0, nanos);
                runs++;
 
-               /* lock the threads lists */
-
-               threadlist_lock();
+               // Lock the thread lists.
+               ThreadList_lock();
 
                /* iterate over all started threads */
 
-               for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
+               for (t = ThreadList_first(); t != NULL; t = ThreadList_next(t)) {
                        /* is this a Java thread? */
 
                        if (!(t->flags & THREAD_FLAG_JAVA))
@@ -149,16 +147,15 @@ static void profile_thread(void)
                                                        /* add this method to the method list and
                                                           start recompilation */
 
-                                                       recompile_queue_method(m);
+                                                       Recompiler_queue_method(m);
                                                }
                                        }
                                }
                        }
                }
 
-               /* unlock the threads lists */
-
-               threadlist_unlock();
+               // Unlock the thread lists.
+               ThreadList_unlock();
        }
 }
 #endif
@@ -196,9 +193,6 @@ bool profile_start_thread(void)
 #if !defined(NDEBUG)
 void profile_printstats(void)
 {
-       list_t                 *l;
-       list_method_entry      *lme;
-       list_method_entry      *tlme;
        classinfo              *c;
        methodinfo             *m;
        codeinfo               *code;
@@ -214,8 +208,8 @@ void profile_printstats(void)
        cycles    = 0;
 
        /* create new method list */
-
-       l = list_create(OFFSET(list_method_entry, linkage));
+       // TODO Use a sorted container.
+       List* l = List_new();
 
        /* iterate through all classes and methods */
 
@@ -246,15 +240,10 @@ void profile_printstats(void)
                                                frequency += code->frequency;
                                                cycles    += code->cycles;
 
-                                               /* create new list entry */
-
-                                               lme = NEW(list_method_entry);
-                                               lme->m = m;
-
                                                /* sort the new entry into the list */
                                                
-                                               if ((tlme = list_first(l)) == NULL) {
-                                                       list_add_first(l, lme);
+                                               if (List_empty(l) == NULL) {
+                                                       List_push_back(l, m);
                                                }
                                                else {
                                                        for (; tlme != NULL; tlme = list_next(l, tlme)) {
index a88c1b611a24fcb91cd389e845a7c182416de86d..a235afacd4cab06e0c2df9114bb93255b3575fc5 100644 (file)
@@ -1,9 +1,7 @@
-/* src/vm/jit/profile.h - runtime profiling
+/* src/vm/jit/optimizing/profile.h - runtime profiling
 
-   Copyright (C) 1996-2005, 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, J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
 */
 
 
 #define _PROFILE_H
 
 #include "config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "vm/types.h"
 
 #include "vm/global.h"
@@ -49,6 +46,10 @@ bool profile_start_thread(void);
 void profile_printstats(void);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _PROFILE_H */
 
 
diff --git a/src/vm/jit/optimizing/recompile.c b/src/vm/jit/optimizing/recompile.c
deleted file mode 100644 (file)
index aa61989..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-/* src/vm/jit/optimizing/recompile.c - recompilation system
-
-   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 <stdlib.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "threads/lock-common.h"
-#include "threads/thread.h"
-
-#include "toolbox/list.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-
-#include "vm/jit/code.h"
-#include "vm/jit/jit.h"
-
-#include "vm/jit/optimizing/recompile.h"
-
-#include "vmcore/classcache.h"
-#include "vmcore/options.h"
-
-
-/* global variables ***********************************************************/
-
-static java_object_t *lock_thread_recompile;
-static list_t        *list_recompile_methods;
-
-
-/* recompile_init **************************************************************
-
-   Initializes the recompilation system.
-
-*******************************************************************************/
-
-bool recompile_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("recompile_init");
-
-       /* initialize the recompile lock object */
-
-       lock_thread_recompile = NEW(java_object_t);
-
-       LOCK_INIT_OBJECT_LOCK(lock_thread_recompile);
-
-       /* create method list */
-
-       list_recompile_methods = list_create(OFFSET(list_method_entry, linkage));
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* recompile_replace_vftbl *****************************************************
-
-   XXX
-
-*******************************************************************************/
-
-static void recompile_replace_vftbl(methodinfo *m)
-{
-       codeinfo               *code;
-       codeinfo               *pcode;
-       u4                      slot;
-       classcache_name_entry  *nmen;
-       classcache_class_entry *clsen;
-       classinfo              *c;
-       vftbl_t                *vftbl;
-       s4                      i;
-
-       /* get current and previous codeinfo structure */
-
-       code  = m->code;
-       pcode = code->prev;
-
-       assert(pcode);
-
-       /* iterate over all classes */
-
-       for (slot = 0; slot < hashtable_classcache.size; slot++) {
-               nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
-
-               for (; nmen; nmen = nmen->hashlink) {
-                       /* iterate over all class entries */
-
-                       for (clsen = nmen->classes; clsen; clsen = clsen->next) {
-                               c = clsen->classobj;
-
-                               if (c == NULL)
-                                       continue;
-
-                               /* Search for entrypoint of the previous codeinfo in
-                                  the vftbl and replace it with the current one. */
-
-                               vftbl = c->vftbl;
-
-                               /* Is the class linked? Means, is the vftbl finished? */
-
-                               if (!(c->state & CLASS_LINKED))
-                                       continue;
-
-                               /* Does the class have a vftbl? Some internal classes
-                                  (e.g. $NEW$) are linked, but do not have a
-                                  vftbl. */
-
-                               if (vftbl == NULL)
-                                       continue;
-
-                               for (i = 0; i < vftbl->vftbllength; i++) {
-                                       if (vftbl->table[i] == pcode->entrypoint) {
-#if !defined(NDEBUG)
-                                               printf("replacing vftbl in: ");
-                                               class_println(c);
-#endif
-                                               vftbl->table[i] = code->entrypoint;
-                                       }
-                               }
-                       }
-               }
-       }
-}
-
-
-/* recompile_thread ************************************************************
-
-   XXX
-
-*******************************************************************************/
-
-static void recompile_thread(void)
-{
-       list_method_entry *lme;
-
-       while (true) {
-               /* get the lock on the recompile lock object, so we can call wait */
-
-               LOCK_MONITOR_ENTER(lock_thread_recompile);
-
-               /* wait forever on that object till we are signaled */
-       
-               LOCK_WAIT_FOREVER(lock_thread_recompile);
-
-               /* leave the lock */
-
-               LOCK_MONITOR_EXIT(lock_thread_recompile);
-
-               /* get the next method and recompile it */
-
-               while ((lme = list_first(list_recompile_methods)) != NULL) {
-                       /* recompile this method */
-
-                       if (jit_recompile(lme->m) != NULL) {
-                               /* replace in vftbl's */
-
-                               recompile_replace_vftbl(lme->m);
-                       }
-                       else {
-                               /* XXX what is the right-thing(tm) to do here? */
-
-                               exceptions_print_current_exception();
-                       }
-
-                       /* remove the compiled method */
-
-                       list_remove(list_recompile_methods, lme);
-
-                       /* free the entry */
-
-                       FREE(lme, list_method_entry);
-               }
-       }
-}
-
-
-/* recompile_start_thread ******************************************************
-
-   Starts the recompilation thread.
-
-*******************************************************************************/
-
-bool recompile_start_thread(void)
-{
-       utf *name;
-
-       name = utf_new_char("Recompiler");
-
-       if (!threads_thread_start_internal(name, recompile_thread))
-               return false;
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* recompile_queue_method ******************************************************
-
-   Adds a method to the recompilation list and signal the
-   recompilation thread that there is some work to do.
-
-*******************************************************************************/
-
-void recompile_queue_method(methodinfo *m)
-{
-       list_method_entry *lme;
-
-       /* create a method entry */
-
-       lme = NEW(list_method_entry);
-       lme->m = m;
-
-       /* and add it to the list */
-
-       list_add_last(list_recompile_methods, lme);
-
-       /* get the lock on the recompile lock object, so we can call notify */
-
-       LOCK_MONITOR_ENTER(lock_thread_recompile);
-
-       /* signal the recompiler thread */
-       
-       LOCK_NOTIFY(lock_thread_recompile);
-
-       /* leave the lock */
-
-       LOCK_MONITOR_EXIT(lock_thread_recompile);
-}
-
-
-/*
- * 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:
- */
diff --git a/src/vm/jit/optimizing/recompile.h b/src/vm/jit/optimizing/recompile.h
deleted file mode 100644 (file)
index ca71ac9..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* src/vm/jit/optimizing/recompile.h - recompilation system
-
-   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, J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   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 _RECOMPILE_H
-#define _RECOMPILE_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-
-/* list_method_entry **********************************************************/
-
-typedef struct list_method_entry list_method_entry;
-
-struct list_method_entry {
-       methodinfo *m;
-       listnode_t  linkage;
-};
-
-
-/* function prototypes ********************************************************/
-
-bool recompile_init(void);
-bool recompile_start_thread(void);
-
-void recompile_queue_method(methodinfo *m);
-
-#endif /* _PROFILE_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:
- */
diff --git a/src/vm/jit/optimizing/recompiler.cpp b/src/vm/jit/optimizing/recompiler.cpp
new file mode 100644 (file)
index 0000000..4f3d524
--- /dev/null
@@ -0,0 +1,236 @@
+/* src/vm/jit/optimizing/recompiler.cpp - recompilation system
+
+   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 <stdint.h>
+
+#include "mm/memory.h"
+
+#include "threads/condition.hpp"
+#include "threads/mutex.hpp"
+#include "threads/thread.hpp"
+
+#include "vm/classcache.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/options.h"
+#include "vm/string.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/jit/code.hpp"
+#include "vm/jit/jit.hpp"
+
+#include "vm/jit/optimizing/recompiler.hpp"
+
+
+/**
+ * Stop the worker thread.
+ */
+Recompiler::~Recompiler()
+{
+       // Set the running flag to false.
+       _run = false;
+
+       // Now signal the worker thread.
+       _cond.signal();
+
+       // TODO We should wait here until the thread exits.
+}
+
+
+/* recompile_replace_vftbl *****************************************************
+
+   XXX
+
+*******************************************************************************/
+
+static void recompile_replace_vftbl(methodinfo *m)
+{
+       codeinfo               *code;
+       codeinfo               *pcode;
+       u4                      slot;
+       classcache_name_entry  *nmen;
+       classcache_class_entry *clsen;
+       classinfo              *c;
+       vftbl_t                *vftbl;
+       s4                      i;
+
+       /* get current and previous codeinfo structure */
+
+       code  = m->code;
+       pcode = code->prev;
+
+       assert(pcode);
+
+       /* iterate over all classes */
+
+       for (slot = 0; slot < hashtable_classcache.size; slot++) {
+               nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
+
+               for (; nmen; nmen = nmen->hashlink) {
+                       /* iterate over all class entries */
+
+                       for (clsen = nmen->classes; clsen; clsen = clsen->next) {
+                               c = clsen->classobj;
+
+                               if (c == NULL)
+                                       continue;
+
+                               /* Search for entrypoint of the previous codeinfo in
+                                  the vftbl and replace it with the current one. */
+
+                               vftbl = c->vftbl;
+
+                               /* Is the class linked? Means, is the vftbl finished? */
+
+                               if (!(c->state & CLASS_LINKED))
+                                       continue;
+
+                               /* Does the class have a vftbl? Some internal classes
+                                  (e.g. $NEW$) are linked, but do not have a
+                                  vftbl. */
+
+                               if (vftbl == NULL)
+                                       continue;
+
+                               for (i = 0; i < vftbl->vftbllength; i++) {
+                                       if (vftbl->table[i] == pcode->entrypoint) {
+#if !defined(NDEBUG)
+                                               printf("replacing vftbl in: ");
+                                               class_println(c);
+#endif
+                                               vftbl->table[i] = code->entrypoint;
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+
+/**
+ * The actual recompilation thread.
+ */
+void Recompiler::thread()
+{
+       // FIXME This just works for one recompiler.
+       Recompiler& r = VM::get_current()->get_recompiler();
+
+       while (r._run == true) {
+               // Enter the recompile mutex, so we can call wait.
+               r._mutex.lock();
+
+               // Wait forever on that condition until we are signaled.
+               r._cond.wait(r._mutex);
+
+               // Leave the mutex.
+               r._mutex.unlock();
+
+               // FIXME Move this into the for loop.
+               if (r._run == false)
+                       break;
+
+               // Sanity check.
+               assert(r._methods.empty() == false);
+
+               // Get the next method form the queue and recompile it.
+               while (r._methods.empty() == false) {
+                       methodinfo* m = r._methods.front();
+
+                       // Recompile this method.
+                       if (jit_recompile(m) != NULL) {
+                               // Replace in vftbl's.
+                               recompile_replace_vftbl(m);
+                       }
+                       else {
+                               // XXX What is the right-thing(tm) to do here?
+                               exceptions_print_current_exception();
+                       }
+
+                       // Remove the method from the queue.
+                       r._methods.pop();
+               }
+       }
+}
+
+
+/**
+ * Start the recompilation thread.
+ *
+ * @return true on success, false otherwise.
+ */
+bool Recompiler::start()
+{
+       utf *name = utf_new_char("Recompiler");
+
+       if (!threads_thread_start_internal(name, (functionptr) &Recompiler::thread))
+               return false;
+
+       return true;
+}
+
+
+/**
+ * Add a method to the recompilation queue and signal the
+ * recompilation thread that there is some work to do.
+ *
+ * @param m Method to recompile.
+ */
+void Recompiler::queue_method(methodinfo *m)
+{
+       // Add the method to the queue.
+       _methods.push(m);
+
+       // Enter the recompile mutex, so we can call notify.
+       _mutex.lock();
+
+       // Signal the recompiler thread.
+       _cond.signal();
+
+       // Leave the mutex.
+       _mutex.unlock();
+}
+
+
+
+// Legacy C interface.
+extern "C" {
+       void Recompiler_queue_method(methodinfo* m) { VM::get_current()->get_recompiler().queue_method(m); }
+}
+
+/*
+ * 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/jit/optimizing/recompiler.hpp b/src/vm/jit/optimizing/recompiler.hpp
new file mode 100644 (file)
index 0000000..86eba45
--- /dev/null
@@ -0,0 +1,105 @@
+/* src/vm/jit/optimizing/recompiler.hpp - recompilation system
+
+   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 _RECOMPILER_HPP
+#define _RECOMPILER_HPP
+
+#include "config.h"
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+#include <queue>
+#endif
+
+#include "threads/condition.hpp"
+#include "threads/mutex.hpp"
+
+#include "vm/method.hpp"
+
+
+#ifdef __cplusplus
+
+/**
+ * Thread for JIT recompilations.
+ */
+class Recompiler {
+private:
+       Mutex                   _mutex;
+       Condition               _cond;
+       std::queue<methodinfo*> _methods;
+       bool                    _run;       ///< Flag to stop worker thread.
+
+       static void thread();               ///< Worker thread.
+
+public:
+       Recompiler() : _run(true) {}
+       ~Recompiler();
+
+       bool start();                       ///< Start the worker thread.
+       void queue_method(methodinfo* m);   ///< Queue a method for recompilation.
+};
+
+#endif
+
+/* list_method_entry **********************************************************/
+
+typedef struct list_method_entry list_method_entry;
+
+struct list_method_entry {
+       methodinfo *m;
+/*     listnode_t  linkage; */
+};
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void Recompiler_queue_method(methodinfo *m);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _RECOMPILER_HPP
+
+
+/*
+ * 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 bd43c368579dc04a8f6bb7cdaecb7c37c77e929c..2b135943f62a20f0473c95bf7340dfa646c8a183 100644 (file)
@@ -38,7 +38,7 @@
 #include "vm/types.h"
 
 #include "mm/memory.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* reorder_place_next_unplaced_block *******************************************
index d76b463519aed72456924fd1beac55f60998345c..fccc8e77e6b7dc4ea1852034fa36d853af03fab2 100644 (file)
@@ -1,9 +1,7 @@
-/* src/vm/reorder.h - basic block reordering
+/* src/vm/optimizing/reorder.h - basic block reordering
 
-   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,
-   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.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
 */
 
 
 #define _REORDER_H
 
 #include "config.h"
-#include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include <stdbool.h>
+
+#include "vm/jit/jit.hpp"
 
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool reorder(jitdata *jd);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _REORDER_H */
 
 
index 721323e4bb0df7409dca7d2981c95c6da8c458c1..357f323f6a9d3a8e1d2d2cd2fce0d6024b3a4d73 100644 (file)
 #include "toolbox/bitvector.h"
 #include "toolbox/worklist.h"
 
-#include "vm/builtin.h"
+#include "vm/jit/builtin.hpp"
 
-#include "vm/jit/jit.h" /* icmd_table */
+#include "vm/jit/jit.hpp" /* icmd_table */
 
 #include "vm/jit/ir/bytecode.h"
 
-#include "vm/jit/optimizing/dominators.h"
+#include "vm/jit/optimizing/dominators.hpp"
 #include "vm/jit/optimizing/graph.h"
 #include "vm/jit/optimizing/lifetimes.h"
 #include "vm/jit/optimizing/lsra.h"
@@ -51,7 +51,7 @@
 #include "vm/jit/python.h"
 
 #if defined(SSA_DEBUG_VERBOSE)
-#include "vmcore/options.h"   /* compileverbose */
+#include "vm/options.h"   /* compileverbose */
 #endif
 
 /* function prototypes */
@@ -133,6 +133,7 @@ void ssa(jitdata *jd) {
                yssa(jd);
        }
        /*pythonpass_run(jd, "foo", "after");*/
+       cfg_remove_root(jd);
        return;
 
        ls = jd->ls;
index 56ba88184953ecfde3b09a9475d03250d7589834..78b488ab1e4d2a3303fe2b85b4c02bf709b1fd73 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/optimizing/ssa.h - static single assignment form header
 
-   Copyright (C) 2005 - 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) 2005, 2006, 2007, 2008
+   CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO
 
    This file is part of CACAO.
 
 
    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., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
-
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Christian Ullrich
-
-   $Id: ssa.h$
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
 */
 
@@ -34,6 +26,8 @@
 #ifndef _SSA_H
 #define _SSA_H
 
+#include "config.h"
+
 #include "vm/jit/optimizing/graph.h"
 
 #if !defined(NDEBUG)
 #endif
 
 /* function prototypes */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void ssa_init(jitdata *);
 void ssa(jitdata */* , graphdata **/);
 
+void fix_exception_handlers(jitdata *jd);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _SSA_H */
 
 /*
index 0246777420daef9c473e51785734a2d1d113e163..ad1038a853d2902b2a48a6aa5f18f49585d3250d 100644 (file)
@@ -33,7 +33,7 @@
 #include "toolbox/worklist.h"
 
 #include "vm/global.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #if 1
 #define printf(...) do { if (getenv("VERB")) printf(__VA_ARGS__); } while (0)
index 0f8c1306dcb754a625a7291c8dda1c008fb1b983..3391d41dd4d2223fb82a4487d2f64b32b9da9861 100644 (file)
@@ -1,4 +1,4 @@
-/* src/vm/optimizing/ssa3.c
+/* src/vm/jit/optimizing/ssa3.c
 
    Copyright (C) 2008
    CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO
    * Unify access to phi args.
 */
 
-#include "vm/jit/jit.h"
+
+#include "config.h"
+
+#include "vm/jit/jit.hpp"
 #include "vm/global.h"
 #include "mm/memory.h"
-#include "mm/dumpmemory.h"
-#include "toolbox/list.h"
+#include "mm/dumpmemory.hpp"
+#include "toolbox/list.hpp"
 
 #include <limits.h>
 #include <stdio.h>
 
-#define ELIMINATE_NOP_LOAD_STORE
+/*#define ELIMINATE_NOP_LOAD_STORE*/
 #define FIXME(x) x
 #define SSA_VERIFY
-/* #define SSA_VERBOSE */
+/*#define SSA_VERBOSE */
 
 /*
 __attribute__((always_inline))
@@ -345,8 +348,8 @@ static inline void instruction_set_uses(instruction *iptr, s4 *buf, s4 *uses, un
 
 /*** vars *******************************************************************/
 
-#define VARS_CATEGORY_SHIFT 29
-#define VARS_INDEX_MASK 0x1FFFFFFF
+#define VARS_CATEGORY_SHIFT 28
+#define VARS_INDEX_MASK 0x0FFFFFFF
 
 #define VARS_CATEGORY_LOCAL 0
 #define VARS_CATEGORY_STACK 1
@@ -354,8 +357,15 @@ static inline void instruction_set_uses(instruction *iptr, s4 *buf, s4 *uses, un
 
 #define VAR_TYPE_SUBSTITUED 666
 
+#define OLD_INDEX_UNUSED -2
+
 typedef struct {
-       varinfo items[9000]; /* XXX hardcoded max */
+       varinfo v;
+       s4 old_index;
+} vars_item_t;
+
+typedef struct {
+       vars_item_t items[9000]; /* XXX hardcoded max */
        unsigned max;
        unsigned count;
        unsigned category;
@@ -365,7 +375,8 @@ static inline unsigned vars_add_item(vars_t *vs, const varinfo *item) {
        unsigned i = vs->count;
        assert(i < vs->max);
        vs->count += 1;
-       vs->items[i] = *item;
+       vs->items[i].v = *item;
+       vs->items[i].old_index = OLD_INDEX_UNUSED;
        return (vs->category << VARS_CATEGORY_SHIFT) | i;
 }
 
@@ -378,7 +389,7 @@ static inline unsigned vars_add(vars_t *vs) {
 
 static inline varinfo *vars_back(vars_t *vs) {
        assert(vs->count > 0);
-       return vs->items + (vs->count - 1);
+       return &(vs->items[vs->count - 1].v);
 }
 
 static inline void vars_init(vars_t *vs, unsigned category) {
@@ -400,8 +411,8 @@ static void vars_subst(vars_t *vs, unsigned varindex, unsigned replacementindex)
        varindex = vars_get_index(varindex);
        replacementindex = vars_get_index(replacementindex);
 
-       vs->items[varindex].type = VAR_TYPE_SUBSTITUED;
-       vs->items[varindex].vv.regoff = replacementindex;
+       vs->items[varindex].v.type = VAR_TYPE_SUBSTITUED;
+       vs->items[varindex].v.vv.ii[1] = replacementindex;
 }
 
 static unsigned vars_resolve_subst(const vars_t *vs, unsigned varindex) {
@@ -410,36 +421,80 @@ static unsigned vars_resolve_subst(const vars_t *vs, unsigned varindex) {
 #endif
        varindex = vars_get_index(varindex);
 
-       if (vs->items[varindex].type == VAR_TYPE_SUBSTITUED) /*fprintf(stderr, "*")*/;
+       if (vs->items[varindex].v.type == VAR_TYPE_SUBSTITUED) /*fprintf(stderr, "*")*/;
 
-       while (vs->items[varindex].type == VAR_TYPE_SUBSTITUED) {
+       while (vs->items[varindex].v.type == VAR_TYPE_SUBSTITUED) {
                assert(loop_ctr++ != vs->count);
-               varindex = vs->items[varindex].vv.regoff;
+               varindex = vs->items[varindex].v.vv.ii[1];
        }
 
        return (vs->category << VARS_CATEGORY_SHIFT) | varindex ;
 }
 
 static void vars_copy_to_final(vars_t *vs, varinfo *dst) {
-       const varinfo *it;
+       const vars_item_t *it;
        unsigned subst;
 
        for (it = vs->items; it != vs->items + vs->count; ++it, ++dst) {
 
                /* Copy variable. */
 
-               *dst = *it;
+               *dst = it->v;
 
                /* Eliminate VAR_TYPE_SUBSTITUED as it leads to problems. */
 
                if (dst->type == VAR_TYPE_SUBSTITUED) {
                        subst = vars_get_index(vars_resolve_subst(vs, it - vs->items));
-                       dst->type = vs->items[subst].type;
+                       dst->type = vs->items[subst].v.type;
 
                }
        }
 }
 
+static void vars_import(vars_t *vs, varinfo *v, unsigned count, s4 old_index) {
+       vars_item_t *it;
+
+       assert((vs->count + count) <= vs->max);
+
+       it = vs->items + vs->count;
+       vs->count += count;
+
+       while (count-- > 0) {
+               it->v = *v;
+               it->old_index = old_index;
+               it += 1;
+               v += 1;
+               old_index += 1;
+       }
+}
+
+static inline void vars_record_old_index(vars_t *vs, unsigned varindex, s4 old_index) {
+       vars_item_t *item;
+       varindex = vars_get_index(varindex);
+
+       assert(varindex < vs->count);
+
+       item = vs->items + varindex;
+
+       assert(
+               item->old_index == OLD_INDEX_UNUSED || 
+               item->old_index == old_index
+       );
+
+       item->old_index = old_index;
+}
+
+static inline s4 vars_get_old_index(vars_t *vs, unsigned varindex) {
+       s4 old;
+
+       varindex = vars_get_index(varindex);
+
+       assert(varindex < vs->count);
+       old = vs->items[varindex].old_index;
+       assert(old != OLD_INDEX_UNUSED);
+
+       return old;
+}
 
 /*** phis *******************************************************************/
 
@@ -486,13 +541,15 @@ FIXME() inline void phis_print(const phis_t *ps) {
 }
 #endif
 
-static inline void phis_copy_to(const phis_t *ps, instruction *dst) {
-       MCOPY(
-               dst,
-               ps->items,
-               instruction,
-               ps->count
-       );
+static inline unsigned phis_copy_to(const phis_t *ps, instruction *dst) {
+       instruction *it;
+       instruction *out = dst;
+
+       FOR_EACH_PHI_FUNCTION(ps, it) {
+               *(out++) = *it;
+       }
+
+       return (out - dst);
 }
 
 /*** state_array ************************************************************/
@@ -680,31 +737,41 @@ instruction *traversal_create_phi(traversal_t *t, vars_t *v, unsigned argcount,
 
        state_array_set(t->state_array, index, phi);
 
+       vars_record_old_index(v, phi->dst.varindex, index);
+
        return phi;
 }
 
 static void traversal_rename_def(traversal_t *t, vars_t *vars, instruction *iptr) {
        const varinfo *v;
        unsigned index;
+       s4 old;
 
        state_array_assert_items(t->state_array);
 
        v = t->ops->var_num_to_varinfo(t->ops_vp, iptr->dst.varindex);
        index = t->ops->var_num_to_index(t->ops_vp, iptr->dst.varindex);
 
+       old = iptr->dst.varindex;
        iptr->dst.varindex = vars_add_item(vars, v);
        state_array_set(t->state_array, index, iptr);
+
+       vars_record_old_index(vars, iptr->dst.varindex, index);
 }
 
-static void traversal_rename_use(traversal_t *t, s4 *puse) {
+static void traversal_rename_use(traversal_t *t, vars_t *vars, s4 *puse) {
        unsigned index;
+       s4 old;
 
        state_array_assert_items(t->state_array);
 
        index = t->ops->var_num_to_index(t->ops_vp, *puse);
 
        assert(state_array_get(t->state_array, index));
+       old = *puse;
        *puse = state_array_get_var(t->state_array, index);
+
+       vars_record_old_index(vars, *puse, index);
 }
 
 static inline unsigned traversal_variables_count(traversal_t *t) {
@@ -862,6 +929,18 @@ typedef struct ssa_info {
 
        basicblock_chain_t *new_blocks;
 
+       struct {
+               s4 maxlocals;
+               s4 maxinterfaces;
+               s4 *local_map;
+               varinfo *var;
+               s4 vartop;
+               s4 varcount;
+               s4 localcount;
+       } original;
+
+       unsigned keep_in_out:1;
+
 } ssa_info, ssa_info_t;
 
 void ssa_info_init(ssa_info_t *ssa, jitdata *jd) {
@@ -871,8 +950,7 @@ void ssa_info_init(ssa_info_t *ssa, jitdata *jd) {
        vars_init(ssa->locals, VARS_CATEGORY_LOCAL);
 
        /* Initialize first version of locals, that is always available. */
-       MCOPY(ssa->locals->items, jd->var, varinfo, jd->localcount);
-       ssa->locals->count = jd->localcount;
+       vars_import(ssa->locals, jd->var, jd->localcount, 0);
 
        ssa->stack = DNEW(vars_t);
        vars_init(ssa->stack, VARS_CATEGORY_STACK);
@@ -882,16 +960,26 @@ void ssa_info_init(ssa_info_t *ssa, jitdata *jd) {
 
        ssa->new_blocks = DNEW(basicblock_chain_t);
        basicblock_chain_init(ssa->new_blocks);
+
+       ssa->original.maxlocals = jd->maxlocals;
+       ssa->original.maxinterfaces = jd->maxinterfaces;
+       ssa->original.local_map = jd->local_map;
+       ssa->original.var = jd->var;
+       ssa->original.vartop = jd->vartop;
+       ssa->original.varcount = jd->varcount;
+       ssa->original.localcount = jd->localcount;
+
+       ssa->keep_in_out = false;
 }
 
 /*** others_mapping *********************************************************/
 
 static inline void others_mapping_set(ssa_info *ssa, s4 var, s4 new_var) {
-       ssa->jd->var[var].vv.regoff = new_var;
+       ssa->jd->var[var].vv.ii[1] = new_var;
 }
 
 static inline s4 others_mapping_get(const ssa_info *ssa, s4 var) {
-       return ssa->jd->var[var].vv.regoff;
+       return ssa->jd->var[var].vv.ii[1];
 }
 
 /*** code *******************************************************************/
@@ -907,6 +995,8 @@ void fix_exception_handlers(jitdata *jd) {
        basicblock_chain_t chain;
        basicblock *last = NULL;
        basicblock *marker = NULL;
+       s4 vartop;
+       unsigned i;
 
        if (jd->exceptiontablelength == 0) {
                return;
@@ -914,22 +1004,38 @@ void fix_exception_handlers(jitdata *jd) {
 
        basicblock_chain_init(&chain);
 
-       /* We need to allocate new iovars */
-
-       avail_vars = (jd->varcount - jd->vartop);
-       add_vars = jd->exceptiontablelength;
+       /* Remember, where we started adding IO variables. */
 
-       if (add_vars > avail_vars) {
-               add_vars -= avail_vars;
-               jd->var = DMREALLOC(jd->var, varinfo, jd->varcount, jd->varcount + add_vars);
-               jd->varcount += add_vars;
-       }
+       vartop = jd->vartop;
 
        /* For each exception handler block, create one block with a prologue block */
 
        FOR_EACH_BASICBLOCK(jd, bptr) {
                if (bptr->type == BBTYPE_EXH) {
 
+                       /*
+             
+            +---- EXH (exh)-------+
+            |  in0 in1 in2 exc    |
+                       |  .....              |
+            +---------------------+
+
+            === TRANSFORMED TO ===>
+
+            +---- PROL (exh) -------+
+            |  in0 in1 in2          |
+            |  GETEXECEPTION => OU3 |
+            |  GOTO REAL_EXH        |
+            |  in0 in1 in2 OU3      |
+            +-----------------------+
+
+            +---- REAL_EXH (std) -+
+            |  in0 in1 in2 exc    |
+                       |  ......             |
+            +---------------------+
+
+                       */
+
                        bptr->type = BBTYPE_STD;
                        bptr->predecessorcount = 0; /* legacy */
 
@@ -940,7 +1046,24 @@ void fix_exception_handlers(jitdata *jd) {
 
                        iptr = DMNEW(instruction, 2);
                        MZERO(iptr, instruction, 2);
+                       
+                       /* Create outvars */
+
+                       exh->outdepth = bptr->indepth;
 
+                       if (exh->outdepth > 0) {
+                               exh->outvars = DMNEW(s4, exh->outdepth);
+                               for (i = 0; i < exh->outdepth; ++i) {
+                                       exh->outvars[i] = vartop++;
+                               }
+                       }
+
+                       /* Create invars */
+
+                       exh->indepth = exh->outdepth - 1;
+                       exh->invars = exh->outvars;
+
+#if 0
                        /* Create new outvar */
 
                        assert(jd->vartop < jd->varcount);
@@ -948,6 +1071,7 @@ void fix_exception_handlers(jitdata *jd) {
                        jd->vartop += 1;
                        jd->var[v].type = TYPE_ADR;
                        jd->var[v].flags = INOUT;
+#endif
 
                        exh->nr = jd->basicblockcount;
                        jd->basicblockcount += 1;
@@ -955,9 +1079,11 @@ void fix_exception_handlers(jitdata *jd) {
                        exh->type = BBTYPE_EXH;
                        exh->icount = 2;
                        exh->iinstr = iptr;
+/*
                        exh->outdepth = 1;
                        exh->outvars = DNEW(s4);
                        exh->outvars[0] = v;
+*/
                        exh->predecessorcount = -1; /* legacy */
                        exh->flags = BBFINISHED;
                        exh->method = jd->m;
@@ -967,7 +1093,7 @@ void fix_exception_handlers(jitdata *jd) {
                        /* Get exception */
 
                        iptr->opc = ICMD_GETEXCEPTION;
-                       iptr->dst.varindex = v;
+                       iptr->dst.varindex = exh->outvars[exh->outdepth - 1];
                        iptr += 1;
 
                        /* Goto real exception handler */
@@ -986,6 +1112,19 @@ void fix_exception_handlers(jitdata *jd) {
                }
        }
 
+       /* We need to allocate the new iovars in the var array */
+
+       avail_vars = (jd->varcount - jd->vartop);
+       add_vars = (vartop - jd->vartop);
+
+       if (add_vars > avail_vars) {
+               add_vars -= avail_vars;
+               jd->var = DMREALLOC(jd->var, varinfo, jd->varcount, jd->varcount + add_vars);
+               jd->varcount += add_vars;
+       }
+
+       jd->vartop = vartop;
+
        /* Put the chain of exception handlers between just before the last
           basic block (end marker). */
 
@@ -1003,9 +1142,68 @@ void fix_exception_handlers(jitdata *jd) {
 
        for (ee = jd->exceptiontable; ee; ee = ee->down) {
                assert(ee->handler->vp);
-               ee->handler = ee->handler->vp;
+
+               bptr = ee->handler;
+               exh = (basicblock *)ee->handler->vp;
+
+               ee->handler = exh;
+
+               /* Set up IO variables in newly craeted exception handlers. */
+
+               for (i = 0; i < exh->outdepth; ++i) {
+                       v = exh->outvars[i];
+
+                       jd->var[v].flags = INOUT;
+                       jd->var[v].type = jd->var[ bptr->invars[i] ].type;
+               }
+       }
+
+}
+
+void unfix_exception_handlers(jitdata *jd) {
+       basicblock *bptr, *exh;
+       unsigned i;
+       exception_entry *ee;
+#if !defined(NDEBUG)
+       bool found = false;
+#endif
+
+       FOR_EACH_BASICBLOCK(jd, bptr) {
+               if (bptr->type == BBTYPE_EXH) {
+                       assert(bptr->iinstr[1].opc == ICMD_GOTO);
+                       exh = bptr->iinstr[1].dst.block;
+
+                       bptr->type = BBDELETED;
+                       bptr->icount = 0;
+                       bptr->indepth = 0;
+                       bptr->outdepth = 0;
+                       exh->type = BBTYPE_EXH;
+                       bptr->vp = exh;
+               
+                       /* bptr is no more a predecessor of exh */
+
+                       for (i = 0; i < exh->predecessorcount; ++i) {
+                               if (exh->predecessors[i] == bptr) {
+                                       exh->predecessors[i] = exh->predecessors[exh->predecessorcount - 1];
+                                       exh->predecessorcount -= 1;
+#if !defined(NDEBUG)
+                                       found = true;
+#endif
+                                       break;
+                               }
+                       }
+
+                       assert(found);
+
+               } else {
+                       bptr->vp = NULL;
+               }
        }
 
+       for (ee = jd->exceptiontable; ee; ee = ee->down) {
+               assert(ee->handler->vp);
+               ee->handler = ee->handler->vp;
+       }
 }
 
 /*** ssa_enter ***************************************************************/
@@ -1119,6 +1317,10 @@ static void ssa_enter_verify_no_redundant_phis(ssa_info_t *ssa) {
        basicblock *bptr;
        basicblock_info_t *bbi;
        instruction *itph;
+
+       /* XXX */
+       return;
+
        FOR_EACH_BASICBLOCK(ssa->jd, bptr) {
                if (basicblock_reached(bptr)) {
                        bbi = bb_info(bptr);
@@ -1241,6 +1443,14 @@ static void ssa_enter_process_pei(ssa_info *ssa, basicblock *bb, unsigned pei) {
                        basicblock_get_ex_predecessor_index(bb, pei, *itsucc),
                        ssa->locals
                );
+
+               ssa_enter_merge(
+                       bbi->stack,
+                       succi->stack,
+                       *itsucc,
+                       basicblock_get_ex_predecessor_index(bb, pei, *itsucc),
+                       ssa->stack
+               );
        }
 }
 
@@ -1249,6 +1459,9 @@ static FIXME(bool) ssa_enter_eliminate_redundant_phis(traversal_t *t, vars_t *vs
        instruction *itph;
        bool ret = false;
 
+       /* XXX */
+       return;
+
        FOR_EACH_PHI_FUNCTION(t->phis, itph) {
 
                phi_calculate_redundancy(itph);
@@ -1346,23 +1559,33 @@ static void ssa_enter_process_block(ssa_info *ssa, basicblock *bb) {
                state_array_allocate_items(bbi->stack->state_array);
        }
 
+#if 0
        /* Exception handlers have a clean stack. */
 
+       /* Not true with inlining. */
+
        if (bb->type == BBTYPE_EXH) {
                state_array_assert_no_items(bbi->stack->state_array);
                state_array_allocate_items(bbi->stack->state_array);
        }
+#endif
 
        /* Some in/out vars get marked as INOUT in simplereg,
           and are not marked at this point. 
           Mark them manually. */
 
        for (ituse = bb->invars; ituse != bb->invars + bb->indepth; ++ituse) {
+               if (ssa->keep_in_out && ssa->jd->var[*ituse].type == TYPE_RET) {
+                       continue;
+               }
                ssa->jd->var[*ituse].flags |= INOUT;
                ssa->jd->var[*ituse].flags &= ~PREALLOC;
        }
 
        for (ituse = bb->outvars; ituse != bb->outvars + bb->outdepth; ++ituse) {
+               if (ssa->keep_in_out && ssa->jd->var[*ituse].type == TYPE_RET) {
+                       continue;
+               }
                ssa->jd->var[*ituse].flags |= INOUT;
                ssa->jd->var[*ituse].flags &= ~PREALLOC;
        }
@@ -1404,11 +1627,13 @@ static void ssa_enter_process_block(ssa_info *ssa, basicblock *bb) {
                        if (var_is_local(ssa->jd, *ituse)) {
                                traversal_rename_use(
                                        bbi->locals, 
+                                       ssa->locals,
                                        ituse
                                );
                        } else if (var_is_inout(ssa->jd, *ituse)) {
                                traversal_rename_use(
                                        bbi->stack,
+                                       ssa->stack,
                                        ituse
                                );
                        } else {
@@ -1437,6 +1662,7 @@ static void ssa_enter_process_block(ssa_info *ssa, basicblock *bb) {
                                        ssa->others,
                                        ssa->jd->var + iptr->dst.varindex
                                );
+                               vars_record_old_index(ssa->others, iptr->dst.varindex, old);
                                others_mapping_set(ssa, old, iptr->dst.varindex);
                        }
                }
@@ -1456,6 +1682,7 @@ static void ssa_enter_export_variables(ssa_info *ssa) {
        s4 *it;
        unsigned i, j;
        jitdata *jd = ssa->jd;
+       s4 *local_map;
 
        vartop = ssa->locals->count + ssa->stack->count + ssa->others->count;
        vars = DMNEW(varinfo, vartop);
@@ -1470,13 +1697,15 @@ static void ssa_enter_export_variables(ssa_info *ssa) {
        /* Grow local map to accomodate all new locals and iovars.
           But keep the local map for version 1 of locals, that contains the holes. */
        
-       jd->local_map = DMREALLOC(
-               jd->local_map, 
-               s4, 
-               5 * jd->maxlocals, 
+       local_map = DMNEW(
+               s4,
                5 * (jd->maxlocals + ssa->locals->count + ssa->stack->count - jd->localcount)
        );
 
+       MCOPY(local_map, jd->local_map, s4, 5 * jd->maxlocals);
+
+       jd->local_map = local_map;
+
        it = jd->local_map + (jd->maxlocals * 5); /* start adding entries here */
 
        /* Add version > 1 of all locals */
@@ -1524,19 +1753,15 @@ static void ssa_enter_export_phis(ssa_info_t *ssa) {
        FOR_EACH_BASICBLOCK(ssa->jd, bptr) {
                bbi = bb_info(bptr);
                if (bbi != NULL) {
-                       bptr->phicount = 
-                               bbi->locals->phis->count + 
-                               bbi->stack->phis->count;
-
-                       bptr->phis = DMNEW(instruction, bptr->phicount);
+                       bptr->phis = DMNEW(instruction, bbi->locals->phis->count + bbi->stack->phis->count);
 
                        dst = bptr->phis;
 
-                       phis_copy_to(bbi->locals->phis, dst);
+                       dst += phis_copy_to(bbi->locals->phis, dst);
 
-                       dst += bbi->locals->phis->count;
+                       dst += phis_copy_to(bbi->stack->phis, dst);
 
-                       phis_copy_to(bbi->stack->phis, dst);
+                       bptr->phicount = dst - bptr->phis;
                }
        }
 }
@@ -1569,8 +1794,10 @@ void ssa_enter_eliminate_categories(ssa_info_t *ssa) {
 
                bbi = bb_info(bb);
 
-               bb->indepth = 0;
-               bb->outdepth = 0;
+               if (! ssa->keep_in_out) {
+                       bb->indepth = 0;
+                       bb->outdepth = 0;
+               }
 
                if (bbi != NULL) {
                        FOR_EACH_PHI_FUNCTION(bbi->locals->phis, itph) {
@@ -2055,20 +2282,115 @@ static void ssa_leave_create_exceptional_phi_moves(ssa_info *ssa) {
        }
 }
 
+void ssa_simple_leave_restore(ssa_info_t *ssa, basicblock *bptr, s4 *pvar) {
+       s4 var = *pvar;
+       s4 index;
+       basicblock_info_t *bbi;
+
+       if (var < ssa->locals->count) {
+               *pvar = vars_get_old_index(ssa->locals, var);
+       } else if (var < ssa->locals->count + ssa->stack->count) {
+
+               index = vars_get_old_index(
+                       ssa->stack,
+                       var - ssa->locals->count
+               );
+
+               bbi = bb_info(bptr);
+
+               /* We have to determine whether to take an invar or an outvar for
+                  the stack depth ``index''.
+                  The state array contains the last definition of the stack element
+                  at the given depth.
+               */
+
+               if (state_array_get_var(bbi->stack->state_array, index) == var) {
+                       /* The last definition of a stack depth inside the basicblock.
+                          This is the outvar at the given depth.
+                          If there is no outvar at the given depth, it must be an invar.
+                       */
+                       if (index < bptr->outdepth) {
+                               *pvar = bptr->outvars[index];
+                       } else if (index < bptr->indepth) {
+                               *pvar = bptr->invars[index];
+                       } else {
+                               assert(0);
+                       }
+               } else {
+                       /* A different than the last definition of a stack depth.
+                          This must be an invar.
+                       */
+                       assert(index < bptr->indepth);
+                       *pvar = bptr->invars[index];
+               }
+       } else {
+               *pvar = vars_get_old_index(
+                       ssa->others,
+                       var - ssa->locals->count - ssa->stack->count
+               );
+       }
+}
+
+void ssa_simple_leave(ssa_info_t *ssa) {
+       basicblock *bptr;
+       instruction *iptr;
+       s4 *ituse, *uses;
+       unsigned uses_count;
+
+       FOR_EACH_BASICBLOCK(ssa->jd, bptr) {
+               if (bptr->type == BBTYPE_EXH) {
+                       /* (Aritifical) exception handler blocks will be eliminated. */
+                       continue;
+               }
+               /* In reverse order. We need to rename the definition after any use! */
+               FOR_EACH_INSTRUCTION_REV(bptr, iptr) {
+                       if (instruction_has_dst(iptr)) {
+                               ssa_simple_leave_restore(ssa, bptr, &(iptr->dst.varindex));
+                       }
+                       instruction_get_uses(iptr, ssa->s_buf, &uses, &uses_count);
+                       for (ituse = uses; ituse != uses + uses_count; ++ituse) {
+                               ssa_simple_leave_restore(ssa, bptr, ituse);
+                       }
+                       instruction_set_uses(iptr, ssa->s_buf, uses, uses_count);
+               }
+               bptr->phicount = 0;
+       }
+
+       unfix_exception_handlers(ssa->jd);
+
+       ssa->jd->maxlocals = ssa->original.maxlocals;
+       ssa->jd->maxinterfaces = ssa->original.maxinterfaces;
+       ssa->jd->local_map =ssa->original.local_map;
+       ssa->jd->var = ssa->original.var;
+       ssa->jd->vartop = ssa->original.vartop;
+       ssa->jd->varcount = ssa->original.varcount;
+       ssa->jd->localcount = ssa->original.localcount;
+}
+
+#include "vm/rt-timing.h"
+
 void yssa(jitdata *jd) {
        basicblock *it;
        basicblock_info_t *iti;
        ssa_info *ssa;
 
+       struct timespec bs, es, be, ee;
+
+       RT_TIMING_GET_TIME(bs);
+
 #ifdef SSA_VERBOSE
-       printf("=============== [ before %s ] =========================\n", jd->m->name->text);
-       show_method(jd, 3);
-       printf("=============== [ /before ] =========================\n");
+       bool verb = true;
+       if (verb) {
+               printf("=============== [ before %s ] =========================\n", jd->m->name->text);
+               show_method(jd, 3);
+               printf("=============== [ /before ] =========================\n");
+       }
 #endif
 
        ssa = DNEW(ssa_info);
 
        ssa_info_init(ssa, jd);
+       ssa->keep_in_out = true;
 
        FOR_EACH_BASICBLOCK(jd, it) {
                if (basicblock_reached(it)) {
@@ -2094,18 +2416,38 @@ void yssa(jitdata *jd) {
 
        /*ssa_enter_create_phi_graph(ssa);*/
 
+       RT_TIMING_GET_TIME(be);
        escape_analysis_perform(ssa->jd);
+       RT_TIMING_GET_TIME(ee);
 
+       /*
        ssa_leave_create_phi_moves(ssa);
 
        ssa_leave_create_exceptional_phi_moves(ssa);
+       */
+       
+#ifdef SSA_VERBOSE
+       if (verb) {
+               printf("=============== [ mid ] =========================\n");
+               show_method(jd, 3);
+               printf("=============== [ /mid ] =========================\n");
+       }
+#endif
+
+       ssa_simple_leave(ssa);
 
 #ifdef SSA_VERBOSE
-       printf("=============== [ after ] =========================\n");
-       show_method(jd, 3);
-       printf("=============== [ /after ] =========================\n");
+       if (verb) {
+               printf("=============== [ after ] =========================\n");
+               show_method(jd, 3);
+               printf("=============== [ /after ] =========================\n");
+       }
 #endif
 
+       RT_TIMING_GET_TIME(es);
+
+       RT_TIMING_TIME_DIFF(bs, es, RT_TIMING_1);
+       RT_TIMING_TIME_DIFF(be, ee, RT_TIMING_2);
 }
 
 void eliminate_subbasicblocks(jitdata *jd) {
index 9ab4f6c29a34f2f1ccfc96f58a3765f1cc0b3722..e79b1654d7be1452270a65c824c339a069977198 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/optimizing/ssa.c - static single-assignment form
 
-   Copyright (C) 2005 - 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) 2005-2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    02111-1307, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Christian Ullrich
+*/
 
-   $Id: $
 
-*/
+#include "config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 #include "toolbox/bitvector.h"
 #include "toolbox/worklist.h"
 
-#include "vm/builtin.h"
+#include "vm/jit/builtin.hpp"
 
-#include "vm/jit/jit.h" /* icmd_table */
+#include "vm/jit/jit.hpp" /* icmd_table */
 
-#include "vm/jit/optimizing/dominators.h"
+#include "vm/jit/optimizing/dominators.hpp"
 #include "vm/jit/optimizing/graph.h"
 #include "vm/jit/optimizing/lifetimes.h"
 #include "vm/jit/optimizing/lsra.h"
@@ -50,7 +45,7 @@
 #include "vm/jit/optimizing/ssa_phi.h"
 
 #if defined(SSA_DEBUG_VERBOSE)
-#include "vmcore/options.h"   /* compileverbose */
+#include "vm/options.h"   /* compileverbose */
 #endif
 
 /* ssa_place_phi_functions *****************************************************
index 474419c1235240a7171260a217e5dab27a18f23d..87fdd130f76934a7e717f966a38113915dfb6158 100644 (file)
 #include "toolbox/bitvector.h"
 #include "toolbox/worklist.h"
 
-#include "vm/builtin.h"
+#include "vm/jit/builtin.hpp"
 
-#include "vm/jit/jit.h" /* icmd_table */
+#include "vm/jit/jit.hpp" /* icmd_table */
 
-#include "vm/jit/optimizing/dominators.h"
+#include "vm/jit/optimizing/dominators.hpp"
 #include "vm/jit/optimizing/graph.h"
 #include "vm/jit/optimizing/lifetimes.h"
 #include "vm/jit/optimizing/lsra.h"
@@ -45,7 +45,7 @@
 #include "vm/jit/optimizing/ssa_rename.h"
 
 #if defined(SSA_DEBUG_VERBOSE)
-#include "vmcore/options.h"   /* compileverbose */
+#include "vm/options.h"   /* compileverbose */
 #endif
 
 /* function prototypes */
index 6b99040fbb0b3c880db694b9dedbd9b56d62cb78..083470a3f6f567a778f6e00015103ffa53e60297 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/parisc/arch.h - architecture defines for PA-RISC
 
-   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.
 
@@ -33,8 +31,6 @@
 
 /* define architecture features ***********************************************/
 
-#define U8_AVAILABLE                     1
-
 /*  #define USEBUILTINTABLE */
 
 #define SUPPORT_DIVISION                 0
@@ -95,8 +91,6 @@
 #endif
 
 
-#define USE_FAKE_ATOMIC_INSTRUCTIONS     1
-
 /* replacement ****************************************************************/
 
 #define REPLACEMENT_PATCH_SIZE           4  /* bytes */
diff --git a/src/vm/jit/parse.c b/src/vm/jit/parse.c
deleted file mode 100644 (file)
index db707e7..0000000
+++ /dev/null
@@ -1,1938 +0,0 @@
-/* src/vm/jit/parse.c - parser for JavaVM to intermediate code translation
-
-   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 <string.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/native.h"
-
-#include "threads/lock-common.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/stringlocal.h"
-
-#include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/loop/loop.h"
-
-#include "vm/jit/ir/bytecode.h"
-
-#include "vmcore/linker.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vm/resolve.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
-#include "vmcore/suck.h"
-
-#define INSTRUCTIONS_INCREMENT  5  /* number of additional instructions to    */
-                                   /* allocate if space runs out              */
-
-
-/* local macros ***************************************************************/
-
-#define BYTECODEINDEX_TO_BASICBLOCK(dst) \
-    do { \
-        (dst).block = \
-            parse_bytecodeindex_to_basicblock(jd, &pd, (dst).insindex); \
-    } while (0)
-
-
-/* parserdata_t ***************************************************************/
-
-typedef struct parsedata_t parsedata_t;
-
-struct parsedata_t {
-       u1          *bytecodestart;         /* start of bytecode instructions     */
-       u1          *basicblockstart;       /* start of bytecode basic-blocks     */
-
-       s4          *bytecodemap;           /* bytecode to IR mapping             */
-       
-       instruction *instructions;          /* instruction array                  */
-       s4           instructionslength;    /* length of the instruction array    */
-
-       s4          *instructionmap;        /* IR to basic-block mapping          */
-};
-
-
-/* parse_setup *****************************************************************
-
-   Fills the passed parsedata_t structure.
-
-*******************************************************************************/
-
-static void parse_setup(jitdata *jd, parsedata_t *pd)
-{
-       methodinfo *m;
-
-       /* get required compiler data */
-
-       m = jd->m;
-
-       /* bytecode start array */
-
-       pd->bytecodestart = DMNEW(u1, m->jcodelength + 1);
-       MZERO(pd->bytecodestart, u1, m->jcodelength + 1);
-
-       /* bytecode basic-block start array */
-
-       pd->basicblockstart = DMNEW(u1, m->jcodelength + 1);
-       MZERO(pd->basicblockstart, u1, m->jcodelength + 1);
-
-       /* bytecode instruction index to IR instruction mapping */
-
-       pd->bytecodemap = DMNEW(s4, m->jcodelength + 1);
-       MSET(pd->bytecodemap, -1, s4, m->jcodelength + 1);
-
-       /* allocate the instruction array */
-
-       pd->instructionslength = m->jcodelength + 1;
-       pd->instructions = DMNEW(instruction, pd->instructionslength);
-
-       /* Zero the intermediate instructions array so we don't have any
-          invalid pointers in it if we cannot finish stack_analyse(). */
-
-       MZERO(pd->instructions, instruction, pd->instructionslength);
-
-       /* The instructionmap is allocated later when we know the count of
-          instructions. */
-
-       pd->instructionmap = NULL;
-}
-
-
-/* parse_realloc_instructions **************************************************
-
-   Reallocate the instructions array so there is room for at least N 
-   additional instructions.
-
-   RETURN VALUE:
-       the new value for iptr
-
-*******************************************************************************/
-
-static instruction *parse_realloc_instructions(parsedata_t *pd, s4 icount, s4 n)
-{
-       /* increase the size of the instruction array */
-
-       pd->instructionslength += (n + INSTRUCTIONS_INCREMENT);
-
-       /* reallocate the array */
-
-       pd->instructions = DMREALLOC(pd->instructions, instruction, icount,
-                                                                pd->instructionslength);
-       MZERO(pd->instructions + icount, instruction,
-                 (pd->instructionslength - icount));
-
-       /* return the iptr */
-
-       return pd->instructions + icount;
-}
-
-
-/* parse_bytecodeindex_to_basicblock *******************************************
-
-   Resolves a bytecode index to the corresponding basic block.
-
-*******************************************************************************/
-
-static basicblock *parse_bytecodeindex_to_basicblock(jitdata *jd,
-                                                                                                        parsedata_t *pd,
-                                                                                                        s4 bcindex)
-{
-       s4          irindex;
-       basicblock *bb;
-
-       irindex = pd->bytecodemap[bcindex];
-       bb      = jd->basicblocks + pd->instructionmap[irindex];
-
-       return bb;
-}
-
-
-/* parse_mark_exception_boundaries *********************************************
-
-   Mark exception handlers and the boundaries of the handled regions as
-   basic block boundaries.
-
-   IN:
-       jd...............current jitdata
-
-   RETURN VALUE:
-       true.............everything ok
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-static bool parse_mark_exception_boundaries(jitdata *jd, parsedata_t *pd)
-{
-       s4                   bcindex;
-       s4                   i;
-       s4                   len;
-       raw_exception_entry *rex;
-       methodinfo          *m;
-
-       m = jd->m;
-       
-       len = m->rawexceptiontablelength;
-
-       if (len == 0)
-               return true;
-
-       rex = m->rawexceptiontable;
-
-       for (i = 0; i < len; ++i, ++rex) {
-
-               /* the start of the handled region becomes a basic block start */
-
-               bcindex = rex->startpc;
-               CHECK_BYTECODE_INDEX(bcindex);
-               MARK_BASICBLOCK(pd, bcindex);
-               
-               bcindex = rex->endpc; /* see JVM Spec 4.7.3 */
-               CHECK_BYTECODE_INDEX_EXCLUSIVE(bcindex);
-
-               /* check that the range is valid */
-
-#if defined(ENABLE_VERIFIER)
-               if (bcindex <= rex->startpc) {
-                       exceptions_throw_verifyerror(m, "Invalid exception handler range");
-                       return false;
-               }
-#endif
-               
-               /* End of handled region becomes a basic block boundary (if it
-                  is the bytecode end, we'll use the special end block that
-                  is created anyway). */
-
-               if (bcindex < m->jcodelength)
-                       MARK_BASICBLOCK(pd, bcindex);
-               else
-                       jd->branchtoend = true;
-
-               /* the start of the handler becomes a basic block start  */
-
-               bcindex = rex->handlerpc;
-               CHECK_BYTECODE_INDEX(bcindex);
-               MARK_BASICBLOCK(pd, bcindex);
-       }
-
-       /* everything ok */
-
-       return true;
-
-#if defined(ENABLE_VERIFIER)
-throw_invalid_bytecode_index:
-       exceptions_throw_verifyerror(m,
-                                                                "Illegal bytecode index in exception table");
-       return false;
-#endif
-}
-
-
-/* parse_resolve_exception_table ***********************************************
-
-   Enter the exception handlers and their ranges, resolved to basicblock *s,
-   in the jitdata.
-
-   IN:
-       jd...............current jitdata
-
-   RETURN VALUE:
-          true.............everything ok
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-static bool parse_resolve_exception_table(jitdata *jd, parsedata_t *pd)
-{
-       methodinfo          *m;
-       raw_exception_entry *rex;
-       exception_entry     *ex;
-       s4                   i;
-       s4                   len;
-       classinfo           *exclass;
-
-       m = jd->m;
-
-       len = m->rawexceptiontablelength;
-
-       /* common case: no handler entries */
-
-       if (len == 0)
-               return true;
-
-       /* allocate the exception table */
-
-       jd->exceptiontablelength = len;
-       jd->exceptiontable = DMNEW(exception_entry, len + 1); /* XXX why +1? */
-
-       /* copy and resolve the entries */
-
-       ex = jd->exceptiontable;
-       rex = m->rawexceptiontable;
-
-       for (i = 0; i < len; ++i, ++rex, ++ex) {
-               /* resolve instruction indices to basic blocks */
-
-               ex->start   = parse_bytecodeindex_to_basicblock(jd, pd, rex->startpc);
-               ex->end     = parse_bytecodeindex_to_basicblock(jd, pd, rex->endpc);
-               ex->handler = parse_bytecodeindex_to_basicblock(jd, pd, rex->handlerpc);
-
-               /* lazily resolve the catchtype */
-
-               if (rex->catchtype.any != NULL) {
-                       if (!resolve_classref_or_classinfo(m,
-                                                                                          rex->catchtype,
-                                                                                          resolveLazy, true, false,
-                                                                                          &exclass))
-                               return false;
-
-                       /* if resolved, enter the result of resolution in the table */
-
-                       if (exclass != NULL)
-                               rex->catchtype.cls = exclass;
-               }
-
-               ex->catchtype = rex->catchtype;
-               ex->next = NULL;   /* set by loop analysis */
-               ex->down = ex + 1; /* link to next exception entry */
-       }
-
-       /* terminate the ->down linked list */
-
-       assert(ex != jd->exceptiontable);
-       ex[-1].down = NULL;
-
-       return true;
-}
-
-
-/*******************************************************************************
-
-       function 'parse' scans the JavaVM code and generates intermediate code
-
-       During parsing the block index table is used to store at bit pos 0
-       a flag which marks basic block starts and at position 1 to 31 the
-       intermediate instruction index. After parsing the block index table
-       is scanned, for marked positions a block is generated and the block
-       number is stored in the block index table.
-
-*******************************************************************************/
-
-/*** macro for checking the length of the bytecode ***/
-
-#if defined(ENABLE_VERIFIER)
-#define CHECK_END_OF_BYTECODE(neededlength) \
-       do { \
-               if ((neededlength) > m->jcodelength) \
-                       goto throw_unexpected_end_of_bytecode; \
-       } while (0)
-#else /* !ENABLE_VERIFIER */
-#define CHECK_END_OF_BYTECODE(neededlength)
-#endif /* ENABLE_VERIFIER */
-
-bool parse(jitdata *jd)
-{
-       methodinfo  *m;                     /* method being parsed                */
-       codeinfo    *code;
-       parsedata_t  pd;
-       instruction *iptr;                  /* current ptr into instruction array */
-
-       s4           bcindex;               /* bytecode instruction index         */
-       s4           nextbc;                /* start of next bytecode instruction */
-       s4           opcode;                /* bytecode instruction opcode        */
-
-       s4           irindex;               /* IR instruction index               */
-       s4           ircount;               /* IR instruction count               */
-
-       s4           bbcount;               /* basic block count                  */
-
-       int  s_count = 0;             /* stack element counter                    */
-       bool blockend;                /* true if basic block end has been reached */
-       bool iswide;                  /* true if last instruction was a wide      */
-
-       constant_classref  *cr;
-       constant_classref  *compr;
-       classinfo          *c;
-       builtintable_entry *bte;
-       constant_FMIref    *fmi;
-       methoddesc         *md;
-       unresolved_method  *um;
-       unresolved_field   *uf;
-
-       resolve_result_t    result;
-       u2                  lineindex = 0;
-       u2                  currentline = 0;
-       u2                  linepcchange = 0;
-       u4                  flags;
-       basicblock         *bptr;
-
-       int                *local_map; /* local pointer to renaming map           */
-                                      /* is assigned to rd->local_map at the end */
-       branch_target_t *table;
-       lookup_target_t *lookup;
-       s4               i;
-       s4               j;
-
-       /* get required compiler data */
-
-       m    = jd->m;
-       code = jd->code;
-
-       /* allocate buffers for local variable renaming */
-
-       local_map = DMNEW(int, m->maxlocals * 5);
-
-       for (i = 0; i < m->maxlocals; i++) {
-               local_map[i * 5 + 0] = 0;
-               local_map[i * 5 + 1] = 0;
-               local_map[i * 5 + 2] = 0;
-               local_map[i * 5 + 3] = 0;
-               local_map[i * 5 + 4] = 0;
-       }
-
-       /* initialize the parse data structures */
-  
-       parse_setup(jd, &pd);
-  
-       /* initialize local variables */
-  
-       iptr     = pd.instructions;
-       ircount  = 0;
-       bbcount  = 0;
-       blockend = false;
-       iswide   = false;
-
-       /* mark basic block boundaries for exception table */
-
-       if (!parse_mark_exception_boundaries(jd, &pd))
-               return false;
-
-       /* initialize stack element counter */
-
-       s_count = 1 + m->rawexceptiontablelength;
-
-       /* setup line number info */
-
-       currentline = 0;
-       linepcchange = 0;
-
-       if (m->linenumbercount == 0) {
-               lineindex = 0;
-       }
-       else {
-               linepcchange = m->linenumbers[0].start_pc;
-       }
-
-       /*** LOOP OVER ALL BYTECODE INSTRUCTIONS **********************************/
-
-       for (bcindex = 0; bcindex < m->jcodelength; bcindex = nextbc) {
-
-               /* mark this position as a valid bytecode instruction start */
-
-               pd.bytecodestart[bcindex] = 1;
-
-               /* change the current line number, if necessary */
-
-               /* XXX rewrite this using pointer arithmetic */
-
-               if (linepcchange == bcindex) {
-                       if (m->linenumbercount > lineindex) {
-next_linenumber:
-                               currentline = m->linenumbers[lineindex].line_number;
-                               lineindex++;
-                               if (lineindex < m->linenumbercount) {
-                                       linepcchange = m->linenumbers[lineindex].start_pc;
-                                       if (linepcchange == bcindex)
-                                               goto next_linenumber;
-                               }
-                       }
-               }
-
-fetch_opcode:
-               /* fetch next opcode  */        
-
-               opcode = SUCK_BE_U1(m->jcode + bcindex);
-
-               /* If the previous instruction was a block-end instruction,
-                  mark the current bytecode instruction as basic-block
-                  starting instruction. */
-
-               /* NOTE: Some compilers put a BC_nop after a blockend
-                  instruction. */
-
-               if (blockend && (opcode != BC_nop)) {
-                       MARK_BASICBLOCK(&pd, bcindex);
-                       blockend = false;
-               }
-
-               /* If the current bytecode instruction was marked as
-                  basic-block starting instruction before (e.g. blockend,
-                  forward-branch target), mark the current IR instruction
-                  too. */
-
-               if (pd.basicblockstart[bcindex] != 0) {
-                       /* We need a NOP as last instruction in each basic block
-                          for basic block reordering (may be replaced with a GOTO
-                          later). */
-
-                       INSTRUCTIONS_CHECK(1);
-                       OP(ICMD_NOP);
-               }
-
-               /* store intermediate instruction count (bit 0 mark block starts) */
-
-               pd.bytecodemap[bcindex] = ircount;
-
-               /* compute next instruction start */
-
-               nextbc = bcindex + bytecode[opcode].length;
-
-               CHECK_END_OF_BYTECODE(nextbc);
-
-               /* add stack elements produced by this instruction */
-
-               s_count += bytecode[opcode].slots;
-
-               /* We check here for the space of 1 instruction in the
-                  instruction array.  If an opcode is converted to more than
-                  1 instruction, this is checked in the corresponding
-                  case. */
-
-               INSTRUCTIONS_CHECK(1);
-
-               /* translate this bytecode instruction */
-               switch (opcode) {
-
-               case BC_nop:
-                       break;
-
-               /* pushing constants onto the stack ***********************************/
-
-               case BC_bipush:
-                       OP_LOADCONST_I(SUCK_BE_S1(m->jcode + bcindex + 1));
-                       break;
-
-               case BC_sipush:
-                       OP_LOADCONST_I(SUCK_BE_S2(m->jcode + bcindex + 1));
-                       break;
-
-               case BC_ldc1:
-                       i = SUCK_BE_U1(m->jcode + bcindex + 1);
-                       goto pushconstantitem;
-
-               case BC_ldc2:
-               case BC_ldc2w:
-                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-
-               pushconstantitem:
-
-#if defined(ENABLE_VERIFIER)
-                       if (i >= m->clazz->cpcount) {
-                               exceptions_throw_verifyerror(m,
-                                       "Attempt to access constant outside range");
-                               return false;
-                       }
-#endif
-
-                       switch (m->clazz->cptags[i]) {
-                       case CONSTANT_Integer:
-                               OP_LOADCONST_I(((constant_integer *) (m->clazz->cpinfos[i]))->value);
-                               break;
-                       case CONSTANT_Long:
-                               OP_LOADCONST_L(((constant_long *) (m->clazz->cpinfos[i]))->value);
-                               break;
-                       case CONSTANT_Float:
-                               OP_LOADCONST_F(((constant_float *) (m->clazz->cpinfos[i]))->value);
-                               break;
-                       case CONSTANT_Double:
-                               OP_LOADCONST_D(((constant_double *) (m->clazz->cpinfos[i]))->value);
-                               break;
-                       case CONSTANT_String:
-                               OP_LOADCONST_STRING(literalstring_new((utf *) (m->clazz->cpinfos[i])));
-                               break;
-                       case CONSTANT_Class:
-                               cr = (constant_classref *) (m->clazz->cpinfos[i]);
-
-                               if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
-                                       return false;
-
-                               /* if not resolved, c == NULL */
-
-                               OP_LOADCONST_CLASSINFO_OR_CLASSREF_CHECK(c, cr);
-
-                               break;
-
-#if defined(ENABLE_VERIFIER)
-                       default:
-                               exceptions_throw_verifyerror(m,
-                                               "Invalid constant type to push");
-                               return false;
-#endif
-                       }
-                       break;
-
-               case BC_aconst_null:
-                       OP_LOADCONST_NULL();
-                       break;
-
-               case BC_iconst_m1:
-               case BC_iconst_0:
-               case BC_iconst_1:
-               case BC_iconst_2:
-               case BC_iconst_3:
-               case BC_iconst_4:
-               case BC_iconst_5:
-                       OP_LOADCONST_I(opcode - BC_iconst_0);
-                       break;
-
-               case BC_lconst_0:
-               case BC_lconst_1:
-                       OP_LOADCONST_L(opcode - BC_lconst_0);
-                       break;
-
-               case BC_fconst_0:
-               case BC_fconst_1:
-               case BC_fconst_2:
-                       OP_LOADCONST_F(opcode - BC_fconst_0);
-                       break;
-
-               case BC_dconst_0:
-               case BC_dconst_1:
-                       OP_LOADCONST_D(opcode - BC_dconst_0);
-                       break;
-
-               /* stack operations ***************************************************/
-
-               /* We need space for additional instruction so we can
-                  translate these instructions to sequences of ICMD_COPY and
-                  ICMD_MOVE instructions. */
-
-               case BC_dup_x1:
-                       INSTRUCTIONS_CHECK(4);
-                       OP(opcode);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       break;
-
-               case BC_dup_x2:
-                       INSTRUCTIONS_CHECK(6);
-                       OP(opcode);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       break;
-
-               case BC_dup2:
-                       INSTRUCTIONS_CHECK(2);
-                       OP(opcode);
-                       OP(ICMD_NOP);
-                       break;
-
-               case BC_dup2_x1:
-                       INSTRUCTIONS_CHECK(7);
-                       OP(opcode);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       break;
-
-               case BC_dup2_x2:
-                       INSTRUCTIONS_CHECK(9);
-                       OP(opcode);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       break;
-
-               case BC_swap:
-                       INSTRUCTIONS_CHECK(3);
-                       OP(opcode);
-                       OP(ICMD_NOP);
-                       OP(ICMD_NOP);
-                       break;
-
-               /* local variable access instructions *********************************/
-
-               case BC_iload:
-               case BC_fload:
-               case BC_aload:
-                       if (iswide == false) {
-                               i = SUCK_BE_U1(m->jcode + bcindex + 1);
-                       }
-                       else {
-                               i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                               nextbc = bcindex + 3;
-                               iswide = false;
-                       }
-                       OP_LOAD_ONEWORD(opcode, i, opcode - BC_iload);
-                       break;
-
-               case BC_lload:
-               case BC_dload:
-                       if (iswide == false) {
-                               i = SUCK_BE_U1(m->jcode + bcindex + 1);
-                       }
-                       else {
-                               i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                               nextbc = bcindex + 3;
-                               iswide = false;
-                       }
-                       OP_LOAD_TWOWORD(opcode, i, opcode - BC_iload);
-                       break;
-
-               case BC_iload_0:
-               case BC_iload_1:
-               case BC_iload_2:
-               case BC_iload_3:
-                       OP_LOAD_ONEWORD(ICMD_ILOAD, opcode - BC_iload_0, TYPE_INT);
-                       break;
-
-               case BC_lload_0:
-               case BC_lload_1:
-               case BC_lload_2:
-               case BC_lload_3:
-                       OP_LOAD_TWOWORD(ICMD_LLOAD, opcode - BC_lload_0, TYPE_LNG);
-                       break;
-
-               case BC_fload_0:
-               case BC_fload_1:
-               case BC_fload_2:
-               case BC_fload_3:
-                       OP_LOAD_ONEWORD(ICMD_FLOAD, opcode - BC_fload_0, TYPE_FLT);
-                       break;
-
-               case BC_dload_0:
-               case BC_dload_1:
-               case BC_dload_2:
-               case BC_dload_3:
-                       OP_LOAD_TWOWORD(ICMD_DLOAD, opcode - BC_dload_0, TYPE_DBL);
-                       break;
-
-               case BC_aload_0:
-               case BC_aload_1:
-               case BC_aload_2:
-               case BC_aload_3:
-                       OP_LOAD_ONEWORD(ICMD_ALOAD, opcode - BC_aload_0, TYPE_ADR);
-                       break;
-
-               case BC_istore:
-               case BC_fstore:
-               case BC_astore:
-                       if (iswide == false) {
-                               i = SUCK_BE_U1(m->jcode + bcindex + 1);
-                       }
-                       else {
-                               i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                               nextbc = bcindex + 3;
-                               iswide = false;
-                       }
-                       OP_STORE_ONEWORD(opcode, i, opcode - BC_istore);
-                       break;
-
-               case BC_lstore:
-               case BC_dstore:
-                       if (iswide == false) {
-                               i = SUCK_BE_U1(m->jcode + bcindex + 1);
-                       }
-                       else {
-                               i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                               nextbc = bcindex + 3;
-                               iswide = false;
-                       }
-                       OP_STORE_TWOWORD(opcode, i, opcode - BC_istore);
-                       break;
-
-               case BC_istore_0:
-               case BC_istore_1:
-               case BC_istore_2:
-               case BC_istore_3:
-                       OP_STORE_ONEWORD(ICMD_ISTORE, opcode - BC_istore_0, TYPE_INT);
-                       break;
-
-               case BC_lstore_0:
-               case BC_lstore_1:
-               case BC_lstore_2:
-               case BC_lstore_3:
-                       OP_STORE_TWOWORD(ICMD_LSTORE, opcode - BC_lstore_0, TYPE_LNG);
-                       break;
-
-               case BC_fstore_0:
-               case BC_fstore_1:
-               case BC_fstore_2:
-               case BC_fstore_3:
-                       OP_STORE_ONEWORD(ICMD_FSTORE, opcode - BC_fstore_0, TYPE_FLT);
-                       break;
-
-               case BC_dstore_0:
-               case BC_dstore_1:
-               case BC_dstore_2:
-               case BC_dstore_3:
-                       OP_STORE_TWOWORD(ICMD_DSTORE, opcode - BC_dstore_0, TYPE_DBL);
-                       break;
-
-               case BC_astore_0:
-               case BC_astore_1:
-               case BC_astore_2:
-               case BC_astore_3:
-                       OP_STORE_ONEWORD(ICMD_ASTORE, opcode - BC_astore_0, TYPE_ADR);
-                       break;
-
-               case BC_iinc:
-                       {
-                               int v;
-
-                               if (iswide == false) {
-                                       i = SUCK_BE_U1(m->jcode + bcindex + 1);
-                                       v = SUCK_BE_S1(m->jcode + bcindex + 2);
-                               }
-                               else {
-                                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                                       v = SUCK_BE_S2(m->jcode + bcindex + 3);
-                                       nextbc = bcindex + 5;
-                                       iswide = false;
-                               }
-                               INDEX_ONEWORD(i);
-                               LOCALTYPE_USED(i, TYPE_INT);
-                               OP_LOCALINDEX_I(opcode, i, v);
-                       }
-                       break;
-
-               /* wider index for loading, storing and incrementing ******************/
-
-               case BC_wide:
-                       bcindex++;
-                       iswide = true;
-                       goto fetch_opcode;
-
-               /* managing arrays ****************************************************/
-
-               case BC_newarray:
-                       switch (SUCK_BE_S1(m->jcode + bcindex + 1)) {
-                       case 4:
-                               bte = builtintable_get_internal(BUILTIN_newarray_boolean);
-                               break;
-                       case 5:
-                               bte = builtintable_get_internal(BUILTIN_newarray_char);
-                               break;
-                       case 6:
-                               bte = builtintable_get_internal(BUILTIN_newarray_float);
-                               break;
-                       case 7:
-                               bte = builtintable_get_internal(BUILTIN_newarray_double);
-                               break;
-                       case 8:
-                               bte = builtintable_get_internal(BUILTIN_newarray_byte);
-                               break;
-                       case 9:
-                               bte = builtintable_get_internal(BUILTIN_newarray_short);
-                               break;
-                       case 10:
-                               bte = builtintable_get_internal(BUILTIN_newarray_int);
-                               break;
-                       case 11:
-                               bte = builtintable_get_internal(BUILTIN_newarray_long);
-                               break;
-#if defined(ENABLE_VERIFIER)
-                       default:
-                               exceptions_throw_verifyerror(m, "Invalid array-type to create");
-                               return false;
-#endif
-                       }
-                       OP_BUILTIN_CHECK_EXCEPTION(bte);
-                       break;
-
-               case BC_anewarray:
-                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                       compr = (constant_classref *) class_getconstant(m->clazz, i, CONSTANT_Class);
-                       if (compr == NULL)
-                               return false;
-
-                       if (!(cr = class_get_classref_multiarray_of(1, compr)))
-                               return false;
-
-                       if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
-                               return false;
-
-                       INSTRUCTIONS_CHECK(2);
-                       OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr);
-                       bte = builtintable_get_internal(BUILTIN_newarray);
-                       OP_BUILTIN_CHECK_EXCEPTION(bte);
-                       s_count++;
-                       break;
-
-               case BC_multianewarray:
-                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                       j = SUCK_BE_U1(m->jcode + bcindex + 3);
-  
-                       cr = (constant_classref *) class_getconstant(m->clazz, i, CONSTANT_Class);
-                       if (cr == NULL)
-                               return false;
-  
-                       if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
-                               return false;
-  
-                       /* if unresolved, c == NULL */
-  
-                       iptr->s1.argcount = j;
-                       OP_S3_CLASSINFO_OR_CLASSREF(opcode, c, cr, INS_FLAG_CHECK);
-                       code_unflag_leafmethod(code);
-                       break;
-
-               /* control flow instructions ******************************************/
-
-               case BC_ifeq:
-               case BC_iflt:
-               case BC_ifle:
-               case BC_ifne:
-               case BC_ifgt:
-               case BC_ifge:
-               case BC_ifnull:
-               case BC_ifnonnull:
-               case BC_if_icmpeq:
-               case BC_if_icmpne:
-               case BC_if_icmplt:
-               case BC_if_icmpgt:
-               case BC_if_icmple:
-               case BC_if_icmpge:
-               case BC_if_acmpeq:
-               case BC_if_acmpne:
-               case BC_goto:
-                       i = bcindex + SUCK_BE_S2(m->jcode + bcindex + 1);
-                       CHECK_BYTECODE_INDEX(i);
-                       MARK_BASICBLOCK(&pd, i);
-                       blockend = true;
-                       OP_INSINDEX(opcode, i);
-                       break;
-
-               case BC_goto_w:
-                       i = bcindex + SUCK_BE_S4(m->jcode + bcindex + 1);
-                       CHECK_BYTECODE_INDEX(i);
-                       MARK_BASICBLOCK(&pd, i);
-                       blockend = true;
-                       OP_INSINDEX(ICMD_GOTO, i);
-                       break;
-
-               case BC_jsr:
-                       i = bcindex + SUCK_BE_S2(m->jcode + bcindex + 1);
-jsr_tail:
-                       CHECK_BYTECODE_INDEX(i);
-                       MARK_BASICBLOCK(&pd, i);
-                       blockend = true;
-                       OP_PREPARE_ZEROFLAGS(BC_jsr);
-                       iptr->sx.s23.s3.jsrtarget.insindex = i;
-                       PINC;
-                       break;
-
-               case BC_jsr_w:
-                       i = bcindex + SUCK_BE_S4(m->jcode + bcindex + 1);
-                       goto jsr_tail;
-
-               case BC_ret:
-                       if (iswide == false) {
-                               i = SUCK_BE_U1(m->jcode + bcindex + 1);
-                       }
-                       else {
-                               i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                               nextbc = bcindex + 3;
-                               iswide = false;
-                       }
-                       blockend = true;
-
-                       OP_LOAD_ONEWORD(opcode, i, TYPE_ADR);
-                       break;
-
-               case BC_ireturn:
-               case BC_lreturn:
-               case BC_freturn:
-               case BC_dreturn:
-               case BC_areturn:
-               case BC_return:
-                       blockend = true;
-                       /* XXX ARETURN will need a flag in the typechecker */
-                       OP(opcode);
-                       break;
-
-               case BC_athrow:
-                       blockend = true;
-                       /* XXX ATHROW will need a flag in the typechecker */
-                       OP(opcode);
-                       break;
-
-
-               /* table jumps ********************************************************/
-
-               case BC_lookupswitch:
-                       {
-                               s4 num, j;
-                               lookup_target_t *lookup;
-#if defined(ENABLE_VERIFIER)
-                               s4 prevvalue = 0;
-#endif
-                               blockend = true;
-                               nextbc = MEMORY_ALIGN((bcindex + 1), 4);
-
-                               CHECK_END_OF_BYTECODE(nextbc + 8);
-
-                               OP_PREPARE_ZEROFLAGS(opcode);
-
-                               /* default target */
-
-                               j = bcindex + SUCK_BE_S4(m->jcode + nextbc);
-                               iptr->sx.s23.s3.lookupdefault.insindex = j;
-                               nextbc += 4;
-                               CHECK_BYTECODE_INDEX(j);
-                               MARK_BASICBLOCK(&pd, j);
-
-                               /* number of pairs */
-
-                               num = SUCK_BE_U4(m->jcode + nextbc);
-                               iptr->sx.s23.s2.lookupcount = num;
-                               nextbc += 4;
-
-                               /* allocate the intermediate code table */
-
-                               lookup = DMNEW(lookup_target_t, num);
-                               iptr->dst.lookup = lookup;
-
-                               /* iterate over the lookup table */
-
-                               CHECK_END_OF_BYTECODE(nextbc + 8 * num);
-
-                               for (i = 0; i < num; i++) {
-                                       /* value */
-
-                                       j = SUCK_BE_S4(m->jcode + nextbc);
-                                       lookup->value = j;
-
-                                       nextbc += 4;
-
-#if defined(ENABLE_VERIFIER)
-                                       /* check if the lookup table is sorted correctly */
-
-                                       if (i && (j <= prevvalue)) {
-                                               exceptions_throw_verifyerror(m, "Unsorted lookup switch");
-                                               return false;
-                                       }
-                                       prevvalue = j;
-#endif
-                                       /* target */
-
-                                       j = bcindex + SUCK_BE_S4(m->jcode + nextbc);
-                                       lookup->target.insindex = j;
-                                       lookup++;
-                                       nextbc += 4;
-                                       CHECK_BYTECODE_INDEX(j);
-                                       MARK_BASICBLOCK(&pd, j);
-                               }
-
-                               PINC;
-                               break;
-                       }
-
-               case BC_tableswitch:
-                       {
-                               s4 num, j;
-                               s4 deftarget;
-                               branch_target_t *table;
-
-                               blockend = true;
-                               nextbc = MEMORY_ALIGN((bcindex + 1), 4);
-
-                               CHECK_END_OF_BYTECODE(nextbc + 12);
-
-                               OP_PREPARE_ZEROFLAGS(opcode);
-
-                               /* default target */
-
-                               deftarget = bcindex + SUCK_BE_S4(m->jcode + nextbc);
-                               nextbc += 4;
-                               CHECK_BYTECODE_INDEX(deftarget);
-                               MARK_BASICBLOCK(&pd, deftarget);
-
-                               /* lower bound */
-
-                               j = SUCK_BE_S4(m->jcode + nextbc);
-                               iptr->sx.s23.s2.tablelow = j;
-                               nextbc += 4;
-
-                               /* upper bound */
-
-                               num = SUCK_BE_S4(m->jcode + nextbc);
-                               iptr->sx.s23.s3.tablehigh = num;
-                               nextbc += 4;
-
-                               /* calculate the number of table entries */
-
-                               num = num - j + 1;
-
-#if defined(ENABLE_VERIFIER)
-                               if (num < 1) {
-                                       exceptions_throw_verifyerror(m,
-                                                       "invalid TABLESWITCH: upper bound < lower bound");
-                                       return false;
-                               }
-#endif
-                               /* create the intermediate code table */
-                               /* the first entry is the default target */
-
-                               table = DMNEW(branch_target_t, 1 + num);
-                               iptr->dst.table = table;
-                               (table++)->insindex = deftarget;
-
-                               /* iterate over the target table */
-
-                               CHECK_END_OF_BYTECODE(nextbc + 4 * num);
-
-                               for (i = 0; i < num; i++) {
-                                       j = bcindex + SUCK_BE_S4(m->jcode + nextbc);
-                                       (table++)->insindex = j;
-                                       nextbc += 4;
-                                       CHECK_BYTECODE_INDEX(j);
-                                       MARK_BASICBLOCK(&pd, j);
-                               }
-
-                               PINC;
-                               break;
-                       }
-
-
-               /* load and store of object fields ************************************/
-
-               case BC_aastore:
-                       OP(opcode);
-                       code_unflag_leafmethod(code);
-                       break;
-
-               case BC_getstatic:
-               case BC_putstatic:
-               case BC_getfield:
-               case BC_putfield:
-                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                       fmi = class_getconstant(m->clazz, i, CONSTANT_Fieldref);
-
-                       if (fmi == NULL)
-                               return false;
-
-                       OP_PREPARE_ZEROFLAGS(opcode);
-                       iptr->sx.s23.s3.fmiref = fmi;
-
-                       /* only with -noverify, otherwise the typechecker does this */
-
-#if defined(ENABLE_VERIFIER)
-                       if (!JITDATA_HAS_FLAG_VERIFY(jd)) {
-#endif
-                               result = resolve_field_lazy(m, fmi);
-
-                               if (result == resolveFailed)
-                                       return false;
-
-                               if (result != resolveSucceeded) {
-                                       uf = resolve_create_unresolved_field(m->clazz, m, iptr);
-
-                                       if (uf == NULL)
-                                               return false;
-
-                                       /* store the unresolved_field pointer */
-
-                                       iptr->sx.s23.s3.uf = uf;
-                                       iptr->flags.bits |= INS_FLAG_UNRESOLVED;
-                               }
-#if defined(ENABLE_VERIFIER)
-                       }
-#endif
-                       PINC;
-                       break;
-
-
-               /* method invocation **************************************************/
-
-               case BC_invokestatic:
-                       OP_PREPARE_ZEROFLAGS(opcode);
-
-                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                       fmi = class_getconstant(m->clazz, i, CONSTANT_Methodref);
-
-                       if (fmi == NULL)
-                               return false;
-
-                       md = fmi->parseddesc.md;
-
-                       if (md->params == NULL)
-                               if (!descriptor_params_from_paramtypes(md, ACC_STATIC))
-                                       return false;
-
-                       goto invoke_method;
-
-               case BC_invokespecial:
-                       OP_PREPARE_FLAGS(opcode, INS_FLAG_CHECK);
-
-                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                       fmi = class_getconstant(m->clazz, i, CONSTANT_Methodref);
-
-                       goto invoke_nonstatic_method;
-
-               case BC_invokeinterface:
-                       OP_PREPARE_ZEROFLAGS(opcode);
-
-                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                       fmi = class_getconstant(m->clazz, i, CONSTANT_InterfaceMethodref);
-
-                       goto invoke_nonstatic_method;
-
-               case BC_invokevirtual:
-                       OP_PREPARE_ZEROFLAGS(opcode);
-
-                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                       fmi = class_getconstant(m->clazz, i, CONSTANT_Methodref);
-
-invoke_nonstatic_method:
-                       if (fmi == NULL)
-                               return false;
-
-                       md = fmi->parseddesc.md;
-
-                       if (md->params == NULL)
-                               if (!descriptor_params_from_paramtypes(md, 0))
-                                       return false;
-
-invoke_method:
-                       code_unflag_leafmethod(code);
-
-                       iptr->sx.s23.s3.fmiref = fmi;
-
-                       /* only with -noverify, otherwise the typechecker does this */
-
-#if defined(ENABLE_VERIFIER)
-                       if (!JITDATA_HAS_FLAG_VERIFY(jd)) {
-#endif
-                               result = resolve_method_lazy(m, fmi, 
-                                                                                        (opcode == BC_invokespecial));
-
-                               if (result == resolveFailed)
-                                       return false;
-
-                               if (result == resolveSucceeded) {
-                                       methodinfo *mi = iptr->sx.s23.s3.fmiref->p.method;
-
-                                       /* if this call is monomorphic, turn it into an
-                                          INVOKESPECIAL */
-
-                                       assert(IS_FMIREF_RESOLVED(iptr->sx.s23.s3.fmiref));
-
-                                       if ((iptr->opc == ICMD_INVOKEVIRTUAL)
-                                               && (mi->flags & (ACC_FINAL | ACC_PRIVATE)))
-                                       {
-                                               iptr->opc         = ICMD_INVOKESPECIAL;
-                                               iptr->flags.bits |= INS_FLAG_CHECK;
-                                       }
-                               }
-                               else {
-                                       um = resolve_create_unresolved_method(m->clazz, m, fmi,
-                                                       (opcode == BC_invokestatic),
-                                                       (opcode == BC_invokespecial));
-
-                                       if (um == NULL)
-                                               return false;
-
-                                       /* store the unresolved_method pointer */
-
-                                       iptr->sx.s23.s3.um = um;
-                                       iptr->flags.bits |= INS_FLAG_UNRESOLVED;
-                               }
-#if defined(ENABLE_VERIFIER)
-                       }
-#endif
-                       PINC;
-                       break;
-
-               /* instructions taking class arguments ********************************/
-
-               case BC_new:
-                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                       cr = class_getconstant(m->clazz, i, CONSTANT_Class);
-
-                       if (cr == NULL)
-                               return false;
-
-                       if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
-                               return false;
-
-                       INSTRUCTIONS_CHECK(2);
-                       OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr);
-                       bte = builtintable_get_internal(BUILTIN_new);
-                       OP_BUILTIN_CHECK_EXCEPTION(bte);
-                       s_count++;
-                       break;
-
-               case BC_checkcast:
-                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                       cr = class_getconstant(m->clazz, i, CONSTANT_Class);
-
-                       if (cr == NULL)
-                               return false;
-
-                       if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
-                               return false;
-
-                       if (cr->name->text[0] == '[') {
-                               /* array type cast-check */
-                               flags = INS_FLAG_CHECK | INS_FLAG_ARRAY;
-                               code_unflag_leafmethod(code);
-                       }
-                       else {
-                               /* object type cast-check */
-                               flags = INS_FLAG_CHECK;
-                       }
-                       OP_S3_CLASSINFO_OR_CLASSREF(opcode, c, cr, flags);
-                       break;
-
-               case BC_instanceof:
-                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
-                       cr = class_getconstant(m->clazz, i, CONSTANT_Class);
-
-                       if (cr == NULL)
-                               return false;
-
-                       if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
-                               return false;
-
-                       if (cr->name->text[0] == '[') {
-                               /* array type cast-check */
-                               INSTRUCTIONS_CHECK(2);
-                               OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr);
-                               bte = builtintable_get_internal(BUILTIN_arrayinstanceof);
-                               OP_BUILTIN_NO_EXCEPTION(bte);
-                               s_count++;
-                       }
-                       else {
-                               /* object type cast-check */
-                               OP_S3_CLASSINFO_OR_CLASSREF(opcode, c, cr, 0 /* flags*/);
-                       }
-                       break;
-
-               /* synchronization instructions ***************************************/
-
-               case BC_monitorenter:
-#if defined(ENABLE_THREADS)
-                       if (checksync) {
-                               bte = builtintable_get_internal(LOCK_monitor_enter);
-                               OP_BUILTIN_CHECK_EXCEPTION(bte);
-                       }
-                       else
-#endif
-                       {
-                               OP_CHECK_EXCEPTION(ICMD_CHECKNULL);
-                               OP(ICMD_POP);
-                       }
-                       break;
-
-               case BC_monitorexit:
-#if defined(ENABLE_THREADS)
-                       if (checksync) {
-                               bte = builtintable_get_internal(LOCK_monitor_exit);
-                               OP_BUILTIN_CHECK_EXCEPTION(bte);
-                       }
-                       else
-#endif
-                       {
-                               OP_CHECK_EXCEPTION(ICMD_CHECKNULL);
-                               OP(ICMD_POP);
-                       }
-                       break;
-
-               /* arithmetic instructions that may become builtin functions **********/
-
-               case BC_idiv:
-#if !SUPPORT_DIVISION
-                       bte = builtintable_get_internal(BUILTIN_idiv);
-                       OP_BUILTIN_ARITHMETIC(opcode, bte);
-#else
-# if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
-                       OP(opcode);
-# else
-                       OP_CHECK_EXCEPTION(opcode);
-# endif
-#endif
-                       break;
-
-               case BC_irem:
-#if !SUPPORT_DIVISION
-                       bte = builtintable_get_internal(BUILTIN_irem);
-                       OP_BUILTIN_ARITHMETIC(opcode, bte);
-#else
-# if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
-                       OP(opcode);
-# else
-                       OP_CHECK_EXCEPTION(opcode);
-# endif
-#endif
-                       break;
-
-               case BC_ldiv:
-#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
-                       bte = builtintable_get_internal(BUILTIN_ldiv);
-                       OP_BUILTIN_ARITHMETIC(opcode, bte);
-#else
-# if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
-                       OP(opcode);
-# else
-                       OP_CHECK_EXCEPTION(opcode);
-# endif
-#endif
-                       break;
-
-               case BC_lrem:
-#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
-                       bte = builtintable_get_internal(BUILTIN_lrem);
-                       OP_BUILTIN_ARITHMETIC(opcode, bte);
-#else
-# if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
-                       OP(opcode);
-# else
-                       OP_CHECK_EXCEPTION(opcode);
-# endif
-#endif
-                       break;
-
-               case BC_frem:
-#if defined(__I386__)
-                       OP(opcode);
-#else
-                       bte = builtintable_get_internal(BUILTIN_frem);
-                       OP_BUILTIN_NO_EXCEPTION(bte);
-#endif
-                       break;
-
-               case BC_drem:
-#if defined(__I386__)
-                       OP(opcode);
-#else
-                       bte = builtintable_get_internal(BUILTIN_drem);
-                       OP_BUILTIN_NO_EXCEPTION(bte);
-#endif
-                       break;
-
-               case BC_f2i:
-#if defined(__ALPHA__)
-                       if (!opt_noieee) {
-                               bte = builtintable_get_internal(BUILTIN_f2i);
-                               OP_BUILTIN_NO_EXCEPTION(bte);
-                       }
-                       else
-#endif
-                       {
-                               OP(opcode);
-                       }
-                       break;
-
-               case BC_f2l:
-#if defined(__ALPHA__)
-                       if (!opt_noieee) {
-                               bte = builtintable_get_internal(BUILTIN_f2l);
-                               OP_BUILTIN_NO_EXCEPTION(bte);
-                       }
-                       else
-#endif
-                       {
-                               OP(opcode);
-                       }
-                       break;
-
-               case BC_d2i:
-#if defined(__ALPHA__)
-                       if (!opt_noieee) {
-                               bte = builtintable_get_internal(BUILTIN_d2i);
-                               OP_BUILTIN_NO_EXCEPTION(bte);
-                       }
-                       else
-#endif
-                       {
-                               OP(opcode);
-                       }
-                       break;
-
-               case BC_d2l:
-#if defined(__ALPHA__)
-                       if (!opt_noieee) {
-                               bte = builtintable_get_internal(BUILTIN_d2l);
-                               OP_BUILTIN_NO_EXCEPTION(bte);
-                       }
-                       else
-#endif
-                       {
-                               OP(opcode);
-                       }
-                       break;
-
-
-               /* invalid opcodes ****************************************************/
-
-                       /* check for invalid opcodes if the verifier is enabled */
-#if defined(ENABLE_VERIFIER)
-               case BC_breakpoint:
-                       exceptions_throw_verifyerror(m, "Quick instructions shouldn't appear, yet.");
-                       return false;
-
-
-               /* Unused opcodes ************************************************** */
-
-               case 186:
-               case 203:
-               case 204:
-               case 205:
-               case 206:
-               case 207:
-               case 208:
-               case 209:
-               case 210:
-               case 211:
-               case 212:
-               case 213:
-               case 214:
-               case 215:
-               case 216:
-               case 217:
-               case 218:
-               case 219:
-               case 220:
-               case 221:
-               case 222:
-               case 223:
-               case 224:
-               case 225:
-               case 226:
-               case 227:
-               case 228:
-               case 229:
-               case 230:
-               case 231:
-               case 232:
-               case 233:
-               case 234:
-               case 235:
-               case 236:
-               case 237:
-               case 238:
-               case 239:
-               case 240:
-               case 241:
-               case 242:
-               case 243:
-               case 244:
-               case 245:
-               case 246:
-               case 247:
-               case 248:
-               case 249:
-               case 250:
-               case 251:
-               case 252:
-               case 253:
-               case 254:
-               case 255:
-                       exceptions_throw_verifyerror(m, "Illegal opcode %d at instr %d\n",
-                                                                                opcode, ircount);
-                       return false;
-                       break;
-#endif /* defined(ENABLE_VERIFIER) */
-
-               /* opcodes that don't require translation *****************************/
-
-               default:
-                       /* Straight-forward translation to HIR. */
-                       OP(opcode);
-                       break;
-
-               } /* end switch */
-
-               /* verifier checks ****************************************************/
-
-#if defined(ENABLE_VERIFIER)
-               /* If WIDE was used correctly, iswide should have been reset by now. */
-               if (iswide) {
-                       exceptions_throw_verifyerror(m,
-                                       "Illegal instruction: WIDE before incompatible opcode");
-                       return false;
-               }
-#endif /* defined(ENABLE_VERIFIER) */
-
-       } /* end for */
-
-       if (JITDATA_HAS_FLAG_REORDER(jd)) {
-               /* add a NOP to the last basic block */
-
-               INSTRUCTIONS_CHECK(1);
-               OP(ICMD_NOP);
-       }
-
-       /*** END OF LOOP **********************************************************/
-
-       /* assert that we did not write more ICMDs than allocated */
-
-       assert(ircount <= pd.instructionslength);
-       assert(ircount == (iptr - pd.instructions));
-
-       /*** verifier checks ******************************************************/
-
-#if defined(ENABLE_VERIFIER)
-       if (bcindex != m->jcodelength) {
-               exceptions_throw_verifyerror(m,
-                               "Command-sequence crosses code-boundary");
-               return false;
-       }
-
-       if (!blockend) {
-               exceptions_throw_verifyerror(m, "Falling off the end of the code");
-               return false;
-       }
-#endif /* defined(ENABLE_VERIFIER) */
-
-       /*** setup the methodinfo, allocate stack and basic blocks ****************/
-
-       /* identify basic blocks */
-
-       /* check if first instruction is a branch target */
-
-       if (pd.basicblockstart[0] == 1) {
-               jd->branchtoentry = true;
-       }
-       else {
-               /* first instruction always starts a basic block */
-
-               iptr = pd.instructions;
-
-               iptr->flags.bits |= INS_FLAG_BASICBLOCK;
-       }
-
-       /* Iterate over all bytecode instructions and set missing
-          basic-block starts in IR instructions. */
-
-       for (bcindex = 0; bcindex < m->jcodelength; bcindex++) {
-               /* Does the current bytecode instruction start a basic
-                  block? */
-
-               if (pd.basicblockstart[bcindex] == 1) {
-#if defined(ENABLE_VERIFIER)
-                       /* Check if this bytecode basic-block start at the
-                          beginning of a bytecode instruction. */
-
-                       if (pd.bytecodestart[bcindex] == 0) {
-                               exceptions_throw_verifyerror(m,
-                                                                                "Branch into middle of instruction");
-                               return false;
-                       }
-#endif
-
-                       /* Get the IR instruction mapped to the bytecode
-                          instruction and set the basic block flag. */
-
-                       irindex = pd.bytecodemap[bcindex];
-                       iptr    = pd.instructions + irindex;
-
-                       iptr->flags.bits |= INS_FLAG_BASICBLOCK;
-               }
-       }
-
-       /* IR instruction index to basic-block index mapping */
-
-       pd.instructionmap = DMNEW(s4, ircount);
-       MZERO(pd.instructionmap, s4, ircount);
-
-       /* Iterate over all IR instructions and count the basic blocks. */
-
-       iptr = pd.instructions;
-
-       bbcount = 0;
-
-       for (i = 0; i < ircount; i++, iptr++) {
-               if (INSTRUCTION_STARTS_BASICBLOCK(iptr)) {
-                       /* store the basic-block number in the IR instruction
-                          map */
-
-                       pd.instructionmap[i] = bbcount;
-
-                       /* post-increment the basic-block count */
-
-                       bbcount++;
-               }
-       }
-
-       /* Allocate basic block array (one more for end ipc). */
-
-       jd->basicblocks = DMNEW(basicblock, bbcount + 1);
-       MZERO(jd->basicblocks, basicblock, bbcount + 1);
-
-       /* Now iterate again over all IR instructions and initialize the
-          basic block structures and, in the same loop, resolve the
-          branch-target instruction indices to basic blocks. */
-
-       iptr = pd.instructions;
-       bptr = jd->basicblocks;
-
-       bbcount = 0;
-
-       for (i = 0; i < ircount; i++, iptr++) {
-               /* check for basic block */
-
-               if (INSTRUCTION_STARTS_BASICBLOCK(iptr)) {
-                       /* intialize the basic block */
-
-                       BASICBLOCK_INIT(bptr, m);
-
-                       bptr->iinstr = iptr;
-
-                       if (bbcount > 0) {
-                               bptr[-1].icount = bptr->iinstr - bptr[-1].iinstr;
-                       }
-
-                       /* bptr->icount is set when the next block is allocated */
-
-                       bptr->nr = bbcount++;
-                       bptr++;
-                       bptr[-1].next = bptr;
-               }
-
-               /* resolve instruction indices to basic blocks */
-
-               switch (iptr->opc) {
-               case ICMD_IFEQ:
-               case ICMD_IFLT:
-               case ICMD_IFLE:
-               case ICMD_IFNE:
-               case ICMD_IFGT:
-               case ICMD_IFGE:
-               case ICMD_IFNULL:
-               case ICMD_IFNONNULL:
-               case ICMD_IF_ICMPEQ:
-               case ICMD_IF_ICMPNE:
-               case ICMD_IF_ICMPLT:
-               case ICMD_IF_ICMPGT:
-               case ICMD_IF_ICMPLE:
-               case ICMD_IF_ICMPGE:
-               case ICMD_IF_ACMPEQ:
-               case ICMD_IF_ACMPNE:
-               case ICMD_GOTO:
-                       BYTECODEINDEX_TO_BASICBLOCK(iptr->dst);
-                       break;
-
-               case ICMD_JSR:
-                       BYTECODEINDEX_TO_BASICBLOCK(iptr->sx.s23.s3.jsrtarget);
-                       break;
-
-               case ICMD_TABLESWITCH:
-                       table = iptr->dst.table;
-
-                       BYTECODEINDEX_TO_BASICBLOCK(*table);
-                       table++;
-
-                       j = iptr->sx.s23.s3.tablehigh - iptr->sx.s23.s2.tablelow + 1;
-
-                       while (--j >= 0) {
-                               BYTECODEINDEX_TO_BASICBLOCK(*table);
-                               table++;
-                       }
-                       break;
-
-               case ICMD_LOOKUPSWITCH:
-                       BYTECODEINDEX_TO_BASICBLOCK(iptr->sx.s23.s3.lookupdefault);
-
-                       lookup = iptr->dst.lookup;
-
-                       j = iptr->sx.s23.s2.lookupcount;
-
-                       while (--j >= 0) {
-                               BYTECODEINDEX_TO_BASICBLOCK(lookup->target);
-                               lookup++;
-                       }
-                       break;
-               }
-       }
-
-       /* set instruction count of last real block */
-
-       if (bbcount > 0) {
-               bptr[-1].icount = (pd.instructions + ircount) - bptr[-1].iinstr;
-       }
-
-       /* allocate additional block at end */
-
-       BASICBLOCK_INIT(bptr, m);
-       bptr->nr = bbcount;
-
-       /* set basicblock pointers in exception table */
-
-       if (!parse_resolve_exception_table(jd, &pd))
-               return false;
-
-       /* store the local map */
-
-       jd->local_map = local_map;
-
-       /* calculate local variable renaming */
-
-       {
-               s4 nlocals = 0;
-               s4 i;
-               s4 t;
-               s4 varindex;
-               s4 *mapptr;
-               s4 *reversemap;
-
-               mapptr = local_map;
-
-               /* iterate over local_map[0..m->maxlocals*5-1] and allocate a unique */
-               /* variable index for each _used_ (javaindex,type) pair.             */
-               /* (local_map[javaindex*5+type] = cacaoindex)                        */
-               /* Unused (javaindex,type) pairs are marked with UNUSED.             */
-
-               for (i = 0; i < (m->maxlocals * 5); i++, mapptr++) {
-                       if (*mapptr)
-                               *mapptr = nlocals++;
-                       else
-                               *mapptr = UNUSED;
-               }
-
-               jd->localcount = nlocals;
-
-               /* calculate the (maximum) number of variables needed */
-
-               jd->varcount = 
-                         nlocals                                      /* local variables */
-                       + bbcount * m->maxstack                                 /* invars */
-                       + s_count;         /* variables created within blocks (non-invar) */
-
-               /* reserve the first indices for local variables */
-
-               jd->vartop = nlocals;
-
-               /* reserve extra variables needed by stack analyse */
-
-               jd->varcount += STACK_EXTRA_VARS;
-               jd->vartop   += STACK_EXTRA_VARS;
-
-               /* The verifier needs space for saving invars in some cases and */
-               /* extra variables.                                             */
-
-#if defined(ENABLE_VERIFIER)
-               jd->varcount += VERIFIER_EXTRA_LOCALS + VERIFIER_EXTRA_VARS + m->maxstack;
-               jd->vartop   += VERIFIER_EXTRA_LOCALS + VERIFIER_EXTRA_VARS + m->maxstack;
-#endif
-               /* allocate and initialize the variable array */
-
-               jd->var = DMNEW(varinfo, jd->varcount);
-               MZERO(jd->var, varinfo, jd->varcount);
-
-               /* set types of all locals in jd->var */
-               /* and fill the reverselocalmap       */
-
-               reversemap = DMNEW(s4, nlocals);
-
-               for (i = 0; i < m->maxlocals; i++)
-                       for (t=0; t<5; t++) {
-                               varindex = local_map[5*i + t];
-                               if (varindex != UNUSED) {
-                                       VAR(varindex)->type = t;
-                                       reversemap[varindex] = i;
-                               }
-                       }
-
-               jd->reverselocalmap = reversemap;
-       }
-
-       /* assign local variables to method variables */
-
-       jd->instructions     = pd.instructions;
-       jd->instructioncount = ircount;
-       jd->basicblockcount  = bbcount;
-       jd->stackcount       = s_count + bbcount * m->maxstack; /* in-stacks */
-
-       /* allocate stack table */
-
-       jd->stack = DMNEW(stackelement_t, jd->stackcount);
-
-       /* everything's ok */
-
-       return true;
-
-       /*** goto labels for throwing verifier exceptions *************************/
-
-#if defined(ENABLE_VERIFIER)
-
-throw_unexpected_end_of_bytecode:
-       exceptions_throw_verifyerror(m, "Unexpected end of bytecode");
-       return false;
-
-throw_invalid_bytecode_index:
-       exceptions_throw_verifyerror(m, "Illegal target of branch instruction");
-       return false;
-
-throw_illegal_local_variable_number:
-       exceptions_throw_verifyerror(m, "Illegal local variable number");
-       return false;
-
-#endif /* ENABLE_VERIFIER */
-}
-
-
-/*
- * 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/jit/parse.cpp b/src/vm/jit/parse.cpp
new file mode 100644 (file)
index 0000000..63a15bb
--- /dev/null
@@ -0,0 +1,1928 @@
+/* src/vm/jit/parse.c - parser for JavaVM to intermediate code translation
+
+   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 <string.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "native/native.hpp"
+
+#include "threads/lock.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/linker.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/resolve.hpp"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#include "vm/string.hpp"
+#include "vm/suck.hpp"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/loop/loop.h"
+
+#include "vm/jit/ir/bytecode.h"
+
+
+#define INSTRUCTIONS_INCREMENT  5  /* number of additional instructions to    */
+                                   /* allocate if space runs out              */
+
+
+/* local macros ***************************************************************/
+
+#define BYTECODEINDEX_TO_BASICBLOCK(dst) \
+    do { \
+        (dst).block = \
+            parse_bytecodeindex_to_basicblock(jd, &pd, (dst).insindex); \
+    } while (0)
+
+
+/* parserdata_t ***************************************************************/
+
+typedef struct parsedata_t parsedata_t;
+
+struct parsedata_t {
+       u1          *bytecodestart;         /* start of bytecode instructions     */
+       u1          *basicblockstart;       /* start of bytecode basic-blocks     */
+
+       s4          *bytecodemap;           /* bytecode to IR mapping             */
+       
+       instruction *instructions;          /* instruction array                  */
+       s4           instructionslength;    /* length of the instruction array    */
+
+       s4          *instructionmap;        /* IR to basic-block mapping          */
+};
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* parse_setup *****************************************************************
+
+   Fills the passed parsedata_t structure.
+
+*******************************************************************************/
+
+static void parse_setup(jitdata *jd, parsedata_t *pd)
+{
+       methodinfo *m;
+
+       /* get required compiler data */
+
+       m = jd->m;
+
+       /* bytecode start array */
+
+       pd->bytecodestart = (u1*) DumpMemory::allocate(sizeof(u1) * (m->jcodelength + 1));
+       MZERO(pd->bytecodestart, u1, m->jcodelength + 1);
+
+       /* bytecode basic-block start array */
+
+       pd->basicblockstart = (u1*) DumpMemory::allocate(sizeof(u1) *(m->jcodelength + 1));
+       MZERO(pd->basicblockstart, u1, m->jcodelength + 1);
+
+       /* bytecode instruction index to IR instruction mapping */
+
+       pd->bytecodemap = (s4*) DumpMemory::allocate(sizeof(s4) * (m->jcodelength + 1));
+       MSET(pd->bytecodemap, -1, s4, m->jcodelength + 1);
+
+       /* allocate the instruction array */
+
+       pd->instructionslength = m->jcodelength + 1;
+       pd->instructions = (instruction*) DumpMemory::allocate(sizeof(instruction) * pd->instructionslength);
+
+       /* Zero the intermediate instructions array so we don't have any
+          invalid pointers in it if we cannot finish stack_analyse(). */
+
+       MZERO(pd->instructions, instruction, pd->instructionslength);
+
+       /* The instructionmap is allocated later when we know the count of
+          instructions. */
+
+       pd->instructionmap = NULL;
+}
+
+
+/* parse_realloc_instructions **************************************************
+
+   Reallocate the instructions array so there is room for at least N 
+   additional instructions.
+
+   RETURN VALUE:
+       the new value for iptr
+
+*******************************************************************************/
+
+static instruction *parse_realloc_instructions(parsedata_t *pd, s4 icount, s4 n)
+{
+       /* increase the size of the instruction array */
+
+       pd->instructionslength += (n + INSTRUCTIONS_INCREMENT);
+
+       /* reallocate the array */
+
+       pd->instructions = (instruction*) DumpMemory::reallocate(pd->instructions, sizeof(instruction) * icount,
+                                                                sizeof(instruction) * pd->instructionslength);
+       MZERO(pd->instructions + icount, instruction,
+                 (pd->instructionslength - icount));
+
+       /* return the iptr */
+
+       return pd->instructions + icount;
+}
+
+
+/* parse_bytecodeindex_to_basicblock *******************************************
+
+   Resolves a bytecode index to the corresponding basic block.
+
+*******************************************************************************/
+
+static basicblock *parse_bytecodeindex_to_basicblock(jitdata *jd,
+                                                                                                        parsedata_t *pd,
+                                                                                                        s4 bcindex)
+{
+       s4          irindex;
+       basicblock *bb;
+
+       irindex = pd->bytecodemap[bcindex];
+       bb      = jd->basicblocks + pd->instructionmap[irindex];
+
+       return bb;
+}
+
+
+/* parse_mark_exception_boundaries *********************************************
+
+   Mark exception handlers and the boundaries of the handled regions as
+   basic block boundaries.
+
+   IN:
+       jd...............current jitdata
+
+   RETURN VALUE:
+       true.............everything ok
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+static bool parse_mark_exception_boundaries(jitdata *jd, parsedata_t *pd)
+{
+       s4                   bcindex;
+       s4                   i;
+       s4                   len;
+       raw_exception_entry *rex;
+       methodinfo          *m;
+
+       m = jd->m;
+       
+       len = m->rawexceptiontablelength;
+
+       if (len == 0)
+               return true;
+
+       rex = m->rawexceptiontable;
+
+       for (i = 0; i < len; ++i, ++rex) {
+
+               /* the start of the handled region becomes a basic block start */
+
+               bcindex = rex->startpc;
+               CHECK_BYTECODE_INDEX(bcindex);
+               MARK_BASICBLOCK(pd, bcindex);
+               
+               bcindex = rex->endpc; /* see JVM Spec 4.7.3 */
+               CHECK_BYTECODE_INDEX_EXCLUSIVE(bcindex);
+
+               /* check that the range is valid */
+
+#if defined(ENABLE_VERIFIER)
+               if (bcindex <= rex->startpc) {
+                       exceptions_throw_verifyerror(m, "Invalid exception handler range");
+                       return false;
+               }
+#endif
+               
+               /* End of handled region becomes a basic block boundary (if it
+                  is the bytecode end, we'll use the special end block that
+                  is created anyway). */
+
+               if (bcindex < m->jcodelength)
+                       MARK_BASICBLOCK(pd, bcindex);
+               else
+                       jd->branchtoend = true;
+
+               /* the start of the handler becomes a basic block start  */
+
+               bcindex = rex->handlerpc;
+               CHECK_BYTECODE_INDEX(bcindex);
+               MARK_BASICBLOCK(pd, bcindex);
+       }
+
+       /* everything ok */
+
+       return true;
+
+#if defined(ENABLE_VERIFIER)
+throw_invalid_bytecode_index:
+       exceptions_throw_verifyerror(m,
+                                                                "Illegal bytecode index in exception table");
+       return false;
+#endif
+}
+
+
+/* parse_resolve_exception_table ***********************************************
+
+   Enter the exception handlers and their ranges, resolved to basicblock *s,
+   in the jitdata.
+
+   IN:
+       jd...............current jitdata
+
+   RETURN VALUE:
+          true.............everything ok
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+static bool parse_resolve_exception_table(jitdata *jd, parsedata_t *pd)
+{
+       methodinfo          *m;
+       raw_exception_entry *rex;
+       exception_entry     *ex;
+       s4                   i;
+       s4                   len;
+       classinfo           *exclass;
+
+       m = jd->m;
+
+       len = m->rawexceptiontablelength;
+
+       /* common case: no handler entries */
+
+       if (len == 0)
+               return true;
+
+       /* allocate the exception table */
+
+       jd->exceptiontablelength = len;
+       jd->exceptiontable = (exception_entry*) DumpMemory::allocate(sizeof(exception_entry) * (len + 1)); /* XXX why +1? */
+
+       /* copy and resolve the entries */
+
+       ex = jd->exceptiontable;
+       rex = m->rawexceptiontable;
+
+       for (i = 0; i < len; ++i, ++rex, ++ex) {
+               /* resolve instruction indices to basic blocks */
+
+               ex->start   = parse_bytecodeindex_to_basicblock(jd, pd, rex->startpc);
+               ex->end     = parse_bytecodeindex_to_basicblock(jd, pd, rex->endpc);
+               ex->handler = parse_bytecodeindex_to_basicblock(jd, pd, rex->handlerpc);
+
+               /* lazily resolve the catchtype */
+
+               if (rex->catchtype.any != NULL) {
+                       if (!resolve_classref_or_classinfo(m,
+                                                                                          rex->catchtype,
+                                                                                          resolveLazy, true, false,
+                                                                                          &exclass))
+                               return false;
+
+                       /* if resolved, enter the result of resolution in the table */
+
+                       if (exclass != NULL)
+                               rex->catchtype.cls = exclass;
+               }
+
+               ex->catchtype = rex->catchtype;
+               ex->next = NULL;   /* set by loop analysis */
+               ex->down = ex + 1; /* link to next exception entry */
+       }
+
+       /* terminate the ->down linked list */
+
+       assert(ex != jd->exceptiontable);
+       ex[-1].down = NULL;
+
+       return true;
+}
+
+
+/*******************************************************************************
+
+       function 'parse' scans the JavaVM code and generates intermediate code
+
+       During parsing the block index table is used to store at bit pos 0
+       a flag which marks basic block starts and at position 1 to 31 the
+       intermediate instruction index. After parsing the block index table
+       is scanned, for marked positions a block is generated and the block
+       number is stored in the block index table.
+
+*******************************************************************************/
+
+/*** macro for checking the length of the bytecode ***/
+
+#if defined(ENABLE_VERIFIER)
+#define CHECK_END_OF_BYTECODE(neededlength) \
+       do { \
+               if ((neededlength) > m->jcodelength) \
+                       goto throw_unexpected_end_of_bytecode; \
+       } while (0)
+#else /* !ENABLE_VERIFIER */
+#define CHECK_END_OF_BYTECODE(neededlength)
+#endif /* ENABLE_VERIFIER */
+
+bool parse(jitdata *jd)
+{
+       methodinfo  *m;                     /* method being parsed                */
+       codeinfo    *code;
+       parsedata_t  pd;
+       instruction *iptr;                  /* current ptr into instruction array */
+
+       s4           bcindex;               /* bytecode instruction index         */
+       s4           nextbc;                /* start of next bytecode instruction */
+       s4           opcode;                /* bytecode instruction opcode        */
+
+       s4           irindex;               /* IR instruction index               */
+       s4           ircount;               /* IR instruction count               */
+
+       s4           bbcount;               /* basic block count                  */
+
+       int  s_count = 0;             /* stack element counter                    */
+       bool blockend;                /* true if basic block end has been reached */
+       bool iswide;                  /* true if last instruction was a wide      */
+
+       constant_classref  *cr;
+       constant_classref  *compr;
+       classinfo          *c;
+       builtintable_entry *bte;
+       constant_FMIref    *fmi;
+       methoddesc         *md;
+       unresolved_method  *um;
+       unresolved_field   *uf;
+
+       resolve_result_t    result;
+       u2                  lineindex = 0;
+       u2                  currentline = 0;
+       u2                  linepcchange = 0;
+       u4                  flags;
+       basicblock         *bptr;
+
+       int                *local_map; /* local pointer to renaming map           */
+                                      /* is assigned to rd->local_map at the end */
+       branch_target_t *table;
+       lookup_target_t *lookup;
+       s4               i;
+       s4               j;
+
+       /* get required compiler data */
+
+       m    = jd->m;
+       code = jd->code;
+
+       /* allocate buffers for local variable renaming */
+
+       local_map = (int*) DumpMemory::allocate(sizeof(int) * m->maxlocals * 5);
+
+       for (i = 0; i < m->maxlocals; i++) {
+               local_map[i * 5 + 0] = 0;
+               local_map[i * 5 + 1] = 0;
+               local_map[i * 5 + 2] = 0;
+               local_map[i * 5 + 3] = 0;
+               local_map[i * 5 + 4] = 0;
+       }
+
+       /* initialize the parse data structures */
+  
+       parse_setup(jd, &pd);
+  
+       /* initialize local variables */
+  
+       iptr     = pd.instructions;
+       ircount  = 0;
+       bbcount  = 0;
+       blockend = false;
+       iswide   = false;
+
+       /* mark basic block boundaries for exception table */
+
+       if (!parse_mark_exception_boundaries(jd, &pd))
+               return false;
+
+       /* initialize stack element counter */
+
+       s_count = 1 + m->rawexceptiontablelength;
+
+       /* setup line number info */
+
+       currentline = 0;
+       linepcchange = 0;
+
+       if (m->linenumbercount == 0) {
+               lineindex = 0;
+       }
+       else {
+               linepcchange = m->linenumbers[0].start_pc;
+       }
+
+       /*** LOOP OVER ALL BYTECODE INSTRUCTIONS **********************************/
+
+       for (bcindex = 0; bcindex < m->jcodelength; bcindex = nextbc) {
+
+               /* mark this position as a valid bytecode instruction start */
+
+               pd.bytecodestart[bcindex] = 1;
+
+               /* change the current line number, if necessary */
+
+               /* XXX rewrite this using pointer arithmetic */
+
+               if (linepcchange == bcindex) {
+                       if (m->linenumbercount > lineindex) {
+next_linenumber:
+                               currentline = m->linenumbers[lineindex].line_number;
+                               lineindex++;
+                               if (lineindex < m->linenumbercount) {
+                                       linepcchange = m->linenumbers[lineindex].start_pc;
+                                       if (linepcchange == bcindex)
+                                               goto next_linenumber;
+                               }
+                       }
+               }
+
+fetch_opcode:
+               /* fetch next opcode  */        
+
+               opcode = SUCK_BE_U1(m->jcode + bcindex);
+
+               /* If the previous instruction was a block-end instruction,
+                  mark the current bytecode instruction as basic-block
+                  starting instruction. */
+
+               /* NOTE: Some compilers put a BC_nop after a blockend
+                  instruction. */
+
+               if (blockend && (opcode != BC_nop)) {
+                       MARK_BASICBLOCK(&pd, bcindex);
+                       blockend = false;
+               }
+
+               /* If the current bytecode instruction was marked as
+                  basic-block starting instruction before (e.g. blockend,
+                  forward-branch target), mark the current IR instruction
+                  too. */
+
+               if (pd.basicblockstart[bcindex] != 0) {
+                       /* We need a NOP as last instruction in each basic block
+                          for basic block reordering (may be replaced with a GOTO
+                          later). */
+
+                       INSTRUCTIONS_CHECK(1);
+                       OP(ICMD_NOP);
+               }
+
+               /* store intermediate instruction count (bit 0 mark block starts) */
+
+               pd.bytecodemap[bcindex] = ircount;
+
+               /* compute next instruction start */
+
+               nextbc = bcindex + bytecode[opcode].length;
+
+               CHECK_END_OF_BYTECODE(nextbc);
+
+               /* add stack elements produced by this instruction */
+
+               s_count += bytecode[opcode].slots;
+
+               /* We check here for the space of 1 instruction in the
+                  instruction array.  If an opcode is converted to more than
+                  1 instruction, this is checked in the corresponding
+                  case. */
+
+               INSTRUCTIONS_CHECK(1);
+
+               /* translate this bytecode instruction */
+               switch (opcode) {
+
+               case BC_nop:
+                       break;
+
+               /* pushing constants onto the stack ***********************************/
+
+               case BC_bipush:
+                       OP_LOADCONST_I(SUCK_BE_S1(m->jcode + bcindex + 1));
+                       break;
+
+               case BC_sipush:
+                       OP_LOADCONST_I(SUCK_BE_S2(m->jcode + bcindex + 1));
+                       break;
+
+               case BC_ldc1:
+                       i = SUCK_BE_U1(m->jcode + bcindex + 1);
+                       goto pushconstantitem;
+
+               case BC_ldc2:
+               case BC_ldc2w:
+                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+
+               pushconstantitem:
+
+#if defined(ENABLE_VERIFIER)
+                       if (i >= m->clazz->cpcount) {
+                               exceptions_throw_verifyerror(m,
+                                       "Attempt to access constant outside range");
+                               return false;
+                       }
+#endif
+
+                       switch (m->clazz->cptags[i]) {
+                       case CONSTANT_Integer:
+                               OP_LOADCONST_I(((constant_integer *) (m->clazz->cpinfos[i]))->value);
+                               break;
+                       case CONSTANT_Long:
+                               OP_LOADCONST_L(((constant_long *) (m->clazz->cpinfos[i]))->value);
+                               break;
+                       case CONSTANT_Float:
+                               OP_LOADCONST_F(((constant_float *) (m->clazz->cpinfos[i]))->value);
+                               break;
+                       case CONSTANT_Double:
+                               OP_LOADCONST_D(((constant_double *) (m->clazz->cpinfos[i]))->value);
+                               break;
+                       case CONSTANT_String:
+                               OP_LOADCONST_STRING(literalstring_new((utf *) (m->clazz->cpinfos[i])));
+                               break;
+                       case CONSTANT_Class:
+                               cr = (constant_classref *) (m->clazz->cpinfos[i]);
+
+                               if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
+                                       return false;
+
+                               /* if not resolved, c == NULL */
+
+                               OP_LOADCONST_CLASSINFO_OR_CLASSREF_CHECK(c, cr);
+
+                               break;
+
+#if defined(ENABLE_VERIFIER)
+                       default:
+                               exceptions_throw_verifyerror(m,
+                                               "Invalid constant type to push");
+                               return false;
+#endif
+                       }
+                       break;
+
+               case BC_aconst_null:
+                       OP_LOADCONST_NULL();
+                       break;
+
+               case BC_iconst_m1:
+               case BC_iconst_0:
+               case BC_iconst_1:
+               case BC_iconst_2:
+               case BC_iconst_3:
+               case BC_iconst_4:
+               case BC_iconst_5:
+                       OP_LOADCONST_I(opcode - BC_iconst_0);
+                       break;
+
+               case BC_lconst_0:
+               case BC_lconst_1:
+                       OP_LOADCONST_L(opcode - BC_lconst_0);
+                       break;
+
+               case BC_fconst_0:
+               case BC_fconst_1:
+               case BC_fconst_2:
+                       OP_LOADCONST_F(opcode - BC_fconst_0);
+                       break;
+
+               case BC_dconst_0:
+               case BC_dconst_1:
+                       OP_LOADCONST_D(opcode - BC_dconst_0);
+                       break;
+
+               /* stack operations ***************************************************/
+
+               /* We need space for additional instruction so we can
+                  translate these instructions to sequences of ICMD_COPY and
+                  ICMD_MOVE instructions. */
+
+               case BC_dup_x1:
+                       INSTRUCTIONS_CHECK(4);
+                       OP(opcode);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       break;
+
+               case BC_dup_x2:
+                       INSTRUCTIONS_CHECK(6);
+                       OP(opcode);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       break;
+
+               case BC_dup2:
+                       INSTRUCTIONS_CHECK(2);
+                       OP(opcode);
+                       OP(ICMD_NOP);
+                       break;
+
+               case BC_dup2_x1:
+                       INSTRUCTIONS_CHECK(7);
+                       OP(opcode);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       break;
+
+               case BC_dup2_x2:
+                       INSTRUCTIONS_CHECK(9);
+                       OP(opcode);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       break;
+
+               case BC_swap:
+                       INSTRUCTIONS_CHECK(3);
+                       OP(opcode);
+                       OP(ICMD_NOP);
+                       OP(ICMD_NOP);
+                       break;
+
+               /* local variable access instructions *********************************/
+
+               case BC_iload:
+               case BC_fload:
+               case BC_aload:
+                       if (iswide == false) {
+                               i = SUCK_BE_U1(m->jcode + bcindex + 1);
+                       }
+                       else {
+                               i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                               nextbc = bcindex + 3;
+                               iswide = false;
+                       }
+                       OP_LOAD_ONEWORD(opcode, i, opcode - BC_iload);
+                       break;
+
+               case BC_lload:
+               case BC_dload:
+                       if (iswide == false) {
+                               i = SUCK_BE_U1(m->jcode + bcindex + 1);
+                       }
+                       else {
+                               i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                               nextbc = bcindex + 3;
+                               iswide = false;
+                       }
+                       OP_LOAD_TWOWORD(opcode, i, opcode - BC_iload);
+                       break;
+
+               case BC_iload_0:
+               case BC_iload_1:
+               case BC_iload_2:
+               case BC_iload_3:
+                       OP_LOAD_ONEWORD(ICMD_ILOAD, opcode - BC_iload_0, TYPE_INT);
+                       break;
+
+               case BC_lload_0:
+               case BC_lload_1:
+               case BC_lload_2:
+               case BC_lload_3:
+                       OP_LOAD_TWOWORD(ICMD_LLOAD, opcode - BC_lload_0, TYPE_LNG);
+                       break;
+
+               case BC_fload_0:
+               case BC_fload_1:
+               case BC_fload_2:
+               case BC_fload_3:
+                       OP_LOAD_ONEWORD(ICMD_FLOAD, opcode - BC_fload_0, TYPE_FLT);
+                       break;
+
+               case BC_dload_0:
+               case BC_dload_1:
+               case BC_dload_2:
+               case BC_dload_3:
+                       OP_LOAD_TWOWORD(ICMD_DLOAD, opcode - BC_dload_0, TYPE_DBL);
+                       break;
+
+               case BC_aload_0:
+               case BC_aload_1:
+               case BC_aload_2:
+               case BC_aload_3:
+                       OP_LOAD_ONEWORD(ICMD_ALOAD, opcode - BC_aload_0, TYPE_ADR);
+                       break;
+
+               case BC_istore:
+               case BC_fstore:
+               case BC_astore:
+                       if (iswide == false) {
+                               i = SUCK_BE_U1(m->jcode + bcindex + 1);
+                       }
+                       else {
+                               i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                               nextbc = bcindex + 3;
+                               iswide = false;
+                       }
+                       OP_STORE_ONEWORD(opcode, i, opcode - BC_istore);
+                       break;
+
+               case BC_lstore:
+               case BC_dstore:
+                       if (iswide == false) {
+                               i = SUCK_BE_U1(m->jcode + bcindex + 1);
+                       }
+                       else {
+                               i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                               nextbc = bcindex + 3;
+                               iswide = false;
+                       }
+                       OP_STORE_TWOWORD(opcode, i, opcode - BC_istore);
+                       break;
+
+               case BC_istore_0:
+               case BC_istore_1:
+               case BC_istore_2:
+               case BC_istore_3:
+                       OP_STORE_ONEWORD(ICMD_ISTORE, opcode - BC_istore_0, TYPE_INT);
+                       break;
+
+               case BC_lstore_0:
+               case BC_lstore_1:
+               case BC_lstore_2:
+               case BC_lstore_3:
+                       OP_STORE_TWOWORD(ICMD_LSTORE, opcode - BC_lstore_0, TYPE_LNG);
+                       break;
+
+               case BC_fstore_0:
+               case BC_fstore_1:
+               case BC_fstore_2:
+               case BC_fstore_3:
+                       OP_STORE_ONEWORD(ICMD_FSTORE, opcode - BC_fstore_0, TYPE_FLT);
+                       break;
+
+               case BC_dstore_0:
+               case BC_dstore_1:
+               case BC_dstore_2:
+               case BC_dstore_3:
+                       OP_STORE_TWOWORD(ICMD_DSTORE, opcode - BC_dstore_0, TYPE_DBL);
+                       break;
+
+               case BC_astore_0:
+               case BC_astore_1:
+               case BC_astore_2:
+               case BC_astore_3:
+                       OP_STORE_ONEWORD(ICMD_ASTORE, opcode - BC_astore_0, TYPE_ADR);
+                       break;
+
+               case BC_iinc:
+                       {
+                               int v;
+
+                               if (iswide == false) {
+                                       i = SUCK_BE_U1(m->jcode + bcindex + 1);
+                                       v = SUCK_BE_S1(m->jcode + bcindex + 2);
+                               }
+                               else {
+                                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                                       v = SUCK_BE_S2(m->jcode + bcindex + 3);
+                                       nextbc = bcindex + 5;
+                                       iswide = false;
+                               }
+                               INDEX_ONEWORD(i);
+                               LOCALTYPE_USED(i, TYPE_INT);
+                               OP_LOCALINDEX_I(opcode, i, v);
+                       }
+                       break;
+
+               /* wider index for loading, storing and incrementing ******************/
+
+               case BC_wide:
+                       bcindex++;
+                       iswide = true;
+                       goto fetch_opcode;
+
+               /* managing arrays ****************************************************/
+
+               case BC_newarray:
+                       switch (SUCK_BE_S1(m->jcode + bcindex + 1)) {
+                       case 4:
+                               bte = builtintable_get_internal(BUILTIN_newarray_boolean);
+                               break;
+                       case 5:
+                               bte = builtintable_get_internal(BUILTIN_newarray_char);
+                               break;
+                       case 6:
+                               bte = builtintable_get_internal(BUILTIN_newarray_float);
+                               break;
+                       case 7:
+                               bte = builtintable_get_internal(BUILTIN_newarray_double);
+                               break;
+                       case 8:
+                               bte = builtintable_get_internal(BUILTIN_newarray_byte);
+                               break;
+                       case 9:
+                               bte = builtintable_get_internal(BUILTIN_newarray_short);
+                               break;
+                       case 10:
+                               bte = builtintable_get_internal(BUILTIN_newarray_int);
+                               break;
+                       case 11:
+                               bte = builtintable_get_internal(BUILTIN_newarray_long);
+                               break;
+#if defined(ENABLE_VERIFIER)
+                       default:
+                               exceptions_throw_verifyerror(m, "Invalid array-type to create");
+                               return false;
+#endif
+                       }
+                       OP_BUILTIN_CHECK_EXCEPTION(bte);
+                       break;
+
+               case BC_anewarray:
+                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                       compr = (constant_classref *) class_getconstant(m->clazz, i, CONSTANT_Class);
+                       if (compr == NULL)
+                               return false;
+
+                       if (!(cr = class_get_classref_multiarray_of(1, compr)))
+                               return false;
+
+                       if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
+                               return false;
+
+                       INSTRUCTIONS_CHECK(2);
+                       OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr);
+                       bte = builtintable_get_internal(BUILTIN_newarray);
+                       OP_BUILTIN_CHECK_EXCEPTION(bte);
+                       s_count++;
+                       break;
+
+               case BC_multianewarray:
+                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                       j = SUCK_BE_U1(m->jcode + bcindex + 3);
+  
+                       cr = (constant_classref *) class_getconstant(m->clazz, i, CONSTANT_Class);
+                       if (cr == NULL)
+                               return false;
+  
+                       if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
+                               return false;
+  
+                       /* if unresolved, c == NULL */
+  
+                       iptr->s1.argcount = j;
+                       OP_S3_CLASSINFO_OR_CLASSREF(opcode, c, cr, INS_FLAG_CHECK);
+                       code_unflag_leafmethod(code);
+                       break;
+
+               /* control flow instructions ******************************************/
+
+               case BC_ifeq:
+               case BC_iflt:
+               case BC_ifle:
+               case BC_ifne:
+               case BC_ifgt:
+               case BC_ifge:
+               case BC_ifnull:
+               case BC_ifnonnull:
+               case BC_if_icmpeq:
+               case BC_if_icmpne:
+               case BC_if_icmplt:
+               case BC_if_icmpgt:
+               case BC_if_icmple:
+               case BC_if_icmpge:
+               case BC_if_acmpeq:
+               case BC_if_acmpne:
+               case BC_goto:
+                       i = bcindex + SUCK_BE_S2(m->jcode + bcindex + 1);
+                       CHECK_BYTECODE_INDEX(i);
+                       MARK_BASICBLOCK(&pd, i);
+                       blockend = true;
+                       OP_INSINDEX(opcode, i);
+                       break;
+
+               case BC_goto_w:
+                       i = bcindex + SUCK_BE_S4(m->jcode + bcindex + 1);
+                       CHECK_BYTECODE_INDEX(i);
+                       MARK_BASICBLOCK(&pd, i);
+                       blockend = true;
+                       OP_INSINDEX(ICMD_GOTO, i);
+                       break;
+
+               case BC_jsr:
+                       i = bcindex + SUCK_BE_S2(m->jcode + bcindex + 1);
+jsr_tail:
+                       CHECK_BYTECODE_INDEX(i);
+                       MARK_BASICBLOCK(&pd, i);
+                       blockend = true;
+                       OP_PREPARE_ZEROFLAGS(BC_jsr);
+                       iptr->sx.s23.s3.jsrtarget.insindex = i;
+                       PINC;
+                       break;
+
+               case BC_jsr_w:
+                       i = bcindex + SUCK_BE_S4(m->jcode + bcindex + 1);
+                       goto jsr_tail;
+
+               case BC_ret:
+                       if (iswide == false) {
+                               i = SUCK_BE_U1(m->jcode + bcindex + 1);
+                       }
+                       else {
+                               i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                               nextbc = bcindex + 3;
+                               iswide = false;
+                       }
+                       blockend = true;
+
+                       OP_LOAD_ONEWORD(opcode, i, TYPE_ADR);
+                       break;
+
+               case BC_ireturn:
+               case BC_lreturn:
+               case BC_freturn:
+               case BC_dreturn:
+               case BC_areturn:
+               case BC_return:
+                       blockend = true;
+                       /* XXX ARETURN will need a flag in the typechecker */
+                       OP(opcode);
+                       break;
+
+               case BC_athrow:
+                       blockend = true;
+                       /* XXX ATHROW will need a flag in the typechecker */
+                       OP(opcode);
+                       break;
+
+
+               /* table jumps ********************************************************/
+
+               case BC_lookupswitch:
+                       {
+                               s4 num, j;
+                               lookup_target_t *lookup;
+#if defined(ENABLE_VERIFIER)
+                               s4 prevvalue = 0;
+#endif
+                               blockend = true;
+                               nextbc = MEMORY_ALIGN((bcindex + 1), 4);
+
+                               CHECK_END_OF_BYTECODE(nextbc + 8);
+
+                               OP_PREPARE_ZEROFLAGS(opcode);
+
+                               /* default target */
+
+                               j = bcindex + SUCK_BE_S4(m->jcode + nextbc);
+                               iptr->sx.s23.s3.lookupdefault.insindex = j;
+                               nextbc += 4;
+                               CHECK_BYTECODE_INDEX(j);
+                               MARK_BASICBLOCK(&pd, j);
+
+                               /* number of pairs */
+
+                               num = SUCK_BE_U4(m->jcode + nextbc);
+                               iptr->sx.s23.s2.lookupcount = num;
+                               nextbc += 4;
+
+                               /* allocate the intermediate code table */
+
+                               lookup = (lookup_target_t*) DumpMemory::allocate(sizeof(lookup_target_t) * num);
+                               iptr->dst.lookup = lookup;
+
+                               /* iterate over the lookup table */
+
+                               CHECK_END_OF_BYTECODE(nextbc + 8 * num);
+
+                               for (i = 0; i < num; i++) {
+                                       /* value */
+
+                                       j = SUCK_BE_S4(m->jcode + nextbc);
+                                       lookup->value = j;
+
+                                       nextbc += 4;
+
+#if defined(ENABLE_VERIFIER)
+                                       /* check if the lookup table is sorted correctly */
+
+                                       if (i && (j <= prevvalue)) {
+                                               exceptions_throw_verifyerror(m, "Unsorted lookup switch");
+                                               return false;
+                                       }
+                                       prevvalue = j;
+#endif
+                                       /* target */
+
+                                       j = bcindex + SUCK_BE_S4(m->jcode + nextbc);
+                                       lookup->target.insindex = j;
+                                       lookup++;
+                                       nextbc += 4;
+                                       CHECK_BYTECODE_INDEX(j);
+                                       MARK_BASICBLOCK(&pd, j);
+                               }
+
+                               PINC;
+                               break;
+                       }
+
+               case BC_tableswitch:
+                       {
+                               s4 num, j;
+                               s4 deftarget;
+                               branch_target_t *table;
+
+                               blockend = true;
+                               nextbc = MEMORY_ALIGN((bcindex + 1), 4);
+
+                               CHECK_END_OF_BYTECODE(nextbc + 12);
+
+                               OP_PREPARE_ZEROFLAGS(opcode);
+
+                               /* default target */
+
+                               deftarget = bcindex + SUCK_BE_S4(m->jcode + nextbc);
+                               nextbc += 4;
+                               CHECK_BYTECODE_INDEX(deftarget);
+                               MARK_BASICBLOCK(&pd, deftarget);
+
+                               /* lower bound */
+
+                               j = SUCK_BE_S4(m->jcode + nextbc);
+                               iptr->sx.s23.s2.tablelow = j;
+                               nextbc += 4;
+
+                               /* upper bound */
+
+                               num = SUCK_BE_S4(m->jcode + nextbc);
+                               iptr->sx.s23.s3.tablehigh = num;
+                               nextbc += 4;
+
+                               /* calculate the number of table entries */
+
+                               num = num - j + 1;
+
+#if defined(ENABLE_VERIFIER)
+                               if (num < 1) {
+                                       exceptions_throw_verifyerror(m,
+                                                       "invalid TABLESWITCH: upper bound < lower bound");
+                                       return false;
+                               }
+#endif
+                               /* create the intermediate code table */
+                               /* the first entry is the default target */
+
+                               table = (branch_target_t*) DumpMemory::allocate(sizeof(branch_target_t) * (1 + num));
+                               iptr->dst.table = table;
+                               (table++)->insindex = deftarget;
+
+                               /* iterate over the target table */
+
+                               CHECK_END_OF_BYTECODE(nextbc + 4 * num);
+
+                               for (i = 0; i < num; i++) {
+                                       j = bcindex + SUCK_BE_S4(m->jcode + nextbc);
+                                       (table++)->insindex = j;
+                                       nextbc += 4;
+                                       CHECK_BYTECODE_INDEX(j);
+                                       MARK_BASICBLOCK(&pd, j);
+                               }
+
+                               PINC;
+                               break;
+                       }
+
+
+               /* load and store of object fields ************************************/
+
+               case BC_aastore:
+                       OP(opcode);
+                       code_unflag_leafmethod(code);
+                       break;
+
+               case BC_getstatic:
+               case BC_putstatic:
+               case BC_getfield:
+               case BC_putfield:
+                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                       fmi = (constant_FMIref*) class_getconstant(m->clazz, i, CONSTANT_Fieldref);
+
+                       if (fmi == NULL)
+                               return false;
+
+                       OP_PREPARE_ZEROFLAGS(opcode);
+                       iptr->sx.s23.s3.fmiref = fmi;
+
+                       /* only with -noverify, otherwise the typechecker does this */
+
+#if defined(ENABLE_VERIFIER)
+                       if (!JITDATA_HAS_FLAG_VERIFY(jd)) {
+#endif
+                               result = resolve_field_lazy(m, fmi);
+
+                               if (result == resolveFailed)
+                                       return false;
+
+                               if (result != resolveSucceeded) {
+                                       uf = resolve_create_unresolved_field(m->clazz, m, iptr);
+
+                                       if (uf == NULL)
+                                               return false;
+
+                                       /* store the unresolved_field pointer */
+
+                                       iptr->sx.s23.s3.uf = uf;
+                                       iptr->flags.bits |= INS_FLAG_UNRESOLVED;
+                               }
+#if defined(ENABLE_VERIFIER)
+                       }
+#endif
+                       PINC;
+                       break;
+
+
+               /* method invocation **************************************************/
+
+               case BC_invokestatic:
+                       OP_PREPARE_ZEROFLAGS(opcode);
+
+                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                       fmi = (constant_FMIref*) class_getconstant(m->clazz, i, CONSTANT_Methodref);
+
+                       if (fmi == NULL)
+                               return false;
+
+                       md = fmi->parseddesc.md;
+
+                       if (md->params == NULL)
+                               if (!descriptor_params_from_paramtypes(md, ACC_STATIC))
+                                       return false;
+
+                       goto invoke_method;
+
+               case BC_invokespecial:
+                       OP_PREPARE_FLAGS(opcode, INS_FLAG_CHECK);
+
+                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                       fmi = (constant_FMIref*) class_getconstant(m->clazz, i, CONSTANT_Methodref);
+
+                       goto invoke_nonstatic_method;
+
+               case BC_invokeinterface:
+                       OP_PREPARE_ZEROFLAGS(opcode);
+
+                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                       fmi = (constant_FMIref*) class_getconstant(m->clazz, i, CONSTANT_InterfaceMethodref);
+
+                       goto invoke_nonstatic_method;
+
+               case BC_invokevirtual:
+                       OP_PREPARE_ZEROFLAGS(opcode);
+
+                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                       fmi = (constant_FMIref*) class_getconstant(m->clazz, i, CONSTANT_Methodref);
+
+invoke_nonstatic_method:
+                       if (fmi == NULL)
+                               return false;
+
+                       md = fmi->parseddesc.md;
+
+                       if (md->params == NULL)
+                               if (!descriptor_params_from_paramtypes(md, 0))
+                                       return false;
+
+invoke_method:
+                       code_unflag_leafmethod(code);
+
+                       iptr->sx.s23.s3.fmiref = fmi;
+
+                       /* only with -noverify, otherwise the typechecker does this */
+
+#if defined(ENABLE_VERIFIER)
+                       if (!JITDATA_HAS_FLAG_VERIFY(jd)) {
+#endif
+                               result = resolve_method_lazy(m, fmi, 
+                                                                                        (opcode == BC_invokespecial));
+
+                               if (result == resolveFailed)
+                                       return false;
+
+                               if (result == resolveSucceeded) {
+                                       methodinfo *mi = iptr->sx.s23.s3.fmiref->p.method;
+
+                                       /* if this call is monomorphic, turn it into an
+                                          INVOKESPECIAL */
+
+                                       assert(IS_FMIREF_RESOLVED(iptr->sx.s23.s3.fmiref));
+
+                                       if ((iptr->opc == ICMD_INVOKEVIRTUAL)
+                                               && (mi->flags & (ACC_FINAL | ACC_PRIVATE)))
+                                       {
+                                               iptr->opc         = ICMD_INVOKESPECIAL;
+                                               iptr->flags.bits |= INS_FLAG_CHECK;
+                                       }
+                               }
+                               else {
+                                       um = resolve_create_unresolved_method(m->clazz, m, fmi,
+                                                       (opcode == BC_invokestatic),
+                                                       (opcode == BC_invokespecial));
+
+                                       if (um == NULL)
+                                               return false;
+
+                                       /* store the unresolved_method pointer */
+
+                                       iptr->sx.s23.s3.um = um;
+                                       iptr->flags.bits |= INS_FLAG_UNRESOLVED;
+                               }
+#if defined(ENABLE_VERIFIER)
+                       }
+#endif
+                       PINC;
+                       break;
+
+               /* instructions taking class arguments ********************************/
+
+               case BC_new:
+                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                       cr = (constant_classref*) class_getconstant(m->clazz, i, CONSTANT_Class);
+
+                       if (cr == NULL)
+                               return false;
+
+                       if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
+                               return false;
+
+                       INSTRUCTIONS_CHECK(2);
+                       OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr);
+                       bte = builtintable_get_internal(BUILTIN_new);
+                       OP_BUILTIN_CHECK_EXCEPTION(bte);
+                       s_count++;
+                       break;
+
+               case BC_checkcast:
+                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                       cr = (constant_classref*) class_getconstant(m->clazz, i, CONSTANT_Class);
+
+                       if (cr == NULL)
+                               return false;
+
+                       if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
+                               return false;
+
+                       if (cr->name->text[0] == '[') {
+                               /* array type cast-check */
+                               flags = INS_FLAG_CHECK | INS_FLAG_ARRAY;
+                               code_unflag_leafmethod(code);
+                       }
+                       else {
+                               /* object type cast-check */
+                               flags = INS_FLAG_CHECK;
+                       }
+                       OP_S3_CLASSINFO_OR_CLASSREF(opcode, c, cr, flags);
+                       break;
+
+               case BC_instanceof:
+                       i = SUCK_BE_U2(m->jcode + bcindex + 1);
+                       cr = (constant_classref*) class_getconstant(m->clazz, i, CONSTANT_Class);
+
+                       if (cr == NULL)
+                               return false;
+
+                       if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
+                               return false;
+
+                       if (cr->name->text[0] == '[') {
+                               /* array type cast-check */
+                               INSTRUCTIONS_CHECK(2);
+                               OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr);
+                               bte = builtintable_get_internal(BUILTIN_arrayinstanceof);
+                               OP_BUILTIN_NO_EXCEPTION(bte);
+                               s_count++;
+                       }
+                       else {
+                               /* object type cast-check */
+                               OP_S3_CLASSINFO_OR_CLASSREF(opcode, c, cr, 0 /* flags*/);
+                       }
+                       break;
+
+               /* synchronization instructions ***************************************/
+
+               case BC_monitorenter:
+#if defined(ENABLE_THREADS)
+                       if (checksync) {
+                               bte = builtintable_get_internal(LOCK_monitor_enter);
+                               OP_BUILTIN_CHECK_EXCEPTION(bte);
+                       }
+                       else
+#endif
+                       {
+                               OP_CHECK_EXCEPTION(ICMD_CHECKNULL);
+                               OP(ICMD_POP);
+                       }
+                       break;
+
+               case BC_monitorexit:
+#if defined(ENABLE_THREADS)
+                       if (checksync) {
+                               bte = builtintable_get_internal(LOCK_monitor_exit);
+                               OP_BUILTIN_CHECK_EXCEPTION(bte);
+                       }
+                       else
+#endif
+                       {
+                               OP_CHECK_EXCEPTION(ICMD_CHECKNULL);
+                               OP(ICMD_POP);
+                       }
+                       break;
+
+               /* arithmetic instructions that may become builtin functions **********/
+
+               case BC_idiv:
+#if !SUPPORT_DIVISION
+                       bte = builtintable_get_internal(BUILTIN_idiv);
+                       OP_BUILTIN_ARITHMETIC(opcode, bte);
+#else
+# if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
+                       OP(opcode);
+# else
+                       OP_CHECK_EXCEPTION(opcode);
+# endif
+#endif
+                       break;
+
+               case BC_irem:
+#if !SUPPORT_DIVISION
+                       bte = builtintable_get_internal(BUILTIN_irem);
+                       OP_BUILTIN_ARITHMETIC(opcode, bte);
+#else
+# if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
+                       OP(opcode);
+# else
+                       OP_CHECK_EXCEPTION(opcode);
+# endif
+#endif
+                       break;
+
+               case BC_ldiv:
+#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
+                       bte = builtintable_get_internal(BUILTIN_ldiv);
+                       OP_BUILTIN_ARITHMETIC(opcode, bte);
+#else
+# if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
+                       OP(opcode);
+# else
+                       OP_CHECK_EXCEPTION(opcode);
+# endif
+#endif
+                       break;
+
+               case BC_lrem:
+#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
+                       bte = builtintable_get_internal(BUILTIN_lrem);
+                       OP_BUILTIN_ARITHMETIC(opcode, bte);
+#else
+# if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
+                       OP(opcode);
+# else
+                       OP_CHECK_EXCEPTION(opcode);
+# endif
+#endif
+                       break;
+
+               case BC_frem:
+#if defined(__I386__)
+                       OP(opcode);
+#else
+                       bte = builtintable_get_internal(BUILTIN_frem);
+                       OP_BUILTIN_NO_EXCEPTION(bte);
+#endif
+                       break;
+
+               case BC_drem:
+#if defined(__I386__)
+                       OP(opcode);
+#else
+                       bte = builtintable_get_internal(BUILTIN_drem);
+                       OP_BUILTIN_NO_EXCEPTION(bte);
+#endif
+                       break;
+
+               case BC_f2i:
+#if defined(__ALPHA__)
+                       bte = builtintable_get_internal(BUILTIN_f2i);
+                       OP_BUILTIN_NO_EXCEPTION(bte);
+#else
+                       OP(opcode);
+#endif
+                       break;
+
+               case BC_f2l:
+#if defined(__ALPHA__)
+                       bte = builtintable_get_internal(BUILTIN_f2l);
+                       OP_BUILTIN_NO_EXCEPTION(bte);
+#else
+                       OP(opcode);
+#endif
+                       break;
+
+               case BC_d2i:
+#if defined(__ALPHA__)
+                       bte = builtintable_get_internal(BUILTIN_d2i);
+                       OP_BUILTIN_NO_EXCEPTION(bte);
+#else
+                       OP(opcode);
+#endif
+                       break;
+
+               case BC_d2l:
+#if defined(__ALPHA__)
+                       bte = builtintable_get_internal(BUILTIN_d2l);
+                       OP_BUILTIN_NO_EXCEPTION(bte);
+#else
+                       OP(opcode);
+#endif
+                       break;
+
+
+               /* invalid opcodes ****************************************************/
+
+                       /* check for invalid opcodes if the verifier is enabled */
+#if defined(ENABLE_VERIFIER)
+               case BC_breakpoint:
+                       exceptions_throw_verifyerror(m, "Quick instructions shouldn't appear, yet.");
+                       return false;
+
+
+               /* Unused opcodes ************************************************** */
+
+               case 186:
+               case 203:
+               case 204:
+               case 205:
+               case 206:
+               case 207:
+               case 208:
+               case 209:
+               case 210:
+               case 211:
+               case 212:
+               case 213:
+               case 214:
+               case 215:
+               case 216:
+               case 217:
+               case 218:
+               case 219:
+               case 220:
+               case 221:
+               case 222:
+               case 223:
+               case 224:
+               case 225:
+               case 226:
+               case 227:
+               case 228:
+               case 229:
+               case 230:
+               case 231:
+               case 232:
+               case 233:
+               case 234:
+               case 235:
+               case 236:
+               case 237:
+               case 238:
+               case 239:
+               case 240:
+               case 241:
+               case 242:
+               case 243:
+               case 244:
+               case 245:
+               case 246:
+               case 247:
+               case 248:
+               case 249:
+               case 250:
+               case 251:
+               case 252:
+               case 253:
+               case 254:
+               case 255:
+                       exceptions_throw_verifyerror(m, "Illegal opcode %d at instr %d\n",
+                                                                                opcode, ircount);
+                       return false;
+                       break;
+#endif /* defined(ENABLE_VERIFIER) */
+
+               /* opcodes that don't require translation *****************************/
+
+               default:
+                       /* Straight-forward translation to HIR. */
+                       OP(opcode);
+                       break;
+
+               } /* end switch */
+
+               /* verifier checks ****************************************************/
+
+#if defined(ENABLE_VERIFIER)
+               /* If WIDE was used correctly, iswide should have been reset by now. */
+               if (iswide) {
+                       exceptions_throw_verifyerror(m,
+                                       "Illegal instruction: WIDE before incompatible opcode");
+                       return false;
+               }
+#endif /* defined(ENABLE_VERIFIER) */
+
+       } /* end for */
+
+       if (JITDATA_HAS_FLAG_REORDER(jd)) {
+               /* add a NOP to the last basic block */
+
+               INSTRUCTIONS_CHECK(1);
+               OP(ICMD_NOP);
+       }
+
+       /*** END OF LOOP **********************************************************/
+
+       /* assert that we did not write more ICMDs than allocated */
+
+       assert(ircount <= pd.instructionslength);
+       assert(ircount == (iptr - pd.instructions));
+
+       /*** verifier checks ******************************************************/
+
+#if defined(ENABLE_VERIFIER)
+       if (bcindex != m->jcodelength) {
+               exceptions_throw_verifyerror(m,
+                               "Command-sequence crosses code-boundary");
+               return false;
+       }
+
+       if (!blockend) {
+               exceptions_throw_verifyerror(m, "Falling off the end of the code");
+               return false;
+       }
+#endif /* defined(ENABLE_VERIFIER) */
+
+       /*** setup the methodinfo, allocate stack and basic blocks ****************/
+
+       /* identify basic blocks */
+
+       /* check if first instruction is a branch target */
+
+       if (pd.basicblockstart[0] == 1) {
+               jd->branchtoentry = true;
+       }
+       else {
+               /* first instruction always starts a basic block */
+
+               iptr = pd.instructions;
+
+               iptr->flags.bits |= INS_FLAG_BASICBLOCK;
+       }
+
+       /* Iterate over all bytecode instructions and set missing
+          basic-block starts in IR instructions. */
+
+       for (bcindex = 0; bcindex < m->jcodelength; bcindex++) {
+               /* Does the current bytecode instruction start a basic
+                  block? */
+
+               if (pd.basicblockstart[bcindex] == 1) {
+#if defined(ENABLE_VERIFIER)
+                       /* Check if this bytecode basic-block start at the
+                          beginning of a bytecode instruction. */
+
+                       if (pd.bytecodestart[bcindex] == 0) {
+                               exceptions_throw_verifyerror(m,
+                                                                                "Branch into middle of instruction");
+                               return false;
+                       }
+#endif
+
+                       /* Get the IR instruction mapped to the bytecode
+                          instruction and set the basic block flag. */
+
+                       irindex = pd.bytecodemap[bcindex];
+                       iptr    = pd.instructions + irindex;
+
+                       iptr->flags.bits |= INS_FLAG_BASICBLOCK;
+               }
+       }
+
+       /* IR instruction index to basic-block index mapping */
+
+       pd.instructionmap = (s4*) DumpMemory::allocate(sizeof(s4) * ircount);
+       MZERO(pd.instructionmap, s4, ircount);
+
+       /* Iterate over all IR instructions and count the basic blocks. */
+
+       iptr = pd.instructions;
+
+       bbcount = 0;
+
+       for (i = 0; i < ircount; i++, iptr++) {
+               if (INSTRUCTION_STARTS_BASICBLOCK(iptr)) {
+                       /* store the basic-block number in the IR instruction
+                          map */
+
+                       pd.instructionmap[i] = bbcount;
+
+                       /* post-increment the basic-block count */
+
+                       bbcount++;
+               }
+       }
+
+       /* Allocate basic block array (one more for end ipc). */
+
+       jd->basicblocks = (basicblock*) DumpMemory::allocate(sizeof(basicblock) * (bbcount + 1));
+       MZERO(jd->basicblocks, basicblock, bbcount + 1);
+
+       /* Now iterate again over all IR instructions and initialize the
+          basic block structures and, in the same loop, resolve the
+          branch-target instruction indices to basic blocks. */
+
+       iptr = pd.instructions;
+       bptr = jd->basicblocks;
+
+       bbcount = 0;
+
+       for (i = 0; i < ircount; i++, iptr++) {
+               /* check for basic block */
+
+               if (INSTRUCTION_STARTS_BASICBLOCK(iptr)) {
+                       /* intialize the basic block */
+
+                       BASICBLOCK_INIT(bptr, m);
+
+                       bptr->iinstr = iptr;
+
+                       if (bbcount > 0) {
+                               bptr[-1].icount = bptr->iinstr - bptr[-1].iinstr;
+                       }
+
+                       /* bptr->icount is set when the next block is allocated */
+
+                       bptr->nr = bbcount++;
+                       bptr++;
+                       bptr[-1].next = bptr;
+               }
+
+               /* resolve instruction indices to basic blocks */
+
+               switch (iptr->opc) {
+               case ICMD_IFEQ:
+               case ICMD_IFLT:
+               case ICMD_IFLE:
+               case ICMD_IFNE:
+               case ICMD_IFGT:
+               case ICMD_IFGE:
+               case ICMD_IFNULL:
+               case ICMD_IFNONNULL:
+               case ICMD_IF_ICMPEQ:
+               case ICMD_IF_ICMPNE:
+               case ICMD_IF_ICMPLT:
+               case ICMD_IF_ICMPGT:
+               case ICMD_IF_ICMPLE:
+               case ICMD_IF_ICMPGE:
+               case ICMD_IF_ACMPEQ:
+               case ICMD_IF_ACMPNE:
+               case ICMD_GOTO:
+                       BYTECODEINDEX_TO_BASICBLOCK(iptr->dst);
+                       break;
+
+               case ICMD_JSR:
+                       BYTECODEINDEX_TO_BASICBLOCK(iptr->sx.s23.s3.jsrtarget);
+                       break;
+
+               case ICMD_TABLESWITCH:
+                       table = iptr->dst.table;
+
+                       BYTECODEINDEX_TO_BASICBLOCK(*table);
+                       table++;
+
+                       j = iptr->sx.s23.s3.tablehigh - iptr->sx.s23.s2.tablelow + 1;
+
+                       while (--j >= 0) {
+                               BYTECODEINDEX_TO_BASICBLOCK(*table);
+                               table++;
+                       }
+                       break;
+
+               case ICMD_LOOKUPSWITCH:
+                       BYTECODEINDEX_TO_BASICBLOCK(iptr->sx.s23.s3.lookupdefault);
+
+                       lookup = iptr->dst.lookup;
+
+                       j = iptr->sx.s23.s2.lookupcount;
+
+                       while (--j >= 0) {
+                               BYTECODEINDEX_TO_BASICBLOCK(lookup->target);
+                               lookup++;
+                       }
+                       break;
+               }
+       }
+
+       /* set instruction count of last real block */
+
+       if (bbcount > 0) {
+               bptr[-1].icount = (pd.instructions + ircount) - bptr[-1].iinstr;
+       }
+
+       /* allocate additional block at end */
+
+       BASICBLOCK_INIT(bptr, m);
+       bptr->nr = bbcount;
+
+       /* set basicblock pointers in exception table */
+
+       if (!parse_resolve_exception_table(jd, &pd))
+               return false;
+
+       /* store the local map */
+
+       jd->local_map = local_map;
+
+       /* calculate local variable renaming */
+
+       {
+               s4 nlocals = 0;
+               s4 i;
+               s4 t;
+               s4 varindex;
+               s4 *mapptr;
+               s4 *reversemap;
+
+               mapptr = local_map;
+
+               /* iterate over local_map[0..m->maxlocals*5-1] and allocate a unique */
+               /* variable index for each _used_ (javaindex,type) pair.             */
+               /* (local_map[javaindex*5+type] = cacaoindex)                        */
+               /* Unused (javaindex,type) pairs are marked with UNUSED.             */
+
+               for (i = 0; i < (m->maxlocals * 5); i++, mapptr++) {
+                       if (*mapptr)
+                               *mapptr = nlocals++;
+                       else
+                               *mapptr = UNUSED;
+               }
+
+               jd->localcount = nlocals;
+
+               /* calculate the (maximum) number of variables needed */
+
+               jd->varcount = 
+                         nlocals                                      /* local variables */
+                       + bbcount * m->maxstack                                 /* invars */
+                       + s_count;         /* variables created within blocks (non-invar) */
+
+               /* reserve the first indices for local variables */
+
+               jd->vartop = nlocals;
+
+               /* reserve extra variables needed by stack analyse */
+
+               jd->varcount += STACK_EXTRA_VARS;
+               jd->vartop   += STACK_EXTRA_VARS;
+
+               /* The verifier needs space for saving invars in some cases and */
+               /* extra variables.                                             */
+
+#if defined(ENABLE_VERIFIER)
+               jd->varcount += VERIFIER_EXTRA_LOCALS + VERIFIER_EXTRA_VARS + m->maxstack;
+               jd->vartop   += VERIFIER_EXTRA_LOCALS + VERIFIER_EXTRA_VARS + m->maxstack;
+#endif
+               /* allocate and initialize the variable array */
+
+               jd->var = (varinfo*) DumpMemory::allocate(sizeof(varinfo) * jd->varcount);
+               MZERO(jd->var, varinfo, jd->varcount);
+
+               /* set types of all locals in jd->var */
+               /* and fill the reverselocalmap       */
+
+               reversemap = (s4*) DumpMemory::allocate(sizeof(s4) * nlocals);
+
+               for (i = 0; i < m->maxlocals; i++)
+                       for (t=0; t<5; t++) {
+                               varindex = local_map[5*i + t];
+                               if (varindex != UNUSED) {
+                                       VAR(varindex)->type = t;
+                                       reversemap[varindex] = i;
+                               }
+                       }
+
+               jd->reverselocalmap = reversemap;
+       }
+
+       /* assign local variables to method variables */
+
+       jd->instructions     = pd.instructions;
+       jd->instructioncount = ircount;
+       jd->basicblockcount  = bbcount;
+       jd->stackcount       = s_count + bbcount * m->maxstack; /* in-stacks */
+
+       /* allocate stack table */
+
+       jd->stack = (stackelement_t*) DumpMemory::allocate(sizeof(stackelement_t) * jd->stackcount);
+
+       /* everything's ok */
+
+       return true;
+
+       /*** goto labels for throwing verifier exceptions *************************/
+
+#if defined(ENABLE_VERIFIER)
+
+throw_unexpected_end_of_bytecode:
+       exceptions_throw_verifyerror(m, "Unexpected end of bytecode");
+       return false;
+
+throw_invalid_bytecode_index:
+       exceptions_throw_verifyerror(m, "Illegal target of branch instruction");
+       return false;
+
+throw_illegal_local_variable_number:
+       exceptions_throw_verifyerror(m, "Illegal local variable number");
+       return false;
+
+#endif /* ENABLE_VERIFIER */
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+/*
+ * 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/jit/parse.h b/src/vm/jit/parse.h
deleted file mode 100644 (file)
index 55917d6..0000000
+++ /dev/null
@@ -1,297 +0,0 @@
-/* src/vm/jit/parse.h - parser header
-
-   Copyright (C) 1996-2005, 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
-
-   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.
-
-   Contact: cacao@cacaojvm.org
-
-   Author:  Christian Thalinger
-            Edwin Steiner
-
-*/
-
-
-#ifndef _PARSE_H
-#define _PARSE_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-#include "vm/jit/codegen-common.h"
-
-
-/* macros for verifier checks during parsing **********************************/
-
-#if defined(ENABLE_VERIFIER)
-
-/* We have to check local variables indices here because they are             */
-/* used in stack.c to index the locals array.                                 */
-
-#define INDEX_ONEWORD(num) \
-    do { \
-        if (((num) < 0) || ((num) >= m->maxlocals)) \
-            goto throw_illegal_local_variable_number; \
-    } while (0)
-
-#define INDEX_TWOWORD(num) \
-    do { \
-        if (((num) < 0) || (((num) + 1) >= m->maxlocals)) \
-            goto throw_illegal_local_variable_number; \
-    } while (0)
-
-/* CHECK_BYTECODE_INDEX(i) checks whether i is a valid bytecode index.        */
-/* The end of the bytecode (i == m->jcodelength) is considered valid.         */
-
-#define CHECK_BYTECODE_INDEX(i) \
-    do { \
-        if (((i) < 0) || ((i) >= m->jcodelength)) \
-                       goto throw_invalid_bytecode_index; \
-    } while (0)
-
-/* CHECK_BYTECODE_INDEX_EXCLUSIVE is used for the exclusive ends               */
-/* of exception handler ranges.                                                */
-#define CHECK_BYTECODE_INDEX_EXCLUSIVE(i) \
-    do { \
-        if ((i) < 0 || (i) > m->jcodelength) \
-                       goto throw_invalid_bytecode_index; \
-    } while (0)
-
-#else /* !defined(ENABLE_VERIFIER) */
-
-#define INDEX_ONEWORD(num)
-#define INDEX_TWOWORD(num)
-#define CHECK_BYTECODE_INDEX(i)
-#define CHECK_BYTECODE_INDEX_EXCLUSIVE(i)
-
-#endif /* defined(ENABLE_VERIFIER) */
-
-
-/* basic block generating macro ***********************************************/
-
-#define MARK_BASICBLOCK(pd, i)                                       \
-    do {                                                             \
-        (pd)->basicblockstart[(i)] = 1;                              \
-    } while (0)
-
-#define INSTRUCTIONS_CHECK(i)                                        \
-    if ((ircount + (i)) > pd.instructionslength)                     \
-        iptr = parse_realloc_instructions(&pd, ircount, (i))
-
-
-/* intermediate code generating macros ****************************************/
-
-/* These macros ALWAYS set the following fields of *iptr to valid values:     */
-/*     iptr->opc                                                              */
-/*     iptr->flags                                                            */
-/*     iptr->line                                                             */
-
-/* These macros do NOT touch the following fields of *iptr, unless a value is */
-/* given for them:                                                            */
-/*     iptr->s1                                                               */
-/*     iptr->sx                                                               */
-/*     iptr->dst                                                              */
-
-/* The _PREPARE macros omit the PINC, so you can set additional fields        */
-/* afterwards.                                                                */
-
-#define PINC                                                         \
-    iptr++; ircount++
-
-#define OP_PREPARE_FLAGS(o, f)                                       \
-    iptr->opc         = (o);                                         \
-    iptr->line        = currentline;                                 \
-    iptr->flags.bits |= (f) | (ircount << INS_FLAG_ID_SHIFT);
-
-#define OP_PREPARE_ZEROFLAGS(o)                                      \
-    OP_PREPARE_FLAGS(o, 0)
-
-#define OP_PREPARE(o)                                                \
-    OP_PREPARE_ZEROFLAGS(o)
-
-#define OP(o)                                                        \
-    OP_PREPARE_ZEROFLAGS(o);                                         \
-    PINC
-
-#define OP_CHECK_EXCEPTION(o)                                        \
-    OP_PREPARE_FLAGS(o, INS_FLAG_CHECK);                             \
-    PINC
-
-#define OP_LOADCONST_I(v)                                            \
-    OP_PREPARE_ZEROFLAGS(ICMD_ICONST);                               \
-    iptr->sx.val.i           = (v);                                  \
-    PINC
-
-#define OP_LOADCONST_L(v)                                            \
-    OP_PREPARE_ZEROFLAGS(ICMD_LCONST);                               \
-    iptr->sx.val.l           = (v);                                  \
-    PINC
-
-#define OP_LOADCONST_F(v)                                            \
-    OP_PREPARE_ZEROFLAGS(ICMD_FCONST);                               \
-    iptr->sx.val.f           = (v);                                  \
-    PINC
-
-#define OP_LOADCONST_D(v)                                            \
-    OP_PREPARE_ZEROFLAGS(ICMD_DCONST);                               \
-    iptr->sx.val.d           = (v);                                  \
-    PINC
-
-#define OP_LOADCONST_NULL()                                          \
-    OP_PREPARE_FLAGS(ICMD_ACONST, INS_FLAG_CHECK);                   \
-    iptr->sx.val.anyptr      = NULL;                                 \
-    PINC
-
-#define OP_LOADCONST_STRING(v)                                       \
-    OP_PREPARE_FLAGS(ICMD_ACONST, INS_FLAG_CHECK);                   \
-    iptr->sx.val.stringconst = (v);                                  \
-    PINC
-
-#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS(cl, cr, extraflags) \
-    OP_PREPARE(ICMD_ACONST);                                         \
-    if (cl) {                                                        \
-        iptr->sx.val.c.cls   = (cl);                                 \
-        iptr->flags.bits     |= INS_FLAG_CLASS | (extraflags);       \
-    }                                                                \
-    else {                                                           \
-        iptr->sx.val.c.ref   = (cr);                                 \
-        iptr->flags.bits     |= INS_FLAG_CLASS | INS_FLAG_UNRESOLVED \
-                             | (extraflags);                         \
-    }                                                                \
-    PINC
-
-#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_CHECK(c, cr)              \
-    OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS((c), (cr), INS_FLAG_CHECK)
-
-#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr)            \
-    OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS((c), (cr), 0)
-
-#define OP_S3_CLASSINFO_OR_CLASSREF(o, c, cr, extraflags)            \
-    OP_PREPARE(o);                                                   \
-    if (c) {                                                         \
-        iptr->sx.s23.s3.c.cls= (c);                                  \
-        iptr->flags.bits     |= (extraflags);                        \
-    }                                                                \
-    else {                                                           \
-        iptr->sx.s23.s3.c.ref= (cr);                                 \
-        iptr->flags.bits     |= INS_FLAG_UNRESOLVED | (extraflags);  \
-    }                                                                \
-    PINC
-
-#define OP_INSINDEX(o, iindex)                                       \
-    OP_PREPARE_ZEROFLAGS(o);                                         \
-    iptr->dst.insindex       = (iindex);                             \
-    PINC
-
-# define OP_LOCALINDEX(o,index)                                      \
-    OP_PREPARE_ZEROFLAGS(o);                                         \
-    iptr->s1.varindex      = (index);                                \
-    PINC
-
-# define OP_LOCALINDEX_I(o,index,v)                                  \
-    OP_PREPARE_ZEROFLAGS(o);                                         \
-    iptr->s1.varindex      = (index);                                \
-    iptr->sx.val.i           = (v);                                  \
-    PINC
-
-# define LOCALTYPE_USED(index,type)                                  \
-    do {                                                             \
-        local_map[(index) * 5 + (type)] = 1;                         \
-    } while (0)
-
-#define OP_LOAD_ONEWORD(o,index,type)                                \
-    do {                                                             \
-        INDEX_ONEWORD(index);                                        \
-        OP_LOCALINDEX(o,index);                                      \
-        LOCALTYPE_USED(index,type);                                  \
-    } while (0)
-
-#define OP_LOAD_TWOWORD(o,index,type)                                \
-    do {                                                             \
-        INDEX_TWOWORD(index);                                        \
-        OP_LOCALINDEX(o,index);                                      \
-        LOCALTYPE_USED(index,type);                                  \
-    } while (0)
-
-# define OP_STORE_ONEWORD(o,index,type)                              \
-    do {                                                             \
-        INDEX_ONEWORD(index);                                        \
-        OP_PREPARE_ZEROFLAGS(o);                                     \
-        iptr->dst.varindex = (index);                                \
-        LOCALTYPE_USED(index,type);                                  \
-        PINC;                                                        \
-    } while (0)
-
-# define OP_STORE_TWOWORD(o,index,type)                              \
-    do {                                                             \
-        INDEX_TWOWORD(index);                                        \
-        OP_PREPARE_ZEROFLAGS(o);                                     \
-        iptr->dst.varindex = (index);                                \
-        LOCALTYPE_USED(index,type);                                  \
-        PINC;                                                        \
-    } while (0)
-
-#define OP_BUILTIN_CHECK_EXCEPTION(bte)                              \
-    code_unflag_leafmethod(code);                                    \
-    OP_PREPARE_FLAGS(ICMD_BUILTIN, INS_FLAG_CHECK);                  \
-    iptr->sx.s23.s3.bte      = (bte);                                \
-    PINC
-
-#define OP_BUILTIN_NO_EXCEPTION(bte)                                 \
-    code_unflag_leafmethod(code);                                    \
-    OP_PREPARE_ZEROFLAGS(ICMD_BUILTIN);                              \
-    iptr->sx.s23.s3.bte      = (bte);                                \
-    PINC
-
-#define OP_BUILTIN_ARITHMETIC(opcode, bte)                           \
-    code_unflag_leafmethod(code);                                    \
-    OP_PREPARE_FLAGS(opcode, INS_FLAG_CHECK);                        \
-    iptr->sx.s23.s3.bte      = (bte);                                \
-    PINC
-
-/* CAUTION: You must set iptr->flags yourself when using this!                */
-#define OP_FMIREF_PREPARE(o, fmiref)                                 \
-    OP_PREPARE(o);                                                   \
-    iptr->sx.s23.s3.fmiref   = (fmiref);
-
-
-/* function prototypes ********************************************************/
-
-bool parse(jitdata *jd);
-
-#endif /* _PARSE_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/jit/parse.hpp b/src/vm/jit/parse.hpp
new file mode 100644 (file)
index 0000000..b10d7da
--- /dev/null
@@ -0,0 +1,298 @@
+/* src/vm/jit/parse.h - parser header
+
+   Copyright (C) 1996-2005, 2006, 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 _PARSE_H
+#define _PARSE_H
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/global.h"
+#include "vm/jit/codegen-common.hpp"
+
+
+/* macros for verifier checks during parsing **********************************/
+
+#if defined(ENABLE_VERIFIER)
+
+/* We have to check local variables indices here because they are             */
+/* used in stack.c to index the locals array.                                 */
+
+#define INDEX_ONEWORD(num) \
+    do { \
+        if (((num) < 0) || ((num) >= m->maxlocals)) \
+            goto throw_illegal_local_variable_number; \
+    } while (0)
+
+#define INDEX_TWOWORD(num) \
+    do { \
+        if (((num) < 0) || (((num) + 1) >= m->maxlocals)) \
+            goto throw_illegal_local_variable_number; \
+    } while (0)
+
+/* CHECK_BYTECODE_INDEX(i) checks whether i is a valid bytecode index.        */
+/* The end of the bytecode (i == m->jcodelength) is considered valid.         */
+
+#define CHECK_BYTECODE_INDEX(i) \
+    do { \
+        if (((i) < 0) || ((i) >= m->jcodelength)) \
+                       goto throw_invalid_bytecode_index; \
+    } while (0)
+
+/* CHECK_BYTECODE_INDEX_EXCLUSIVE is used for the exclusive ends               */
+/* of exception handler ranges.                                                */
+#define CHECK_BYTECODE_INDEX_EXCLUSIVE(i) \
+    do { \
+        if ((i) < 0 || (i) > m->jcodelength) \
+                       goto throw_invalid_bytecode_index; \
+    } while (0)
+
+#else /* !defined(ENABLE_VERIFIER) */
+
+#define INDEX_ONEWORD(num)
+#define INDEX_TWOWORD(num)
+#define CHECK_BYTECODE_INDEX(i)
+#define CHECK_BYTECODE_INDEX_EXCLUSIVE(i)
+
+#endif /* defined(ENABLE_VERIFIER) */
+
+
+/* basic block generating macro ***********************************************/
+
+#define MARK_BASICBLOCK(pd, i)                                       \
+    do {                                                             \
+        (pd)->basicblockstart[(i)] = 1;                              \
+    } while (0)
+
+#define INSTRUCTIONS_CHECK(i)                                        \
+    if ((ircount + (i)) > pd.instructionslength)                     \
+        iptr = parse_realloc_instructions(&pd, ircount, (i))
+
+
+/* intermediate code generating macros ****************************************/
+
+/* These macros ALWAYS set the following fields of *iptr to valid values:     */
+/*     iptr->opc                                                              */
+/*     iptr->flags                                                            */
+/*     iptr->line                                                             */
+
+/* These macros do NOT touch the following fields of *iptr, unless a value is */
+/* given for them:                                                            */
+/*     iptr->s1                                                               */
+/*     iptr->sx                                                               */
+/*     iptr->dst                                                              */
+
+/* The _PREPARE macros omit the PINC, so you can set additional fields        */
+/* afterwards.                                                                */
+
+#define PINC                                                         \
+    iptr++; ircount++
+
+#define OP_PREPARE_FLAGS(o, f)                                       \
+    iptr->opc         = (o);                                         \
+    iptr->line        = currentline;                                 \
+    iptr->flags.bits |= (f) | (ircount << INS_FLAG_ID_SHIFT);
+
+#define OP_PREPARE_ZEROFLAGS(o)                                      \
+    OP_PREPARE_FLAGS(o, 0)
+
+#define OP_PREPARE(o)                                                \
+    OP_PREPARE_ZEROFLAGS(o)
+
+#define OP(o)                                                        \
+    OP_PREPARE_ZEROFLAGS(o);                                         \
+    PINC
+
+#define OP_CHECK_EXCEPTION(o)                                        \
+    OP_PREPARE_FLAGS(o, INS_FLAG_CHECK);                             \
+    PINC
+
+#define OP_LOADCONST_I(v)                                            \
+    OP_PREPARE_ZEROFLAGS(ICMD_ICONST);                               \
+    iptr->sx.val.i           = (v);                                  \
+    PINC
+
+#define OP_LOADCONST_L(v)                                            \
+    OP_PREPARE_ZEROFLAGS(ICMD_LCONST);                               \
+    iptr->sx.val.l           = (v);                                  \
+    PINC
+
+#define OP_LOADCONST_F(v)                                            \
+    OP_PREPARE_ZEROFLAGS(ICMD_FCONST);                               \
+    iptr->sx.val.f           = (v);                                  \
+    PINC
+
+#define OP_LOADCONST_D(v)                                            \
+    OP_PREPARE_ZEROFLAGS(ICMD_DCONST);                               \
+    iptr->sx.val.d           = (v);                                  \
+    PINC
+
+#define OP_LOADCONST_NULL()                                          \
+    OP_PREPARE_FLAGS(ICMD_ACONST, INS_FLAG_CHECK);                   \
+    iptr->sx.val.anyptr      = NULL;                                 \
+    PINC
+
+#define OP_LOADCONST_STRING(v)                                       \
+    OP_PREPARE_FLAGS(ICMD_ACONST, INS_FLAG_CHECK);                   \
+    iptr->sx.val.stringconst = (v);                                  \
+    PINC
+
+#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS(cl, cr, extraflags) \
+    OP_PREPARE(ICMD_ACONST);                                         \
+    if (cl) {                                                        \
+        iptr->sx.val.c.cls   = (cl);                                 \
+        iptr->flags.bits     |= INS_FLAG_CLASS | (extraflags);       \
+    }                                                                \
+    else {                                                           \
+        iptr->sx.val.c.ref   = (cr);                                 \
+        iptr->flags.bits     |= INS_FLAG_CLASS | INS_FLAG_UNRESOLVED \
+                             | (extraflags);                         \
+    }                                                                \
+    PINC
+
+#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_CHECK(c, cr)              \
+    OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS((c), (cr), INS_FLAG_CHECK)
+
+#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr)            \
+    OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS((c), (cr), 0)
+
+#define OP_S3_CLASSINFO_OR_CLASSREF(o, c, cr, extraflags)            \
+    OP_PREPARE(o);                                                   \
+    if (c) {                                                         \
+        iptr->sx.s23.s3.c.cls= (c);                                  \
+        iptr->flags.bits     |= (extraflags);                        \
+    }                                                                \
+    else {                                                           \
+        iptr->sx.s23.s3.c.ref= (cr);                                 \
+        iptr->flags.bits     |= INS_FLAG_UNRESOLVED | (extraflags);  \
+    }                                                                \
+    PINC
+
+#define OP_INSINDEX(o, iindex)                                       \
+    OP_PREPARE_ZEROFLAGS(o);                                         \
+    iptr->dst.insindex       = (iindex);                             \
+    PINC
+
+# define OP_LOCALINDEX(o,index)                                      \
+    OP_PREPARE_ZEROFLAGS(o);                                         \
+    iptr->s1.varindex      = (index);                                \
+    PINC
+
+# define OP_LOCALINDEX_I(o,index,v)                                  \
+    OP_PREPARE_ZEROFLAGS(o);                                         \
+    iptr->s1.varindex      = (index);                                \
+    iptr->sx.val.i           = (v);                                  \
+    PINC
+
+# define LOCALTYPE_USED(index,type)                                  \
+    do {                                                             \
+        local_map[(index) * 5 + (type)] = 1;                         \
+    } while (0)
+
+#define OP_LOAD_ONEWORD(o,index,type)                                \
+    do {                                                             \
+        INDEX_ONEWORD(index);                                        \
+        OP_LOCALINDEX(o,index);                                      \
+        LOCALTYPE_USED(index,type);                                  \
+    } while (0)
+
+#define OP_LOAD_TWOWORD(o,index,type)                                \
+    do {                                                             \
+        INDEX_TWOWORD(index);                                        \
+        OP_LOCALINDEX(o,index);                                      \
+        LOCALTYPE_USED(index,type);                                  \
+    } while (0)
+
+# define OP_STORE_ONEWORD(o,index,type)                              \
+    do {                                                             \
+        INDEX_ONEWORD(index);                                        \
+        OP_PREPARE_ZEROFLAGS(o);                                     \
+        iptr->dst.varindex = (index);                                \
+        LOCALTYPE_USED(index,type);                                  \
+        PINC;                                                        \
+    } while (0)
+
+# define OP_STORE_TWOWORD(o,index,type)                              \
+    do {                                                             \
+        INDEX_TWOWORD(index);                                        \
+        OP_PREPARE_ZEROFLAGS(o);                                     \
+        iptr->dst.varindex = (index);                                \
+        LOCALTYPE_USED(index,type);                                  \
+        PINC;                                                        \
+    } while (0)
+
+#define OP_BUILTIN_CHECK_EXCEPTION(bte)                              \
+    code_unflag_leafmethod(code);                                    \
+    OP_PREPARE_FLAGS(ICMD_BUILTIN, INS_FLAG_CHECK);                  \
+    iptr->sx.s23.s3.bte      = (bte);                                \
+    PINC
+
+#define OP_BUILTIN_NO_EXCEPTION(bte)                                 \
+    code_unflag_leafmethod(code);                                    \
+    OP_PREPARE_ZEROFLAGS(ICMD_BUILTIN);                              \
+    iptr->sx.s23.s3.bte      = (bte);                                \
+    PINC
+
+#define OP_BUILTIN_ARITHMETIC(opcode, bte)                           \
+    code_unflag_leafmethod(code);                                    \
+    OP_PREPARE_FLAGS(opcode, INS_FLAG_CHECK);                        \
+    iptr->sx.s23.s3.bte      = (bte);                                \
+    PINC
+
+/* CAUTION: You must set iptr->flags yourself when using this!                */
+#define OP_FMIREF_PREPARE(o, fmiref)                                 \
+    OP_PREPARE(o);                                                   \
+    iptr->sx.s23.s3.fmiref   = (fmiref);
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool parse(jitdata *jd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PARSE_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/jit/patcher-common.c b/src/vm/jit/patcher-common.c
deleted file mode 100644 (file)
index b3fbe30..0000000
+++ /dev/null
@@ -1,498 +0,0 @@
-/* src/vm/jit/patcher-common.c - architecture independent code patching stuff
-
-   Copyright (C) 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 <stdint.h>
-
-#include "codegen.h"                   /* for PATCHER_NOPS */
-#include "md.h"
-
-#include "mm/memory.h"
-
-#include "native/native.h"
-
-#include "threads/lock-common.h"
-
-#include "toolbox/list.h"
-#include "toolbox/logging.h"           /* XXX remove me! */
-
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/resolve.h"
-#include "vm/vm.h"                     /* for vm_abort */
-
-#include "vm/jit/code.h"
-#include "vm/jit/disass.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
-
-#include "vmcore/options.h"
-
-
-/* patcher_function_list *******************************************************
-
-   This is a list which maps patcher function pointers to the according
-   names of the patcher functions. It is only usefull for debugging
-   purposes.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-typedef struct patcher_function_list_t {
-       functionptr  patcher;
-       char        *name;
-} patcher_function_list_t;
-
-static patcher_function_list_t patcher_function_list[] = {
-       { PATCHER_initialize_class,              "initialize_class" },
-       { PATCHER_resolve_class,                 "resolve_class" },
-       { PATCHER_resolve_native_function,       "resolve_native_function" },
-       { PATCHER_invokestatic_special,          "invokestatic_special" },
-       { PATCHER_invokevirtual,                 "invokevirtual" },
-       { PATCHER_invokeinterface,               "invokeinterface" },
-       { NULL,                                  "-UNKNOWN PATCHER FUNCTION-" }
-};
-#endif
-
-
-/* patcher_list_create *********************************************************
-
-   Creates an empty patcher list for the given codeinfo.
-
-*******************************************************************************/
-
-void patcher_list_create(codeinfo *code)
-{
-       code->patchers = list_create(OFFSET(patchref_t, linkage));
-}
-
-
-/* patcher_list_reset **********************************************************
-
-   Resets the patcher list inside a codeinfo. This is usefull when
-   resetting a codeinfo for recompiling.
-
-*******************************************************************************/
-
-void patcher_list_reset(codeinfo *code)
-{
-       patchref_t *pr;
-
-       /* free all elements of the list */
-
-       while((pr = list_first(code->patchers)) != NULL) {
-               list_remove(code->patchers, pr);
-
-               FREE(pr, patchref_t);
-
-#if defined(ENABLE_STATISTICS)
-               if (opt_stat)
-                       size_patchref -= sizeof(patchref_t);
-#endif
-       }
-}
-
-/* patcher_list_free ***********************************************************
-
-   Frees the patcher list and all its entries for the given codeinfo.
-
-*******************************************************************************/
-
-void patcher_list_free(codeinfo *code)
-{
-       /* free all elements of the list */
-
-       patcher_list_reset(code);
-
-       /* free the list itself */
-
-       FREE(code->patchers, list_t);
-}
-
-
-/* patcher_list_find ***********************************************************
-
-   Find an entry inside the patcher list for the given codeinfo
-   by specifying the program counter of the patcher position.
-
-   NOTE: Caller should hold the patcher list lock or maintain
-   exclusive access otherwise.
-
-*******************************************************************************/
-
-static patchref_t *patcher_list_find(codeinfo *code, u1 *pc)
-{
-       patchref_t *pr;
-
-       /* walk through all patcher references for the given codeinfo */
-
-       pr = list_first(code->patchers);
-
-       while (pr) {
-
-/*#define TRACE_PATCHER_FIND*/
-#ifdef TRACE_PATCHER_FIND
-               log_println("patcher_list_find: %p == %p", pr->mpc, pc);
-#endif
-
-               if (pr->mpc == (ptrint) pc)
-                       return pr;
-
-               pr = list_next(code->patchers, pr);
-       }
-
-       return NULL;
-}
-
-
-/* patcher_add_patch_ref *******************************************************
-
-   Appends a new patcher reference to the list of patching positions.
-
-*******************************************************************************/
-
-void patcher_add_patch_ref(jitdata *jd, functionptr patcher, voidptr ref,
-                           s4 disp)
-{
-       codegendata *cd;
-       codeinfo    *code;
-       patchref_t  *pr;
-       s4           patchmpc;
-
-       cd       = jd->cd;
-       code     = jd->code;
-       patchmpc = cd->mcodeptr - cd->mcodebase;
-
-#if !defined(NDEBUG)
-       if (patcher_list_find(code, (u1 *) (intptr_t) patchmpc) != NULL)
-               vm_abort("patcher_add_patch_ref: different patchers at same position.");
-#endif
-
-       /* allocate patchref on heap (at least freed together with codeinfo) */
-
-       pr = NEW(patchref_t);
-       list_add_first(code->patchers, pr);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_patchref += sizeof(patchref_t);
-#endif
-
-       /* set patcher information (mpc is resolved later) */
-
-       pr->mpc     = patchmpc;
-       pr->disp    = disp;
-       pr->patcher = patcher;
-       pr->ref     = ref;
-       pr->mcode   = 0;
-       pr->done    = false;
-
-       /* Generate NOPs for opt_shownops. */
-
-       if (opt_shownops)
-               PATCHER_NOPS;
-
-#if defined(ENABLE_JIT) && (defined(__I386__) || defined(__M68K__) || defined(__SPARC_64__) || defined(__X86_64__))
-
-       /* XXX We can remove that when we don't use UD2 anymore on i386
-          and x86_64. */
-
-       /* On some architectures the patcher stub call instruction might
-          be longer than the actual instruction generated.  On this
-          architectures we store the last patcher call position and after
-          the basic block code generation is completed, we check the
-          range and maybe generate some nop's. */
-       /* The nops are generated in codegen_emit in each codegen */
-
-       cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE;
-#endif
-}
-
-
-/**
- * Resolve all patchers in the current JIT run.
- *
- * @param jd JIT data-structure
- */
-void patcher_resolve(jitdata* jd)
-{
-       codeinfo*   code;
-       patchref_t* pr;
-
-       /* Get required compiler data. */
-
-       code = jd->code;
-
-       for (pr = list_first(code->patchers); pr != NULL; pr = list_next(code->patchers, pr)) {
-               pr->mpc   += (intptr_t) code->entrypoint;
-               pr->datap  = (intptr_t) (pr->disp + code->entrypoint);
-       }
-}
-
-
-/* patcher_handler *************************************************************
-
-   Handles the request to patch JIT code at the given patching
-   position. This function is normally called by the signal
-   handler.
-
-   NOTE: The patcher list lock is used to maintain exclusive
-   access of the patched position (in fact of the whole code).
-   After patching has suceeded, the patcher reference should be
-   removed from the patcher list to avoid double patching.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-/* XXX this indent is not thread safe! */
-/* XXX if you want it thread safe, place patcher_depth in threadobject! */
-static int patcher_depth = 0;
-#define TRACE_PATCHER_INDENT for (i=0; i<patcher_depth; i++) printf("\t")
-#endif /* !defined(NDEBUG) */
-
-java_handle_t *patcher_handler(u1 *pc)
-{
-       codeinfo      *code;
-       patchref_t    *pr;
-       bool           result;
-       java_handle_t *e;
-#if !defined(NDEBUG)
-       patcher_function_list_t *l;
-       int                      i;
-#endif
-
-       /* define the patcher function */
-
-       bool (*patcher_function)(patchref_t *);
-
-       /* search the codeinfo for the given PC */
-
-       code = code_find_codeinfo_for_pc(pc);
-       assert(code);
-
-       /* enter a monitor on the patcher list */
-
-       LOCK_MONITOR_ENTER(code->patchers);
-
-       /* search the patcher information for the given PC */
-
-       pr = patcher_list_find(code, pc);
-
-       if (pr == NULL)
-               vm_abort("patcher_handler: Unable to find patcher reference.");
-
-       if (pr->done) {
-#if !defined(NDEBUG)
-               if (opt_DebugPatcher) {
-                       log_println("patcher_handler: double-patching detected!");
-               }
-#endif
-               LOCK_MONITOR_EXIT(code->patchers);
-               return NULL;
-       }
-
-#if !defined(NDEBUG)
-       if (opt_DebugPatcher) {
-               for (l = patcher_function_list; l->patcher != NULL; l++)
-                       if (l->patcher == pr->patcher)
-                               break;
-
-               TRACE_PATCHER_INDENT; printf("patching in "); method_print(code->m); printf(" at %p\n", (void *) pr->mpc);
-               TRACE_PATCHER_INDENT; printf("\tpatcher function = %s <%p>\n", l->name, (void *) (intptr_t) pr->patcher);
-
-               TRACE_PATCHER_INDENT;
-               printf("\tmachine code before = ");
-
-# if defined(ENABLE_DISASSEMBLER)
-               disassinstr((void *) pr->mpc);
-# else
-               printf("disassembler disabled\n");
-# endif
-
-               patcher_depth++;
-               assert(patcher_depth > 0);
-       }
-#endif
-
-       /* cast the passed function to a patcher function */
-
-       patcher_function = (bool (*)(patchref_t *)) (ptrint) pr->patcher;
-
-       /* call the proper patcher function */
-
-       result = (patcher_function)(pr);
-
-#if !defined(NDEBUG)
-       if (opt_DebugPatcher) {
-               assert(patcher_depth > 0);
-               patcher_depth--;
-
-               TRACE_PATCHER_INDENT;
-               printf("\tmachine code after  = ");
-
-# if defined(ENABLE_DISASSEMBLER)
-               disassinstr((void *) pr->mpc);
-# else
-               printf("disassembler disabled\n");
-# endif
-
-               if (result == false) {
-                       TRACE_PATCHER_INDENT; printf("\tPATCHER EXCEPTION!\n");
-               }
-       }
-#endif
-
-       /* check for return value and exit accordingly */
-
-       if (result == false) {
-               e = exceptions_get_and_clear_exception();
-
-               LOCK_MONITOR_EXIT(code->patchers);
-
-               return e;
-       }
-
-       pr->done = true; /* XXX this is only preliminary to prevent double-patching */
-
-       LOCK_MONITOR_EXIT(code->patchers);
-
-       return NULL;
-}
-
-
-/* patcher_initialize_class ****************************************************
-
-   Initalizes a given classinfo pointer.
-   This function does not patch any data.
-
-*******************************************************************************/
-
-bool patcher_initialize_class(patchref_t *pr)
-{
-       classinfo *c;
-
-       /* get stuff from the patcher reference */
-
-       c = (classinfo *) pr->ref;
-
-       /* check if the class is initialized */
-
-       if (!(c->state & CLASS_INITIALIZED))
-               if (!initialize_class(c))
-                       return false;
-
-       /* patch back original code */
-
-       patcher_patch_code(pr);
-
-       return true;
-}
-
-
-/* patcher_resolve_class *******************************************************
-
-   Resolves a given unresolved class reference.
-   This function does not patch any data.
-
-*******************************************************************************/
-
-#ifdef ENABLE_VERIFIER
-bool patcher_resolve_class(patchref_t *pr)
-{
-       unresolved_class *uc;
-
-       /* get stuff from the patcher reference */
-
-       uc = (unresolved_class *) pr->ref;
-
-       /* resolve the class and check subtype constraints */
-
-       if (!resolve_class_eager_no_access_check(uc))
-               return false;
-
-       /* patch back original code */
-
-       patcher_patch_code(pr);
-
-       return true;
-}
-#endif /* ENABLE_VERIFIER */
-
-
-/* patcher_resolve_native_function *********************************************
-
-   Resolves the native function for a given methodinfo.
-   This function patches one data segment word.
-
-*******************************************************************************/
-
-bool patcher_resolve_native_function(patchref_t *pr)
-{
-       methodinfo  *m;
-       uint8_t     *datap;
-       functionptr  f;
-
-       /* get stuff from the patcher reference */
-
-       m     = (methodinfo *) pr->ref;
-       datap = (uint8_t *)    pr->datap;
-
-       /* resolve native function */
-
-       if (!(f = native_method_resolve(m)))
-               return false;
-
-       /* patch native function pointer */
-
-       *((intptr_t *) datap) = (intptr_t) f;
-
-       /* synchronize data cache */
-
-       md_dcacheflush(datap, SIZEOF_VOID_P);
-
-       /* patch back original code */
-
-       patcher_patch_code(pr);
-
-       return true;
-}
-
-
-/*
- * 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/jit/patcher-common.cpp b/src/vm/jit/patcher-common.cpp
new file mode 100644 (file)
index 0000000..b4799b3
--- /dev/null
@@ -0,0 +1,521 @@
+/* src/vm/jit/patcher-common.cpp - architecture independent code patching stuff
+
+   Copyright (C) 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 <stdint.h>
+
+#include <algorithm>
+#include <functional>
+
+#include "codegen.h"                   /* for PATCHER_NOPS */
+#include "md.h"
+
+#include "mm/memory.h"
+
+#include "native/native.hpp"
+
+#include "toolbox/list.hpp"
+#include "toolbox/logging.h"           /* XXX remove me! */
+
+#include "vm/exceptions.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/resolve.hpp"
+#include "vm/vm.hpp"                     /* for vm_abort */
+
+#include "vm/jit/code.hpp"
+#include "vm/jit/disass.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/patcher-common.hpp"
+
+
+/* patcher_function_list *******************************************************
+
+   This is a list which maps patcher function pointers to the according
+   names of the patcher functions. It is only usefull for debugging
+   purposes.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+typedef struct patcher_function_list_t {
+       functionptr patcher;
+       const char* name;
+} patcher_function_list_t;
+
+static patcher_function_list_t patcher_function_list[] = {
+       { PATCHER_initialize_class,              "initialize_class" },
+       { PATCHER_resolve_class,                 "resolve_class" },
+       { PATCHER_resolve_native_function,       "resolve_native_function" },
+       { PATCHER_invokestatic_special,          "invokestatic_special" },
+       { PATCHER_invokevirtual,                 "invokevirtual" },
+       { PATCHER_invokeinterface,               "invokeinterface" },
+       { NULL,                                  "-UNKNOWN PATCHER FUNCTION-" }
+};
+#endif
+
+
+/* patcher_list_create *********************************************************
+
+   Creates an empty patcher list for the given codeinfo.
+
+*******************************************************************************/
+
+void patcher_list_create(codeinfo *code)
+{
+       code->patchers = new List<patchref_t>();
+}
+
+
+/* patcher_list_reset **********************************************************
+
+   Resets the patcher list inside a codeinfo. This is usefull when
+   resetting a codeinfo for recompiling.
+
+*******************************************************************************/
+
+void patcher_list_reset(codeinfo *code)
+{
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_patchref -= sizeof(patchref_t) * code->patchers->size();
+#endif
+
+       // Free all elements of the list.
+       code->patchers->clear();
+}
+
+/* patcher_list_free ***********************************************************
+
+   Frees the patcher list and all its entries for the given codeinfo.
+
+*******************************************************************************/
+
+void patcher_list_free(codeinfo *code)
+{
+       // Free all elements of the list.
+       patcher_list_reset(code);
+
+       // Free the list itself.
+       delete code->patchers;
+}
+
+
+/**
+ * Find an entry inside the patcher list for the given codeinfo by
+ * specifying the program counter of the patcher position.
+ *
+ * NOTE: Caller should hold the patcher list lock or maintain
+ * exclusive access otherwise.
+ *
+ * @param pc Program counter to find.
+ *
+ * @return Pointer to patcher.
+ */
+
+struct foo : public std::binary_function<patchref_t, void*, bool> {
+       bool operator() (const patchref_t& pr, const void* pc) const
+       {
+               return (pr.mpc == (uintptr_t) pc);
+       }
+};
+
+static patchref_t* patcher_list_find(codeinfo* code, void* pc)
+{
+       // Search for a patcher with the given PC.
+       List<patchref_t>::iterator it = std::find_if(code->patchers->begin(), code->patchers->end(), std::bind2nd(foo(), pc));
+
+       if (it == code->patchers->end())
+               return NULL;
+
+       return &(*it);
+}
+
+
+/* patcher_add_patch_ref *******************************************************
+
+   Appends a new patcher reference to the list of patching positions.
+
+*******************************************************************************/
+
+void patcher_add_patch_ref(jitdata *jd, functionptr patcher, void* ref, s4 disp)
+{
+       codegendata *cd;
+       codeinfo    *code;
+       s4           patchmpc;
+
+       cd       = jd->cd;
+       code     = jd->code;
+       patchmpc = cd->mcodeptr - cd->mcodebase;
+
+#if !defined(NDEBUG)
+       if (patcher_list_find(code, (void*) (intptr_t) patchmpc) != NULL)
+               vm_abort("patcher_add_patch_ref: different patchers at same position.");
+#endif
+
+       // Set patcher information (mpc is resolved later).
+       patchref_t pr;
+
+       pr.mpc     = patchmpc;
+       pr.datap   = 0;
+       pr.disp    = disp;
+       pr.patcher = patcher;
+       pr.ref     = ref;
+       pr.mcode   = 0;
+       pr.done    = false;
+
+       // Store patcher in the list (NOTE: structure is copied).
+       code->patchers->push_back(pr);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_patchref += sizeof(patchref_t);
+#endif
+
+#if defined(ENABLE_JIT) && (defined(__I386__) || defined(__M68K__) || defined(__SPARC_64__) || defined(__X86_64__))
+
+       /* XXX We can remove that when we don't use UD2 anymore on i386
+          and x86_64. */
+
+       /* On some architectures the patcher stub call instruction might
+          be longer than the actual instruction generated.  On this
+          architectures we store the last patcher call position and after
+          the basic block code generation is completed, we check the
+          range and maybe generate some nop's. */
+       /* The nops are generated in codegen_emit in each codegen */
+
+       cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE;
+#endif
+}
+
+
+/**
+ * Resolve all patchers in the current JIT run.
+ *
+ * @param jd JIT data-structure
+ */
+void patcher_resolve(jitdata* jd)
+{
+       // Get required compiler data.
+       codeinfo* code = jd->code;
+
+       for (List<patchref_t>::iterator it = code->patchers->begin(); it != code->patchers->end(); it++) {
+               patchref_t& pr = *it;
+
+               pr.mpc   += (intptr_t) code->entrypoint;
+               pr.datap  = (intptr_t) (pr.disp + code->entrypoint);
+       }
+}
+
+
+/**
+ * Check if the patcher is already patched.  This is done by comparing
+ * the machine instruction.
+ *
+ * @param pr Patcher structure.
+ *
+ * @return true if patched, false otherwise.
+ */
+bool patcher_is_patched(patchref_t* pr)
+{
+       // Validate the instruction at the patching position is the same
+       // instruction as the patcher structure contains.
+       uint32_t mcode = *((uint32_t*) pr->mpc);
+
+       if (mcode != pr->mcode) {
+               // The code differs.
+               return false;
+       }
+
+       return true;
+}
+
+
+/**
+ *
+ */
+bool patcher_is_patched_at(void* pc)
+{
+       codeinfo* code = code_find_codeinfo_for_pc(pc);
+
+       // Get the patcher for the given PC.
+       patchref_t* pr = patcher_list_find(code, pc);
+
+       if (pr == NULL) {
+               // The given PC is not a patcher position.
+               return false;
+       }
+
+       // Validate the instruction.
+       return patcher_is_patched(pr);
+}
+
+
+/* patcher_handler *************************************************************
+
+   Handles the request to patch JIT code at the given patching
+   position. This function is normally called by the signal
+   handler.
+
+   NOTE: The patcher list lock is used to maintain exclusive
+   access of the patched position (in fact of the whole code).
+   After patching has suceeded, the patcher reference should be
+   removed from the patcher list to avoid double patching.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+/* XXX this indent is not thread safe! */
+/* XXX if you want it thread safe, place patcher_depth in threadobject! */
+static int patcher_depth = 0;
+#define TRACE_PATCHER_INDENT for (i=0; i<patcher_depth; i++) printf("\t")
+#endif /* !defined(NDEBUG) */
+
+java_handle_t *patcher_handler(u1 *pc)
+{
+       codeinfo      *code;
+       patchref_t    *pr;
+       bool           result;
+       java_handle_t *e;
+#if !defined(NDEBUG)
+       patcher_function_list_t *l;
+       int                      i;
+#endif
+
+       /* define the patcher function */
+
+       bool (*patcher_function)(patchref_t *);
+
+       /* search the codeinfo for the given PC */
+
+       code = code_find_codeinfo_for_pc(pc);
+       assert(code);
+
+       // Enter a mutex on the patcher list.
+       code->patchers->lock();
+
+       /* search the patcher information for the given PC */
+
+       pr = patcher_list_find(code, pc);
+
+       if (pr == NULL)
+               vm_abort("patcher_handler: Unable to find patcher reference.");
+
+       if (pr->done) {
+#if !defined(NDEBUG)
+               if (opt_DebugPatcher) {
+                       log_println("patcher_handler: double-patching detected!");
+               }
+#endif
+               code->patchers->unlock();
+               return NULL;
+       }
+
+#if !defined(NDEBUG)
+       if (opt_DebugPatcher) {
+               for (l = patcher_function_list; l->patcher != NULL; l++)
+                       if (l->patcher == pr->patcher)
+                               break;
+
+               TRACE_PATCHER_INDENT; printf("patching in "); method_print(code->m); printf(" at %p\n", (void *) pr->mpc);
+               TRACE_PATCHER_INDENT; printf("\tpatcher function = %s <%p>\n", l->name, (void *) (intptr_t) pr->patcher);
+
+               TRACE_PATCHER_INDENT;
+               printf("\tmachine code before = ");
+
+# if defined(ENABLE_DISASSEMBLER)
+               disassinstr((u1*) (void*) pr->mpc);
+# else
+               printf("%x at %p (disassembler disabled)\n", *((uint32_t*) pr->mpc), (void*) pr->mpc);
+# endif
+
+               patcher_depth++;
+               assert(patcher_depth > 0);
+       }
+#endif
+
+       /* cast the passed function to a patcher function */
+
+       patcher_function = (bool (*)(patchref_t *)) (ptrint) pr->patcher;
+
+       /* call the proper patcher function */
+
+       result = (patcher_function)(pr);
+
+#if !defined(NDEBUG)
+       if (opt_DebugPatcher) {
+               assert(patcher_depth > 0);
+               patcher_depth--;
+
+               TRACE_PATCHER_INDENT;
+               printf("\tmachine code after  = ");
+
+# if defined(ENABLE_DISASSEMBLER)
+               disassinstr((u1*) (void*) pr->mpc);
+# else
+               printf("%x at %p (disassembler disabled)\n", *((uint32_t*) pr->mpc), (void*) pr->mpc);
+# endif
+
+               if (result == false) {
+                       TRACE_PATCHER_INDENT; printf("\tPATCHER EXCEPTION!\n");
+               }
+       }
+#endif
+
+       /* check for return value and exit accordingly */
+
+       if (result == false) {
+               e = exceptions_get_and_clear_exception();
+
+               code->patchers->unlock();
+
+               return e;
+       }
+
+       pr->done = true; /* XXX this is only preliminary to prevent double-patching */
+
+       code->patchers->unlock();
+
+       return NULL;
+}
+
+
+/* patcher_initialize_class ****************************************************
+
+   Initalizes a given classinfo pointer.
+   This function does not patch any data.
+
+*******************************************************************************/
+
+bool patcher_initialize_class(patchref_t *pr)
+{
+       classinfo *c;
+
+       /* get stuff from the patcher reference */
+
+       c = (classinfo *) pr->ref;
+
+       /* check if the class is initialized */
+
+       if (!(c->state & CLASS_INITIALIZED))
+               if (!initialize_class(c))
+                       return false;
+
+       /* patch back original code */
+
+       patcher_patch_code(pr);
+
+       return true;
+}
+
+
+/* patcher_resolve_class *******************************************************
+
+   Resolves a given unresolved class reference.
+   This function does not patch any data.
+
+*******************************************************************************/
+
+#ifdef ENABLE_VERIFIER
+bool patcher_resolve_class(patchref_t *pr)
+{
+       unresolved_class *uc;
+
+       /* get stuff from the patcher reference */
+
+       uc = (unresolved_class *) pr->ref;
+
+       /* resolve the class and check subtype constraints */
+
+       if (!resolve_class_eager_no_access_check(uc))
+               return false;
+
+       /* patch back original code */
+
+       patcher_patch_code(pr);
+
+       return true;
+}
+#endif /* ENABLE_VERIFIER */
+
+
+/* patcher_resolve_native_function *********************************************
+
+   Resolves the native function for a given methodinfo.
+   This function patches one data segment word.
+
+*******************************************************************************/
+
+bool patcher_resolve_native_function(patchref_t *pr)
+{
+       methodinfo  *m;
+       uint8_t     *datap;
+
+       /* get stuff from the patcher reference */
+
+       m     = (methodinfo *) pr->ref;
+       datap = (uint8_t *)    pr->datap;
+
+       /* resolve native function */
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       void* f = nm.resolve_method(m);
+
+       if (f == NULL)
+               return false;
+
+       /* patch native function pointer */
+
+       *((intptr_t*) datap) = (intptr_t) f;
+
+       /* synchronize data cache */
+
+       md_dcacheflush(datap, SIZEOF_VOID_P);
+
+       /* patch back original code */
+
+       patcher_patch_code(pr);
+
+       return true;
+}
+
+
+/*
+ * 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/jit/patcher-common.h b/src/vm/jit/patcher-common.h
deleted file mode 100644 (file)
index a103447..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/* src/vm/jit/patcher-common.h - architecture independent code patching stuff
-
-   Copyright (C) 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
-
-   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 _PATCHER_COMMON_H
-#define _PATCHER_COMMON_H
-
-/* forward typedefs ***********************************************************/
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "toolbox/list.h"
-
-#include "vm/global.h"
-
-#include "vm/jit/jit.h"
-
-
-/* patchref_t ******************************************************************
-
-   A patcher reference contains information about a code position
-   which needs additional code patching during runtime.
-
-*******************************************************************************/
-
-typedef struct patchref_t {
-       ptrint       mpc;           /* absolute position in code segment          */
-       ptrint       datap;         /* absolute position in data segment          */
-       s4           disp;          /* displacement of ref in the data segment    */
-       functionptr  patcher;       /* patcher function to call                   */
-       voidptr      ref;           /* reference passed                           */
-       u8           mcode;         /* machine code to be patched back in         */
-       bool         done;          /* XXX preliminary: patch already applied?    */
-       listnode_t   linkage;
-} patchref_t;
-
-
-/* macros *********************************************************************/
-
-
-/* function prototypes ********************************************************/
-
-void patcher_list_create(codeinfo *code);
-void patcher_list_reset(codeinfo *code);
-void patcher_list_free(codeinfo *code);
-
-void patcher_add_patch_ref(jitdata *jd, functionptr patcher, voidptr ref,
-                           s4 disp);
-
-void patcher_resolve(jitdata* jd);
-
-java_handle_t *patcher_handler(u1 *pc);
-
-
-/* empty patcher (just patches back original mcode) ***************************/
-
-void patcher_patch_code(patchref_t *pr);
-
-
-/* patcher prototypes and macros **********************************************/
-
-/* new patcher functions */
-
-bool patcher_resolve_class(patchref_t *pr);
-#define PATCHER_resolve_class (functionptr) patcher_resolve_class
-
-bool patcher_initialize_class(patchref_t *pr);
-#define PATCHER_initialize_class (functionptr) patcher_initialize_class
-
-bool patcher_resolve_classref_to_classinfo(patchref_t *pr);
-#define PATCHER_resolve_classref_to_classinfo (functionptr) patcher_resolve_classref_to_classinfo
-
-bool patcher_resolve_classref_to_vftbl(patchref_t *pr);
-#define PATCHER_resolve_classref_to_vftbl (functionptr) patcher_resolve_classref_to_vftbl
-
-bool patcher_resolve_classref_to_index(patchref_t *pr);
-#define PATCHER_resolve_classref_to_index (functionptr) patcher_resolve_classref_to_index
-
-bool patcher_resolve_classref_to_flags(patchref_t *pr);
-#define PATCHER_resolve_classref_to_flags (functionptr) patcher_resolve_classref_to_flags
-
-bool patcher_resolve_native_function(patchref_t *pr);
-#define PATCHER_resolve_native_function (functionptr) patcher_resolve_native_function
-
-/* old patcher functions */
-
-bool patcher_get_putstatic(patchref_t *pr);
-#define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
-
-#if defined(__I386__)
-
-bool patcher_getfield(patchref_t *pr);
-#define PATCHER_getfield (functionptr) patcher_getfield
-
-bool patcher_putfield(patchref_t *pr);
-#define PATCHER_putfield (functionptr) patcher_putfield
-
-#else
-
-bool patcher_get_putfield(patchref_t *pr);
-#define PATCHER_get_putfield (functionptr) patcher_get_putfield
-
-#endif /* defined(__I386__) */
-
-#if defined(__I386__) || defined(__X86_64__)
-
-bool patcher_putfieldconst(patchref_t *pr);
-#define PATCHER_putfieldconst (functionptr) patcher_putfieldconst
-
-#endif /* defined(__I386__) || defined(__X86_64__) */
-
-bool patcher_invokestatic_special(patchref_t *pr);
-#define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special
-
-bool patcher_invokevirtual(patchref_t *pr);
-#define PATCHER_invokevirtual (functionptr) patcher_invokevirtual
-
-bool patcher_invokeinterface(patchref_t *pr);
-#define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
-
-#if defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__)
-
-bool patcher_checkcast_interface(patchref_t *pr);
-#define PATCHER_checkcast_interface (functionptr) patcher_checkcast_interface
-
-bool patcher_instanceof_interface(patchref_t *pr);
-#define PATCHER_instanceof_interface (functionptr) patcher_instanceof_interface
-
-#endif /* defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__) */
-
-#if defined(__S390__)
-
-bool patcher_checkcast_instanceof_interface(patchref_t *pr);
-#define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
-
-#endif /* defined(__S390__) */
-
-#if defined(__I386__)
-
-bool patcher_aconst(patchref_t *pr);
-#define PATCHER_aconst (functionptr) patcher_aconst
-
-bool patcher_builtin_multianewarray(patchref_t *pr);
-#define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
-
-bool patcher_builtin_arraycheckcast(patchref_t *pr);
-#define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
-
-bool patcher_checkcast_instanceof_flags(patchref_t *pr);
-#define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
-
-bool patcher_checkcast_class(patchref_t *pr);
-#define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
-
-bool patcher_instanceof_class(patchref_t *pr);
-#define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
-
-#endif /* defined(__I386__) */
-
-
-#endif /* _PATCHER_COMMON_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/jit/patcher-common.hpp b/src/vm/jit/patcher-common.hpp
new file mode 100644 (file)
index 0000000..72ed1ec
--- /dev/null
@@ -0,0 +1,211 @@
+/* src/vm/jit/patcher-common.hpp - architecture independent code patching stuff
+
+   Copyright (C) 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 _PATCHER_COMMON_HPP
+#define _PATCHER_COMMON_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct patchref_t patchref_t;
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "toolbox/list.hpp"
+
+#include "vm/global.h"
+
+#include "vm/jit/jit.hpp"
+
+
+/* patchref_t ******************************************************************
+
+   A patcher reference contains information about a code position
+   which needs additional code patching during runtime.
+
+*******************************************************************************/
+
+struct patchref_t {
+       ptrint       mpc;           /* absolute position in code segment          */
+       ptrint       datap;         /* absolute position in data segment          */
+       s4           disp;          /* displacement of ref in the data segment    */
+       functionptr  patcher;       /* patcher function to call                   */
+       void*        ref;           /* reference passed                           */
+       uint32_t     mcode;         /* machine code to be patched back in         */
+       bool         done;          /* XXX preliminary: patch already applied?    */
+};
+
+
+/* macros *********************************************************************/
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void patcher_list_create(codeinfo *code);
+void patcher_list_reset(codeinfo *code);
+void patcher_list_free(codeinfo *code);
+
+void patcher_add_patch_ref(jitdata *jd, functionptr patcher, void* ref, s4 disp);
+
+void patcher_resolve(jitdata* jd);
+
+bool patcher_is_patched(patchref_t* pr);
+bool patcher_is_patched_at(void* pc);
+
+// MD function.
+bool patcher_is_valid_trap_instruction_at(void* pc);
+
+java_handle_t *patcher_handler(u1 *pc);
+
+
+/* empty patcher (just patches back original mcode) ***************************/
+
+void patcher_patch_code(patchref_t *pr);
+
+
+/* patcher prototypes and macros **********************************************/
+
+/* new patcher functions */
+
+bool patcher_resolve_class(patchref_t *pr);
+#define PATCHER_resolve_class (functionptr) patcher_resolve_class
+
+bool patcher_initialize_class(patchref_t *pr);
+#define PATCHER_initialize_class (functionptr) patcher_initialize_class
+
+bool patcher_resolve_classref_to_classinfo(patchref_t *pr);
+#define PATCHER_resolve_classref_to_classinfo (functionptr) patcher_resolve_classref_to_classinfo
+
+bool patcher_resolve_classref_to_vftbl(patchref_t *pr);
+#define PATCHER_resolve_classref_to_vftbl (functionptr) patcher_resolve_classref_to_vftbl
+
+bool patcher_resolve_classref_to_index(patchref_t *pr);
+#define PATCHER_resolve_classref_to_index (functionptr) patcher_resolve_classref_to_index
+
+bool patcher_resolve_classref_to_flags(patchref_t *pr);
+#define PATCHER_resolve_classref_to_flags (functionptr) patcher_resolve_classref_to_flags
+
+bool patcher_resolve_native_function(patchref_t *pr);
+#define PATCHER_resolve_native_function (functionptr) patcher_resolve_native_function
+
+/* old patcher functions */
+
+bool patcher_get_putstatic(patchref_t *pr);
+#define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
+
+#if defined(__I386__)
+
+bool patcher_getfield(patchref_t *pr);
+#define PATCHER_getfield (functionptr) patcher_getfield
+
+bool patcher_putfield(patchref_t *pr);
+#define PATCHER_putfield (functionptr) patcher_putfield
+
+#else
+
+bool patcher_get_putfield(patchref_t *pr);
+#define PATCHER_get_putfield (functionptr) patcher_get_putfield
+
+#endif /* defined(__I386__) */
+
+#if defined(__I386__) || defined(__X86_64__)
+
+bool patcher_putfieldconst(patchref_t *pr);
+#define PATCHER_putfieldconst (functionptr) patcher_putfieldconst
+
+#endif /* defined(__I386__) || defined(__X86_64__) */
+
+bool patcher_invokestatic_special(patchref_t *pr);
+#define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special
+
+bool patcher_invokevirtual(patchref_t *pr);
+#define PATCHER_invokevirtual (functionptr) patcher_invokevirtual
+
+bool patcher_invokeinterface(patchref_t *pr);
+#define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
+
+#if defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__)
+
+bool patcher_checkcast_interface(patchref_t *pr);
+#define PATCHER_checkcast_interface (functionptr) patcher_checkcast_interface
+
+bool patcher_instanceof_interface(patchref_t *pr);
+#define PATCHER_instanceof_interface (functionptr) patcher_instanceof_interface
+
+#endif /* defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__) */
+
+#if defined(__S390__)
+
+bool patcher_checkcast_instanceof_interface(patchref_t *pr);
+#define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
+
+#endif /* defined(__S390__) */
+
+#if defined(__I386__)
+
+bool patcher_aconst(patchref_t *pr);
+#define PATCHER_aconst (functionptr) patcher_aconst
+
+bool patcher_builtin_multianewarray(patchref_t *pr);
+#define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
+
+bool patcher_builtin_arraycheckcast(patchref_t *pr);
+#define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
+
+bool patcher_checkcast_instanceof_flags(patchref_t *pr);
+#define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
+
+bool patcher_checkcast_class(patchref_t *pr);
+#define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
+
+bool patcher_instanceof_class(patchref_t *pr);
+#define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
+
+#endif /* defined(__I386__) */
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PATCHER_COMMON_HPP
+
+
+/*
+ * 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 d8e59bfa4957cc271a752439dc3524ccbcbc22a1..730fb9d8f6cf74de04fea6cdd51418576b3b9105 100644 (file)
@@ -35,7 +35,7 @@ LIBS =
 
 noinst_HEADERS = \
        arch.h \
-       machine-instr.h
+       md-atomic.hpp
 
 noinst_LTLIBRARIES = \
        libarch.la
@@ -53,6 +53,7 @@ libarch_la_SOURCES = \
        emit.c \
        patcher.c \
        \
+       md-stubs.hpp \
        md-trap.h \
        md.c \
        md.h
index 13f7b158b11c9bce60a144be3756dbd4b198f9c8..ca0efa5a4512997f72f226678d00135147e684d8 100644 (file)
@@ -35,8 +35,6 @@
 
 /* define architecture features ***********************************************/
 
-#define U8_AVAILABLE                     1
-
 #define SUPPORT_DIVISION                 1
 #define SUPPORT_LONG                     1
 
index 3413a354f16384a5bb3df4b84558db4a4aa7543d..cae9439fa6471ab1170a558a1c176a946e9f57bc 100644 (file)
@@ -57,9 +57,6 @@
 
        .globl asm_cacheflush
 
-       .globl asm_compare_and_swap
-       .globl asm_memory_barrier
-
 
 /* asm_vm_call_method **********************************************************
 *                                                                              *
@@ -463,36 +460,6 @@ asm_cacheflush:
        blr
 
 
-/* asm_compare_and_swap ********************************************************
-
-   XXX
-
-*******************************************************************************/
-
-asm_compare_and_swap:
-1:
-       lwarx   a6,0,a0 
-       subf.   r0,a6,a1 
-       bne-    2f 
-       or      r0,a2,a2 
-       stwcx.  r0,0,a0 
-       bne-    1b 
-2: 
-       mr      a0,a6
-       blr
-
-
-/* asm_memory_barrier **********************************************************
-
-   XXX
-
-*******************************************************************************/
-
-asm_memory_barrier:
-       sync
-       blr
-
-
 #if defined(__DARWIN__)
 
 .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
index 378a7279e180dbdd2ebf1dcc2dcb4894680a22dc..dcfc0482e276bfe38417c7cbebd7ecc8ca58ab41 100644 (file)
 
 #include "mm/memory.h"
 
-#include "native/localref.h"
-#include "native/native.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/methodheader.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #if defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
 #endif
 
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
 
 /* codegen *********************************************************************
 
@@ -2439,9 +2437,6 @@ gen_method:
                                        superindex = super->index;
                                }
 
-                               if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                                       CODEGEN_CRITICAL_SECTION_NEW;
-
                                s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                                /* if class is not resolved, check which code to call */
@@ -2514,16 +2509,12 @@ gen_method:
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl));
 
-                                       CODEGEN_CRITICAL_SECTION_START;
-
                                        M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                        M_ALD(REG_ITMP2, REG_PV, disp);
                                        if (s1 != REG_ITMP1) {
                                                M_ILD(REG_ITMP1, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 
-                                               CODEGEN_CRITICAL_SECTION_END;
-
                                                M_ISUB(REG_ITMP3, REG_ITMP1, REG_ITMP3);
                                        }
                                        else {
@@ -2531,8 +2522,6 @@ gen_method:
                                                M_ISUB(REG_ITMP3, REG_ITMP2, REG_ITMP3);
                                                M_ALD(REG_ITMP2, REG_PV, disp);
                                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
-
-                                               CODEGEN_CRITICAL_SECTION_END;
                                        }
                                        M_CMPU(REG_ITMP3, REG_ITMP2);
                                        emit_classcast_check(cd, iptr, BRANCH_GT, REG_ITMP3, s1);
@@ -2594,9 +2583,6 @@ gen_method:
                                superindex = super->index;
                        }
                        
-                       if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                               CODEGEN_CRITICAL_SECTION_NEW;
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
@@ -2675,14 +2661,10 @@ gen_method:
                                M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl));
                                M_ALD(REG_ITMP2, REG_PV, disp);
 
-                               CODEGEN_CRITICAL_SECTION_START;
-
                                M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 
-                               CODEGEN_CRITICAL_SECTION_END;
-
                                M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                M_CMPU(REG_ITMP1, REG_ITMP2);
                                M_CLR(d);
@@ -2985,7 +2967,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
                /* put env into first argument register */
 
-               disp = dseg_add_address(cd, _Jv_env);
+               disp = dseg_add_address(cd, VM_get_jnienv());
                M_ALD(REG_A0, REG_PV, disp);
        }
 
index ea6f9843546d91b19d233bc4ddc1d7abc1c85215..8ed75e85cb5c91cacd3420f036c4c2830930059c 100644 (file)
@@ -32,7 +32,7 @@
 #include "md-abi.h"
 
 #include "vm/global.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
 
 
     } while (0)
 
 
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE    1 * 4
-
-
 /* macros to create code ******************************************************/
 
 #define M_OP3(opcode,y,oe,rc,d,a,b) \
 #define MI_and(rA,rS,rB)                M_OP3(31,  28, 0, 0, rS, rA, rB)
 #define MI_anddot(rA,rS,rB)             M_OP3(31,  28, 0, 1, rS, rA, rB)
 #define MI_andi(rA,rS,UIMM)             M_OP2_IMM(28, rS, rA, UIMM)
+#define MI_illegal                      M_OP3( 0,   0, 0, 0,  0,  0,  0)
 #define MI_lwarx(rD,rA,rB)              M_OP3(31,  20, 0, 0, rD, rA, rB)
 #define MI_or(rA,rS,rB)                 M_OP3(31, 444, 0, 0, rS, rA, rB)
 #define MI_ordot(rA,rS,rB)              M_OP3(31, 444, 0, 1, rS, rA, rB)
 
 #define M_IAND(a,b,d)                   MI_and(d, a, b)
 #define M_IAND_IMM(a,b,d)               MI_andi(d, a, b)
+#define M_ILLEGAL                       MI_illegal
 #define M_IOR(a,b,d)                    MI_or(d, a, b)
 #define M_IOR_IMM(a,b,d)                MI_ori(d, a, b)
 #define M_IOR_TST(a,b,d)                MI_ordot(d, a, b)
index 783991af9aab3f00461445f2daca116524c2abe7..68899b4eed91f0bd048674cd78691b49a7cbb961 100644 (file)
 
 #include "vm/jit/powerpc/darwin/md-abi.h"
 
+#include "vm/descriptor.h"
 #include "vm/global.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/stack.h"
 
-#include "vmcore/descriptor.h"
-
 
 /* register descripton arrays *************************************************/
 
index 44b0f73d81afcd986dd97a9e6ec9ba96ae051287..d2e6bf2313e963153948df503ede60f17255d6aa 100644 (file)
 #include "vm/jit/powerpc/codegen.h"
 #include "vm/jit/powerpc/darwin/md-abi.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
 #include "vm/global.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
 
 
 /* md_signal_handler_sigsegv ***************************************************
@@ -251,34 +248,6 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 }
 
 
-/* md_critical_section_restart *************************************************
-
-   Search the critical sections tree for a matching section and set
-   the PC to the restart point, if necessary.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
-{
-       mcontext_t          _mc;
-       ppc_thread_state_t *_ss;
-       u1                 *pc;
-       u1                 *npc;
-
-       _mc = _uc->uc_mcontext;
-       _ss = &_mc->ss;
-
-       pc = (u1 *) _ss->srr0;
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL)
-               _ss->srr0 = (ptrint) npc;
-}
-#endif
-
-
 /*
  * 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
index 65927bb8a8260ff856c2d51345e403f4cda7d747..66221d67d115adbbdcd0aeec1ce1697bb31027db 100644 (file)
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/exceptions.h"
+#include "vm/options.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/trace.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/options.h"
-
 
 /* emit_load *******************************************************************
 
@@ -346,36 +344,46 @@ void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 opt)
                                                          CODEGENDATA_FLAG_LONGBRANCHES);
                        }
 
-                       switch (condition) {
-                       case BRANCH_EQ:
-                               M_BNE(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_NE:
-                               M_BEQ(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_LT:
-                               M_BGE(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_GE:
-                               M_BLT(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_GT:
-                               M_BLE(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_LE:
-                               M_BGT(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_NAN:
-                               vm_abort("emit_branch: long BRANCH_NAN");
-                               break;
-                       default:
-                               vm_abort("emit_branch: unknown condition %d", condition);
+                       // Subtract 1 instruction from the displacement as the
+                       // actual branch is the second instruction.
+                       checkdisp  = checkdisp - 4;
+                       branchdisp = branchdisp - 1;
+
+                       if ((checkdisp < (int32_t) 0xfe000000) || (checkdisp > (int32_t) 0x01fffffc)) {
+                               vm_abort("emit_branch: emit conditional long-branch code");
+                       }
+                       else {
+                               switch (condition) {
+                               case BRANCH_EQ:
+                                       M_BNE(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_NE:
+                                       M_BEQ(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_LT:
+                                       M_BGE(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_GE:
+                                       M_BLT(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_GT:
+                                       M_BLE(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_LE:
+                                       M_BGT(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_NAN:
+                                       vm_abort("emit_branch: long BRANCH_NAN");
+                                       break;
+                               default:
+                                       vm_abort("emit_branch: unknown condition %d", condition);
+                               }
                        }
                }
                else {
@@ -535,14 +543,11 @@ void emit_trap_compiler(codegendata *cd)
 
 uint32_t emit_trap(codegendata *cd)
 {
-       uint32_t mcode;
-
-       /* Get machine code which is patched back in later. The
-          trap is 1 instruction word long. */
-
-       mcode = *((uint32_t *) cd->mcodeptr);
+       // Get machine code which is patched back in later. The rap is 1
+       // instruction word long.
+       uint32_t mcode = *((uint32_t*) cd->mcodeptr);
 
-       M_ALD_INTERN(REG_ZERO, REG_ZERO, TRAP_PATCHER);
+       M_ILLEGAL;
 
        return mcode;
 }
index af175d4cac72d7a5fe22a199779de0200101537b..df5af31dbfbdf1d354915418c61458a22a099666 100644 (file)
 
 #include "vm/jit/powerpc/linux/md-abi.h"
 
+#include "vm/descriptor.h"
 #include "vm/global.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/stack.h"
 
-#include "vmcore/descriptor.h"
-
 
 /* register descripton arrays *************************************************/
 
index beab97d872476f00447b035adfc4ce09943965b7..e59a84cbb1813b29b7e3f0194d8b4877e7041f74 100644 (file)
@@ -2,6 +2,7 @@
 
    Copyright (C) 1996-2005, 2006, 2007, 2008
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
 
    This file is part of CACAO.
 
 #include "vm/jit/powerpc/md.h"
 #include "vm/jit/powerpc/linux/md-abi.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
+#include "vm/os.hpp"
 
 #include "vm/jit/asmpart.h"
+#include "vm/jit/disass.h"
 #include "vm/jit/executionstate.h"
 
 #if defined(ENABLE_PROFILING)
 # include "vm/jit/optimizing/profile.h"
 #endif
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/system.h"
-
 
 /* md_signal_handler_sigsegv ***************************************************
 
@@ -77,7 +76,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        intptr_t        addr;
        intptr_t        val;
        int             type;
-       void           *p;
 
        _uc = (ucontext_t *) _p;
 
@@ -128,43 +126,59 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
+}
 
-       switch (type) {
-       case TRAP_COMPILER:
-               if (p != NULL) {
-                       _gregs[REG_PV] = (uintptr_t) p;
-                       _gregs[PT_NIP] = (uintptr_t) p;
-                       break;
-               }
 
-               /* Get and set the PV from the parent Java method. */
+/**
+ * Signal handler for patcher calls.
+ */
+void md_signal_handler_sigill(int sig, siginfo_t* siginfo, void* _p)
+{
+       ucontext_t* _uc = (ucontext_t*) _p;
+       mcontext_t* _mc;
+       unsigned long* _gregs;
 
-               pv = md_codegen_get_pv_from_pc(ra);
+#if defined(__UCLIBC__)
+       _mc    = &(_uc->uc_mcontext);
+       _gregs = _mc->regs->gpr;
+#else
+       _mc    = _uc->uc_mcontext.uc_regs;
+       _gregs = _mc->gregs;
+#endif
 
-               _gregs[REG_PV] = (uintptr_t) pv;
+       /* get register values */
 
-               /* Get the exception object. */
+       void* pv = (void*) _gregs[REG_PV];
+       void* sp = (void*) _gregs[REG_SP];
+       void* ra = (void*) _gregs[PT_LNK]; // The RA is correct for leag methods.
+       void* xpc =(void*) _gregs[PT_NIP];
 
-               p = builtin_retrieve_exception();
+       // Get the illegal-instruction.
+       uint32_t mcode = *((uint32_t*) xpc);
 
-               assert(p != NULL);
+       // Check if the trap instruction is valid.
+       // TODO Move this into patcher_handler.
+       if (patcher_is_valid_trap_instruction_at(xpc) == false) {
+               // Check if the PC has been patched during our way to this
+               // signal handler (see PR85).
+               if (patcher_is_patched_at(xpc) == true)
+                       return;
 
-               /* fall-through */
+               // We have a problem...
+               log_println("md_signal_handler_sigill: Unknown illegal instruction 0x%x at 0x%lx", mcode, xpc);
+#if defined(ENABLE_DISASSEMBLER)
+               (void) disassinstr(xpc);
+#endif
+               vm_abort("Aborting...");
+       }
 
-       case TRAP_PATCHER:
-               if (p == NULL)
-                       break;
+       // This signal is always a patcher.
+       int      type = TRAP_PATCHER;
+       intptr_t val  = 0;
 
-               /* fall-through */
-               
-       default:
-               _gregs[REG_ITMP1_XPTR] = (uintptr_t) p;
-               _gregs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
-               _gregs[PT_NIP]         = (uintptr_t) asm_handle_exception;
-       }
+       // Handle the trap.
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -187,7 +201,6 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p)
        int             s1;
        intptr_t        val;
        int             type;
-       void           *p;
 
        _uc = (ucontext_t *) _p;
 
@@ -217,13 +230,7 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-       _gregs[REG_ITMP1_XPTR] = (uintptr_t) p;
-       _gregs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
-       _gregs[PT_NIP]         = (uintptr_t) asm_handle_exception;
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -335,7 +342,7 @@ void md_executionstate_read(executionstate_t *es, void *context)
         * the _mc->fpregs[i] can cause invalid conversions. */
 
        assert(sizeof(_mc->fpregs.fpregs) == sizeof(es->fltregs));
-       system_memcpy(&es->fltregs, &_mc->fpregs.fpregs, sizeof(_mc->fpregs.fpregs));
+       os_memcpy(&es->fltregs, &_mc->fpregs.fpregs, sizeof(_mc->fpregs.fpregs));
 }
 
 
@@ -370,7 +377,7 @@ void md_executionstate_write(executionstate_t *es, void *context)
         * the _mc->fpregs[i] can cause invalid conversions. */
 
        assert(sizeof(_mc->fpregs.fpregs) == sizeof(es->fltregs));
-       system_memcpy(&_mc->fpregs.fpregs, &es->fltregs, sizeof(_mc->fpregs.fpregs));
+       os_memcpy(&_mc->fpregs.fpregs, &es->fltregs, sizeof(_mc->fpregs.fpregs));
 
        /* write special registers */
        _gregs[PT_NIP] = (ptrint) es->pc;
@@ -380,39 +387,6 @@ void md_executionstate_write(executionstate_t *es, void *context)
 }
 
 
-/* md_critical_section_restart *************************************************
-
-   Search the critical sections tree for a matching section and set
-   the PC to the restart point, if necessary.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
-{
-       mcontext_t    *_mc;
-       unsigned long *_gregs;
-       u1            *pc;
-       u1            *npc;
-
-#if defined(__UCLIBC__)
-       _mc    = &(_uc->uc_mcontext);
-       _gregs = _mc->regs->gpr;
-#else
-       _mc    = _uc->uc_mcontext.uc_regs;
-       _gregs = _mc->gregs;
-#endif
-
-       pc = (u1 *) _gregs[PT_NIP];
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL)
-               _gregs[PT_NIP] = (ptrint) npc;
-}
-#endif
-
-
 /*
  * 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
diff --git a/src/vm/jit/powerpc/machine-instr.h b/src/vm/jit/powerpc/machine-instr.h
deleted file mode 100644 (file)
index 8c7ba6e..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _MACHINE_INSTR_H
-#define _MACHINE_INSTR_H
-
-static inline long compare_and_swap(long *p, long oldval, long newval)
-{
-  long ret, temp;
-
-  __asm__ __volatile__ ("\n\
-1:  lwarx  %0,0,%4 \n\
-    subf.  %1,%0,%2 \n\
-    bne-   2f \n\
-    or     %1,%3,%3 \n\
-    stwcx. %1,0,%4 \n\
-    bne-   1b \n\
-2: \n\
-"   : "=&r"(ret), "=&r"(temp)
-    : "r"(oldval), "r"(newval), "r"(p) : "cr0", "memory");
-
-  return ret;
-}
-
-#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory");
-#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("isync" : : : "memory");
-#define MEMORY_BARRIER() __asm__ __volatile__ ( "sync" : : : "memory" );
-
-#endif
diff --git a/src/vm/jit/powerpc/md-atomic.hpp b/src/vm/jit/powerpc/md-atomic.hpp
new file mode 100644 (file)
index 0000000..09a3533
--- /dev/null
@@ -0,0 +1,137 @@
+/* src/vm/jit/powerpc/md-atomic.hpp - PowerPC atomic instructions
+
+   Copyright (C) 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 _MD_ATOMIC_HPP
+#define _MD_ATOMIC_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "threads/atomic.hpp"
+
+
+/**
+ * An atomic compare and swap for 32-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
+{
+       uint32_t temp;
+       uint32_t result;
+
+       __asm__ __volatile__ (
+               "1:                   \n"
+               "    lwarx  %0,0,%4   \n"
+               "    subf.  %1,%0,%2  \n"
+               "    bne-   2f        \n"
+               "    or     %1,%3,%3  \n"
+               "    stwcx. %1,0,%4   \n"
+               "    bne-   1b        \n"
+               "2:                   \n"
+               : "=&r" (result), "=&r" (temp)
+               : "r" (oldval), "r" (newval), "r" (p)
+               : "cr0", "memory");
+
+       return result;
+}
+
+
+/**
+ * An atomic compare and swap for 64-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
+{
+       return Atomic::generic_compare_and_swap(p, oldval, newval);
+}
+
+
+/**
+ * An atomic compare and swap for pointer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval)
+{
+       return (void*) compare_and_swap((volatile uint32_t*) p, (uint32_t) oldval, (uint32_t) newval);
+}
+
+
+/**
+ * A memory barrier.
+ */
+inline void Atomic::memory_barrier(void)
+{
+       __asm__ __volatile__ ("sync" : : : "memory");
+}
+
+
+/**
+ * A write memory barrier.
+ */
+inline void Atomic::write_memory_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+/**
+ * An instruction barrier.
+ */
+inline void Atomic::instruction_barrier(void)
+{
+       __asm__ __volatile__ ("isync" : : : "memory");
+}
+
+#endif // _MD_ATOMIC_HPP
+
+
+/*
+ * 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/jit/powerpc/md-stubs.hpp b/src/vm/jit/powerpc/md-stubs.hpp
new file mode 100644 (file)
index 0000000..caf3cc6
--- /dev/null
@@ -0,0 +1,56 @@
+/* src/vm/jit/powerpc/md-stubs.hpp - PowerPC JIT stubs
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a PowerPC architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+       return 1 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * 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 3e552352653de800010fc569fc75843638fe2f90..fc9807d081ee0e4e60e4495c940ca469694082dd 100644 (file)
@@ -58,6 +58,7 @@ enum {
        /* Don't use 8 (could be a normal load offset). */
 
        TRAP_COMPILER                       = 9,
+       TRAP_COUNTDOWN                      = 10,
        TRAP_END
 };
 
index b85321c9d7f4ab89d4efe3a6802d00dcf1bd99c9..3595f407a4c2688c48b44d5e280a53e974c7329f 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/powerpc/md.c - machine dependent PowerPC functions
 
-   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.
 
@@ -37,9 +35,9 @@
 #include "vm/jit/powerpc/md.h"
 
 #include "vm/global.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* md_init *********************************************************************
index 6572885984ce9f7d9a51ef888f802d76e63150dd..33724ab14ae24b774b90f4536e4fcb9448d95a1e 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/powerpc/md.h - machine dependent PowerPC functions
 
-   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.
 
 #include "vm/jit/powerpc/codegen.h"
 
 #include "vm/global.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* md_stacktrace_get_returnaddress *********************************************
@@ -77,46 +75,46 @@ inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframe
 
 *******************************************************************************/
 
-inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
+inline static void* md_codegen_get_pv_from_pc(void* ra)
 {
-       u1 *pv;
-       u4  mcode;
-       s4  offset;
+       int32_t offset;
+
+       uint32_t* pc = (uint32_t*) ra;
 
        /* get first instruction word after jump */
 
-       mcode = *((u4 *) (ra + 1 * 4));
+       uint32_t mcode = pc[1];
 
        /* check if we have 2 instructions (addis, addi) */
 
        if ((mcode >> 16) == 0x3dab) {
                /* get displacement of first instruction (addis) */
 
-               offset = (s4) (mcode << 16);
+               offset = (int32_t) (mcode << 16);
 
                /* get displacement of second instruction (addi) */
 
-               mcode = *((u4 *) (ra + 2 * 4));
+               mcode = pc[2];
 
                /* check for addi instruction */
 
                assert((mcode >> 16) == 0x39ad);
 
-               offset += (s2) (mcode & 0x0000ffff);
-
-       else {
+               offset += (int16_t) (mcode & 0x0000ffff);
+       }
+       else {
                /* check for addi instruction */
 
                assert((mcode >> 16) == 0x39ab);
 
                /* get offset of first instruction (addi) */
 
-               offset = (s2) (mcode & 0x0000ffff);
+               offset = (int16_t) (mcode & 0x0000ffff);
        }
 
        /* calculate PV via RA + offset */
 
-       pv = ra + offset;
+       void* pv = (void*) (((uintptr_t) ra) + offset);
 
        return pv;
 }
index 6955088303b909764671e2cf0d4c18881b7d6c73..a18683ef72475c94e1b79cf88d0e784706acd892 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/powerpc/netbsd/md-os.c - machine dependent PowerPC NetBSD functions
 
-   Copyright (C) 1996-2005, 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) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
 */
 
 
 
 #include "vm/jit/powerpc/netbsd/md-abi.h"
 
-#include "vm/exceptions.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
+
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* md_signal_handle_sigsegv ****************************************************
@@ -92,14 +83,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 }
 
 
-#if defined(ENABLE_THREADS)
-void thread_restartcriticalsection(ucontext_t *uc)
-{
-       /* XXX set pc to restart address */
-}
-#endif
-
-
 /*
  * 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
index f87a1a99dc0a9b8c89fe739fffae0948071c1bb7..a4fc722b1de7077f4e5689b3c2918b3580021e45 100644 (file)
@@ -2,6 +2,7 @@
 
    Copyright (C) 1996-2005, 2006, 2007, 2008
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
 
    This file is part of CACAO.
 
 
 #include "mm/memory.h"
 
-#include "native/native.h"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/methodheader.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vm/resolve.h"
-#include "vmcore/references.h"
-
-
-#define PATCH_BACK_ORIGINAL_MCODE \
-       *((u4 *) pr->mpc) = (u4) pr->mcode; \
-       md_icacheflush((u1 *) pr->mpc, 4);
+#include "vm/jit/patcher-common.hpp"
 
 
 /* patcher_patch_code **********************************************************
 
 void patcher_patch_code(patchref_t *pr)
 {
-       PATCH_BACK_ORIGINAL_MCODE;
+       // Patch back original code.
+       *((uint32_t*) pr->mpc) = pr->mcode;
+
+       // Synchronize instruction cache.
+       md_icacheflush((void*) pr->mpc, 1 * 4);
+}
+
+
+/**
+ * Check if the trap instruction at the given PC is valid.
+ *
+ * @param pc Program counter.
+ *
+ * @return true if valid, false otherwise.
+ */
+bool patcher_is_valid_trap_instruction_at(void* pc)
+{
+       uint32_t mcode = *((uint32_t*) pc);
+
+       // Check for the undefined instruction we use.
+       return (mcode == 0x00000000);
 }
 
 
@@ -102,30 +115,24 @@ void patcher_patch_code(patchref_t *pr)
 
 bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
 {
-       constant_classref *cr;
-       u1                *datap;
-       classinfo         *c;
+       constant_classref * cr    = (constant_classref*) pr->ref;
+       uintptr_t*          datap = (uintptr_t*)         pr->datap;
 
-       /* get stuff from the stack */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
-
-       /* get the classinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch the classinfo pointer */
-
-       *((ptrint *) datap) = (ptrint) c;
-
-       /* synchronize data cache */
+       // Patch the class pointer.
+       *datap = (uintptr_t) c;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -150,30 +157,24 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
 
 bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
 {
-       constant_classref *cr;
-       u1                *datap;
-       classinfo         *c;
-
-       /* get stuff from the stack */
-
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)         pr->datap;
 
-       /* get the fieldinfo */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch super class' vftbl */
-
-       *((ptrint *) datap) = (ptrint) c->vftbl;
-
-       /* synchronize data cache */
+       // Patch super class' vftbl.
+       *datap = (uintptr_t) c->vftbl;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -189,30 +190,24 @@ bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
 
 bool patcher_resolve_classref_to_flags(patchref_t *pr)
 {
-       constant_classref *cr;
-       u1                *datap;
-       classinfo         *c;
-
-       /* get stuff from the stack */
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       int32_t*           datap = (int32_t*)           pr->datap;
 
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch class flags */
-
-       *((s4 *) datap) = (s4) c->flags;
-
-       /* synchronize data cache */
+       // Patch class flags.
+       *datap = c->flags;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -229,38 +224,29 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr)
 
 bool patcher_get_putstatic(patchref_t *pr)
 {
-       u1               *ra;
-       unresolved_field *uf;
-       u1               *datap;
-       fieldinfo        *fi;
-
-       /* get stuff from the stack */
-
-       ra    = (u1 *)                pr->mpc;
-       uf    = (unresolved_field *)  pr->ref;
-       datap = (u1 *)                pr->datap;
+       unresolved_field* uf    = (unresolved_field*) pr->ref;
+       uintptr_t*        datap = (uintptr_t*)        pr->datap;
 
-       /* get the fieldinfo */
+       // Resolve the field.
+       fieldinfo* fi = resolve_field_eager(uf);
 
-       if (!(fi = resolve_field_eager(uf)))
+       if (fi == NULL)
                return false;
 
-       /* check if the field's class is initialized */
-
+       // Check if the field's class is initialized.
        if (!(fi->clazz->state & CLASS_INITIALIZED))
                if (!initialize_class(fi->clazz))
                        return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch the field value's address */
-
-       *((intptr_t *) datap) = (intptr_t) fi->value;
-
-       /* synchronize data cache */
+       // Patch the field value's address.
+       *datap = (uintptr_t) fi->value;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -276,53 +262,44 @@ bool patcher_get_putstatic(patchref_t *pr)
 
 bool patcher_get_putfield(patchref_t *pr)
 {
-       u1               *ra;
-       unresolved_field *uf;
-       fieldinfo        *fi;
-       s2                disp;
+       uint32_t*         pc = (uint32_t*)         pr->mpc;
+       unresolved_field* uf = (unresolved_field*) pr->ref;
 
-       ra = (u1 *)               pr->mpc;
-       uf = (unresolved_field *) pr->ref;
+       // Resolve the field.
+       fieldinfo* fi = resolve_field_eager(uf);
 
-       /* get the fieldinfo */
-
-       if (!(fi = resolve_field_eager(uf)))
+       if (fi == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show NOPs, we have to skip them */
-
-       if (opt_shownops)
-               ra = ra + 1 * 4;
-
-       /* patch the field's offset */
-
+       // Patch the field's offset.
        if (IS_LNG_TYPE(fi->type)) {
                /* If the field has type long, we have to patch two
                   instructions.  But we have to check which instruction
                   is first.  We do that with the offset of the first
                   instruction. */
 
-               disp = *((u4 *) (ra + 0 * 4));
+               uint32_t disp = (pr->mcode & 0x0000ffff);
 
                if (disp == 4) {
-                       *((u4 *) (ra + 0 * 4)) &= 0xffff0000;
-                       *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
-                       *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
+                       pr->mcode &= 0xffff0000;
+                       pr->mcode |= ((fi->offset + 4) & 0x0000ffff);
+                       pc[1] |= ((fi->offset + 0) & 0x0000ffff);
                }
                else {
-                       *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
-                       *((u4 *) (ra + 1 * 4)) &= 0xffff0000;
-                       *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
+                       pr->mcode |= ((fi->offset + 0) & 0x0000ffff);
+                       pc[1] &= 0xffff0000;
+                       pc[1] |= ((fi->offset + 4) & 0x0000ffff);
                }
-       }
-       else
-               *((u4 *) (ra + 0 * 4)) |= (s2) (fi->offset & 0x0000ffff);
 
-       /* synchronize instruction cache */
+               // Synchronize instruction cache.
+               md_icacheflush(pc + 1, 1 * 4);
+       }
+       else {
+               pr->mcode |= (fi->offset & 0x0000ffff);
+       }
 
-       md_icacheflush(ra + 0 * 4, 2 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -341,30 +318,24 @@ bool patcher_get_putfield(patchref_t *pr)
 
 bool patcher_invokestatic_special(patchref_t *pr)
 {
-       unresolved_method *um;
-       u1                *datap;
-       methodinfo        *m;
-
-       /* get stuff from the stack */
-
-       um    = (unresolved_method *) pr->ref;
-       datap = (u1 *)                pr->datap;
+       unresolved_method* um    = (unresolved_method*) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)         pr->datap;
 
-       /* get the fieldinfo */
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* patch stubroutine */
-
-       *((ptrint *) datap) = (ptrint) m->stubroutine;
-
-       /* synchronize data cache */
+       // Patch stubroutine.
+       *datap = (uintptr_t) m->stubroutine;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -383,37 +354,25 @@ bool patcher_invokestatic_special(patchref_t *pr)
 
 bool patcher_invokevirtual(patchref_t *pr)
 {
-       u1                *ra;
-       unresolved_method *um;
-       methodinfo        *m;
-       s4                 disp;
-
-       /* get stuff from the stack */
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       unresolved_method* um = (unresolved_method*) pr->ref;
 
-       ra = (u1 *)                pr->mpc;
-       um = (unresolved_method *) pr->ref;
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       /* get the fieldinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show NOPs, we have to skip them */
-
-       if (opt_shownops)
-               ra = ra + 1 * 4;
-
-       /* patch vftbl index */
-
-       disp = (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex);
+       // Patch vftbl index.
+       int32_t disp = (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex);
 
-       *((s4 *) (ra + 1 * 4)) |= (disp & 0x0000ffff);
+       pc[1] |= (disp & 0x0000ffff);
 
-       /* synchronize instruction cache */
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 1, 1 * 4);
 
-       md_icacheflush(ra + 1 * 4, 1 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -434,48 +393,32 @@ bool patcher_invokevirtual(patchref_t *pr)
 
 bool patcher_invokeinterface(patchref_t *pr)
 {
-       u1                *ra;
-       unresolved_method *um;
-       methodinfo        *m;
-       s4                 disp;
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       unresolved_method* um = (unresolved_method*) pr->ref;
 
-       /* get stuff from the stack */
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       ra = (u1 *)                pr->mpc;
-       um = (unresolved_method *) pr->ref;
-
-       /* get the fieldinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show NOPs, we have to skip them */
-
-       if (opt_shownops)
-               ra = ra + 1 * 4;
-
-       /* patch interfacetable index */
-
-       disp = OFFSET(vftbl_t, interfacetable[0]) -
-               sizeof(methodptr*) * m->clazz->index;
+       // Patch interfacetable index.
+       int32_t disp = OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr*) * m->clazz->index;
 
        /* XXX TWISTI: check displacement */
+       pc[1] |= (disp & 0x0000ffff);
 
-       *((s4 *) (ra + 1 * 4)) |= (disp & 0x0000ffff);
-
-       /* patch method offset */
-
+       // Patch method offset.
        disp = sizeof(methodptr) * (m - m->clazz->methods);
 
        /* XXX TWISTI: check displacement */
+       pc[2] |= (disp & 0x0000ffff);
 
-       *((s4 *) (ra + 2 * 4)) |= (disp & 0x0000ffff);
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 1, 2 * 4);
 
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra + 1 * 4, 2 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -497,41 +440,27 @@ bool patcher_invokeinterface(patchref_t *pr)
 
 bool patcher_checkcast_interface(patchref_t *pr)
 {
-       u1                *ra;
-       constant_classref *cr;
-       classinfo         *c;
-       s4                 disp;
-
-       /* get stuff from the stack */
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       constant_classref* cr = (constant_classref*) pr->ref;
 
-       ra = (u1 *)                pr->mpc;
-       cr = (constant_classref *) pr->ref;
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show NOPs, we have to skip them */
-
-       if (opt_shownops)
-               ra = ra + 1 * 4;
-
-       /* patch super class index */
-
-       disp = -(c->index);
-
-       *((s4 *) (ra + 2 * 4)) |= (disp & 0x0000ffff);
+       // Patch super class index.
+       int32_t disp = -(c->index);
+       pc[2] |= (disp & 0x0000ffff);
 
        disp = OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*);
+       pc[5] |= (disp & 0x0000ffff);
 
-       *((s4 *) (ra + 5 * 4)) |= (disp & 0x0000ffff);
-
-       /* synchronize instruction cache */
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 2, 4 * 4);
 
-       md_icacheflush(ra + 2 * 4, 4 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -553,41 +482,27 @@ bool patcher_checkcast_interface(patchref_t *pr)
 
 bool patcher_instanceof_interface(patchref_t *pr)
 {
-       u1                *ra;
-       constant_classref *cr;
-       classinfo         *c;
-       s4                 disp;
-
-       /* get stuff from the stack */
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       constant_classref* cr = (constant_classref*) pr->ref;
 
-       ra = (u1 *)                pr->mpc;
-       cr = (constant_classref *) pr->ref;
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show NOPs, we have to skip them */
-
-       if (opt_shownops)
-               ra = ra + 1 * 4;
-
-       /* patch super class index */
-
-       disp = -(c->index);
-
-       *((s4 *) (ra + 2 * 4)) |= (disp & 0x0000ffff);
+       // Patch super class index.
+       int32_t disp = -(c->index);
+       pc[2] |= (disp & 0x0000ffff);
 
        disp = OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*);
+       pc[4] |= (disp & 0x0000ffff);
 
-       *((s4 *) (ra + 4 * 4)) |= (disp & 0x0000ffff);
-
-       /* synchronize instruction cache */
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 2, 3 * 4);
 
-       md_icacheflush(ra + 2 * 4, 3 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
index 4ec4826ae012a0be82dd536a09cc7311a3b4d282..d61007a20e7fc08952f0892612d312901eca1fc6 100644 (file)
@@ -33,7 +33,7 @@ LIBS =
 
 noinst_HEADERS = \
        arch.h \
-       machine-instr.h
+       md-atomic.hpp
 
 noinst_LTLIBRARIES = libarch.la
 
@@ -50,6 +50,7 @@ libarch_la_SOURCES = \
        emit.c \
        patcher.c \
        \
+       md-stubs.hpp \
        md-trap.h \
        md.c \
        md.h
index 5c7daa42bdd70b2b6bfd1fb6f806b89cbf7dfefc..33651985ca75c0977c2b1ae805475f0d7a753ea0 100644 (file)
@@ -35,8 +35,6 @@
 
 /* define architecture features ***********************************************/
 
-#define U8_AVAILABLE                     1
-
 #define SUPPORT_DIVISION                 1
 #define SUPPORT_LONG                     1
 
index f9cd0fbe63068332dbdb078ed0be244ac6659532..6de89aaf0b6c5c16d65127a5f882d02e4e68a968 100644 (file)
 
 #include "mm/memory.h"
 
-#include "native/localref.h"
-#include "native/native.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
 #if defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
 #endif
@@ -2204,10 +2202,6 @@ gen_method:
                                        superindex = super->index;
                                }
                
-                               if ((super == NULL) || !(super->flags & ACC_INTERFACE)) {
-                                       CODEGEN_CRITICAL_SECTION_NEW;
-                               }
-
                                s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                                /* if class is not resolved, check which code to call */
@@ -2276,16 +2270,12 @@ gen_method:
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl));
 
-                                       CODEGEN_CRITICAL_SECTION_START;
-
                                        M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                        M_ALD(REG_ITMP2, REG_PV, disp);
                                        if (s1 != REG_ITMP1) {
                                                M_ILD(REG_ITMP1, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 
-                                               CODEGEN_CRITICAL_SECTION_END;
-
                                                M_SUB(REG_ITMP3, REG_ITMP1, REG_ITMP3);
                                                M_EXTSW(REG_ITMP3, REG_ITMP3);
                                        } else {
@@ -2294,9 +2284,6 @@ gen_method:
                                                M_EXTSW(REG_ITMP3, REG_ITMP3);
                                                M_ALD(REG_ITMP2, REG_PV, disp);
                                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
-
-                                               CODEGEN_CRITICAL_SECTION_END;
-
                                        }
                                        M_CMPU(REG_ITMP3, REG_ITMP2);
                                        emit_classcast_check(cd, iptr, BRANCH_GT, REG_ITMP3, s1);
@@ -2373,10 +2360,6 @@ gen_method:
                                superindex = super->index;
                        }
                        
-                       if ((super == NULL) || !(super->flags & ACC_INTERFACE)) {
-                               CODEGEN_CRITICAL_SECTION_NEW;
-                       }
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s1 == d) {
@@ -2453,14 +2436,10 @@ gen_method:
                                M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl));
                                M_ALD(REG_ITMP2, REG_PV, disp);
 
-                               CODEGEN_CRITICAL_SECTION_START;
-
                                M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 
-                               CODEGEN_CRITICAL_SECTION_END;
-
                                M_SUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                M_EXTSW(REG_ITMP1, REG_ITMP1);
                                M_CMPU(REG_ITMP1, REG_ITMP2);
@@ -2727,7 +2706,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
                /* put env into first argument register */
 
-               disp = dseg_add_unique_address(cd, _Jv_env);
+               disp = dseg_add_unique_address(cd, VM_get_jnienv());
                M_ALD(REG_A0, REG_PV, disp);
        }
 
index 1ffe1bfd91a3c5d5aa975f92ea1ebf90e4d08795..df9120f088af2393c10f792277c962306969c9c5 100644 (file)
@@ -1,10 +1,8 @@
-/* src/vm/jit/powerpc64/codegen.h - code generation macros and definitions for
-                                 64-bit PowerPC
+/* src/vm/jit/powerpc64/codegen.h - code generation macros and
+                                    definitions for PowerPC64
 
-   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.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Andreas Krall
-            Stefan Ring
-            Christian Thalinger
-            Christian Ullrich
-
-
 */
 
 
@@ -42,7 +32,7 @@
 #include "md-abi.h"
 
 #include "vm/global.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
 
 
     } while (0)
 
 
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE    1 * 4
-
-
 /* macros to create code ******************************************************/
 
 #define M_OP3(opcode,y,oe,rc,d,a,b) \
 
 /* instruction macros *********************************************************/
 
-#define M_IADD(a,b,c)                  M_LADD(a,b,c)
+#define M_ILLEGAL                       M_OP3(0, 0, 0, 0, 0, 0, 0)
+#define M_IADD(a,b,c)                   M_LADD(a,b,c)
 #define M_LADD(a,b,c)                   M_OP3(31, 266, 0, 0, c, a, b) 
 #define M_IADD_IMM(a,b,c)               M_OP2_IMM(14, c, a, b) /* XXX */
 #define M_LADD_IMM(a,b,c)               M_OP2_IMM(14, c, a, b)
index b2a5119ee15daed98a51cba959f36ab118e0b736..4e7a37f718c21b0200688098c29e828f78dc7257 100644 (file)
 #include "md-abi.h"
 #include "vm/jit/powerpc64/codegen.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/exceptions.h"
-#include "vm/vm.h"
+#include "vm/options.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/trace.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/options.h"
-
 
 /* emit_load *******************************************************************
 
@@ -431,39 +429,47 @@ void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 opt)
                                                          CODEGENDATA_FLAG_LONGBRANCHES);
                        }
 
-                       branchdisp --;          /* we jump from the second instruction */
-                       switch (condition) {
-                       case BRANCH_EQ:
-                               M_BNE(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_NE:
-                               M_BEQ(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_LT:
-                               M_BGE(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_GE:
-                               M_BLT(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_GT:
-                               M_BLE(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_LE:
-                               M_BGT(1);
-                               M_BR(branchdisp);
-                               break;
-                       case BRANCH_NAN:
-                               vm_abort("emit_branch: long BRANCH_NAN");
-                               break;
-                       default:
-                               vm_abort("emit_branch: unknown condition %d", condition);
-                       }
+                       // Subtract 1 instruction from the displacement as the
+                       // actual branch is the second instruction.
+                       checkdisp  = checkdisp - 4;
+                       branchdisp = branchdisp - 1;
 
+                       if ((checkdisp < (int32_t) 0xfe000000) || (checkdisp > (int32_t) 0x01fffffc)) {
+                               vm_abort("emit_branch: emit conditional long-branch code");
+                       }
+                       else {
+                               switch (condition) {
+                               case BRANCH_EQ:
+                                       M_BNE(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_NE:
+                                       M_BEQ(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_LT:
+                                       M_BGE(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_GE:
+                                       M_BLT(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_GT:
+                                       M_BLE(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_LE:
+                                       M_BGT(1);
+                                       M_BR(branchdisp);
+                                       break;
+                               case BRANCH_NAN:
+                                       vm_abort("emit_branch: long BRANCH_NAN");
+                                       break;
+                               default:
+                                       vm_abort("emit_branch: unknown condition %d", condition);
+                               }
+                       }
                }
                else {
                        switch (condition) {
@@ -629,15 +635,11 @@ void emit_trap_compiler(codegendata *cd)
 
 uint32_t emit_trap(codegendata *cd)
 {
-       uint32_t mcode;
-
-       /* Get machine code which is patched back in later. The
-          trap is 1 instruction word long. */
-
-       mcode = *((uint32_t *) cd->mcodeptr);
+       // Get machine code which is patched back in later. The trap is 1
+       // instruction word long.
+       uint32_t mcode = *((uint32_t*) cd->mcodeptr);
 
-       /* ALD is 4 byte aligned, ILD 2, only LWZ is byte aligned */
-       M_LWZ(REG_ZERO, REG_ZERO, TRAP_PATCHER);
+       M_ILLEGAL;
 
        return mcode;
 }
index f1a054e122c6130ca8c6d3ae8516475b89e76714..68f1ae5e768a8f47acb1eed3089f9ed0d2909d39 100644 (file)
 
 #include "vm/jit/powerpc64/linux/md-abi.h"
 
+#include "vm/descriptor.h"
 #include "vm/global.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/stack.h"
 
-#include "vmcore/descriptor.h"
-
-
-#define CACAO_ALIGN(a)    do { if ((a) & 1) (a)++; } while (0)
-
 
 /* register descripton array **************************************************/
 
index 8b292f1adb037876f59c8f3757c23618a66f88c6..ebb284b4410cf7cba3fbd8fedef59dcdf2363d7a 100644 (file)
@@ -2,6 +2,7 @@
 
    Copyright (C) 1996-2005, 2006, 2007, 2008
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
 
    This file is part of CACAO.
 
 #include "vm/jit/powerpc64/md.h"
 #include "vm/jit/powerpc64/linux/md-abi.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
 #include "vm/signallocal.h"
+#include "vm/os.hpp"
 
 #include "vm/jit/asmpart.h"
+#include "vm/jit/executionstate.h"
 
 #if defined(ENABLE_PROFILING)
 # include "vm/jit/optimizing/profile.h"
 #endif
 
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/disass.h"
 #include "vm/jit/trap.h"
 
 
@@ -72,7 +74,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        int             type;
        intptr_t        addr;
        intptr_t        val;
-       void           *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &(_uc->uc_mcontext);
@@ -113,43 +114,50 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-       switch (type) {
-       case TRAP_COMPILER:
-               if (p != NULL) {
-                       _mc->gp_regs[REG_PV] = (uintptr_t) p;
-                       _mc->gp_regs[PT_NIP] = (uintptr_t) p;
-                       break;
-               }
-
-               /* Get and set the PV from the parent Java method. */
-
-               pv = md_codegen_get_pv_from_pc(ra);
-
-               _mc->gp_regs[REG_PV] = (uintptr_t) pv;
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
+}
 
-               /* Get the exception object. */
 
-               p = builtin_retrieve_exception();
+/**
+ * Signal handler for patcher calls.
+ */
+void md_signal_handler_sigill(int sig, siginfo_t* siginfo, void* _p)
+{
+       ucontext_t* _uc = (ucontext_t*) _p;
+       mcontext_t* _mc = &(_uc->uc_mcontext);
 
-               assert(p != NULL);
+       /* get register values */
 
-               /* fall-through */
+       void* pv = (void*) _mc->gp_regs[REG_PV];
+       void* sp = (void*) _mc->gp_regs[REG_SP];
+       void* ra = (void*) _mc->gp_regs[PT_LNK]; // The RA is correct for leag methods.
+       void* xpc =(void*) _mc->gp_regs[PT_NIP];
+
+       // Get the illegal-instruction.
+       uint32_t mcode = *((uint32_t*) xpc);
+
+       // Check if the trap instruction is valid.
+       // TODO Move this into patcher_handler.
+       if (patcher_is_valid_trap_instruction_at(xpc) == false) {
+               // Check if the PC has been patched during our way to this
+               // signal handler (see PR85).
+               if (patcher_is_patched_at(xpc) == true)
+                       return;
+
+               // We have a problem...
+               log_println("md_signal_handler_sigill: Unknown illegal instruction 0x%x at 0x%lx", mcode, xpc);
+#if defined(ENABLE_DISASSEMBLER)
+               (void) disassinstr(xpc);
+#endif
+               vm_abort("Aborting...");
+       }
 
-       case TRAP_PATCHER:
-               if (p == NULL)
-                       break;
+       // This signal is always a patcher.
+       int      type = TRAP_PATCHER;
+       intptr_t val  = 0;
 
-               /* fall-through */
-               
-       default:
-               _mc->gp_regs[REG_ITMP1_XPTR] = (uintptr_t) p;
-               _mc->gp_regs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
-               _mc->gp_regs[PT_NIP]         = (uintptr_t) asm_handle_exception;
-       }
+       // Handle the trap.
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -179,30 +187,76 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 #endif
 
 
-/* md_critical_section_restart *************************************************
+/* md_executionstate_read ******************************************************
 
-   Search the critical sections tree for a matching section and set
-   the PC to the restart point, if necessary.
+   Read the given context into an executionstate.
 
 *******************************************************************************/
 
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
+void md_executionstate_read(executionstate_t *es, void *context)
 {
-       mcontext_t *_mc;
-       u1         *pc;
-       u1         *npc;
+       ucontext_t    *_uc;
+       mcontext_t    *_mc;
+       s4              i;
 
+       _uc = (ucontext_t *) context;
        _mc = &(_uc->uc_mcontext);
 
-       pc = (u1 *) _mc->gp_regs[PT_NIP];
+       /* read special registers */
+       es->pc = (u1 *) _mc->gp_regs[PT_NIP];
+       es->sp = (u1 *) _mc->gp_regs[REG_SP];
+       es->pv = (u1 *) _mc->gp_regs[REG_PV];
+       es->ra = (u1 *) _mc->gp_regs[PT_LNK];
+
+       /* read integer registers */
+       for (i = 0; i < INT_REG_CNT; i++)
+               es->intregs[i] = _mc->gp_regs[i];
 
-       npc = critical_find_restart_point(pc);
+       /* read float registers */
+       /* Do not use the assignment operator '=', as the type of
+        * the _mc->fpregs[i] can cause invalid conversions. */
 
-       if (npc != NULL)
-               _mc->gp_regs[PT_NIP] = (ptrint) npc;
+       // The assertion below will fail because _mc->fp_regs[] also
+       // contains the "fpscr" register.
+       //assert(sizeof(_mc->fp_regs) == sizeof(es->fltregs));
+       os_memcpy(&es->fltregs, &_mc->fp_regs, sizeof(es->fltregs));
+}
+
+
+/* md_executionstate_write *****************************************************
+
+   Write the given executionstate back to the context.
+
+*******************************************************************************/
+
+void md_executionstate_write(executionstate_t *es, void *context)
+{
+       ucontext_t    *_uc;
+       mcontext_t    *_mc;
+       s4              i;
+
+       _uc = (ucontext_t *) context;
+       _mc = &(_uc->uc_mcontext);
+
+       /* write integer registers */
+       for (i = 0; i < INT_REG_CNT; i++)
+               _mc->gp_regs[i] = es->intregs[i];
+
+       /* write float registers */
+       /* Do not use the assignment operator '=', as the type of
+        * the _mc->fpregs[i] can cause invalid conversions. */
+
+       // The assertion below will fail because _mc->fp_regs[] also
+       // contains the "fpscr" register.
+       //assert(sizeof(_mc->fp_regs) == sizeof(es->fltregs));
+       os_memcpy(&_mc->fp_regs, &es->fltregs, sizeof(es->fltregs));
+
+       /* write special registers */
+       _mc->gp_regs[PT_NIP] = (ptrint) es->pc;
+       _mc->gp_regs[REG_SP] = (ptrint) es->sp;
+       _mc->gp_regs[REG_PV] = (ptrint) es->pv;
+       _mc->gp_regs[PT_LNK] = (ptrint) es->ra;
 }
-#endif
 
 
 /*
diff --git a/src/vm/jit/powerpc64/machine-instr.h b/src/vm/jit/powerpc64/machine-instr.h
deleted file mode 100644 (file)
index 5e3390c..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _MACHINE_INSTR_H
-#define _MACHINE_INSTR_H
-
-static inline long compare_and_swap(long *p, long oldval, long newval)
-{
-  long ret, temp;
-
-  __asm__ __volatile__ ("\n\
-1:  ldarx  %0,0,%4 \n\
-    subf.  %1,%0,%2 \n\
-    bne-   2f \n\
-    or     %1,%3,%3 \n\
-    stdcx. %1,0,%4 \n\
-    bne-   1b \n\
-2: \n\
-"   : "=&r"(ret), "=&r"(temp)
-    : "r"(oldval), "r"(newval), "r"(p) : "cr0", "memory");
-
-  return ret;
-}
-
-#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory");
-#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("isync" : : : "memory");
-#define MEMORY_BARRIER() __asm__ __volatile__ ( "sync" : : : "memory" );
-
-#endif
diff --git a/src/vm/jit/powerpc64/md-atomic.hpp b/src/vm/jit/powerpc64/md-atomic.hpp
new file mode 100644 (file)
index 0000000..f469e75
--- /dev/null
@@ -0,0 +1,154 @@
+/* src/vm/jit/powerpc64/atomic.hpp - PowerPC64 atomic instructions
+
+   Copyright (C) 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 _MD_ATOMIC_HPP
+#define _MD_ATOMIC_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "threads/atomic.hpp"
+
+
+/**
+ * An atomic compare and swap for 32-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
+{
+       uint32_t temp;
+       uint32_t result;
+
+       __asm__ __volatile__ (
+               "1:                   \n"
+               "    lwarx  %0,0,%4   \n"
+               "    subf.  %1,%0,%2  \n"
+               "    bne-   2f        \n"
+               "    or     %1,%3,%3  \n"
+               "    stwcx. %1,0,%4   \n"
+               "    bne-   1b        \n"
+               "2:                   \n"
+               : "=&r" (result), "=&r" (temp)
+               : "r" (oldval), "r" (newval), "r" (p)
+               : "cr0", "memory");
+
+       return result;
+}
+
+
+/**
+ * An atomic compare and swap for 64-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
+{
+       uint64_t temp;
+       uint64_t result;
+
+       __asm__ __volatile__ (
+               "1:                   \n"
+               "    ldarx  %0,0,%4   \n"
+               "    subf.  %1,%0,%2  \n"
+               "    bne-   2f        \n"
+               "    or     %1,%3,%3  \n"
+               "    stdcx. %1,0,%4   \n"
+               "    bne-   1b        \n"
+               "2:                   \n"
+               : "=&r" (result), "=&r" (temp)
+               : "r" (oldval), "r" (newval), "r" (p)
+               : "cr0", "memory");
+
+       return result;
+}
+
+
+/**
+ * An atomic compare and swap for pointer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval)
+{
+       return (void*) compare_and_swap((volatile uint64_t*) p, (uint64_t) oldval, (uint64_t) newval);
+}
+
+
+/**
+ * A memory barrier.
+ */
+inline void Atomic::memory_barrier(void)
+{
+       __asm__ __volatile__ ("sync" : : : "memory");
+}
+
+
+/**
+ * A write memory barrier.
+ */
+inline void Atomic::write_memory_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+
+/**
+ * An instruction memory barrier.
+ */
+inline void Atomic::instruction_barrier(void)
+{
+       __asm__ __volatile__ ("isync" : : : "memory");
+}
+
+#endif // _MD_ATOMIC_HPP
+
+
+/*
+ * 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/jit/powerpc64/md-stubs.hpp b/src/vm/jit/powerpc64/md-stubs.hpp
new file mode 100644 (file)
index 0000000..5356f7f
--- /dev/null
@@ -0,0 +1,56 @@
+/* src/vm/jit/powerpc64/md-stubs.hpp - PowerPC64 JIT stubs
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a PowerPC64 architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+       return 1 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * 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 7e8c5b6fdc830e60c792585bfe4bd5cc8dfed3bf..3830d1598ef9eb95c94cd248c7182f98105675bf 100644 (file)
@@ -53,12 +53,15 @@ enum {
 
        TRAP_ClassCastException             = 5,
        TRAP_CHECK_EXCEPTION                = 6,
-       TRAP_PATCHER                        = 7,
+       TRAP_COMPILER                       = 7,
 
        /* Don't use 8 (could be a normal load offset). */
 
-       TRAP_COMPILER                       = 9,
-       TRAP_END
+       TRAP_COUNTDOWN                      = 9,
+       TRAP_END,
+
+       // This handled via SIGILL.
+       TRAP_PATCHER                        = 99 // A large number.
 };
 
 #endif /* _MD_TRAP_H */
index 3e8bc5c15edbb3c26b2375a9f17dfc4231f15129..15b564227e38b010872290989fd36e2874bfdd83 100644 (file)
 #include "vm/jit/powerpc64/codegen.h"
 #include "vm/jit/powerpc64/md.h"
 
-#include "vm/exceptions.h"
 #include "vm/global.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/trap.h"
 
 
index 4a4d165e94777bb75a612bca55b73f98892f4ea7..b70509f86130e849b1ef14677104dc89303e045c 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/powerpc64/md.h - machine dependent PowerPC functions
 
-   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.
 
 #include "vm/jit/powerpc64/codegen.h"
 
 #include "vm/global.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* md_stacktrace_get_returnaddress *********************************************
@@ -77,37 +75,37 @@ inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframe
 
 *******************************************************************************/
 
-inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
+inline static void* md_codegen_get_pv_from_pc(void* ra)
 {
-       u1 *pv;
-       u4  mcode;
-       s4  offset;
+       int32_t offset;
+
+       uint32_t* pc = (uint32_t*) ra;
 
        /* get first instruction word after jump */
 
-       mcode = *((u4 *) (ra + 1 * 4));
+       uint32_t mcode = pc[1];
 
        /* check if we have 2 instructions (addis, addi) */
 
        if ((mcode >> 16) == 0x3dcb) {
                /* get displacement of first instruction (addis) */
 
-               offset = (s4) (mcode << 16);
+               offset = (int32_t) (mcode << 16);
 
                /* get displacement of second instruction (addi) */
 
-               mcode = *((u4 *) (ra + 2 * 4));
+               mcode = pc[2];
 
                /* check for addi instruction */
 
                assert((mcode >> 16) == 0x39ce);
 
-               offset += (s2) (mcode & 0x0000ffff);
+               offset += (int16_t) (mcode & 0x0000ffff);
        }
        else if ((mcode >> 16) == 0x39cb) {
                /* get offset of first instruction (addi) */
 
-               offset = (s2) (mcode & 0x0000ffff);
+               offset = (int16_t) (mcode & 0x0000ffff);
        }
        else {
                vm_abort("md_codegen_get_pv_from_pc: unknown instruction %x", mcode);
@@ -119,7 +117,7 @@ inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
 
        /* calculate PV via RA + offset */
 
-       pv = ra + offset;
+       void* pv = (void*) (((uintptr_t) ra) + offset);
 
        return pv;
 }
index 8f6f160ad37bf1e942993e94e7206f5df6121fd4..9e1799c2296270d680a9243dd4d27786a04991a6 100644 (file)
@@ -2,6 +2,7 @@
 
    Copyright (C) 1996-2005, 2006, 2007, 2008
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
 
    This file is part of CACAO.
 
 
 #include "mm/memory.h"
 
-#include "native/native.h"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/methodheader.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vmcore/references.h"
-#include "vm/resolve.h"
+#include "vm/jit/patcher-common.hpp"
 
 
 /* patcher_patch_code **********************************************************
 
 void patcher_patch_code(patchref_t *pr)
 {
-       /* patch back original code */
+       // Patch back original code.
+       *((uint32_t*) pr->mpc) = pr->mcode;
 
-       *((u4 *) pr->mpc) = pr->mcode;
+       // Synchronize instruction cache.
+       md_icacheflush((void*) pr->mpc, 1 * 4);
+}
 
-       /* synchronize instruction cache */
 
-       md_icacheflush(pr->mpc, 4);
+/**
+ * Check if the trap instruction at the given PC is valid.
+ *
+ * @param pc Program counter.
+ *
+ * @return true if valid, false otherwise.
+ */
+bool patcher_is_valid_trap_instruction_at(void* pc)
+{
+       uint32_t mcode = *((uint32_t*) pc);
+
+       // Check for the undefined instruction we use.
+       return (mcode == 0x00000000);
 }
 
 
@@ -80,48 +92,31 @@ void patcher_patch_code(patchref_t *pr)
 
 *******************************************************************************/
 
-bool patcher_get_putstatic(patchref_t *pr)
+bool patcher_get_putstatic(patchref_tpr)
 {
-       u1               *ra;
-       u4                mcode;
-       unresolved_field *uf;
-       u1               *datap;
-       fieldinfo        *fi;
-
-       /* get stuff from the stack */
-
-       ra    = (u1 *)                pr->mpc;
-       mcode =                       pr->mcode;
-       uf    = (unresolved_field *)  pr->ref;
-       datap = (u1 *)                pr->datap;
+       unresolved_field* uf    = (unresolved_field*) pr->ref;
+       uintptr_t*        datap = (uintptr_t*)        pr->datap;
 
-       /* get the fieldinfo */
+       // Resolve the field.
+       fieldinfo* fi = resolve_field_eager(uf);
 
-       if (!(fi = resolve_field_eager(uf)))
+       if (fi == NULL)
                return false;
 
-       /* check if the field's class is initialized */
-
+       // Check if the field's class is initialized.
        if (!(fi->clazz->state & CLASS_INITIALIZED))
                if (!initialize_class(fi->clazz))
                        return false;
 
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra, 4);
-
-       /* patch the field value's address */
-
-       *((intptr_t *) datap) = (intptr_t) fi->value;
-
-       /* synchronize data cache */
+       // Patch the field value's address.
+       *datap = (uintptr_t) fi->value;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -135,42 +130,22 @@ bool patcher_get_putstatic(patchref_t *pr)
 
 *******************************************************************************/
 
-bool patcher_get_putfield(patchref_t *pr)
+bool patcher_get_putfield(patchref_tpr)
 {
-       u1               *ra;
-       u4                mcode;
-       unresolved_field *uf;
-       fieldinfo        *fi;
-
-       ra    = (u1 *)                pr->mpc;
-       mcode =                       pr->mcode;
-       uf    = (unresolved_field *)  pr->ref;
+       unresolved_field* uf = (unresolved_field*) pr->ref;
 
-       /* get the fieldinfo */
+       // Resolve the field.
+       fieldinfo* fi = resolve_field_eager(uf);
 
-       if (!(fi = resolve_field_eager(uf)))
+       if (fi == NULL)
                return false;
 
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra, 4);
+       // Patch the field offset in the patcher.  We also need this to
+       // validate patchers.
+       pr->mcode |= (int16_t) (fi->offset & 0x0000ffff);
 
-       /* if we show disassembly, we have to skip the nop */
-
-       if (opt_shownops)
-               ra = ra + 4;
-
-       /* patch the field's offset */
-
-       *((u4 *) ra) |= (s2) (fi->offset & 0x0000ffff);
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra, 8);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -187,42 +162,26 @@ bool patcher_get_putfield(patchref_t *pr)
 
 ******************************************************************************/
 
-bool patcher_invokestatic_special(patchref_t *pr)
+bool patcher_invokestatic_special(patchref_tpr)
 {
-       u1                *ra;
-       u4                 mcode;
-       unresolved_method *um;
-       u1                *datap;
-       methodinfo        *m;
-
-       /* get stuff from the stack */
+       unresolved_method* um    = (unresolved_method*) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)         pr->datap;
 
-       ra    = (u1 *)                pr->mpc;
-       mcode =                       pr->mcode;
-       um    = (unresolved_method *) pr->ref;
-       datap = (u1 *)                pr->datap;
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       /* get the fieldinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra, 4);
-
-       /* patch stubroutine */
-
-       *((ptrint *) datap) = (ptrint) m->stubroutine;
-
-       /* synchronize data cache */
+       // Patch stubroutine.
+       *datap = (uintptr_t) m->stubroutine;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -239,47 +198,27 @@ bool patcher_invokestatic_special(patchref_t *pr)
 
 *******************************************************************************/
 
-bool patcher_invokevirtual(patchref_t *pr)
+bool patcher_invokevirtual(patchref_tpr)
 {
-       u1                *ra;
-       u4                 mcode;
-       unresolved_method *um;
-       methodinfo        *m;
-       s4                 disp;
-
-       /* get stuff from the stack */
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       unresolved_method* um = (unresolved_method*) pr->ref;
 
-       ra    = (u1 *)                pr->mpc;
-       mcode =                       pr->mcode;
-       um    = (unresolved_method *) pr->ref;
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       /* get the fieldinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
+       // Patch vftbl index.
+       int32_t disp = (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex);
 
-       md_icacheflush(ra, 4);
+       pc[1] |= (disp & 0x0000ffff);
 
-       /* if we show disassembly, we have to skip the nop */
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 1, 1 * 4);
 
-       if (opt_shownops)
-               ra = ra + 4;
-
-       /* patch vftbl index */
-
-       disp = (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex);
-
-       *((s4 *) (ra + 4)) |= (disp & 0x0000ffff);
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra, 2 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -298,58 +237,34 @@ bool patcher_invokevirtual(patchref_t *pr)
 
 *******************************************************************************/
 
-bool patcher_invokeinterface(patchref_t *pr)
+bool patcher_invokeinterface(patchref_tpr)
 {
-       u1                *ra;
-       u4                 mcode;
-       unresolved_method *um;
-       methodinfo        *m;
-       s4                 disp;
-
-       /* get stuff from the stack */
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       unresolved_method* um = (unresolved_method*) pr->ref;
 
-       ra    = (u1 *)                pr->mpc;
-       mcode =                       pr->mcode;
-       um    = (unresolved_method *) pr->ref;
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       /* get the fieldinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra, 4);
-
-       /* if we show disassembly, we have to skip the nop */
-
-       if (opt_shownops)
-               ra = ra + 4;
+       // Patch interfacetable index.
+       int32_t disp = OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr*) * m->clazz->index;
 
-       /* patch interfacetable index */
-
-       disp = OFFSET(vftbl_t, interfacetable[0]) -
-               sizeof(methodptr*) * m->clazz->index;
-
-       /* XXX TWISTI: check displacement */
-
-       *((s4 *) (ra + 1 * 4)) |= (disp & 0x0000ffff);
-
-       /* patch method offset */
+       // XXX TWISTI: check displacement
+       pc[1] |= (disp & 0x0000ffff);
 
+       // Patch method offset.
        disp = sizeof(methodptr) * (m - m->clazz->methods);
 
-       /* XXX TWISTI: check displacement */
-
-       *((s4 *) (ra + 2 * 4)) |= (disp & 0x0000ffff);
+       // XXX TWISTI: check displacement
+       pc[2] |= (disp & 0x0000ffff);
 
-       /* synchronize instruction cache */
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 1, 2 * 4);
 
-       md_icacheflush(ra, 3 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -369,46 +284,29 @@ bool patcher_invokeinterface(patchref_t *pr)
 
 *******************************************************************************/
 
-bool patcher_checkcast_interface(patchref_t *pr)
+bool patcher_checkcast_interface(patchref_tpr)
 {
-       u1                *ra;
-       constant_classref *cr;
-       classinfo         *c;
-       s4                 disp;
-       u4                 mcode;
-
-       /* get stuff from stack */
-       ra    = (u1 *)                pr->mpc;
-       mcode =                       pr->mcode;
-       cr    = (constant_classref *) pr->ref;
-
-       /* get the fieldinfo */
-       if (!(c = resolve_classref_eager(cr)))  {
-               return false;
-       }
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       constant_classref* cr = (constant_classref*) pr->ref;
 
-       /* patch back original code */
-       *((u4 *) ra) = mcode;
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra, 4);
-
-       /* if we show NOPs, we have to skip them */
-       if (opt_shownops)
-               ra = ra +4;
-
-       /* patch super class index */
-       disp = -(c->index);
+       if (c == NULL)
+               return false;
 
-       *((s4*)(ra + 2*4)) |= (disp & 0x0000ffff);
+       // Patch super class index.
+       int32_t disp = -(c->index);
+       pc[2] |= (disp & 0x0000ffff);
 
        disp = OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*);
+       pc[5] |= (disp & 0x0000ffff);
 
-       *((s4 *)(ra + 5*4)) |= (disp & 0x0000ffff);
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 2, 4 * 4);
 
-       /* sync instruction cache */
-       md_icacheflush(ra, 6*4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -427,51 +325,29 @@ bool patcher_checkcast_interface(patchref_t *pr)
 
 *******************************************************************************/
 
-bool patcher_instanceof_interface(patchref_t *pr)
+bool patcher_instanceof_interface(patchref_tpr)
 {
-       u1                *ra;
-       u4                 mcode;
-       constant_classref *cr;
-       classinfo         *c;
-       s4                 disp;
-
-       /* get stuff from the stack */
-
-       ra    = (u1 *)                pr->mpc;
-       mcode =                       pr->mcode;
-       cr    = (constant_classref *) pr->ref;
+       uint32_t*          pc = (uint32_t*)          pr->mpc;
+       constant_classref* cr = (constant_classref*) pr->ref;
 
-       /* get the fieldinfo */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra, 4);
-
-       /* if we show disassembly, we have to skip the nop */
-
-       if (opt_shownops)
-               ra = ra + 4;
-
-       /* patch super class index */
-
-       disp = -(c->index);
-
-       *((s4 *) (ra + 2 * 4)) |= (disp & 0x0000ffff);
+       // Patch super class index.
+       int32_t disp = -(c->index);
+       pc[2] |= (disp & 0x0000ffff);
 
        disp = OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*);
+       pc[4] |= (disp & 0x0000ffff);
 
-       *((s4 *) (ra + 4 * 4)) |= (disp & 0x0000ffff);
-
-       /* synchronize instruction cache */
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 2, 3 * 4);
 
-       md_icacheflush(ra, 5 * 4);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -508,41 +384,26 @@ bool patcher_instanceof_interface(patchref_t *pr)
 
 *******************************************************************************/
 
-bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
+bool patcher_resolve_classref_to_classinfo(patchref_tpr)
 {
-       constant_classref *cr;
-       u1                *datap, *ra;
-       u4                 mcode;
-       classinfo         *c;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)         pr->datap;
 
-       /* get stuff from the stack */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       ra    = (u1 *)                pr->mpc;
-       mcode =                       pr->mcode;
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
-
-       /* get the classinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra, 4);
-
-       /* patch the classinfo pointer */
-
-       *((ptrint *) datap) = (ptrint) c;
-
-       /* synchronize data cache */
+       // Patch the classinfo pointer.
+       *datap = (uintptr_t) c;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -565,41 +426,26 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
 
 *******************************************************************************/
 
-bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
+bool patcher_resolve_classref_to_vftbl(patchref_tpr)
 {
-       constant_classref *cr;
-       u1                *datap, *ra;
-       u4                 mcode;
-       classinfo         *c;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)         pr->datap;
 
-       /* get stuff from the stack */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       ra    = (u1 *)                pr->mpc;
-       mcode =                       pr->mcode;
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
-
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra, 4);
-
-       /* patch super class' vftbl */
-
-       *((ptrint *) datap) = (ptrint) c->vftbl;
-
-       /* synchronize data cache */
+       // Patch super class' vftbl.
+       *datap = (uintptr_t) c->vftbl;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -612,41 +458,26 @@ bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
 
 *******************************************************************************/
 
-bool patcher_resolve_classref_to_flags(patchref_t *pr)
+bool patcher_resolve_classref_to_flags(patchref_tpr)
 {
-       constant_classref *cr;
-       u1                *datap, *ra;
-       u4                 mcode;
-       classinfo         *c;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       int32_t*           datap = (int32_t*)           pr->datap;
 
-       /* get stuff from the stack */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       ra    = (u1 *)                pr->mpc;
-       mcode =                       pr->mcode;
-       cr    = (constant_classref *) pr->ref;
-       datap = (u1 *)                pr->datap;
-
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra, 4);
-
-       /* patch class flags */
-
-       *((s4 *) datap) = (s4) c->flags;
-
-       /* synchronize data cache */
+       // Patch class flags.
+       *datap = (int32_t) c->flags;
 
+       // Synchronize data cache.
        md_dcacheflush(datap, SIZEOF_VOID_P);
 
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
index 025c11f62e1e7207e72b2a76e2089f8bef7c9965..32fb401e2e8b3d18d43764b3dc886aeeca34e8c5 100644 (file)
 
 #include "vm/global.h"
 #include "vm/jit/python.h"
-#include "vm/jit/show.h"
+#include "vm/jit/show.hpp"
 #if defined(ENABLE_THREADS)
-# include "threads/lock-common.h"
+# include "threads/mutex.hpp"
 #endif
 
 #if defined(ENABLE_THREADS)
-static java_object_t *python_global_lock;
+static Mutex *python_global_mutex;
 #endif
 
 /*
@@ -1825,8 +1825,7 @@ void pythonpass_init() {
        }
 
 #if defined(ENABLE_THREADS)
-       python_global_lock = NEW(java_object_t);
-       LOCK_INIT_OBJECT_LOCK(python_global_lock);
+       python_global_mutex = Mutex_new();
 #endif
 
 }
@@ -1847,7 +1846,7 @@ int pythonpass_run(jitdata *jd, const char *module, const char *function) {
        int success = 0;
        root_state root;
 
-       LOCK_MONITOR_ENTER(python_global_lock);
+       Mutex_lock(python_global_mutex);
 
        pymodname = PyString_FromString(module);
        pymod = PyImport_Import(pymodname);
@@ -1888,7 +1887,7 @@ int pythonpass_run(jitdata *jd, const char *module, const char *function) {
        Py_XDECREF(pyret);
        Py_XDECREF(objcache);
 
-       LOCK_MONITOR_EXIT(python_global_lock);
+       Mutex_unlock(python_global_mutex);
 
        return (success == 1 ? 1 : 0);
 }
index 56a44d4294751dac3ba81bd1636fc663a4dcea8d..5d63784134e088fbb85f8b99120d5d29cc60bf47 100644 (file)
@@ -26,7 +26,7 @@
 #define _VM_JIT_PYTHON_H
 #if defined(ENABLE_PYTHON)
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 void pythonpass_init();
 void pythonpass_cleanup();
index 699b362befc08de266cbc692e4cc69d680791719..3829d98651bcb3169a3434c88c365f9a35ed9cf6 100644 (file)
@@ -119,7 +119,7 @@ void reg_setup(jitdata *jd)
        assert(rd->tmpadrreguse == ADR_TMP_CNT);
        assert(rd->argadrreguse == ADR_ARG_CNT);
 #endif
-               
+
        /* setup the float register table */
 
        rd->tmpfltregs = DMNEW(s4, FLT_TMP_CNT);
@@ -148,11 +148,7 @@ void reg_setup(jitdata *jd)
        assert(rd->savfltreguse == FLT_SAV_CNT);
        assert(rd->tmpfltreguse == FLT_TMP_CNT);
 
-
        rd->freemem    = DMNEW(s4, m->maxstack);
-#if defined(HAS_4BYTE_STACKSLOT)
-       rd->freemem_2  = DMNEW(s4, m->maxstack);
-#endif
 
 #if defined(SPECIALMEMUSE)
 # if defined(__DARWIN__)
index 66e989f006371a76bb23070191d9531136cbc7cf..5235e1b119ea9356d388263f47c88e6b0e84dcc9 100644 (file)
@@ -37,8 +37,8 @@ typedef struct registerdata registerdata;
 
 #include "arch.h"
 
-#include "vm/jit/jit.h"
-#include "vm/jit/verify/typeinfo.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/verify/typeinfo.hpp"
 
 
 /************************* pseudo variable structure **************************/
@@ -53,6 +53,7 @@ struct varinfo {
                float f;
                double d;
                basicblock *retaddr;
+               s4 ii[2];
        } vv;
 #if defined(ENABLE_VERIFIER)
        typeinfo_t typeinfo;       /* type info for reference types              */
@@ -98,10 +99,6 @@ struct registerdata {
        int freeargadrtop;              /* free argument address register count   */
 #endif
 
-#if defined(HAS_4BYTE_STACKSLOT)
-       int *freemem_2;
-       int freememtop_2;
-#endif
        int *freemem;                   /* free scratch memory                    */
        int freememtop;                 /* free memory count                      */
 
@@ -132,8 +129,16 @@ struct registerdata {
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void reg_setup(jitdata *jd);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _REG_H */
 
 
diff --git a/src/vm/jit/replace.c b/src/vm/jit/replace.c
deleted file mode 100644 (file)
index 5895bec..0000000
+++ /dev/null
@@ -1,3481 +0,0 @@
-/* src/vm/jit/replace.c - on-stack replacement of methods
-
-   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 "vm/types.h"
-
-#include <assert.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "arch.h"
-#include "md.h"
-
-#if defined(ENABLE_GC_CACAO)
-# include "mm/cacao-gc/gc.h"
-#endif
-
-#include "mm/memory.h"
-
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/stringlocal.h"
-
-#include "vm/jit/abi.h"
-#include "vm/jit/asmpart.h"
-#include "vm/jit/disass.h"
-#include "vm/jit/executionstate.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/methodheader.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/show.h"
-#include "vm/jit/stack.h"
-
-#include "vmcore/options.h"
-#include "vmcore/classcache.h"
-
-
-#define REPLACE_PATCH_DYNAMIC_CALL
-/*#define REPLACE_PATCH_ALL*/
-
-#if defined(ENABLE_VMLOG)
-#include <vmlog_cacao.h>
-#endif
-
-/*** architecture-dependent configuration *************************************/
-
-/* first unset the macros (default) */
-#undef REPLACE_RA_BETWEEN_FRAMES
-#undef REPLACE_RA_TOP_OF_FRAME
-#undef REPLACE_RA_LINKAGE_AREA
-#undef REPLACE_LEAFMETHODS_RA_REGISTER
-#undef REPLACE_REG_RA
-
-/* i386, x86_64 and m68k */
-#if defined(__I386__) || defined(__X86_64__) || defined(__M68K__)
-#define REPLACE_RA_BETWEEN_FRAMES
-/* alpha */
-#elif defined(__ALPHA__)
-#define REPLACE_RA_TOP_OF_FRAME
-#define REPLACE_LEAFMETHODS_RA_REGISTER
-#define REPLACE_REG_RA REG_RA
-/* powerpc */
-#elif defined(__POWERPC__)
-#define REPLACE_RA_LINKAGE_AREA
-#define REPLACE_LEAFMETHODS_RA_REGISTER
-#define REPLACE_REG_RA REG_ITMP3 /* the execution state has the LR in itmp3 */
-/* s390 */
-#elif defined(__S390__)
-#define REPLACE_RA_TOP_OF_FRAME
-#define REPLACE_REG_RA REG_ITMP3
-#endif
-
-
-/*** configuration of native stack slot size **********************************/
-
-/* XXX this should be in md-abi.h files, probably */
-
-#if defined(HAS_4BYTE_STACKSLOT)
-#define SIZE_OF_STACKSLOT      4
-#define STACK_SLOTS_PER_FLOAT  2
-typedef u4 stackslot_t;
-#else
-#define SIZE_OF_STACKSLOT      8
-#define STACK_SLOTS_PER_FLOAT  1
-typedef u8 stackslot_t;
-#endif
-
-
-/*** debugging ****************************************************************/
-
-#if !defined(NDEBUG)
-static void java_value_print(s4 type, replace_val_t value);
-static void replace_stackframeinfo_println(stackframeinfo_t *sfi);
-#endif
-
-#if !defined(NDEBUG)
-#define DOLOG(code)        do{ if (opt_TraceReplacement > 1) { code; } } while(0)
-#define DOLOG_SHORT(code)  do{ if (opt_TraceReplacement > 0) { code; } } while(0)
-#else
-#define DOLOG(code)
-#define DOLOG_SHORT(code)
-#endif
-
-
-/*** statistics ***************************************************************/
-
-#define REPLACE_STATISTICS
-
-#if defined(REPLACE_STATISTICS)
-
-static int stat_replacements = 0;
-static int stat_frames = 0;
-static int stat_recompile = 0;
-static int stat_staticpatch = 0;
-static int stat_unroll_inline = 0;
-static int stat_unroll_call = 0;
-static int stat_dist_frames[20] = { 0 };
-static int stat_dist_locals[20] = { 0 };
-static int stat_dist_locals_adr[10] = { 0 };
-static int stat_dist_locals_prim[10] = { 0 };
-static int stat_dist_locals_ret[10] = { 0 };
-static int stat_dist_locals_void[10] = { 0 };
-static int stat_dist_stack[10] = { 0 };
-static int stat_dist_stack_adr[10] = { 0 };
-static int stat_dist_stack_prim[10] = { 0 };
-static int stat_dist_stack_ret[10] = { 0 };
-static int stat_methods = 0;
-static int stat_rploints = 0;
-static int stat_regallocs = 0;
-static int stat_dist_method_rplpoints[20] = { 0 };
-
-#define REPLACE_COUNT(cnt)  (cnt)++
-#define REPLACE_COUNT_IF(cnt, cond)  do{ if(cond) (cnt)++; } while(0)
-#define REPLACE_COUNT_INC(cnt, inc)  ((cnt) += (inc))
-
-#define REPLACE_COUNT_DIST(array, val)                               \
-    do {                                                             \
-        int limit = (sizeof(array) / sizeof(int)) - 1;               \
-        if ((val) < (limit)) (array)[val]++;                         \
-        else (array)[limit]++;                                       \
-    } while (0)
-
-static void replace_statistics_source_frame(sourceframe_t *frame);
-
-#else
-
-#define REPLACE_COUNT(cnt)
-#define REPLACE_COUNT_IF(cnt, cond)
-#define REPLACE_COUNT_INC(cnt, inc)
-#define REPLACE_COUNT_DIST(array, val)
-
-#endif /* defined(REPLACE_STATISTICS) */
-
-
-/*** constants used internally ************************************************/
-
-#define TOP_IS_NORMAL    0
-#define TOP_IS_ON_STACK  1
-#define TOP_IS_IN_ITMP1  2
-#define TOP_IS_VOID      3
-
-
-/******************************************************************************/
-/* PART I: Creating / freeing replacement points                              */
-/******************************************************************************/
-
-
-/* replace_create_replacement_point ********************************************
-   Create a replacement point.
-  
-   IN:
-       jd...............current jitdata
-          iinfo............inlining info for the current position
-          rp...............pre-allocated (uninitialized) rplpoint
-          type.............RPLPOINT_TYPE constant
-          iptr.............current instruction
-          *pra.............current rplalloc pointer
-          javalocals.......the javalocals at the current point
-          stackvars........the stack variables at the current point
-          stackdepth.......the stack depth at the current point
-          paramcount.......number of parameters at the start of stackvars
-  
-   OUT:
-       *rpa.............points to the next free rplalloc
-  
-*******************************************************************************/
-
-static void replace_create_replacement_point(jitdata *jd,
-                                                                                        insinfo_inline *iinfo,
-                                                                                        rplpoint *rp,
-                                                                                        s4 type,
-                                                                                        instruction *iptr,
-                                                                                        rplalloc **pra,
-                                                                                        s4 *javalocals,
-                                                                                        s4 *stackvars,
-                                                                                        s4 stackdepth,
-                                                                                        s4 paramcount)
-{
-       rplalloc *ra;
-       s4        i;
-       varinfo  *v;
-       s4        index;
-
-       ra = *pra;
-
-       REPLACE_COUNT(stat_rploints);
-
-       rp->method = (iinfo) ? iinfo->method : jd->m;
-       rp->pc = NULL;        /* set by codegen */
-       rp->callsize = 0;     /* set by codegen */
-       rp->regalloc = ra;
-       rp->flags = 0;
-       rp->type = type;
-       rp->id = iptr->flags.bits >> INS_FLAG_ID_SHIFT;
-
-       /* XXX unify these two fields */
-       rp->parent = (iinfo) ? iinfo->rp : NULL;
-
-       /* store local allocation info of javalocals */
-
-       if (javalocals) {
-               for (i = 0; i < rp->method->maxlocals; ++i) {
-                       index = javalocals[i];
-                       if (index == UNUSED)
-                               continue;
-
-                       ra->index = i;
-                       if (index >= 0) {
-                               v = VAR(index);
-                               ra->flags = v->flags & (INMEMORY);
-                               ra->regoff = v->vv.regoff;
-                               ra->type = v->type;
-                       }
-                       else {
-                               ra->regoff = RETADDR_FROM_JAVALOCAL(index);
-                               ra->type = TYPE_RET;
-                               ra->flags = 0;
-                       }
-                       ra++;
-               }
-       }
-
-       /* store allocation info of java stack vars */
-
-       for (i = 0; i < stackdepth; ++i) {
-               v = VAR(stackvars[i]);
-               ra->flags = v->flags & (INMEMORY);
-               ra->index = (i < paramcount) ? RPLALLOC_PARAM : RPLALLOC_STACK;
-               ra->type  = v->type;
-               /* XXX how to handle locals on the stack containing returnAddresses? */
-               if (v->type == TYPE_RET) {
-                       assert(stackvars[i] >= jd->localcount);
-                       ra->regoff = v->vv.retaddr->nr;
-               }
-               else
-                       ra->regoff = v->vv.regoff;
-               ra++;
-       }
-
-       /* total number of allocations */
-
-       rp->regalloccount = ra - rp->regalloc;
-
-       *pra = ra;
-}
-
-
-/* replace_create_inline_start_replacement_point *******************************
-
-   Create an INLINE_START replacement point.
-
-   IN:
-       jd...............current jitdata
-          rp...............pre-allocated (uninitialized) rplpoint
-          iptr.............current instruction
-          *pra.............current rplalloc pointer
-          javalocals.......the javalocals at the current point
-
-   OUT:
-       *rpa.............points to the next free rplalloc
-
-   RETURN VALUE:
-       the insinfo_inline * for the following inlined body
-
-*******************************************************************************/
-
-static insinfo_inline * replace_create_inline_start_replacement_point(
-                                                                                        jitdata *jd,
-                                                                                        rplpoint *rp,
-                                                                                        instruction *iptr,
-                                                                                        rplalloc **pra,
-                                                                                        s4 *javalocals)
-{
-       insinfo_inline *calleeinfo;
-       rplalloc       *ra;
-
-       calleeinfo = iptr->sx.s23.s3.inlineinfo;
-
-       calleeinfo->rp = rp;
-
-       replace_create_replacement_point(jd, calleeinfo->parent, rp,
-                       RPLPOINT_TYPE_INLINE, iptr, pra,
-                       javalocals,
-                       calleeinfo->stackvars, calleeinfo->stackvarscount,
-                       calleeinfo->paramcount);
-
-       if (calleeinfo->synclocal != UNUSED) {
-               ra = (*pra)++;
-               ra->index  = RPLALLOC_SYNC;
-               ra->regoff = jd->var[calleeinfo->synclocal].vv.regoff;
-               ra->flags  = jd->var[calleeinfo->synclocal].flags & INMEMORY;
-               ra->type   = TYPE_ADR;
-
-               rp->regalloccount++;
-       }
-
-       return calleeinfo;
-}
-
-
-/* replace_create_replacement_points *******************************************
-   Create the replacement points for the given code.
-  
-   IN:
-       jd...............current jitdata, must not have any replacement points
-  
-   OUT:
-       code->rplpoints.......set to the list of replacement points
-          code->rplpointcount...number of replacement points
-          code->regalloc........list of allocation info
-          code->regalloccount...total length of allocation info list
-          code->globalcount.....number of global allocations at the
-                                start of code->regalloc
-  
-   RETURN VALUE:
-       true.............everything ok 
-       false............an exception has been thrown
-   
-*******************************************************************************/
-
-#define CLEAR_javalocals(array, method)                              \
-    do {                                                             \
-        for (i=0; i<(method)->maxlocals; ++i)                        \
-            (array)[i] = UNUSED;                                     \
-    } while (0)
-
-#define COPY_OR_CLEAR_javalocals(dest, array, method)                \
-    do {                                                             \
-        if ((array) != NULL)                                         \
-            MCOPY((dest), (array), s4, (method)->maxlocals);         \
-        else                                                         \
-            CLEAR_javalocals((dest), (method));                      \
-    } while (0)
-
-#define COUNT_javalocals(array, method, counter)                     \
-    do {                                                             \
-        for (i=0; i<(method)->maxlocals; ++i)                        \
-            if ((array)[i] != UNUSED)                                \
-                               (counter)++;                                         \
-    } while (0)
-
-bool replace_create_replacement_points(jitdata *jd)
-{
-       codeinfo        *code;
-       registerdata    *rd;
-       basicblock      *bptr;
-       int              count;
-       methodinfo      *m;
-       rplpoint        *rplpoints;
-       rplpoint        *rp;
-       int              alloccount;
-       rplalloc        *regalloc;
-       rplalloc        *ra;
-       int              i;
-       instruction     *iptr;
-       instruction     *iend;
-       s4              *javalocals;
-       s4              *jl;
-       methoddesc      *md;
-       insinfo_inline  *iinfo;
-       s4               startcount;
-       s4               firstcount;
-#if defined(REPLACE_PATCH_DYNAMIC_CALL)
-       bool             needentry;
-#endif
-
-       REPLACE_COUNT(stat_methods);
-
-       /* get required compiler data */
-
-       code = jd->code;
-       rd   = jd->rd;
-
-       /* assert that we wont overwrite already allocated data */
-
-       assert(code);
-       assert(code->m);
-       assert(code->rplpoints == NULL);
-       assert(code->rplpointcount == 0);
-       assert(code->regalloc == NULL);
-       assert(code->regalloccount == 0);
-       assert(code->globalcount == 0);
-
-       m = code->m;
-
-       /* in instance methods, we may need a rplpoint at the method entry */
-
-#if defined(REPLACE_PATCH_DYNAMIC_CALL)
-       if (!(m->flags & ACC_STATIC)) {
-               jd->basicblocks[0].bitflags |= BBFLAG_REPLACEMENT;
-               needentry = true;
-       }
-       else {
-               needentry = false;
-       }
-#endif /* defined(REPLACE_PATCH_DYNAMIC_CALL) */
-
-       /* iterate over the basic block list to find replacement points */
-
-       count = 0;
-       alloccount = 0;
-
-       javalocals = DMNEW(s4, jd->maxlocals);
-
-       for (bptr = jd->basicblocks; bptr; bptr = bptr->next) {
-
-               /* skip dead code */
-
-               if (bptr->flags < BBFINISHED)
-                       continue;
-
-               /* get info about this block */
-
-               m = bptr->method;
-               iinfo = bptr->inlineinfo;
-
-               /* initialize javalocals at the start of this block */
-
-               COPY_OR_CLEAR_javalocals(javalocals, bptr->javalocals, m);
-
-               /* iterate over the instructions */
-
-               iptr = bptr->iinstr;
-               iend = iptr + bptr->icount;
-               startcount = count;
-               firstcount = count;
-
-               for (; iptr != iend; ++iptr) {
-                       switch (iptr->opc) {
-#if defined(ENABLE_GC_CACAO)
-                               case ICMD_BUILTIN:
-                                       md = iptr->sx.s23.s3.bte->md;
-                                       count++;
-                                       COUNT_javalocals(javalocals, m, alloccount);
-                                       alloccount += iptr->s1.argcount;
-                                       if (iinfo)
-                                               alloccount -= iinfo->throughcount;
-                                       break;
-#endif
-
-                               case ICMD_INVOKESTATIC:
-                               case ICMD_INVOKESPECIAL:
-                               case ICMD_INVOKEVIRTUAL:
-                               case ICMD_INVOKEINTERFACE:
-                                       INSTRUCTION_GET_METHODDESC(iptr, md);
-                                       count++;
-                                       COUNT_javalocals(javalocals, m, alloccount);
-                                       alloccount += iptr->s1.argcount;
-                                       if (iinfo)
-                                               alloccount -= iinfo->throughcount;
-                                       break;
-
-                               case ICMD_ISTORE:
-                               case ICMD_LSTORE:
-                               case ICMD_FSTORE:
-                               case ICMD_DSTORE:
-                               case ICMD_ASTORE:
-                                       stack_javalocals_store(iptr, javalocals);
-                                       break;
-
-                               case ICMD_IRETURN:
-                               case ICMD_LRETURN:
-                               case ICMD_FRETURN:
-                               case ICMD_DRETURN:
-                               case ICMD_ARETURN:
-                                       alloccount += 1;
-                                       /* FALLTHROUGH! */
-                               case ICMD_RETURN:
-                                       count++;
-                                       break;
-
-                               case ICMD_INLINE_START:
-                                       iinfo = iptr->sx.s23.s3.inlineinfo;
-
-                                       count++;
-                                       COUNT_javalocals(javalocals, m, alloccount);
-                                       alloccount += iinfo->stackvarscount;
-                                       if (iinfo->synclocal != UNUSED)
-                                               alloccount++;
-
-                                       m = iinfo->method;
-                                       /* javalocals may be set at next block start, or now */
-                                       COPY_OR_CLEAR_javalocals(javalocals, iinfo->javalocals_start, m);
-                                       break;
-
-                               case ICMD_INLINE_BODY:
-                                       assert(iinfo == iptr->sx.s23.s3.inlineinfo);
-
-                                       jl = iinfo->javalocals_start;
-                                       if (jl == NULL) {
-                                               /* get the javalocals from the following block start */
-                                               assert(bptr->next);
-                                               jl = bptr->next->javalocals;
-                                       }
-                                       count++;
-                                       COUNT_javalocals(jl, m, alloccount);
-                                       break;
-
-                               case ICMD_INLINE_END:
-                                       assert(iinfo == iptr->sx.s23.s3.inlineinfo ||
-                                                  iinfo == iptr->sx.s23.s3.inlineinfo->parent);
-                                       iinfo = iptr->sx.s23.s3.inlineinfo;
-                                       m = iinfo->outer;
-                                       if (iinfo->javalocals_end)
-                                               MCOPY(javalocals, iinfo->javalocals_end, s4, m->maxlocals);
-                                       iinfo = iinfo->parent;
-                                       break;
-                       }
-
-                       if (iptr == bptr->iinstr)
-                               firstcount = count;
-               } /* end instruction loop */
-
-               /* create replacement points at targets of backward branches */
-               /* We only need the replacement point there, if there is no  */
-               /* replacement point inside the block.                       */
-
-               if (bptr->bitflags & BBFLAG_REPLACEMENT) {
-#if defined(REPLACE_PATCH_DYNAMIC_CALL)
-                       int test = (needentry && bptr == jd->basicblocks) ? firstcount : count;
-#else
-                       int test = count;
-#endif
-                       if (test > startcount) {
-                               /* we don't need an extra rplpoint */
-                               bptr->bitflags &= ~BBFLAG_REPLACEMENT;
-                       }
-                       else {
-                               count++;
-                               alloccount += bptr->indepth;
-                               if (bptr->inlineinfo)
-                                       alloccount -= bptr->inlineinfo->throughcount;
-
-                               COUNT_javalocals(bptr->javalocals, bptr->method, alloccount);
-                       }
-               }
-
-       } /* end basicblock loop */
-
-       /* if no points were found, there's nothing to do */
-
-       if (!count)
-               return true;
-
-       /* allocate replacement point array and allocation array */
-
-       rplpoints = MNEW(rplpoint, count);
-       regalloc = MNEW(rplalloc, alloccount);
-       ra = regalloc;
-
-       /* initialize replacement point structs */
-
-       rp = rplpoints;
-
-       /* XXX try to share code with the counting loop! */
-
-       for (bptr = jd->basicblocks; bptr; bptr = bptr->next) {
-               /* skip dead code */
-
-               if (bptr->flags < BBFINISHED)
-                       continue;
-
-               /* get info about this block */
-
-               m = bptr->method;
-               iinfo = bptr->inlineinfo;
-
-               /* initialize javalocals at the start of this block */
-
-               COPY_OR_CLEAR_javalocals(javalocals, bptr->javalocals, m);
-
-               /* create replacement points at targets of backward branches */
-
-               if (bptr->bitflags & BBFLAG_REPLACEMENT) {
-
-                       i = (iinfo) ? iinfo->throughcount : 0;
-                       replace_create_replacement_point(jd, iinfo, rp++,
-                                       bptr->type, bptr->iinstr, &ra,
-                                       bptr->javalocals, bptr->invars + i, bptr->indepth - i, 0);
-
-                       if (JITDATA_HAS_FLAG_COUNTDOWN(jd))
-                               rp[-1].flags |= RPLPOINT_FLAG_COUNTDOWN;
-               }
-
-               /* iterate over the instructions */
-
-               iptr = bptr->iinstr;
-               iend = iptr + bptr->icount;
-
-               for (; iptr != iend; ++iptr) {
-                       switch (iptr->opc) {
-#if defined(ENABLE_GC_CACAO)
-                               case ICMD_BUILTIN:
-                                       md = iptr->sx.s23.s3.bte->md;
-
-                                       i = (iinfo) ? iinfo->throughcount : 0;
-                                       replace_create_replacement_point(jd, iinfo, rp++,
-                                                       RPLPOINT_TYPE_CALL, iptr, &ra,
-                                                       javalocals, iptr->sx.s23.s2.args,
-                                                       iptr->s1.argcount - i,
-                                                       md->paramcount);
-                                       break;
-#endif
-
-                               case ICMD_INVOKESTATIC:
-                               case ICMD_INVOKESPECIAL:
-                               case ICMD_INVOKEVIRTUAL:
-                               case ICMD_INVOKEINTERFACE:
-                                       INSTRUCTION_GET_METHODDESC(iptr, md);
-
-                                       i = (iinfo) ? iinfo->throughcount : 0;
-                                       replace_create_replacement_point(jd, iinfo, rp++,
-                                                       RPLPOINT_TYPE_CALL, iptr, &ra,
-                                                       javalocals, iptr->sx.s23.s2.args,
-                                                       iptr->s1.argcount - i,
-                                                       md->paramcount);
-                                       break;
-
-                               case ICMD_ISTORE:
-                               case ICMD_LSTORE:
-                               case ICMD_FSTORE:
-                               case ICMD_DSTORE:
-                               case ICMD_ASTORE:
-                                       stack_javalocals_store(iptr, javalocals);
-                                       break;
-
-                               case ICMD_IRETURN:
-                               case ICMD_LRETURN:
-                               case ICMD_FRETURN:
-                               case ICMD_DRETURN:
-                               case ICMD_ARETURN:
-                                       replace_create_replacement_point(jd, iinfo, rp++,
-                                                       RPLPOINT_TYPE_RETURN, iptr, &ra,
-                                                       NULL, &(iptr->s1.varindex), 1, 0);
-                                       break;
-
-                               case ICMD_RETURN:
-                                       replace_create_replacement_point(jd, iinfo, rp++,
-                                                       RPLPOINT_TYPE_RETURN, iptr, &ra,
-                                                       NULL, NULL, 0, 0);
-                                       break;
-
-                               case ICMD_INLINE_START:
-                                       iinfo = replace_create_inline_start_replacement_point(
-                                                               jd, rp++, iptr, &ra, javalocals);
-                                       m = iinfo->method;
-                                       /* javalocals may be set at next block start, or now */
-                                       COPY_OR_CLEAR_javalocals(javalocals, iinfo->javalocals_start, m);
-                                       break;
-
-                               case ICMD_INLINE_BODY:
-                                       assert(iinfo == iptr->sx.s23.s3.inlineinfo);
-
-                                       jl = iinfo->javalocals_start;
-                                       if (jl == NULL) {
-                                               /* get the javalocals from the following block start */
-                                               assert(bptr->next);
-                                               jl = bptr->next->javalocals;
-                                       }
-                                       /* create a non-trappable rplpoint */
-                                       replace_create_replacement_point(jd, iinfo, rp++,
-                                                       RPLPOINT_TYPE_BODY, iptr, &ra,
-                                                       jl, NULL, 0, 0);
-                                       rp[-1].flags |= RPLPOINT_FLAG_NOTRAP;
-                                       break;
-
-                               case ICMD_INLINE_END:
-                                       assert(iinfo == iptr->sx.s23.s3.inlineinfo ||
-                                                  iinfo == iptr->sx.s23.s3.inlineinfo->parent);
-                                       iinfo = iptr->sx.s23.s3.inlineinfo;
-                                       m = iinfo->outer;
-                                       if (iinfo->javalocals_end)
-                                               MCOPY(javalocals, iinfo->javalocals_end, s4, m->maxlocals);
-                                       iinfo = iinfo->parent;
-                                       break;
-                       }
-               } /* end instruction loop */
-       } /* end basicblock loop */
-
-       assert((rp - rplpoints) == count);
-       assert((ra - regalloc) == alloccount);
-
-       /* store the data in the codeinfo */
-
-       code->rplpoints     = rplpoints;
-       code->rplpointcount = count;
-       code->regalloc      = regalloc;
-       code->regalloccount = alloccount;
-       code->globalcount   = 0;
-       code->savedintcount = INT_SAV_CNT - rd->savintreguse;
-       code->savedfltcount = FLT_SAV_CNT - rd->savfltreguse;
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-       code->savedadrcount = ADR_SAV_CNT - rd->savadrreguse;
-#endif
-       code->memuse        = rd->memuse;
-       code->stackframesize = jd->cd->stackframesize;
-
-       REPLACE_COUNT_DIST(stat_dist_method_rplpoints, count);
-       REPLACE_COUNT_INC(stat_regallocs, alloccount);
-
-       /* everything alright */
-
-       return true;
-}
-
-
-/* replace_free_replacement_points *********************************************
-   Free memory used by replacement points.
-  
-   IN:
-       code.............codeinfo whose replacement points should be freed.
-  
-*******************************************************************************/
-
-void replace_free_replacement_points(codeinfo *code)
-{
-       assert(code);
-
-       if (code->rplpoints)
-               MFREE(code->rplpoints,rplpoint,code->rplpointcount);
-
-       if (code->regalloc)
-               MFREE(code->regalloc,rplalloc,code->regalloccount);
-
-       code->rplpoints = NULL;
-       code->rplpointcount = 0;
-       code->regalloc = NULL;
-       code->regalloccount = 0;
-       code->globalcount = 0;
-}
-
-
-/******************************************************************************/
-/* PART II: Activating / deactivating replacement points                      */
-/******************************************************************************/
-
-
-/* replace_activate_replacement_points *****************************************
-   Activate the replacement points of the given compilation unit. When this
-   function returns, the replacement points are "armed", so each thread
-   reaching one of the points will enter the replacement mechanism.
-   
-   IN:
-       code.............codeinfo of which replacement points should be
-                                               activated
-          mappable.........if true, only mappable replacement points are
-                                               activated
-  
-*******************************************************************************/
-
-void replace_activate_replacement_points(codeinfo *code, bool mappable)
-{
-       rplpoint *rp;
-       s4        i;
-       s4        count;
-       u1       *savedmcode;
-
-       assert(code->savedmcode == NULL);
-
-       /* count trappable replacement points */
-
-       count = 0;
-       i = code->rplpointcount;
-       rp = code->rplpoints;
-       for (; i--; rp++) {
-               if (rp->flags & RPLPOINT_FLAG_NOTRAP)
-                       continue;
-
-               if (mappable && (rp->type == RPLPOINT_TYPE_RETURN))
-                       continue;
-
-               count++;
-       }
-
-       /* allocate buffer for saved machine code */
-
-       savedmcode = MNEW(u1, count * REPLACEMENT_PATCH_SIZE);
-       code->savedmcode = savedmcode;
-       savedmcode += count * REPLACEMENT_PATCH_SIZE;
-
-       /* activate trappable replacement points */
-       /* (in reverse order to handle overlapping points within basic blocks) */
-
-       i = code->rplpointcount;
-       rp = code->rplpoints + i;
-       while (rp--, i--) {
-               assert(!(rp->flags & RPLPOINT_FLAG_ACTIVE));
-
-               if (rp->flags & RPLPOINT_FLAG_NOTRAP)
-                       continue;
-
-               if (mappable && (rp->type == RPLPOINT_TYPE_RETURN))
-                       continue;
-
-               DOLOG( printf("activate replacement point:\n");
-                          replace_replacement_point_println(rp, 1); fflush(stdout); );
-
-               savedmcode -= REPLACEMENT_PATCH_SIZE;
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_DISASSEMBLER)
-               DOLOG( printf("\tinstruction before: ");
-                          disassinstr(rp->pc); fflush(stdout); );
-# endif
-
-               md_patch_replacement_point(rp->pc, savedmcode, false);
-
-# if defined(ENABLE_DISASSEMBLER)
-               DOLOG( printf("\tinstruction after : ");
-                          disassinstr(rp->pc); fflush(stdout); );
-# endif
-#endif
-
-               rp->flags |= RPLPOINT_FLAG_ACTIVE;
-       }
-
-       assert(savedmcode == code->savedmcode);
-}
-
-
-/* replace_deactivate_replacement_points ***************************************
-   Deactivate a replacement points in the given compilation unit.
-   When this function returns, the replacement points will be "un-armed",
-   that is a each thread reaching a point will just continue normally.
-   
-   IN:
-       code.............the compilation unit
-  
-*******************************************************************************/
-
-void replace_deactivate_replacement_points(codeinfo *code)
-{
-       rplpoint *rp;
-       s4        i;
-       s4        count;
-       u1       *savedmcode;
-
-       if (code->savedmcode == NULL) {
-               /* disarm countdown points by patching the branches */
-
-               i = code->rplpointcount;
-               rp = code->rplpoints;
-               for (; i--; rp++) {
-                       if ((rp->flags & (RPLPOINT_FLAG_ACTIVE | RPLPOINT_FLAG_COUNTDOWN))
-                                       == RPLPOINT_FLAG_COUNTDOWN)
-                       {
-#if 0
-                               *(s4*) (rp->pc + 9) = 0; /* XXX machine dependent! */
-#endif
-                       }
-               }
-               return;
-       }
-
-       assert(code->savedmcode != NULL);
-       savedmcode = code->savedmcode;
-
-       /* de-activate each trappable replacement point */
-
-       i = code->rplpointcount;
-       rp = code->rplpoints;
-       count = 0;
-       for (; i--; rp++) {
-               if (!(rp->flags & RPLPOINT_FLAG_ACTIVE))
-                       continue;
-
-               count++;
-
-               DOLOG( printf("deactivate replacement point:\n");
-                          replace_replacement_point_println(rp, 1); fflush(stdout); );
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_DISASSEMBLER)
-               DOLOG( printf("\tinstruction before: ");
-                          disassinstr(rp->pc); fflush(stdout); );
-# endif
-
-               md_patch_replacement_point(rp->pc, savedmcode, true);
-
-# if defined(ENABLE_DISASSEMBLER)
-               DOLOG( printf("\tinstruction before: ");
-                          disassinstr(rp->pc); fflush(stdout); );
-# endif
-#endif
-
-               rp->flags &= ~RPLPOINT_FLAG_ACTIVE;
-
-               savedmcode += REPLACEMENT_PATCH_SIZE;
-       }
-
-       assert(savedmcode == code->savedmcode + count * REPLACEMENT_PATCH_SIZE);
-
-       /* free saved machine code */
-
-       MFREE(code->savedmcode, u1, count * REPLACEMENT_PATCH_SIZE);
-       code->savedmcode = NULL;
-}
-
-
-/******************************************************************************/
-/* PART III: The replacement mechanism                                        */
-/******************************************************************************/
-
-
-/* replace_read_value **********************************************************
-
-   Read a value with the given allocation from the execution state.
-   
-   IN:
-          es...............execution state
-          ra...............allocation
-          javaval..........where to put the value
-
-   OUT:
-       *javaval.........the value
-  
-*******************************************************************************/
-
-static void replace_read_value(executionstate_t *es,
-                                                          rplalloc *ra,
-                                                          replace_val_t *javaval)
-{
-       if (ra->flags & INMEMORY) {
-               /* XXX HAS_4BYTE_STACKSLOT may not be the right discriminant here */
-#ifdef HAS_4BYTE_STACKSLOT
-               if (IS_2_WORD_TYPE(ra->type)) {
-                       javaval->l = *(u8*)(es->sp + ra->regoff);
-               }
-               else {
-#endif
-                       javaval->p = *(ptrint*)(es->sp + ra->regoff);
-#ifdef HAS_4BYTE_STACKSLOT
-               }
-#endif
-       }
-       else {
-               /* allocated register */
-               if (IS_FLT_DBL_TYPE(ra->type)) {
-                       javaval->d = es->fltregs[ra->regoff];
-
-                       if (ra->type == TYPE_FLT)
-                               javaval->f = javaval->d;
-               }
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-               else if (IS_ADR_TYPE(ra->type)) {
-                       javaval->p = es->adrregs[ra->regoff];
-               }
-#endif
-               else {
-#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
-                       if (ra->type == TYPE_LNG) {
-                               javaval->words.lo = es->intregs[GET_LOW_REG(ra->regoff)];
-                               javaval->words.hi = es->intregs[GET_HIGH_REG(ra->regoff)];
-                       }
-                       else
-#endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */
-                               javaval->p = es->intregs[ra->regoff];
-               }
-       }
-}
-
-
-/* replace_write_value *********************************************************
-
-   Write a value to the given allocation in the execution state.
-   
-   IN:
-          es...............execution state
-          ra...............allocation
-          *javaval.........the value
-
-*******************************************************************************/
-
-static void replace_write_value(executionstate_t *es,
-                                                           rplalloc *ra,
-                                                           replace_val_t *javaval)
-{
-       if (ra->flags & INMEMORY) {
-               /* XXX HAS_4BYTE_STACKSLOT may not be the right discriminant here */
-#ifdef HAS_4BYTE_STACKSLOT
-               if (IS_2_WORD_TYPE(ra->type)) {
-                       *(u8*)(es->sp + ra->regoff) = javaval->l;
-               }
-               else {
-#endif
-                       *(ptrint*)(es->sp + ra->regoff) = javaval->p;
-#ifdef HAS_4BYTE_STACKSLOT
-               }
-#endif
-       }
-       else {
-               /* allocated register */
-               switch (ra->type) {
-                       case TYPE_FLT:
-                               es->fltregs[ra->regoff] = (double) javaval->f;
-                               break;
-                       case TYPE_DBL:
-                               es->fltregs[ra->regoff] = javaval->d;
-                               break;
-#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
-                       case TYPE_LNG:
-                               es->intregs[GET_LOW_REG(ra->regoff)] = javaval->words.lo;
-                               es->intregs[GET_HIGH_REG(ra->regoff)] = javaval->words.hi;
-                               break;
-#endif
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-                       case TYPE_ADR:
-                               es->adrregs[ra->regoff] = javaval->p;
-#endif
-                       default:
-                               es->intregs[ra->regoff] = javaval->p;
-               }
-       }
-}
-
-
-/* replace_new_sourceframe *****************************************************
-
-   Allocate a new source frame and insert it at the front of the frame list.
-   
-   IN:
-          ss...............the source state
-
-   OUT:
-          ss->frames.......set to new frame (the new head of the frame list).
-
-   RETURN VALUE:
-       returns the new frame
-
-*******************************************************************************/
-
-static sourceframe_t *replace_new_sourceframe(sourcestate_t *ss)
-{
-       sourceframe_t *frame;
-
-       frame = DNEW(sourceframe_t);
-       MZERO(frame, sourceframe_t, 1);
-
-       frame->down = ss->frames;
-       ss->frames = frame;
-
-       return frame;
-}
-
-
-/* replace_read_executionstate *************************************************
-
-   Read a source frame from the given executions state.
-   The new source frame is pushed to the front of the frame list of the
-   source state.
-
-   IN:
-       rp...............replacement point at which `es` was taken
-          es...............execution state
-          ss...............the source state to add the source frame to
-          topframe.........true, if the first (top-most) source frame on the
-                           stack is to be read
-
-   OUT:
-       *ss..............the source state with the newly created source frame
-                           added
-  
-*******************************************************************************/
-
-static s4 replace_normalize_type_map[] = {
-/* RPLPOINT_TYPE_STD    |--> */ RPLPOINT_TYPE_STD,
-/* RPLPOINT_TYPE_EXH    |--> */ RPLPOINT_TYPE_STD,
-/* RPLPOINT_TYPE_SBR    |--> */ RPLPOINT_TYPE_STD,
-/* RPLPOINT_TYPE_CALL   |--> */ RPLPOINT_TYPE_CALL,
-/* RPLPOINT_TYPE_INLINE |--> */ RPLPOINT_TYPE_CALL,
-/* RPLPOINT_TYPE_RETURN |--> */ RPLPOINT_TYPE_RETURN,
-/* RPLPOINT_TYPE_BODY   |--> */ RPLPOINT_TYPE_STD
-};
-
-
-static void replace_read_executionstate(rplpoint *rp,
-                                                                               executionstate_t *es,
-                                                                               sourcestate_t *ss,
-                                                                               bool topframe)
-{
-       methodinfo    *m;
-       codeinfo      *code;
-       int            count;
-       int            i;
-       rplalloc      *ra;
-       sourceframe_t *frame;
-       int            topslot;
-       stackslot_t   *sp;
-       stackslot_t   *basesp;
-
-       code = code_find_codeinfo_for_pc(rp->pc);
-       m = rp->method;
-       topslot = TOP_IS_NORMAL;
-
-       /* stack pointer */
-
-       sp = (stackslot_t *) es->sp;
-
-       /* in some cases the top stack slot is passed in REG_ITMP1 */
-
-       if (rp->type == BBTYPE_EXH) {
-               topslot = TOP_IS_IN_ITMP1;
-       }
-
-       /* calculate base stack pointer */
-
-       basesp = sp + code->stackframesize;
-
-       /* create the source frame */
-
-       frame = replace_new_sourceframe(ss);
-       frame->method = rp->method;
-       frame->id = rp->id;
-       assert(rp->type >= 0 && rp->type < sizeof(replace_normalize_type_map)/sizeof(s4));
-       frame->type = replace_normalize_type_map[rp->type];
-       frame->fromrp = rp;
-       frame->fromcode = code;
-
-       /* read local variables */
-
-       count = m->maxlocals;
-       frame->javalocalcount = count;
-       frame->javalocals = DMNEW(replace_val_t, count);
-       frame->javalocaltype = DMNEW(u1, count);
-
-       /* mark values as undefined */
-       for (i=0; i<count; ++i) {
-#if !defined(NDEBUG)
-               frame->javalocals[i].l = (u8) 0x00dead0000dead00ULL;
-#endif
-               frame->javalocaltype[i] = TYPE_VOID;
-       }
-
-       /* some entries in the intregs array are not meaningful */
-       /*es->intregs[REG_ITMP3] = (u8) 0x11dead1111dead11ULL;*/
-#if !defined(NDEBUG)
-       es->intregs[REG_SP   ] = (ptrint) 0x11dead1111dead11ULL;
-#ifdef REG_PV
-       es->intregs[REG_PV   ] = (ptrint) 0x11dead1111dead11ULL;
-#endif
-#endif /* !defined(NDEBUG) */
-
-       /* read javalocals */
-
-       count = rp->regalloccount;
-       ra = rp->regalloc;
-
-       while (count && (i = ra->index) >= 0) {
-               assert(i < m->maxlocals);
-               frame->javalocaltype[i] = ra->type;
-               if (ra->type == TYPE_RET)
-                       frame->javalocals[i].i = ra->regoff;
-               else
-                       replace_read_value(es, ra, frame->javalocals + i);
-               ra++;
-               count--;
-       }
-
-       /* read instance, if this is the first rplpoint */
-
-#if defined(REPLACE_PATCH_DYNAMIC_CALL)
-       if (topframe && !(rp->method->flags & ACC_STATIC) && rp == code->rplpoints) {
-#if 1
-               /* we are at the start of the method body, so if local 0 is set, */
-               /* it is the instance.                                           */
-               if (frame->javalocaltype[0] == TYPE_ADR)
-                       frame->instance = frame->javalocals[0];
-#else
-               rplalloc instra;
-               methoddesc *md;
-
-               md = rp->method->parseddesc;
-               assert(md->params);
-               assert(md->paramcount >= 1);
-               instra.type = TYPE_ADR;
-               instra.regoff = md->params[0].regoff;
-               if (md->params[0].inmemory) {
-                       instra.flags = INMEMORY;
-                       instra.regoff += (1 + code->stackframesize) * SIZE_OF_STACKSLOT;
-               }
-               else {
-                       instra.flags = 0;
-               }
-               replace_read_value(es, &instra, &(frame->instance));
-#endif
-       }
-#endif /* defined(REPLACE_PATCH_DYNAMIC_CALL) */
-
-       /* read stack slots */
-
-       frame->javastackdepth = count;
-       frame->javastack = DMNEW(replace_val_t, count);
-       frame->javastacktype = DMNEW(u1, count);
-
-#if !defined(NDEBUG)
-       /* mark values as undefined */
-       for (i=0; i<count; ++i) {
-               frame->javastack[i].l = (u8) 0x00dead0000dead00ULL;
-               frame->javastacktype[i] = TYPE_VOID;
-       }
-#endif /* !defined(NDEBUG) */
-
-       i = 0;
-
-       /* the first stack slot is special in SBR and EXH blocks */
-
-       if (topslot == TOP_IS_ON_STACK) {
-               assert(count);
-
-               assert(ra->index == RPLALLOC_STACK);
-               assert(ra->type == TYPE_ADR);
-               frame->javastack[i].p = sp[-1];
-               frame->javastacktype[i] = TYPE_ADR; /* XXX RET */
-               count--;
-               i++;
-               ra++;
-       }
-       else if (topslot == TOP_IS_IN_ITMP1) {
-               assert(count);
-
-               assert(ra->index == RPLALLOC_STACK);
-               assert(ra->type == TYPE_ADR);
-               frame->javastack[i].p = es->intregs[REG_ITMP1];
-               frame->javastacktype[i] = TYPE_ADR; /* XXX RET */
-               count--;
-               i++;
-               ra++;
-       }
-       else if (topslot == TOP_IS_VOID) {
-               assert(count);
-
-               assert(ra->index == RPLALLOC_STACK);
-               frame->javastack[i].l = 0;
-               frame->javastacktype[i] = TYPE_VOID;
-               count--;
-               i++;
-               ra++;
-       }
-
-       /* read remaining stack slots */
-
-       for (; count--; ra++) {
-               if (ra->index == RPLALLOC_SYNC) {
-                       assert(rp->type == RPLPOINT_TYPE_INLINE);
-
-                       /* only read synchronization slots when traversing an inline point */
-
-                       if (!topframe) {
-                               sourceframe_t *calleeframe = frame->down;
-                               assert(calleeframe);
-                               assert(calleeframe->syncslotcount == 0);
-                               assert(calleeframe->syncslots == NULL);
-
-                               calleeframe->syncslotcount = 1;
-                               calleeframe->syncslots = DMNEW(replace_val_t, 1);
-                               replace_read_value(es,ra,calleeframe->syncslots);
-                       }
-
-                       frame->javastackdepth--;
-                       continue;
-               }
-
-               assert(ra->index == RPLALLOC_STACK || ra->index == RPLALLOC_PARAM);
-
-               /* do not read parameters of calls down the call chain */
-
-               if (!topframe && ra->index == RPLALLOC_PARAM) {
-                       frame->javastackdepth--;
-               }
-               else {
-                       if (ra->type == TYPE_RET)
-                               frame->javastack[i].i = ra->regoff;
-                       else
-                               replace_read_value(es,ra,frame->javastack + i);
-                       frame->javastacktype[i] = ra->type;
-                       i++;
-               }
-       }
-}
-
-
-/* replace_write_executionstate ************************************************
-
-   Pop a source frame from the front of the frame list of the given source state
-   and write its values into the execution state.
-
-   IN:
-       rp...............replacement point for which execution state should be
-                           created
-          es...............the execution state to modify
-          ss...............the given source state
-          topframe.........true, if this is the last (top-most) source frame to be
-                           translated
-
-   OUT:
-       *es..............the execution state derived from the source state
-  
-*******************************************************************************/
-
-static void replace_write_executionstate(rplpoint *rp,
-                                                                                executionstate_t *es,
-                                                                                sourcestate_t *ss,
-                                                                                bool topframe)
-{
-       methodinfo     *m;
-       codeinfo       *code;
-       int             count;
-       int             i;
-       rplalloc       *ra;
-       sourceframe_t  *frame;
-       int             topslot;
-       stackslot_t    *sp;
-       stackslot_t    *basesp;
-
-       code = code_find_codeinfo_for_pc(rp->pc);
-       m = rp->method;
-       topslot = TOP_IS_NORMAL;
-
-       /* pop a source frame */
-
-       frame = ss->frames;
-       assert(frame);
-       ss->frames = frame->down;
-
-       /* calculate stack pointer */
-
-       sp = (stackslot_t *) es->sp;
-
-       basesp = sp + code->stackframesize;
-
-       /* in some cases the top stack slot is passed in REG_ITMP1 */
-
-       if (rp->type == BBTYPE_EXH) {
-               topslot = TOP_IS_IN_ITMP1;
-       }
-
-       /* write javalocals */
-
-       ra = rp->regalloc;
-       count = rp->regalloccount;
-
-       while (count && (i = ra->index) >= 0) {
-               assert(i < m->maxlocals);
-               assert(i < frame->javalocalcount);
-               assert(ra->type == frame->javalocaltype[i]);
-               if (ra->type == TYPE_RET) {
-                       /* XXX assert that it matches this rplpoint */
-               }
-               else
-                       replace_write_value(es, ra, frame->javalocals + i);
-               count--;
-               ra++;
-       }
-
-       /* write stack slots */
-
-       i = 0;
-
-       /* the first stack slot is special in SBR and EXH blocks */
-
-       if (topslot == TOP_IS_ON_STACK) {
-               assert(count);
-
-               assert(ra->index == RPLALLOC_STACK);
-               assert(i < frame->javastackdepth);
-               assert(frame->javastacktype[i] == TYPE_ADR);
-               sp[-1] = frame->javastack[i].p;
-               count--;
-               i++;
-               ra++;
-       }
-       else if (topslot == TOP_IS_IN_ITMP1) {
-               assert(count);
-
-               assert(ra->index == RPLALLOC_STACK);
-               assert(i < frame->javastackdepth);
-               assert(frame->javastacktype[i] == TYPE_ADR);
-               es->intregs[REG_ITMP1] = frame->javastack[i].p;
-               count--;
-               i++;
-               ra++;
-       }
-       else if (topslot == TOP_IS_VOID) {
-               assert(count);
-
-               assert(ra->index == RPLALLOC_STACK);
-               assert(i < frame->javastackdepth);
-               assert(frame->javastacktype[i] == TYPE_VOID);
-               count--;
-               i++;
-               ra++;
-       }
-
-       /* write remaining stack slots */
-
-       for (; count--; ra++) {
-               if (ra->index == RPLALLOC_SYNC) {
-                       assert(rp->type == RPLPOINT_TYPE_INLINE);
-
-                       /* only write synchronization slots when traversing an inline point */
-
-                       if (!topframe) {
-                               assert(frame->down);
-                               assert(frame->down->syncslotcount == 1); /* XXX need to understand more cases */
-                               assert(frame->down->syncslots != NULL);
-
-                               replace_write_value(es,ra,frame->down->syncslots);
-                       }
-                       continue;
-               }
-
-               assert(ra->index == RPLALLOC_STACK || ra->index == RPLALLOC_PARAM);
-
-               /* do not write parameters of calls down the call chain */
-
-               if (!topframe && ra->index == RPLALLOC_PARAM) {
-                       /* skip it */
-               }
-               else {
-                       assert(i < frame->javastackdepth);
-                       assert(ra->type == frame->javastacktype[i]);
-                       if (ra->type == TYPE_RET) {
-                               /* XXX assert that it matches this rplpoint */
-                       }
-                       else {
-                               replace_write_value(es,ra,frame->javastack + i);
-                       }
-                       i++;
-               }
-       }
-
-       /* set new pc */
-
-       es->pc = rp->pc;
-}
-
-
-/* replace_pop_activation_record ***********************************************
-
-   Peel a stack frame from the execution state.
-   
-   *** This function imitates the effects of the method epilog ***
-   *** and returning from the method call.                     ***
-
-   IN:
-          es...............execution state
-          frame............source frame, receives synchronization slots
-
-   OUT:
-       *es..............the execution state after popping the stack frame
-  
-*******************************************************************************/
-
-u1* replace_pop_activation_record(executionstate_t *es,
-                                                                 sourceframe_t *frame)
-{
-       u1 *ra;
-       u1 *pv;
-       s4 reg;
-       s4 i;
-       s4 count;
-       codeinfo *code;
-       stackslot_t *basesp;
-       stackslot_t *sp;
-
-       assert(es->code);
-       assert(frame);
-
-       /* read the return address */
-
-#if defined(REPLACE_LEAFMETHODS_RA_REGISTER)
-       if (code_is_leafmethod(es->code))
-               ra = (u1*) (ptrint) es->intregs[REPLACE_REG_RA];
-       else
-#endif
-               ra = md_stacktrace_get_returnaddress(es->sp,
-                               SIZE_OF_STACKSLOT * es->code->stackframesize);
-
-       DOLOG( printf("RA = %p\n", (void*)ra); );
-
-       assert(ra);
-
-       /* calculate the base of the stack frame */
-
-       sp = (stackslot_t *) es->sp;
-       basesp = sp + es->code->stackframesize;
-
-       /* read slots used for synchronization */
-
-       assert(frame->syncslotcount == 0);
-       assert(frame->syncslots == NULL);
-       count = code_get_sync_slot_count(es->code);
-       frame->syncslotcount = count;
-       frame->syncslots = DMNEW(replace_val_t, count);
-       for (i=0; i<count; ++i) {
-               frame->syncslots[i].p = sp[es->code->memuse + i]; /* XXX */
-       }
-
-       /* restore return address, if part of frame */
-
-#if defined(REPLACE_RA_TOP_OF_FRAME)
-#if defined(REPLACE_LEAFMETHODS_RA_REGISTER)
-       if (!code_is_leafmethod(es->code))
-#endif
-               es->intregs[REPLACE_REG_RA] = *--basesp;
-#endif /* REPLACE_RA_TOP_OF_FRAME */
-
-#if defined(REPLACE_RA_LINKAGE_AREA)
-#if defined(REPLACE_LEAFMETHODS_RA_REGISTER)
-       if (!code_is_leafmethod(es->code))
-#endif
-               es->intregs[REPLACE_REG_RA] = basesp[LA_LR_OFFSET / sizeof(stackslot_t)];
-#endif /* REPLACE_RA_LINKAGE_AREA */
-
-       /* restore saved int registers */
-
-       reg = INT_REG_CNT;
-       for (i=0; i<es->code->savedintcount; ++i) {
-               while (nregdescint[--reg] != REG_SAV)
-                       ;
-               es->intregs[reg] = *--basesp;
-       }
-
-       /* restore saved flt registers */
-
-       /* XXX align? */
-       reg = FLT_REG_CNT;
-       for (i=0; i<es->code->savedfltcount; ++i) {
-               while (nregdescfloat[--reg] != REG_SAV)
-                       ;
-               basesp -= STACK_SLOTS_PER_FLOAT;
-               es->fltregs[reg] = *(double*)basesp;
-       }
-
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-       /* restore saved adr registers */
-
-       reg = ADR_REG_CNT;
-       for (i=0; i<es->code->savedadrcount; ++i) {
-               while (nregdescadr[--reg] != REG_SAV)
-                       ;
-               es->adrregs[reg] = *--basesp;
-       }
-#endif
-
-       /* adjust the stackpointer */
-
-       es->sp += SIZE_OF_STACKSLOT * es->code->stackframesize;
-
-#if defined(REPLACE_RA_BETWEEN_FRAMES)
-       es->sp += SIZE_OF_STACKSLOT; /* skip return address */
-#endif
-
-       /* Set the new pc. Subtract one so we do not hit the replacement point */
-       /* of the instruction following the call, if there is one.             */
-
-       es->pc = ra - 1;
-
-       /* find the new codeinfo */
-
-       pv = md_codegen_get_pv_from_pc(ra);
-       DOLOG( printf("PV = %p\n", (void*) pv); );
-
-       code = code_get_codeinfo_for_pv(pv);
-       DOLOG( printf("CODE = %p\n", (void*) code); );
-
-       /* return NULL if we reached native code */
-
-       es->pv = pv;
-       es->code = code;
-
-       /* in debugging mode clobber non-saved registers */
-
-#if !defined(NDEBUG)
-       /* for debugging */
-       for (i=0; i<INT_REG_CNT; ++i)
-               if ((nregdescint[i] != REG_SAV)
-#if defined(REG_RA)
-                               && (i != REPLACE_REG_RA)
-#endif
-                       )
-                       es->intregs[i] = (ptrint) 0x33dead3333dead33ULL;
-       for (i=0; i<FLT_REG_CNT; ++i)
-               if (nregdescfloat[i] != REG_SAV)
-                       *(u8*)&(es->fltregs[i]) = 0x33dead3333dead33ULL;
-# if defined(HAS_ADDRESS_REGISTER_FILE)
-       for (i=0; i<ADR_REG_CNT; ++i)
-               if (nregdescadr[i] != REG_SAV)
-                       es->adrregs[i] = (ptrint) 0x33dead3333dead33ULL;
-# endif
-#endif /* !defined(NDEBUG) */
-
-       return (code) ? ra : NULL;
-}
-
-
-/* replace_patch_method_pointer ************************************************
-
-   Patch a method pointer (may be in code, data segment, vftbl, or interface
-   table).
-
-   IN:
-          mpp..............address of the method pointer to patch
-          entrypoint.......the new entrypoint of the method
-          kind.............kind of call to patch, used only for debugging
-
-*******************************************************************************/
-
-static void replace_patch_method_pointer(methodptr *mpp,
-                                                                                methodptr entrypoint,
-                                                                                const char *kind)
-{
-#if !defined(NDEBUG)
-       codeinfo       *oldcode;
-       codeinfo       *newcode;
-#endif
-
-       DOLOG( printf("patch method pointer from: %p to %p\n",
-                                 (void*) *mpp, (void*)entrypoint); );
-
-#if !defined(NDEBUG)
-       oldcode = code_get_codeinfo_for_pv(*mpp);
-       newcode = code_get_codeinfo_for_pv(entrypoint);
-
-       DOLOG_SHORT( printf("\tpatch %s %p ", kind, (void*) oldcode);
-                                method_println(oldcode->m);
-                                printf("\t      with      %p ", (void*) newcode);
-                                method_println(newcode->m); );
-
-       assert(oldcode->m == newcode->m);
-#endif
-
-       /* write the new entrypoint */
-
-       *mpp = (methodptr) entrypoint;
-}
-
-
-/* replace_patch_class *********************************************************
-
-   Patch a method in the given class.
-
-   IN:
-          vftbl............vftbl of the class
-          m................the method to patch
-          oldentrypoint....the old entrypoint to replace
-          entrypoint.......the new entrypoint
-
-*******************************************************************************/
-
-void replace_patch_class(vftbl_t *vftbl,
-                                                methodinfo *m,
-                                                u1 *oldentrypoint,
-                                                u1 *entrypoint)
-{
-       s4                 i;
-       methodptr         *mpp;
-       methodptr         *mppend;
-
-       /* patch the vftbl of the class */
-
-       replace_patch_method_pointer(vftbl->table + m->vftblindex,
-                                                                entrypoint,
-                                                                "virtual  ");
-
-       /* patch the interface tables */
-
-       assert(oldentrypoint);
-
-       for (i=0; i < vftbl->interfacetablelength; ++i) {
-               mpp = vftbl->interfacetable[-i];
-               mppend = mpp + vftbl->interfacevftbllength[i];
-               for (; mpp != mppend; ++mpp)
-                       if (*mpp == oldentrypoint) {
-                               replace_patch_method_pointer(mpp, entrypoint, "interface");
-                       }
-       }
-}
-
-
-/* replace_patch_class_hierarchy ***********************************************
-
-   Patch a method in all loaded classes.
-
-   IN:
-          m................the method to patch
-          oldentrypoint....the old entrypoint to replace
-          entrypoint.......the new entrypoint
-
-*******************************************************************************/
-
-struct replace_patch_data_t {
-       methodinfo *m;
-       u1         *oldentrypoint;
-       u1         *entrypoint;
-};
-
-void replace_patch_callback(classinfo *c, struct replace_patch_data_t *pd)
-{
-       vftbl_t *vftbl = c->vftbl;
-
-       if (vftbl != NULL
-               && vftbl->vftbllength > pd->m->vftblindex
-               && vftbl->table[pd->m->vftblindex] != &asm_abstractmethoderror
-               && code_get_methodinfo_for_pv(vftbl->table[pd->m->vftblindex]) == pd->m)
-       {
-               replace_patch_class(c->vftbl, pd->m, pd->oldentrypoint, pd->entrypoint);
-       }
-}
-
-void replace_patch_class_hierarchy(methodinfo *m,
-                                                                  u1 *oldentrypoint,
-                                                                  u1 *entrypoint)
-{
-       struct replace_patch_data_t pd;
-
-       pd.m = m;
-       pd.oldentrypoint = oldentrypoint;
-       pd.entrypoint = entrypoint;
-
-       DOLOG_SHORT( printf("patching class hierarchy: ");
-                            method_println(m); );
-
-       classcache_foreach_loaded_class(
-                       (classcache_foreach_functionptr_t) &replace_patch_callback,
-                       (void*) &pd);
-}
-
-
-/* replace_patch_future_calls **************************************************
-
-   Analyse a call site and depending on the kind of call patch the call, the
-   virtual function table, or the interface table.
-
-   IN:
-          ra...............return address pointing after the call site
-          callerframe......source frame of the caller
-          calleeframe......source frame of the callee, must have been mapped
-
-*******************************************************************************/
-
-void replace_patch_future_calls(u1 *ra,
-                                                               sourceframe_t *callerframe,
-                                                               sourceframe_t *calleeframe)
-{
-       u1            *patchpos;
-       methodptr      entrypoint;
-       methodptr      oldentrypoint;
-       bool           atentry;
-       void          *pv;
-       codeinfo      *calleecode;
-       methodinfo    *calleem;
-       java_object_t *obj;
-       vftbl_t       *vftbl;
-
-       assert(ra);
-       assert(callerframe->down == calleeframe);
-
-       /* get the new codeinfo and the method that shall be entered */
-
-       calleecode = calleeframe->tocode;
-       assert(calleecode);
-
-       calleem = calleeframe->method;
-       assert(calleem == calleecode->m);
-
-       entrypoint = (methodptr) calleecode->entrypoint;
-
-       /* check if we are at an method entry rplpoint at the innermost frame */
-
-       atentry = (calleeframe->down == NULL)
-                       && !(calleem->flags & ACC_STATIC)
-                       && (calleeframe->fromrp->id == 0); /* XXX */
-
-       /* get the position to patch, in case it was a statically bound call   */
-
-       pv = callerframe->fromcode->entrypoint;
-       patchpos = md_jit_method_patch_address(pv, ra, NULL);
-
-       if (patchpos == NULL) {
-               /* the call was dispatched dynamically */
-
-               /* we can only patch such calls if we are at the entry point */
-
-               if (!atentry)
-                       return;
-
-               assert((calleem->flags & ACC_STATIC) == 0);
-
-               oldentrypoint = calleeframe->fromcode->entrypoint;
-
-               /* we need to know the instance */
-
-               if (!calleeframe->instance.a) {
-                       DOLOG_SHORT( printf("WARNING: object instance unknown!\n"); );
-                       replace_patch_class_hierarchy(calleem, oldentrypoint, entrypoint);
-                       return;
-               }
-
-               /* get the vftbl */
-
-               obj = calleeframe->instance.a;
-               vftbl = obj->vftbl;
-
-               assert(vftbl->clazz->vftbl == vftbl);
-
-               DOLOG_SHORT( printf("\tclass: "); class_println(vftbl->clazz); );
-
-               replace_patch_class(vftbl, calleem, oldentrypoint, entrypoint);
-       }
-       else {
-               /* the call was statically bound */
-
-               replace_patch_method_pointer((methodptr *) patchpos, entrypoint, "static   ");
-       }
-}
-
-
-/* replace_push_activation_record **********************************************
-
-   Push a stack frame onto the execution state.
-   
-   *** This function imitates the effects of a call and the ***
-   *** method prolog of the callee.                         ***
-
-   IN:
-          es...............execution state
-          rpcall...........the replacement point at the call site
-          callerframe......source frame of the caller, or NULL for creating the
-                           first frame
-          calleeframe......source frame of the callee, must have been mapped
-
-   OUT:
-       *es..............the execution state after pushing the stack frame
-  
-*******************************************************************************/
-
-void replace_push_activation_record(executionstate_t *es,
-                                                                       rplpoint *rpcall,
-                                                                       sourceframe_t *callerframe,
-                                                                       sourceframe_t *calleeframe)
-{
-       s4           reg;
-       s4           i;
-       s4           count;
-       stackslot_t *basesp;
-       stackslot_t *sp;
-       u1          *ra;
-       codeinfo    *calleecode;
-
-       assert(es);
-       assert(!rpcall || callerframe);
-    assert(!rpcall || rpcall->type == RPLPOINT_TYPE_CALL);
-       assert(!rpcall || rpcall == callerframe->torp);
-       assert(calleeframe);
-       assert(!callerframe || calleeframe == callerframe->down);
-
-       /* the compilation unit we are entering */
-
-       calleecode = calleeframe->tocode;
-       assert(calleecode);
-
-       /* calculate the return address */
-
-       if (rpcall)
-               ra = rpcall->pc + rpcall->callsize;
-       else
-               ra = es->pc + 1 /* XXX this is ugly */;
-
-       /* write the return address */
-
-#if defined(REPLACE_RA_BETWEEN_FRAMES)
-       es->sp -= SIZE_OF_STACKSLOT;
-
-       *((stackslot_t *)es->sp) = (stackslot_t) ra;
-#endif /* REPLACE_RA_BETWEEN_FRAMES */
-
-#if defined(REPLACE_REG_RA)
-       es->intregs[REPLACE_REG_RA] = (ptrint) ra;
-#endif
-
-       /* we move into a new code unit */
-
-       es->code = calleecode;
-
-       /* set the new pc XXX not needed? */
-
-       es->pc = calleecode->entrypoint;
-
-       /* build the stackframe */
-
-       DOLOG( printf("building stackframe of %d words at %p\n",
-                                 calleecode->stackframesize, (void*)es->sp); );
-
-       sp = (stackslot_t *) es->sp;
-       basesp = sp;
-
-       sp -= calleecode->stackframesize;
-       es->sp = (u1*) sp;
-
-       /* in debug mode, invalidate stack frame first */
-
-       /* XXX may not invalidate linkage area used by native code! */
-#if !defined(NDEBUG) && 0
-       for (i=0; i<(basesp - sp); ++i) {
-               sp[i] = 0xdeaddeadU;
-       }
-#endif
-
-       /* save the return address register */
-
-#if defined(REPLACE_RA_TOP_OF_FRAME)
-#if defined(REPLACE_LEAFMETHODS_RA_REGISTER)
-       if (!code_is_leafmethod(calleecode))
-#endif
-               *--basesp = (ptrint) ra;
-#endif /* REPLACE_RA_TOP_OF_FRAME */
-
-#if defined(REPLACE_RA_LINKAGE_AREA)
-#if defined(REPLACE_LEAFMETHODS_RA_REGISTER)
-       if (!code_is_leafmethod(calleecode))
-#endif
-               basesp[LA_LR_OFFSET / sizeof(stackslot_t)] = (ptrint) ra;
-#endif /* REPLACE_RA_LINKAGE_AREA */
-
-       /* save int registers */
-
-       reg = INT_REG_CNT;
-       for (i=0; i<calleecode->savedintcount; ++i) {
-               while (nregdescint[--reg] != REG_SAV)
-                       ;
-               *--basesp = es->intregs[reg];
-
-               /* XXX may not clobber saved regs used by native code! */
-#if !defined(NDEBUG) && 0
-               es->intregs[reg] = (ptrint) 0x44dead4444dead44ULL;
-#endif
-       }
-
-       /* save flt registers */
-
-       /* XXX align? */
-       reg = FLT_REG_CNT;
-       for (i=0; i<calleecode->savedfltcount; ++i) {
-               while (nregdescfloat[--reg] != REG_SAV)
-                       ;
-               basesp -= STACK_SLOTS_PER_FLOAT;
-               *(double*)basesp = es->fltregs[reg];
-
-               /* XXX may not clobber saved regs used by native code! */
-#if !defined(NDEBUG) && 0
-               *(u8*)&(es->fltregs[reg]) = 0x44dead4444dead44ULL;
-#endif
-       }
-
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-       /* save adr registers */
-
-       reg = ADR_REG_CNT;
-       for (i=0; i<calleecode->savedadrcount; ++i) {
-               while (nregdescadr[--reg] != REG_SAV)
-                       ;
-               *--basesp = es->adrregs[reg];
-
-               /* XXX may not clobber saved regs used by native code! */
-#if !defined(NDEBUG) && 0
-               es->adrregs[reg] = (ptrint) 0x44dead4444dead44ULL;
-#endif
-       }
-#endif
-
-       /* write slots used for synchronization */
-
-       count = code_get_sync_slot_count(calleecode);
-       assert(count == calleeframe->syncslotcount);
-       for (i=0; i<count; ++i) {
-               sp[calleecode->memuse + i] = calleeframe->syncslots[i].p;
-       }
-
-       /* set the PV */
-
-       es->pv = calleecode->entrypoint;
-
-       /* redirect future invocations */
-
-       if (callerframe && rpcall) {
-#if defined(REPLACE_PATCH_ALL)
-               if (rpcall->type == callerframe->fromrp->type)
-#else
-               if (rpcall == callerframe->fromrp)
-#endif
-                       replace_patch_future_calls(ra, callerframe, calleeframe);
-       }
-}
-
-
-/* replace_find_replacement_point **********************************************
-
-   Find the replacement point in the given code corresponding to the
-   position given in the source frame.
-   
-   IN:
-          code.............the codeinfo in which to search the rplpoint
-          frame............the source frame defining the position to look for
-          parent...........parent replacement point to match
-
-   RETURN VALUE:
-       the replacement point
-  
-*******************************************************************************/
-
-rplpoint * replace_find_replacement_point(codeinfo *code,
-                                                                                 sourceframe_t *frame,
-                                                                                 rplpoint *parent)
-{
-       methodinfo *m;
-       rplpoint *rp;
-       s4        i;
-       s4        j;
-       s4        stacki;
-       rplalloc *ra;
-
-       assert(code);
-       assert(frame);
-
-       DOLOG( printf("searching replacement point for:\n");
-                  replace_source_frame_println(frame); );
-
-       m = frame->method;
-
-       DOLOG( printf("code = %p\n", (void*)code); );
-
-       rp = code->rplpoints;
-       i = code->rplpointcount;
-       while (i--) {
-               if (rp->id == frame->id && rp->method == frame->method
-                               && rp->parent == parent
-                               && replace_normalize_type_map[rp->type] == frame->type)
-               {
-                       /* check if returnAddresses match */
-                       /* XXX optimize: only do this if JSRs in method */
-                       DOLOG( printf("checking match for:");
-                                  replace_replacement_point_println(rp, 1); fflush(stdout); );
-                       ra = rp->regalloc;
-                       stacki = 0;
-                       for (j = rp->regalloccount; j--; ++ra) {
-                               if (ra->type == TYPE_RET) {
-                                       if (ra->index == RPLALLOC_STACK) {
-                                               assert(stacki < frame->javastackdepth);
-                                               if (frame->javastack[stacki].i != ra->regoff)
-                                                       goto no_match;
-                                               stacki++;
-                                       }
-                                       else {
-                                               assert(ra->index >= 0 && ra->index < frame->javalocalcount);
-                                               if (frame->javalocals[ra->index].i != ra->regoff)
-                                                       goto no_match;
-                                       }
-                               }
-                       }
-
-                       /* found */
-                       return rp;
-               }
-no_match:
-               rp++;
-       }
-
-#if !defined(NDEBUG)
-       printf("candidate replacement points were:\n");
-       rp = code->rplpoints;
-       i = code->rplpointcount;
-       for (; i--; ++rp) {
-               replace_replacement_point_println(rp, 1);
-       }
-#endif
-
-       vm_abort("no matching replacement point found");
-       return NULL; /* NOT REACHED */
-}
-
-
-/* replace_find_replacement_point_for_pc ***************************************
-
-   Find the nearest replacement point at or before the given PC. The
-   given PC has to be between (rp->pc) and (rp->pc+rp->callsize) for
-   the replacement point to be found.
-
-   IN:
-       code.............compilation unit the PC is in
-          pc...............the machine code PC
-
-   RETURN VALUE:
-       the replacement point found, or
-          NULL if no replacement point was found
-
-*******************************************************************************/
-
-rplpoint *replace_find_replacement_point_for_pc(codeinfo *code, u1 *pc)
-{
-       rplpoint *found;
-       rplpoint *rp;
-       s4        i;
-
-       DOLOG( printf("searching for rp at pc:%p in %p ", (void*)pc, (void*)code);
-                  method_println(code->m); );
-
-       found = NULL;
-
-       rp = code->rplpoints;
-       for (i=0; i<code->rplpointcount; ++i, ++rp) {
-               DOLOG( replace_replacement_point_println(rp, 2); );
-               if (rp->pc <= pc && rp->pc + rp->callsize >= pc)
-                       found = rp;
-       }
-
-       return found;
-}
-
-
-/* replace_pop_native_frame ****************************************************
-
-   Unroll a native frame in the execution state and create a source frame
-   for it.
-
-   IN:
-          es...............current execution state
-          ss...............the current source state
-          sfi..............stackframeinfo for the native frame
-
-   OUT:
-       es...............execution state after unrolling the native frame
-          ss...............gets the added native source frame
-
-*******************************************************************************/
-
-static void replace_pop_native_frame(executionstate_t *es,
-                                                                        sourcestate_t *ss,
-                                                                        stackframeinfo_t *sfi)
-{
-       sourceframe_t *frame;
-       codeinfo      *code;
-       s4             i,j;
-
-       assert(sfi);
-
-       frame = replace_new_sourceframe(ss);
-
-       frame->sfi = sfi;
-
-       /* remember pc and size of native frame */
-
-       frame->nativepc = es->pc;
-       frame->nativeframesize = (es->sp != 0) ? (sfi->sp - es->sp) : 0;
-       assert(frame->nativeframesize >= 0);
-
-       /* remember values of saved registers */
-
-       j = 0;
-       for (i=0; i<INT_REG_CNT; ++i) {
-               if (nregdescint[i] == REG_SAV)
-                       frame->nativesavint[j++] = es->intregs[i];
-       }
-
-       j = 0;
-       for (i=0; i<FLT_REG_CNT; ++i) {
-               if (nregdescfloat[i] == REG_SAV)
-                       frame->nativesavflt[j++] = es->fltregs[i];
-       }
-
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-       j = 0;
-       for (i=0; i<ADR_REG_CNT; ++i) {
-               if (nregdescadr[i] == REG_SAV)
-                       frame->nativesavadr[j++] = es->adrregs[i];
-       }
-#endif
-
-       /* restore saved registers */
-
-#if defined(ENABLE_GC_CACAO) && !defined(HAS_ADDRESS_REGISTER_FILE)
-       j = 0;
-       for (i=0; i<INT_REG_CNT; ++i) {
-               if (nregdescint[i] == REG_SAV)
-                       es->intregs[i] = sfi->intregs[j++];
-       }
-#else
-       /* XXX we don't have them, yet, in the sfi, so clear them */
-
-       for (i=0; i<INT_REG_CNT; ++i) {
-               if (nregdescint[i] == REG_SAV)
-                       es->intregs[i] = 0;
-       }
-#endif
-
-       /* XXX we don't have float registers in the sfi, so clear them */
-
-       for (i=0; i<FLT_REG_CNT; ++i) {
-               if (nregdescfloat[i] == REG_SAV)
-                       es->fltregs[i] = 0.0;
-       }
-
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-# if defined(ENABLE_GC_CACAO)
-       j = 0;
-       for (i=0; i<ADR_REG_CNT; ++i) {
-               if (nregdescadr[i] == REG_SAV)
-                       es->adrregs[i] = sfi->adrregs[j++];
-       }
-# else
-       for (i=0; i<ADR_REG_CNT; ++i) {
-               if (nregdescadr[i] == REG_SAV)
-                       es->adrregs[i] = 0;
-       }
-# endif
-#endif
-
-       /* restore codeinfo of the native stub */
-
-       code = code_get_codeinfo_for_pv(sfi->pv);
-
-       /* restore sp, pv, pc and codeinfo of the parent method */
-
-       /* XXX michi: use this instead:
-       es->sp = sfi->sp + code->stackframesize; */
-       es->sp   = sfi->sp + (*(s4 *) (sfi->pv + FrameSize));
-#if defined(REPLACE_RA_BETWEEN_FRAMES)
-       es->sp  += SIZE_OF_STACKSLOT; /* skip return address */
-#endif
-       es->pv   = md_codegen_get_pv_from_pc(sfi->ra);
-       es->pc   = ((sfi->xpc) ? sfi->xpc : sfi->ra) - 1;
-       es->code = code_get_codeinfo_for_pv(es->pv);
-}
-
-
-/* replace_push_native_frame ***************************************************
-
-   Rebuild a native frame onto the execution state and remove its source frame.
-
-   Note: The native frame is "rebuild" by setting fields like PC and stack
-         pointer in the execution state accordingly. Values in the
-                stackframeinfo may be modified, but the actual stack frame of the
-                native code is not touched.
-
-   IN:
-          es...............current execution state
-          ss...............the current source state
-
-   OUT:
-       es...............execution state after re-rolling the native frame
-          ss...............the native source frame is removed
-
-*******************************************************************************/
-
-static void replace_push_native_frame(executionstate_t *es, sourcestate_t *ss)
-{
-       sourceframe_t *frame;
-       s4             i,j;
-
-       assert(es);
-       assert(ss);
-
-       DOLOG( printf("pushing native frame\n"); );
-
-       /* remove the frame from the source state */
-
-       frame = ss->frames;
-       assert(frame);
-       assert(REPLACE_IS_NATIVE_FRAME(frame));
-
-       ss->frames = frame->down;
-
-       /* skip sp for the native stub */
-
-       es->sp -= (*(s4 *) (frame->sfi->pv + FrameSize));
-#if defined(REPLACE_RA_BETWEEN_FRAMES)
-       es->sp -= SIZE_OF_STACKSLOT; /* skip return address */
-#endif
-
-       /* assert that the native frame has not moved */
-
-       assert(es->sp == frame->sfi->sp);
-
-       /* update saved registers in the stackframeinfo */
-
-#if defined(ENABLE_GC_CACAO)
-       j = 0;
-# if !defined(HAS_ADDRESS_REGISTER_FILE)
-       for (i=0; i<INT_REG_CNT; ++i) {
-               if (nregdescint[i] == REG_SAV)
-                       frame->sfi->intregs[j++] = es->intregs[i];
-       }
-# else
-       for (i=0; i<ADR_REG_CNT; ++i) {
-               if (nregdescadr[i] == REG_SAV)
-                       frame->sfi->adrregs[j++] = es->adrregs[i];
-       }
-# endif
-
-       /* XXX leave float registers untouched here */
-#endif
-
-       /* restore saved registers */
-
-       j = 0;
-       for (i=0; i<INT_REG_CNT; ++i) {
-               if (nregdescint[i] == REG_SAV)
-                       es->intregs[i] = frame->nativesavint[j++];
-       }
-
-       j = 0;
-       for (i=0; i<FLT_REG_CNT; ++i) {
-               if (nregdescfloat[i] == REG_SAV)
-                       es->fltregs[i] = frame->nativesavflt[j++];
-       }
-
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-       j = 0;
-       for (i=0; i<ADR_REG_CNT; ++i) {
-               if (nregdescadr[i] == REG_SAV)
-                       es->adrregs[i] = frame->nativesavadr[j++];
-       }
-#endif
-
-       /* skip the native frame on the machine stack */
-
-       es->sp -= frame->nativeframesize;
-
-       /* set the pc the next frame must return to */
-
-       es->pc = frame->nativepc;
-}
-
-
-/* replace_recover_source_state ************************************************
-
-   Recover the source state from the given replacement point and execution
-   state.
-
-   IN:
-       rp...............replacement point that has been reached, if any
-          sfi..............stackframeinfo, if called from native code
-          es...............execution state at the replacement point rp
-
-   RETURN VALUE:
-       the source state
-
-*******************************************************************************/
-
-sourcestate_t *replace_recover_source_state(rplpoint *rp,
-                                                                                       stackframeinfo_t *sfi,
-                                                                                   executionstate_t *es)
-{
-       sourcestate_t *ss;
-       u1            *ra;
-       bool           locked;
-#if defined(REPLACE_STATISTICS)
-       s4             depth;
-#endif
-
-       /* create the source frame structure in dump memory */
-
-       ss = DNEW(sourcestate_t);
-       ss->frames = NULL;
-
-       /* each iteration of the loop recovers one source frame */
-
-       depth = 0;
-       locked = false;
-
-       while (rp || sfi) {
-
-               DOLOG( executionstate_println(es); );
-
-               /* if we are not at a replacement point, it is a native frame */
-
-               if (rp == NULL) {
-                       DOLOG( printf("native frame: sfi: "); replace_stackframeinfo_println(sfi); );
-
-                       locked = true;
-                       replace_pop_native_frame(es, ss, sfi);
-                       sfi = sfi->prev;
-
-                       if (es->code == NULL)
-                               continue;
-
-                       goto after_machine_frame;
-               }
-
-               /* read the values for this source frame from the execution state */
-
-               DOLOG( printf("recovering source state for%s:\n",
-                                       (ss->frames == NULL) ? " TOPFRAME" : "");
-                          replace_replacement_point_println(rp, 1); );
-
-               replace_read_executionstate(rp, es, ss, ss->frames == NULL);
-
-#if defined(ENABLE_VMLOG)
-               vmlog_cacao_unrol_method(ss->frames->method);
-#endif
-
-#if defined(REPLACE_STATISTICS)
-               REPLACE_COUNT(stat_frames);
-               depth++;
-               replace_statistics_source_frame(ss->frames);
-#endif
-
-               /* in locked areas (below native frames), identity map the frame */
-
-               if (locked) {
-                       ss->frames->torp = ss->frames->fromrp;
-                       ss->frames->tocode = ss->frames->fromcode;
-               }
-
-               /* unroll to the next (outer) frame */
-
-               if (rp->parent) {
-                       /* this frame is in inlined code */
-
-                       DOLOG( printf("INLINED!\n"); );
-
-                       rp = rp->parent;
-
-                       assert(rp->type == RPLPOINT_TYPE_INLINE);
-                       REPLACE_COUNT(stat_unroll_inline);
-               }
-               else {
-                       /* this frame had been called at machine-level. pop it. */
-
-                       DOLOG( printf("UNWIND\n"); );
-
-                       ra = replace_pop_activation_record(es, ss->frames);
-                       if (ra == NULL) {
-                               DOLOG( printf("REACHED NATIVE CODE\n"); );
-
-                               rp = NULL;
-
-#if !defined(ENABLE_GC_CACAO)
-                               break; /* XXX remove to activate native frames */
-#endif
-                               continue;
-                       }
-
-                       /* find the replacement point at the call site */
-
-after_machine_frame:
-                       rp = replace_find_replacement_point_for_pc(es->code, es->pc);
-
-                       if (rp == NULL)
-                               vm_abort("could not find replacement point while unrolling call");
-
-                       DOLOG( printf("found replacement point.\n");
-                                       replace_replacement_point_println(rp, 1); );
-
-                       assert(rp->type == RPLPOINT_TYPE_CALL);
-                       REPLACE_COUNT(stat_unroll_call);
-               }
-       } /* end loop over source frames */
-
-       REPLACE_COUNT_DIST(stat_dist_frames, depth);
-
-       return ss;
-}
-
-
-/* replace_map_source_state ****************************************************
-
-   Map each source frame in the given source state to a target replacement
-   point and compilation unit. If no valid code is available for a source
-   frame, it is (re)compiled.
-
-   IN:
-       ss...............the source state
-
-   OUT:
-       ss...............the source state, modified: The `torp` and `tocode`
-                           fields of each source frame are set.
-
-   RETURN VALUE:
-       true.............everything went ok
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-static bool replace_map_source_state(sourcestate_t *ss)
-{
-       sourceframe_t *frame;
-       codeinfo      *code;
-       rplpoint      *rp;
-       rplpoint      *parent; /* parent of inlined rplpoint */
-#if defined(REPLACE_STATISTICS)
-       codeinfo      *oldcode;
-#endif
-
-       parent = NULL;
-       code = NULL;
-
-       /* iterate over the source frames from outermost to innermost */
-
-       for (frame = ss->frames; frame != NULL; frame = frame->down) {
-
-               /* XXX skip native frames */
-
-               if (REPLACE_IS_NATIVE_FRAME(frame)) {
-                       parent = NULL;
-                       continue;
-               }
-
-               /* map frames which are not already mapped */
-
-               if (frame->tocode) {
-                       code = frame->tocode;
-                       rp = frame->torp;
-                       assert(rp);
-               }
-               else {
-                       assert(frame->torp == NULL);
-
-                       if (parent == NULL) {
-                               /* find code for this frame */
-
-#if defined(REPLACE_STATISTICS)
-                               oldcode = frame->method->code;
-#endif
-                               /* request optimization of hot methods and their callers */
-
-                               if (frame->method->hitcountdown < 0
-                                       || (frame->down && frame->down->method->hitcountdown < 0))
-                                       jit_request_optimization(frame->method);
-
-                               code = jit_get_current_code(frame->method);
-
-                               if (code == NULL)
-                                       return false; /* exception */
-
-                               REPLACE_COUNT_IF(stat_recompile, code != oldcode);
-                       }
-
-                       assert(code);
-
-                       /* map this frame */
-
-                       rp = replace_find_replacement_point(code, frame, parent);
-
-                       frame->tocode = code;
-                       frame->torp = rp;
-               }
-
-               if (rp->type == RPLPOINT_TYPE_CALL) {
-                       parent = NULL;
-               }
-               else {
-                       /* inlining */
-                       parent = rp;
-               }
-       }
-
-       return true;
-}
-
-
-/* replace_map_source_state_identity *******************************************
-
-   Map each source frame in the given source state to the same replacement
-   point and compilation unit it was derived from. This is mainly used for
-   garbage collection.
-
-   IN:
-       ss...............the source state
-
-   OUT:
-       ss...............the source state, modified: The `torp` and `tocode`
-                           fields of each source frame are set.
-
-*******************************************************************************/
-
-#if defined(ENABLE_GC_CACAO)
-static void replace_map_source_state_identity(sourcestate_t *ss)
-{
-       sourceframe_t *frame;
-
-       /* iterate over the source frames from outermost to innermost */
-
-       for (frame = ss->frames; frame != NULL; frame = frame->down) {
-
-               /* skip native frames */
-
-               if (REPLACE_IS_NATIVE_FRAME(frame)) {
-                       continue;
-               }
-
-               /* map frames using the identity mapping */
-
-               if (frame->tocode) {
-                       assert(frame->tocode == frame->fromcode);
-                       assert(frame->torp   == frame->fromrp);
-               } else {
-                       assert(frame->tocode == NULL);
-                       assert(frame->torp   == NULL);
-                       frame->tocode = frame->fromcode;
-                       frame->torp   = frame->fromrp;
-               }
-       }
-}
-#endif
-
-
-/* replace_build_execution_state ***********************************************
-
-   Build an execution state for the given (mapped) source state.
-
-   !!! CAUTION: This function rewrites the machine stack !!!
-
-   THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA!
-
-   IN:
-       ss...............the source state. Must have been mapped by
-                                               replace_map_source_state before.
-          es...............the base execution state on which to build
-
-   OUT:
-       *es..............the new execution state
-
-*******************************************************************************/
-
-static void replace_build_execution_state(sourcestate_t *ss,
-                                                                                 executionstate_t *es)
-{
-       rplpoint      *rp;
-       sourceframe_t *prevframe;
-       rplpoint      *parent;
-
-       parent = NULL;
-       prevframe = NULL;
-       rp = NULL;
-
-       while (ss->frames) {
-
-               if (REPLACE_IS_NATIVE_FRAME(ss->frames)) {
-                       prevframe = ss->frames;
-                       replace_push_native_frame(es, ss);
-                       parent = NULL;
-                       rp = NULL;
-                       continue;
-               }
-
-               if (parent == NULL) {
-                       /* create a machine-level stack frame */
-
-                       DOLOG( printf("pushing activation record for:\n");
-                                  if (rp) replace_replacement_point_println(rp, 1);
-                                  else printf("\tfirst frame\n"); );
-
-                       replace_push_activation_record(es, rp, prevframe, ss->frames);
-
-                       DOLOG( executionstate_println(es); );
-               }
-
-               rp = ss->frames->torp;
-               assert(rp);
-
-               DOLOG( printf("creating execution state for%s:\n",
-                               (ss->frames->down == NULL) ? " TOPFRAME" : "");
-                          replace_replacement_point_println(ss->frames->fromrp, 1);
-                          replace_replacement_point_println(rp, 1); );
-
-               es->code = ss->frames->tocode;
-               prevframe = ss->frames;
-
-#if defined(ENABLE_VMLOG)
-               vmlog_cacao_rerol_method(ss->frames->method);
-#endif
-
-               replace_write_executionstate(rp, es, ss, ss->frames->down == NULL);
-
-               DOLOG( executionstate_println(es); );
-
-               if (rp->type == RPLPOINT_TYPE_CALL) {
-                       parent = NULL;
-               }
-               else {
-                       /* inlining */
-                       parent = rp;
-               }
-       }
-}
-
-
-/* replace_me ******************************************************************
-   This function is called by the signal handler when a thread reaches
-   a replacement point. `replace_me` must map the execution state to the
-   target replacement point and let execution continue there.
-
-   THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA!
-
-   IN:
-       rp...............replacement point that has been reached
-       es...............execution state read by signal handler
-  
-*******************************************************************************/
-
-static void replace_me(rplpoint *rp, executionstate_t *es)
-{
-       stackframeinfo_t    *sfi;
-       sourcestate_t       *ss;
-       sourceframe_t       *frame;
-       codeinfo            *origcode;
-       rplpoint            *origrp;
-#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
-       threadobject        *thread;
-#endif
-       int32_t              dumpmarker;
-
-       origcode = es->code;
-       origrp   = rp;
-
-       DOLOG_SHORT( printf("REPLACING(%d %p): (id %d %p) ",
-                                stat_replacements, (void*)THREADOBJECT,
-                                rp->id, (void*)rp);
-                                method_println(es->code->m); );
-
-       DOLOG( replace_replacement_point_println(rp, 1); );
-
-       REPLACE_COUNT(stat_replacements);
-
-       /* mark start of dump memory area */
-
-       DMARKER;
-
-       /* Get the stackframeinfo for the current thread. */
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* recover source state */
-
-       ss = replace_recover_source_state(rp, sfi, es);
-
-#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
-       /* if there is a collection pending, we assume the replacement point should
-          suspend this thread */
-
-       if (gc_pending) {
-
-               thread = THREADOBJECT;
-
-               DOLOG_SHORT( printf("REPLACEMENT: Suspending thread for GC now!\n"); );
-
-               /* map the sourcestate using the identity mapping */
-               replace_map_source_state_identity(ss);
-
-               /* since we enter the same method again, we turn off rps now */
-               /* XXX michi: can we really do this? what if the rp was active before
-                  we activated it for the gc? */
-               replace_deactivate_replacement_points(origcode);
-
-               /* remember executionstate and sourcestate for this thread */
-               GC_EXECUTIONSTATE = es;
-               GC_SOURCESTATE    = ss;
-
-               /* really suspend this thread now (PC = 0) */
-               threads_suspend_ack(NULL, NULL);
-
-               DOLOG_SHORT( printf("REPLACEMENT: Resuming thread after GC now!\n"); );
-
-       } else {
-#endif /*defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)*/
-
-       /* map the source state */
-
-       if (!replace_map_source_state(ss))
-               vm_abort("exception during method replacement");
-
-       DOLOG( replace_sourcestate_println(ss); );
-
-       DOLOG_SHORT( replace_sourcestate_println_short(ss); );
-
-#if !defined(NDEBUG)
-       /* avoid infinite loops by self-replacement, only if not in testing mode */
-
-       if (!opt_TestReplacement) {
-               frame = ss->frames;
-               while (frame->down)
-                       frame = frame->down;
-
-               if (frame->torp == origrp) {
-                       DOLOG_SHORT(
-                               printf("WARNING: identity replacement, turning off rps to avoid infinite loop\n");
-                       );
-                       replace_deactivate_replacement_points(origcode);
-               }
-       }
-#endif
-
-#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
-       }
-#endif
-
-       /* build the new execution state */
-
-       replace_build_execution_state(ss, es);
-
-#if !defined(NDEBUG)
-       /* continue execution after patched machine code, if testing mode enabled */
-
-       if (opt_TestReplacement)
-               es->pc += REPLACEMENT_PATCH_SIZE;
-#endif
-
-       /* release dump area */
-
-       DRELEASE;
-}
-
-
-/* replace_me_wrapper **********************************************************
-
-   This function is called by the signal handler. It determines if there
-   is an active replacement point pending at the given PC and returns
-   accordingly.
-
-   THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA!
-
-   IN:
-       pc...............the program counter that triggered the replacement.
-       context..........the context (machine state) to which the
-                           replacement should be applied.
-
-   OUT:
-       context..........the context after replacement finished.
-
-   RETURN VALUE:
-       true.............replacement done, everything went ok
-       false............no replacement done, context unchanged
-
-*******************************************************************************/
-
-bool replace_me_wrapper(u1 *pc, void *context)
-{
-       codeinfo         *code;
-       rplpoint         *rp;
-       executionstate_t  es;
-
-       /* search the codeinfo for the given PC */
-
-       code = code_find_codeinfo_for_pc(pc);
-       assert(code);
-
-       /* search for a replacement point at the given PC */
-
-       rp = replace_find_replacement_point_for_pc(code, pc);
-
-       /* check if the replacement point belongs to given PC and is active */
-
-       if ((rp != NULL) && (rp->pc == pc) && (rp->flags & RPLPOINT_FLAG_ACTIVE)) {
-
-#if !defined(NDEBUG)
-               executionstate_sanity_check(context);
-#endif
-
-               /* set codeinfo pointer in execution state */
-
-               es.code = code;
-
-               /* read execution state from current context */
-
-               md_executionstate_read(&es, context);
-
-               DOLOG( printf("REPLACEMENT READ: ");
-                          executionstate_println(&es); );
-
-               /* do the actual replacement */
-
-               replace_me(rp, &es);
-
-               /* write execution state to current context */
-
-               md_executionstate_write(&es, context);
-
-               DOLOG( printf("REPLACEMENT WRITE: ");
-                          executionstate_println(&es); );
-
-               /* new code is entered after returning */
-
-               DOLOG( printf("JUMPING IN!\n"); fflush(stdout); );
-               return true;
-       }
-       else
-               return false;
-}
-
-
-/******************************************************************************/
-/* NOTE: Stuff specific to the exact GC is below.                             */
-/******************************************************************************/
-
-#if defined(ENABLE_GC_CACAO)
-void replace_gc_from_native(threadobject *thread, u1 *pc, u1 *sp)
-{
-       stackframeinfo_t *sfi;
-       executionstate_t *es;
-       sourcestate_t    *ss;
-
-       /* Get the stackframeinfo of this thread. */
-
-       assert(thread == THREADOBJECT);
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* create the execution state */
-       es = DNEW(executionstate_t);
-       es->pc = pc;
-       es->sp = sp;
-       es->pv = 0;      /* since we are in a native, PV is invalid! */
-       es->code = NULL; /* since we are in a native, we do not have a codeinfo */
-
-       /* we assume we are in a native (no replacement point)! */
-       ss = replace_recover_source_state(NULL, sfi, es);
-
-       /* map the sourcestate using the identity mapping */
-       replace_map_source_state_identity(ss);
-
-       /* remember executionstate and sourcestate for this thread */
-       GC_EXECUTIONSTATE = es;
-       GC_SOURCESTATE    = ss;
-}
-#endif
-
-#if defined(ENABLE_GC_CACAO)
-void replace_gc_into_native(threadobject *thread)
-{
-       executionstate_t *es;
-       sourcestate_t    *ss;
-
-       /* get the executionstate and sourcestate for the given thread */
-       es = GC_EXECUTIONSTATE;
-       ss = GC_SOURCESTATE;
-
-       /* rebuild the stack of the given thread */
-       replace_build_execution_state(ss, es);
-}
-#endif
-
-
-/******************************************************************************/
-/* NOTE: No important code below.                                             */
-/******************************************************************************/
-
-
-/* statistics *****************************************************************/
-
-#if defined(REPLACE_STATISTICS)
-static void print_freq(FILE *file,int *array,int limit)
-{
-       int i;
-       int sum = 0;
-       int cum = 0;
-       for (i=0; i<limit; ++i)
-               sum += array[i];
-       sum += array[limit];
-       for (i=0; i<limit; ++i) {
-               cum += array[i];
-               fprintf(file,"      %3d: %8d (cum %3d%%)\n",
-                               i, array[i], (sum) ? ((100*cum)/sum) : 0);
-       }
-       fprintf(file,"    >=%3d: %8d\n",limit,array[limit]);
-}
-#endif /* defined(REPLACE_STATISTICS) */
-
-
-#if defined(REPLACE_STATISTICS)
-
-#define REPLACE_PRINT_DIST(name, array)                              \
-    printf("    " name " distribution:\n");                          \
-    print_freq(stdout, (array), sizeof(array)/sizeof(int) - 1);
-
-void replace_print_statistics(void)
-{
-       printf("replacement statistics:\n");
-       printf("    # of replacements:   %d\n", stat_replacements);
-       printf("    # of frames:         %d\n", stat_frames);
-       printf("    # of recompilations: %d\n", stat_recompile);
-       printf("    patched static calls:%d\n", stat_staticpatch);
-       printf("    unrolled inlines:    %d\n", stat_unroll_inline);
-       printf("    unrolled calls:      %d\n", stat_unroll_call);
-       REPLACE_PRINT_DIST("frame depth", stat_dist_frames);
-       REPLACE_PRINT_DIST("locals per frame", stat_dist_locals);
-       REPLACE_PRINT_DIST("ADR locals per frame", stat_dist_locals_adr);
-       REPLACE_PRINT_DIST("primitive locals per frame", stat_dist_locals_prim);
-       REPLACE_PRINT_DIST("RET locals per frame", stat_dist_locals_ret);
-       REPLACE_PRINT_DIST("void locals per frame", stat_dist_locals_void);
-       REPLACE_PRINT_DIST("stack slots per frame", stat_dist_stack);
-       REPLACE_PRINT_DIST("ADR stack slots per frame", stat_dist_stack_adr);
-       REPLACE_PRINT_DIST("primitive stack slots per frame", stat_dist_stack_prim);
-       REPLACE_PRINT_DIST("RET stack slots per frame", stat_dist_stack_ret);
-       printf("\n");
-       printf("    # of methods:            %d\n", stat_methods);
-       printf("    # of replacement points: %d\n", stat_rploints);
-       printf("    # of regallocs:          %d\n", stat_regallocs);
-       printf("        per rplpoint:        %f\n", (double)stat_regallocs / stat_rploints);
-       printf("        per method:          %f\n", (double)stat_regallocs / stat_methods);
-       REPLACE_PRINT_DIST("replacement points per method", stat_dist_method_rplpoints);
-       printf("\n");
-
-}
-#endif /* defined(REPLACE_STATISTICS) */
-
-
-#if defined(REPLACE_STATISTICS)
-static void replace_statistics_source_frame(sourceframe_t *frame)
-{
-       int adr = 0;
-       int ret = 0;
-       int prim = 0;
-       int vd = 0;
-       int n = 0;
-       int i;
-
-       for (i=0; i<frame->javalocalcount; ++i) {
-               switch (frame->javalocaltype[i]) {
-                       case TYPE_ADR: adr++; break;
-                       case TYPE_RET: ret++; break;
-                       case TYPE_INT: case TYPE_LNG: case TYPE_FLT: case TYPE_DBL: prim++; break;
-                       case TYPE_VOID: vd++; break;
-                       default: assert(0);
-               }
-               n++;
-       }
-       REPLACE_COUNT_DIST(stat_dist_locals, n);
-       REPLACE_COUNT_DIST(stat_dist_locals_adr, adr);
-       REPLACE_COUNT_DIST(stat_dist_locals_void, vd);
-       REPLACE_COUNT_DIST(stat_dist_locals_ret, ret);
-       REPLACE_COUNT_DIST(stat_dist_locals_prim, prim);
-       adr = ret = prim = n = 0;
-       for (i=0; i<frame->javastackdepth; ++i) {
-               switch (frame->javastacktype[i]) {
-                       case TYPE_ADR: adr++; break;
-                       case TYPE_RET: ret++; break;
-                       case TYPE_INT: case TYPE_LNG: case TYPE_FLT: case TYPE_DBL: prim++; break;
-               }
-               n++;
-       }
-       REPLACE_COUNT_DIST(stat_dist_stack, n);
-       REPLACE_COUNT_DIST(stat_dist_stack_adr, adr);
-       REPLACE_COUNT_DIST(stat_dist_stack_ret, ret);
-       REPLACE_COUNT_DIST(stat_dist_stack_prim, prim);
-}
-#endif /* defined(REPLACE_STATISTICS) */
-
-
-/* debugging helpers **********************************************************/
-
-/* replace_replacement_point_println *******************************************
-   Print replacement point info.
-  
-   IN:
-       rp...............the replacement point to print
-  
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-
-#define TYPECHAR(t)  (((t) >= 0 && (t) <= TYPE_RET) ? show_jit_type_letters[t] : '?')
-
-static char *replace_type_str[] = {
-       "STD",
-       "EXH",
-       "SBR",
-       "CALL",
-       "INLINE",
-       "RETURN",
-       "BODY"
-};
-
-void replace_replacement_point_println(rplpoint *rp, int depth)
-{
-       int j;
-       int index;
-
-       if (!rp) {
-               printf("(rplpoint *)NULL\n");
-               return;
-       }
-
-       for (j=0; j<depth; ++j)
-               putchar('\t');
-
-       printf("rplpoint (id %d) %p pc:%p+%d type:%s",
-                       rp->id, (void*)rp,rp->pc,rp->callsize,
-                       replace_type_str[rp->type]);
-       if (rp->flags & RPLPOINT_FLAG_NOTRAP)
-               printf(" NOTRAP");
-       if (rp->flags & RPLPOINT_FLAG_COUNTDOWN)
-               printf(" COUNTDOWN");
-       if (rp->flags & RPLPOINT_FLAG_ACTIVE)
-               printf(" ACTIVE");
-       printf(" parent:%p\n", (void*)rp->parent);
-       for (j=0; j<depth; ++j)
-               putchar('\t');
-       printf("ra:%d = [",     rp->regalloccount);
-
-       for (j=0; j<rp->regalloccount; ++j) {
-               if (j)
-                       putchar(' ');
-               index = rp->regalloc[j].index;
-               switch (index) {
-                       case RPLALLOC_STACK: printf("S"); break;
-                       case RPLALLOC_PARAM: printf("P"); break;
-                       case RPLALLOC_SYNC : printf("Y"); break;
-                       default: printf("%d", index);
-               }
-               printf(":%1c:", TYPECHAR(rp->regalloc[j].type));
-               if (rp->regalloc[j].type == TYPE_RET) {
-                       printf("ret(L%03d)", rp->regalloc[j].regoff);
-               }
-               else {
-                       show_allocation(rp->regalloc[j].type, rp->regalloc[j].flags, rp->regalloc[j].regoff);
-               }
-       }
-
-       printf("]\n");
-       for (j=0; j<depth; ++j)
-               putchar('\t');
-       printf("method: ");
-       method_print(rp->method);
-
-       printf("\n");
-}
-#endif /* !defined(NDEBUG) */
-
-
-/* replace_show_replacement_points *********************************************
-   Print replacement point info.
-  
-   IN:
-       code.............codeinfo whose replacement points should be printed.
-  
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void replace_show_replacement_points(codeinfo *code)
-{
-       int i;
-       int depth;
-       rplpoint *rp;
-       rplpoint *parent;
-
-       if (!code) {
-               printf("(codeinfo *)NULL\n");
-               return;
-       }
-
-       printf("\treplacement points: %d\n",code->rplpointcount);
-
-       printf("\ttotal allocations : %d\n",code->regalloccount);
-       printf("\tsaved int regs    : %d\n",code->savedintcount);
-       printf("\tsaved flt regs    : %d\n",code->savedfltcount);
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-       printf("\tsaved adr regs    : %d\n",code->savedadrcount);
-#endif
-       printf("\tmemuse            : %d\n",code->memuse);
-
-       printf("\n");
-
-       for (i=0; i<code->rplpointcount; ++i) {
-               rp = code->rplpoints + i;
-
-               depth = 1;
-               parent = rp->parent;
-               while (parent) {
-                       depth++;
-                       parent = parent->parent;
-               }
-               replace_replacement_point_println(rp, depth);
-       }
-}
-#endif
-
-
-#if !defined(NDEBUG)
-static void java_value_print(s4 type, replace_val_t value)
-{
-       java_object_t *obj;
-       utf           *u;
-
-       printf("%016llx",(unsigned long long) value.l);
-
-       if (type < 0 || type > TYPE_RET)
-               printf(" <INVALID TYPE:%d>", type);
-       else
-               printf(" %s", show_jit_type_names[type]);
-
-       if (type == TYPE_ADR && value.a != NULL) {
-               obj = value.a;
-               putchar(' ');
-               utf_display_printable_ascii_classname(obj->vftbl->clazz->name);
-
-               if (obj->vftbl->clazz == class_java_lang_String) {
-                       printf(" \"");
-                       u = javastring_toutf(obj, false);
-                       utf_display_printable_ascii(u);
-                       printf("\"");
-               }
-       }
-       else if (type == TYPE_INT) {
-               printf(" %ld", (long) value.i);
-       }
-       else if (type == TYPE_LNG) {
-               printf(" %lld", (long long) value.l);
-       }
-       else if (type == TYPE_FLT) {
-               printf(" %f", value.f);
-       }
-       else if (type == TYPE_DBL) {
-               printf(" %f", value.d);
-       }
-}
-#endif /* !defined(NDEBUG) */
-
-
-#if !defined(NDEBUG)
-void replace_source_frame_println(sourceframe_t *frame)
-{
-       s4 i,j;
-       s4 t;
-
-       if (REPLACE_IS_NATIVE_FRAME(frame)) {
-               printf("\tNATIVE\n");
-               printf("\tsfi: "); replace_stackframeinfo_println(frame->sfi);
-               printf("\tnativepc: %p\n", frame->nativepc);
-               printf("\tframesize: %d\n", frame->nativeframesize);
-
-               j = 0;
-               for (i=0; i<INT_REG_CNT; ++i) {
-                       if (nregdescint[i] == REG_SAV)
-                               printf("\t%s = %p\n", abi_registers_integer_name[i], (void*)frame->nativesavint[j++]);
-               }
-
-               j = 0;
-               for (i=0; i<FLT_REG_CNT; ++i) {
-                       if (nregdescfloat[i] == REG_SAV)
-                               printf("\tF%02d = %f\n", i, frame->nativesavflt[j++]);
-               }
-
-               printf("\n");
-               return;
-       }
-
-       printf("\t");
-       method_println(frame->method);
-       printf("\tid: %d\n", frame->id);
-       printf("\ttype: %s\n", replace_type_str[frame->type]);
-       printf("\n");
-
-       if (frame->instance.a) {
-               printf("\tinstance: ");
-               java_value_print(TYPE_ADR, frame->instance);
-               printf("\n");
-       }
-
-       if (frame->javalocalcount) {
-               printf("\tlocals (%d):\n",frame->javalocalcount);
-               for (i=0; i<frame->javalocalcount; ++i) {
-                       t = frame->javalocaltype[i];
-                       if (t == TYPE_VOID) {
-                               printf("\tlocal[ %2d] = void\n",i);
-                       }
-                       else {
-                               printf("\tlocal[%c%2d] = ",TYPECHAR(t),i);
-                               java_value_print(t, frame->javalocals[i]);
-                               printf("\n");
-                       }
-               }
-               printf("\n");
-       }
-
-       if (frame->javastackdepth) {
-               printf("\tstack (depth %d):\n",frame->javastackdepth);
-               for (i=0; i<frame->javastackdepth; ++i) {
-                       t = frame->javastacktype[i];
-                       if (t == TYPE_VOID) {
-                               printf("\tstack[%2d] = void", i);
-                       }
-                       else {
-                               printf("\tstack[%2d] = ",i);
-                               java_value_print(frame->javastacktype[i], frame->javastack[i]);
-                               printf("\n");
-                       }
-               }
-               printf("\n");
-       }
-
-       if (frame->syncslotcount) {
-               printf("\tsynchronization slots (%d):\n",frame->syncslotcount);
-               for (i=0; i<frame->syncslotcount; ++i) {
-                       printf("\tslot[%2d] = ",i);
-#ifdef HAS_4BYTE_STACKSLOT
-                       printf("%08lx\n",(unsigned long) frame->syncslots[i].p);
-#else
-                       printf("%016llx\n",(unsigned long long) frame->syncslots[i].p);
-#endif
-               }
-               printf("\n");
-       }
-
-       if (frame->fromcode) {
-               printf("\tfrom %p ", (void*)frame->fromcode);
-               method_println(frame->fromcode->m);
-       }
-       if (frame->tocode) {
-               printf("\tto %p ", (void*)frame->tocode);
-               method_println(frame->tocode->m);
-       }
-
-       if (frame->fromrp) {
-               printf("\tfrom replacement point:\n");
-               replace_replacement_point_println(frame->fromrp, 2);
-       }
-       if (frame->torp) {
-               printf("\tto replacement point:\n");
-               replace_replacement_point_println(frame->torp, 2);
-       }
-
-       printf("\n");
-}
-#endif /* !defined(NDEBUG) */
-
-
-/* replace_sourcestate_println *************************************************
-   Print source state
-  
-   IN:
-       ss...............the source state to print
-  
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void replace_sourcestate_println(sourcestate_t *ss)
-{
-       int i;
-       sourceframe_t *frame;
-
-       if (!ss) {
-               printf("(sourcestate_t *)NULL\n");
-               return;
-       }
-
-       printf("sourcestate_t:\n");
-
-       for (i=0, frame = ss->frames; frame != NULL; frame = frame->down, ++i) {
-               printf("    frame %d:\n", i);
-               replace_source_frame_println(frame);
-       }
-}
-#endif
-
-
-/* replace_sourcestate_println_short *******************************************
-
-   Print a compact representation of the given source state.
-
-   IN:
-       ss...............the source state to print
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void replace_sourcestate_println_short(sourcestate_t *ss)
-{
-       sourceframe_t *frame;
-
-       for (frame = ss->frames; frame != NULL; frame = frame->down) {
-               printf("\t");
-
-               if (REPLACE_IS_NATIVE_FRAME(frame)) {
-                       printf("NATIVE (pc %p size %d) ",
-                                  (void*)frame->nativepc, frame->nativeframesize);
-                       replace_stackframeinfo_println(frame->sfi);
-                       continue;
-               }
-
-               if (frame->torp) {
-                       printf("%c", (frame->torp == frame->fromrp) ? '=' : '+');
-               }
-
-               printf("%s", replace_type_str[frame->fromrp->type]);
-
-               if (frame->torp && frame->torp->type != frame->fromrp->type)
-                       printf("->%s", replace_type_str[frame->torp->type]);
-
-               if (frame->tocode != frame->fromcode)
-                       printf(" (%p->%p/%d) ",
-                                  (void*) frame->fromcode, (void*) frame->tocode,
-                                  frame->fromrp->id);
-               else
-                       printf(" (%p/%d) ", (void*) frame->fromcode, frame->fromrp->id);
-
-               method_println(frame->method);
-       }
-}
-#endif
-
-#if !defined(NDEBUG)
-static void replace_stackframeinfo_println(stackframeinfo_t *sfi)
-{
-       printf("prev=%p pv=%p sp=%p ra=%p xpc=%p method=",
-                       (void*)sfi->prev, (void*)sfi->pv, (void*)sfi->sp,
-                       (void*)sfi->ra, (void*)sfi->xpc);
-
-       if (sfi->code)
-               method_println(sfi->code->m);
-       else
-               printf("(nil)\n");
-}
-#endif
-
-
-/*
- * 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/jit/replace.cpp b/src/vm/jit/replace.cpp
new file mode 100644 (file)
index 0000000..427f074
--- /dev/null
@@ -0,0 +1,3593 @@
+/* src/vm/jit/replace.cpp - on-stack replacement of methods
+
+   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 "vm/types.h"
+
+#include <assert.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "arch.h"
+#include "md.h"
+
+#if defined(ENABLE_GC_CACAO)
+# include "mm/cacao-gc/gc.h"
+#endif
+
+#include "mm/dumpmemory.hpp"
+#include "mm/memory.h"
+
+#include "threads/thread.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/classcache.hpp"
+#include "vm/globals.hpp"
+#include "vm/options.h"
+#include "vm/string.hpp"
+
+#if defined(ENABLE_RT_TIMING)
+# include "vm/rt-timing.h"
+#endif
+
+#include "vm/jit/abi.h"
+#include "vm/jit/asmpart.h"
+#include "vm/jit/disass.h"
+#include "vm/jit/executionstate.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/methodheader.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/show.hpp"
+#include "vm/jit/stack.h"
+
+
+#define REPLACE_PATCH_DYNAMIC_CALL
+/*#define REPLACE_PATCH_ALL*/
+
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
+/*** architecture-dependent configuration *************************************/
+
+/* first unset the macros (default) */
+#undef REPLACE_RA_BETWEEN_FRAMES
+#undef REPLACE_RA_TOP_OF_FRAME
+#undef REPLACE_RA_LINKAGE_AREA
+#undef REPLACE_LEAFMETHODS_RA_REGISTER
+
+/* i386, x86_64 and m68k */
+#if defined(__I386__) || defined(__X86_64__) || defined(__M68K__)
+#define REPLACE_RA_BETWEEN_FRAMES
+/* alpha */
+#elif defined(__ALPHA__)
+#define REPLACE_RA_TOP_OF_FRAME
+#define REPLACE_LEAFMETHODS_RA_REGISTER
+/* powerpc */
+#elif defined(__POWERPC__)
+#define REPLACE_RA_LINKAGE_AREA
+#define REPLACE_LEAFMETHODS_RA_REGISTER
+/* s390 */
+#elif defined(__S390__)
+#define REPLACE_RA_TOP_OF_FRAME
+#endif
+
+
+/*** configuration of native stack slot size **********************************/
+
+/* XXX this should be in md-abi.h files, probably */
+
+#define SIZE_OF_STACKSLOT      8
+#define STACK_SLOTS_PER_FLOAT  1
+typedef u8 stackslot_t;
+
+
+/*** debugging ****************************************************************/
+
+#if !defined(NDEBUG)
+static void java_value_print(s4 type, replace_val_t value);
+static void replace_stackframeinfo_println(stackframeinfo_t *sfi);
+#endif
+
+#if !defined(NDEBUG)
+#define DOLOG(code)        do{ if (opt_TraceReplacement > 1) { code; } } while(0)
+#define DOLOG_SHORT(code)  do{ if (opt_TraceReplacement > 0) { code; } } while(0)
+#else
+#define DOLOG(code)
+#define DOLOG_SHORT(code)
+#endif
+
+
+/*** statistics ***************************************************************/
+
+#define REPLACE_STATISTICS
+
+#if defined(REPLACE_STATISTICS)
+
+static int stat_replacements = 0;
+static int stat_frames = 0;
+static int stat_recompile = 0;
+static int stat_staticpatch = 0;
+static int stat_unroll_inline = 0;
+static int stat_unroll_call = 0;
+static int stat_dist_frames[20] = { 0 };
+static int stat_dist_locals[20] = { 0 };
+static int stat_dist_locals_adr[10] = { 0 };
+static int stat_dist_locals_prim[10] = { 0 };
+static int stat_dist_locals_ret[10] = { 0 };
+static int stat_dist_locals_void[10] = { 0 };
+static int stat_dist_stack[10] = { 0 };
+static int stat_dist_stack_adr[10] = { 0 };
+static int stat_dist_stack_prim[10] = { 0 };
+static int stat_dist_stack_ret[10] = { 0 };
+static int stat_methods = 0;
+static int stat_rploints = 0;
+static int stat_regallocs = 0;
+static int stat_dist_method_rplpoints[20] = { 0 };
+
+#define REPLACE_COUNT(cnt)  (cnt)++
+#define REPLACE_COUNT_IF(cnt, cond)  do{ if(cond) (cnt)++; } while(0)
+#define REPLACE_COUNT_INC(cnt, inc)  ((cnt) += (inc))
+
+#define REPLACE_COUNT_DIST(array, val)                               \
+    do {                                                             \
+        int limit = (sizeof(array) / sizeof(int)) - 1;               \
+        if ((val) < (limit)) (array)[val]++;                         \
+        else (array)[limit]++;                                       \
+    } while (0)
+
+static void replace_statistics_source_frame(sourceframe_t *frame);
+
+#else
+
+#define REPLACE_COUNT(cnt)
+#define REPLACE_COUNT_IF(cnt, cond)
+#define REPLACE_COUNT_INC(cnt, inc)
+#define REPLACE_COUNT_DIST(array, val)
+
+#endif /* defined(REPLACE_STATISTICS) */
+
+
+/*** constants used internally ************************************************/
+
+#define TOP_IS_NORMAL    0
+#define TOP_IS_ON_STACK  1
+#define TOP_IS_IN_ITMP1  2
+#define TOP_IS_VOID      3
+
+
+/******************************************************************************/
+/* PART I: Creating / freeing replacement points                              */
+/******************************************************************************/
+
+
+/* replace_create_replacement_point ********************************************
+   Create a replacement point.
+  
+   IN:
+       jd...............current jitdata
+          iinfo............inlining info for the current position
+          rp...............pre-allocated (uninitialized) rplpoint
+          type.............RPLPOINT_TYPE constant
+          iptr.............current instruction
+          *pra.............current rplalloc pointer
+          javalocals.......the javalocals at the current point
+          stackvars........the stack variables at the current point
+          stackdepth.......the stack depth at the current point
+          paramcount.......number of parameters at the start of stackvars
+  
+   OUT:
+       *rpa.............points to the next free rplalloc
+  
+*******************************************************************************/
+
+static void replace_create_replacement_point(jitdata *jd,
+                                                                                        insinfo_inline *iinfo,
+                                                                                        rplpoint *rp,
+                                                                                        s4 type,
+                                                                                        instruction *iptr,
+                                                                                        rplalloc **pra,
+                                                                                        s4 *javalocals,
+                                                                                        s4 *stackvars,
+                                                                                        s4 stackdepth,
+                                                                                        s4 paramcount)
+{
+       rplalloc *ra;
+       s4        i;
+       varinfo  *v;
+       s4        index;
+
+       ra = *pra;
+
+       REPLACE_COUNT(stat_rploints);
+
+       rp->method = (iinfo) ? iinfo->method : jd->m;
+       rp->pc = NULL;        /* set by codegen */
+       rp->callsize = 0;     /* set by codegen */
+       rp->regalloc = ra;
+       rp->flags = 0;
+       rp->type = type;
+       rp->id = iptr->flags.bits >> INS_FLAG_ID_SHIFT;
+
+       /* XXX unify these two fields */
+       rp->parent = (iinfo) ? iinfo->rp : NULL;
+
+       /* store local allocation info of javalocals */
+
+       if (javalocals) {
+               for (i = 0; i < rp->method->maxlocals; ++i) {
+                       index = javalocals[i];
+                       if (index == UNUSED)
+                               continue;
+
+                       ra->index = i;
+                       if (index >= 0) {
+                               v = VAR(index);
+                               ra->flags = v->flags & (INMEMORY);
+                               ra->regoff = v->vv.regoff;
+                               ra->type = v->type;
+                       }
+                       else {
+                               ra->regoff = RETADDR_FROM_JAVALOCAL(index);
+                               ra->type = TYPE_RET;
+                               ra->flags = 0;
+                       }
+                       ra++;
+               }
+       }
+
+       /* store allocation info of java stack vars */
+
+       for (i = 0; i < stackdepth; ++i) {
+               v = VAR(stackvars[i]);
+               ra->flags = v->flags & (INMEMORY);
+               ra->index = (i < paramcount) ? RPLALLOC_PARAM : RPLALLOC_STACK;
+               ra->type  = v->type;
+               /* XXX how to handle locals on the stack containing returnAddresses? */
+               if (v->type == TYPE_RET) {
+                       assert(stackvars[i] >= jd->localcount);
+                       ra->regoff = v->vv.retaddr->nr;
+               }
+               else
+                       ra->regoff = v->vv.regoff;
+               ra++;
+       }
+
+       /* total number of allocations */
+
+       rp->regalloccount = ra - rp->regalloc;
+
+       *pra = ra;
+}
+
+
+/* replace_create_inline_start_replacement_point *******************************
+
+   Create an INLINE_START replacement point.
+
+   IN:
+       jd...............current jitdata
+          rp...............pre-allocated (uninitialized) rplpoint
+          iptr.............current instruction
+          *pra.............current rplalloc pointer
+          javalocals.......the javalocals at the current point
+
+   OUT:
+       *rpa.............points to the next free rplalloc
+
+   RETURN VALUE:
+       the insinfo_inline * for the following inlined body
+
+*******************************************************************************/
+
+static insinfo_inline * replace_create_inline_start_replacement_point(
+                                                                                        jitdata *jd,
+                                                                                        rplpoint *rp,
+                                                                                        instruction *iptr,
+                                                                                        rplalloc **pra,
+                                                                                        s4 *javalocals)
+{
+       insinfo_inline *calleeinfo;
+       rplalloc       *ra;
+
+       calleeinfo = iptr->sx.s23.s3.inlineinfo;
+
+       calleeinfo->rp = rp;
+
+       replace_create_replacement_point(jd, calleeinfo->parent, rp,
+                       RPLPOINT_TYPE_INLINE, iptr, pra,
+                       javalocals,
+                       calleeinfo->stackvars, calleeinfo->stackvarscount,
+                       calleeinfo->paramcount);
+
+       if (calleeinfo->synclocal != UNUSED) {
+               ra = (*pra)++;
+               ra->index  = RPLALLOC_SYNC;
+               ra->regoff = jd->var[calleeinfo->synclocal].vv.regoff;
+               ra->flags  = jd->var[calleeinfo->synclocal].flags & INMEMORY;
+               ra->type   = TYPE_ADR;
+
+               rp->regalloccount++;
+       }
+
+       return calleeinfo;
+}
+
+
+/* replace_create_replacement_points *******************************************
+   Create the replacement points for the given code.
+  
+   IN:
+       jd...............current jitdata, must not have any replacement points
+  
+   OUT:
+       code->rplpoints.......set to the list of replacement points
+          code->rplpointcount...number of replacement points
+          code->regalloc........list of allocation info
+          code->regalloccount...total length of allocation info list
+          code->globalcount.....number of global allocations at the
+                                start of code->regalloc
+  
+   RETURN VALUE:
+       true.............everything ok 
+       false............an exception has been thrown
+   
+*******************************************************************************/
+
+#define CLEAR_javalocals(array, method)                              \
+    do {                                                             \
+        for (i=0; i<(method)->maxlocals; ++i)                        \
+            (array)[i] = UNUSED;                                     \
+    } while (0)
+
+#define COPY_OR_CLEAR_javalocals(dest, array, method)                \
+    do {                                                             \
+        if ((array) != NULL)                                         \
+            MCOPY((dest), (array), s4, (method)->maxlocals);         \
+        else                                                         \
+            CLEAR_javalocals((dest), (method));                      \
+    } while (0)
+
+#define COUNT_javalocals(array, method, counter)                     \
+    do {                                                             \
+        for (i=0; i<(method)->maxlocals; ++i)                        \
+            if ((array)[i] != UNUSED)                                \
+                               (counter)++;                                         \
+    } while (0)
+
+bool replace_create_replacement_points(jitdata *jd)
+{
+       codeinfo        *code;
+       registerdata    *rd;
+       basicblock      *bptr;
+       int              count;
+       methodinfo      *m;
+       rplpoint        *rplpoints;
+       rplpoint        *rp;
+       int              alloccount;
+       rplalloc        *regalloc;
+       rplalloc        *ra;
+       int              i;
+       instruction     *iptr;
+       instruction     *iend;
+       s4              *javalocals;
+       s4              *jl;
+       methoddesc      *md;
+       insinfo_inline  *iinfo;
+       s4               startcount;
+       s4               firstcount;
+#if defined(REPLACE_PATCH_DYNAMIC_CALL)
+       bool             needentry;
+#endif
+
+       REPLACE_COUNT(stat_methods);
+
+       /* get required compiler data */
+
+       code = jd->code;
+       rd   = jd->rd;
+
+       /* assert that we wont overwrite already allocated data */
+
+       assert(code);
+       assert(code->m);
+       assert(code->rplpoints == NULL);
+       assert(code->rplpointcount == 0);
+       assert(code->regalloc == NULL);
+       assert(code->regalloccount == 0);
+       assert(code->globalcount == 0);
+
+       m = code->m;
+
+       /* in instance methods, we may need a rplpoint at the method entry */
+
+#if defined(REPLACE_PATCH_DYNAMIC_CALL)
+       if (!(m->flags & ACC_STATIC)) {
+               jd->basicblocks[0].bitflags |= BBFLAG_REPLACEMENT;
+               needentry = true;
+       }
+       else {
+               needentry = false;
+       }
+#endif /* defined(REPLACE_PATCH_DYNAMIC_CALL) */
+
+       /* iterate over the basic block list to find replacement points */
+
+       count = 0;
+       alloccount = 0;
+
+       javalocals = (s4*) DumpMemory::allocate(sizeof(s4) * jd->maxlocals);
+
+       for (bptr = jd->basicblocks; bptr; bptr = bptr->next) {
+
+               /* skip dead code */
+
+               if (bptr->flags < BBFINISHED)
+                       continue;
+
+               /* get info about this block */
+
+               m = bptr->method;
+               iinfo = bptr->inlineinfo;
+
+               /* initialize javalocals at the start of this block */
+
+               COPY_OR_CLEAR_javalocals(javalocals, bptr->javalocals, m);
+
+               /* iterate over the instructions */
+
+               iptr = bptr->iinstr;
+               iend = iptr + bptr->icount;
+               startcount = count;
+               firstcount = count;
+
+               for (; iptr != iend; ++iptr) {
+                       switch (iptr->opc) {
+#if defined(ENABLE_GC_CACAO)
+                               case ICMD_BUILTIN:
+                                       md = iptr->sx.s23.s3.bte->md;
+                                       count++;
+                                       COUNT_javalocals(javalocals, m, alloccount);
+                                       alloccount += iptr->s1.argcount;
+                                       if (iinfo)
+                                               alloccount -= iinfo->throughcount;
+                                       break;
+#endif
+
+                               case ICMD_INVOKESTATIC:
+                               case ICMD_INVOKESPECIAL:
+                               case ICMD_INVOKEVIRTUAL:
+                               case ICMD_INVOKEINTERFACE:
+                                       INSTRUCTION_GET_METHODDESC(iptr, md);
+                                       count++;
+                                       COUNT_javalocals(javalocals, m, alloccount);
+                                       alloccount += iptr->s1.argcount;
+                                       if (iinfo)
+                                               alloccount -= iinfo->throughcount;
+                                       break;
+
+                               case ICMD_ISTORE:
+                               case ICMD_LSTORE:
+                               case ICMD_FSTORE:
+                               case ICMD_DSTORE:
+                               case ICMD_ASTORE:
+                                       stack_javalocals_store(iptr, javalocals);
+                                       break;
+
+                               case ICMD_IRETURN:
+                               case ICMD_LRETURN:
+                               case ICMD_FRETURN:
+                               case ICMD_DRETURN:
+                               case ICMD_ARETURN:
+                                       alloccount += 1;
+                                       /* FALLTHROUGH! */
+                               case ICMD_RETURN:
+                                       count++;
+                                       break;
+
+                               case ICMD_INLINE_START:
+                                       iinfo = iptr->sx.s23.s3.inlineinfo;
+
+                                       count++;
+                                       COUNT_javalocals(javalocals, m, alloccount);
+                                       alloccount += iinfo->stackvarscount;
+                                       if (iinfo->synclocal != UNUSED)
+                                               alloccount++;
+
+                                       m = iinfo->method;
+                                       /* javalocals may be set at next block start, or now */
+                                       COPY_OR_CLEAR_javalocals(javalocals, iinfo->javalocals_start, m);
+                                       break;
+
+                               case ICMD_INLINE_BODY:
+                                       assert(iinfo == iptr->sx.s23.s3.inlineinfo);
+
+                                       jl = iinfo->javalocals_start;
+                                       if (jl == NULL) {
+                                               /* get the javalocals from the following block start */
+                                               assert(bptr->next);
+                                               jl = bptr->next->javalocals;
+                                       }
+                                       count++;
+                                       COUNT_javalocals(jl, m, alloccount);
+                                       break;
+
+                               case ICMD_INLINE_END:
+                                       assert(iinfo == iptr->sx.s23.s3.inlineinfo ||
+                                                  iinfo == iptr->sx.s23.s3.inlineinfo->parent);
+                                       iinfo = iptr->sx.s23.s3.inlineinfo;
+                                       m = iinfo->outer;
+                                       if (iinfo->javalocals_end)
+                                               MCOPY(javalocals, iinfo->javalocals_end, s4, m->maxlocals);
+                                       iinfo = iinfo->parent;
+                                       break;
+                       }
+
+                       if (iptr == bptr->iinstr)
+                               firstcount = count;
+               } /* end instruction loop */
+
+               /* create replacement points at targets of backward branches */
+               /* We only need the replacement point there, if there is no  */
+               /* replacement point inside the block.                       */
+
+               if (bptr->bitflags & BBFLAG_REPLACEMENT) {
+#if defined(REPLACE_PATCH_DYNAMIC_CALL)
+                       int test = (needentry && bptr == jd->basicblocks) ? firstcount : count;
+#else
+                       int test = count;
+#endif
+                       if (test > startcount) {
+                               /* we don't need an extra rplpoint */
+                               bptr->bitflags &= ~BBFLAG_REPLACEMENT;
+                       }
+                       else {
+                               count++;
+                               alloccount += bptr->indepth;
+                               if (bptr->inlineinfo)
+                                       alloccount -= bptr->inlineinfo->throughcount;
+
+                               COUNT_javalocals(bptr->javalocals, bptr->method, alloccount);
+                       }
+               }
+
+       } /* end basicblock loop */
+
+       /* if no points were found, there's nothing to do */
+
+       if (!count)
+               return true;
+
+       /* allocate replacement point array and allocation array */
+
+       rplpoints = MNEW(rplpoint, count);
+       regalloc = MNEW(rplalloc, alloccount);
+       ra = regalloc;
+
+       /* initialize replacement point structs */
+
+       rp = rplpoints;
+
+       /* XXX try to share code with the counting loop! */
+
+       for (bptr = jd->basicblocks; bptr; bptr = bptr->next) {
+               /* skip dead code */
+
+               if (bptr->flags < BBFINISHED)
+                       continue;
+
+               /* get info about this block */
+
+               m = bptr->method;
+               iinfo = bptr->inlineinfo;
+
+               /* initialize javalocals at the start of this block */
+
+               COPY_OR_CLEAR_javalocals(javalocals, bptr->javalocals, m);
+
+               /* create replacement points at targets of backward branches */
+
+               if (bptr->bitflags & BBFLAG_REPLACEMENT) {
+
+                       i = (iinfo) ? iinfo->throughcount : 0;
+                       replace_create_replacement_point(jd, iinfo, rp++,
+                                       bptr->type, bptr->iinstr, &ra,
+                                       bptr->javalocals, bptr->invars + i, bptr->indepth - i, 0);
+
+                       if (JITDATA_HAS_FLAG_COUNTDOWN(jd))
+                               rp[-1].flags |= RPLPOINT_FLAG_COUNTDOWN;
+               }
+
+               /* iterate over the instructions */
+
+               iptr = bptr->iinstr;
+               iend = iptr + bptr->icount;
+
+               for (; iptr != iend; ++iptr) {
+                       switch (iptr->opc) {
+#if defined(ENABLE_GC_CACAO)
+                               case ICMD_BUILTIN:
+                                       md = iptr->sx.s23.s3.bte->md;
+
+                                       i = (iinfo) ? iinfo->throughcount : 0;
+                                       replace_create_replacement_point(jd, iinfo, rp++,
+                                                       RPLPOINT_TYPE_CALL, iptr, &ra,
+                                                       javalocals, iptr->sx.s23.s2.args,
+                                                       iptr->s1.argcount - i,
+                                                       md->paramcount);
+                                       break;
+#endif
+
+                               case ICMD_INVOKESTATIC:
+                               case ICMD_INVOKESPECIAL:
+                               case ICMD_INVOKEVIRTUAL:
+                               case ICMD_INVOKEINTERFACE:
+                                       INSTRUCTION_GET_METHODDESC(iptr, md);
+
+                                       i = (iinfo) ? iinfo->throughcount : 0;
+                                       replace_create_replacement_point(jd, iinfo, rp++,
+                                                       RPLPOINT_TYPE_CALL, iptr, &ra,
+                                                       javalocals, iptr->sx.s23.s2.args,
+                                                       iptr->s1.argcount - i,
+                                                       md->paramcount);
+                                       break;
+
+                               case ICMD_ISTORE:
+                               case ICMD_LSTORE:
+                               case ICMD_FSTORE:
+                               case ICMD_DSTORE:
+                               case ICMD_ASTORE:
+                                       stack_javalocals_store(iptr, javalocals);
+                                       break;
+
+                               case ICMD_IRETURN:
+                               case ICMD_LRETURN:
+                               case ICMD_FRETURN:
+                               case ICMD_DRETURN:
+                               case ICMD_ARETURN:
+                                       replace_create_replacement_point(jd, iinfo, rp++,
+                                                       RPLPOINT_TYPE_RETURN, iptr, &ra,
+                                                       NULL, &(iptr->s1.varindex), 1, 0);
+                                       break;
+
+                               case ICMD_RETURN:
+                                       replace_create_replacement_point(jd, iinfo, rp++,
+                                                       RPLPOINT_TYPE_RETURN, iptr, &ra,
+                                                       NULL, NULL, 0, 0);
+                                       break;
+
+                               case ICMD_INLINE_START:
+                                       iinfo = replace_create_inline_start_replacement_point(
+                                                               jd, rp++, iptr, &ra, javalocals);
+                                       m = iinfo->method;
+                                       /* javalocals may be set at next block start, or now */
+                                       COPY_OR_CLEAR_javalocals(javalocals, iinfo->javalocals_start, m);
+                                       break;
+
+                               case ICMD_INLINE_BODY:
+                                       assert(iinfo == iptr->sx.s23.s3.inlineinfo);
+
+                                       jl = iinfo->javalocals_start;
+                                       if (jl == NULL) {
+                                               /* get the javalocals from the following block start */
+                                               assert(bptr->next);
+                                               jl = bptr->next->javalocals;
+                                       }
+                                       /* create a non-trappable rplpoint */
+                                       replace_create_replacement_point(jd, iinfo, rp++,
+                                                       RPLPOINT_TYPE_BODY, iptr, &ra,
+                                                       jl, NULL, 0, 0);
+                                       rp[-1].flags |= RPLPOINT_FLAG_NOTRAP;
+                                       break;
+
+                               case ICMD_INLINE_END:
+                                       assert(iinfo == iptr->sx.s23.s3.inlineinfo ||
+                                                  iinfo == iptr->sx.s23.s3.inlineinfo->parent);
+                                       iinfo = iptr->sx.s23.s3.inlineinfo;
+                                       m = iinfo->outer;
+                                       if (iinfo->javalocals_end)
+                                               MCOPY(javalocals, iinfo->javalocals_end, s4, m->maxlocals);
+                                       iinfo = iinfo->parent;
+                                       break;
+                       }
+               } /* end instruction loop */
+       } /* end basicblock loop */
+
+       assert((rp - rplpoints) == count);
+       assert((ra - regalloc) == alloccount);
+
+       /* store the data in the codeinfo */
+
+       code->rplpoints     = rplpoints;
+       code->rplpointcount = count;
+       code->regalloc      = regalloc;
+       code->regalloccount = alloccount;
+       code->globalcount   = 0;
+       code->savedintcount = INT_SAV_CNT - rd->savintreguse;
+       code->savedfltcount = FLT_SAV_CNT - rd->savfltreguse;
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+       code->savedadrcount = ADR_SAV_CNT - rd->savadrreguse;
+#endif
+       code->memuse        = rd->memuse;
+       code->stackframesize = jd->cd->stackframesize;
+
+       REPLACE_COUNT_DIST(stat_dist_method_rplpoints, count);
+       REPLACE_COUNT_INC(stat_regallocs, alloccount);
+
+       /* everything alright */
+
+       return true;
+}
+
+
+/* replace_free_replacement_points *********************************************
+   Free memory used by replacement points.
+  
+   IN:
+       code.............codeinfo whose replacement points should be freed.
+  
+*******************************************************************************/
+
+void replace_free_replacement_points(codeinfo *code)
+{
+       assert(code);
+
+       if (code->rplpoints)
+               MFREE(code->rplpoints,rplpoint,code->rplpointcount);
+
+       if (code->regalloc)
+               MFREE(code->regalloc,rplalloc,code->regalloccount);
+
+       code->rplpoints = NULL;
+       code->rplpointcount = 0;
+       code->regalloc = NULL;
+       code->regalloccount = 0;
+       code->globalcount = 0;
+}
+
+
+/******************************************************************************/
+/* PART II: Activating / deactivating replacement points                      */
+/******************************************************************************/
+
+
+/* replace_activate_replacement_points *****************************************
+   Activate the replacement points of the given compilation unit. When this
+   function returns, the replacement points are "armed", so each thread
+   reaching one of the points will enter the replacement mechanism.
+   
+   IN:
+       code.............codeinfo of which replacement points should be
+                                               activated
+          mappable.........if true, only mappable replacement points are
+                                               activated
+  
+*******************************************************************************/
+
+void replace_activate_replacement_points(codeinfo *code, bool mappable)
+{
+       rplpoint *rp;
+       s4        i;
+       s4        count;
+       u1       *savedmcode;
+
+       assert(code->savedmcode == NULL);
+
+       /* count trappable replacement points */
+
+       count = 0;
+       i = code->rplpointcount;
+       rp = code->rplpoints;
+       for (; i--; rp++) {
+               if (rp->flags & RPLPOINT_FLAG_NOTRAP)
+                       continue;
+
+               if (mappable && (rp->type == RPLPOINT_TYPE_RETURN))
+                       continue;
+
+               count++;
+       }
+
+       /* allocate buffer for saved machine code */
+
+       savedmcode = MNEW(u1, count * REPLACEMENT_PATCH_SIZE);
+       code->savedmcode = savedmcode;
+       savedmcode += count * REPLACEMENT_PATCH_SIZE;
+
+       /* activate trappable replacement points */
+       /* (in reverse order to handle overlapping points within basic blocks) */
+
+       i = code->rplpointcount;
+       rp = code->rplpoints + i;
+       while (rp--, i--) {
+               assert(!(rp->flags & RPLPOINT_FLAG_ACTIVE));
+
+               if (rp->flags & RPLPOINT_FLAG_NOTRAP)
+                       continue;
+
+               if (mappable && (rp->type == RPLPOINT_TYPE_RETURN))
+                       continue;
+
+               DOLOG( printf("activate replacement point:\n");
+                          replace_replacement_point_println(rp, 1); fflush(stdout); );
+
+               savedmcode -= REPLACEMENT_PATCH_SIZE;
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_DISASSEMBLER)
+               DOLOG( printf("\tinstruction before: ");
+                          disassinstr(rp->pc); fflush(stdout); );
+# endif
+
+               md_patch_replacement_point(rp->pc, savedmcode, false);
+
+# if defined(ENABLE_DISASSEMBLER)
+               DOLOG( printf("\tinstruction after : ");
+                          disassinstr(rp->pc); fflush(stdout); );
+# endif
+#endif
+
+               rp->flags |= RPLPOINT_FLAG_ACTIVE;
+       }
+
+       assert(savedmcode == code->savedmcode);
+}
+
+
+/* replace_deactivate_replacement_points ***************************************
+   Deactivate a replacement points in the given compilation unit.
+   When this function returns, the replacement points will be "un-armed",
+   that is a each thread reaching a point will just continue normally.
+   
+   IN:
+       code.............the compilation unit
+  
+*******************************************************************************/
+
+void replace_deactivate_replacement_points(codeinfo *code)
+{
+       rplpoint *rp;
+       s4        i;
+       s4        count;
+       u1       *savedmcode;
+
+       if (code->savedmcode == NULL) {
+               /* disarm countdown points by patching the branches */
+
+               i = code->rplpointcount;
+               rp = code->rplpoints;
+               for (; i--; rp++) {
+                       if ((rp->flags & (RPLPOINT_FLAG_ACTIVE | RPLPOINT_FLAG_COUNTDOWN))
+                                       == RPLPOINT_FLAG_COUNTDOWN)
+                       {
+#if 0
+                               *(s4*) (rp->pc + 9) = 0; /* XXX machine dependent! */
+#endif
+                       }
+               }
+               return;
+       }
+
+       assert(code->savedmcode != NULL);
+       savedmcode = code->savedmcode;
+
+       /* de-activate each trappable replacement point */
+
+       i = code->rplpointcount;
+       rp = code->rplpoints;
+       count = 0;
+       for (; i--; rp++) {
+               if (!(rp->flags & RPLPOINT_FLAG_ACTIVE))
+                       continue;
+
+               count++;
+
+               DOLOG( printf("deactivate replacement point:\n");
+                          replace_replacement_point_println(rp, 1); fflush(stdout); );
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_DISASSEMBLER)
+               DOLOG( printf("\tinstruction before: ");
+                          disassinstr(rp->pc); fflush(stdout); );
+# endif
+
+               md_patch_replacement_point(rp->pc, savedmcode, true);
+
+# if defined(ENABLE_DISASSEMBLER)
+               DOLOG( printf("\tinstruction before: ");
+                          disassinstr(rp->pc); fflush(stdout); );
+# endif
+#endif
+
+               rp->flags &= ~RPLPOINT_FLAG_ACTIVE;
+
+               savedmcode += REPLACEMENT_PATCH_SIZE;
+       }
+
+       assert(savedmcode == code->savedmcode + count * REPLACEMENT_PATCH_SIZE);
+
+       /* free saved machine code */
+
+       MFREE(code->savedmcode, u1, count * REPLACEMENT_PATCH_SIZE);
+       code->savedmcode = NULL;
+}
+
+
+/******************************************************************************/
+/* PART III: The replacement mechanism                                        */
+/******************************************************************************/
+
+
+/* replace_read_value **********************************************************
+
+   Read a value with the given allocation from the execution state.
+   
+   IN:
+          es...............execution state
+          ra...............allocation
+          javaval..........where to put the value
+
+   OUT:
+       *javaval.........the value
+  
+*******************************************************************************/
+
+static void replace_read_value(executionstate_t *es,
+                                                          rplalloc *ra,
+                                                          replace_val_t *javaval)
+{
+       if (ra->flags & INMEMORY) {
+               /* XXX HAS_4BYTE_STACKSLOT may not be the right discriminant here */
+#ifdef HAS_4BYTE_STACKSLOT
+               if (IS_2_WORD_TYPE(ra->type)) {
+                       javaval->l = *(u8*)(es->sp + ra->regoff);
+               }
+               else {
+#endif
+                       javaval->p = *(ptrint*)(es->sp + ra->regoff);
+#ifdef HAS_4BYTE_STACKSLOT
+               }
+#endif
+       }
+       else {
+               /* allocated register */
+               if (IS_FLT_DBL_TYPE(ra->type)) {
+                       javaval->d = es->fltregs[ra->regoff];
+
+                       if (ra->type == TYPE_FLT)
+                               javaval->f = javaval->d;
+               }
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+               else if (IS_ADR_TYPE(ra->type)) {
+                       javaval->p = es->adrregs[ra->regoff];
+               }
+#endif
+               else {
+#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+                       if (ra->type == TYPE_LNG) {
+                               javaval->words.lo = es->intregs[GET_LOW_REG(ra->regoff)];
+                               javaval->words.hi = es->intregs[GET_HIGH_REG(ra->regoff)];
+                       }
+                       else
+#endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */
+                               javaval->p = es->intregs[ra->regoff];
+               }
+       }
+}
+
+
+/* replace_write_value *********************************************************
+
+   Write a value to the given allocation in the execution state.
+   
+   IN:
+          es...............execution state
+          ra...............allocation
+          *javaval.........the value
+
+*******************************************************************************/
+
+static void replace_write_value(executionstate_t *es,
+                                                           rplalloc *ra,
+                                                           replace_val_t *javaval)
+{
+       if (ra->flags & INMEMORY) {
+               /* XXX HAS_4BYTE_STACKSLOT may not be the right discriminant here */
+#ifdef HAS_4BYTE_STACKSLOT
+               if (IS_2_WORD_TYPE(ra->type)) {
+                       *(u8*)(es->sp + ra->regoff) = javaval->l;
+               }
+               else {
+#endif
+                       *(ptrint*)(es->sp + ra->regoff) = javaval->p;
+#ifdef HAS_4BYTE_STACKSLOT
+               }
+#endif
+       }
+       else {
+               /* allocated register */
+               switch (ra->type) {
+                       case TYPE_FLT:
+                               es->fltregs[ra->regoff] = (double) javaval->f;
+                               break;
+                       case TYPE_DBL:
+                               es->fltregs[ra->regoff] = javaval->d;
+                               break;
+#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+                       case TYPE_LNG:
+                               es->intregs[GET_LOW_REG(ra->regoff)] = javaval->words.lo;
+                               es->intregs[GET_HIGH_REG(ra->regoff)] = javaval->words.hi;
+                               break;
+#endif
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+                       case TYPE_ADR:
+                               es->adrregs[ra->regoff] = javaval->p;
+#endif
+                       default:
+                               es->intregs[ra->regoff] = javaval->p;
+               }
+       }
+}
+
+
+/* replace_new_sourceframe *****************************************************
+
+   Allocate a new source frame and insert it at the front of the frame list.
+   
+   IN:
+          ss...............the source state
+
+   OUT:
+          ss->frames.......set to new frame (the new head of the frame list).
+
+   RETURN VALUE:
+       returns the new frame
+
+*******************************************************************************/
+
+static sourceframe_t *replace_new_sourceframe(sourcestate_t *ss)
+{
+       sourceframe_t *frame;
+
+       frame = (sourceframe_t*) DumpMemory::allocate(sizeof(sourceframe_t));
+       MZERO(frame, sourceframe_t, 1);
+
+       frame->down = ss->frames;
+       ss->frames = frame;
+
+       return frame;
+}
+
+
+/* replace_read_executionstate *************************************************
+
+   Read a source frame from the given executions state.
+   The new source frame is pushed to the front of the frame list of the
+   source state.
+
+   IN:
+       rp...............replacement point at which `es` was taken
+          es...............execution state
+          ss...............the source state to add the source frame to
+          topframe.........true, if the first (top-most) source frame on the
+                           stack is to be read
+
+   OUT:
+       *ss..............the source state with the newly created source frame
+                           added
+  
+*******************************************************************************/
+
+static s4 replace_normalize_type_map[] = {
+/* RPLPOINT_TYPE_STD    |--> */ RPLPOINT_TYPE_STD,
+/* RPLPOINT_TYPE_EXH    |--> */ RPLPOINT_TYPE_STD,
+/* RPLPOINT_TYPE_SBR    |--> */ RPLPOINT_TYPE_STD,
+/* RPLPOINT_TYPE_CALL   |--> */ RPLPOINT_TYPE_CALL,
+/* RPLPOINT_TYPE_INLINE |--> */ RPLPOINT_TYPE_CALL,
+/* RPLPOINT_TYPE_RETURN |--> */ RPLPOINT_TYPE_RETURN,
+/* RPLPOINT_TYPE_BODY   |--> */ RPLPOINT_TYPE_STD
+};
+
+
+static void replace_read_executionstate(rplpoint *rp,
+                                                                               executionstate_t *es,
+                                                                               sourcestate_t *ss,
+                                                                               bool topframe)
+{
+       methodinfo    *m;
+       codeinfo      *code;
+       int            count;
+       int            i;
+       rplalloc      *ra;
+       sourceframe_t *frame;
+       int            topslot;
+       stackslot_t   *sp;
+       stackslot_t   *basesp;
+
+       code = code_find_codeinfo_for_pc(rp->pc);
+       m = rp->method;
+       topslot = TOP_IS_NORMAL;
+
+       /* stack pointer */
+
+       sp = (stackslot_t *) es->sp;
+
+       /* in some cases the top stack slot is passed in REG_ITMP1 */
+
+       if (rp->type == BBTYPE_EXH) {
+               topslot = TOP_IS_IN_ITMP1;
+       }
+
+       /* calculate base stack pointer */
+
+       basesp = sp + code->stackframesize;
+
+       /* create the source frame */
+
+       frame = replace_new_sourceframe(ss);
+       frame->method = rp->method;
+       frame->id = rp->id;
+       assert(rp->type >= 0 && rp->type < sizeof(replace_normalize_type_map)/sizeof(s4));
+       frame->type = replace_normalize_type_map[rp->type];
+       frame->fromrp = rp;
+       frame->fromcode = code;
+
+       /* read local variables */
+
+       count = m->maxlocals;
+       frame->javalocalcount = count;
+       frame->javalocals = (replace_val_t*) DumpMemory::allocate(sizeof(replace_val_t) * count);
+       frame->javalocaltype = (u1*) DumpMemory::allocate(sizeof(u1) * count);
+
+       /* mark values as undefined */
+       for (i=0; i<count; ++i) {
+#if !defined(NDEBUG)
+               frame->javalocals[i].l = (u8) 0x00dead0000dead00ULL;
+#endif
+               frame->javalocaltype[i] = TYPE_VOID;
+       }
+
+       /* some entries in the intregs array are not meaningful */
+       /*es->intregs[REG_ITMP3] = (u8) 0x11dead1111dead11ULL;*/
+#if !defined(NDEBUG)
+       es->intregs[REG_SP   ] = (ptrint) 0x11dead1111dead11ULL;
+#ifdef REG_PV
+       es->intregs[REG_PV   ] = (ptrint) 0x11dead1111dead11ULL;
+#endif
+#endif /* !defined(NDEBUG) */
+
+       /* read javalocals */
+
+       count = rp->regalloccount;
+       ra = rp->regalloc;
+
+       while (count && (i = ra->index) >= 0) {
+               assert(i < m->maxlocals);
+               frame->javalocaltype[i] = ra->type;
+               if (ra->type == TYPE_RET)
+                       frame->javalocals[i].i = ra->regoff;
+               else
+                       replace_read_value(es, ra, frame->javalocals + i);
+               ra++;
+               count--;
+       }
+
+       /* read instance, if this is the first rplpoint */
+
+#if defined(REPLACE_PATCH_DYNAMIC_CALL)
+       if (topframe && !(rp->method->flags & ACC_STATIC) && rp == code->rplpoints) {
+#if 1
+               /* we are at the start of the method body, so if local 0 is set, */
+               /* it is the instance.                                           */
+               if (frame->javalocaltype[0] == TYPE_ADR)
+                       frame->instance = frame->javalocals[0];
+#else
+               rplalloc instra;
+               methoddesc *md;
+
+               md = rp->method->parseddesc;
+               assert(md->params);
+               assert(md->paramcount >= 1);
+               instra.type = TYPE_ADR;
+               instra.regoff = md->params[0].regoff;
+               if (md->params[0].inmemory) {
+                       instra.flags = INMEMORY;
+                       instra.regoff += (1 + code->stackframesize) * SIZE_OF_STACKSLOT;
+               }
+               else {
+                       instra.flags = 0;
+               }
+               replace_read_value(es, &instra, &(frame->instance));
+#endif
+       }
+#if defined(__I386__)
+       else if (!(rp->method->flags & ACC_STATIC)) {
+               /* On i386 we always pass the first argument on stack. */
+               frame->instance.a = *(java_object_t **)(basesp + 1);
+       } 
+#endif
+#endif /* defined(REPLACE_PATCH_DYNAMIC_CALL) */
+
+       /* read stack slots */
+
+       frame->javastackdepth = count;
+       frame->javastack = (replace_val_t*) DumpMemory::allocate(sizeof(replace_val_t) * count);
+       frame->javastacktype = (u1*) DumpMemory::allocate(sizeof(u1) * count);
+
+#if !defined(NDEBUG)
+       /* mark values as undefined */
+       for (i=0; i<count; ++i) {
+               frame->javastack[i].l = (u8) 0x00dead0000dead00ULL;
+               frame->javastacktype[i] = TYPE_VOID;
+       }
+#endif /* !defined(NDEBUG) */
+
+       i = 0;
+
+       /* the first stack slot is special in SBR and EXH blocks */
+
+       if (topslot == TOP_IS_ON_STACK) {
+               assert(count);
+
+               assert(ra->index == RPLALLOC_STACK);
+               assert(ra->type == TYPE_ADR);
+               frame->javastack[i].p = sp[-1];
+               frame->javastacktype[i] = TYPE_ADR; /* XXX RET */
+               count--;
+               i++;
+               ra++;
+       }
+       else if (topslot == TOP_IS_IN_ITMP1) {
+               assert(count);
+
+               assert(ra->index == RPLALLOC_STACK);
+               assert(ra->type == TYPE_ADR);
+               frame->javastack[i].p = es->intregs[REG_ITMP1];
+               frame->javastacktype[i] = TYPE_ADR; /* XXX RET */
+               count--;
+               i++;
+               ra++;
+       }
+       else if (topslot == TOP_IS_VOID) {
+               assert(count);
+
+               assert(ra->index == RPLALLOC_STACK);
+               frame->javastack[i].l = 0;
+               frame->javastacktype[i] = TYPE_VOID;
+               count--;
+               i++;
+               ra++;
+       }
+
+       /* read remaining stack slots */
+
+       for (; count--; ra++) {
+               if (ra->index == RPLALLOC_SYNC) {
+                       assert(rp->type == RPLPOINT_TYPE_INLINE);
+
+                       /* only read synchronization slots when traversing an inline point */
+
+                       if (!topframe) {
+                               sourceframe_t *calleeframe = frame->down;
+                               assert(calleeframe);
+                               assert(calleeframe->syncslotcount == 0);
+                               assert(calleeframe->syncslots == NULL);
+
+                               calleeframe->syncslotcount = 1;
+                               calleeframe->syncslots = (replace_val_t*) DumpMemory::allocate(sizeof(replace_val_t));
+                               replace_read_value(es,ra,calleeframe->syncslots);
+                       }
+
+                       frame->javastackdepth--;
+                       continue;
+               }
+
+               assert(ra->index == RPLALLOC_STACK || ra->index == RPLALLOC_PARAM);
+
+               /* do not read parameters of calls down the call chain */
+
+               if (!topframe && ra->index == RPLALLOC_PARAM) {
+                       frame->javastackdepth--;
+               }
+               else {
+                       if (ra->type == TYPE_RET)
+                               frame->javastack[i].i = ra->regoff;
+                       else
+                               replace_read_value(es,ra,frame->javastack + i);
+                       frame->javastacktype[i] = ra->type;
+                       i++;
+               }
+       }
+}
+
+
+/* replace_write_executionstate ************************************************
+
+   Pop a source frame from the front of the frame list of the given source state
+   and write its values into the execution state.
+
+   IN:
+       rp...............replacement point for which execution state should be
+                           created
+          es...............the execution state to modify
+          ss...............the given source state
+          topframe.........true, if this is the last (top-most) source frame to be
+                           translated
+
+   OUT:
+       *es..............the execution state derived from the source state
+  
+*******************************************************************************/
+
+static void replace_write_executionstate(rplpoint *rp,
+                                                                                executionstate_t *es,
+                                                                                sourcestate_t *ss,
+                                                                                bool topframe)
+{
+       methodinfo     *m;
+       codeinfo       *code;
+       int             count;
+       int             i;
+       rplalloc       *ra;
+       sourceframe_t  *frame;
+       int             topslot;
+       stackslot_t    *sp;
+       stackslot_t    *basesp;
+
+       code = code_find_codeinfo_for_pc(rp->pc);
+       m = rp->method;
+       topslot = TOP_IS_NORMAL;
+
+       /* pop a source frame */
+
+       frame = ss->frames;
+       assert(frame);
+       ss->frames = frame->down;
+
+       /* calculate stack pointer */
+
+       sp = (stackslot_t *) es->sp;
+
+       basesp = sp + code->stackframesize;
+
+       /* in some cases the top stack slot is passed in REG_ITMP1 */
+
+       if (rp->type == BBTYPE_EXH) {
+               topslot = TOP_IS_IN_ITMP1;
+       }
+
+       /* write javalocals */
+
+       ra = rp->regalloc;
+       count = rp->regalloccount;
+
+       while (count && (i = ra->index) >= 0) {
+               assert(i < m->maxlocals);
+               assert(i < frame->javalocalcount);
+               assert(ra->type == frame->javalocaltype[i]);
+               if (ra->type == TYPE_RET) {
+                       /* XXX assert that it matches this rplpoint */
+               }
+               else
+                       replace_write_value(es, ra, frame->javalocals + i);
+               count--;
+               ra++;
+       }
+
+       /* write stack slots */
+
+       i = 0;
+
+       /* the first stack slot is special in SBR and EXH blocks */
+
+       if (topslot == TOP_IS_ON_STACK) {
+               assert(count);
+
+               assert(ra->index == RPLALLOC_STACK);
+               assert(i < frame->javastackdepth);
+               assert(frame->javastacktype[i] == TYPE_ADR);
+               sp[-1] = frame->javastack[i].p;
+               count--;
+               i++;
+               ra++;
+       }
+       else if (topslot == TOP_IS_IN_ITMP1) {
+               assert(count);
+
+               assert(ra->index == RPLALLOC_STACK);
+               assert(i < frame->javastackdepth);
+               assert(frame->javastacktype[i] == TYPE_ADR);
+               es->intregs[REG_ITMP1] = frame->javastack[i].p;
+               count--;
+               i++;
+               ra++;
+       }
+       else if (topslot == TOP_IS_VOID) {
+               assert(count);
+
+               assert(ra->index == RPLALLOC_STACK);
+               assert(i < frame->javastackdepth);
+               assert(frame->javastacktype[i] == TYPE_VOID);
+               count--;
+               i++;
+               ra++;
+       }
+
+       /* write remaining stack slots */
+
+       for (; count--; ra++) {
+               if (ra->index == RPLALLOC_SYNC) {
+                       assert(rp->type == RPLPOINT_TYPE_INLINE);
+
+                       /* only write synchronization slots when traversing an inline point */
+
+                       if (!topframe) {
+                               assert(frame->down);
+                               assert(frame->down->syncslotcount == 1); /* XXX need to understand more cases */
+                               assert(frame->down->syncslots != NULL);
+
+                               replace_write_value(es,ra,frame->down->syncslots);
+                       }
+                       continue;
+               }
+
+               assert(ra->index == RPLALLOC_STACK || ra->index == RPLALLOC_PARAM);
+
+               /* do not write parameters of calls down the call chain */
+
+               if (!topframe && ra->index == RPLALLOC_PARAM) {
+                       /* skip it */
+                       /*
+                       ra->index = RPLALLOC_PARAM;
+                       replace_val_t v;
+                       v.l = 0;
+                       replace_write_value(es,ra,&v);
+                       */
+               }
+               else {
+                       assert(i < frame->javastackdepth);
+                       assert(ra->type == frame->javastacktype[i]);
+                       if (ra->type == TYPE_RET) {
+                               /* XXX assert that it matches this rplpoint */
+                       }
+                       else {
+                               replace_write_value(es,ra,frame->javastack + i);
+                       }
+                       i++;
+               }
+       }
+
+       /* set new pc */
+
+       es->pc = rp->pc;
+}
+
+
+/* md_pop_stackframe ***********************************************************
+
+   Restore callee-saved registers (including the RA register),
+   set the stack pointer to the next stackframe,
+   set the PC to the return address of the popped frame.
+
+   *** This function imitates the effects of the method epilog ***
+   *** and returning from the method call.                     ***
+
+   IN:
+       es...............execution state
+
+   OUT:
+       *es..............the execution state after popping the stack frame
+                        NOTE: es->code and es->pv are NOT updated.
+
+*******************************************************************************/
+
+void md_pop_stackframe(executionstate_t *es)
+{
+       u1 *ra;
+       s4 ra_align_off;
+       s4 reg;
+       s4 i;
+       stackslot_t *basesp;
+       stackslot_t *sp;
+
+       assert(es->code);
+
+       /* alignment offset of RA */
+
+       ra_align_off = 0;
+#if defined(REPLACE_RA_BETWEEN_FRAMES)
+    if (es->code->stackframesize)
+               ra_align_off = SIZE_OF_STACKSLOT - SIZEOF_VOID_P;
+#endif
+
+       /* read the return address */
+
+#if defined(REPLACE_LEAFMETHODS_RA_REGISTER)
+       if (code_is_leafmethod(es->code))
+               ra = es->ra;
+       else
+#endif
+               ra = (u1*) md_stacktrace_get_returnaddress(es->sp,
+                          SIZE_OF_STACKSLOT * es->code->stackframesize + ra_align_off);
+
+       /* calculate the base of the stack frame */
+
+       sp = (stackslot_t *) es->sp;
+       basesp = sp + es->code->stackframesize;
+
+       /* restore return address, if part of frame */
+
+#if defined(REPLACE_RA_TOP_OF_FRAME)
+#if defined(REPLACE_LEAFMETHODS_RA_REGISTER)
+       if (!code_is_leafmethod(es->code))
+#endif
+               es->ra = (u1*) (ptrint) *--basesp;
+#endif /* REPLACE_RA_TOP_OF_FRAME */
+
+#if defined(REPLACE_RA_LINKAGE_AREA)
+#if defined(REPLACE_LEAFMETHODS_RA_REGISTER)
+       if (!code_is_leafmethod(es->code))
+#endif
+               es->ra = (u1*) (ptrint) basesp[LA_LR_OFFSET / sizeof(stackslot_t)];
+#endif /* REPLACE_RA_LINKAGE_AREA */
+
+       /* restore saved int registers */
+
+       reg = INT_REG_CNT;
+       for (i=0; i<es->code->savedintcount; ++i) {
+               while (nregdescint[--reg] != REG_SAV)
+                       ;
+               es->intregs[reg] = *--basesp;
+       }
+
+       /* restore saved flt registers */
+
+       /* XXX align? */
+       reg = FLT_REG_CNT;
+       for (i=0; i<es->code->savedfltcount; ++i) {
+               while (nregdescfloat[--reg] != REG_SAV)
+                       ;
+               basesp -= STACK_SLOTS_PER_FLOAT;
+               es->fltregs[reg] = *(double*)basesp;
+       }
+
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+       /* restore saved adr registers */
+
+       reg = ADR_REG_CNT;
+       for (i=0; i<es->code->savedadrcount; ++i) {
+               while (nregdescadr[--reg] != REG_SAV)
+                       ;
+               es->adrregs[reg] = *--basesp;
+       }
+#endif
+
+       /* adjust the stackpointer */
+
+       es->sp += SIZE_OF_STACKSLOT * es->code->stackframesize;
+
+#if defined(REPLACE_RA_BETWEEN_FRAMES)
+       es->sp += ra_align_off + SIZEOF_VOID_P; /* skip return address */
+#endif
+
+       /* set the program counter to the return address */
+
+       es->pc = ra;
+
+       /* in debugging mode clobber non-saved registers */
+
+#if !defined(NDEBUG)
+       /* for debugging */
+       for (i=0; i<INT_REG_CNT; ++i)
+               if (nregdescint[i] != REG_SAV)
+                       es->intregs[i] = (ptrint) 0x33dead3333dead33ULL;
+       for (i=0; i<FLT_REG_CNT; ++i)
+               if (nregdescfloat[i] != REG_SAV)
+                       *(u8*)&(es->fltregs[i]) = 0x33dead3333dead33ULL;
+# if defined(HAS_ADDRESS_REGISTER_FILE)
+       for (i=0; i<ADR_REG_CNT; ++i)
+               if (nregdescadr[i] != REG_SAV)
+                       es->adrregs[i] = (ptrint) 0x33dead3333dead33ULL;
+# endif
+#endif /* !defined(NDEBUG) */
+}
+
+
+/* md_push_stackframe **********************************************************
+
+   Save the given return address, build the new stackframe,
+   and store callee-saved registers.
+
+   *** This function imitates the effects of a call and the ***
+   *** method prolog of the callee.                         ***
+
+   IN:
+       es...............execution state
+       calleecode.......the code we are "calling"
+       ra...............the return address to save
+
+   OUT:
+       *es..............the execution state after pushing the stack frame
+                        NOTE: es->pc, es->code, and es->pv are NOT updated.
+
+*******************************************************************************/
+
+void md_push_stackframe(executionstate_t *es, codeinfo *calleecode, u1 *ra)
+{
+       s4           reg;
+       s4           i;
+       stackslot_t *basesp;
+       stackslot_t *sp;
+
+       assert(es);
+       assert(calleecode);
+
+       /* write the return address */
+
+#if defined(REPLACE_RA_BETWEEN_FRAMES)
+       es->sp -= SIZEOF_VOID_P;
+       *((void **)es->sp) = (void *) ra;
+       if (calleecode->stackframesize)
+               es->sp -= (SIZE_OF_STACKSLOT - SIZEOF_VOID_P);
+#endif /* REPLACE_RA_BETWEEN_FRAMES */
+
+       es->ra = (u1*) (ptrint) ra;
+
+       /* build the stackframe */
+
+       DOLOG( printf("building stackframe of %d words at %p\n",
+                                 calleecode->stackframesize, (void*)es->sp); );
+
+       sp = (stackslot_t *) es->sp;
+       basesp = sp;
+
+       sp -= calleecode->stackframesize;
+       es->sp = (u1*) sp;
+
+       /* in debug mode, invalidate stack frame first */
+
+       /* XXX may not invalidate linkage area used by native code! */
+
+#if !defined(NDEBUG) && 0
+       for (i=0; i< (basesp - sp) && i < 1; ++i) {
+               sp[i] = 0xdeaddeadU;
+       }
+#endif
+
+#if defined(__I386__)
+       /* Stackslot 0 may contain the object instance for vftbl patching.
+          Destroy it, so there's no undefined value used. */
+       if ((basesp - sp) > 0) {
+               sp[0] = 0;
+       }
+#endif
+
+       /* save the return address register */
+
+#if defined(REPLACE_RA_TOP_OF_FRAME)
+#if defined(REPLACE_LEAFMETHODS_RA_REGISTER)
+       if (!code_is_leafmethod(calleecode))
+#endif
+               *--basesp = (ptrint) ra;
+#endif /* REPLACE_RA_TOP_OF_FRAME */
+
+#if defined(REPLACE_RA_LINKAGE_AREA)
+#if defined(REPLACE_LEAFMETHODS_RA_REGISTER)
+       if (!code_is_leafmethod(calleecode))
+#endif
+               basesp[LA_LR_OFFSET / sizeof(stackslot_t)] = (ptrint) ra;
+#endif /* REPLACE_RA_LINKAGE_AREA */
+
+       /* save int registers */
+
+       reg = INT_REG_CNT;
+       for (i=0; i<calleecode->savedintcount; ++i) {
+               while (nregdescint[--reg] != REG_SAV)
+                       ;
+               *--basesp = es->intregs[reg];
+
+               /* XXX may not clobber saved regs used by native code! */
+#if !defined(NDEBUG) && 0
+               es->intregs[reg] = (ptrint) 0x44dead4444dead44ULL;
+#endif
+       }
+
+       /* save flt registers */
+
+       /* XXX align? */
+       reg = FLT_REG_CNT;
+       for (i=0; i<calleecode->savedfltcount; ++i) {
+               while (nregdescfloat[--reg] != REG_SAV)
+                       ;
+               basesp -= STACK_SLOTS_PER_FLOAT;
+               *(double*)basesp = es->fltregs[reg];
+
+               /* XXX may not clobber saved regs used by native code! */
+#if !defined(NDEBUG) && 0
+               *(u8*)&(es->fltregs[reg]) = 0x44dead4444dead44ULL;
+#endif
+       }
+
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+       /* save adr registers */
+
+       reg = ADR_REG_CNT;
+       for (i=0; i<calleecode->savedadrcount; ++i) {
+               while (nregdescadr[--reg] != REG_SAV)
+                       ;
+               *--basesp = es->adrregs[reg];
+
+               /* XXX may not clobber saved regs used by native code! */
+#if !defined(NDEBUG) && 0
+               es->adrregs[reg] = (ptrint) 0x44dead4444dead44ULL;
+#endif
+       }
+#endif
+}
+
+
+/* replace_pop_activation_record ***********************************************
+
+   Peel a stack frame from the execution state.
+
+   *** This function imitates the effects of the method epilog ***
+   *** and returning from the method call.                     ***
+
+   IN:
+       es...............execution state
+       frame............source frame, receives synchronization slots
+
+   OUT:
+       *es..............the execution state after popping the stack frame
+
+   RETURN VALUE:
+       the return address of the poped activation record
+
+*******************************************************************************/
+
+u1* replace_pop_activation_record(executionstate_t *es,
+                                                                 sourceframe_t *frame)
+{
+       u1 *ra;
+       s4 i;
+       s4 count;
+       codeinfo *code;
+       stackslot_t *sp;
+
+       assert(es->code);
+       assert(frame);
+
+       /* calculate the base of the stack frame */
+
+       sp = (stackslot_t *) es->sp;
+       assert(frame->syncslotcount == 0);
+       assert(frame->syncslots == NULL);
+       count = code_get_sync_slot_count(es->code);
+       frame->syncslotcount = count;
+       frame->syncslots = (replace_val_t*) DumpMemory::allocate(sizeof(replace_val_t) * count);
+       for (i=0; i<count; ++i) {
+               frame->syncslots[i].p = sp[es->code->memuse + i]; /* XXX md_ function */
+       }
+
+       /* pop the stackframe */
+
+       md_pop_stackframe(es);
+
+       ra = es->pc;
+
+       DOLOG( printf("RA = %p\n", (void*)ra); );
+
+       /* Subtract one from the PC so we do not hit the replacement point */
+       /* of the instruction following the call, if there is one.         */
+
+       es->pc--;
+
+       /* find the new codeinfo */
+
+       void* pv = md_codegen_get_pv_from_pc(ra);
+       DOLOG( printf("PV = %p\n", pv); );
+
+       code = code_get_codeinfo_for_pv(pv);
+       DOLOG( printf("CODE = %p\n", (void*) code); );
+
+       /* return NULL if we reached native code */
+
+       es->pv   = (uint8_t*) pv;
+       es->code = code;
+
+       return (code) ? ra : NULL;
+}
+
+
+/* replace_patch_method_pointer ************************************************
+
+   Patch a method pointer (may be in code, data segment, vftbl, or interface
+   table).
+
+   IN:
+          mpp..............address of the method pointer to patch
+          entrypoint.......the new entrypoint of the method
+          kind.............kind of call to patch, used only for debugging
+
+*******************************************************************************/
+
+static void replace_patch_method_pointer(methodptr *mpp,
+                                                                                methodptr entrypoint,
+                                                                                const char *kind)
+{
+#if !defined(NDEBUG)
+       codeinfo       *oldcode;
+       codeinfo       *newcode;
+#endif
+
+       DOLOG( printf("patch method pointer from: %p to %p\n",
+                                 (void*) *mpp, (void*)entrypoint); );
+
+#if !defined(NDEBUG)
+       oldcode = code_get_codeinfo_for_pv(*mpp);
+       newcode = code_get_codeinfo_for_pv(entrypoint);
+
+       DOLOG_SHORT( printf("\tpatch %s %p ", kind, (void*) oldcode);
+                                method_println(oldcode->m);
+                                printf("\t      with      %p ", (void*) newcode);
+                                method_println(newcode->m); );
+
+       assert(oldcode->m == newcode->m);
+#endif
+
+       /* write the new entrypoint */
+
+       *mpp = (methodptr) entrypoint;
+}
+
+
+/* replace_patch_class *********************************************************
+
+   Patch a method in the given class.
+
+   IN:
+          vftbl............vftbl of the class
+          m................the method to patch
+          oldentrypoint....the old entrypoint to replace
+          entrypoint.......the new entrypoint
+
+*******************************************************************************/
+
+void replace_patch_class(vftbl_t *vftbl,
+                                                methodinfo *m,
+                                                u1 *oldentrypoint,
+                                                u1 *entrypoint)
+{
+       s4                 i;
+       methodptr         *mpp;
+       methodptr         *mppend;
+
+       /* patch the vftbl of the class */
+
+       replace_patch_method_pointer(vftbl->table + m->vftblindex,
+                                                                entrypoint,
+                                                                "virtual  ");
+
+       /* patch the interface tables */
+
+       assert(oldentrypoint);
+
+       for (i=0; i < vftbl->interfacetablelength; ++i) {
+               mpp = vftbl->interfacetable[-i];
+               mppend = mpp + vftbl->interfacevftbllength[i];
+               for (; mpp != mppend; ++mpp)
+                       if (*mpp == oldentrypoint) {
+                               replace_patch_method_pointer(mpp, entrypoint, "interface");
+                       }
+       }
+}
+
+
+/* replace_patch_class_hierarchy ***********************************************
+
+   Patch a method in all loaded classes.
+
+   IN:
+          m................the method to patch
+          oldentrypoint....the old entrypoint to replace
+          entrypoint.......the new entrypoint
+
+*******************************************************************************/
+
+struct replace_patch_data_t {
+       methodinfo *m;
+       u1         *oldentrypoint;
+       u1         *entrypoint;
+};
+
+void replace_patch_callback(classinfo *c, struct replace_patch_data_t *pd)
+{
+       vftbl_t *vftbl = c->vftbl;
+
+       if (vftbl != NULL
+               && vftbl->vftbllength > pd->m->vftblindex
+               && (void*) vftbl->table[pd->m->vftblindex] != (void*) (uintptr_t) &asm_abstractmethoderror
+               && code_get_methodinfo_for_pv(vftbl->table[pd->m->vftblindex]) == pd->m)
+       {
+               replace_patch_class(c->vftbl, pd->m, pd->oldentrypoint, pd->entrypoint);
+       }
+}
+
+void replace_patch_class_hierarchy(methodinfo *m,
+                                                                  u1 *oldentrypoint,
+                                                                  u1 *entrypoint)
+{
+       struct replace_patch_data_t pd;
+
+       pd.m = m;
+       pd.oldentrypoint = oldentrypoint;
+       pd.entrypoint = entrypoint;
+
+       DOLOG_SHORT( printf("patching class hierarchy: ");
+                            method_println(m); );
+
+       classcache_foreach_loaded_class(
+                       (classcache_foreach_functionptr_t) &replace_patch_callback,
+                       (void*) &pd);
+}
+
+
+/* replace_patch_future_calls **************************************************
+
+   Analyse a call site and depending on the kind of call patch the call, the
+   virtual function table, or the interface table.
+
+   IN:
+          ra...............return address pointing after the call site
+          callerframe......source frame of the caller
+          calleeframe......source frame of the callee, must have been mapped
+
+*******************************************************************************/
+
+void replace_patch_future_calls(u1 *ra,
+                                                               sourceframe_t *callerframe,
+                                                               sourceframe_t *calleeframe)
+{
+       u1            *patchpos;
+       methodptr      entrypoint;
+       methodptr      oldentrypoint;
+       bool           atentry;
+       void          *pv;
+       codeinfo      *calleecode;
+       methodinfo    *calleem;
+       java_object_t *obj;
+       vftbl_t       *vftbl;
+
+       assert(ra);
+       assert(callerframe->down == calleeframe);
+
+       /* get the new codeinfo and the method that shall be entered */
+
+       calleecode = calleeframe->tocode;
+       assert(calleecode);
+
+       calleem = calleeframe->method;
+       assert(calleem == calleecode->m);
+
+       entrypoint = (methodptr) calleecode->entrypoint;
+
+       /* check if we are at an method entry rplpoint at the innermost frame */
+
+       atentry = (calleeframe->down == NULL)
+                       && !(calleem->flags & ACC_STATIC)
+                       && (calleeframe->fromrp->id == 0); /* XXX */
+
+       /* get the position to patch, in case it was a statically bound call   */
+
+       pv = callerframe->fromcode->entrypoint;
+       patchpos = (u1*) md_jit_method_patch_address(pv, ra, NULL);
+
+       if (patchpos == NULL) {
+               /* the call was dispatched dynamically */
+
+               /* we can only patch such calls if we are at the entry point */
+
+#if !defined(__I386__)
+               /* On i386 we always know the instance argument. */
+               if (!atentry)
+                       return;
+#endif
+
+               assert((calleem->flags & ACC_STATIC) == 0);
+
+               oldentrypoint = calleeframe->fromcode->entrypoint;
+
+               /* we need to know the instance */
+
+               if (!calleeframe->instance.a) {
+                       DOLOG_SHORT( printf("WARNING: object instance unknown!\n"); );
+                       replace_patch_class_hierarchy(calleem, oldentrypoint, entrypoint);
+                       return;
+               }
+
+               /* get the vftbl */
+
+               obj = calleeframe->instance.a;
+               vftbl = obj->vftbl;
+
+               assert(vftbl->clazz->vftbl == vftbl);
+
+               DOLOG_SHORT( printf("\tclass: "); class_println(vftbl->clazz); );
+
+               replace_patch_class(vftbl, calleem, oldentrypoint, entrypoint);
+       }
+       else {
+               /* the call was statically bound */
+
+#if defined(__I386__)
+               /* It happens that there is a patcher trap. (pm) */
+               if (*(u2 *)(patchpos - 1) == 0x0b0f) {
+               } else
+#endif
+               replace_patch_method_pointer((methodptr *) patchpos, entrypoint, "static   ");
+       }
+}
+
+
+/* replace_push_activation_record **********************************************
+
+   Push a stack frame onto the execution state.
+   
+   *** This function imitates the effects of a call and the ***
+   *** method prolog of the callee.                         ***
+
+   IN:
+          es...............execution state
+          rpcall...........the replacement point at the call site
+          callerframe......source frame of the caller, or NULL for creating the
+                           first frame
+          calleeframe......source frame of the callee, must have been mapped
+
+   OUT:
+       *es..............the execution state after pushing the stack frame
+  
+*******************************************************************************/
+
+void replace_push_activation_record(executionstate_t *es,
+                                                                       rplpoint *rpcall,
+                                                                       sourceframe_t *callerframe,
+                                                                       sourceframe_t *calleeframe)
+{
+       s4           i;
+       s4           count;
+       stackslot_t *sp;
+       u1          *ra;
+       codeinfo    *calleecode;
+
+       assert(es);
+       assert(!rpcall || callerframe);
+    assert(!rpcall || rpcall->type == RPLPOINT_TYPE_CALL);
+       assert(!rpcall || rpcall == callerframe->torp);
+       assert(calleeframe);
+       assert(!callerframe || calleeframe == callerframe->down);
+
+       /* the compilation unit we are entering */
+
+       calleecode = calleeframe->tocode;
+       assert(calleecode);
+
+       /* calculate the return address */
+
+       if (rpcall)
+               ra = rpcall->pc + rpcall->callsize;
+       else
+               ra = es->pc + 1 /* XXX this is ugly */;
+
+       /* push the stackframe */
+
+       md_push_stackframe(es, calleecode, ra);
+
+       /* we move into a new code unit, set code, PC, PV */
+
+       es->code = calleecode;
+       es->pc = calleecode->entrypoint; /* XXX not needed? */
+       es->pv = calleecode->entrypoint;
+
+       /* write slots used for synchronization */
+
+       sp = (stackslot_t *) es->sp;
+       count = code_get_sync_slot_count(calleecode);
+       assert(count == calleeframe->syncslotcount);
+       for (i=0; i<count; ++i) {
+               sp[calleecode->memuse + i] = calleeframe->syncslots[i].p;
+       }
+
+       /* redirect future invocations */
+
+       if (callerframe && rpcall) {
+#if defined(REPLACE_PATCH_ALL)
+               if (rpcall->type == callerframe->fromrp->type)
+#else
+               if (rpcall == callerframe->fromrp)
+#endif
+                       replace_patch_future_calls(ra, callerframe, calleeframe);
+       }
+}
+
+
+/* replace_find_replacement_point **********************************************
+
+   Find the replacement point in the given code corresponding to the
+   position given in the source frame.
+   
+   IN:
+          code.............the codeinfo in which to search the rplpoint
+          frame............the source frame defining the position to look for
+          parent...........parent replacement point to match
+
+   RETURN VALUE:
+       the replacement point
+  
+*******************************************************************************/
+
+rplpoint * replace_find_replacement_point(codeinfo *code,
+                                                                                 sourceframe_t *frame,
+                                                                                 rplpoint *parent)
+{
+       methodinfo *m;
+       rplpoint *rp;
+       s4        i;
+       s4        j;
+       s4        stacki;
+       rplalloc *ra;
+
+       assert(code);
+       assert(frame);
+
+       DOLOG( printf("searching replacement point for:\n");
+                  replace_source_frame_println(frame); );
+
+       m = frame->method;
+
+       DOLOG( printf("code = %p\n", (void*)code); );
+
+       rp = code->rplpoints;
+       i = code->rplpointcount;
+       while (i--) {
+               if (rp->id == frame->id && rp->method == frame->method
+                               && rp->parent == parent
+                               && replace_normalize_type_map[rp->type] == frame->type)
+               {
+                       /* check if returnAddresses match */
+                       /* XXX optimize: only do this if JSRs in method */
+                       DOLOG( printf("checking match for:");
+                                  replace_replacement_point_println(rp, 1); fflush(stdout); );
+                       ra = rp->regalloc;
+                       stacki = 0;
+                       for (j = rp->regalloccount; j--; ++ra) {
+                               if (ra->type == TYPE_RET) {
+                                       if (ra->index == RPLALLOC_STACK) {
+                                               assert(stacki < frame->javastackdepth);
+                                               if (frame->javastack[stacki].i != ra->regoff)
+                                                       goto no_match;
+                                               stacki++;
+                                       }
+                                       else {
+                                               assert(ra->index >= 0 && ra->index < frame->javalocalcount);
+                                               if (frame->javalocals[ra->index].i != ra->regoff)
+                                                       goto no_match;
+                                       }
+                               }
+                       }
+
+                       /* found */
+                       return rp;
+               }
+no_match:
+               rp++;
+       }
+
+#if !defined(NDEBUG)
+       printf("candidate replacement points were:\n");
+       rp = code->rplpoints;
+       i = code->rplpointcount;
+       for (; i--; ++rp) {
+               replace_replacement_point_println(rp, 1);
+       }
+#endif
+
+       vm_abort("no matching replacement point found");
+       return NULL; /* NOT REACHED */
+}
+
+
+/* replace_find_replacement_point_for_pc ***************************************
+
+   Find the nearest replacement point at or before the given PC. The
+   given PC has to be between (rp->pc) and (rp->pc+rp->callsize) for
+   the replacement point to be found.
+
+   IN:
+       code.............compilation unit the PC is in
+          pc...............the machine code PC
+
+   RETURN VALUE:
+       the replacement point found, or
+          NULL if no replacement point was found
+
+*******************************************************************************/
+
+rplpoint *replace_find_replacement_point_for_pc(codeinfo *code, u1 *pc, unsigned desired_flags)
+{
+       rplpoint *found;
+       rplpoint *rp;
+       s4        i;
+
+       DOLOG( printf("searching for rp at pc:%p in %p ", (void*)pc, (void*)code);
+                  method_println(code->m); );
+
+       found = NULL;
+
+       rp = code->rplpoints;
+       for (i=0; i<code->rplpointcount; ++i, ++rp) {
+               DOLOG( replace_replacement_point_println(rp, 2); );
+               if (rp->pc <= pc && rp->pc + rp->callsize >= pc) {
+                       if (desired_flags) {
+                               if (rp->flags & desired_flags) {
+                                       found = rp;
+                               }
+                       } else {
+                               found = rp;
+                       }
+               }
+       }
+
+       return found;
+}
+
+/* replace_pop_native_frame ****************************************************
+
+   Unroll a native frame in the execution state and create a source frame
+   for it.
+
+   IN:
+          es...............current execution state
+          ss...............the current source state
+          sfi..............stackframeinfo for the native frame
+
+   OUT:
+       es...............execution state after unrolling the native frame
+          ss...............gets the added native source frame
+
+*******************************************************************************/
+
+static void replace_pop_native_frame(executionstate_t *es,
+                                                                        sourcestate_t *ss,
+                                                                        stackframeinfo_t *sfi)
+{
+       sourceframe_t *frame;
+       codeinfo      *code;
+       s4             i,j;
+
+       assert(sfi);
+
+       frame = replace_new_sourceframe(ss);
+
+       frame->sfi = sfi;
+
+       /* remember pc and size of native frame */
+
+       frame->nativepc = es->pc;
+       frame->nativeframesize = (es->sp != 0) ? (((uintptr_t) sfi->sp) - ((uintptr_t) es->sp)) : 0;
+       assert(frame->nativeframesize >= 0);
+
+       /* remember values of saved registers */
+
+       j = 0;
+       for (i=0; i<INT_REG_CNT; ++i) {
+               if (nregdescint[i] == REG_SAV)
+                       frame->nativesavint[j++] = es->intregs[i];
+       }
+
+       j = 0;
+       for (i=0; i<FLT_REG_CNT; ++i) {
+               if (nregdescfloat[i] == REG_SAV)
+                       frame->nativesavflt[j++] = es->fltregs[i];
+       }
+
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+       j = 0;
+       for (i=0; i<ADR_REG_CNT; ++i) {
+               if (nregdescadr[i] == REG_SAV)
+                       frame->nativesavadr[j++] = es->adrregs[i];
+       }
+#endif
+
+       /* restore saved registers */
+
+#if defined(ENABLE_GC_CACAO) && !defined(HAS_ADDRESS_REGISTER_FILE)
+       j = 0;
+       for (i=0; i<INT_REG_CNT; ++i) {
+               if (nregdescint[i] == REG_SAV)
+                       es->intregs[i] = sfi->intregs[j++];
+       }
+#else
+       /* XXX we don't have them, yet, in the sfi, so clear them */
+
+       for (i=0; i<INT_REG_CNT; ++i) {
+               if (nregdescint[i] == REG_SAV)
+                       es->intregs[i] = 0;
+       }
+#endif
+
+       /* XXX we don't have float registers in the sfi, so clear them */
+
+       for (i=0; i<FLT_REG_CNT; ++i) {
+               if (nregdescfloat[i] == REG_SAV)
+                       es->fltregs[i] = 0.0;
+       }
+
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+# if defined(ENABLE_GC_CACAO)
+       j = 0;
+       for (i=0; i<ADR_REG_CNT; ++i) {
+               if (nregdescadr[i] == REG_SAV)
+                       es->adrregs[i] = sfi->adrregs[j++];
+       }
+# else
+       for (i=0; i<ADR_REG_CNT; ++i) {
+               if (nregdescadr[i] == REG_SAV)
+                       es->adrregs[i] = 0;
+       }
+# endif
+#endif
+
+       /* restore codeinfo of the native stub */
+
+       code = code_get_codeinfo_for_pv(sfi->pv);
+
+       /* restore sp, pv, pc and codeinfo of the parent method */
+
+       /* XXX michi: use this instead:
+       es->sp = sfi->sp + code->stackframesize; */
+       es->sp   = (uint8_t*) (((uintptr_t) sfi->sp) + (*(s4 *) (((uintptr_t) sfi->pv) + FrameSize)));
+#if defined(REPLACE_RA_BETWEEN_FRAMES)
+       es->sp  += SIZE_OF_STACKSLOT; /* skip return address */
+#endif
+       es->pv   = (uint8_t*) md_codegen_get_pv_from_pc(sfi->ra);
+       es->pc   = (uint8_t*) (((uintptr_t) ((sfi->xpc) ? sfi->xpc : sfi->ra)) - 1);
+       es->code = code_get_codeinfo_for_pv(es->pv);
+}
+
+
+/* replace_push_native_frame ***************************************************
+
+   Rebuild a native frame onto the execution state and remove its source frame.
+
+   Note: The native frame is "rebuild" by setting fields like PC and stack
+         pointer in the execution state accordingly. Values in the
+                stackframeinfo may be modified, but the actual stack frame of the
+                native code is not touched.
+
+   IN:
+          es...............current execution state
+          ss...............the current source state
+
+   OUT:
+       es...............execution state after re-rolling the native frame
+          ss...............the native source frame is removed
+
+*******************************************************************************/
+
+static void replace_push_native_frame(executionstate_t *es, sourcestate_t *ss)
+{
+       sourceframe_t *frame;
+       s4             i,j;
+
+       assert(es);
+       assert(ss);
+
+       DOLOG( printf("pushing native frame\n"); );
+
+       /* remove the frame from the source state */
+
+       frame = ss->frames;
+       assert(frame);
+       assert(REPLACE_IS_NATIVE_FRAME(frame));
+
+       ss->frames = frame->down;
+
+       /* skip sp for the native stub */
+
+       es->sp -= (*(s4 *) (((uintptr_t) frame->sfi->pv) + FrameSize));
+#if defined(REPLACE_RA_BETWEEN_FRAMES)
+       es->sp -= SIZE_OF_STACKSLOT; /* skip return address */
+#endif
+
+       /* assert that the native frame has not moved */
+
+       assert(es->sp == frame->sfi->sp);
+
+       /* update saved registers in the stackframeinfo */
+
+#if defined(ENABLE_GC_CACAO)
+       j = 0;
+# if !defined(HAS_ADDRESS_REGISTER_FILE)
+       for (i=0; i<INT_REG_CNT; ++i) {
+               if (nregdescint[i] == REG_SAV)
+                       frame->sfi->intregs[j++] = es->intregs[i];
+       }
+# else
+       for (i=0; i<ADR_REG_CNT; ++i) {
+               if (nregdescadr[i] == REG_SAV)
+                       frame->sfi->adrregs[j++] = es->adrregs[i];
+       }
+# endif
+
+       /* XXX leave float registers untouched here */
+#endif
+
+       /* restore saved registers */
+
+       j = 0;
+       for (i=0; i<INT_REG_CNT; ++i) {
+               if (nregdescint[i] == REG_SAV)
+                       es->intregs[i] = frame->nativesavint[j++];
+       }
+
+       j = 0;
+       for (i=0; i<FLT_REG_CNT; ++i) {
+               if (nregdescfloat[i] == REG_SAV)
+                       es->fltregs[i] = frame->nativesavflt[j++];
+       }
+
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+       j = 0;
+       for (i=0; i<ADR_REG_CNT; ++i) {
+               if (nregdescadr[i] == REG_SAV)
+                       es->adrregs[i] = frame->nativesavadr[j++];
+       }
+#endif
+
+       /* skip the native frame on the machine stack */
+
+       es->sp -= frame->nativeframesize;
+
+       /* set the pc the next frame must return to */
+
+       es->pc = frame->nativepc;
+}
+
+
+/* replace_recover_source_state ************************************************
+
+   Recover the source state from the given replacement point and execution
+   state.
+
+   IN:
+       rp...............replacement point that has been reached, if any
+          sfi..............stackframeinfo, if called from native code
+          es...............execution state at the replacement point rp
+
+   RETURN VALUE:
+       the source state
+
+*******************************************************************************/
+
+sourcestate_t *replace_recover_source_state(rplpoint *rp,
+                                                                                       stackframeinfo_t *sfi,
+                                                                                   executionstate_t *es)
+{
+       sourcestate_t *ss;
+       u1            *ra;
+       bool           locked;
+#if defined(REPLACE_STATISTICS)
+       s4             depth;
+#endif
+
+       /* create the source frame structure in dump memory */
+
+       ss = (sourcestate_t*) DumpMemory::allocate(sizeof(sourcestate_t));
+       ss->frames = NULL;
+
+       /* each iteration of the loop recovers one source frame */
+
+       depth = 0;
+       locked = false;
+
+       while (rp || sfi) {
+
+               DOLOG( executionstate_println(es); );
+
+               /* if we are not at a replacement point, it is a native frame */
+
+               if (rp == NULL) {
+                       DOLOG( printf("native frame: sfi: "); replace_stackframeinfo_println(sfi); );
+
+                       locked = true;
+                       replace_pop_native_frame(es, ss, sfi);
+                       sfi = sfi->prev;
+
+                       if (es->code == NULL)
+                               continue;
+
+                       goto after_machine_frame;
+               }
+
+               /* read the values for this source frame from the execution state */
+
+               DOLOG( printf("recovering source state for%s:\n",
+                                       (ss->frames == NULL) ? " TOPFRAME" : "");
+                          replace_replacement_point_println(rp, 1); );
+
+               replace_read_executionstate(rp, es, ss, ss->frames == NULL);
+
+#if defined(ENABLE_VMLOG)
+               vmlog_cacao_unrol_method(ss->frames->method);
+#endif
+
+#if defined(REPLACE_STATISTICS)
+               REPLACE_COUNT(stat_frames);
+               depth++;
+               replace_statistics_source_frame(ss->frames);
+#endif
+
+               /* in locked areas (below native frames), identity map the frame */
+
+               if (locked) {
+                       ss->frames->torp = ss->frames->fromrp;
+                       ss->frames->tocode = ss->frames->fromcode;
+               }
+
+               /* unroll to the next (outer) frame */
+
+               if (rp->parent) {
+                       /* this frame is in inlined code */
+
+                       DOLOG( printf("INLINED!\n"); );
+
+                       rp = rp->parent;
+
+                       assert(rp->type == RPLPOINT_TYPE_INLINE);
+                       REPLACE_COUNT(stat_unroll_inline);
+               }
+               else {
+                       /* this frame had been called at machine-level. pop it. */
+
+                       DOLOG( printf("UNWIND\n"); );
+
+                       ra = replace_pop_activation_record(es, ss->frames);
+                       if (ra == NULL) {
+                               DOLOG( printf("REACHED NATIVE CODE\n"); );
+
+                               rp = NULL;
+
+#if !defined(ENABLE_GC_CACAO)
+                               break; /* XXX remove to activate native frames */
+#endif
+                               continue;
+                       }
+
+                       /* find the replacement point at the call site */
+
+after_machine_frame:
+                       rp = replace_find_replacement_point_for_pc(es->code, es->pc, 0);
+
+                       if (rp == NULL)
+                               vm_abort("could not find replacement point while unrolling call");
+
+                       DOLOG( printf("found replacement point.\n");
+                                       replace_replacement_point_println(rp, 1); );
+
+                       assert(rp->type == RPLPOINT_TYPE_CALL);
+                       REPLACE_COUNT(stat_unroll_call);
+               }
+       } /* end loop over source frames */
+
+       REPLACE_COUNT_DIST(stat_dist_frames, depth);
+
+       return ss;
+}
+
+
+/* replace_map_source_state ****************************************************
+
+   Map each source frame in the given source state to a target replacement
+   point and compilation unit. If no valid code is available for a source
+   frame, it is (re)compiled.
+
+   IN:
+       ss...............the source state
+
+   OUT:
+       ss...............the source state, modified: The `torp` and `tocode`
+                           fields of each source frame are set.
+
+   RETURN VALUE:
+       true.............everything went ok
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+static bool replace_map_source_state(sourcestate_t *ss)
+{
+       sourceframe_t *frame;
+       codeinfo      *code;
+       rplpoint      *rp;
+       rplpoint      *parent; /* parent of inlined rplpoint */
+#if defined(REPLACE_STATISTICS)
+       codeinfo      *oldcode;
+#endif
+
+       parent = NULL;
+       code = NULL;
+
+       /* iterate over the source frames from outermost to innermost */
+
+       for (frame = ss->frames; frame != NULL; frame = frame->down) {
+
+               /* XXX skip native frames */
+
+               if (REPLACE_IS_NATIVE_FRAME(frame)) {
+                       parent = NULL;
+                       continue;
+               }
+
+               /* map frames which are not already mapped */
+
+               if (frame->tocode) {
+                       code = frame->tocode;
+                       rp = frame->torp;
+                       assert(rp);
+               }
+               else {
+                       assert(frame->torp == NULL);
+
+                       if (parent == NULL) {
+                               /* find code for this frame */
+
+#if defined(REPLACE_STATISTICS)
+                               oldcode = frame->method->code;
+#endif
+                               /* request optimization of hot methods and their callers */
+
+                               if (frame->method->hitcountdown < 0
+                                       || (frame->down && frame->down->method->hitcountdown < 0))
+                                       jit_request_optimization(frame->method);
+
+                               code = jit_get_current_code(frame->method);
+
+                               if (code == NULL)
+                                       return false; /* exception */
+
+                               REPLACE_COUNT_IF(stat_recompile, code != oldcode);
+                       }
+
+                       assert(code);
+
+                       /* map this frame */
+
+                       rp = replace_find_replacement_point(code, frame, parent);
+
+                       frame->tocode = code;
+                       frame->torp = rp;
+               }
+
+               if (rp->type == RPLPOINT_TYPE_CALL) {
+                       parent = NULL;
+               }
+               else {
+                       /* inlining */
+                       parent = rp;
+               }
+       }
+
+       return true;
+}
+
+
+/* replace_map_source_state_identity *******************************************
+
+   Map each source frame in the given source state to the same replacement
+   point and compilation unit it was derived from. This is mainly used for
+   garbage collection.
+
+   IN:
+       ss...............the source state
+
+   OUT:
+       ss...............the source state, modified: The `torp` and `tocode`
+                           fields of each source frame are set.
+
+*******************************************************************************/
+
+#if defined(ENABLE_GC_CACAO)
+static void replace_map_source_state_identity(sourcestate_t *ss)
+{
+       sourceframe_t *frame;
+
+       /* iterate over the source frames from outermost to innermost */
+
+       for (frame = ss->frames; frame != NULL; frame = frame->down) {
+
+               /* skip native frames */
+
+               if (REPLACE_IS_NATIVE_FRAME(frame)) {
+                       continue;
+               }
+
+               /* map frames using the identity mapping */
+
+               if (frame->tocode) {
+                       assert(frame->tocode == frame->fromcode);
+                       assert(frame->torp   == frame->fromrp);
+               } else {
+                       assert(frame->tocode == NULL);
+                       assert(frame->torp   == NULL);
+                       frame->tocode = frame->fromcode;
+                       frame->torp   = frame->fromrp;
+               }
+       }
+}
+#endif
+
+
+/* replace_build_execution_state ***********************************************
+
+   Build an execution state for the given (mapped) source state.
+
+   !!! CAUTION: This function rewrites the machine stack !!!
+
+   THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA!
+
+   IN:
+       ss...............the source state. Must have been mapped by
+                                               replace_map_source_state before.
+          es...............the base execution state on which to build
+
+   OUT:
+       *es..............the new execution state
+
+*******************************************************************************/
+
+static void replace_build_execution_state(sourcestate_t *ss,
+                                                                                 executionstate_t *es)
+{
+       rplpoint      *rp;
+       sourceframe_t *prevframe;
+       rplpoint      *parent;
+
+       parent = NULL;
+       prevframe = NULL;
+       rp = NULL;
+
+       while (ss->frames) {
+
+               if (REPLACE_IS_NATIVE_FRAME(ss->frames)) {
+                       prevframe = ss->frames;
+                       replace_push_native_frame(es, ss);
+                       parent = NULL;
+                       rp = NULL;
+                       continue;
+               }
+
+               if (parent == NULL) {
+                       /* create a machine-level stack frame */
+
+                       DOLOG( printf("pushing activation record for:\n");
+                                  if (rp) replace_replacement_point_println(rp, 1);
+                                  else printf("\tfirst frame\n"); );
+
+                       replace_push_activation_record(es, rp, prevframe, ss->frames);
+
+                       DOLOG( executionstate_println(es); );
+               }
+
+               rp = ss->frames->torp;
+               assert(rp);
+
+               DOLOG( printf("creating execution state for%s:\n",
+                               (ss->frames->down == NULL) ? " TOPFRAME" : "");
+                          replace_replacement_point_println(ss->frames->fromrp, 1);
+                          replace_replacement_point_println(rp, 1); );
+
+               es->code = ss->frames->tocode;
+               prevframe = ss->frames;
+
+#if defined(ENABLE_VMLOG)
+               vmlog_cacao_rerol_method(ss->frames->method);
+#endif
+
+               replace_write_executionstate(rp, es, ss, ss->frames->down == NULL);
+
+               DOLOG( executionstate_println(es); );
+
+               if (rp->type == RPLPOINT_TYPE_CALL) {
+                       parent = NULL;
+               }
+               else {
+                       /* inlining */
+                       parent = rp;
+               }
+       }
+}
+
+
+/* replace_me ******************************************************************
+   This function is called by the signal handler when a thread reaches
+   a replacement point. `replace_me` must map the execution state to the
+   target replacement point and let execution continue there.
+
+   THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA!
+
+   IN:
+       rp...............replacement point that has been reached
+       es...............execution state read by signal handler
+  
+*******************************************************************************/
+
+static void replace_me(rplpoint *rp, executionstate_t *es)
+{
+       stackframeinfo_t    *sfi;
+       sourcestate_t       *ss;
+       sourceframe_t       *frame;
+       codeinfo            *origcode;
+       rplpoint            *origrp;
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+       threadobject        *thread;
+#endif
+
+       origcode = es->code;
+       origrp   = rp;
+
+#if defined(ENABLE_TLH)
+       /*printf("Replacing in %s/%s\n", rp->method->clazz->name->text, rp->method->name->text);*/
+#endif
+
+       /*if (strcmp(rp->method->clazz->name->text, "antlr/AlternativeElement") == 0 && strcmp(rp->method->name->text, "getAutoGenType") ==0) opt_TraceReplacement = 2; else opt_TraceReplacement = 0;*/
+
+       DOLOG_SHORT( printf("REPLACING(%d %p): (id %d %p) ",
+                                stat_replacements, (void*)THREADOBJECT,
+                                rp->id, (void*)rp);
+                                method_println(es->code->m); );
+
+       DOLOG( replace_replacement_point_println(rp, 1); );
+
+       REPLACE_COUNT(stat_replacements);
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       /* Get the stackframeinfo for the current thread. */
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* recover source state */
+
+       ss = replace_recover_source_state(rp, sfi, es);
+
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+       /* if there is a collection pending, we assume the replacement point should
+          suspend this thread */
+
+       if (gc_pending) {
+
+               thread = THREADOBJECT;
+
+               DOLOG_SHORT( printf("REPLACEMENT: Suspending thread for GC now!\n"); );
+
+               /* map the sourcestate using the identity mapping */
+               replace_map_source_state_identity(ss);
+
+               /* since we enter the same method again, we turn off rps now */
+               /* XXX michi: can we really do this? what if the rp was active before
+                  we activated it for the gc? */
+               replace_deactivate_replacement_points(origcode);
+
+               /* remember executionstate and sourcestate for this thread */
+               GC_EXECUTIONSTATE = es;
+               GC_SOURCESTATE    = ss;
+
+               /* really suspend this thread now (PC = 0) */
+               threads_suspend_ack(NULL, NULL);
+
+               DOLOG_SHORT( printf("REPLACEMENT: Resuming thread after GC now!\n"); );
+
+       } else {
+#endif /*defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)*/
+
+       /* map the source state */
+
+       if (!replace_map_source_state(ss))
+               vm_abort("exception during method replacement");
+
+       DOLOG( replace_sourcestate_println(ss); );
+
+       DOLOG_SHORT( replace_sourcestate_println_short(ss); );
+
+#if !defined(NDEBUG)
+       /* avoid infinite loops by self-replacement, only if not in testing mode */
+
+       if (!opt_TestReplacement) {
+               frame = ss->frames;
+               while (frame->down)
+                       frame = frame->down;
+
+               if (frame->torp == origrp) {
+                       DOLOG_SHORT(
+                               printf("WARNING: identity replacement, turning off rps to avoid infinite loop\n");
+                       );
+                       replace_deactivate_replacement_points(origcode);
+               }
+       }
+#endif
+
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+       }
+#endif
+
+       /* build the new execution state */
+
+       replace_build_execution_state(ss, es);
+
+#if !defined(NDEBUG)
+       /* continue execution after patched machine code, if testing mode enabled */
+
+       if (opt_TestReplacement)
+               es->pc += REPLACEMENT_PATCH_SIZE;
+#endif
+}
+
+
+/* replace_me_wrapper **********************************************************
+
+   This function is called by the signal handler. It determines if there
+   is an active replacement point pending at the given PC and returns
+   accordingly.
+
+   THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA!
+
+   IN:
+       pc...............the program counter that triggered the replacement.
+       context..........the context (machine state) to which the
+                           replacement should be applied.
+
+   OUT:
+       context..........the context after replacement finished.
+
+   RETURN VALUE:
+       true.............replacement done, everything went ok
+       false............no replacement done, context unchanged
+
+*******************************************************************************/
+
+bool replace_me_wrapper(u1 *pc, void *context)
+{
+       codeinfo         *code;
+       rplpoint         *rp;
+       executionstate_t  es;
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_end;
+#endif
+
+       /* search the codeinfo for the given PC */
+
+       code = code_find_codeinfo_for_pc(pc);
+       assert(code);
+
+       /* search for a replacement point at the given PC */
+
+       rp = replace_find_replacement_point_for_pc(code, pc, (RPLPOINT_FLAG_ACTIVE | RPLPOINT_FLAG_COUNTDOWN));
+
+       /* check if the replacement point belongs to given PC and is active */
+
+       if ((rp != NULL) && (rp->pc == pc)
+           && (rp->flags & (RPLPOINT_FLAG_ACTIVE | RPLPOINT_FLAG_COUNTDOWN))) {
+
+               DOLOG( printf("valid replacement point\n"); );
+
+#if !defined(NDEBUG)
+               executionstate_sanity_check(context);
+#endif
+
+               /* set codeinfo pointer in execution state */
+
+               es.code = code;
+
+               /* read execution state from current context */
+
+               md_executionstate_read(&es, context);
+
+               DOLOG( printf("REPLACEMENT READ: ");
+                          executionstate_println(&es); );
+
+               /* do the actual replacement */
+
+#if defined(ENABLE_RT_TIMING)
+               RT_TIMING_GET_TIME(time_start);
+#endif
+
+               replace_me(rp, &es);
+
+#if defined(ENABLE_RT_TIMING)
+               RT_TIMING_GET_TIME(time_end);
+               RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_REPLACE);
+#endif
+
+               /* write execution state to current context */
+
+               md_executionstate_write(&es, context);
+
+               DOLOG( printf("REPLACEMENT WRITE: ");
+                          executionstate_println(&es); );
+
+               /* new code is entered after returning */
+
+               DOLOG( printf("JUMPING IN!\n"); fflush(stdout); );
+               return true;
+       }
+       else
+               return false;
+}
+
+
+/******************************************************************************/
+/* NOTE: Stuff specific to the exact GC is below.                             */
+/******************************************************************************/
+
+#if defined(ENABLE_GC_CACAO)
+void replace_gc_from_native(threadobject *thread, u1 *pc, u1 *sp)
+{
+       stackframeinfo_t *sfi;
+       executionstate_t *es;
+       sourcestate_t    *ss;
+
+       /* Get the stackframeinfo of this thread. */
+
+       assert(thread == THREADOBJECT);
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* create the execution state */
+       es = (executionstate_t*) DumpMemory::allocate(sizeof(executionstate_t));
+       es->pc = pc;
+       es->sp = sp;
+       es->pv = 0;      /* since we are in a native, PV is invalid! */
+       es->code = NULL; /* since we are in a native, we do not have a codeinfo */
+
+       /* we assume we are in a native (no replacement point)! */
+       ss = replace_recover_source_state(NULL, sfi, es);
+
+       /* map the sourcestate using the identity mapping */
+       replace_map_source_state_identity(ss);
+
+       /* remember executionstate and sourcestate for this thread */
+       GC_EXECUTIONSTATE = es;
+       GC_SOURCESTATE    = ss;
+}
+#endif
+
+#if defined(ENABLE_GC_CACAO)
+void replace_gc_into_native(threadobject *thread)
+{
+       executionstate_t *es;
+       sourcestate_t    *ss;
+
+       /* get the executionstate and sourcestate for the given thread */
+       es = GC_EXECUTIONSTATE;
+       ss = GC_SOURCESTATE;
+
+       /* rebuild the stack of the given thread */
+       replace_build_execution_state(ss, es);
+}
+#endif
+
+
+/******************************************************************************/
+/* NOTE: No important code below.                                             */
+/******************************************************************************/
+
+
+/* statistics *****************************************************************/
+
+#if defined(REPLACE_STATISTICS)
+static void print_freq(FILE *file,int *array,int limit)
+{
+       int i;
+       int sum = 0;
+       int cum = 0;
+       for (i=0; i<limit; ++i)
+               sum += array[i];
+       sum += array[limit];
+       for (i=0; i<limit; ++i) {
+               cum += array[i];
+               fprintf(file,"      %3d: %8d (cum %3d%%)\n",
+                               i, array[i], (sum) ? ((100*cum)/sum) : 0);
+       }
+       fprintf(file,"    >=%3d: %8d\n",limit,array[limit]);
+}
+#endif /* defined(REPLACE_STATISTICS) */
+
+
+#if defined(REPLACE_STATISTICS)
+
+#define REPLACE_PRINT_DIST(name, array)                              \
+    printf("    " name " distribution:\n");                          \
+    print_freq(stdout, (array), sizeof(array)/sizeof(int) - 1);
+
+void replace_print_statistics(void)
+{
+       printf("replacement statistics:\n");
+       printf("    # of replacements:   %d\n", stat_replacements);
+       printf("    # of frames:         %d\n", stat_frames);
+       printf("    # of recompilations: %d\n", stat_recompile);
+       printf("    patched static calls:%d\n", stat_staticpatch);
+       printf("    unrolled inlines:    %d\n", stat_unroll_inline);
+       printf("    unrolled calls:      %d\n", stat_unroll_call);
+       REPLACE_PRINT_DIST("frame depth", stat_dist_frames);
+       REPLACE_PRINT_DIST("locals per frame", stat_dist_locals);
+       REPLACE_PRINT_DIST("ADR locals per frame", stat_dist_locals_adr);
+       REPLACE_PRINT_DIST("primitive locals per frame", stat_dist_locals_prim);
+       REPLACE_PRINT_DIST("RET locals per frame", stat_dist_locals_ret);
+       REPLACE_PRINT_DIST("void locals per frame", stat_dist_locals_void);
+       REPLACE_PRINT_DIST("stack slots per frame", stat_dist_stack);
+       REPLACE_PRINT_DIST("ADR stack slots per frame", stat_dist_stack_adr);
+       REPLACE_PRINT_DIST("primitive stack slots per frame", stat_dist_stack_prim);
+       REPLACE_PRINT_DIST("RET stack slots per frame", stat_dist_stack_ret);
+       printf("\n");
+       printf("    # of methods:            %d\n", stat_methods);
+       printf("    # of replacement points: %d\n", stat_rploints);
+       printf("    # of regallocs:          %d\n", stat_regallocs);
+       printf("        per rplpoint:        %f\n", (double)stat_regallocs / stat_rploints);
+       printf("        per method:          %f\n", (double)stat_regallocs / stat_methods);
+       REPLACE_PRINT_DIST("replacement points per method", stat_dist_method_rplpoints);
+       printf("\n");
+
+}
+#endif /* defined(REPLACE_STATISTICS) */
+
+
+#if defined(REPLACE_STATISTICS)
+static void replace_statistics_source_frame(sourceframe_t *frame)
+{
+       int adr = 0;
+       int ret = 0;
+       int prim = 0;
+       int vd = 0;
+       int n = 0;
+       int i;
+
+       for (i=0; i<frame->javalocalcount; ++i) {
+               switch (frame->javalocaltype[i]) {
+                       case TYPE_ADR: adr++; break;
+                       case TYPE_RET: ret++; break;
+                       case TYPE_INT: case TYPE_LNG: case TYPE_FLT: case TYPE_DBL: prim++; break;
+                       case TYPE_VOID: vd++; break;
+                       default: assert(0);
+               }
+               n++;
+       }
+       REPLACE_COUNT_DIST(stat_dist_locals, n);
+       REPLACE_COUNT_DIST(stat_dist_locals_adr, adr);
+       REPLACE_COUNT_DIST(stat_dist_locals_void, vd);
+       REPLACE_COUNT_DIST(stat_dist_locals_ret, ret);
+       REPLACE_COUNT_DIST(stat_dist_locals_prim, prim);
+       adr = ret = prim = n = 0;
+       for (i=0; i<frame->javastackdepth; ++i) {
+               switch (frame->javastacktype[i]) {
+                       case TYPE_ADR: adr++; break;
+                       case TYPE_RET: ret++; break;
+                       case TYPE_INT: case TYPE_LNG: case TYPE_FLT: case TYPE_DBL: prim++; break;
+               }
+               n++;
+       }
+       REPLACE_COUNT_DIST(stat_dist_stack, n);
+       REPLACE_COUNT_DIST(stat_dist_stack_adr, adr);
+       REPLACE_COUNT_DIST(stat_dist_stack_ret, ret);
+       REPLACE_COUNT_DIST(stat_dist_stack_prim, prim);
+}
+#endif /* defined(REPLACE_STATISTICS) */
+
+
+/* debugging helpers **********************************************************/
+
+/* replace_replacement_point_println *******************************************
+   Print replacement point info.
+  
+   IN:
+       rp...............the replacement point to print
+  
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+
+#define TYPECHAR(t)  (((t) >= 0 && (t) <= TYPE_RET) ? show_jit_type_letters[t] : '?')
+
+static const char *replace_type_str[] = {
+       "STD",
+       "EXH",
+       "SBR",
+       "CALL",
+       "INLINE",
+       "RETURN",
+       "BODY"
+};
+
+void replace_replacement_point_println(rplpoint *rp, int depth)
+{
+       int j;
+       int index;
+
+       if (!rp) {
+               printf("(rplpoint *)NULL\n");
+               return;
+       }
+
+       for (j=0; j<depth; ++j)
+               putchar('\t');
+
+       printf("rplpoint (id %d) %p pc:%p+%d type:%s",
+                       rp->id, (void*)rp,rp->pc,rp->callsize,
+                       replace_type_str[rp->type]);
+       if (rp->flags & RPLPOINT_FLAG_NOTRAP)
+               printf(" NOTRAP");
+       if (rp->flags & RPLPOINT_FLAG_COUNTDOWN)
+               printf(" COUNTDOWN");
+       if (rp->flags & RPLPOINT_FLAG_ACTIVE)
+               printf(" ACTIVE");
+       printf(" parent:%p\n", (void*)rp->parent);
+       for (j=0; j<depth; ++j)
+               putchar('\t');
+       printf("ra:%d = [",     rp->regalloccount);
+
+       for (j=0; j<rp->regalloccount; ++j) {
+               if (j)
+                       putchar(' ');
+               index = rp->regalloc[j].index;
+               switch (index) {
+                       case RPLALLOC_STACK: printf("S"); break;
+                       case RPLALLOC_PARAM: printf("P"); break;
+                       case RPLALLOC_SYNC : printf("Y"); break;
+                       default: printf("%d", index);
+               }
+               printf(":%1c:", TYPECHAR(rp->regalloc[j].type));
+               if (rp->regalloc[j].type == TYPE_RET) {
+                       printf("ret(L%03d)", rp->regalloc[j].regoff);
+               }
+               else {
+                       show_allocation(rp->regalloc[j].type, rp->regalloc[j].flags, rp->regalloc[j].regoff);
+               }
+       }
+
+       printf("]\n");
+       for (j=0; j<depth; ++j)
+               putchar('\t');
+       printf("method: ");
+       method_print(rp->method);
+
+       printf("\n");
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* replace_show_replacement_points *********************************************
+   Print replacement point info.
+  
+   IN:
+       code.............codeinfo whose replacement points should be printed.
+  
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void replace_show_replacement_points(codeinfo *code)
+{
+       int i;
+       int depth;
+       rplpoint *rp;
+       rplpoint *parent;
+
+       if (!code) {
+               printf("(codeinfo *)NULL\n");
+               return;
+       }
+
+       printf("\treplacement points: %d\n",code->rplpointcount);
+
+       printf("\ttotal allocations : %d\n",code->regalloccount);
+       printf("\tsaved int regs    : %d\n",code->savedintcount);
+       printf("\tsaved flt regs    : %d\n",code->savedfltcount);
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+       printf("\tsaved adr regs    : %d\n",code->savedadrcount);
+#endif
+       printf("\tmemuse            : %d\n",code->memuse);
+
+       printf("\n");
+
+       for (i=0; i<code->rplpointcount; ++i) {
+               rp = code->rplpoints + i;
+
+               depth = 1;
+               parent = rp->parent;
+               while (parent) {
+                       depth++;
+                       parent = parent->parent;
+               }
+               replace_replacement_point_println(rp, depth);
+       }
+}
+#endif
+
+
+#if !defined(NDEBUG)
+static void java_value_print(s4 type, replace_val_t value)
+{
+       java_object_t *obj;
+       utf           *u;
+
+       printf("%016llx",(unsigned long long) value.l);
+
+       if (type < 0 || type > TYPE_RET)
+               printf(" <INVALID TYPE:%d>", type);
+       else
+               printf(" %s", show_jit_type_names[type]);
+
+       if (type == TYPE_ADR && value.a != NULL) {
+               obj = value.a;
+               putchar(' ');
+               utf_display_printable_ascii_classname(obj->vftbl->clazz->name);
+
+               if (obj->vftbl->clazz == class_java_lang_String) {
+                       printf(" \"");
+                       u = javastring_toutf(obj, false);
+                       utf_display_printable_ascii(u);
+                       printf("\"");
+               }
+       }
+       else if (type == TYPE_INT) {
+               printf(" %ld", (long) value.i);
+       }
+       else if (type == TYPE_LNG) {
+               printf(" %lld", (long long) value.l);
+       }
+       else if (type == TYPE_FLT) {
+               printf(" %f", value.f);
+       }
+       else if (type == TYPE_DBL) {
+               printf(" %f", value.d);
+       }
+}
+#endif /* !defined(NDEBUG) */
+
+
+#if !defined(NDEBUG)
+void replace_source_frame_println(sourceframe_t *frame)
+{
+       s4 i,j;
+       s4 t;
+
+       if (REPLACE_IS_NATIVE_FRAME(frame)) {
+               printf("\tNATIVE\n");
+               printf("\tsfi: "); replace_stackframeinfo_println(frame->sfi);
+               printf("\tnativepc: %p\n", frame->nativepc);
+               printf("\tframesize: %d\n", frame->nativeframesize);
+
+               j = 0;
+               for (i=0; i<INT_REG_CNT; ++i) {
+                       if (nregdescint[i] == REG_SAV)
+                               printf("\t%s = %p\n", abi_registers_integer_name[i], (void*)frame->nativesavint[j++]);
+               }
+
+               j = 0;
+               for (i=0; i<FLT_REG_CNT; ++i) {
+                       if (nregdescfloat[i] == REG_SAV)
+                               printf("\tF%02d = %f\n", i, frame->nativesavflt[j++]);
+               }
+
+               printf("\n");
+               return;
+       }
+
+       printf("\t");
+       method_println(frame->method);
+       printf("\tid: %d\n", frame->id);
+       printf("\ttype: %s\n", replace_type_str[frame->type]);
+       printf("\n");
+
+       if (frame->instance.a) {
+               printf("\tinstance: ");
+               java_value_print(TYPE_ADR, frame->instance);
+               printf("\n");
+       }
+
+       if (frame->javalocalcount) {
+               printf("\tlocals (%d):\n",frame->javalocalcount);
+               for (i=0; i<frame->javalocalcount; ++i) {
+                       t = frame->javalocaltype[i];
+                       if (t == TYPE_VOID) {
+                               printf("\tlocal[ %2d] = void\n",i);
+                       }
+                       else {
+                               printf("\tlocal[%c%2d] = ",TYPECHAR(t),i);
+                               java_value_print(t, frame->javalocals[i]);
+                               printf("\n");
+                       }
+               }
+               printf("\n");
+       }
+
+       if (frame->javastackdepth) {
+               printf("\tstack (depth %d):\n",frame->javastackdepth);
+               for (i=0; i<frame->javastackdepth; ++i) {
+                       t = frame->javastacktype[i];
+                       if (t == TYPE_VOID) {
+                               printf("\tstack[%2d] = void", i);
+                       }
+                       else {
+                               printf("\tstack[%2d] = ",i);
+                               java_value_print(frame->javastacktype[i], frame->javastack[i]);
+                               printf("\n");
+                       }
+               }
+               printf("\n");
+       }
+
+       if (frame->syncslotcount) {
+               printf("\tsynchronization slots (%d):\n",frame->syncslotcount);
+               for (i=0; i<frame->syncslotcount; ++i) {
+                       printf("\tslot[%2d] = %016llx\n",i,(unsigned long long) frame->syncslots[i].p);
+               }
+               printf("\n");
+       }
+
+       if (frame->fromcode) {
+               printf("\tfrom %p ", (void*)frame->fromcode);
+               method_println(frame->fromcode->m);
+       }
+       if (frame->tocode) {
+               printf("\tto %p ", (void*)frame->tocode);
+               method_println(frame->tocode->m);
+       }
+
+       if (frame->fromrp) {
+               printf("\tfrom replacement point:\n");
+               replace_replacement_point_println(frame->fromrp, 2);
+       }
+       if (frame->torp) {
+               printf("\tto replacement point:\n");
+               replace_replacement_point_println(frame->torp, 2);
+       }
+
+       printf("\n");
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* replace_sourcestate_println *************************************************
+   Print source state
+  
+   IN:
+       ss...............the source state to print
+  
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void replace_sourcestate_println(sourcestate_t *ss)
+{
+       int i;
+       sourceframe_t *frame;
+
+       if (!ss) {
+               printf("(sourcestate_t *)NULL\n");
+               return;
+       }
+
+       printf("sourcestate_t:\n");
+
+       for (i=0, frame = ss->frames; frame != NULL; frame = frame->down, ++i) {
+               printf("    frame %d:\n", i);
+               replace_source_frame_println(frame);
+       }
+}
+#endif
+
+
+/* replace_sourcestate_println_short *******************************************
+
+   Print a compact representation of the given source state.
+
+   IN:
+       ss...............the source state to print
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void replace_sourcestate_println_short(sourcestate_t *ss)
+{
+       sourceframe_t *frame;
+
+       for (frame = ss->frames; frame != NULL; frame = frame->down) {
+               printf("\t");
+
+               if (REPLACE_IS_NATIVE_FRAME(frame)) {
+                       printf("NATIVE (pc %p size %d) ",
+                                  (void*)frame->nativepc, frame->nativeframesize);
+                       replace_stackframeinfo_println(frame->sfi);
+                       continue;
+               }
+
+               if (frame->torp) {
+                       printf("%c", (frame->torp == frame->fromrp) ? '=' : '+');
+               }
+
+               printf("%s", replace_type_str[frame->fromrp->type]);
+
+               if (frame->torp && frame->torp->type != frame->fromrp->type)
+                       printf("->%s", replace_type_str[frame->torp->type]);
+
+               if (frame->tocode != frame->fromcode)
+                       printf(" (%p->%p/%d) ",
+                                  (void*) frame->fromcode, (void*) frame->tocode,
+                                  frame->fromrp->id);
+               else
+                       printf(" (%p/%d) ", (void*) frame->fromcode, frame->fromrp->id);
+
+               method_println(frame->method);
+       }
+}
+#endif
+
+#if !defined(NDEBUG)
+static void replace_stackframeinfo_println(stackframeinfo_t *sfi)
+{
+       printf("prev=%p pv=%p sp=%p ra=%p xpc=%p method=",
+                       (void*)sfi->prev, (void*)sfi->pv, (void*)sfi->sp,
+                       (void*)sfi->ra, (void*)sfi->xpc);
+
+       if (sfi->code)
+               method_println(sfi->code->m);
+       else
+               printf("(nil)\n");
+}
+#endif
+
+
+/*
+ * 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/jit/replace.h b/src/vm/jit/replace.h
deleted file mode 100644 (file)
index 752cd38..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/* src/vm/jit/replace.h - on-stack replacement of methods
-
-   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
-
-   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 _REPLACE_H
-#define _REPLACE_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#if !defined(ENABLE_REPLACEMENT)
-
-/*** macros for the codegens (disabled version) ************************/
-
-#define REPLACEMENT_POINTS_INIT(cd, jd)
-#define REPLACEMENT_POINTS_RESET(cd, jd)
-#define REPLACEMENT_POINT_BLOCK_START(cd, bptr)
-#define REPLACEMENT_POINT_INLINE_START(cd, iptr)
-#define REPLACEMENT_POINT_INLINE_BODY(cd, iptr)
-#define REPLACEMENT_POINT_RETURN(cd, iptr)
-#define REPLACEMENT_POINT_INVOKE(cd, iptr)
-#define REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr)
-#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr)
-#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr)
-
-#else /* defined(ENABLE_REPLACEMENT) */
-
-/* forward typedefs ***********************************************************/
-
-typedef struct rplalloc rplalloc;
-typedef struct rplpoint rplpoint;
-typedef struct sourcestate_t sourcestate_t;
-typedef struct sourceframe_t sourceframe_t;
-typedef union  replace_val_t replace_val_t;
-
-#include "arch.h"
-#include "md-abi.h"
-
-#include "vm/jit/reg.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/method.h"
-
-
-/*** structs *********************************************************/
-
-#define RPLALLOC_STACK  -1
-#define RPLALLOC_PARAM  -2
-#define RPLALLOC_SYNC   -3
-
-/* `rplalloc` is a compact struct for register allocation info        */
-
-/* XXX optimize this for space efficiency */
-struct rplalloc {
-       s4           index;     /* local index, -1 for stack slot         */
-       s4           regoff;    /* register index / stack slot offset     */
-       unsigned int flags:4;   /* OR of (INMEMORY,...)                   */
-       unsigned int type:4;    /* TYPE_... constant                      */
-};
-
-#if INMEMORY > 0x08
-#error value of INMEMORY is too big to fit in rplalloc.flags
-#endif
-
-
-/* XXX what to do about overlapping rplpoints? */
-/* CAUTION: Do not change the numerical values. These are used as     */
-/*          indices into replace_normalize_type_map.                  */
-#define RPLPOINT_TYPE_STD     BBTYPE_STD
-#define RPLPOINT_TYPE_EXH     BBTYPE_EXH
-#define RPLPOINT_TYPE_SBR     BBTYPE_SBR
-#define RPLPOINT_TYPE_CALL    3
-#define RPLPOINT_TYPE_INLINE  4
-#define RPLPOINT_TYPE_RETURN  5
-#define RPLPOINT_TYPE_BODY    6
-
-#define RPLPOINT_FLAG_NOTRAP     0x01  /* rplpoint cannot be trapped */
-#define RPLPOINT_FLAG_COUNTDOWN  0x02  /* count down hits            */
-#define RPLPOINT_FLAG_ACTIVE     0x08  /* trap is active             */
-
-
-#if !defined(NDEBUG)
-#define RPLPOINT_CHECK(type)     , RPLPOINT_TYPE_##type
-#define RPLPOINT_CHECK_BB(bptr)  , (bptr)->type
-#else
-#define RPLPOINT_CHECK(type)
-#define RPLPOINT_CHECK_BB(bptr)
-#endif
-
-
-/* An `rplpoint` represents a replacement point in a compiled method  */
-
-struct rplpoint {
-       u1          *pc;           /* machine code PC of this point       */
-       methodinfo  *method;       /* source method this point is in      */
-       rplpoint    *parent;       /* rplpoint of the inlined body        */ /* XXX unify with code */
-       rplalloc    *regalloc;     /* pointer to register index table     */
-       s4           id;           /* id of the rplpoint within method    */
-       s4           callsize;     /* size of call code in bytes          */
-       unsigned int regalloccount:20; /* number of local allocations     */
-       unsigned int type:4;           /* RPLPOINT_TYPE_... constant      */
-       unsigned int flags:8;          /* OR of RPLPOINT_... constants    */
-};
-
-
-union replace_val_t {
-       s4             i;
-       s8             l;
-       ptrint         p;
-       struct {
-               u4 lo;
-               u4 hi;
-       }              words;
-       float          f;
-       double         d;
-       java_object_t *a;
-};
-
-
-       u1           *ra;                /* return address / link register */
-struct sourceframe_t {
-       sourceframe_t *down;           /* source frame down the call chain */
-
-       methodinfo    *method;                  /* method this frame is in */
-       s4             id;
-       s4             type;
-
-       /* values */
-       replace_val_t  instance;
-
-       replace_val_t *javastack;                  /* values of stack vars */
-       u1            *javastacktype;              /*  types of stack vars */
-       s4             javastackdepth;             /* number of stack vars */
-
-       replace_val_t *javalocals;                 /* values of javalocals */
-       u1            *javalocaltype;              /*  types of javalocals */
-       s4             javalocalcount;             /* number of javalocals */
-
-       replace_val_t *syncslots;
-       s4             syncslotcount; /* XXX do we need more than one? */
-
-       /* mapping info */
-       rplpoint      *fromrp;         /* rplpoint used to read this frame */
-       codeinfo      *fromcode;              /* code this frame was using */
-       rplpoint      *torp;          /* rplpoint this frame was mapped to */
-       codeinfo      *tocode;            /* code this frame was mapped to */
-
-       /* info for native frames */
-       stackframeinfo_t *sfi;      /* sfi for native frames, otherwise NULL */
-       s4             nativeframesize;    /* size (bytes) of native frame */
-       u1            *nativepc;
-       ptrint         nativesavint[INT_SAV_CNT]; /* XXX temporary */
-       double         nativesavflt[FLT_REG_CNT]; /* XXX temporary */
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-       ptrint         nativesavadr[ADR_SAV_CNT]; /* XXX temporary */
-#endif
-};
-
-#define REPLACE_IS_NATIVE_FRAME(frame)  ((frame)->sfi != NULL)
-#define REPLACE_IS_JAVA_FRAME(frame)    ((frame)->sfi == NULL)
-
-
-struct sourcestate_t {
-       sourceframe_t *frames;    /* list of source frames, from bottom up */
-};
-
-
-/*** macros for the codegens *******************************************/
-
-#define REPLACEMENT_POINTS_INIT(cd, jd)                              \
-    if (!replace_create_replacement_points(jd))                      \
-        return false;                                                \
-    (cd)->replacementpoint = (jd)->code->rplpoints;
-
-#define REPLACEMENT_POINTS_RESET(cd, jd)                             \
-    (cd)->replacementpoint = (jd)->code->rplpoints;
-
-#define REPLACEMENT_POINT_BLOCK_START(cd, bptr)                      \
-    if ((bptr)->bitflags & BBFLAG_REPLACEMENT)                       \
-        codegen_set_replacement_point((cd) RPLPOINT_CHECK_BB(bptr));
-
-#define REPLACEMENT_POINT_INLINE_START(cd, iptr)                     \
-    codegen_set_replacement_point(cd RPLPOINT_CHECK(INLINE));
-
-#define REPLACEMENT_POINT_INLINE_BODY(cd, iptr)                      \
-    codegen_set_replacement_point_notrap(cd RPLPOINT_CHECK(BODY));
-
-#define REPLACEMENT_POINT_RETURN(cd, iptr)                           \
-    codegen_set_replacement_point(cd RPLPOINT_CHECK(RETURN));
-
-#define REPLACEMENT_POINT_INVOKE(cd, iptr)                           \
-    codegen_set_replacement_point(cd RPLPOINT_CHECK(CALL));
-
-#define REPLACEMENT_POINT_INVOKE_RETURN(cd,  iptr)                   \
-    if (iptr->opc != ICMD_BUILTIN)                                   \
-        cd->replacementpoint[-1].callsize = (cd->mcodeptr - cd->mcodebase)\
-                    - (ptrint) cd->replacementpoint[-1].pc;
-
-
-/*** macros for the codegens (for GC) **********************************/
-
-#if defined(ENABLE_GC_CACAO)
-
-#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr)                    \
-       codegen_set_replacement_point(cd RPLPOINT_CHECK(CALL));
-
-#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr)             \
-       if (iptr->opc == ICMD_BUILTIN)                                   \
-               cd->replacementpoint[-1].callsize = (cd->mcodeptr - cd->mcodebase)\
-                                       - (ptrint) cd->replacementpoint[-1].pc;
-
-#else /* defined(ENABLE_GC_CACAO) */
-
-#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr)
-#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr)
-
-#endif /* defined(ENABLE_GC_CACAO) */
-
-
-/*** prototypes ********************************************************/
-
-bool replace_create_replacement_points(jitdata *jd);
-void replace_free_replacement_points(codeinfo *code);
-
-void replace_activate_replacement_points(codeinfo *code, bool mappable);
-void replace_deactivate_replacement_points(codeinfo *code);
-
-bool replace_me_wrapper(u1 *pc, void *context);
-
-#if !defined(NDEBUG)
-void replace_show_replacement_points(codeinfo *code);
-void replace_replacement_point_println(rplpoint *rp, int depth);
-void replace_sourcestate_println(sourcestate_t *ss);
-void replace_sourcestate_println_short(sourcestate_t *ss);
-void replace_source_frame_println(sourceframe_t *frame);
-#endif
-
-/* machine dependent functions (code in ARCH_DIR/md.c) */
-
-#if defined(ENABLE_JIT)
-void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert);
-#endif
-
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-#endif /* _REPLACE_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/jit/replace.hpp b/src/vm/jit/replace.hpp
new file mode 100644 (file)
index 0000000..5c520d5
--- /dev/null
@@ -0,0 +1,289 @@
+/* src/vm/jit/replace.hpp - on-stack replacement of methods
+
+   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 _REPLACE_HPP
+#define _REPLACE_HPP
+
+#include "config.h"
+#include "vm/types.h"
+
+#if !defined(ENABLE_REPLACEMENT)
+
+/*** macros for the codegens (disabled version) ************************/
+
+#define REPLACEMENT_POINTS_INIT(cd, jd)
+#define REPLACEMENT_POINTS_RESET(cd, jd)
+#define REPLACEMENT_POINT_BLOCK_START(cd, bptr)
+#define REPLACEMENT_POINT_INLINE_START(cd, iptr)
+#define REPLACEMENT_POINT_INLINE_BODY(cd, iptr)
+#define REPLACEMENT_POINT_RETURN(cd, iptr)
+#define REPLACEMENT_POINT_INVOKE(cd, iptr)
+#define REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr)
+#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr)
+#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr)
+
+#else /* defined(ENABLE_REPLACEMENT) */
+
+/* forward typedefs ***********************************************************/
+
+typedef struct rplalloc rplalloc;
+typedef struct rplpoint rplpoint;
+typedef struct sourcestate_t sourcestate_t;
+typedef struct sourceframe_t sourceframe_t;
+typedef union  replace_val_t replace_val_t;
+
+#include "arch.h"
+#include "md-abi.h"
+
+#include "vm/method.hpp"
+
+#include "vm/jit/reg.h"
+#include "vm/jit/stacktrace.hpp"
+
+
+/*** structs *********************************************************/
+
+#define RPLALLOC_STACK  -1
+#define RPLALLOC_PARAM  -2
+#define RPLALLOC_SYNC   -3
+
+/* `rplalloc` is a compact struct for register allocation info        */
+
+/* XXX optimize this for space efficiency */
+struct rplalloc {
+       s4           index;     /* local index, -1 for stack slot         */
+       s4           regoff;    /* register index / stack slot offset     */
+       unsigned int flags:4;   /* OR of (INMEMORY,...)                   */
+       unsigned int type:4;    /* TYPE_... constant                      */
+};
+
+#if INMEMORY > 0x08
+#error value of INMEMORY is too big to fit in rplalloc.flags
+#endif
+
+
+/* XXX what to do about overlapping rplpoints? */
+/* CAUTION: Do not change the numerical values. These are used as     */
+/*          indices into replace_normalize_type_map.                  */
+#define RPLPOINT_TYPE_STD     BBTYPE_STD
+#define RPLPOINT_TYPE_EXH     BBTYPE_EXH
+#define RPLPOINT_TYPE_SBR     BBTYPE_SBR
+#define RPLPOINT_TYPE_CALL    3
+#define RPLPOINT_TYPE_INLINE  4
+#define RPLPOINT_TYPE_RETURN  5
+#define RPLPOINT_TYPE_BODY    6
+
+#define RPLPOINT_FLAG_NOTRAP     0x01  /* rplpoint cannot be trapped */
+#define RPLPOINT_FLAG_COUNTDOWN  0x02  /* count down hits            */
+#define RPLPOINT_FLAG_ACTIVE     0x08  /* trap is active             */
+
+
+#if !defined(NDEBUG)
+#define RPLPOINT_CHECK(type)     , RPLPOINT_TYPE_##type
+#define RPLPOINT_CHECK_BB(bptr)  , (bptr)->type
+#else
+#define RPLPOINT_CHECK(type)
+#define RPLPOINT_CHECK_BB(bptr)
+#endif
+
+
+/* An `rplpoint` represents a replacement point in a compiled method  */
+
+struct rplpoint {
+       u1          *pc;           /* machine code PC of this point       */
+       methodinfo  *method;       /* source method this point is in      */
+       rplpoint    *parent;       /* rplpoint of the inlined body        */ /* XXX unify with code */
+       rplalloc    *regalloc;     /* pointer to register index table     */
+       s4           id;           /* id of the rplpoint within method    */
+       s4           callsize;     /* size of call code in bytes          */
+       unsigned int regalloccount:20; /* number of local allocations     */
+       unsigned int type:4;           /* RPLPOINT_TYPE_... constant      */
+       unsigned int flags:8;          /* OR of RPLPOINT_... constants    */
+};
+
+
+union replace_val_t {
+       s4             i;
+       s8             l;
+       ptrint         p;
+       struct {
+               u4 lo;
+               u4 hi;
+       }              words;
+       float          f;
+       double         d;
+       java_object_t *a;
+};
+
+
+struct sourceframe_t {
+       sourceframe_t *down;           /* source frame down the call chain */
+
+       methodinfo    *method;                  /* method this frame is in */
+       s4             id;
+       s4             type;
+
+       /* values */
+       replace_val_t  instance;
+
+       replace_val_t *javastack;                  /* values of stack vars */
+       u1            *javastacktype;              /*  types of stack vars */
+       s4             javastackdepth;             /* number of stack vars */
+
+       replace_val_t *javalocals;                 /* values of javalocals */
+       u1            *javalocaltype;              /*  types of javalocals */
+       s4             javalocalcount;             /* number of javalocals */
+
+       replace_val_t *syncslots;
+       s4             syncslotcount; /* XXX do we need more than one? */
+
+       /* mapping info */
+       rplpoint      *fromrp;         /* rplpoint used to read this frame */
+       codeinfo      *fromcode;              /* code this frame was using */
+       rplpoint      *torp;          /* rplpoint this frame was mapped to */
+       codeinfo      *tocode;            /* code this frame was mapped to */
+
+       /* info for native frames */
+       stackframeinfo_t *sfi;      /* sfi for native frames, otherwise NULL */
+       s4             nativeframesize;    /* size (bytes) of native frame */
+       u1            *nativepc;
+       ptrint         nativesavint[INT_SAV_CNT]; /* XXX temporary */
+       double         nativesavflt[FLT_REG_CNT]; /* XXX temporary */
+#if defined(HAS_ADDRESS_REGISTER_FILE)
+       ptrint         nativesavadr[ADR_SAV_CNT]; /* XXX temporary */
+#endif
+};
+
+#define REPLACE_IS_NATIVE_FRAME(frame)  ((frame)->sfi != NULL)
+#define REPLACE_IS_JAVA_FRAME(frame)    ((frame)->sfi == NULL)
+
+
+struct sourcestate_t {
+       sourceframe_t *frames;    /* list of source frames, from bottom up */
+};
+
+
+/*** macros for the codegens *******************************************/
+
+#define REPLACEMENT_POINTS_INIT(cd, jd)                              \
+    if (!replace_create_replacement_points(jd))                      \
+        return false;                                                \
+    (cd)->replacementpoint = (jd)->code->rplpoints;
+
+#define REPLACEMENT_POINTS_RESET(cd, jd)                             \
+    (cd)->replacementpoint = (jd)->code->rplpoints;
+
+#define REPLACEMENT_POINT_BLOCK_START(cd, bptr)                      \
+    if ((bptr)->bitflags & BBFLAG_REPLACEMENT)                       \
+        codegen_set_replacement_point((cd) RPLPOINT_CHECK_BB(bptr));
+
+#define REPLACEMENT_POINT_INLINE_START(cd, iptr)                     \
+    codegen_set_replacement_point(cd RPLPOINT_CHECK(INLINE));
+
+#define REPLACEMENT_POINT_INLINE_BODY(cd, iptr)                      \
+    codegen_set_replacement_point_notrap(cd RPLPOINT_CHECK(BODY));
+
+#define REPLACEMENT_POINT_RETURN(cd, iptr)                           \
+    codegen_set_replacement_point(cd RPLPOINT_CHECK(RETURN));
+
+#define REPLACEMENT_POINT_INVOKE(cd, iptr)                           \
+    codegen_set_replacement_point(cd RPLPOINT_CHECK(CALL));
+
+#define REPLACEMENT_POINT_INVOKE_RETURN(cd,  iptr)                   \
+    if (iptr->opc != ICMD_BUILTIN)                                   \
+        cd->replacementpoint[-1].callsize = (cd->mcodeptr - cd->mcodebase)\
+                    - (ptrint) cd->replacementpoint[-1].pc;
+
+
+/*** macros for the codegens (for GC) **********************************/
+
+#if defined(ENABLE_GC_CACAO)
+
+#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr)                    \
+       codegen_set_replacement_point(cd RPLPOINT_CHECK(CALL));
+
+#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr)             \
+       if (iptr->opc == ICMD_BUILTIN)                                   \
+               cd->replacementpoint[-1].callsize = (cd->mcodeptr - cd->mcodebase)\
+                                       - (ptrint) cd->replacementpoint[-1].pc;
+
+#else // ENABLE_GC_CACAO
+
+#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr)
+#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr)
+
+#endif // ENABLE_GC_CACAO
+
+
+/*** prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool replace_create_replacement_points(jitdata *jd);
+void replace_free_replacement_points(codeinfo *code);
+
+void replace_activate_replacement_points(codeinfo *code, bool mappable);
+void replace_deactivate_replacement_points(codeinfo *code);
+
+bool replace_me_wrapper(u1 *pc, void *context);
+
+#if !defined(NDEBUG)
+void replace_show_replacement_points(codeinfo *code);
+void replace_replacement_point_println(rplpoint *rp, int depth);
+void replace_sourcestate_println(sourcestate_t *ss);
+void replace_sourcestate_println_short(sourcestate_t *ss);
+void replace_source_frame_println(sourceframe_t *frame);
+#endif
+
+/* machine dependent functions (code in ARCH_DIR/md.c) */
+
+#if defined(ENABLE_JIT)
+void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ENABLE_REPLACEMENT
+
+#endif // _REPLACE_HPP
+
+
+/*
+ * 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 a9c16bd31a3ac1ae7e4da4f34928cd5eb28a5330..002ce18e8c3e5ead51b342003f0c852aceb47dad 100644 (file)
@@ -28,9 +28,9 @@ LIBS =
 
 noinst_HEADERS = \
        arch.h \
-       machine-instr.h \
        \
-       md-asm.h
+       md-asm.h \
+       md-atomic.hpp
 
 noinst_LTLIBRARIES = \
        libarch.la
@@ -51,6 +51,7 @@ libarch_la_SOURCES = \
        \
        md-abi.c \
        md-abi.h \
+       md-stubs.hpp \
        md-trap.h \
        md.c \
        md.h
index f09c7c8046b21695a5f9851bf06b48408e8fee29..002ba7f956db07116bfbffcb4dcdf4a397bb72fa 100644 (file)
@@ -33,8 +33,6 @@
 
 /* define architecture features ***********************************************/
 
-#define U8_AVAILABLE                     1
-
 #define SUPPORT_DIVISION                 1
 #define SUPPORT_LONG                     1
 
index 37de069008202e107531539eb15bcc3f068cf0a7..f69e661fb8f8a64fc5a4d8cccc5442923820b369 100644 (file)
 #include "vm/jit/s390/emit.h"
 #include "vm/jit/s390/md-abi.h"
 
-#include "native/jni.h"
-#include "native/localref.h"
-#include "native/native.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/statistics.h"
 #include "vm/types.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
 #if defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
 #endif
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/methodheader.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 
@@ -3003,9 +3000,6 @@ gen_method:
                                        supervftbl = super->vftbl;
                                }
 
-                               if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                                       CODEGEN_CRITICAL_SECTION_NEW;
-
                                s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                                /* if class is not resolved, check which code to call */
@@ -3083,8 +3077,6 @@ gen_method:
                                        }
 
 #if 1
-                                       CODEGEN_CRITICAL_SECTION_START;
-
                                        /* REG_ITMP3 := baseval(s1) */
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl));
                                        M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
@@ -3100,8 +3092,6 @@ gen_method:
                                        M_ALD_DSEG(REG_ITMP2, disp);
                                        M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 
-                                       CODEGEN_CRITICAL_SECTION_END;
-
                                        M_CMPU(REG_ITMP3, REG_ITMP2); /* Unsigned compare */
 
                                        /* M_CMPULE(REG_ITMP2, REG_ITMP3, REG_ITMP3); itmp3 = (itmp2 <= itmp3) */
@@ -3111,16 +3101,12 @@ gen_method:
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl));
                                        M_ALD_DSEG(REG_ITMP3, disp);
 
-                                       CODEGEN_CRITICAL_SECTION_START;
-
                                        M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                        M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, baseval));
                                        M_ISUB(REG_ITMP3, REG_ITMP2);
                                        M_ALD_DSEG(REG_ITMP3, disp);
                                        M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval));
 
-                                       CODEGEN_CRITICAL_SECTION_END;
-                                       
                                        M_CMPU(REG_ITMP2, REG_ITMP3); /* Unsigned compare */
                                        /* M_CMPULE(REG_ITMP2, REG_ITMP3, REG_ITMP3); itmp3 = (itmp2 <= itmp3) */
                                        /* M_BEQZ(REG_ITMP3, 0); branch if (! itmp) -> branch if > */
@@ -3223,9 +3209,6 @@ gen_method:
 #                      define LABEL_EXIT_INTERFACE_DONE BRANCH_LABEL_5
 #                      define LABEL_EXIT_CLASS_NULL BRANCH_LABEL_6
 
-                       if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                               CODEGEN_CRITICAL_SECTION_NEW;
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s1 == d) {
@@ -3327,14 +3310,10 @@ gen_method:
                                M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl));
                                M_ALD_DSEG(REG_ITMP2, disp);
 
-                               CODEGEN_CRITICAL_SECTION_START;
-
                                M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 
-                               CODEGEN_CRITICAL_SECTION_END;
-
                                M_ISUB(REG_ITMP3, REG_ITMP1); /* itmp1 :=  itmp1 (sub.baseval) - itmp3 (super.baseval) */
 
                                M_CMPU(REG_ITMP1, REG_ITMP2); /* d := (uint)REG_ITMP1 <= (uint)REG_ITMP2 */
@@ -3665,7 +3644,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
                /* put env into first argument register */
 
-               disp = dseg_add_address(cd, _Jv_env);
+               disp = dseg_add_address(cd, VM_get_jnienv());
                M_ALD_DSEG(REG_A0, disp);
        }
 
index 8cb750ac9e50340626144c4f53efead7f62ca56f..3e5262d459631f77cad2ac7bf499570b7a9d1f61 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/s390/codegen.h - code generation macros for s390
 
-   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.
 
@@ -34,7 +32,7 @@
 
 #include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* MCODECHECK(icnt) */
@@ -49,7 +47,6 @@
 
 #define PATCHER_CALL_SIZE    2          /* size in bytes of a patcher call    */
 #define PATCHER_NOPS M_NOP3
-#define PATCHER_NOPS_SKIP   2
 
 /* branch defines ************************************************************/
 
@@ -64,9 +61,6 @@
                } \
        } while (0) 
 
-/* stub defines **************************************************************/
-
-#define COMPILERSTUB_CODESIZE    (SZ_AHI + SZ_L + SZ_L + SZ_BCR)
 
 /* *** BIG TODO ***
  * Make all this inline functions !!!!!!!!!!
index 9ac259c71ff7dc7482dd32e287c9999803ea023e..ef5c2289c0135f08b54fb810b268fa5aa0ee566a 100644 (file)
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
 #include "vm/global.h"
 #include "vm/types.h"
+#include "vm/options.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/trace.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/options.h"
-
 
 /* emit_load *******************************************************************
 
diff --git a/src/vm/jit/s390/machine-instr.h b/src/vm/jit/s390/machine-instr.h
deleted file mode 100644 (file)
index b470961..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef _MACHINE_INSTR_H
-#define _MACHINE_INSTR_H
-
-/*  Taken from linux kernel source 
- *  include/asm-s390/atomic.h
- *
- *  S390 version
- *    Copyright (C) 1999-2005 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- *               Denis Joseph Barrow,
- *              Arnd Bergmann (arndb@de.ibm.com)
- *
- *  Derived from "include/asm-i386/bitops.h"
- *    Copyright (C) 1992, Linus Torvalds
- */
-
-static inline long
-compare_and_swap (volatile long *p, long oldval, long newval)
-{
-       __asm__ __volatile__("  cs   %0,%3,0(%2)\n"
-                            : "+d" (oldval), "=m" (*p)
-                            : "a" (p), "d" (newval), "m" (*p)
-                            : "cc", "memory" );
-       return oldval;
-}
-
-/*
- *  Taken from linux kerenl source
- *  include/asm-s390/system.h
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- *
- *  Derived from "include/asm-i386/system.h"
- */
-
-/*
- * Force strict CPU ordering.
- * And yes, this is required on UP too when we're talking
- * to devices.
- *
- * This is very similar to the ppc eieio/sync instruction in that is
- * does a checkpoint syncronisation & makes sure that 
- * all memory ops have completed wrt other CPU's ( see 7-15 POP  DJB ).
- */
-
-#define eieio()  __asm__ __volatile__ ( "bcr 15,0" : : : "memory" ) 
-
-#define STORE_ORDER_BARRIER() eieio()
-#define MEMORY_BARRIER() eieio()
-
-/* TODO not sure if the following two can't be just empty. */
-
-#define MEMORY_BARRIER_AFTER_ATOMIC() eieio()
-
-#endif
index 99715c6e1a2f272d03597ea5750e42a426042755..95ad22ac5d0e1e6be847fa5f99c2d56d075a872f 100644 (file)
 
 #include "config.h"
 
+#include "vm/descriptor.h"
 #include "vm/global.h"
 #include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/stack.h"
 
 #include "vm/jit/s390/md-abi.h"
 
-#include "vmcore/descriptor.h"
-
 #include <assert.h>
 
 
diff --git a/src/vm/jit/s390/md-atomic.hpp b/src/vm/jit/s390/md-atomic.hpp
new file mode 100644 (file)
index 0000000..fafb642
--- /dev/null
@@ -0,0 +1,127 @@
+/* src/vm/jit/s390/md-atomic.hpp - s390 atomic instructions
+
+   Copyright (C) 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 _MD_ATOMIC_HPP
+#define _MD_ATOMIC_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "threads/atomic.hpp"
+
+
+/**
+ * An atomic compare and swap for 32-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
+{
+       __asm__ __volatile__ (
+               "cs %0,%3,0(%2)\n"
+               : "+d" (oldval), "=m" (*p)
+               : "a" (p), "d" (newval), "m" (*p)
+               : "cc", "memory" );
+
+       return oldval;
+}
+
+
+/**
+ * An atomic compare and swap for 64-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
+{
+       return generic_compare_and_swap(p, oldval, newval);
+}
+
+
+/**
+ * An atomic compare and swap for pointer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval)
+{
+       return (void*) compare_and_swap((volatile uint32_t*) p, (uint32_t) oldval, (uint32_t) newval);
+}
+
+
+/**
+ * A memory barrier.
+ */
+inline void Atomic::memory_barrier(void)
+{
+       __asm__ __volatile__ ("bcr 15,0" : : : "memory" );
+}
+
+
+/**
+ * A write memory barrier.
+ */
+inline void Atomic::write_memory_barrier(void)
+{
+       memory_barrier();
+}
+
+/**
+ * An instruction barrier.
+ */
+inline void Atomic::instruction_barrier(void)
+{
+       memory_barrier();
+}
+
+#endif // _MD_ATOMIC_HPP
+
+
+/*
+ * 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/jit/s390/md-stubs.hpp b/src/vm/jit/s390/md-stubs.hpp
new file mode 100644 (file)
index 0000000..6fbe822
--- /dev/null
@@ -0,0 +1,58 @@
+/* src/vm/jit/s390/md-stubs.hpp - s390 JIT stubs
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+#include "vm/jit/s390/codegen.h"
+
+
+/**
+ * Return the code size of a compiler on a s390 architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+       return (SZ_AHI + SZ_L + SZ_L + SZ_BCR);
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * 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 ac0fe0816edf26b4d1eaad1c47a6c8f7fddc9166..a5e05a0716e82606a380dc0f3637eff78fd315e9 100644 (file)
@@ -46,7 +46,8 @@ enum {
        TRAP_ClassCastException             = 4,
        TRAP_CHECK_EXCEPTION                = 5,
        TRAP_PATCHER                        = 6,
-       TRAP_COMPILER                       = 7
+       TRAP_COMPILER                       = 7,
+       TRAP_COUNTDOWN                      = 8
 };
 
 #endif /* _MD_TRAP_H */
index 3959f0a91b87a2398462fc32b7da77c4c8187516..5e11280ac1dc33ceeb731e5cd3ec03929b100126 100644 (file)
@@ -34,9 +34,9 @@
 
 #include "vm/jit/s390/md-abi.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/exceptions.h"
+#include "vm/exceptions.hpp"
 #include "vm/signallocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/methodtree.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
-#include "vmcore/options.h" /* XXX debug */
+#include "vm/options.h" /* XXX debug */
 #include "vm/jit/disass.h" /* XXX debug */
 #endif
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/s390/codegen.h"
 #include "vm/jit/s390/md.h"
 
@@ -412,27 +412,6 @@ void md_executionstate_write(executionstate_t* es, void* context)
 }
 
 
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
-{
-       mcontext_t *_mc;
-       u1         *pc;
-       void       *npc;
-
-       _mc = &_uc->uc_mcontext;
-
-       pc = (u1 *)_mc->psw.addr;
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL) {
-               log_println("%s: pc=%p, npc=%p", __FUNCTION__, pc, npc);
-               _mc->psw.addr = (ptrint) npc;
-       }
-}
-#endif
-
-
 /* md_jit_method_patch_address *************************************************
 
    Gets the patch address of the currently compiled method. The offset
index 1664cd4172cbfa4b9faa37f3394edc8f04e569ad..cbb7f9b6df26dd1609b9144d02f7a4548aa306be 100644 (file)
@@ -31,7 +31,7 @@
 #include <assert.h>
 #include <stdint.h>
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/methodtree.h"
 
 
index 667aa07587c0f05db22fb65ce0ee78b20727c4c3..1add8371907da523544b80c3f0dbe8479616def7 100644 (file)
 #include <stdint.h>
 
 #include "mm/memory.h"
-#include "native/native.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/jit/patcher-common.h"
+#include "native/native.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
+#include "vm/types.h"
+
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/s390/codegen.h"
 #include "vm/jit/s390/md-abi.h"
-#include "vm/jit/stacktrace.h"
-#include "vm/resolve.h"
-#include "vm/types.h"
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vmcore/references.h"
+
 
 #define PATCH_BACK_ORIGINAL_MCODE \
        *((u2 *) pr->mpc) = (u2) pr->mcode;
@@ -130,11 +131,6 @@ bool patcher_get_putfield(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* If NOPs are generated, skip them */
-
-       if (opt_shownops)
-               ra += PATCHER_NOPS_SKIP;
-
        /* If there is an operand load before, skip the load size passed in disp (see ICMD_PUTFIELD) */
 
        ra += disp;
@@ -218,11 +214,6 @@ bool patcher_invokevirtual(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* If NOPs are generated, skip them */
-
-       if (opt_shownops)
-               ra += PATCHER_NOPS_SKIP;
-
        /* patch vftbl index */
 
 
@@ -266,11 +257,6 @@ bool patcher_invokeinterface(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* If NOPs are generated, skip them */
-
-       if (opt_shownops)
-               ra += PATCHER_NOPS_SKIP;
-
        /* get interfacetable index */
 
        idx = (s4) (OFFSET(vftbl_t, interfacetable[0]) -
@@ -427,11 +413,6 @@ bool patcher_checkcast_instanceof_interface(patchref_t *pr)
 
        PATCH_BACK_ORIGINAL_MCODE;
 
-       /* If NOPs are generated, skip them */
-
-       if (opt_shownops)
-               ra += PATCHER_NOPS_SKIP;
-
        /* patch super class index */
 
        /* From here, split your editor and open codegen.c */
diff --git a/src/vm/jit/show.c b/src/vm/jit/show.c
deleted file mode 100644 (file)
index 0b429cc..0000000
+++ /dev/null
@@ -1,1661 +0,0 @@
-/* src/vm/jit/show.c - showing the intermediate representation
-
-   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 <stdint.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "threads/lock-common.h"
-
-#include "vm/global.h"
-#include "vm/builtin.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/abi.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/show.h"
-#include "vm/jit/disass.h"
-#include "vm/jit/stack.h"
-#include "vm/jit/parse.h"
-
-#include "vmcore/options.h"
-
-#if defined(ENABLE_DEBUG_FILTER)
-# include <sys/types.h>
-# include <regex.h>
-# include "threads/thread.h"
-#endif
-
-
-/* global variables ***********************************************************/
-
-#if defined(ENABLE_THREADS) && !defined(NDEBUG)
-static java_object_t *show_global_lock;
-#endif
-
-
-/* prototypes *****************************************************************/
-
-#if !defined(NDEBUG)
-static void show_variable_intern(jitdata *jd, s4 index, int stage);
-#endif
-
-
-/* show_init *******************************************************************
-
-   Initialized the show subsystem (called by jit_init).
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-bool show_init(void)
-{
-#if defined(ENABLE_THREADS)
-       /* initialize the show lock */
-
-       show_global_lock = NEW(java_object_t);
-
-       LOCK_INIT_OBJECT_LOCK(show_global_lock);
-#endif
-
-#if defined(ENABLE_DEBUG_FILTER)
-       show_filters_init();
-#endif
-
-       /* everything's ok */
-
-       return true;
-}
-#endif
-
-
-#if !defined(NDEBUG)
-char *show_jit_type_names[] = {
-       "INT",
-       "LNG",
-       "FLT",
-       "DBL",
-       "ADR",
-       "??5",
-       "??6",
-       "??7",
-       "RET"
-};
-char show_jit_type_letters[] = {
-       'I',
-       'L',
-       'F',
-       'D',
-       'A',
-       '5',
-       '6',
-       '7',
-       'R'
-};
-#endif
-
-
-/* show_method *****************************************************************
-
-   Print the intermediate representation of a method.
-
-   NOTE: Currently this function may only be called after register allocation!
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void show_method(jitdata *jd, int stage)
-{
-       methodinfo     *m;
-       codeinfo       *code;
-       codegendata    *cd;
-       registerdata   *rd;
-       basicblock     *bptr;
-       basicblock     *lastbptr;
-       exception_entry *ex;
-       s4              i, j;
-       int             irstage;
-#if defined(ENABLE_DISASSEMBLER)
-       u1             *pc;
-#endif
-
-       /* get required compiler data */
-
-       m    = jd->m;
-       code = jd->code;
-       cd   = jd->cd;
-       rd   = jd->rd;
-
-       /* We need to enter a lock here, since the binutils disassembler
-          is not reentrant-able and we could not read functions printed
-          at the same time. */
-
-       LOCK_MONITOR_ENTER(show_global_lock);
-
-#if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               irstage = SHOW_PARSE;
-       else
-#endif
-               irstage = stage;
-
-       /* get the last basic block */
-
-       for (lastbptr = jd->basicblocks; lastbptr->next != NULL; lastbptr = lastbptr->next);
-
-       printf("\n");
-
-       method_println(m);
-
-       if (code_is_leafmethod(code))
-               printf("LEAFMETHOD\n");
-
-       printf("\nBasic blocks: %d\n", jd->basicblockcount);
-       if (stage >= SHOW_CODE) {
-               printf("Code length:  %d\n", (lastbptr->mpc - jd->basicblocks[0].mpc));
-               printf("Data length:  %d\n", cd->dseglen);
-               printf("Stub length:  %d\n", (s4) (code->mcodelength -
-                                                                                  ((ptrint) cd->dseglen + lastbptr->mpc)));
-       }
-       printf("Variables:       %d (%d used)\n", jd->varcount, jd->vartop);
-       if (stage >= SHOW_STACK)
-               printf("Max interfaces:  %d\n", jd->maxinterfaces);
-       printf("Max locals:      %d\n", jd->maxlocals);
-       printf("Max stack:       %d\n", m->maxstack);
-       printf("Linenumbers:     %d\n", m->linenumbercount);
-       printf("Branch to entry: %s\n", (jd->branchtoentry) ? "yes" : "no");
-       printf("Branch to end:   %s\n", (jd->branchtoend) ? "yes" : "no");
-       if (stage >= SHOW_STACK) {
-               printf("Number of RETURNs: %d", jd->returncount);
-               if (jd->returncount == 1)
-                       printf(" (block L%03d)", jd->returnblock->nr);
-               printf("\n");
-       }
-
-       if (stage >= SHOW_PARSE) {
-               printf("Exceptions (Number: %d):\n", jd->exceptiontablelength);
-               for (ex = jd->exceptiontable; ex != NULL; ex = ex->down) {
-                       printf("    L%03d ... ", ex->start->nr );
-                       printf("L%03d  = ", ex->end->nr);
-                       printf("L%03d", ex->handler->nr);
-                       printf("  (catchtype: ");
-                       if (ex->catchtype.any)
-                               if (IS_CLASSREF(ex->catchtype))
-                                       class_classref_print(ex->catchtype.ref);
-                               else
-                                       class_print(ex->catchtype.cls);
-                       else
-                               printf("ANY");
-                       printf(")\n");
-               }
-       }
-       
-       if (irstage >= SHOW_PARSE && rd && jd->localcount > 0) {
-               printf("Local Table:\n");
-               for (i = 0; i < jd->localcount; i++) {
-                       printf("   %3d: ", i);
-
-#if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
-# if defined(ENABLE_INTRP)
-                       if (!opt_intrp) {
-# endif
-                               printf("   (%s) ", show_jit_type_names[VAR(i)->type]);
-                               if (irstage >= SHOW_REGS)
-                                       show_allocation(VAR(i)->type, VAR(i)->flags, VAR(i)->vv.regoff);
-                               printf("\n");
-# if defined(ENABLE_INTRP)
-                       }
-# endif
-#endif /* defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER) */
-               }
-               printf("\n");
-       }
-
-       if (jd->maxlocals > 0 && jd->local_map != NULL) {
-               printf("Local Map:\n");
-               printf("    index ");
-               for (j = 0; j < jd->maxlocals; j++) {
-                       printf(" [%2d]", j);
-               }
-               printf("\n");
-               for (i = 0; i < 5; i++) {
-                       printf("    %5s ",show_jit_type_names[i]);
-                       for (j = 0; j < jd->maxlocals; j++) {
-                               if (jd->local_map[j*5+i] == UNUSED)
-                                       printf("  -- ");
-                               else
-                                       printf("%4i ",jd->local_map[j*5+i]);
-                       }
-                       printf("\n");
-               }
-               printf("\n");
-       }
-
-       if (jd->maxinterfaces > 0 && jd->interface_map && irstage >= SHOW_STACK) {
-               bool exist = false;
-               interface_info *mapptr = jd->interface_map;
-               
-               /* look if there exist any INOUTS */
-               for (i = 0; (i < (5 * jd->maxinterfaces)) && !exist; i++, mapptr++)
-                       exist = (mapptr->flags != UNUSED);
-
-               if (exist) {
-                       printf("Interface Table: (In/Outvars)\n");
-                       printf("    depth ");
-                       for (j = 0; j < jd->maxinterfaces; j++) {
-                               printf("      [%2d]", j);
-                       }
-                       printf("\n");
-
-                       for (i = 0; i < 5; i++) {
-                               printf("    %5s      ",show_jit_type_names[i]);
-                               for (j = 0; j < jd->maxinterfaces; j++) {
-                                       s4 flags  = jd->interface_map[j*5+i].flags;
-                                       s4 regoff = jd->interface_map[j*5+i].regoff;
-                                       if (flags == UNUSED)
-                                               printf("  --      ");
-                                       else {
-                                               int ch;
-
-                                               if (irstage >= SHOW_REGS) {
-                                                       if (flags & SAVEDVAR) {
-                                                               if (flags & INMEMORY)
-                                                                       ch = 'M';
-                                                               else
-                                                                       ch = 'R';
-                                                       }
-                                                       else {
-                                                               if (flags & INMEMORY)
-                                                                       ch = 'm';
-                                                               else
-                                                                       ch = 'r';
-                                                       }
-                                                       printf("%c%03d(", ch, regoff);
-                                                       show_allocation(i, flags, regoff);
-                                                       printf(") ");
-                                               }
-                                               else {
-                                                       if (flags & SAVEDVAR)
-                                                               printf("  I       ");
-                                                       else
-                                                               printf("  i       ");
-                                               }
-                                       }
-                               }
-                               printf("\n");
-                       }
-                       printf("\n");
-               }
-       }
-
-       if (rd->memuse && irstage >= SHOW_REGS) {
-               int max;
-
-               max = rd->memuse;
-               printf("Stack slots: (memuse=%d", rd->memuse);
-               if (irstage >= SHOW_CODE) {
-                       printf(", stackframesize=%d", cd->stackframesize);
-                       max = cd->stackframesize;
-               }
-               printf(")\n");
-               for (i = 0; i < max; ++i) {
-#if defined(HAS_4BYTE_STACKSLOT)
-                       printf("    M%02d = 0x%02x(sp): ", i, i * 4);
-#else
-                       printf("    M%02d = 0x%02x(sp): ", i, i * 8);
-#endif
-                       for (j = 0; j < jd->vartop; ++j) {
-                               varinfo *v = VAR(j);
-                               if ((v->flags & INMEMORY) && (v->vv.regoff == i)) {
-                                       show_variable(jd, j, irstage);
-                                       putchar(' ');
-                               }
-                       }
-
-                       printf("\n");
-
-               }
-               printf("\n");
-       }
-
-#if defined(ENABLE_REPLACEMENT)
-       if (code->rplpoints) {
-               printf("Replacement Points:\n");
-               replace_show_replacement_points(code);
-               printf("\n");
-       }
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-#if defined(ENABLE_DISASSEMBLER)
-       /* show code before first basic block */
-
-       if ((stage >= SHOW_CODE) && JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
-               pc = (u1 *) ((ptrint) code->mcode + cd->dseglen);
-
-               for (; pc < (u1 *) ((ptrint) code->mcode + cd->dseglen + jd->basicblocks[0].mpc);)
-                       DISASSINSTR(pc);
-
-               printf("\n");
-       }
-#endif
-
-       /* show code of all basic blocks */
-
-       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next)
-               show_basicblock(jd, bptr, stage);
-
-#if 0 && defined(ENABLE_DISASSEMBLER)
-       /* show code after last basic block */
-
-       if (stage >= SHOW_CODE && opt_showdisassemble) {
-               printf("\nStubs code:\n");
-               printf("Length: %d\n\n", (s4) (code->mcodelength -
-                                                                          ((ptrint) cd->dseglen + lastbptr->mpc)));
-
-               pc = (u1 *) ((ptrint) code->mcode + cd->dseglen + lastbptr->mpc);
-
-               for (; (ptrint) pc < ((ptrint) code->mcode + code->mcodelength);)
-                       DISASSINSTR(pc);
-
-               printf("\n");
-       }
-#endif
-
-       LOCK_MONITOR_EXIT(show_global_lock);
-
-       /* finally flush the output */
-
-       fflush(stdout);
-}
-#endif /* !defined(NDEBUG) */
-
-
-#if !defined(NDEBUG) && defined(ENABLE_INLINING)
-static void show_inline_info(jitdata *jd, insinfo_inline *ii, s4 opcode, s4 stage)
-{
-       s4 *jl;
-       s4 n;
-
-       printf("(pt %d+%d+%d st ", 
-                       ii->throughcount - (ii->stackvarscount - ii->paramcount),
-                       ii->stackvarscount - ii->paramcount,
-                       ii->paramcount);
-       show_variable_array(jd, ii->stackvars, ii->stackvarscount, stage);
-
-       if (opcode == ICMD_INLINE_START || opcode == ICMD_INLINE_END) {
-               printf(" jl ");
-               jl = (opcode == ICMD_INLINE_START) ? ii->javalocals_start : ii->javalocals_end;
-               n = (opcode == ICMD_INLINE_START) ? ii->method->maxlocals : ii->outer->maxlocals;
-               show_javalocals_array(jd, jl, n, stage);
-       }
-
-       printf(") ");
-
-#if 0
-       printf("(");
-       method_print(ii->outer);
-       printf(" ==> ");
-#endif
-
-       method_print(ii->method);
-}
-#endif /* !defined(NDEBUG) && defined(ENABLE_INLINING) */
-
-
-/* show_basicblock *************************************************************
-
-   Print the intermediate representation of a basic block.
-
-   NOTE: Currently this function may only be called after register allocation!
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void show_basicblock(jitdata *jd, basicblock *bptr, int stage)
-{
-       codeinfo    *code;
-       codegendata *cd;
-       s4           i;
-       bool         deadcode;
-       instruction *iptr;
-       int          irstage;
-#if defined(ENABLE_DISASSEMBLER)
-       methodinfo  *m;                     /* this is only a dummy               */
-       void        *pc;
-       s4           linenumber;
-       s4           currentlinenumber;
-#endif
-
-       /* get required compiler data */
-
-       code = jd->code;
-       cd   = jd->cd;
-
-       if (bptr->flags != BBDELETED) {
-#if defined(ENABLE_INTRP)
-               if (opt_intrp) {
-                       deadcode = false;
-                       irstage = SHOW_PARSE;
-               }
-               else
-#endif
-               {
-                       deadcode = (bptr->flags < BBREACHED);
-                       irstage = stage;
-               }
-
-               printf("======== %sL%03d ======== %s(flags: %d, bitflags: %01x, next: %d, type: ",
-#if defined(ENABLE_REPLACEMENT)
-                               (bptr->bitflags & BBFLAG_REPLACEMENT) ? "<REPLACE> " : 
-#endif
-                                                                                                               "",
-                          bptr->nr, 
-                          (deadcode && stage >= SHOW_STACK) ? "DEADCODE! " : "",
-                          bptr->flags, bptr->bitflags, 
-                          (bptr->next) ? (bptr->next->nr) : -1);
-
-               switch (bptr->type) {
-               case BBTYPE_STD:
-                       printf("STD");
-                       break;
-               case BBTYPE_EXH:
-                       printf("EXH");
-                       break;
-               case BBTYPE_SBR:
-                       printf("SBR");
-                       break;
-               }
-
-               printf(", icount: %d", bptr->icount);
-
-               if (irstage >= SHOW_CFG) {
-                       printf(", preds: %d [ ", bptr->predecessorcount);
-
-                       for (i = 0; i < bptr->predecessorcount; i++)
-                               printf("%d ", bptr->predecessors[i]->nr);
-
-                       printf("]");
-               }
-
-               printf("):");
-
-               if (bptr->original)
-                       printf(" (clone of L%03d)", bptr->original->nr);
-               else {
-                       basicblock *b = bptr->copied_to;
-                       if (b) {
-                               printf(" (copied to ");
-                               for (; b; b = b->copied_to)
-                                       printf("L%03d ", b->nr);
-                               printf(")");
-                       }
-               }
-
-               printf("\n");
-
-               if (irstage >= SHOW_CFG) {
-                       printf("succs: %d [ ", bptr->successorcount);
-
-                       for (i = 0; i < bptr->successorcount; i++)
-                               printf("%d ", bptr->successors[i]->nr);
-
-                       printf("]\n");
-               }
-
-               if (irstage >= SHOW_STACK) {
-                       printf("IN:  ");
-                       show_variable_array(jd, bptr->invars, bptr->indepth, irstage);
-                       printf(" javalocals: ");
-                       if (bptr->javalocals)
-                               show_javalocals_array(jd, bptr->javalocals, bptr->method->maxlocals, irstage);
-                       else
-                               printf("null");
-                       printf("\n");
-               }
-
-#if defined(ENABLE_INLINING)
-               if (bptr->inlineinfo) {
-                       printf("inlineinfo: ");
-                       show_inline_info(jd, bptr->inlineinfo, -1, irstage);
-                       printf("\n");
-               }
-#endif /* defined(ENABLE_INLINING) */
-
-               iptr = bptr->iinstr;
-
-               for (i = 0; i < bptr->icount; i++, iptr++) {
-                       printf("%4d:%4d:  ", iptr->line, iptr->flags.bits >> INS_FLAG_ID_SHIFT);
-
-                       show_icmd(jd, iptr, deadcode, irstage);
-                       printf("\n");
-               }
-
-               if (irstage >= SHOW_STACK) {
-                       printf("OUT: ");
-                       show_variable_array(jd, bptr->outvars, bptr->outdepth, irstage);
-                       printf("\n");
-               }
-
-#if defined(ENABLE_DISASSEMBLER)
-               if ((stage >= SHOW_CODE) && JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) &&
-                       (!deadcode)) 
-               {
-                       printf("\n");
-                       pc         = (void *) (code->mcode + cd->dseglen + bptr->mpc);
-                       linenumber = 0;
-
-                       if (bptr->next != NULL) {
-                               for (; pc < (void *) (code->mcode + cd->dseglen + bptr->next->mpc);) {
-                                       currentlinenumber =
-                                               linenumbertable_linenumber_for_pc(&m, code, pc);
-
-                                       if (currentlinenumber != linenumber) {
-                                               linenumber = currentlinenumber;
-                                               printf("%4d:\n", linenumber);
-                                       }
-
-                                       DISASSINSTR(pc);
-                               }
-                       }
-                       else {
-                               for (; pc < (void *) (code->mcode + code->mcodelength);) {
-                                       currentlinenumber =
-                                               linenumbertable_linenumber_for_pc(&m, code, pc);
-
-                                       if (currentlinenumber != linenumber) {
-                                               linenumber = currentlinenumber;
-                                               printf("%4d:\n", linenumber);
-                                       }
-
-                                       DISASSINSTR(pc);
-                               }
-                       }
-                       printf("\n");
-               }
-#endif
-       }
-}
-#endif /* !defined(NDEBUG) */
-
-
-/* show_icmd *******************************************************************
-
-   Print the intermediate representation of an instruction.
-
-   NOTE: Currently this function may only be called after register allocation!
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-
-#define SHOW_TARGET(target)                                          \
-        if (stage >= SHOW_PARSE) {                                   \
-            printf("--> L%03d ", (target).block->nr);                \
-        }                                                            \
-        else {                                                       \
-            printf("--> insindex %d ", (target).insindex);           \
-        }
-
-#define SHOW_INT_CONST(val)                                          \
-        if (stage >= SHOW_PARSE) {                                   \
-            printf("%d (0x%08x) ", (int32_t) (val), (int32_t) (val)); \
-        }                                                            \
-        else {                                                       \
-            printf("iconst ");                                       \
-        }
-
-#if SIZEOF_VOID_P == 4
-#define SHOW_LNG_CONST(val)                                          \
-        if (stage >= SHOW_PARSE)                                     \
-            printf("%lld (0x%016llx) ", (val), (val));               \
-        else                                                         \
-            printf("lconst ");
-#else
-#define SHOW_LNG_CONST(val)                                          \
-        if (stage >= SHOW_PARSE)                                     \
-            printf("%ld (0x%016lx) ", (val), (val));                 \
-        else                                                         \
-            printf("lconst ");
-#endif
-
-#if SIZEOF_VOID_P == 4
-#define SHOW_ADR_CONST(val)                                          \
-        if (stage >= SHOW_PARSE)                                     \
-            printf("0x%08x ", (ptrint) (val));                       \
-        else                                                         \
-            printf("aconst ");
-#else
-#define SHOW_ADR_CONST(val)                                          \
-        if (stage >= SHOW_PARSE)                                     \
-            printf("0x%016lx ", (ptrint) (val));                     \
-        else                                                         \
-            printf("aconst ");
-#endif
-
-#define SHOW_FLT_CONST(val)                                          \
-        if (stage >= SHOW_PARSE) {                                   \
-            imm_union v;                                             \
-            v.f = (val);                                             \
-            printf("%g (0x%08x) ", (val), v.i);                      \
-        }                                                            \
-        else {                                                       \
-            printf("fconst ");                                       \
-        }
-
-#if SIZEOF_VOID_P == 4
-#define SHOW_DBL_CONST(val)                                          \
-        if (stage >= SHOW_PARSE) {                                   \
-            imm_union v;                                             \
-            v.d = (val);                                             \
-            printf("%g (0x%016llx) ", (val), v.l);                   \
-        }                                                            \
-        else                                                         \
-            printf("dconst ");
-#else
-#define SHOW_DBL_CONST(val)                                          \
-        if (stage >= SHOW_PARSE) {                                   \
-            imm_union v;                                             \
-            v.d = (val);                                             \
-            printf("%g (0x%016lx) ", (val), v.l);                    \
-        }                                                            \
-        else                                                         \
-            printf("dconst ");
-#endif
-
-#define SHOW_INDEX(index)                                            \
-        if (stage >= SHOW_PARSE) {                                   \
-            printf("%d ", index);                                    \
-        }                                                            \
-        else {                                                       \
-            printf("index");                                         \
-        }
-
-#define SHOW_STRING(val)                                             \
-        if (stage >= SHOW_PARSE) {                                   \
-            putchar('"');                                            \
-            utf_display_printable_ascii(                             \
-               javastring_toutf((java_handle_t *)(val), false));     \
-            printf("\" ");                                           \
-        }                                                            \
-        else {                                                       \
-            printf("string ");                                       \
-        }
-
-#define SHOW_CLASSREF_OR_CLASSINFO(c)                                \
-        if (stage >= SHOW_PARSE) {                                   \
-            if (IS_CLASSREF(c))                                      \
-                class_classref_print(c.ref);                         \
-            else                                                     \
-                class_print(c.cls);                                  \
-            putchar(' ');                                            \
-        }                                                            \
-        else {                                                       \
-            printf("class ");                                        \
-        }
-
-#define SHOW_FIELD(fmiref)                                           \
-        if (stage >= SHOW_PARSE) {                                   \
-            field_fieldref_print(fmiref);                            \
-            putchar(' ');                                            \
-        }                                                            \
-        else {                                                       \
-            printf("field ");                                        \
-        }
-
-#define SHOW_VARIABLE(v)                                             \
-    show_variable(jd, (v), stage)
-
-#define SHOW_S1(iptr)                                                \
-        if (stage >= SHOW_STACK) {                                   \
-            SHOW_VARIABLE(iptr->s1.varindex);                        \
-        }
-
-#define SHOW_S2(iptr)                                                \
-        if (stage >= SHOW_STACK) {                                   \
-            SHOW_VARIABLE(iptr->sx.s23.s2.varindex);                 \
-        }
-
-#define SHOW_S3(iptr)                                                \
-    if (stage >= SHOW_STACK) {                                       \
-        SHOW_VARIABLE(iptr->sx.s23.s3.varindex);                     \
-    }
-
-#define SHOW_DST(iptr)                                               \
-    if (stage >= SHOW_STACK) {                                       \
-        printf("=> ");                                               \
-        SHOW_VARIABLE(iptr->dst.varindex);                           \
-    }
-
-#define SHOW_S1_LOCAL(iptr)                                          \
-    if (stage >= SHOW_STACK) {                                       \
-        printf("L%d ", iptr->s1.varindex);                           \
-    }                                                                \
-    else {                                                           \
-        printf("JavaL%d ", iptr->s1.varindex);                       \
-    }
-
-#define SHOW_DST_LOCAL(iptr)                                         \
-    if (stage >= SHOW_STACK) {                                       \
-        printf("=> L%d ", iptr->dst.varindex);                       \
-    }                                                                \
-    else {                                                           \
-        printf("=> JavaL%d ", iptr->dst.varindex);                   \
-    }
-
-void show_allocation(s4 type, s4 flags, s4 regoff)
-{
-       if (type == TYPE_RET) {
-               printf("N/A");
-               return;
-       }
-
-       if (flags & INMEMORY) {
-               printf("M%02d", regoff);
-               return;
-       }
-
-#ifdef HAS_ADDRESS_REGISTER_FILE
-       if (type == TYPE_ADR) {
-               printf("R%02d", regoff);
-               return;
-       }
-#endif
-
-       if (IS_FLT_DBL_TYPE(type)) {
-               printf("F%02d", regoff);
-               return;
-       }
-
-#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
-       if (IS_2_WORD_TYPE(type)) {
-# if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
-#  if defined(ENABLE_INTRP)
-               if (opt_intrp)
-                       printf("%3d/%3d", GET_LOW_REG(regoff),
-                                       GET_HIGH_REG(regoff));
-               else
-#  endif
-                       printf("%3s/%3s", abi_registers_integer_name[GET_LOW_REG(regoff)],
-                                  abi_registers_integer_name[GET_HIGH_REG(regoff)]);
-# else
-               printf("%3d/%3d", GET_LOW_REG(regoff),
-                          GET_HIGH_REG(regoff));
-# endif
-               return;
-       } 
-#endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */
-
-#if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               printf("%3d", regoff);
-       else
-# endif
-               printf("%3s", abi_registers_integer_name[regoff]);
-#else
-       printf("%3d", regoff);
-#endif
-}
-
-void show_variable(jitdata *jd, s4 index, int stage)
-{
-       show_variable_intern(jd, index, stage);
-       putchar(' ');
-}
-
-static void show_variable_intern(jitdata *jd, s4 index, int stage)
-{
-       char type;
-       char kind;
-       varinfo *v;
-
-       if (index < 0 || index >= jd->vartop) {
-               printf("<INVALID INDEX:%d>", index);
-               return;
-       }
-
-       v = VAR(index);
-
-       switch (v->type) {
-               case TYPE_INT: type = 'i'; break;
-               case TYPE_LNG: type = 'l'; break;
-               case TYPE_FLT: type = 'f'; break;
-               case TYPE_DBL: type = 'd'; break;
-               case TYPE_ADR: type = 'a'; break;
-               case TYPE_RET: type = 'r'; break;
-               default:       type = '?';
-       }
-
-       if (index < jd->localcount) {
-               kind = 'L';
-               if (v->flags & (PREALLOC | INOUT))
-                               printf("<INVALID FLAGS!>");
-       }
-       else {
-               if (v->flags & PREALLOC) {
-                       kind = 'A';
-                       if (v->flags & INOUT) {
-                               /* PREALLOC is used to avoid allocation of TYPE_RET */
-                               if (v->type == TYPE_RET)
-                                       kind = 'i';
-                               else
-                                       printf("<INVALID FLAGS!>");
-                       }
-               }
-               else if (v->flags & INOUT)
-                       kind = 'I';
-               else
-                       kind = 'T';
-       }
-
-       printf("%c%c%d", kind, type, index);
-
-       if (v->flags & SAVEDVAR)
-               putchar('!');
-
-       if (stage >= SHOW_REGS || (v->flags & PREALLOC)) {
-               putchar('(');
-               show_allocation(v->type, v->flags, v->vv.regoff);
-               putchar(')');
-       }
-
-       if (v->type == TYPE_RET && (v->flags & PREALLOC)) {
-               printf("(L%03d)", v->vv.retaddr->nr);
-       }
-}
-
-static void show_variable_array_intern(jitdata *jd, s4 *vars, int n, int stage,
-                                                                          bool javalocals)
-{
-       int i;
-       int nr;
-
-       if (vars == NULL) {
-               printf("<null>");
-               return;
-       }
-
-       printf("[");
-       for (i=0; i<n; ++i) {
-               if (i)
-                       putchar(' ');
-               if (vars[i] < 0) {
-                       if (vars[i] == UNUSED)
-                               putchar('-');
-                       else if (javalocals) {
-                               nr = RETADDR_FROM_JAVALOCAL(vars[i]);
-                               printf("ret(L%03d)", nr);
-                       }
-                       else {
-                               printf("<INVALID INDEX:%d>", vars[i]);
-                       }
-               }
-               else
-                       show_variable_intern(jd, vars[i], stage);
-       }
-       printf("]");
-}
-
-void show_variable_array(jitdata *jd, s4 *vars, int n, int stage)
-{
-       show_variable_array_intern(jd, vars, n, stage, false);
-}
-
-void show_javalocals_array(jitdata *jd, s4 *vars, int n, int stage)
-{
-       show_variable_array_intern(jd, vars, n, stage, true);
-}
-
-void show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage)
-{
-       u2                 opcode;
-       branch_target_t   *table;
-       lookup_target_t   *lookup;
-       constant_FMIref   *fmiref;
-       s4                *argp;
-       s4                 i;
-
-       /* get the opcode and the condition */
-
-       opcode    =  iptr->opc;
-
-       printf("%s ", icmd_table[opcode].name);
-
-       if (stage < SHOW_PARSE)
-               return;
-
-       if (deadcode)
-               stage = SHOW_PARSE;
-
-       /* Print the condition for conditional instructions. */
-
-       /* XXX print condition from flags */
-
-       if (iptr->flags.bits & INS_FLAG_UNRESOLVED)
-               printf("(UNRESOLVED) ");
-
-       switch (opcode) {
-
-       case ICMD_POP:
-       case ICMD_CHECKNULL:
-               SHOW_S1(iptr);
-               break;
-
-               /* unary */
-       case ICMD_ARRAYLENGTH:
-       case ICMD_INEG:
-       case ICMD_LNEG:
-       case ICMD_FNEG:
-       case ICMD_DNEG:
-       case ICMD_I2L:
-       case ICMD_I2F:
-       case ICMD_I2D:
-       case ICMD_L2I:
-       case ICMD_L2F:
-       case ICMD_L2D:
-       case ICMD_F2I:
-       case ICMD_F2L:
-       case ICMD_F2D:
-       case ICMD_D2I:
-       case ICMD_D2L:
-       case ICMD_D2F:
-       case ICMD_INT2BYTE:
-       case ICMD_INT2CHAR:
-       case ICMD_INT2SHORT:
-               SHOW_S1(iptr);
-               SHOW_DST(iptr);
-               break;
-
-               /* binary */
-       case ICMD_IADD:
-       case ICMD_LADD:
-       case ICMD_FADD:
-       case ICMD_DADD:
-       case ICMD_ISUB:
-       case ICMD_LSUB:
-       case ICMD_FSUB:
-       case ICMD_DSUB:
-       case ICMD_IMUL:
-       case ICMD_LMUL:
-       case ICMD_FMUL:
-       case ICMD_DMUL:
-       case ICMD_IDIV:
-       case ICMD_LDIV:
-       case ICMD_FDIV:
-       case ICMD_DDIV:
-       case ICMD_IREM:
-       case ICMD_LREM:
-       case ICMD_FREM:
-       case ICMD_DREM:
-       case ICMD_ISHL:
-       case ICMD_LSHL:
-       case ICMD_ISHR:
-       case ICMD_LSHR:
-       case ICMD_IUSHR:
-       case ICMD_LUSHR:
-       case ICMD_IAND:
-       case ICMD_LAND:
-       case ICMD_IOR:
-       case ICMD_LOR:
-       case ICMD_IXOR:
-       case ICMD_LXOR:
-       case ICMD_LCMP:
-       case ICMD_FCMPL:
-       case ICMD_FCMPG:
-       case ICMD_DCMPL:
-       case ICMD_DCMPG:
-               SHOW_S1(iptr);
-               SHOW_S2(iptr);
-               SHOW_DST(iptr);
-               break;
-
-               /* binary/const INT */
-       case ICMD_IADDCONST:
-       case ICMD_ISUBCONST:
-       case ICMD_IMULCONST:
-       case ICMD_IMULPOW2:
-       case ICMD_IDIVPOW2:
-       case ICMD_IREMPOW2:
-       case ICMD_IANDCONST:
-       case ICMD_IORCONST:
-       case ICMD_IXORCONST:
-       case ICMD_ISHLCONST:
-       case ICMD_ISHRCONST:
-       case ICMD_IUSHRCONST:
-       case ICMD_LSHLCONST:
-       case ICMD_LSHRCONST:
-       case ICMD_LUSHRCONST:
-               SHOW_S1(iptr);
-               SHOW_INT_CONST(iptr->sx.val.i); 
-               SHOW_DST(iptr);
-               break;
-
-               /* ?ASTORECONST (trinary/const INT) */
-       case ICMD_IASTORECONST:
-       case ICMD_BASTORECONST:
-       case ICMD_CASTORECONST:
-       case ICMD_SASTORECONST:
-               SHOW_S1(iptr);
-               SHOW_S2(iptr);
-               SHOW_INT_CONST(iptr->sx.s23.s3.constval);
-               break;
-
-               /* const INT */
-       case ICMD_ICONST:
-               SHOW_INT_CONST(iptr->sx.val.i); 
-               SHOW_DST(iptr);
-               break;
-
-               /* binary/const LNG */
-       case ICMD_LADDCONST:
-       case ICMD_LSUBCONST:
-       case ICMD_LMULCONST:
-       case ICMD_LMULPOW2:
-       case ICMD_LDIVPOW2:
-       case ICMD_LREMPOW2:
-       case ICMD_LANDCONST:
-       case ICMD_LORCONST:
-       case ICMD_LXORCONST:
-               SHOW_S1(iptr);
-               SHOW_LNG_CONST(iptr->sx.val.l);
-               SHOW_DST(iptr);
-               break;
-
-               /* trinary/const LNG (<= pointer size) */
-       case ICMD_LASTORECONST:
-               SHOW_S1(iptr);
-               SHOW_S2(iptr);
-               SHOW_ADR_CONST(iptr->sx.s23.s3.constval);
-               break;
-
-               /* const LNG */
-       case ICMD_LCONST:
-               SHOW_LNG_CONST(iptr->sx.val.l); 
-               SHOW_DST(iptr);
-               break;
-
-               /* const FLT */
-       case ICMD_FCONST:
-               SHOW_FLT_CONST(iptr->sx.val.f); 
-               SHOW_DST(iptr);
-               break;
-
-               /* const DBL */
-       case ICMD_DCONST:
-               SHOW_DBL_CONST(iptr->sx.val.d); 
-               SHOW_DST(iptr);
-               break;
-
-               /* const ADR */
-       case ICMD_ACONST:
-               if (iptr->flags.bits & INS_FLAG_CLASS) {
-                       SHOW_ADR_CONST(iptr->sx.val.anyptr);
-                       SHOW_CLASSREF_OR_CLASSINFO(iptr->sx.val.c);
-               }
-               else if (iptr->sx.val.anyptr == NULL) {
-                       printf("NULL ");
-               }
-               else {
-                       SHOW_ADR_CONST(iptr->sx.val.anyptr);
-                       SHOW_STRING(iptr->sx.val.stringconst);
-               }
-               SHOW_DST(iptr);
-               break;
-
-       case ICMD_AASTORECONST:
-               SHOW_S1(iptr);
-               SHOW_S2(iptr);
-               printf("%p ", (void*) iptr->sx.s23.s3.constval);
-               break;
-
-       case ICMD_GETFIELD:        /* 1 -> 1 */
-       case ICMD_PUTFIELD:        /* 2 -> 0 */
-       case ICMD_PUTSTATIC:       /* 1 -> 0 */
-       case ICMD_GETSTATIC:       /* 0 -> 1 */
-       case ICMD_PUTSTATICCONST:  /* 0 -> 0 */
-       case ICMD_PUTFIELDCONST:   /* 1 -> 0 */
-               if (opcode != ICMD_GETSTATIC && opcode != ICMD_PUTSTATICCONST) {
-                       SHOW_S1(iptr);
-                       if (opcode == ICMD_PUTFIELD) {
-                               SHOW_S2(iptr);
-                       }
-               }
-               INSTRUCTION_GET_FIELDREF(iptr, fmiref);
-               SHOW_FIELD(fmiref);
-
-               if (opcode == ICMD_GETSTATIC || opcode == ICMD_GETFIELD) {
-                       SHOW_DST(iptr);
-               }
-               break;
-
-       case ICMD_IINC:
-               SHOW_S1_LOCAL(iptr);
-               SHOW_INT_CONST(iptr->sx.val.i);
-               SHOW_DST_LOCAL(iptr);
-               break;
-
-       case ICMD_IASTORE:
-       case ICMD_SASTORE:
-       case ICMD_BASTORE:
-       case ICMD_CASTORE:
-       case ICMD_LASTORE:
-       case ICMD_DASTORE:
-       case ICMD_FASTORE:
-       case ICMD_AASTORE:
-               SHOW_S1(iptr);
-               SHOW_S2(iptr);
-               SHOW_S3(iptr);
-               break;
-
-       case ICMD_IALOAD:
-       case ICMD_SALOAD:
-       case ICMD_BALOAD:
-       case ICMD_CALOAD:
-       case ICMD_LALOAD:
-       case ICMD_DALOAD:
-       case ICMD_FALOAD:
-       case ICMD_AALOAD:
-               SHOW_S1(iptr);
-               SHOW_S2(iptr);
-               SHOW_DST(iptr);
-               break;
-
-       case ICMD_RET:
-               SHOW_S1_LOCAL(iptr);
-               if (stage >= SHOW_STACK) {
-                       printf(" ---> L%03d", iptr->dst.block->nr);
-               }
-               break;
-
-       case ICMD_ILOAD:
-       case ICMD_LLOAD:
-       case ICMD_FLOAD:
-       case ICMD_DLOAD:
-       case ICMD_ALOAD:
-               SHOW_S1_LOCAL(iptr);
-               SHOW_DST(iptr);
-               break;
-
-       case ICMD_ISTORE:
-       case ICMD_LSTORE:
-       case ICMD_FSTORE:
-       case ICMD_DSTORE:
-       case ICMD_ASTORE:
-               SHOW_S1(iptr);
-               SHOW_DST_LOCAL(iptr);
-               if (stage >= SHOW_STACK && iptr->sx.s23.s3.javaindex != UNUSED)
-                       printf(" (javaindex %d)", iptr->sx.s23.s3.javaindex);
-               if (iptr->flags.bits & INS_FLAG_RETADDR) {
-                       printf(" (retaddr L%03d)", RETADDR_FROM_JAVALOCAL(iptr->sx.s23.s2.retaddrnr));
-               }
-               break;
-
-       case ICMD_NEW:
-               SHOW_DST(iptr);
-               break;
-
-       case ICMD_NEWARRAY:
-               SHOW_DST(iptr);
-               break;
-
-       case ICMD_ANEWARRAY:
-               SHOW_DST(iptr);
-               break;
-
-       case ICMD_MULTIANEWARRAY:
-               if (stage >= SHOW_STACK) {
-                       argp = iptr->sx.s23.s2.args;
-                       i = iptr->s1.argcount;
-                       while (i--) {
-                               SHOW_VARIABLE(*(argp++));
-                       }
-               }
-               else {
-                       printf("argcount=%d ", iptr->s1.argcount);
-               }
-               class_classref_or_classinfo_print(iptr->sx.s23.s3.c);
-               putchar(' ');
-               SHOW_DST(iptr);
-               break;
-
-       case ICMD_CHECKCAST:
-               SHOW_S1(iptr);
-               class_classref_or_classinfo_print(iptr->sx.s23.s3.c);
-               putchar(' ');
-               SHOW_DST(iptr);
-               break;
-
-       case ICMD_INSTANCEOF:
-               SHOW_S1(iptr);
-               SHOW_DST(iptr);
-               break;
-
-       case ICMD_INLINE_START:
-       case ICMD_INLINE_END:
-       case ICMD_INLINE_BODY:
-#if defined(ENABLE_INLINING)
-               {
-                       insinfo_inline *ii = iptr->sx.s23.s3.inlineinfo;
-                       show_inline_info(jd, ii, opcode, stage);
-               }
-#endif
-               break;
-
-       case ICMD_BUILTIN:
-               if (stage >= SHOW_STACK) {
-                       argp = iptr->sx.s23.s2.args;
-                       i = iptr->s1.argcount;
-                       while (i--) {
-                               if ((iptr->s1.argcount - 1 - i) == iptr->sx.s23.s3.bte->md->paramcount)
-                                       printf(" pass-through: ");
-                               SHOW_VARIABLE(*(argp++));
-                       }
-               }
-               printf("%s ", iptr->sx.s23.s3.bte->cname);
-               if (iptr->sx.s23.s3.bte->md->returntype.type != TYPE_VOID) {
-                       SHOW_DST(iptr);
-               }
-               break;
-
-       case ICMD_INVOKEVIRTUAL:
-       case ICMD_INVOKESPECIAL:
-       case ICMD_INVOKESTATIC:
-       case ICMD_INVOKEINTERFACE:
-               if (stage >= SHOW_STACK) {
-                       methoddesc *md;
-                       INSTRUCTION_GET_METHODDESC(iptr, md);
-                       argp = iptr->sx.s23.s2.args;
-                       i = iptr->s1.argcount;
-                       while (i--) {
-                               if ((iptr->s1.argcount - 1 - i) == md->paramcount)
-                                       printf(" pass-through: ");
-                               SHOW_VARIABLE(*(argp++));
-                       }
-               }
-               INSTRUCTION_GET_METHODREF(iptr, fmiref);
-               method_methodref_print(fmiref);
-               if (fmiref->parseddesc.md->returntype.type != TYPE_VOID) {
-                       putchar(' ');
-                       SHOW_DST(iptr);
-               }
-               break;
-
-       case ICMD_IFEQ:
-       case ICMD_IFNE:
-       case ICMD_IFLT:
-       case ICMD_IFGE:
-       case ICMD_IFGT:
-       case ICMD_IFLE:
-               SHOW_S1(iptr);
-               SHOW_INT_CONST(iptr->sx.val.i); 
-               SHOW_TARGET(iptr->dst);
-               break;
-
-       case ICMD_IF_LEQ:
-       case ICMD_IF_LNE:
-       case ICMD_IF_LLT:
-       case ICMD_IF_LGE:
-       case ICMD_IF_LGT:
-       case ICMD_IF_LLE:
-               SHOW_S1(iptr);
-               SHOW_LNG_CONST(iptr->sx.val.l); 
-               SHOW_TARGET(iptr->dst);
-               break;
-
-       case ICMD_GOTO:
-               SHOW_TARGET(iptr->dst);
-               break;
-
-       case ICMD_JSR:
-               SHOW_TARGET(iptr->sx.s23.s3.jsrtarget);
-               SHOW_DST(iptr);
-               break;
-
-       case ICMD_IFNULL:
-       case ICMD_IFNONNULL:
-               SHOW_S1(iptr);
-               SHOW_TARGET(iptr->dst);
-               break;
-
-       case ICMD_IF_ICMPEQ:
-       case ICMD_IF_ICMPNE:
-       case ICMD_IF_ICMPLT:
-       case ICMD_IF_ICMPGE:
-       case ICMD_IF_ICMPGT:
-       case ICMD_IF_ICMPLE:
-
-       case ICMD_IF_LCMPEQ:
-       case ICMD_IF_LCMPNE:
-       case ICMD_IF_LCMPLT:
-       case ICMD_IF_LCMPGE:
-       case ICMD_IF_LCMPGT:
-       case ICMD_IF_LCMPLE:
-
-       case ICMD_IF_ACMPEQ:
-       case ICMD_IF_ACMPNE:
-               SHOW_S1(iptr);
-               SHOW_S2(iptr);
-               SHOW_TARGET(iptr->dst);
-               break;
-
-       case ICMD_TABLESWITCH:
-               SHOW_S1(iptr);
-               table = iptr->dst.table;
-
-               i = iptr->sx.s23.s3.tablehigh - iptr->sx.s23.s2.tablelow + 1;
-
-               printf("high=%d low=%d count=%d\n", iptr->sx.s23.s3.tablehigh, iptr->sx.s23.s2.tablelow, i);
-               while (--i >= 0) {
-                       printf("\t\t%d --> ", (int) (table - iptr->dst.table));
-                       printf("L%03d\n", table->block->nr);
-                       table++;
-               }
-
-               break;
-
-       case ICMD_LOOKUPSWITCH:
-               SHOW_S1(iptr);
-
-               printf("count=%d, default=L%03d\n",
-                          iptr->sx.s23.s2.lookupcount,
-                          iptr->sx.s23.s3.lookupdefault.block->nr);
-
-               lookup = iptr->dst.lookup;
-               i = iptr->sx.s23.s2.lookupcount;
-
-               while (--i >= 0) {
-                       printf("\t\t%d --> L%03d\n",
-                                  lookup->value,
-                                  lookup->target.block->nr);
-                       lookup++;
-               }
-               break;
-
-       case ICMD_FRETURN:
-       case ICMD_IRETURN:
-       case ICMD_DRETURN:
-       case ICMD_LRETURN:
-               SHOW_S1(iptr);
-               break;
-
-       case ICMD_ARETURN:
-       case ICMD_ATHROW:
-               SHOW_S1(iptr);
-               if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
-                       /* XXX this needs more work */
-#if 0
-                       unresolved_class_debug_dump(iptr->sx.s23.s2.uc, stdout);
-#endif
-               }
-               break;
-
-       case ICMD_COPY:
-       case ICMD_MOVE:
-               SHOW_S1(iptr);
-               SHOW_DST(iptr);
-               break;
-       case ICMD_GETEXCEPTION:
-               SHOW_DST(iptr);
-               break;
-       }
-       fflush(stdout);
-}
-#endif /* !defined(NDEBUG) */
-
-/* Debug output filtering */
-
-#if defined(ENABLE_DEBUG_FILTER)
-
-#if !defined(ENABLE_THREADS)
-u2 _no_threads_filterverbosecallctr[2] = { 0, 0 };
-#endif
-
-struct show_filter {
-       /* Boolean indicating if filter is enabled. */
-       u1 enabled;
-       /* Regular expression the method name is matched against */
-       regex_t regex;
-       /* Flag set on m->filtermatches if regex matches */
-       u1 flag;
-};
-
-typedef struct show_filter show_filter_t;
-
-#define SHOW_FILTERS_SIZE 3
-
-/* Array of filters applyed on a method */
-static struct show_filter show_filters[SHOW_FILTERS_SIZE];
-
-static void show_filter_init(show_filter_t *cf, const char *str, u1 flag, u1 default_flag, const char *description) {
-       int err;
-       char err_buf[128];
-
-       if (str) {
-               err = regcomp(&cf->regex, str, REG_EXTENDED | REG_NOSUB);
-               if (err != 0) {
-                       regerror(err, &cf->regex, err_buf, sizeof(err_buf));
-                       vm_abort(
-                               "Invalid value given for %s: `%s' (%s).", 
-                               description, str, err_buf
-                       );
-               }
-               cf->flag = flag;
-               cf->enabled = 1;
-       } else {
-               cf->flag = default_flag;
-               cf->enabled = 0;
-       }
-}
-
-void show_filters_init(void) {
-
-       show_filter_init(
-               show_filters + 0,
-               opt_filter_verbosecall_include,
-               SHOW_FILTER_FLAG_VERBOSECALL_INCLUDE,
-               SHOW_FILTER_FLAG_VERBOSECALL_INCLUDE,
-               "verbose call include filter"
-       );
-
-       show_filter_init(
-               show_filters + 1,
-               opt_filter_verbosecall_exclude,
-               SHOW_FILTER_FLAG_VERBOSECALL_EXCLUDE,
-               0,
-               "verbose call exclude filter"
-       );
-
-       show_filter_init(
-               show_filters + 2,
-               opt_filter_show_method,
-               SHOW_FILTER_FLAG_SHOW_METHOD,
-               SHOW_FILTER_FLAG_SHOW_METHOD,
-               "show method filter"
-       );
-}
-
-/*
- (Pseudo)State machine:
-
- States are INITIAL, INCLUDE1, INCLUDE2, ..., EXCLUDE1, ..., EXCLUDE2, ...
-
-                                                        Enter              Enter
- Enter                                                  Include            Include
- Exclude                                                  | |                | |
-  | |    Enter              Enter              Enter      | |     Enter      | |
-  | |    Include            Include            Exclude    | |     Exclude    | |
-  | v   --------->        ---------->        ---------->  | v   ---------->  | v
-INITIAL           INCLUDE1           INCLUDE2           EXCLUDE1           EXCLUDE2
-  | ^   <---------        <----------        <----------  | ^   <----------  | ^
-  | |    Exit               Exit               Exit       | |     Exit       | |
-  | |    Include            Include            Exclude    | |     Exclude    | |
-  | |                                                     | |                | |
- Exit                                                    Exit               Exit
- Exclude                                                 Include            Include
-
-  Verbose call scope is active if we are in a INCLUDE state.
-
-  State encoding:
-
-  INITIAL: ctr[0] == 0, ctr[1] == 0
-  INCLUDEN: ctr[1] == N, ctr[1] == 0
-  EXCLUDEN: ctr[1] == N
-*/
-
-void show_filters_apply(methodinfo *m) {
-       int i;
-       int res;
-       char *method_name;
-       s4 len;
-       int32_t dumpmarker;
-
-       /* compose full name of method */
-
-       len = 
-               utf_bytes(m->clazz->name) +
-               1 +
-               utf_bytes(m->name) +
-               utf_bytes(m->descriptor) +
-               1;
-
-       DMARKER;
-
-       method_name = DMNEW(char, len);
-
-       utf_cat_classname(method_name, m->clazz->name);
-       strcat(method_name, ".");
-       utf_cat(method_name, m->name);
-       utf_cat(method_name, m->descriptor);
-
-       /* reset all flags */
-
-       m->filtermatches = 0;
-
-       for (i = 0; i < SHOW_FILTERS_SIZE; ++i) {
-               if (show_filters[i].enabled) {
-
-                       res = regexec(&show_filters[i].regex, method_name, 0, NULL, 0);
-
-                       if (res == 0) {
-                               m->filtermatches |= show_filters[i].flag;
-                       }
-               } else {
-                       /* Default is to show all */
-                       m->filtermatches |= show_filters[i].flag;
-               }
-       }
-
-       /* release memory */
-
-       DRELEASE; 
-}
-
-#define STATE_IS_INITIAL() ((FILTERVERBOSECALLCTR[0] == 0) && (FILTERVERBOSECALLCTR[1] == 0))
-#define STATE_IS_INCLUDE() ((FILTERVERBOSECALLCTR[0] > 0) && (FILTERVERBOSECALLCTR[1] == 0))
-#define STATE_IS_EXCLUDE() (FILTERVERBOSECALLCTR[1] > 0)
-#define EVENT_INCLUDE() (m->filtermatches & SHOW_FILTER_FLAG_VERBOSECALL_INCLUDE)
-#define EVENT_EXCLUDE() (m->filtermatches & SHOW_FILTER_FLAG_VERBOSECALL_EXCLUDE)
-#define TRANSITION_NEXT_INCLUDE() ++FILTERVERBOSECALLCTR[0]
-#define TRANSITION_PREV_INCLUDE() --FILTERVERBOSECALLCTR[0]
-#define TRANSITION_NEXT_EXCLUDE() ++FILTERVERBOSECALLCTR[1]
-#define TRANSITION_PREV_EXCLUDE() --FILTERVERBOSECALLCTR[1]
-
-#if 0
-void dump_state() {
-       if (STATE_IS_INITIAL()) printf("<INITIAL>\n");
-       else if (STATE_IS_INCLUDE()) printf("<INCLUDE %hd>\n", FILTERVERBOSECALLCTR[0]);
-       else if (STATE_IS_EXCLUDE()) printf("<EXCLUDE %hd>\n", FILTERVERBOSECALLCTR[1]);
-}
-#endif
-
-int show_filters_test_verbosecall_enter(methodinfo *m) {
-
-       int force_show = 0;
-
-       if (STATE_IS_INITIAL()) {
-               if (EVENT_INCLUDE()) {
-                       TRANSITION_NEXT_INCLUDE();
-               }
-       } else if (STATE_IS_INCLUDE()) {
-               if (EVENT_EXCLUDE()) {
-                       TRANSITION_NEXT_EXCLUDE();
-                       /* just entered exclude, show this method */
-                       force_show = 1;
-               } else if (EVENT_INCLUDE()) {
-                       TRANSITION_NEXT_INCLUDE();
-               }
-       } else if (STATE_IS_EXCLUDE()) {
-               if (EVENT_EXCLUDE()) {
-                       TRANSITION_NEXT_EXCLUDE();
-               }
-       }
-
-       return STATE_IS_INCLUDE() || force_show;
-}
-
-int show_filters_test_verbosecall_exit(methodinfo *m) {
-
-       int force_show = 0;
-
-       if (m) {
-               if (STATE_IS_INCLUDE()) {
-                       if (EVENT_INCLUDE()) {
-                               TRANSITION_PREV_INCLUDE();
-                               /* just entered initial, show this method */
-                               if (STATE_IS_INITIAL()) force_show = 1;
-                       }
-           } else if (STATE_IS_EXCLUDE()) {
-                       if (EVENT_EXCLUDE()) {
-                               TRANSITION_PREV_EXCLUDE();
-                       }
-               }
-       }
-
-       return STATE_IS_INCLUDE() || force_show;
-}
-
-#endif
-
-
-/*
- * 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/jit/show.cpp b/src/vm/jit/show.cpp
new file mode 100644 (file)
index 0000000..e0ba2a3
--- /dev/null
@@ -0,0 +1,1667 @@
+/* src/vm/jit/show.cpp - showing the intermediate representation
+
+   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 <stdint.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "threads/lock.hpp"
+
+#include "vm/global.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/options.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/abi.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/show.hpp"
+#include "vm/jit/disass.h"
+#include "vm/jit/stack.h"
+#include "vm/jit/parse.hpp"
+
+#if defined(ENABLE_DEBUG_FILTER)
+# include <sys/types.h>
+# include <regex.h>
+# include "threads/thread.hpp"
+#endif
+
+
+/* global variables ***********************************************************/
+
+#if !defined(NDEBUG)
+static Mutex mutex;
+#endif
+
+
+/* prototypes *****************************************************************/
+
+#if !defined(NDEBUG)
+static void show_variable_intern(jitdata *jd, s4 index, int stage);
+#endif
+
+
+/* show_init *******************************************************************
+
+   Initialized the show subsystem (called by jit_init).
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+bool show_init(void)
+{
+#if defined(ENABLE_DEBUG_FILTER)
+       show_filters_init();
+#endif
+
+       /* everything's ok */
+
+       return true;
+}
+#endif
+
+
+#if !defined(NDEBUG)
+const char *show_jit_type_names[] = {
+       "INT",
+       "LNG",
+       "FLT",
+       "DBL",
+       "ADR",
+       "??5",
+       "??6",
+       "??7",
+       "RET"
+};
+
+const char show_jit_type_letters[] = {
+       'I',
+       'L',
+       'F',
+       'D',
+       'A',
+       '5',
+       '6',
+       '7',
+       'R'
+};
+#endif
+
+
+/* show_method *****************************************************************
+
+   Print the intermediate representation of a method.
+
+   NOTE: Currently this function may only be called after register allocation!
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void show_method(jitdata *jd, int stage)
+{
+       methodinfo     *m;
+       codeinfo       *code;
+       codegendata    *cd;
+       registerdata   *rd;
+       basicblock     *bptr;
+       basicblock     *lastbptr;
+       exception_entry *ex;
+       s4              i, j;
+       int             irstage;
+#if defined(ENABLE_DISASSEMBLER)
+       u1             *pc;
+#endif
+
+       /* get required compiler data */
+
+       m    = jd->m;
+       code = jd->code;
+       cd   = jd->cd;
+       rd   = jd->rd;
+
+       // We need to enter a lock here, since the binutils disassembler
+       // is not reentrant-able and we could not read functions printed
+       // at the same time.
+       mutex.lock();
+
+#if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               irstage = SHOW_PARSE;
+       else
+#endif
+               irstage = stage;
+
+       /* get the last basic block */
+
+       for (lastbptr = jd->basicblocks; lastbptr->next != NULL; lastbptr = lastbptr->next);
+
+       printf("\n");
+
+       method_println(m);
+
+       if (code_is_leafmethod(code))
+               printf("LEAFMETHOD\n");
+
+       printf("\nBasic blocks: %d\n", jd->basicblockcount);
+       if (stage >= SHOW_CODE) {
+               printf("Code length:  %d\n", (lastbptr->mpc - jd->basicblocks[0].mpc));
+               printf("Data length:  %d\n", cd->dseglen);
+               printf("Stub length:  %d\n", (s4) (code->mcodelength -
+                                                                                  ((ptrint) cd->dseglen + lastbptr->mpc)));
+       }
+       printf("Variables:       %d (%d used)\n", jd->varcount, jd->vartop);
+       if (stage >= SHOW_STACK)
+               printf("Max interfaces:  %d\n", jd->maxinterfaces);
+       printf("Max locals:      %d\n", jd->maxlocals);
+       printf("Max stack:       %d\n", m->maxstack);
+       printf("Linenumbers:     %d\n", m->linenumbercount);
+       printf("Branch to entry: %s\n", (jd->branchtoentry) ? "yes" : "no");
+       printf("Branch to end:   %s\n", (jd->branchtoend) ? "yes" : "no");
+       if (stage >= SHOW_STACK) {
+               printf("Number of RETURNs: %d", jd->returncount);
+               if (jd->returncount == 1)
+                       printf(" (block L%03d)", jd->returnblock->nr);
+               printf("\n");
+       }
+
+       if (stage >= SHOW_PARSE) {
+               printf("Exceptions (Number: %d):\n", jd->exceptiontablelength);
+               for (ex = jd->exceptiontable; ex != NULL; ex = ex->down) {
+                       printf("    L%03d ... ", ex->start->nr );
+                       printf("L%03d  = ", ex->end->nr);
+                       printf("L%03d", ex->handler->nr);
+                       printf("  (catchtype: ");
+                       if (ex->catchtype.any)
+                               if (IS_CLASSREF(ex->catchtype))
+                                       class_classref_print(ex->catchtype.ref);
+                               else
+                                       class_print(ex->catchtype.cls);
+                       else
+                               printf("ANY");
+                       printf(")\n");
+               }
+       }
+       
+       if (irstage >= SHOW_PARSE && rd && jd->localcount > 0) {
+               printf("Local Table:\n");
+               for (i = 0; i < jd->localcount; i++) {
+                       printf("   %3d: ", i);
+
+#if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
+# if defined(ENABLE_INTRP)
+                       if (!opt_intrp) {
+# endif
+                               printf("   (%s) ", show_jit_type_names[VAR(i)->type]);
+                               if (irstage >= SHOW_REGS)
+                                       show_allocation(VAR(i)->type, VAR(i)->flags, VAR(i)->vv.regoff);
+                               printf("\n");
+# if defined(ENABLE_INTRP)
+                       }
+# endif
+#endif /* defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER) */
+               }
+               printf("\n");
+       }
+
+       if (jd->maxlocals > 0 && jd->local_map != NULL) {
+               printf("Local Map:\n");
+               printf("    index ");
+               for (j = 0; j < jd->maxlocals; j++) {
+                       printf(" [%2d]", j);
+               }
+               printf("\n");
+               for (i = 0; i < 5; i++) {
+                       printf("    %5s ",show_jit_type_names[i]);
+                       for (j = 0; j < jd->maxlocals; j++) {
+                               if (jd->local_map[j*5+i] == UNUSED)
+                                       printf("  -- ");
+                               else
+                                       printf("%4i ",jd->local_map[j*5+i]);
+                       }
+                       printf("\n");
+               }
+               printf("\n");
+       }
+
+       if (jd->maxinterfaces > 0 && jd->interface_map && irstage >= SHOW_STACK) {
+               bool exist = false;
+               interface_info *mapptr = jd->interface_map;
+               
+               /* look if there exist any INOUTS */
+               for (i = 0; (i < (5 * jd->maxinterfaces)) && !exist; i++, mapptr++)
+                       exist = (mapptr->flags != UNUSED);
+
+               if (exist) {
+                       printf("Interface Table: (In/Outvars)\n");
+                       printf("    depth ");
+                       for (j = 0; j < jd->maxinterfaces; j++) {
+                               printf("      [%2d]", j);
+                       }
+                       printf("\n");
+
+                       for (i = 0; i < 5; i++) {
+                               printf("    %5s      ",show_jit_type_names[i]);
+                               for (j = 0; j < jd->maxinterfaces; j++) {
+                                       s4 flags  = jd->interface_map[j*5+i].flags;
+                                       s4 regoff = jd->interface_map[j*5+i].regoff;
+                                       if (flags == UNUSED)
+                                               printf("  --      ");
+                                       else {
+                                               int ch;
+
+                                               if (irstage >= SHOW_REGS) {
+                                                       if (flags & SAVEDVAR) {
+                                                               if (flags & INMEMORY)
+                                                                       ch = 'M';
+                                                               else
+                                                                       ch = 'R';
+                                                       }
+                                                       else {
+                                                               if (flags & INMEMORY)
+                                                                       ch = 'm';
+                                                               else
+                                                                       ch = 'r';
+                                                       }
+                                                       printf("%c%03d(", ch, regoff);
+                                                       show_allocation(i, flags, regoff);
+                                                       printf(") ");
+                                               }
+                                               else {
+                                                       if (flags & SAVEDVAR)
+                                                               printf("  I       ");
+                                                       else
+                                                               printf("  i       ");
+                                               }
+                                       }
+                               }
+                               printf("\n");
+                       }
+                       printf("\n");
+               }
+       }
+
+       if (rd->memuse && irstage >= SHOW_REGS) {
+               int max;
+
+               max = rd->memuse;
+               printf("Stack slots: (memuse=%d", rd->memuse);
+               if (irstage >= SHOW_CODE) {
+                       printf(", stackframesize=%d", cd->stackframesize);
+                       max = cd->stackframesize;
+               }
+               printf(")\n");
+               for (i = 0; i < max; ++i) {
+                       printf("    M%02d = 0x%02x(sp): ", i, i * 8);
+                       for (j = 0; j < jd->vartop; ++j) {
+                               varinfo *v = VAR(j);
+                               if ((v->flags & INMEMORY) && (v->vv.regoff == i)) {
+                                       show_variable(jd, j, irstage);
+                                       putchar(' ');
+                               }
+                       }
+
+                       printf("\n");
+
+               }
+               printf("\n");
+       }
+
+#if defined(ENABLE_REPLACEMENT)
+       if (code->rplpoints) {
+               printf("Replacement Points:\n");
+               replace_show_replacement_points(code);
+               printf("\n");
+       }
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+#if defined(ENABLE_DISASSEMBLER)
+       /* show code before first basic block */
+
+       if ((stage >= SHOW_CODE) && JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
+               pc = (u1 *) ((ptrint) code->mcode + cd->dseglen);
+
+               for (; pc < (u1 *) ((ptrint) code->mcode + cd->dseglen + jd->basicblocks[0].mpc);)
+                       DISASSINSTR(pc);
+
+               printf("\n");
+       }
+#endif
+
+       /* show code of all basic blocks */
+
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next)
+               show_basicblock(jd, bptr, stage);
+
+#if 0 && defined(ENABLE_DISASSEMBLER)
+       /* show code after last basic block */
+
+       if (stage >= SHOW_CODE && opt_showdisassemble) {
+               printf("\nStubs code:\n");
+               printf("Length: %d\n\n", (s4) (code->mcodelength -
+                                                                          ((ptrint) cd->dseglen + lastbptr->mpc)));
+
+               pc = (u1 *) ((ptrint) code->mcode + cd->dseglen + lastbptr->mpc);
+
+               for (; (ptrint) pc < ((ptrint) code->mcode + code->mcodelength);)
+                       DISASSINSTR(pc);
+
+               printf("\n");
+       }
+#endif
+
+       mutex.unlock();
+
+       /* finally flush the output */
+
+       fflush(stdout);
+}
+#endif /* !defined(NDEBUG) */
+
+
+#if !defined(NDEBUG) && defined(ENABLE_INLINING)
+static void show_inline_info(jitdata *jd, insinfo_inline *ii, s4 opcode, s4 stage)
+{
+       s4 *jl;
+       s4 n;
+
+       printf("(pt %d+%d+%d st ", 
+                       ii->throughcount - (ii->stackvarscount - ii->paramcount),
+                       ii->stackvarscount - ii->paramcount,
+                       ii->paramcount);
+       show_variable_array(jd, ii->stackvars, ii->stackvarscount, stage);
+
+       if (opcode == ICMD_INLINE_START || opcode == ICMD_INLINE_END) {
+               printf(" jl ");
+               jl = (opcode == ICMD_INLINE_START) ? ii->javalocals_start : ii->javalocals_end;
+               n = (opcode == ICMD_INLINE_START) ? ii->method->maxlocals : ii->outer->maxlocals;
+               show_javalocals_array(jd, jl, n, stage);
+       }
+
+       printf(") ");
+
+#if 0
+       printf("(");
+       method_print(ii->outer);
+       printf(" ==> ");
+#endif
+
+       method_print(ii->method);
+}
+#endif /* !defined(NDEBUG) && defined(ENABLE_INLINING) */
+
+
+/* show_basicblock *************************************************************
+
+   Print the intermediate representation of a basic block.
+
+   NOTE: Currently this function may only be called after register allocation!
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void show_basicblock(jitdata *jd, basicblock *bptr, int stage)
+{
+       codeinfo    *code;
+       codegendata *cd;
+       s4           i;
+       bool         deadcode;
+       instruction *iptr;
+       int          irstage;
+#if defined(ENABLE_DISASSEMBLER)
+       methodinfo  *m;                     /* this is only a dummy               */
+       void        *pc;
+       s4           linenumber;
+       s4           currentlinenumber;
+#endif
+
+       /* get required compiler data */
+
+       code = jd->code;
+       cd   = jd->cd;
+
+       if (bptr->flags != BBDELETED) {
+#if defined(ENABLE_INTRP)
+               if (opt_intrp) {
+                       deadcode = false;
+                       irstage = SHOW_PARSE;
+               }
+               else
+#endif
+               {
+                       deadcode = (bptr->flags < BBREACHED);
+                       irstage = stage;
+               }
+
+               printf("======== %sL%03d ======== %s(flags: %d, bitflags: %01x, next: %d, type: ",
+#if defined(ENABLE_REPLACEMENT)
+                               (bptr->bitflags & BBFLAG_REPLACEMENT) ? "<REPLACE> " : 
+#endif
+                                                                                                               "",
+                          bptr->nr, 
+                          (deadcode && stage >= SHOW_STACK) ? "DEADCODE! " : "",
+                          bptr->flags, bptr->bitflags, 
+                          (bptr->next) ? (bptr->next->nr) : -1);
+
+               switch (bptr->type) {
+               case BBTYPE_STD:
+                       printf("STD");
+                       break;
+               case BBTYPE_EXH:
+                       printf("EXH");
+                       break;
+               case BBTYPE_SBR:
+                       printf("SBR");
+                       break;
+               }
+
+               printf(", icount: %d", bptr->icount);
+
+               if (irstage >= SHOW_CFG) {
+                       printf(", preds: %d [ ", bptr->predecessorcount);
+
+                       for (i = 0; i < bptr->predecessorcount; i++)
+                               printf("%d ", bptr->predecessors[i]->nr);
+
+                       printf("]");
+               }
+
+               printf("):");
+
+               if (bptr->original)
+                       printf(" (clone of L%03d)", bptr->original->nr);
+               else {
+                       basicblock *b = bptr->copied_to;
+                       if (b) {
+                               printf(" (copied to ");
+                               for (; b; b = b->copied_to)
+                                       printf("L%03d ", b->nr);
+                               printf(")");
+                       }
+               }
+
+               printf("\n");
+
+               if (irstage >= SHOW_CFG) {
+                       printf("succs: %d [ ", bptr->successorcount);
+
+                       for (i = 0; i < bptr->successorcount; i++)
+                               printf("%d ", bptr->successors[i]->nr);
+
+                       printf("]\n");
+               }
+
+               if (irstage >= SHOW_STACK) {
+                       printf("IN:  ");
+                       show_variable_array(jd, bptr->invars, bptr->indepth, irstage);
+                       printf(" javalocals: ");
+                       if (bptr->javalocals)
+                               show_javalocals_array(jd, bptr->javalocals, bptr->method->maxlocals, irstage);
+                       else
+                               printf("null");
+                       printf("\n");
+               }
+
+#if defined(ENABLE_INLINING)
+               if (bptr->inlineinfo) {
+                       printf("inlineinfo: ");
+                       show_inline_info(jd, bptr->inlineinfo, -1, irstage);
+                       printf("\n");
+               }
+#endif /* defined(ENABLE_INLINING) */
+
+#if defined(ENABLE_SSA)
+       
+               iptr = bptr->phis;
+
+               for (i = 0; i < bptr->phicount; i++, iptr++) {
+                       printf("%4d:%4d:  ", iptr->line, iptr->flags.bits >> INS_FLAG_ID_SHIFT);
+
+                       show_icmd(jd, iptr, deadcode, irstage);
+                       printf("\n");
+               }
+#endif
+
+               iptr = bptr->iinstr;
+
+               for (i = 0; i < bptr->icount; i++, iptr++) {
+                       printf("%4d:%4d:  ", iptr->line, iptr->flags.bits >> INS_FLAG_ID_SHIFT);
+
+                       show_icmd(jd, iptr, deadcode, irstage);
+                       printf("\n");
+               }
+
+               if (irstage >= SHOW_STACK) {
+                       printf("OUT: ");
+                       show_variable_array(jd, bptr->outvars, bptr->outdepth, irstage);
+                       printf("\n");
+               }
+
+#if defined(ENABLE_DISASSEMBLER)
+               if ((stage >= SHOW_CODE) && JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) &&
+                       (!deadcode)) 
+               {
+                       printf("\n");
+                       pc         = (void *) (code->mcode + cd->dseglen + bptr->mpc);
+                       linenumber = 0;
+
+                       if (bptr->next != NULL) {
+                               for (; pc < (void *) (code->mcode + cd->dseglen + bptr->next->mpc);) {
+                                       currentlinenumber = code->linenumbertable->find(&m, pc);
+
+                                       if (currentlinenumber != linenumber) {
+                                               linenumber = currentlinenumber;
+                                               printf("%4d:\n", linenumber);
+                                       }
+
+                                       DISASSINSTR(pc);
+                               }
+                       }
+                       else {
+                               for (; pc < (void *) (code->mcode + code->mcodelength);) {
+                                       currentlinenumber = code->linenumbertable->find(&m, pc);
+
+                                       if (currentlinenumber != linenumber) {
+                                               linenumber = currentlinenumber;
+                                               printf("%4d:\n", linenumber);
+                                       }
+
+                                       DISASSINSTR(pc);
+                               }
+                       }
+                       printf("\n");
+               }
+#endif
+       }
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* show_icmd *******************************************************************
+
+   Print the intermediate representation of an instruction.
+
+   NOTE: Currently this function may only be called after register allocation!
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+
+#define SHOW_TARGET(target)                                          \
+        if (stage >= SHOW_PARSE) {                                   \
+            printf("--> L%03d ", (target).block->nr);                \
+        }                                                            \
+        else {                                                       \
+            printf("--> insindex %d ", (target).insindex);           \
+        }
+
+#define SHOW_INT_CONST(val)                                          \
+        if (stage >= SHOW_PARSE) {                                   \
+            printf("%d (0x%08x) ", (int32_t) (val), (int32_t) (val)); \
+        }                                                            \
+        else {                                                       \
+            printf("iconst ");                                       \
+        }
+
+#if SIZEOF_VOID_P == 4
+#define SHOW_LNG_CONST(val)                                          \
+        if (stage >= SHOW_PARSE)                                     \
+            printf("%lld (0x%016llx) ", (val), (val));               \
+        else                                                         \
+            printf("lconst ");
+#else
+#define SHOW_LNG_CONST(val)                                          \
+        if (stage >= SHOW_PARSE)                                     \
+            printf("%ld (0x%016lx) ", (val), (val));                 \
+        else                                                         \
+            printf("lconst ");
+#endif
+
+#if SIZEOF_VOID_P == 4
+#define SHOW_ADR_CONST(val)                                          \
+        if (stage >= SHOW_PARSE)                                     \
+            printf("0x%08x ", (ptrint) (val));                       \
+        else                                                         \
+            printf("aconst ");
+#else
+#define SHOW_ADR_CONST(val)                                          \
+        if (stage >= SHOW_PARSE)                                     \
+            printf("0x%016lx ", (ptrint) (val));                     \
+        else                                                         \
+            printf("aconst ");
+#endif
+
+#define SHOW_FLT_CONST(val)                                          \
+        if (stage >= SHOW_PARSE) {                                   \
+            imm_union v;                                             \
+            v.f = (val);                                             \
+            printf("%g (0x%08x) ", (val), v.i);                      \
+        }                                                            \
+        else {                                                       \
+            printf("fconst ");                                       \
+        }
+
+#if SIZEOF_VOID_P == 4
+#define SHOW_DBL_CONST(val)                                          \
+        if (stage >= SHOW_PARSE) {                                   \
+            imm_union v;                                             \
+            v.d = (val);                                             \
+            printf("%g (0x%016llx) ", (val), v.l);                   \
+        }                                                            \
+        else                                                         \
+            printf("dconst ");
+#else
+#define SHOW_DBL_CONST(val)                                          \
+        if (stage >= SHOW_PARSE) {                                   \
+            imm_union v;                                             \
+            v.d = (val);                                             \
+            printf("%g (0x%016lx) ", (val), v.l);                    \
+        }                                                            \
+        else                                                         \
+            printf("dconst ");
+#endif
+
+#define SHOW_INDEX(index)                                            \
+        if (stage >= SHOW_PARSE) {                                   \
+            printf("%d ", index);                                    \
+        }                                                            \
+        else {                                                       \
+            printf("index");                                         \
+        }
+
+#define SHOW_STRING(val)                                             \
+        if (stage >= SHOW_PARSE) {                                   \
+            putchar('"');                                            \
+            utf_display_printable_ascii(                             \
+               javastring_toutf((java_handle_t *)(val), false));     \
+            printf("\" ");                                           \
+        }                                                            \
+        else {                                                       \
+            printf("string ");                                       \
+        }
+
+#define SHOW_CLASSREF_OR_CLASSINFO(c)                                \
+        if (stage >= SHOW_PARSE) {                                   \
+            if (IS_CLASSREF(c))                                      \
+                class_classref_print(c.ref);                         \
+            else                                                     \
+                class_print(c.cls);                                  \
+            putchar(' ');                                            \
+        }                                                            \
+        else {                                                       \
+            printf("class ");                                        \
+        }
+
+#define SHOW_FIELD(fmiref)                                           \
+        if (stage >= SHOW_PARSE) {                                   \
+            field_fieldref_print(fmiref);                            \
+            putchar(' ');                                            \
+        }                                                            \
+        else {                                                       \
+            printf("field ");                                        \
+        }
+
+#define SHOW_VARIABLE(v)                                             \
+    show_variable(jd, (v), stage)
+
+#define SHOW_S1(iptr)                                                \
+        if (stage >= SHOW_STACK) {                                   \
+            SHOW_VARIABLE(iptr->s1.varindex);                        \
+        }
+
+#define SHOW_S2(iptr)                                                \
+        if (stage >= SHOW_STACK) {                                   \
+            SHOW_VARIABLE(iptr->sx.s23.s2.varindex);                 \
+        }
+
+#define SHOW_S3(iptr)                                                \
+    if (stage >= SHOW_STACK) {                                       \
+        SHOW_VARIABLE(iptr->sx.s23.s3.varindex);                     \
+    }
+
+#define SHOW_DST(iptr)                                               \
+    if (stage >= SHOW_STACK) {                                       \
+        printf("=> ");                                               \
+        SHOW_VARIABLE(iptr->dst.varindex);                           \
+    }
+
+#define SHOW_S1_LOCAL(iptr)                                          \
+    if (stage >= SHOW_STACK) {                                       \
+        printf("L%d ", iptr->s1.varindex);                           \
+    }                                                                \
+    else {                                                           \
+        printf("JavaL%d ", iptr->s1.varindex);                       \
+    }
+
+#define SHOW_DST_LOCAL(iptr)                                         \
+    if (stage >= SHOW_STACK) {                                       \
+        printf("=> L%d ", iptr->dst.varindex);                       \
+    }                                                                \
+    else {                                                           \
+        printf("=> JavaL%d ", iptr->dst.varindex);                   \
+    }
+
+void show_allocation(s4 type, s4 flags, s4 regoff)
+{
+       if (type == TYPE_RET) {
+               printf("N/A");
+               return;
+       }
+
+       if (flags & INMEMORY) {
+               printf("M%02d", regoff);
+               return;
+       }
+
+#ifdef HAS_ADDRESS_REGISTER_FILE
+       if (type == TYPE_ADR) {
+               printf("R%02d", regoff);
+               return;
+       }
+#endif
+
+       if (IS_FLT_DBL_TYPE(type)) {
+               printf("F%02d", regoff);
+               return;
+       }
+
+#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+       if (IS_2_WORD_TYPE(type)) {
+# if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
+#  if defined(ENABLE_INTRP)
+               if (opt_intrp)
+                       printf("%3d/%3d", GET_LOW_REG(regoff),
+                                       GET_HIGH_REG(regoff));
+               else
+#  endif
+                       printf("%3s/%3s", abi_registers_integer_name[GET_LOW_REG(regoff)],
+                                  abi_registers_integer_name[GET_HIGH_REG(regoff)]);
+# else
+               printf("%3d/%3d", GET_LOW_REG(regoff),
+                          GET_HIGH_REG(regoff));
+# endif
+               return;
+       } 
+#endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */
+
+#if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
+# if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               printf("%3d", regoff);
+       else
+# endif
+               printf("%3s", abi_registers_integer_name[regoff]);
+#else
+       printf("%3d", regoff);
+#endif
+}
+
+void show_variable(jitdata *jd, s4 index, int stage)
+{
+       show_variable_intern(jd, index, stage);
+       putchar(' ');
+}
+
+static void show_variable_intern(jitdata *jd, s4 index, int stage)
+{
+       char type;
+       char kind;
+       varinfo *v;
+
+       if (index < 0 || index >= jd->vartop) {
+               printf("<INVALID INDEX:%d>", index);
+               return;
+       }
+
+       v = VAR(index);
+
+       switch (v->type) {
+               case TYPE_INT: type = 'i'; break;
+               case TYPE_LNG: type = 'l'; break;
+               case TYPE_FLT: type = 'f'; break;
+               case TYPE_DBL: type = 'd'; break;
+               case TYPE_ADR: type = 'a'; break;
+               case TYPE_RET: type = 'r'; break;
+               default:       type = '?';
+       }
+
+       if (index < jd->localcount) {
+               kind = 'L';
+               if (v->flags & (PREALLOC | INOUT))
+                               printf("<INVALID FLAGS!>");
+       }
+       else {
+               if (v->flags & PREALLOC) {
+                       kind = 'A';
+                       if (v->flags & INOUT) {
+                               /* PREALLOC is used to avoid allocation of TYPE_RET */
+                               if (v->type == TYPE_RET)
+                                       kind = 'i';
+                               else
+                                       printf("<INVALID FLAGS!>");
+                       }
+               }
+               else if (v->flags & INOUT)
+                       kind = 'I';
+               else
+                       kind = 'T';
+       }
+
+       printf("%c%c%d", kind, type, index);
+
+       if (v->flags & SAVEDVAR)
+               putchar('!');
+
+       if (stage >= SHOW_REGS || (v->flags & PREALLOC)) {
+               putchar('(');
+               show_allocation(v->type, v->flags, v->vv.regoff);
+               putchar(')');
+       }
+
+       if (v->type == TYPE_RET && (v->flags & PREALLOC)) {
+               printf("(L%03d)", v->vv.retaddr->nr);
+       }
+}
+
+static void show_variable_array_intern(jitdata *jd, s4 *vars, int n, int stage,
+                                                                          bool javalocals)
+{
+       int i;
+       int nr;
+
+       if (vars == NULL) {
+               printf("<null>");
+               return;
+       }
+
+       printf("[");
+       for (i=0; i<n; ++i) {
+               if (i)
+                       putchar(' ');
+               if (vars[i] < 0) {
+                       if (vars[i] == UNUSED)
+                               putchar('-');
+                       else if (javalocals) {
+                               nr = RETADDR_FROM_JAVALOCAL(vars[i]);
+                               printf("ret(L%03d)", nr);
+                       }
+                       else {
+                               printf("<INVALID INDEX:%d>", vars[i]);
+                       }
+               }
+               else
+                       show_variable_intern(jd, vars[i], stage);
+       }
+       printf("]");
+}
+
+void show_variable_array(jitdata *jd, s4 *vars, int n, int stage)
+{
+       show_variable_array_intern(jd, vars, n, stage, false);
+}
+
+void show_javalocals_array(jitdata *jd, s4 *vars, int n, int stage)
+{
+       show_variable_array_intern(jd, vars, n, stage, true);
+}
+
+void show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage)
+{
+       u2                 opcode;
+       branch_target_t   *table;
+       lookup_target_t   *lookup;
+       constant_FMIref   *fmiref;
+       s4                *argp;
+       s4                 i;
+
+       /* get the opcode and the condition */
+
+       opcode    =  iptr->opc;
+
+       printf("%s ", icmd_table[opcode].name);
+
+       if (stage < SHOW_PARSE)
+               return;
+
+       if (deadcode)
+               stage = SHOW_PARSE;
+
+       /* Print the condition for conditional instructions. */
+
+       /* XXX print condition from flags */
+
+       if (iptr->flags.bits & INS_FLAG_UNRESOLVED)
+               printf("(UNRESOLVED) ");
+
+       switch (opcode) {
+
+       case ICMD_POP:
+       case ICMD_CHECKNULL:
+               SHOW_S1(iptr);
+               break;
+
+               /* unary */
+       case ICMD_ARRAYLENGTH:
+       case ICMD_INEG:
+       case ICMD_LNEG:
+       case ICMD_FNEG:
+       case ICMD_DNEG:
+       case ICMD_I2L:
+       case ICMD_I2F:
+       case ICMD_I2D:
+       case ICMD_L2I:
+       case ICMD_L2F:
+       case ICMD_L2D:
+       case ICMD_F2I:
+       case ICMD_F2L:
+       case ICMD_F2D:
+       case ICMD_D2I:
+       case ICMD_D2L:
+       case ICMD_D2F:
+       case ICMD_INT2BYTE:
+       case ICMD_INT2CHAR:
+       case ICMD_INT2SHORT:
+               SHOW_S1(iptr);
+               SHOW_DST(iptr);
+               break;
+
+               /* binary */
+       case ICMD_IADD:
+       case ICMD_LADD:
+       case ICMD_FADD:
+       case ICMD_DADD:
+       case ICMD_ISUB:
+       case ICMD_LSUB:
+       case ICMD_FSUB:
+       case ICMD_DSUB:
+       case ICMD_IMUL:
+       case ICMD_LMUL:
+       case ICMD_FMUL:
+       case ICMD_DMUL:
+       case ICMD_IDIV:
+       case ICMD_LDIV:
+       case ICMD_FDIV:
+       case ICMD_DDIV:
+       case ICMD_IREM:
+       case ICMD_LREM:
+       case ICMD_FREM:
+       case ICMD_DREM:
+       case ICMD_ISHL:
+       case ICMD_LSHL:
+       case ICMD_ISHR:
+       case ICMD_LSHR:
+       case ICMD_IUSHR:
+       case ICMD_LUSHR:
+       case ICMD_IAND:
+       case ICMD_LAND:
+       case ICMD_IOR:
+       case ICMD_LOR:
+       case ICMD_IXOR:
+       case ICMD_LXOR:
+       case ICMD_LCMP:
+       case ICMD_FCMPL:
+       case ICMD_FCMPG:
+       case ICMD_DCMPL:
+       case ICMD_DCMPG:
+               SHOW_S1(iptr);
+               SHOW_S2(iptr);
+               SHOW_DST(iptr);
+               break;
+
+               /* binary/const INT */
+       case ICMD_IADDCONST:
+       case ICMD_ISUBCONST:
+       case ICMD_IMULCONST:
+       case ICMD_IMULPOW2:
+       case ICMD_IDIVPOW2:
+       case ICMD_IREMPOW2:
+       case ICMD_IANDCONST:
+       case ICMD_IORCONST:
+       case ICMD_IXORCONST:
+       case ICMD_ISHLCONST:
+       case ICMD_ISHRCONST:
+       case ICMD_IUSHRCONST:
+       case ICMD_LSHLCONST:
+       case ICMD_LSHRCONST:
+       case ICMD_LUSHRCONST:
+               SHOW_S1(iptr);
+               SHOW_INT_CONST(iptr->sx.val.i); 
+               SHOW_DST(iptr);
+               break;
+
+               /* ?ASTORECONST (trinary/const INT) */
+       case ICMD_IASTORECONST:
+       case ICMD_BASTORECONST:
+       case ICMD_CASTORECONST:
+       case ICMD_SASTORECONST:
+               SHOW_S1(iptr);
+               SHOW_S2(iptr);
+               SHOW_INT_CONST(iptr->sx.s23.s3.constval);
+               break;
+
+               /* const INT */
+       case ICMD_ICONST:
+               SHOW_INT_CONST(iptr->sx.val.i); 
+               SHOW_DST(iptr);
+               break;
+
+               /* binary/const LNG */
+       case ICMD_LADDCONST:
+       case ICMD_LSUBCONST:
+       case ICMD_LMULCONST:
+       case ICMD_LMULPOW2:
+       case ICMD_LDIVPOW2:
+       case ICMD_LREMPOW2:
+       case ICMD_LANDCONST:
+       case ICMD_LORCONST:
+       case ICMD_LXORCONST:
+               SHOW_S1(iptr);
+               SHOW_LNG_CONST(iptr->sx.val.l);
+               SHOW_DST(iptr);
+               break;
+
+               /* trinary/const LNG (<= pointer size) */
+       case ICMD_LASTORECONST:
+               SHOW_S1(iptr);
+               SHOW_S2(iptr);
+               SHOW_ADR_CONST(iptr->sx.s23.s3.constval);
+               break;
+
+               /* const LNG */
+       case ICMD_LCONST:
+               SHOW_LNG_CONST(iptr->sx.val.l); 
+               SHOW_DST(iptr);
+               break;
+
+               /* const FLT */
+       case ICMD_FCONST:
+               SHOW_FLT_CONST(iptr->sx.val.f); 
+               SHOW_DST(iptr);
+               break;
+
+               /* const DBL */
+       case ICMD_DCONST:
+               SHOW_DBL_CONST(iptr->sx.val.d); 
+               SHOW_DST(iptr);
+               break;
+
+               /* const ADR */
+       case ICMD_ACONST:
+               if (iptr->flags.bits & INS_FLAG_CLASS) {
+                       SHOW_ADR_CONST(iptr->sx.val.anyptr);
+                       SHOW_CLASSREF_OR_CLASSINFO(iptr->sx.val.c);
+               }
+               else if (iptr->sx.val.anyptr == NULL) {
+                       printf("NULL ");
+               }
+               else {
+                       SHOW_ADR_CONST(iptr->sx.val.anyptr);
+                       SHOW_STRING(iptr->sx.val.stringconst);
+               }
+               SHOW_DST(iptr);
+               break;
+
+       case ICMD_AASTORECONST:
+               SHOW_S1(iptr);
+               SHOW_S2(iptr);
+               printf("%p ", (void*) iptr->sx.s23.s3.constval);
+               break;
+
+       case ICMD_GETFIELD:        /* 1 -> 1 */
+       case ICMD_PUTFIELD:        /* 2 -> 0 */
+       case ICMD_PUTSTATIC:       /* 1 -> 0 */
+       case ICMD_GETSTATIC:       /* 0 -> 1 */
+       case ICMD_PUTSTATICCONST:  /* 0 -> 0 */
+       case ICMD_PUTFIELDCONST:   /* 1 -> 0 */
+               if (opcode != ICMD_GETSTATIC && opcode != ICMD_PUTSTATICCONST) {
+                       SHOW_S1(iptr);
+                       if (opcode == ICMD_PUTFIELD) {
+                               SHOW_S2(iptr);
+                       }
+               }
+               INSTRUCTION_GET_FIELDREF(iptr, fmiref);
+               SHOW_FIELD(fmiref);
+
+               if (opcode == ICMD_GETSTATIC || opcode == ICMD_GETFIELD) {
+                       SHOW_DST(iptr);
+               }
+               break;
+
+       case ICMD_IINC:
+               SHOW_S1_LOCAL(iptr);
+               SHOW_INT_CONST(iptr->sx.val.i);
+               SHOW_DST_LOCAL(iptr);
+               break;
+
+       case ICMD_IASTORE:
+       case ICMD_SASTORE:
+       case ICMD_BASTORE:
+       case ICMD_CASTORE:
+       case ICMD_LASTORE:
+       case ICMD_DASTORE:
+       case ICMD_FASTORE:
+       case ICMD_AASTORE:
+               SHOW_S1(iptr);
+               SHOW_S2(iptr);
+               SHOW_S3(iptr);
+               break;
+
+       case ICMD_IALOAD:
+       case ICMD_SALOAD:
+       case ICMD_BALOAD:
+       case ICMD_CALOAD:
+       case ICMD_LALOAD:
+       case ICMD_DALOAD:
+       case ICMD_FALOAD:
+       case ICMD_AALOAD:
+               SHOW_S1(iptr);
+               SHOW_S2(iptr);
+               SHOW_DST(iptr);
+               break;
+
+       case ICMD_RET:
+               SHOW_S1_LOCAL(iptr);
+               if (stage >= SHOW_STACK) {
+                       printf(" ---> L%03d", iptr->dst.block->nr);
+               }
+               break;
+
+       case ICMD_ILOAD:
+       case ICMD_LLOAD:
+       case ICMD_FLOAD:
+       case ICMD_DLOAD:
+       case ICMD_ALOAD:
+               SHOW_S1_LOCAL(iptr);
+               SHOW_DST(iptr);
+               break;
+
+       case ICMD_ISTORE:
+       case ICMD_LSTORE:
+       case ICMD_FSTORE:
+       case ICMD_DSTORE:
+       case ICMD_ASTORE:
+               SHOW_S1(iptr);
+               SHOW_DST_LOCAL(iptr);
+               if (stage >= SHOW_STACK && iptr->sx.s23.s3.javaindex != UNUSED)
+                       printf(" (javaindex %d)", iptr->sx.s23.s3.javaindex);
+               if (iptr->flags.bits & INS_FLAG_RETADDR) {
+                       printf(" (retaddr L%03d)", RETADDR_FROM_JAVALOCAL(iptr->sx.s23.s2.retaddrnr));
+               }
+               break;
+
+       case ICMD_NEW:
+               SHOW_DST(iptr);
+               break;
+
+       case ICMD_NEWARRAY:
+               SHOW_DST(iptr);
+               break;
+
+       case ICMD_ANEWARRAY:
+               SHOW_DST(iptr);
+               break;
+
+       case ICMD_MULTIANEWARRAY:
+               if (stage >= SHOW_STACK) {
+                       argp = iptr->sx.s23.s2.args;
+                       i = iptr->s1.argcount;
+                       while (i--) {
+                               SHOW_VARIABLE(*(argp++));
+                       }
+               }
+               else {
+                       printf("argcount=%d ", iptr->s1.argcount);
+               }
+               class_classref_or_classinfo_print(iptr->sx.s23.s3.c);
+               putchar(' ');
+               SHOW_DST(iptr);
+               break;
+
+       case ICMD_CHECKCAST:
+               SHOW_S1(iptr);
+               class_classref_or_classinfo_print(iptr->sx.s23.s3.c);
+               putchar(' ');
+               SHOW_DST(iptr);
+               break;
+
+       case ICMD_INSTANCEOF:
+               SHOW_S1(iptr);
+               SHOW_DST(iptr);
+               break;
+
+       case ICMD_INLINE_START:
+       case ICMD_INLINE_END:
+       case ICMD_INLINE_BODY:
+#if defined(ENABLE_INLINING)
+               {
+                       insinfo_inline *ii = iptr->sx.s23.s3.inlineinfo;
+                       show_inline_info(jd, ii, opcode, stage);
+               }
+#endif
+               break;
+
+       case ICMD_BUILTIN:
+               if (stage >= SHOW_STACK) {
+                       argp = iptr->sx.s23.s2.args;
+                       i = iptr->s1.argcount;
+                       while (i--) {
+                               if ((iptr->s1.argcount - 1 - i) == iptr->sx.s23.s3.bte->md->paramcount)
+                                       printf(" pass-through: ");
+                               SHOW_VARIABLE(*(argp++));
+                       }
+               }
+               printf("%s ", iptr->sx.s23.s3.bte->cname);
+               if (iptr->sx.s23.s3.bte->md->returntype.type != TYPE_VOID) {
+                       SHOW_DST(iptr);
+               }
+               break;
+
+       case ICMD_INVOKEVIRTUAL:
+       case ICMD_INVOKESPECIAL:
+       case ICMD_INVOKESTATIC:
+       case ICMD_INVOKEINTERFACE:
+               if (stage >= SHOW_STACK) {
+                       methoddesc *md;
+                       INSTRUCTION_GET_METHODDESC(iptr, md);
+                       argp = iptr->sx.s23.s2.args;
+                       i = iptr->s1.argcount;
+                       while (i--) {
+                               if ((iptr->s1.argcount - 1 - i) == md->paramcount)
+                                       printf(" pass-through: ");
+                               SHOW_VARIABLE(*(argp++));
+                       }
+               }
+               INSTRUCTION_GET_METHODREF(iptr, fmiref);
+               method_methodref_print(fmiref);
+               if (fmiref->parseddesc.md->returntype.type != TYPE_VOID) {
+                       putchar(' ');
+                       SHOW_DST(iptr);
+               }
+               break;
+
+       case ICMD_IFEQ:
+       case ICMD_IFNE:
+       case ICMD_IFLT:
+       case ICMD_IFGE:
+       case ICMD_IFGT:
+       case ICMD_IFLE:
+               SHOW_S1(iptr);
+               SHOW_INT_CONST(iptr->sx.val.i); 
+               SHOW_TARGET(iptr->dst);
+               break;
+
+       case ICMD_IF_LEQ:
+       case ICMD_IF_LNE:
+       case ICMD_IF_LLT:
+       case ICMD_IF_LGE:
+       case ICMD_IF_LGT:
+       case ICMD_IF_LLE:
+               SHOW_S1(iptr);
+               SHOW_LNG_CONST(iptr->sx.val.l); 
+               SHOW_TARGET(iptr->dst);
+               break;
+
+       case ICMD_GOTO:
+               SHOW_TARGET(iptr->dst);
+               break;
+
+       case ICMD_JSR:
+               SHOW_TARGET(iptr->sx.s23.s3.jsrtarget);
+               SHOW_DST(iptr);
+               break;
+
+       case ICMD_IFNULL:
+       case ICMD_IFNONNULL:
+               SHOW_S1(iptr);
+               SHOW_TARGET(iptr->dst);
+               break;
+
+       case ICMD_IF_ICMPEQ:
+       case ICMD_IF_ICMPNE:
+       case ICMD_IF_ICMPLT:
+       case ICMD_IF_ICMPGE:
+       case ICMD_IF_ICMPGT:
+       case ICMD_IF_ICMPLE:
+
+       case ICMD_IF_LCMPEQ:
+       case ICMD_IF_LCMPNE:
+       case ICMD_IF_LCMPLT:
+       case ICMD_IF_LCMPGE:
+       case ICMD_IF_LCMPGT:
+       case ICMD_IF_LCMPLE:
+
+       case ICMD_IF_ACMPEQ:
+       case ICMD_IF_ACMPNE:
+               SHOW_S1(iptr);
+               SHOW_S2(iptr);
+               SHOW_TARGET(iptr->dst);
+               break;
+
+       case ICMD_TABLESWITCH:
+               SHOW_S1(iptr);
+               table = iptr->dst.table;
+
+               i = iptr->sx.s23.s3.tablehigh - iptr->sx.s23.s2.tablelow + 1;
+
+               printf("high=%d low=%d count=%d\n", iptr->sx.s23.s3.tablehigh, iptr->sx.s23.s2.tablelow, i);
+               while (--i >= 0) {
+                       printf("\t\t%d --> ", (int) (table - iptr->dst.table));
+                       printf("L%03d\n", table->block->nr);
+                       table++;
+               }
+
+               break;
+
+       case ICMD_LOOKUPSWITCH:
+               SHOW_S1(iptr);
+
+               printf("count=%d, default=L%03d\n",
+                          iptr->sx.s23.s2.lookupcount,
+                          iptr->sx.s23.s3.lookupdefault.block->nr);
+
+               lookup = iptr->dst.lookup;
+               i = iptr->sx.s23.s2.lookupcount;
+
+               while (--i >= 0) {
+                       printf("\t\t%d --> L%03d\n",
+                                  lookup->value,
+                                  lookup->target.block->nr);
+                       lookup++;
+               }
+               break;
+
+       case ICMD_FRETURN:
+       case ICMD_IRETURN:
+       case ICMD_DRETURN:
+       case ICMD_LRETURN:
+               SHOW_S1(iptr);
+               break;
+
+       case ICMD_ARETURN:
+       case ICMD_ATHROW:
+               SHOW_S1(iptr);
+               if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
+                       /* XXX this needs more work */
+#if 0
+                       unresolved_class_debug_dump(iptr->sx.s23.s2.uc, stdout);
+#endif
+               }
+               break;
+
+       case ICMD_COPY:
+       case ICMD_MOVE:
+               SHOW_S1(iptr);
+               SHOW_DST(iptr);
+               break;
+       case ICMD_GETEXCEPTION:
+               SHOW_DST(iptr);
+               break;
+#if defined(ENABLE_SSA)        
+       case ICMD_PHI:
+               printf("[ ");
+               for (i = 0; i < iptr->s1.argcount; ++i) {
+                       SHOW_VARIABLE(iptr->sx.s23.s2.iargs[i]->dst.varindex);
+               }
+               printf("] ");
+               SHOW_DST(iptr);
+               if (iptr->flags.bits & (1 << 0)) printf("used ");
+               if (iptr->flags.bits & (1 << 1)) printf("redundantAll ");
+               if (iptr->flags.bits & (1 << 2)) printf("redundantOne ");
+               break;
+#endif
+       }
+       fflush(stdout);
+}
+#endif /* !defined(NDEBUG) */
+
+/* Debug output filtering */
+
+#if defined(ENABLE_DEBUG_FILTER)
+
+#if !defined(ENABLE_THREADS)
+u2 _no_threads_filterverbosecallctr[2] = { 0, 0 };
+#endif
+
+struct show_filter {
+       /* Boolean indicating if filter is enabled. */
+       u1 enabled;
+       /* Regular expression the method name is matched against */
+       regex_t regex;
+       /* Flag set on m->filtermatches if regex matches */
+       u1 flag;
+};
+
+typedef struct show_filter show_filter_t;
+
+#define SHOW_FILTERS_SIZE 3
+
+/* Array of filters applyed on a method */
+static struct show_filter show_filters[SHOW_FILTERS_SIZE];
+
+static void show_filter_init(show_filter_t *cf, const char *str, u1 flag, u1 default_flag, const char *description) {
+       int err;
+       char err_buf[128];
+
+       if (str) {
+               err = regcomp(&cf->regex, str, REG_EXTENDED | REG_NOSUB);
+               if (err != 0) {
+                       regerror(err, &cf->regex, err_buf, sizeof(err_buf));
+                       vm_abort(
+                               "Invalid value given for %s: `%s' (%s).", 
+                               description, str, err_buf
+                       );
+               }
+               cf->flag = flag;
+               cf->enabled = 1;
+       } else {
+               cf->flag = default_flag;
+               cf->enabled = 0;
+       }
+}
+
+void show_filters_init(void) {
+
+       show_filter_init(
+               show_filters + 0,
+               opt_filter_verbosecall_include,
+               SHOW_FILTER_FLAG_VERBOSECALL_INCLUDE,
+               SHOW_FILTER_FLAG_VERBOSECALL_INCLUDE,
+               "verbose call include filter"
+       );
+
+       show_filter_init(
+               show_filters + 1,
+               opt_filter_verbosecall_exclude,
+               SHOW_FILTER_FLAG_VERBOSECALL_EXCLUDE,
+               0,
+               "verbose call exclude filter"
+       );
+
+       show_filter_init(
+               show_filters + 2,
+               opt_filter_show_method,
+               SHOW_FILTER_FLAG_SHOW_METHOD,
+               SHOW_FILTER_FLAG_SHOW_METHOD,
+               "show method filter"
+       );
+}
+
+/*
+ (Pseudo)State machine:
+
+ States are INITIAL, INCLUDE1, INCLUDE2, ..., EXCLUDE1, ..., EXCLUDE2, ...
+
+                                                        Enter              Enter
+ Enter                                                  Include            Include
+ Exclude                                                  | |                | |
+  | |    Enter              Enter              Enter      | |     Enter      | |
+  | |    Include            Include            Exclude    | |     Exclude    | |
+  | v   --------->        ---------->        ---------->  | v   ---------->  | v
+INITIAL           INCLUDE1           INCLUDE2           EXCLUDE1           EXCLUDE2
+  | ^   <---------        <----------        <----------  | ^   <----------  | ^
+  | |    Exit               Exit               Exit       | |     Exit       | |
+  | |    Include            Include            Exclude    | |     Exclude    | |
+  | |                                                     | |                | |
+ Exit                                                    Exit               Exit
+ Exclude                                                 Include            Include
+
+  Verbose call scope is active if we are in a INCLUDE state.
+
+  State encoding:
+
+  INITIAL: ctr[0] == 0, ctr[1] == 0
+  INCLUDEN: ctr[1] == N, ctr[1] == 0
+  EXCLUDEN: ctr[1] == N
+*/
+
+void show_filters_apply(methodinfo *m) {
+       int i;
+       int res;
+       char *method_name;
+       s4 len;
+
+       /* compose full name of method */
+
+       len = 
+               utf_bytes(m->clazz->name) +
+               1 +
+               utf_bytes(m->name) +
+               utf_bytes(m->descriptor) +
+               1;
+
+       method_name = MNEW(char, len);
+
+       utf_cat_classname(method_name, m->clazz->name);
+       strcat(method_name, ".");
+       utf_cat(method_name, m->name);
+       utf_cat(method_name, m->descriptor);
+
+       /* reset all flags */
+
+       m->filtermatches = 0;
+
+       for (i = 0; i < SHOW_FILTERS_SIZE; ++i) {
+               if (show_filters[i].enabled) {
+
+                       res = regexec(&show_filters[i].regex, method_name, 0, NULL, 0);
+
+                       if (res == 0) {
+                               m->filtermatches |= show_filters[i].flag;
+                       }
+               } else {
+                       /* Default is to show all */
+                       m->filtermatches |= show_filters[i].flag;
+               }
+       }
+
+       // Release memory.
+       MFREE(method_name, char, len);
+}
+
+#define STATE_IS_INITIAL() ((FILTERVERBOSECALLCTR[0] == 0) && (FILTERVERBOSECALLCTR[1] == 0))
+#define STATE_IS_INCLUDE() ((FILTERVERBOSECALLCTR[0] > 0) && (FILTERVERBOSECALLCTR[1] == 0))
+#define STATE_IS_EXCLUDE() (FILTERVERBOSECALLCTR[1] > 0)
+#define EVENT_INCLUDE() (m->filtermatches & SHOW_FILTER_FLAG_VERBOSECALL_INCLUDE)
+#define EVENT_EXCLUDE() (m->filtermatches & SHOW_FILTER_FLAG_VERBOSECALL_EXCLUDE)
+#define TRANSITION_NEXT_INCLUDE() ++FILTERVERBOSECALLCTR[0]
+#define TRANSITION_PREV_INCLUDE() --FILTERVERBOSECALLCTR[0]
+#define TRANSITION_NEXT_EXCLUDE() ++FILTERVERBOSECALLCTR[1]
+#define TRANSITION_PREV_EXCLUDE() --FILTERVERBOSECALLCTR[1]
+
+#if 0
+void dump_state() {
+       if (STATE_IS_INITIAL()) printf("<INITIAL>\n");
+       else if (STATE_IS_INCLUDE()) printf("<INCLUDE %hd>\n", FILTERVERBOSECALLCTR[0]);
+       else if (STATE_IS_EXCLUDE()) printf("<EXCLUDE %hd>\n", FILTERVERBOSECALLCTR[1]);
+}
+#endif
+
+int show_filters_test_verbosecall_enter(methodinfo *m) {
+
+       int force_show = 0;
+
+       if (STATE_IS_INITIAL()) {
+               if (EVENT_INCLUDE()) {
+                       TRANSITION_NEXT_INCLUDE();
+               }
+       } else if (STATE_IS_INCLUDE()) {
+               if (EVENT_EXCLUDE()) {
+                       TRANSITION_NEXT_EXCLUDE();
+                       /* just entered exclude, show this method */
+                       force_show = 1;
+               } else if (EVENT_INCLUDE()) {
+                       TRANSITION_NEXT_INCLUDE();
+               }
+       } else if (STATE_IS_EXCLUDE()) {
+               if (EVENT_EXCLUDE()) {
+                       TRANSITION_NEXT_EXCLUDE();
+               }
+       }
+
+       return STATE_IS_INCLUDE() || force_show;
+}
+
+int show_filters_test_verbosecall_exit(methodinfo *m) {
+
+       int force_show = 0;
+
+       if (m) {
+               if (STATE_IS_INCLUDE()) {
+                       if (EVENT_INCLUDE()) {
+                               TRANSITION_PREV_INCLUDE();
+                               /* just entered initial, show this method */
+                               if (STATE_IS_INITIAL()) force_show = 1;
+                       }
+           } else if (STATE_IS_EXCLUDE()) {
+                       if (EVENT_EXCLUDE()) {
+                               TRANSITION_PREV_EXCLUDE();
+                       }
+               }
+       }
+
+       return STATE_IS_INCLUDE() || force_show;
+}
+
+#endif
+
+
+/*
+ * 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/jit/show.h b/src/vm/jit/show.h
deleted file mode 100644 (file)
index 5739322..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* src/vm/jit/show.h - showing the intermediate representation
-
-   Copyright (C) 1996-2005, 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
-
-   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.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Andreas Krall
-
-   Changes: Edwin Steiner
-            Christian Thalinger
-            Christian Ullrich
-
-
-*/
-
-
-#ifndef _SHOW_H
-#define _SHOW_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/jit/jit.h"
-
-
-/* compiler stage defines *****************************************************/
-
-#define SHOW_INSTRUCTIONS  0
-#define SHOW_PARSE         1
-#define SHOW_STACK         2
-#define SHOW_CFG           3
-#define SHOW_REGS          4
-#define SHOW_CODE          5
-
-
-/* function prototypes ********************************************************/
-
-#if !defined(NDEBUG)
-extern char *show_jit_type_names[];
-extern char show_jit_type_letters[];
-
-bool show_init(void);
-
-void show_method(jitdata *jd, int stage);
-void show_basicblock(jitdata *jd, basicblock *bptr, int stage);
-void show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage);
-void show_variable(jitdata *jd, s4 index, int stage);
-void show_variable_array(jitdata *jd, s4 *vars, int n, int stage);
-void show_javalocals_array(jitdata *jd, s4 *vars, int n, int stage);
-void show_allocation(s4 type, s4 flags, s4 regoff);
-#endif /* !defined(NDEBUG) */
-
-/* Debug output filtering */
-
-#if defined(ENABLE_DEBUG_FILTER)
-void show_filters_init(void);
-#define SHOW_FILTER_FLAG_VERBOSECALL_INCLUDE 0x01
-#define SHOW_FILTER_FLAG_VERBOSECALL_EXCLUDE 0x02
-#define SHOW_FILTER_FLAG_SHOW_METHOD 0x04
-void show_filters_apply(methodinfo *m);
-int show_filters_test_verbosecall_enter(methodinfo *m);
-int show_filters_test_verbosecall_exit(methodinfo *m);
-#endif
-
-
-#endif /* _SHOW_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/jit/show.hpp b/src/vm/jit/show.hpp
new file mode 100644 (file)
index 0000000..1f5852c
--- /dev/null
@@ -0,0 +1,97 @@
+/* src/vm/jit/show.hpp - showing the intermediate representation
+
+   Copyright (C) 1996-2005, 2006, 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 _SHOW_HPP
+#define _SHOW_HPP
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/jit/jit.hpp"
+
+
+/* compiler stage defines *****************************************************/
+
+#define SHOW_INSTRUCTIONS  0
+#define SHOW_PARSE         1
+#define SHOW_STACK         2
+#define SHOW_CFG           3
+#define SHOW_REGS          4
+#define SHOW_CODE          5
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(NDEBUG)
+extern const char *show_jit_type_names[];
+extern const char show_jit_type_letters[];
+
+bool show_init(void);
+
+void show_method(jitdata *jd, int stage);
+void show_basicblock(jitdata *jd, basicblock *bptr, int stage);
+void show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage);
+void show_variable(jitdata *jd, s4 index, int stage);
+void show_variable_array(jitdata *jd, s4 *vars, int n, int stage);
+void show_javalocals_array(jitdata *jd, s4 *vars, int n, int stage);
+void show_allocation(s4 type, s4 flags, s4 regoff);
+#endif /* !defined(NDEBUG) */
+
+/* Debug output filtering */
+
+#if defined(ENABLE_DEBUG_FILTER)
+void show_filters_init(void);
+#define SHOW_FILTER_FLAG_VERBOSECALL_INCLUDE 0x01
+#define SHOW_FILTER_FLAG_VERBOSECALL_EXCLUDE 0x02
+#define SHOW_FILTER_FLAG_SHOW_METHOD 0x04
+void show_filters_apply(methodinfo *m);
+int show_filters_test_verbosecall_enter(methodinfo *m);
+int show_filters_test_verbosecall_exit(methodinfo *m);
+#endif
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _SHOW_HPP
+
+
+/*
+ * 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 38535c3a897ada405cecc2aae28f20f2a25f013a..2fbeef9f5cd9d5a68b34229e3f6e060387ccc669 100644 (file)
@@ -34,9 +34,9 @@ LIBS =
 
 noinst_HEADERS = \
        arch.h \
-       machine-instr.h \
        \
-       md-asm.h
+       md-asm.h \
+       md-atomic.hpp
 
 noinst_LTLIBRARIES = libarch.la
 
@@ -57,6 +57,7 @@ libarch_la_SOURCES = \
        \
        md-abi.c \
        md-abi.h \
+       md-stubs.hpp \
        md-trap.h \
        md.c \
        md.h
index 93581b3630ca15e43ec3f61ddd33dee93a147dbb..5897ad13ae47b817ad38c5810f821b4902c7d376 100644 (file)
@@ -33,8 +33,6 @@
 
 /* define architecture features ***********************************************/
 
-#define U8_AVAILABLE                     1
-
 #define SUPPORT_DIVISION                 1
 #define SUPPORT_LONG                     1
 
index d13339a8a8dc63c5d024de7e0d27b71d2f0ffc24..b048fbe3272e933413752b0fe8aa8da7966f299d 100644 (file)
 
 #include "mm/memory.h"
 
-#include "native/jni.h"
-#include "native/localref.h"
-#include "native/native.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/parse.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/parse.hpp"
 #include "vm/jit/patcher.h"
 #include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vm/jit/sparc64/solaris/macro_rename.h"
 
@@ -2671,9 +2670,6 @@ gen_method:
                                        superindex = super->index;
                                }
 
-                               if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                                       CODEGEN_CRITICAL_SECTION_NEW;
-
                                s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                                /* if class is not resolved, check which code to call */
@@ -2744,16 +2740,12 @@ gen_method:
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl));
                                        M_ALD(REG_ITMP3, REG_PV, disp);
                                        
-                                       CODEGEN_CRITICAL_SECTION_START;
-
                                        M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                        M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, baseval));
                                        M_SUB(REG_ITMP2, REG_ITMP3, REG_ITMP2);
                                        M_ALD(REG_ITMP3, REG_PV, disp);
                                        M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval));
 
-                                       CODEGEN_CRITICAL_SECTION_END;
-
                                        /*                              } */
                                        M_CMP(REG_ITMP3, REG_ITMP2);
                                        emit_classcast_check(cd, iptr, BRANCH_ULT, REG_ITMP3, s1);
@@ -2836,9 +2828,6 @@ gen_method:
                                supervftbl = super->vftbl;
                        }
 
-                       if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                               CODEGEN_CRITICAL_SECTION_NEW;
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s1 == d) {
@@ -2914,14 +2903,10 @@ gen_method:
                                M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl));
                                M_ALD(REG_ITMP2, REG_PV, disp);
 
-                               CODEGEN_CRITICAL_SECTION_START;
-
                                M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 
-                               CODEGEN_CRITICAL_SECTION_END;
-
                                M_SUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                M_CMP(REG_ITMP1, REG_ITMP2);
                                M_XCMOVULE_IMM(1, d);
@@ -3434,7 +3419,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
        /* put env into first argument register */
 
-       disp = dseg_add_address(cd, _Jv_env);
+       disp = dseg_add_address(cd, VM_get_jnienv());
        M_ALD(REG_OUT0, REG_PV_CALLEE, disp);
 
        /* do the native function call */
index ade165128a665165191011b905ce4d3424039e77..b64cf4fc656ed4f6bf991b7ae42fee51ee512caf 100644 (file)
@@ -1,10 +1,8 @@
-/* src/vm/jit/sparc64/codegen.h - code generation macros and definitions for
-                                  Sparc64
+/* src/vm/jit/sparc64/codegen.h - code generation macros and
+                                  definitions for SPARC64
 
-   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.
 
@@ -31,7 +29,7 @@
 #include "config.h"
 #include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #include "md-abi.h" /* for INT_NATARG_CNT */
 
@@ -72,11 +70,6 @@ s4 nat_argintregs[INT_NATARG_CNT];
     } while (0)
 
 
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE    4 * 4
-
-
 /* additional functions and macros to generate code ***************************/
 
 
index def530822aeb785a3f430854e37586925df4014a..e7f8f379e6b21bfebf2ecf4a2e1fb8b8d7bcd2dd 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/sparc64/emit.c - SPARC code emitter functions
 
-   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.
 
 
 #include "mm/memory.h"
 
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h" /* XXX for gen_resolvebranch */
+#include "vm/jit/builtin.hpp"
+#include "vm/options.h"
+
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
-#include "vm/builtin.h"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/replace.h"
-
-#include "vmcore/options.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/replace.hpp"
 
 #include "vm/jit/sparc64/solaris/macro_rename.h"
 
index 1144594771951d8f44736215ff77135dd490bdd8..e1cdfdb9f08de767d5931942ad77fa128b0711a5 100644 (file)
 #include "vm/jit/sparc64/md-abi.h"
 
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 
@@ -176,40 +175,6 @@ void md_icacheflush(u1 *addr, s4 nbytes)
        }
 }
 
-#if defined(ENABLE_THREADS)
-/* md_critical_section_restart ************************************************
-   Search the critical sections tree for a matching section and set
-   the NPC to the restart point, if necessary.
-
-   Reads PC and modifies NPC.
-
-******************************************************************************/
-
-void md_critical_section_restart(ucontext_t *_uc)
-{
-       /* mcontext_t *_mc; */
-       sigcontext *ctx;
-       u1         *pc;
-       u1         *npc;
-
-       printf("ignoring md_critical_section_restart\n");
-       return;
-
-       /* again, we are getting sigcontext instead of ucontext */
-       ctx = (sigcontext *) _uc;
-       
-       pc = (u1 *) ctx->sigc_regs.tpc;
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL) {
-               log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc);
-               ctx->sigc_regs.tnpc = (ptrint) npc;
-       }
-
-}
-#endif
        
 /*
  * These are local overrides for various environment variables in Emacs.
diff --git a/src/vm/jit/sparc64/machine-instr.h b/src/vm/jit/sparc64/machine-instr.h
deleted file mode 100644 (file)
index cc07238..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _MACHINE_INSTR_H
-#define _MACHINE_INSTR_H
-
-#include "toolbox/logging.h"
-
-static inline long
-__attribute__ ((unused))
-compare_and_swap (volatile long *p, long oldval, long newval)
-{
-  long ret;
-  /*dolog("compare_and_swap(%p [%d], %d, %d)", p, *p, oldval, newval);*/
-
-  __asm__ __volatile__ (
-    "mov %3,%0\n\t"
-    "casx [%4],%2,%0\n\t"
-    : "=&r"(ret), "=m"(*p) 
-    : "r"(oldval), "r"(newval), "r"(p));
-
-  /*dolog("compare_and_swap() return=%d mem=%d", ret, *p);*/
-  return ret;
-}
-
-#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("wmb" : : : "memory");
-#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("mb" : : : "memory");
-#define MEMORY_BARRIER() __asm__ __volatile__ ( \
-               "membar 0x0F" : : : "memory" );
-
-#endif
index 4afd70d7c8e8b337cafb4412071629ef70e26c0a..cc12be598716a5abb965949cc178b629d7e566ff 100644 (file)
 
 #include "vm/jit/sparc64/md-abi.h"
 
+#include "vm/descriptor.h"
 #include "vm/global.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/stack.h"
 
-#include "vmcore/descriptor.h"
-
 /* temp */
 #include "mm/memory.h"
 #include <assert.h>
diff --git a/src/vm/jit/sparc64/md-atomic.hpp b/src/vm/jit/sparc64/md-atomic.hpp
new file mode 100644 (file)
index 0000000..5539c38
--- /dev/null
@@ -0,0 +1,143 @@
+/* src/vm/jit/sparc64/atomic.hpp - SPARC64 atomic instructions
+
+   Copyright (C) 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 _MD_ATOMIC_HPP
+#define _MD_ATOMIC_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "threads/atomic.hpp"
+
+
+/**
+ * An atomic compare and swap for 32-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
+{
+#if 0
+       // This one should be correct.
+       uint32_t result;
+
+       __asm__ __volatile__ (
+               "    mov %3,%0       \n"
+               "    cas [%4],%2,%0  \n"
+               : "=&r" (result), "=m" (*p) 
+               : "r" (oldval), "r" (newval), "r" (p));
+
+       return result;
+#else
+       return generic_compare_and_swap(p, oldval, newval);
+#endif
+}
+
+
+/**
+ * An atomic compare and swap for 64-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
+{
+       uint64_t result;
+
+       __asm__ __volatile__ (
+               "    mov %3,%0        \n"
+               "    casx [%4],%2,%0  \n"
+               : "=&r" (result), "=m" (*p) 
+               : "r" (oldval), "r" (newval), "r" (p));
+
+       return result;
+}
+
+
+/**
+ * An atomic compare and swap for pointer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval)
+{
+       return (void*) compare_and_swap((volatile uint64_t*) p, (uint64_t) oldval, (uint64_t) newval);
+}
+
+
+/**
+ * A memory barrier.
+ */
+inline void Atomic::memory_barrier(void)
+{
+       __asm__ __volatile__ ("membar 0x0F" : : : "memory" );
+}
+
+
+/**
+ * A write memory barrier.
+ */
+inline void Atomic::write_memory_barrier(void)
+{
+       __asm__ __volatile__ ("wmb" : : : "memory");
+}
+
+
+/**
+ * An instruction barrier.
+ */
+inline void Atomic::instruction_barrier(void)
+{
+       __asm__ __volatile__ ("mb" : : : "memory");
+}
+
+#endif // _MD_ATOMIC_HPP
+
+
+/*
+ * 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/jit/sparc64/md-stubs.hpp b/src/vm/jit/sparc64/md-stubs.hpp
new file mode 100644 (file)
index 0000000..eb0dc65
--- /dev/null
@@ -0,0 +1,56 @@
+/* src/vm/jit/sparc64/md-stubs.hpp - SPARC64 JIT stubs
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a SPARC64 architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+       return 4 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * 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 e06903192b68bd7a65d8480bd3e93fe5f0e8b8bc..9cfaaeaeec73b7a0096d64ba44ba8af83e459996 100644 (file)
@@ -58,6 +58,7 @@ enum {
        /* Don't use 8 (could be a normal load offset). */
 
        TRAP_COMPILER                       = 9,
+       TRAP_COUNTDOWN                      = 10,
        TRAP_END
 };
 
index caf2d003deb8f4591850efb02b7be285e9dfcafd..398fb809d974b3723fd7bce3b92aad02af6d071e 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/sparc64/md.c - machine dependent SPARC64 functions
 
-   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.
 
 
 #include "vm/jit/sparc64/md-abi.h"
 
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/jit.hpp"
 
 
 /* assembler function prototypes **********************************************/
index a66b2552a84a819f7a300a13bd6ff03addca647e..f47f7750d88747e331d0b228e4231be8ffb36ace 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "vm/types.h"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* md_stacktrace_get_returnaddress *********************************************
index 576e710c918b8b8bf324722167953d0121066f21..c36a5abc7bcdcfe40e5d19a978642b0d8a3fe49f 100644 (file)
 #include "vm/jit/sparc64/md.h"
 #include "vm/jit/sparc64/md-abi.h"
 
-#include "native/native.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
+#include "native/native.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/patcher.h"
 #include "vm/jit/methodheader.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vmcore/references.h"
-#include "vm/resolve.h"
+#include "vm/jit/stacktrace.hpp"
 
 #include "vm/jit/sparc64/solaris/macro_rename.h"
 
@@ -231,22 +231,9 @@ bool patcher_get_putfield(u1 *sp)
        if (!(fi = resolve_field_eager(uf)))
                return false;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops) {
-               /* patch the field's offset into the instruction */
-
-               *((u4 *) (ra + 2 * 4)) |= (s2) (fi->offset & 0x00001fff);
+       /* store the patched instruction on the stack */
 
-               /* synchronize instruction cache */
-
-               md_icacheflush(ra + 2 * 4, 1 * 4);
-       }
-       else {
-               /* otherwise store the patched instruction on the stack */
-
-               *((u4 *) (sp + 3 * 8)) |= (s2) (fi->offset & 0x00001fff);
-       }
+       *((u4 *) (sp + 3 * 8)) |= (s2) (fi->offset & 0x00001fff);
 
        return true;
 }
@@ -445,28 +432,11 @@ bool patcher_invokevirtual(u1 *sp)
        if (!(m = resolve_method_eager(um)))
                return false;
 
-       /* if we show disassembly, we have to skip the nop's */
+       /* patch vftbl index */
 
-       if (opt_shownops) {
-               ra = ra + PATCHER_CALL_SIZE;
-
-               /* patch vftbl index */
-
-               *((s4 *) (ra + 1 * 4)) |=
-                       (s4) ((OFFSET(vftbl_t, table[0]) +
-                                  sizeof(methodptr) * m->vftblindex) & 0x00001fff);
-
-               /* synchronize instruction cache */
-
-               md_icacheflush(ra + 1 * 4, 1 * 4);
-       }
-       else {
-               /* patch vftbl index */
-
-               *((s4 *) (sp + 3 * 8 + 4)) |=
-                       (s4) ((OFFSET(vftbl_t, table[0]) +
-                                  sizeof(methodptr) * m->vftblindex) & 0x00001fff);
-       }
+       *((s4 *) (sp + 3 * 8 + 4)) |=
+               (s4) ((OFFSET(vftbl_t, table[0]) +
+                          sizeof(methodptr) * m->vftblindex) & 0x00001fff);
 
        return true;
 }
@@ -501,42 +471,20 @@ bool patcher_invokeinterface(u1 *sp)
        if (!(m = resolve_method_eager(um)))
                return false;
 
-       /* if we show disassembly, we have to skip the nop's */
+       /* patch interfacetable index */
 
-       if (opt_shownops) {
-               ra = ra + PATCHER_CALL_SIZE;
-
-               /* patch interfacetable index */
-
-               *((s4 *) (ra + 1 * 4)) |= 
-                       (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
-                               sizeof(methodptr*) * m->clazz->index) & 0x00001fff);
-
-               /* patch method offset */
-
-               *((s4 *) (ra + 2 * 4)) |=
-                       (s4) ((sizeof(methodptr) * (m - m->clazz->methods)) & 0x00001fff);
-
-               /* synchronize instruction cache */
-
-               md_icacheflush(ra + 1 * 4, 2 * 4);
-       }
-       else {
-               /* patch interfacetable index */
-
-               *((s4 *) (sp + 3 * 8 + 4)) |=
-                       (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
-                               sizeof(methodptr*) * m->clazz->index) & 0x00001fff);
+       *((s4 *) (sp + 3 * 8 + 4)) |=
+               (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
+                          sizeof(methodptr*) * m->clazz->index) & 0x00001fff);
 
-               /* patch method offset */
+       /* patch method offset */
 
-               *((s4 *) (ra + 2 * 4)) |=
-                       (s4) ((sizeof(methodptr) * (m - m->clazz->methods)) & 0x00001fff);
+       *((s4 *) (ra + 2 * 4)) |=
+               (s4) ((sizeof(methodptr) * (m - m->clazz->methods)) & 0x00001fff);
 
-               /* synchronize instruction cache */
+       /* synchronize instruction cache */
 
-               md_icacheflush(ra + 2 * 4, 1 * 4);
-       }
+       md_icacheflush(ra + 2 * 4, 1 * 4);
 
        return true;
 }
@@ -614,11 +562,6 @@ bool patcher_checkcast_interface(u1 *sp)
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch super class index */
 
        *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x00001fff);
@@ -629,10 +572,7 @@ bool patcher_checkcast_interface(u1 *sp)
 
        /* synchronize instruction cache */
 
-       if (opt_shownops)
-               md_icacheflush(ra - 2 * 4, (6 + EXCEPTION_CHECK_INSTRUCTIONS) * 4);
-       else
-               md_icacheflush(ra, (4 + EXCEPTION_CHECK_INSTRUCTIONS) * 4);
+       md_icacheflush(ra, (4 + EXCEPTION_CHECK_INSTRUCTIONS) * 4);
 
        return true;
 }
@@ -667,11 +607,6 @@ bool patcher_instanceof_interface(u1 *sp)
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
        /* patch super class index */
 
        *((s4 *) (ra + 2 * 4)) |= (s4) ((c->index) & 0x00001fff);
@@ -681,10 +616,7 @@ bool patcher_instanceof_interface(u1 *sp)
 
        /* synchronize instruction cache */
 
-       if (opt_shownops)
-               md_icacheflush(ra - PATCHER_CALL_SIZE * 4, 8 * 4);
-       else
-               md_icacheflush(ra, 6 * 4);
+       md_icacheflush(ra, 6 * 4);
 
        return true;
 }
index 81f191896fcc537fab491f57d8dae8609c441f93..7c4c802a84d1c7bc3a27784cdc854854300ba231 100644 (file)
 #include "vm/jit/sparc64/codegen.h"
 #include "vm/jit/sparc64/md-abi.h"
 
-#include "vm/exceptions.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 
@@ -151,22 +149,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 }
 
 
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
-void thread_restartcriticalsection(ucontext_t *_uc)
-{
-       mcontext_t *_mc;
-       void       *critical;
-
-       _mc = &_uc->uc_mcontext;
-
-       critical = thread_checkcritical((void *) _mc->sc_pc);
-
-       if (critical)
-               _mc->sc_pc = (ptrint) critical;
-}
-#endif
-
-
 /* md_icacheflush **************************************************************
 
    Calls the system's function to flush the instruction cache.
index e692269d25bf2c6846b3dac13efe6597a0c8a94c..8c7ad97c3c9bab8c95dca5327998f05532f08eeb 100644 (file)
 
 #include "mm/memory.h"
 
-#include "native/native.h"
+#include "native/native.hpp"
 
 #include "toolbox/logging.h"
 
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/builtin.h"
-#include "vm/stringlocal.h"
+#include "vm/options.h"
+#include "vm/resolve.hpp"
+#include "vm/string.hpp"
 #include "vm/types.h"
 
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
 #include "vm/jit/abi.h"
 #include "vm/jit/cfg.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/show.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/show.hpp"
 
 #if defined(ENABLE_DISASSEMBLER)
 # include "vm/jit/disass.h"
 #endif
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/stack.h"
 
 #if 0
 #endif
 #endif
 
-#include "vmcore/options.h"
-#include "vm/resolve.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
 /*#define STACK_VERBOSE*/
 
 
index eceb2db2204fd84ca3b6256b58a5a471c9d559a9..803d2db11d83ed7ae3d5c3e5c561e6554613e1bd 100644 (file)
@@ -37,10 +37,9 @@ typedef struct stackelement_t stackelement_t;
 
 #include "vm/types.h"
 
-#include "vm/exceptions.h"
 #include "vm/global.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
 
 
@@ -162,12 +161,20 @@ struct stackelement_t {
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool stack_init(void);
 
 bool stack_analyse(jitdata *jd);
 
 void stack_javalocals_store(instruction *iptr, s4 *javalocals);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _STACK_H */
 
 
diff --git a/src/vm/jit/stacktrace.c b/src/vm/jit/stacktrace.c
deleted file mode 100644 (file)
index 4f4765a..0000000
+++ /dev/null
@@ -1,1328 +0,0 @@
-/* src/vm/jit/stacktrace.c - machine independent stacktrace system
-
-   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 <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "md.h"
-
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vm/global.h"                   /* required here for native includes */
-#include "native/jni.h"
-#include "native/llni.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Throwable.h"
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/gnu_classpath_Pointer.h"
-# include "native/include/java_lang_VMThrowable.h"
-#endif
-
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/cycles-stats.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/methodheader.h"
-#include "vm/jit/methodtree.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-
-
-/* global variables ***********************************************************/
-
-CYCLES_STATS_DECLARE(stacktrace_overhead        , 100, 1)
-CYCLES_STATS_DECLARE(stacktrace_fillInStackTrace, 40,  5000)
-CYCLES_STATS_DECLARE(stacktrace_get,              40,  5000)
-CYCLES_STATS_DECLARE(stacktrace_getClassContext , 40,  5000)
-CYCLES_STATS_DECLARE(stacktrace_getCurrentClass , 40,  5000)
-CYCLES_STATS_DECLARE(stacktrace_get_stack       , 40,  10000)
-
-
-/* stacktrace_stackframeinfo_add ***********************************************
-
-   Fills a stackframe info structure with the given or calculated
-   values and adds it to the chain.
-
-*******************************************************************************/
-
-void stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, u1 *pv, u1 *sp, u1 *ra, u1 *xpc)
-{
-       stackframeinfo_t *currentsfi;
-       codeinfo         *code;
-#if defined(ENABLE_JIT)
-       s4                 framesize;
-#endif
-
-       /* Get current stackframe info. */
-
-       currentsfi = threads_get_current_stackframeinfo();
-
-       /* sometimes we don't have pv handy (e.g. in asmpart.S:
-       L_asm_call_jit_compiler_exception or in the interpreter). */
-
-       if (pv == NULL) {
-#if defined(ENABLE_INTRP)
-               if (opt_intrp)
-                       pv = methodtree_find(ra);
-               else
-#endif
-                       {
-#if defined(ENABLE_JIT)
-# if defined(__SPARC_64__)
-                               pv = md_get_pv_from_stackframe(sp);
-# else
-                               pv = md_codegen_get_pv_from_pc(ra);
-# endif
-#endif
-                       }
-       }
-
-       /* Get codeinfo pointer for the parent Java method. */
-
-       code = code_get_codeinfo_for_pv(pv);
-
-       /* XXX */
-       /*      assert(m != NULL); */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       /* When using the interpreter, we pass RA to the function. */
-
-       if (!opt_intrp) {
-# endif
-# if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__M68K__)
-               /* On i386 and x86_64 we always have to get the return address
-                  from the stack. */
-               /* m68k has return address on stack always */
-               /* On S390 we use REG_RA as REG_ITMP3, so we have always to get
-                  the RA from stack. */
-
-               framesize = *((u4 *) (pv + FrameSize));
-
-               ra = md_stacktrace_get_returnaddress(sp, framesize);
-# else
-               /* If the method is a non-leaf function, we need to get the
-                  return address from the stack.  For leaf functions the
-                  return address is set correctly.  This makes the assembler
-                  and the signal handler code simpler.  The code is NULL is
-                  the asm_vm_call_method special case. */
-
-               if ((code == NULL) || !code_is_leafmethod(code)) {
-                       framesize = *((u4 *) (pv + FrameSize));
-
-                       ra = md_stacktrace_get_returnaddress(sp, framesize);
-               }
-# endif
-# if defined(ENABLE_INTRP)
-       }
-# endif
-#endif
-
-       /* Calculate XPC when not given.  The XPC is then the return
-          address of the current method minus 1 because the RA points to
-          the instruction after the call instruction.  This is required
-          e.g. for method stubs. */
-
-       if (xpc == NULL) {
-               xpc = (void *) (((intptr_t) ra) - 1);
-       }
-
-       /* Fill new stackframeinfo structure. */
-
-       sfi->prev = currentsfi;
-       sfi->code = code;
-       sfi->pv   = pv;
-       sfi->sp   = sp;
-       sfi->ra   = ra;
-       sfi->xpc  = xpc;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackFrameInfo) {
-               log_start();
-               log_print("[stackframeinfo add   : sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
-                                 sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc);
-               method_print(sfi->code->m);
-               log_print("]");
-               log_finish();
-       }
-#endif
-
-       /* Store new stackframeinfo pointer. */
-
-       threads_set_current_stackframeinfo(sfi);
-
-       /* set the native world flag for the current thread */
-       /* ATTENTION: This flag tells the GC how to treat this thread in case of
-          a collection. Set this flag _after_ a valid stackframe info was set. */
-
-       THREAD_NATIVEWORLD_ENTER;
-}
-
-
-/* stacktrace_stackframeinfo_remove ********************************************
-
-   Remove the given stackframeinfo from the chain in the current
-   thread.
-
-*******************************************************************************/
-
-void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi)
-{
-       /* Clear the native world flag for the current thread. */
-       /* ATTENTION: Clear this flag _before_ removing the stackframe info. */
-
-       THREAD_NATIVEWORLD_EXIT;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackFrameInfo) {
-               log_start();
-               log_print("[stackframeinfo remove: sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
-                                 sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc);
-               method_print(sfi->code->m);
-               log_print("]");
-               log_finish();
-       }
-#endif
-
-       /* Set previous stackframe info. */
-
-       threads_set_current_stackframeinfo(sfi->prev);
-}
-
-
-/* stacktrace_stackframeinfo_fill **********************************************
-
-   Fill the temporary stackframeinfo structure with the values given
-   in sfi.
-
-   IN:
-       tmpsfi ... temporary stackframeinfo
-       sfi ...... stackframeinfo to be used in the next iteration
-
-*******************************************************************************/
-
-static inline void stacktrace_stackframeinfo_fill(stackframeinfo_t *tmpsfi, stackframeinfo_t *sfi)
-{
-       /* Sanity checks. */
-
-       assert(tmpsfi != NULL);
-       assert(sfi != NULL);
-
-       /* Fill the temporary stackframeinfo. */
-
-       tmpsfi->code = sfi->code;
-       tmpsfi->pv   = sfi->pv;
-       tmpsfi->sp   = sfi->sp;
-       tmpsfi->ra   = sfi->ra;
-       tmpsfi->xpc  = sfi->xpc;
-
-       /* Set the previous stackframe info of the temporary one to the
-          next in the chain. */
-
-       tmpsfi->prev = sfi->prev;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace fill]");
-#endif
-}
-
-
-/* stacktrace_stackframeinfo_next **********************************************
-
-   Walk the stack (or the stackframeinfo-chain) to the next method and
-   return the new stackframe values in the temporary stackframeinfo
-   passed.
-
-   ATTENTION: This function does NOT skip builtin methods!
-
-   IN:
-       tmpsfi ... temporary stackframeinfo of current method
-
-*******************************************************************************/
-
-static inline void stacktrace_stackframeinfo_next(stackframeinfo_t *tmpsfi)
-{
-       codeinfo         *code;
-       void             *pv;
-       void             *sp;
-       void             *ra;
-       void             *xpc;
-       uint32_t          framesize;
-       stackframeinfo_t *prevsfi;
-
-       /* Sanity check. */
-
-       assert(tmpsfi != NULL);
-
-       /* Get values from the stackframeinfo. */
-
-       code = tmpsfi->code;
-       pv   = tmpsfi->pv;
-       sp   = tmpsfi->sp;
-       ra   = tmpsfi->ra;
-       xpc  = tmpsfi->xpc;
-       /* Get the current stack frame size. */
-
-       framesize = *((uint32_t *) (((intptr_t) pv) + FrameSize));
-
-       /* Get the RA of the current stack frame (RA to the parent Java
-          method) if the current method is a non-leaf method.  Otherwise
-          the value in the stackframeinfo is correct (from the signal
-          handler). */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               ra = intrp_md_stacktrace_get_returnaddress(sp, framesize);
-       else
-# endif
-               {
-                       if (!code_is_leafmethod(code))
-                               ra = md_stacktrace_get_returnaddress(sp, framesize);
-               }
-#else
-       ra = intrp_md_stacktrace_get_returnaddress(sp, framesize);
-#endif
-
-       /* Get the PV for the parent Java method. */
-
-#if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               pv = methodtree_find(ra);
-       else
-#endif
-               {
-#if defined(ENABLE_JIT)
-# if defined(__SPARC_64__)
-                       sp = md_get_framepointer(sp);
-                       pv = md_get_pv_from_stackframe(sp);
-# else
-                       pv = md_codegen_get_pv_from_pc(ra);
-# endif
-#endif
-               }
-
-       /* Get the codeinfo pointer for the parent Java method. */
-
-       code = code_get_codeinfo_for_pv(pv);
-
-       /* Calculate the SP for the parent Java method. */
-
-#if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               sp = *(u1 **) (sp - framesize);
-       else
-#endif
-               {
-#if defined(__I386__) || defined (__X86_64__) || defined (__M68K__)
-                       sp = (void *) (((intptr_t) sp) + framesize + SIZEOF_VOID_P);
-#elif defined(__SPARC_64__)
-                       /* already has the new sp */
-#else
-                       sp = (void *) (((intptr_t) sp) + framesize);
-#endif
-               }
-
-       /* If the new codeinfo pointer is NULL we reached a
-          asm_vm_call_method function.  In this case we get the next
-          values from the previous stackframeinfo in the chain.
-          Otherwise the new values have been calculated before. */
-
-       if (code == NULL) {
-               prevsfi = tmpsfi->prev;
-
-               /* If the previous stackframeinfo in the chain is NULL we
-                  reached the top of the stacktrace.  We set code and prev to
-                  NULL to mark the end, which is checked in
-                  stacktrace_stackframeinfo_end_check. */
-
-               if (prevsfi == NULL) {
-                       tmpsfi->code = NULL;
-                       tmpsfi->prev = NULL;
-                       return;
-               }
-
-               /* Fill the temporary stackframeinfo with the new values. */
-
-               stacktrace_stackframeinfo_fill(tmpsfi, prevsfi);
-       }
-       else {
-               /* Store the new values in the stackframeinfo.  NOTE: We
-                  subtract 1 from the RA to get the XPC, because the RA
-                  points to the instruction after the call instruction. */
-
-               tmpsfi->code = code;
-               tmpsfi->pv   = pv;
-               tmpsfi->sp   = sp;
-               tmpsfi->ra   = ra;
-               tmpsfi->xpc  = (void *) (((intptr_t) ra) - 1);
-       }
-
-#if !defined(NDEBUG)
-       /* Print current method information. */
-
-       if (opt_DebugStackTrace) {
-               log_start();
-               log_print("[stacktrace: method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
-                                 tmpsfi->code->m, tmpsfi->pv, tmpsfi->sp, tmpsfi->ra,
-                                 tmpsfi->xpc);
-               method_print(tmpsfi->code->m);
-               log_print("]");
-               log_finish();
-       }
-#endif
-}
-
-
-/* stacktrace_stackframeinfo_end_check *****************************************
-
-   Check if we reached the end of the stacktrace.
-
-   IN:
-       tmpsfi ... temporary stackframeinfo of current method
-
-   RETURN:
-       true .... the end is reached
-          false ... the end is not reached
-
-*******************************************************************************/
-
-static inline bool stacktrace_stackframeinfo_end_check(stackframeinfo_t *tmpsfi)
-{
-       /* Sanity check. */
-
-       assert(tmpsfi != NULL);
-
-       if ((tmpsfi->code == NULL) && (tmpsfi->prev == NULL)) {
-#if !defined(NDEBUG)
-               if (opt_DebugStackTrace)
-                       log_println("[stacktrace stop]");
-#endif
-
-               return true;
-       }
-
-       return false;
-}
-
-
-/* stacktrace_depth ************************************************************
-
-   Calculates and returns the depth of the current stacktrace.
-
-   IN:
-       sfi ... stackframeinfo where to start the stacktrace
-
-   RETURN:
-       depth of the stacktrace
-
-*******************************************************************************/
-
-static int stacktrace_depth(stackframeinfo_t *sfi)
-{
-       stackframeinfo_t  tmpsfi;
-       int               depth;
-       methodinfo       *m;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_depth]");
-#endif
-
-       /* XXX This is not correct, but a workaround for threads-dump for
-          now. */
-/*     assert(sfi != NULL); */
-       if (sfi == NULL)
-               return 0;
-
-       /* Iterate over all stackframes. */
-
-       depth = 0;
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get methodinfo. */
-
-               m = tmpsfi.code->m;
-
-               /* Skip builtin methods. */
-
-               if (m->flags & ACC_METHOD_BUILTIN)
-                       continue;
-
-               depth++;
-       }
-
-       return depth;
-}
-
-
-/* stacktrace_get **************************************************************
-
-   Builds and returns a stacktrace starting from the given stackframe
-   info and returns the stacktrace structure wrapped in a Java
-   byte-array to not confuse the GC.
-
-   IN:
-       sfi ... stackframe info to start stacktrace from
-
-   RETURN:
-       stacktrace as Java byte-array
-
-*******************************************************************************/
-
-java_handle_bytearray_t *stacktrace_get(stackframeinfo_t *sfi)
-{
-       stackframeinfo_t         tmpsfi;
-       int                      depth;
-       java_handle_bytearray_t *ba;
-       int32_t                  ba_size;
-       stacktrace_t            *st;
-       stacktrace_entry_t      *ste;
-       methodinfo              *m;
-       bool                     skip_fillInStackTrace;
-       bool                     skip_init;
-
-       CYCLES_STATS_DECLARE_AND_START_WITH_OVERHEAD
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_get]");
-#endif
-
-       skip_fillInStackTrace = true;
-       skip_init             = true;
-
-       depth = stacktrace_depth(sfi);
-
-       if (depth == 0)
-               return NULL;
-
-       /* Allocate memory from the GC heap and copy the stacktrace
-          buffer. */
-       /* ATTENTION: Use a Java byte-array for this to not confuse the
-          GC. */
-       /* FIXME: We waste some memory here as we skip some entries
-          later. */
-
-       ba_size = sizeof(stacktrace_t) + sizeof(stacktrace_entry_t) * depth;
-
-       ba = builtin_newarray_byte(ba_size);
-
-       if (ba == NULL)
-               goto return_NULL;
-
-       /* Get a stacktrace entry pointer. */
-       /* ATTENTION: We need a critical section here because we use the
-          byte-array data pointer directly. */
-
-       LLNI_CRITICAL_START;
-
-       st = (stacktrace_t *) LLNI_array_data(ba);
-
-       ste = st->entries;
-
-       /* Iterate over the whole stack. */
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get the methodinfo. */
-
-               m = tmpsfi.code->m;
-
-               /* Skip builtin methods. */
-
-               if (m->flags & ACC_METHOD_BUILTIN)
-                       continue;
-
-               /* This logic is taken from
-                  hotspot/src/share/vm/classfile/javaClasses.cpp
-                  (java_lang_Throwable::fill_in_stack_trace). */
-
-               if (skip_fillInStackTrace == true) {
-                       /* Check "fillInStackTrace" only once, so we negate the
-                          flag after the first time check. */
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-                       /* For GNU Classpath we also need to skip
-                          VMThrowable.fillInStackTrace(). */
-
-                       if ((m->clazz == class_java_lang_VMThrowable) &&
-                               (m->name  == utf_fillInStackTrace))
-                               continue;
-#endif
-
-                       skip_fillInStackTrace = false;
-
-                       if (m->name == utf_fillInStackTrace)
-                               continue;
-               }
-
-               /* Skip <init> methods of the exceptions klass.  If there is
-                  <init> methods that belongs to a superclass of the
-                  exception we are going to skipping them in stack trace. */
-
-               if (skip_init == true) {
-                       if ((m->name == utf_init) &&
-                               (class_issubclass(m->clazz, class_java_lang_Throwable))) {
-                               continue;
-                       }
-                       else {
-                               /* If no "Throwable.init()" method found, we stop
-                                  checking it next time. */
-
-                               skip_init = false;
-                       }
-               }
-
-               /* Store the stacktrace entry and increment the pointer. */
-
-               ste->code = tmpsfi.code;
-               ste->pc   = tmpsfi.xpc;
-
-               ste++;
-       }
-
-       /* Store the number of entries in the stacktrace structure. */
-
-       st->length = ste - st->entries;
-
-       LLNI_CRITICAL_END;
-
-       /* release dump memory */
-
-/*     dump_release(dumpsize); */
-
-       CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace,
-                                                                  stacktrace_overhead)
-       return ba;
-
-return_NULL:
-/*     dump_release(dumpsize); */
-
-       CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace,
-                                                                  stacktrace_overhead)
-
-       return NULL;
-}
-
-
-/* stacktrace_get_current ******************************************************
-
-   Builds and returns a stacktrace from the current thread and returns
-   the stacktrace structure wrapped in a Java byte-array to not
-   confuse the GC.
-
-   RETURN:
-       stacktrace as Java byte-array
-
-*******************************************************************************/
-
-java_handle_bytearray_t *stacktrace_get_current(void)
-{
-       stackframeinfo_t        *sfi;
-       java_handle_bytearray_t *ba;
-
-       sfi = threads_get_current_stackframeinfo();
-       ba  = stacktrace_get(sfi);
-
-       return ba;
-}
-
-
-/* stacktrace_get_caller_class *************************************************
-
-   Get the class on the stack at the given depth.  This function skips
-   various special classes or methods.
-
-   ARGUMENTS:
-       depth ... depth to get caller class of
-
-   RETURN:
-       caller class
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-classinfo *stacktrace_get_caller_class(int depth)
-{
-       stackframeinfo_t *sfi;
-       stackframeinfo_t  tmpsfi;
-       methodinfo       *m;
-       classinfo        *c;
-       int               i;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_get_caller_class]");
-#endif
-
-       /* Get the stackframeinfo of the current thread. */
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* Iterate over the whole stack until we reached the requested
-          depth. */
-
-       i = 0;
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-
-               m = tmpsfi.code->m;
-               c = m->clazz;
-
-               /* Skip builtin methods. */
-
-               if (m->flags & ACC_METHOD_BUILTIN)
-                       continue;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-               /* NOTE: See hotspot/src/share/vm/runtime/vframe.cpp
-                  (vframeStreamCommon::security_get_caller_frame). */
-
-               /* This is java.lang.reflect.Method.invoke(), skip it. */
-
-               if (m == method_java_lang_reflect_Method_invoke)
-                       continue;
-
-               /* This is an auxiliary frame, skip it. */
-
-               if (class_issubclass(c, class_sun_reflect_MagicAccessorImpl))
-                       continue;
-#endif
-
-               /* We reached the requested depth. */
-
-               if (i >= depth)
-                       return c;
-
-               i++;
-       }
-
-       return NULL;
-}
-#endif
-
-
-/* stacktrace_first_nonnull_classloader ****************************************
-
-   Returns the first non-null (user-defined) classloader on the stack.
-   If none is found NULL is returned.
-
-   RETURN:
-       classloader
-
-*******************************************************************************/
-
-classloader_t *stacktrace_first_nonnull_classloader(void)
-{
-       stackframeinfo_t *sfi;
-       stackframeinfo_t  tmpsfi;
-       methodinfo       *m;
-       classloader_t    *cl;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_first_nonnull_classloader]");
-#endif
-
-       /* Get the stackframeinfo of the current thread. */
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* Iterate over the whole stack. */
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-
-               m  = tmpsfi.code->m;
-               cl = class_get_classloader(m->clazz);
-
-               if (cl != NULL)
-                       return cl;
-       }
-
-       return NULL;
-}
-
-
-/* stacktrace_getClassContext **************************************************
-
-   Creates a Class context array.
-
-   RETURN VALUE:
-      the array of java.lang.Class objects, or
-         NULL if an exception has been thrown
-
-*******************************************************************************/
-
-java_handle_objectarray_t *stacktrace_getClassContext(void)
-{
-       stackframeinfo_t           *sfi;
-       stackframeinfo_t            tmpsfi;
-       int                         depth;
-       java_handle_objectarray_t  *oa;
-       java_object_t             **data;
-       int                         i;
-       methodinfo                 *m;
-
-       CYCLES_STATS_DECLARE_AND_START
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_getClassContext]");
-#endif
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* Get the depth of the current stack. */
-
-       depth = stacktrace_depth(sfi);
-
-       /* The first stackframe corresponds to the method whose
-          implementation calls this native function.  We remove that
-          entry. */
-
-       depth--;
-       stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-       stacktrace_stackframeinfo_next(&tmpsfi);
-
-       /* Allocate the Class array. */
-
-       oa = builtin_anewarray(depth, class_java_lang_Class);
-
-       if (oa == NULL) {
-               CYCLES_STATS_END(stacktrace_getClassContext);
-
-               return NULL;
-       }
-
-       /* Fill the Class array from the stacktrace list. */
-
-       LLNI_CRITICAL_START;
-
-       data = LLNI_array_data(oa);
-
-       /* Iterate over the whole stack. */
-
-       i = 0;
-
-       for (;
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get methodinfo. */
-
-               m = tmpsfi.code->m;
-
-               /* Skip builtin methods. */
-
-               if (m->flags & ACC_METHOD_BUILTIN)
-                       continue;
-
-               /* Store the class in the array. */
-
-               data[i] = (java_object_t *) m->clazz;
-
-               i++;
-       }
-
-       LLNI_CRITICAL_END;
-
-       CYCLES_STATS_END(stacktrace_getClassContext)
-
-       return oa;
-}
-
-
-/* stacktrace_getCurrentClass **************************************************
-
-   Find the current class by walking the stack trace.
-
-   Quote from the JNI documentation:
-        
-   In the Java 2 Platform, FindClass locates the class loader
-   associated with the current native method.  If the native code
-   belongs to a system class, no class loader will be
-   involved. Otherwise, the proper class loader will be invoked to
-   load and link the named class. When FindClass is called through the
-   Invocation Interface, there is no current native method or its
-   associated class loader. In that case, the result of
-   ClassLoader.getBaseClassLoader is used."
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-classinfo *stacktrace_get_current_class(void)
-{
-       stackframeinfo_t *sfi;
-       stackframeinfo_t  tmpsfi;
-       methodinfo       *m;
-
-       CYCLES_STATS_DECLARE_AND_START;
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_get_current_class]");
-#endif
-
-       /* Get the stackframeinfo of the current thread. */
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* If the stackframeinfo is NULL then FindClass is called through
-          the Invocation Interface and we return NULL */
-
-       if (sfi == NULL) {
-               CYCLES_STATS_END(stacktrace_getCurrentClass);
-
-               return NULL;
-       }
-
-       /* Iterate over the whole stack. */
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get the methodinfo. */
-
-               m = tmpsfi.code->m;
-
-               if (m->clazz == class_java_security_PrivilegedAction) {
-                       CYCLES_STATS_END(stacktrace_getCurrentClass);
-
-                       return NULL;
-               }
-
-               if (m->clazz != NULL) {
-                       CYCLES_STATS_END(stacktrace_getCurrentClass);
-
-                       return m->clazz;
-               }
-       }
-
-       /* No Java method found on the stack. */
-
-       CYCLES_STATS_END(stacktrace_getCurrentClass);
-
-       return NULL;
-}
-#endif /* ENABLE_JAVASE */
-
-
-/* stacktrace_get_stack ********************************************************
-
-   Create a 2-dimensional array for java.security.VMAccessControler.
-
-   RETURN VALUE:
-      the arrary, or
-         NULL if an exception has been thrown
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-java_handle_objectarray_t *stacktrace_get_stack(void)
-{
-       stackframeinfo_t          *sfi;
-       stackframeinfo_t           tmpsfi;
-       int                        depth;
-       java_handle_objectarray_t *oa;
-       java_handle_objectarray_t *classes;
-       java_handle_objectarray_t *methodnames;
-       methodinfo                *m;
-       java_handle_t             *string;
-       int                        i;
-
-       CYCLES_STATS_DECLARE_AND_START
-
-#if !defined(NDEBUG)
-       if (opt_DebugStackTrace)
-               log_println("[stacktrace_get_stack]");
-#endif
-
-       /* Get the stackframeinfo of the current thread. */
-
-       sfi = threads_get_current_stackframeinfo();
-
-       /* Get the depth of the current stack. */
-
-       depth = stacktrace_depth(sfi);
-
-       if (depth == 0)
-               return NULL;
-
-       /* Allocate the required arrays. */
-
-       oa = builtin_anewarray(2, arrayclass_java_lang_Object);
-
-       if (oa == NULL)
-               goto return_NULL;
-
-       classes = builtin_anewarray(depth, class_java_lang_Class);
-
-       if (classes == NULL)
-               goto return_NULL;
-
-       methodnames = builtin_anewarray(depth, class_java_lang_String);
-
-       if (methodnames == NULL)
-               goto return_NULL;
-
-       /* Set up the 2-dimensional array. */
-
-       array_objectarray_element_set(oa, 0, (java_handle_t *) classes);
-       array_objectarray_element_set(oa, 1, (java_handle_t *) methodnames);
-
-       /* Iterate over the whole stack. */
-       /* TODO We should use a critical section here to speed things
-          up. */
-
-       i = 0;
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get the methodinfo. */
-
-               m = tmpsfi.code->m;
-
-               /* Skip builtin methods. */
-
-               if (m->flags & ACC_METHOD_BUILTIN)
-                       continue;
-
-               /* Store the class in the array. */
-               /* NOTE: We use a LLNI-macro here, because a classinfo is not
-                  a handle. */
-
-               LLNI_array_direct(classes, i) = (java_object_t *) m->clazz;
-
-               /* Store the name in the array. */
-
-               string = javastring_new(m->name);
-
-               if (string == NULL)
-                       goto return_NULL;
-
-               array_objectarray_element_set(methodnames, i, string);
-
-               i++;
-       }
-
-       CYCLES_STATS_END(stacktrace_get_stack)
-
-       return oa;
-
-return_NULL:
-       CYCLES_STATS_END(stacktrace_get_stack)
-
-       return NULL;
-}
-#endif
-
-
-/* stacktrace_print_entry ****************************************************
-
-   Print line for a stacktrace entry.
-
-   ARGUMENTS:
-       m ............ methodinfo of the entry
-       linenumber ... linenumber of the entry
-
-*******************************************************************************/
-
-static void stacktrace_print_entry(methodinfo *m, int32_t linenumber)
-{
-       /* Sanity check. */
-
-       assert(m != NULL);
-
-       printf("\tat ");
-
-       if (m->flags & ACC_METHOD_BUILTIN)
-               printf("NULL");
-       else
-               utf_display_printable_ascii_classname(m->clazz->name);
-
-       printf(".");
-       utf_display_printable_ascii(m->name);
-       utf_display_printable_ascii(m->descriptor);
-
-       if (m->flags & ACC_NATIVE) {
-               puts("(Native Method)");
-       }
-       else {
-               if (m->flags & ACC_METHOD_BUILTIN) {
-                       puts("(builtin)");
-               }
-               else {
-                       printf("(");
-                       utf_display_printable_ascii(m->clazz->sourcefile);
-                       printf(":%d)\n", linenumber);
-               }
-       }
-
-       fflush(stdout);
-}
-
-
-/* stacktrace_print ************************************************************
-
-   Print the given stacktrace with CACAO intern methods only (no Java
-   code required).
-
-   This method is used by stacktrace_dump_trace and
-   builtin_trace_exception.
-
-   IN:
-       st ... stacktrace to print
-
-*******************************************************************************/
-
-void stacktrace_print(stacktrace_t *st)
-{
-       stacktrace_entry_t *ste;
-       methodinfo         *m;
-       int32_t             linenumber;
-       int                 i;
-
-       ste = &(st->entries[0]);
-
-       for (i = 0; i < st->length; i++, ste++) {
-               m = ste->code->m;
-
-               /* Get the line number. */
-
-               linenumber = linenumbertable_linenumber_for_pc(&m, ste->code, ste->pc);
-
-               stacktrace_print_entry(m, linenumber);
-       }
-}
-
-
-/* stacktrace_print_current ****************************************************
-
-   Print the current stacktrace of the current thread.
-
-   NOTE: This function prints all frames of the stacktrace and does
-   not skip frames like stacktrace_get.
-
-*******************************************************************************/
-
-void stacktrace_print_current(void)
-{
-       stackframeinfo_t *sfi;
-       stackframeinfo_t  tmpsfi;
-       codeinfo         *code;
-       methodinfo       *m;
-       int32_t           linenumber;
-
-       sfi = threads_get_current_stackframeinfo();
-
-       if (sfi == NULL) {
-               puts("\t<<No stacktrace available>>");
-               fflush(stdout);
-               return;
-       }
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get the methodinfo. */
-
-               code = tmpsfi.code;
-               m    = code->m;
-
-               /* Get the line number. */
-
-               linenumber = linenumbertable_linenumber_for_pc(&m, code, tmpsfi.xpc);
-
-               stacktrace_print_entry(m, linenumber);
-       }
-}
-
-
-/* stacktrace_print_of_thread **************************************************
-
-   Print the current stacktrace of the given thread.
-
-   ARGUMENTS:
-       t ... thread
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void stacktrace_print_of_thread(threadobject *t)
-{
-       stackframeinfo_t *sfi;
-       stackframeinfo_t  tmpsfi;
-       codeinfo         *code;
-       methodinfo       *m;
-       int32_t           linenumber;
-
-       /* Build a stacktrace for the passed thread. */
-
-       sfi = t->_stackframeinfo;
-       
-       if (sfi == NULL) {
-               puts("\t<<No stacktrace available>>");
-               fflush(stdout);
-               return;
-       }
-
-       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
-                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
-                stacktrace_stackframeinfo_next(&tmpsfi)) {
-               /* Get the methodinfo. */
-
-               code = tmpsfi.code;
-               m    = code->m;
-
-               /* Get the line number. */
-
-               linenumber = linenumbertable_linenumber_for_pc(&m, code, tmpsfi.xpc);
-
-               stacktrace_print_entry(m, linenumber);
-       }
-}
-#endif
-
-
-/* stacktrace_print_exception **************************************************
-
-   Print the stacktrace of a given exception (more or less a wrapper
-   to stacktrace_print).
-
-   IN:
-       h ... handle of exception to print
-
-*******************************************************************************/
-
-void stacktrace_print_exception(java_handle_t *h)
-{
-       java_lang_Throwable     *o;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       java_lang_VMThrowable   *vmt;
-#endif
-
-       java_lang_Object        *backtrace;
-       java_handle_bytearray_t *ba;
-       stacktrace_t            *st;
-
-       o = (java_lang_Throwable *) h;
-
-       if (o == NULL)
-               return;
-
-       /* now print the stacktrace */
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       LLNI_field_get_ref(o,   vmState, vmt);
-       LLNI_field_get_ref(vmt, vmdata,  backtrace);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-
-       LLNI_field_get_ref(o, backtrace, backtrace);
-
-#else
-# error unknown classpath configuration
-#endif
-
-       ba = (java_handle_bytearray_t *) backtrace;
-
-       /* Sanity check. */
-
-       assert(ba != NULL);
-
-       /* We need a critical section here as we use the byte-array data
-          pointer directly. */
-
-       LLNI_CRITICAL_START;
-       
-       st = (stacktrace_t *) LLNI_array_data(ba);
-
-       stacktrace_print(st);
-
-       LLNI_CRITICAL_END;
-}
-
-
-#if defined(ENABLE_CYCLES_STATS)
-void stacktrace_print_cycles_stats(FILE *file)
-{
-       CYCLES_STATS_PRINT_OVERHEAD(stacktrace_overhead, file);
-       CYCLES_STATS_PRINT(stacktrace_get,               file);
-       CYCLES_STATS_PRINT(stacktrace_getClassContext ,  file);
-       CYCLES_STATS_PRINT(stacktrace_getCurrentClass ,  file);
-       CYCLES_STATS_PRINT(stacktrace_get_stack,         file);
-}
-#endif
-
-
-/*
- * 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/jit/stacktrace.cpp b/src/vm/jit/stacktrace.cpp
new file mode 100644 (file)
index 0000000..9b63c7e
--- /dev/null
@@ -0,0 +1,1310 @@
+/* src/vm/jit/stacktrace.cpp - machine independent stacktrace system
+
+   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 <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "md.h"
+
+#include "mm/gc.hpp"
+#include "mm/memory.h"
+
+#include "vm/jit/stacktrace.hpp"
+
+#include "native/llni.h"
+
+#include "threads/thread.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/array.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/cycles-stats.h"
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/loader.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/methodheader.h"
+#include "vm/jit/methodtree.h"
+
+
+// FIXME Use C-linkage for now.
+extern "C" {
+
+/* global variables ***********************************************************/
+
+CYCLES_STATS_DECLARE(stacktrace_overhead        , 100, 1)
+CYCLES_STATS_DECLARE(stacktrace_fillInStackTrace, 40,  5000)
+CYCLES_STATS_DECLARE(stacktrace_get,              40,  5000)
+CYCLES_STATS_DECLARE(stacktrace_getClassContext , 40,  5000)
+CYCLES_STATS_DECLARE(stacktrace_getCurrentClass , 40,  5000)
+CYCLES_STATS_DECLARE(stacktrace_get_stack       , 40,  10000)
+
+
+/* stacktrace_stackframeinfo_add ***********************************************
+
+   Fills a stackframe info structure with the given or calculated
+   values and adds it to the chain.
+
+*******************************************************************************/
+
+void stacktrace_stackframeinfo_add(stackframeinfo_t* sfi, void* pv, void* sp, void* ra, void* xpc)
+{
+       stackframeinfo_t *currentsfi;
+       codeinfo         *code;
+#if defined(ENABLE_JIT)
+       s4                 framesize;
+#endif
+
+       /* Get current stackframe info. */
+
+       currentsfi = threads_get_current_stackframeinfo();
+
+       /* sometimes we don't have pv handy (e.g. in asmpart.S:
+       L_asm_call_jit_compiler_exception or in the interpreter). */
+
+       if (pv == NULL) {
+#if defined(ENABLE_INTRP)
+               if (opt_intrp)
+                       pv = methodtree_find(ra);
+               else
+#endif
+                       {
+#if defined(ENABLE_JIT)
+# if defined(__SPARC_64__)
+                               pv = md_get_pv_from_stackframe(sp);
+# else
+                               pv = md_codegen_get_pv_from_pc(ra);
+# endif
+#endif
+                       }
+       }
+
+       /* Get codeinfo pointer for the parent Java method. */
+
+       code = code_get_codeinfo_for_pv(pv);
+
+       /* XXX */
+       /*      assert(m != NULL); */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       /* When using the interpreter, we pass RA to the function. */
+
+       if (!opt_intrp) {
+# endif
+# if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__M68K__)
+               /* On i386 and x86_64 we always have to get the return address
+                  from the stack. */
+               /* m68k has return address on stack always */
+               /* On S390 we use REG_RA as REG_ITMP3, so we have always to get
+                  the RA from stack. */
+
+               framesize = *((u4 *) (((uintptr_t) pv) + FrameSize));
+
+               ra = md_stacktrace_get_returnaddress(sp, framesize);
+# else
+               /* If the method is a non-leaf function, we need to get the
+                  return address from the stack.  For leaf functions the
+                  return address is set correctly.  This makes the assembler
+                  and the signal handler code simpler.  The code is NULL is
+                  the asm_vm_call_method special case. */
+
+               if ((code == NULL) || !code_is_leafmethod(code)) {
+                       framesize = *((u4 *) (((uintptr_t) pv) + FrameSize));
+
+                       ra = md_stacktrace_get_returnaddress(sp, framesize);
+               }
+# endif
+# if defined(ENABLE_INTRP)
+       }
+# endif
+#endif
+
+       /* Calculate XPC when not given.  The XPC is then the return
+          address of the current method minus 1 because the RA points to
+          the instruction after the call instruction.  This is required
+          e.g. for method stubs. */
+
+       if (xpc == NULL) {
+               xpc = (void *) (((intptr_t) ra) - 1);
+       }
+
+       /* Fill new stackframeinfo structure. */
+
+       sfi->prev = currentsfi;
+       sfi->code = code;
+       sfi->pv   = pv;
+       sfi->sp   = sp;
+       sfi->ra   = ra;
+       sfi->xpc  = xpc;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackFrameInfo) {
+               log_start();
+               log_print("[stackframeinfo add   : sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
+                                 sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc);
+               method_print(sfi->code->m);
+               log_print("]");
+               log_finish();
+       }
+#endif
+
+       /* Store new stackframeinfo pointer. */
+
+       threads_set_current_stackframeinfo(sfi);
+
+       /* set the native world flag for the current thread */
+       /* ATTENTION: This flag tells the GC how to treat this thread in case of
+          a collection. Set this flag _after_ a valid stackframe info was set. */
+
+       THREAD_NATIVEWORLD_ENTER;
+}
+
+
+/* stacktrace_stackframeinfo_remove ********************************************
+
+   Remove the given stackframeinfo from the chain in the current
+   thread.
+
+*******************************************************************************/
+
+void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi)
+{
+       /* Clear the native world flag for the current thread. */
+       /* ATTENTION: Clear this flag _before_ removing the stackframe info. */
+
+       THREAD_NATIVEWORLD_EXIT;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackFrameInfo) {
+               log_start();
+               log_print("[stackframeinfo remove: sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
+                                 sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc);
+               method_print(sfi->code->m);
+               log_print("]");
+               log_finish();
+       }
+#endif
+
+       /* Set previous stackframe info. */
+
+       threads_set_current_stackframeinfo(sfi->prev);
+}
+
+
+/* stacktrace_stackframeinfo_fill **********************************************
+
+   Fill the temporary stackframeinfo structure with the values given
+   in sfi.
+
+   IN:
+       tmpsfi ... temporary stackframeinfo
+       sfi ...... stackframeinfo to be used in the next iteration
+
+*******************************************************************************/
+
+static inline void stacktrace_stackframeinfo_fill(stackframeinfo_t *tmpsfi, stackframeinfo_t *sfi)
+{
+       /* Sanity checks. */
+
+       assert(tmpsfi != NULL);
+       assert(sfi != NULL);
+
+       /* Fill the temporary stackframeinfo. */
+
+       tmpsfi->code = sfi->code;
+       tmpsfi->pv   = sfi->pv;
+       tmpsfi->sp   = sfi->sp;
+       tmpsfi->ra   = sfi->ra;
+       tmpsfi->xpc  = sfi->xpc;
+
+       /* Set the previous stackframe info of the temporary one to the
+          next in the chain. */
+
+       tmpsfi->prev = sfi->prev;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace fill]");
+#endif
+}
+
+
+/* stacktrace_stackframeinfo_next **********************************************
+
+   Walk the stack (or the stackframeinfo-chain) to the next method and
+   return the new stackframe values in the temporary stackframeinfo
+   passed.
+
+   ATTENTION: This function does NOT skip builtin methods!
+
+   IN:
+       tmpsfi ... temporary stackframeinfo of current method
+
+*******************************************************************************/
+
+static inline void stacktrace_stackframeinfo_next(stackframeinfo_t *tmpsfi)
+{
+       codeinfo         *code;
+       void             *pv;
+       void             *sp;
+       void             *ra;
+       void             *xpc;
+       uint32_t          framesize;
+       stackframeinfo_t *prevsfi;
+
+       /* Sanity check. */
+
+       assert(tmpsfi != NULL);
+
+       /* Get values from the stackframeinfo. */
+
+       code = tmpsfi->code;
+       pv   = tmpsfi->pv;
+       sp   = tmpsfi->sp;
+       ra   = tmpsfi->ra;
+       xpc  = tmpsfi->xpc;
+       /* Get the current stack frame size. */
+
+       framesize = *((uint32_t *) (((intptr_t) pv) + FrameSize));
+
+       /* Get the RA of the current stack frame (RA to the parent Java
+          method) if the current method is a non-leaf method.  Otherwise
+          the value in the stackframeinfo is correct (from the signal
+          handler). */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               ra = intrp_md_stacktrace_get_returnaddress(sp, framesize);
+       else
+# endif
+               {
+                       if (!code_is_leafmethod(code))
+                               ra = md_stacktrace_get_returnaddress(sp, framesize);
+               }
+#else
+       ra = intrp_md_stacktrace_get_returnaddress(sp, framesize);
+#endif
+
+       /* Get the PV for the parent Java method. */
+
+#if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               pv = methodtree_find(ra);
+       else
+#endif
+               {
+#if defined(ENABLE_JIT)
+# if defined(__SPARC_64__)
+                       sp = md_get_framepointer(sp);
+                       pv = md_get_pv_from_stackframe(sp);
+# else
+                       pv = md_codegen_get_pv_from_pc(ra);
+# endif
+#endif
+               }
+
+       /* Get the codeinfo pointer for the parent Java method. */
+
+       code = code_get_codeinfo_for_pv(pv);
+
+       /* Calculate the SP for the parent Java method. */
+
+#if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               sp = *(u1 **) (sp - framesize);
+       else
+#endif
+               {
+#if defined(__I386__) || defined (__X86_64__) || defined (__M68K__)
+                       sp = (void *) (((intptr_t) sp) + framesize + SIZEOF_VOID_P);
+#elif defined(__SPARC_64__)
+                       /* already has the new sp */
+#else
+                       sp = (void *) (((intptr_t) sp) + framesize);
+#endif
+               }
+
+       /* If the new codeinfo pointer is NULL we reached a
+          asm_vm_call_method function.  In this case we get the next
+          values from the previous stackframeinfo in the chain.
+          Otherwise the new values have been calculated before. */
+
+       if (code == NULL) {
+               prevsfi = tmpsfi->prev;
+
+               /* If the previous stackframeinfo in the chain is NULL we
+                  reached the top of the stacktrace.  We set code and prev to
+                  NULL to mark the end, which is checked in
+                  stacktrace_stackframeinfo_end_check. */
+
+               if (prevsfi == NULL) {
+                       tmpsfi->code = NULL;
+                       tmpsfi->prev = NULL;
+                       return;
+               }
+
+               /* Fill the temporary stackframeinfo with the new values. */
+
+               stacktrace_stackframeinfo_fill(tmpsfi, prevsfi);
+       }
+       else {
+               /* Store the new values in the stackframeinfo.  NOTE: We
+                  subtract 1 from the RA to get the XPC, because the RA
+                  points to the instruction after the call instruction. */
+
+               tmpsfi->code = code;
+               tmpsfi->pv   = pv;
+               tmpsfi->sp   = sp;
+               tmpsfi->ra   = ra;
+               tmpsfi->xpc  = (void *) (((intptr_t) ra) - 1);
+       }
+
+#if !defined(NDEBUG)
+       /* Print current method information. */
+
+       if (opt_DebugStackTrace) {
+               log_start();
+               log_print("[stacktrace: method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=",
+                                 tmpsfi->code->m, tmpsfi->pv, tmpsfi->sp, tmpsfi->ra,
+                                 tmpsfi->xpc);
+               method_print(tmpsfi->code->m);
+               log_print("]");
+               log_finish();
+       }
+#endif
+}
+
+
+/* stacktrace_stackframeinfo_end_check *****************************************
+
+   Check if we reached the end of the stacktrace.
+
+   IN:
+       tmpsfi ... temporary stackframeinfo of current method
+
+   RETURN:
+       true .... the end is reached
+          false ... the end is not reached
+
+*******************************************************************************/
+
+static inline bool stacktrace_stackframeinfo_end_check(stackframeinfo_t *tmpsfi)
+{
+       /* Sanity check. */
+
+       assert(tmpsfi != NULL);
+
+       if ((tmpsfi->code == NULL) && (tmpsfi->prev == NULL)) {
+#if !defined(NDEBUG)
+               if (opt_DebugStackTrace)
+                       log_println("[stacktrace stop]");
+#endif
+
+               return true;
+       }
+
+       return false;
+}
+
+
+/* stacktrace_depth ************************************************************
+
+   Calculates and returns the depth of the current stacktrace.
+
+   IN:
+       sfi ... stackframeinfo where to start the stacktrace
+
+   RETURN:
+       depth of the stacktrace
+
+*******************************************************************************/
+
+static int stacktrace_depth(stackframeinfo_t *sfi)
+{
+       stackframeinfo_t  tmpsfi;
+       int               depth;
+       methodinfo       *m;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_depth]");
+#endif
+
+       /* XXX This is not correct, but a workaround for threads-dump for
+          now. */
+/*     assert(sfi != NULL); */
+       if (sfi == NULL)
+               return 0;
+
+       /* Iterate over all stackframes. */
+
+       depth = 0;
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get methodinfo. */
+
+               m = tmpsfi.code->m;
+
+               /* Skip builtin methods. */
+
+               if (m->flags & ACC_METHOD_BUILTIN)
+                       continue;
+
+               depth++;
+       }
+
+       return depth;
+}
+
+
+/* stacktrace_get **************************************************************
+
+   Builds and returns a stacktrace starting from the given stackframe
+   info and returns the stacktrace structure wrapped in a Java
+   byte-array to not confuse the GC.
+
+   IN:
+       sfi ... stackframe info to start stacktrace from
+
+   RETURN:
+       stacktrace as Java byte-array
+
+*******************************************************************************/
+
+java_handle_bytearray_t *stacktrace_get(stackframeinfo_t *sfi)
+{
+       stackframeinfo_t         tmpsfi;
+       int                      depth;
+       java_handle_bytearray_t *ba;
+       int32_t                  ba_size;
+       stacktrace_t            *st;
+       stacktrace_entry_t      *ste;
+       methodinfo              *m;
+       bool                     skip_fillInStackTrace;
+       bool                     skip_init;
+
+       CYCLES_STATS_DECLARE_AND_START_WITH_OVERHEAD
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_get]");
+#endif
+
+       skip_fillInStackTrace = true;
+       skip_init             = true;
+
+       depth = stacktrace_depth(sfi);
+
+       if (depth == 0)
+               return NULL;
+
+       /* Allocate memory from the GC heap and copy the stacktrace
+          buffer. */
+       /* ATTENTION: Use a Java byte-array for this to not confuse the
+          GC. */
+       /* FIXME: We waste some memory here as we skip some entries
+          later. */
+
+       ba_size = sizeof(stacktrace_t) + sizeof(stacktrace_entry_t) * depth;
+
+       ba = builtin_newarray_byte(ba_size);
+
+       if (ba == NULL)
+               goto return_NULL;
+
+       /* Get a stacktrace entry pointer. */
+       /* ATTENTION: We need a critical section here because we use the
+          byte-array data pointer directly. */
+
+       LLNI_CRITICAL_START;
+
+       st = (stacktrace_t *) LLNI_array_data(ba);
+
+       ste = st->entries;
+
+       /* Iterate over the whole stack. */
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get the methodinfo. */
+
+               m = tmpsfi.code->m;
+
+               /* Skip builtin methods. */
+
+               if (m->flags & ACC_METHOD_BUILTIN)
+                       continue;
+
+               /* This logic is taken from
+                  hotspot/src/share/vm/classfile/javaClasses.cpp
+                  (java_lang_Throwable::fill_in_stack_trace). */
+
+               if (skip_fillInStackTrace == true) {
+                       /* Check "fillInStackTrace" only once, so we negate the
+                          flag after the first time check. */
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+                       /* For GNU Classpath we also need to skip
+                          VMThrowable.fillInStackTrace(). */
+
+                       if ((m->clazz == class_java_lang_VMThrowable) &&
+                               (m->name  == utf_fillInStackTrace))
+                               continue;
+#endif
+
+                       skip_fillInStackTrace = false;
+
+                       if (m->name == utf_fillInStackTrace)
+                               continue;
+               }
+
+               /* Skip <init> methods of the exceptions klass.  If there is
+                  <init> methods that belongs to a superclass of the
+                  exception we are going to skipping them in stack trace. */
+
+               if (skip_init == true) {
+                       if ((m->name == utf_init) &&
+                               (class_issubclass(m->clazz, class_java_lang_Throwable))) {
+                               continue;
+                       }
+                       else {
+                               /* If no "Throwable.init()" method found, we stop
+                                  checking it next time. */
+
+                               skip_init = false;
+                       }
+               }
+
+               /* Store the stacktrace entry and increment the pointer. */
+
+               ste->code = tmpsfi.code;
+               ste->pc   = tmpsfi.xpc;
+
+               ste++;
+       }
+
+       /* Store the number of entries in the stacktrace structure. */
+
+       st->length = ste - st->entries;
+
+       LLNI_CRITICAL_END;
+
+       /* release dump memory */
+
+/*     dump_release(dumpsize); */
+
+       CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace,
+                                                                  stacktrace_overhead)
+       return ba;
+
+return_NULL:
+/*     dump_release(dumpsize); */
+
+       CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace,
+                                                                  stacktrace_overhead)
+
+       return NULL;
+}
+
+
+/* stacktrace_get_current ******************************************************
+
+   Builds and returns a stacktrace from the current thread and returns
+   the stacktrace structure wrapped in a Java byte-array to not
+   confuse the GC.
+
+   RETURN:
+       stacktrace as Java byte-array
+
+*******************************************************************************/
+
+java_handle_bytearray_t *stacktrace_get_current(void)
+{
+       stackframeinfo_t        *sfi;
+       java_handle_bytearray_t *ba;
+
+       sfi = threads_get_current_stackframeinfo();
+       ba  = stacktrace_get(sfi);
+
+       return ba;
+}
+
+
+/* stacktrace_get_caller_class *************************************************
+
+   Get the class on the stack at the given depth.  This function skips
+   various special classes or methods.
+
+   ARGUMENTS:
+       depth ... depth to get caller class of
+
+   RETURN:
+       caller class
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+classinfo *stacktrace_get_caller_class(int depth)
+{
+       stackframeinfo_t *sfi;
+       stackframeinfo_t  tmpsfi;
+       methodinfo       *m;
+       classinfo        *c;
+       int               i;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_get_caller_class]");
+#endif
+
+       /* Get the stackframeinfo of the current thread. */
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* Iterate over the whole stack until we reached the requested
+          depth. */
+
+       i = 0;
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+
+               m = tmpsfi.code->m;
+               c = m->clazz;
+
+               /* Skip builtin methods. */
+
+               if (m->flags & ACC_METHOD_BUILTIN)
+                       continue;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+               /* NOTE: See hotspot/src/share/vm/runtime/vframe.cpp
+                  (vframeStreamCommon::security_get_caller_frame). */
+
+               /* This is java.lang.reflect.Method.invoke(), skip it. */
+
+               if (m == method_java_lang_reflect_Method_invoke)
+                       continue;
+
+               /* This is an auxiliary frame, skip it. */
+
+               if (class_issubclass(c, class_sun_reflect_MagicAccessorImpl))
+                       continue;
+#endif
+
+               /* We reached the requested depth. */
+
+               if (i >= depth)
+                       return c;
+
+               i++;
+       }
+
+       return NULL;
+}
+#endif
+
+
+/* stacktrace_first_nonnull_classloader ****************************************
+
+   Returns the first non-null (user-defined) classloader on the stack.
+   If none is found NULL is returned.
+
+   RETURN:
+       classloader
+
+*******************************************************************************/
+
+classloader_t *stacktrace_first_nonnull_classloader(void)
+{
+       stackframeinfo_t *sfi;
+       stackframeinfo_t  tmpsfi;
+       methodinfo       *m;
+       classloader_t    *cl;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_first_nonnull_classloader]");
+#endif
+
+       /* Get the stackframeinfo of the current thread. */
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* Iterate over the whole stack. */
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+
+               m  = tmpsfi.code->m;
+               cl = class_get_classloader(m->clazz);
+
+               if (cl != NULL)
+                       return cl;
+       }
+
+       return NULL;
+}
+
+
+/* stacktrace_getClassContext **************************************************
+
+   Creates a Class context array.
+
+   RETURN VALUE:
+      the array of java.lang.Class objects, or
+         NULL if an exception has been thrown
+
+*******************************************************************************/
+
+java_handle_objectarray_t *stacktrace_getClassContext(void)
+{
+       stackframeinfo_t           *sfi;
+       stackframeinfo_t            tmpsfi;
+       int                         depth;
+       java_handle_objectarray_t  *oa;
+       java_object_t             **data;
+       int                         i;
+       methodinfo                 *m;
+
+       CYCLES_STATS_DECLARE_AND_START
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_getClassContext]");
+#endif
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* Get the depth of the current stack. */
+
+       depth = stacktrace_depth(sfi);
+
+       /* The first stackframe corresponds to the method whose
+          implementation calls this native function.  We remove that
+          entry. */
+
+       depth--;
+       stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+       stacktrace_stackframeinfo_next(&tmpsfi);
+
+       /* Allocate the Class array. */
+
+       oa = builtin_anewarray(depth, class_java_lang_Class);
+
+       if (oa == NULL) {
+               CYCLES_STATS_END(stacktrace_getClassContext);
+
+               return NULL;
+       }
+
+       /* Fill the Class array from the stacktrace list. */
+
+       LLNI_CRITICAL_START;
+
+       data = LLNI_array_data(oa);
+
+       /* Iterate over the whole stack. */
+
+       i = 0;
+
+       for (;
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get methodinfo. */
+
+               m = tmpsfi.code->m;
+
+               /* Skip builtin methods. */
+
+               if (m->flags & ACC_METHOD_BUILTIN)
+                       continue;
+
+               /* Store the class in the array. */
+
+               data[i] = (java_object_t *) m->clazz;
+
+               i++;
+       }
+
+       LLNI_CRITICAL_END;
+
+       CYCLES_STATS_END(stacktrace_getClassContext)
+
+       return oa;
+}
+
+
+/* stacktrace_getCurrentClass **************************************************
+
+   Find the current class by walking the stack trace.
+
+   Quote from the JNI documentation:
+        
+   In the Java 2 Platform, FindClass locates the class loader
+   associated with the current native method.  If the native code
+   belongs to a system class, no class loader will be
+   involved. Otherwise, the proper class loader will be invoked to
+   load and link the named class. When FindClass is called through the
+   Invocation Interface, there is no current native method or its
+   associated class loader. In that case, the result of
+   ClassLoader.getBaseClassLoader is used."
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+classinfo *stacktrace_get_current_class(void)
+{
+       stackframeinfo_t *sfi;
+       stackframeinfo_t  tmpsfi;
+       methodinfo       *m;
+
+       CYCLES_STATS_DECLARE_AND_START;
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_get_current_class]");
+#endif
+
+       /* Get the stackframeinfo of the current thread. */
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* If the stackframeinfo is NULL then FindClass is called through
+          the Invocation Interface and we return NULL */
+
+       if (sfi == NULL) {
+               CYCLES_STATS_END(stacktrace_getCurrentClass);
+
+               return NULL;
+       }
+
+       /* Iterate over the whole stack. */
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get the methodinfo. */
+
+               m = tmpsfi.code->m;
+
+               if (m->clazz == class_java_security_PrivilegedAction) {
+                       CYCLES_STATS_END(stacktrace_getCurrentClass);
+
+                       return NULL;
+               }
+
+               if (m->clazz != NULL) {
+                       CYCLES_STATS_END(stacktrace_getCurrentClass);
+
+                       return m->clazz;
+               }
+       }
+
+       /* No Java method found on the stack. */
+
+       CYCLES_STATS_END(stacktrace_getCurrentClass);
+
+       return NULL;
+}
+#endif /* ENABLE_JAVASE */
+
+
+/* stacktrace_get_stack ********************************************************
+
+   Create a 2-dimensional array for java.security.VMAccessControler.
+
+   RETURN VALUE:
+      the arrary, or
+         NULL if an exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+java_handle_objectarray_t *stacktrace_get_stack(void)
+{
+       stackframeinfo_t          *sfi;
+       stackframeinfo_t           tmpsfi;
+       int                        depth;
+       java_handle_objectarray_t *oa;
+       java_handle_objectarray_t *classes;
+       java_handle_objectarray_t *methodnames;
+       methodinfo                *m;
+       java_handle_t             *string;
+       int                        i;
+
+       CYCLES_STATS_DECLARE_AND_START
+
+#if !defined(NDEBUG)
+       if (opt_DebugStackTrace)
+               log_println("[stacktrace_get_stack]");
+#endif
+
+       /* Get the stackframeinfo of the current thread. */
+
+       sfi = threads_get_current_stackframeinfo();
+
+       /* Get the depth of the current stack. */
+
+       depth = stacktrace_depth(sfi);
+
+       if (depth == 0)
+               return NULL;
+
+       /* Allocate the required arrays. */
+
+       oa = builtin_anewarray(2, arrayclass_java_lang_Object);
+
+       if (oa == NULL)
+               goto return_NULL;
+
+       classes = builtin_anewarray(depth, class_java_lang_Class);
+
+       if (classes == NULL)
+               goto return_NULL;
+
+       methodnames = builtin_anewarray(depth, class_java_lang_String);
+
+       if (methodnames == NULL)
+               goto return_NULL;
+
+       /* Set up the 2-dimensional array. */
+
+       array_objectarray_element_set(oa, 0, (java_handle_t *) classes);
+       array_objectarray_element_set(oa, 1, (java_handle_t *) methodnames);
+
+       /* Iterate over the whole stack. */
+       /* TODO We should use a critical section here to speed things
+          up. */
+
+       i = 0;
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get the methodinfo. */
+
+               m = tmpsfi.code->m;
+
+               /* Skip builtin methods. */
+
+               if (m->flags & ACC_METHOD_BUILTIN)
+                       continue;
+
+               /* Store the class in the array. */
+               /* NOTE: We use a LLNI-macro here, because a classinfo is not
+                  a handle. */
+
+               LLNI_array_direct(classes, i) = (java_object_t *) m->clazz;
+
+               /* Store the name in the array. */
+
+               string = javastring_new(m->name);
+
+               if (string == NULL)
+                       goto return_NULL;
+
+               array_objectarray_element_set(methodnames, i, string);
+
+               i++;
+       }
+
+       CYCLES_STATS_END(stacktrace_get_stack)
+
+       return oa;
+
+return_NULL:
+       CYCLES_STATS_END(stacktrace_get_stack)
+
+       return NULL;
+}
+#endif
+
+
+/* stacktrace_print_entry ****************************************************
+
+   Print line for a stacktrace entry.
+
+   ARGUMENTS:
+       m ............ methodinfo of the entry
+       linenumber ... linenumber of the entry
+
+*******************************************************************************/
+
+static void stacktrace_print_entry(methodinfo *m, int32_t linenumber)
+{
+       /* Sanity check. */
+
+       assert(m != NULL);
+
+       printf("\tat ");
+
+       if (m->flags & ACC_METHOD_BUILTIN)
+               printf("NULL");
+       else
+               utf_display_printable_ascii_classname(m->clazz->name);
+
+       printf(".");
+       utf_display_printable_ascii(m->name);
+       utf_display_printable_ascii(m->descriptor);
+
+       if (m->flags & ACC_NATIVE) {
+               puts("(Native Method)");
+       }
+       else {
+               if (m->flags & ACC_METHOD_BUILTIN) {
+                       puts("(builtin)");
+               }
+               else {
+                       printf("(");
+                       utf_display_printable_ascii(m->clazz->sourcefile);
+                       printf(":%d)\n", linenumber);
+               }
+       }
+
+       fflush(stdout);
+}
+
+
+/* stacktrace_print ************************************************************
+
+   Print the given stacktrace with CACAO intern methods only (no Java
+   code required).
+
+   This method is used by stacktrace_dump_trace and
+   builtin_trace_exception.
+
+   IN:
+       st ... stacktrace to print
+
+*******************************************************************************/
+
+void stacktrace_print(stacktrace_t *st)
+{
+       stacktrace_entry_t *ste;
+       methodinfo         *m;
+       int32_t             linenumber;
+       int                 i;
+
+       ste = &(st->entries[0]);
+
+       for (i = 0; i < st->length; i++, ste++) {
+               m = ste->code->m;
+
+               /* Get the line number. */
+
+               linenumber = ste->code->linenumbertable->find(&m, ste->pc);
+
+               stacktrace_print_entry(m, linenumber);
+       }
+}
+
+
+/* stacktrace_print_current ****************************************************
+
+   Print the current stacktrace of the current thread.
+
+   NOTE: This function prints all frames of the stacktrace and does
+   not skip frames like stacktrace_get.
+
+*******************************************************************************/
+
+void stacktrace_print_current(void)
+{
+       stackframeinfo_t *sfi;
+       stackframeinfo_t  tmpsfi;
+       codeinfo         *code;
+       methodinfo       *m;
+       int32_t           linenumber;
+
+       sfi = threads_get_current_stackframeinfo();
+
+       if (sfi == NULL) {
+               puts("\t<<No stacktrace available>>");
+               fflush(stdout);
+               return;
+       }
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get the methodinfo. */
+
+               code = tmpsfi.code;
+               m    = code->m;
+
+               // Get the line number.
+               linenumber = code->linenumbertable->find(&m, tmpsfi.xpc);
+
+               stacktrace_print_entry(m, linenumber);
+       }
+}
+
+
+/* stacktrace_print_of_thread **************************************************
+
+   Print the current stacktrace of the given thread.
+
+   ARGUMENTS:
+       t ... thread
+
+*******************************************************************************/
+
+#if defined(ENABLE_THREADS)
+void stacktrace_print_of_thread(threadobject *t)
+{
+       stackframeinfo_t *sfi;
+       stackframeinfo_t  tmpsfi;
+       codeinfo         *code;
+       methodinfo       *m;
+       int32_t           linenumber;
+
+       /* Build a stacktrace for the passed thread. */
+
+       sfi = t->_stackframeinfo;
+       
+       if (sfi == NULL) {
+               puts("\t<<No stacktrace available>>");
+               fflush(stdout);
+               return;
+       }
+
+       for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi);
+                stacktrace_stackframeinfo_end_check(&tmpsfi) == false;
+                stacktrace_stackframeinfo_next(&tmpsfi)) {
+               /* Get the methodinfo. */
+
+               code = tmpsfi.code;
+               m    = code->m;
+
+               // Get the line number.
+               linenumber = code->linenumbertable->find(&m, tmpsfi.xpc);
+
+               stacktrace_print_entry(m, linenumber);
+       }
+}
+#endif
+
+
+/* stacktrace_print_exception **************************************************
+
+   Print the stacktrace of a given exception (more or less a wrapper
+   to stacktrace_print).
+
+   IN:
+       h ... handle of exception to print
+
+*******************************************************************************/
+
+void stacktrace_print_exception(java_handle_t *h)
+{
+       if (h == NULL)
+               return;
+
+       java_lang_Throwable t(h);
+
+       /* now print the stacktrace */
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       java_lang_VMThrowable vmt(t.get_vmState());
+       java_handle_bytearray_t* backtrace = vmt.get_vmdata();
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+       java_handle_bytearray_t* backtrace = t.get_backtrace();
+
+#else
+# error unknown classpath configuration
+#endif
+
+       // Sanity check.
+
+       assert(backtrace != NULL);
+
+       /* We need a critical section here as we use the byte-array data
+          pointer directly. */
+
+       LLNI_CRITICAL_START;
+       
+       stacktrace_t* st = (stacktrace_t*) LLNI_array_data(backtrace);
+
+       stacktrace_print(st);
+
+       LLNI_CRITICAL_END;
+}
+
+
+#if defined(ENABLE_CYCLES_STATS)
+void stacktrace_print_cycles_stats(FILE *file)
+{
+       CYCLES_STATS_PRINT_OVERHEAD(stacktrace_overhead, file);
+       CYCLES_STATS_PRINT(stacktrace_get,               file);
+       CYCLES_STATS_PRINT(stacktrace_getClassContext ,  file);
+       CYCLES_STATS_PRINT(stacktrace_getCurrentClass ,  file);
+       CYCLES_STATS_PRINT(stacktrace_get_stack,         file);
+}
+#endif
+
+} // extern "C"
+
+
+/*
+ * 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/jit/stacktrace.h b/src/vm/jit/stacktrace.h
deleted file mode 100644 (file)
index e21c348..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/* src/vm/jit/stacktrace.h - header file for stacktrace generation
-
-   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 _STACKTRACE_H
-#define _STACKTRACE_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct stackframeinfo_t   stackframeinfo_t;
-typedef struct stacktrace_entry_t stacktrace_entry_t;
-typedef struct stacktrace_t       stacktrace_t;
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "md-abi.h"
-
-#include "threads/thread.h"
-
-#include "vm/global.h"
-
-#include "vm/jit/code.h"
-
-#include "vmcore/class.h"
-
-
-/* stackframeinfo **************************************************************
-
-   ATTENTION: Keep the number of elements of this structure even, to
-   make sure that the stack keeps aligned (e.g. 16-bytes for x86_64).
-
-*******************************************************************************/
-
-struct stackframeinfo_t {
-       stackframeinfo_t *prev;             /* pointer to prev stackframeinfo     */
-       codeinfo         *code;             /* codeinfo of current method         */
-       u1               *pv;               /* PV of current function             */
-       u1               *sp;               /* SP of parent Java function         */
-       u1               *ra;               /* RA to parent Java function         */
-       u1               *xpc;              /* XPC (for inline stubs)             */
-#if defined(ENABLE_GC_CACAO)
-       /* 
-        * The exact GC needs to be able to recover saved registers, so the
-        * native-stub saves these registers here
-        */
-# if defined(HAS_ADDRESS_REGISTER_FILE)
-       uintptr_t         adrregs[ADR_SAV_CNT];
-# else
-       uintptr_t         intregs[INT_SAV_CNT];
-# endif
-#endif
-};
-
-
-/* stacktrace_entry_t *********************************************************/
-
-struct stacktrace_entry_t {
-       codeinfo *code;                     /* codeinfo pointer of this method    */
-       void     *pc;                       /* PC in this method                  */
-};
-
-
-/* stacktrace_t ***************************************************************/
-
-struct stacktrace_t {
-       int32_t            length;          /* length of the entries array        */
-       stacktrace_entry_t entries[1];      /* stacktrace entries                 */
-};
-
-
-/* function prototypes ********************************************************/
-
-void                       stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, u1 *pv, u1 *sp, u1 *ra, u1 *xpc);
-void                       stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi);
-
-java_handle_bytearray_t   *stacktrace_get(stackframeinfo_t *sfi);
-java_handle_bytearray_t   *stacktrace_get_current(void);
-
-#if defined(ENABLE_JAVASE)
-classinfo                 *stacktrace_get_caller_class(int depth);
-classloader_t             *stacktrace_first_nonnull_classloader(void);
-java_handle_objectarray_t *stacktrace_getClassContext(void);
-classinfo                 *stacktrace_get_current_class(void);
-java_handle_objectarray_t *stacktrace_get_stack(void);
-#endif
-
-void                       stacktrace_print(stacktrace_t *st);
-void                       stacktrace_print_current(void);
-
-#if defined(ENABLE_THREADS)
-void                       stacktrace_print_of_thread(threadobject *t);
-#endif
-
-void                       stacktrace_print_exception(java_handle_t *h);
-
-/* machine dependent functions (code in ARCH_DIR/md.c) */
-
-#if defined(ENABLE_JIT)
-# if defined(__SPARC_64__)
-u1 *md_get_framepointer(u1 *sp);
-u1 *md_get_pv_from_stackframe(u1 *sp);
-# endif
-#endif
-
-#if defined(ENABLE_INTRP)
-u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
-#endif
-
-#if defined(ENABLE_CYCLES_STATS)
-void stacktrace_print_cycles_stats(FILE *file);
-#endif
-
-#endif /* _STACKTRACE_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/jit/stacktrace.hpp b/src/vm/jit/stacktrace.hpp
new file mode 100644 (file)
index 0000000..6aa0ecf
--- /dev/null
@@ -0,0 +1,161 @@
+/* src/vm/jit/stacktrace.hpp - header file for stacktrace generation
+
+   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 _STACKTRACE_HPP
+#define _STACKTRACE_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct stackframeinfo_t   stackframeinfo_t;
+typedef struct stacktrace_entry_t stacktrace_entry_t;
+typedef struct stacktrace_t       stacktrace_t;
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/types.h"
+
+#include "md-abi.h"
+
+#include "threads/thread.hpp"
+
+#include "vm/class.hpp"
+#include "vm/global.h"
+
+#include "vm/jit/code.hpp"
+
+
+/* stackframeinfo **************************************************************
+
+   ATTENTION: Keep the number of elements of this structure even, to
+   make sure that the stack keeps aligned (e.g. 16-bytes for x86_64).
+
+*******************************************************************************/
+
+struct stackframeinfo_t {
+       stackframeinfo_t *prev;             /* pointer to prev stackframeinfo     */
+       codeinfo         *code;             /* codeinfo of current method         */
+       void             *pv;               /* PV of current function             */
+       void             *sp;               /* SP of parent Java function         */
+       void             *ra;               /* RA to parent Java function         */
+       void             *xpc;              /* XPC (for inline stubs)             */
+#if defined(ENABLE_GC_CACAO)
+       /* 
+        * The exact GC needs to be able to recover saved registers, so the
+        * native-stub saves these registers here
+        */
+# if defined(HAS_ADDRESS_REGISTER_FILE)
+       uintptr_t         adrregs[ADR_SAV_CNT];
+# else
+       uintptr_t         intregs[INT_SAV_CNT];
+# endif
+#endif
+};
+
+
+/* stacktrace_entry_t *********************************************************/
+
+struct stacktrace_entry_t {
+       codeinfo *code;                     /* codeinfo pointer of this method    */
+       void     *pc;                       /* PC in this method                  */
+};
+
+
+/* stacktrace_t ***************************************************************/
+
+struct stacktrace_t {
+       int32_t            length;          /* length of the entries array        */
+       stacktrace_entry_t entries[1];      /* stacktrace entries                 */
+};
+
+
+/* function prototypes ********************************************************/
+
+// FIXME Use C-linkage for now.
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void                       stacktrace_stackframeinfo_add(stackframeinfo_t* sfi, void* pv, void* sp, void* ra, void* xpc);
+void                       stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi);
+
+java_handle_bytearray_t   *stacktrace_get(stackframeinfo_t *sfi);
+java_handle_bytearray_t   *stacktrace_get_current(void);
+
+#if defined(ENABLE_JAVASE)
+classinfo                 *stacktrace_get_caller_class(int depth);
+classloader_t             *stacktrace_first_nonnull_classloader(void);
+java_handle_objectarray_t *stacktrace_getClassContext(void);
+classinfo                 *stacktrace_get_current_class(void);
+java_handle_objectarray_t *stacktrace_get_stack(void);
+#endif
+
+void                       stacktrace_print(stacktrace_t *st);
+void                       stacktrace_print_current(void);
+
+#if defined(ENABLE_THREADS)
+void                       stacktrace_print_of_thread(threadobject *t);
+#endif
+
+void                       stacktrace_print_exception(java_handle_t *h);
+
+/* machine dependent functions (code in ARCH_DIR/md.c) */
+
+#if defined(ENABLE_JIT)
+# if defined(__SPARC_64__)
+u1 *md_get_framepointer(u1 *sp);
+u1 *md_get_pv_from_stackframe(u1 *sp);
+# endif
+#endif
+
+#if defined(ENABLE_INTRP)
+void* intrp_md_stacktrace_get_returnaddress(void* sp, int32_t framesize);
+#endif
+
+#if defined(ENABLE_CYCLES_STATS)
+void stacktrace_print_cycles_stats(FILE *file);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _STACKTRACE_HPP
+
+
+/*
+ * 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/jit/stubs.cpp b/src/vm/jit/stubs.cpp
new file mode 100644 (file)
index 0000000..66489b6
--- /dev/null
@@ -0,0 +1,439 @@
+/* src/vm/jit/stubs.cpp - JIT stubs
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 <stdint.h>
+
+// Include machine dependent headers.
+#include "md.h"
+
+#include "mm/dumpmemory.hpp"
+
+#include "vm/method.hpp"
+#include "vm/options.h"
+
+#include "vm/jit/abi.h"
+#include "vm/jit/code.hpp"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/disass.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/show.hpp"
+#include "vm/jit/stubs.hpp"
+
+
+/**
+ * Wrapper for codegen_emit_stub_compiler.
+ *
+ * @param m Method object.
+ *
+ * @return Pointer to the compiler stub code.
+ */
+void* CompilerStub::generate(methodinfo *m)
+{
+       jitdata     *jd;
+       codegendata *cd;
+       ptrint      *d;                     /* pointer to data memory             */
+       u1          *c;                     /* pointer to code memory             */
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       /* allocate required data structures */
+
+       jd = (jitdata*) DumpMemory::allocate(sizeof(jitdata));
+
+       jd->m     = m;
+       jd->cd    = (codegendata*) DumpMemory::allocate(sizeof(codegendata));
+       jd->flags = 0;
+
+       /* get required compiler data */
+
+       cd = jd->cd;
+
+#if !defined(JIT_COMPILER_VIA_SIGNAL)
+       /* allocate code memory */
+
+       c = CNEW(u1, 3 * SIZEOF_VOID_P + get_code_size());
+
+       /* set pointers correctly */
+
+       d = (ptrint *) c;
+
+       cd->mcodebase = c;
+
+       c = c + 3 * SIZEOF_VOID_P;
+       cd->mcodeptr = c;
+
+       /* NOTE: The codeinfo pointer is actually a pointer to the
+          methodinfo (this fakes a codeinfo structure). */
+
+       d[0] = (ptrint) asm_call_jit_compiler;
+       d[1] = (ptrint) m;
+       d[2] = (ptrint) &d[1];                                    /* fake code->m */
+
+       /* call the emit function */
+
+       codegen_emit_stub_compiler(jd);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               count_cstub_len += 3 * SIZEOF_VOID_P + get_code_size();
+#endif
+
+       /* flush caches */
+
+       md_cacheflush(cd->mcodebase, 3 * SIZEOF_VOID_P + get_code_size());
+#else
+       /* Allocate code memory. */
+
+       c = CNEW(uint8_t, 2 * SIZEOF_VOID_P + get_code_size());
+
+       /* Set pointers correctly. */
+
+       d = (ptrint *) c;
+
+       cd->mcodebase = c;
+
+       c = c + 2 * SIZEOF_VOID_P;
+       cd->mcodeptr = c;
+
+       /* NOTE: The codeinfo pointer is actually a pointer to the
+          methodinfo (this fakes a codeinfo structure). */
+
+       d[0] = (ptrint) m;
+       d[1] = (ptrint) &d[0];                                    /* fake code->m */
+
+       /* Emit the trap instruction. */
+
+       emit_trap_compiler(cd);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               count_cstub_len += 2 * SIZEOF_VOID_P + get_code_size();
+#endif
+
+       /* Flush caches. */
+
+       md_cacheflush(cd->mcodebase, 2 * SIZEOF_VOID_P + get_code_size());
+#endif
+
+       /* return native stub code */
+
+       return c;
+}
+
+
+/**
+ * Free a compiler stub from memory.
+ *
+ * @param 
+ */
+void CompilerStub::remove(void* stub)
+{
+       // Pass size 1 to keep the intern function happy.
+       CFREE(stub, 1);
+}
+
+
+/* codegen_disassemble_nativestub **********************************************
+
+   Disassembles the generated builtin or native stub.
+
+*******************************************************************************/
+
+#if defined(ENABLE_DISASSEMBLER)
+static void codegen_disassemble_stub(methodinfo *m, u1 *start, u1 *end)
+{
+       printf("Stub code: ");
+       if (m->clazz != NULL)
+               utf_fprint_printable_ascii_classname(stdout, m->clazz->name);
+       else
+               printf("NULL");
+       printf(".");
+       utf_fprint_printable_ascii(stdout, m->name);
+       utf_fprint_printable_ascii(stdout, m->descriptor);
+       printf("\nLength: %d\n\n", (s4) (end - start));
+
+       DISASSEMBLE(start, end);
+}
+#endif
+
+
+/**
+ * Wrapper for codegen_emit_stub_native.
+ *
+ * @param m   Method object.
+ * @param bte Builtin function structure.
+ */
+void BuiltinStub::generate(methodinfo* m, builtintable_entry* bte)
+{
+       jitdata  *jd;
+       codeinfo *code;
+       int       skipparams;
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       /* Create JIT data structure. */
+
+       jd = jit_jitdata_new(m);
+
+       /* Get required compiler data. */
+
+       code = jd->code;
+
+       /* Stubs are non-leaf methods. */
+
+       code_unflag_leafmethod(code);
+
+       /* setup code generation stuff */
+
+       codegen_setup(jd);
+
+       /* Set the number of native arguments we need to skip. */
+
+       skipparams = 0;
+
+       /* generate the code */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (!opt_intrp) {
+# endif
+               assert(bte->fp != NULL);
+               codegen_emit_stub_native(jd, bte->md, bte->fp, skipparams);
+# if defined(ENABLE_INTRP)
+       }
+# endif
+#endif
+
+       /* reallocate the memory and finish the code generation */
+
+       codegen_finish(jd);
+
+       /* set the stub entry point in the builtin table */
+
+       bte->stub = code->entrypoint;
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_stub_native += code->mcodelength;
+#endif
+
+#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
+       /* disassemble native stub */
+
+       if (opt_DisassembleStubs) {
+               codegen_disassemble_stub(m,
+                                                                (u1 *) (ptrint) code->entrypoint,
+                                                                (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen));
+
+               /* show data segment */
+
+               if (opt_showddatasegment)
+                       dseg_display(jd);
+       }
+#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */
+}
+
+
+/**
+ * Wrapper for codegen_emit_stub_native.
+ *
+ * @param m Method object of the native function.
+ * @param f Native function pointer.
+ *
+ * @return The codeinfo representing the stub code.
+ */
+codeinfo* NativeStub::generate(methodinfo* m, functionptr f)
+{
+       jitdata     *jd;
+       codeinfo    *code;
+       methoddesc  *md;
+       methoddesc  *nmd;       
+       int          skipparams;
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       /* Create JIT data structure. */
+
+       jd = jit_jitdata_new(m);
+
+       /* Get required compiler data. */
+
+       code = jd->code;
+
+       /* Stubs are non-leaf methods. */
+
+       code_unflag_leafmethod(code);
+
+       /* set the flags for the current JIT run */
+
+#if defined(ENABLE_PROFILING)
+       if (opt_prof)
+               jd->flags |= JITDATA_FLAG_INSTRUMENT;
+#endif
+
+       if (opt_verbosecall)
+               jd->flags |= JITDATA_FLAG_VERBOSECALL;
+
+       /* setup code generation stuff */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (!opt_intrp)
+# endif
+               reg_setup(jd);
+#endif
+
+       codegen_setup(jd);
+
+       /* create new method descriptor with additional native parameters */
+
+       md = m->parseddesc;
+
+       /* Set the number of native arguments we need to skip. */
+
+       if (m->flags & ACC_STATIC)
+               skipparams = 2;
+       else
+               skipparams = 1;
+       
+       nmd = (methoddesc*) DumpMemory::allocate(sizeof(methoddesc) - sizeof(typedesc) +
+                                                                                        md->paramcount * sizeof(typedesc) +
+                                                                                        skipparams * sizeof(typedesc));
+
+       nmd->paramcount = md->paramcount + skipparams;
+
+       nmd->params = (paramdesc*) DumpMemory::allocate(sizeof(paramdesc) * nmd->paramcount);
+
+       nmd->paramtypes[0].type = TYPE_ADR; /* add environment pointer            */
+
+       if (m->flags & ACC_STATIC)
+               nmd->paramtypes[1].type = TYPE_ADR; /* add class pointer              */
+
+       MCOPY(nmd->paramtypes + skipparams, md->paramtypes, typedesc,
+                 md->paramcount);
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (!opt_intrp)
+# endif
+               /* pre-allocate the arguments for the native ABI */
+
+               md_param_alloc_native(nmd);
+#endif
+
+       /* generate the code */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               intrp_createnativestub(f, jd, nmd);
+       else
+# endif
+               codegen_emit_stub_native(jd, nmd, f, skipparams);
+#else
+       intrp_createnativestub(f, jd, nmd);
+#endif
+
+       /* reallocate the memory and finish the code generation */
+
+       codegen_finish(jd);
+
+#if defined(ENABLE_STATISTICS)
+       /* must be done after codegen_finish() */
+
+       if (opt_stat)
+               size_stub_native += code->mcodelength;
+#endif
+
+#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
+       /* disassemble native stub */
+
+       if (opt_DisassembleStubs) {
+# if defined(ENABLE_DEBUG_FILTER)
+               if (m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
+# endif
+               {
+                       codegen_disassemble_stub(m,
+                                                                        (u1 *) (ptrint) code->entrypoint,
+                                                                        (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen));
+
+                       /* show data segment */
+
+                       if (opt_showddatasegment)
+                               dseg_display(jd);
+               }
+       }
+#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */
+
+       /* return native stub code */
+
+       return code;
+}
+
+
+/**
+ * Free a native stub from memory.
+ *
+ * @param stub Pointer to stub memory.
+ */    
+void NativeStub::remove(void* stub)
+{
+       // Pass size 1 to keep the intern function happy.
+       CFREE(stub, 1);
+}
+
+
+// Legacy C interface.
+
+extern "C" {
+       void*     CompilerStub_generate(methodinfo* m) { return CompilerStub::generate(m); }
+       void      CompilerStub_remove(void* stub) { CompilerStub::remove(stub); }
+
+       void      BuiltinStub_generate(methodinfo* m, builtintable_entry* bte) { BuiltinStub::generate(m, bte); }
+
+       void      NativeStub_remove(void* stub) { NativeStub::remove(stub); }
+}
+
+
+/*
+ * 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/jit/stubs.hpp b/src/vm/jit/stubs.hpp
new file mode 100644 (file)
index 0000000..a8af314
--- /dev/null
@@ -0,0 +1,99 @@
+/* src/vm/jit/stubs.hpp - JIT stubs
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _STUBS_HPP
+#define _STUBS_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/method.hpp"
+
+#include "vm/jit/code.hpp"
+
+
+#ifdef __cplusplus
+
+/**
+ * Class for compiler stub generation.
+ */
+class CompilerStub {
+public:
+       static inline int get_code_size();
+
+       static void* generate(methodinfo* m);
+       static void  remove(void* stub);
+};
+
+
+/**
+ * Class for builtin stub generation.
+ */
+class BuiltinStub {
+public:
+       static void generate(methodinfo* m, builtintable_entry* bte);
+};
+
+
+/**
+ * Class for native stub generation.
+ */
+class NativeStub {
+public:
+       static codeinfo* generate(methodinfo* m, functionptr f);
+       static void      remove(void* stub);
+};
+
+
+// Include machine dependent implementation.
+#include "md-stubs.hpp"
+
+#else
+
+// Legacy C interface.
+
+void*     CompilerStub_generate(methodinfo* m);
+void*     CompilerStub_remove(void* stub);
+void      BuiltinStub_generate(methodinfo* m, builtintable_entry* bte);
+void      NativeStub_remove(void* stub);
+
+#endif
+
+#endif // _STUBS_HPP
+
+
+/*
+ * 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/jit/trace.c b/src/vm/jit/trace.c
deleted file mode 100644 (file)
index ba75999..0000000
+++ /dev/null
@@ -1,643 +0,0 @@
-/* src/vm/jit/trace.c - Functions for tracing from java code.
-
-   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 <stdio.h>
-
-#include "arch.h"
-#include "md-abi.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Throwable.h"
-
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/jit/argument.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/trace.h"
-#include "vm/jit/show.h"
-
-#include "vmcore/options.h"
-#include "vmcore/utf8.h"
-
-
-#if !defined(NDEBUG)
-
-
-/* global variables ***********************************************************/
-
-#if !defined(ENABLE_THREADS)
-s4 _no_threads_tracejavacallindent = 0;
-u4 _no_threads_tracejavacallcount= 0;
-#endif
-
-
-/* trace_java_call_print_argument **********************************************
-
-   XXX: Document me!
-
-*******************************************************************************/
-
-static char *trace_java_call_print_argument(methodinfo *m, char *logtext, s4 *logtextlen, typedesc *paramtype, imm_union imu)
-{
-       java_object_t *o;
-       classinfo     *c;
-       utf           *u;
-       u4             len;
-
-       switch (paramtype->type) {
-       case TYPE_INT:
-               sprintf(logtext + strlen(logtext), "%d (0x%08x)", (int32_t)imu.l, (int32_t)imu.l);
-               break;
-
-       case TYPE_LNG:
-#if SIZEOF_VOID_P == 4
-               sprintf(logtext + strlen(logtext), "%lld (0x%016llx)", imu.l, imu.l);
-#else
-               sprintf(logtext + strlen(logtext), "%ld (0x%016lx)", imu.l, imu.l);
-#endif
-               break;
-
-       case TYPE_FLT:
-               sprintf(logtext + strlen(logtext), "%g (0x%08x)", imu.f, imu.i);
-               break;
-
-       case TYPE_DBL:
-#if SIZEOF_VOID_P == 4
-               sprintf(logtext + strlen(logtext), "%g (0x%016llx)", imu.d, imu.l);
-#else
-               sprintf(logtext + strlen(logtext), "%g (0x%016lx)", imu.d, imu.l);
-#endif
-               break;
-
-       case TYPE_ADR:
-#if SIZEOF_VOID_P == 4
-               sprintf(logtext + strlen(logtext), "0x%08x", (ptrint) imu.l);
-#else
-               sprintf(logtext + strlen(logtext), "0x%016lx", (ptrint) imu.l);
-#endif
-
-               /* Workaround for sun.misc.Unsafe methods.  In the future
-                  (exact GC) we should check if the address is on the GC
-                  heap. */
-
-               if ((m->clazz       != NULL) &&
-                       (m->clazz->name == utf_new_char("sun/misc/Unsafe")))
-                       break;
-
-               /* Cast to java.lang.Object. */
-
-               o = (java_object_t *) (ptrint) imu.l;
-
-               /* Check return argument for java.lang.Class or
-                  java.lang.String. */
-
-               if (o != NULL) {
-                       if (o->vftbl->clazz == class_java_lang_String) {
-                               /* get java.lang.String object and the length of the
-                                  string */
-
-                               u = javastring_toutf(o, false);
-
-                               len = strlen(" (String = \"") + utf_bytes(u) + strlen("\")");
-
-                               /* realloc memory for string length */
-
-                               logtext = DMREALLOC(logtext, char, *logtextlen, *logtextlen + len);
-                               *logtextlen += len;
-
-                               /* convert to utf8 string and strcat it to the logtext */
-
-                               strcat(logtext, " (String = \"");
-                               utf_cat(logtext, u);
-                               strcat(logtext, "\")");
-                       }
-                       else {
-                               if (o->vftbl->clazz == class_java_lang_Class) {
-                                       /* if the object returned is a java.lang.Class
-                                          cast it to classinfo structure and get the name
-                                          of the class */
-
-                                       c = (classinfo *) o;
-
-                                       u = c->name;
-                               }
-                               else {
-                                       /* if the object returned is not a java.lang.String or
-                                          a java.lang.Class just print the name of the class */
-
-                                       u = o->vftbl->clazz->name;
-                               }
-
-                               len = strlen(" (Class = \"") + utf_bytes(u) + strlen("\")");
-
-                               /* realloc memory for string length */
-
-                               logtext = DMREALLOC(logtext, char, *logtextlen, *logtextlen + len);
-                               *logtextlen += len;
-
-                               /* strcat to the logtext */
-
-                               strcat(logtext, " (Class = \"");
-                               utf_cat_classname(logtext, u);
-                               strcat(logtext, "\")");
-                       }
-               }
-       }
-
-       return logtext;
-}
-
-/* trace_java_call_enter ******************************************************
-   Traces an entry into a java method.
-
-   arg_regs: Array containing all argument registers as int64_t values in
-   the same order as listed in m->methoddesc. The array is usually allocated
-   on the stack and used for restoring the argument registers later.
-
-   stack: Pointer to first on stack argument in the same format passed to 
-   asm_vm_call_method.
-
-*******************************************************************************/
-
-void trace_java_call_enter(methodinfo *m, uint64_t *arg_regs, uint64_t *stack)
-{
-       methoddesc *md;
-       imm_union   arg;
-       char       *logtext;
-       s4          logtextlen;
-       s4          i;
-       s4          pos;
-       int32_t     dumpmarker;
-
-       /* We don't trace builtin functions here because the argument
-          passing happens via the native ABI and does not fit these
-          functions. */
-
-       if (method_is_builtin(m))
-               return;
-
-#if defined(ENABLE_DEBUG_FILTER)
-       if (!show_filters_test_verbosecall_enter(m))
-               return;
-#endif
-
-#if defined(ENABLE_VMLOG)
-       vmlog_cacao_enter_method(m);
-       return;
-#endif
-
-       md = m->parseddesc;
-
-       /* calculate message length */
-
-       logtextlen =
-               strlen("4294967295 ") +
-               strlen("-2147483647-") +        /* INT_MAX should be sufficient       */
-               TRACEJAVACALLINDENT +
-               strlen("called: ") +
-               ((m->clazz == NULL) ? strlen("NULL") : utf_bytes(m->clazz->name)) +
-               strlen(".") +
-               utf_bytes(m->name) +
-               utf_bytes(m->descriptor);
-
-       /* Actually it's not possible to have all flags printed, but:
-          safety first! */
-
-       logtextlen +=
-               strlen(" PUBLIC") +
-               strlen(" PRIVATE") +
-               strlen(" PROTECTED") +
-               strlen(" STATIC") +
-               strlen(" FINAL") +
-               strlen(" SYNCHRONIZED") +
-               strlen(" VOLATILE") +
-               strlen(" TRANSIENT") +
-               strlen(" NATIVE") +
-               strlen(" INTERFACE") +
-               strlen(" ABSTRACT") +
-               strlen(" METHOD_BUILTIN");
-
-       /* add maximal argument length */
-
-       logtextlen +=
-               strlen("(") +
-               strlen("-9223372036854775808 (0x123456789abcdef0), ") * md->paramcount +
-               strlen("...(255)") +
-               strlen(")");
-
-       /* allocate memory */
-
-       DMARKER;
-
-       logtext = DMNEW(char, logtextlen);
-
-       TRACEJAVACALLCOUNT++;
-
-       sprintf(logtext, "%10d ", TRACEJAVACALLCOUNT);
-       sprintf(logtext + strlen(logtext), "-%d-", TRACEJAVACALLINDENT);
-
-       pos = strlen(logtext);
-
-       for (i = 0; i < TRACEJAVACALLINDENT; i++)
-               logtext[pos++] = '\t';
-
-       strcpy(logtext + pos, "called: ");
-
-       if (m->clazz != NULL)
-               utf_cat_classname(logtext, m->clazz->name);
-       else
-               strcat(logtext, "NULL");
-       strcat(logtext, ".");
-       utf_cat(logtext, m->name);
-       utf_cat(logtext, m->descriptor);
-
-       if (m->flags & ACC_PUBLIC)         strcat(logtext, " PUBLIC");
-       if (m->flags & ACC_PRIVATE)        strcat(logtext, " PRIVATE");
-       if (m->flags & ACC_PROTECTED)      strcat(logtext, " PROTECTED");
-       if (m->flags & ACC_STATIC)         strcat(logtext, " STATIC");
-       if (m->flags & ACC_FINAL)          strcat(logtext, " FINAL");
-       if (m->flags & ACC_SYNCHRONIZED)   strcat(logtext, " SYNCHRONIZED");
-       if (m->flags & ACC_VOLATILE)       strcat(logtext, " VOLATILE");
-       if (m->flags & ACC_TRANSIENT)      strcat(logtext, " TRANSIENT");
-       if (m->flags & ACC_NATIVE)         strcat(logtext, " NATIVE");
-       if (m->flags & ACC_INTERFACE)      strcat(logtext, " INTERFACE");
-       if (m->flags & ACC_ABSTRACT)       strcat(logtext, " ABSTRACT");
-
-       strcat(logtext, "(");
-
-       for (i = 0; i < md->paramcount; ++i) {
-               arg = argument_jitarray_load(md, i, arg_regs, stack);
-               logtext = trace_java_call_print_argument(m, logtext, &logtextlen,
-                                                                                                &md->paramtypes[i], arg);
-               if (i != (md->paramcount - 1)) {
-                       strcat(logtext, ", ");
-               }
-       }
-
-       strcat(logtext, ")");
-
-       log_text(logtext);
-
-       /* release memory */
-
-       DRELEASE;
-
-       TRACEJAVACALLINDENT++;
-
-}
-
-/* trace_java_call_exit ********************************************************
-
-   Traces an exit form a java method.
-
-   return_regs: Array of size 1 containing return register.
-   The array is usually allocated on the stack and used for restoring the
-   registers later.
-
-*******************************************************************************/
-
-void trace_java_call_exit(methodinfo *m, uint64_t *return_regs)
-{
-       methoddesc *md;
-       char       *logtext;
-       s4          logtextlen;
-       s4          i;
-       s4          pos;
-       imm_union   val;
-       int32_t     dumpmarker;
-
-       /* We don't trace builtin functions here because the argument
-          passing happens via the native ABI and does not fit these
-          functions. */
-
-       if (method_is_builtin(m))
-               return;
-
-#if defined(ENABLE_DEBUG_FILTER)
-       if (!show_filters_test_verbosecall_exit(m))
-               return;
-#endif
-
-#if defined(ENABLE_VMLOG)
-       vmlog_cacao_leave_method(m);
-       return;
-#endif
-
-       md = m->parseddesc;
-
-       /* outdent the log message */
-
-       if (TRACEJAVACALLINDENT)
-               TRACEJAVACALLINDENT--;
-       else
-               log_text("trace_java_call_exit: WARNING: unmatched unindent");
-
-       /* calculate message length */
-
-       logtextlen =
-               strlen("4294967295 ") +
-               strlen("-2147483647-") +        /* INT_MAX should be sufficient       */
-               TRACEJAVACALLINDENT +
-               strlen("finished: ") +
-               ((m->clazz == NULL) ? strlen("NULL") : utf_bytes(m->clazz->name)) +
-               strlen(".") +
-               utf_bytes(m->name) +
-               utf_bytes(m->descriptor) +
-               strlen(" SYNCHRONIZED") + strlen("(") + strlen(")");
-
-       /* add maximal argument length */
-
-       logtextlen += strlen("->0.4872328470301428 (0x0123456789abcdef)");
-
-       /* allocate memory */
-
-       DMARKER;
-
-       logtext = DMNEW(char, logtextlen);
-
-       /* generate the message */
-
-       sprintf(logtext, "           ");
-       sprintf(logtext + strlen(logtext), "-%d-", TRACEJAVACALLINDENT);
-
-       pos = strlen(logtext);
-
-       for (i = 0; i < TRACEJAVACALLINDENT; i++)
-               logtext[pos++] = '\t';
-
-       strcpy(logtext + pos, "finished: ");
-       if (m->clazz != NULL)
-               utf_cat_classname(logtext, m->clazz->name);
-       else
-               strcat(logtext, "NULL");
-       strcat(logtext, ".");
-       utf_cat(logtext, m->name);
-       utf_cat(logtext, m->descriptor);
-
-       if (!IS_VOID_TYPE(md->returntype.type)) {
-               strcat(logtext, "->");
-               val = argument_jitreturn_load(md, return_regs);
-
-               logtext =
-                       trace_java_call_print_argument(m, logtext, &logtextlen,
-                                                                                  &md->returntype, val);
-       }
-
-       log_text(logtext);
-
-       /* release memory */
-
-       DRELEASE;
-}
-
-
-/* trace_exception *************************************************************
-
-   Traces an exception which is handled by exceptions_handle_exception.
-
-*******************************************************************************/
-
-void trace_exception(java_object_t *xptr, methodinfo *m, void *pos)
-{
-       char *logtext;
-       s4    logtextlen;
-       codeinfo *code;
-       int32_t   dumpmarker;
-
-       /* calculate message length */
-
-       if (xptr) {
-               logtextlen =
-                       strlen("Exception ") + utf_bytes(xptr->vftbl->clazz->name);
-       } 
-       else {
-               logtextlen = strlen("Some Throwable");
-       }
-
-       logtextlen += strlen(" thrown in ");
-
-       if (m) {
-               logtextlen +=
-                       utf_bytes(m->clazz->name) +
-                       strlen(".") +
-                       utf_bytes(m->name) +
-                       utf_bytes(m->descriptor) +
-                       strlen("(NOSYNC,NATIVE");
-
-#if SIZEOF_VOID_P == 8
-               logtextlen +=
-                       strlen(")(0x123456789abcdef0) at position 0x123456789abcdef0 (");
-#else
-               logtextlen += strlen(")(0x12345678) at position 0x12345678 (");
-#endif
-
-               if (m->clazz->sourcefile == NULL)
-                       logtextlen += strlen("<NO CLASSFILE INFORMATION>");
-               else
-                       logtextlen += utf_bytes(m->clazz->sourcefile);
-
-               logtextlen += strlen(":65536)");
-
-       } 
-       else {
-               logtextlen += strlen("call_java_method");
-       }
-
-       logtextlen += strlen("0");
-
-       /* allocate memory */
-
-       DMARKER;
-
-       logtext = DMNEW(char, logtextlen);
-
-       if (xptr) {
-               strcpy(logtext, "Exception ");
-               utf_cat_classname(logtext, xptr->vftbl->clazz->name);
-
-       } else {
-               strcpy(logtext, "Some Throwable");
-       }
-
-       strcat(logtext, " thrown in ");
-
-       if (m) {
-               utf_cat_classname(logtext, m->clazz->name);
-               strcat(logtext, ".");
-               utf_cat(logtext, m->name);
-               utf_cat(logtext, m->descriptor);
-
-               if (m->flags & ACC_SYNCHRONIZED)
-                       strcat(logtext, "(SYNC");
-               else
-                       strcat(logtext, "(NOSYNC");
-
-               if (m->flags & ACC_NATIVE) {
-                       strcat(logtext, ",NATIVE");
-
-                       code = m->code;
-
-#if SIZEOF_VOID_P == 8
-                       sprintf(logtext + strlen(logtext),
-                                       ")(0x%016lx) at position 0x%016lx",
-                                       (ptrint) code->entrypoint, (ptrint) pos);
-#else
-                       sprintf(logtext + strlen(logtext),
-                                       ")(0x%08x) at position 0x%08x",
-                                       (ptrint) code->entrypoint, (ptrint) pos);
-#endif
-
-               } else {
-
-                       /* XXX preliminary: This should get the actual codeinfo */
-                       /* in which the exception happened.                     */
-                       code = m->code;
-                       
-#if SIZEOF_VOID_P == 8
-                       sprintf(logtext + strlen(logtext),
-                                       ")(0x%016lx) at position 0x%016lx (",
-                                       (ptrint) code->entrypoint, (ptrint) pos);
-#else
-                       sprintf(logtext + strlen(logtext),
-                                       ")(0x%08x) at position 0x%08x (",
-                                       (ptrint) code->entrypoint, (ptrint) pos);
-#endif
-
-                       if (m->clazz->sourcefile == NULL)
-                               strcat(logtext, "<NO CLASSFILE INFORMATION>");
-                       else
-                               utf_cat(logtext, m->clazz->sourcefile);
-
-                       sprintf(logtext + strlen(logtext), ":%d)", 0);
-               }
-
-       } else
-               strcat(logtext, "call_java_method");
-
-       log_text(logtext);
-
-       /* release memory */
-
-       DRELEASE;
-}
-
-
-/* trace_exception_builtin *****************************************************
-
-   Traces an exception which is thrown by builtin_throw_exception.
-
-*******************************************************************************/
-
-void trace_exception_builtin(java_object_t *xptr)
-{
-       java_lang_Throwable *t;
-       java_lang_String    *s;
-       char                *logtext;
-       s4                   logtextlen;
-       int32_t              dumpmarker;
-
-       t = (java_lang_Throwable *) xptr;
-
-       /* get detail message */
-       if (t)
-               LLNI_field_get_ref(t, detailMessage, s);
-
-       /* calculate message length */
-
-       logtextlen = strlen("Builtin exception thrown: ") + strlen("0");
-
-       if (t) {
-               logtextlen +=
-                       utf_bytes(xptr->vftbl->clazz->name);
-               if (s) {
-                       logtextlen += strlen(": ") +
-                               u2_utflength(LLNI_field_direct(s, value)->data 
-                                                               + LLNI_field_direct(s, offset),
-                                                        LLNI_field_direct(s,count));
-               }
-       } 
-       else {
-               logtextlen += strlen("(nil)");
-       }
-
-       /* allocate memory */
-
-       DMARKER;
-
-       logtext = DMNEW(char, logtextlen);
-
-       strcpy(logtext, "Builtin exception thrown: ");
-
-       if (t) {
-               utf_cat_classname(logtext, xptr->vftbl->clazz->name);
-
-               if (s) {
-                       char *buf;
-
-                       buf = javastring_tochar((java_handle_t *) s);
-                       strcat(logtext, ": ");
-                       strcat(logtext, buf);
-                       MFREE(buf, char, strlen(buf) + 1);
-               }
-
-       } else {
-               strcat(logtext, "(nil)");
-       }
-
-       log_text(logtext);
-
-       /* release memory */
-
-       DRELEASE;
-}
-
-
-#endif /* !defined(NDEBUG) */
-
-
-/*
- * 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/jit/trace.cpp b/src/vm/jit/trace.cpp
new file mode 100644 (file)
index 0000000..91a3655
--- /dev/null
@@ -0,0 +1,624 @@
+/* src/vm/jit/trace.cpp - Functions for tracing from java code.
+
+   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 <stdio.h>
+
+#include "arch.h"
+#include "md-abi.h"
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "threads/thread.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/options.h"
+#include "vm/string.hpp"
+#include "vm/utf8.h"
+
+#include "vm/jit/argument.hpp"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/trace.hpp"
+#include "vm/jit/show.hpp"
+
+
+#if !defined(NDEBUG)
+
+// FIXME For now we export everything as C functions.
+extern "C" {
+
+/* global variables ***********************************************************/
+
+#if !defined(ENABLE_THREADS)
+s4 _no_threads_tracejavacallindent = 0;
+u4 _no_threads_tracejavacallcount= 0;
+#endif
+
+
+/* trace_java_call_print_argument **********************************************
+
+   XXX: Document me!
+
+*******************************************************************************/
+
+static char *trace_java_call_print_argument(methodinfo *m, char *logtext, s4 *logtextlen, typedesc *paramtype, imm_union imu)
+{
+       java_object_t *o;
+       classinfo     *c;
+       utf           *u;
+       u4             len;
+
+       switch (paramtype->type) {
+       case TYPE_INT:
+               sprintf(logtext + strlen(logtext), "%d (0x%08x)", (int32_t)imu.l, (int32_t)imu.l);
+               break;
+
+       case TYPE_LNG:
+#if SIZEOF_VOID_P == 4
+               sprintf(logtext + strlen(logtext), "%lld (0x%016llx)", imu.l, imu.l);
+#else
+               sprintf(logtext + strlen(logtext), "%ld (0x%016lx)", imu.l, imu.l);
+#endif
+               break;
+
+       case TYPE_FLT:
+               sprintf(logtext + strlen(logtext), "%g (0x%08x)", imu.f, imu.i);
+               break;
+
+       case TYPE_DBL:
+#if SIZEOF_VOID_P == 4
+               sprintf(logtext + strlen(logtext), "%g (0x%016llx)", imu.d, imu.l);
+#else
+               sprintf(logtext + strlen(logtext), "%g (0x%016lx)", imu.d, imu.l);
+#endif
+               break;
+
+       case TYPE_ADR:
+#if SIZEOF_VOID_P == 4
+               sprintf(logtext + strlen(logtext), "0x%08x", (ptrint) imu.l);
+#else
+               sprintf(logtext + strlen(logtext), "0x%016lx", (ptrint) imu.l);
+#endif
+
+               /* Workaround for sun.misc.Unsafe methods.  In the future
+                  (exact GC) we should check if the address is on the GC
+                  heap. */
+
+               if ((m->clazz       != NULL) &&
+                       (m->clazz->name == utf_new_char("sun/misc/Unsafe")))
+                       break;
+
+               /* Cast to java.lang.Object. */
+
+               o = (java_handle_t*) (uintptr_t) imu.l;
+
+               /* Check return argument for java.lang.Class or
+                  java.lang.String. */
+
+               if (o != NULL) {
+                       if (o->vftbl->clazz == class_java_lang_String) {
+                               /* get java.lang.String object and the length of the
+                                  string */
+
+                               u = javastring_toutf(o, false);
+
+                               len = strlen(" (String = \"") + utf_bytes(u) + strlen("\")");
+
+                               /* realloc memory for string length */
+
+                               logtext = (char*) DumpMemory::reallocate(logtext, *logtextlen, *logtextlen + len);
+                               *logtextlen += len;
+
+                               /* convert to utf8 string and strcat it to the logtext */
+
+                               strcat(logtext, " (String = \"");
+                               utf_cat(logtext, u);
+                               strcat(logtext, "\")");
+                       }
+                       else {
+                               if (o->vftbl->clazz == class_java_lang_Class) {
+                                       /* if the object returned is a java.lang.Class
+                                          cast it to classinfo structure and get the name
+                                          of the class */
+
+                                       c = (classinfo *) o;
+
+                                       u = c->name;
+                               }
+                               else {
+                                       /* if the object returned is not a java.lang.String or
+                                          a java.lang.Class just print the name of the class */
+
+                                       u = o->vftbl->clazz->name;
+                               }
+
+                               len = strlen(" (Class = \"") + utf_bytes(u) + strlen("\")");
+
+                               /* realloc memory for string length */
+
+                               logtext = (char*) DumpMemory::reallocate(logtext, *logtextlen, *logtextlen + len);
+                               *logtextlen += len;
+
+                               /* strcat to the logtext */
+
+                               strcat(logtext, " (Class = \"");
+                               utf_cat_classname(logtext, u);
+                               strcat(logtext, "\")");
+                       }
+               }
+       }
+
+       return logtext;
+}
+
+/* trace_java_call_enter ******************************************************
+   Traces an entry into a java method.
+
+   arg_regs: Array containing all argument registers as int64_t values in
+   the same order as listed in m->methoddesc. The array is usually allocated
+   on the stack and used for restoring the argument registers later.
+
+   stack: Pointer to first on stack argument in the same format passed to 
+   asm_vm_call_method.
+
+*******************************************************************************/
+
+void trace_java_call_enter(methodinfo *m, uint64_t *arg_regs, uint64_t *stack)
+{
+       methoddesc *md;
+       imm_union   arg;
+       char       *logtext;
+       s4          logtextlen;
+       s4          i;
+       s4          pos;
+
+       /* We don't trace builtin functions here because the argument
+          passing happens via the native ABI and does not fit these
+          functions. */
+
+       if (method_is_builtin(m))
+               return;
+
+#if defined(ENABLE_DEBUG_FILTER)
+       if (!show_filters_test_verbosecall_enter(m))
+               return;
+#endif
+
+#if defined(ENABLE_VMLOG)
+       vmlog_cacao_enter_method(m);
+       return;
+#endif
+
+       md = m->parseddesc;
+
+       /* calculate message length */
+
+       logtextlen =
+               strlen("4294967295 ") +
+               strlen("-2147483647-") +        /* INT_MAX should be sufficient       */
+               TRACEJAVACALLINDENT +
+               strlen("called: ") +
+               ((m->clazz == NULL) ? strlen("NULL") : utf_bytes(m->clazz->name)) +
+               strlen(".") +
+               utf_bytes(m->name) +
+               utf_bytes(m->descriptor);
+
+       /* Actually it's not possible to have all flags printed, but:
+          safety first! */
+
+       logtextlen +=
+               strlen(" PUBLIC") +
+               strlen(" PRIVATE") +
+               strlen(" PROTECTED") +
+               strlen(" STATIC") +
+               strlen(" FINAL") +
+               strlen(" SYNCHRONIZED") +
+               strlen(" VOLATILE") +
+               strlen(" TRANSIENT") +
+               strlen(" NATIVE") +
+               strlen(" INTERFACE") +
+               strlen(" ABSTRACT") +
+               strlen(" METHOD_BUILTIN");
+
+       /* add maximal argument length */
+
+       logtextlen +=
+               strlen("(") +
+               strlen("-9223372036854775808 (0x123456789abcdef0), ") * md->paramcount +
+               strlen("...(255)") +
+               strlen(")");
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       // TODO Use a std::string here.
+       logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen);
+
+       TRACEJAVACALLCOUNT++;
+
+       sprintf(logtext, "%10d ", TRACEJAVACALLCOUNT);
+       sprintf(logtext + strlen(logtext), "-%d-", TRACEJAVACALLINDENT);
+
+       pos = strlen(logtext);
+
+       for (i = 0; i < TRACEJAVACALLINDENT; i++)
+               logtext[pos++] = '\t';
+
+       strcpy(logtext + pos, "called: ");
+
+       if (m->clazz != NULL)
+               utf_cat_classname(logtext, m->clazz->name);
+       else
+               strcat(logtext, "NULL");
+       strcat(logtext, ".");
+       utf_cat(logtext, m->name);
+       utf_cat(logtext, m->descriptor);
+
+       if (m->flags & ACC_PUBLIC)         strcat(logtext, " PUBLIC");
+       if (m->flags & ACC_PRIVATE)        strcat(logtext, " PRIVATE");
+       if (m->flags & ACC_PROTECTED)      strcat(logtext, " PROTECTED");
+       if (m->flags & ACC_STATIC)         strcat(logtext, " STATIC");
+       if (m->flags & ACC_FINAL)          strcat(logtext, " FINAL");
+       if (m->flags & ACC_SYNCHRONIZED)   strcat(logtext, " SYNCHRONIZED");
+       if (m->flags & ACC_VOLATILE)       strcat(logtext, " VOLATILE");
+       if (m->flags & ACC_TRANSIENT)      strcat(logtext, " TRANSIENT");
+       if (m->flags & ACC_NATIVE)         strcat(logtext, " NATIVE");
+       if (m->flags & ACC_INTERFACE)      strcat(logtext, " INTERFACE");
+       if (m->flags & ACC_ABSTRACT)       strcat(logtext, " ABSTRACT");
+
+       strcat(logtext, "(");
+
+       for (i = 0; i < md->paramcount; ++i) {
+               arg = argument_jitarray_load(md, i, arg_regs, stack);
+               logtext = trace_java_call_print_argument(m, logtext, &logtextlen,
+                                                                                                &md->paramtypes[i], arg);
+               if (i != (md->paramcount - 1)) {
+                       strcat(logtext, ", ");
+               }
+       }
+
+       strcat(logtext, ")");
+
+       log_text(logtext);
+
+       TRACEJAVACALLINDENT++;
+}
+
+/* trace_java_call_exit ********************************************************
+
+   Traces an exit form a java method.
+
+   return_regs: Array of size 1 containing return register.
+   The array is usually allocated on the stack and used for restoring the
+   registers later.
+
+*******************************************************************************/
+
+void trace_java_call_exit(methodinfo *m, uint64_t *return_regs)
+{
+       methoddesc *md;
+       char       *logtext;
+       s4          logtextlen;
+       s4          i;
+       s4          pos;
+       imm_union   val;
+
+       /* We don't trace builtin functions here because the argument
+          passing happens via the native ABI and does not fit these
+          functions. */
+
+       if (method_is_builtin(m))
+               return;
+
+#if defined(ENABLE_DEBUG_FILTER)
+       if (!show_filters_test_verbosecall_exit(m))
+               return;
+#endif
+
+#if defined(ENABLE_VMLOG)
+       vmlog_cacao_leave_method(m);
+       return;
+#endif
+
+       md = m->parseddesc;
+
+       /* outdent the log message */
+
+       if (TRACEJAVACALLINDENT)
+               TRACEJAVACALLINDENT--;
+       else
+               log_text("trace_java_call_exit: WARNING: unmatched unindent");
+
+       /* calculate message length */
+
+       logtextlen =
+               strlen("4294967295 ") +
+               strlen("-2147483647-") +        /* INT_MAX should be sufficient       */
+               TRACEJAVACALLINDENT +
+               strlen("finished: ") +
+               ((m->clazz == NULL) ? strlen("NULL") : utf_bytes(m->clazz->name)) +
+               strlen(".") +
+               utf_bytes(m->name) +
+               utf_bytes(m->descriptor) +
+               strlen(" SYNCHRONIZED") + strlen("(") + strlen(")");
+
+       /* add maximal argument length */
+
+       logtextlen += strlen("->0.4872328470301428 (0x0123456789abcdef)");
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       // TODO Use a std::string here.
+       logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen);
+
+       /* generate the message */
+
+       sprintf(logtext, "           ");
+       sprintf(logtext + strlen(logtext), "-%d-", TRACEJAVACALLINDENT);
+
+       pos = strlen(logtext);
+
+       for (i = 0; i < TRACEJAVACALLINDENT; i++)
+               logtext[pos++] = '\t';
+
+       strcpy(logtext + pos, "finished: ");
+       if (m->clazz != NULL)
+               utf_cat_classname(logtext, m->clazz->name);
+       else
+               strcat(logtext, "NULL");
+       strcat(logtext, ".");
+       utf_cat(logtext, m->name);
+       utf_cat(logtext, m->descriptor);
+
+       if (!IS_VOID_TYPE(md->returntype.type)) {
+               strcat(logtext, "->");
+               val = argument_jitreturn_load(md, return_regs);
+
+               logtext =
+                       trace_java_call_print_argument(m, logtext, &logtextlen,
+                                                                                  &md->returntype, val);
+       }
+
+       log_text(logtext);
+}
+
+
+/* trace_exception *************************************************************
+
+   Traces an exception which is handled by exceptions_handle_exception.
+
+*******************************************************************************/
+
+void trace_exception(java_object_t *xptr, methodinfo *m, void *pos)
+{
+       char *logtext;
+       s4    logtextlen;
+       codeinfo *code;
+
+       /* calculate message length */
+
+       if (xptr) {
+               logtextlen =
+                       strlen("Exception ") + utf_bytes(xptr->vftbl->clazz->name);
+       } 
+       else {
+               logtextlen = strlen("Some Throwable");
+       }
+
+       logtextlen += strlen(" thrown in ");
+
+       if (m) {
+               logtextlen +=
+                       utf_bytes(m->clazz->name) +
+                       strlen(".") +
+                       utf_bytes(m->name) +
+                       utf_bytes(m->descriptor) +
+                       strlen("(NOSYNC,NATIVE");
+
+#if SIZEOF_VOID_P == 8
+               logtextlen +=
+                       strlen(")(0x123456789abcdef0) at position 0x123456789abcdef0 (");
+#else
+               logtextlen += strlen(")(0x12345678) at position 0x12345678 (");
+#endif
+
+               if (m->clazz->sourcefile == NULL)
+                       logtextlen += strlen("<NO CLASSFILE INFORMATION>");
+               else
+                       logtextlen += utf_bytes(m->clazz->sourcefile);
+
+               logtextlen += strlen(":65536)");
+
+       } 
+       else {
+               logtextlen += strlen("call_java_method");
+       }
+
+       logtextlen += strlen("0");
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       // TODO Use a std::string here.
+       logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen);
+
+       if (xptr) {
+               strcpy(logtext, "Exception ");
+               utf_cat_classname(logtext, xptr->vftbl->clazz->name);
+
+       } else {
+               strcpy(logtext, "Some Throwable");
+       }
+
+       strcat(logtext, " thrown in ");
+
+       if (m) {
+               utf_cat_classname(logtext, m->clazz->name);
+               strcat(logtext, ".");
+               utf_cat(logtext, m->name);
+               utf_cat(logtext, m->descriptor);
+
+               if (m->flags & ACC_SYNCHRONIZED)
+                       strcat(logtext, "(SYNC");
+               else
+                       strcat(logtext, "(NOSYNC");
+
+               if (m->flags & ACC_NATIVE) {
+                       strcat(logtext, ",NATIVE");
+
+                       code = m->code;
+
+#if SIZEOF_VOID_P == 8
+                       sprintf(logtext + strlen(logtext),
+                                       ")(0x%016lx) at position 0x%016lx",
+                                       (ptrint) code->entrypoint, (ptrint) pos);
+#else
+                       sprintf(logtext + strlen(logtext),
+                                       ")(0x%08x) at position 0x%08x",
+                                       (ptrint) code->entrypoint, (ptrint) pos);
+#endif
+
+               } else {
+
+                       /* XXX preliminary: This should get the actual codeinfo */
+                       /* in which the exception happened.                     */
+                       code = m->code;
+                       
+#if SIZEOF_VOID_P == 8
+                       sprintf(logtext + strlen(logtext),
+                                       ")(0x%016lx) at position 0x%016lx (",
+                                       (ptrint) code->entrypoint, (ptrint) pos);
+#else
+                       sprintf(logtext + strlen(logtext),
+                                       ")(0x%08x) at position 0x%08x (",
+                                       (ptrint) code->entrypoint, (ptrint) pos);
+#endif
+
+                       if (m->clazz->sourcefile == NULL)
+                               strcat(logtext, "<NO CLASSFILE INFORMATION>");
+                       else
+                               utf_cat(logtext, m->clazz->sourcefile);
+
+                       sprintf(logtext + strlen(logtext), ":%d)", 0);
+               }
+
+       } else
+               strcat(logtext, "call_java_method");
+
+       log_text(logtext);
+}
+
+
+/* trace_exception_builtin *****************************************************
+
+   Traces an exception which is thrown by builtin_throw_exception.
+
+*******************************************************************************/
+
+void trace_exception_builtin(java_handle_t* h)
+{
+       char                *logtext;
+       s4                   logtextlen;
+
+       java_lang_Throwable jlt(h);
+
+       // Get detail message.
+       java_handle_t* s = NULL;
+
+       if (jlt.get_handle() != NULL)
+               s = jlt.get_detailMessage();
+
+       java_lang_String jls(s);
+
+       /* calculate message length */
+
+       logtextlen = strlen("Builtin exception thrown: ") + strlen("0");
+
+       if (jlt.get_handle() != NULL) {
+               logtextlen += utf_bytes(jlt.get_vftbl()->clazz->name);
+
+               if (jls.get_handle()) {
+                       // FIXME This is not handle capable!
+                       logtextlen += strlen(": ") +
+                               u2_utflength(jls.get_value()->data + jls.get_offset(), jls.get_count());
+               }
+       } 
+       else {
+               logtextlen += strlen("(nil)");
+       }
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen);
+
+       strcpy(logtext, "Builtin exception thrown: ");
+
+       if (jlt.get_handle()) {
+               utf_cat_classname(logtext, jlt.get_vftbl()->clazz->name);
+
+               if (s) {
+                       char *buf;
+
+                       buf = javastring_tochar(jls.get_handle());
+                       strcat(logtext, ": ");
+                       strcat(logtext, buf);
+                       MFREE(buf, char, strlen(buf) + 1);
+               }
+
+       } else {
+               strcat(logtext, "(nil)");
+       }
+
+       log_text(logtext);
+}
+
+} // extern "C"
+
+#endif /* !defined(NDEBUG) */
+
+
+/*
+ * 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/jit/trace.h b/src/vm/jit/trace.h
deleted file mode 100644 (file)
index db41359..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* src/vm/jit/trace.h - Functions for tracing from java code.
-
-   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
-
-   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 _VM_JIT_TRACE_H
-#define _VM_JIT_TRACE_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vmcore/method.h"
-
-#if !defined(NDEBUG)
-
-void trace_java_call_enter(methodinfo *m, uint64_t *arg_regs, uint64_t *stack);
-void trace_java_call_exit(methodinfo *m, uint64_t *return_regs);
-
-void trace_exception(java_object_t *xptr, methodinfo *m, void *pos);
-void trace_exception_builtin(java_object_t *xptr);
-
-#endif /* !defined(NDEBUG) */
-
-#endif /* _VM_JIT_TRACE_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/jit/trace.hpp b/src/vm/jit/trace.hpp
new file mode 100644 (file)
index 0000000..14d1b61
--- /dev/null
@@ -0,0 +1,70 @@
+/* src/vm/jit/trace.hpp - Functions for tracing from java code.
+
+   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 _VM_JIT_TRACE_HPP
+#define _VM_JIT_TRACE_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/method.hpp"
+
+#if !defined(NDEBUG)
+
+// FIXME For now we export everything as C functions.
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void trace_java_call_enter(methodinfo *m, uint64_t *arg_regs, uint64_t *stack);
+void trace_java_call_exit(methodinfo *m, uint64_t *return_regs);
+
+void trace_exception(java_object_t *xptr, methodinfo *m, void *pos);
+void trace_exception_builtin(java_object_t *xptr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !defined(NDEBUG) */
+
+#endif // _VM_JIT_TRACE_HPP
+
+
+/*
+ * 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 d06295235c72847e3bc7dbd4c442d845f3dfdf5e..1ac7ffe7e71e6d016b8d3a8594b75da78803f214 100644 (file)
 
 /* Include machine dependent trap stuff. */
 
+#include "md.h"
 #include "md-trap.h"
 
+#include "mm/memory.h"
+
 #include "native/llni.h"
 
 #include "toolbox/logging.h"
 
-#include "vm/exceptions.h"
-#include "vm/vm.h"
+#include "vm/exceptions.hpp"
+#include "vm/options.h"
+#include "vm/os.hpp"
+#include "vm/vm.hpp"
 
-#include "vm/jit/code.h"
+#include "vm/jit/asmpart.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/disass.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/executionstate.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/methodtree.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/options.h"
-#include "vmcore/system.h"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
 
 
 /**
@@ -66,9 +70,9 @@ void trap_init(void)
        /* mmap a memory page at address 0x0, so our hardware-exceptions
           work. */
 
-       pagesize = system_getpagesize();
+       pagesize = os_getpagesize();
 
-       (void) system_mmap_anonymous(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_FIXED);
+       (void) os_mmap_anonymous(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_FIXED);
 #endif
 
        TRACESUBSYSTEMINITIALIZATION("trap_init");
@@ -95,6 +99,7 @@ void trap_init(void)
  */
 void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xpc, void *context)
 {
+       executionstate_t  es;
        stackframeinfo_t  sfi;
        int32_t           index;
        java_handle_t    *o;
@@ -115,6 +120,19 @@ void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xp
        o = NULL;
        m = NULL;
 
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__X86_64__)
+# if !defined(NDEBUG)
+       /* Perform a sanity check on our execution state functions. */
+
+       executionstate_sanity_check(context);
+# endif
+
+       /* Read execution state from current context. */
+
+       es.code = NULL;
+       md_executionstate_read(&es, context);
+#endif
+
        /* wrap the value into a handle if it is a reference */
        /* BEFORE: creating stackframeinfo */
 
@@ -182,6 +200,15 @@ void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xp
                p = jit_compile_handle(m, sfi.pv, ra, (void *) val);
                break;
 
+#if defined(ENABLE_REPLACEMENT)
+       case TRAP_COUNTDOWN:
+#if defined(__I386__)
+               replace_me_wrapper((char*)xpc - 13, context);
+#endif
+               p = NULL;
+               break;
+#endif
+
        default:
                /* Let's try to get a backtrace. */
 
@@ -213,6 +240,63 @@ void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xp
 
        stacktrace_stackframeinfo_remove(&sfi);
 
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__X86_64__)
+       /* Update execution state and set registers. */
+       /* AFTER: removing stackframeinfo */
+
+       switch (type) {
+       case TRAP_COMPILER:
+               // The normal case for a compiler trap is to jump directly to
+               // the newly compiled method.
+
+               if (p != NULL) {
+                       es.pc = (uint8_t *) (uintptr_t) p;
+                       es.pv = (uint8_t *) (uintptr_t) p;
+                       break;
+               }
+
+               // In case of an exception during JIT compilation, we fetch
+               // the exception here and proceed with exception handling.
+
+               java_handle_t *e = exceptions_get_and_clear_exception();
+               assert(e != NULL);
+
+               // Get and set the PV from the parent Java method.
+
+               es.pv = md_codegen_get_pv_from_pc(ra);
+
+               // XXX: Make the code below a fall-through to default case!
+
+               es.intregs[REG_ITMP1_XPTR] = (uintptr_t) LLNI_DIRECT(e);
+               es.intregs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
+               es.pc                      = (uint8_t *) (uintptr_t) asm_handle_exception;
+               break;
+
+       case TRAP_PATCHER:
+               // The normal case for a patcher trap is to continue execution at
+               // the trap instruction. On some archs the PC may point after the
+               // trap instruction, so we reset it here.
+
+               if (p == NULL) {
+                       es.pc = (uint8_t *) (uintptr_t) xpc;
+                       break;
+               }
+
+               /* fall-through */
+
+       default:
+               if (p != NULL) {
+                       es.intregs[REG_ITMP1_XPTR] = (uintptr_t) LLNI_DIRECT(p);
+                       es.intregs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
+                       es.pc                      = (uint8_t *) (uintptr_t) asm_handle_exception;
+               }
+       }
+
+       /* Write back execution state to current context. */
+
+       md_executionstate_write(&es, context);
+#endif
+
        /* unwrap and return the exception object */
        /* AFTER: removing stackframeinfo */
 
index 8eb295bd58ed20372165298264b7064e42ca8db7..6a18c35dc696da41776fd8f4841ed72f5c0340a1 100644 (file)
 
 #include <stdint.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Include machine dependent trap stuff. */
 
 #include "md-trap.h"
 void  trap_init(void);
 void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xpc, void *context);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _TRAP_H */
 
 
index 8be3839e3a1ae3c916c7df1fd1c917bea5bbad69..c9e3a632e3992d2316c33b4977cb204970014417 100644 (file)
@@ -37,22 +37,22 @@ LIBS =
 noinst_LTLIBRARIES = libverify.la
 
 libverify_la_SOURCES = \
-       typecheck.c \
-       typecheck.h \
-       typecheck-common.c \
-       typecheck-common.h \
+       typecheck.cpp \
+       typecheck.hpp \
+       typecheck-common.cpp \
+       typecheck-common.hpp \
        typecheck-builtins.inc \
        typecheck-fields.inc \
        typecheck-invoke.inc \
        typecheck-multianewarray.inc \
-       typecheck-stackbased.c \
-       typecheck-typeinferer.c \
-       typecheck-typeinferer.h \
+       typecheck-stackbased.cpp \
+       typecheck-typeinferer.cpp \
+       typecheck-typeinferer.hpp \
        typecheck-stackbased-gen.inc \
        typecheck-variablesbased-gen.inc \
        typecheck-typeinferer-gen.inc \
-       typeinfo.c \
-       typeinfo.h
+       typeinfo.cpp \
+       typeinfo.hpp
 
 
 ## Local variables:
diff --git a/src/vm/jit/verify/icmds.c b/src/vm/jit/verify/icmds.c
deleted file mode 100644 (file)
index d308d8b..0000000
+++ /dev/null
@@ -1,781 +0,0 @@
-/* src/vm/jit/verify/icmds.c - ICMD-specific type checking code
-
-   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
-
-   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.
-
-*/
-
-#if 0 /* (needed for code examples in the following comment) */
-/******************************************************************************/
-/* This file contains ICMD-specific code for type checking and type
- * inference. It is an input file for the verifier generator
- * (src/vm/jit/verify/generate.pl). The verifier generator creates
- * code for three compiler passes:
- *     - stack-based type-infering verification
- *     - vasiables-based type-infering verification
- *     - type inference pass (no verification - used for optimizing compiler)
- *
- * The rest of this file must consist of "case" clauses starting in
- * the first column. Each clause can be marked with tags like this:
- *
- */          case ICMD_CONSTANT: /* {TAG, TAG, ...} */
-/*
- * This must be on one line. The following tags are defined:
- *     STACKBASED..........use this clause for the stack-based verifier
- *     VARIABLESBASED......use this clause for the variables-based verifier
- *     TYPEINFERER.........use this clause for the type inference pass
- *     ALL.................use for all passes
- *
- * If no tag is specified, {STACKBASED,VARIABLESBASED} is assumed.
- *
- * There are also tags that can be used inside a clause like this:
- *
- */          /* {TAG} */
-/*
- * The following tags are defined within clauses:
- *     RESULTNOW...........generate code for modelling the stack action
- *                         _before_ the user-defined code in the clause
- *                         (Default is to model the stack action afterwards.)
- *
- * The following macros are pre-defined:
- *
- *     TYPECHECK_STACKBASED.......iff compiling the stack-based verifier
- *     TYPECHECK_VARIABLESBASED...iff compiling the variables-based verifier
- *     TYPECHECK_TYPEINFERER......iff compiling the type inference pass
- *
-/******************************************************************************/
-#endif /* (end #if 0) */
-
-
-/* this marker is needed by generate.pl: */
-/* {START_OF_CODE} */
-
-       /****************************************/
-       /* MOVE/COPY                            */
-
-       /* We just need to copy the typeinfo */
-       /* for slots containing addresses.   */
-
-       /* (These are only used by the variables based verifier.) */
-
-case ICMD_MOVE: /* {VARIABLESBASED,TYPEINFERER} */
-case ICMD_COPY: /* {VARIABLESBASED,TYPEINFERER} */
-       TYPECHECK_COUNT(stat_ins_stack);
-       COPYTYPE(IPTR->s1, IPTR->dst);
-       DST->type = OP1->type;
-       break;
-
-       /****************************************/
-       /* LOADING ADDRESS FROM VARIABLE        */
-
-case ICMD_ALOAD: /* {ALL} */
-       TYPECHECK_COUNT(stat_ins_aload);
-
-#if !defined(TYPECHECK_TYPEINFERER)
-       /* loading a returnAddress is not allowed */
-       if (!TYPEDESC_IS_REFERENCE(*OP1)) {
-               VERIFY_ERROR("illegal instruction: ALOAD loading non-reference");
-       }
-#endif
-       TYPEINFO_COPY(OP1->typeinfo,DST->typeinfo);
-       break;
-
-       /****************************************/
-       /* STORING ADDRESS TO VARIABLE          */
-
-case ICMD_ASTORE: /* {ALL} */
-       TYPEINFO_COPY(OP1->typeinfo, DST->typeinfo);
-       break;
-
-       /****************************************/
-       /* LOADING ADDRESS FROM ARRAY           */
-
-case ICMD_AALOAD: /* {ALL} */
-#if !defined(TYPECHECK_TYPEINFERER)
-       if (!TYPEINFO_MAYBE_ARRAY_OF_REFS(OP1->typeinfo))
-               VERIFY_ERROR("illegal instruction: AALOAD on non-reference array");
-#endif
-
-       if (!typeinfo_init_component(&OP1->typeinfo,&DST->typeinfo))
-               EXCEPTION;
-       break;
-
-       /****************************************/
-       /* FIELD ACCESS                         */
-
-case ICMD_PUTFIELD: /* {STACKBASED} */
-       CHECK_STACK_DEPTH(2);
-       if (!IS_CAT1(stack[0])) {
-               CHECK_STACK_DEPTH(3);
-               stack -= 1;
-       }
-       CHECK_STACK_TYPE(stack[-1], TYPE_ADR);
-       stack = typecheck_stackbased_verify_fieldaccess(STATE, stack-1, stack, stack-2);
-       if (stack == NULL)
-               EXCEPTION;
-       break;
-
-case ICMD_PUTSTATIC: /* {STACKBASED} */
-       CHECK_STACK_DEPTH(1);
-       if (!IS_CAT1(stack[0])) {
-               /* (stack depth >= 2 is guaranteed) */
-               stack -= 1;
-       }
-       stack = typecheck_stackbased_verify_fieldaccess(STATE, NULL, stack, stack-1);
-       if (stack == NULL)
-               EXCEPTION;
-       break;
-
-case ICMD_GETFIELD: /* {STACKBASED} */
-       CHECK_STACK_TYPE(stack[0], TYPE_ADR);
-       stack = typecheck_stackbased_verify_fieldaccess(STATE, stack, NULL, stack-1);
-       if (stack == NULL)
-               EXCEPTION;
-       break;
-
-case ICMD_GETSTATIC:      /* {STACKBASED} */
-       stack = typecheck_stackbased_verify_fieldaccess(STATE, NULL, NULL, stack);
-       if (stack == NULL)
-               EXCEPTION;
-       break;
-
-case ICMD_PUTFIELD:       /* {VARIABLESBASED} */
-       if (!handle_fieldaccess(state, VAROP(iptr->s1), VAROP(iptr->sx.s23.s2)))
-               return false;
-       maythrow = true;
-       break;
-
-case ICMD_PUTSTATIC:      /* {VARIABLESBASED} */
-       if (!handle_fieldaccess(state, NULL, VAROP(iptr->s1)))
-               return false;
-       maythrow = true;
-       break;
-
-case ICMD_PUTFIELDCONST:  /* {VARIABLESBASED} */
-       /* XXX this mess will go away with const operands */
-       INSTRUCTION_GET_FIELDREF(state->iptr, fieldref);
-       constvalue.type = fieldref->parseddesc.fd->type;
-       if (IS_ADR_TYPE(constvalue.type)) {
-               if (state->iptr->sx.val.anyptr) {
-                       classinfo *cc = (state->iptr->flags.bits & INS_FLAG_CLASS)
-                               ? class_java_lang_Class : class_java_lang_String;
-                       assert(cc);
-                       assert(cc->state & CLASS_LINKED);
-                       typeinfo_init_classinfo(&(constvalue.typeinfo), cc);
-               }
-               else {
-                       TYPEINFO_INIT_NULLTYPE(constvalue.typeinfo);
-               }
-       }
-       if (!handle_fieldaccess(state, VAROP(iptr->s1), &constvalue))
-               return false;
-       maythrow = true;
-       break;
-
-case ICMD_PUTSTATICCONST: /* {VARIABLESBASED} */
-       /* XXX this mess will go away with const operands */
-       INSTRUCTION_GET_FIELDREF(state->iptr, fieldref);
-       constvalue.type = fieldref->parseddesc.fd->type;
-       if (IS_ADR_TYPE(constvalue.type)) {
-               if (state->iptr->sx.val.anyptr) {
-                       classinfo *cc = (state->iptr->flags.bits & INS_FLAG_CLASS)
-                               ? class_java_lang_Class : class_java_lang_String;
-                       assert(cc);
-                       assert(cc->state & CLASS_LINKED);
-                       typeinfo_init_classinfo(&(constvalue.typeinfo), cc);
-               }
-               else {
-                       TYPEINFO_INIT_NULLTYPE(constvalue.typeinfo);
-               }
-       }
-       if (!handle_fieldaccess(state, NULL, &constvalue))
-               return false;
-       maythrow = true;
-       break;
-
-case ICMD_GETFIELD:       /* {VARIABLESBASED,TYPEINFERER} */
-       if (!handle_fieldaccess(state, VAROP(iptr->s1), NULL))
-               return false;
-       maythrow = true;
-       break;
-
-case ICMD_GETSTATIC:      /* {VARIABLESBASED,TYPEINFERER} */
-       if (!handle_fieldaccess(state, NULL, NULL))
-               return false;
-       maythrow = true;
-       break;
-
-       /****************************************/
-       /* PRIMITIVE ARRAY ACCESS               */
-
-case ICMD_ARRAYLENGTH:
-       if (!TYPEINFO_MAYBE_ARRAY(OP1->typeinfo)
-                       && OP1->typeinfo.typeclass.cls != pseudo_class_Arraystub)
-               VERIFY_ERROR("illegal instruction: ARRAYLENGTH on non-array");
-       break;
-
-case ICMD_BALOAD:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_BOOLEAN)
-                       && !TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_BYTE))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_CALOAD:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_CHAR))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_DALOAD:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_DOUBLE))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_FALOAD:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_FLOAT))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_IALOAD:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_INT))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_SALOAD:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_SHORT))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_LALOAD:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_LONG))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_BASTORE:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_BOOLEAN)
-                       && !TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_BYTE))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_CASTORE:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_CHAR))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_DASTORE:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_DOUBLE))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_FASTORE:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_FLOAT))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_IASTORE:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_INT))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_SASTORE:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_SHORT))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_LASTORE:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_LONG))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_AASTORE:
-       /* we just check the basic input types and that the           */
-       /* destination is an array of references. Assignability to    */
-       /* the actual array must be checked at runtime, each time the */
-       /* instruction is performed. (See builtin_canstore.)          */
-       if (!TYPEINFO_MAYBE_ARRAY_OF_REFS(OP1->typeinfo))
-               VERIFY_ERROR("illegal instruction: AASTORE to non-reference array");
-       break;
-
-case ICMD_IASTORECONST:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_INT))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_LASTORECONST:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_LONG))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_BASTORECONST:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_BOOLEAN)
-                       && !TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_BYTE))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_CASTORECONST:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_CHAR))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-case ICMD_SASTORECONST:
-       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_SHORT))
-               VERIFY_ERROR("Array type mismatch");
-       break;
-
-       /****************************************/
-       /* ADDRESS CONSTANTS                    */
-
-case ICMD_ACONST: /* {ALL} */
-       if (IPTR->flags.bits & INS_FLAG_CLASS) {
-               /* a java.lang.Class reference */
-               TYPEINFO_INIT_JAVA_LANG_CLASS(DST->typeinfo,IPTR->sx.val.c);
-       }
-       else {
-               if (IPTR->sx.val.anyptr == NULL)
-                       TYPEINFO_INIT_NULLTYPE(DST->typeinfo);
-               else {
-                       /* string constant (or constant for builtin function) */
-                       typeinfo_init_classinfo(&(DST->typeinfo),class_java_lang_String);
-               }
-       }
-       break;
-
-       /****************************************/
-       /* CHECKCAST AND INSTANCEOF             */
-
-case ICMD_CHECKCAST: /* {ALL} */
-#if !defined(TYPECHECK_TYPEINFERER)
-       /* returnAddress is not allowed */
-       if (!TYPEINFO_IS_REFERENCE(OP1->typeinfo))
-               VERIFY_ERROR("Illegal instruction: CHECKCAST on non-reference");
-#endif
-
-    /* XXX only if narrower */
-       if (!typeinfo_init_class(&(DST->typeinfo),IPTR->sx.s23.s3.c))
-               EXCEPTION;
-       break;
-
-case ICMD_INSTANCEOF:
-       /* returnAddress is not allowed */
-       if (!TYPEINFO_IS_REFERENCE(OP1->typeinfo))
-               VERIFY_ERROR("Illegal instruction: INSTANCEOF on non-reference");
-
-       /* XXX should propagate type information to the following if-branches */
-       break;
-
-       /****************************************/
-       /* BRANCH INSTRUCTIONS                  */
-
-case ICMD_GOTO:            /* {ALL} */
-case ICMD_IFNULL:          /* {ALL} */
-case ICMD_IFNONNULL:       /* {ALL} */
-case ICMD_IFEQ:            /* {ALL} */
-case ICMD_IFNE:            /* {ALL} */
-case ICMD_IFLT:            /* {ALL} */
-case ICMD_IFGE:            /* {ALL} */
-case ICMD_IFGT:            /* {ALL} */
-case ICMD_IFLE:            /* {ALL} */
-case ICMD_IF_ICMPEQ:       /* {ALL} */
-case ICMD_IF_ICMPNE:       /* {ALL} */
-case ICMD_IF_ICMPLT:       /* {ALL} */
-case ICMD_IF_ICMPGE:       /* {ALL} */
-case ICMD_IF_ICMPGT:       /* {ALL} */
-case ICMD_IF_ICMPLE:       /* {ALL} */
-case ICMD_IF_ACMPEQ:       /* {ALL} */
-case ICMD_IF_ACMPNE:       /* {ALL} */
-
-case ICMD_IF_LEQ:          /* {ALL} */
-case ICMD_IF_LNE:          /* {ALL} */
-case ICMD_IF_LLT:          /* {ALL} */
-case ICMD_IF_LGE:          /* {ALL} */
-case ICMD_IF_LGT:          /* {ALL} */
-case ICMD_IF_LLE:          /* {ALL} */
-
-case ICMD_IF_LCMPEQ:       /* {ALL} */
-case ICMD_IF_LCMPNE:       /* {ALL} */
-case ICMD_IF_LCMPLT:       /* {ALL} */
-case ICMD_IF_LCMPGE:       /* {ALL} */
-case ICMD_IF_LCMPGT:       /* {ALL} */
-case ICMD_IF_LCMPLE:       /* {ALL} */
-       /* {RESULTNOW} */
-       TYPECHECK_COUNT(stat_ins_branch);
-
-       /* propagate stack and variables to the target block */
-       REACH(IPTR->dst);
-       break;
-
-       /****************************************/
-       /* SWITCHES                             */
-
-case ICMD_TABLESWITCH:     /* {ALL} */
-       /* {RESULTNOW} */
-       TYPECHECK_COUNT(stat_ins_switch);
-
-       table = IPTR->dst.table;
-       i = IPTR->sx.s23.s3.tablehigh
-       - IPTR->sx.s23.s2.tablelow + 1 + 1; /* plus default */
-
-       while (--i >= 0) {
-               REACH(*table);
-               table++;
-       }
-
-       LOG("switch done");
-       break;
-
-case ICMD_LOOKUPSWITCH:    /* {ALL} */
-       /* {RESULTNOW} */
-       TYPECHECK_COUNT(stat_ins_switch);
-
-       lookup = IPTR->dst.lookup;
-       i = IPTR->sx.s23.s2.lookupcount;
-       REACH(IPTR->sx.s23.s3.lookupdefault);
-
-       while (--i >= 0) {
-               REACH(lookup->target);
-               lookup++;
-       }
-
-       LOG("switch done");
-       break;
-
-
-       /****************************************/
-       /* ADDRESS RETURNS AND THROW            */
-
-case ICMD_ATHROW:
-       TYPECHECK_COUNT(stat_ins_athrow);
-       r = typeinfo_is_assignable_to_class(&OP1->typeinfo,
-                       CLASSREF_OR_CLASSINFO(class_java_lang_Throwable));
-       if (r == typecheck_FALSE)
-               VERIFY_ERROR("illegal instruction: ATHROW on non-Throwable");
-       if (r == typecheck_FAIL)
-               EXCEPTION;
-       if (r == typecheck_MAYBE) {
-               /* the check has to be postponed. we need a patcher */
-               TYPECHECK_COUNT(stat_ins_athrow_unresolved);
-               IPTR->sx.s23.s2.uc = create_unresolved_class(
-                               METHOD,
-                               /* XXX make this more efficient, use class_java_lang_Throwable
-                                * directly */
-                               class_get_classref(METHOD->clazz,utf_java_lang_Throwable),
-                               &OP1->typeinfo);
-               IPTR->flags.bits |= INS_FLAG_UNRESOLVED;
-       }
-       break;
-
-case ICMD_ARETURN:
-       TYPECHECK_COUNT(stat_ins_areturn);
-       if (!TYPEINFO_IS_REFERENCE(OP1->typeinfo))
-               VERIFY_ERROR("illegal instruction: ARETURN on non-reference");
-
-       if (STATE->returntype.type != TYPE_ADR
-                       || (r = typeinfo_is_assignable(&OP1->typeinfo,&(STATE->returntype.typeinfo)))
-                       == typecheck_FALSE)
-               VERIFY_ERROR("Return type mismatch");
-       if (r == typecheck_FAIL)
-               EXCEPTION;
-       if (r == typecheck_MAYBE) {
-               /* the check has to be postponed, we need a patcher */
-               TYPECHECK_COUNT(stat_ins_areturn_unresolved);
-               IPTR->sx.s23.s2.uc = create_unresolved_class(
-                               METHOD,
-                               METHOD->parseddesc->returntype.classref,
-                               &OP1->typeinfo);
-               IPTR->flags.bits |= INS_FLAG_UNRESOLVED;
-       }
-       goto return_tail;
-
-       /****************************************/
-       /* PRIMITIVE RETURNS                    */
-
-case ICMD_IRETURN:
-       if (STATE->returntype.type != TYPE_INT)
-               VERIFY_ERROR("Return type mismatch");
-       goto return_tail;
-
-case ICMD_LRETURN:
-       if (STATE->returntype.type != TYPE_LNG)
-               VERIFY_ERROR("Return type mismatch");
-       goto return_tail;
-
-case ICMD_FRETURN:
-       if (STATE->returntype.type != TYPE_FLT)
-               VERIFY_ERROR("Return type mismatch");
-       goto return_tail;
-
-case ICMD_DRETURN:
-       if (STATE->returntype.type != TYPE_DBL)
-               VERIFY_ERROR("Return type mismatch");
-       goto return_tail;
-
-case ICMD_RETURN:
-       if (STATE->returntype.type != TYPE_VOID)
-               VERIFY_ERROR("Return type mismatch");
-
-return_tail:
-       TYPECHECK_COUNT(stat_ins_primitive_return);
-
-       if (STATE->initmethod && METHOD->clazz != class_java_lang_Object) {
-               /* Check if the 'this' instance has been initialized. */
-               LOG("Checking <init> marker");
-#if defined(TYPECHECK_VARIABLESBASED)
-               if (!typevector_checktype(jd->var,STATE->numlocals-1,TYPE_INT))
-#else
-               if (STATE->locals[STATE->numlocals-1].type != TYPE_INT)
-#endif
-                       VERIFY_ERROR("<init> method does not initialize 'this'");
-       }
-       break;
-
-       /****************************************/
-       /* SUBROUTINE INSTRUCTIONS              */
-
-case ICMD_JSR: /* {VARIABLESBASED,TYPEINFERER} */
-       TYPEINFO_INIT_RETURNADDRESS(DST->typeinfo, BPTR->next);
-       REACH(IPTR->sx.s23.s3.jsrtarget);
-       break;
-
-case ICMD_JSR: /* {STACKBASED} */
-       /* {RESULTNOW} */
-       tbptr = IPTR->sx.s23.s3.jsrtarget.block;
-
-       TYPEINFO_INIT_RETURNADDRESS(stack[0].typeinfo, tbptr);
-       REACH_BLOCK(tbptr);
-
-       stack = typecheck_stackbased_jsr(STATE, stack, stackfloor);
-       if (stack == NULL)
-               EXCEPTION;
-       break;
-
-case ICMD_RET: /* {VARIABLESBASED,TYPEINFERER} */
-#if !defined(TYPECHECK_TYPEINFERER)
-       /* check returnAddress variable */
-       if (!typevector_checkretaddr(jd->var,IPTR->s1.varindex))
-               VERIFY_ERROR("illegal instruction: RET using non-returnAddress variable");
-#endif
-       REACH(IPTR->dst);
-       break;
-
-case ICMD_RET: /* {STACKBASED} */
-       /* {RESULTNOW} */
-       CHECK_LOCAL_TYPE(IPTR->s1.varindex, TYPE_RET);
-       if (!TYPEINFO_IS_PRIMITIVE(STATE->locals[IPTR->s1.varindex].typeinfo))
-               VERIFY_ERROR("illegal instruction: RET using non-returnAddress variable");
-
-       if (!typecheck_stackbased_ret(STATE, stack, stackfloor))
-               EXCEPTION;
-       break;
-
-       /****************************************/
-       /* INVOKATIONS                          */
-
-case ICMD_INVOKEVIRTUAL:   /* {VARIABLESBASED,TYPEINFERER} */
-case ICMD_INVOKESPECIAL:   /* {VARIABLESBASED,TYPEINFERER} */
-case ICMD_INVOKESTATIC:    /* {VARIABLESBASED,TYPEINFERER} */
-case ICMD_INVOKEINTERFACE: /* {VARIABLESBASED,TYPEINFERER} */
-       TYPECHECK_COUNT(stat_ins_invoke);
-       if (!handle_invocation(state))
-               EXCEPTION;
-       TYPECHECK_COUNTIF(INSTRUCTION_IS_UNRESOLVED(IPTR), stat_ins_invoke_unresolved);
-       break;
-
-case ICMD_INVOKEVIRTUAL:   /* {STACKBASED} */
-case ICMD_INVOKESPECIAL:   /* {STACKBASED} */
-case ICMD_INVOKESTATIC:    /* {STACKBASED} */
-case ICMD_INVOKEINTERFACE: /* {STACKBASED} */
-       TYPECHECK_COUNT(stat_ins_invoke);
-
-       INSTRUCTION_GET_METHODDESC(IPTR, md);
-       CHECK_STACK_DEPTH(md->paramslots);
-
-       if (!typecheck_stackbased_verify_invocation(STATE, stack, stackfloor))
-               EXCEPTION;
-
-       stack -= md->paramslots;
-
-       if (md->returntype.type != TYPE_VOID) {
-               if (IS_2_WORD_TYPE(md->returntype.type)) {
-                       CHECK_STACK_SPACE(2);
-                       stack += 2;
-                       stack[0].type = TYPE_VOID;
-                       stack[-1].type = md->returntype.type;
-               }
-               else {
-                       CHECK_STACK_SPACE(1);
-                       stack += 1;
-                       stack[0].type = md->returntype.type;
-               }
-       }
-       TYPECHECK_COUNTIF(INSTRUCTION_IS_UNRESOLVED(IPTR), stat_ins_invoke_unresolved);
-       break;
-
-       /****************************************/
-       /* MULTIANEWARRAY                       */
-
-case ICMD_MULTIANEWARRAY: /* {VARIABLESBASED,TYPEINFERER} */
-       if (!handle_multianewarray(STATE))
-               EXCEPTION;
-       break;
-
-case ICMD_MULTIANEWARRAY: /* {STACKBASED} */
-       if (!typecheck_stackbased_multianewarray(STATE, stack, stackfloor))
-               EXCEPTION;
-       stack -= (IPTR->s1.argcount - 1);
-       stack[0].type = TYPE_ADR;
-       break;
-
-       /****************************************/
-       /* BUILTINS                             */
-
-case ICMD_BUILTIN: /* {VARIABLESBASED,TYPEINFERER} */
-       TYPECHECK_COUNT(stat_ins_builtin);
-       if (!handle_builtin(state))
-               EXCEPTION;
-       break;
-
-case ICMD_BUILTIN: /* {STACKBASED} */
-       TYPECHECK_COUNT(stat_ins_builtin);
-       if (!typecheck_stackbased_verify_builtin(STATE, stack, stackfloor))
-               EXCEPTION;
-
-       /* pop operands and push return value */
-       {
-               u1 rtype = IPTR->sx.s23.s3.bte->md->returntype.type;
-               stack -=  IPTR->sx.s23.s3.bte->md->paramslots;
-               if (rtype != TYPE_VOID) {
-                       if (IS_2_WORD_TYPE(rtype))
-                               stack += 2;
-                       else
-                               stack += 1;
-               }
-       }
-       break;
-
-/* the following code is only used by the stackbased verifier */
-
-case ICMD_POP: /* {STACKBASED} */
-       /* we pop 1 */
-       CHECK_CAT1(stack[0]);
-       break;
-
-case ICMD_POP2: /* {STACKBASED} */
-       /* we pop either 11 or 2 */
-       if (IS_CAT1(stack[0]))
-               CHECK_CAT1(stack[-1]);
-       break;
-
-case ICMD_SWAP: /* {STACKBASED} */
-       CHECK_CAT1(stack[0]);
-       CHECK_CAT1(stack[-1]);
-
-       COPY_SLOT(stack[ 0], temp     );
-       COPY_SLOT(stack[-1], stack[ 0]);
-       COPY_SLOT(temp     , stack[-1]);
-       break;
-
-case ICMD_DUP: /* {STACKBASED} */
-       /* we dup 1 */
-       CHECK_CAT1(stack[0]);
-
-       COPY_SLOT(stack[ 0], stack[ 1]);
-       break;
-
-case ICMD_DUP_X1: /* {STACKBASED} */
-       /* we dup 1 */
-       CHECK_CAT1(stack[0]);
-       /* we skip 1 */
-       CHECK_CAT1(stack[-1]);
-
-       COPY_SLOT(stack[ 0], stack[ 1]);
-       COPY_SLOT(stack[-1], stack[ 0]);
-       COPY_SLOT(stack[ 1], stack[-1]);
-       break;
-
-case ICMD_DUP_X2: /* {STACKBASED} */
-       /* we dup 1 */
-       CHECK_CAT1(stack[0]);
-       /* we skip either 11 or 2 */
-       if (IS_CAT1(stack[-1]))
-               CHECK_CAT1(stack[-2]);
-
-       COPY_SLOT(stack[ 0], stack[ 1]);
-       COPY_SLOT(stack[-1], stack[ 0]);
-       COPY_SLOT(stack[-2], stack[-1]);
-       COPY_SLOT(stack[ 1], stack[-2]);
-       break;
-
-case ICMD_DUP2: /* {STACKBASED} */
-       /* we dup either 11 or 2 */
-       if (IS_CAT1(stack[0]))
-               CHECK_CAT1(stack[-1]);
-
-       COPY_SLOT(stack[ 0], stack[ 2]);
-       COPY_SLOT(stack[-1], stack[ 1]);
-       break;
-
-case ICMD_DUP2_X1: /* {STACKBASED} */
-       /* we dup either 11 or 2 */
-       if (IS_CAT1(stack[0]))
-               CHECK_CAT1(stack[-1]);
-       /* we skip 1 */
-       CHECK_CAT1(stack[-2]);
-
-       COPY_SLOT(stack[ 0], stack[ 2]);
-       COPY_SLOT(stack[-1], stack[ 1]);
-       COPY_SLOT(stack[-2], stack[ 0]);
-       COPY_SLOT(stack[ 2], stack[-1]);
-       COPY_SLOT(stack[ 1], stack[-2]);
-       break;
-
-case ICMD_DUP2_X2: /* {STACKBASED} */
-       /* we dup either 11 or 2 */
-       if (IS_CAT1(stack[0]))
-               CHECK_CAT1(stack[-1]);
-       /* we skip either 11 or 2 */
-       if (IS_CAT1(stack[-2]))
-               CHECK_CAT1(stack[-3]);
-
-       COPY_SLOT(stack[ 0], stack[ 2]);
-       COPY_SLOT(stack[-1], stack[ 1]);
-       COPY_SLOT(stack[-2], stack[ 0]);
-       COPY_SLOT(stack[-3], stack[-1]);
-       COPY_SLOT(stack[ 2], stack[-2]);
-       COPY_SLOT(stack[ 1], stack[-3]);
-       break;
-
-
-/* this marker is needed by generate.pl: */
-/* {END_OF_CODE} */
-
-/*
- * 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/jit/verify/icmds.cpp b/src/vm/jit/verify/icmds.cpp
new file mode 100644 (file)
index 0000000..0d3457e
--- /dev/null
@@ -0,0 +1,779 @@
+/* src/vm/jit/verify/icmds.c - ICMD-specific type checking code
+
+   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.
+
+*/
+
+#if 0 /* (needed for code examples in the following comment) */
+/******************************************************************************/
+/* This file contains ICMD-specific code for type checking and type
+ * inference. It is an input file for the verifier generator
+ * (src/vm/jit/verify/generate.pl). The verifier generator creates
+ * code for three compiler passes:
+ *     - stack-based type-infering verification
+ *     - vasiables-based type-infering verification
+ *     - type inference pass (no verification - used for optimizing compiler)
+ *
+ * The rest of this file must consist of "case" clauses starting in
+ * the first column. Each clause can be marked with tags like this:
+ *
+ */          case ICMD_CONSTANT: /* {TAG, TAG, ...} */
+/*
+ * This must be on one line. The following tags are defined:
+ *     STACKBASED..........use this clause for the stack-based verifier
+ *     VARIABLESBASED......use this clause for the variables-based verifier
+ *     TYPEINFERER.........use this clause for the type inference pass
+ *     ALL.................use for all passes
+ *
+ * If no tag is specified, {STACKBASED,VARIABLESBASED} is assumed.
+ *
+ * There are also tags that can be used inside a clause like this:
+ *
+ */          /* {TAG} */
+/*
+ * The following tags are defined within clauses:
+ *     RESULTNOW...........generate code for modelling the stack action
+ *                         _before_ the user-defined code in the clause
+ *                         (Default is to model the stack action afterwards.)
+ *
+ * The following macros are pre-defined:
+ *
+ *     TYPECHECK_STACKBASED.......iff compiling the stack-based verifier
+ *     TYPECHECK_VARIABLESBASED...iff compiling the variables-based verifier
+ *     TYPECHECK_TYPEINFERER......iff compiling the type inference pass
+ *
+/******************************************************************************/
+#endif /* (end #if 0) */
+
+
+/* this marker is needed by generate.pl: */
+/* {START_OF_CODE} */
+
+       /****************************************/
+       /* MOVE/COPY                            */
+
+       /* We just need to copy the typeinfo */
+       /* for slots containing addresses.   */
+
+       /* (These are only used by the variables based verifier.) */
+
+case ICMD_MOVE: /* {VARIABLESBASED,TYPEINFERER} */
+case ICMD_COPY: /* {VARIABLESBASED,TYPEINFERER} */
+       TYPECHECK_COUNT(stat_ins_stack);
+       COPYTYPE(IPTR->s1, IPTR->dst);
+       DST->type = OP1->type;
+       break;
+
+       /****************************************/
+       /* LOADING ADDRESS FROM VARIABLE        */
+
+case ICMD_ALOAD: /* {ALL} */
+       TYPECHECK_COUNT(stat_ins_aload);
+
+#if !defined(TYPECHECK_TYPEINFERER)
+       /* loading a returnAddress is not allowed */
+       if (!TYPEDESC_IS_REFERENCE(*OP1)) {
+               VERIFY_ERROR("illegal instruction: ALOAD loading non-reference");
+       }
+#endif
+       TYPEINFO_COPY(OP1->typeinfo,DST->typeinfo);
+       break;
+
+       /****************************************/
+       /* STORING ADDRESS TO VARIABLE          */
+
+case ICMD_ASTORE: /* {ALL} */
+       TYPEINFO_COPY(OP1->typeinfo, DST->typeinfo);
+       break;
+
+       /****************************************/
+       /* LOADING ADDRESS FROM ARRAY           */
+
+case ICMD_AALOAD: /* {ALL} */
+#if !defined(TYPECHECK_TYPEINFERER)
+       if (!TYPEINFO_MAYBE_ARRAY_OF_REFS(OP1->typeinfo))
+               VERIFY_ERROR("illegal instruction: AALOAD on non-reference array");
+#endif
+
+       if (!typeinfo_init_component(&OP1->typeinfo,&DST->typeinfo))
+               EXCEPTION;
+       break;
+
+       /****************************************/
+       /* FIELD ACCESS                         */
+
+case ICMD_PUTFIELD: /* {STACKBASED} */
+       CHECK_STACK_DEPTH(2);
+       if (!IS_CAT1(stack[0])) {
+               CHECK_STACK_DEPTH(3);
+               stack -= 1;
+       }
+       CHECK_STACK_TYPE(stack[-1], TYPE_ADR);
+       stack = typecheck_stackbased_verify_fieldaccess(STATE, stack-1, stack, stack-2);
+       if (stack == NULL)
+               EXCEPTION;
+       break;
+
+case ICMD_PUTSTATIC: /* {STACKBASED} */
+       CHECK_STACK_DEPTH(1);
+       if (!IS_CAT1(stack[0])) {
+               /* (stack depth >= 2 is guaranteed) */
+               stack -= 1;
+       }
+       stack = typecheck_stackbased_verify_fieldaccess(STATE, NULL, stack, stack-1);
+       if (stack == NULL)
+               EXCEPTION;
+       break;
+
+case ICMD_GETFIELD: /* {STACKBASED} */
+       CHECK_STACK_TYPE(stack[0], TYPE_ADR);
+       stack = typecheck_stackbased_verify_fieldaccess(STATE, stack, NULL, stack-1);
+       if (stack == NULL)
+               EXCEPTION;
+       break;
+
+case ICMD_GETSTATIC:      /* {STACKBASED} */
+       stack = typecheck_stackbased_verify_fieldaccess(STATE, NULL, NULL, stack);
+       if (stack == NULL)
+               EXCEPTION;
+       break;
+
+case ICMD_PUTFIELD:       /* {VARIABLESBASED} */
+       if (!handle_fieldaccess(state, VAROP(iptr->s1), VAROP(iptr->sx.s23.s2)))
+               return false;
+       maythrow = true;
+       break;
+
+case ICMD_PUTSTATIC:      /* {VARIABLESBASED} */
+       if (!handle_fieldaccess(state, NULL, VAROP(iptr->s1)))
+               return false;
+       maythrow = true;
+       break;
+
+case ICMD_PUTFIELDCONST:  /* {VARIABLESBASED} */
+       /* XXX this mess will go away with const operands */
+       INSTRUCTION_GET_FIELDREF(state->iptr, fieldref);
+       constvalue.type = fieldref->parseddesc.fd->type;
+       if (IS_ADR_TYPE(constvalue.type)) {
+               if (state->iptr->sx.val.anyptr) {
+                       classinfo *cc = (state->iptr->flags.bits & INS_FLAG_CLASS)
+                               ? class_java_lang_Class : class_java_lang_String;
+                       assert(cc);
+                       assert(cc->state & CLASS_LINKED);
+                       typeinfo_init_classinfo(&(constvalue.typeinfo), cc);
+               }
+               else {
+                       TYPEINFO_INIT_NULLTYPE(constvalue.typeinfo);
+               }
+       }
+       if (!handle_fieldaccess(state, VAROP(iptr->s1), &constvalue))
+               return false;
+       maythrow = true;
+       break;
+
+case ICMD_PUTSTATICCONST: /* {VARIABLESBASED} */
+       /* XXX this mess will go away with const operands */
+       INSTRUCTION_GET_FIELDREF(state->iptr, fieldref);
+       constvalue.type = fieldref->parseddesc.fd->type;
+       if (IS_ADR_TYPE(constvalue.type)) {
+               if (state->iptr->sx.val.anyptr) {
+                       classinfo *cc = (state->iptr->flags.bits & INS_FLAG_CLASS)
+                               ? class_java_lang_Class : class_java_lang_String;
+                       assert(cc);
+                       assert(cc->state & CLASS_LINKED);
+                       typeinfo_init_classinfo(&(constvalue.typeinfo), cc);
+               }
+               else {
+                       TYPEINFO_INIT_NULLTYPE(constvalue.typeinfo);
+               }
+       }
+       if (!handle_fieldaccess(state, NULL, &constvalue))
+               return false;
+       maythrow = true;
+       break;
+
+case ICMD_GETFIELD:       /* {VARIABLESBASED,TYPEINFERER} */
+       if (!handle_fieldaccess(state, VAROP(iptr->s1), NULL))
+               return false;
+       maythrow = true;
+       break;
+
+case ICMD_GETSTATIC:      /* {VARIABLESBASED,TYPEINFERER} */
+       if (!handle_fieldaccess(state, NULL, NULL))
+               return false;
+       maythrow = true;
+       break;
+
+       /****************************************/
+       /* PRIMITIVE ARRAY ACCESS               */
+
+case ICMD_ARRAYLENGTH:
+       if (!TYPEINFO_MAYBE_ARRAY(OP1->typeinfo)
+                       && OP1->typeinfo.typeclass.cls != pseudo_class_Arraystub)
+               VERIFY_ERROR("illegal instruction: ARRAYLENGTH on non-array");
+       break;
+
+case ICMD_BALOAD:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_BOOLEAN)
+                       && !TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_BYTE))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_CALOAD:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_CHAR))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_DALOAD:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_DOUBLE))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_FALOAD:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_FLOAT))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_IALOAD:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_INT))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_SALOAD:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_SHORT))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_LALOAD:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_LONG))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_BASTORE:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_BOOLEAN)
+                       && !TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_BYTE))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_CASTORE:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_CHAR))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_DASTORE:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_DOUBLE))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_FASTORE:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_FLOAT))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_IASTORE:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_INT))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_SASTORE:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_SHORT))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_LASTORE:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo,ARRAYTYPE_LONG))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_AASTORE:
+       /* we just check the basic input types and that the           */
+       /* destination is an array of references. Assignability to    */
+       /* the actual array must be checked at runtime, each time the */
+       /* instruction is performed. (See builtin_canstore.)          */
+       if (!TYPEINFO_MAYBE_ARRAY_OF_REFS(OP1->typeinfo))
+               VERIFY_ERROR("illegal instruction: AASTORE to non-reference array");
+       break;
+
+case ICMD_IASTORECONST:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_INT))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_LASTORECONST:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_LONG))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_BASTORECONST:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_BOOLEAN)
+                       && !TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_BYTE))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_CASTORECONST:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_CHAR))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+case ICMD_SASTORECONST:
+       if (!TYPEINFO_MAYBE_PRIMITIVE_ARRAY(OP1->typeinfo, ARRAYTYPE_SHORT))
+               VERIFY_ERROR("Array type mismatch");
+       break;
+
+       /****************************************/
+       /* ADDRESS CONSTANTS                    */
+
+case ICMD_ACONST: /* {ALL} */
+       if (IPTR->flags.bits & INS_FLAG_CLASS) {
+               /* a java.lang.Class reference */
+               TYPEINFO_INIT_JAVA_LANG_CLASS(DST->typeinfo,IPTR->sx.val.c);
+       }
+       else {
+               if (IPTR->sx.val.anyptr == NULL)
+                       TYPEINFO_INIT_NULLTYPE(DST->typeinfo);
+               else {
+                       /* string constant (or constant for builtin function) */
+                       typeinfo_init_classinfo(&(DST->typeinfo),class_java_lang_String);
+               }
+       }
+       break;
+
+       /****************************************/
+       /* CHECKCAST AND INSTANCEOF             */
+
+case ICMD_CHECKCAST: /* {ALL} */
+#if !defined(TYPECHECK_TYPEINFERER)
+       /* returnAddress is not allowed */
+       if (!TYPEINFO_IS_REFERENCE(OP1->typeinfo))
+               VERIFY_ERROR("Illegal instruction: CHECKCAST on non-reference");
+#endif
+
+    /* XXX only if narrower */
+       if (!typeinfo_init_class(&(DST->typeinfo),IPTR->sx.s23.s3.c))
+               EXCEPTION;
+       break;
+
+case ICMD_INSTANCEOF:
+       /* returnAddress is not allowed */
+       if (!TYPEINFO_IS_REFERENCE(OP1->typeinfo))
+               VERIFY_ERROR("Illegal instruction: INSTANCEOF on non-reference");
+
+       /* XXX should propagate type information to the following if-branches */
+       break;
+
+       /****************************************/
+       /* BRANCH INSTRUCTIONS                  */
+
+case ICMD_GOTO:            /* {ALL} */
+case ICMD_IFNULL:          /* {ALL} */
+case ICMD_IFNONNULL:       /* {ALL} */
+case ICMD_IFEQ:            /* {ALL} */
+case ICMD_IFNE:            /* {ALL} */
+case ICMD_IFLT:            /* {ALL} */
+case ICMD_IFGE:            /* {ALL} */
+case ICMD_IFGT:            /* {ALL} */
+case ICMD_IFLE:            /* {ALL} */
+case ICMD_IF_ICMPEQ:       /* {ALL} */
+case ICMD_IF_ICMPNE:       /* {ALL} */
+case ICMD_IF_ICMPLT:       /* {ALL} */
+case ICMD_IF_ICMPGE:       /* {ALL} */
+case ICMD_IF_ICMPGT:       /* {ALL} */
+case ICMD_IF_ICMPLE:       /* {ALL} */
+case ICMD_IF_ACMPEQ:       /* {ALL} */
+case ICMD_IF_ACMPNE:       /* {ALL} */
+
+case ICMD_IF_LEQ:          /* {ALL} */
+case ICMD_IF_LNE:          /* {ALL} */
+case ICMD_IF_LLT:          /* {ALL} */
+case ICMD_IF_LGE:          /* {ALL} */
+case ICMD_IF_LGT:          /* {ALL} */
+case ICMD_IF_LLE:          /* {ALL} */
+
+case ICMD_IF_LCMPEQ:       /* {ALL} */
+case ICMD_IF_LCMPNE:       /* {ALL} */
+case ICMD_IF_LCMPLT:       /* {ALL} */
+case ICMD_IF_LCMPGE:       /* {ALL} */
+case ICMD_IF_LCMPGT:       /* {ALL} */
+case ICMD_IF_LCMPLE:       /* {ALL} */
+       /* {RESULTNOW} */
+       TYPECHECK_COUNT(stat_ins_branch);
+
+       /* propagate stack and variables to the target block */
+       REACH(IPTR->dst);
+       break;
+
+       /****************************************/
+       /* SWITCHES                             */
+
+case ICMD_TABLESWITCH:     /* {ALL} */
+       /* {RESULTNOW} */
+       TYPECHECK_COUNT(stat_ins_switch);
+
+       table = IPTR->dst.table;
+       i = IPTR->sx.s23.s3.tablehigh
+       - IPTR->sx.s23.s2.tablelow + 1 + 1; /* plus default */
+
+       while (--i >= 0) {
+               REACH(*table);
+               table++;
+       }
+
+       LOG("switch done");
+       break;
+
+case ICMD_LOOKUPSWITCH:    /* {ALL} */
+       /* {RESULTNOW} */
+       TYPECHECK_COUNT(stat_ins_switch);
+
+       lookup = IPTR->dst.lookup;
+       i = IPTR->sx.s23.s2.lookupcount;
+       REACH(IPTR->sx.s23.s3.lookupdefault);
+
+       while (--i >= 0) {
+               REACH(lookup->target);
+               lookup++;
+       }
+
+       LOG("switch done");
+       break;
+
+
+       /****************************************/
+       /* ADDRESS RETURNS AND THROW            */
+
+case ICMD_ATHROW:
+       TYPECHECK_COUNT(stat_ins_athrow);
+       r = typeinfo_is_assignable_to_class(&OP1->typeinfo,
+                       CLASSREF_OR_CLASSINFO(class_java_lang_Throwable));
+       if (r == typecheck_FALSE)
+               VERIFY_ERROR("illegal instruction: ATHROW on non-Throwable");
+       if (r == typecheck_FAIL)
+               EXCEPTION;
+       if (r == typecheck_MAYBE) {
+               /* the check has to be postponed. we need a patcher */
+               TYPECHECK_COUNT(stat_ins_athrow_unresolved);
+               IPTR->sx.s23.s2.uc = create_unresolved_class(
+                               METHOD,
+                               /* XXX make this more efficient, use class_java_lang_Throwable
+                                * directly */
+                               class_get_classref(METHOD->clazz,utf_java_lang_Throwable),
+                               &OP1->typeinfo);
+               IPTR->flags.bits |= INS_FLAG_UNRESOLVED;
+       }
+       break;
+
+case ICMD_ARETURN:
+       TYPECHECK_COUNT(stat_ins_areturn);
+       if (!TYPEINFO_IS_REFERENCE(OP1->typeinfo))
+               VERIFY_ERROR("illegal instruction: ARETURN on non-reference");
+
+       if (STATE->returntype.type != TYPE_ADR
+                       || (r = typeinfo_is_assignable(&OP1->typeinfo,&(STATE->returntype.typeinfo)))
+                       == typecheck_FALSE)
+               VERIFY_ERROR("Return type mismatch");
+       if (r == typecheck_FAIL)
+               EXCEPTION;
+       if (r == typecheck_MAYBE) {
+               /* the check has to be postponed, we need a patcher */
+               TYPECHECK_COUNT(stat_ins_areturn_unresolved);
+               IPTR->sx.s23.s2.uc = create_unresolved_class(
+                               METHOD,
+                               METHOD->parseddesc->returntype.classref,
+                               &OP1->typeinfo);
+               IPTR->flags.bits |= INS_FLAG_UNRESOLVED;
+       }
+       goto return_tail;
+
+       /****************************************/
+       /* PRIMITIVE RETURNS                    */
+
+case ICMD_IRETURN:
+       if (STATE->returntype.type != TYPE_INT)
+               VERIFY_ERROR("Return type mismatch");
+       goto return_tail;
+
+case ICMD_LRETURN:
+       if (STATE->returntype.type != TYPE_LNG)
+               VERIFY_ERROR("Return type mismatch");
+       goto return_tail;
+
+case ICMD_FRETURN:
+       if (STATE->returntype.type != TYPE_FLT)
+               VERIFY_ERROR("Return type mismatch");
+       goto return_tail;
+
+case ICMD_DRETURN:
+       if (STATE->returntype.type != TYPE_DBL)
+               VERIFY_ERROR("Return type mismatch");
+       goto return_tail;
+
+case ICMD_RETURN:
+       if (STATE->returntype.type != TYPE_VOID)
+               VERIFY_ERROR("Return type mismatch");
+
+return_tail:
+       TYPECHECK_COUNT(stat_ins_primitive_return);
+
+       if (STATE->initmethod && METHOD->clazz != class_java_lang_Object) {
+               /* Check if the 'this' instance has been initialized. */
+               LOG("Checking <init> marker");
+#if defined(TYPECHECK_VARIABLESBASED)
+               if (!typevector_checktype(jd->var,STATE->numlocals-1,TYPE_INT))
+#else
+               if (STATE->locals[STATE->numlocals-1].type != TYPE_INT)
+#endif
+                       VERIFY_ERROR("<init> method does not initialize 'this'");
+       }
+       break;
+
+       /****************************************/
+       /* SUBROUTINE INSTRUCTIONS              */
+
+case ICMD_JSR: /* {VARIABLESBASED,TYPEINFERER} */
+       TYPEINFO_INIT_RETURNADDRESS(DST->typeinfo, BPTR->next);
+       REACH(IPTR->sx.s23.s3.jsrtarget);
+       break;
+
+case ICMD_JSR: /* {STACKBASED} */
+       /* {RESULTNOW} */
+       tbptr = IPTR->sx.s23.s3.jsrtarget.block;
+
+       TYPEINFO_INIT_RETURNADDRESS(stack[0].typeinfo, tbptr);
+       REACH_BLOCK(tbptr);
+
+       stack = typecheck_stackbased_jsr(STATE, stack, stackfloor);
+       if (stack == NULL)
+               EXCEPTION;
+       break;
+
+case ICMD_RET: /* {VARIABLESBASED,TYPEINFERER} */
+#if !defined(TYPECHECK_TYPEINFERER)
+       /* check returnAddress variable */
+       if (!typevector_checkretaddr(jd->var,IPTR->s1.varindex))
+               VERIFY_ERROR("illegal instruction: RET using non-returnAddress variable");
+#endif
+       REACH(IPTR->dst);
+       break;
+
+case ICMD_RET: /* {STACKBASED} */
+       /* {RESULTNOW} */
+       CHECK_LOCAL_TYPE(IPTR->s1.varindex, TYPE_RET);
+       if (!TYPEINFO_IS_PRIMITIVE(STATE->locals[IPTR->s1.varindex].typeinfo))
+               VERIFY_ERROR("illegal instruction: RET using non-returnAddress variable");
+
+       if (!typecheck_stackbased_ret(STATE, stack, stackfloor))
+               EXCEPTION;
+       break;
+
+       /****************************************/
+       /* INVOKATIONS                          */
+
+case ICMD_INVOKEVIRTUAL:   /* {VARIABLESBASED,TYPEINFERER} */
+case ICMD_INVOKESPECIAL:   /* {VARIABLESBASED,TYPEINFERER} */
+case ICMD_INVOKESTATIC:    /* {VARIABLESBASED,TYPEINFERER} */
+case ICMD_INVOKEINTERFACE: /* {VARIABLESBASED,TYPEINFERER} */
+       TYPECHECK_COUNT(stat_ins_invoke);
+       if (!handle_invocation(state))
+               EXCEPTION;
+       TYPECHECK_COUNTIF(INSTRUCTION_IS_UNRESOLVED(IPTR), stat_ins_invoke_unresolved);
+       break;
+
+case ICMD_INVOKEVIRTUAL:   /* {STACKBASED} */
+case ICMD_INVOKESPECIAL:   /* {STACKBASED} */
+case ICMD_INVOKESTATIC:    /* {STACKBASED} */
+case ICMD_INVOKEINTERFACE: /* {STACKBASED} */
+       TYPECHECK_COUNT(stat_ins_invoke);
+
+       INSTRUCTION_GET_METHODDESC(IPTR, md);
+       CHECK_STACK_DEPTH(md->paramslots);
+
+       if (!typecheck_stackbased_verify_invocation(STATE, stack, stackfloor))
+               EXCEPTION;
+
+       stack -= md->paramslots;
+
+       if (md->returntype.type != TYPE_VOID) {
+               if (IS_2_WORD_TYPE(md->returntype.type)) {
+                       CHECK_STACK_SPACE(2);
+                       stack += 2;
+                       stack[0].type = TYPE_VOID;
+                       stack[-1].type = md->returntype.type;
+               }
+               else {
+                       CHECK_STACK_SPACE(1);
+                       stack += 1;
+                       stack[0].type = md->returntype.type;
+               }
+       }
+       TYPECHECK_COUNTIF(INSTRUCTION_IS_UNRESOLVED(IPTR), stat_ins_invoke_unresolved);
+       break;
+
+       /****************************************/
+       /* MULTIANEWARRAY                       */
+
+case ICMD_MULTIANEWARRAY: /* {VARIABLESBASED,TYPEINFERER} */
+       if (!handle_multianewarray(STATE))
+               EXCEPTION;
+       break;
+
+case ICMD_MULTIANEWARRAY: /* {STACKBASED} */
+       if (!typecheck_stackbased_multianewarray(STATE, stack, stackfloor))
+               EXCEPTION;
+       stack -= (IPTR->s1.argcount - 1);
+       stack[0].type = TYPE_ADR;
+       break;
+
+       /****************************************/
+       /* BUILTINS                             */
+
+case ICMD_BUILTIN: /* {VARIABLESBASED,TYPEINFERER} */
+       TYPECHECK_COUNT(stat_ins_builtin);
+       if (!handle_builtin(state))
+               EXCEPTION;
+       break;
+
+case ICMD_BUILTIN: /* {STACKBASED} */
+       TYPECHECK_COUNT(stat_ins_builtin);
+       if (!typecheck_stackbased_verify_builtin(STATE, stack, stackfloor))
+               EXCEPTION;
+
+       /* pop operands and push return value */
+       {
+               u1 rtype = IPTR->sx.s23.s3.bte->md->returntype.type;
+               stack -=  IPTR->sx.s23.s3.bte->md->paramslots;
+               if (rtype != TYPE_VOID) {
+                       if (IS_2_WORD_TYPE(rtype))
+                               stack += 2;
+                       else
+                               stack += 1;
+               }
+       }
+       break;
+
+/* the following code is only used by the stackbased verifier */
+
+case ICMD_POP: /* {STACKBASED} */
+       /* we pop 1 */
+       CHECK_CAT1(stack[0]);
+       break;
+
+case ICMD_POP2: /* {STACKBASED} */
+       /* we pop either 11 or 2 */
+       if (IS_CAT1(stack[0]))
+               CHECK_CAT1(stack[-1]);
+       break;
+
+case ICMD_SWAP: /* {STACKBASED} */
+       CHECK_CAT1(stack[0]);
+       CHECK_CAT1(stack[-1]);
+
+       COPY_SLOT(stack[ 0], temp     );
+       COPY_SLOT(stack[-1], stack[ 0]);
+       COPY_SLOT(temp     , stack[-1]);
+       break;
+
+case ICMD_DUP: /* {STACKBASED} */
+       /* we dup 1 */
+       CHECK_CAT1(stack[0]);
+
+       COPY_SLOT(stack[ 0], stack[ 1]);
+       break;
+
+case ICMD_DUP_X1: /* {STACKBASED} */
+       /* we dup 1 */
+       CHECK_CAT1(stack[0]);
+       /* we skip 1 */
+       CHECK_CAT1(stack[-1]);
+
+       COPY_SLOT(stack[ 0], stack[ 1]);
+       COPY_SLOT(stack[-1], stack[ 0]);
+       COPY_SLOT(stack[ 1], stack[-1]);
+       break;
+
+case ICMD_DUP_X2: /* {STACKBASED} */
+       /* we dup 1 */
+       CHECK_CAT1(stack[0]);
+       /* we skip either 11 or 2 */
+       if (IS_CAT1(stack[-1]))
+               CHECK_CAT1(stack[-2]);
+
+       COPY_SLOT(stack[ 0], stack[ 1]);
+       COPY_SLOT(stack[-1], stack[ 0]);
+       COPY_SLOT(stack[-2], stack[-1]);
+       COPY_SLOT(stack[ 1], stack[-2]);
+       break;
+
+case ICMD_DUP2: /* {STACKBASED} */
+       /* we dup either 11 or 2 */
+       if (IS_CAT1(stack[0]))
+               CHECK_CAT1(stack[-1]);
+
+       COPY_SLOT(stack[ 0], stack[ 2]);
+       COPY_SLOT(stack[-1], stack[ 1]);
+       break;
+
+case ICMD_DUP2_X1: /* {STACKBASED} */
+       /* we dup either 11 or 2 */
+       if (IS_CAT1(stack[0]))
+               CHECK_CAT1(stack[-1]);
+       /* we skip 1 */
+       CHECK_CAT1(stack[-2]);
+
+       COPY_SLOT(stack[ 0], stack[ 2]);
+       COPY_SLOT(stack[-1], stack[ 1]);
+       COPY_SLOT(stack[-2], stack[ 0]);
+       COPY_SLOT(stack[ 2], stack[-1]);
+       COPY_SLOT(stack[ 1], stack[-2]);
+       break;
+
+case ICMD_DUP2_X2: /* {STACKBASED} */
+       /* we dup either 11 or 2 */
+       if (IS_CAT1(stack[0]))
+               CHECK_CAT1(stack[-1]);
+       /* we skip either 11 or 2 */
+       if (IS_CAT1(stack[-2]))
+               CHECK_CAT1(stack[-3]);
+
+       COPY_SLOT(stack[ 0], stack[ 2]);
+       COPY_SLOT(stack[-1], stack[ 1]);
+       COPY_SLOT(stack[-2], stack[ 0]);
+       COPY_SLOT(stack[-3], stack[-1]);
+       COPY_SLOT(stack[ 2], stack[-2]);
+       COPY_SLOT(stack[ 1], stack[-3]);
+       break;
+
+
+/* this marker is needed by generate.pl: */
+/* {END_OF_CODE} */
+
+/*
+ * 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/jit/verify/typecheck-common.c b/src/vm/jit/verify/typecheck-common.c
deleted file mode 100644 (file)
index 5b55943..0000000
+++ /dev/null
@@ -1,548 +0,0 @@
-/* src/vm/jit/verify/typecheck-common.c - shared verifier code
-
-   Copyright (C) 1996-2005, 2006, 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 "vm/types.h"
-#include "vm/global.h"
-
-#include <assert.h>
-
-#include <vm/exceptions.h>
-#include <vm/jit/show.h>
-#include <typecheck-common.h>
-
-/****************************************************************************/
-/* DEBUG HELPERS                                                            */
-/****************************************************************************/
-
-#ifdef TYPECHECK_VERBOSE_OPT
-bool opt_typecheckverbose = false;
-#endif
-
-#if defined(TYPECHECK_VERBOSE) || defined(TYPECHECK_VERBOSE_IMPORTANT)
-
-void typecheck_print_var(FILE *file, jitdata *jd, s4 index)
-{
-       varinfo *var;
-
-       assert(index >= 0 && index < jd->varcount);
-       var = VAR(index);
-       typeinfo_print_type(file, var->type, &(var->typeinfo));
-}
-
-void typecheck_print_vararray(FILE *file, jitdata *jd, s4 *vars, int len)
-{
-       s4 i;
-
-       for (i=0; i<len; ++i) {
-               if (i)
-                       fputc(' ', file);
-               typecheck_print_var(file, jd, *vars++);
-       }
-}
-
-#endif /* defined(TYPECHECK_VERBOSE) || defined(TYPECHECK_VERBOSE_IMPORTANT) */
-
-
-/****************************************************************************/
-/* STATISTICS                                                               */
-/****************************************************************************/
-
-#if defined(TYPECHECK_STATISTICS)
-int stat_typechecked = 0;
-int stat_methods_with_handlers = 0;
-int stat_methods_maythrow = 0;
-int stat_iterations[STAT_ITERATIONS+1] = { 0 };
-int stat_reached = 0;
-int stat_copied = 0;
-int stat_merged = 0;
-int stat_merging_changed = 0;
-int stat_blocks[STAT_BLOCKS+1] = { 0 };
-int stat_locals[STAT_LOCALS+1] = { 0 };
-int stat_ins = 0;
-int stat_ins_maythrow = 0;
-int stat_ins_stack = 0;
-int stat_ins_field = 0;
-int stat_ins_field_unresolved = 0;
-int stat_ins_field_uninitialized = 0;
-int stat_ins_invoke = 0;
-int stat_ins_invoke_unresolved = 0;
-int stat_ins_primload = 0;
-int stat_ins_aload = 0;
-int stat_ins_builtin = 0;
-int stat_ins_builtin_gen = 0;
-int stat_ins_branch = 0;
-int stat_ins_switch = 0;
-int stat_ins_primitive_return = 0;
-int stat_ins_areturn = 0;
-int stat_ins_areturn_unresolved = 0;
-int stat_ins_athrow = 0;
-int stat_ins_athrow_unresolved = 0;
-int stat_ins_unchecked = 0;
-int stat_handlers_reached = 0;
-int stat_savedstack = 0;
-
-static void print_freq(FILE *file,int *array,int limit)
-{
-       int i;
-       for (i=0; i<limit; ++i)
-               fprintf(file,"      %3d: %8d\n",i,array[i]);
-       fprintf(file,"    >=%3d: %8d\n",limit,array[limit]);
-}
-
-void typecheck_print_statistics(FILE *file) {
-       fprintf(file,"typechecked methods: %8d\n",stat_typechecked);
-       fprintf(file,"    with handler(s): %8d\n",stat_methods_with_handlers);
-       fprintf(file,"    with throw(s)  : %8d\n",stat_methods_maythrow);
-       fprintf(file,"reached blocks     : %8d\n",stat_reached);
-       fprintf(file,"copied states      : %8d\n",stat_copied);
-       fprintf(file,"merged states      : %8d\n",stat_merged);
-       fprintf(file,"merging changed    : %8d\n",stat_merging_changed);
-       fprintf(file,"handlers reached   : %8d\n",stat_handlers_reached);
-       fprintf(file,"saved stack (times): %8d\n",stat_savedstack);
-       fprintf(file,"instructions       : %8d\n",stat_ins);
-       fprintf(file,"    stack          : %8d\n",stat_ins_stack);
-       fprintf(file,"    field access   : %8d\n",stat_ins_field);
-       fprintf(file,"      (unresolved) : %8d\n",stat_ins_field_unresolved);
-       fprintf(file,"      (uninit.)    : %8d\n",stat_ins_field_uninitialized);
-       fprintf(file,"    invocations    : %8d\n",stat_ins_invoke);
-       fprintf(file,"      (unresolved) : %8d\n",stat_ins_invoke_unresolved);
-       fprintf(file,"    load primitive : (currently not counted) %8d\n",stat_ins_primload);
-       fprintf(file,"    load address   : %8d\n",stat_ins_aload);
-       fprintf(file,"    builtins       : %8d\n",stat_ins_builtin);
-       fprintf(file,"        generic    : %8d\n",stat_ins_builtin_gen);
-       fprintf(file,"    branches       : %8d\n",stat_ins_branch);
-       fprintf(file,"    switches       : %8d\n",stat_ins_switch);
-       fprintf(file,"    prim. return   : %8d\n",stat_ins_primitive_return);
-       fprintf(file,"    areturn        : %8d\n",stat_ins_areturn);
-       fprintf(file,"      (unresolved) : %8d\n",stat_ins_areturn_unresolved);
-       fprintf(file,"    athrow         : %8d\n",stat_ins_athrow);
-       fprintf(file,"      (unresolved) : %8d\n",stat_ins_athrow_unresolved);
-       fprintf(file,"    unchecked      : %8d\n",stat_ins_unchecked);
-       fprintf(file,"    maythrow       : %8d\n",stat_ins_maythrow);
-       fprintf(file,"iterations used:\n");
-       print_freq(file,stat_iterations,STAT_ITERATIONS);
-       fprintf(file,"basic blocks per method / 10:\n");
-       print_freq(file,stat_blocks,STAT_BLOCKS);
-       fprintf(file,"locals:\n");
-       print_freq(file,stat_locals,STAT_LOCALS);
-}
-#endif /* defined(TYPECHECK_STATISTICS) */
-
-
-/* typecheck_init_flags ********************************************************
-   Initialize the basic block flags for the following CFG traversal.
-  
-   IN:
-       state............the current state of the verifier
-       minflags.........minimum flags value of blocks that should be
-                        considered
-
-*******************************************************************************/
-
-void typecheck_init_flags(verifier_state *state, s4 minflags)
-{
-       basicblock *block;
-
-    /* set all BBFINISHED blocks to BBTYPECHECK_UNDEF. */
-       
-    for (block = state->basicblocks; block; block = block->next) {
-               
-#ifdef TYPECHECK_DEBUG
-               /* check for invalid flags */
-        if (block->flags != BBFINISHED && block->flags != BBDELETED && block->flags != BBUNDEF)
-        {
-            LOGSTR1("block flags: %d\n",block->flags); LOGFLUSH;
-                       TYPECHECK_ASSERT(false);
-        }
-#endif
-
-        if (block->flags >= minflags) {
-            block->flags = BBTYPECHECK_UNDEF;
-        }
-    }
-
-    /* the first block is always reached */
-       
-    if (state->basicblockcount && state->basicblocks[0].flags == BBTYPECHECK_UNDEF)
-        state->basicblocks[0].flags = BBTYPECHECK_REACHED;
-}
-
-
-/* typecheck_reset_flags *******************************************************
-   Reset the flags of basic blocks we have not reached.
-  
-   IN:
-       state............the current state of the verifier
-
-*******************************************************************************/
-
-void typecheck_reset_flags(verifier_state *state)
-{
-       basicblock *block;
-
-       /* check for invalid flags at exit */
-       
-#ifdef TYPECHECK_DEBUG
-       for (block = state->basicblocks; block; block = block->next) {
-               if (block->flags != BBDELETED
-                       && block->flags != BBUNDEF
-                       && block->flags != BBFINISHED
-                       && block->flags != BBTYPECHECK_UNDEF) /* typecheck may never reach
-                                                                                                        * some exception handlers,
-                                                                                                        * that's ok. */
-               {
-                       LOG2("block L%03d has invalid flags after typecheck: %d",
-                                block->nr,block->flags);
-                       TYPECHECK_ASSERT(false);
-               }
-       }
-#endif
-       
-       /* Delete blocks we never reached */
-       
-       for (block = state->basicblocks; block; block = block->next) {
-               if (block->flags == BBTYPECHECK_UNDEF)
-                       block->flags = BBDELETED;
-       }
-}
-
-
-/****************************************************************************/
-/* TYPESTACK MACROS AND FUNCTIONS                                           */
-/*                                                                          */
-/* These macros and functions act on the 'type stack', which is a shorthand */
-/* for the types of the stackslots of the current stack. The type of a      */
-/* stack slot is usually described by a TYPE_* constant and -- for TYPE_ADR */
-/* -- by the typeinfo of the slot. The only thing that makes the type stack */
-/* more complicated are returnAddresses of local subroutines, because a     */
-/* single stack slot may contain a set of more than one possible return     */
-/* address. This is handled by 'return address sets'. A return address set  */
-/* is kept as a linked list dangling off the typeinfo of the stack slot.    */
-/****************************************************************************/
-
-/* typecheck_copy_types ********************************************************
-
-   Copy the types of the source variables to the destination variables.
-
-   IN:
-          state............current verifier state
-          srcvars..........array of variable indices to copy
-          dstvars..........array of the destination variables
-          n................number of variables to copy
-
-   RETURN VALUE:
-       true.............success
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-bool typecheck_copy_types(verifier_state *state, s4 *srcvars, s4 *dstvars, s4 n)
-{
-       s4 i;
-       varinfo *sv;
-       varinfo *dv;
-       jitdata *jd = state->jd;
-
-       for (i=0; i < n; ++i, ++srcvars, ++dstvars) {
-               sv = VAR(*srcvars);
-               dv = VAR(*dstvars);
-
-               dv->type = sv->type;
-               if (dv->type == TYPE_ADR) {
-                       TYPEINFO_CLONE(sv->typeinfo,dv->typeinfo);
-               }
-       }
-       return true;
-}
-
-
-/* typecheck_merge_types *******************************************************
-
-   Merge the types of the source variables into the destination variables.
-
-   IN:
-       state............current state of the verifier
-          srcvars..........source variable indices
-          dstvars..........destination variable indices
-          n................number of variables
-
-   RETURN VALUE:
-       typecheck_TRUE...the destination variables have been modified
-          typecheck_FALSE..the destination variables are unchanged
-          typecheck_FAIL...an exception has been thrown
-
-*******************************************************************************/
-
-typecheck_result typecheck_merge_types(verifier_state *state,
-                                                                          s4 *srcvars,
-                                                                          s4 *dstvars,
-                                                                          s4 n)
-{
-       s4 i;
-       varinfo *sv;
-       varinfo *dv;
-       jitdata *jd = state->jd;
-       typecheck_result r;
-       bool changed = false;
-
-       for (i=0; i < n; ++i, ++srcvars, ++dstvars) {
-               sv = VAR(*srcvars);
-               dv = VAR(*dstvars);
-
-               if (dv->type != sv->type) {
-                       exceptions_throw_verifyerror(state->m,"Stack type mismatch");
-                       return typecheck_FAIL;
-               }
-               if (dv->type == TYPE_ADR) {
-                       if (TYPEINFO_IS_PRIMITIVE(dv->typeinfo)) {
-                               /* dv has returnAddress type */
-                               if (!TYPEINFO_IS_PRIMITIVE(sv->typeinfo)) {
-                                       exceptions_throw_verifyerror(state->m,"Merging returnAddress with reference");
-                                       return typecheck_FAIL;
-                               }
-                       }
-                       else {
-                               /* dv has reference type */
-                               if (TYPEINFO_IS_PRIMITIVE(sv->typeinfo)) {
-                                       exceptions_throw_verifyerror(state->m,"Merging reference with returnAddress");
-                                       return typecheck_FAIL;
-                               }
-                               r = typeinfo_merge(state->m,&(dv->typeinfo),&(sv->typeinfo));
-                               if (r == typecheck_FAIL)
-                                       return r;
-                               changed |= r;
-                       }
-               }
-       }
-       return changed;
-}
-
-
-/* typestate_merge *************************************************************
-
-   Merge the types of one state into the destination state.
-
-   IN:
-       state............current state of the verifier
-          dstvars..........indices of the destinations invars
-          dstlocals........the destinations inlocals
-          srcvars..........indices of the source's outvars
-          srclocals........the source locals
-          n................number of invars (== number of outvars)
-
-   RETURN VALUE:
-       typecheck_TRUE...destination state has been modified
-          typecheck_FALSE..destination state has not been modified
-          typecheck_FAIL...an exception has been thrown
-
-*******************************************************************************/
-
-typecheck_result typestate_merge(verifier_state *state,
-                                                s4 *srcvars, varinfo *srclocals,
-                                                s4 *dstvars, varinfo *dstlocals,
-                                                s4 n)
-{
-       bool changed = false;
-       typecheck_result r;
-
-       /* The stack is always merged. If there are returnAddresses on
-        * the stack they are ignored in this step. */
-
-       r = typecheck_merge_types(state, srcvars, dstvars, n);
-       if (r == typecheck_FAIL)
-               return r;
-       changed |= r;
-
-       /* merge the locals */
-
-       r = typevector_merge(state->m, dstlocals, srclocals, state->numlocals);
-       if (r == typecheck_FAIL)
-               return r;
-       return changed | r;
-}
-
-
-/* typestate_reach *************************************************************
-
-   Reach a destination block and propagate stack and local variable types
-
-   IN:
-       state............current state of the verifier
-          destblock........destination basic block
-          srcvars..........variable indices of the outvars to propagate
-          srclocals........local variables to propagate
-          n................number of srcvars
-
-   OUT:
-       state->repeat....set to true if the verifier must iterate again
-                           over the basic blocks
-
-   RETURN VALUE:
-       true.............success
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-bool typestate_reach(verifier_state *state,
-                                        basicblock *destblock,
-                                        s4 *srcvars, varinfo *srclocals, s4 n)
-{
-       varinfo *destloc;
-       bool changed = false;
-       typecheck_result r;
-
-       LOG1("reaching block L%03d",destblock->nr);
-       TYPECHECK_COUNT(stat_reached);
-
-       destloc = destblock->inlocals;
-
-       if (destblock->flags == BBTYPECHECK_UNDEF) {
-               /* The destblock has never been reached before */
-
-               TYPECHECK_COUNT(stat_copied);
-               LOG1("block L%03d reached first time",destblock->nr);
-
-               if (!typecheck_copy_types(state, srcvars, destblock->invars, n))
-                       return false;
-               typevector_copy_inplace(srclocals, destloc, state->numlocals);
-               changed = true;
-       }
-       else {
-               /* The destblock has already been reached before */
-
-               TYPECHECK_COUNT(stat_merged);
-               LOG1("block L%03d reached before", destblock->nr);
-
-               r = typestate_merge(state, srcvars, srclocals,
-                               destblock->invars, destblock->inlocals, n);
-               if (r == typecheck_FAIL)
-                       return false;
-               changed = r;
-               TYPECHECK_COUNTIF(changed,stat_merging_changed);
-       }
-
-       if (changed) {
-               LOG("changed!");
-               destblock->flags = BBTYPECHECK_REACHED;
-               if (destblock->nr <= state->bptr->nr) {
-                       LOG("REPEAT!");
-                       state->repeat = true;
-               }
-       }
-       return true;
-}
-
-
-/* typecheck_init_locals *******************************************************
-
-   Initialize the local variables in the verifier state.
-
-   IN:
-       state............the current state of the verifier
-          newthis..........if true, mark the instance in <init> methods as
-                           uninitialized object.
-
-   RETURN VALUE:
-       true.............success,
-          false............an exception has been thrown.
-
-*******************************************************************************/
-
-bool typecheck_init_locals(verifier_state *state, bool newthis)
-{
-       int i;
-       int varindex;
-       varinfo *locals;
-       varinfo *v;
-       jitdata *jd = state->jd;
-       int skip = 0;
-
-       locals = state->basicblocks[0].inlocals;
-
-       /* allocate parameter descriptors if necessary */
-
-       if (!state->m->parseddesc->params)
-               if (!descriptor_params_from_paramtypes(state->m->parseddesc,state->m->flags))
-                       return false;
-
-       /* pre-initialize variables as TYPE_VOID */
-
-       i = state->numlocals;
-       v = locals;
-       while (i--) {
-               v->type = TYPE_VOID;
-               v++;
-       }
-
-    /* if this is an instance method initialize the "this" ref type */
-
-    if (!(state->m->flags & ACC_STATIC)) {
-               varindex = jd->local_map[5*0 + TYPE_ADR];
-               if (varindex != UNUSED) {
-                       if (state->validlocals < 1)
-                               TYPECHECK_VERIFYERROR_bool("Not enough local variables for method arguments");
-                       v = locals + varindex;
-                       v->type = TYPE_ADR;
-                       if (state->initmethod && newthis)
-                               TYPEINFO_INIT_NEWOBJECT(v->typeinfo, NULL);
-                       else
-                               typeinfo_init_classinfo(&(v->typeinfo), state->m->clazz);
-               }
-
-               skip = 1;
-    }
-
-    LOG("'this' argument set.\n");
-
-    /* the rest of the arguments and the return type */
-
-    if (!typeinfo_init_varinfos_from_methoddesc(locals, state->m->parseddesc,
-                                                                                         state->validlocals,
-                                                                                         skip, /* skip 'this' pointer */
-                                                                                         jd->local_map,
-                                                                                         &state->returntype))
-               return false;
-
-    LOG("Arguments set.\n");
-       return true;
-}
-
-
-/*
- * 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/jit/verify/typecheck-common.cpp b/src/vm/jit/verify/typecheck-common.cpp
new file mode 100644 (file)
index 0000000..88f3861
--- /dev/null
@@ -0,0 +1,558 @@
+/* src/vm/jit/verify/typecheck-common.c - shared verifier code
+
+   Copyright (C) 1996-2005, 2006, 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 "vm/types.h"
+#include "vm/global.h"
+
+#include <assert.h>
+
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+
+#include "vm/jit/show.hpp"
+
+#include "typecheck-common.hpp"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/****************************************************************************/
+/* DEBUG HELPERS                                                            */
+/****************************************************************************/
+
+#ifdef TYPECHECK_VERBOSE_OPT
+bool opt_typecheckverbose = false;
+#endif
+
+#if defined(TYPECHECK_VERBOSE) || defined(TYPECHECK_VERBOSE_IMPORTANT)
+
+void typecheck_print_var(FILE *file, jitdata *jd, s4 index)
+{
+       varinfo *var;
+
+       assert(index >= 0 && index < jd->varcount);
+       var = VAR(index);
+       typeinfo_print_type(file, var->type, &(var->typeinfo));
+}
+
+void typecheck_print_vararray(FILE *file, jitdata *jd, s4 *vars, int len)
+{
+       s4 i;
+
+       for (i=0; i<len; ++i) {
+               if (i)
+                       fputc(' ', file);
+               typecheck_print_var(file, jd, *vars++);
+       }
+}
+
+#endif /* defined(TYPECHECK_VERBOSE) || defined(TYPECHECK_VERBOSE_IMPORTANT) */
+
+
+/****************************************************************************/
+/* STATISTICS                                                               */
+/****************************************************************************/
+
+#if defined(TYPECHECK_STATISTICS)
+int stat_typechecked = 0;
+int stat_methods_with_handlers = 0;
+int stat_methods_maythrow = 0;
+int stat_iterations[STAT_ITERATIONS+1] = { 0 };
+int stat_reached = 0;
+int stat_copied = 0;
+int stat_merged = 0;
+int stat_merging_changed = 0;
+int stat_blocks[STAT_BLOCKS+1] = { 0 };
+int stat_locals[STAT_LOCALS+1] = { 0 };
+int stat_ins = 0;
+int stat_ins_maythrow = 0;
+int stat_ins_stack = 0;
+int stat_ins_field = 0;
+int stat_ins_field_unresolved = 0;
+int stat_ins_field_uninitialized = 0;
+int stat_ins_invoke = 0;
+int stat_ins_invoke_unresolved = 0;
+int stat_ins_primload = 0;
+int stat_ins_aload = 0;
+int stat_ins_builtin = 0;
+int stat_ins_builtin_gen = 0;
+int stat_ins_branch = 0;
+int stat_ins_switch = 0;
+int stat_ins_primitive_return = 0;
+int stat_ins_areturn = 0;
+int stat_ins_areturn_unresolved = 0;
+int stat_ins_athrow = 0;
+int stat_ins_athrow_unresolved = 0;
+int stat_ins_unchecked = 0;
+int stat_handlers_reached = 0;
+int stat_savedstack = 0;
+
+static void print_freq(FILE *file,int *array,int limit)
+{
+       int i;
+       for (i=0; i<limit; ++i)
+               fprintf(file,"      %3d: %8d\n",i,array[i]);
+       fprintf(file,"    >=%3d: %8d\n",limit,array[limit]);
+}
+
+void typecheck_print_statistics(FILE *file) {
+       fprintf(file,"typechecked methods: %8d\n",stat_typechecked);
+       fprintf(file,"    with handler(s): %8d\n",stat_methods_with_handlers);
+       fprintf(file,"    with throw(s)  : %8d\n",stat_methods_maythrow);
+       fprintf(file,"reached blocks     : %8d\n",stat_reached);
+       fprintf(file,"copied states      : %8d\n",stat_copied);
+       fprintf(file,"merged states      : %8d\n",stat_merged);
+       fprintf(file,"merging changed    : %8d\n",stat_merging_changed);
+       fprintf(file,"handlers reached   : %8d\n",stat_handlers_reached);
+       fprintf(file,"saved stack (times): %8d\n",stat_savedstack);
+       fprintf(file,"instructions       : %8d\n",stat_ins);
+       fprintf(file,"    stack          : %8d\n",stat_ins_stack);
+       fprintf(file,"    field access   : %8d\n",stat_ins_field);
+       fprintf(file,"      (unresolved) : %8d\n",stat_ins_field_unresolved);
+       fprintf(file,"      (uninit.)    : %8d\n",stat_ins_field_uninitialized);
+       fprintf(file,"    invocations    : %8d\n",stat_ins_invoke);
+       fprintf(file,"      (unresolved) : %8d\n",stat_ins_invoke_unresolved);
+       fprintf(file,"    load primitive : (currently not counted) %8d\n",stat_ins_primload);
+       fprintf(file,"    load address   : %8d\n",stat_ins_aload);
+       fprintf(file,"    builtins       : %8d\n",stat_ins_builtin);
+       fprintf(file,"        generic    : %8d\n",stat_ins_builtin_gen);
+       fprintf(file,"    branches       : %8d\n",stat_ins_branch);
+       fprintf(file,"    switches       : %8d\n",stat_ins_switch);
+       fprintf(file,"    prim. return   : %8d\n",stat_ins_primitive_return);
+       fprintf(file,"    areturn        : %8d\n",stat_ins_areturn);
+       fprintf(file,"      (unresolved) : %8d\n",stat_ins_areturn_unresolved);
+       fprintf(file,"    athrow         : %8d\n",stat_ins_athrow);
+       fprintf(file,"      (unresolved) : %8d\n",stat_ins_athrow_unresolved);
+       fprintf(file,"    unchecked      : %8d\n",stat_ins_unchecked);
+       fprintf(file,"    maythrow       : %8d\n",stat_ins_maythrow);
+       fprintf(file,"iterations used:\n");
+       print_freq(file,stat_iterations,STAT_ITERATIONS);
+       fprintf(file,"basic blocks per method / 10:\n");
+       print_freq(file,stat_blocks,STAT_BLOCKS);
+       fprintf(file,"locals:\n");
+       print_freq(file,stat_locals,STAT_LOCALS);
+}
+#endif /* defined(TYPECHECK_STATISTICS) */
+
+
+/* typecheck_init_flags ********************************************************
+   Initialize the basic block flags for the following CFG traversal.
+  
+   IN:
+       state............the current state of the verifier
+       minflags.........minimum flags value of blocks that should be
+                        considered
+
+*******************************************************************************/
+
+void typecheck_init_flags(verifier_state *state, s4 minflags)
+{
+       basicblock *block;
+
+    /* set all BBFINISHED blocks to BBTYPECHECK_UNDEF. */
+       
+    for (block = state->basicblocks; block; block = block->next) {
+               
+#ifdef TYPECHECK_DEBUG
+               /* check for invalid flags */
+        if (block->flags != BBFINISHED && block->flags != BBDELETED && block->flags != BBUNDEF)
+        {
+            LOGSTR1("block flags: %d\n",block->flags); LOGFLUSH;
+                       TYPECHECK_ASSERT(false);
+        }
+#endif
+
+        if (block->flags >= minflags) {
+            block->flags = BBTYPECHECK_UNDEF;
+        }
+    }
+
+    /* the first block is always reached */
+       
+    if (state->basicblockcount && state->basicblocks[0].flags == BBTYPECHECK_UNDEF)
+        state->basicblocks[0].flags = BBTYPECHECK_REACHED;
+}
+
+
+/* typecheck_reset_flags *******************************************************
+   Reset the flags of basic blocks we have not reached.
+  
+   IN:
+       state............the current state of the verifier
+
+*******************************************************************************/
+
+void typecheck_reset_flags(verifier_state *state)
+{
+       basicblock *block;
+
+       /* check for invalid flags at exit */
+       
+#ifdef TYPECHECK_DEBUG
+       for (block = state->basicblocks; block; block = block->next) {
+               if (block->flags != BBDELETED
+                       && block->flags != BBUNDEF
+                       && block->flags != BBFINISHED
+                       && block->flags != BBTYPECHECK_UNDEF) /* typecheck may never reach
+                                                                                                        * some exception handlers,
+                                                                                                        * that's ok. */
+               {
+                       LOG2("block L%03d has invalid flags after typecheck: %d",
+                                block->nr,block->flags);
+                       TYPECHECK_ASSERT(false);
+               }
+       }
+#endif
+       
+       /* Delete blocks we never reached */
+       
+       for (block = state->basicblocks; block; block = block->next) {
+               if (block->flags == BBTYPECHECK_UNDEF)
+                       block->flags = BBDELETED;
+       }
+}
+
+
+/****************************************************************************/
+/* TYPESTACK MACROS AND FUNCTIONS                                           */
+/*                                                                          */
+/* These macros and functions act on the 'type stack', which is a shorthand */
+/* for the types of the stackslots of the current stack. The type of a      */
+/* stack slot is usually described by a TYPE_* constant and -- for TYPE_ADR */
+/* -- by the typeinfo of the slot. The only thing that makes the type stack */
+/* more complicated are returnAddresses of local subroutines, because a     */
+/* single stack slot may contain a set of more than one possible return     */
+/* address. This is handled by 'return address sets'. A return address set  */
+/* is kept as a linked list dangling off the typeinfo of the stack slot.    */
+/****************************************************************************/
+
+/* typecheck_copy_types ********************************************************
+
+   Copy the types of the source variables to the destination variables.
+
+   IN:
+          state............current verifier state
+          srcvars..........array of variable indices to copy
+          dstvars..........array of the destination variables
+          n................number of variables to copy
+
+   RETURN VALUE:
+       true.............success
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+bool typecheck_copy_types(verifier_state *state, s4 *srcvars, s4 *dstvars, s4 n)
+{
+       s4 i;
+       varinfo *sv;
+       varinfo *dv;
+       jitdata *jd = state->jd;
+
+       for (i=0; i < n; ++i, ++srcvars, ++dstvars) {
+               sv = VAR(*srcvars);
+               dv = VAR(*dstvars);
+
+               dv->type = sv->type;
+               if (dv->type == TYPE_ADR) {
+                       TYPEINFO_CLONE(sv->typeinfo,dv->typeinfo);
+               }
+       }
+       return true;
+}
+
+
+/* typecheck_merge_types *******************************************************
+
+   Merge the types of the source variables into the destination variables.
+
+   IN:
+       state............current state of the verifier
+          srcvars..........source variable indices
+          dstvars..........destination variable indices
+          n................number of variables
+
+   RETURN VALUE:
+       typecheck_TRUE...the destination variables have been modified
+          typecheck_FALSE..the destination variables are unchanged
+          typecheck_FAIL...an exception has been thrown
+
+*******************************************************************************/
+
+typecheck_result typecheck_merge_types(verifier_state *state,
+                                                                          s4 *srcvars,
+                                                                          s4 *dstvars,
+                                                                          s4 n)
+{
+       s4 i;
+       varinfo *sv;
+       varinfo *dv;
+       jitdata *jd = state->jd;
+       typecheck_result r;
+       bool changed = false;
+
+       for (i=0; i < n; ++i, ++srcvars, ++dstvars) {
+               sv = VAR(*srcvars);
+               dv = VAR(*dstvars);
+
+               if (dv->type != sv->type) {
+                       exceptions_throw_verifyerror(state->m,"Stack type mismatch");
+                       return typecheck_FAIL;
+               }
+               if (dv->type == TYPE_ADR) {
+                       if (TYPEINFO_IS_PRIMITIVE(dv->typeinfo)) {
+                               /* dv has returnAddress type */
+                               if (!TYPEINFO_IS_PRIMITIVE(sv->typeinfo)) {
+                                       exceptions_throw_verifyerror(state->m,"Merging returnAddress with reference");
+                                       return typecheck_FAIL;
+                               }
+                       }
+                       else {
+                               /* dv has reference type */
+                               if (TYPEINFO_IS_PRIMITIVE(sv->typeinfo)) {
+                                       exceptions_throw_verifyerror(state->m,"Merging reference with returnAddress");
+                                       return typecheck_FAIL;
+                               }
+                               r = typeinfo_merge(state->m,&(dv->typeinfo),&(sv->typeinfo));
+                               if (r == typecheck_FAIL)
+                                       return r;
+                               changed |= r;
+                       }
+               }
+       }
+       return (typecheck_result) changed;
+}
+
+
+/* typestate_merge *************************************************************
+
+   Merge the types of one state into the destination state.
+
+   IN:
+       state............current state of the verifier
+          dstvars..........indices of the destinations invars
+          dstlocals........the destinations inlocals
+          srcvars..........indices of the source's outvars
+          srclocals........the source locals
+          n................number of invars (== number of outvars)
+
+   RETURN VALUE:
+       typecheck_TRUE...destination state has been modified
+          typecheck_FALSE..destination state has not been modified
+          typecheck_FAIL...an exception has been thrown
+
+*******************************************************************************/
+
+typecheck_result typestate_merge(verifier_state *state,
+                                                s4 *srcvars, varinfo *srclocals,
+                                                s4 *dstvars, varinfo *dstlocals,
+                                                s4 n)
+{
+       bool changed = false;
+       typecheck_result r;
+
+       /* The stack is always merged. If there are returnAddresses on
+        * the stack they are ignored in this step. */
+
+       r = typecheck_merge_types(state, srcvars, dstvars, n);
+       if (r == typecheck_FAIL)
+               return r;
+       changed |= r;
+
+       /* merge the locals */
+
+       r = typevector_merge(state->m, dstlocals, srclocals, state->numlocals);
+       if (r == typecheck_FAIL)
+               return r;
+       return (typecheck_result) (changed | r);
+}
+
+
+/* typestate_reach *************************************************************
+
+   Reach a destination block and propagate stack and local variable types
+
+   IN:
+       state............current state of the verifier
+          destblock........destination basic block
+          srcvars..........variable indices of the outvars to propagate
+          srclocals........local variables to propagate
+          n................number of srcvars
+
+   OUT:
+       state->repeat....set to true if the verifier must iterate again
+                           over the basic blocks
+
+   RETURN VALUE:
+       true.............success
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+bool typestate_reach(verifier_state *state,
+                                        basicblock *destblock,
+                                        s4 *srcvars, varinfo *srclocals, s4 n)
+{
+       varinfo *destloc;
+       bool changed = false;
+       typecheck_result r;
+
+       LOG1("reaching block L%03d",destblock->nr);
+       TYPECHECK_COUNT(stat_reached);
+
+       destloc = destblock->inlocals;
+
+       if (destblock->flags == BBTYPECHECK_UNDEF) {
+               /* The destblock has never been reached before */
+
+               TYPECHECK_COUNT(stat_copied);
+               LOG1("block L%03d reached first time",destblock->nr);
+
+               if (!typecheck_copy_types(state, srcvars, destblock->invars, n))
+                       return false;
+               typevector_copy_inplace(srclocals, destloc, state->numlocals);
+               changed = true;
+       }
+       else {
+               /* The destblock has already been reached before */
+
+               TYPECHECK_COUNT(stat_merged);
+               LOG1("block L%03d reached before", destblock->nr);
+
+               r = typestate_merge(state, srcvars, srclocals,
+                               destblock->invars, destblock->inlocals, n);
+               if (r == typecheck_FAIL)
+                       return false;
+               changed = r;
+               TYPECHECK_COUNTIF(changed,stat_merging_changed);
+       }
+
+       if (changed) {
+               LOG("changed!");
+               destblock->flags = BBTYPECHECK_REACHED;
+               if (destblock->nr <= state->bptr->nr) {
+                       LOG("REPEAT!");
+                       state->repeat = true;
+               }
+       }
+       return true;
+}
+
+
+/* typecheck_init_locals *******************************************************
+
+   Initialize the local variables in the verifier state.
+
+   IN:
+       state............the current state of the verifier
+          newthis..........if true, mark the instance in <init> methods as
+                           uninitialized object.
+
+   RETURN VALUE:
+       true.............success,
+          false............an exception has been thrown.
+
+*******************************************************************************/
+
+bool typecheck_init_locals(verifier_state *state, bool newthis)
+{
+       int i;
+       int varindex;
+       varinfo *locals;
+       varinfo *v;
+       jitdata *jd = state->jd;
+       int skip = 0;
+
+       locals = state->basicblocks[0].inlocals;
+
+       /* allocate parameter descriptors if necessary */
+
+       if (!state->m->parseddesc->params)
+               if (!descriptor_params_from_paramtypes(state->m->parseddesc,state->m->flags))
+                       return false;
+
+       /* pre-initialize variables as TYPE_VOID */
+
+       i = state->numlocals;
+       v = locals;
+       while (i--) {
+               v->type = TYPE_VOID;
+               v++;
+       }
+
+    /* if this is an instance method initialize the "this" ref type */
+
+    if (!(state->m->flags & ACC_STATIC)) {
+               varindex = jd->local_map[5*0 + TYPE_ADR];
+               if (varindex != UNUSED) {
+                       if (state->validlocals < 1)
+                               TYPECHECK_VERIFYERROR_bool("Not enough local variables for method arguments");
+                       v = locals + varindex;
+                       v->type = TYPE_ADR;
+                       if (state->initmethod && newthis)
+                               TYPEINFO_INIT_NEWOBJECT(v->typeinfo, NULL);
+                       else
+                               typeinfo_init_classinfo(&(v->typeinfo), state->m->clazz);
+               }
+
+               skip = 1;
+    }
+
+    LOG("'this' argument set.\n");
+
+    /* the rest of the arguments and the return type */
+
+    if (!typeinfo_init_varinfos_from_methoddesc(locals, state->m->parseddesc,
+                                                                                         state->validlocals,
+                                                                                         skip, /* skip 'this' pointer */
+                                                                                         jd->local_map,
+                                                                                         &state->returntype))
+               return false;
+
+    LOG("Arguments set.\n");
+       return true;
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+/*
+ * 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/jit/verify/typecheck-common.h b/src/vm/jit/verify/typecheck-common.h
deleted file mode 100644 (file)
index fd3f6ab..0000000
+++ /dev/null
@@ -1,308 +0,0 @@
-/* src/vm/jit/verify/typecheck-common.h - internal header for the type checker
-
-   Copyright (C) 1996-2005, 2006, 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 _TYPECHECK_COMMON_H
-#define _TYPECHECK_COMMON_H
-
-#include "config.h"
-#include "vm/types.h"
-#include "vm/global.h"
-
-#include <assert.h>
-
-#include "vm/jit/jit.h"
-
-
-/****************************************************************************/
-/* DEBUG HELPERS                                                            */
-/****************************************************************************/
-
-#ifdef TYPECHECK_DEBUG
-#define TYPECHECK_ASSERT(cond)  assert(cond)
-#else
-#define TYPECHECK_ASSERT(cond)
-#endif
-
-#ifdef TYPECHECK_VERBOSE_OPT
-extern bool opt_typecheckverbose;
-#define DOLOG(action)  do { if (opt_typecheckverbose) {action;} } while(0)
-#else
-#define DOLOG(action)
-#endif
-
-#ifdef TYPECHECK_VERBOSE
-#define TYPECHECK_VERBOSE_IMPORTANT
-#define LOGNL              DOLOG(puts(""))
-#define LOG(str)           DOLOG(puts(str);)
-#define LOG1(str,a)        DOLOG(printf(str,a); LOGNL)
-#define LOG2(str,a,b)      DOLOG(printf(str,a,b); LOGNL)
-#define LOG3(str,a,b,c)    DOLOG(printf(str,a,b,c); LOGNL)
-#define LOGIF(cond,str)    DOLOG(do {if (cond) { puts(str); }} while(0))
-#ifdef  TYPEINFO_DEBUG
-#define LOGINFO(info)      DOLOG(do {typeinfo_print_short(stdout,(info)); LOGNL;} while(0))
-#else
-#define LOGINFO(info)
-#define typevector_print(x,y,z)
-#endif
-#define LOGFLUSH           DOLOG(fflush(stdout))
-#define LOGSTR(str)        DOLOG(printf("%s", str))
-#define LOGSTR1(str,a)     DOLOG(printf(str,a))
-#define LOGSTR2(str,a,b)   DOLOG(printf(str,a,b))
-#define LOGSTR3(str,a,b,c) DOLOG(printf(str,a,b,c))
-#define LOGNAME(c)         DOLOG(class_classref_or_classinfo_print(c))
-#define LOGMETHOD(str,m)   DOLOG(printf("%s", str); method_println(m);)
-#else
-#define LOG(str)
-#define LOG1(str,a)
-#define LOG2(str,a,b)
-#define LOG3(str,a,b,c)
-#define LOGIF(cond,str)
-#define LOGINFO(info)
-#define LOGFLUSH
-#define LOGNL
-#define LOGSTR(str)
-#define LOGSTR1(str,a)
-#define LOGSTR2(str,a,b)
-#define LOGSTR3(str,a,b,c)
-#define LOGNAME(c)
-#define LOGMETHOD(str,m)
-#endif
-
-#ifdef TYPECHECK_VERBOSE_IMPORTANT
-#define LOGimp(str)     DOLOG(puts(str);LOGNL)
-#define LOGimpSTR(str)  DOLOG(puts(str))
-#else
-#define LOGimp(str)
-#define LOGimpSTR(str)
-#endif
-
-#if defined(TYPECHECK_VERBOSE) || defined(TYPECHECK_VERBOSE_IMPORTANT)
-#include <stdio.h>
-void typecheck_print_var(FILE *file, jitdata *jd, s4 index);
-void typecheck_print_vararray(FILE *file, jitdata *jd, s4 *vars, int len);
-#endif
-
-
-/****************************************************************************/
-/* STATISTICS                                                               */
-/****************************************************************************/
-
-#if defined(TYPECHECK_DEBUG) && !defined(TYPECHECK_NO_STATISTICS)
-/*#define TYPECHECK_STATISTICS*/
-#endif
-
-#ifdef TYPECHECK_STATISTICS
-#define STAT_ITERATIONS  10
-#define STAT_BLOCKS      10
-#define STAT_LOCALS      16
-
-extern int stat_typechecked;
-extern int stat_methods_with_handlers;
-extern int stat_methods_maythrow;
-extern int stat_iterations[STAT_ITERATIONS+1];
-extern int stat_reached;
-extern int stat_copied;
-extern int stat_merged;
-extern int stat_merging_changed;
-extern int stat_blocks[STAT_BLOCKS+1];
-extern int stat_locals[STAT_LOCALS+1];
-extern int stat_ins;
-extern int stat_ins_maythrow;
-extern int stat_ins_stack;
-extern int stat_ins_field;
-extern int stat_ins_field_unresolved;
-extern int stat_ins_field_uninitialized;
-extern int stat_ins_invoke;
-extern int stat_ins_invoke_unresolved;
-extern int stat_ins_primload;
-extern int stat_ins_aload;
-extern int stat_ins_builtin;
-extern int stat_ins_builtin_gen;
-extern int stat_ins_branch;
-extern int stat_ins_switch;
-extern int stat_ins_primitive_return;
-extern int stat_ins_areturn;
-extern int stat_ins_areturn_unresolved;
-extern int stat_ins_athrow;
-extern int stat_ins_athrow_unresolved;
-extern int stat_ins_unchecked;
-extern int stat_handlers_reached;
-extern int stat_savedstack;
-
-#define TYPECHECK_MARK(var)   ((var) = true)
-#define TYPECHECK_COUNT(cnt)  (cnt)++
-#define TYPECHECK_COUNTIF(cond,cnt)  do{if(cond) (cnt)++;} while(0)
-#define TYPECHECK_COUNT_FREQ(array,val,limit) \
-       do {                                                                      \
-               if ((val) < (limit)) (array)[val]++;  \
-               else (array)[limit]++;                            \
-       } while (0)
-
-void typecheck_print_statistics(FILE *file);
-
-#else /* !defined(TYPECHECK_STATISTICS) */
-                                                  
-#define TYPECHECK_COUNT(cnt)
-#define TYPECHECK_MARK(var)
-#define TYPECHECK_COUNTIF(cond,cnt)
-#define TYPECHECK_COUNT_FREQ(array,val,limit)
-
-#endif /* defined(TYPECHECK_STATISTICS) */
-
-
-/****************************************************************************/
-/* MACROS FOR THROWING EXCEPTIONS                                           */
-/****************************************************************************/
-
-#define TYPECHECK_VERIFYERROR_ret(m,msg,retval)                      \
-    do {                                                             \
-        exceptions_throw_verifyerror((m), (msg));                    \
-        return (retval);                                             \
-    } while (0)
-
-#define TYPECHECK_VERIFYERROR_main(msg)  TYPECHECK_VERIFYERROR_ret(state.m,(msg),NULL)
-#define TYPECHECK_VERIFYERROR_bool(msg)  TYPECHECK_VERIFYERROR_ret(state->m,(msg),false)
-
-
-/****************************************************************************/
-/* MISC MACROS                                                              */
-/****************************************************************************/
-
-#define COPYTYPE(source,dest)                                        \
-    {if (VAROP(source)->type == TYPE_ADR)                            \
-            TYPEINFO_COPY(VAROP(source)->typeinfo,VAROP(dest)->typeinfo);}
-
-
-/****************************************************************************/
-/* JSR VERIFICATION (stack-based verifier)                                  */
-/****************************************************************************/
-
-typedef struct typecheck_jsr_t typecheck_jsr_t;
-typedef struct typecheck_jsr_caller_t typecheck_jsr_caller_t;
-
-struct typecheck_jsr_caller_t {
-       typecheck_jsr_caller_t *next;                   /* next in linked list */
-       basicblock *callblock;             /* block containing the calling JSR */
-};
-
-struct typecheck_jsr_t {
-       typecheck_jsr_t *next;               /* next (lower) in the call chain */
-       basicblock  *start;                                   /* for debugging */
-       typecheck_jsr_caller_t *callers;  /* list of callers (blocks with JSR) */
-       basicblock  *retblock;              /* block with the RET for this sub */
-       bool         active;           /* true if this sub is currently active */
-       char        *blockflags;   /* saved block flags when JSR was traversed */
-       char        *usedlocals;       /* != 0 for each local used in this sub */
-       typedescriptor_t *retlocals;                 /* locals on the RET edge */
-       typedescriptor_t *retstack;                   /* stack on the RET edge */
-       s4              retdepth;               /* stack depth on the RET edge */
-};
-
-/****************************************************************************/
-/* VERIFIER STATE STRUCT                                                    */
-/****************************************************************************/
-
-/* verifier_state - This structure keeps the current state of the      */
-/* bytecode verifier for passing it between verifier functions.        */
-
-typedef struct verifier_state {
-    instruction *iptr;               /* pointer to current instruction */
-    basicblock *bptr;                /* pointer to current basic block */
-
-       methodinfo *m;                               /* the current method */
-       jitdata *jd;                         /* jitdata for current method */
-       codegendata *cd;                 /* codegendata for current method */
-
-       basicblock *basicblocks;
-       s4 basicblockcount;
-       
-       s4 numlocals;                         /* number of local variables */
-       s4 validlocals;                /* number of Java-accessible locals */
-       
-       typedescriptor_t returntype;  /* return type of the current method */
-
-       s4 *savedindices;
-       s4 *savedinvars;                            /* saved invar pointer */
-
-       s4 exinvars;
-       
-    exception_entry **handlers;           /* active exception handlers */
-       
-    bool repeat;            /* if true, blocks are iterated over again */
-    bool initmethod;             /* true if this is an "<init>" method */
-
-#ifdef TYPECHECK_STATISTICS
-       bool stat_maythrow;          /* at least one instruction may throw */
-#endif
-
-       /* the following fields are used by the stackbased verifier only:  */
-
-       typedescriptor_t *locals;               /* current local variables */
-       typedescriptor_t *startlocals;/* locals at the start of each block */
-       typedescriptor_t *startstack;  /* stack at the start of each block */
-       s4               *indepth;                /* stack depth at --''-- */
-       typedescriptor_t *stackceiling;    /* upper edge of verifier stack */
-
-       typecheck_jsr_t *topjsr;        /* most recently called subroutine */
-       typecheck_jsr_t **jsrinfos;      /* subroutine info for each block */
-} verifier_state;
-
-void typecheck_init_flags(verifier_state *state, s4 minflags);
-void typecheck_reset_flags(verifier_state *state);
-
-bool typecheck_copy_types(verifier_state *state,
-                                                 s4 *srcvars, s4 *dstvars, s4 n);
-
-typecheck_result typecheck_merge_types(verifier_state *state,
-                                                                          s4 *srcvars,
-                                                                          s4 *dstvars,
-                                                                          s4 n);
-
-typecheck_result typestate_merge(verifier_state *state,
-                                                s4 *srcvars, varinfo *srclocals,
-                                                s4 *dstvars, varinfo *dstlocals,
-                                                s4 n);
-
-bool typestate_reach(verifier_state *state,
-                                        basicblock *destblock,
-                                        s4 *srcvars, varinfo *srclocals, s4 n);
-
-bool typecheck_init_locals(verifier_state *state, bool newthis);
-
-#endif /* _TYPECHECK_COMMON_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/jit/verify/typecheck-common.hpp b/src/vm/jit/verify/typecheck-common.hpp
new file mode 100644 (file)
index 0000000..f6cb2e4
--- /dev/null
@@ -0,0 +1,315 @@
+/* src/vm/jit/verify/typecheck-common.h - internal header for the type checker
+
+   Copyright (C) 1996-2005, 2006, 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 _TYPECHECK_COMMON_H
+#define _TYPECHECK_COMMON_H
+
+#include "config.h"
+#include "vm/types.h"
+#include "vm/global.h"
+
+#include <assert.h>
+
+#include "vm/jit/jit.hpp"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/****************************************************************************/
+/* DEBUG HELPERS                                                            */
+/****************************************************************************/
+
+#ifdef TYPECHECK_DEBUG
+#define TYPECHECK_ASSERT(cond)  assert(cond)
+#else
+#define TYPECHECK_ASSERT(cond)
+#endif
+
+#ifdef TYPECHECK_VERBOSE_OPT
+extern bool opt_typecheckverbose;
+#define DOLOG(action)  do { if (opt_typecheckverbose) {action;} } while(0)
+#else
+#define DOLOG(action)
+#endif
+
+#ifdef TYPECHECK_VERBOSE
+#define TYPECHECK_VERBOSE_IMPORTANT
+#define LOGNL              DOLOG(puts(""))
+#define LOG(str)           DOLOG(puts(str);)
+#define LOG1(str,a)        DOLOG(printf(str,a); LOGNL)
+#define LOG2(str,a,b)      DOLOG(printf(str,a,b); LOGNL)
+#define LOG3(str,a,b,c)    DOLOG(printf(str,a,b,c); LOGNL)
+#define LOGIF(cond,str)    DOLOG(do {if (cond) { puts(str); }} while(0))
+#ifdef  TYPEINFO_DEBUG
+#define LOGINFO(info)      DOLOG(do {typeinfo_print_short(stdout,(info)); LOGNL;} while(0))
+#else
+#define LOGINFO(info)
+#define typevector_print(x,y,z)
+#endif
+#define LOGFLUSH           DOLOG(fflush(stdout))
+#define LOGSTR(str)        DOLOG(printf("%s", str))
+#define LOGSTR1(str,a)     DOLOG(printf(str,a))
+#define LOGSTR2(str,a,b)   DOLOG(printf(str,a,b))
+#define LOGSTR3(str,a,b,c) DOLOG(printf(str,a,b,c))
+#define LOGNAME(c)         DOLOG(class_classref_or_classinfo_print(c))
+#define LOGMETHOD(str,m)   DOLOG(printf("%s", str); method_println(m);)
+#else
+#define LOG(str)
+#define LOG1(str,a)
+#define LOG2(str,a,b)
+#define LOG3(str,a,b,c)
+#define LOGIF(cond,str)
+#define LOGINFO(info)
+#define LOGFLUSH
+#define LOGNL
+#define LOGSTR(str)
+#define LOGSTR1(str,a)
+#define LOGSTR2(str,a,b)
+#define LOGSTR3(str,a,b,c)
+#define LOGNAME(c)
+#define LOGMETHOD(str,m)
+#endif
+
+#ifdef TYPECHECK_VERBOSE_IMPORTANT
+#define LOGimp(str)     DOLOG(puts(str);LOGNL)
+#define LOGimpSTR(str)  DOLOG(puts(str))
+#else
+#define LOGimp(str)
+#define LOGimpSTR(str)
+#endif
+
+#if defined(TYPECHECK_VERBOSE) || defined(TYPECHECK_VERBOSE_IMPORTANT)
+#include <stdio.h>
+void typecheck_print_var(FILE *file, jitdata *jd, s4 index);
+void typecheck_print_vararray(FILE *file, jitdata *jd, s4 *vars, int len);
+#endif
+
+
+/****************************************************************************/
+/* STATISTICS                                                               */
+/****************************************************************************/
+
+#if defined(TYPECHECK_DEBUG) && !defined(TYPECHECK_NO_STATISTICS)
+/*#define TYPECHECK_STATISTICS*/
+#endif
+
+#ifdef TYPECHECK_STATISTICS
+#define STAT_ITERATIONS  10
+#define STAT_BLOCKS      10
+#define STAT_LOCALS      16
+
+extern int stat_typechecked;
+extern int stat_methods_with_handlers;
+extern int stat_methods_maythrow;
+extern int stat_iterations[STAT_ITERATIONS+1];
+extern int stat_reached;
+extern int stat_copied;
+extern int stat_merged;
+extern int stat_merging_changed;
+extern int stat_blocks[STAT_BLOCKS+1];
+extern int stat_locals[STAT_LOCALS+1];
+extern int stat_ins;
+extern int stat_ins_maythrow;
+extern int stat_ins_stack;
+extern int stat_ins_field;
+extern int stat_ins_field_unresolved;
+extern int stat_ins_field_uninitialized;
+extern int stat_ins_invoke;
+extern int stat_ins_invoke_unresolved;
+extern int stat_ins_primload;
+extern int stat_ins_aload;
+extern int stat_ins_builtin;
+extern int stat_ins_builtin_gen;
+extern int stat_ins_branch;
+extern int stat_ins_switch;
+extern int stat_ins_primitive_return;
+extern int stat_ins_areturn;
+extern int stat_ins_areturn_unresolved;
+extern int stat_ins_athrow;
+extern int stat_ins_athrow_unresolved;
+extern int stat_ins_unchecked;
+extern int stat_handlers_reached;
+extern int stat_savedstack;
+
+#define TYPECHECK_MARK(var)   ((var) = true)
+#define TYPECHECK_COUNT(cnt)  (cnt)++
+#define TYPECHECK_COUNTIF(cond,cnt)  do{if(cond) (cnt)++;} while(0)
+#define TYPECHECK_COUNT_FREQ(array,val,limit) \
+       do {                                                                      \
+               if ((val) < (limit)) (array)[val]++;  \
+               else (array)[limit]++;                            \
+       } while (0)
+
+void typecheck_print_statistics(FILE *file);
+
+#else /* !defined(TYPECHECK_STATISTICS) */
+                                                  
+#define TYPECHECK_COUNT(cnt)
+#define TYPECHECK_MARK(var)
+#define TYPECHECK_COUNTIF(cond,cnt)
+#define TYPECHECK_COUNT_FREQ(array,val,limit)
+
+#endif /* defined(TYPECHECK_STATISTICS) */
+
+
+/****************************************************************************/
+/* MACROS FOR THROWING EXCEPTIONS                                           */
+/****************************************************************************/
+
+#define TYPECHECK_VERIFYERROR_ret(m,msg,retval)                      \
+    do {                                                             \
+        exceptions_throw_verifyerror((m), (msg));                    \
+        return (retval);                                             \
+    } while (0)
+
+#define TYPECHECK_VERIFYERROR_main(msg)  TYPECHECK_VERIFYERROR_ret(state.m,(msg),NULL)
+#define TYPECHECK_VERIFYERROR_bool(msg)  TYPECHECK_VERIFYERROR_ret(state->m,(msg),false)
+
+
+/****************************************************************************/
+/* MISC MACROS                                                              */
+/****************************************************************************/
+
+#define COPYTYPE(source,dest)                                        \
+    {if (VAROP(source)->type == TYPE_ADR)                            \
+            TYPEINFO_COPY(VAROP(source)->typeinfo,VAROP(dest)->typeinfo);}
+
+
+/****************************************************************************/
+/* JSR VERIFICATION (stack-based verifier)                                  */
+/****************************************************************************/
+
+typedef struct typecheck_jsr_t typecheck_jsr_t;
+typedef struct typecheck_jsr_caller_t typecheck_jsr_caller_t;
+
+struct typecheck_jsr_caller_t {
+       typecheck_jsr_caller_t *next;                   /* next in linked list */
+       basicblock *callblock;             /* block containing the calling JSR */
+};
+
+struct typecheck_jsr_t {
+       typecheck_jsr_t *next;               /* next (lower) in the call chain */
+       basicblock  *start;                                   /* for debugging */
+       typecheck_jsr_caller_t *callers;  /* list of callers (blocks with JSR) */
+       basicblock  *retblock;              /* block with the RET for this sub */
+       bool         active;           /* true if this sub is currently active */
+       char        *blockflags;   /* saved block flags when JSR was traversed */
+       char        *usedlocals;       /* != 0 for each local used in this sub */
+       typedescriptor_t *retlocals;                 /* locals on the RET edge */
+       typedescriptor_t *retstack;                   /* stack on the RET edge */
+       s4              retdepth;               /* stack depth on the RET edge */
+};
+
+/****************************************************************************/
+/* VERIFIER STATE STRUCT                                                    */
+/****************************************************************************/
+
+/* verifier_state - This structure keeps the current state of the      */
+/* bytecode verifier for passing it between verifier functions.        */
+
+typedef struct verifier_state {
+    instruction *iptr;               /* pointer to current instruction */
+    basicblock *bptr;                /* pointer to current basic block */
+
+       methodinfo *m;                               /* the current method */
+       jitdata *jd;                         /* jitdata for current method */
+       codegendata *cd;                 /* codegendata for current method */
+
+       basicblock *basicblocks;
+       s4 basicblockcount;
+       
+       s4 numlocals;                         /* number of local variables */
+       s4 validlocals;                /* number of Java-accessible locals */
+       
+       typedescriptor_t returntype;  /* return type of the current method */
+
+       s4 *savedindices;
+       s4 *savedinvars;                            /* saved invar pointer */
+
+       s4 exinvars;
+       
+    exception_entry **handlers;           /* active exception handlers */
+       
+    bool repeat;            /* if true, blocks are iterated over again */
+    bool initmethod;             /* true if this is an "<init>" method */
+
+#ifdef TYPECHECK_STATISTICS
+       bool stat_maythrow;          /* at least one instruction may throw */
+#endif
+
+       /* the following fields are used by the stackbased verifier only:  */
+
+       typedescriptor_t *locals;               /* current local variables */
+       typedescriptor_t *startlocals;/* locals at the start of each block */
+       typedescriptor_t *startstack;  /* stack at the start of each block */
+       s4               *indepth;                /* stack depth at --''-- */
+       typedescriptor_t *stackceiling;    /* upper edge of verifier stack */
+
+       typecheck_jsr_t *topjsr;        /* most recently called subroutine */
+       typecheck_jsr_t **jsrinfos;      /* subroutine info for each block */
+} verifier_state;
+
+void typecheck_init_flags(verifier_state *state, s4 minflags);
+void typecheck_reset_flags(verifier_state *state);
+
+bool typecheck_copy_types(verifier_state *state,
+                                                 s4 *srcvars, s4 *dstvars, s4 n);
+
+typecheck_result typecheck_merge_types(verifier_state *state,
+                                                                          s4 *srcvars,
+                                                                          s4 *dstvars,
+                                                                          s4 n);
+
+typecheck_result typestate_merge(verifier_state *state,
+                                                s4 *srcvars, varinfo *srclocals,
+                                                s4 *dstvars, varinfo *dstlocals,
+                                                s4 n);
+
+bool typestate_reach(verifier_state *state,
+                                        basicblock *destblock,
+                                        s4 *srcvars, varinfo *srclocals, s4 n);
+
+bool typecheck_init_locals(verifier_state *state, bool newthis);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* _TYPECHECK_COMMON_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/jit/verify/typecheck-stackbased.c b/src/vm/jit/verify/typecheck-stackbased.c
deleted file mode 100644 (file)
index 5141dd8..0000000
+++ /dev/null
@@ -1,1025 +0,0 @@
-/* src/vm/jit/verify/typecheck-stackbased.c - stack-based verifier
-
-   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 "vm/types.h"
-
-#include "vm/builtin.h"
-#include "mm/memory.h"
-
-#include "vm/array.h"
-#include "vm/global.h"
-#include "vm/primitive.h"
-
-#include "vm/jit/parse.h"
-#include "vm/jit/show.h"
-#include "vm/jit/stack.h"
-#include "vm/jit/verify/typecheck-common.h"
-
-
-/* this #if runs over the whole file: */
-#if defined(ENABLE_VERIFIER)
-
-typedef typedescriptor_t verifier_slot_t;
-
-#if defined(TYPECHECK_VERBOSE)
-static void typecheck_stackbased_show_state(verifier_state *state,
-                                                                                       typedescriptor *stack,
-                                                                                       typedescriptor *stackfloor,
-                                                                                       bool showins);
-#endif
-
-
-#define CHECK_STACK_DEPTH(d)                                         \
-    if (((u1*)stack - (u1*)stackfloor)                               \
-            < (((d)-1) * (int)sizeof(verifier_slot_t)))              \
-        goto throw_stack_underflow;
-
-/* XXX don't need to check against ACONST for every ICMD */
-#define CHECK_STACK_SPACE(d)                                         \
-    if (((u1*)STATE->stackceiling - (u1*)stack)                      \
-            < (((d)+1) * (int)sizeof(verifier_slot_t)))              \
-        if (STATE->iptr->opc != ICMD_ACONST                          \
-                || INSTRUCTION_MUST_CHECK(STATE->iptr))              \
-            goto throw_stack_overflow;
-
-#define CHECK_STACK_TYPE(s, t)                                       \
-    if ((s).type != (t))                                             \
-        goto throw_stack_type_error;
-
-/* XXX inefficient */
-#define CHECK_LOCAL_TYPE(index, t)                                   \
-    do {                                                             \
-        if (state.locals[(index)].type != (t))                       \
-            goto throw_local_type_error;                             \
-        if (STATE->topjsr)                                           \
-            STATE->topjsr->usedlocals[(index)] = 1;                  \
-        if (STATE->topjsr && IS_2_WORD_TYPE(t))                      \
-            STATE->topjsr->usedlocals[(index) + 1] = 1;              \
-    } while(0)
-
-/* XXX inefficient */
-#define STORE_LOCAL(t, index)                                        \
-    do {                                                             \
-        state.locals[(index)].type = (t);                            \
-        if ((index) && IS_2_WORD_TYPE(state.locals[(index)-1].type)) \
-            state.locals[(index-1)].type = TYPE_VOID;                \
-        if (STATE->topjsr)                                           \
-            STATE->topjsr->usedlocals[(index)] = 1;                  \
-    } while (0)
-
-/* XXX inefficient */
-#define STORE_LOCAL_2_WORD(t, index)                                 \
-    do {                                                             \
-        STORE_LOCAL(t, index);                                       \
-        state.locals[(index)+1].type = TYPE_VOID;                    \
-        if (STATE->topjsr)                                           \
-            STATE->topjsr->usedlocals[(index)] = 1;                  \
-    } while (0)
-
-#define VERIFY_ERROR(msg)                                            \
-    do {                                                             \
-        LOG1("VerifyError: %s", msg);                                \
-        exceptions_throw_verifyerror(STATE->m, msg);                 \
-        return false;                                                \
-    } while (0)
-
-#define IS_CAT1(slot)                                                \
-    ((slot).type != TYPE_VOID && !IS_2_WORD_TYPE((slot).type))
-
-#define IS_CAT2(slot)                                                \
-    ((slot).type != TYPE_VOID && IS_2_WORD_TYPE((slot).type))
-
-#define CHECK_CAT1(slot)                                             \
-    do {                                                             \
-        if (!IS_CAT1(slot))                                          \
-            goto throw_stack_category_error;                         \
-    } while (0)
-
-#define CHECK_CAT2(slot)                                             \
-    do {                                                             \
-        if (!IS_CAT2(slot))                                          \
-            goto throw_stack_category_error;                         \
-    } while (0)
-
-#define COPY_SLOT(s, d)                                              \
-    do { (d) = (s); } while (0)
-
-#define REACH_BLOCK(target)                                          \
-    do {                                                             \
-        if (!typecheck_stackbased_reach(STATE, (target), stack,      \
-                    (stack - stackfloor) + 1))                       \
-            return false;                                            \
-    } while (0)
-
-#define REACH(target)                                                \
-    do {                                                             \
-        REACH_BLOCK((target).block);                                 \
-    } while (0)
-
-#undef TYPECHECK_INT
-#undef TYPECHECK_LNG
-#undef TYPECHECK_FLT
-#undef TYPECHECK_DBL
-#undef TYPECHECK_ADR
-
-/* XXX should reuse typevector code */
-static typecheck_result typecheck_stackbased_merge_locals(methodinfo *m,
-                                                                                                                 typedescriptor_t *dst,
-                                                                                                                 typedescriptor_t *y,
-                                                                                                                 int size)
-{
-       bool changed = false;
-       typecheck_result r;
-
-       typedescriptor_t *a = dst;
-       typedescriptor_t *b = y;
-       while (size--) {
-               if (a->type != TYPE_VOID && a->type != b->type) {
-                       a->type = TYPE_VOID;
-                       changed = true;
-               }
-               else if (a->type == TYPE_ADR) {
-                       if (TYPEINFO_IS_PRIMITIVE(a->typeinfo)) {
-                               /* 'a' is a returnAddress */
-                               if (!TYPEINFO_IS_PRIMITIVE(b->typeinfo)
-                                       || (TYPEINFO_RETURNADDRESS(a->typeinfo)
-                                               != TYPEINFO_RETURNADDRESS(b->typeinfo)))
-                               {
-                                       a->type = TYPE_VOID;
-                                       changed = true;
-                               }
-                       }
-                       else {
-                               /* 'a' is a reference */
-                               if (TYPEINFO_IS_PRIMITIVE(b->typeinfo)) {
-                                       a->type = TYPE_VOID;
-                                       changed = true;
-                               }
-                               else {
-                                       /* two reference types are merged. There cannot be */
-                                       /* a merge error. In the worst case we get j.l.O.  */
-                                       r = typeinfo_merge(m,&(a->typeinfo),&(b->typeinfo));
-                                       if (r == typecheck_FAIL)
-                                               return r;
-                                       changed |= r;
-                               }
-                       }
-               }
-               a++;
-               b++;
-       }
-       return changed;
-}
-
-static typecheck_result typecheck_stackbased_merge(verifier_state *state,
-                                                                                                  basicblock *destblock,
-                                                                                                  typedescriptor_t *stack,
-                                                                                                  s4 stackdepth)
-{
-       s4 i;
-       s4 destidx;
-       typedescriptor_t *stackfloor;
-       typedescriptor_t *sp;
-       typedescriptor_t *dp;
-       typecheck_result r;
-       bool changed = false;
-
-       destidx = destblock->nr;
-
-       if (stackdepth != state->indepth[destidx]) {
-               exceptions_throw_verifyerror(state->m, "Stack depth mismatch");
-               return typecheck_FAIL;
-       }
-
-       stackfloor = stack - (stackdepth - 1);
-
-       sp = stackfloor;
-       dp = state->startstack + (destidx * state->m->maxstack);
-
-       for (i=0; i<stackdepth; ++i, ++sp, ++dp) {
-               if (sp->type != dp->type) {
-                       exceptions_throw_verifyerror(state->m, "Mismatched stack types");
-                       return typecheck_FAIL;
-               }
-               if (dp->type == TYPE_ADR) {
-                       if (TYPEINFO_IS_PRIMITIVE(dp->typeinfo)) {
-                               /* dp has returnAddress type */
-                               if (TYPEINFO_IS_PRIMITIVE(sp->typeinfo)) {
-                                       if (TYPEINFO_RETURNADDRESS(dp->typeinfo) != TYPEINFO_RETURNADDRESS(sp->typeinfo)) {
-                                               exceptions_throw_verifyerror(state->m, "Mismatched stack types");
-                                               return typecheck_FAIL;
-                                       }
-                               }
-                               else {
-                                       exceptions_throw_verifyerror(state->m,"Merging returnAddress with reference");
-                                       return typecheck_FAIL;
-                               }
-                       }
-                       else {
-                               /* dp has reference type */
-                               if (TYPEINFO_IS_PRIMITIVE(sp->typeinfo)) {
-                                       exceptions_throw_verifyerror(state->m,"Merging reference with returnAddress");
-                                       return typecheck_FAIL;
-                               }
-                               r = typeinfo_merge(state->m,&(dp->typeinfo),&(sp->typeinfo));
-                               if (r == typecheck_FAIL)
-                                       return r;
-                               changed |= r;
-                       }
-               }
-       }
-
-       dp = state->startlocals + (destidx * state->numlocals);
-       r = typecheck_stackbased_merge_locals(state->m, dp, state->locals, state->numlocals);
-       if (r == typecheck_FAIL)
-               return r;
-       changed |= r;
-
-       return changed;
-}
-
-static bool typecheck_stackbased_reach(verifier_state *state,
-                                                                          basicblock *destblock,
-                                                                          typedescriptor_t *stack,
-                                                                          s4 stackdepth)
-{
-       bool changed = false;
-       typecheck_result r;
-
-       assert(destblock);
-
-       if (destblock->flags == BBTYPECHECK_UNDEF) {
-               /* The destblock has never been reached before */
-
-               TYPECHECK_COUNT(stat_copied);
-               LOG1("block L%03d reached first time",destblock->nr); LOGSTR("\t");
-               DOLOG( typecheck_stackbased_show_state(state, stack, stack - (stackdepth - 1), false); );
-
-               state->indepth[destblock->nr] = stackdepth;
-
-               MCOPY(state->startstack + (destblock->nr * state->m->maxstack),
-                         stack - (stackdepth - 1),
-                         typedescriptor_t,
-                         stackdepth);
-
-               MCOPY(state->startlocals + (destblock->nr * state->numlocals),
-                         state->locals,
-                         typedescriptor_t,
-                         state->numlocals);
-
-               changed = true;
-       }
-       else {
-               /* The destblock has already been reached before */
-
-               TYPECHECK_COUNT(stat_merged);
-               LOG1("block L%03d reached before", destblock->nr); LOGSTR("\t");
-               DOLOG( typecheck_stackbased_show_state(state, stack, stack - (stackdepth - 1), false); );
-
-               r = typecheck_stackbased_merge(state, destblock, stack, stackdepth);
-               if (r == typecheck_FAIL)
-                       return false;
-               changed = r;
-
-               TYPECHECK_COUNTIF(changed,stat_merging_changed);
-       }
-
-       if (changed) {
-               LOG("\tchanged!");
-               destblock->flags = BBTYPECHECK_REACHED;
-               /* XXX is this check ok? */
-               if (destblock->nr <= state->bptr->nr) {
-                       LOG("\tREPEAT!");
-                       state->repeat = true;
-               }
-       }
-       return true;
-}
-
-
-/* typecheck_stackbased_verify_fieldaccess *************************************
-
-   Verify an ICMD_{GET,PUT}{STATIC,FIELD}
-
-   IN:
-       state............the current state of the verifier
-          instance.........the instance slot, or NULL
-          value............the value slot, or NULL
-          stack............stack after popping the arguments
-
-   RETURN VALUE:
-       stack pointer....successful verification,
-          NULL.............an exception has been thrown.
-
-*******************************************************************************/
-
-static typedescriptor_t *typecheck_stackbased_verify_fieldaccess(
-               verifier_state *state,
-               typedescriptor_t *instance,
-               typedescriptor_t *value,
-               typedescriptor_t *stack)
-{
-       jitdata *jd;
-
-       jd = state->jd;
-
-#define TYPECHECK_STACKBASED
-#define EXCEPTION  do { return NULL; } while (0)
-#define STATE  state
-#include <typecheck-fields.inc>
-#undef  EXCEPTION
-#undef  STATE
-#undef  TYPECHECK_STACKBASED
-
-       return stack;
-
-throw_stack_overflow:
-       LOG("STACK OVERFLOW!");
-       exceptions_throw_verifyerror(state->m, "Stack size too large");
-       return NULL;
-}
-
-static bool typecheck_stackbased_verify_invocation(verifier_state *state,
-                                                                                                  typedescriptor_t *stack,
-                                                                                                  typedescriptor_t *stackfloor)
-{
-       s4 paramslots;
-       methoddesc *md;
-       typedescriptor_t *dv;
-
-       /* check stack depth */
-
-       /* XXX parse params */
-
-       INSTRUCTION_GET_METHODDESC(state->iptr, md);
-
-       paramslots = md->paramslots;
-
-       if ((stack - stackfloor) + 1 < paramslots) {
-               exceptions_throw_verifyerror(state->m, 
-                               "Trying to pop operand of an empty stack");
-               return false;
-       }
-
-       dv = stack - (paramslots - 1);
-
-#define TYPECHECK_STACKBASED
-#define OP1   dv
-#include <typecheck-invoke.inc>
-#undef  OP1
-#undef  TYPECHECK_STACKBASED
-
-       return true;
-}
-
-static bool typecheck_stackbased_verify_builtin(verifier_state *state,
-                                                                                               typedescriptor_t *stack,
-                                                                                               typedescriptor_t *stackfloor)
-{
-       s4 paramslots;
-       typedescriptor_t *dv;
-
-       /* check stack depth */
-
-       /* XXX parse params */
-
-       paramslots = state->iptr->sx.s23.s3.bte->md->paramslots;
-
-       if ((stack - stackfloor) + 1 < paramslots) {
-               exceptions_throw_verifyerror(state->m, 
-                               "Trying to pop operand of an empty stack");
-               return false;
-       }
-
-       dv = stack - (paramslots - 1);
-
-#define TYPECHECK_STACKBASED
-#define OP1   dv
-#define TYPECHECK_INT(s)  CHECK_STACK_TYPE(*(s), TYPE_INT)
-#define TYPECHECK_ADR(s)  CHECK_STACK_TYPE(*(s), TYPE_ADR)
-#define TYPECHECK_LNG(s)  CHECK_STACK_TYPE(*(s), TYPE_LNG)
-#define TYPECHECK_FLT(s)  CHECK_STACK_TYPE(*(s), TYPE_FLT)
-#define TYPECHECK_DBL(s)  CHECK_STACK_TYPE(*(s), TYPE_DBL)
-#include <typecheck-builtins.inc>
-#undef  OP1
-#undef  TYPECHECK_STACKBASED
-
-       return true;
-
-throw_stack_type_error:
-       exceptions_throw_verifyerror(state->m, "Wrong type on stack"); /* XXX */
-       return false;
-}
-
-static bool typecheck_stackbased_multianewarray(verifier_state *state,
-                                                                                               typedescriptor_t *stack,
-                                                                                               typedescriptor_t *stackfloor)
-{
-       /* XXX recombine with verify_multianewarray */
-
-       classinfo *arrayclass;
-       arraydescriptor *desc;
-       s4 i;
-       typedescriptor_t *sp;
-       typedescriptor_t *dst;
-
-       /* destination slot */
-
-       i = state->iptr->s1.argcount;
-
-       dst = stack - (i-1);
-
-       /* check the array lengths on the stack */
-
-       if ((stack - stackfloor) + 1 < i) {
-               exceptions_throw_verifyerror(state->m, 
-                               "Trying to pop operand of an empty stack");
-               return false;
-       }
-
-       if (i < 1)
-               TYPECHECK_VERIFYERROR_bool("Illegal dimension argument");
-
-       for (sp = dst; sp <= stack; ++sp) {
-               if (sp->type != TYPE_INT) {
-                       exceptions_throw_verifyerror_for_stack(state->m, TYPE_INT);
-                       return false;
-               }
-       }
-
-       /* check array descriptor */
-
-       if (INSTRUCTION_IS_RESOLVED(state->iptr)) {
-               /* the array class reference has already been resolved */
-               arrayclass = state->iptr->sx.s23.s3.c.cls;
-               if (!arrayclass)
-                       TYPECHECK_VERIFYERROR_bool("MULTIANEWARRAY with unlinked class");
-               if ((desc = arrayclass->vftbl->arraydesc) == NULL)
-                       TYPECHECK_VERIFYERROR_bool("MULTIANEWARRAY with non-array class");
-               if (desc->dimension < state->iptr->s1.argcount)
-                       TYPECHECK_VERIFYERROR_bool("MULTIANEWARRAY dimension to high");
-
-               /* set the array type of the result */
-               typeinfo_init_classinfo(&(dst->typeinfo), arrayclass);
-       }
-       else {
-               const char *p;
-               constant_classref *cr;
-
-               /* the array class reference is still unresolved */
-               /* check that the reference indicates an array class of correct dimension */
-               cr = state->iptr->sx.s23.s3.c.ref;
-               i = 0;
-               p = cr->name->text;
-               while (p[i] == '[')
-                       i++;
-               /* { the dimension of the array class == i } */
-               if (i < 1)
-                       TYPECHECK_VERIFYERROR_bool("MULTIANEWARRAY with non-array class");
-               if (i < state->iptr->s1.argcount)
-                       TYPECHECK_VERIFYERROR_bool("MULTIANEWARRAY dimension to high");
-
-               /* set the array type of the result */
-               if (!typeinfo_init_class(&(dst->typeinfo),CLASSREF_OR_CLASSINFO(cr)))
-                       return false;
-       }
-
-       /* everything ok */
-       return true;
-
-}
-
-static void typecheck_stackbased_add_jsr_caller(typecheck_jsr_t *jsr,
-                                                                                               basicblock *bptr)
-{
-       typecheck_jsr_caller_t *jc;
-
-       for (jc = jsr->callers; jc; jc = jc->next)
-               if (jc->callblock == bptr)
-                       return;
-
-       jc = DNEW(typecheck_jsr_caller_t);
-       jc->next = jsr->callers;
-       jc->callblock = bptr;
-       jsr->callers = jc;
-}
-
-static typedescriptor_t *typecheck_stackbased_jsr(verifier_state *state,
-                                                                                               typedescriptor_t *stack,
-                                                                                               typedescriptor_t *stackfloor)
-{
-       typecheck_jsr_t *jsr;
-       basicblock *tbptr;
-       jitdata *jd;
-       s4 i;
-
-       jd = state->jd;
-
-       tbptr = state->iptr->sx.s23.s3.jsrtarget.block;
-       jsr = state->jsrinfos[tbptr->nr];
-
-       if (jsr && tbptr->flags == BBFINISHED) {
-
-               LOG1("another JSR to analysed subroutine L%03d", tbptr->nr);
-               if (jsr->active) {
-                       exceptions_throw_verifyerror(state->m, "Recursive JSR");
-                       return NULL;
-               }
-
-               assert(jsr->callers);
-               assert(jsr->callers->callblock);
-
-               /* copy the stack of the RET edge */
-
-               MCOPY(stackfloor, jsr->retstack, typedescriptor_t, jsr->retdepth);
-               stack = stackfloor + (jsr->retdepth - 1);
-
-               /* copy variables that were used in the subroutine from the RET edge */
-
-               for (i=0; i<state->numlocals; ++i)
-                       if (jsr->usedlocals[i])
-                               state->locals[i] = jsr->retlocals[i];
-
-               /* reach the following block */
-
-               if (!typecheck_stackbased_reach(state, state->bptr->next, stack, 
-                                       (stack - stackfloor) + 1))
-                       return NULL;
-       }
-       else {
-               if (!jsr) {
-                       LOG1("first JSR to block L%03d", tbptr->nr);
-
-                       jsr = DNEW(typecheck_jsr_t);
-                       state->jsrinfos[tbptr->nr] = jsr;
-                       jsr->callers = NULL;
-                       jsr->blockflags = DMNEW(char, state->basicblockcount);
-                       jsr->retblock = NULL;
-                       jsr->start = tbptr;
-                       jsr->usedlocals = DMNEW(char, state->numlocals);
-                       MZERO(jsr->usedlocals, char, state->numlocals);
-                       jsr->retlocals = DMNEW(typedescriptor_t, state->numlocals);
-                       jsr->retstack = DMNEW(typedescriptor_t, state->m->maxstack);
-                       jsr->retdepth = 0;
-               }
-               else {
-                       LOG1("re-analysing JSR to block L%03d", tbptr->nr);
-               }
-
-               jsr->active = true;
-               jsr->next = state->topjsr;
-               state->topjsr = jsr;
-
-               assert(state->iptr->sx.s23.s3.jsrtarget.block->flags == BBTYPECHECK_REACHED);
-
-               tbptr->flags = BBFINISHED;
-
-               for (tbptr = state->basicblocks; tbptr != NULL; tbptr = tbptr->next) {
-                       jsr->blockflags[tbptr->nr] = tbptr->flags;
-
-                       if (tbptr->flags == BBTYPECHECK_REACHED)
-                               tbptr->flags = BBFINISHED;
-               }
-
-               state->iptr->sx.s23.s3.jsrtarget.block->flags = BBTYPECHECK_REACHED;
-       }
-
-       /* register this block as a caller, if not already done */
-
-       typecheck_stackbased_add_jsr_caller(jsr, state->bptr);
-
-       return stack;
-}
-
-static bool typecheck_stackbased_ret(verifier_state *state,
-                                                                        typedescriptor_t *stack,
-                                                                        typedescriptor_t *stackfloor)
-{
-       basicblock *tbptr;
-       typecheck_jsr_caller_t *jsrcaller;
-       typecheck_jsr_t *jsr;
-       s4 i;
-
-       /* get the subroutine we are RETurning from */
-
-       tbptr = TYPEINFO_RETURNADDRESS(state->locals[state->iptr->s1.varindex].typeinfo);
-       if (tbptr == NULL) {
-               exceptions_throw_verifyerror(state->m, "Illegal RET");
-               return false;
-       }
-
-       LOG1("RET from subroutine L%03d", tbptr->nr);
-       jsr = state->jsrinfos[tbptr->nr];
-       assert(jsr);
-
-       /* check against recursion */
-
-       if (!jsr->active) {
-               exceptions_throw_verifyerror(state->m, "RET outside of local subroutine");
-               return false;
-       }
-
-       /* check against multiple RETs for one subroutine */
-
-       if (jsr->retblock && jsr->retblock != state->bptr) {
-               exceptions_throw_verifyerror(state->m, "Multiple RETs from local subroutine");
-               return false;
-       }
-
-       /* store data-flow of the RET edge */
-
-       jsr->retblock = state->bptr;
-       jsr->retdepth = (stack - stackfloor) + 1;
-       MCOPY(jsr->retstack, stackfloor, typedescriptor_t, jsr->retdepth);
-       MCOPY(jsr->retlocals, state->locals, typedescriptor_t, state->numlocals);
-
-       /* invalidate the returnAddress used by this RET */
-       /* XXX should we also invalidate the returnAddresses of JSRs that are skipped by this RET? */
-
-       for (i=0; i<state->numlocals; ++i) {
-               typedescriptor_t *lc = &(jsr->retlocals[i]);
-               if (TYPE_IS_RETURNADDRESS(lc->type, lc->typeinfo))
-                       if (TYPEINFO_RETURNADDRESS(lc->typeinfo) == tbptr) {
-                               LOG1("invalidating returnAddress in local %d", i);
-                               TYPEINFO_INIT_RETURNADDRESS(lc->typeinfo, NULL);
-                       }
-       }
-
-       /* touch all callers of the subroutine, so they are analysed again */
-
-       for (jsrcaller = jsr->callers; jsrcaller != NULL; jsrcaller = jsrcaller->next) {
-               tbptr = jsrcaller->callblock;
-               LOG1("touching caller L%03d from RET", tbptr->nr);
-               assert(jsr->blockflags[tbptr->nr] >= BBFINISHED);
-               jsr->blockflags[tbptr->nr] = BBTYPECHECK_REACHED; /* XXX repeat? */
-       }
-
-       return true;
-}
-
-bool typecheck_stackbased(jitdata *jd)
-{
-       register verifier_slot_t *stack;
-       verifier_slot_t *stackfloor;
-       s4 len;
-       methoddesc *md;
-       bool maythrow;
-       bool superblockend;
-       verifier_slot_t temp;
-       branch_target_t *table;
-       lookup_target_t *lookup;
-       s4 i;
-       typecheck_result r;
-       verifier_slot_t *dst;
-       verifier_state state;
-       basicblock *tbptr;
-       exception_entry *ex;
-       typedescriptor_t exstack;
-       s4 skip = 0;
-
-       DOLOG( show_method(jd, SHOW_PARSE); );
-
-       /* initialize verifier state */
-
-       state.jd = jd;
-       state.m = jd->m;
-       state.cd = jd->cd;
-       state.basicblocks = jd->basicblocks;
-       state.basicblockcount = jd->basicblockcount;
-       state.topjsr = NULL;
-#   define STATE (&state)
-
-       /* check that the basicblock numbers are valid */
-
-#if !defined(NDEBUG)
-       jit_check_basicblock_numbers(jd);
-#endif
-
-       /* check if this method is an instance initializer method */
-
-    state.initmethod = (state.m->name == utf_init);
-
-       /* allocate parameter descriptors if necessary */
-
-       if (!state.m->parseddesc->params)
-               if (!descriptor_params_from_paramtypes(state.m->parseddesc,state.m->flags))
-                       return false;
-
-       /* allocate the stack buffers */
-
-       stackfloor = DMNEW(verifier_slot_t, state.m->maxstack + 1);
-       state.stackceiling = stackfloor + state.m->maxstack;
-       stack = stackfloor - 1;
-       state.indepth = DMNEW(s4, state.basicblockcount);
-       state.startstack = DMNEW(verifier_slot_t, state.m->maxstack * state.basicblockcount);
-
-       /* allocate the local variables buffers */
-
-       state.numlocals = state.m->maxlocals;
-       state.validlocals = state.m->maxlocals;
-    if (state.initmethod)
-               state.numlocals++; /* extra marker variable */
-
-       state.locals = DMNEW(verifier_slot_t, state.numlocals);
-       state.startlocals = DMNEW(verifier_slot_t, state.numlocals * state.basicblockcount);
-
-    /* allocate the buffer of active exception handlers */
-
-    state.handlers = DMNEW(exception_entry*, state.jd->exceptiontablelength + 1);
-
-    /* initialize instack of exception handlers */
-
-       exstack.type = TYPE_ADR;
-       typeinfo_init_classinfo(&(exstack.typeinfo),
-                                                       class_java_lang_Throwable); /* changed later */
-
-    LOG("Exception handler stacks set.\n");
-
-       /* initialize jsr info buffer */
-
-       state.jsrinfos = DMNEW(typecheck_jsr_t *, state.basicblockcount);
-       MZERO(state.jsrinfos, typecheck_jsr_t *, state.basicblockcount);
-
-       /* initialize stack of first block */
-
-       state.indepth[0] = 0;
-
-       /* initialize locals of first block */
-
-    /* if this is an instance method initialize the "this" ref type */
-
-    if (!(state.m->flags & ACC_STATIC)) {
-               if (state.validlocals < 1)
-                       VERIFY_ERROR("Not enough local variables for method arguments");
-               dst = state.startlocals;
-               dst->type = TYPE_ADR;
-               if (state.initmethod)
-                       TYPEINFO_INIT_NEWOBJECT(dst->typeinfo, NULL);
-               else
-                       typeinfo_init_classinfo(&(dst->typeinfo), state.m->clazz);
-
-               skip = 1;
-    }
-
-    LOG("'this' argument set.\n");
-
-       len = typedescriptors_init_from_methoddesc(state.startlocals + skip,
-                       state.m->parseddesc,
-                       state.validlocals, true, skip, &state.returntype);
-       if (len < 0)
-               return false;
-
-       /* set remaining locals to void */
-
-       for (i = skip + len; i<state.numlocals; ++i)
-               state.startlocals[i].type = TYPE_VOID;
-
-       /* initialize block flags */
-
-       typecheck_init_flags(&state, BBUNDEF);
-
-       /* iterate until fixpoint reached */
-
-       do {
-
-               state.repeat = false;
-
-               /* iterate over the basic blocks */
-
-               for (state.bptr = state.basicblocks; state.bptr != NULL; state.bptr = state.bptr->next) {
-
-                       if (state.bptr->flags != BBTYPECHECK_REACHED)
-                               continue;
-
-                       DOLOG( show_basicblock(jd, state.bptr, SHOW_PARSE); );
-
-                       /* mark this block as analysed */
-
-                       state.bptr->flags = BBFINISHED;
-
-                       /* determine the active exception handlers for this block */
-                       /* XXX could use a faster algorithm with sorted lists or  */
-                       /* something?                                             */
-                       /* XXX reuse code from variables based verifer? */
-                       len = 0;
-                       for (ex = STATE->jd->exceptiontable; ex ; ex = ex->down) {
-                               if ((ex->start->nr <= STATE->bptr->nr) && (ex->end->nr > STATE->bptr->nr)) {
-                                       LOG1("\tactive handler L%03d", ex->handler->nr);
-                                       STATE->handlers[len++] = ex;
-                               }
-                       }
-                       STATE->handlers[len] = NULL;
-
-                       /* initialize the locals */
-
-                       MCOPY(state.locals,
-                                 state.startlocals + (state.bptr->nr * state.numlocals),
-                                 verifier_slot_t, state.numlocals);
-
-                       /* initialize the stack */
-
-                       len = state.indepth[state.bptr->nr];
-
-                       MCOPY(stackfloor,
-                                 state.startstack + (state.bptr->nr * state.m->maxstack),
-                                 verifier_slot_t, len);
-
-                       stack = stackfloor + (len - 1);
-
-                       /* iterate over the instructions in this block */
-
-                       state.iptr = state.bptr->iinstr;
-                       len = state.bptr->icount;
-
-                       superblockend = false;
-
-                       for (; len--; state.iptr++) {
-
-                               maythrow = false;
-
-                               LOGNL;
-                               DOLOG( typecheck_stackbased_show_state(&state, stack, stackfloor, true); );
-
-                               switch (state.iptr->opc) {
-#define TYPECHECK_STACKBASED 1
-#define STATE (&state)
-#define IPTR state.iptr
-#define BPTR state.bptr
-#define METHOD state.m
-#define LOCAL_SLOT(index)  (state.locals + (index))
-#define EXCEPTION                                                    \
-    do {                                                             \
-        LOG("EXCEPTION THROWN!\n");                                  \
-        return false;                                                \
-    } while (0)
-
-#include <typecheck-stackbased-gen.inc>
-#undef  TYPECHECK_STACKBASED
-                               }
-
-                               /* reach exception handlers for this instruction */
-
-                               if (maythrow) {
-                                       TYPECHECK_COUNT(stat_ins_maythrow);
-                                       TYPECHECK_MARK(STATE->stat_maythrow);
-                                       LOG("\treaching exception handlers");
-                                       i = 0;
-                                       while (STATE->handlers[i]) {
-                                               TYPECHECK_COUNT(stat_handlers_reached);
-                                               if (STATE->handlers[i]->catchtype.any)
-                                                       exstack.typeinfo.typeclass = STATE->handlers[i]->catchtype;
-                                               else
-                                                       exstack.typeinfo.typeclass.cls = class_java_lang_Throwable;
-                                               if (!typecheck_stackbased_reach(
-                                                               STATE,
-                                                               STATE->handlers[i]->handler,
-                                                               &exstack, 1))
-                                                       EXCEPTION;
-                                               i++;
-                                       }
-                               }
-                       }
-
-                       /* propagate types to the following block */
-
-                       if (!superblockend) {
-                               if (!typecheck_stackbased_reach(&state, state.bptr->next,
-                                                                                               stack, stack - stackfloor + 1))
-                                       EXCEPTION;
-                       }
-               } /* end loop over blocks */
-
-               while (!state.repeat && state.topjsr) {
-                       LOG1("done analysing subroutine L%03d", state.topjsr->start->nr);
-
-                       /* propagate down used locals */
-
-                       if (state.topjsr->next) {
-                               for (i=0; i<state.numlocals; ++i)
-                                       state.topjsr->next->usedlocals[i] |= state.topjsr->usedlocals[i];
-                       }
-
-                       /* restore REACHED flags */
-
-                       for (tbptr = state.basicblocks; tbptr != NULL; tbptr = tbptr->next) {
-                               assert(tbptr->flags != BBTYPECHECK_REACHED);
-                               if (state.topjsr->blockflags[tbptr->nr] == BBTYPECHECK_REACHED) {
-                                       tbptr->flags = BBTYPECHECK_REACHED;
-                                       state.repeat = true;
-                               }
-                       }
-
-                       /* dactivate the subroutine */
-
-                       state.topjsr->active = false;
-                       state.topjsr = state.topjsr->next;
-               }
-       } while (state.repeat);
-
-       /* reset block flags */
-
-       typecheck_reset_flags(&state);
-
-       LOG("typecheck_stackbased successful");
-
-       return true;
-
-throw_stack_underflow:
-       LOG("STACK UNDERFLOW!");
-       exceptions_throw_verifyerror(state.m, "Unable to pop operand off an empty stack");
-       return false;
-
-throw_stack_overflow:
-       LOG("STACK OVERFLOW!");
-       exceptions_throw_verifyerror(state.m, "Stack size too large");
-       return false;
-
-throw_stack_type_error:
-       LOG("STACK TYPE ERROR!");
-       exceptions_throw_verifyerror(state.m, "Mismatched stack types");
-       return false;
-
-throw_local_type_error:
-       LOG("LOCAL TYPE ERROR!");
-       exceptions_throw_verifyerror(state.m, "Local variable type mismatch");
-       return false;
-
-throw_stack_category_error:
-       LOG("STACK CATEGORY ERROR!");
-       exceptions_throw_verifyerror(state.m, "Attempt to split long or double on the stack");
-       return false;
-}
-
-
-#if defined(TYPECHECK_VERBOSE)
-static void typecheck_stackbased_show_state(verifier_state *state,
-                                                                                       typedescriptor_t *stack,
-                                                                                       typedescriptor_t *stackfloor,
-                                                                                       bool showins)
-{
-       typedescriptor_t *sp;
-       s4 i;
-
-       LOGSTR1("stackdepth %d stack [", (stack - stackfloor) + 1);
-       for (sp=stackfloor; sp <= stack; sp++) {
-               LOGSTR(" ");
-               DOLOG( typedescriptor_print(stdout, sp); );
-       }
-       LOGSTR(" ] locals [");
-       for (i=0; i<state->numlocals; ++i) {
-               LOGSTR(" ");
-               DOLOG( typedescriptor_print(stdout, state->locals + i); );
-       }
-       LOGSTR(" ]");
-       LOGNL;
-       if (showins && state->iptr < (state->bptr->iinstr + state->bptr->icount)) {
-               LOGSTR("\t");
-               DOLOG( show_icmd(state->jd, state->iptr, false, SHOW_PARSE); );
-               LOGNL;
-       }
-}
-#endif
-
-#endif /* defined(ENABLE_VERIFIER) */
-
-
-/*
- * 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/jit/verify/typecheck-stackbased.cpp b/src/vm/jit/verify/typecheck-stackbased.cpp
new file mode 100644 (file)
index 0000000..8ac6267
--- /dev/null
@@ -0,0 +1,1034 @@
+/* src/vm/jit/verify/typecheck-stackbased.c - stack-based verifier
+
+   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 "vm/types.h"
+
+#include "vm/jit/builtin.hpp"
+#include "mm/memory.h"
+
+#include "vm/array.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/primitive.hpp"
+
+#include "vm/jit/parse.hpp"
+#include "vm/jit/show.hpp"
+#include "vm/jit/stack.h"
+#include "vm/jit/verify/typecheck-common.hpp"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* this #if runs over the whole file: */
+#if defined(ENABLE_VERIFIER)
+
+typedef typedescriptor_t verifier_slot_t;
+
+#if defined(TYPECHECK_VERBOSE)
+static void typecheck_stackbased_show_state(verifier_state *state,
+                                                                                       typedescriptor *stack,
+                                                                                       typedescriptor *stackfloor,
+                                                                                       bool showins);
+#endif
+
+
+#define CHECK_STACK_DEPTH(d)                                         \
+    if (((u1*)stack - (u1*)stackfloor)                               \
+            < (((d)-1) * (int)sizeof(verifier_slot_t)))              \
+        goto throw_stack_underflow;
+
+/* XXX don't need to check against ACONST for every ICMD */
+#define CHECK_STACK_SPACE(d)                                         \
+    if (((u1*)STATE->stackceiling - (u1*)stack)                      \
+            < (((d)+1) * (int)sizeof(verifier_slot_t)))              \
+        if (STATE->iptr->opc != ICMD_ACONST                          \
+                || INSTRUCTION_MUST_CHECK(STATE->iptr))              \
+            goto throw_stack_overflow;
+
+#define CHECK_STACK_TYPE(s, t)                                       \
+    if ((s).type != (t))                                             \
+        goto throw_stack_type_error;
+
+/* XXX inefficient */
+#define CHECK_LOCAL_TYPE(index, t)                                   \
+    do {                                                             \
+        if (state.locals[(index)].type != (t))                       \
+            goto throw_local_type_error;                             \
+        if (STATE->topjsr)                                           \
+            STATE->topjsr->usedlocals[(index)] = 1;                  \
+        if (STATE->topjsr && IS_2_WORD_TYPE(t))                      \
+            STATE->topjsr->usedlocals[(index) + 1] = 1;              \
+    } while(0)
+
+/* XXX inefficient */
+#define STORE_LOCAL(t, index)                                        \
+    do {                                                             \
+        state.locals[(index)].type = (t);                            \
+        if ((index) && IS_2_WORD_TYPE(state.locals[(index)-1].type)) \
+            state.locals[(index-1)].type = TYPE_VOID;                \
+        if (STATE->topjsr)                                           \
+            STATE->topjsr->usedlocals[(index)] = 1;                  \
+    } while (0)
+
+/* XXX inefficient */
+#define STORE_LOCAL_2_WORD(t, index)                                 \
+    do {                                                             \
+        STORE_LOCAL(t, index);                                       \
+        state.locals[(index)+1].type = TYPE_VOID;                    \
+        if (STATE->topjsr)                                           \
+            STATE->topjsr->usedlocals[(index)] = 1;                  \
+    } while (0)
+
+#define VERIFY_ERROR(msg)                                            \
+    do {                                                             \
+        LOG1("VerifyError: %s", msg);                                \
+        exceptions_throw_verifyerror(STATE->m, msg);                 \
+        return false;                                                \
+    } while (0)
+
+#define IS_CAT1(slot)                                                \
+    ((slot).type != TYPE_VOID && !IS_2_WORD_TYPE((slot).type))
+
+#define IS_CAT2(slot)                                                \
+    ((slot).type != TYPE_VOID && IS_2_WORD_TYPE((slot).type))
+
+#define CHECK_CAT1(slot)                                             \
+    do {                                                             \
+        if (!IS_CAT1(slot))                                          \
+            goto throw_stack_category_error;                         \
+    } while (0)
+
+#define CHECK_CAT2(slot)                                             \
+    do {                                                             \
+        if (!IS_CAT2(slot))                                          \
+            goto throw_stack_category_error;                         \
+    } while (0)
+
+#define COPY_SLOT(s, d)                                              \
+    do { (d) = (s); } while (0)
+
+#define REACH_BLOCK(target)                                          \
+    do {                                                             \
+        if (!typecheck_stackbased_reach(STATE, (target), stack,      \
+                    (stack - stackfloor) + 1))                       \
+            return false;                                            \
+    } while (0)
+
+#define REACH(target)                                                \
+    do {                                                             \
+        REACH_BLOCK((target).block);                                 \
+    } while (0)
+
+#undef TYPECHECK_INT
+#undef TYPECHECK_LNG
+#undef TYPECHECK_FLT
+#undef TYPECHECK_DBL
+#undef TYPECHECK_ADR
+
+/* XXX should reuse typevector code */
+static typecheck_result typecheck_stackbased_merge_locals(methodinfo *m,
+                                                                                                                 typedescriptor_t *dst,
+                                                                                                                 typedescriptor_t *y,
+                                                                                                                 int size)
+{
+       bool changed = false;
+       typecheck_result r;
+
+       typedescriptor_t *a = dst;
+       typedescriptor_t *b = y;
+       while (size--) {
+               if (a->type != TYPE_VOID && a->type != b->type) {
+                       a->type = TYPE_VOID;
+                       changed = true;
+               }
+               else if (a->type == TYPE_ADR) {
+                       if (TYPEINFO_IS_PRIMITIVE(a->typeinfo)) {
+                               /* 'a' is a returnAddress */
+                               if (!TYPEINFO_IS_PRIMITIVE(b->typeinfo)
+                                       || (TYPEINFO_RETURNADDRESS(a->typeinfo)
+                                               != TYPEINFO_RETURNADDRESS(b->typeinfo)))
+                               {
+                                       a->type = TYPE_VOID;
+                                       changed = true;
+                               }
+                       }
+                       else {
+                               /* 'a' is a reference */
+                               if (TYPEINFO_IS_PRIMITIVE(b->typeinfo)) {
+                                       a->type = TYPE_VOID;
+                                       changed = true;
+                               }
+                               else {
+                                       /* two reference types are merged. There cannot be */
+                                       /* a merge error. In the worst case we get j.l.O.  */
+                                       r = typeinfo_merge(m,&(a->typeinfo),&(b->typeinfo));
+                                       if (r == typecheck_FAIL)
+                                               return r;
+                                       changed |= r;
+                               }
+                       }
+               }
+               a++;
+               b++;
+       }
+       return (typecheck_result) changed;
+}
+
+static typecheck_result typecheck_stackbased_merge(verifier_state *state,
+                                                                                                  basicblock *destblock,
+                                                                                                  typedescriptor_t *stack,
+                                                                                                  s4 stackdepth)
+{
+       s4 i;
+       s4 destidx;
+       typedescriptor_t *stackfloor;
+       typedescriptor_t *sp;
+       typedescriptor_t *dp;
+       typecheck_result r;
+       bool changed = false;
+
+       destidx = destblock->nr;
+
+       if (stackdepth != state->indepth[destidx]) {
+               exceptions_throw_verifyerror(state->m, "Stack depth mismatch");
+               return typecheck_FAIL;
+       }
+
+       stackfloor = stack - (stackdepth - 1);
+
+       sp = stackfloor;
+       dp = state->startstack + (destidx * state->m->maxstack);
+
+       for (i=0; i<stackdepth; ++i, ++sp, ++dp) {
+               if (sp->type != dp->type) {
+                       exceptions_throw_verifyerror(state->m, "Mismatched stack types");
+                       return typecheck_FAIL;
+               }
+               if (dp->type == TYPE_ADR) {
+                       if (TYPEINFO_IS_PRIMITIVE(dp->typeinfo)) {
+                               /* dp has returnAddress type */
+                               if (TYPEINFO_IS_PRIMITIVE(sp->typeinfo)) {
+                                       if (TYPEINFO_RETURNADDRESS(dp->typeinfo) != TYPEINFO_RETURNADDRESS(sp->typeinfo)) {
+                                               exceptions_throw_verifyerror(state->m, "Mismatched stack types");
+                                               return typecheck_FAIL;
+                                       }
+                               }
+                               else {
+                                       exceptions_throw_verifyerror(state->m,"Merging returnAddress with reference");
+                                       return typecheck_FAIL;
+                               }
+                       }
+                       else {
+                               /* dp has reference type */
+                               if (TYPEINFO_IS_PRIMITIVE(sp->typeinfo)) {
+                                       exceptions_throw_verifyerror(state->m,"Merging reference with returnAddress");
+                                       return typecheck_FAIL;
+                               }
+                               r = typeinfo_merge(state->m,&(dp->typeinfo),&(sp->typeinfo));
+                               if (r == typecheck_FAIL)
+                                       return r;
+                               changed |= r;
+                       }
+               }
+       }
+
+       dp = state->startlocals + (destidx * state->numlocals);
+       r = typecheck_stackbased_merge_locals(state->m, dp, state->locals, state->numlocals);
+       if (r == typecheck_FAIL)
+               return r;
+       changed |= r;
+
+       return (typecheck_result) changed;
+}
+
+static bool typecheck_stackbased_reach(verifier_state *state,
+                                                                          basicblock *destblock,
+                                                                          typedescriptor_t *stack,
+                                                                          s4 stackdepth)
+{
+       bool changed = false;
+       typecheck_result r;
+
+       assert(destblock);
+
+       if (destblock->flags == BBTYPECHECK_UNDEF) {
+               /* The destblock has never been reached before */
+
+               TYPECHECK_COUNT(stat_copied);
+               LOG1("block L%03d reached first time",destblock->nr); LOGSTR("\t");
+               DOLOG( typecheck_stackbased_show_state(state, stack, stack - (stackdepth - 1), false); );
+
+               state->indepth[destblock->nr] = stackdepth;
+
+               MCOPY(state->startstack + (destblock->nr * state->m->maxstack),
+                         stack - (stackdepth - 1),
+                         typedescriptor_t,
+                         stackdepth);
+
+               MCOPY(state->startlocals + (destblock->nr * state->numlocals),
+                         state->locals,
+                         typedescriptor_t,
+                         state->numlocals);
+
+               changed = true;
+       }
+       else {
+               /* The destblock has already been reached before */
+
+               TYPECHECK_COUNT(stat_merged);
+               LOG1("block L%03d reached before", destblock->nr); LOGSTR("\t");
+               DOLOG( typecheck_stackbased_show_state(state, stack, stack - (stackdepth - 1), false); );
+
+               r = typecheck_stackbased_merge(state, destblock, stack, stackdepth);
+               if (r == typecheck_FAIL)
+                       return false;
+               changed = r;
+
+               TYPECHECK_COUNTIF(changed,stat_merging_changed);
+       }
+
+       if (changed) {
+               LOG("\tchanged!");
+               destblock->flags = BBTYPECHECK_REACHED;
+               /* XXX is this check ok? */
+               if (destblock->nr <= state->bptr->nr) {
+                       LOG("\tREPEAT!");
+                       state->repeat = true;
+               }
+       }
+       return true;
+}
+
+
+/* typecheck_stackbased_verify_fieldaccess *************************************
+
+   Verify an ICMD_{GET,PUT}{STATIC,FIELD}
+
+   IN:
+       state............the current state of the verifier
+          instance.........the instance slot, or NULL
+          value............the value slot, or NULL
+          stack............stack after popping the arguments
+
+   RETURN VALUE:
+       stack pointer....successful verification,
+          NULL.............an exception has been thrown.
+
+*******************************************************************************/
+
+static typedescriptor_t *typecheck_stackbased_verify_fieldaccess(
+               verifier_state *state,
+               typedescriptor_t *instance,
+               typedescriptor_t *value,
+               typedescriptor_t *stack)
+{
+       jitdata *jd;
+
+       jd = state->jd;
+
+#define TYPECHECK_STACKBASED
+#define EXCEPTION  do { return NULL; } while (0)
+#define STATE  state
+#include <typecheck-fields.inc>
+#undef  EXCEPTION
+#undef  STATE
+#undef  TYPECHECK_STACKBASED
+
+       return stack;
+
+throw_stack_overflow:
+       LOG("STACK OVERFLOW!");
+       exceptions_throw_verifyerror(state->m, "Stack size too large");
+       return NULL;
+}
+
+static bool typecheck_stackbased_verify_invocation(verifier_state *state,
+                                                                                                  typedescriptor_t *stack,
+                                                                                                  typedescriptor_t *stackfloor)
+{
+       s4 paramslots;
+       methoddesc *md;
+       typedescriptor_t *dv;
+
+       /* check stack depth */
+
+       /* XXX parse params */
+
+       INSTRUCTION_GET_METHODDESC(state->iptr, md);
+
+       paramslots = md->paramslots;
+
+       if ((stack - stackfloor) + 1 < paramslots) {
+               exceptions_throw_verifyerror(state->m, 
+                               "Trying to pop operand of an empty stack");
+               return false;
+       }
+
+       dv = stack - (paramslots - 1);
+
+#define TYPECHECK_STACKBASED
+#define OP1   dv
+#include <typecheck-invoke.inc>
+#undef  OP1
+#undef  TYPECHECK_STACKBASED
+
+       return true;
+}
+
+static bool typecheck_stackbased_verify_builtin(verifier_state *state,
+                                                                                               typedescriptor_t *stack,
+                                                                                               typedescriptor_t *stackfloor)
+{
+       s4 paramslots;
+       typedescriptor_t *dv;
+
+       /* check stack depth */
+
+       /* XXX parse params */
+
+       paramslots = state->iptr->sx.s23.s3.bte->md->paramslots;
+
+       if ((stack - stackfloor) + 1 < paramslots) {
+               exceptions_throw_verifyerror(state->m, 
+                               "Trying to pop operand of an empty stack");
+               return false;
+       }
+
+       dv = stack - (paramslots - 1);
+
+#define TYPECHECK_STACKBASED
+#define OP1   dv
+#define TYPECHECK_INT(s)  CHECK_STACK_TYPE(*(s), TYPE_INT)
+#define TYPECHECK_ADR(s)  CHECK_STACK_TYPE(*(s), TYPE_ADR)
+#define TYPECHECK_LNG(s)  CHECK_STACK_TYPE(*(s), TYPE_LNG)
+#define TYPECHECK_FLT(s)  CHECK_STACK_TYPE(*(s), TYPE_FLT)
+#define TYPECHECK_DBL(s)  CHECK_STACK_TYPE(*(s), TYPE_DBL)
+#include <typecheck-builtins.inc>
+#undef  OP1
+#undef  TYPECHECK_STACKBASED
+
+       return true;
+
+throw_stack_type_error:
+       exceptions_throw_verifyerror(state->m, "Wrong type on stack"); /* XXX */
+       return false;
+}
+
+static bool typecheck_stackbased_multianewarray(verifier_state *state,
+                                                                                               typedescriptor_t *stack,
+                                                                                               typedescriptor_t *stackfloor)
+{
+       /* XXX recombine with verify_multianewarray */
+
+       classinfo *arrayclass;
+       arraydescriptor *desc;
+       s4 i;
+       typedescriptor_t *sp;
+       typedescriptor_t *dst;
+
+       /* destination slot */
+
+       i = state->iptr->s1.argcount;
+
+       dst = stack - (i-1);
+
+       /* check the array lengths on the stack */
+
+       if ((stack - stackfloor) + 1 < i) {
+               exceptions_throw_verifyerror(state->m, 
+                               "Trying to pop operand of an empty stack");
+               return false;
+       }
+
+       if (i < 1)
+               TYPECHECK_VERIFYERROR_bool("Illegal dimension argument");
+
+       for (sp = dst; sp <= stack; ++sp) {
+               if (sp->type != TYPE_INT) {
+                       exceptions_throw_verifyerror_for_stack(state->m, TYPE_INT);
+                       return false;
+               }
+       }
+
+       /* check array descriptor */
+
+       if (INSTRUCTION_IS_RESOLVED(state->iptr)) {
+               /* the array class reference has already been resolved */
+               arrayclass = state->iptr->sx.s23.s3.c.cls;
+               if (!arrayclass)
+                       TYPECHECK_VERIFYERROR_bool("MULTIANEWARRAY with unlinked class");
+               if ((desc = arrayclass->vftbl->arraydesc) == NULL)
+                       TYPECHECK_VERIFYERROR_bool("MULTIANEWARRAY with non-array class");
+               if (desc->dimension < state->iptr->s1.argcount)
+                       TYPECHECK_VERIFYERROR_bool("MULTIANEWARRAY dimension to high");
+
+               /* set the array type of the result */
+               typeinfo_init_classinfo(&(dst->typeinfo), arrayclass);
+       }
+       else {
+               const char *p;
+               constant_classref *cr;
+
+               /* the array class reference is still unresolved */
+               /* check that the reference indicates an array class of correct dimension */
+               cr = state->iptr->sx.s23.s3.c.ref;
+               i = 0;
+               p = cr->name->text;
+               while (p[i] == '[')
+                       i++;
+               /* { the dimension of the array class == i } */
+               if (i < 1)
+                       TYPECHECK_VERIFYERROR_bool("MULTIANEWARRAY with non-array class");
+               if (i < state->iptr->s1.argcount)
+                       TYPECHECK_VERIFYERROR_bool("MULTIANEWARRAY dimension to high");
+
+               /* set the array type of the result */
+               if (!typeinfo_init_class(&(dst->typeinfo),CLASSREF_OR_CLASSINFO(cr)))
+                       return false;
+       }
+
+       /* everything ok */
+       return true;
+
+}
+
+static void typecheck_stackbased_add_jsr_caller(typecheck_jsr_t *jsr,
+                                                                                               basicblock *bptr)
+{
+       typecheck_jsr_caller_t *jc;
+
+       for (jc = jsr->callers; jc; jc = jc->next)
+               if (jc->callblock == bptr)
+                       return;
+
+       jc = (typecheck_jsr_caller_t*) DumpMemory::allocate(sizeof(typecheck_jsr_caller_t));
+       jc->next = jsr->callers;
+       jc->callblock = bptr;
+       jsr->callers = jc;
+}
+
+static typedescriptor_t *typecheck_stackbased_jsr(verifier_state *state,
+                                                                                               typedescriptor_t *stack,
+                                                                                               typedescriptor_t *stackfloor)
+{
+       typecheck_jsr_t *jsr;
+       basicblock *tbptr;
+       jitdata *jd;
+       s4 i;
+
+       jd = state->jd;
+
+       tbptr = state->iptr->sx.s23.s3.jsrtarget.block;
+       jsr = state->jsrinfos[tbptr->nr];
+
+       if (jsr && tbptr->flags == BBFINISHED) {
+
+               LOG1("another JSR to analysed subroutine L%03d", tbptr->nr);
+               if (jsr->active) {
+                       exceptions_throw_verifyerror(state->m, "Recursive JSR");
+                       return NULL;
+               }
+
+               assert(jsr->callers);
+               assert(jsr->callers->callblock);
+
+               /* copy the stack of the RET edge */
+
+               MCOPY(stackfloor, jsr->retstack, typedescriptor_t, jsr->retdepth);
+               stack = stackfloor + (jsr->retdepth - 1);
+
+               /* copy variables that were used in the subroutine from the RET edge */
+
+               for (i=0; i<state->numlocals; ++i)
+                       if (jsr->usedlocals[i])
+                               state->locals[i] = jsr->retlocals[i];
+
+               /* reach the following block */
+
+               if (!typecheck_stackbased_reach(state, state->bptr->next, stack, 
+                                       (stack - stackfloor) + 1))
+                       return NULL;
+       }
+       else {
+               if (!jsr) {
+                       LOG1("first JSR to block L%03d", tbptr->nr);
+
+                       jsr = (typecheck_jsr_t*) DumpMemory::allocate(sizeof(typecheck_jsr_t));
+                       state->jsrinfos[tbptr->nr] = jsr;
+                       jsr->callers = NULL;
+                       jsr->blockflags = (char*) DumpMemory::allocate(sizeof(char) * state->basicblockcount);
+                       jsr->retblock = NULL;
+                       jsr->start = tbptr;
+                       jsr->usedlocals = (char*) DumpMemory::allocate(sizeof(char) * state->numlocals);
+                       MZERO(jsr->usedlocals, char, state->numlocals);
+                       jsr->retlocals = (typedescriptor_t*) DumpMemory::allocate(sizeof(typedescriptor_t) * state->numlocals);
+                       jsr->retstack = (typedescriptor_t*) DumpMemory::allocate(sizeof(typedescriptor_t) * state->m->maxstack);
+                       jsr->retdepth = 0;
+               }
+               else {
+                       LOG1("re-analysing JSR to block L%03d", tbptr->nr);
+               }
+
+               jsr->active = true;
+               jsr->next = state->topjsr;
+               state->topjsr = jsr;
+
+               assert(state->iptr->sx.s23.s3.jsrtarget.block->flags == BBTYPECHECK_REACHED);
+
+               tbptr->flags = BBFINISHED;
+
+               for (tbptr = state->basicblocks; tbptr != NULL; tbptr = tbptr->next) {
+                       jsr->blockflags[tbptr->nr] = tbptr->flags;
+
+                       if (tbptr->flags == BBTYPECHECK_REACHED)
+                               tbptr->flags = BBFINISHED;
+               }
+
+               state->iptr->sx.s23.s3.jsrtarget.block->flags = BBTYPECHECK_REACHED;
+       }
+
+       /* register this block as a caller, if not already done */
+
+       typecheck_stackbased_add_jsr_caller(jsr, state->bptr);
+
+       return stack;
+}
+
+static bool typecheck_stackbased_ret(verifier_state *state,
+                                                                        typedescriptor_t *stack,
+                                                                        typedescriptor_t *stackfloor)
+{
+       basicblock *tbptr;
+       typecheck_jsr_caller_t *jsrcaller;
+       typecheck_jsr_t *jsr;
+       s4 i;
+
+       /* get the subroutine we are RETurning from */
+
+       tbptr = (basicblock*) TYPEINFO_RETURNADDRESS(state->locals[state->iptr->s1.varindex].typeinfo);
+       if (tbptr == NULL) {
+               exceptions_throw_verifyerror(state->m, "Illegal RET");
+               return false;
+       }
+
+       LOG1("RET from subroutine L%03d", tbptr->nr);
+       jsr = state->jsrinfos[tbptr->nr];
+       assert(jsr);
+
+       /* check against recursion */
+
+       if (!jsr->active) {
+               exceptions_throw_verifyerror(state->m, "RET outside of local subroutine");
+               return false;
+       }
+
+       /* check against multiple RETs for one subroutine */
+
+       if (jsr->retblock && jsr->retblock != state->bptr) {
+               exceptions_throw_verifyerror(state->m, "Multiple RETs from local subroutine");
+               return false;
+       }
+
+       /* store data-flow of the RET edge */
+
+       jsr->retblock = state->bptr;
+       jsr->retdepth = (stack - stackfloor) + 1;
+       MCOPY(jsr->retstack, stackfloor, typedescriptor_t, jsr->retdepth);
+       MCOPY(jsr->retlocals, state->locals, typedescriptor_t, state->numlocals);
+
+       /* invalidate the returnAddress used by this RET */
+       /* XXX should we also invalidate the returnAddresses of JSRs that are skipped by this RET? */
+
+       for (i=0; i<state->numlocals; ++i) {
+               typedescriptor_t *lc = &(jsr->retlocals[i]);
+               if (TYPE_IS_RETURNADDRESS(lc->type, lc->typeinfo))
+                       if (TYPEINFO_RETURNADDRESS(lc->typeinfo) == tbptr) {
+                               LOG1("invalidating returnAddress in local %d", i);
+                               TYPEINFO_INIT_RETURNADDRESS(lc->typeinfo, NULL);
+                       }
+       }
+
+       /* touch all callers of the subroutine, so they are analysed again */
+
+       for (jsrcaller = jsr->callers; jsrcaller != NULL; jsrcaller = jsrcaller->next) {
+               tbptr = jsrcaller->callblock;
+               LOG1("touching caller L%03d from RET", tbptr->nr);
+               assert(jsr->blockflags[tbptr->nr] >= BBFINISHED);
+               jsr->blockflags[tbptr->nr] = BBTYPECHECK_REACHED; /* XXX repeat? */
+       }
+
+       return true;
+}
+
+bool typecheck_stackbased(jitdata *jd)
+{
+       register verifier_slot_t *stack;
+       verifier_slot_t *stackfloor;
+       s4 len;
+       methoddesc *md;
+       bool maythrow;
+       bool superblockend;
+       verifier_slot_t temp;
+       branch_target_t *table;
+       lookup_target_t *lookup;
+       s4 i;
+       typecheck_result r;
+       verifier_slot_t *dst;
+       verifier_state state;
+       basicblock *tbptr;
+       exception_entry *ex;
+       typedescriptor_t exstack;
+       s4 skip = 0;
+
+       DOLOG( show_method(jd, SHOW_PARSE); );
+
+       /* initialize verifier state */
+
+       state.jd = jd;
+       state.m = jd->m;
+       state.cd = jd->cd;
+       state.basicblocks = jd->basicblocks;
+       state.basicblockcount = jd->basicblockcount;
+       state.topjsr = NULL;
+#   define STATE (&state)
+
+       /* check that the basicblock numbers are valid */
+
+#if !defined(NDEBUG)
+       jit_check_basicblock_numbers(jd);
+#endif
+
+       /* check if this method is an instance initializer method */
+
+    state.initmethod = (state.m->name == utf_init);
+
+       /* allocate parameter descriptors if necessary */
+
+       if (!state.m->parseddesc->params)
+               if (!descriptor_params_from_paramtypes(state.m->parseddesc,state.m->flags))
+                       return false;
+
+       /* allocate the stack buffers */
+
+       stackfloor = (verifier_slot_t*) DumpMemory::allocate(sizeof(verifier_slot_t) * (state.m->maxstack + 1));
+       state.stackceiling = stackfloor + state.m->maxstack;
+       stack = stackfloor - 1;
+       state.indepth = (s4*) DumpMemory::allocate(sizeof(s4) * state.basicblockcount);
+       state.startstack = (verifier_slot_t*) DumpMemory::allocate(sizeof(verifier_slot_t) * state.m->maxstack * state.basicblockcount);
+
+       /* allocate the local variables buffers */
+
+       state.numlocals = state.m->maxlocals;
+       state.validlocals = state.m->maxlocals;
+    if (state.initmethod)
+               state.numlocals++; /* extra marker variable */
+
+       state.locals = (verifier_slot_t*) DumpMemory::allocate(sizeof(verifier_slot_t) * state.numlocals);
+       state.startlocals = (verifier_slot_t*) DumpMemory::allocate(sizeof(verifier_slot_t) * state.numlocals * state.basicblockcount);
+
+    /* allocate the buffer of active exception handlers */
+
+    state.handlers = (exception_entry**) DumpMemory::allocate(sizeof(exception_entry*) * (state.jd->exceptiontablelength + 1));
+
+    /* initialize instack of exception handlers */
+
+       exstack.type = TYPE_ADR;
+       typeinfo_init_classinfo(&(exstack.typeinfo),
+                                                       class_java_lang_Throwable); /* changed later */
+
+    LOG("Exception handler stacks set.\n");
+
+       /* initialize jsr info buffer */
+
+       state.jsrinfos = (typecheck_jsr_t**) DumpMemory::allocate(sizeof(typecheck_jsr_t*) * state.basicblockcount);
+       MZERO(state.jsrinfos, typecheck_jsr_t *, state.basicblockcount);
+
+       /* initialize stack of first block */
+
+       state.indepth[0] = 0;
+
+       /* initialize locals of first block */
+
+    /* if this is an instance method initialize the "this" ref type */
+
+    if (!(state.m->flags & ACC_STATIC)) {
+               if (state.validlocals < 1)
+                       VERIFY_ERROR("Not enough local variables for method arguments");
+               dst = state.startlocals;
+               dst->type = TYPE_ADR;
+               if (state.initmethod)
+                       TYPEINFO_INIT_NEWOBJECT(dst->typeinfo, NULL);
+               else
+                       typeinfo_init_classinfo(&(dst->typeinfo), state.m->clazz);
+
+               skip = 1;
+    }
+
+    LOG("'this' argument set.\n");
+
+       len = typedescriptors_init_from_methoddesc(state.startlocals + skip,
+                       state.m->parseddesc,
+                       state.validlocals, true, skip, &state.returntype);
+       if (len < 0)
+               return false;
+
+       /* set remaining locals to void */
+
+       for (i = skip + len; i<state.numlocals; ++i)
+               state.startlocals[i].type = TYPE_VOID;
+
+       /* initialize block flags */
+
+       typecheck_init_flags(&state, BBUNDEF);
+
+       /* iterate until fixpoint reached */
+
+       do {
+
+               state.repeat = false;
+
+               /* iterate over the basic blocks */
+
+               for (state.bptr = state.basicblocks; state.bptr != NULL; state.bptr = state.bptr->next) {
+
+                       if (state.bptr->flags != BBTYPECHECK_REACHED)
+                               continue;
+
+                       DOLOG( show_basicblock(jd, state.bptr, SHOW_PARSE); );
+
+                       /* mark this block as analysed */
+
+                       state.bptr->flags = BBFINISHED;
+
+                       /* determine the active exception handlers for this block */
+                       /* XXX could use a faster algorithm with sorted lists or  */
+                       /* something?                                             */
+                       /* XXX reuse code from variables based verifer? */
+                       len = 0;
+                       for (ex = STATE->jd->exceptiontable; ex ; ex = ex->down) {
+                               if ((ex->start->nr <= STATE->bptr->nr) && (ex->end->nr > STATE->bptr->nr)) {
+                                       LOG1("\tactive handler L%03d", ex->handler->nr);
+                                       STATE->handlers[len++] = ex;
+                               }
+                       }
+                       STATE->handlers[len] = NULL;
+
+                       /* initialize the locals */
+
+                       MCOPY(state.locals,
+                                 state.startlocals + (state.bptr->nr * state.numlocals),
+                                 verifier_slot_t, state.numlocals);
+
+                       /* initialize the stack */
+
+                       len = state.indepth[state.bptr->nr];
+
+                       MCOPY(stackfloor,
+                                 state.startstack + (state.bptr->nr * state.m->maxstack),
+                                 verifier_slot_t, len);
+
+                       stack = stackfloor + (len - 1);
+
+                       /* iterate over the instructions in this block */
+
+                       state.iptr = state.bptr->iinstr;
+                       len = state.bptr->icount;
+
+                       superblockend = false;
+
+                       for (; len--; state.iptr++) {
+
+                               maythrow = false;
+
+                               LOGNL;
+                               DOLOG( typecheck_stackbased_show_state(&state, stack, stackfloor, true); );
+
+                               switch (state.iptr->opc) {
+#define TYPECHECK_STACKBASED 1
+#define STATE (&state)
+#define IPTR state.iptr
+#define BPTR state.bptr
+#define METHOD state.m
+#define LOCAL_SLOT(index)  (state.locals + (index))
+#define EXCEPTION                                                    \
+    do {                                                             \
+        LOG("EXCEPTION THROWN!\n");                                  \
+        return false;                                                \
+    } while (0)
+
+#include <typecheck-stackbased-gen.inc>
+#undef  TYPECHECK_STACKBASED
+                               }
+
+                               /* reach exception handlers for this instruction */
+
+                               if (maythrow) {
+                                       TYPECHECK_COUNT(stat_ins_maythrow);
+                                       TYPECHECK_MARK(STATE->stat_maythrow);
+                                       LOG("\treaching exception handlers");
+                                       i = 0;
+                                       while (STATE->handlers[i]) {
+                                               TYPECHECK_COUNT(stat_handlers_reached);
+                                               if (STATE->handlers[i]->catchtype.any)
+                                                       exstack.typeinfo.typeclass = STATE->handlers[i]->catchtype;
+                                               else
+                                                       exstack.typeinfo.typeclass.cls = class_java_lang_Throwable;
+                                               if (!typecheck_stackbased_reach(
+                                                               STATE,
+                                                               STATE->handlers[i]->handler,
+                                                               &exstack, 1))
+                                                       EXCEPTION;
+                                               i++;
+                                       }
+                               }
+                       }
+
+                       /* propagate types to the following block */
+
+                       if (!superblockend) {
+                               if (!typecheck_stackbased_reach(&state, state.bptr->next,
+                                                                                               stack, stack - stackfloor + 1))
+                                       EXCEPTION;
+                       }
+               } /* end loop over blocks */
+
+               while (!state.repeat && state.topjsr) {
+                       LOG1("done analysing subroutine L%03d", state.topjsr->start->nr);
+
+                       /* propagate down used locals */
+
+                       if (state.topjsr->next) {
+                               for (i=0; i<state.numlocals; ++i)
+                                       state.topjsr->next->usedlocals[i] |= state.topjsr->usedlocals[i];
+                       }
+
+                       /* restore REACHED flags */
+
+                       for (tbptr = state.basicblocks; tbptr != NULL; tbptr = tbptr->next) {
+                               assert(tbptr->flags != BBTYPECHECK_REACHED);
+                               if (state.topjsr->blockflags[tbptr->nr] == BBTYPECHECK_REACHED) {
+                                       tbptr->flags = BBTYPECHECK_REACHED;
+                                       state.repeat = true;
+                               }
+                       }
+
+                       /* dactivate the subroutine */
+
+                       state.topjsr->active = false;
+                       state.topjsr = state.topjsr->next;
+               }
+       } while (state.repeat);
+
+       /* reset block flags */
+
+       typecheck_reset_flags(&state);
+
+       LOG("typecheck_stackbased successful");
+
+       return true;
+
+throw_stack_underflow:
+       LOG("STACK UNDERFLOW!");
+       exceptions_throw_verifyerror(state.m, "Unable to pop operand off an empty stack");
+       return false;
+
+throw_stack_overflow:
+       LOG("STACK OVERFLOW!");
+       exceptions_throw_verifyerror(state.m, "Stack size too large");
+       return false;
+
+throw_stack_type_error:
+       LOG("STACK TYPE ERROR!");
+       exceptions_throw_verifyerror(state.m, "Mismatched stack types");
+       return false;
+
+throw_local_type_error:
+       LOG("LOCAL TYPE ERROR!");
+       exceptions_throw_verifyerror(state.m, "Local variable type mismatch");
+       return false;
+
+throw_stack_category_error:
+       LOG("STACK CATEGORY ERROR!");
+       exceptions_throw_verifyerror(state.m, "Attempt to split long or double on the stack");
+       return false;
+}
+
+
+#if defined(TYPECHECK_VERBOSE)
+static void typecheck_stackbased_show_state(verifier_state *state,
+                                                                                       typedescriptor_t *stack,
+                                                                                       typedescriptor_t *stackfloor,
+                                                                                       bool showins)
+{
+       typedescriptor_t *sp;
+       s4 i;
+
+       LOGSTR1("stackdepth %d stack [", (stack - stackfloor) + 1);
+       for (sp=stackfloor; sp <= stack; sp++) {
+               LOGSTR(" ");
+               DOLOG( typedescriptor_print(stdout, sp); );
+       }
+       LOGSTR(" ] locals [");
+       for (i=0; i<state->numlocals; ++i) {
+               LOGSTR(" ");
+               DOLOG( typedescriptor_print(stdout, state->locals + i); );
+       }
+       LOGSTR(" ]");
+       LOGNL;
+       if (showins && state->iptr < (state->bptr->iinstr + state->bptr->icount)) {
+               LOGSTR("\t");
+               DOLOG( show_icmd(state->jd, state->iptr, false, SHOW_PARSE); );
+               LOGNL;
+       }
+}
+#endif
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* defined(ENABLE_VERIFIER) */
+
+
+/*
+ * 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/jit/verify/typecheck-typeinferer.c b/src/vm/jit/verify/typecheck-typeinferer.c
deleted file mode 100644 (file)
index 3500582..0000000
+++ /dev/null
@@ -1,487 +0,0 @@
-/* src/vm/jit/verify/typecheck-typeinferer.c - type inference pass
-
-   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
-
-   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 "vm/types.h"
-#include "vm/global.h"
-
-#include <assert.h>
-#include <string.h>
-
-#include "mm/memory.h"
-
-#include "native/native.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/array.h"
-#include "vm/access.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/primitive.h"
-#include "vm/resolve.h"
-#include "vm/vm.h"
-
-#include "vm/jit/jit.h"
-#include "vm/jit/show.h"
-#include "vm/jit/parse.h"
-
-#include "vm/jit/verify/typecheck-typeinferer.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
-#define TYPECHECK_NO_STATISTICS
-#include <typecheck-common.h>
-
-
-/* macros used by the generated code ******************************************/
-
-#define EXCEPTION          do { return false; } while (0)
-#define VERIFY_ERROR(msg)  assert(false)
-
-#define CHECK_LOCAL_TYPE(index, t)                                   \
-       assert(jd->var[(index)].type == (t));
-
-#define STORE_LOCAL(t, index)                                        \
-    do {                                                             \
-         typevector_store(jd->var, (index), (t), NULL);              \
-    } while (0)
-
-#define STORE_LOCAL_2_WORD(t, index)                                 \
-    do {                                                             \
-         typevector_store(jd->var, (index), (t), NULL);              \
-    } while (0)
-
-#define REACH_BLOCK(target)                                          \
-    do {                                                             \
-        if (!typestate_reach(state, (target),                        \
-                             state->bptr->outvars, jd->var,          \
-                             state->bptr->outdepth))                 \
-                return false;                                        \
-    } while (0)
-
-#define REACH(target)   REACH_BLOCK((target).block)
-
-#define TYPECHECK_INT(v)  assert(jd->var[(v)].type == TYPE_INT)
-#define TYPECHECK_ADR(v)  assert(jd->var[(v)].type == TYPE_ADR)
-
-
-/* handle_fieldaccess **********************************************************
-   Verify an ICMD_{GET,PUT}{STATIC,FIELD}(CONST)?
-  
-   IN:
-       state............the current state of the verifier
-
-   RETURN VALUE:
-       true.............successful verification,
-          false............an exception has been thrown.
-
-*******************************************************************************/
-
-static bool
-handle_fieldaccess(verifier_state *state, 
-                                  varinfo *instance,
-                                  varinfo *value)
-{
-       jitdata *jd;
-
-       jd = state->jd;
-
-#define TYPECHECK_TYPEINFERER
-#include <typecheck-fields.inc>
-#undef  TYPECHECK_TYPEINFERER
-
-       return true;
-}
-
-
-/* handle_invocation ***********************************************************
-   Verify an ICMD_INVOKE* instruction.
-  
-   IN:
-       state............the current state of the verifier
-
-   RETURN VALUE:
-       true.............successful verification,
-          false............an exception has been thrown.
-
-*******************************************************************************/
-
-static bool
-handle_invocation(verifier_state *state)
-{
-       jitdata *jd;
-    varinfo *dv;               /* output variable of current instruction */
-
-       jd = state->jd;
-       dv = VAROP(state->iptr->dst);
-
-#define TYPECHECK_TYPEINFERER
-#define OP1   VAR(state->iptr->sx.s23.s2.args[0])
-#include <typecheck-invoke.inc>
-#undef  OP1
-#undef  TYPECHECK_TYPEINFERER
-
-       return true;
-}
-
-
-/* handle_builtin **************************************************************
-   Verify the call of a builtin method.
-  
-   IN:
-       state............the current state of the verifier
-
-   RETURN VALUE:
-       true.............successful verification,
-          false............an exception has been thrown.
-
-*******************************************************************************/
-
-static bool
-handle_builtin(verifier_state *state)
-{
-       jitdata *jd;
-    varinfo *dv;               /* output variable of current instruction */
-
-       jd = state->jd;
-       dv = VAROP(state->iptr->dst);
-
-#define TYPECHECK_TYPEINFERER
-#define OP1   state->iptr->sx.s23.s2.args[0]
-#include <typecheck-builtins.inc>
-#undef  OP1
-#undef  TYPECHECK_TYPEINFERER
-
-       return true;
-}
-
-/* handle_multianewarray *******************************************************
-   Verify a MULTIANEWARRAY instruction.
-  
-   IN:
-       state............the current state of the verifier
-
-   RETURN VALUE:
-       true.............successful verification,
-          false............an exception has been thrown.
-
-*******************************************************************************/
-
-static bool
-handle_multianewarray(verifier_state *state)
-{
-       jitdata *jd;
-    varinfo *dv;               /* output variable of current instruction */
-
-       jd = state->jd;
-       dv = VAROP(state->iptr->dst);
-
-#define TYPECHECK_TYPEINFERER
-#include <typecheck-multianewarray.inc>
-#undef  TYPECHECK_TYPEINFERER
-
-       return true;
-}
-
-
-/* handle_basic_block **********************************************************
-   Perform bytecode verification of a basic block.
-  
-   IN:
-       state............the current state of the verifier
-
-   RETURN VALUE:
-       true.............successful verification,
-          false............an exception has been thrown.
-
-*******************************************************************************/
-
-static bool
-handle_basic_block(verifier_state *state)
-{
-    int opcode;                                      /* current opcode */
-    int len;                        /* for counting instructions, etc. */
-    bool superblockend;        /* true if no fallthrough to next block */
-       instruction *iptr;                      /* the current instruction */
-    basicblock *tbptr;                   /* temporary for target block */
-    bool maythrow;               /* true if this instruction may throw */
-       s4 i;
-       branch_target_t *table;
-       lookup_target_t *lookup;
-       jitdata *jd = state->jd;
-       exception_entry *ex;
-
-       LOGSTR1("\n---- BLOCK %04d ------------------------------------------------\n",state->bptr->nr);
-       LOGFLUSH;
-       DOLOG(show_basicblock(jd, state->bptr, SHOW_STACK));
-
-       superblockend = false;
-       state->bptr->flags = BBFINISHED;
-
-       /* prevent compiler warnings */
-
-
-       /* determine the active exception handlers for this block */
-       /* XXX could use a faster algorithm with sorted lists or  */
-       /* something?                                             */
-       len = 0;
-       for (ex = state->jd->exceptiontable; ex ; ex = ex->down) {
-               if ((ex->start->nr <= state->bptr->nr) && (ex->end->nr > state->bptr->nr)) {
-                       LOG1("active handler L%03d", ex->handler->nr);
-                       state->handlers[len++] = ex;
-               }
-       }
-       state->handlers[len] = NULL;
-
-       /* init variable types at the start of this block */
-       typevector_copy_inplace(state->bptr->inlocals, jd->var, state->numlocals);
-
-       DOLOG(typecheck_print_vararray(stdout, jd, state->bptr->invars, 
-                               state->bptr->indepth));
-       DOLOG(typevector_print(stdout, jd->var, state->numlocals));
-       LOGNL; LOGFLUSH;
-
-       /* loop over the instructions */
-       len = state->bptr->icount;
-       state->iptr = state->bptr->iinstr;
-       while (--len >= 0)  {
-               TYPECHECK_COUNT(stat_ins);
-
-               iptr = state->iptr;
-
-               DOLOG(typevector_print(stdout, jd->var, state->numlocals));
-               LOGNL; LOGFLUSH;
-               DOLOG(show_icmd(jd, state->iptr, false, SHOW_STACK)); LOGNL; LOGFLUSH;
-
-               opcode = iptr->opc;
-               maythrow = false;
-
-               switch (opcode) {
-
-                       /* include generated code for ICMDs verification */
-
-#define TYPECHECK_TYPEINFERER
-#define STATE  state
-#define METHOD (state->m)
-#define IPTR   iptr
-#define BPTR   (state->bptr)
-#include <typecheck-typeinferer-gen.inc>
-#undef  STATE
-#undef  METHOD
-#undef  IPTR
-#undef  BPTR
-#undef  TYPECHECK_TYPEINFERER
-
-                       default:
-                               vm_abort("missing ICMD in type inferer: %d\n", opcode);
-               }
-
-               /* reach exception handlers for this instruction */
-
-               if (maythrow) {
-                       TYPECHECK_COUNT(stat_ins_maythrow);
-                       TYPECHECK_MARK(state->stat_maythrow);
-                       LOG("reaching exception handlers");
-                       i = 0;
-                       while (state->handlers[i]) {
-                               TYPECHECK_COUNT(stat_handlers_reached);
-                               if (state->handlers[i]->catchtype.any)
-                                       VAR(state->exinvars)->typeinfo.typeclass = state->handlers[i]->catchtype;
-                               else
-                                       VAR(state->exinvars)->typeinfo.typeclass.cls = class_java_lang_Throwable;
-                               if (!typestate_reach(state,
-                                               state->handlers[i]->handler,
-                                               &(state->exinvars), jd->var, 1))
-                                       return false;
-                               i++;
-                       }
-               }
-
-               LOG("\t\tnext instruction");
-               state->iptr++;
-       } /* while instructions */
-
-       LOG("instructions done");
-       LOGSTR("RESULT=> ");
-       DOLOG(typecheck_print_vararray(stdout, jd, state->bptr->outvars,
-                               state->bptr->outdepth));
-       DOLOG(typevector_print(stdout, jd->var, state->numlocals));
-       LOGNL; LOGFLUSH;
-
-       /* propagate stack and variables to the following block */
-       if (!superblockend) {
-               LOG("reaching following block");
-               tbptr = state->bptr->next;
-               while (tbptr->flags == BBDELETED) {
-                       tbptr = tbptr->next;
-               }
-               if (!typestate_reach(state,tbptr,state->bptr->outvars, jd->var,
-                                       state->bptr->outdepth))
-                       return false;
-       }
-
-       return true;
-}
-
-
-bool typecheck_infer_types(jitdata *jd)
-{
-       methodinfo     *meth;
-       codegendata    *cd;
-       varinfo        *savedlocals;
-       verifier_state  state;             /* current state of the verifier */
-
-       /* get required compiler data */
-
-       meth = jd->m;
-       cd   = jd->cd;
-
-       /* some logging on entry */
-
-
-    LOGSTR("\n==============================================================================\n");
-    DOLOG( show_method(jd, SHOW_STACK) );
-    LOGSTR("\n==============================================================================\n");
-    LOGMETHOD("Entering type inference: ",cd->method);
-
-       /* initialize the verifier state */
-
-       state.m = meth;
-       state.jd = jd;
-       state.cd = cd;
-       state.basicblockcount = jd->basicblockcount;
-       state.basicblocks = jd->basicblocks;
-       state.savedindices = NULL;
-       state.savedinvars = NULL;
-
-       /* check that the basicblock numbers are valid */
-
-#if !defined(NDEBUG)
-       jit_check_basicblock_numbers(jd);
-#endif
-
-       /* check if this method is an instance initializer method */
-
-    state.initmethod = (state.m->name == utf_init);
-
-       /* initialize the basic block flags for the following CFG traversal */
-
-       typecheck_init_flags(&state, BBFINISHED);
-
-    /* number of local variables */
-    
-    /* In <init> methods we use an extra local variable to indicate whether */
-    /* the 'this' reference has been initialized.                           */
-       /*         TYPE_VOID...means 'this' has not been initialized,           */
-       /*         TYPE_INT....means 'this' has been initialized.               */
-
-    state.numlocals = state.jd->localcount;
-       state.validlocals = state.numlocals;
-    if (state.initmethod) 
-               state.numlocals++; /* VERIFIER_EXTRA_LOCALS */
-
-    /* allocate the buffer of active exception handlers */
-       
-    state.handlers = DMNEW(exception_entry*, state.jd->exceptiontablelength + 1);
-
-       /* save local variables */
-
-       savedlocals = DMNEW(varinfo, state.numlocals);
-       MCOPY(savedlocals, jd->var, varinfo, state.numlocals);
-
-       /* initialized local variables of first block */
-
-       if (!typecheck_init_locals(&state, false))
-               return false;
-
-    /* initialize invars of exception handlers */
-       
-       state.exinvars = state.numlocals;
-       VAR(state.exinvars)->type = TYPE_ADR;
-       typeinfo_init_classinfo(&(VAR(state.exinvars)->typeinfo),
-                                                       class_java_lang_Throwable); /* changed later */
-
-    LOG("Exception handler stacks set.\n");
-
-    /* loop while there are still blocks to be checked */
-    do {
-               TYPECHECK_COUNT(count_iterations);
-
-        state.repeat = false;
-        
-        state.bptr = state.basicblocks;
-
-        for (; state.bptr; state.bptr = state.bptr->next) {
-            LOGSTR1("---- BLOCK %04d, ",state.bptr->nr);
-            LOGSTR1("blockflags: %d\n",state.bptr->flags);
-            LOGFLUSH;
-            
-                   /* verify reached block */  
-            if (state.bptr->flags == BBTYPECHECK_REACHED) {
-                if (!handle_basic_block(&state))
-                                       return false;
-            }
-        } /* for blocks */
-
-        LOGIF(state.repeat,"state.repeat == true");
-    } while (state.repeat);
-
-       /* statistics */
-       
-       /* reset the flags of blocks we haven't reached */
-
-       typecheck_reset_flags(&state);
-
-       /* restore locals */
-
-       MCOPY(jd->var, savedlocals, varinfo, state.numlocals);
-
-       /* everything's ok */
-
-    LOGimp("exiting type inference");
-       return true;
-}
-
-/*
- * 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/jit/verify/typecheck-typeinferer.cpp b/src/vm/jit/verify/typecheck-typeinferer.cpp
new file mode 100644 (file)
index 0000000..7626890
--- /dev/null
@@ -0,0 +1,492 @@
+/* src/vm/jit/verify/typecheck-typeinferer.c - type inference pass
+
+   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 "vm/types.h"
+#include "vm/global.h"
+
+#include <assert.h>
+#include <string.h>
+
+#include "mm/memory.h"
+
+#include "native/native.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/access.hpp"
+#include "vm/array.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/resolve.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/jit.hpp"
+#include "vm/jit/show.hpp"
+#include "vm/jit/parse.hpp"
+
+#include "vm/jit/verify/typecheck-typeinferer.hpp"
+
+#define TYPECHECK_NO_STATISTICS
+#include "vm/jit/verify/typecheck-common.hpp"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* macros used by the generated code ******************************************/
+
+#define EXCEPTION          do { return false; } while (0)
+#define VERIFY_ERROR(msg)  assert(false)
+
+#define CHECK_LOCAL_TYPE(index, t)                                   \
+       assert(jd->var[(index)].type == (t));
+
+#define STORE_LOCAL(t, index)                                        \
+    do {                                                             \
+         typevector_store(jd->var, (index), (t), NULL);              \
+    } while (0)
+
+#define STORE_LOCAL_2_WORD(t, index)                                 \
+    do {                                                             \
+         typevector_store(jd->var, (index), (t), NULL);              \
+    } while (0)
+
+#define REACH_BLOCK(target)                                          \
+    do {                                                             \
+        if (!typestate_reach(state, (target),                        \
+                             state->bptr->outvars, jd->var,          \
+                             state->bptr->outdepth))                 \
+                return false;                                        \
+    } while (0)
+
+#define REACH(target)   REACH_BLOCK((target).block)
+
+#define TYPECHECK_INT(v)  assert(jd->var[(v)].type == TYPE_INT)
+#define TYPECHECK_ADR(v)  assert(jd->var[(v)].type == TYPE_ADR)
+
+
+/* handle_fieldaccess **********************************************************
+   Verify an ICMD_{GET,PUT}{STATIC,FIELD}(CONST)?
+  
+   IN:
+       state............the current state of the verifier
+
+   RETURN VALUE:
+       true.............successful verification,
+          false............an exception has been thrown.
+
+*******************************************************************************/
+
+static bool
+handle_fieldaccess(verifier_state *state, 
+                                  varinfo *instance,
+                                  varinfo *value)
+{
+       jitdata *jd;
+
+       jd = state->jd;
+
+#define TYPECHECK_TYPEINFERER
+#include <typecheck-fields.inc>
+#undef  TYPECHECK_TYPEINFERER
+
+       return true;
+}
+
+
+/* handle_invocation ***********************************************************
+   Verify an ICMD_INVOKE* instruction.
+  
+   IN:
+       state............the current state of the verifier
+
+   RETURN VALUE:
+       true.............successful verification,
+          false............an exception has been thrown.
+
+*******************************************************************************/
+
+static bool
+handle_invocation(verifier_state *state)
+{
+       jitdata *jd;
+    varinfo *dv;               /* output variable of current instruction */
+
+       jd = state->jd;
+       dv = VAROP(state->iptr->dst);
+
+#define TYPECHECK_TYPEINFERER
+#define OP1   VAR(state->iptr->sx.s23.s2.args[0])
+#include <typecheck-invoke.inc>
+#undef  OP1
+#undef  TYPECHECK_TYPEINFERER
+
+       return true;
+}
+
+
+/* handle_builtin **************************************************************
+   Verify the call of a builtin method.
+  
+   IN:
+       state............the current state of the verifier
+
+   RETURN VALUE:
+       true.............successful verification,
+          false............an exception has been thrown.
+
+*******************************************************************************/
+
+static bool
+handle_builtin(verifier_state *state)
+{
+       jitdata *jd;
+    varinfo *dv;               /* output variable of current instruction */
+
+       jd = state->jd;
+       dv = VAROP(state->iptr->dst);
+
+#define TYPECHECK_TYPEINFERER
+#define OP1   state->iptr->sx.s23.s2.args[0]
+#include <typecheck-builtins.inc>
+#undef  OP1
+#undef  TYPECHECK_TYPEINFERER
+
+       return true;
+}
+
+/* handle_multianewarray *******************************************************
+   Verify a MULTIANEWARRAY instruction.
+  
+   IN:
+       state............the current state of the verifier
+
+   RETURN VALUE:
+       true.............successful verification,
+          false............an exception has been thrown.
+
+*******************************************************************************/
+
+static bool
+handle_multianewarray(verifier_state *state)
+{
+       jitdata *jd;
+    varinfo *dv;               /* output variable of current instruction */
+
+       jd = state->jd;
+       dv = VAROP(state->iptr->dst);
+
+#define TYPECHECK_TYPEINFERER
+#include <typecheck-multianewarray.inc>
+#undef  TYPECHECK_TYPEINFERER
+
+       return true;
+}
+
+
+/* handle_basic_block **********************************************************
+   Perform bytecode verification of a basic block.
+  
+   IN:
+       state............the current state of the verifier
+
+   RETURN VALUE:
+       true.............successful verification,
+          false............an exception has been thrown.
+
+*******************************************************************************/
+
+static bool
+handle_basic_block(verifier_state *state)
+{
+    int opcode;                                      /* current opcode */
+    int len;                        /* for counting instructions, etc. */
+    bool superblockend;        /* true if no fallthrough to next block */
+       instruction *iptr;                      /* the current instruction */
+    basicblock *tbptr;                   /* temporary for target block */
+    bool maythrow;               /* true if this instruction may throw */
+       s4 i;
+       branch_target_t *table;
+       lookup_target_t *lookup;
+       jitdata *jd = state->jd;
+       exception_entry *ex;
+
+       LOGSTR1("\n---- BLOCK %04d ------------------------------------------------\n",state->bptr->nr);
+       LOGFLUSH;
+       DOLOG(show_basicblock(jd, state->bptr, SHOW_STACK));
+
+       superblockend = false;
+       state->bptr->flags = BBFINISHED;
+
+       /* prevent compiler warnings */
+
+
+       /* determine the active exception handlers for this block */
+       /* XXX could use a faster algorithm with sorted lists or  */
+       /* something?                                             */
+       len = 0;
+       for (ex = state->jd->exceptiontable; ex ; ex = ex->down) {
+               if ((ex->start->nr <= state->bptr->nr) && (ex->end->nr > state->bptr->nr)) {
+                       LOG1("active handler L%03d", ex->handler->nr);
+                       state->handlers[len++] = ex;
+               }
+       }
+       state->handlers[len] = NULL;
+
+       /* init variable types at the start of this block */
+       typevector_copy_inplace(state->bptr->inlocals, jd->var, state->numlocals);
+
+       DOLOG(typecheck_print_vararray(stdout, jd, state->bptr->invars, 
+                               state->bptr->indepth));
+       DOLOG(typevector_print(stdout, jd->var, state->numlocals));
+       LOGNL; LOGFLUSH;
+
+       /* loop over the instructions */
+       len = state->bptr->icount;
+       state->iptr = state->bptr->iinstr;
+       while (--len >= 0)  {
+               TYPECHECK_COUNT(stat_ins);
+
+               iptr = state->iptr;
+
+               DOLOG(typevector_print(stdout, jd->var, state->numlocals));
+               LOGNL; LOGFLUSH;
+               DOLOG(show_icmd(jd, state->iptr, false, SHOW_STACK)); LOGNL; LOGFLUSH;
+
+               opcode = iptr->opc;
+               maythrow = false;
+
+               switch (opcode) {
+
+                       /* include generated code for ICMDs verification */
+
+#define TYPECHECK_TYPEINFERER
+#define STATE  state
+#define METHOD (state->m)
+#define IPTR   iptr
+#define BPTR   (state->bptr)
+#include <typecheck-typeinferer-gen.inc>
+#undef  STATE
+#undef  METHOD
+#undef  IPTR
+#undef  BPTR
+#undef  TYPECHECK_TYPEINFERER
+
+                       default:
+                               vm_abort("missing ICMD in type inferer: %d\n", opcode);
+               }
+
+               /* reach exception handlers for this instruction */
+
+               if (maythrow) {
+                       TYPECHECK_COUNT(stat_ins_maythrow);
+                       TYPECHECK_MARK(state->stat_maythrow);
+                       LOG("reaching exception handlers");
+                       i = 0;
+                       while (state->handlers[i]) {
+                               TYPECHECK_COUNT(stat_handlers_reached);
+                               if (state->handlers[i]->catchtype.any)
+                                       VAR(state->exinvars)->typeinfo.typeclass = state->handlers[i]->catchtype;
+                               else
+                                       VAR(state->exinvars)->typeinfo.typeclass.cls = class_java_lang_Throwable;
+                               if (!typestate_reach(state,
+                                               state->handlers[i]->handler,
+                                               &(state->exinvars), jd->var, 1))
+                                       return false;
+                               i++;
+                       }
+               }
+
+               LOG("\t\tnext instruction");
+               state->iptr++;
+       } /* while instructions */
+
+       LOG("instructions done");
+       LOGSTR("RESULT=> ");
+       DOLOG(typecheck_print_vararray(stdout, jd, state->bptr->outvars,
+                               state->bptr->outdepth));
+       DOLOG(typevector_print(stdout, jd->var, state->numlocals));
+       LOGNL; LOGFLUSH;
+
+       /* propagate stack and variables to the following block */
+       if (!superblockend) {
+               LOG("reaching following block");
+               tbptr = state->bptr->next;
+               while (tbptr->flags == BBDELETED) {
+                       tbptr = tbptr->next;
+               }
+               if (!typestate_reach(state,tbptr,state->bptr->outvars, jd->var,
+                                       state->bptr->outdepth))
+                       return false;
+       }
+
+       return true;
+}
+
+
+bool typecheck_infer_types(jitdata *jd)
+{
+       methodinfo     *meth;
+       codegendata    *cd;
+       varinfo        *savedlocals;
+       verifier_state  state;             /* current state of the verifier */
+
+       /* get required compiler data */
+
+       meth = jd->m;
+       cd   = jd->cd;
+
+       /* some logging on entry */
+
+
+    LOGSTR("\n==============================================================================\n");
+    DOLOG( show_method(jd, SHOW_STACK) );
+    LOGSTR("\n==============================================================================\n");
+    LOGMETHOD("Entering type inference: ",cd->method);
+
+       /* initialize the verifier state */
+
+       state.m = meth;
+       state.jd = jd;
+       state.cd = cd;
+       state.basicblockcount = jd->basicblockcount;
+       state.basicblocks = jd->basicblocks;
+       state.savedindices = NULL;
+       state.savedinvars = NULL;
+
+       /* check that the basicblock numbers are valid */
+
+#if !defined(NDEBUG)
+       jit_check_basicblock_numbers(jd);
+#endif
+
+       /* check if this method is an instance initializer method */
+
+    state.initmethod = (state.m->name == utf_init);
+
+       /* initialize the basic block flags for the following CFG traversal */
+
+       typecheck_init_flags(&state, BBFINISHED);
+
+    /* number of local variables */
+    
+    /* In <init> methods we use an extra local variable to indicate whether */
+    /* the 'this' reference has been initialized.                           */
+       /*         TYPE_VOID...means 'this' has not been initialized,           */
+       /*         TYPE_INT....means 'this' has been initialized.               */
+
+    state.numlocals = state.jd->localcount;
+       state.validlocals = state.numlocals;
+    if (state.initmethod) 
+               state.numlocals++; /* VERIFIER_EXTRA_LOCALS */
+
+    /* allocate the buffer of active exception handlers */
+       
+    state.handlers = (exception_entry**) DumpMemory::allocate(sizeof(exception_entry*) * (state.jd->exceptiontablelength + 1));
+
+       /* save local variables */
+
+       savedlocals = (varinfo*) DumpMemory::allocate(sizeof(varinfo) * state.numlocals);
+       MCOPY(savedlocals, jd->var, varinfo, state.numlocals);
+
+       /* initialized local variables of first block */
+
+       if (!typecheck_init_locals(&state, false))
+               return false;
+
+    /* initialize invars of exception handlers */
+       
+       state.exinvars = state.numlocals;
+       VAR(state.exinvars)->type = TYPE_ADR;
+       typeinfo_init_classinfo(&(VAR(state.exinvars)->typeinfo),
+                                                       class_java_lang_Throwable); /* changed later */
+
+    LOG("Exception handler stacks set.\n");
+
+    /* loop while there are still blocks to be checked */
+    do {
+               TYPECHECK_COUNT(count_iterations);
+
+        state.repeat = false;
+        
+        state.bptr = state.basicblocks;
+
+        for (; state.bptr; state.bptr = state.bptr->next) {
+            LOGSTR1("---- BLOCK %04d, ",state.bptr->nr);
+            LOGSTR1("blockflags: %d\n",state.bptr->flags);
+            LOGFLUSH;
+            
+                   /* verify reached block */  
+            if (state.bptr->flags == BBTYPECHECK_REACHED) {
+                if (!handle_basic_block(&state))
+                                       return false;
+            }
+        } /* for blocks */
+
+        LOGIF(state.repeat,"state.repeat == true");
+    } while (state.repeat);
+
+       /* statistics */
+       
+       /* reset the flags of blocks we haven't reached */
+
+       typecheck_reset_flags(&state);
+
+       /* restore locals */
+
+       MCOPY(jd->var, savedlocals, varinfo, state.numlocals);
+
+       /* everything's ok */
+
+    LOGimp("exiting type inference");
+       return true;
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+/*
+ * 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/jit/verify/typecheck-typeinferer.h b/src/vm/jit/verify/typecheck-typeinferer.h
deleted file mode 100644 (file)
index 530a5e1..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* src/vm/jit/verify/typecheck-typeinferer.h - type inference header
-
-   Copyright (C) 1996-2005, 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
-
-   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.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Edwin Steiner
-
-
-*/
-
-
-#ifndef _TYPECHECK_TYPEINFERER_H
-#define _TYPECHECK_TYPEINFERER_H
-
-#include "config.h"
-
-#include "vm/global.h"
-#include "vm/jit/jit.h"
-
-
-/* function prototypes ********************************************************/
-
-#if defined(ENABLE_VERIFIER)
-bool typecheck_infer_types(jitdata *jd);
-#endif
-
-#endif /* _TYPECHECK_TYPEINFERER_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:
- */
diff --git a/src/vm/jit/verify/typecheck-typeinferer.hpp b/src/vm/jit/verify/typecheck-typeinferer.hpp
new file mode 100644 (file)
index 0000000..a3e79b8
--- /dev/null
@@ -0,0 +1,69 @@
+/* src/vm/jit/verify/typecheck-typeinferer.h - type inference header
+
+   Copyright (C) 1996-2005, 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
+
+   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.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Edwin Steiner
+
+
+*/
+
+
+#ifndef _TYPECHECK_TYPEINFERER_H
+#define _TYPECHECK_TYPEINFERER_H
+
+#include "config.h"
+
+#include "vm/global.h"
+#include "vm/jit/jit.hpp"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* function prototypes ********************************************************/
+
+#if defined(ENABLE_VERIFIER)
+bool typecheck_infer_types(jitdata *jd);
+#endif
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* _TYPECHECK_TYPEINFERER_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:
+ */
diff --git a/src/vm/jit/verify/typecheck.c b/src/vm/jit/verify/typecheck.c
deleted file mode 100644 (file)
index e679e95..0000000
+++ /dev/null
@@ -1,833 +0,0 @@
-/* src/vm/jit/verify/typecheck.c - typechecking (part of bytecode verification)
-
-   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.
-
-*/
-
-/*
-
-What's the purpose of the `typechecker`?
-----------------------------------------
-
-The typechecker analyses (the intermediate repr. of) the bytecode of
-each method and ensures that for each instruction the values on the
-stack and in local variables are of the correct type whenever the
-instruction is executed.
-
-type checking is a mandatory part of bytecode verification.
-
-
-How does the typechecker work?
-------------------------------
-
-The JVM stack and the local variables are not statically typed, so the
-typechecker has to *infer* the static types of stack slots and local
-variables at each point of the method. The JVM spec imposes a lot of
-restrictions on the bytecode in order to guarantee that this is always
-possible.
-
-Basically the typechecker solves the data flow equations of the method.
-This is done in the usual way for a forward data flow analysis: Starting
-from the entry point of the method the typechecker follows the CFG and
-records the type of each stack slot and local variable at each point[1].
-When two or more control flow paths merge at a point, the union of the
-types for each slot/variable is taken. The algorithm continues to follow
-all possible paths[2] until the recorded types do not change anymore (ie.
-the equations have been solved).
-
-If the solution has been reached and the resulting types are valid for
-all instructions, then type checking terminates with success, otherwise
-an exception is thrown.
-
-
-Why is this code so damn complicated?
--------------------------------------
-
-Short answer: The devil's in the details.
-
-While the basic operation of the typechecker is no big deal, there are
-many properties of Java bytecode which make type checking hard. Some of
-them are not even addressed in the JVM spec. Some problems and their
-solutions:
-
-*) Finding a good representation of the union of two reference types is
-difficult because of multiple inheritance of interfaces. 
-
-       Solution: The typeinfo system can represent such "merged" types by a
-       list of proper subclasses of a class. Example:
-
-               typeclass=java.lang.Object merged={ InterfaceA, InterfaceB }
-       
-       represents the result of merging two interface types "InterfaceA"
-       and "InterfaceB".
-
-*) When the code of a method is verified, there may still be unresolved
-references to classes/methods/fields in the code, which we may not force
-to be resolved eagerly. (A similar problem arises because of the special
-checks for protected members.)
-
-       Solution: The typeinfo system knows how to deal with unresolved
-       class references. Whenever a check has to be performed for an
-       unresolved type, the type is annotated with constraints representing
-       the check. Later, when the type is resolved, the constraints are
-       checked. (See the constrain_unresolved_... and the resolve_...
-       methods.)[3]
-
-*) Checks for uninitialized object instances are hard because after the
-invocation of <init> on an uninitialized object *all* slots/variables
-referring to this object (and exactly those slots/variables) must be
-marked as initialized.
-
-       Solution: The JVM spec describes a solution, which has been
-       implemented in this typechecker.
-
-Note that some checks mentioned in the JVM spec are unnecessary[4] and
-not performed by either the reference implementation, or this implementation.
-
-
---- Footnotes
-
-[1] Actually only the types of slots/variables at the start of each
-basic block are remembered. Within a basic block the algorithm only keeps
-the types of the slots/variables for the "current" instruction which is
-being analysed. 
-
-[2] Actually the algorithm iterates through the basic block list until
-there are no more changes. Theoretically it would be wise to sort the
-basic blocks topologically beforehand, but the number of average/max
-iterations observed is so low, that this was not deemed necessary.
-
-[3] This is similar to a method proposed by: Alessandro Coglio et al., A
-Formal Specification of Java Class Loading, Technical Report, Kestrel
-Institute April 2000, revised July 2000 
-http://www.kestrel.edu/home/people/coglio/loading.pdf
-An important difference is that Coglio's subtype constraints are checked
-after loading, while our constraints are checked when the field/method
-is accessed for the first time, so we can guarantee lexically correct
-error reporting.
-
-[4] Alessandro Coglio
-    Improving the official specification of Java bytecode verification
-    Proceedings of the 3rd ECOOP Workshop on Formal Techniques for Java Programs
-    June 2001
-    citeseer.ist.psu.edu/article/coglio03improving.html
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#ifdef ENABLE_VERIFIER
-
-#include "mm/memory.h"
-
-#include "native/native.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/access.h"
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/primitive.h"
-#include "vm/resolve.h"
-
-#include "vm/jit/jit.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/show.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
-#include <typecheck-common.h>
-
-
-/****************************************************************************/
-/* MACROS FOR VARIABLE TYPE CHECKING                                        */
-/****************************************************************************/
-
-#define TYPECHECK_CHECK_TYPE(i,tp,msg)                               \
-    do {                                                             \
-        if (VAR(i)->type != (tp)) {                                  \
-            exceptions_throw_verifyerror(state->m, (msg));           \
-            return false;                                            \
-        }                                                            \
-    } while (0)
-
-#define TYPECHECK_INT(i)                                             \
-    TYPECHECK_CHECK_TYPE(i,TYPE_INT,"Expected to find integer value")
-#define TYPECHECK_LNG(i)                                             \
-    TYPECHECK_CHECK_TYPE(i,TYPE_LNG,"Expected to find long value")
-#define TYPECHECK_FLT(i)                                             \
-    TYPECHECK_CHECK_TYPE(i,TYPE_FLT,"Expected to find float value")
-#define TYPECHECK_DBL(i)                                             \
-    TYPECHECK_CHECK_TYPE(i,TYPE_DBL,"Expected to find double value")
-#define TYPECHECK_ADR(i)                                             \
-    TYPECHECK_CHECK_TYPE(i,TYPE_ADR,"Expected to find object value")
-
-#define TYPECHECK_INT_OP(o)  TYPECHECK_INT((o).varindex)
-#define TYPECHECK_LNG_OP(o)  TYPECHECK_LNG((o).varindex)
-#define TYPECHECK_FLT_OP(o)  TYPECHECK_FLT((o).varindex)
-#define TYPECHECK_DBL_OP(o)  TYPECHECK_DBL((o).varindex)
-#define TYPECHECK_ADR_OP(o)  TYPECHECK_ADR((o).varindex)
-
-
-/* typestate_save_invars *******************************************************
-   Save the invars of the current basic block in the space reserved by
-   parse.
-
-   This function must be called before an instruction modifies a variable
-   that is an invar of the current block. In such cases the invars of the
-   block must be saved, and restored at the end of the analysis of this
-   basic block, so that the invars again reflect the *input* to this basic
-   block (and do not randomly contain types that appear within the block).
-
-   IN:
-       state............current state of the verifier
-
-*******************************************************************************/
-
-static void
-typestate_save_invars(verifier_state *state)
-{
-       s4 i, index;
-       s4 *pindex;
-       
-       LOG("saving invars");
-
-       if (!state->savedindices) {
-               LOG("allocating savedindices buffer");
-               pindex = DMNEW(s4, state->m->maxstack);
-               state->savedindices = pindex;
-               index = state->numlocals + VERIFIER_EXTRA_VARS;
-               for (i=0; i<state->m->maxstack; ++i)
-                       *pindex++ = index++;
-       }
-
-       /* save types */
-
-       typecheck_copy_types(state, state->bptr->invars, state->savedindices, 
-                       state->bptr->indepth);
-
-       /* set the invars of the block to the saved variables */
-       /* and remember the original invars                   */
-
-       state->savedinvars = state->bptr->invars;
-       state->bptr->invars = state->savedindices;
-}
-
-
-/* typestate_restore_invars  ***************************************************
-   Restore the invars of the current basic block that have been previously
-   saved by `typestate_save_invars`.
-
-   IN:
-       state............current state of the verifier
-
-*******************************************************************************/
-
-static void
-typestate_restore_invars(verifier_state *state)
-{
-       TYPECHECK_COUNT(stat_savedstack);
-       LOG("restoring saved invars");
-
-       /* restore the invars pointer */
-
-       state->bptr->invars = state->savedinvars;
-
-       /* copy the types back */
-
-       typecheck_copy_types(state, state->savedindices, state->bptr->invars,
-                       state->bptr->indepth);
-
-       /* mark that there are no saved invars currently */
-
-       state->savedinvars = NULL;
-}
-
-
-/* handle_fieldaccess **********************************************************
-   Verify an ICMD_{GET,PUT}{STATIC,FIELD}(CONST)?
-  
-   IN:
-       state............the current state of the verifier
-
-   RETURN VALUE:
-       true.............successful verification,
-          false............an exception has been thrown.
-
-*******************************************************************************/
-
-static bool
-handle_fieldaccess(verifier_state *state,
-                                  varinfo *instance,
-                                  varinfo *value)
-{
-       jitdata *jd;
-
-       jd = state->jd;
-
-#define TYPECHECK_VARIABLESBASED
-#define EXCEPTION  do { return false; } while (0)
-#define VERIFY_ERROR(msg)  TYPECHECK_VERIFYERROR_bool(msg)
-#include <typecheck-fields.inc>
-#undef  EXCEPTION
-#undef  VERIFY_ERROR
-#undef  TYPECHECK_VARIABLESBASED
-
-       return true;
-}
-
-
-/* handle_invocation ***********************************************************
-   Verify an ICMD_INVOKE* instruction.
-  
-   IN:
-       state............the current state of the verifier
-
-   RETURN VALUE:
-       true.............successful verification,
-          false............an exception has been thrown.
-
-*******************************************************************************/
-
-static bool
-handle_invocation(verifier_state *state)
-{
-       jitdata *jd;
-    varinfo *dv;               /* output variable of current instruction */
-
-       jd = state->jd;
-       dv = VAROP(state->iptr->dst);
-
-#define TYPECHECK_VARIABLESBASED
-#define OP1   VAR(state->iptr->sx.s23.s2.args[0])
-#include <typecheck-invoke.inc>
-#undef  OP1
-#undef  TYPECHECK_VARIABLESBASED
-
-       return true;
-}
-
-
-/* handle_builtin **************************************************************
-   Verify the call of a builtin method.
-  
-   IN:
-       state............the current state of the verifier
-
-   RETURN VALUE:
-       true.............successful verification,
-          false............an exception has been thrown.
-
-*******************************************************************************/
-
-static bool
-handle_builtin(verifier_state *state)
-{
-       jitdata *jd;
-    varinfo *dv;               /* output variable of current instruction */
-
-       jd = state->jd;
-       dv = VAROP(state->iptr->dst);
-
-#define TYPECHECK_VARIABLESBASED
-#define OP1   state->iptr->sx.s23.s2.args[0]
-#include <typecheck-builtins.inc>
-#undef  OP1
-#undef  TYPECHECK_VARIABLESBASED
-
-       return true;
-}
-
-/* handle_multianewarray *******************************************************
-   Verify a MULTIANEWARRAY instruction.
-  
-   IN:
-       state............the current state of the verifier
-
-   RETURN VALUE:
-       true.............successful verification,
-          false............an exception has been thrown.
-
-*******************************************************************************/
-
-static bool
-handle_multianewarray(verifier_state *state)
-{
-       jitdata *jd;
-    varinfo *dv;               /* output variable of current instruction */
-
-       jd = state->jd;
-       dv = VAROP(state->iptr->dst);
-
-#define TYPECHECK_VARIABLESBASED
-#define VERIFY_ERROR(msg)  TYPECHECK_VERIFYERROR_bool(msg)
-#include <typecheck-multianewarray.inc>
-#undef VERIFY_ERROR
-#undef  TYPECHECK_VARIABLESBASED
-
-       return true;
-}
-
-/* typecheck_invalidate_locals *************************************************
-   Invalidate locals that are overwritten by writing to the given local.
-  
-   IN:
-       state............the current state of the verifier
-          index............the index of the local that is written
-          twoword..........true, if a two-word type is written
-
-*******************************************************************************/
-
-static void typecheck_invalidate_locals(verifier_state *state, s4 index, bool twoword)
-{
-       s4 javaindex;
-       s4 t;
-       s4 varindex;
-       jitdata *jd = state->jd;
-       s4 *localmap = jd->local_map;
-       varinfo *vars = jd->var;
-
-       javaindex = jd->reverselocalmap[index];
-
-       /* invalidate locals of two-word type at index javaindex-1 */
-
-       if (javaindex > 0) {
-               localmap += 5 * (javaindex-1);
-               for (t=0; t<5; ++t) {
-                       varindex = *localmap++;
-                       if (varindex >= 0 && IS_2_WORD_TYPE(vars[varindex].type)) {
-                               LOG1("invalidate local %d", varindex);
-                               vars[varindex].type = TYPE_VOID;
-                       }
-               }
-       }
-       else {
-               localmap += 5 * javaindex;
-       }
-
-       /* invalidate locals at index javaindex */
-
-       for (t=0; t<5; ++t) {
-               varindex = *localmap++;
-               if (varindex >= 0) {
-                       LOG1("invalidate local %d", varindex);
-                       vars[varindex].type = TYPE_VOID;
-               }
-       }
-
-       /* if a two-word type is written, invalidate locals at index javaindex+1 */
-
-       if (twoword) {
-               for (t=0; t<5; ++t) {
-                       varindex = *localmap++;
-                       if (varindex >= 0) {
-                               LOG1("invalidate local %d", varindex);
-                               vars[varindex].type = TYPE_VOID;
-                       }
-               }
-       }
-}
-
-
-/* macros used by the generated code ******************************************/
-
-#define EXCEPTION          do { return false; } while (0)
-#define VERIFY_ERROR(msg)  TYPECHECK_VERIFYERROR_bool(msg)
-
-#define CHECK_LOCAL_TYPE(index, t)                                   \
-    do {                                                             \
-        if (!typevector_checktype(jd->var, (index), (t)))            \
-             VERIFY_ERROR("Local variable type mismatch");           \
-    } while (0)
-
-#define STORE_LOCAL(t, index)                                        \
-    do {                                                             \
-         s4 temp_t = (t);                                            \
-         typecheck_invalidate_locals(state, (index), false);         \
-         typevector_store(jd->var, (index), (temp_t), NULL);         \
-    } while (0)
-
-#define STORE_LOCAL_2_WORD(t, index)                                 \
-    do {                                                             \
-         s4 temp_t = (t);                                            \
-         typecheck_invalidate_locals(state, (index), true);          \
-         typevector_store(jd->var, (index), (temp_t), NULL);         \
-    } while (0)
-
-#define REACH_BLOCK(target)                                          \
-    do {                                                             \
-        if (!typestate_reach(state, (target),                        \
-                             state->bptr->outvars, jd->var,          \
-                             state->bptr->outdepth))                 \
-                return false;                                        \
-    } while (0)
-
-#define REACH(target)   REACH_BLOCK((target).block)
-
-
-/* handle_basic_block **********************************************************
-   Perform bytecode verification of a basic block.
-  
-   IN:
-       state............the current state of the verifier
-
-   RETURN VALUE:
-       true.............successful verification,
-          false............an exception has been thrown.
-
-*******************************************************************************/
-
-static bool
-handle_basic_block(verifier_state *state)
-{
-    int opcode;                                      /* current opcode */
-    int len;                        /* for counting instructions, etc. */
-    bool superblockend;        /* true if no fallthrough to next block */
-       instruction *iptr;                      /* the current instruction */
-    basicblock *tbptr;                   /* temporary for target block */
-    bool maythrow;               /* true if this instruction may throw */
-       s4 i;
-       typecheck_result r;
-       branch_target_t *table;
-       lookup_target_t *lookup;
-       jitdata *jd = state->jd;
-       exception_entry *ex;
-       varinfo constvalue;                               /* for PUT*CONST */
-       constant_FMIref *fieldref;
-
-       LOGSTR1("\n---- BLOCK %04d ------------------------------------------------\n",state->bptr->nr);
-       LOGFLUSH;
-
-       superblockend = false;
-       state->bptr->flags = BBFINISHED;
-
-       /* prevent compiler warnings */
-
-
-       /* determine the active exception handlers for this block */
-       /* XXX could use a faster algorithm with sorted lists or  */
-       /* something?                                             */
-       len = 0;
-       for (ex = state->jd->exceptiontable; ex ; ex = ex->down) {
-               if ((ex->start->nr <= state->bptr->nr) && (ex->end->nr > state->bptr->nr)) {
-                       LOG1("active handler L%03d", ex->handler->nr);
-                       state->handlers[len++] = ex;
-               }
-       }
-       state->handlers[len] = NULL;
-
-       /* init variable types at the start of this block */
-       typevector_copy_inplace(state->bptr->inlocals, jd->var, state->numlocals);
-
-       DOLOG(show_basicblock(jd, state->bptr, SHOW_STACK));
-       DOLOG(typecheck_print_vararray(stdout, jd, state->bptr->invars, 
-                               state->bptr->indepth));
-       DOLOG(typevector_print(stdout, jd->var, state->numlocals));
-       LOGNL; LOGFLUSH;
-
-       /* loop over the instructions */
-       len = state->bptr->icount;
-       state->iptr = state->bptr->iinstr;
-       while (--len >= 0)  {
-               TYPECHECK_COUNT(stat_ins);
-
-               iptr = state->iptr;
-
-               DOLOG(typevector_print(stdout, jd->var, state->numlocals));
-               LOGNL; LOGFLUSH;
-               DOLOG(show_icmd(jd, state->iptr, false, SHOW_STACK)); LOGNL; LOGFLUSH;
-
-               opcode = iptr->opc;
-               maythrow = false;
-
-               switch (opcode) {
-
-                       /* include generated code for ICMDs verification */
-
-#define TYPECHECK_VARIABLESBASED
-#define STATE  state
-#define METHOD (state->m)
-#define IPTR   iptr
-#define BPTR   (state->bptr)
-#include <typecheck-variablesbased-gen.inc>
-#undef  STATE
-#undef  METHOD
-#undef  IPTR
-#undef  BPTR
-#undef  TYPECHECK_VARIABLESBASED
-
-                       default:
-                               LOG1("ICMD %d\n", opcode);
-                               TYPECHECK_VERIFYERROR_bool("Missing ICMD code during typecheck");
-               }
-
-               /* reach exception handlers for this instruction */
-
-               if (maythrow) {
-                       TYPECHECK_COUNT(stat_ins_maythrow);
-                       TYPECHECK_MARK(state->stat_maythrow);
-                       LOG("reaching exception handlers");
-                       i = 0;
-                       while (state->handlers[i]) {
-                               TYPECHECK_COUNT(stat_handlers_reached);
-                               if (state->handlers[i]->catchtype.any)
-                                       VAR(state->exinvars)->typeinfo.typeclass = state->handlers[i]->catchtype;
-                               else
-                                       VAR(state->exinvars)->typeinfo.typeclass.cls = class_java_lang_Throwable;
-                               if (!typestate_reach(state,
-                                               state->handlers[i]->handler,
-                                               &(state->exinvars), jd->var, 1))
-                                       return false;
-                               i++;
-                       }
-               }
-
-               LOG("\t\tnext instruction");
-               state->iptr++;
-       } /* while instructions */
-
-       LOG("instructions done");
-       LOGSTR("RESULT=> ");
-       DOLOG(typecheck_print_vararray(stdout, jd, state->bptr->outvars,
-                               state->bptr->outdepth));
-       DOLOG(typevector_print(stdout, jd->var, state->numlocals));
-       LOGNL; LOGFLUSH;
-
-       /* propagate stack and variables to the following block */
-       if (!superblockend) {
-               LOG("reaching following block");
-               tbptr = state->bptr->next;
-               while (tbptr->flags == BBDELETED) {
-                       tbptr = tbptr->next;
-#ifdef TYPECHECK_DEBUG
-                       /* this must be checked in parse.c */
-                       if ((tbptr->nr) >= state->basicblockcount)
-                               TYPECHECK_VERIFYERROR_bool("Control flow falls off the last block");
-#endif
-               }
-               if (!typestate_reach(state,tbptr,state->bptr->outvars, jd->var,
-                                       state->bptr->outdepth))
-                       return false;
-       }
-
-       /* We may have to restore the types of the instack slots. They
-        * have been saved if an <init> call inside the block has
-        * modified the instack types. (see INVOKESPECIAL) */
-
-       if (state->savedinvars)
-               typestate_restore_invars(state);
-
-       return true;
-}
-
-
-/****************************************************************************/
-/* typecheck()                                                              */
-/* This is the main function of the bytecode verifier. It is called         */
-/* directly after analyse_stack.                                            */
-/*                                                                          */
-/* IN:                                                                      */
-/*    meth.............the method to verify                                 */
-/*    cdata............codegendata for the method                           */
-/*    rdata............registerdata for the method                          */
-/*                                                                          */
-/* RETURN VALUE:                                                            */
-/*     true.............successful verification                             */
-/*     false............an exception has been thrown                        */
-/*                                                                          */
-/****************************************************************************/
-
-#define MAXPARAMS 255
-
-bool typecheck(jitdata *jd)
-{
-       methodinfo     *meth;
-       codegendata    *cd;
-       varinfo        *savedlocals;
-       verifier_state  state;             /* current state of the verifier */
-
-       /* collect statistics */
-
-#ifdef TYPECHECK_STATISTICS
-       int count_iterations = 0;
-       TYPECHECK_COUNT(stat_typechecked);
-       TYPECHECK_COUNT_FREQ(stat_locals,jd->maxlocals,STAT_LOCALS);
-       TYPECHECK_COUNT_FREQ(stat_blocks,cdata->method->basicblockcount/10,STAT_BLOCKS);
-       TYPECHECK_COUNTIF(cdata->method->exceptiontablelength != 0,stat_methods_with_handlers);
-       state.stat_maythrow = false;
-#endif
-
-       /* get required compiler data */
-
-       meth = jd->m;
-       cd   = jd->cd;
-
-       /* some logging on entry */
-
-
-    LOGSTR("\n==============================================================================\n");
-    DOLOG( show_method(jd, SHOW_STACK) );
-    LOGSTR("\n==============================================================================\n");
-    LOGMETHOD("Entering typecheck: ",cd->method);
-
-       /* initialize the verifier state */
-
-       state.m = meth;
-       state.jd = jd;
-       state.cd = cd;
-       state.basicblockcount = jd->basicblockcount;
-       state.basicblocks = jd->basicblocks;
-       state.savedindices = NULL;
-       state.savedinvars = NULL;
-
-       /* check that the basicblock numbers are valid */
-
-#if !defined(NDEBUG)
-       jit_check_basicblock_numbers(jd);
-#endif
-
-       /* check if this method is an instance initializer method */
-
-    state.initmethod = (state.m->name == utf_init);
-
-       /* initialize the basic block flags for the following CFG traversal */
-
-       typecheck_init_flags(&state, BBFINISHED);
-
-    /* number of local variables */
-    
-    /* In <init> methods we use an extra local variable to indicate whether */
-    /* the 'this' reference has been initialized.                           */
-       /*         TYPE_VOID...means 'this' has not been initialized,           */
-       /*         TYPE_INT....means 'this' has been initialized.               */
-
-    state.numlocals = state.jd->localcount;
-       state.validlocals = state.numlocals;
-    if (state.initmethod) 
-               state.numlocals++; /* VERIFIER_EXTRA_LOCALS */
-
-       DOLOG(
-               s4 i;
-               s4 t;
-               LOG("reverselocalmap:");
-               for (i=0; i<state.validlocals; ++i) {
-                       LOG2("    %i => javaindex %i", i, jd->reverselocalmap[i]);
-               });
-
-    /* allocate the buffer of active exception handlers */
-       
-    state.handlers = DMNEW(exception_entry*, state.jd->exceptiontablelength + 1);
-
-       /* save local variables */
-
-       savedlocals = DMNEW(varinfo, state.numlocals);
-       MCOPY(savedlocals, jd->var, varinfo, state.numlocals);
-
-       /* initialized local variables of first block */
-
-       if (!typecheck_init_locals(&state, true))
-               return false;
-
-    /* initialize invars of exception handlers */
-       
-       state.exinvars = state.numlocals;
-       VAR(state.exinvars)->type = TYPE_ADR;
-       typeinfo_init_classinfo(&(VAR(state.exinvars)->typeinfo),
-                                                       class_java_lang_Throwable); /* changed later */
-
-    LOG("Exception handler stacks set.\n");
-
-    /* loop while there are still blocks to be checked */
-    do {
-               TYPECHECK_COUNT(count_iterations);
-
-        state.repeat = false;
-        
-        state.bptr = state.basicblocks;
-
-        for (; state.bptr; state.bptr = state.bptr->next) {
-            LOGSTR1("---- BLOCK %04d, ",state.bptr->nr);
-            LOGSTR1("blockflags: %d\n",state.bptr->flags);
-            LOGFLUSH;
-            
-                   /* verify reached block */  
-            if (state.bptr->flags == BBTYPECHECK_REACHED) {
-                if (!handle_basic_block(&state))
-                                       return false;
-            }
-        } /* for blocks */
-
-        LOGIF(state.repeat,"state.repeat == true");
-    } while (state.repeat);
-
-       /* statistics */
-       
-#ifdef TYPECHECK_STATISTICS
-       LOG1("Typechecker did %4d iterations",count_iterations);
-       TYPECHECK_COUNT_FREQ(stat_iterations,count_iterations,STAT_ITERATIONS);
-       TYPECHECK_COUNTIF(state.jsrencountered,stat_typechecked_jsr);
-       TYPECHECK_COUNTIF(state.stat_maythrow,stat_methods_maythrow);
-#endif
-
-       /* reset the flags of blocks we haven't reached */
-
-       typecheck_reset_flags(&state);
-
-       /* restore locals */
-
-       MCOPY(jd->var, savedlocals, varinfo, state.numlocals);
-
-       /* everything's ok */
-
-    LOGimp("exiting typecheck");
-       return true;
-}
-#endif /* ENABLE_VERIFIER */
-
-/*
- * 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/jit/verify/typecheck.cpp b/src/vm/jit/verify/typecheck.cpp
new file mode 100644 (file)
index 0000000..d63c422
--- /dev/null
@@ -0,0 +1,841 @@
+/* src/vm/jit/verify/typecheck.c - typechecking (part of bytecode verification)
+
+   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.
+
+*/
+
+/*
+
+What's the purpose of the `typechecker`?
+----------------------------------------
+
+The typechecker analyses (the intermediate repr. of) the bytecode of
+each method and ensures that for each instruction the values on the
+stack and in local variables are of the correct type whenever the
+instruction is executed.
+
+type checking is a mandatory part of bytecode verification.
+
+
+How does the typechecker work?
+------------------------------
+
+The JVM stack and the local variables are not statically typed, so the
+typechecker has to *infer* the static types of stack slots and local
+variables at each point of the method. The JVM spec imposes a lot of
+restrictions on the bytecode in order to guarantee that this is always
+possible.
+
+Basically the typechecker solves the data flow equations of the method.
+This is done in the usual way for a forward data flow analysis: Starting
+from the entry point of the method the typechecker follows the CFG and
+records the type of each stack slot and local variable at each point[1].
+When two or more control flow paths merge at a point, the union of the
+types for each slot/variable is taken. The algorithm continues to follow
+all possible paths[2] until the recorded types do not change anymore (ie.
+the equations have been solved).
+
+If the solution has been reached and the resulting types are valid for
+all instructions, then type checking terminates with success, otherwise
+an exception is thrown.
+
+
+Why is this code so damn complicated?
+-------------------------------------
+
+Short answer: The devil's in the details.
+
+While the basic operation of the typechecker is no big deal, there are
+many properties of Java bytecode which make type checking hard. Some of
+them are not even addressed in the JVM spec. Some problems and their
+solutions:
+
+*) Finding a good representation of the union of two reference types is
+difficult because of multiple inheritance of interfaces. 
+
+       Solution: The typeinfo system can represent such "merged" types by a
+       list of proper subclasses of a class. Example:
+
+               typeclass=java.lang.Object merged={ InterfaceA, InterfaceB }
+       
+       represents the result of merging two interface types "InterfaceA"
+       and "InterfaceB".
+
+*) When the code of a method is verified, there may still be unresolved
+references to classes/methods/fields in the code, which we may not force
+to be resolved eagerly. (A similar problem arises because of the special
+checks for protected members.)
+
+       Solution: The typeinfo system knows how to deal with unresolved
+       class references. Whenever a check has to be performed for an
+       unresolved type, the type is annotated with constraints representing
+       the check. Later, when the type is resolved, the constraints are
+       checked. (See the constrain_unresolved_... and the resolve_...
+       methods.)[3]
+
+*) Checks for uninitialized object instances are hard because after the
+invocation of <init> on an uninitialized object *all* slots/variables
+referring to this object (and exactly those slots/variables) must be
+marked as initialized.
+
+       Solution: The JVM spec describes a solution, which has been
+       implemented in this typechecker.
+
+Note that some checks mentioned in the JVM spec are unnecessary[4] and
+not performed by either the reference implementation, or this implementation.
+
+
+--- Footnotes
+
+[1] Actually only the types of slots/variables at the start of each
+basic block are remembered. Within a basic block the algorithm only keeps
+the types of the slots/variables for the "current" instruction which is
+being analysed. 
+
+[2] Actually the algorithm iterates through the basic block list until
+there are no more changes. Theoretically it would be wise to sort the
+basic blocks topologically beforehand, but the number of average/max
+iterations observed is so low, that this was not deemed necessary.
+
+[3] This is similar to a method proposed by: Alessandro Coglio et al., A
+Formal Specification of Java Class Loading, Technical Report, Kestrel
+Institute April 2000, revised July 2000 
+http://www.kestrel.edu/home/people/coglio/loading.pdf
+An important difference is that Coglio's subtype constraints are checked
+after loading, while our constraints are checked when the field/method
+is accessed for the first time, so we can guarantee lexically correct
+error reporting.
+
+[4] Alessandro Coglio
+    Improving the official specification of Java bytecode verification
+    Proceedings of the 3rd ECOOP Workshop on Formal Techniques for Java Programs
+    June 2001
+    citeseer.ist.psu.edu/article/coglio03improving.html
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#ifdef ENABLE_VERIFIER
+
+#include "mm/memory.h"
+
+#include "native/native.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/access.hpp"
+#include "vm/array.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/resolve.hpp"
+
+#include "vm/jit/jit.hpp"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/show.hpp"
+
+#include "vm/jit/verify/typecheck-common.hpp"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/****************************************************************************/
+/* MACROS FOR VARIABLE TYPE CHECKING                                        */
+/****************************************************************************/
+
+#define TYPECHECK_CHECK_TYPE(i,tp,msg)                               \
+    do {                                                             \
+        if (VAR(i)->type != (tp)) {                                  \
+            exceptions_throw_verifyerror(state->m, (msg));           \
+            return false;                                            \
+        }                                                            \
+    } while (0)
+
+#define TYPECHECK_INT(i)                                             \
+    TYPECHECK_CHECK_TYPE(i,TYPE_INT,"Expected to find integer value")
+#define TYPECHECK_LNG(i)                                             \
+    TYPECHECK_CHECK_TYPE(i,TYPE_LNG,"Expected to find long value")
+#define TYPECHECK_FLT(i)                                             \
+    TYPECHECK_CHECK_TYPE(i,TYPE_FLT,"Expected to find float value")
+#define TYPECHECK_DBL(i)                                             \
+    TYPECHECK_CHECK_TYPE(i,TYPE_DBL,"Expected to find double value")
+#define TYPECHECK_ADR(i)                                             \
+    TYPECHECK_CHECK_TYPE(i,TYPE_ADR,"Expected to find object value")
+
+#define TYPECHECK_INT_OP(o)  TYPECHECK_INT((o).varindex)
+#define TYPECHECK_LNG_OP(o)  TYPECHECK_LNG((o).varindex)
+#define TYPECHECK_FLT_OP(o)  TYPECHECK_FLT((o).varindex)
+#define TYPECHECK_DBL_OP(o)  TYPECHECK_DBL((o).varindex)
+#define TYPECHECK_ADR_OP(o)  TYPECHECK_ADR((o).varindex)
+
+
+/* typestate_save_invars *******************************************************
+   Save the invars of the current basic block in the space reserved by
+   parse.
+
+   This function must be called before an instruction modifies a variable
+   that is an invar of the current block. In such cases the invars of the
+   block must be saved, and restored at the end of the analysis of this
+   basic block, so that the invars again reflect the *input* to this basic
+   block (and do not randomly contain types that appear within the block).
+
+   IN:
+       state............current state of the verifier
+
+*******************************************************************************/
+
+static void
+typestate_save_invars(verifier_state *state)
+{
+       s4 i, index;
+       s4 *pindex;
+       
+       LOG("saving invars");
+
+       if (!state->savedindices) {
+               LOG("allocating savedindices buffer");
+               pindex = (s4*) DumpMemory::allocate(sizeof(s4) * state->m->maxstack);
+               state->savedindices = pindex;
+               index = state->numlocals + VERIFIER_EXTRA_VARS;
+               for (i=0; i<state->m->maxstack; ++i)
+                       *pindex++ = index++;
+       }
+
+       /* save types */
+
+       typecheck_copy_types(state, state->bptr->invars, state->savedindices, 
+                       state->bptr->indepth);
+
+       /* set the invars of the block to the saved variables */
+       /* and remember the original invars                   */
+
+       state->savedinvars = state->bptr->invars;
+       state->bptr->invars = state->savedindices;
+}
+
+
+/* typestate_restore_invars  ***************************************************
+   Restore the invars of the current basic block that have been previously
+   saved by `typestate_save_invars`.
+
+   IN:
+       state............current state of the verifier
+
+*******************************************************************************/
+
+static void
+typestate_restore_invars(verifier_state *state)
+{
+       TYPECHECK_COUNT(stat_savedstack);
+       LOG("restoring saved invars");
+
+       /* restore the invars pointer */
+
+       state->bptr->invars = state->savedinvars;
+
+       /* copy the types back */
+
+       typecheck_copy_types(state, state->savedindices, state->bptr->invars,
+                       state->bptr->indepth);
+
+       /* mark that there are no saved invars currently */
+
+       state->savedinvars = NULL;
+}
+
+
+/* handle_fieldaccess **********************************************************
+   Verify an ICMD_{GET,PUT}{STATIC,FIELD}(CONST)?
+  
+   IN:
+       state............the current state of the verifier
+
+   RETURN VALUE:
+       true.............successful verification,
+          false............an exception has been thrown.
+
+*******************************************************************************/
+
+static bool
+handle_fieldaccess(verifier_state *state,
+                                  varinfo *instance,
+                                  varinfo *value)
+{
+       jitdata *jd;
+
+       jd = state->jd;
+
+#define TYPECHECK_VARIABLESBASED
+#define EXCEPTION  do { return false; } while (0)
+#define VERIFY_ERROR(msg)  TYPECHECK_VERIFYERROR_bool(msg)
+#include <typecheck-fields.inc>
+#undef  EXCEPTION
+#undef  VERIFY_ERROR
+#undef  TYPECHECK_VARIABLESBASED
+
+       return true;
+}
+
+
+/* handle_invocation ***********************************************************
+   Verify an ICMD_INVOKE* instruction.
+  
+   IN:
+       state............the current state of the verifier
+
+   RETURN VALUE:
+       true.............successful verification,
+          false............an exception has been thrown.
+
+*******************************************************************************/
+
+static bool
+handle_invocation(verifier_state *state)
+{
+       jitdata *jd;
+    varinfo *dv;               /* output variable of current instruction */
+
+       jd = state->jd;
+       dv = VAROP(state->iptr->dst);
+
+#define TYPECHECK_VARIABLESBASED
+#define OP1   VAR(state->iptr->sx.s23.s2.args[0])
+#include <typecheck-invoke.inc>
+#undef  OP1
+#undef  TYPECHECK_VARIABLESBASED
+
+       return true;
+}
+
+
+/* handle_builtin **************************************************************
+   Verify the call of a builtin method.
+  
+   IN:
+       state............the current state of the verifier
+
+   RETURN VALUE:
+       true.............successful verification,
+          false............an exception has been thrown.
+
+*******************************************************************************/
+
+static bool
+handle_builtin(verifier_state *state)
+{
+       jitdata *jd;
+    varinfo *dv;               /* output variable of current instruction */
+
+       jd = state->jd;
+       dv = VAROP(state->iptr->dst);
+
+#define TYPECHECK_VARIABLESBASED
+#define OP1   state->iptr->sx.s23.s2.args[0]
+#include <typecheck-builtins.inc>
+#undef  OP1
+#undef  TYPECHECK_VARIABLESBASED
+
+       return true;
+}
+
+/* handle_multianewarray *******************************************************
+   Verify a MULTIANEWARRAY instruction.
+  
+   IN:
+       state............the current state of the verifier
+
+   RETURN VALUE:
+       true.............successful verification,
+          false............an exception has been thrown.
+
+*******************************************************************************/
+
+static bool
+handle_multianewarray(verifier_state *state)
+{
+       jitdata *jd;
+    varinfo *dv;               /* output variable of current instruction */
+
+       jd = state->jd;
+       dv = VAROP(state->iptr->dst);
+
+#define TYPECHECK_VARIABLESBASED
+#define VERIFY_ERROR(msg)  TYPECHECK_VERIFYERROR_bool(msg)
+#include <typecheck-multianewarray.inc>
+#undef VERIFY_ERROR
+#undef  TYPECHECK_VARIABLESBASED
+
+       return true;
+}
+
+/* typecheck_invalidate_locals *************************************************
+   Invalidate locals that are overwritten by writing to the given local.
+  
+   IN:
+       state............the current state of the verifier
+          index............the index of the local that is written
+          twoword..........true, if a two-word type is written
+
+*******************************************************************************/
+
+static void typecheck_invalidate_locals(verifier_state *state, s4 index, bool twoword)
+{
+       s4 javaindex;
+       s4 t;
+       s4 varindex;
+       jitdata *jd = state->jd;
+       s4 *localmap = jd->local_map;
+       varinfo *vars = jd->var;
+
+       javaindex = jd->reverselocalmap[index];
+
+       /* invalidate locals of two-word type at index javaindex-1 */
+
+       if (javaindex > 0) {
+               localmap += 5 * (javaindex-1);
+               for (t=0; t<5; ++t) {
+                       varindex = *localmap++;
+                       if (varindex >= 0 && IS_2_WORD_TYPE(vars[varindex].type)) {
+                               LOG1("invalidate local %d", varindex);
+                               vars[varindex].type = TYPE_VOID;
+                       }
+               }
+       }
+       else {
+               localmap += 5 * javaindex;
+       }
+
+       /* invalidate locals at index javaindex */
+
+       for (t=0; t<5; ++t) {
+               varindex = *localmap++;
+               if (varindex >= 0) {
+                       LOG1("invalidate local %d", varindex);
+                       vars[varindex].type = TYPE_VOID;
+               }
+       }
+
+       /* if a two-word type is written, invalidate locals at index javaindex+1 */
+
+       if (twoword) {
+               for (t=0; t<5; ++t) {
+                       varindex = *localmap++;
+                       if (varindex >= 0) {
+                               LOG1("invalidate local %d", varindex);
+                               vars[varindex].type = TYPE_VOID;
+                       }
+               }
+       }
+}
+
+
+/* macros used by the generated code ******************************************/
+
+#define EXCEPTION          do { return false; } while (0)
+#define VERIFY_ERROR(msg)  TYPECHECK_VERIFYERROR_bool(msg)
+
+#define CHECK_LOCAL_TYPE(index, t)                                   \
+    do {                                                             \
+        if (!typevector_checktype(jd->var, (index), (t)))            \
+             VERIFY_ERROR("Local variable type mismatch");           \
+    } while (0)
+
+#define STORE_LOCAL(t, index)                                        \
+    do {                                                             \
+         s4 temp_t = (t);                                            \
+         typecheck_invalidate_locals(state, (index), false);         \
+         typevector_store(jd->var, (index), (temp_t), NULL);         \
+    } while (0)
+
+#define STORE_LOCAL_2_WORD(t, index)                                 \
+    do {                                                             \
+         s4 temp_t = (t);                                            \
+         typecheck_invalidate_locals(state, (index), true);          \
+         typevector_store(jd->var, (index), (temp_t), NULL);         \
+    } while (0)
+
+#define REACH_BLOCK(target)                                          \
+    do {                                                             \
+        if (!typestate_reach(state, (target),                        \
+                             state->bptr->outvars, jd->var,          \
+                             state->bptr->outdepth))                 \
+                return false;                                        \
+    } while (0)
+
+#define REACH(target)   REACH_BLOCK((target).block)
+
+
+/* handle_basic_block **********************************************************
+   Perform bytecode verification of a basic block.
+  
+   IN:
+       state............the current state of the verifier
+
+   RETURN VALUE:
+       true.............successful verification,
+          false............an exception has been thrown.
+
+*******************************************************************************/
+
+static bool
+handle_basic_block(verifier_state *state)
+{
+    int opcode;                                      /* current opcode */
+    int len;                        /* for counting instructions, etc. */
+    bool superblockend;        /* true if no fallthrough to next block */
+       instruction *iptr;                      /* the current instruction */
+    basicblock *tbptr;                   /* temporary for target block */
+    bool maythrow;               /* true if this instruction may throw */
+       s4 i;
+       typecheck_result r;
+       branch_target_t *table;
+       lookup_target_t *lookup;
+       jitdata *jd = state->jd;
+       exception_entry *ex;
+       varinfo constvalue;                               /* for PUT*CONST */
+       constant_FMIref *fieldref;
+
+       LOGSTR1("\n---- BLOCK %04d ------------------------------------------------\n",state->bptr->nr);
+       LOGFLUSH;
+
+       superblockend = false;
+       state->bptr->flags = BBFINISHED;
+
+       /* prevent compiler warnings */
+
+
+       /* determine the active exception handlers for this block */
+       /* XXX could use a faster algorithm with sorted lists or  */
+       /* something?                                             */
+       len = 0;
+       for (ex = state->jd->exceptiontable; ex ; ex = ex->down) {
+               if ((ex->start->nr <= state->bptr->nr) && (ex->end->nr > state->bptr->nr)) {
+                       LOG1("active handler L%03d", ex->handler->nr);
+                       state->handlers[len++] = ex;
+               }
+       }
+       state->handlers[len] = NULL;
+
+       /* init variable types at the start of this block */
+       typevector_copy_inplace(state->bptr->inlocals, jd->var, state->numlocals);
+
+       DOLOG(show_basicblock(jd, state->bptr, SHOW_STACK));
+       DOLOG(typecheck_print_vararray(stdout, jd, state->bptr->invars, 
+                               state->bptr->indepth));
+       DOLOG(typevector_print(stdout, jd->var, state->numlocals));
+       LOGNL; LOGFLUSH;
+
+       /* loop over the instructions */
+       len = state->bptr->icount;
+       state->iptr = state->bptr->iinstr;
+       while (--len >= 0)  {
+               TYPECHECK_COUNT(stat_ins);
+
+               iptr = state->iptr;
+
+               DOLOG(typevector_print(stdout, jd->var, state->numlocals));
+               LOGNL; LOGFLUSH;
+               DOLOG(show_icmd(jd, state->iptr, false, SHOW_STACK)); LOGNL; LOGFLUSH;
+
+               opcode = iptr->opc;
+               maythrow = false;
+
+               switch (opcode) {
+
+                       /* include generated code for ICMDs verification */
+
+#define TYPECHECK_VARIABLESBASED
+#define STATE  state
+#define METHOD (state->m)
+#define IPTR   iptr
+#define BPTR   (state->bptr)
+#include <typecheck-variablesbased-gen.inc>
+#undef  STATE
+#undef  METHOD
+#undef  IPTR
+#undef  BPTR
+#undef  TYPECHECK_VARIABLESBASED
+
+                       default:
+                               LOG1("ICMD %d\n", opcode);
+                               TYPECHECK_VERIFYERROR_bool("Missing ICMD code during typecheck");
+               }
+
+               /* reach exception handlers for this instruction */
+
+               if (maythrow) {
+                       TYPECHECK_COUNT(stat_ins_maythrow);
+                       TYPECHECK_MARK(state->stat_maythrow);
+                       LOG("reaching exception handlers");
+                       i = 0;
+                       while (state->handlers[i]) {
+                               TYPECHECK_COUNT(stat_handlers_reached);
+                               if (state->handlers[i]->catchtype.any)
+                                       VAR(state->exinvars)->typeinfo.typeclass = state->handlers[i]->catchtype;
+                               else
+                                       VAR(state->exinvars)->typeinfo.typeclass.cls = class_java_lang_Throwable;
+                               if (!typestate_reach(state,
+                                               state->handlers[i]->handler,
+                                               &(state->exinvars), jd->var, 1))
+                                       return false;
+                               i++;
+                       }
+               }
+
+               LOG("\t\tnext instruction");
+               state->iptr++;
+       } /* while instructions */
+
+       LOG("instructions done");
+       LOGSTR("RESULT=> ");
+       DOLOG(typecheck_print_vararray(stdout, jd, state->bptr->outvars,
+                               state->bptr->outdepth));
+       DOLOG(typevector_print(stdout, jd->var, state->numlocals));
+       LOGNL; LOGFLUSH;
+
+       /* propagate stack and variables to the following block */
+       if (!superblockend) {
+               LOG("reaching following block");
+               tbptr = state->bptr->next;
+               while (tbptr->flags == BBDELETED) {
+                       tbptr = tbptr->next;
+#ifdef TYPECHECK_DEBUG
+                       /* this must be checked in parse.c */
+                       if ((tbptr->nr) >= state->basicblockcount)
+                               TYPECHECK_VERIFYERROR_bool("Control flow falls off the last block");
+#endif
+               }
+               if (!typestate_reach(state,tbptr,state->bptr->outvars, jd->var,
+                                       state->bptr->outdepth))
+                       return false;
+       }
+
+       /* We may have to restore the types of the instack slots. They
+        * have been saved if an <init> call inside the block has
+        * modified the instack types. (see INVOKESPECIAL) */
+
+       if (state->savedinvars)
+               typestate_restore_invars(state);
+
+       return true;
+}
+
+
+/****************************************************************************/
+/* typecheck()                                                              */
+/* This is the main function of the bytecode verifier. It is called         */
+/* directly after analyse_stack.                                            */
+/*                                                                          */
+/* IN:                                                                      */
+/*    meth.............the method to verify                                 */
+/*    cdata............codegendata for the method                           */
+/*    rdata............registerdata for the method                          */
+/*                                                                          */
+/* RETURN VALUE:                                                            */
+/*     true.............successful verification                             */
+/*     false............an exception has been thrown                        */
+/*                                                                          */
+/****************************************************************************/
+
+#define MAXPARAMS 255
+
+bool typecheck(jitdata *jd)
+{
+       methodinfo     *meth;
+       codegendata    *cd;
+       varinfo        *savedlocals;
+       verifier_state  state;             /* current state of the verifier */
+
+       /* collect statistics */
+
+#ifdef TYPECHECK_STATISTICS
+       int count_iterations = 0;
+       TYPECHECK_COUNT(stat_typechecked);
+       TYPECHECK_COUNT_FREQ(stat_locals,jd->maxlocals,STAT_LOCALS);
+       TYPECHECK_COUNT_FREQ(stat_blocks,cdata->method->basicblockcount/10,STAT_BLOCKS);
+       TYPECHECK_COUNTIF(cdata->method->exceptiontablelength != 0,stat_methods_with_handlers);
+       state.stat_maythrow = false;
+#endif
+
+       /* get required compiler data */
+
+       meth = jd->m;
+       cd   = jd->cd;
+
+       /* some logging on entry */
+
+
+    LOGSTR("\n==============================================================================\n");
+    DOLOG( show_method(jd, SHOW_STACK) );
+    LOGSTR("\n==============================================================================\n");
+    LOGMETHOD("Entering typecheck: ",cd->method);
+
+       /* initialize the verifier state */
+
+       state.m = meth;
+       state.jd = jd;
+       state.cd = cd;
+       state.basicblockcount = jd->basicblockcount;
+       state.basicblocks = jd->basicblocks;
+       state.savedindices = NULL;
+       state.savedinvars = NULL;
+
+       /* check that the basicblock numbers are valid */
+
+#if !defined(NDEBUG)
+       jit_check_basicblock_numbers(jd);
+#endif
+
+       /* check if this method is an instance initializer method */
+
+    state.initmethod = (state.m->name == utf_init);
+
+       /* initialize the basic block flags for the following CFG traversal */
+
+       typecheck_init_flags(&state, BBFINISHED);
+
+    /* number of local variables */
+    
+    /* In <init> methods we use an extra local variable to indicate whether */
+    /* the 'this' reference has been initialized.                           */
+       /*         TYPE_VOID...means 'this' has not been initialized,           */
+       /*         TYPE_INT....means 'this' has been initialized.               */
+
+    state.numlocals = state.jd->localcount;
+       state.validlocals = state.numlocals;
+    if (state.initmethod) 
+               state.numlocals++; /* VERIFIER_EXTRA_LOCALS */
+
+       DOLOG(
+               s4 i;
+               s4 t;
+               LOG("reverselocalmap:");
+               for (i=0; i<state.validlocals; ++i) {
+                       LOG2("    %i => javaindex %i", i, jd->reverselocalmap[i]);
+               });
+
+    /* allocate the buffer of active exception handlers */
+       
+    state.handlers = (exception_entry**) DumpMemory::allocate(sizeof(exception_entry*) * (state.jd->exceptiontablelength + 1));
+
+       /* save local variables */
+
+       savedlocals = (varinfo*) DumpMemory::allocate(sizeof(varinfo) * state.numlocals);
+       MCOPY(savedlocals, jd->var, varinfo, state.numlocals);
+
+       /* initialized local variables of first block */
+
+       if (!typecheck_init_locals(&state, true))
+               return false;
+
+    /* initialize invars of exception handlers */
+       
+       state.exinvars = state.numlocals;
+       VAR(state.exinvars)->type = TYPE_ADR;
+       typeinfo_init_classinfo(&(VAR(state.exinvars)->typeinfo),
+                                                       class_java_lang_Throwable); /* changed later */
+
+    LOG("Exception handler stacks set.\n");
+
+    /* loop while there are still blocks to be checked */
+    do {
+               TYPECHECK_COUNT(count_iterations);
+
+        state.repeat = false;
+        
+        state.bptr = state.basicblocks;
+
+        for (; state.bptr; state.bptr = state.bptr->next) {
+            LOGSTR1("---- BLOCK %04d, ",state.bptr->nr);
+            LOGSTR1("blockflags: %d\n",state.bptr->flags);
+            LOGFLUSH;
+            
+                   /* verify reached block */  
+            if (state.bptr->flags == BBTYPECHECK_REACHED) {
+                if (!handle_basic_block(&state))
+                                       return false;
+            }
+        } /* for blocks */
+
+        LOGIF(state.repeat,"state.repeat == true");
+    } while (state.repeat);
+
+       /* statistics */
+       
+#ifdef TYPECHECK_STATISTICS
+       LOG1("Typechecker did %4d iterations",count_iterations);
+       TYPECHECK_COUNT_FREQ(stat_iterations,count_iterations,STAT_ITERATIONS);
+       TYPECHECK_COUNTIF(state.jsrencountered,stat_typechecked_jsr);
+       TYPECHECK_COUNTIF(state.stat_maythrow,stat_methods_maythrow);
+#endif
+
+       /* reset the flags of blocks we haven't reached */
+
+       typecheck_reset_flags(&state);
+
+       /* restore locals */
+
+       MCOPY(jd->var, savedlocals, varinfo, state.numlocals);
+
+       /* everything's ok */
+
+    LOGimp("exiting typecheck");
+       return true;
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* ENABLE_VERIFIER */
+
+/*
+ * 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/jit/verify/typecheck.h b/src/vm/jit/verify/typecheck.h
deleted file mode 100644 (file)
index 01492ea..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* src/vm/jit/verify/typecheck.h - type checking header
-
-   Copyright (C) 1996-2005, 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
-
-   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.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-
-*/
-
-
-#ifndef _TYPECHECK_H
-#define _TYPECHECK_H
-
-#include "config.h"
-
-#include "vm/global.h"
-#include "vm/jit/jit.h"
-
-
-/* function prototypes ********************************************************/
-
-#if defined(ENABLE_VERIFIER)
-bool typecheck(jitdata *jd);
-bool typecheck_stackbased(jitdata *jd);
-#endif
-
-#endif /* _TYPECHECK_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:
- */
diff --git a/src/vm/jit/verify/typecheck.hpp b/src/vm/jit/verify/typecheck.hpp
new file mode 100644 (file)
index 0000000..8e0305c
--- /dev/null
@@ -0,0 +1,64 @@
+/* src/vm/jit/verify/typecheck.h - type checking header
+
+   Copyright (C) 1996-2005, 2006, 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 _TYPECHECK_H
+#define _TYPECHECK_H
+
+#include "config.h"
+
+#include "vm/global.h"
+#include "vm/jit/jit.hpp"
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(ENABLE_VERIFIER)
+bool typecheck(jitdata *jd);
+bool typecheck_stackbased(jitdata *jd);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _TYPECHECK_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:
+ */
diff --git a/src/vm/jit/verify/typeinfo.c b/src/vm/jit/verify/typeinfo.c
deleted file mode 100644 (file)
index f31c4c9..0000000
+++ /dev/null
@@ -1,2565 +0,0 @@
-/* src/vm/jit/verify/typeinfo.c - type system used by the type checker
-
-   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 <string.h>
-
-#include "mm/memory.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/array.h"
-#include "vm/exceptions.h"
-#include "vm/primitive.h"
-#include "vm/resolve.h"
-
-#include "vm/jit/jit.h"
-#include "vm/jit/verify/typeinfo.h"
-
-#include "vmcore/class.h"
-#include "vmcore/descriptor.h"
-#include "vmcore/loader.h"
-
-
-/* check if a linked class is an array class. Only use for linked classes! */
-#define CLASSINFO_IS_ARRAY(clsinfo)  ((clsinfo)->vftbl->arraydesc != NULL)
-
-/* check if a linked class implements the interface with the given index */
-#define CLASSINFO_IMPLEMENTS_INTERFACE(cls,index)                   \
-    ( ((index) < (cls)->vftbl->interfacetablelength)            \
-      && ( (cls)->vftbl->interfacetable[-(index)] != NULL ) )
-
-/******************************************************************************/
-/* DEBUG HELPERS                                                              */
-/******************************************************************************/
-
-#ifdef TYPEINFO_DEBUG
-#define TYPEINFO_ASSERT(cond)  assert(cond)
-#else
-#define TYPEINFO_ASSERT(cond)
-#endif
-
-/**********************************************************************/
-/* TYPEVECTOR FUNCTIONS                                               */
-/**********************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-
-/* typevector_copy *************************************************************
-   Return a copy of the given typevector.
-  
-   IN:
-          src..............typevector set to copy, must be != NULL
-          size.............number of elements per typevector
-
-   RETURN VALUE:
-       a pointer to the new typevector set
-
-*******************************************************************************/
-
-varinfo *
-typevector_copy(varinfo *src, int size)
-{
-       varinfo *dst;
-       
-       TYPEINFO_ASSERT(src);
-       
-       dst = DNEW_TYPEVECTOR(size);
-       memcpy(dst,src,TYPEVECTOR_SIZE(size));
-
-       return dst;
-}
-
-/* typevector_copy_inplace *****************************************************
-   Copy a typevector to a given destination.
-
-   IN:
-          src..............typevector to copy, must be != NULL
-          dst..............destination to write the copy to
-          size.............number of elements per typevector
-
-*******************************************************************************/
-
-void
-typevector_copy_inplace(varinfo *src,varinfo *dst,int size)
-{
-       memcpy(dst,src,TYPEVECTOR_SIZE(size));
-}
-
-/* typevector_checktype ********************************************************
-   Check if the typevector contains a given type at a given index.
-  
-   IN:
-          vec..............typevector set, must be != NULL
-          index............index of component to check
-          type.............TYPE_* constant to check against
-
-   RETURN VALUE:
-       true if the typevector contains TYPE at INDEX,
-          false otherwise
-
-*******************************************************************************/
-
-bool
-typevector_checktype(varinfo *vec,int index,int type)
-{
-       TYPEINFO_ASSERT(vec);
-
-       return vec[index].type == type;
-}
-
-/* typevector_checkreference ***************************************************
-   Check if the typevector contains a reference at a given index.
-  
-   IN:
-          vec..............typevector, must be != NULL
-          index............index of component to check
-
-   RETURN VALUE:
-       true if the typevector contains a reference at INDEX,
-          false otherwise
-
-*******************************************************************************/
-
-bool
-typevector_checkreference(varinfo *vec, int index)
-{
-       TYPEINFO_ASSERT(vec);
-       return TYPEDESC_IS_REFERENCE(vec[index]);
-}
-
-/* typevectorset_checkretaddr **************************************************
-   Check if the typevectors contains a returnAddress at a given index.
-  
-   IN:
-          vec..............typevector, must be != NULL
-          index............index of component to check
-
-   RETURN VALUE:
-       true if the typevector contains a returnAddress at INDEX,
-          false otherwise
-
-*******************************************************************************/
-
-bool
-typevector_checkretaddr(varinfo *vec,int index)
-{
-       TYPEINFO_ASSERT(vec);
-       return TYPEDESC_IS_RETURNADDRESS(vec[index]);
-}
-
-/* typevector_store ************************************************************
-   Store a type at a given index in the typevector.
-  
-   IN:
-          vec..............typevector set, must be != NULL
-          index............index of component to set
-          type.............TYPE_* constant of type to set
-          info.............typeinfo of type to set, may be NULL, 
-                           if TYPE != TYPE_ADR
-
-*******************************************************************************/
-
-void
-typevector_store(varinfo *vec,int index,int type,typeinfo_t *info)
-{
-       TYPEINFO_ASSERT(vec);
-
-       vec[index].type = type;
-       if (info)
-               TYPEINFO_COPY(*info,vec[index].typeinfo);
-}
-
-/* typevector_store_retaddr ****************************************************
-   Store a returnAddress type at a given index in the typevector.
-  
-   IN:
-          vec..............typevector set, must be != NULL
-          index............index of component to set
-          info.............typeinfo of the returnAddress.
-
-*******************************************************************************/
-
-void
-typevector_store_retaddr(varinfo *vec,int index,typeinfo_t *info)
-{
-       TYPEINFO_ASSERT(vec);
-       TYPEINFO_ASSERT(TYPEINFO_IS_PRIMITIVE(*info));
-       
-       vec[index].type = TYPE_ADR;
-       TYPEINFO_INIT_RETURNADDRESS(vec[index].typeinfo,
-                       TYPEINFO_RETURNADDRESS(*info));
-}
-
-/* typevector_init_object ******************************************************
-   Replace all uninitialized object types in the typevector set which were 
-   created by the given instruction by initialized object types.
-  
-   IN:
-          set..............typevector set
-          ins..............instruction which created the uninitialized object type
-          initclass........class of the initialized object type to set
-          size.............number of elements per typevector
-
-   RETURN VALUE:
-       true.............success
-          false............an exception has been thrown
-
-   XXX maybe we should do the lazy resolving before calling this function
-
-*******************************************************************************/
-
-bool
-typevector_init_object(varinfo *set,void *ins,
-                                          classref_or_classinfo initclass,
-                                          int size)
-{
-       int i;
-
-       for (i=0; i<size; ++i) {
-               if (set[i].type == TYPE_ADR
-                       && TYPEINFO_IS_NEWOBJECT(set[i].typeinfo)
-                       && TYPEINFO_NEWOBJECT_INSTRUCTION(set[i].typeinfo) == ins)
-               {
-                       if (!typeinfo_init_class(&(set[i].typeinfo),initclass))
-                               return false;
-               }
-       }
-       return true;
-}
-
-/* typevector_merge ************************************************************
-   Merge a typevector with another one.
-   The given typevectors must have the same number of components.
-  
-   IN:
-       m................method for exception messages
-          dst..............the first typevector
-          y................the second typevector
-          size.............number of elements per typevector
-
-   OUT:
-       *dst.............the resulting typevector
-
-   RETURN VALUE:
-       typecheck_TRUE...dst has been modified
-          typecheck_FALSE..dst has not been modified
-          typecheck_FAIL...an exception has been thrown
-
-*******************************************************************************/
-
-typecheck_result
-typevector_merge(methodinfo *m,varinfo *dst,varinfo *y,int size)
-{
-       bool changed = false;
-       typecheck_result r;
-       
-       varinfo *a = dst;
-       varinfo *b = y;
-       while (size--) {
-               if (a->type != TYPE_VOID && a->type != b->type) {
-                       a->type = TYPE_VOID;
-                       changed = true;
-               }
-               else if (a->type == TYPE_ADR) {
-                       if (TYPEINFO_IS_PRIMITIVE(a->typeinfo)) {
-                               /* 'a' is a returnAddress */
-                               if (!TYPEINFO_IS_PRIMITIVE(b->typeinfo)
-                                       || (TYPEINFO_RETURNADDRESS(a->typeinfo)
-                                               != TYPEINFO_RETURNADDRESS(b->typeinfo)))
-                               {
-                                       a->type = TYPE_VOID;
-                                       changed = true;
-                               }
-                       }
-                       else {
-                               /* 'a' is a reference */
-                               if (TYPEINFO_IS_PRIMITIVE(b->typeinfo)) {
-                                       a->type = TYPE_VOID;
-                                       changed = true;
-                               }
-                               else {
-                                       /* two reference types are merged. There cannot be */
-                                       /* a merge error. In the worst case we get j.l.O.  */
-                                       r = typeinfo_merge(m,&(a->typeinfo),&(b->typeinfo));
-                                       if (r == typecheck_FAIL)
-                                               return r;
-                                       changed |= r;
-                               }
-                       }
-               }
-               a++;
-               b++;
-       }
-       return changed;
-}
-
-/**********************************************************************/
-/* READ-ONLY FUNCTIONS                                                */
-/* The following functions don't change typeinfo data.                */
-/**********************************************************************/
-
-/* typeinfo_is_array ***********************************************************
-   Check whether a typeinfo describes an array type.
-   
-   IN:
-          info.............the typeinfo, must be != NULL
-
-   RETURN VALUE:
-       true if INFO describes an array type.
-
-*******************************************************************************/
-
-bool
-typeinfo_is_array(typeinfo_t *info)
-{
-       TYPEINFO_ASSERT(info);
-    return TYPEINFO_IS_ARRAY(*info);
-}
-
-/* typeinfo_is_primitive_array *************************************************
-   Check whether a typeinfo describes a primitive array type.
-   
-   IN:
-          info.............the typeinfo, must be != NULL
-
-   RETURN VALUE:
-       true if INFO describes an array of a primitive type.
-
-*******************************************************************************/
-
-bool
-typeinfo_is_primitive_array(typeinfo_t *info,int arraytype)
-{
-       TYPEINFO_ASSERT(info);
-    return TYPEINFO_IS_PRIMITIVE_ARRAY(*info,arraytype);
-}
-
-/* typeinfo_is_array_of_refs ***************************************************
-   Check whether a typeinfo describes an array of references type.
-   
-   IN:
-          info.............the typeinfo, must be != NULL
-
-   RETURN VALUE:
-       true if INFO describes an array of a refrence type.
-
-*******************************************************************************/
-
-bool
-typeinfo_is_array_of_refs(typeinfo_t *info)
-{
-       TYPEINFO_ASSERT(info);
-    return TYPEINFO_IS_ARRAY_OF_REFS(*info);
-}
-
-/* interface_extends_interface *************************************************
-   Check if a resolved interface extends a given resolved interface.
-   
-   IN:
-          cls..............the interface, must be linked
-          interf...........the interface to check against
-
-   RETURN VALUE:
-       true.............CLS extends INTERF
-          false............CLS does not extend INTERF
-
-*******************************************************************************/
-
-static bool
-interface_extends_interface(classinfo *cls,classinfo *interf)
-{
-    int i;
-    
-       TYPEINFO_ASSERT(cls);
-       TYPEINFO_ASSERT(interf);
-       TYPEINFO_ASSERT((interf->flags & ACC_INTERFACE) != 0);
-       TYPEINFO_ASSERT((cls->flags & ACC_INTERFACE) != 0);
-       TYPEINFO_ASSERT(cls->state & CLASS_LINKED);
-
-    /* first check direct superinterfaces */
-    for (i=0; i<cls->interfacescount; ++i) {
-        if (cls->interfaces[i] == interf)
-            return true;
-    }
-    
-    /* check indirect superinterfaces */
-    for (i=0; i<cls->interfacescount; ++i) {
-        if (interface_extends_interface(cls->interfaces[i],interf))
-            return true;
-    }
-    
-    return false;
-}
-
-/* classinfo_implements_interface **********************************************
-   Check if a resolved class implements a given resolved interface.
-   
-   IN:
-          cls..............the class
-          interf...........the interface
-
-   RETURN VALUE:
-       typecheck_TRUE...CLS implements INTERF
-          typecheck_FALSE..CLS does not implement INTERF
-          typecheck_FAIL...an exception has been thrown
-
-*******************************************************************************/
-
-static typecheck_result
-classinfo_implements_interface(classinfo *cls,classinfo *interf)
-{
-       TYPEINFO_ASSERT(cls);
-       TYPEINFO_ASSERT(interf);
-       TYPEINFO_ASSERT((interf->flags & ACC_INTERFACE) != 0);
-
-       if (!(cls->state & CLASS_LINKED))
-               if (!link_class(cls))
-                       return typecheck_FAIL;
-
-    if (cls->flags & ACC_INTERFACE) {
-        /* cls is an interface */
-        if (cls == interf)
-            return typecheck_TRUE;
-
-        /* check superinterfaces */
-        return interface_extends_interface(cls,interf);
-    }
-
-       TYPEINFO_ASSERT(cls->state & CLASS_LINKED);
-    return CLASSINFO_IMPLEMENTS_INTERFACE(cls,interf->index);
-}
-
-/* mergedlist_implements_interface *********************************************
-   Check if all the classes in a given merged list implement a given resolved
-   interface.
-   
-   IN:
-          merged...........the list of merged class types
-          interf...........the interface to check against
-
-   RETURN VALUE:
-       typecheck_TRUE...all classes implement INTERF
-          typecheck_FALSE..there is at least one class that does not implement
-                           INTERF
-          typecheck_MAYBE..check cannot be performed now because of unresolved
-                           classes
-          typecheck_FAIL...an exception has been thrown
-
-*******************************************************************************/
-
-static typecheck_result
-mergedlist_implements_interface(typeinfo_mergedlist_t *merged,
-                                classinfo *interf)
-{
-    int i;
-    classref_or_classinfo *mlist;
-       typecheck_result r;
-    
-       TYPEINFO_ASSERT(interf);
-       TYPEINFO_ASSERT((interf->flags & ACC_INTERFACE) != 0);
-
-    /* Check if there is an non-empty mergedlist. */
-    if (!merged)
-        return typecheck_FALSE;
-
-    /* If all classinfos in the (non-empty) merged array implement the
-     * interface return true, otherwise false.
-     */
-    mlist = merged->list;
-    i = merged->count;
-    while (i--) {
-               if (IS_CLASSREF(*mlist)) {
-                       return typecheck_MAYBE;
-               }
-        r = classinfo_implements_interface((mlist++)->cls,interf);
-        if (r != typecheck_TRUE)
-                       return r;
-    }
-    return typecheck_TRUE;
-}
-
-/* merged_implements_interface *************************************************
-   Check if a possible merged type implements a given resolved interface
-   interface.
-   
-   IN:
-       typeclass........(common) class of the (merged) type
-          merged...........the list of merged class types
-          interf...........the interface to check against
-
-   RETURN VALUE:
-       typecheck_TRUE...the type implement INTERF
-          typecheck_FALSE..the type does not implement INTERF
-          typecheck_MAYBE..check cannot be performed now because of unresolved
-                           classes
-          typecheck_FAIL...an exception has been thrown
-
-*******************************************************************************/
-
-static typecheck_result
-merged_implements_interface(classinfo *typeclass,typeinfo_mergedlist_t *merged,
-                            classinfo *interf)
-{
-       typecheck_result r;
-       
-    /* primitive types don't support interfaces. */
-    if (!typeclass)
-        return typecheck_FALSE;
-
-    /* the null type can be cast to any interface type. */
-    if (typeclass == pseudo_class_Null)
-        return typecheck_TRUE;
-
-    /* check if typeclass implements the interface. */
-    r = classinfo_implements_interface(typeclass,interf);
-       if (r != typecheck_FALSE)
-        return r;
-
-    /* check the mergedlist */
-       if (!merged)
-               return typecheck_FALSE;
-    return mergedlist_implements_interface(merged,interf);
-}
-
-/* merged_is_subclass **********************************************************
-   Check if a possible merged type is a subclass of a given class.
-   A merged type is a subclass of a class C if all types in the merged list
-   are subclasses of C. A sufficient condition for this is that the
-   common type of the merged type is a subclass of C.
-
-   IN:
-       typeclass........(common) class of the (merged) type
-                           MUST be a loaded and linked class
-          merged...........the list of merged class types
-          cls..............the class to theck against
-
-   RETURN VALUE:
-       typecheck_TRUE...the type is a subclass of CLS
-          typecheck_FALSE..the type is not a subclass of CLS
-          typecheck_MAYBE..check cannot be performed now because of unresolved
-                           classes
-          typecheck_FAIL...an exception has been thrown
-
-*******************************************************************************/
-
-static typecheck_result
-merged_is_subclass(classinfo *typeclass,typeinfo_mergedlist_t *merged,
-               classinfo *cls)
-{
-    int i;
-    classref_or_classinfo *mlist;
-
-       TYPEINFO_ASSERT(cls);
-       
-    /* primitive types aren't subclasses of anything. */
-    if (!typeclass)
-        return typecheck_FALSE;
-
-    /* the null type can be cast to any reference type. */
-    if (typeclass == pseudo_class_Null)
-        return typecheck_TRUE;
-
-       TYPEINFO_ASSERT(typeclass->state & CLASS_LOADED);
-       TYPEINFO_ASSERT(typeclass->state & CLASS_LINKED);
-
-    /* check if the common typeclass is a subclass of CLS. */
-       if (class_issubclass(typeclass,cls))
-               return typecheck_TRUE;
-       
-    /* check the mergedlist */
-       if (!merged)
-               return typecheck_FALSE;
-    /* If all classinfos in the (non-empty) merged list are subclasses
-        * of CLS, return true, otherwise false.
-        * If there is at least one unresolved type in the list,
-        * return typecheck_MAYBE.
-     */
-    mlist = merged->list;
-    i = merged->count;
-    while (i--) {
-               if (IS_CLASSREF(*mlist)) {
-                       return typecheck_MAYBE;
-               }
-               if (!(mlist->cls->state & CLASS_LINKED))
-                       if (!link_class(mlist->cls))
-                               return typecheck_FAIL;
-               if (!class_issubclass(mlist->cls,cls))
-                       return typecheck_FALSE;
-               mlist++;
-    }
-    return typecheck_TRUE;
-}
-
-/* typeinfo_is_assignable_to_class *********************************************
-   Check if a type is assignable to a given class type.
-   
-   IN:
-       value............the type of the value
-          dest.............the type of the destination
-
-   RETURN VALUE:
-       typecheck_TRUE...the type is assignable
-          typecheck_FALSE..the type is not assignable
-          typecheck_MAYBE..check cannot be performed now because of unresolved
-                           classes
-          typecheck_FAIL...an exception has been thrown
-
-*******************************************************************************/
-
-typecheck_result
-typeinfo_is_assignable_to_class(typeinfo_t *value,classref_or_classinfo dest)
-{
-       classref_or_classinfo c;
-    classinfo *cls;
-       utf *classname;
-
-       TYPEINFO_ASSERT(value);
-
-    c = value->typeclass;
-
-    /* assignments of primitive values are not checked here. */
-    if (!c.any && !dest.any)
-        return typecheck_TRUE;
-
-    /* primitive and reference types are not assignment compatible. */
-    if (!c.any || !dest.any)
-        return typecheck_FALSE;
-
-    /* the null type can be assigned to any type */
-    if (TYPEINFO_IS_NULLTYPE(*value))
-        return typecheck_TRUE;
-
-    /* uninitialized objects are not assignable */
-    if (TYPEINFO_IS_NEWOBJECT(*value))
-        return typecheck_FALSE;
-
-       if (IS_CLASSREF(c)) {
-               /* The value type is an unresolved class reference. */
-               classname = c.ref->name;
-       }
-       else {
-               classname = c.cls->name;
-       }
-
-       if (IS_CLASSREF(dest)) {
-               /* the destination type is an unresolved class reference */
-               /* In this case we cannot tell a lot about assignability. */
-
-               /* the common case of value and dest type having the same classname */
-               if (dest.ref->name == classname && !value->merged)
-                       return typecheck_TRUE;
-
-               /* we cannot tell if value is assignable to dest, so we */
-               /* leave it up to the resolving code to check this      */
-               return typecheck_MAYBE;
-       }
-
-       /* { we know that dest is a loaded class } */
-
-       if (IS_CLASSREF(c)) {
-               /* the value type is an unresolved class reference */
-               
-               /* the common case of value and dest type having the same classname */
-               if (dest.cls->name == classname)
-                       return typecheck_TRUE;
-
-               /* we cannot tell if value is assignable to dest, so we */
-               /* leave it up to the resolving code to check this      */
-               return typecheck_MAYBE;
-       }
-
-       /* { we know that both c and dest are loaded classes } */
-       /* (c may still have a merged list containing unresolved classrefs!) */
-
-       TYPEINFO_ASSERT(!IS_CLASSREF(c));
-       TYPEINFO_ASSERT(!IS_CLASSREF(dest));
-
-       cls = c.cls;
-       
-       TYPEINFO_ASSERT(cls->state & CLASS_LOADED);
-       TYPEINFO_ASSERT(dest.cls->state & CLASS_LOADED);
-
-       /* maybe we need to link the classes */
-       if (!(cls->state & CLASS_LINKED))
-               if (!link_class(cls))
-                       return typecheck_FAIL;
-       if (!(dest.cls->state & CLASS_LINKED))
-               if (!link_class(dest.cls))
-                       return typecheck_FAIL;
-
-       /* { we know that both c and dest are linked classes } */
-       TYPEINFO_ASSERT(cls->state & CLASS_LINKED);
-       TYPEINFO_ASSERT(dest.cls->state & CLASS_LINKED);
-
-    if (dest.cls->flags & ACC_INTERFACE) {
-        /* We are assigning to an interface type. */
-        return merged_implements_interface(cls,value->merged,dest.cls);
-    }
-
-    if (CLASSINFO_IS_ARRAY(dest.cls)) {
-               arraydescriptor *arraydesc = dest.cls->vftbl->arraydesc;
-               int dimension = arraydesc->dimension;
-               classinfo *elementclass = (arraydesc->elementvftbl)
-                       ? arraydesc->elementvftbl->clazz : NULL;
-                       
-        /* We are assigning to an array type. */
-        if (!TYPEINFO_IS_ARRAY(*value))
-            return typecheck_FALSE;
-
-        /* {Both value and dest.cls are array types.} */
-
-        /* value must have at least the dimension of dest.cls. */
-        if (value->dimension < dimension)
-            return typecheck_FALSE;
-
-        if (value->dimension > dimension) {
-            /* value has higher dimension so we need to check
-             * if its component array can be assigned to the
-             * element type of dest.cls */
-
-                       if (!elementclass) return typecheck_FALSE;
-            
-            if (elementclass->flags & ACC_INTERFACE) {
-                /* We are assigning to an interface type. */
-                return classinfo_implements_interface(pseudo_class_Arraystub,
-                                                      elementclass);
-            }
-
-            /* We are assigning to a class type. */
-            return class_issubclass(pseudo_class_Arraystub,elementclass);
-        }
-
-        /* {value and dest.cls have the same dimension} */
-
-        if (value->elementtype != arraydesc->elementtype)
-            return typecheck_FALSE;
-
-        if (value->elementclass.any) {
-            /* We are assigning an array of objects so we have to
-             * check if the elements are assignable.
-             */
-
-            if (elementclass->flags & ACC_INTERFACE) {
-                /* We are assigning to an interface type. */
-
-                return merged_implements_interface(value->elementclass.cls,
-                                                   value->merged,
-                                                   elementclass);
-            }
-            
-            /* We are assigning to a class type. */
-            return merged_is_subclass(value->elementclass.cls,value->merged,elementclass);
-        }
-
-        return typecheck_TRUE;
-    }
-
-    /* {dest.cls is not an array} */
-    /* {dest.cls is a loaded class} */
-
-       /* If there are any unresolved references in the merged list, we cannot */
-       /* tell if the assignment will be ok.                                   */
-       /* This can only happen when cls is java.lang.Object                    */
-       if (cls == class_java_lang_Object && value->merged) {
-               classref_or_classinfo *mlist = value->merged->list;
-               int i = value->merged->count;
-               while (i--)
-                       if (IS_CLASSREF(*mlist++))
-                               return typecheck_MAYBE;
-       }
-        
-    /* We are assigning to a class type */
-    if (cls->flags & ACC_INTERFACE)
-        cls = class_java_lang_Object;
-    
-    return merged_is_subclass(cls,value->merged,dest.cls);
-}
-
-/* typeinfo_is_assignable ******************************************************
-   Check if a type is assignable to a given type.
-   
-   IN:
-       value............the type of the value
-          dest.............the type of the destination, must not be a merged type
-
-   RETURN VALUE:
-       typecheck_TRUE...the type is assignable
-          typecheck_FALSE..the type is not assignable
-          typecheck_MAYBE..check cannot be performed now because of unresolved
-                           classes
-          typecheck_FAIL...an exception has been thrown
-
-*******************************************************************************/
-
-typecheck_result
-typeinfo_is_assignable(typeinfo_t *value,typeinfo_t *dest)
-{
-       TYPEINFO_ASSERT(value);
-       TYPEINFO_ASSERT(dest);
-       TYPEINFO_ASSERT(dest->merged == NULL);
-
-       return typeinfo_is_assignable_to_class(value,dest->typeclass);
-}
-
-/**********************************************************************/
-/* INITIALIZATION FUNCTIONS                                           */
-/* The following functions fill in uninitialized typeinfo structures. */
-/**********************************************************************/
-
-/* typeinfo_init_classinfo *****************************************************
-   Initialize a typeinfo to a resolved class.
-   
-   IN:
-          c................the class
-
-   OUT:
-       *info............is initialized
-
-   RETURN VALUE:
-       true.............success
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-void
-typeinfo_init_classinfo(typeinfo_t *info, classinfo *c)
-{
-       if ((info->typeclass.cls = c)->vftbl->arraydesc) {
-               if (c->vftbl->arraydesc->elementvftbl)
-                       info->elementclass.cls = c->vftbl->arraydesc->elementvftbl->clazz;
-               else
-                       info->elementclass.any = NULL;
-               info->dimension = c->vftbl->arraydesc->dimension;
-               info->elementtype = c->vftbl->arraydesc->elementtype;
-       }
-       else {
-               info->elementclass.any = NULL;
-               info->dimension = 0;
-               info->elementtype = 0;
-       }
-       info->merged = NULL;
-}
-
-/* typeinfo_init_class *********************************************************
-   Initialize a typeinfo to a possibly unresolved class type.
-   
-   IN:
-          c................the class type
-
-   OUT:
-       *info............is initialized
-
-   RETURN VALUE:
-       true.............success
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-bool
-typeinfo_init_class(typeinfo_t *info,classref_or_classinfo c)
-{
-       char *utf_ptr;
-       int len;
-       classinfo *cls;
-               
-       TYPEINFO_ASSERT(c.any);
-       TYPEINFO_ASSERT(info);
-
-       /* if necessary, try to resolve lazily */
-       if (!resolve_classref_or_classinfo(NULL /* XXX should know method */,
-                               c,resolveLazy,false,true,&cls))
-       {
-               return false;
-       }
-       
-       if (cls) {
-               typeinfo_init_classinfo(info,cls);
-               return true;
-       }
-
-       /* {the type could no be resolved lazily} */
-
-       info->typeclass.ref = c.ref;
-       info->elementclass.any = NULL;
-       info->dimension = 0;
-       info->merged = NULL;
-
-       /* handle array type references */
-       utf_ptr = c.ref->name->text;
-       len = c.ref->name->blength;
-       if (*utf_ptr == '[') {
-               /* count dimensions */
-               while (*utf_ptr == '[') {
-                       utf_ptr++;
-                       info->dimension++;
-                       len--;
-               }
-               if (*utf_ptr == 'L') {
-                       utf_ptr++;
-                       len -= 2;
-                       info->elementtype = ARRAYTYPE_OBJECT;
-                       info->elementclass.ref = class_get_classref(c.ref->referer,utf_new(utf_ptr,len));
-               }
-               else {
-                       /* an array with primitive element type */
-                       /* should have been resolved above */
-                       TYPEINFO_ASSERT(false);
-               }
-       }
-       return true;
-}
-
-/* typeinfo_init_from_typedesc *************************************************
-   Initialize a typeinfo from a typedesc.
-   
-   IN:
-          desc.............the typedesc
-
-   OUT:
-       *type............set to the TYPE_* constant of DESC (if type != NULL)
-       *info............receives the typeinfo (if info != NULL)
-
-   RETURN VALUE:
-       true.............success
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-bool
-typeinfo_init_from_typedesc(typedesc *desc,u1 *type,typeinfo_t *info)
-{
-       TYPEINFO_ASSERT(desc);
-
-#ifdef TYPEINFO_VERBOSE
-       fprintf(stderr,"typeinfo_init_from_typedesc(");
-       descriptor_debug_print_typedesc(stderr,desc);
-       fprintf(stderr,")\n");
-#endif
-
-       if (type)
-               *type = desc->type;
-
-       if (info) {
-               if (desc->type == TYPE_ADR) {
-                       TYPEINFO_ASSERT(desc->classref);
-                       if (!typeinfo_init_class(info,CLASSREF_OR_CLASSINFO(desc->classref)))
-                               return false;
-               }
-               else {
-                       TYPEINFO_INIT_PRIMITIVE(*info);
-               }
-       }
-       return true;
-}
-
-/* typeinfos_init_from_methoddesc **********************************************
-   Initialize an array of typeinfos and u1 TYPE_* values from a methoddesc.
-   
-   IN:
-       desc.............the methoddesc
-       buflen...........number of parameters the buffer can hold
-       twoword..........if true, use two parameter slots for two-word types
-
-   OUT:
-       *typebuf.........receives a TYPE_* constant for each parameter
-                        typebuf must be != NULL
-       *infobuf.........receives a typeinfo for each parameter
-                        infobuf must be != NULL
-       *returntype......receives a TYPE_* constant for the return type
-                        returntype may be NULL
-       *returntypeinfo..receives a typeinfo for the return type
-                        returntypeinfo may be NULL
-
-   RETURN VALUE:
-       true.............success
-       false............an exception has been thrown
-
-   NOTE:
-       If (according to BUFLEN) the buffers are to small to hold the
-          parameter types, an internal error is thrown. This must be
-          avoided by checking the number of parameters and allocating enough
-          space before calling this function.
-
-*******************************************************************************/
-
-bool
-typeinfos_init_from_methoddesc(methoddesc *desc,u1 *typebuf,typeinfo_t *infobuf,
-                              int buflen,bool twoword,
-                              u1 *returntype,typeinfo_t *returntypeinfo)
-{
-       int i;
-    int args = 0;
-
-       TYPEINFO_ASSERT(desc);
-       TYPEINFO_ASSERT(typebuf);
-       TYPEINFO_ASSERT(infobuf);
-
-#ifdef TYPEINFO_VERBOSE
-       fprintf(stderr,"typeinfos_init_from_methoddesc(");
-       descriptor_debug_print_methoddesc(stderr,desc);
-       fprintf(stderr,")\n");
-#endif
-
-    /* check arguments */
-    for (i=0; i<desc->paramcount; ++i) {
-               if (++args > buflen) {
-                       exceptions_throw_internalerror("Buffer too small for method arguments.");
-                       return false;
-               }
-
-               if (!typeinfo_init_from_typedesc(desc->paramtypes + i,typebuf++,infobuf++))
-                       return false;
-               
-               if (twoword && (typebuf[-1] == TYPE_LNG || typebuf[-1] == TYPE_DBL)) {
-                       if (++args > buflen) {
-                               exceptions_throw_internalerror("Buffer too small for method arguments.");
-                               return false;
-                       }
-
-                       *typebuf++ = TYPE_VOID;
-                       TYPEINFO_INIT_PRIMITIVE(*infobuf);
-                       infobuf++;
-               }
-    }
-
-    /* check returntype */
-    if (returntype) {
-               if (!typeinfo_init_from_typedesc(&(desc->returntype),returntype,returntypeinfo))
-                       return false;
-       }
-
-       return true;
-}
-
-/* typedescriptor_init_from_typedesc *******************************************
-   Initialize a typedescriptor from a typedesc.
-   
-   IN:
-          desc.............the typedesc
-
-   OUT:
-       *td..............receives the typedescriptor
-                           td must be != NULL
-
-   RETURN VALUE:
-       true.............success
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-bool
-typedescriptor_init_from_typedesc(typedescriptor_t *td,
-                                                                 typedesc *desc)
-{
-       TYPEINFO_ASSERT(td);
-       TYPEINFO_ASSERT(desc);
-
-       td->type = desc->type;
-       if (td->type == TYPE_ADR) {
-               if (!typeinfo_init_class(&(td->typeinfo),CLASSREF_OR_CLASSINFO(desc->classref)))
-                       return false;
-       }
-       else {
-               TYPEINFO_INIT_PRIMITIVE(td->typeinfo);
-       }
-       return true;
-}
-
-/* typeinfo_init_varinfo_from_typedesc *****************************************
-   Initialize a varinfo from a typedesc.
-   
-   IN:
-          desc.............the typedesc
-
-   OUT:
-       *var.............receives the type
-                           var must be != NULL
-
-   RETURN VALUE:
-       true.............success
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-bool
-typeinfo_init_varinfo_from_typedesc(varinfo *var,
-                                                                 typedesc *desc)
-{
-       TYPEINFO_ASSERT(var);
-       TYPEINFO_ASSERT(desc);
-
-       var->type = desc->type;
-       if (var->type == TYPE_ADR) {
-               if (!typeinfo_init_class(&(var->typeinfo),CLASSREF_OR_CLASSINFO(desc->classref)))
-                       return false;
-       }
-       else {
-               TYPEINFO_INIT_PRIMITIVE(var->typeinfo);
-       }
-       return true;
-}
-
-/* typeinfo_init_varinfos_from_methoddesc **************************************
-   Initialize an array of varinfos from a methoddesc.
-   
-   IN:
-       desc.............the methoddesc
-       buflen...........number of parameters the buffer can hold
-          startindex.......the zero-based index of the first parameter to
-                           write to the array. In other words the number of
-                                               parameters to skip at the beginning of the methoddesc.
-          map..............map from parameter indices to varinfo indices
-                           (indexed like jitdata.local_map)
-
-   OUT:
-       *vars............array receiving the varinfos
-                           td[0] receives the type of the
-                                               (startindex+1)th parameter of the method
-       *returntype......receives the typedescriptor of the return type.
-                           returntype may be NULL
-
-   RETURN VALUE:
-       true.............everything ok
-          false............an exception has been thrown
-
-   NOTE:
-       If (according to BUFLEN) the buffer is to small to hold the
-          parameter types, an internal error is thrown. This must be
-          avoided by checking the number of parameters and allocating enough
-          space before calling this function.
-
-*******************************************************************************/
-
-bool
-typeinfo_init_varinfos_from_methoddesc(varinfo *vars,
-                                                                        methoddesc *desc,
-                                                                        int buflen, int startindex,
-                                                                        s4 *map,
-                                                                        typedescriptor_t *returntype)
-{
-       s4 i;
-    s4 varindex;
-       s4 type;
-       s4 slot = 0;
-
-       /* skip arguments */
-       for (i=0; i<startindex; ++i) {
-               slot++;
-               if (IS_2_WORD_TYPE(desc->paramtypes[i].type))
-                       slot++;
-       }
-
-    /* check arguments */
-    for (i=startindex; i<desc->paramcount; ++i) {
-               type = desc->paramtypes[i].type;
-               varindex = map[5*slot + type];
-
-               slot++;
-               if (IS_2_WORD_TYPE(type))
-                       slot++;
-
-               if (varindex == UNUSED)
-                       continue;
-
-               if (varindex >= buflen) {
-                       exceptions_throw_internalerror("Buffer too small for method arguments.");
-                       return false;
-               }
-
-               if (!typeinfo_init_varinfo_from_typedesc(vars + varindex, desc->paramtypes + i))
-                       return false;
-    }
-
-    /* check returntype */
-    if (returntype) {
-               if (!typedescriptor_init_from_typedesc(returntype,&(desc->returntype)))
-                       return false;
-       }
-
-       return true;
-}
-
-/* typedescriptors_init_from_methoddesc ****************************************
-   Initialize an array of typedescriptors from a methoddesc.
-   
-   IN:
-       desc.............the methoddesc
-       buflen...........number of parameters the buffer can hold
-       twoword..........if true, use two parameter slots for two-word types
-          startindex.......the zero-based index of the first parameter to
-                           write to the array. In other words the number of
-                                               parameters to skip at the beginning of the methoddesc.
-
-   OUT:
-       *td..............array receiving the typedescriptors.
-                           td[0] receives the typedescriptor of the
-                                               (startindex+1)th parameter of the method
-       *returntype......receives the typedescriptor of the return type.
-                           returntype may be NULL
-
-   RETURN VALUE:
-       >= 0.............number of typedescriptors filled in TD
-          -1...............an exception has been thrown
-
-   NOTE:
-       If (according to BUFLEN) the buffer is to small to hold the
-          parameter types, an internal error is thrown. This must be
-          avoided by checking the number of parameters and allocating enough
-          space before calling this function.
-
-*******************************************************************************/
-
-int
-typedescriptors_init_from_methoddesc(typedescriptor_t *td,
-                                                                        methoddesc *desc,
-                                                                        int buflen,bool twoword,int startindex,
-                                                                        typedescriptor_t *returntype)
-{
-       int i;
-    int args = 0;
-
-    /* check arguments */
-    for (i=startindex; i<desc->paramcount; ++i) {
-               if (++args > buflen) {
-                       exceptions_throw_internalerror("Buffer too small for method arguments.");
-                       return -1;
-               }
-
-               if (!typedescriptor_init_from_typedesc(td,desc->paramtypes + i))
-                       return -1;
-               td++;
-
-               if (twoword && (td[-1].type == TYPE_LNG || td[-1].type == TYPE_DBL)) {
-                       if (++args > buflen) {
-                               exceptions_throw_internalerror("Buffer too small for method arguments.");
-                               return -1;
-                       }
-
-                       td->type = TYPE_VOID;
-                       TYPEINFO_INIT_PRIMITIVE(td->typeinfo);
-                       td++;
-               }
-    }
-
-    /* check returntype */
-    if (returntype) {
-               if (!typedescriptor_init_from_typedesc(returntype,&(desc->returntype)))
-                       return -1;
-       }
-
-       return args;
-}
-
-/* typeinfo_init_component *****************************************************
-   Initialize a typeinfo with the component type of a given array type.
-   
-   IN:
-          srcarray.........the typeinfo of the array type
-
-   OUT:
-       *dst.............receives the typeinfo of the component type
-
-   RETURN VALUE:
-       true.............success
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-bool
-typeinfo_init_component(typeinfo_t *srcarray,typeinfo_t *dst)
-{
-       typeinfo_mergedlist_t *merged;
-
-       TYPEINFO_ASSERT(srcarray);
-       TYPEINFO_ASSERT(dst);
-
-    if (TYPEINFO_IS_NULLTYPE(*srcarray)) {
-        TYPEINFO_INIT_NULLTYPE(*dst);
-        return true;
-    }
-    
-    if (!TYPEINFO_IS_ARRAY(*srcarray)) {
-               /* XXX should we make that a verify error? */
-               exceptions_throw_internalerror("Trying to access component of non-array");
-               return false;
-       }
-
-       /* save the mergedlist (maybe dst == srcarray) */
-
-       merged = srcarray->merged;
-
-       if (IS_CLASSREF(srcarray->typeclass)) {
-               constant_classref *comp;
-               comp = class_get_classref_component_of(srcarray->typeclass.ref);
-
-               if (comp) {
-                       if (!typeinfo_init_class(dst,CLASSREF_OR_CLASSINFO(comp)))
-                               return false;
-               }
-               else {
-                       TYPEINFO_INIT_PRIMITIVE(*dst);
-               }
-       }
-       else {
-               vftbl_t *comp;
-               
-               if (!(srcarray->typeclass.cls->state & CLASS_LINKED)) {
-                       if (!link_class(srcarray->typeclass.cls)) {
-                               return false;
-                       }
-               }
-
-               TYPEINFO_ASSERT(srcarray->typeclass.cls->vftbl);
-               TYPEINFO_ASSERT(srcarray->typeclass.cls->vftbl->arraydesc);
-
-               comp = srcarray->typeclass.cls->vftbl->arraydesc->componentvftbl;
-               if (comp)
-                       typeinfo_init_classinfo(dst,comp->clazz);
-               else
-                       TYPEINFO_INIT_PRIMITIVE(*dst);
-       }
-    
-    dst->merged = merged; /* XXX should we do a deep copy? */
-       return true;
-}
-
-/* typeinfo_clone **************************************************************
-   Create a deep copy of a typeinfo struct.
-   
-   IN:
-          src..............the typeinfo to copy
-
-   OUT:
-       *dest............receives the copy
-
-   NOTE:
-       If src == dest this function is a nop.
-
-*******************************************************************************/
-
-void
-typeinfo_clone(typeinfo_t *src,typeinfo_t *dest)
-{
-    int count;
-    classref_or_classinfo *srclist,*destlist;
-
-    if (src == dest)
-        return;
-    
-    *dest = *src;
-
-    if (src->merged) {
-        count = src->merged->count;
-        TYPEINFO_ALLOCMERGED(dest->merged,count);
-        dest->merged->count = count;
-
-        srclist = src->merged->list;
-        destlist = dest->merged->list;
-        while (count--)
-            *destlist++ = *srclist++;
-    }
-}
-
-/**********************************************************************/
-/* MISCELLANEOUS FUNCTIONS                                            */
-/**********************************************************************/
-
-/* typeinfo_free ***************************************************************
-   Free memory referenced by the given typeinfo. The typeinfo itself is not
-   freed.
-   
-   IN:
-       info.............the typeinfo
-
-*******************************************************************************/
-
-void
-typeinfo_free(typeinfo_t *info)
-{
-    TYPEINFO_FREEMERGED_IF_ANY(info->merged);
-    info->merged = NULL;
-}
-
-/**********************************************************************/
-/* MERGING FUNCTIONS                                                  */
-/* The following functions are used to merge the types represented by */
-/* two typeinfo structures into one typeinfo structure.               */
-/**********************************************************************/
-
-static
-void
-typeinfo_merge_error(methodinfo *m,char *str,typeinfo_t *x,typeinfo_t *y) {
-#ifdef TYPEINFO_VERBOSE
-    fprintf(stderr,"Error in typeinfo_merge: %s\n",str);
-    fprintf(stderr,"Typeinfo x:\n");
-    typeinfo_print(stderr,x,1);
-    fprintf(stderr,"Typeinfo y:\n");
-    typeinfo_print(stderr,y,1);
-    log_text(str);
-#endif
-
-       exceptions_throw_verifyerror(m, str);
-}
-
-/* Condition: clsx != clsy. */
-/* Returns: true if dest was changed (currently always true). */
-static
-bool
-typeinfo_merge_two(typeinfo_t *dest,classref_or_classinfo clsx,classref_or_classinfo clsy)
-{
-       TYPEINFO_ASSERT(dest);
-    TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
-    TYPEINFO_ALLOCMERGED(dest->merged,2);
-    dest->merged->count = 2;
-
-       TYPEINFO_ASSERT(clsx.any != clsy.any);
-
-    if (clsx.any < clsy.any) {
-        dest->merged->list[0] = clsx;
-        dest->merged->list[1] = clsy;
-    }
-    else {
-        dest->merged->list[0] = clsy;
-        dest->merged->list[1] = clsx;
-    }
-
-    return true;
-}
-
-/* Returns: true if dest was changed. */
-static
-bool
-typeinfo_merge_add(typeinfo_t *dest,typeinfo_mergedlist_t *m,classref_or_classinfo cls)
-{
-    int count;
-    typeinfo_mergedlist_t *newmerged;
-    classref_or_classinfo *mlist,*newlist;
-
-    count = m->count;
-    mlist = m->list;
-
-    /* Check if cls is already in the mergedlist m. */
-    while (count--) {
-        if ((mlist++)->any == cls.any) { /* XXX check equal classrefs? */
-            /* cls is in the list, so m is the resulting mergedlist */
-            if (dest->merged == m)
-                return false;
-
-            /* We have to copy the mergedlist */
-            TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
-            count = m->count;
-            TYPEINFO_ALLOCMERGED(dest->merged,count);
-            dest->merged->count = count;
-            newlist = dest->merged->list;
-            mlist = m->list;
-            while (count--) {
-                *newlist++ = *mlist++;
-            }
-            return true;
-        }
-    }
-
-    /* Add cls to the mergedlist. */
-    count = m->count;
-    TYPEINFO_ALLOCMERGED(newmerged,count+1);
-    newmerged->count = count+1;
-    newlist = newmerged->list;    
-    mlist = m->list;
-    while (count) {
-        if (mlist->any > cls.any)
-            break;
-        *newlist++ = *mlist++;
-        count--;
-    }
-    *newlist++ = cls;
-    while (count--) {
-        *newlist++ = *mlist++;
-    }
-
-    /* Put the new mergedlist into dest. */
-    TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
-    dest->merged = newmerged;
-    
-    return true;
-}
-
-/* Returns: true if dest was changed. */
-static
-bool
-typeinfo_merge_mergedlists(typeinfo_t *dest,typeinfo_mergedlist_t *x,
-                           typeinfo_mergedlist_t *y)
-{
-    int count = 0;
-    int countx,county;
-    typeinfo_mergedlist_t *temp,*result;
-    classref_or_classinfo *clsx,*clsy,*newlist;
-
-    /* count the elements that will be in the resulting list */
-    /* (Both lists are sorted, equal elements are counted only once.) */
-    clsx = x->list;
-    clsy = y->list;
-    countx = x->count;
-    county = y->count;
-    while (countx && county) {
-        if (clsx->any == clsy->any) {
-            clsx++;
-            clsy++;
-            countx--;
-            county--;
-        }
-        else if (clsx->any < clsy->any) {
-            clsx++;
-            countx--;
-        }
-        else {
-            clsy++;
-            county--;
-        }
-        count++;
-    }
-    count += countx + county;
-
-    /* {The new mergedlist will have count entries.} */
-
-    if ((x->count != count) && (y->count == count)) {
-        temp = x; x = y; y = temp;
-    }
-    /* {If one of x,y is already the result it is x.} */
-    if (x->count == count) {
-        /* x->merged is equal to the result */
-        if (x == dest->merged)
-            return false;
-
-        if (!dest->merged || dest->merged->count != count) {
-            TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
-            TYPEINFO_ALLOCMERGED(dest->merged,count);
-            dest->merged->count = count;
-        }
-
-        newlist = dest->merged->list;
-        clsx = x->list;
-        while (count--) {
-            *newlist++ = *clsx++;
-        }
-        return true;
-    }
-
-    /* {We have to merge two lists.} */
-
-    /* allocate the result list */
-    TYPEINFO_ALLOCMERGED(result,count);
-    result->count = count;
-    newlist = result->list;
-
-    /* merge the sorted lists */
-    clsx = x->list;
-    clsy = y->list;
-    countx = x->count;
-    county = y->count;
-    while (countx && county) {
-        if (clsx->any == clsy->any) {
-            *newlist++ = *clsx++;
-            clsy++;
-            countx--;
-            county--;
-        }
-        else if (clsx->any < clsy->any) {
-            *newlist++ = *clsx++;
-            countx--;
-        }
-        else {
-            *newlist++ = *clsy++;
-            county--;
-        }
-    }
-    while (countx--)
-            *newlist++ = *clsx++;
-    while (county--)
-            *newlist++ = *clsy++;
-
-    /* replace the list in dest with the result list */
-    TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
-    dest->merged = result;
-
-    return true;
-}
-
-/* typeinfo_merge_nonarrays ****************************************************
-   Merge two non-array types.
-   
-   IN:
-       x................the first type
-          y................the second type
-          mergedx..........merged list of the first type, may be NULL
-          mergedy..........merged list of the descond type, may be NULL
-
-   OUT:
-       *dest............receives the resulting merged list
-          *result..........receives the resulting type
-
-   RETURN VALUE:
-       typecheck_TRUE...*dest has been modified
-          typecheck_FALSE..*dest has not been modified
-          typecheck_FAIL...an exception has been thrown
-
-   NOTE:
-       RESULT is an extra parameter so it can point to dest->typeclass or to
-          dest->elementclass.
-
-*******************************************************************************/
-
-static typecheck_result
-typeinfo_merge_nonarrays(typeinfo_t *dest,
-                         classref_or_classinfo *result,
-                         classref_or_classinfo x,classref_or_classinfo y,
-                         typeinfo_mergedlist_t *mergedx,
-                         typeinfo_mergedlist_t *mergedy)
-{
-       classref_or_classinfo t;
-    classinfo *tcls,*common;
-    typeinfo_mergedlist_t *tmerged;
-    bool changed;
-       typecheck_result r;
-       utf *xname;
-       utf *yname;
-
-       TYPEINFO_ASSERT(dest && result && x.any && y.any);
-       TYPEINFO_ASSERT(x.cls != pseudo_class_Null);
-       TYPEINFO_ASSERT(y.cls != pseudo_class_Null);
-       TYPEINFO_ASSERT(x.cls != pseudo_class_New);
-       TYPEINFO_ASSERT(y.cls != pseudo_class_New);
-
-       /*--------------------------------------------------*/
-       /* common cases                                     */
-       /*--------------------------------------------------*/
-
-    /* Common case 1: x and y are the same class or class reference */
-    /* (This case is very simple unless *both* x and y really represent
-     *  merges of subclasses of clsx==clsy.)
-     */
-    if ( (x.any == y.any) && (!mergedx || !mergedy) ) {
-  return_simple_x:
-        /* DEBUG */ /* log_text("return simple x"); */
-        changed = (dest->merged != NULL);
-        TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
-        dest->merged = NULL;
-        *result = x;
-        /* DEBUG */ /* log_text("returning"); */
-        return changed;
-    }
-
-       xname = (IS_CLASSREF(x)) ? x.ref->name : x.cls->name;
-       yname = (IS_CLASSREF(y)) ? y.ref->name : y.cls->name;
-
-       /* Common case 2: xname == yname, at least one unresolved */
-    if ((IS_CLASSREF(x) || IS_CLASSREF(y)) && (xname == yname))
-       {
-               /* use the loaded one if any */
-               if (!IS_CLASSREF(y))
-                       x = y;
-               goto return_simple_x;
-    }
-
-       /*--------------------------------------------------*/
-       /* non-trivial cases                                */
-       /*--------------------------------------------------*/
-
-#ifdef TYPEINFO_VERBOSE
-       {
-               typeinfo_t dbgx,dbgy;
-               fprintf(stderr,"merge_nonarrays:\n");
-               fprintf(stderr,"    ");if(IS_CLASSREF(x))fprintf(stderr,"<ref>");utf_fprint_printable_ascii(stderr,xname);fprintf(stderr,"\n");
-               fprintf(stderr,"    ");if(IS_CLASSREF(y))fprintf(stderr,"<ref>");utf_fprint_printable_ascii(stderr,yname);fprintf(stderr,"\n");
-               fflush(stderr);
-               typeinfo_init_class(&dbgx,x);
-               dbgx.merged = mergedx;
-               typeinfo_init_class(&dbgy,y);
-               dbgy.merged = mergedy;
-               typeinfo_print(stderr,&dbgx,4);
-               fprintf(stderr,"  with:\n");
-               typeinfo_print(stderr,&dbgy,4);
-       }
-#endif
-
-       TYPEINFO_ASSERT(IS_CLASSREF(x) || (x.cls->state & CLASS_LOADED));
-       TYPEINFO_ASSERT(IS_CLASSREF(y) || (y.cls->state & CLASS_LOADED));
-
-    /* If y is unresolved or an interface, swap x and y. */
-    if (IS_CLASSREF(y) || (!IS_CLASSREF(x) && y.cls->flags & ACC_INTERFACE))
-       {
-        t = x; x = y; y = t;
-        tmerged = mergedx; mergedx = mergedy; mergedy = tmerged;
-    }
-       
-    /* {We know: If only one of x,y is unresolved it is x,} */
-    /* {         If both x,y are resolved and only one of x,y is an interface it is x.} */
-
-       if (IS_CLASSREF(x)) {
-               /* {We know: x and y have different class names} */
-               
-        /* Check if we are merging an unresolved type with java.lang.Object */
-        if (y.cls == class_java_lang_Object && !mergedy) {
-            x = y;
-            goto return_simple_x;
-        }
-            
-               common = class_java_lang_Object;
-               goto merge_with_simple_x;
-       }
-
-       /* {We know: both x and y are resolved} */
-    /* {We know: If only one of x,y is an interface it is x.} */
-
-       TYPEINFO_ASSERT(!IS_CLASSREF(x) && !IS_CLASSREF(y));
-       TYPEINFO_ASSERT(x.cls->state & CLASS_LOADED);
-       TYPEINFO_ASSERT(y.cls->state & CLASS_LOADED);
-
-    /* Handle merging of interfaces: */
-    if (x.cls->flags & ACC_INTERFACE) {
-        /* {x.cls is an interface and mergedx == NULL.} */
-        
-        if (y.cls->flags & ACC_INTERFACE) {
-            /* We are merging two interfaces. */
-            /* {mergedy == NULL} */
-
-            /* {We know that x.cls!=y.cls (see common case at beginning.)} */
-            result->cls = class_java_lang_Object;
-            return typeinfo_merge_two(dest,x,y);
-        }
-
-        /* {We know: x is an interface, y is a class.} */
-
-        /* Check if we are merging an interface with java.lang.Object */
-        if (y.cls == class_java_lang_Object && !mergedy) {
-            x = y;
-            goto return_simple_x;
-        }
-
-        /* If the type y implements x then the result of the merge
-         * is x regardless of mergedy.
-         */
-
-               /* we may have to link the classes */
-               if (!(x.cls->state & CLASS_LINKED))
-                       if (!link_class(x.cls))
-                               return typecheck_FAIL;
-               if (!(y.cls->state & CLASS_LINKED))
-                       if (!link_class(y.cls))
-                               return typecheck_FAIL;
-        
-               TYPEINFO_ASSERT(x.cls->state & CLASS_LINKED);
-               TYPEINFO_ASSERT(y.cls->state & CLASS_LINKED);
-
-        if (CLASSINFO_IMPLEMENTS_INTERFACE(y.cls,x.cls->index))
-               {
-            /* y implements x, so the result of the merge is x. */
-            goto return_simple_x;
-               }
-               
-        r = mergedlist_implements_interface(mergedy,x.cls);
-               if (r == typecheck_FAIL)
-                       return r;
-               if (r == typecheck_TRUE)
-        {
-            /* y implements x, so the result of the merge is x. */
-            goto return_simple_x;
-        }
-        
-        /* {We know: x is an interface, the type y a class or a merge
-         * of subclasses and is not guaranteed to implement x.} */
-
-        common = class_java_lang_Object;
-        goto merge_with_simple_x;
-    }
-
-    /* {We know: x and y are classes (not interfaces).} */
-    
-       /* we may have to link the classes */
-       if (!(x.cls->state & CLASS_LINKED))
-               if (!link_class(x.cls))
-                       return typecheck_FAIL;
-       if (!(y.cls->state & CLASS_LINKED))
-               if (!link_class(y.cls))
-                       return typecheck_FAIL;
-        
-       TYPEINFO_ASSERT(x.cls->state & CLASS_LINKED);
-       TYPEINFO_ASSERT(y.cls->state & CLASS_LINKED);
-
-    /* If *x is deeper in the inheritance hierarchy swap x and y. */
-    if (x.cls->index > y.cls->index) {
-        t = x; x = y; y = t;
-        tmerged = mergedx; mergedx = mergedy; mergedy = tmerged;
-    }
-
-    /* {We know: y is at least as deep in the hierarchy as x.} */
-
-    /* Find nearest common anchestor for the classes. */
-
-    common = x.cls;
-    tcls   = y.cls;
-
-    while (tcls->index > common->index)
-        tcls = tcls->super;
-
-    while (common != tcls) {
-        common = common->super;
-        tcls = tcls->super;
-    }
-
-    /* {common == nearest common anchestor of x and y.} */
-
-    /* If x.cls==common and x is a whole class (not a merge of subclasses)
-     * then the result of the merge is x.
-     */
-    if (x.cls == common && !mergedx) {
-        goto return_simple_x;
-    }
-   
-    if (mergedx) {
-        result->cls = common;
-        if (mergedy)
-            return typeinfo_merge_mergedlists(dest,mergedx,mergedy);
-        else
-            return typeinfo_merge_add(dest,mergedx,y);
-    }
-
-merge_with_simple_x:
-    result->cls = common;
-    if (mergedy)
-        return typeinfo_merge_add(dest,mergedy,x);
-    else
-        return typeinfo_merge_two(dest,x,y);
-}
-
-/* typeinfo_merge **************************************************************
-   Merge two types.
-   
-   IN:
-       m................method for exception messages
-       dest.............the first type
-       y................the second type
-
-   OUT:
-       *dest............receives the result of the merge
-
-   RETURN VALUE:
-       typecheck_TRUE...*dest has been modified
-       typecheck_FALSE..*dest has not been modified
-       typecheck_FAIL...an exception has been thrown
-
-   PRE-CONDITIONS:
-       1) *dest must be a valid initialized typeinfo
-       2) dest != y
-
-*******************************************************************************/
-
-typecheck_result
-typeinfo_merge(methodinfo *m,typeinfo_t *dest,typeinfo_t* y)
-{
-    typeinfo_t *x;
-    typeinfo_t *tmp;
-    classref_or_classinfo common;
-    classref_or_classinfo elementclass;
-    int dimension;
-    int elementtype;
-    bool changed;
-       typecheck_result r;
-
-       /*--------------------------------------------------*/
-       /* fast checks                                      */
-       /*--------------------------------------------------*/
-
-    /* Merging something with itself is a nop */
-    if (dest == y)
-        return typecheck_FALSE;
-
-    /* Merging two returnAddress types is ok. */
-       /* Merging two different returnAddresses never happens, as the verifier */
-       /* keeps them separate in order to check all the possible return paths  */
-       /* from JSR subroutines.                                                */
-    if (!dest->typeclass.any && !y->typeclass.any) {
-               TYPEINFO_ASSERT(TYPEINFO_RETURNADDRESS(*dest) ==  TYPEINFO_RETURNADDRESS(*y));
-        return typecheck_FALSE;
-       }
-    
-    /* Primitive types cannot be merged with reference types */
-       /* This must be checked before calls to typeinfo_merge.  */
-    TYPEINFO_ASSERT(dest->typeclass.any && y->typeclass.any);
-
-    /* handle uninitialized object types */
-    if (TYPEINFO_IS_NEWOBJECT(*dest) || TYPEINFO_IS_NEWOBJECT(*y)) {
-        if (!TYPEINFO_IS_NEWOBJECT(*dest) || !TYPEINFO_IS_NEWOBJECT(*y)) {
-            typeinfo_merge_error(m,"Trying to merge uninitialized object type.",dest,y);
-                       return typecheck_FAIL;
-               }
-        if (TYPEINFO_NEWOBJECT_INSTRUCTION(*dest) != TYPEINFO_NEWOBJECT_INSTRUCTION(*y)) {
-            typeinfo_merge_error(m,"Trying to merge different uninitialized objects.",dest,y);
-                       return typecheck_FAIL;
-               }
-               /* the same uninitialized object -- no change */
-               return typecheck_FALSE;
-    }
-    
-       /*--------------------------------------------------*/
-       /* common cases                                     */
-       /*--------------------------------------------------*/
-
-    /* Common case: dest and y are the same class or class reference */
-    /* (This case is very simple unless *both* dest and y really represent
-     *  merges of subclasses of class dest==class y.)
-     */
-    if ((dest->typeclass.any == y->typeclass.any) && (!dest->merged || !y->merged)) {
-return_simple:
-        changed = (dest->merged != NULL);
-        TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
-        dest->merged = NULL;
-        return changed;
-    }
-    
-    /* Handle null types: */
-    if (TYPEINFO_IS_NULLTYPE(*y)) {
-        return typecheck_FALSE;
-    }
-    if (TYPEINFO_IS_NULLTYPE(*dest)) {
-        TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
-        TYPEINFO_CLONE(*y,*dest);
-        return typecheck_TRUE;
-    }
-
-       /* Common case: two types with the same name, at least one unresolved */
-       if (IS_CLASSREF(dest->typeclass)) {
-               if (IS_CLASSREF(y->typeclass)) {
-                       if (dest->typeclass.ref->name == y->typeclass.ref->name)
-                               goto return_simple;
-               }
-               else {
-                       /* XXX should we take y instead of dest here? */
-                       if (dest->typeclass.ref->name == y->typeclass.cls->name)
-                               goto return_simple;
-               }
-       }
-       else {
-               if (IS_CLASSREF(y->typeclass) 
-                   && (dest->typeclass.cls->name == y->typeclass.ref->name))
-               {
-                       goto return_simple;
-               }
-       }
-
-       /*--------------------------------------------------*/
-       /* non-trivial cases                                */
-       /*--------------------------------------------------*/
-
-#ifdef TYPEINFO_VERBOSE
-       fprintf(stderr,"merge:\n");
-    typeinfo_print(stderr,dest,4);
-    typeinfo_print(stderr,y,4);
-#endif
-
-    /* This function uses x internally, so x and y can be swapped
-     * without changing dest. */
-    x = dest;
-    changed = false;
-    
-    /* Handle merging of arrays: */
-    if (TYPEINFO_IS_ARRAY(*x) && TYPEINFO_IS_ARRAY(*y)) {
-        
-        /* Make x the one with lesser dimension */
-        if (x->dimension > y->dimension) {
-            tmp = x; x = y; y = tmp;
-        }
-
-        /* If one array (y) has higher dimension than the other,
-         * interpret it as an array (same dim. as x) of Arraystubs. */
-        if (x->dimension < y->dimension) {
-            dimension = x->dimension;
-            elementtype = ARRAYTYPE_OBJECT;
-            elementclass.cls = pseudo_class_Arraystub;
-        }
-        else {
-            dimension = y->dimension;
-            elementtype = y->elementtype;
-            elementclass = y->elementclass;
-        }
-        
-        /* {The arrays are of the same dimension.} */
-        
-        if (x->elementtype != elementtype) {
-            /* Different element types are merged, so the resulting array
-             * type has one accessible dimension less. */
-            if (--dimension == 0) {
-                common.cls = pseudo_class_Arraystub;
-                elementtype = 0;
-                elementclass.any = NULL;
-            }
-            else {
-                common.cls = class_multiarray_of(dimension,pseudo_class_Arraystub,true);
-                               if (!common.cls) {
-                                       exceptions_throw_internalerror("XXX Coult not create array class");
-                                       return typecheck_FAIL;
-                               }
-
-                elementtype = ARRAYTYPE_OBJECT;
-                elementclass.cls = pseudo_class_Arraystub;
-            }
-        }
-        else {
-            /* {The arrays have the same dimension and elementtype.} */
-
-            if (elementtype == ARRAYTYPE_OBJECT) {
-                /* The elements are references, so their respective
-                 * types must be merged.
-                 */
-                               r = typeinfo_merge_nonarrays(dest,
-                                               &elementclass,
-                                               x->elementclass,
-                                               elementclass,
-                                               x->merged,y->merged);
-                               TYPEINFO_ASSERT(r != typecheck_MAYBE);
-                               if (r == typecheck_FAIL)
-                                       return r;
-                               changed |= r;
-
-                /* DEBUG */ /* log_text("finding resulting array class: "); */
-                               if (IS_CLASSREF(elementclass))
-                                       common.ref = class_get_classref_multiarray_of(dimension,elementclass.ref);
-                               else {
-                                       common.cls = class_multiarray_of(dimension,elementclass.cls,true);
-                                       if (!common.cls) {
-                                               exceptions_throw_internalerror("XXX Coult not create array class");
-                                               return typecheck_FAIL;
-                                       }
-                               }
-                /* DEBUG */ /* utf_display_printable_ascii(common->name); printf("\n"); */
-            }
-                       else {
-                               common.any = y->typeclass.any;
-                       }
-        }
-    }
-    else {
-        /* {We know that at least one of x or y is no array, so the
-         *  result cannot be an array.} */
-        
-               r = typeinfo_merge_nonarrays(dest,
-                               &common,
-                               x->typeclass,y->typeclass,
-                               x->merged,y->merged);
-               TYPEINFO_ASSERT(r != typecheck_MAYBE);
-               if (r == typecheck_FAIL)
-                       return r;
-               changed |= r;
-
-        dimension = 0;
-        elementtype = 0;
-        elementclass.any = NULL;
-    }
-
-    /* Put the new values into dest if neccessary. */
-
-    if (dest->typeclass.any != common.any) {
-        dest->typeclass.any = common.any;
-        changed = true;
-    }
-    if (dest->dimension != dimension) {
-        dest->dimension = dimension;
-        changed = true;
-    }
-    if (dest->elementtype != elementtype) {
-        dest->elementtype = elementtype;
-        changed = true;
-    }
-    if (dest->elementclass.any != elementclass.any) {
-        dest->elementclass.any = elementclass.any;
-        changed = true;
-    }
-
-    return changed;
-}
-#endif /* ENABLE_VERIFER */
-
-
-/**********************************************************************/
-/* DEBUGGING HELPERS                                                  */
-/**********************************************************************/
-
-#ifdef TYPEINFO_DEBUG
-
-#if 0
-static int
-typeinfo_test_compare(classref_or_classinfo *a,classref_or_classinfo *b)
-{
-    if (a->any == b->any) return 0;
-    if (a->any < b->any) return -1;
-    return +1;
-}
-
-static void
-typeinfo_test_parse(typeinfo_t *info,char *str)
-{
-    int num;
-    int i;
-    typeinfo_t *infobuf;
-    u1 *typebuf;
-    int returntype;
-    utf *desc = utf_new_char(str);
-    
-    num = typeinfo_count_method_args(desc,false);
-    if (num) {
-        typebuf = DMNEW(u1,num);
-        infobuf = DMNEW(typeinfo_t,num);
-        
-        typeinfo_init_from_method_args(desc,typebuf,infobuf,num,false,
-                                       &returntype,info);
-
-        TYPEINFO_ALLOCMERGED(info->merged,num);
-        info->merged->count = num;
-
-        for (i=0; i<num; ++i) {
-            if (typebuf[i] != TYPE_ADR) {
-                log_text("non-reference type in mergedlist");
-                               assert(0);
-                       }
-
-            info->merged->list[i].any = infobuf[i].typeclass.any;
-        }
-        qsort(info->merged->list,num,sizeof(classref_or_classinfo),
-              (int(*)(const void *,const void *))&typeinfo_test_compare);
-    }
-    else {
-        typeinfo_init_from_method_args(desc,NULL,NULL,0,false,
-                                       &returntype,info);
-    }
-}
-#endif
-
-#define TYPEINFO_TEST_BUFLEN  4000
-
-static bool
-typeinfo_equal(typeinfo_t *x,typeinfo_t *y)
-{
-    int i;
-    
-    if (x->typeclass.any != y->typeclass.any) return false;
-    if (x->dimension != y->dimension) return false;
-    if (x->dimension) {
-        if (x->elementclass.any != y->elementclass.any) return false;
-        if (x->elementtype != y->elementtype) return false;
-    }
-
-    if (TYPEINFO_IS_NEWOBJECT(*x))
-        if (TYPEINFO_NEWOBJECT_INSTRUCTION(*x)
-            != TYPEINFO_NEWOBJECT_INSTRUCTION(*y))
-            return false;
-
-    if (x->merged || y->merged) {
-        if (!(x->merged && y->merged)) return false;
-        if (x->merged->count != y->merged->count) return false;
-        for (i=0; i<x->merged->count; ++i)
-            if (x->merged->list[i].any != y->merged->list[i].any)
-                return false;
-    }
-    return true;
-}
-
-static void
-typeinfo_testmerge(typeinfo_t *a,typeinfo_t *b,typeinfo_t *result,int *failed)
-{
-    typeinfo_t dest;
-    bool changed,changed_should_be;
-       typecheck_result r;
-
-    TYPEINFO_CLONE(*a,dest);
-    
-    printf("\n          ");
-    typeinfo_print_short(stdout,&dest);
-    printf("\n          ");
-    typeinfo_print_short(stdout,b);
-    printf("\n");
-
-       r = typeinfo_merge(NULL,&dest,b);
-       if (r == typecheck_FAIL) {
-               printf("EXCEPTION\n");
-               return;
-       }
-    changed = (r) ? 1 : 0;
-    changed_should_be = (!typeinfo_equal(&dest,a)) ? 1 : 0;
-
-    printf("          %s\n",(changed) ? "changed" : "=");
-
-    if (typeinfo_equal(&dest,result)) {
-        printf("OK        ");
-        typeinfo_print_short(stdout,&dest);
-        printf("\n");
-        if (changed != changed_should_be) {
-            printf("WRONG RETURN VALUE!\n");
-            (*failed)++;
-        }
-    }
-    else {
-        printf("RESULT    ");
-        typeinfo_print_short(stdout,&dest);
-        printf("\n");
-        printf("SHOULD BE ");
-        typeinfo_print_short(stdout,result);
-        printf("\n");
-        (*failed)++;
-    }
-}
-
-#if 0
-static void
-typeinfo_inc_dimension(typeinfo_t *info)
-{
-    if (info->dimension++ == 0) {
-        info->elementtype = ARRAYTYPE_OBJECT;
-        info->elementclass = info->typeclass;
-    }
-    info->typeclass = class_array_of(info->typeclass,true);
-}
-#endif
-
-#define TYPEINFO_TEST_MAXDIM  10
-
-static void
-typeinfo_testrun(char *filename)
-{
-    char buf[TYPEINFO_TEST_BUFLEN];
-    char bufa[TYPEINFO_TEST_BUFLEN];
-    char bufb[TYPEINFO_TEST_BUFLEN];
-    char bufc[TYPEINFO_TEST_BUFLEN];
-    typeinfo_t a,b,c;
-    int maxdim;
-    int failed = 0;
-    FILE *file = fopen(filename,"rt");
-       int res;
-    
-    if (!file) {
-        log_text("could not open typeinfo test file");
-               assert(0);
-       }
-
-    while (fgets(buf,TYPEINFO_TEST_BUFLEN,file)) {
-        if (buf[0] == '#' || !strlen(buf))
-            continue;
-        
-        res = sscanf(buf,"%s\t%s\t%s\n",bufa,bufb,bufc);
-        if (res != 3 || !strlen(bufa) || !strlen(bufb) || !strlen(bufc)) {
-            log_text("Invalid line in typeinfo test file (none of empty, comment or test)");
-                       assert(0);
-               }
-
-#if 0
-        typeinfo_test_parse(&a,bufa);
-        typeinfo_test_parse(&b,bufb);
-        typeinfo_test_parse(&c,bufc);
-#endif
-#if 0
-        do {
-#endif
-            typeinfo_testmerge(&a,&b,&c,&failed); /* check result */
-            typeinfo_testmerge(&b,&a,&c,&failed); /* check commutativity */
-
-            if (TYPEINFO_IS_NULLTYPE(a)) break;
-            if (TYPEINFO_IS_NULLTYPE(b)) break;
-            if (TYPEINFO_IS_NULLTYPE(c)) break;
-            
-            maxdim = a.dimension;
-            if (b.dimension > maxdim) maxdim = b.dimension;
-            if (c.dimension > maxdim) maxdim = c.dimension;
-
-#if 0
-            if (maxdim < TYPEINFO_TEST_MAXDIM) {
-                typeinfo_inc_dimension(&a);
-                typeinfo_inc_dimension(&b);
-                typeinfo_inc_dimension(&c);
-            }
-        } while (maxdim < TYPEINFO_TEST_MAXDIM);
-#endif
-    }
-
-    fclose(file);
-
-    if (failed) {
-        fprintf(stderr,"Failed typeinfo_merge tests: %d\n",failed);
-        log_text("Failed test");
-               assert(0);
-    }
-}
-
-void
-typeinfo_test()
-{
-    log_text("Running typeinfo test file...");
-    typeinfo_testrun("typeinfo.tst");
-    log_text("Finished typeinfo test file.");
-}
-
-#if 0
-void
-typeinfo_init_from_fielddescriptor(typeinfo_t *info,char *desc)
-{
-    typeinfo_init_from_descriptor(info,desc,desc+strlen(desc));
-}
-#endif
-
-#define TYPEINFO_MAXINDENT  80
-
-void
-typeinfo_print_class(FILE *file,classref_or_classinfo c)
-{
-       /*fprintf(file,"<class %p>",c.any);*/
-
-       if (!c.any) {
-               fprintf(file,"<null>");
-       }
-       else {
-               if (IS_CLASSREF(c)) {
-                       fprintf(file,"<ref>");
-                       utf_fprint_printable_ascii(file,c.ref->name);
-               }
-               else {
-                       utf_fprint_printable_ascii(file,c.cls->name);
-               }
-       }
-}
-
-void
-typeinfo_print(FILE *file,typeinfo_t *info,int indent)
-{
-    int i;
-    char ind[TYPEINFO_MAXINDENT + 1];
-    instruction *ins;
-       basicblock *bptr;
-
-    if (indent > TYPEINFO_MAXINDENT) indent = TYPEINFO_MAXINDENT;
-    
-    for (i=0; i<indent; ++i)
-        ind[i] = ' ';
-    ind[i] = (char) 0;
-    
-    if (TYPEINFO_IS_PRIMITIVE(*info)) {
-               bptr = (basicblock*) TYPEINFO_RETURNADDRESS(*info);
-               if (bptr)
-                       fprintf(file,"%sreturnAddress (L%03d)\n",ind,bptr->nr);
-               else
-                       fprintf(file,"%sprimitive\n",ind);
-        return;
-    }
-    
-    if (TYPEINFO_IS_NULLTYPE(*info)) {
-        fprintf(file,"%snull\n",ind);
-        return;
-    }
-
-    if (TYPEINFO_IS_NEWOBJECT(*info)) {
-        ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*info);
-        if (ins) {
-            fprintf(file,"%sNEW(%p):",ind,(void*)ins);
-                       typeinfo_print_class(file,ins[-1].sx.val.c);
-            fprintf(file,"\n");
-        }
-        else {
-            fprintf(file,"%sNEW(this)",ind);
-        }
-        return;
-    }
-
-    fprintf(file,"%sClass:      ",ind);
-       typeinfo_print_class(file,info->typeclass);
-    fprintf(file,"\n");
-
-    if (TYPEINFO_IS_ARRAY(*info)) {
-        fprintf(file,"%sDimension:    %d",ind,(int)info->dimension);
-        fprintf(file,"\n%sElements:     ",ind);
-        switch (info->elementtype) {
-          case ARRAYTYPE_INT     : fprintf(file,"int\n"); break;
-          case ARRAYTYPE_LONG    : fprintf(file,"long\n"); break;
-          case ARRAYTYPE_FLOAT   : fprintf(file,"float\n"); break;
-          case ARRAYTYPE_DOUBLE  : fprintf(file,"double\n"); break;
-          case ARRAYTYPE_BYTE    : fprintf(file,"byte\n"); break;
-          case ARRAYTYPE_CHAR    : fprintf(file,"char\n"); break;
-          case ARRAYTYPE_SHORT   : fprintf(file,"short\n"); break;
-          case ARRAYTYPE_BOOLEAN : fprintf(file,"boolean\n"); break;
-              
-          case ARRAYTYPE_OBJECT:
-                         typeinfo_print_class(file,info->elementclass);
-              fprintf(file,"\n");
-              break;
-              
-          default:
-              fprintf(file,"INVALID ARRAYTYPE!\n");
-        }
-    }
-
-    if (info->merged) {
-        fprintf(file,"%sMerged:     ",ind);
-        for (i=0; i<info->merged->count; ++i) {
-            if (i) fprintf(file,", ");
-                       typeinfo_print_class(file,info->merged->list[i]);
-        }
-        fprintf(file,"\n");
-    }
-}
-
-void
-typeinfo_print_short(FILE *file,typeinfo_t *info)
-{
-    int i;
-    instruction *ins;
-       basicblock *bptr;
-
-       /*fprintf(file,"<typeinfo %p>",info);*/
-
-       if (!info) {
-               fprintf(file,"(typeinfo*)NULL");
-               return;
-       }
-
-    if (TYPEINFO_IS_PRIMITIVE(*info)) {
-               bptr = (basicblock*) TYPEINFO_RETURNADDRESS(*info);
-               if (bptr)
-                       fprintf(file,"ret(L%03d)",bptr->nr);
-               else
-                       fprintf(file,"primitive");
-        return;
-    }
-    
-    if (TYPEINFO_IS_NULLTYPE(*info)) {
-        fprintf(file,"null");
-        return;
-    }
-    
-    if (TYPEINFO_IS_NEWOBJECT(*info)) {
-        ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*info);
-        if (ins) {
-                       /*fprintf(file,"<ins %p>",ins);*/
-            fprintf(file,"NEW(%p):",(void*)ins);
-                       typeinfo_print_class(file,ins[-1].sx.val.c);
-        }
-        else
-            fprintf(file,"NEW(this)");
-        return;
-    }
-
-    typeinfo_print_class(file,info->typeclass);
-
-    if (info->merged) {
-        fprintf(file,"{");
-        for (i=0; i<info->merged->count; ++i) {
-            if (i) fprintf(file,",");
-                       typeinfo_print_class(file,info->merged->list[i]);
-        }
-        fprintf(file,"}");
-    }
-}
-
-void
-typeinfo_print_type(FILE *file,int type,typeinfo_t *info)
-{
-    switch (type) {
-      case TYPE_VOID: fprintf(file,"V"); break;
-      case TYPE_INT:  fprintf(file,"I"); break;
-      case TYPE_FLT:  fprintf(file,"F"); break;
-      case TYPE_DBL:  fprintf(file,"D"); break;
-      case TYPE_LNG:  fprintf(file,"J"); break;
-         case TYPE_RET:  fprintf(file,"R:"); /* FALLTHROUGH! */
-      case TYPE_ADR:
-                 typeinfo_print_short(file,info);
-          break;
-          
-      default:
-          fprintf(file,"!");
-    }
-}
-
-void
-typedescriptor_print(FILE *file,typedescriptor_t *td)
-{
-       typeinfo_print_type(file,td->type,&(td->typeinfo));
-}
-
-void
-typevector_print(FILE *file,varinfo *vec,int size)
-{
-    int i;
-
-    for (i=0; i<size; ++i) {
-               fprintf(file," %d=",i);
-        typeinfo_print_type(file, vec[i].type, &(vec[i].typeinfo));
-    }
-}
-
-#endif /* TYPEINFO_DEBUG */
-
-
-/*
- * 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/jit/verify/typeinfo.cpp b/src/vm/jit/verify/typeinfo.cpp
new file mode 100644 (file)
index 0000000..4df771a
--- /dev/null
@@ -0,0 +1,2572 @@
+/* src/vm/jit/verify/typeinfo.c - type system used by the type checker
+
+   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 <string.h>
+
+#include "mm/memory.h"
+
+#include "toolbox/logging.h"
+
+#include "vm/array.hpp"
+#include "vm/class.hpp"
+#include "vm/descriptor.h"
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/loader.hpp"
+#include "vm/primitive.hpp"
+#include "vm/resolve.hpp"
+
+#include "vm/jit/jit.hpp"
+#include "vm/jit/verify/typeinfo.hpp"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* check if a linked class is an array class. Only use for linked classes! */
+#define CLASSINFO_IS_ARRAY(clsinfo)  ((clsinfo)->vftbl->arraydesc != NULL)
+
+/* check if a linked class implements the interface with the given index */
+#define CLASSINFO_IMPLEMENTS_INTERFACE(cls,index)                   \
+    ( ((index) < (cls)->vftbl->interfacetablelength)            \
+      && ( (cls)->vftbl->interfacetable[-(index)] != NULL ) )
+
+/******************************************************************************/
+/* DEBUG HELPERS                                                              */
+/******************************************************************************/
+
+#ifdef TYPEINFO_DEBUG
+#define TYPEINFO_ASSERT(cond)  assert(cond)
+#else
+#define TYPEINFO_ASSERT(cond)
+#endif
+
+/**********************************************************************/
+/* TYPEVECTOR FUNCTIONS                                               */
+/**********************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+
+/* typevector_copy *************************************************************
+   Return a copy of the given typevector.
+  
+   IN:
+          src..............typevector set to copy, must be != NULL
+          size.............number of elements per typevector
+
+   RETURN VALUE:
+       a pointer to the new typevector set
+
+*******************************************************************************/
+
+varinfo *
+typevector_copy(varinfo *src, int size)
+{
+       varinfo *dst;
+       
+       TYPEINFO_ASSERT(src);
+       
+       dst = DNEW_TYPEVECTOR(size);
+       memcpy(dst,src,TYPEVECTOR_SIZE(size));
+
+       return dst;
+}
+
+/* typevector_copy_inplace *****************************************************
+   Copy a typevector to a given destination.
+
+   IN:
+          src..............typevector to copy, must be != NULL
+          dst..............destination to write the copy to
+          size.............number of elements per typevector
+
+*******************************************************************************/
+
+void
+typevector_copy_inplace(varinfo *src,varinfo *dst,int size)
+{
+       memcpy(dst,src,TYPEVECTOR_SIZE(size));
+}
+
+/* typevector_checktype ********************************************************
+   Check if the typevector contains a given type at a given index.
+  
+   IN:
+          vec..............typevector set, must be != NULL
+          index............index of component to check
+          type.............TYPE_* constant to check against
+
+   RETURN VALUE:
+       true if the typevector contains TYPE at INDEX,
+          false otherwise
+
+*******************************************************************************/
+
+bool
+typevector_checktype(varinfo *vec,int index,int type)
+{
+       TYPEINFO_ASSERT(vec);
+
+       return vec[index].type == type;
+}
+
+/* typevector_checkreference ***************************************************
+   Check if the typevector contains a reference at a given index.
+  
+   IN:
+          vec..............typevector, must be != NULL
+          index............index of component to check
+
+   RETURN VALUE:
+       true if the typevector contains a reference at INDEX,
+          false otherwise
+
+*******************************************************************************/
+
+bool
+typevector_checkreference(varinfo *vec, int index)
+{
+       TYPEINFO_ASSERT(vec);
+       return TYPEDESC_IS_REFERENCE(vec[index]);
+}
+
+/* typevectorset_checkretaddr **************************************************
+   Check if the typevectors contains a returnAddress at a given index.
+  
+   IN:
+          vec..............typevector, must be != NULL
+          index............index of component to check
+
+   RETURN VALUE:
+       true if the typevector contains a returnAddress at INDEX,
+          false otherwise
+
+*******************************************************************************/
+
+bool
+typevector_checkretaddr(varinfo *vec,int index)
+{
+       TYPEINFO_ASSERT(vec);
+       return TYPEDESC_IS_RETURNADDRESS(vec[index]);
+}
+
+/* typevector_store ************************************************************
+   Store a type at a given index in the typevector.
+  
+   IN:
+          vec..............typevector set, must be != NULL
+          index............index of component to set
+          type.............TYPE_* constant of type to set
+          info.............typeinfo of type to set, may be NULL, 
+                           if TYPE != TYPE_ADR
+
+*******************************************************************************/
+
+void
+typevector_store(varinfo *vec,int index,int type,typeinfo_t *info)
+{
+       TYPEINFO_ASSERT(vec);
+
+       vec[index].type = type;
+       if (info)
+               TYPEINFO_COPY(*info,vec[index].typeinfo);
+}
+
+/* typevector_store_retaddr ****************************************************
+   Store a returnAddress type at a given index in the typevector.
+  
+   IN:
+          vec..............typevector set, must be != NULL
+          index............index of component to set
+          info.............typeinfo of the returnAddress.
+
+*******************************************************************************/
+
+void
+typevector_store_retaddr(varinfo *vec,int index,typeinfo_t *info)
+{
+       TYPEINFO_ASSERT(vec);
+       TYPEINFO_ASSERT(TYPEINFO_IS_PRIMITIVE(*info));
+       
+       vec[index].type = TYPE_ADR;
+       TYPEINFO_INIT_RETURNADDRESS(vec[index].typeinfo,
+                       TYPEINFO_RETURNADDRESS(*info));
+}
+
+/* typevector_init_object ******************************************************
+   Replace all uninitialized object types in the typevector set which were 
+   created by the given instruction by initialized object types.
+  
+   IN:
+          set..............typevector set
+          ins..............instruction which created the uninitialized object type
+          initclass........class of the initialized object type to set
+          size.............number of elements per typevector
+
+   RETURN VALUE:
+       true.............success
+          false............an exception has been thrown
+
+   XXX maybe we should do the lazy resolving before calling this function
+
+*******************************************************************************/
+
+bool
+typevector_init_object(varinfo *set,void *ins,
+                                          classref_or_classinfo initclass,
+                                          int size)
+{
+       int i;
+
+       for (i=0; i<size; ++i) {
+               if (set[i].type == TYPE_ADR
+                       && TYPEINFO_IS_NEWOBJECT(set[i].typeinfo)
+                       && TYPEINFO_NEWOBJECT_INSTRUCTION(set[i].typeinfo) == ins)
+               {
+                       if (!typeinfo_init_class(&(set[i].typeinfo),initclass))
+                               return false;
+               }
+       }
+       return true;
+}
+
+/* typevector_merge ************************************************************
+   Merge a typevector with another one.
+   The given typevectors must have the same number of components.
+  
+   IN:
+       m................method for exception messages
+          dst..............the first typevector
+          y................the second typevector
+          size.............number of elements per typevector
+
+   OUT:
+       *dst.............the resulting typevector
+
+   RETURN VALUE:
+       typecheck_TRUE...dst has been modified
+          typecheck_FALSE..dst has not been modified
+          typecheck_FAIL...an exception has been thrown
+
+*******************************************************************************/
+
+typecheck_result
+typevector_merge(methodinfo *m,varinfo *dst,varinfo *y,int size)
+{
+       bool changed = false;
+       typecheck_result r;
+       
+       varinfo *a = dst;
+       varinfo *b = y;
+       while (size--) {
+               if (a->type != TYPE_VOID && a->type != b->type) {
+                       a->type = TYPE_VOID;
+                       changed = true;
+               }
+               else if (a->type == TYPE_ADR) {
+                       if (TYPEINFO_IS_PRIMITIVE(a->typeinfo)) {
+                               /* 'a' is a returnAddress */
+                               if (!TYPEINFO_IS_PRIMITIVE(b->typeinfo)
+                                       || (TYPEINFO_RETURNADDRESS(a->typeinfo)
+                                               != TYPEINFO_RETURNADDRESS(b->typeinfo)))
+                               {
+                                       a->type = TYPE_VOID;
+                                       changed = true;
+                               }
+                       }
+                       else {
+                               /* 'a' is a reference */
+                               if (TYPEINFO_IS_PRIMITIVE(b->typeinfo)) {
+                                       a->type = TYPE_VOID;
+                                       changed = true;
+                               }
+                               else {
+                                       /* two reference types are merged. There cannot be */
+                                       /* a merge error. In the worst case we get j.l.O.  */
+                                       r = typeinfo_merge(m,&(a->typeinfo),&(b->typeinfo));
+                                       if (r == typecheck_FAIL)
+                                               return r;
+                                       changed |= r;
+                               }
+                       }
+               }
+               a++;
+               b++;
+       }
+       return (typecheck_result) changed;
+}
+
+/**********************************************************************/
+/* READ-ONLY FUNCTIONS                                                */
+/* The following functions don't change typeinfo data.                */
+/**********************************************************************/
+
+/* typeinfo_is_array ***********************************************************
+   Check whether a typeinfo describes an array type.
+   
+   IN:
+          info.............the typeinfo, must be != NULL
+
+   RETURN VALUE:
+       true if INFO describes an array type.
+
+*******************************************************************************/
+
+bool
+typeinfo_is_array(typeinfo_t *info)
+{
+       TYPEINFO_ASSERT(info);
+    return TYPEINFO_IS_ARRAY(*info);
+}
+
+/* typeinfo_is_primitive_array *************************************************
+   Check whether a typeinfo describes a primitive array type.
+   
+   IN:
+          info.............the typeinfo, must be != NULL
+
+   RETURN VALUE:
+       true if INFO describes an array of a primitive type.
+
+*******************************************************************************/
+
+bool
+typeinfo_is_primitive_array(typeinfo_t *info,int arraytype)
+{
+       TYPEINFO_ASSERT(info);
+    return TYPEINFO_IS_PRIMITIVE_ARRAY(*info,arraytype);
+}
+
+/* typeinfo_is_array_of_refs ***************************************************
+   Check whether a typeinfo describes an array of references type.
+   
+   IN:
+          info.............the typeinfo, must be != NULL
+
+   RETURN VALUE:
+       true if INFO describes an array of a refrence type.
+
+*******************************************************************************/
+
+bool
+typeinfo_is_array_of_refs(typeinfo_t *info)
+{
+       TYPEINFO_ASSERT(info);
+    return TYPEINFO_IS_ARRAY_OF_REFS(*info);
+}
+
+/* interface_extends_interface *************************************************
+   Check if a resolved interface extends a given resolved interface.
+   
+   IN:
+          cls..............the interface, must be linked
+          interf...........the interface to check against
+
+   RETURN VALUE:
+       true.............CLS extends INTERF
+          false............CLS does not extend INTERF
+
+*******************************************************************************/
+
+static bool
+interface_extends_interface(classinfo *cls,classinfo *interf)
+{
+    int i;
+    
+       TYPEINFO_ASSERT(cls);
+       TYPEINFO_ASSERT(interf);
+       TYPEINFO_ASSERT((interf->flags & ACC_INTERFACE) != 0);
+       TYPEINFO_ASSERT((cls->flags & ACC_INTERFACE) != 0);
+       TYPEINFO_ASSERT(cls->state & CLASS_LINKED);
+
+    /* first check direct superinterfaces */
+    for (i=0; i<cls->interfacescount; ++i) {
+        if (cls->interfaces[i] == interf)
+            return true;
+    }
+    
+    /* check indirect superinterfaces */
+    for (i=0; i<cls->interfacescount; ++i) {
+        if (interface_extends_interface(cls->interfaces[i],interf))
+            return true;
+    }
+    
+    return false;
+}
+
+/* classinfo_implements_interface **********************************************
+   Check if a resolved class implements a given resolved interface.
+   
+   IN:
+          cls..............the class
+          interf...........the interface
+
+   RETURN VALUE:
+       typecheck_TRUE...CLS implements INTERF
+          typecheck_FALSE..CLS does not implement INTERF
+          typecheck_FAIL...an exception has been thrown
+
+*******************************************************************************/
+
+static typecheck_result
+classinfo_implements_interface(classinfo *cls,classinfo *interf)
+{
+       TYPEINFO_ASSERT(cls);
+       TYPEINFO_ASSERT(interf);
+       TYPEINFO_ASSERT((interf->flags & ACC_INTERFACE) != 0);
+
+       if (!(cls->state & CLASS_LINKED))
+               if (!link_class(cls))
+                       return typecheck_FAIL;
+
+    if (cls->flags & ACC_INTERFACE) {
+        /* cls is an interface */
+        if (cls == interf)
+            return typecheck_TRUE;
+
+        /* check superinterfaces */
+        return (typecheck_result) interface_extends_interface(cls,interf);
+    }
+
+       TYPEINFO_ASSERT(cls->state & CLASS_LINKED);
+    return (typecheck_result) CLASSINFO_IMPLEMENTS_INTERFACE(cls,interf->index);
+}
+
+/* mergedlist_implements_interface *********************************************
+   Check if all the classes in a given merged list implement a given resolved
+   interface.
+   
+   IN:
+          merged...........the list of merged class types
+          interf...........the interface to check against
+
+   RETURN VALUE:
+       typecheck_TRUE...all classes implement INTERF
+          typecheck_FALSE..there is at least one class that does not implement
+                           INTERF
+          typecheck_MAYBE..check cannot be performed now because of unresolved
+                           classes
+          typecheck_FAIL...an exception has been thrown
+
+*******************************************************************************/
+
+static typecheck_result
+mergedlist_implements_interface(typeinfo_mergedlist_t *merged,
+                                classinfo *interf)
+{
+    int i;
+    classref_or_classinfo *mlist;
+       typecheck_result r;
+    
+       TYPEINFO_ASSERT(interf);
+       TYPEINFO_ASSERT((interf->flags & ACC_INTERFACE) != 0);
+
+    /* Check if there is an non-empty mergedlist. */
+    if (!merged)
+        return typecheck_FALSE;
+
+    /* If all classinfos in the (non-empty) merged array implement the
+     * interface return true, otherwise false.
+     */
+    mlist = merged->list;
+    i = merged->count;
+    while (i--) {
+               if (IS_CLASSREF(*mlist)) {
+                       return typecheck_MAYBE;
+               }
+        r = classinfo_implements_interface((mlist++)->cls,interf);
+        if (r != typecheck_TRUE)
+                       return r;
+    }
+    return typecheck_TRUE;
+}
+
+/* merged_implements_interface *************************************************
+   Check if a possible merged type implements a given resolved interface
+   interface.
+   
+   IN:
+       typeclass........(common) class of the (merged) type
+          merged...........the list of merged class types
+          interf...........the interface to check against
+
+   RETURN VALUE:
+       typecheck_TRUE...the type implement INTERF
+          typecheck_FALSE..the type does not implement INTERF
+          typecheck_MAYBE..check cannot be performed now because of unresolved
+                           classes
+          typecheck_FAIL...an exception has been thrown
+
+*******************************************************************************/
+
+static typecheck_result
+merged_implements_interface(classinfo *typeclass,typeinfo_mergedlist_t *merged,
+                            classinfo *interf)
+{
+       typecheck_result r;
+       
+    /* primitive types don't support interfaces. */
+    if (!typeclass)
+        return typecheck_FALSE;
+
+    /* the null type can be cast to any interface type. */
+    if (typeclass == pseudo_class_Null)
+        return typecheck_TRUE;
+
+    /* check if typeclass implements the interface. */
+    r = classinfo_implements_interface(typeclass,interf);
+       if (r != typecheck_FALSE)
+        return r;
+
+    /* check the mergedlist */
+       if (!merged)
+               return typecheck_FALSE;
+    return mergedlist_implements_interface(merged,interf);
+}
+
+/* merged_is_subclass **********************************************************
+   Check if a possible merged type is a subclass of a given class.
+   A merged type is a subclass of a class C if all types in the merged list
+   are subclasses of C. A sufficient condition for this is that the
+   common type of the merged type is a subclass of C.
+
+   IN:
+       typeclass........(common) class of the (merged) type
+                           MUST be a loaded and linked class
+          merged...........the list of merged class types
+          cls..............the class to theck against
+
+   RETURN VALUE:
+       typecheck_TRUE...the type is a subclass of CLS
+          typecheck_FALSE..the type is not a subclass of CLS
+          typecheck_MAYBE..check cannot be performed now because of unresolved
+                           classes
+          typecheck_FAIL...an exception has been thrown
+
+*******************************************************************************/
+
+static typecheck_result
+merged_is_subclass(classinfo *typeclass,typeinfo_mergedlist_t *merged,
+               classinfo *cls)
+{
+    int i;
+    classref_or_classinfo *mlist;
+
+       TYPEINFO_ASSERT(cls);
+       
+    /* primitive types aren't subclasses of anything. */
+    if (!typeclass)
+        return typecheck_FALSE;
+
+    /* the null type can be cast to any reference type. */
+    if (typeclass == pseudo_class_Null)
+        return typecheck_TRUE;
+
+       TYPEINFO_ASSERT(typeclass->state & CLASS_LOADED);
+       TYPEINFO_ASSERT(typeclass->state & CLASS_LINKED);
+
+    /* check if the common typeclass is a subclass of CLS. */
+       if (class_issubclass(typeclass,cls))
+               return typecheck_TRUE;
+       
+    /* check the mergedlist */
+       if (!merged)
+               return typecheck_FALSE;
+    /* If all classinfos in the (non-empty) merged list are subclasses
+        * of CLS, return true, otherwise false.
+        * If there is at least one unresolved type in the list,
+        * return typecheck_MAYBE.
+     */
+    mlist = merged->list;
+    i = merged->count;
+    while (i--) {
+               if (IS_CLASSREF(*mlist)) {
+                       return typecheck_MAYBE;
+               }
+               if (!(mlist->cls->state & CLASS_LINKED))
+                       if (!link_class(mlist->cls))
+                               return typecheck_FAIL;
+               if (!class_issubclass(mlist->cls,cls))
+                       return typecheck_FALSE;
+               mlist++;
+    }
+    return typecheck_TRUE;
+}
+
+/* typeinfo_is_assignable_to_class *********************************************
+   Check if a type is assignable to a given class type.
+   
+   IN:
+       value............the type of the value
+          dest.............the type of the destination
+
+   RETURN VALUE:
+       typecheck_TRUE...the type is assignable
+          typecheck_FALSE..the type is not assignable
+          typecheck_MAYBE..check cannot be performed now because of unresolved
+                           classes
+          typecheck_FAIL...an exception has been thrown
+
+*******************************************************************************/
+
+typecheck_result
+typeinfo_is_assignable_to_class(typeinfo_t *value,classref_or_classinfo dest)
+{
+       classref_or_classinfo c;
+    classinfo *cls;
+       utf *classname;
+
+       TYPEINFO_ASSERT(value);
+
+    c = value->typeclass;
+
+    /* assignments of primitive values are not checked here. */
+    if (!c.any && !dest.any)
+        return typecheck_TRUE;
+
+    /* primitive and reference types are not assignment compatible. */
+    if (!c.any || !dest.any)
+        return typecheck_FALSE;
+
+    /* the null type can be assigned to any type */
+    if (TYPEINFO_IS_NULLTYPE(*value))
+        return typecheck_TRUE;
+
+    /* uninitialized objects are not assignable */
+    if (TYPEINFO_IS_NEWOBJECT(*value))
+        return typecheck_FALSE;
+
+       if (IS_CLASSREF(c)) {
+               /* The value type is an unresolved class reference. */
+               classname = c.ref->name;
+       }
+       else {
+               classname = c.cls->name;
+       }
+
+       if (IS_CLASSREF(dest)) {
+               /* the destination type is an unresolved class reference */
+               /* In this case we cannot tell a lot about assignability. */
+
+               /* the common case of value and dest type having the same classname */
+               if (dest.ref->name == classname && !value->merged)
+                       return typecheck_TRUE;
+
+               /* we cannot tell if value is assignable to dest, so we */
+               /* leave it up to the resolving code to check this      */
+               return typecheck_MAYBE;
+       }
+
+       /* { we know that dest is a loaded class } */
+
+       if (IS_CLASSREF(c)) {
+               /* the value type is an unresolved class reference */
+               
+               /* the common case of value and dest type having the same classname */
+               if (dest.cls->name == classname)
+                       return typecheck_TRUE;
+
+               /* we cannot tell if value is assignable to dest, so we */
+               /* leave it up to the resolving code to check this      */
+               return typecheck_MAYBE;
+       }
+
+       /* { we know that both c and dest are loaded classes } */
+       /* (c may still have a merged list containing unresolved classrefs!) */
+
+       TYPEINFO_ASSERT(!IS_CLASSREF(c));
+       TYPEINFO_ASSERT(!IS_CLASSREF(dest));
+
+       cls = c.cls;
+       
+       TYPEINFO_ASSERT(cls->state & CLASS_LOADED);
+       TYPEINFO_ASSERT(dest.cls->state & CLASS_LOADED);
+
+       /* maybe we need to link the classes */
+       if (!(cls->state & CLASS_LINKED))
+               if (!link_class(cls))
+                       return typecheck_FAIL;
+       if (!(dest.cls->state & CLASS_LINKED))
+               if (!link_class(dest.cls))
+                       return typecheck_FAIL;
+
+       /* { we know that both c and dest are linked classes } */
+       TYPEINFO_ASSERT(cls->state & CLASS_LINKED);
+       TYPEINFO_ASSERT(dest.cls->state & CLASS_LINKED);
+
+    if (dest.cls->flags & ACC_INTERFACE) {
+        /* We are assigning to an interface type. */
+        return merged_implements_interface(cls,value->merged,dest.cls);
+    }
+
+    if (CLASSINFO_IS_ARRAY(dest.cls)) {
+               arraydescriptor *arraydesc = dest.cls->vftbl->arraydesc;
+               int dimension = arraydesc->dimension;
+               classinfo *elementclass = (arraydesc->elementvftbl)
+                       ? arraydesc->elementvftbl->clazz : NULL;
+                       
+        /* We are assigning to an array type. */
+        if (!TYPEINFO_IS_ARRAY(*value))
+            return typecheck_FALSE;
+
+        /* {Both value and dest.cls are array types.} */
+
+        /* value must have at least the dimension of dest.cls. */
+        if (value->dimension < dimension)
+            return typecheck_FALSE;
+
+        if (value->dimension > dimension) {
+            /* value has higher dimension so we need to check
+             * if its component array can be assigned to the
+             * element type of dest.cls */
+
+                       if (!elementclass) return typecheck_FALSE;
+            
+            if (elementclass->flags & ACC_INTERFACE) {
+                /* We are assigning to an interface type. */
+                return classinfo_implements_interface(pseudo_class_Arraystub,
+                                                      elementclass);
+            }
+
+            /* We are assigning to a class type. */
+            return (typecheck_result) class_issubclass(pseudo_class_Arraystub,elementclass);
+        }
+
+        /* {value and dest.cls have the same dimension} */
+
+        if (value->elementtype != arraydesc->elementtype)
+            return typecheck_FALSE;
+
+        if (value->elementclass.any) {
+            /* We are assigning an array of objects so we have to
+             * check if the elements are assignable.
+             */
+
+            if (elementclass->flags & ACC_INTERFACE) {
+                /* We are assigning to an interface type. */
+
+                return merged_implements_interface(value->elementclass.cls,
+                                                   value->merged,
+                                                   elementclass);
+            }
+            
+            /* We are assigning to a class type. */
+            return merged_is_subclass(value->elementclass.cls,value->merged,elementclass);
+        }
+
+        return typecheck_TRUE;
+    }
+
+    /* {dest.cls is not an array} */
+    /* {dest.cls is a loaded class} */
+
+       /* If there are any unresolved references in the merged list, we cannot */
+       /* tell if the assignment will be ok.                                   */
+       /* This can only happen when cls is java.lang.Object                    */
+       if (cls == class_java_lang_Object && value->merged) {
+               classref_or_classinfo *mlist = value->merged->list;
+               int i = value->merged->count;
+               while (i--)
+                       if (IS_CLASSREF(*mlist++))
+                               return typecheck_MAYBE;
+       }
+        
+    /* We are assigning to a class type */
+    if (cls->flags & ACC_INTERFACE)
+        cls = class_java_lang_Object;
+    
+    return merged_is_subclass(cls,value->merged,dest.cls);
+}
+
+/* typeinfo_is_assignable ******************************************************
+   Check if a type is assignable to a given type.
+   
+   IN:
+       value............the type of the value
+          dest.............the type of the destination, must not be a merged type
+
+   RETURN VALUE:
+       typecheck_TRUE...the type is assignable
+          typecheck_FALSE..the type is not assignable
+          typecheck_MAYBE..check cannot be performed now because of unresolved
+                           classes
+          typecheck_FAIL...an exception has been thrown
+
+*******************************************************************************/
+
+typecheck_result
+typeinfo_is_assignable(typeinfo_t *value,typeinfo_t *dest)
+{
+       TYPEINFO_ASSERT(value);
+       TYPEINFO_ASSERT(dest);
+       TYPEINFO_ASSERT(dest->merged == NULL);
+
+       return typeinfo_is_assignable_to_class(value,dest->typeclass);
+}
+
+/**********************************************************************/
+/* INITIALIZATION FUNCTIONS                                           */
+/* The following functions fill in uninitialized typeinfo structures. */
+/**********************************************************************/
+
+/* typeinfo_init_classinfo *****************************************************
+   Initialize a typeinfo to a resolved class.
+   
+   IN:
+          c................the class
+
+   OUT:
+       *info............is initialized
+
+   RETURN VALUE:
+       true.............success
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+void
+typeinfo_init_classinfo(typeinfo_t *info, classinfo *c)
+{
+       if ((info->typeclass.cls = c)->vftbl->arraydesc) {
+               if (c->vftbl->arraydesc->elementvftbl)
+                       info->elementclass.cls = c->vftbl->arraydesc->elementvftbl->clazz;
+               else
+                       info->elementclass.any = NULL;
+               info->dimension = c->vftbl->arraydesc->dimension;
+               info->elementtype = c->vftbl->arraydesc->elementtype;
+       }
+       else {
+               info->elementclass.any = NULL;
+               info->dimension = 0;
+               info->elementtype = 0;
+       }
+       info->merged = NULL;
+}
+
+/* typeinfo_init_class *********************************************************
+   Initialize a typeinfo to a possibly unresolved class type.
+   
+   IN:
+          c................the class type
+
+   OUT:
+       *info............is initialized
+
+   RETURN VALUE:
+       true.............success
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+bool
+typeinfo_init_class(typeinfo_t *info,classref_or_classinfo c)
+{
+       char *utf_ptr;
+       int len;
+       classinfo *cls;
+               
+       TYPEINFO_ASSERT(c.any);
+       TYPEINFO_ASSERT(info);
+
+       /* if necessary, try to resolve lazily */
+       if (!resolve_classref_or_classinfo(NULL /* XXX should know method */,
+                               c,resolveLazy,false,true,&cls))
+       {
+               return false;
+       }
+       
+       if (cls) {
+               typeinfo_init_classinfo(info,cls);
+               return true;
+       }
+
+       /* {the type could no be resolved lazily} */
+
+       info->typeclass.ref = c.ref;
+       info->elementclass.any = NULL;
+       info->dimension = 0;
+       info->merged = NULL;
+
+       /* handle array type references */
+       utf_ptr = c.ref->name->text;
+       len = c.ref->name->blength;
+       if (*utf_ptr == '[') {
+               /* count dimensions */
+               while (*utf_ptr == '[') {
+                       utf_ptr++;
+                       info->dimension++;
+                       len--;
+               }
+               if (*utf_ptr == 'L') {
+                       utf_ptr++;
+                       len -= 2;
+                       info->elementtype = ARRAYTYPE_OBJECT;
+                       info->elementclass.ref = class_get_classref(c.ref->referer,utf_new(utf_ptr,len));
+               }
+               else {
+                       /* an array with primitive element type */
+                       /* should have been resolved above */
+                       TYPEINFO_ASSERT(false);
+               }
+       }
+       return true;
+}
+
+/* typeinfo_init_from_typedesc *************************************************
+   Initialize a typeinfo from a typedesc.
+   
+   IN:
+          desc.............the typedesc
+
+   OUT:
+       *type............set to the TYPE_* constant of DESC (if type != NULL)
+       *info............receives the typeinfo (if info != NULL)
+
+   RETURN VALUE:
+       true.............success
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+bool
+typeinfo_init_from_typedesc(typedesc *desc,u1 *type,typeinfo_t *info)
+{
+       TYPEINFO_ASSERT(desc);
+
+#ifdef TYPEINFO_VERBOSE
+       fprintf(stderr,"typeinfo_init_from_typedesc(");
+       descriptor_debug_print_typedesc(stderr,desc);
+       fprintf(stderr,")\n");
+#endif
+
+       if (type)
+               *type = desc->type;
+
+       if (info) {
+               if (desc->type == TYPE_ADR) {
+                       TYPEINFO_ASSERT(desc->classref);
+                       if (!typeinfo_init_class(info,CLASSREF_OR_CLASSINFO(desc->classref)))
+                               return false;
+               }
+               else {
+                       TYPEINFO_INIT_PRIMITIVE(*info);
+               }
+       }
+       return true;
+}
+
+/* typeinfos_init_from_methoddesc **********************************************
+   Initialize an array of typeinfos and u1 TYPE_* values from a methoddesc.
+   
+   IN:
+       desc.............the methoddesc
+       buflen...........number of parameters the buffer can hold
+       twoword..........if true, use two parameter slots for two-word types
+
+   OUT:
+       *typebuf.........receives a TYPE_* constant for each parameter
+                        typebuf must be != NULL
+       *infobuf.........receives a typeinfo for each parameter
+                        infobuf must be != NULL
+       *returntype......receives a TYPE_* constant for the return type
+                        returntype may be NULL
+       *returntypeinfo..receives a typeinfo for the return type
+                        returntypeinfo may be NULL
+
+   RETURN VALUE:
+       true.............success
+       false............an exception has been thrown
+
+   NOTE:
+       If (according to BUFLEN) the buffers are to small to hold the
+          parameter types, an internal error is thrown. This must be
+          avoided by checking the number of parameters and allocating enough
+          space before calling this function.
+
+*******************************************************************************/
+
+bool
+typeinfos_init_from_methoddesc(methoddesc *desc,u1 *typebuf,typeinfo_t *infobuf,
+                              int buflen,bool twoword,
+                              u1 *returntype,typeinfo_t *returntypeinfo)
+{
+       int i;
+    int args = 0;
+
+       TYPEINFO_ASSERT(desc);
+       TYPEINFO_ASSERT(typebuf);
+       TYPEINFO_ASSERT(infobuf);
+
+#ifdef TYPEINFO_VERBOSE
+       fprintf(stderr,"typeinfos_init_from_methoddesc(");
+       descriptor_debug_print_methoddesc(stderr,desc);
+       fprintf(stderr,")\n");
+#endif
+
+    /* check arguments */
+    for (i=0; i<desc->paramcount; ++i) {
+               if (++args > buflen) {
+                       exceptions_throw_internalerror("Buffer too small for method arguments.");
+                       return false;
+               }
+
+               if (!typeinfo_init_from_typedesc(desc->paramtypes + i,typebuf++,infobuf++))
+                       return false;
+               
+               if (twoword && (typebuf[-1] == TYPE_LNG || typebuf[-1] == TYPE_DBL)) {
+                       if (++args > buflen) {
+                               exceptions_throw_internalerror("Buffer too small for method arguments.");
+                               return false;
+                       }
+
+                       *typebuf++ = TYPE_VOID;
+                       TYPEINFO_INIT_PRIMITIVE(*infobuf);
+                       infobuf++;
+               }
+    }
+
+    /* check returntype */
+    if (returntype) {
+               if (!typeinfo_init_from_typedesc(&(desc->returntype),returntype,returntypeinfo))
+                       return false;
+       }
+
+       return true;
+}
+
+/* typedescriptor_init_from_typedesc *******************************************
+   Initialize a typedescriptor from a typedesc.
+   
+   IN:
+          desc.............the typedesc
+
+   OUT:
+       *td..............receives the typedescriptor
+                           td must be != NULL
+
+   RETURN VALUE:
+       true.............success
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+bool
+typedescriptor_init_from_typedesc(typedescriptor_t *td,
+                                                                 typedesc *desc)
+{
+       TYPEINFO_ASSERT(td);
+       TYPEINFO_ASSERT(desc);
+
+       td->type = desc->type;
+       if (td->type == TYPE_ADR) {
+               if (!typeinfo_init_class(&(td->typeinfo),CLASSREF_OR_CLASSINFO(desc->classref)))
+                       return false;
+       }
+       else {
+               TYPEINFO_INIT_PRIMITIVE(td->typeinfo);
+       }
+       return true;
+}
+
+/* typeinfo_init_varinfo_from_typedesc *****************************************
+   Initialize a varinfo from a typedesc.
+   
+   IN:
+          desc.............the typedesc
+
+   OUT:
+       *var.............receives the type
+                           var must be != NULL
+
+   RETURN VALUE:
+       true.............success
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+bool
+typeinfo_init_varinfo_from_typedesc(varinfo *var,
+                                                                 typedesc *desc)
+{
+       TYPEINFO_ASSERT(var);
+       TYPEINFO_ASSERT(desc);
+
+       var->type = desc->type;
+       if (var->type == TYPE_ADR) {
+               if (!typeinfo_init_class(&(var->typeinfo),CLASSREF_OR_CLASSINFO(desc->classref)))
+                       return false;
+       }
+       else {
+               TYPEINFO_INIT_PRIMITIVE(var->typeinfo);
+       }
+       return true;
+}
+
+/* typeinfo_init_varinfos_from_methoddesc **************************************
+   Initialize an array of varinfos from a methoddesc.
+   
+   IN:
+       desc.............the methoddesc
+       buflen...........number of parameters the buffer can hold
+          startindex.......the zero-based index of the first parameter to
+                           write to the array. In other words the number of
+                                               parameters to skip at the beginning of the methoddesc.
+          map..............map from parameter indices to varinfo indices
+                           (indexed like jitdata.local_map)
+
+   OUT:
+       *vars............array receiving the varinfos
+                           td[0] receives the type of the
+                                               (startindex+1)th parameter of the method
+       *returntype......receives the typedescriptor of the return type.
+                           returntype may be NULL
+
+   RETURN VALUE:
+       true.............everything ok
+          false............an exception has been thrown
+
+   NOTE:
+       If (according to BUFLEN) the buffer is to small to hold the
+          parameter types, an internal error is thrown. This must be
+          avoided by checking the number of parameters and allocating enough
+          space before calling this function.
+
+*******************************************************************************/
+
+bool
+typeinfo_init_varinfos_from_methoddesc(varinfo *vars,
+                                                                        methoddesc *desc,
+                                                                        int buflen, int startindex,
+                                                                        s4 *map,
+                                                                        typedescriptor_t *returntype)
+{
+       s4 i;
+    s4 varindex;
+       s4 type;
+       s4 slot = 0;
+
+       /* skip arguments */
+       for (i=0; i<startindex; ++i) {
+               slot++;
+               if (IS_2_WORD_TYPE(desc->paramtypes[i].type))
+                       slot++;
+       }
+
+    /* check arguments */
+    for (i=startindex; i<desc->paramcount; ++i) {
+               type = desc->paramtypes[i].type;
+               varindex = map[5*slot + type];
+
+               slot++;
+               if (IS_2_WORD_TYPE(type))
+                       slot++;
+
+               if (varindex == UNUSED)
+                       continue;
+
+               if (varindex >= buflen) {
+                       exceptions_throw_internalerror("Buffer too small for method arguments.");
+                       return false;
+               }
+
+               if (!typeinfo_init_varinfo_from_typedesc(vars + varindex, desc->paramtypes + i))
+                       return false;
+    }
+
+    /* check returntype */
+    if (returntype) {
+               if (!typedescriptor_init_from_typedesc(returntype,&(desc->returntype)))
+                       return false;
+       }
+
+       return true;
+}
+
+/* typedescriptors_init_from_methoddesc ****************************************
+   Initialize an array of typedescriptors from a methoddesc.
+   
+   IN:
+       desc.............the methoddesc
+       buflen...........number of parameters the buffer can hold
+       twoword..........if true, use two parameter slots for two-word types
+          startindex.......the zero-based index of the first parameter to
+                           write to the array. In other words the number of
+                                               parameters to skip at the beginning of the methoddesc.
+
+   OUT:
+       *td..............array receiving the typedescriptors.
+                           td[0] receives the typedescriptor of the
+                                               (startindex+1)th parameter of the method
+       *returntype......receives the typedescriptor of the return type.
+                           returntype may be NULL
+
+   RETURN VALUE:
+       >= 0.............number of typedescriptors filled in TD
+          -1...............an exception has been thrown
+
+   NOTE:
+       If (according to BUFLEN) the buffer is to small to hold the
+          parameter types, an internal error is thrown. This must be
+          avoided by checking the number of parameters and allocating enough
+          space before calling this function.
+
+*******************************************************************************/
+
+int
+typedescriptors_init_from_methoddesc(typedescriptor_t *td,
+                                                                        methoddesc *desc,
+                                                                        int buflen,bool twoword,int startindex,
+                                                                        typedescriptor_t *returntype)
+{
+       int i;
+    int args = 0;
+
+    /* check arguments */
+    for (i=startindex; i<desc->paramcount; ++i) {
+               if (++args > buflen) {
+                       exceptions_throw_internalerror("Buffer too small for method arguments.");
+                       return -1;
+               }
+
+               if (!typedescriptor_init_from_typedesc(td,desc->paramtypes + i))
+                       return -1;
+               td++;
+
+               if (twoword && (td[-1].type == TYPE_LNG || td[-1].type == TYPE_DBL)) {
+                       if (++args > buflen) {
+                               exceptions_throw_internalerror("Buffer too small for method arguments.");
+                               return -1;
+                       }
+
+                       td->type = TYPE_VOID;
+                       TYPEINFO_INIT_PRIMITIVE(td->typeinfo);
+                       td++;
+               }
+    }
+
+    /* check returntype */
+    if (returntype) {
+               if (!typedescriptor_init_from_typedesc(returntype,&(desc->returntype)))
+                       return -1;
+       }
+
+       return args;
+}
+
+/* typeinfo_init_component *****************************************************
+   Initialize a typeinfo with the component type of a given array type.
+   
+   IN:
+          srcarray.........the typeinfo of the array type
+
+   OUT:
+       *dst.............receives the typeinfo of the component type
+
+   RETURN VALUE:
+       true.............success
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+bool
+typeinfo_init_component(typeinfo_t *srcarray,typeinfo_t *dst)
+{
+       typeinfo_mergedlist_t *merged;
+
+       TYPEINFO_ASSERT(srcarray);
+       TYPEINFO_ASSERT(dst);
+
+    if (TYPEINFO_IS_NULLTYPE(*srcarray)) {
+        TYPEINFO_INIT_NULLTYPE(*dst);
+        return true;
+    }
+    
+    if (!TYPEINFO_IS_ARRAY(*srcarray)) {
+               /* XXX should we make that a verify error? */
+               exceptions_throw_internalerror("Trying to access component of non-array");
+               return false;
+       }
+
+       /* save the mergedlist (maybe dst == srcarray) */
+
+       merged = srcarray->merged;
+
+       if (IS_CLASSREF(srcarray->typeclass)) {
+               constant_classref *comp;
+               comp = class_get_classref_component_of(srcarray->typeclass.ref);
+
+               if (comp) {
+                       if (!typeinfo_init_class(dst,CLASSREF_OR_CLASSINFO(comp)))
+                               return false;
+               }
+               else {
+                       TYPEINFO_INIT_PRIMITIVE(*dst);
+               }
+       }
+       else {
+               vftbl_t *comp;
+               
+               if (!(srcarray->typeclass.cls->state & CLASS_LINKED)) {
+                       if (!link_class(srcarray->typeclass.cls)) {
+                               return false;
+                       }
+               }
+
+               TYPEINFO_ASSERT(srcarray->typeclass.cls->vftbl);
+               TYPEINFO_ASSERT(srcarray->typeclass.cls->vftbl->arraydesc);
+
+               comp = srcarray->typeclass.cls->vftbl->arraydesc->componentvftbl;
+               if (comp)
+                       typeinfo_init_classinfo(dst,comp->clazz);
+               else
+                       TYPEINFO_INIT_PRIMITIVE(*dst);
+       }
+    
+    dst->merged = merged; /* XXX should we do a deep copy? */
+       return true;
+}
+
+/* typeinfo_clone **************************************************************
+   Create a deep copy of a typeinfo struct.
+   
+   IN:
+          src..............the typeinfo to copy
+
+   OUT:
+       *dest............receives the copy
+
+   NOTE:
+       If src == dest this function is a nop.
+
+*******************************************************************************/
+
+void
+typeinfo_clone(typeinfo_t *src,typeinfo_t *dest)
+{
+    int count;
+    classref_or_classinfo *srclist,*destlist;
+
+    if (src == dest)
+        return;
+    
+    *dest = *src;
+
+    if (src->merged) {
+        count = src->merged->count;
+        TYPEINFO_ALLOCMERGED(dest->merged,count);
+        dest->merged->count = count;
+
+        srclist = src->merged->list;
+        destlist = dest->merged->list;
+        while (count--)
+            *destlist++ = *srclist++;
+    }
+}
+
+/**********************************************************************/
+/* MISCELLANEOUS FUNCTIONS                                            */
+/**********************************************************************/
+
+/* typeinfo_free ***************************************************************
+   Free memory referenced by the given typeinfo. The typeinfo itself is not
+   freed.
+   
+   IN:
+       info.............the typeinfo
+
+*******************************************************************************/
+
+void
+typeinfo_free(typeinfo_t *info)
+{
+    TYPEINFO_FREEMERGED_IF_ANY(info->merged);
+    info->merged = NULL;
+}
+
+/**********************************************************************/
+/* MERGING FUNCTIONS                                                  */
+/* The following functions are used to merge the types represented by */
+/* two typeinfo structures into one typeinfo structure.               */
+/**********************************************************************/
+
+static
+void
+typeinfo_merge_error(methodinfo *m,char *str,typeinfo_t *x,typeinfo_t *y) {
+#ifdef TYPEINFO_VERBOSE
+    fprintf(stderr,"Error in typeinfo_merge: %s\n",str);
+    fprintf(stderr,"Typeinfo x:\n");
+    typeinfo_print(stderr,x,1);
+    fprintf(stderr,"Typeinfo y:\n");
+    typeinfo_print(stderr,y,1);
+    log_text(str);
+#endif
+
+       exceptions_throw_verifyerror(m, str);
+}
+
+/* Condition: clsx != clsy. */
+/* Returns: true if dest was changed (currently always true). */
+static
+bool
+typeinfo_merge_two(typeinfo_t *dest,classref_or_classinfo clsx,classref_or_classinfo clsy)
+{
+       TYPEINFO_ASSERT(dest);
+    TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
+    TYPEINFO_ALLOCMERGED(dest->merged,2);
+    dest->merged->count = 2;
+
+       TYPEINFO_ASSERT(clsx.any != clsy.any);
+
+    if (clsx.any < clsy.any) {
+        dest->merged->list[0] = clsx;
+        dest->merged->list[1] = clsy;
+    }
+    else {
+        dest->merged->list[0] = clsy;
+        dest->merged->list[1] = clsx;
+    }
+
+    return true;
+}
+
+/* Returns: true if dest was changed. */
+static
+bool
+typeinfo_merge_add(typeinfo_t *dest,typeinfo_mergedlist_t *m,classref_or_classinfo cls)
+{
+    int count;
+    typeinfo_mergedlist_t *newmerged;
+    classref_or_classinfo *mlist,*newlist;
+
+    count = m->count;
+    mlist = m->list;
+
+    /* Check if cls is already in the mergedlist m. */
+    while (count--) {
+        if ((mlist++)->any == cls.any) { /* XXX check equal classrefs? */
+            /* cls is in the list, so m is the resulting mergedlist */
+            if (dest->merged == m)
+                return false;
+
+            /* We have to copy the mergedlist */
+            TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
+            count = m->count;
+            TYPEINFO_ALLOCMERGED(dest->merged,count);
+            dest->merged->count = count;
+            newlist = dest->merged->list;
+            mlist = m->list;
+            while (count--) {
+                *newlist++ = *mlist++;
+            }
+            return true;
+        }
+    }
+
+    /* Add cls to the mergedlist. */
+    count = m->count;
+    TYPEINFO_ALLOCMERGED(newmerged,count+1);
+    newmerged->count = count+1;
+    newlist = newmerged->list;    
+    mlist = m->list;
+    while (count) {
+        if (mlist->any > cls.any)
+            break;
+        *newlist++ = *mlist++;
+        count--;
+    }
+    *newlist++ = cls;
+    while (count--) {
+        *newlist++ = *mlist++;
+    }
+
+    /* Put the new mergedlist into dest. */
+    TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
+    dest->merged = newmerged;
+    
+    return true;
+}
+
+/* Returns: true if dest was changed. */
+static
+bool
+typeinfo_merge_mergedlists(typeinfo_t *dest,typeinfo_mergedlist_t *x,
+                           typeinfo_mergedlist_t *y)
+{
+    int count = 0;
+    int countx,county;
+    typeinfo_mergedlist_t *temp,*result;
+    classref_or_classinfo *clsx,*clsy,*newlist;
+
+    /* count the elements that will be in the resulting list */
+    /* (Both lists are sorted, equal elements are counted only once.) */
+    clsx = x->list;
+    clsy = y->list;
+    countx = x->count;
+    county = y->count;
+    while (countx && county) {
+        if (clsx->any == clsy->any) {
+            clsx++;
+            clsy++;
+            countx--;
+            county--;
+        }
+        else if (clsx->any < clsy->any) {
+            clsx++;
+            countx--;
+        }
+        else {
+            clsy++;
+            county--;
+        }
+        count++;
+    }
+    count += countx + county;
+
+    /* {The new mergedlist will have count entries.} */
+
+    if ((x->count != count) && (y->count == count)) {
+        temp = x; x = y; y = temp;
+    }
+    /* {If one of x,y is already the result it is x.} */
+    if (x->count == count) {
+        /* x->merged is equal to the result */
+        if (x == dest->merged)
+            return false;
+
+        if (!dest->merged || dest->merged->count != count) {
+            TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
+            TYPEINFO_ALLOCMERGED(dest->merged,count);
+            dest->merged->count = count;
+        }
+
+        newlist = dest->merged->list;
+        clsx = x->list;
+        while (count--) {
+            *newlist++ = *clsx++;
+        }
+        return true;
+    }
+
+    /* {We have to merge two lists.} */
+
+    /* allocate the result list */
+    TYPEINFO_ALLOCMERGED(result,count);
+    result->count = count;
+    newlist = result->list;
+
+    /* merge the sorted lists */
+    clsx = x->list;
+    clsy = y->list;
+    countx = x->count;
+    county = y->count;
+    while (countx && county) {
+        if (clsx->any == clsy->any) {
+            *newlist++ = *clsx++;
+            clsy++;
+            countx--;
+            county--;
+        }
+        else if (clsx->any < clsy->any) {
+            *newlist++ = *clsx++;
+            countx--;
+        }
+        else {
+            *newlist++ = *clsy++;
+            county--;
+        }
+    }
+    while (countx--)
+            *newlist++ = *clsx++;
+    while (county--)
+            *newlist++ = *clsy++;
+
+    /* replace the list in dest with the result list */
+    TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
+    dest->merged = result;
+
+    return true;
+}
+
+/* typeinfo_merge_nonarrays ****************************************************
+   Merge two non-array types.
+   
+   IN:
+       x................the first type
+          y................the second type
+          mergedx..........merged list of the first type, may be NULL
+          mergedy..........merged list of the descond type, may be NULL
+
+   OUT:
+       *dest............receives the resulting merged list
+          *result..........receives the resulting type
+
+   RETURN VALUE:
+       typecheck_TRUE...*dest has been modified
+          typecheck_FALSE..*dest has not been modified
+          typecheck_FAIL...an exception has been thrown
+
+   NOTE:
+       RESULT is an extra parameter so it can point to dest->typeclass or to
+          dest->elementclass.
+
+*******************************************************************************/
+
+static typecheck_result
+typeinfo_merge_nonarrays(typeinfo_t *dest,
+                         classref_or_classinfo *result,
+                         classref_or_classinfo x,classref_or_classinfo y,
+                         typeinfo_mergedlist_t *mergedx,
+                         typeinfo_mergedlist_t *mergedy)
+{
+       classref_or_classinfo t;
+    classinfo *tcls,*common;
+    typeinfo_mergedlist_t *tmerged;
+    bool changed;
+       typecheck_result r;
+       utf *xname;
+       utf *yname;
+
+       TYPEINFO_ASSERT(dest && result && x.any && y.any);
+       TYPEINFO_ASSERT(x.cls != pseudo_class_Null);
+       TYPEINFO_ASSERT(y.cls != pseudo_class_Null);
+       TYPEINFO_ASSERT(x.cls != pseudo_class_New);
+       TYPEINFO_ASSERT(y.cls != pseudo_class_New);
+
+       /*--------------------------------------------------*/
+       /* common cases                                     */
+       /*--------------------------------------------------*/
+
+    /* Common case 1: x and y are the same class or class reference */
+    /* (This case is very simple unless *both* x and y really represent
+     *  merges of subclasses of clsx==clsy.)
+     */
+    if ( (x.any == y.any) && (!mergedx || !mergedy) ) {
+  return_simple_x:
+        /* DEBUG */ /* log_text("return simple x"); */
+        changed = (dest->merged != NULL);
+        TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
+        dest->merged = NULL;
+        *result = x;
+        /* DEBUG */ /* log_text("returning"); */
+        return (typecheck_result) changed;
+    }
+
+       xname = (IS_CLASSREF(x)) ? x.ref->name : x.cls->name;
+       yname = (IS_CLASSREF(y)) ? y.ref->name : y.cls->name;
+
+       /* Common case 2: xname == yname, at least one unresolved */
+    if ((IS_CLASSREF(x) || IS_CLASSREF(y)) && (xname == yname))
+       {
+               /* use the loaded one if any */
+               if (!IS_CLASSREF(y))
+                       x = y;
+               goto return_simple_x;
+    }
+
+       /*--------------------------------------------------*/
+       /* non-trivial cases                                */
+       /*--------------------------------------------------*/
+
+#ifdef TYPEINFO_VERBOSE
+       {
+               typeinfo_t dbgx,dbgy;
+               fprintf(stderr,"merge_nonarrays:\n");
+               fprintf(stderr,"    ");if(IS_CLASSREF(x))fprintf(stderr,"<ref>");utf_fprint_printable_ascii(stderr,xname);fprintf(stderr,"\n");
+               fprintf(stderr,"    ");if(IS_CLASSREF(y))fprintf(stderr,"<ref>");utf_fprint_printable_ascii(stderr,yname);fprintf(stderr,"\n");
+               fflush(stderr);
+               typeinfo_init_class(&dbgx,x);
+               dbgx.merged = mergedx;
+               typeinfo_init_class(&dbgy,y);
+               dbgy.merged = mergedy;
+               typeinfo_print(stderr,&dbgx,4);
+               fprintf(stderr,"  with:\n");
+               typeinfo_print(stderr,&dbgy,4);
+       }
+#endif
+
+       TYPEINFO_ASSERT(IS_CLASSREF(x) || (x.cls->state & CLASS_LOADED));
+       TYPEINFO_ASSERT(IS_CLASSREF(y) || (y.cls->state & CLASS_LOADED));
+
+    /* If y is unresolved or an interface, swap x and y. */
+    if (IS_CLASSREF(y) || (!IS_CLASSREF(x) && y.cls->flags & ACC_INTERFACE))
+       {
+        t = x; x = y; y = t;
+        tmerged = mergedx; mergedx = mergedy; mergedy = tmerged;
+    }
+       
+    /* {We know: If only one of x,y is unresolved it is x,} */
+    /* {         If both x,y are resolved and only one of x,y is an interface it is x.} */
+
+       if (IS_CLASSREF(x)) {
+               /* {We know: x and y have different class names} */
+               
+        /* Check if we are merging an unresolved type with java.lang.Object */
+        if (y.cls == class_java_lang_Object && !mergedy) {
+            x = y;
+            goto return_simple_x;
+        }
+            
+               common = class_java_lang_Object;
+               goto merge_with_simple_x;
+       }
+
+       /* {We know: both x and y are resolved} */
+    /* {We know: If only one of x,y is an interface it is x.} */
+
+       TYPEINFO_ASSERT(!IS_CLASSREF(x) && !IS_CLASSREF(y));
+       TYPEINFO_ASSERT(x.cls->state & CLASS_LOADED);
+       TYPEINFO_ASSERT(y.cls->state & CLASS_LOADED);
+
+    /* Handle merging of interfaces: */
+    if (x.cls->flags & ACC_INTERFACE) {
+        /* {x.cls is an interface and mergedx == NULL.} */
+        
+        if (y.cls->flags & ACC_INTERFACE) {
+            /* We are merging two interfaces. */
+            /* {mergedy == NULL} */
+
+            /* {We know that x.cls!=y.cls (see common case at beginning.)} */
+            result->cls = class_java_lang_Object;
+            return (typecheck_result) typeinfo_merge_two(dest,x,y);
+        }
+
+        /* {We know: x is an interface, y is a class.} */
+
+        /* Check if we are merging an interface with java.lang.Object */
+        if (y.cls == class_java_lang_Object && !mergedy) {
+            x = y;
+            goto return_simple_x;
+        }
+
+        /* If the type y implements x then the result of the merge
+         * is x regardless of mergedy.
+         */
+
+               /* we may have to link the classes */
+               if (!(x.cls->state & CLASS_LINKED))
+                       if (!link_class(x.cls))
+                               return typecheck_FAIL;
+               if (!(y.cls->state & CLASS_LINKED))
+                       if (!link_class(y.cls))
+                               return typecheck_FAIL;
+        
+               TYPEINFO_ASSERT(x.cls->state & CLASS_LINKED);
+               TYPEINFO_ASSERT(y.cls->state & CLASS_LINKED);
+
+        if (CLASSINFO_IMPLEMENTS_INTERFACE(y.cls,x.cls->index))
+               {
+            /* y implements x, so the result of the merge is x. */
+            goto return_simple_x;
+               }
+               
+        r = mergedlist_implements_interface(mergedy,x.cls);
+               if (r == typecheck_FAIL)
+                       return r;
+               if (r == typecheck_TRUE)
+        {
+            /* y implements x, so the result of the merge is x. */
+            goto return_simple_x;
+        }
+        
+        /* {We know: x is an interface, the type y a class or a merge
+         * of subclasses and is not guaranteed to implement x.} */
+
+        common = class_java_lang_Object;
+        goto merge_with_simple_x;
+    }
+
+    /* {We know: x and y are classes (not interfaces).} */
+    
+       /* we may have to link the classes */
+       if (!(x.cls->state & CLASS_LINKED))
+               if (!link_class(x.cls))
+                       return typecheck_FAIL;
+       if (!(y.cls->state & CLASS_LINKED))
+               if (!link_class(y.cls))
+                       return typecheck_FAIL;
+        
+       TYPEINFO_ASSERT(x.cls->state & CLASS_LINKED);
+       TYPEINFO_ASSERT(y.cls->state & CLASS_LINKED);
+
+    /* If *x is deeper in the inheritance hierarchy swap x and y. */
+    if (x.cls->index > y.cls->index) {
+        t = x; x = y; y = t;
+        tmerged = mergedx; mergedx = mergedy; mergedy = tmerged;
+    }
+
+    /* {We know: y is at least as deep in the hierarchy as x.} */
+
+    /* Find nearest common anchestor for the classes. */
+
+    common = x.cls;
+    tcls   = y.cls;
+
+    while (tcls->index > common->index)
+        tcls = tcls->super;
+
+    while (common != tcls) {
+        common = common->super;
+        tcls = tcls->super;
+    }
+
+    /* {common == nearest common anchestor of x and y.} */
+
+    /* If x.cls==common and x is a whole class (not a merge of subclasses)
+     * then the result of the merge is x.
+     */
+    if (x.cls == common && !mergedx) {
+        goto return_simple_x;
+    }
+   
+    if (mergedx) {
+        result->cls = common;
+        if (mergedy)
+            return (typecheck_result) typeinfo_merge_mergedlists(dest,mergedx,mergedy);
+        else
+            return (typecheck_result) typeinfo_merge_add(dest,mergedx,y);
+    }
+
+merge_with_simple_x:
+    result->cls = common;
+    if (mergedy)
+        return (typecheck_result) typeinfo_merge_add(dest,mergedy,x);
+    else
+        return (typecheck_result) typeinfo_merge_two(dest,x,y);
+}
+
+/* typeinfo_merge **************************************************************
+   Merge two types.
+   
+   IN:
+       m................method for exception messages
+       dest.............the first type
+       y................the second type
+
+   OUT:
+       *dest............receives the result of the merge
+
+   RETURN VALUE:
+       typecheck_TRUE...*dest has been modified
+       typecheck_FALSE..*dest has not been modified
+       typecheck_FAIL...an exception has been thrown
+
+   PRE-CONDITIONS:
+       1) *dest must be a valid initialized typeinfo
+       2) dest != y
+
+*******************************************************************************/
+
+typecheck_result
+typeinfo_merge(methodinfo *m,typeinfo_t *dest,typeinfo_t* y)
+{
+    typeinfo_t *x;
+    typeinfo_t *tmp;
+    classref_or_classinfo common;
+    classref_or_classinfo elementclass;
+    int dimension;
+    int elementtype;
+    bool changed;
+       typecheck_result r;
+
+       /*--------------------------------------------------*/
+       /* fast checks                                      */
+       /*--------------------------------------------------*/
+
+    /* Merging something with itself is a nop */
+    if (dest == y)
+        return typecheck_FALSE;
+
+    /* Merging two returnAddress types is ok. */
+       /* Merging two different returnAddresses never happens, as the verifier */
+       /* keeps them separate in order to check all the possible return paths  */
+       /* from JSR subroutines.                                                */
+    if (!dest->typeclass.any && !y->typeclass.any) {
+               TYPEINFO_ASSERT(TYPEINFO_RETURNADDRESS(*dest) ==  TYPEINFO_RETURNADDRESS(*y));
+        return typecheck_FALSE;
+       }
+    
+    /* Primitive types cannot be merged with reference types */
+       /* This must be checked before calls to typeinfo_merge.  */
+    TYPEINFO_ASSERT(dest->typeclass.any && y->typeclass.any);
+
+    /* handle uninitialized object types */
+    if (TYPEINFO_IS_NEWOBJECT(*dest) || TYPEINFO_IS_NEWOBJECT(*y)) {
+        if (!TYPEINFO_IS_NEWOBJECT(*dest) || !TYPEINFO_IS_NEWOBJECT(*y)) {
+            typeinfo_merge_error(m,(char*) "Trying to merge uninitialized object type.",dest,y);
+                       return typecheck_FAIL;
+               }
+        if (TYPEINFO_NEWOBJECT_INSTRUCTION(*dest) != TYPEINFO_NEWOBJECT_INSTRUCTION(*y)) {
+            typeinfo_merge_error(m,(char*) "Trying to merge different uninitialized objects.",dest,y);
+                       return typecheck_FAIL;
+               }
+               /* the same uninitialized object -- no change */
+               return typecheck_FALSE;
+    }
+    
+       /*--------------------------------------------------*/
+       /* common cases                                     */
+       /*--------------------------------------------------*/
+
+    /* Common case: dest and y are the same class or class reference */
+    /* (This case is very simple unless *both* dest and y really represent
+     *  merges of subclasses of class dest==class y.)
+     */
+    if ((dest->typeclass.any == y->typeclass.any) && (!dest->merged || !y->merged)) {
+return_simple:
+        changed = (dest->merged != NULL);
+        TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
+        dest->merged = NULL;
+        return (typecheck_result) changed;
+    }
+    
+    /* Handle null types: */
+    if (TYPEINFO_IS_NULLTYPE(*y)) {
+        return typecheck_FALSE;
+    }
+    if (TYPEINFO_IS_NULLTYPE(*dest)) {
+        TYPEINFO_FREEMERGED_IF_ANY(dest->merged);
+        TYPEINFO_CLONE(*y,*dest);
+        return typecheck_TRUE;
+    }
+
+       /* Common case: two types with the same name, at least one unresolved */
+       if (IS_CLASSREF(dest->typeclass)) {
+               if (IS_CLASSREF(y->typeclass)) {
+                       if (dest->typeclass.ref->name == y->typeclass.ref->name)
+                               goto return_simple;
+               }
+               else {
+                       /* XXX should we take y instead of dest here? */
+                       if (dest->typeclass.ref->name == y->typeclass.cls->name)
+                               goto return_simple;
+               }
+       }
+       else {
+               if (IS_CLASSREF(y->typeclass) 
+                   && (dest->typeclass.cls->name == y->typeclass.ref->name))
+               {
+                       goto return_simple;
+               }
+       }
+
+       /*--------------------------------------------------*/
+       /* non-trivial cases                                */
+       /*--------------------------------------------------*/
+
+#ifdef TYPEINFO_VERBOSE
+       fprintf(stderr,"merge:\n");
+    typeinfo_print(stderr,dest,4);
+    typeinfo_print(stderr,y,4);
+#endif
+
+    /* This function uses x internally, so x and y can be swapped
+     * without changing dest. */
+    x = dest;
+    changed = false;
+    
+    /* Handle merging of arrays: */
+    if (TYPEINFO_IS_ARRAY(*x) && TYPEINFO_IS_ARRAY(*y)) {
+        
+        /* Make x the one with lesser dimension */
+        if (x->dimension > y->dimension) {
+            tmp = x; x = y; y = tmp;
+        }
+
+        /* If one array (y) has higher dimension than the other,
+         * interpret it as an array (same dim. as x) of Arraystubs. */
+        if (x->dimension < y->dimension) {
+            dimension = x->dimension;
+            elementtype = ARRAYTYPE_OBJECT;
+            elementclass.cls = pseudo_class_Arraystub;
+        }
+        else {
+            dimension = y->dimension;
+            elementtype = y->elementtype;
+            elementclass = y->elementclass;
+        }
+        
+        /* {The arrays are of the same dimension.} */
+        
+        if (x->elementtype != elementtype) {
+            /* Different element types are merged, so the resulting array
+             * type has one accessible dimension less. */
+            if (--dimension == 0) {
+                common.cls = pseudo_class_Arraystub;
+                elementtype = 0;
+                elementclass.any = NULL;
+            }
+            else {
+                common.cls = class_multiarray_of(dimension,pseudo_class_Arraystub,true);
+                               if (!common.cls) {
+                                       exceptions_throw_internalerror("XXX Coult not create array class");
+                                       return typecheck_FAIL;
+                               }
+
+                elementtype = ARRAYTYPE_OBJECT;
+                elementclass.cls = pseudo_class_Arraystub;
+            }
+        }
+        else {
+            /* {The arrays have the same dimension and elementtype.} */
+
+            if (elementtype == ARRAYTYPE_OBJECT) {
+                /* The elements are references, so their respective
+                 * types must be merged.
+                 */
+                               r = typeinfo_merge_nonarrays(dest,
+                                               &elementclass,
+                                               x->elementclass,
+                                               elementclass,
+                                               x->merged,y->merged);
+                               TYPEINFO_ASSERT(r != typecheck_MAYBE);
+                               if (r == typecheck_FAIL)
+                                       return r;
+                               changed |= r;
+
+                /* DEBUG */ /* log_text("finding resulting array class: "); */
+                               if (IS_CLASSREF(elementclass))
+                                       common.ref = class_get_classref_multiarray_of(dimension,elementclass.ref);
+                               else {
+                                       common.cls = class_multiarray_of(dimension,elementclass.cls,true);
+                                       if (!common.cls) {
+                                               exceptions_throw_internalerror("XXX Coult not create array class");
+                                               return typecheck_FAIL;
+                                       }
+                               }
+                /* DEBUG */ /* utf_display_printable_ascii(common->name); printf("\n"); */
+            }
+                       else {
+                               common.any = y->typeclass.any;
+                       }
+        }
+    }
+    else {
+        /* {We know that at least one of x or y is no array, so the
+         *  result cannot be an array.} */
+        
+               r = typeinfo_merge_nonarrays(dest,
+                               &common,
+                               x->typeclass,y->typeclass,
+                               x->merged,y->merged);
+               TYPEINFO_ASSERT(r != typecheck_MAYBE);
+               if (r == typecheck_FAIL)
+                       return r;
+               changed |= r;
+
+        dimension = 0;
+        elementtype = 0;
+        elementclass.any = NULL;
+    }
+
+    /* Put the new values into dest if neccessary. */
+
+    if (dest->typeclass.any != common.any) {
+        dest->typeclass.any = common.any;
+        changed = true;
+    }
+    if (dest->dimension != dimension) {
+        dest->dimension = dimension;
+        changed = true;
+    }
+    if (dest->elementtype != elementtype) {
+        dest->elementtype = elementtype;
+        changed = true;
+    }
+    if (dest->elementclass.any != elementclass.any) {
+        dest->elementclass.any = elementclass.any;
+        changed = true;
+    }
+
+    return (typecheck_result) changed;
+}
+#endif /* ENABLE_VERIFER */
+
+
+/**********************************************************************/
+/* DEBUGGING HELPERS                                                  */
+/**********************************************************************/
+
+#ifdef TYPEINFO_DEBUG
+
+#if 0
+static int
+typeinfo_test_compare(classref_or_classinfo *a,classref_or_classinfo *b)
+{
+    if (a->any == b->any) return 0;
+    if (a->any < b->any) return -1;
+    return +1;
+}
+
+static void
+typeinfo_test_parse(typeinfo_t *info,char *str)
+{
+    int num;
+    int i;
+    typeinfo_t *infobuf;
+    u1 *typebuf;
+    int returntype;
+    utf *desc = utf_new_char(str);
+    
+    num = typeinfo_count_method_args(desc,false);
+    if (num) {
+        typebuf = (u1*) DumpMemory::allocate(sizeof(u1) * num);
+        infobuf = (typeinfo_t*) DumpMemory::allocate(sizeof(typeinfo_t) * num);
+        
+        typeinfo_init_from_method_args(desc,typebuf,infobuf,num,false,
+                                       &returntype,info);
+
+        TYPEINFO_ALLOCMERGED(info->merged,num);
+        info->merged->count = num;
+
+        for (i=0; i<num; ++i) {
+            if (typebuf[i] != TYPE_ADR) {
+                log_text("non-reference type in mergedlist");
+                               assert(0);
+                       }
+
+            info->merged->list[i].any = infobuf[i].typeclass.any;
+        }
+        qsort(info->merged->list,num,sizeof(classref_or_classinfo),
+              (int(*)(const void *,const void *))&typeinfo_test_compare);
+    }
+    else {
+        typeinfo_init_from_method_args(desc,NULL,NULL,0,false,
+                                       &returntype,info);
+    }
+}
+#endif
+
+#define TYPEINFO_TEST_BUFLEN  4000
+
+static bool
+typeinfo_equal(typeinfo_t *x,typeinfo_t *y)
+{
+    int i;
+    
+    if (x->typeclass.any != y->typeclass.any) return false;
+    if (x->dimension != y->dimension) return false;
+    if (x->dimension) {
+        if (x->elementclass.any != y->elementclass.any) return false;
+        if (x->elementtype != y->elementtype) return false;
+    }
+
+    if (TYPEINFO_IS_NEWOBJECT(*x))
+        if (TYPEINFO_NEWOBJECT_INSTRUCTION(*x)
+            != TYPEINFO_NEWOBJECT_INSTRUCTION(*y))
+            return false;
+
+    if (x->merged || y->merged) {
+        if (!(x->merged && y->merged)) return false;
+        if (x->merged->count != y->merged->count) return false;
+        for (i=0; i<x->merged->count; ++i)
+            if (x->merged->list[i].any != y->merged->list[i].any)
+                return false;
+    }
+    return true;
+}
+
+static void
+typeinfo_testmerge(typeinfo_t *a,typeinfo_t *b,typeinfo_t *result,int *failed)
+{
+    typeinfo_t dest;
+    bool changed,changed_should_be;
+       typecheck_result r;
+
+    TYPEINFO_CLONE(*a,dest);
+    
+    printf("\n          ");
+    typeinfo_print_short(stdout,&dest);
+    printf("\n          ");
+    typeinfo_print_short(stdout,b);
+    printf("\n");
+
+       r = typeinfo_merge(NULL,&dest,b);
+       if (r == typecheck_FAIL) {
+               printf("EXCEPTION\n");
+               return;
+       }
+    changed = (r) ? 1 : 0;
+    changed_should_be = (!typeinfo_equal(&dest,a)) ? 1 : 0;
+
+    printf("          %s\n",(changed) ? "changed" : "=");
+
+    if (typeinfo_equal(&dest,result)) {
+        printf("OK        ");
+        typeinfo_print_short(stdout,&dest);
+        printf("\n");
+        if (changed != changed_should_be) {
+            printf("WRONG RETURN VALUE!\n");
+            (*failed)++;
+        }
+    }
+    else {
+        printf("RESULT    ");
+        typeinfo_print_short(stdout,&dest);
+        printf("\n");
+        printf("SHOULD BE ");
+        typeinfo_print_short(stdout,result);
+        printf("\n");
+        (*failed)++;
+    }
+}
+
+#if 0
+static void
+typeinfo_inc_dimension(typeinfo_t *info)
+{
+    if (info->dimension++ == 0) {
+        info->elementtype = ARRAYTYPE_OBJECT;
+        info->elementclass = info->typeclass;
+    }
+    info->typeclass = class_array_of(info->typeclass,true);
+}
+#endif
+
+#define TYPEINFO_TEST_MAXDIM  10
+
+static void
+typeinfo_testrun(char *filename)
+{
+    char buf[TYPEINFO_TEST_BUFLEN];
+    char bufa[TYPEINFO_TEST_BUFLEN];
+    char bufb[TYPEINFO_TEST_BUFLEN];
+    char bufc[TYPEINFO_TEST_BUFLEN];
+    typeinfo_t a,b,c;
+    int maxdim;
+    int failed = 0;
+    FILE *file = fopen(filename,"rt");
+       int res;
+    
+    if (!file) {
+        log_text("could not open typeinfo test file");
+               assert(0);
+       }
+
+    while (fgets(buf,TYPEINFO_TEST_BUFLEN,file)) {
+        if (buf[0] == '#' || !strlen(buf))
+            continue;
+        
+        res = sscanf(buf,"%s\t%s\t%s\n",bufa,bufb,bufc);
+        if (res != 3 || !strlen(bufa) || !strlen(bufb) || !strlen(bufc)) {
+            log_text("Invalid line in typeinfo test file (none of empty, comment or test)");
+                       assert(0);
+               }
+
+#if 0
+        typeinfo_test_parse(&a,bufa);
+        typeinfo_test_parse(&b,bufb);
+        typeinfo_test_parse(&c,bufc);
+#endif
+#if 0
+        do {
+#endif
+            typeinfo_testmerge(&a,&b,&c,&failed); /* check result */
+            typeinfo_testmerge(&b,&a,&c,&failed); /* check commutativity */
+
+            if (TYPEINFO_IS_NULLTYPE(a)) break;
+            if (TYPEINFO_IS_NULLTYPE(b)) break;
+            if (TYPEINFO_IS_NULLTYPE(c)) break;
+            
+            maxdim = a.dimension;
+            if (b.dimension > maxdim) maxdim = b.dimension;
+            if (c.dimension > maxdim) maxdim = c.dimension;
+
+#if 0
+            if (maxdim < TYPEINFO_TEST_MAXDIM) {
+                typeinfo_inc_dimension(&a);
+                typeinfo_inc_dimension(&b);
+                typeinfo_inc_dimension(&c);
+            }
+        } while (maxdim < TYPEINFO_TEST_MAXDIM);
+#endif
+    }
+
+    fclose(file);
+
+    if (failed) {
+        fprintf(stderr,"Failed typeinfo_merge tests: %d\n",failed);
+        log_text("Failed test");
+               assert(0);
+    }
+}
+
+void
+typeinfo_test()
+{
+    log_text("Running typeinfo test file...");
+    typeinfo_testrun("typeinfo.tst");
+    log_text("Finished typeinfo test file.");
+}
+
+#if 0
+void
+typeinfo_init_from_fielddescriptor(typeinfo_t *info,char *desc)
+{
+    typeinfo_init_from_descriptor(info,desc,desc+strlen(desc));
+}
+#endif
+
+#define TYPEINFO_MAXINDENT  80
+
+void
+typeinfo_print_class(FILE *file,classref_or_classinfo c)
+{
+       /*fprintf(file,"<class %p>",c.any);*/
+
+       if (!c.any) {
+               fprintf(file,"<null>");
+       }
+       else {
+               if (IS_CLASSREF(c)) {
+                       fprintf(file,"<ref>");
+                       utf_fprint_printable_ascii(file,c.ref->name);
+               }
+               else {
+                       utf_fprint_printable_ascii(file,c.cls->name);
+               }
+       }
+}
+
+void
+typeinfo_print(FILE *file,typeinfo_t *info,int indent)
+{
+    int i;
+    char ind[TYPEINFO_MAXINDENT + 1];
+    instruction *ins;
+       basicblock *bptr;
+
+    if (indent > TYPEINFO_MAXINDENT) indent = TYPEINFO_MAXINDENT;
+    
+    for (i=0; i<indent; ++i)
+        ind[i] = ' ';
+    ind[i] = (char) 0;
+    
+    if (TYPEINFO_IS_PRIMITIVE(*info)) {
+               bptr = (basicblock*) TYPEINFO_RETURNADDRESS(*info);
+               if (bptr)
+                       fprintf(file,"%sreturnAddress (L%03d)\n",ind,bptr->nr);
+               else
+                       fprintf(file,"%sprimitive\n",ind);
+        return;
+    }
+    
+    if (TYPEINFO_IS_NULLTYPE(*info)) {
+        fprintf(file,"%snull\n",ind);
+        return;
+    }
+
+    if (TYPEINFO_IS_NEWOBJECT(*info)) {
+        ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*info);
+        if (ins) {
+            fprintf(file,"%sNEW(%p):",ind,(void*)ins);
+                       typeinfo_print_class(file,ins[-1].sx.val.c);
+            fprintf(file,"\n");
+        }
+        else {
+            fprintf(file,"%sNEW(this)",ind);
+        }
+        return;
+    }
+
+    fprintf(file,"%sClass:      ",ind);
+       typeinfo_print_class(file,info->typeclass);
+    fprintf(file,"\n");
+
+    if (TYPEINFO_IS_ARRAY(*info)) {
+        fprintf(file,"%sDimension:    %d",ind,(int)info->dimension);
+        fprintf(file,"\n%sElements:     ",ind);
+        switch (info->elementtype) {
+          case ARRAYTYPE_INT     : fprintf(file,"int\n"); break;
+          case ARRAYTYPE_LONG    : fprintf(file,"long\n"); break;
+          case ARRAYTYPE_FLOAT   : fprintf(file,"float\n"); break;
+          case ARRAYTYPE_DOUBLE  : fprintf(file,"double\n"); break;
+          case ARRAYTYPE_BYTE    : fprintf(file,"byte\n"); break;
+          case ARRAYTYPE_CHAR    : fprintf(file,"char\n"); break;
+          case ARRAYTYPE_SHORT   : fprintf(file,"short\n"); break;
+          case ARRAYTYPE_BOOLEAN : fprintf(file,"boolean\n"); break;
+              
+          case ARRAYTYPE_OBJECT:
+                         typeinfo_print_class(file,info->elementclass);
+              fprintf(file,"\n");
+              break;
+              
+          default:
+              fprintf(file,"INVALID ARRAYTYPE!\n");
+        }
+    }
+
+    if (info->merged) {
+        fprintf(file,"%sMerged:     ",ind);
+        for (i=0; i<info->merged->count; ++i) {
+            if (i) fprintf(file,", ");
+                       typeinfo_print_class(file,info->merged->list[i]);
+        }
+        fprintf(file,"\n");
+    }
+}
+
+void
+typeinfo_print_short(FILE *file,typeinfo_t *info)
+{
+    int i;
+    instruction *ins;
+       basicblock *bptr;
+
+       /*fprintf(file,"<typeinfo %p>",info);*/
+
+       if (!info) {
+               fprintf(file,"(typeinfo*)NULL");
+               return;
+       }
+
+    if (TYPEINFO_IS_PRIMITIVE(*info)) {
+               bptr = (basicblock*) TYPEINFO_RETURNADDRESS(*info);
+               if (bptr)
+                       fprintf(file,"ret(L%03d)",bptr->nr);
+               else
+                       fprintf(file,"primitive");
+        return;
+    }
+    
+    if (TYPEINFO_IS_NULLTYPE(*info)) {
+        fprintf(file,"null");
+        return;
+    }
+    
+    if (TYPEINFO_IS_NEWOBJECT(*info)) {
+        ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*info);
+        if (ins) {
+                       /*fprintf(file,"<ins %p>",ins);*/
+            fprintf(file,"NEW(%p):",(void*)ins);
+                       typeinfo_print_class(file,ins[-1].sx.val.c);
+        }
+        else
+            fprintf(file,"NEW(this)");
+        return;
+    }
+
+    typeinfo_print_class(file,info->typeclass);
+
+    if (info->merged) {
+        fprintf(file,"{");
+        for (i=0; i<info->merged->count; ++i) {
+            if (i) fprintf(file,",");
+                       typeinfo_print_class(file,info->merged->list[i]);
+        }
+        fprintf(file,"}");
+    }
+}
+
+void
+typeinfo_print_type(FILE *file,int type,typeinfo_t *info)
+{
+    switch (type) {
+      case TYPE_VOID: fprintf(file,"V"); break;
+      case TYPE_INT:  fprintf(file,"I"); break;
+      case TYPE_FLT:  fprintf(file,"F"); break;
+      case TYPE_DBL:  fprintf(file,"D"); break;
+      case TYPE_LNG:  fprintf(file,"J"); break;
+         case TYPE_RET:  fprintf(file,"R:"); /* FALLTHROUGH! */
+      case TYPE_ADR:
+                 typeinfo_print_short(file,info);
+          break;
+          
+      default:
+          fprintf(file,"!");
+    }
+}
+
+void
+typedescriptor_print(FILE *file,typedescriptor_t *td)
+{
+       typeinfo_print_type(file,td->type,&(td->typeinfo));
+}
+
+void
+typevector_print(FILE *file,varinfo *vec,int size)
+{
+    int i;
+
+    for (i=0; i<size; ++i) {
+               fprintf(file," %d=",i);
+        typeinfo_print_type(file, vec[i].type, &(vec[i].typeinfo));
+    }
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* TYPEINFO_DEBUG */
+
+
+/*
+ * 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/jit/verify/typeinfo.h b/src/vm/jit/verify/typeinfo.h
deleted file mode 100644 (file)
index e352149..0000000
+++ /dev/null
@@ -1,532 +0,0 @@
-/* src/vm/jit/verify/typeinfo.h - type system used by the type checker
-
-   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 _TYPEINFO_H
-#define _TYPEINFO_H
-
-/* resolve typedef cycles *****************************************************/
-
-typedef struct typeinfo            typeinfo_t;
-typedef struct typeinfo_mergedlist typeinfo_mergedlist_t;
-typedef struct typedescriptor      typedescriptor_t;
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#include "vmcore/references.h"
-
-
-/* configuration **************************************************************/
-
-/*
- * TYPECHECK_STATISTICS activates gathering statistical information.
- * TYPEINFO_DEBUG activates debug checks and debug helpers in typeinfo.c
- * TYPECHECK_DEBUG activates debug checks in typecheck.c
- * TYPEINFO_DEBUG_TEST activates the typeinfo test at startup.
- * TYPECHECK_VERBOSE_IMPORTANT activates important debug messages
- * TYPECHECK_VERBOSE activates all debug messages
- * TYPEINFO_VERBOSE activates debug prints in typeinfo.c
- */
-#ifdef ENABLE_VERIFIER
-#ifndef NDEBUG
-/*#define TYPECHECK_STATISTICS*/
-#define TYPEINFO_DEBUG
-/*#define TYPEINFO_VERBOSE*/
-#define TYPECHECK_DEBUG
-/*#define TYPEINFO_DEBUG_TEST*/
-/*#define TYPECHECK_VERBOSE*/
-/*#define TYPECHECK_VERBOSE_IMPORTANT*/
-#if defined(TYPECHECK_VERBOSE) || defined(TYPECHECK_VERBOSE_IMPORTANT)
-#define TYPECHECK_VERBOSE_OPT
-#endif
-#endif
-#endif
-
-#ifdef TYPECHECK_VERBOSE_OPT
-extern bool opt_typecheckverbose;
-#endif
-
-/* types **********************************************************************/
-
-/* typecheck_result - return type for boolean and tristate  functions     */
-/*                    which may also throw exceptions (typecheck_FAIL).   */
-
-/* NOTE: Use the enum values, not the uppercase #define macros!          */
-#define TYPECHECK_MAYBE  0x02
-#define TYPECHECK_FAIL   0x04
-
-typedef enum {
-       typecheck_FALSE = false,
-       typecheck_TRUE  = true,
-       typecheck_MAYBE = TYPECHECK_MAYBE,
-       typecheck_FAIL  = TYPECHECK_FAIL
-} typecheck_result;
-
-/* check that typecheck_MAYBE is not ambiguous */
-#if TYPECHECK_MAYBE == true
-#error "`typecheck_MAYBE` must not be the same as `true`"
-#endif
-#if TYPECHECK_MAYBE == false
-#error "`typecheck_MAYBE` must not be the same as `false`"
-#endif
-
-/* check that typecheck_FAIL is not ambiguous */
-#if (true & TYPECHECK_FAIL) != 0
-#error "`true` must not have bit 0x02 set (conflicts with typecheck_FAIL)"
-#endif
-
-/* data structures for the type system ****************************************/
-
-/* The typeinfo structure stores detailed information on address types.
- * (stack elements, variables, etc. with type == TYPE_ADR.)
- *
- * There are two kinds of address types which can be distinguished by
- * the value of the typeclass field:
- *
- * 1) typeclass == NULL: returnAddress type
- *                       use TYPEINFO_IS_PRIMITIVE to test for this
- *
- * 2) typeclass != NULL: reference type
- *                       use TYPEINFO_IS_REFERENCE to test for this
- *
- * Note: For non-address types either there is no typeinfo allocated
- * or the fields of the typeinfo struct contain undefined values!
- * DO NOT access the typeinfo for non-address types!
- *
- * CAUTION: The typeinfo structure should be considered opaque outside of
- *          typeinfo.[ch]. Please use the macros and functions defined here to
- *          access typeinfo structures!
- */
-
-/* At all times *exactly one* of the following conditions is true for
- * a particular typeinfo struct:
- *
- * A) typeclass == NULL
- *
- *        This is a returnAddress type.
- *
- *        Use TYPEINFO_IS_PRIMITIVE to check for this.
- *        Use TYPEINFO_RETURNADDRESS to access the pointer in elementclass.
- *        Don't access other fields of the struct.
- *
- * B) typeclass == pseudo_class_Null
- *
- *        This is the null-reference type. 
- *        Use TYPEINFO_IS_NULLTYPE to check for this.
- *        Don't access other fields of the struct.
- *
- * C) typeclass == pseudo_class_New
- *
- *        This is an 'uninitialized object' type. elementclass can be
- *        cast to instruction* and points to the NEW instruction
- *        responsible for creating this type.
- *
- *        Use TYPEINFO_NEWOBJECT_INSTRUCTION to access the pointer in
- *        elementclass.
- *        Don't access other fields of the struct.
- *
- * D) typeclass == pseudo_class_Arraystub
- *
- *        This type is used to represent the result of merging array types
- *        with incompatible component types. An arraystub allows no access
- *        to its components (since their type is undefined), but it allows
- *        operations which act directly on an arbitrary array type (such as
- *        requesting the array size).
- *
- *        NOTE: An array stub does *not* count as an array. It has dimension
- *              zero.
- *
- *        Otherwise like a normal class reference type.
- *        Don't access other fields of the struct.
- *
- * E) typeclass is an array class
- *
- *        An array reference.
- *            elementclass...typeclass of the element type
- *            dimension......dimension of the array (>=1)
- *            elementtype....element type (ARRAYTYPE_...)
- *            merged.........mergedlist of the element type
- *
- *        Use TYPEINFO_IS_ARRAY to check for this case.
- *
- *        The elementclass may be one of the following:
- *        1) pseudo_class_Arraystub
- *        2) an unresolved type
- *        3) a loaded interface
- *        4) a loaded (non-pseudo-,non-array-)class != (BOOTSTRAP)java.lang.Object
- *                Note: `merged` may be used
- *        5) (BOOTSTRAP)java.lang.Object
- *                Note: `merged` may be used
- *
- *        For the semantics of the merged field in cases 4) and 5) consult the 
- *        corresponding descriptions with `elementclass` replaced by `typeclass`.
- *
- * F) typeclass is an unresolved type (a symbolic class/interface reference)
- *
- *        The type has not been resolved yet. (Meaning it corresponds to an
- *        unloaded class or interface).
- *        Don't access other fields of the struct.
- *
- * G) typeclass is a loaded interface
- *
- *        An interface reference type.
- *        Don't access other fields of the struct.
- *
- * H) typeclass is a loaded (non-pseudo-,non-array-)class != (BOOTSTRAP)java.lang.Object
- *
- *        A loaded class type.
- *        All classref_or_classinfos in u.merged.list (if any) are
- *        loaded subclasses of typeclass (no interfaces, array classes, or
- *        unresolved types).
- *        Don't access other fields of the struct.
- *
- * I) typeclass is (BOOTSTRAP)java.lang.Object
- *
- *        The most general kind of reference type.
- *        In this case u.merged.count and u.merged.list
- *        are valid and may be non-zero.
- *        The classref_or_classinfos in u.merged.list (if any) may be
- *        classes, interfaces, pseudo classes or unresolved types.
- *        Don't access other fields of the struct.
- */
-
-/* The following algorithm is used to determine if the type described
- * by this typeinfo struct supports the interface X:  * XXX add MAYBE *
- *
- *     1) If typeclass is X or a subinterface of X the answer is "yes".
- *     2) If typeclass is a (pseudo) class implementing X the answer is "yes".
- *     3) If typeclass is not an array and u.merged.count>0
- *        and all classes/interfaces in u.merged.list implement X
- *        the answer is "yes".
- *     4) If none of the above is true the answer is "no".
- */
-
-/*
- * CAUTION: The typeinfo structure should be considered opaque outside of
- *          typeinfo.[ch]. Please use the macros and functions defined here to
- *          access typeinfo structures!
- */
-struct typeinfo {
-       classref_or_classinfo  typeclass;
-       classref_or_classinfo  elementclass; /* valid if dimension>0 */ /* various uses! */
-       typeinfo_mergedlist_t *merged;
-       u1                     dimension;
-       u1                     elementtype;  /* valid if dimension>0           */
-};
-
-struct typeinfo_mergedlist {
-       s4                    count;
-       classref_or_classinfo list[1];       /* variable length!                        */
-};
-
-/* a type descriptor stores a basic type and the typeinfo                */
-/* this is used for storing the type of a local variable, and for        */
-/* storing types in the signature of a method                            */
-
-struct typedescriptor {
-       typeinfo_t      typeinfo; /* valid if type == TYPE_ADR               */
-       u1              type;     /* basic type (TYPE_INT, ...)              */
-};
-
-/****************************************************************************/
-/* MACROS                                                                   */
-/****************************************************************************/
-
-/* NOTE: The TYPEINFO macros take typeinfo *structs*, not pointers as
- *       arguments.  You have to dereference any pointers.
- */
-
-/* typevectors **************************************************************/
-
-#define TYPEVECTOR_SIZE(size)                                          \
-    ((size) * sizeof(varinfo)) 
-
-#define DNEW_TYPEVECTOR(size)                                          \
-    ((varinfo *) DMNEW(uint8_t, TYPEVECTOR_SIZE(size)))
-
-#define DMNEW_TYPEVECTOR(num,size)                                             \
-    ((void *) DMNEW(uint8_t, (num) * TYPEVECTOR_SIZE(size)))
-
-#define MGET_TYPEVECTOR(array,index,size) \
-    ((varinfo*) (((u1*)(array)) + TYPEVECTOR_SIZE(size) * (index)))
-
-/* internally used macros ***************************************************/
-
-/* internal, don't use this explicitly! */
-#define TYPEINFO_ALLOCMERGED(mergedlist,count)                                 \
-    do {(mergedlist) = (typeinfo_mergedlist_t *) DMNEW(uint8_t,        \
-            sizeof(typeinfo_mergedlist_t)                       \
-            + ((count)-1)*sizeof(classinfo*));} while(0)
-
-/* internal, don't use this explicitly! */
-#define TYPEINFO_FREEMERGED(mergedlist)
-
-/* internal, don't use this explicitly! */
-#define TYPEINFO_FREEMERGED_IF_ANY(mergedlist)
-
-/* macros for type queries **************************************************/
-
-#define TYPEINFO_IS_PRIMITIVE(info)                             \
-            ((info).typeclass.any == NULL)
-
-#define TYPEINFO_IS_REFERENCE(info)                             \
-            ((info).typeclass.any != NULL)
-
-#define TYPEINFO_IS_NULLTYPE(info)                              \
-            ((info).typeclass.cls == pseudo_class_Null)
-
-#define TYPEINFO_IS_NEWOBJECT(info)                             \
-            ((info).typeclass.cls == pseudo_class_New)
-
-#define TYPEINFO_IS_JAVA_LANG_CLASS(info)                       \
-            ((info).typeclass.cls == class_java_lang_Class)
-
-/* only use this if TYPEINFO_IS_PRIMITIVE returned true! */
-#define TYPEINFO_RETURNADDRESS(info)                            \
-            ((info).elementclass.any)
-
-/* only use this if TYPEINFO_IS_NEWOBJECT returned true! */
-#define TYPEINFO_NEWOBJECT_INSTRUCTION(info)                    \
-               ((info).elementclass.any)
-
-/* only use this if TYPEINFO_IS_JAVA_LANG_CLASS returned true! */
-#define TYPEINFO_JAVA_LANG_CLASS_CLASSREF(info)                 \
-               ((info).elementclass.ref)
-
-/* macros for array type queries ********************************************/
-
-#define TYPEINFO_IS_ARRAY(info)                                 \
-            ( TYPEINFO_IS_REFERENCE(info)                       \
-              && ((info).dimension != 0) )
-
-#define TYPEINFO_IS_SIMPLE_ARRAY(info)                          \
-            ( ((info).dimension == 1) )
-
-#define TYPEINFO_IS_ARRAY_ARRAY(info)                           \
-            ( ((info).dimension >= 2) )
-
-#define TYPEINFO_IS_PRIMITIVE_ARRAY(info,arraytype)             \
-            ( TYPEINFO_IS_SIMPLE_ARRAY(info)                    \
-              && ((info).elementtype == (arraytype)) )
-
-#define TYPEINFO_IS_OBJECT_ARRAY(info)                          \
-            ( TYPEINFO_IS_SIMPLE_ARRAY(info)                    \
-              && ((info).elementclass.any != NULL) )
-
-/* assumes that info describes an array type */
-#define TYPEINFO_IS_ARRAY_OF_REFS_NOCHECK(info)                 \
-            ( ((info).elementclass.any != NULL)                 \
-              || ((info).dimension >= 2) )
-
-#define TYPEINFO_IS_ARRAY_OF_REFS(info)                         \
-            ( TYPEINFO_IS_ARRAY(info)                           \
-              && TYPEINFO_IS_ARRAY_OF_REFS_NOCHECK(info) )
-
-#define TYPE_IS_RETURNADDRESS(type,info)                        \
-            ( ((type)==TYPE_RET)                                \
-              && TYPEINFO_IS_PRIMITIVE(info) )
-
-#define TYPE_IS_REFERENCE(type,info)                            \
-            ( ((type)==TYPE_ADR)                                \
-              && !TYPEINFO_IS_PRIMITIVE(info) )
-
-#define TYPEDESC_IS_RETURNADDRESS(td)                           \
-            TYPE_IS_RETURNADDRESS((td).type,(td).typeinfo)
-
-#define TYPEDESC_IS_REFERENCE(td)                               \
-            TYPE_IS_REFERENCE((td).type,(td).typeinfo)
-
-/* queries allowing the null type ********************************************/
-
-#define TYPEINFO_MAYBE_ARRAY(info)                              \
-    (TYPEINFO_IS_ARRAY(info) || TYPEINFO_IS_NULLTYPE(info))
-
-#define TYPEINFO_MAYBE_PRIMITIVE_ARRAY(info,at)                 \
-    (TYPEINFO_IS_PRIMITIVE_ARRAY(info,at) || TYPEINFO_IS_NULLTYPE(info))
-
-#define TYPEINFO_MAYBE_ARRAY_OF_REFS(info)                      \
-    (TYPEINFO_IS_ARRAY_OF_REFS(info) || TYPEINFO_IS_NULLTYPE(info))
-
-/* macros for initializing typeinfo structures ******************************/
-
-#define TYPEINFO_INIT_PRIMITIVE(info)                           \
-         do {(info).typeclass.any = NULL;                       \
-             (info).elementclass.any = NULL;                    \
-             (info).merged = NULL;                              \
-             (info).dimension = 0;                              \
-             (info).elementtype = 0;} while(0)
-
-#define TYPEINFO_INIT_RETURNADDRESS(info,adr)                   \
-         do {(info).typeclass.any = NULL;                       \
-             (info).elementclass.any = (adr);                   \
-             (info).merged = NULL;                              \
-             (info).dimension = 0;                              \
-             (info).elementtype = 0;} while(0)
-
-#define TYPEINFO_INIT_NON_ARRAY_CLASSINFO(info,cinfo)   \
-         do {(info).typeclass.cls = (cinfo);            \
-             (info).elementclass.any = NULL;            \
-             (info).merged = NULL;                      \
-             (info).dimension = 0;                      \
-             (info).elementtype = 0;} while(0)
-
-#define TYPEINFO_INIT_JAVA_LANG_CLASS(info,c)                   \
-         do {(info).typeclass.any = class_java_lang_Class;      \
-             (info).elementclass = (c);                         \
-             (info).merged = NULL;                              \
-             (info).dimension = 0;                              \
-             (info).elementtype = 0;} while(0)
-
-#define TYPEINFO_INIT_NULLTYPE(info)                            \
-            TYPEINFO_INIT_NON_ARRAY_CLASSINFO(info,pseudo_class_Null)
-
-#define TYPEINFO_INIT_NEWOBJECT(info,instr)             \
-         do {(info).typeclass.cls = pseudo_class_New;   \
-             (info).elementclass.any = (instr);         \
-             (info).merged = NULL;                      \
-             (info).dimension = 0;                      \
-             (info).elementtype = 0;} while(0)
-
-#define TYPEINFO_INIT_PRIMITIVE_ARRAY(info,arraytype)                   \
-    typeinfo_init_classinfo(&(info),primitivetype_table[arraytype].arrayclass);
-
-/* macros for copying types (destinition is not checked or freed) ***********/
-
-/* TYPEINFO_COPY makes a shallow copy, the merged pointer is simply copied. */
-#define TYPEINFO_COPY(src,dst)                                  \
-    do {(dst) = (src);} while(0)
-
-/* TYPEINFO_CLONE makes a deep copy, the merged list (if any) is duplicated
- * into a newly allocated array.
- */
-#define TYPEINFO_CLONE(src,dst)                                 \
-    do {(dst) = (src);                                          \
-        if ((dst).merged) typeinfo_clone(&(src),&(dst));} while(0)
-
-/****************************************************************************/
-/* FUNCTIONS                                                                */
-/****************************************************************************/
-
-/* typevector functions *****************************************************/
-
-/* element read-only access */
-bool typevector_checktype(varinfo *set,int index,int type);
-bool typevector_checkreference(varinfo *set,int index);
-bool typevector_checkretaddr(varinfo *set,int index);
-
-/* element write access */
-void typevector_store(varinfo *set,int index,int type,typeinfo_t *info);
-void typevector_store_retaddr(varinfo *set,int index,typeinfo_t *info);
-bool typevector_init_object(varinfo *set,void *ins,classref_or_classinfo initclass,int size);
-
-/* vector functions */
-varinfo *typevector_copy(varinfo *src,int size);
-void typevector_copy_inplace(varinfo *src,varinfo *dst,int size);
-typecheck_result typevector_merge(methodinfo *m,varinfo *dst,varinfo *y,int size);
-
-/* inquiry functions (read-only) ********************************************/
-
-bool typeinfo_is_array(typeinfo_t *info);
-bool typeinfo_is_primitive_array(typeinfo_t *info,int arraytype);
-bool typeinfo_is_array_of_refs(typeinfo_t *info);
-
-typecheck_result typeinfo_is_assignable(typeinfo_t *value,typeinfo_t *dest);
-typecheck_result typeinfo_is_assignable_to_class(typeinfo_t *value,classref_or_classinfo dest);
-
-/* initialization functions *************************************************/
-
-/* RETURN VALUE (bool):
- *     true.............ok,
- *     false............an exception has been thrown.
- *
- * RETURN VALUE (int):
- *     >= 0.............ok,
- *     -1...............an exception has been thrown.
- */
-void typeinfo_init_classinfo(typeinfo_t *info,classinfo *c);
-bool typeinfo_init_class(typeinfo_t *info,classref_or_classinfo c);
-bool typeinfo_init_component(typeinfo_t *srcarray,typeinfo_t *dst);
-
-bool typeinfo_init_from_typedesc(typedesc *desc,u1 *type,typeinfo_t *info);
-bool typeinfos_init_from_methoddesc(methoddesc *desc,u1 *typebuf,
-                                   typeinfo_t *infobuf,
-                                   int buflen,bool twoword,
-                                   u1 *returntype,typeinfo_t *returntypeinfo);
-bool  typedescriptor_init_from_typedesc(typedescriptor_t *td,
-                                                                           typedesc *desc);
-bool  typeinfo_init_varinfo_from_typedesc(varinfo *var,
-                                                                           typedesc *desc);
-int  typedescriptors_init_from_methoddesc(typedescriptor_t *td,
-                                                                                 methoddesc *desc,
-                                                                                 int buflen,bool twoword,int startindex,
-                                                                                 typedescriptor_t *returntype);
-bool typeinfo_init_varinfos_from_methoddesc(varinfo *vars,
-                                                                                 methoddesc *desc,
-                                                                                 int buflen, int startindex,
-                                                                                 s4 *map,
-                                                                                 typedescriptor_t *returntype);
-
-void typeinfo_clone(typeinfo_t *src,typeinfo_t *dest);
-
-/* freeing memory ***********************************************************/
-
-void typeinfo_free(typeinfo_t *info);
-
-/* functions for merging types **********************************************/
-
-typecheck_result typeinfo_merge(methodinfo *m,typeinfo_t *dest,typeinfo_t* y);
-
-/* debugging helpers ********************************************************/
-
-#ifdef TYPEINFO_DEBUG
-
-#include <stdio.h>
-
-void typeinfo_test();
-void typeinfo_print_class(FILE *file,classref_or_classinfo c);
-void typeinfo_print(FILE *file,typeinfo_t *info,int indent);
-void typeinfo_print_short(FILE *file,typeinfo_t *info);
-void typeinfo_print_type(FILE *file,int type,typeinfo_t *info);
-void typedescriptor_print(FILE *file,typedescriptor_t *td);
-void typevector_print(FILE *file,varinfo *vec,int size);
-
-#endif /* TYPEINFO_DEBUG */
-
-#endif /* _TYPEINFO_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:
- */
diff --git a/src/vm/jit/verify/typeinfo.hpp b/src/vm/jit/verify/typeinfo.hpp
new file mode 100644 (file)
index 0000000..ea42925
--- /dev/null
@@ -0,0 +1,538 @@
+/* src/vm/jit/verify/typeinfo.h - type system used by the type checker
+
+   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 _TYPEINFO_H
+#define _TYPEINFO_H
+
+/* resolve typedef cycles *****************************************************/
+
+typedef struct typeinfo            typeinfo_t;
+typedef struct typeinfo_mergedlist typeinfo_mergedlist_t;
+typedef struct typedescriptor      typedescriptor_t;
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/global.h"
+#include "vm/references.h"
+
+
+/* configuration **************************************************************/
+
+/*
+ * TYPECHECK_STATISTICS activates gathering statistical information.
+ * TYPEINFO_DEBUG activates debug checks and debug helpers in typeinfo.c
+ * TYPECHECK_DEBUG activates debug checks in typecheck.c
+ * TYPEINFO_DEBUG_TEST activates the typeinfo test at startup.
+ * TYPECHECK_VERBOSE_IMPORTANT activates important debug messages
+ * TYPECHECK_VERBOSE activates all debug messages
+ * TYPEINFO_VERBOSE activates debug prints in typeinfo.c
+ */
+#ifdef ENABLE_VERIFIER
+#ifndef NDEBUG
+/*#define TYPECHECK_STATISTICS*/
+#define TYPEINFO_DEBUG
+/*#define TYPEINFO_VERBOSE*/
+#define TYPECHECK_DEBUG
+/*#define TYPEINFO_DEBUG_TEST*/
+/*#define TYPECHECK_VERBOSE*/
+/*#define TYPECHECK_VERBOSE_IMPORTANT*/
+#if defined(TYPECHECK_VERBOSE) || defined(TYPECHECK_VERBOSE_IMPORTANT)
+#define TYPECHECK_VERBOSE_OPT
+#endif
+#endif
+#endif
+
+#ifdef TYPECHECK_VERBOSE_OPT
+extern bool opt_typecheckverbose;
+#endif
+
+/* types **********************************************************************/
+
+/* typecheck_result - return type for boolean and tristate  functions     */
+/*                    which may also throw exceptions (typecheck_FAIL).   */
+
+/* NOTE: Use the enum values, not the uppercase #define macros!          */
+#define TYPECHECK_MAYBE  0x02
+#define TYPECHECK_FAIL   0x04
+
+typedef enum {
+       typecheck_FALSE = false,
+       typecheck_TRUE  = true,
+       typecheck_MAYBE = TYPECHECK_MAYBE,
+       typecheck_FAIL  = TYPECHECK_FAIL
+} typecheck_result;
+
+/* check that typecheck_MAYBE is not ambiguous */
+#if TYPECHECK_MAYBE == true
+#error "`typecheck_MAYBE` must not be the same as `true`"
+#endif
+#if TYPECHECK_MAYBE == false
+#error "`typecheck_MAYBE` must not be the same as `false`"
+#endif
+
+/* check that typecheck_FAIL is not ambiguous */
+#if (true & TYPECHECK_FAIL) != 0
+#error "`true` must not have bit 0x02 set (conflicts with typecheck_FAIL)"
+#endif
+
+/* data structures for the type system ****************************************/
+
+/* The typeinfo structure stores detailed information on address types.
+ * (stack elements, variables, etc. with type == TYPE_ADR.)
+ *
+ * There are two kinds of address types which can be distinguished by
+ * the value of the typeclass field:
+ *
+ * 1) typeclass == NULL: returnAddress type
+ *                       use TYPEINFO_IS_PRIMITIVE to test for this
+ *
+ * 2) typeclass != NULL: reference type
+ *                       use TYPEINFO_IS_REFERENCE to test for this
+ *
+ * Note: For non-address types either there is no typeinfo allocated
+ * or the fields of the typeinfo struct contain undefined values!
+ * DO NOT access the typeinfo for non-address types!
+ *
+ * CAUTION: The typeinfo structure should be considered opaque outside of
+ *          typeinfo.[ch]. Please use the macros and functions defined here to
+ *          access typeinfo structures!
+ */
+
+/* At all times *exactly one* of the following conditions is true for
+ * a particular typeinfo struct:
+ *
+ * A) typeclass == NULL
+ *
+ *        This is a returnAddress type.
+ *
+ *        Use TYPEINFO_IS_PRIMITIVE to check for this.
+ *        Use TYPEINFO_RETURNADDRESS to access the pointer in elementclass.
+ *        Don't access other fields of the struct.
+ *
+ * B) typeclass == pseudo_class_Null
+ *
+ *        This is the null-reference type. 
+ *        Use TYPEINFO_IS_NULLTYPE to check for this.
+ *        Don't access other fields of the struct.
+ *
+ * C) typeclass == pseudo_class_New
+ *
+ *        This is an 'uninitialized object' type. elementclass can be
+ *        cast to instruction* and points to the NEW instruction
+ *        responsible for creating this type.
+ *
+ *        Use TYPEINFO_NEWOBJECT_INSTRUCTION to access the pointer in
+ *        elementclass.
+ *        Don't access other fields of the struct.
+ *
+ * D) typeclass == pseudo_class_Arraystub
+ *
+ *        This type is used to represent the result of merging array types
+ *        with incompatible component types. An arraystub allows no access
+ *        to its components (since their type is undefined), but it allows
+ *        operations which act directly on an arbitrary array type (such as
+ *        requesting the array size).
+ *
+ *        NOTE: An array stub does *not* count as an array. It has dimension
+ *              zero.
+ *
+ *        Otherwise like a normal class reference type.
+ *        Don't access other fields of the struct.
+ *
+ * E) typeclass is an array class
+ *
+ *        An array reference.
+ *            elementclass...typeclass of the element type
+ *            dimension......dimension of the array (>=1)
+ *            elementtype....element type (ARRAYTYPE_...)
+ *            merged.........mergedlist of the element type
+ *
+ *        Use TYPEINFO_IS_ARRAY to check for this case.
+ *
+ *        The elementclass may be one of the following:
+ *        1) pseudo_class_Arraystub
+ *        2) an unresolved type
+ *        3) a loaded interface
+ *        4) a loaded (non-pseudo-,non-array-)class != (BOOTSTRAP)java.lang.Object
+ *                Note: `merged` may be used
+ *        5) (BOOTSTRAP)java.lang.Object
+ *                Note: `merged` may be used
+ *
+ *        For the semantics of the merged field in cases 4) and 5) consult the 
+ *        corresponding descriptions with `elementclass` replaced by `typeclass`.
+ *
+ * F) typeclass is an unresolved type (a symbolic class/interface reference)
+ *
+ *        The type has not been resolved yet. (Meaning it corresponds to an
+ *        unloaded class or interface).
+ *        Don't access other fields of the struct.
+ *
+ * G) typeclass is a loaded interface
+ *
+ *        An interface reference type.
+ *        Don't access other fields of the struct.
+ *
+ * H) typeclass is a loaded (non-pseudo-,non-array-)class != (BOOTSTRAP)java.lang.Object
+ *
+ *        A loaded class type.
+ *        All classref_or_classinfos in u.merged.list (if any) are
+ *        loaded subclasses of typeclass (no interfaces, array classes, or
+ *        unresolved types).
+ *        Don't access other fields of the struct.
+ *
+ * I) typeclass is (BOOTSTRAP)java.lang.Object
+ *
+ *        The most general kind of reference type.
+ *        In this case u.merged.count and u.merged.list
+ *        are valid and may be non-zero.
+ *        The classref_or_classinfos in u.merged.list (if any) may be
+ *        classes, interfaces, pseudo classes or unresolved types.
+ *        Don't access other fields of the struct.
+ */
+
+/* The following algorithm is used to determine if the type described
+ * by this typeinfo struct supports the interface X:  * XXX add MAYBE *
+ *
+ *     1) If typeclass is X or a subinterface of X the answer is "yes".
+ *     2) If typeclass is a (pseudo) class implementing X the answer is "yes".
+ *     3) If typeclass is not an array and u.merged.count>0
+ *        and all classes/interfaces in u.merged.list implement X
+ *        the answer is "yes".
+ *     4) If none of the above is true the answer is "no".
+ */
+
+/*
+ * CAUTION: The typeinfo structure should be considered opaque outside of
+ *          typeinfo.[ch]. Please use the macros and functions defined here to
+ *          access typeinfo structures!
+ */
+struct typeinfo {
+       classref_or_classinfo  typeclass;
+       classref_or_classinfo  elementclass; /* valid if dimension>0 */ /* various uses! */
+       typeinfo_mergedlist_t *merged;
+       u1                     dimension;
+       u1                     elementtype;  /* valid if dimension>0           */
+};
+
+struct typeinfo_mergedlist {
+       s4                    count;
+       classref_or_classinfo list[1];       /* variable length!                        */
+};
+
+/* a type descriptor stores a basic type and the typeinfo                */
+/* this is used for storing the type of a local variable, and for        */
+/* storing types in the signature of a method                            */
+
+struct typedescriptor {
+       typeinfo_t      typeinfo; /* valid if type == TYPE_ADR               */
+       u1              type;     /* basic type (TYPE_INT, ...)              */
+};
+
+/****************************************************************************/
+/* MACROS                                                                   */
+/****************************************************************************/
+
+/* NOTE: The TYPEINFO macros take typeinfo *structs*, not pointers as
+ *       arguments.  You have to dereference any pointers.
+ */
+
+/* typevectors **************************************************************/
+
+#define TYPEVECTOR_SIZE(size)                                          \
+    ((size) * sizeof(varinfo)) 
+
+#define DNEW_TYPEVECTOR(size)                                          \
+    ((varinfo *) DumpMemory::allocate(TYPEVECTOR_SIZE(size)))
+
+#define DMNEW_TYPEVECTOR(num,size)                                     \
+    ((varinfo *) DumpMemory::allocate((num) * TYPEVECTOR_SIZE(size)))
+
+#define MGET_TYPEVECTOR(array,index,size) \
+    ((varinfo*) (((u1*)(array)) + TYPEVECTOR_SIZE(size) * (index)))
+
+/* internally used macros ***************************************************/
+
+/* internal, don't use this explicitly! */
+#define TYPEINFO_ALLOCMERGED(mergedlist,count)                                 \
+    do {(mergedlist) = (typeinfo_mergedlist_t *) DumpMemory::allocate(sizeof(typeinfo_mergedlist_t) \
+            + ((count)-1)*sizeof(classinfo*));} while(0)
+
+/* internal, don't use this explicitly! */
+#define TYPEINFO_FREEMERGED(mergedlist)
+
+/* internal, don't use this explicitly! */
+#define TYPEINFO_FREEMERGED_IF_ANY(mergedlist)
+
+/* macros for type queries **************************************************/
+
+#define TYPEINFO_IS_PRIMITIVE(info)                             \
+            ((info).typeclass.any == NULL)
+
+#define TYPEINFO_IS_REFERENCE(info)                             \
+            ((info).typeclass.any != NULL)
+
+#define TYPEINFO_IS_NULLTYPE(info)                              \
+            ((info).typeclass.cls == pseudo_class_Null)
+
+#define TYPEINFO_IS_NEWOBJECT(info)                             \
+            ((info).typeclass.cls == pseudo_class_New)
+
+#define TYPEINFO_IS_JAVA_LANG_CLASS(info)                       \
+            ((info).typeclass.cls == class_java_lang_Class)
+
+/* only use this if TYPEINFO_IS_PRIMITIVE returned true! */
+#define TYPEINFO_RETURNADDRESS(info)                            \
+            ((info).elementclass.any)
+
+/* only use this if TYPEINFO_IS_NEWOBJECT returned true! */
+#define TYPEINFO_NEWOBJECT_INSTRUCTION(info)                    \
+               ((info).elementclass.any)
+
+/* only use this if TYPEINFO_IS_JAVA_LANG_CLASS returned true! */
+#define TYPEINFO_JAVA_LANG_CLASS_CLASSREF(info)                 \
+               ((info).elementclass.ref)
+
+/* macros for array type queries ********************************************/
+
+#define TYPEINFO_IS_ARRAY(info)                                 \
+            ( TYPEINFO_IS_REFERENCE(info)                       \
+              && ((info).dimension != 0) )
+
+#define TYPEINFO_IS_SIMPLE_ARRAY(info)                          \
+            ( ((info).dimension == 1) )
+
+#define TYPEINFO_IS_ARRAY_ARRAY(info)                           \
+            ( ((info).dimension >= 2) )
+
+#define TYPEINFO_IS_PRIMITIVE_ARRAY(info,arraytype)             \
+            ( TYPEINFO_IS_SIMPLE_ARRAY(info)                    \
+              && ((info).elementtype == (arraytype)) )
+
+#define TYPEINFO_IS_OBJECT_ARRAY(info)                          \
+            ( TYPEINFO_IS_SIMPLE_ARRAY(info)                    \
+              && ((info).elementclass.any != NULL) )
+
+/* assumes that info describes an array type */
+#define TYPEINFO_IS_ARRAY_OF_REFS_NOCHECK(info)                 \
+            ( ((info).elementclass.any != NULL)                 \
+              || ((info).dimension >= 2) )
+
+#define TYPEINFO_IS_ARRAY_OF_REFS(info)                         \
+            ( TYPEINFO_IS_ARRAY(info)                           \
+              && TYPEINFO_IS_ARRAY_OF_REFS_NOCHECK(info) )
+
+#define TYPE_IS_RETURNADDRESS(type,info)                        \
+            ( ((type)==TYPE_RET)                                \
+              && TYPEINFO_IS_PRIMITIVE(info) )
+
+#define TYPE_IS_REFERENCE(type,info)                            \
+            ( ((type)==TYPE_ADR)                                \
+              && !TYPEINFO_IS_PRIMITIVE(info) )
+
+#define TYPEDESC_IS_RETURNADDRESS(td)                           \
+            TYPE_IS_RETURNADDRESS((td).type,(td).typeinfo)
+
+#define TYPEDESC_IS_REFERENCE(td)                               \
+            TYPE_IS_REFERENCE((td).type,(td).typeinfo)
+
+/* queries allowing the null type ********************************************/
+
+#define TYPEINFO_MAYBE_ARRAY(info)                              \
+    (TYPEINFO_IS_ARRAY(info) || TYPEINFO_IS_NULLTYPE(info))
+
+#define TYPEINFO_MAYBE_PRIMITIVE_ARRAY(info,at)                 \
+    (TYPEINFO_IS_PRIMITIVE_ARRAY(info,at) || TYPEINFO_IS_NULLTYPE(info))
+
+#define TYPEINFO_MAYBE_ARRAY_OF_REFS(info)                      \
+    (TYPEINFO_IS_ARRAY_OF_REFS(info) || TYPEINFO_IS_NULLTYPE(info))
+
+/* macros for initializing typeinfo structures ******************************/
+
+#define TYPEINFO_INIT_PRIMITIVE(info)                           \
+         do {(info).typeclass.any = NULL;                       \
+             (info).elementclass.any = NULL;                    \
+             (info).merged = NULL;                              \
+             (info).dimension = 0;                              \
+             (info).elementtype = 0;} while(0)
+
+#define TYPEINFO_INIT_RETURNADDRESS(info,adr)                   \
+         do {(info).typeclass.any = NULL;                       \
+             (info).elementclass.any = (adr);                   \
+             (info).merged = NULL;                              \
+             (info).dimension = 0;                              \
+             (info).elementtype = 0;} while(0)
+
+#define TYPEINFO_INIT_NON_ARRAY_CLASSINFO(info,cinfo)   \
+         do {(info).typeclass.cls = (cinfo);            \
+             (info).elementclass.any = NULL;            \
+             (info).merged = NULL;                      \
+             (info).dimension = 0;                      \
+             (info).elementtype = 0;} while(0)
+
+#define TYPEINFO_INIT_JAVA_LANG_CLASS(info,c)                   \
+         do {(info).typeclass.any = class_java_lang_Class;      \
+             (info).elementclass = (c);                         \
+             (info).merged = NULL;                              \
+             (info).dimension = 0;                              \
+             (info).elementtype = 0;} while(0)
+
+#define TYPEINFO_INIT_NULLTYPE(info)                            \
+            TYPEINFO_INIT_NON_ARRAY_CLASSINFO(info,pseudo_class_Null)
+
+#define TYPEINFO_INIT_NEWOBJECT(info,instr)             \
+         do {(info).typeclass.cls = pseudo_class_New;   \
+             (info).elementclass.any = (instr);         \
+             (info).merged = NULL;                      \
+             (info).dimension = 0;                      \
+             (info).elementtype = 0;} while(0)
+
+#define TYPEINFO_INIT_PRIMITIVE_ARRAY(info,arraytype)                   \
+    typeinfo_init_classinfo(&(info),primitivetype_table[arraytype].arrayclass);
+
+/* macros for copying types (destinition is not checked or freed) ***********/
+
+/* TYPEINFO_COPY makes a shallow copy, the merged pointer is simply copied. */
+#define TYPEINFO_COPY(src,dst)                                  \
+    do {(dst) = (src);} while(0)
+
+/* TYPEINFO_CLONE makes a deep copy, the merged list (if any) is duplicated
+ * into a newly allocated array.
+ */
+#define TYPEINFO_CLONE(src,dst)                                 \
+    do {(dst) = (src);                                          \
+        if ((dst).merged) typeinfo_clone(&(src),&(dst));} while(0)
+
+/****************************************************************************/
+/* FUNCTIONS                                                                */
+/****************************************************************************/
+
+#ifdef __cplusplus
+extern "C" { 
+#endif
+
+/* typevector functions *****************************************************/
+
+/* element read-only access */
+bool typevector_checktype(varinfo *set,int index,int type);
+bool typevector_checkreference(varinfo *set,int index);
+bool typevector_checkretaddr(varinfo *set,int index);
+
+/* element write access */
+void typevector_store(varinfo *set,int index,int type,typeinfo_t *info);
+void typevector_store_retaddr(varinfo *set,int index,typeinfo_t *info);
+bool typevector_init_object(varinfo *set,void *ins,classref_or_classinfo initclass,int size);
+
+/* vector functions */
+varinfo *typevector_copy(varinfo *src,int size);
+void typevector_copy_inplace(varinfo *src,varinfo *dst,int size);
+typecheck_result typevector_merge(methodinfo *m,varinfo *dst,varinfo *y,int size);
+
+/* inquiry functions (read-only) ********************************************/
+
+bool typeinfo_is_array(typeinfo_t *info);
+bool typeinfo_is_primitive_array(typeinfo_t *info,int arraytype);
+bool typeinfo_is_array_of_refs(typeinfo_t *info);
+
+typecheck_result typeinfo_is_assignable(typeinfo_t *value,typeinfo_t *dest);
+typecheck_result typeinfo_is_assignable_to_class(typeinfo_t *value,classref_or_classinfo dest);
+
+/* initialization functions *************************************************/
+
+/* RETURN VALUE (bool):
+ *     true.............ok,
+ *     false............an exception has been thrown.
+ *
+ * RETURN VALUE (int):
+ *     >= 0.............ok,
+ *     -1...............an exception has been thrown.
+ */
+void typeinfo_init_classinfo(typeinfo_t *info,classinfo *c);
+bool typeinfo_init_class(typeinfo_t *info,classref_or_classinfo c);
+bool typeinfo_init_component(typeinfo_t *srcarray,typeinfo_t *dst);
+
+bool typeinfo_init_from_typedesc(typedesc *desc,u1 *type,typeinfo_t *info);
+bool typeinfos_init_from_methoddesc(methoddesc *desc,u1 *typebuf,
+                                   typeinfo_t *infobuf,
+                                   int buflen,bool twoword,
+                                   u1 *returntype,typeinfo_t *returntypeinfo);
+bool  typedescriptor_init_from_typedesc(typedescriptor_t *td,
+                                                                           typedesc *desc);
+bool  typeinfo_init_varinfo_from_typedesc(varinfo *var,
+                                                                           typedesc *desc);
+int  typedescriptors_init_from_methoddesc(typedescriptor_t *td,
+                                                                                 methoddesc *desc,
+                                                                                 int buflen,bool twoword,int startindex,
+                                                                                 typedescriptor_t *returntype);
+bool typeinfo_init_varinfos_from_methoddesc(varinfo *vars,
+                                                                                 methoddesc *desc,
+                                                                                 int buflen, int startindex,
+                                                                                 s4 *map,
+                                                                                 typedescriptor_t *returntype);
+
+void typeinfo_clone(typeinfo_t *src,typeinfo_t *dest);
+
+/* freeing memory ***********************************************************/
+
+void typeinfo_free(typeinfo_t *info);
+
+/* functions for merging types **********************************************/
+
+typecheck_result typeinfo_merge(methodinfo *m,typeinfo_t *dest,typeinfo_t* y);
+
+/* debugging helpers ********************************************************/
+
+#ifdef TYPEINFO_DEBUG
+
+#include <stdio.h>
+
+void typeinfo_test();
+void typeinfo_print_class(FILE *file,classref_or_classinfo c);
+void typeinfo_print(FILE *file,typeinfo_t *info,int indent);
+void typeinfo_print_short(FILE *file,typeinfo_t *info);
+void typeinfo_print_type(FILE *file,int type,typeinfo_t *info);
+void typedescriptor_print(FILE *file,typedescriptor_t *td);
+void typevector_print(FILE *file,varinfo *vec,int size);
+
+#endif /* TYPEINFO_DEBUG */
+
+#ifdef __cplusplus
+} 
+#endif
+
+#endif /* _TYPEINFO_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:
+ */
index 839f39c7bcef3faf045f13b81974c4071f50968f..354c92ec1f3ca273b4dde3dacf3d225f1a381498 100644 (file)
@@ -28,15 +28,16 @@ LIBS =
 
 DIST_SUBDIRS = \
        freebsd \
-       linux
+       linux \
+       solaris
 
 SUBDIRS = $(OS_DIR)
 
 noinst_HEADERS = \
        arch.h \
-       machine-instr.h \
        \
-       md-asm.h
+       md-asm.h \
+       md-atomic.hpp
 
 noinst_LTLIBRARIES = libarch.la
 
@@ -56,6 +57,7 @@ libarch_la_SOURCES = \
        \
        md-abi.c \
        md-abi.h \
+       md-stubs.hpp \
        md-trap.h \
        md.c \
        md.h
index 4144b4f197527f6974275e26a9daac6b3fce81d3..7bd7d809de65cc93262764c3d4cd06506cf60d7e 100644 (file)
@@ -35,8 +35,6 @@
 
 /* define architecture features ***********************************************/
 
-#define U8_AVAILABLE                     1
-
 #define SUPPORT_DIVISION                 1
 #define SUPPORT_LONG                     1
 
index 4f7a69f9fa074b5c22ccfaed0c05c59ea077b545..5807491ecbac01e65242b9c65be0c10615d4faaa 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/x86_64/asmpart.S - Java-C interface functions for x86_64
 
-   Copyright (C) 1996-2005, 2006, 2007, 2008 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.
 
@@ -58,9 +56,6 @@
        .globl asm_builtin_d2i
        .globl asm_builtin_d2l
 
-       .globl asm_compare_and_swap
-       .globl asm_memory_barrier
-
        .globl asm_get_cycle_count
 
 
@@ -394,30 +389,6 @@ asm_builtin_d2l:
        ret
 
 
-/* asm_compare_and_swap ********************************************************
-
-   Does an atomic compare and swap.  Required for the lock
-   implementation.
-
-*******************************************************************************/
-
-asm_compare_and_swap:
-       mov     a1,v0                       /* v0 is %rax                         */
-       lock cmpxchg a2,(a0)
-       ret
-
-
-/* asm_memory_barrier **********************************************************
-
-   A memory barrier for the Java Memory Model.
-
-*******************************************************************************/
-
-asm_memory_barrier:
-       mfence
-       ret
-
-
 /* asm_get_cycle_count *********************************************************
 
    Get the current time-stamp counter from the CPU.
index e9f2c2828cbb429c0de2b5eeb99a4a52cf77d7d0..96f4967bc9f052f7a74ea741adf8dee33a2389bd 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/x86_64/codegen.c - machine code generator for x86_64
 
-   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.
 
 
 #include "mm/memory.h"
 
-#include "native/jni.h"
-#include "native/localref.h"
-#include "native/native.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/primitive.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/statistics.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/code.hpp"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/methodheader.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/parse.hpp"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
 #include "vm/jit/trap.h"
 
 #if defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
 #endif
 
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-
 
 /* codegen_emit ****************************************************************
 
@@ -1889,8 +1885,8 @@ bool codegen_emit(jitdata *jd)
                                if (IS_IMM32(iptr->sx.s23.s2.constval))
                                        M_LST_IMM32(iptr->sx.s23.s2.constval, REG_ITMP1, 0);
                                else {
-                                       M_IST_IMM(iptr->sx.s23.s2.constval, REG_ITMP1, 0);
-                                       M_IST_IMM(iptr->sx.s23.s2.constval >> 32, REG_ITMP1, 4);
+                                       M_MOV_IMM(iptr->sx.s23.s2.constval, REG_ITMP2);
+                                       M_LST(REG_ITMP2, REG_ITMP1, 0);
                                }
                                break;
                        }
@@ -2012,9 +2008,12 @@ bool codegen_emit(jitdata *jd)
                        case TYPE_LNG:
                        case TYPE_ADR:
                        case TYPE_DBL:
-                               /* XXX why no check for IS_IMM32? */
-                               M_IST32_IMM(iptr->sx.s23.s2.constval, s1, disp);
-                               M_IST32_IMM(iptr->sx.s23.s2.constval >> 32, s1, disp + 4);
+                               /* XXX why no check for IS_IMM32? -- probably because of the patcher */
+                               M_MOV_IMM(iptr->sx.s23.s2.constval, REG_ITMP2);
+                               if (disp)  /* resolved, disp can never be 0 */
+                                       M_LST(REG_ITMP2, s1, disp);
+                               else       /* unresolved */
+                                       M_LST32(REG_ITMP2, s1, disp);
                                break;
                        }
                        break;
@@ -3075,7 +3074,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
                /* put env into first argument register */
 
-               M_MOV_IMM(_Jv_env, REG_A0);
+               M_MOV_IMM(VM_get_jnienv(), REG_A0);
        }
 
        /* Call the native function. */
@@ -3090,7 +3089,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
        case TYPE_INT:
        case TYPE_LNG:
        case TYPE_ADR:
-               switch (md->returntype.decltype) {
+               switch (md->returntype.primitivetype) {
                case PRIMITIVETYPE_BOOLEAN:
                        M_BZEXT(REG_RESULT, REG_RESULT);
                        break;
index e4c3d1c0fadc48da63d43dd98c6c54637fbb5b3f..cb073729dd0d69d438a67e1263d05e340a0d4f3a 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/x86_64/codegen.h - code generation macros for x86_64
 
-   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.
 
@@ -36,7 +34,7 @@
 
 #include "vm/jit/x86_64/emit.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* additional functions and macros to generate code ***************************/
     } while (0)
 
 
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE    8
-
-
 /* macros to create code ******************************************************/
 
 #define M_BYTE1(a) \
index ba1766fe3dc71857532bac132ded718fa5ec76f8..9c777fb54a558b0545c5177ea11a2fdea6107ae3 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/x86_64/emit.c - x86_64 code emitter functions
 
-   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.
 
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
+
+#include "vm/options.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/trace.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/options.h"
-
 
 /* emit_load *******************************************************************
 
@@ -110,7 +108,7 @@ s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
     
 *******************************************************************************/
 
-inline void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
+void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
 {
        codegendata  *cd;
        s4            disp;
index a53ca05b2142215e742be0cd423b6aef9e2822a6..4a1cb4c9884a8998b53b94a92ec8c6321a13abee 100644 (file)
@@ -31,8 +31,8 @@
 #include "config.h"
 #include "vm/types.h"
 
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/jit.hpp"
 
 
 /* macros to create code ******************************************************/
index 6e4a2b227853841547c3ab343db497ff64399165..4b683342a409e8298af3c8e412e57cb0b6db21e5 100644 (file)
 #include <stdlib.h>
 #include <ucontext.h>
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
 #include "vm/signallocal.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
@@ -129,25 +129,6 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 #endif
 
 
-#if defined(ENABLE_THREADS)
-void thread_restartcriticalsection(ucontext_t *_uc)
-{
-       mcontext_t *_mc;
-       u1         *pc;
-       void       *critical;
-
-       _mc = &_uc->uc_mcontext;
-
-       pc = (u1 *) _mc->mc_rip;
-
-       critical = critical_find_restart_point(pc);
-
-       if (critical != NULL)
-               _mc->mc_rip = (ptrint) critical;
-}
-#endif
-
-
 /*
  * 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
index 8b8bf32d51f1a44dc0e920b70370ba58d2dd31b5..5036ff2ef64da28a635ca2bb0d7f61670ae04b61 100644 (file)
 #include "vm/jit/x86_64/codegen.h"
 #include "vm/jit/x86_64/md.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
+#include "vm/jit/builtin.hpp"
 #include "vm/signallocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
 #include "vm/jit/trap.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/stacktrace.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
@@ -70,7 +70,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        int             type;
        intptr_t        val;
        void           *p;
-       java_object_t  *o;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -187,23 +186,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        if (type == TRAP_COMPILER) {
                if (p == NULL) {
-                       o = builtin_retrieve_exception();
-
                        _mc->gregs[REG_RSP] = (uintptr_t) sp;    /* Remove RA from stack. */
-
-                       _mc->gregs[REG_RAX] = (uintptr_t) o;
-                       _mc->gregs[REG_R10] = (uintptr_t) xpc;           /* REG_ITMP2_XPC */
-                       _mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception;
-               }
-               else {
-                       _mc->gregs[REG_RIP] = (uintptr_t) p;
                }
        }
-       else {
-               _mc->gregs[REG_RAX] = (uintptr_t) p;
-               _mc->gregs[REG_R10] = (uintptr_t) xpc;               /* REG_ITMP2_XPC */
-               _mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception;
-       }
 }
 
 
@@ -224,7 +209,6 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
        u1             *xpc;
        int             type;
        intptr_t        val;
-       void           *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -244,13 +228,7 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* set registers */
-
-       _mc->gregs[REG_RAX] = (intptr_t) p;
-       _mc->gregs[REG_R10] = (intptr_t) xpc;                    /* REG_ITMP2_XPC */
-       _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception;
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -270,7 +248,6 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
        u1             *xpc;
        int             type;
        intptr_t        val;
-       void           *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -290,15 +267,7 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* set registers */
-
-       if (p != NULL) {
-               _mc->gregs[REG_RAX] = (intptr_t) p;
-               _mc->gregs[REG_R10] = (intptr_t) xpc;                /* REG_ITMP2_XPC */
-               _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception;
-       }
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -498,35 +467,6 @@ void md_executionstate_write(executionstate_t *es, void *context)
 }
 
 
-/* md_critical_section_restart *************************************************
-
-   Search the critical sections tree for a matching section and set
-   the PC to the restart point, if necessary.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
-{
-       mcontext_t *_mc;
-       u1         *pc;
-       u1         *npc;
-
-       _mc = &_uc->uc_mcontext;
-
-       /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
-          different to the ones in <ucontext.h>. */
-
-       pc = (u1 *) _mc->gregs[REG_RIP];
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL)
-               _mc->gregs[REG_RIP] = (ptrint) npc;
-}
-#endif
-
-
 /*
  * 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
diff --git a/src/vm/jit/x86_64/machine-instr.h b/src/vm/jit/x86_64/machine-instr.h
deleted file mode 100644 (file)
index 3afe548..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef _MACHINE_INSTR_H
-#define _MACHINE_INSTR_H
-
-static inline long
-__attribute__ ((unused))
-compare_and_swap (volatile long *p, long oldval, long newval)
-{
-  long ret;
-
-  __asm__ __volatile__ ("lock; cmpxchgq %2, %1"
-                        : "=a" (ret), "=m" (*p)
-                        : "r" (newval), "m" (*p), "0" (oldval));
-  return ret;
-}
-
-#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory");
-#define MEMORY_BARRIER_AFTER_ATOMIC() /* nothing */
-#define MEMORY_BARRIER() __asm__ __volatile__ ( \
-               "mfence" : : : "memory" );
-
-#endif
index 9ae511b14cf585da2310a9ee858cabc74953fd4b..fd248a596b4743b2fee491ed2acc697a56b58653 100644 (file)
 
 #include "vm/jit/x86_64/md-abi.h"
 
+#include "vm/descriptor.h"
 #include "vm/global.h"
 
 #include "vm/jit/abi.h"
-#include "vm/jit/jit.h" /* for REG_* (maybe can be removed) */
+#include "vm/jit/jit.hpp" /* for REG_* (maybe can be removed) */
 #include "vm/jit/stack.h"
 
-#include "vmcore/descriptor.h"
-
 
 /* register descripton array **************************************************/
 
diff --git a/src/vm/jit/x86_64/md-atomic.hpp b/src/vm/jit/x86_64/md-atomic.hpp
new file mode 100644 (file)
index 0000000..accef01
--- /dev/null
@@ -0,0 +1,134 @@
+/* src/vm/jit/x86_64/atomic.hpp - x86_64 atomic instructions
+
+   Copyright (C) 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 _MD_ATOMIC_HPP
+#define _MD_ATOMIC_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "threads/atomic.hpp"
+
+
+/**
+ * An atomic compare and swap for 32-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
+{
+       uint32_t result;
+
+       __asm__ __volatile__ ("lock; cmpxchgl %2, %1"
+                                                 : "=a" (result), "=m" (*p)
+                                                 : "r" (newval), "m" (*p), "0" (oldval));
+
+       return result;
+}
+
+
+/**
+ * An atomic compare and swap for 64-bit integer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
+{
+       uint64_t result;
+
+       __asm__ __volatile__ ("lock; cmpxchgq %2, %1"
+                                                 : "=a" (result), "=m" (*p)
+                                                 : "r" (newval), "m" (*p), "0" (oldval));
+
+       return result;
+}
+
+
+/**
+ * An atomic compare and swap for pointer values.
+ *
+ * @param p      Pointer to memory address.
+ * @param oldval Old value to be expected.
+ * @param newval New value to be stored.
+ *
+ * @return value of the memory location before the store
+ */
+inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval)
+{
+       return (void*) compare_and_swap((volatile uint64_t*) p, (uint64_t) oldval, (uint64_t) newval);
+}
+
+
+/**
+ * A memory barrier.
+ */
+inline void Atomic::memory_barrier(void)
+{
+       __asm__ __volatile__ ("mfence" : : : "memory");
+}
+
+
+/**
+ * A write memory barrier.
+ */
+inline void Atomic::write_memory_barrier(void)
+{
+       __asm__ __volatile__ ("" : : : "memory");
+}
+
+
+/**
+ * An instruction barrier.
+ */
+inline void Atomic::instruction_barrier(void)
+{
+       // Nothing.
+}
+
+#endif // _MD_ATOMIC_HPP
+
+
+/*
+ * 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/jit/x86_64/md-stubs.hpp b/src/vm/jit/x86_64/md-stubs.hpp
new file mode 100644 (file)
index 0000000..521a814
--- /dev/null
@@ -0,0 +1,56 @@
+/* src/vm/jit/x86_64/md-stubs.hpp - x86_64 JIT stubs
+
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a x86_64 architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+       return 8;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * 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 6493e3559c089bf6333168e9bab0529a2b586943..c78e31b9540031ca1567b81d8b9a6803662dfc60 100644 (file)
@@ -58,6 +58,7 @@ enum {
        /* Don't use 8 (could be a normal load offset). */
 
        TRAP_COMPILER                       = 9,
+       TRAP_COUNTDOWN                      = 10,
        TRAP_END
 };
 
index dc4b3fab1820ca149ac1d34817c35a15200c9e92..586550cfd485340406a80c301f65564c815e50f2 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/x86_64/md.c - machine dependent x86_64 functions
 
-   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.
 
 
 #include "vm/jit/x86_64/md-abi.h"
 
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/jit.hpp"
 
 
 /* md_init *********************************************************************
index f60e9720f6ba583088a9c6257c161879b7ed3439..6495479a83f794fcdccf442809275630f85cf087 100644 (file)
@@ -1,6 +1,7 @@
 /* src/vm/jit/x86_64/md.h - machine dependent x86_64 functions
 
    Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -30,7 +31,7 @@
 #include <assert.h>
 #include <stdint.h>
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/methodtree.h"
 
 
@@ -82,9 +83,10 @@ inline static void *md_codegen_get_pv_from_pc(void *ra)
 
 *******************************************************************************/
 
-inline static void md_cacheflush(u1 *addr, s4 nbytes)
+inline static void md_cacheflush(void* addr, int nbytes)
 {
-       /* do nothing */
+       // Compiler optimization barrier (see PR97).
+       __asm__ __volatile__ ("" : : : "memory");
 }
 
 
@@ -94,9 +96,10 @@ inline static void md_cacheflush(u1 *addr, s4 nbytes)
 
 *******************************************************************************/
 
-inline static void md_icacheflush(u1 *addr, s4 nbytes)
+inline static void md_icacheflush(void* addr, int nbytes)
 {
-       /* do nothing */
+       // Compiler optimization barrier (see PR97).
+       __asm__ __volatile__ ("" : : : "memory");
 }
 
 
@@ -106,9 +109,10 @@ inline static void md_icacheflush(u1 *addr, s4 nbytes)
 
 *******************************************************************************/
 
-inline static void md_dcacheflush(u1 *addr, s4 nbytes)
+inline static void md_dcacheflush(void* addr, int nbytes)
 {
-       /* do nothing */
+       // Compiler optimization barrier (see PR97).
+       __asm__ __volatile__ ("" : : : "memory");
 }
 
 #endif /* _VM_JIT_X86_64_MD_H */
index 2ab929aaf413c546d722f315c9e416adf84140df..32008300ec1111a032adfaa2beb18ff5375101e1 100644 (file)
 #include "vm/types.h"
 
 #include "vm/jit/x86_64/codegen.h"
+#include "vm/jit/x86_64/md.h"
 
 #include "mm/memory.h"
 
-#include "native/native.h"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
 
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vmcore/references.h"
-#include "vm/resolve.h"
-
-
-#define PATCH_BACK_ORIGINAL_MCODE \
-    do { \
-        *((uint16_t *) pr->mpc) = (uint16_t) pr->mcode; \
-    } while (0)
+#include "vm/jit/patcher-common.hpp"
 
 
 /* patcher_patch_code **********************************************************
@@ -63,7 +55,8 @@
 
 void patcher_patch_code(patchref_t *pr)
 {
-       PATCH_BACK_ORIGINAL_MCODE;
+       *((uint16_t*) pr->mpc) = (uint16_t) pr->mcode;
+       md_icacheflush((void*) pr->mpc, PATCHER_CALL_SIZE);
 }
 
 
@@ -93,23 +86,23 @@ void patcher_patch_code(patchref_t *pr)
 
 bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
 {
-       constant_classref *cr;
-       intptr_t          *datap;
-       classinfo         *c;
-
-       cr    = (constant_classref *) pr->ref;
-       datap = (intptr_t *)          pr->datap;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)         pr->datap;
 
-       /* get the classinfo */
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
+       // Patch the class.
+       *datap = (uintptr_t) c;
 
-       /* patch the classinfo pointer */
+       // Synchronize data cache.
+       md_dcacheflush((void*) pr->datap, SIZEOF_VOID_P);
 
-       *datap = (intptr_t) c;
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -126,25 +119,23 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
 
 bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
 {
-       constant_classref *cr;
-       intptr_t          *datap;
-       classinfo         *c;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)         pr->datap;
 
-       /* get stuff from the stack */
+       // Resolve the field.
+       classinfo* c = resolve_classref_eager(cr);
 
-       cr    = (constant_classref *) pr->ref;
-       datap = (intptr_t *)          pr->datap;
-
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
+       // Patch super class' vftbl.
+       *datap = (uintptr_t) c->vftbl;
 
-       /* patch super class' vftbl */
+       // Synchronize data cache.
+       md_dcacheflush((void*) pr->datap, SIZEOF_VOID_P);
 
-       *datap = (intptr_t) c->vftbl;
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -160,31 +151,26 @@ bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
 
 bool patcher_resolve_classref_to_flags(patchref_t *pr)
 {
-       constant_classref *cr;
-       int32_t           *datap;
-       classinfo         *c;
-       uint8_t           *ra;
-
-       cr    = (constant_classref *) pr->ref;
-       datap = (int32_t *)           pr->datap;
-       ra    = (uint8_t *)           pr->mpc;
+       constant_classref* cr    = (constant_classref*) pr->ref;
+/*     int32_t*           datap = (int32_t*)           pr->datap; */
+       uint8_t*           ra    = (uint8_t*)           pr->mpc;
 
-       /* get the fieldinfo */
+       // Resolve the field.
+       classinfo* c = resolve_classref_eager(cr);
 
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
+       // Patch class flags.
+/*     *datap = c->flags; */
+       *((int32_t*) (ra + 2)) = c->flags;
 
-       /* patch class flags */
+       // Synchronize data cache.
+/*     md_dcacheflush(datap, sizeof(int32_t)); */
+       md_icacheflush(ra + 2, sizeof(int32_t));
 
-/*     *datap = c->flags; */
-       *((int32_t *) (ra + 2)) = c->flags;
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -202,29 +188,28 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr)
 
 bool patcher_get_putstatic(patchref_t *pr)
 {
-       unresolved_field *uf;
-       intptr_t         *datap;
-       fieldinfo        *fi;
-
-       uf    = (unresolved_field *) pr->ref;
-       datap = (intptr_t *)         pr->datap;
+       unresolved_field* uf    = (unresolved_field*) pr->ref;
+       uintptr_t*        datap = (uintptr_t*)        pr->datap;
 
-       /* get the fieldinfo */
+       // Resolve the field.
+       fieldinfo* fi = resolve_field_eager(uf);
 
-       if (!(fi = resolve_field_eager(uf)))
+       if (fi == NULL)
                return false;
 
-       /* check if the field's class is initialized */
-
+       // Check if the field's class is initialized/
        if (!(fi->clazz->state & CLASS_INITIALIZED))
                if (!initialize_class(fi->clazz))
                        return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
+       // Patch the field value's address.
+       *datap = (uintptr_t) fi->value;
 
-       /* patch the field value's address */
+       // Synchronize data cache.
+       md_dcacheflush((void*) pr->datap, SIZEOF_VOID_P);
 
-       *datap = (intptr_t) fi->value;
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -241,50 +226,38 @@ bool patcher_get_putstatic(patchref_t *pr)
 
 bool patcher_get_putfield(patchref_t *pr)
 {
-       uint8_t          *ra;
-       unresolved_field *uf;
-       fieldinfo        *fi;
-       uint8_t           byte;
+       uint8_t*          pc = (uint8_t*)          pr->mpc;
+       unresolved_field* uf = (unresolved_field*) pr->ref;
 
-       ra = (uint8_t *)          pr->mpc;
-       uf = (unresolved_field *) pr->ref;
+       // Resolve the field.
+       fieldinfo* fi = resolve_field_eager(uf);
 
-       /* get the fieldinfo */
-
-       if (!(fi = resolve_field_eager(uf)))
+       if (fi == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
-       /* Patch the field's offset: we check for the field type, because
-          the instructions have different lengths. */
-
+       // Patch the field's offset: we check for the field type, because
+       // the instructions have different lengths.
        if (IS_INT_LNG_TYPE(fi->type)) {
-               /* Check for special case: %rsp or %r12 as base register. */
-
-               byte = *(ra + 3);
-
-               if (byte == 0x24)
-                       *((int32_t *) (ra + 4)) = fi->offset;
+               // Check for special case: %rsp or %r12 as base register.
+               if (pc[3] == 0x24)
+                       *((int32_t*) (pc + 4)) = fi->offset;
                else
-                       *((int32_t *) (ra + 3)) = fi->offset;
+                       *((int32_t*) (pc + 3)) = fi->offset;
        }
        else {
-               /* Check for special case: %rsp or %r12 as base register. */
-
-               byte = *(ra + 5);
-
-               if (byte == 0x24)
-                       *((int32_t *) (ra + 6)) = fi->offset;
+               // Check for special case: %rsp or %r12 as base register.
+               if (pc[5] == 0x24)
+                       *((int32_t*) (pc + 6)) = fi->offset;
                else
-                       *((int32_t *) (ra + 5)) = fi->offset;
+                       *((int32_t*) (pc + 5)) = fi->offset;
        }
 
+       // Synchronize instruction cache.
+       md_icacheflush(pc, 6 + sizeof(int32_t));
+
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -300,53 +273,37 @@ bool patcher_get_putfield(patchref_t *pr)
 
 bool patcher_putfieldconst(patchref_t *pr)
 {
-       uint8_t          *ra;
-       unresolved_field *uf;
-       fieldinfo        *fi;
-       uint8_t           byte;
-
-       ra = (uint8_t *)          pr->mpc;
-       uf = (unresolved_field *) pr->ref;
+       uint8_t*          pc = (uint8_t*)          pr->mpc;
+       unresolved_field* uf = (unresolved_field*) pr->ref;
 
-       /* get the fieldinfo */
+       // Resolve the field.
+       fieldinfo* fi = resolve_field_eager(uf);
 
-       if (!(fi = resolve_field_eager(uf)))
+       if (fi == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
-       /* patch the field's offset */
-
+       // Patch the field's offset.
        if (IS_2_WORD_TYPE(fi->type) || IS_ADR_TYPE(fi->type)) {
-               /* handle special case when the base register is %r12 */
-
-               byte = *(ra + 2);
-
-               if (byte == 0x84) {
-                       *((uint32_t *) (ra + 4))      = fi->offset;
-                       *((uint32_t *) (ra + 12 + 4)) = fi->offset + 4;
-               }
-               else {
-                       *((uint32_t *) (ra + 3))      = fi->offset;
-                       *((uint32_t *) (ra + 11 + 3)) = fi->offset + 4;
-               }
+               // Handle special case when the base register is %r12.
+               if (pc[12] == 0x94)
+                       *((uint32_t*) (pc + 14)) = fi->offset;
+               else
+                       *((uint32_t*) (pc + 13)) = fi->offset;
        }
        else {
-               /* handle special case when the base register is %r12 */
-
-               byte = *(ra + 2);
-
-               if (byte == 0x84)
-                       *((uint32_t *) (ra + 4)) = fi->offset;
+               // Handle special case when the base register is %r12.
+               if (pc[2] == 0x84)
+                       *((uint32_t*) (pc + 4)) = fi->offset;
                else
-                       *((uint32_t *) (ra + 3)) = fi->offset;
+                       *((uint32_t*) (pc + 3)) = fi->offset;
        }
 
+       // Synchronize instruction cache.
+       md_icacheflush(pc, 14 + sizeof(int32_t));
+
+       // Patch back the original code.
+       patcher_patch_code(pr);
+
        return true;
 }
 
@@ -363,25 +320,23 @@ bool patcher_putfieldconst(patchref_t *pr)
 
 bool patcher_invokestatic_special(patchref_t *pr)
 {
-       unresolved_method *um;
-       intptr_t          *datap;
-       methodinfo        *m;
-
-       /* get stuff from the stack */
+       unresolved_method* um    = (unresolved_method*) pr->ref;
+       uintptr_t*         datap = (uintptr_t*)         pr->datap;
 
-       um    = (unresolved_method *) pr->ref;
-       datap = (intptr_t *)          pr->datap;
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       /* get the fieldinfo */
-
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
+       // Patch stubroutine.
+       *datap = (uintptr_t) m->stubroutine;
 
-       /* patch stubroutine */
+       // Synchronize data cache.
+       md_dcacheflush((void*) pr->datap, SIZEOF_VOID_P);
 
-       *datap = (intptr_t) m->stubroutine;
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -400,30 +355,23 @@ bool patcher_invokestatic_special(patchref_t *pr)
 
 bool patcher_invokevirtual(patchref_t *pr)
 {
-       uint8_t           *ra;
-       unresolved_method *um;
-       methodinfo        *m;
-
-       ra = (uint8_t *)           pr->mpc;
-       um = (unresolved_method *) pr->ref;
+       uint8_t*           pc = (uint8_t*)           pr->mpc;
+       unresolved_method* um = (unresolved_method*) pr->ref;
 
-       /* get the methodinfo */
+       // Resovlve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
+       // Patch vftbl index.
+       *((int32_t*) (pc + 3 + 3)) = (int32_t) (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex);
 
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 3 + 3, SIZEOF_VOID_P);
 
-       /* patch vftbl index */
-
-       *((int32_t *) (ra + 3 + 3)) =
-               (int32_t) (OFFSET(vftbl_t, table[0]) +
-                                  sizeof(methodptr) * m->vftblindex);
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -443,37 +391,26 @@ bool patcher_invokevirtual(patchref_t *pr)
 
 bool patcher_invokeinterface(patchref_t *pr)
 {
-       uint8_t           *ra;
-       unresolved_method *um;
-       methodinfo        *m;
-
-       /* get stuff from the stack */
-
-       ra = (uint8_t *)           pr->mpc;
-       um = (unresolved_method *) pr->ref;
+       uint8_t*           pc = (uint8_t*)           pr->mpc;
+       unresolved_method* um = (unresolved_method*) pr->ref;
 
-       /* get the fieldinfo */
+       // Resolve the method.
+       methodinfo* m = resolve_method_eager(um);
 
-       if (!(m = resolve_method_eager(um)))
+       if (m == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
-       /* patch interfacetable index */
+       // Patch interfacetable index.
+       *((int32_t*) (pc + 3 + 3)) = (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr) * m->clazz->index);
 
-       *((int32_t *) (ra + 3 + 3)) =
-               (int32_t) (OFFSET(vftbl_t, interfacetable[0]) -
-                                  sizeof(methodptr) * m->clazz->index);
+       // Patch method offset.
+       *((int32_t*) (pc + 3 + 7 + 3)) = (int32_t) (sizeof(methodptr) * (m - m->clazz->methods));
 
-       /* patch method offset */
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 3 + 3, SIZEOF_VOID_P + 3 + SIZEOF_VOID_P);
 
-       *((int32_t *) (ra + 3 + 7 + 3)) =
-               (int32_t) (sizeof(methodptr) * (m - m->clazz->methods));
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -494,32 +431,25 @@ bool patcher_invokeinterface(patchref_t *pr)
 
 bool patcher_checkcast_interface(patchref_t *pr)
 {
-       uint8_t           *ra;
-       constant_classref *cr;
-       classinfo         *c;
+       uint8_t*           pc = (uint8_t*)           pr->mpc;
+       constant_classref* cr = (constant_classref*) pr->ref;
 
-       ra = (uint8_t *)           pr->mpc;
-       cr = (constant_classref *) pr->ref;
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
+       // Patch super class index.
+       *((int32_t*) (pc + 7 + 3)) = c->index;
 
-       /* patch super class index */
+       *((int32_t*) (pc + 7 + 7 + 6 + 8 + 3)) = (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*));
 
-       *((int32_t *) (ra + 7 + 3)) = c->index;
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 7 + 3, sizeof(int32_t) + 6 + 8 + 3 + sizeof(int32_t));
 
-       *((int32_t *) (ra + 7 + 7 + 6 + 8 + 3)) =
-               (int32_t) (OFFSET(vftbl_t, interfacetable[0]) -
-                                  c->index * sizeof(methodptr*));
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
@@ -539,32 +469,25 @@ bool patcher_checkcast_interface(patchref_t *pr)
 
 bool patcher_instanceof_interface(patchref_t *pr)
 {
-       uint8_t           *ra;
-       constant_classref *cr;
-       classinfo         *c;
+       uint8_t*           pc = (uint8_t*)           pr->mpc;
+       constant_classref* cr = (constant_classref*) pr->ref;
 
-       ra = (uint8_t *)           pr->mpc;
-       cr = (constant_classref *) pr->ref;
+       // Resolve the class.
+       classinfo* c = resolve_classref_eager(cr);
 
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr)))
+       if (c == NULL)
                return false;
 
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
+       // Patch super class index.
+       *((int32_t*) (pc + 7 + 3)) = c->index;
 
-       /* patch super class index */
+       *((int32_t*) (pc + 7 + 7 + 6 + 3)) = (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*));
 
-       *((int32_t *) (ra + 7 + 3)) = c->index;
+       // Synchronize instruction cache.
+       md_icacheflush(pc + 7 + 3, sizeof(int32_t) + 6 + 3 + sizeof(int32_t));
 
-       *((int32_t *) (ra + 7 + 7 + 6 + 3)) =
-               (int32_t) (OFFSET(vftbl_t, interfacetable[0]) -
-                                  c->index * sizeof(methodptr*));
+       // Patch back the original code.
+       patcher_patch_code(pr);
 
        return true;
 }
diff --git a/src/vm/jit/x86_64/solaris/Makefile.am b/src/vm/jit/x86_64/solaris/Makefile.am
new file mode 100644 (file)
index 0000000..aea86fd
--- /dev/null
@@ -0,0 +1,43 @@
+## src/vm/jit/x86_64/solaris/Makefile.am
+##
+## Copyright (C) 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.
+
+
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_builddir)/src
+
+LIBS =
+
+noinst_HEADERS =
+
+noinst_LTLIBRARIES = \
+       libmd.la
+
+libmd_la_SOURCES = \
+       md-os.c
+
+
+## Local variables:
+## mode: Makefile
+## indent-tabs-mode: t
+## c-basic-offset: 4
+## tab-width: 8
+## compile-command: "automake --add-missing"
+## End:
diff --git a/src/vm/jit/x86_64/solaris/md-os.c b/src/vm/jit/x86_64/solaris/md-os.c
new file mode 100644 (file)
index 0000000..14824a4
--- /dev/null
@@ -0,0 +1,525 @@
+/* src/vm/jit/x86_64/solaris/md-os.c - machine dependent x86_64 Solaris functions
+
+   Copyright (C) 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 <stdint.h>
+#include <stdlib.h>
+#include <ucontext.h>
+
+#include "vm/types.h"
+
+#include "vm/jit/x86_64/codegen.h"
+#include "vm/jit/x86_64/md.h"
+
+#include "threads/thread.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/signallocal.h"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/executionstate.h"
+#include "vm/jit/trap.h"
+#include "vm/jit/stacktrace.hpp"
+
+
+/* md_signal_handler_sigsegv ***************************************************
+
+   Signal handler for hardware exception.
+
+*******************************************************************************/
+
+void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t     *_uc;
+       mcontext_t     *_mc;
+       void           *pv;
+       u1             *sp;
+       u1             *ra;
+       u1             *xpc;
+       u1              opc;
+       u1              mod;
+       u1              rm;
+       s4              d;
+       s4              disp;
+       int             type;
+       intptr_t        val;
+       void           *p;
+       java_object_t  *o;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
+          different to the ones in <ucontext.h>. */
+
+       pv  = NULL;                 /* is resolved during stackframeinfo creation */
+       sp  = (u1 *) _mc->gregs[REG_RSP];
+       xpc = (u1 *) _mc->gregs[REG_RIP];
+       ra  = xpc;                              /* return address is equal to XPC */
+
+#if 0
+       /* check for StackOverflowException */
+
+       threads_check_stackoverflow(sp);
+#endif
+
+       /* get exception-throwing instruction */
+
+       opc = M_ALD_MEM_GET_OPC(xpc);
+       mod = M_ALD_MEM_GET_MOD(xpc);
+       rm  = M_ALD_MEM_GET_RM(xpc);
+
+       /* for values see emit_mov_mem_reg and emit_mem */
+
+       if ((opc == 0x8b) && (mod == 0) && (rm == 4)) {
+               /* this was a hardware-exception */
+
+               d    = M_ALD_MEM_GET_REG(xpc);
+               disp = M_ALD_MEM_GET_DISP(xpc);
+
+               /* we use the exception type as load displacement */
+
+               type = disp;
+
+               /* XXX FIX ME! */
+
+               /* ATTENTION: The _mc->gregs layout is even worse than on
+                  i386! See /usr/include/sys/ucontext.h.  We need a
+                  switch-case here... */
+
+               switch (d) {
+               case 0:  /* REG_RAX == 14 */
+                       d = REG_RAX;
+                       break;
+               case 1:  /* REG_RCX == 13 */
+                       d = REG_RCX;
+                       break;
+               case 2:  /* REG_RDX == 12 */
+                       d = REG_RDX;
+                       break;
+               case 3:  /* REG_RBX == 11 */
+                       d = REG_RBX;
+                       break;
+               case 4:  /* REG_RSP == 20 */
+                       d = REG_RSP;
+                       break;
+               case 5:  /* REG_RBP == 10 */
+                       d = REG_RBP;
+                       break;
+               case 6:  /* REG_RSI == 9  */
+                       d = REG_RSI;
+                       break;
+               case 7:  /* REG_RDI == 8  */
+                       d = REG_RDI;
+                       break;
+               case 8:  /* REG_R8  == 7  */
+                       d = REG_R8;
+                       break;
+               case 9:  /* REG_R9  == 6  */
+                       d = REG_R9;
+                       break;
+               case 10: /* REG_R10 == 5  */
+                       d = REG_R10;
+                       break;
+               case 11: /* REG_R11 == 4  */
+                       d = REG_R11;
+                       break;
+               case 12: /* REG_R12 == 3  */
+                       d = REG_R12;
+                       break;
+               case 13: /* REG_R13 == 2  */
+                       d = REG_R13;
+                       break;
+               case 14: /* REG_R14 == 1  */
+                       d = REG_R14;
+                       break;
+               case 15: /* REG_R15 == 0  */
+                       d = REG_R15;
+                       break;
+               }
+
+               val = _mc->gregs[d];
+
+               if (type == TRAP_COMPILER) {
+                       /* The PV from the compiler stub is equal to the XPC. */
+
+                       pv = xpc;
+
+                       /* We use a framesize of zero here because the call pushed
+                          the return addres onto the stack. */
+
+                       ra = md_stacktrace_get_returnaddress(sp, 0);
+
+                       /* Skip the RA on the stack. */
+
+                       sp = sp + 1 * SIZEOF_VOID_P;
+
+                       /* The XPC is the RA minus 1, because the RA points to the
+                          instruction after the call. */
+
+                       xpc = ra - 3;
+               }
+       }
+       else {
+               /* this was a normal NPE */
+
+               type = TRAP_NullPointerException;
+               val  = 0;
+       }
+
+       /* Handle the trap. */
+
+       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
+
+       /* Set registers. */
+
+       if (type == TRAP_COMPILER) {
+               if (p == NULL) {
+                       o = builtin_retrieve_exception();
+
+                       _mc->gregs[REG_RSP] = (uintptr_t) sp;    /* Remove RA from stack. */
+
+                       _mc->gregs[REG_RAX] = (uintptr_t) o;
+                       _mc->gregs[REG_R10] = (uintptr_t) xpc;           /* REG_ITMP2_XPC */
+                       _mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception;
+               }
+               else {
+                       _mc->gregs[REG_RIP] = (uintptr_t) p;
+               }
+       }
+       else {
+               _mc->gregs[REG_RAX] = (uintptr_t) p;
+               _mc->gregs[REG_R10] = (uintptr_t) xpc;               /* REG_ITMP2_XPC */
+               _mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception;
+       }
+}
+
+
+/* md_signal_handler_sigfpe ****************************************************
+
+   ArithmeticException signal handler for hardware divide by zero
+   check.
+
+*******************************************************************************/
+
+void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t     *_uc;
+       mcontext_t     *_mc;
+       u1             *pv;
+       u1             *sp;
+       u1             *ra;
+       u1             *xpc;
+       int             type;
+       intptr_t        val;
+       void           *p;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
+          different to the ones in <ucontext.h>. */
+
+       pv  = NULL;
+       sp  = (u1 *) _mc->gregs[REG_RSP];
+       xpc = (u1 *) _mc->gregs[REG_RIP];
+       ra  = xpc;                          /* return address is equal to xpc     */
+
+       /* This is an ArithmeticException. */
+
+       type = TRAP_ArithmeticException;
+       val  = 0;
+
+       /* Handle the trap. */
+
+       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
+
+       /* set registers */
+
+       _mc->gregs[REG_RAX] = (intptr_t) p;
+       _mc->gregs[REG_R10] = (intptr_t) xpc;                    /* REG_ITMP2_XPC */
+       _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception;
+}
+
+
+/* md_signal_handler_sigill ****************************************************
+
+   Signal handler for patchers.
+
+*******************************************************************************/
+
+void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t     *_uc;
+       mcontext_t     *_mc;
+       u1             *pv;
+       u1             *sp;
+       u1             *ra;
+       u1             *xpc;
+       int             type;
+       intptr_t        val;
+       void           *p;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
+          different to the ones in <ucontext.h>. */
+
+       pv  = NULL;
+       sp  = (u1 *) _mc->gregs[REG_RSP];
+       xpc = (u1 *) _mc->gregs[REG_RIP];
+       ra  = xpc;                          /* return address is equal to xpc     */
+
+       /* This is a patcher. */
+
+       type = TRAP_PATCHER;
+       val  = 0;
+
+       /* Handle the trap. */
+
+       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
+
+       /* set registers */
+
+       if (p != NULL) {
+               _mc->gregs[REG_RAX] = (intptr_t) p;
+               _mc->gregs[REG_R10] = (intptr_t) xpc;                /* REG_ITMP2_XPC */
+               _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception;
+       }
+}
+
+
+/* md_signal_handler_sigusr1 ***************************************************
+
+   Signal handler for suspending threads.
+
+*******************************************************************************/
+
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+void md_signal_handler_sigusr1(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t *_uc;
+       mcontext_t *_mc;
+       u1         *pc;
+       u1         *sp;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
+          different to the ones in <ucontext.h>. */
+
+       /* get the PC and SP for this thread */
+       pc = (u1 *) _mc->gregs[REG_RIP];
+       sp = (u1 *) _mc->gregs[REG_RSP];
+
+       /* now suspend the current thread */
+       threads_suspend_ack(pc, sp);
+}
+#endif
+
+
+/* md_signal_handler_sigusr2 ***************************************************
+
+   Signal handler for profiling sampling.
+
+*******************************************************************************/
+
+#if defined(ENABLE_THREADS)
+void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
+{
+       threadobject *t;
+       ucontext_t   *_uc;
+       mcontext_t   *_mc;
+       u1           *pc;
+
+       t = THREADOBJECT;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+
+       /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
+          different to the ones in <ucontext.h>. */
+
+       pc = (u1 *) _mc->gregs[REG_RIP];
+
+       t->pc = pc;
+}
+#endif
+
+
+/* md_executionstate_read ******************************************************
+
+   Read the given context into an executionstate.
+
+*******************************************************************************/
+
+void md_executionstate_read(executionstate_t *es, void *context)
+{
+       ucontext_t *_uc;
+       mcontext_t *_mc;
+       s4          i;
+       s4          d;
+
+       _uc = (ucontext_t *) context;
+       _mc = &_uc->uc_mcontext;
+
+       /* read special registers */
+       es->pc = (u1 *) _mc->gregs[REG_RIP];
+       es->sp = (u1 *) _mc->gregs[REG_RSP];
+       es->pv = NULL;
+
+       /* read integer registers */
+       for (i = 0; i < INT_REG_CNT; i++) {
+               /* XXX FIX ME! */
+
+               switch (i) {
+               case 0:  /* REG_RAX == 13 */
+                       d = REG_RAX;
+                       break;
+               case 1:  /* REG_RCX == 14 */
+                       d = REG_RCX;
+                       break;
+               case 2:  /* REG_RDX == 12 */
+                       d = REG_RDX;
+                       break;
+               case 3:  /* REG_RBX == 11 */
+                       d = REG_RBX;
+                       break;
+               case 4:  /* REG_RSP == 15 */
+                       d = REG_RSP;
+                       break;
+               case 5:  /* REG_RBP == 10 */
+                       d = REG_RBP;
+                       break;
+               case 6:  /* REG_RSI == 9  */
+                       d = REG_RSI;
+                       break;
+               case 7:  /* REG_RDI == 8  */
+                       d = REG_RDI;
+                       break;
+               case 8:  /* REG_R8  == 0  */
+               case 9:  /* REG_R9  == 1  */
+               case 10: /* REG_R10 == 2  */
+               case 11: /* REG_R11 == 3  */
+               case 12: /* REG_R12 == 4  */
+               case 13: /* REG_R13 == 5  */
+               case 14: /* REG_R14 == 6  */
+               case 15: /* REG_R15 == 7  */
+                       d = i - 8;
+                       break;
+               }
+
+               es->intregs[i] = _mc->gregs[d];
+       }
+
+       /* read float registers */
+       for (i = 0; i < FLT_REG_CNT; i++)
+               es->fltregs[i] = 0xdeadbeefdeadbeefL;
+}
+
+
+/* md_executionstate_write *****************************************************
+
+   Write the given executionstate back to the context.
+
+*******************************************************************************/
+
+void md_executionstate_write(executionstate_t *es, void *context)
+{
+       ucontext_t *_uc;
+       mcontext_t *_mc;
+       s4          i;
+       s4          d;
+
+       _uc = (ucontext_t *) context;
+       _mc = &_uc->uc_mcontext;
+
+       /* write integer registers */
+       for (i = 0; i < INT_REG_CNT; i++) {
+               /* XXX FIX ME! */
+
+               switch (i) {
+               case 0:  /* REG_RAX == 13 */
+                       d = REG_RAX;
+                       break;
+               case 1:  /* REG_RCX == 14 */
+                       d = REG_RCX;
+                       break;
+               case 2:  /* REG_RDX == 12 */
+                       d = REG_RDX;
+                       break;
+               case 3:  /* REG_RBX == 11 */
+                       d = REG_RBX;
+                       break;
+               case 4:  /* REG_RSP == 15 */
+                       d = REG_RSP;
+                       break;
+               case 5:  /* REG_RBP == 10 */
+                       d = REG_RBP;
+                       break;
+               case 6:  /* REG_RSI == 9  */
+                       d = REG_RSI;
+                       break;
+               case 7:  /* REG_RDI == 8  */
+                       d = REG_RDI;
+                       break;
+               case 8:  /* REG_R8  == 0  */
+               case 9:  /* REG_R9  == 1  */
+               case 10: /* REG_R10 == 2  */
+               case 11: /* REG_R11 == 3  */
+               case 12: /* REG_R12 == 4  */
+               case 13: /* REG_R13 == 5  */
+               case 14: /* REG_R14 == 6  */
+               case 15: /* REG_R15 == 7  */
+                       d = i - 8;
+                       break;
+               }
+
+               _mc->gregs[d] = es->intregs[i];
+       }
+
+       /* write special registers */
+       _mc->gregs[REG_RIP] = (ptrint) es->pc;
+       _mc->gregs[REG_RSP] = (ptrint) es->sp;
+}
+
+
+/*
+ * 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/jit_interface.h b/src/vm/jit_interface.h
deleted file mode 100644 (file)
index 89fbf61..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* src/vm/jit_interface.h - prototypes of jit functions used in vm/ code
-
-   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 _JIT_INTERFACE
-#define _JIT_INTERFACE
-
-#include "config.h"
-#include "vm/types.h"
-
-
-/* These functions are used from vm/ but defined in vm/jit/ */
-
-void code_free_code_of_method(methodinfo *m);
-
-u1       *codegen_generate_stub_compiler(methodinfo *m);
-codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f);
-
-#if defined(ENABLE_INTRP)
-u1 *intrp_createcompilerstub(methodinfo *m);
-#endif
-
-void removecompilerstub(u1 *stub);
-void removenativestub(u1 *stub);
-
-void jit_invalidate_code(methodinfo *m);
-
-void md_param_alloc(methoddesc *md);
-void md_param_alloc_native(methoddesc *md);
-
-/* stub for throwing AbstractMethodError's */
-#if defined(ENABLE_JIT)
-void asm_abstractmethoderror(void);
-#endif
-
-#if defined(ENABLE_INTRP)
-void intrp_asm_abstractmethoderror(void);
-#endif
-
-#endif /* _JIT_INTERFACE */
-
-
-/*
- * 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:
- */
diff --git a/src/vm/linker.cpp b/src/vm/linker.cpp
new file mode 100644 (file)
index 0000000..50639b7
--- /dev/null
@@ -0,0 +1,1412 @@
+/* src/vm/linker.c - class linker 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 <stdint.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "native/native.hpp"
+
+#include "threads/lock.hpp"
+#include "threads/mutex.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/access.hpp"
+#include "vm/array.hpp"
+#include "vm/class.hpp"
+#include "vm/classcache.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/rt-timing.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/stubs.hpp"
+
+
+/* debugging macros ***********************************************************/
+
+#if !defined(NDEBUG)
+# define TRACELINKCLASS(c) \
+    do { \
+        if (opt_TraceLinkClass) { \
+            log_start(); \
+            log_print("[Linking "); \
+            class_print((c)); \
+            log_print("]"); \
+            log_finish(); \
+        } \
+    } while (0)
+#else
+# define TRACELINKCLASS(c)
+#endif
+
+
+/* #include "vm/resolve.hpp" */
+/* copied prototype to avoid bootstrapping problem: */
+classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool checkaccess);
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#if !defined(NDEBUG) && defined(ENABLE_INLINING)
+#define INLINELOG(code)  do { if (opt_TraceInlining) { code } } while (0)
+#else
+#define INLINELOG(code)
+#endif
+
+
+/* global variables ***********************************************************/
+
+static s4 interfaceindex;       /* sequential numbering of interfaces         */
+static s4 classvalue;
+
+#if !USES_NEW_SUBTYPE
+Mutex *linker_classrenumber_lock;
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* private functions **********************************************************/
+
+static classinfo *link_class_intern(classinfo *c);
+static arraydescriptor *link_array(classinfo *c);
+static void linker_compute_class_values(classinfo *c);
+static void linker_compute_subclasses(classinfo *c);
+static bool linker_addinterface(classinfo *c, classinfo *ic);
+static s4 class_highestinterface(classinfo *c);
+
+
+/* linker_init *****************************************************************
+
+   Initializes the linker subsystem and links classes required for the
+   primitive table.
+
+*******************************************************************************/
+
+void linker_preinit(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("linker_preinit");
+
+       /* Reset interface index. */
+
+       interfaceindex = 0;
+
+#if defined(ENABLE_THREADS) && !USES_NEW_SUBTYPE
+       /* create the global mutex */
+
+       linker_classrenumber_lock = new Mutex();
+#endif
+
+       /* Link the most basic classes. */
+
+       if (!link_class(class_java_lang_Object))
+               vm_abort("linker_preinit: linking java/lang/Object failed");
+
+#if defined(ENABLE_JAVASE)
+       if (!link_class(class_java_lang_Cloneable))
+               vm_abort("linker_preinit: linking java/lang/Cloneable failed");
+
+       if (!link_class(class_java_io_Serializable))
+               vm_abort("linker_preinit: linking java/io/Serializable failed");
+#endif
+}
+
+
+/* linker_init *****************************************************************
+
+   Links all classes required in the VM.
+
+*******************************************************************************/
+
+void linker_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("linker_init");
+
+       /* Link java.lang.Class as first class of the system, because we
+       need it's vftbl for all other classes so we can use a class as
+       object. */
+
+       if (!link_class(class_java_lang_Class))
+               vm_abort("linker_init: linking java/lang/Class failed");
+
+       /* Now set the header.vftbl of all classes which were created
+       before java.lang.Class was linked. */
+
+       class_postset_header_vftbl();
+
+       /* Link primitive-type wrapping classes. */
+
+#if defined(ENABLE_JAVASE)
+       if (!link_class(class_java_lang_Void))
+               vm_abort("linker_init: linking failed");
+#endif
+
+       if (!link_class(class_java_lang_Boolean))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_Byte))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_Character))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_Short))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_Integer))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_Long))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_Float))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_Double))
+               vm_abort("linker_init: linking failed");
+
+       /* Link important system classes. */
+
+       if (!link_class(class_java_lang_String))
+               vm_abort("linker_init: linking java/lang/String failed");
+
+#if defined(ENABLE_JAVASE)
+       if (!link_class(class_java_lang_ClassLoader))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_SecurityManager))
+               vm_abort("linker_init: linking failed");
+#endif
+
+       if (!link_class(class_java_lang_System))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_Thread))
+               vm_abort("linker_init: linking failed");
+
+#if defined(ENABLE_JAVASE)
+       if (!link_class(class_java_lang_ThreadGroup))
+               vm_abort("linker_init: linking failed");
+#endif
+
+       if (!link_class(class_java_lang_Throwable))
+               vm_abort("linker_init: linking failed");
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       if (!link_class(class_java_lang_VMSystem))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_VMThread))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_VMThrowable))
+               vm_abort("linker_init: linking failed");
+#endif
+
+       /* Important system exceptions. */
+
+       if (!link_class(class_java_lang_Exception))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_ClassNotFoundException))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_RuntimeException))
+               vm_abort("linker_init: linking failed");
+
+       /* some classes which may be used more often */
+
+#if defined(ENABLE_JAVASE)
+       if (!link_class(class_java_lang_StackTraceElement))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_reflect_Constructor))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_reflect_Field))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_reflect_Method))
+               vm_abort("linker_init: linking failed");
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       if (!link_class(class_java_lang_reflect_VMConstructor))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_reflect_VMField))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_lang_reflect_VMMethod))
+               vm_abort("linker_init: linking failed");
+# endif
+
+       if (!link_class(class_java_security_PrivilegedAction))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_util_Vector))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_java_util_HashMap))
+               vm_abort("linker_init: linking failed");
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       if (!link_class(class_sun_misc_Signal))
+               vm_abort("linker_init: linking failed");
+
+       if (!link_class(class_sun_reflect_MagicAccessorImpl))
+               vm_abort("linker_init: linking failed");
+# endif
+
+       if (!link_class(arrayclass_java_lang_Object))
+               vm_abort("linker_init: linking failed");
+#endif
+
+
+       /* create pseudo classes used by the typechecker */
+
+    /* pseudo class for Arraystubs (extends java.lang.Object) */
+
+       pseudo_class_Arraystub                   =
+               class_create_classinfo(utf_new_char("$ARRAYSTUB$"));
+       pseudo_class_Arraystub->state           |= CLASS_LOADED;
+       pseudo_class_Arraystub->super            = class_java_lang_Object;
+
+#if defined(ENABLE_JAVASE)
+
+       pseudo_class_Arraystub->interfacescount  = 2;
+       pseudo_class_Arraystub->interfaces       = MNEW(classinfo*, 2);
+       pseudo_class_Arraystub->interfaces[0]    = class_java_lang_Cloneable;
+       pseudo_class_Arraystub->interfaces[1]    = class_java_io_Serializable;
+
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+
+       pseudo_class_Arraystub->interfacescount    = 0;
+       pseudo_class_Arraystub->interfaces         = NULL;
+
+#else
+# error unknown Java configuration
+#endif
+
+       if (!classcache_store_unique(pseudo_class_Arraystub))
+               vm_abort("linker_init: could not cache pseudo_class_Arraystub");
+
+       if (!link_class(pseudo_class_Arraystub))
+               vm_abort("linker_init: linking pseudo_class_Arraystub failed");
+
+       /* pseudo class representing the null type */
+
+       pseudo_class_Null         = class_create_classinfo(utf_new_char("$NULL$"));
+       pseudo_class_Null->state |= CLASS_LOADED;
+       pseudo_class_Null->super  = class_java_lang_Object;
+
+       if (!classcache_store_unique(pseudo_class_Null))
+               vm_abort("linker_init: could not cache pseudo_class_Null");
+
+       if (!link_class(pseudo_class_Null))
+               vm_abort("linker_init: linking failed");
+
+       /* pseudo class representing new uninitialized objects */
+    
+       pseudo_class_New         = class_create_classinfo(utf_new_char("$NEW$"));
+       pseudo_class_New->state |= CLASS_LOADED;
+       pseudo_class_New->state |= CLASS_LINKED; /* XXX is this allright? */
+       pseudo_class_New->super  = class_java_lang_Object;
+
+       if (!classcache_store_unique(pseudo_class_New))
+               vm_abort("linker_init: could not cache pseudo_class_New");
+
+       /* Correct vftbl-entries (retarded loading and linking of class
+          java/lang/String). */
+
+       stringtable_update();
+}
+
+
+/* link_class ******************************************************************
+
+   Wrapper function for link_class_intern to ease monitor enter/exit
+   and exception handling.
+
+*******************************************************************************/
+
+classinfo *link_class(classinfo *c)
+{
+       classinfo *r;
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_end;
+#endif
+
+       RT_TIMING_GET_TIME(time_start);
+
+       if (c == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       LOCK_MONITOR_ENTER(c);
+
+       /* Maybe the class is currently linking or is already linked.*/
+
+       if ((c->state & CLASS_LINKING) || (c->state & CLASS_LINKED)) {
+               LOCK_MONITOR_EXIT(c);
+
+               return c;
+       }
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getcompilingtime)
+               compilingtime_stop();
+
+       if (opt_getloadingtime)
+               loadingtime_start();
+#endif
+
+       /* call the internal function */
+
+       r = link_class_intern(c);
+
+       /* If return value is NULL, we had a problem and the class is not
+          linked. */
+
+       if (r == NULL)
+               c->state &= ~CLASS_LINKING;
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getloadingtime)
+               loadingtime_stop();
+
+       if (opt_getcompilingtime)
+               compilingtime_start();
+#endif
+
+       LOCK_MONITOR_EXIT(c);
+
+       RT_TIMING_GET_TIME(time_end);
+
+       RT_TIMING_TIME_DIFF(time_start,time_end,RT_TIMING_LINK_TOTAL);
+
+       return r;
+}
+
+
+/* linker_overwrite_method *****************************************************
+
+   Overwrite a method with another one, update method flags and check
+   assumptions.
+
+   IN:
+      mg................the general method being overwritten
+         ms................the overwriting (more specialized) method
+         wl................worklist where to add invalidated methods
+
+   RETURN VALUE:
+      true..............everything ok
+         false.............an exception has been thrown
+
+*******************************************************************************/
+
+static bool linker_overwrite_method(methodinfo *mg,
+                                                                       methodinfo *ms,
+                                                                       method_worklist **wl)
+{
+       classinfo *cg;
+       classinfo *cs;
+
+       cg = mg->clazz;
+       cs = ms->clazz;
+
+       /* overriding a final method is illegal */
+
+       if (mg->flags & ACC_FINAL) {
+               exceptions_throw_verifyerror(mg, "Overriding final method");
+               return false;
+       }
+
+       /* method ms overwrites method mg */
+
+#if defined(ENABLE_VERIFIER)
+       /* Add loading constraints (for the more general types of method mg). */
+       /* Not for <init>, as it is not invoked virtually.                    */
+
+       if ((ms->name != utf_init)
+                       && !classcache_add_constraints_for_params(
+                               cs->classloader, cg->classloader, mg))
+       {
+               return false;
+       }
+#endif
+
+       /* inherit the vftbl index, and record the overwriting */
+
+       ms->vftblindex = mg->vftblindex;
+       ms->overwrites = mg;
+
+       /* update flags and check assumptions */
+       /* <init> methods are a special case, as they are never dispatched dynamically */
+
+       if ((ms->flags & ACC_METHOD_IMPLEMENTED) && ms->name != utf_init) {
+               do {
+
+#if defined(ENABLE_TLH)
+                       if (mg->flags & ACC_METHOD_MONOMORPHY_USED) {
+                               printf("%s/%s is evil! the siner is %s/%s\n", mg->clazz->name->text, mg->name->text,
+                                       ms->clazz->name->text, ms->name->text);
+                               ms->flags |= ACC_METHOD_PARENT_MONOMORPHY_USED;                                 
+                       }
+#endif
+
+                       if (mg->flags & ACC_METHOD_IMPLEMENTED) {
+                               /* this adds another implementation */
+
+                               mg->flags &= ~ACC_METHOD_MONOMORPHIC;
+
+                               INLINELOG( printf("becomes polymorphic: "); method_println(mg); );
+
+                               method_break_assumption_monomorphic(mg, wl);
+                       }
+                       else {
+                               /* this is the first implementation */
+
+                               mg->flags |= ACC_METHOD_IMPLEMENTED;
+
+                               INLINELOG( printf("becomes implemented: "); method_println(mg); );
+                       }
+
+                       ms = mg;
+                       mg = mg->overwrites;
+               } while (mg != NULL);
+       }
+
+       return true;
+}
+
+
+#if USES_NEW_SUBTYPE
+/* build_display ***************************************************************
+
+   Builds the entire display for a class. This entails filling the fixed part
+   as well as allocating and initializing the overflow part.
+
+   See Cliff Click and John Rose: Fast subtype checking in the Hotspot JVM.
+
+*******************************************************************************/
+
+static classinfo *build_display(classinfo *c)
+{
+       int depth, i;
+       int depth_fixed;
+       classinfo *super;
+
+       do {
+               /* Handle arrays. */
+               if (c->vftbl->arraydesc) {
+                       arraydescriptor *a = c->vftbl->arraydesc;
+                       if (a->elementvftbl && a->elementvftbl->clazz->super) {
+                               classinfo *cls = a->elementvftbl->clazz->super;
+                               int n;
+                               for (n=0; n<a->dimension; n++)
+                                       cls = class_array_of(cls, true);
+                               super = cls;
+                               break;
+                       }
+                       if (a->componentvftbl && a->elementvftbl) {
+                               super = a->componentvftbl->clazz;
+                               break;
+                       }
+               }
+               /* Normal classes. */
+               super = c->super;
+       } while (false);
+       if (super) {
+               if (!link_class(super))
+                       return NULL;
+               depth = super->vftbl->subtype_depth + 1;
+       } else
+               /* java.lang.Object doesn't have a super class. */
+               depth = 0;
+
+       /* Now copy super's display, append c->vftbl and initialize the remaining fields. */
+       if (depth >= DISPLAY_SIZE) {
+               c->vftbl->subtype_overflow = MNEW(vftbl_t *, depth - DISPLAY_SIZE + 1);
+#if defined(ENABLE_STATISTICS)
+               if (opt_stat)
+                       count_vftbl_len += sizeof(vftbl_t*) * (depth - DISPLAY_SIZE + 1);
+#endif
+               memcpy(c->vftbl->subtype_overflow, super->vftbl->subtype_overflow, sizeof(vftbl_t*) * (depth - DISPLAY_SIZE));
+               c->vftbl->subtype_overflow[depth - DISPLAY_SIZE] = c->vftbl;
+               depth_fixed = DISPLAY_SIZE;
+       }
+       else {
+               depth_fixed = depth;
+               c->vftbl->subtype_display[depth] = c->vftbl;
+       }
+
+       if (super)
+               memcpy(c->vftbl->subtype_display, super->vftbl->subtype_display, sizeof(vftbl_t*) * depth_fixed);
+       for (i=depth_fixed+1; i<=DISPLAY_SIZE; i++)
+               c->vftbl->subtype_display[i] = NULL;
+       c->vftbl->subtype_offset = OFFSET(vftbl_t, subtype_display[0]) + sizeof(vftbl_t*) * depth_fixed;
+       c->vftbl->subtype_depth = depth;
+
+       return c;
+}
+#endif
+
+/* link_class_intern ***********************************************************
+
+   Tries to link a class. The function calculates the length in bytes
+   that an instance of this class requires as well as the VTBL for
+   methods and interface methods.
+       
+*******************************************************************************/
+
+static classinfo *link_class_intern(classinfo *c)
+{
+       classinfo *super;             /* super class                              */
+       classinfo *tc;                /* temporary class variable                 */
+       s4 supervftbllength;          /* vftbllegnth of super class               */
+       s4 vftbllength;               /* vftbllength of current class             */
+       s4 interfacetablelength;      /* interface table length                   */
+       vftbl_t *v;                   /* vftbl of current class                   */
+       s4 i;                         /* interface/method/field counter           */
+       arraydescriptor *arraydesc;   /* descriptor for array classes             */
+       method_worklist *worklist;    /* worklist for recompilation               */
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_resolving, time_compute_vftbl,
+                                       time_abstract, time_compute_iftbl, time_fill_vftbl,
+                                       time_offsets, time_fill_iftbl, time_finalizer,
+                                       time_subclasses;
+#endif
+
+       RT_TIMING_GET_TIME(time_start);
+
+       TRACELINKCLASS(c);
+
+       /* the class must be loaded */
+
+       /* XXX should this be a specific exception? */
+       assert(c->state & CLASS_LOADED);
+
+       /* This is check in link_class. */
+
+       assert(!(c->state & CLASS_LINKED));
+
+       /* cache the self-reference of this class                          */
+       /* we do this for cases where the defining loader of the class     */
+       /* has not yet been recorded as an initiating loader for the class */
+       /* this is needed so subsequent code can assume that self-refs     */
+       /* will always resolve lazily                                      */
+       /* No need to do it for the bootloader - it is always registered   */
+       /* as initiating loader for the classes it loads.                  */
+       if (c->classloader)
+               classcache_store(c->classloader,c,false);
+
+       /* this class is currently linking */
+
+       c->state |= CLASS_LINKING;
+
+       arraydesc = NULL;
+       worklist = NULL;
+
+       /* Link the super interfaces. */
+
+       for (i = 0; i < c->interfacescount; i++) {
+               tc = c->interfaces[i];
+
+               if (!(tc->state & CLASS_LINKED))
+                       if (!link_class(tc))
+                               return NULL;
+       }
+       
+       /* check super class */
+
+       super = NULL;
+
+       /* Check for java/lang/Object. */
+
+       if (c->super == NULL) {
+               c->index = 0;
+               c->instancesize = sizeof(java_object_t);
+               
+               vftbllength = supervftbllength = 0;
+
+               c->finalizer = NULL;
+       }
+       else {
+               /* Get super class. */
+
+               super = c->super;
+
+               /* Link the super class if necessary. */
+               
+               if (!(super->state & CLASS_LINKED))
+                       if (!link_class(super))
+                               return NULL;
+
+               /* OR the ACC_CLASS_HAS_POINTERS and the ACC_CLASS_REFERENCE_*
+                  flags. */
+
+               c->flags |= (super->flags &
+                                        (ACC_CLASS_HAS_POINTERS | ACC_CLASS_REFERENCE_MASK));
+
+               /* handle array classes */
+
+               if (c->name->text[0] == '[')
+                       if (!(arraydesc = link_array(c)))
+                               return NULL;
+
+               if (c->flags & ACC_INTERFACE)
+                       c->index = interfaceindex++;
+               else
+                       c->index = super->index + 1;
+               
+               c->instancesize = super->instancesize;
+
+               vftbllength = supervftbllength = super->vftbl->vftbllength;
+               
+               c->finalizer = super->finalizer;
+       }
+       RT_TIMING_GET_TIME(time_resolving);
+
+
+       /* compute vftbl length */
+
+       for (i = 0; i < c->methodscount; i++) {
+               methodinfo *m = &(c->methods[i]);
+
+               if (!(m->flags & ACC_STATIC)) { /* is instance method */
+                       tc = super;
+
+                       while (tc) {
+                               s4 j;
+
+                               for (j = 0; j < tc->methodscount; j++) {
+                                       if (method_canoverwrite(m, &(tc->methods[j]))) {
+                                               if (tc->methods[j].flags & ACC_PRIVATE)
+                                                       goto notfoundvftblindex;
+
+                                               /* package-private methods in other packages */
+                                               /* must not be overridden                    */
+                                               /* (see Java Language Specification 8.4.8.1) */
+                                               if ( !(tc->methods[j].flags & (ACC_PUBLIC | ACC_PROTECTED)) 
+                                                        && !SAME_PACKAGE(c,tc) ) 
+                                               {
+                                                   goto notfoundvftblindex;
+                                               }
+
+                                               if (!linker_overwrite_method(&(tc->methods[j]), m, &worklist))
+                                                       return NULL;
+
+                                               goto foundvftblindex;
+                                       }
+                               }
+
+                               tc = tc->super;
+                       }
+
+               notfoundvftblindex:
+                       m->vftblindex = (vftbllength++);
+               foundvftblindex:
+                       ;
+               }
+       }
+       RT_TIMING_GET_TIME(time_compute_vftbl);
+
+
+       /* Check all interfaces of an abstract class (maybe be an
+          interface too) for unimplemented methods.  Such methods are
+          called miranda-methods and are marked with the ACC_MIRANDA
+          flag.  VMClass.getDeclaredMethods does not return such
+          methods. */
+
+       if (c->flags & ACC_ABSTRACT) {
+               classinfo  *ic;
+               methodinfo *im;
+               s4 abstractmethodscount;
+               s4 j;
+               s4 k;
+
+               abstractmethodscount = 0;
+
+               /* check all interfaces of the abstract class */
+
+               for (i = 0; i < c->interfacescount; i++) {
+                       ic = c->interfaces[i];
+
+                       for (j = 0; j < ic->methodscount; j++) {
+                               im = &(ic->methods[j]);
+
+                               /* skip `<clinit>' and `<init>' */
+
+                               if ((im->name == utf_clinit) || (im->name == utf_init))
+                                       continue;
+
+                               for (tc = c; tc != NULL; tc = tc->super) {
+                                       for (k = 0; k < tc->methodscount; k++) {
+                                               if (method_canoverwrite(im, &(tc->methods[k])))
+                                                       goto noabstractmethod;
+                                       }
+                               }
+
+                               abstractmethodscount++;
+
+                       noabstractmethod:
+                               ;
+                       }
+               }
+
+               if (abstractmethodscount > 0) {
+                       methodinfo *am;
+
+                       /* reallocate methods memory */
+
+                       c->methods = (methodinfo*) MREALLOC(c->methods, methodinfo, c->methodscount,
+                                                                 c->methodscount + abstractmethodscount);
+
+                       for (i = 0; i < c->interfacescount; i++) {
+                               ic = c->interfaces[i];
+
+                               for (j = 0; j < ic->methodscount; j++) {
+                                       im = &(ic->methods[j]);
+
+                                       /* skip `<clinit>' and `<init>' */
+
+                                       if ((im->name == utf_clinit) || (im->name == utf_init))
+                                               continue;
+
+                                       for (tc = c; tc != NULL; tc = tc->super) {
+                                               for (k = 0; k < tc->methodscount; k++) {
+                                                       if (method_canoverwrite(im, &(tc->methods[k])))
+                                                               goto noabstractmethod2;
+                                               }
+                                       }
+
+                                       /* Copy the method found into the new c->methods
+                                          array and tag it as miranda-method. */
+
+                                       am = &(c->methods[c->methodscount]);
+                                       c->methodscount++;
+
+                                       MCOPY(am, im, methodinfo, 1);
+
+                                       am->vftblindex  = (vftbllength++);
+                                       am->clazz       = c;
+                                       am->flags      |= ACC_MIRANDA;
+
+                               noabstractmethod2:
+                                       ;
+                               }
+                       }
+               }
+       }
+       RT_TIMING_GET_TIME(time_abstract);
+
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               count_vftbl_len +=
+                       sizeof(vftbl_t) + (sizeof(methodptr) * (vftbllength - 1));
+#endif
+
+       /* compute interfacetable length */
+
+       interfacetablelength = 0;
+
+       for (tc = c; tc != NULL; tc = tc->super) {
+               for (i = 0; i < tc->interfacescount; i++) {
+                       s4 h = class_highestinterface(tc->interfaces[i]) + 1;
+
+                       if (h > interfacetablelength)
+                               interfacetablelength = h;
+               }
+       }
+       RT_TIMING_GET_TIME(time_compute_iftbl);
+
+       /* allocate virtual function table */
+
+       v = (vftbl_t *) mem_alloc(sizeof(vftbl_t) +
+                                                         sizeof(methodptr) * (vftbllength - 1) +
+                                                         sizeof(methodptr*) * (interfacetablelength - (interfacetablelength > 0)));
+       v = (vftbl_t *) (((methodptr *) v) +
+                                        (interfacetablelength - 1) * (interfacetablelength > 1));
+
+       c->vftbl                = v;
+       v->clazz                = c;
+       v->vftbllength          = vftbllength;
+       v->interfacetablelength = interfacetablelength;
+       v->arraydesc            = arraydesc;
+
+       /* store interface index in vftbl */
+
+       if (c->flags & ACC_INTERFACE)
+               v->baseval = -(c->index);
+
+       /* copy virtual function table of super class */
+
+       for (i = 0; i < supervftbllength; i++) 
+               v->table[i] = super->vftbl->table[i];
+
+       /* Fill the remaining vftbl slots with the AbstractMethodError
+          stub (all after the super class slots, because they are already
+          initialized). */
+
+       for (; i < vftbllength; i++) {
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+               if (opt_intrp)
+                       v->table[i] = (methodptr) (ptrint) &intrp_asm_abstractmethoderror;
+               else
+# endif
+                       v->table[i] = (methodptr) (ptrint) &asm_abstractmethoderror;
+#else
+               v->table[i] = (methodptr) (ptrint) &intrp_asm_abstractmethoderror;
+#endif
+       }
+
+       /* add method stubs into virtual function table */
+
+       for (i = 0; i < c->methodscount; i++) {
+               methodinfo *m = &(c->methods[i]);
+
+               assert(m->stubroutine == NULL);
+
+               /* Don't create a compiler stub for abstract methods as they
+                  throw an AbstractMethodError with the default stub in the
+                  vftbl.  This entry is simply copied by sub-classes. */
+
+               if (m->flags & ACC_ABSTRACT)
+                       continue;
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+               if (opt_intrp)
+                       m->stubroutine = intrp_createcompilerstub(m);
+               else
+#endif
+                       m->stubroutine = (u1*) CompilerStub::generate(m);
+#else
+               m->stubroutine = intrp_createcompilerstub(m);
+#endif
+
+               /* static methods are not in the vftbl */
+
+               if (m->flags & ACC_STATIC)
+                       continue;
+
+               /* insert the stubroutine into the vftbl */
+
+               v->table[m->vftblindex] = (methodptr) (ptrint) m->stubroutine;
+       }
+       RT_TIMING_GET_TIME(time_fill_vftbl);
+
+       /* compute instance size and offset of each field */
+       
+       for (i = 0; i < c->fieldscount; i++) {
+               s4 dsize;
+               fieldinfo *f = &(c->fields[i]);
+               
+               if (!(f->flags & ACC_STATIC)) {
+                       dsize = descriptor_typesize(f->parseddesc);
+                       c->instancesize = MEMORY_ALIGN(c->instancesize, dsize);
+                       f->offset = c->instancesize;
+                       c->instancesize += dsize;
+               }
+       }
+       RT_TIMING_GET_TIME(time_offsets);
+
+       /* initialize interfacetable and interfacevftbllength */
+
+       v->interfacevftbllength = MNEW(s4, interfacetablelength);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               count_vftbl_len += (4 + sizeof(s4)) * v->interfacetablelength;
+#endif
+
+       for (i = 0; i < interfacetablelength; i++) {
+               v->interfacevftbllength[i] = 0;
+               v->interfacetable[-i] = NULL;
+       }
+
+       /* add interfaces */
+
+       for (tc = c; tc != NULL; tc = tc->super)
+               for (i = 0; i < tc->interfacescount; i++)
+                       if (!linker_addinterface(c, tc->interfaces[i]))
+                               return NULL;
+
+       RT_TIMING_GET_TIME(time_fill_iftbl);
+
+       /* add finalizer method (not for java.lang.Object) */
+
+       if (super) {
+               methodinfo *fi;
+
+               fi = class_findmethod(c, utf_finalize, utf_void__void);
+
+               if (fi)
+                       if (!(fi->flags & ACC_STATIC))
+                               c->finalizer = fi;
+       }
+       RT_TIMING_GET_TIME(time_finalizer);
+
+       /* final tasks */
+
+       linker_compute_subclasses(c);
+
+       /* FIXME: this is completely useless now */
+       RT_TIMING_GET_TIME(time_subclasses);
+
+#if USES_NEW_SUBTYPE
+       if (!build_display(c))
+               return NULL;
+#endif
+
+       /* revert the linking state and class is linked */
+
+       c->state = (c->state & ~CLASS_LINKING) | CLASS_LINKED;
+
+       /* check worklist */
+
+       /* XXX must this also be done in case of exception? */
+
+       while (worklist != NULL) {
+               method_worklist *wi = worklist;
+
+               worklist = worklist->next;
+
+               INLINELOG( printf("MUST BE RECOMPILED: "); method_println(wi->m); );
+               jit_invalidate_code(wi->m);
+
+               /* XXX put worklist into dump memory? */
+               FREE(wi, method_worklist);
+       }
+
+       RT_TIMING_TIME_DIFF(time_start        ,time_resolving    ,RT_TIMING_LINK_RESOLVE);
+       RT_TIMING_TIME_DIFF(time_resolving    ,time_compute_vftbl,RT_TIMING_LINK_C_VFTBL);
+       RT_TIMING_TIME_DIFF(time_compute_vftbl,time_abstract     ,RT_TIMING_LINK_ABSTRACT);
+       RT_TIMING_TIME_DIFF(time_abstract     ,time_compute_iftbl,RT_TIMING_LINK_C_IFTBL);
+       RT_TIMING_TIME_DIFF(time_compute_iftbl,time_fill_vftbl   ,RT_TIMING_LINK_F_VFTBL);
+       RT_TIMING_TIME_DIFF(time_fill_vftbl   ,time_offsets      ,RT_TIMING_LINK_OFFSETS);
+       RT_TIMING_TIME_DIFF(time_offsets      ,time_fill_iftbl   ,RT_TIMING_LINK_F_IFTBL);
+       RT_TIMING_TIME_DIFF(time_fill_iftbl   ,time_finalizer    ,RT_TIMING_LINK_FINALIZER);
+       RT_TIMING_TIME_DIFF(time_finalizer    ,time_subclasses   ,RT_TIMING_LINK_SUBCLASS);
+
+       /* just return c to show that we didn't had a problem */
+
+       return c;
+}
+
+
+/* link_array ******************************************************************
+
+   This function is called by link_class to create the arraydescriptor
+   for an array class.
+
+   This function returns NULL if the array cannot be linked because
+   the component type has not been linked yet.
+
+*******************************************************************************/
+
+static arraydescriptor *link_array(classinfo *c)
+{
+       classinfo       *comp;
+       s4               namelen;
+       arraydescriptor *desc;
+       vftbl_t         *compvftbl;
+       utf             *u;
+
+       comp = NULL;
+       namelen = c->name->blength;
+
+       /* Check the component type */
+
+       switch (c->name->text[1]) {
+       case '[':
+               /* c is an array of arrays. */
+               u = utf_new(c->name->text + 1, namelen - 1);
+               if (!(comp = load_class_from_classloader(u, c->classloader)))
+                       return NULL;
+               break;
+
+       case 'L':
+               /* c is an array of objects. */
+               u = utf_new(c->name->text + 2, namelen - 3);
+               if (!(comp = load_class_from_classloader(u, c->classloader)))
+                       return NULL;
+               break;
+       }
+
+       /* If the component type has not been linked, link it now */
+
+       assert(!comp || (comp->state & CLASS_LOADED));
+
+       if (comp && !(comp->state & CLASS_LINKED))
+               if (!link_class(comp))
+                       return NULL;
+
+       /* Allocate the arraydescriptor */
+
+       desc = NEW(arraydescriptor);
+
+       if (comp) {
+               /* c is an array of references */
+               desc->arraytype = ARRAYTYPE_OBJECT;
+               desc->componentsize = sizeof(void*);
+               desc->dataoffset = OFFSET(java_objectarray_t, data);
+               
+               compvftbl = comp->vftbl;
+
+               if (!compvftbl) {
+                       log_text("Component class has no vftbl");
+                       assert(0);
+               }
+
+               desc->componentvftbl = compvftbl;
+               
+               if (compvftbl->arraydesc) {
+                       desc->elementvftbl = compvftbl->arraydesc->elementvftbl;
+
+                       if (compvftbl->arraydesc->dimension >= 255) {
+                               log_text("Creating array of dimension >255");
+                               assert(0);
+                       }
+
+                       desc->dimension = compvftbl->arraydesc->dimension + 1;
+                       desc->elementtype = compvftbl->arraydesc->elementtype;
+
+               } else {
+                       desc->elementvftbl = compvftbl;
+                       desc->dimension = 1;
+                       desc->elementtype = ARRAYTYPE_OBJECT;
+               }
+
+       } else {
+               /* c is an array of a primitive type */
+               switch (c->name->text[1]) {
+               case 'Z':
+                       desc->arraytype = ARRAYTYPE_BOOLEAN;
+                       desc->dataoffset = OFFSET(java_booleanarray_t,data);
+                       desc->componentsize = sizeof(u1);
+                       break;
+
+               case 'B':
+                       desc->arraytype = ARRAYTYPE_BYTE;
+                       desc->dataoffset = OFFSET(java_bytearray_t,data);
+                       desc->componentsize = sizeof(u1);
+                       break;
+
+               case 'C':
+                       desc->arraytype = ARRAYTYPE_CHAR;
+                       desc->dataoffset = OFFSET(java_chararray_t,data);
+                       desc->componentsize = sizeof(u2);
+                       break;
+
+               case 'D':
+                       desc->arraytype = ARRAYTYPE_DOUBLE;
+                       desc->dataoffset = OFFSET(java_doublearray_t,data);
+                       desc->componentsize = sizeof(double);
+                       break;
+
+               case 'F':
+                       desc->arraytype = ARRAYTYPE_FLOAT;
+                       desc->dataoffset = OFFSET(java_floatarray_t,data);
+                       desc->componentsize = sizeof(float);
+                       break;
+
+               case 'I':
+                       desc->arraytype = ARRAYTYPE_INT;
+                       desc->dataoffset = OFFSET(java_intarray_t,data);
+                       desc->componentsize = sizeof(s4);
+                       break;
+
+               case 'J':
+                       desc->arraytype = ARRAYTYPE_LONG;
+                       desc->dataoffset = OFFSET(java_longarray_t,data);
+                       desc->componentsize = sizeof(s8);
+                       break;
+
+               case 'S':
+                       desc->arraytype = ARRAYTYPE_SHORT;
+                       desc->dataoffset = OFFSET(java_shortarray_t,data);
+                       desc->componentsize = sizeof(s2);
+                       break;
+
+               default:
+                       exceptions_throw_noclassdeffounderror(c->name);
+                       return NULL;
+               }
+               
+               desc->componentvftbl = NULL;
+               desc->elementvftbl = NULL;
+               desc->dimension = 1;
+               desc->elementtype = desc->arraytype;
+       }
+
+       return desc;
+}
+
+
+/* linker_compute_subclasses ***************************************************
+
+   XXX
+
+   ATTENTION: DO NOT REMOVE ANY OF THE LOCKING MECHANISMS BELOW:
+   This function needs to take the class renumber lock and stop the
+   world during class renumbering. The lock is used in C code which
+   is not that performance critical. Whereas JIT code uses critical
+   sections to atomically access the class values.
+
+*******************************************************************************/
+
+static void linker_compute_subclasses(classinfo *c)
+{
+
+       LOCK_CLASSRENUMBER_LOCK;
+
+       if (!(c->flags & ACC_INTERFACE)) {
+               c->nextsub = NULL;
+               c->sub     = NULL;
+#if USES_NEW_SUBTYPE
+               c->vftbl->baseval = 1; /* so it does not look like an interface */
+#endif
+       }
+
+       if (!(c->flags & ACC_INTERFACE) && (c->super != NULL)) {
+               c->nextsub    = c->super->sub;
+               c->super->sub = c;
+       }
+
+       classvalue = 0;
+
+#if !USES_NEW_SUBTYPE
+       /* compute class values */
+
+       linker_compute_class_values(class_java_lang_Object);
+#endif
+
+       UNLOCK_CLASSRENUMBER_LOCK;
+
+}
+
+
+/* linker_compute_class_values *************************************************
+
+   XXX
+
+*******************************************************************************/
+
+static void linker_compute_class_values(classinfo *c)
+{
+       classinfo *subs;
+
+       c->vftbl->baseval = ++classvalue;
+
+       subs = c->sub;
+
+       while (subs) {
+               linker_compute_class_values(subs);
+
+               subs = subs->nextsub;
+       }
+
+       c->vftbl->diffval = classvalue - c->vftbl->baseval;
+}
+
+
+/* linker_addinterface *********************************************************
+
+   Is needed by link_class for adding a VTBL to a class. All
+   interfaces implemented by ic are added as well.
+
+   RETURN VALUE:
+      true.........everything ok
+         false........an exception has been thrown
+
+*******************************************************************************/
+
+static bool linker_addinterface(classinfo *c, classinfo *ic)
+{
+       s4          j, k;
+       vftbl_t    *v;
+       s4          i;
+       classinfo  *sc;
+       methodinfo *m;
+
+       v = c->vftbl;
+       i = ic->index;
+
+       if (i >= v->interfacetablelength)
+               vm_abort("Internal error: interfacetable overflow");
+
+       /* if this interface has already been added, return immediately */
+
+       if (v->interfacetable[-i] != NULL)
+               return true;
+
+       if (ic->methodscount == 0) {  /* fake entry needed for subtype test */
+               v->interfacevftbllength[i] = 1;
+               v->interfacetable[-i]      = MNEW(methodptr, 1);
+               v->interfacetable[-i][0]   = NULL;
+       }
+       else {
+               v->interfacevftbllength[i] = ic->methodscount;
+               v->interfacetable[-i]      = MNEW(methodptr, ic->methodscount);
+
+#if defined(ENABLE_STATISTICS)
+               if (opt_stat)
+                       count_vftbl_len += sizeof(methodptr) *
+                               (ic->methodscount + (ic->methodscount == 0));
+#endif
+
+               for (j = 0; j < ic->methodscount; j++) {
+                       for (sc = c; sc != NULL; sc = sc->super) {
+                               for (k = 0; k < sc->methodscount; k++) {
+                                       m = &(sc->methods[k]);
+
+                                       if (method_canoverwrite(m, &(ic->methods[j]))) {
+                                               /* method m overwrites the (abstract) method */
+#if defined(ENABLE_VERIFIER)
+                                               /* Add loading constraints (for the more
+                                                  general types of the method
+                                                  ic->methods[j]).  */
+                                               if (!classcache_add_constraints_for_params(
+                                                                       c->classloader, ic->classloader,
+                                                                       &(ic->methods[j])))
+                                               {
+                                                       return false;
+                                               }
+#endif
+
+                                               /* XXX taken from gcj */
+                                               /* check for ACC_STATIC: IncompatibleClassChangeError */
+
+                                               /* check for !ACC_PUBLIC: IllegalAccessError */
+
+                                               /* check for ACC_ABSTRACT: AbstracMethodError,
+                                                  not sure about that one */
+
+                                               v->interfacetable[-i][j] = v->table[m->vftblindex];
+                                               goto foundmethod;
+                                       }
+                               }
+                       }
+
+                       /* If no method was found, insert the AbstractMethodError
+                          stub. */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+                       if (opt_intrp)
+                               v->interfacetable[-i][j] =
+                                       (methodptr) (ptrint) &intrp_asm_abstractmethoderror;
+                       else
+# endif
+                               v->interfacetable[-i][j] =
+                                       (methodptr) (ptrint) &asm_abstractmethoderror;
+#else
+                       v->interfacetable[-i][j] =
+                               (methodptr) (ptrint) &intrp_asm_abstractmethoderror;
+#endif
+
+               foundmethod:
+                       ;
+               }
+       }
+
+       /* add superinterfaces of this interface */
+
+       for (j = 0; j < ic->interfacescount; j++)
+               if (!linker_addinterface(c, ic->interfaces[j]))
+                       return false;
+
+       /* everything ok */
+
+       return true;
+}
+
+
+/* class_highestinterface ******************************************************
+
+   Used by the function link_class to determine the amount of memory
+   needed for the interface table.
+
+*******************************************************************************/
+
+static s4 class_highestinterface(classinfo *c)
+{
+       s4 h;
+       s4 h2;
+       s4 i;
+       
+    /* check for ACC_INTERFACE bit already done in link_class_intern */
+
+    h = c->index;
+
+       for (i = 0; i < c->interfacescount; i++) {
+               h2 = class_highestinterface(c->interfaces[i]);
+
+               if (h2 > h)
+                       h = h2;
+       }
+
+       return h;
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+/*
+ * 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/linker.hpp b/src/vm/linker.hpp
new file mode 100644 (file)
index 0000000..2142ef8
--- /dev/null
@@ -0,0 +1,111 @@
+/* src/vm/linker.h - class linker 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 _LINKER_H
+#define _LINKER_H
+
+/* forward typedefs ***********************************************************/
+
+typedef struct arraydescriptor arraydescriptor;
+typedef struct primitivetypeinfo primitivetypeinfo;
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "threads/mutex.hpp"
+
+#include "vm/class.hpp"
+#include "vm/references.h"
+#include "vm/vftbl.hpp"
+
+
+/* arraydescriptor *************************************************************
+
+   For every array class an arraydescriptor is allocated which
+   describes the array class. The arraydescriptor is referenced from
+   the vftbl of the array class.
+
+*******************************************************************************/
+
+struct arraydescriptor {
+       vftbl_t *componentvftbl; /* vftbl of the component type, NULL for primit. */
+       vftbl_t *elementvftbl;   /* vftbl of the element type, NULL for primitive */
+       s2       arraytype;      /* ARRAYTYPE_* constant                          */
+       s2       dimension;      /* dimension of the array (always >= 1)          */
+       s4       dataoffset;     /* offset of the array data from object pointer  */
+       s4       componentsize;  /* size of a component in bytes                  */
+       s2       elementtype;    /* ARRAYTYPE_* constant                          */
+};
+
+
+/* global variables ***********************************************************/
+
+/* This lock must be taken while renumbering classes or while atomically      */
+/* accessing classes.                                                         */
+
+#if USES_NEW_SUBTYPE
+
+#define LOCK_CLASSRENUMBER_LOCK   /* nothing */
+#define UNLOCK_CLASSRENUMBER_LOCK /* nothing */
+
+#else
+extern Mutex *linker_classrenumber_lock;
+
+#define LOCK_CLASSRENUMBER_LOCK   linker_classrenumber_lock->lock()
+#define UNLOCK_CLASSRENUMBER_LOCK linker_classrenumber_lock->unlock()
+
+#endif
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void       linker_preinit(void);
+void       linker_init(void);
+classinfo *link_class(classinfo *c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LINKER_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:
+ */
diff --git a/src/vm/loader.cpp b/src/vm/loader.cpp
new file mode 100644 (file)
index 0000000..81ab0ad
--- /dev/null
@@ -0,0 +1,2218 @@
+/* src/vm/loader.cpp - class loader 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 <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "vm/types.h"
+
+#include "mm/dumpmemory.hpp"
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "threads/mutex.hpp"
+
+#include "toolbox/hashtable.h"
+#include "toolbox/logging.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/classcache.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/field.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/linker.hpp"
+#include "vm/loader.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/package.hpp"
+#include "vm/primitive.hpp"
+#include "vm/resolve.hpp"
+#include "vm/rt-timing.h"
+#include "vm/string.hpp"
+#include "vm/suck.hpp"
+#include "vm/vm.hpp"
+
+
+#if defined(ENABLE_JAVASE)
+# include "vm/annotation.h"
+# include "vm/stackmap.h"
+#endif
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#if defined(ENABLE_ZLIB)
+# include "vm/zip.hpp"
+#endif
+
+#include "vm/jit/stubs.hpp"
+
+#if defined(ENABLE_JVMTI)
+# include "native/jvmti/cacaodbg.h"
+#endif
+
+
+/* global variables ***********************************************************/
+
+static hashtable *hashtable_classloader;
+
+
+/* loader_preinit **************************************************************
+
+   Initializes the classpath list and loads classes required for the
+   primitive table.
+
+   NOTE: Exceptions thrown during VM initialization are caught in the
+         exception functions themselves.
+
+*******************************************************************************/
+void loader_preinit(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("loader_preinit");
+
+#if defined(ENABLE_THREADS)
+       /* Initialize the monitor pointer for zip/jar file locking. */
+
+       for (List<list_classpath_entry*>::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end(); it++) {
+               list_classpath_entry* lce = *it;
+
+               if (lce->type == CLASSPATH_ARCHIVE)
+                       lce->mutex = new Mutex();
+       }
+#endif
+
+       /* initialize classloader hashtable, 10 entries should be enough */
+
+       hashtable_classloader = NEW(hashtable);
+       hashtable_create(hashtable_classloader, 10);
+
+       /* Load the most basic classes. */
+
+       assert(VM::get_current()->is_initializing() == true);
+
+       class_java_lang_Object     = load_class_bootstrap(utf_java_lang_Object);
+
+#if defined(ENABLE_JAVASE)
+       class_java_lang_Cloneable  = load_class_bootstrap(utf_java_lang_Cloneable);
+       class_java_io_Serializable = load_class_bootstrap(utf_java_io_Serializable);
+#endif
+}
+
+
+/* loader_init *****************************************************************
+
+   Loads all classes required in the VM.
+
+   NOTE: Exceptions thrown during VM initialization are caught in the
+         exception functions themselves.
+
+*******************************************************************************/
+void loader_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("loader_init");
+
+       /* Load primitive-type wrapping classes. */
+
+       assert(VM::get_current()->is_initializing() == true);
+
+#if defined(ENABLE_JAVASE)
+       class_java_lang_Void       = load_class_bootstrap(utf_java_lang_Void);
+#endif
+
+       class_java_lang_Boolean    = load_class_bootstrap(utf_java_lang_Boolean);
+       class_java_lang_Byte       = load_class_bootstrap(utf_java_lang_Byte);
+       class_java_lang_Character  = load_class_bootstrap(utf_java_lang_Character);
+       class_java_lang_Short      = load_class_bootstrap(utf_java_lang_Short);
+       class_java_lang_Integer    = load_class_bootstrap(utf_java_lang_Integer);
+       class_java_lang_Long       = load_class_bootstrap(utf_java_lang_Long);
+       class_java_lang_Float      = load_class_bootstrap(utf_java_lang_Float);
+       class_java_lang_Double     = load_class_bootstrap(utf_java_lang_Double);
+
+       /* Load important system classes. */
+
+       class_java_lang_Class      = load_class_bootstrap(utf_java_lang_Class);
+       class_java_lang_String     = load_class_bootstrap(utf_java_lang_String);
+
+#if defined(ENABLE_JAVASE)
+       class_java_lang_ClassLoader =
+               load_class_bootstrap(utf_java_lang_ClassLoader);
+
+       class_java_lang_SecurityManager =
+               load_class_bootstrap(utf_java_lang_SecurityManager);
+#endif
+
+       class_java_lang_System     =
+               load_class_bootstrap(utf_new_char("java/lang/System"));
+
+       class_java_lang_Thread     =
+               load_class_bootstrap(utf_new_char("java/lang/Thread"));
+
+#if defined(ENABLE_JAVASE)
+       class_java_lang_ThreadGroup =
+               load_class_bootstrap(utf_java_lang_ThreadGroup);
+#endif
+
+       class_java_lang_Throwable  = load_class_bootstrap(utf_java_lang_Throwable);
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       class_java_lang_VMSystem   =
+               load_class_bootstrap(utf_new_char("java/lang/VMSystem"));
+
+       class_java_lang_VMThread   =
+               load_class_bootstrap(utf_new_char("java/lang/VMThread"));
+
+       class_java_lang_VMThrowable =
+               load_class_bootstrap(utf_new_char("java/lang/VMThrowable"));
+#endif
+
+       /* Important system exceptions. */
+
+       class_java_lang_Exception  = load_class_bootstrap(utf_java_lang_Exception);
+
+       class_java_lang_ClassNotFoundException =
+               load_class_bootstrap(utf_java_lang_ClassNotFoundException);
+
+       class_java_lang_RuntimeException =
+               load_class_bootstrap(utf_java_lang_RuntimeException);
+
+       /* Some classes which may be used often. */
+
+#if defined(ENABLE_JAVASE)
+       class_java_lang_StackTraceElement      = load_class_bootstrap(utf_java_lang_StackTraceElement);
+
+       class_java_lang_reflect_Constructor    = load_class_bootstrap(utf_java_lang_reflect_Constructor);
+       class_java_lang_reflect_Field          = load_class_bootstrap(utf_java_lang_reflect_Field);
+       class_java_lang_reflect_Method         = load_class_bootstrap(utf_java_lang_reflect_Method);
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       class_java_lang_reflect_VMConstructor  = load_class_bootstrap(utf_java_lang_reflect_VMConstructor);
+       class_java_lang_reflect_VMField        = load_class_bootstrap(utf_java_lang_reflect_VMField);
+       class_java_lang_reflect_VMMethod       = load_class_bootstrap(utf_java_lang_reflect_VMMethod);
+# endif
+
+       class_java_security_PrivilegedAction   = load_class_bootstrap(utf_new_char("java/security/PrivilegedAction"));
+
+       class_java_util_HashMap                = load_class_bootstrap(utf_new_char("java/util/HashMap"));
+       class_java_util_Vector                 = load_class_bootstrap(utf_java_util_Vector);
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       class_sun_misc_Signal                  = load_class_bootstrap(utf_new_char("sun/misc/Signal"));
+       class_sun_reflect_MagicAccessorImpl    = load_class_bootstrap(utf_new_char("sun/reflect/MagicAccessorImpl"));
+# endif
+
+       arrayclass_java_lang_Object =
+               load_class_bootstrap(utf_new_char("[Ljava/lang/Object;"));
+
+# if defined(ENABLE_ANNOTATIONS)
+       /* needed by annotation support */
+       class_sun_reflect_ConstantPool =
+               load_class_bootstrap(utf_new_char("sun/reflect/ConstantPool"));
+
+#  if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       /* needed by GNU Classpaths annotation support */
+       class_sun_reflect_annotation_AnnotationParser =
+               load_class_bootstrap(utf_new_char("sun/reflect/annotation/AnnotationParser"));
+#  endif
+# endif
+#endif
+}
+
+
+/* loader_hashtable_classloader_add ********************************************
+
+   Adds an entry to the classloader hashtable.
+
+   REMEMBER: Also use this to register native loaders!
+
+*******************************************************************************/
+
+classloader_t *loader_hashtable_classloader_add(java_handle_t *cl)
+{
+       hashtable_classloader_entry *cle;
+       u4   key;
+       u4   slot;
+
+       if (cl == NULL)
+               return NULL;
+
+       hashtable_classloader->mutex->lock();
+
+       LLNI_CRITICAL_START;
+
+       /* key for entry is the hashcode of the classloader;
+          aligned to 16-byte boundaries */
+
+       key  = heap_hashcode(LLNI_DIRECT(cl)) >> 4;
+       slot = key & (hashtable_classloader->size - 1);
+       cle  = (hashtable_classloader_entry*) hashtable_classloader->ptr[slot];
+
+       /* search hashchain for existing entry */
+
+       while (cle) {
+               if (cle->object == LLNI_DIRECT(cl))
+                       break;
+
+               cle = cle->hashlink;
+       }
+
+       LLNI_CRITICAL_END;
+
+       /* if no classloader was found, we create a new entry here */
+
+       if (cle == NULL) {
+               cle = NEW(hashtable_classloader_entry);
+
+#if defined(ENABLE_GC_CACAO)
+               /* register the classloader object with the GC */
+
+               gc_reference_register(&(cle->object), GC_REFTYPE_CLASSLOADER);
+#endif
+
+               LLNI_CRITICAL_START;
+
+               cle->object = LLNI_DIRECT(cl);
+
+               LLNI_CRITICAL_END;
+
+/*#define LOADER_DEBUG_CLASSLOADER*/
+#ifdef LOADER_DEBUG_CLASSLOADER
+               printf("CLASSLOADER: adding new classloader entry %p for %p: ", cle, cl);
+               class_print(LLNI_vftbl_direct(cl)->class);
+               printf("\n");
+               fflush(stdout);
+#endif
+
+               /* insert entry into hashtable */
+
+               cle->hashlink = (hashtable_classloader_entry*) hashtable_classloader->ptr[slot];
+               hashtable_classloader->ptr[slot] = cle;
+
+               /* update number of entries */
+
+               hashtable_classloader->entries++;
+       }
+
+       hashtable_classloader->mutex->unlock();
+
+#if defined(ENABLE_HANDLES)
+       return cle;
+#else
+       return cl;
+#endif
+}
+
+
+/* loader_hashtable_classloader_find *******************************************
+
+   Find an entry in the classloader hashtable.
+
+*******************************************************************************/
+
+classloader_t *loader_hashtable_classloader_find(java_handle_t *cl)
+{
+       hashtable_classloader_entry *cle;
+       u4   key;
+       u4   slot;
+
+       if (cl == NULL)
+               return NULL;
+
+       LLNI_CRITICAL_START;
+
+       /* key for entry is the hashcode of the classloader;
+          aligned to 16-byte boundaries */
+
+       key  = heap_hashcode(LLNI_DIRECT(cl)) >> 4;
+       slot = key & (hashtable_classloader->size - 1);
+       cle  = (hashtable_classloader_entry*) hashtable_classloader->ptr[slot];
+
+       /* search hashchain for existing entry */
+
+       while (cle) {
+               if (cle->object == LLNI_DIRECT(cl))
+                       break;
+
+               cle = cle->hashlink;
+       }
+
+#ifdef LOADER_DEBUG_CLASSLOADER
+       if (cle == NULL) {
+               printf("CLASSLOADER: unable to find classloader entry for %p: ", cl);
+               class_print(LLNI_vftbl_direct(cl)->class);
+               printf("\n");
+               fflush(stdout);
+       }
+#endif
+
+       LLNI_CRITICAL_END;
+
+#if defined(ENABLE_HANDLES)
+       return cle;
+#else
+       return cl;
+#endif
+}
+
+
+/* loader_load_all_classes *****************************************************
+
+   Loads all classes specified in the BOOTCLASSPATH.
+
+*******************************************************************************/
+
+void loader_load_all_classes(void)
+{
+#if defined(ENABLE_ZLIB)
+       hashtable               *ht;
+       hashtable_zipfile_entry *htzfe;
+       utf                     *u;
+#endif
+
+       for (List<list_classpath_entry*>::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end(); it++) {
+               list_classpath_entry* lce = *it;
+
+#if defined(ENABLE_ZLIB)
+               if (lce->type == CLASSPATH_ARCHIVE) {
+                       /* get the classes hashtable */
+
+                       ht = lce->htclasses;
+
+                       for (uint32_t slot = 0; slot < ht->size; slot++) {
+                               htzfe = (hashtable_zipfile_entry *) ht->ptr[slot];
+
+                               for (; htzfe; htzfe = htzfe->hashlink) {
+                                       u = htzfe->filename;
+
+                                       /* skip all entries in META-INF and .properties,
+                       .png files */
+
+                                       if (!strncmp(u->text, "META-INF", strlen("META-INF")) ||
+                                               strstr(u->text, ".properties") ||
+                                               strstr(u->text, ".png"))
+                                               continue;
+
+                                       /* load class from bootstrap classloader */
+
+                                       if (!load_class_bootstrap(u)) {
+                                               fprintf(stderr, "Error loading: ");
+                                               utf_fprint_printable_ascii_classname(stderr, u);
+                                               fprintf(stderr, "\n");
+
+#if !defined(NDEBUG)
+                                               /* print out exception and cause */
+
+                                               exceptions_print_current_exception();
+#endif
+                                       }
+                               }
+                       }
+
+               } else {
+#endif
+#if defined(ENABLE_ZLIB)
+               }
+#endif
+       }
+}
+
+
+/* loader_skip_attribute_body **************************************************
+
+   Skips an attribute the attribute_name_index has already been read.
+       
+   attribute_info {
+       u2 attribute_name_index;
+       u4 attribute_length;
+       u1 info[attribute_length];
+   }
+
+*******************************************************************************/
+
+bool loader_skip_attribute_body(classbuffer *cb)
+{
+       u4 attribute_length;
+
+       if (!suck_check_classbuffer_size(cb, 4))
+               return false;
+
+       attribute_length = suck_u4(cb);
+
+       if (!suck_check_classbuffer_size(cb, attribute_length))
+               return false;
+
+       suck_skip_nbytes(cb, attribute_length);
+
+       return true;
+}
+
+
+/* load_constantpool ***********************************************************
+
+   Loads the constantpool of a class, the entries are transformed into
+   a simpler format by resolving references (a detailed overview of
+   the compact structures can be found in global.h).
+
+*******************************************************************************/
+
+static bool load_constantpool(classbuffer *cb, descriptor_pool *descpool)
+{
+
+       /* The following structures are used to save information which cannot be 
+          processed during the first pass. After the complete constantpool has 
+          been traversed the references can be resolved. 
+          (only in specific order)                                                */
+       
+       /* CONSTANT_Class entries */
+       typedef struct forward_class {
+               struct forward_class *next;
+               u2 thisindex;
+               u2 name_index;
+       } forward_class;
+
+       /* CONSTANT_String */
+       typedef struct forward_string {
+               struct forward_string *next;
+               u2 thisindex;
+               u2 string_index;
+       } forward_string;
+
+       /* CONSTANT_NameAndType */
+       typedef struct forward_nameandtype {
+               struct forward_nameandtype *next;
+               u2 thisindex;
+               u2 name_index;
+               u2 sig_index;
+       } forward_nameandtype;
+
+       /* CONSTANT_Fieldref, CONSTANT_Methodref or CONSTANT_InterfaceMethodref */
+       typedef struct forward_fieldmethint {
+               struct forward_fieldmethint *next;
+               u2 thisindex;
+               u1 tag;
+               u2 class_index;
+               u2 nameandtype_index;
+       } forward_fieldmethint;
+
+
+       classinfo *c;
+       u4 idx;
+
+       forward_class *forward_classes = NULL;
+       forward_string *forward_strings = NULL;
+       forward_nameandtype *forward_nameandtypes = NULL;
+       forward_fieldmethint *forward_fieldmethints = NULL;
+
+       forward_class *nfc;
+       forward_string *nfs;
+       forward_nameandtype *nfn;
+       forward_fieldmethint *nff;
+
+       u4 cpcount;
+       u1 *cptags;
+       void** cpinfos;
+
+       c = cb->clazz;
+
+       /* number of entries in the constant_pool table plus one */
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       cpcount = c->cpcount = suck_u2(cb);
+
+       /* allocate memory */
+       cptags  = c->cptags  = MNEW(u1, cpcount);
+       cpinfos = c->cpinfos = MNEW(void*, cpcount);
+
+       if (cpcount < 1) {
+               exceptions_throw_classformaterror(c, "Illegal constant pool size");
+               return false;
+       }
+       
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               count_const_pool_len += (sizeof(u1) + sizeof(void*)) * cpcount;
+#endif
+       
+       /* initialize constantpool */
+       for (idx = 0; idx < cpcount; idx++) {
+               cptags[idx] = CONSTANT_UNUSED;
+               cpinfos[idx] = NULL;
+       }
+
+                       
+       /******* first pass *******/
+       /* entries which cannot be resolved now are written into 
+          temporary structures and traversed again later        */
+                  
+       idx = 1;
+       while (idx < cpcount) {
+               u4 t;
+
+               /* get constant type */
+               if (!suck_check_classbuffer_size(cb, 1))
+                       return false;
+
+               t = suck_u1(cb);
+
+               switch (t) {
+               case CONSTANT_Class:
+#warning Use list.
+                       nfc = (forward_class*) DumpMemory::allocate(sizeof(forward_class));
+
+                       nfc->next = forward_classes;
+                       forward_classes = nfc;
+
+                       nfc->thisindex = idx;
+                       /* reference to CONSTANT_NameAndType */
+                       if (!suck_check_classbuffer_size(cb, 2))
+                               return false;
+
+                       nfc->name_index = suck_u2(cb);
+
+                       idx++;
+                       break;
+                       
+               case CONSTANT_String:
+#warning Use list.
+                       nfs = (forward_string*) DumpMemory::allocate(sizeof(forward_string));
+                               
+                       nfs->next = forward_strings;
+                       forward_strings = nfs;
+                               
+                       nfs->thisindex = idx;
+
+                       /* reference to CONSTANT_Utf8_info with string characters */
+                       if (!suck_check_classbuffer_size(cb, 2))
+                               return false;
+
+                       nfs->string_index = suck_u2(cb);
+                               
+                       idx++;
+                       break;
+
+               case CONSTANT_NameAndType:
+#warning Use list.
+                       nfn = (forward_nameandtype*) DumpMemory::allocate(sizeof(forward_nameandtype));
+                               
+                       nfn->next = forward_nameandtypes;
+                       forward_nameandtypes = nfn;
+                               
+                       nfn->thisindex = idx;
+
+                       if (!suck_check_classbuffer_size(cb, 2 + 2))
+                               return false;
+
+                       /* reference to CONSTANT_Utf8_info containing simple name */
+                       nfn->name_index = suck_u2(cb);
+
+                       /* reference to CONSTANT_Utf8_info containing field or method
+                          descriptor */
+                       nfn->sig_index = suck_u2(cb);
+                               
+                       idx++;
+                       break;
+
+               case CONSTANT_Fieldref:
+               case CONSTANT_Methodref:
+               case CONSTANT_InterfaceMethodref:
+#warning Use list.
+                       nff = (forward_fieldmethint*) DumpMemory::allocate(sizeof(forward_fieldmethint));
+                       
+                       nff->next = forward_fieldmethints;
+                       forward_fieldmethints = nff;
+
+                       nff->thisindex = idx;
+                       /* constant type */
+                       nff->tag = t;
+
+                       if (!suck_check_classbuffer_size(cb, 2 + 2))
+                               return false;
+
+                       /* class or interface type that contains the declaration of the
+                          field or method */
+                       nff->class_index = suck_u2(cb);
+
+                       /* name and descriptor of the field or method */
+                       nff->nameandtype_index = suck_u2(cb);
+
+                       idx++;
+                       break;
+                               
+               case CONSTANT_Integer: {
+                       constant_integer *ci = NEW(constant_integer);
+
+#if defined(ENABLE_STATISTICS)
+                       if (opt_stat)
+                               count_const_pool_len += sizeof(constant_integer);
+#endif
+
+                       if (!suck_check_classbuffer_size(cb, 4))
+                               return false;
+
+                       ci->value = suck_s4(cb);
+                       cptags[idx] = CONSTANT_Integer;
+                       cpinfos[idx] = ci;
+
+                       idx++;
+                       break;
+               }
+                               
+               case CONSTANT_Float: {
+                       constant_float *cf = NEW(constant_float);
+
+#if defined(ENABLE_STATISTICS)
+                       if (opt_stat)
+                               count_const_pool_len += sizeof(constant_float);
+#endif
+
+                       if (!suck_check_classbuffer_size(cb, 4))
+                               return false;
+
+                       cf->value = suck_float(cb);
+                       cptags[idx] = CONSTANT_Float;
+                       cpinfos[idx] = cf;
+
+                       idx++;
+                       break;
+               }
+                               
+               case CONSTANT_Long: {
+                       constant_long *cl = NEW(constant_long);
+                                       
+#if defined(ENABLE_STATISTICS)
+                       if (opt_stat)
+                               count_const_pool_len += sizeof(constant_long);
+#endif
+
+                       if (!suck_check_classbuffer_size(cb, 8))
+                               return false;
+
+                       cl->value = suck_s8(cb);
+                       cptags[idx] = CONSTANT_Long;
+                       cpinfos[idx] = cl;
+                       idx += 2;
+                       if (idx > cpcount) {
+                               exceptions_throw_classformaterror(c, "Invalid constant pool entry");
+                               return false;
+                       }
+                       break;
+               }
+                       
+               case CONSTANT_Double: {
+                       constant_double *cd = NEW(constant_double);
+                               
+#if defined(ENABLE_STATISTICS)
+                       if (opt_stat)
+                               count_const_pool_len += sizeof(constant_double);
+#endif
+
+                       if (!suck_check_classbuffer_size(cb, 8))
+                               return false;
+
+                       cd->value = suck_double(cb);
+                       cptags[idx] = CONSTANT_Double;
+                       cpinfos[idx] = cd;
+                       idx += 2;
+                       if (idx > cpcount) {
+                               exceptions_throw_classformaterror(c, "Invalid constant pool entry");
+                               return false;
+                       }
+                       break;
+               }
+                               
+               case CONSTANT_Utf8: { 
+                       u4 length;
+
+                       /* number of bytes in the bytes array (not string-length) */
+                       if (!suck_check_classbuffer_size(cb, 2))
+                               return false;
+
+                       length = suck_u2(cb);
+                       cptags[idx] = CONSTANT_Utf8;
+
+                       /* validate the string */
+                       if (!suck_check_classbuffer_size(cb, length))
+                               return false;
+
+#ifdef ENABLE_VERIFIER
+                       if (opt_verify &&
+                               !is_valid_utf((char *) cb->pos, (char *) (cb->pos + length))) 
+                       {
+                               exceptions_throw_classformaterror(c, "Invalid UTF-8 string");
+                               return false;
+                       }
+#endif /* ENABLE_VERIFIER */
+                       /* insert utf-string into the utf-symboltable */
+                       cpinfos[idx] = utf_new((char *) cb->pos, length);
+
+                       /* skip bytes of the string (buffer size check above) */
+                       suck_skip_nbytes(cb, length);
+                       idx++;
+                       break;
+               }
+                                                                               
+               default:
+                       exceptions_throw_classformaterror(c, "Illegal constant pool type");
+                       return false;
+               }  /* end switch */
+       } /* end while */
+
+
+       /* resolve entries in temporary structures */
+
+       while (forward_classes) {
+               utf *name = (utf*) class_getconstant(c, forward_classes->name_index, CONSTANT_Utf8);
+               if (!name)
+                       return false;
+
+#ifdef ENABLE_VERIFIER
+               if (opt_verify && !is_valid_name_utf(name)) {
+                       exceptions_throw_classformaterror(c, "Class reference with invalid name");
+                       return false;
+               }
+#endif /* ENABLE_VERIFIER */
+
+               /* add all class references to the descriptor_pool */
+
+               if (!descriptor_pool_add_class(descpool, name))
+                       return false;
+
+               cptags[forward_classes->thisindex] = CONSTANT_Class;
+
+               /* the classref is created later */
+               cpinfos[forward_classes->thisindex] = name;
+
+               nfc = forward_classes;
+               forward_classes = forward_classes->next;
+       }
+
+       while (forward_strings) {
+               utf *text = (utf*) class_getconstant(c, forward_strings->string_index, CONSTANT_Utf8);
+
+               if (!text)
+                       return false;
+
+               /* resolve utf-string */
+               cptags[forward_strings->thisindex] = CONSTANT_String;
+               cpinfos[forward_strings->thisindex] = text;
+               
+               nfs = forward_strings;
+               forward_strings = forward_strings->next;
+       }
+
+       while (forward_nameandtypes) {
+               constant_nameandtype *cn = NEW(constant_nameandtype);   
+
+#if defined(ENABLE_STATISTICS)
+               if (opt_stat)
+                       count_const_pool_len += sizeof(constant_nameandtype);
+#endif
+
+               /* resolve simple name and descriptor */
+               cn->name = (utf*) class_getconstant(c,
+                                                                                       forward_nameandtypes->name_index,
+                                                                                       CONSTANT_Utf8);
+               if (!cn->name)
+                       return false;
+
+               cn->descriptor = (utf*) class_getconstant(c,
+                                                                                                 forward_nameandtypes->sig_index,
+                                                                                                 CONSTANT_Utf8);
+               if (!cn->descriptor)
+                       return false;
+
+#ifdef ENABLE_VERIFIER
+               if (opt_verify) {
+                       /* check name */
+                       if (!is_valid_name_utf(cn->name)) {
+                               exceptions_throw_classformaterror(c,
+                                                                                                 "Illegal Field name \"%s\"",
+                                                                                                 cn->name->text);
+
+                               return false;
+                       }
+
+                       /* disallow referencing <clinit> among others */
+                       if (cn->name->text[0] == '<' && cn->name != utf_init) {
+                               exceptions_throw_classformaterror(c, "Illegal reference to special method");
+                               return false;
+                       }
+               }
+#endif /* ENABLE_VERIFIER */
+
+               cptags[forward_nameandtypes->thisindex] = CONSTANT_NameAndType;
+               cpinfos[forward_nameandtypes->thisindex] = cn;
+
+               nfn = forward_nameandtypes;
+               forward_nameandtypes = forward_nameandtypes->next;
+       }
+
+       while (forward_fieldmethints) {
+               constant_nameandtype *nat;
+               constant_FMIref *fmi = NEW(constant_FMIref);
+
+#if defined(ENABLE_STATISTICS)
+               if (opt_stat)
+                       count_const_pool_len += sizeof(constant_FMIref);
+#endif
+               /* resolve simple name and descriptor */
+
+               nat = (constant_nameandtype*) class_getconstant(c,
+                                                                                                               forward_fieldmethints->nameandtype_index,
+                                                                                                               CONSTANT_NameAndType);
+
+               if (!nat)
+                       return false;
+
+               /* add all descriptors in {Field,Method}ref to the descriptor_pool */
+
+               if (!descriptor_pool_add(descpool, nat->descriptor, NULL))
+                       return false;
+
+               /* the classref is created later */
+
+               fmi->p.index = forward_fieldmethints->class_index;
+               fmi->name = nat->name;
+               fmi->descriptor = nat->descriptor;
+
+               cptags[forward_fieldmethints->thisindex] = forward_fieldmethints->tag;
+               cpinfos[forward_fieldmethints->thisindex] = fmi;
+       
+               nff = forward_fieldmethints;
+               forward_fieldmethints = forward_fieldmethints->next;
+       }
+
+       /* everything was ok */
+
+       return true;
+}
+
+
+/* loader_load_attribute_signature *********************************************
+
+   Signature_attribute {
+       u2 attribute_name_index;
+          u4 atrribute_length;
+          u2 signature_index;
+   }
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+bool loader_load_attribute_signature(classbuffer *cb, utf **signature)
+{
+       classinfo *c;
+       u4         attribute_length;
+       u2         signature_index;
+
+       /* get classinfo */
+
+       c = cb->clazz;
+
+       /* check remaining bytecode */
+
+       if (!suck_check_classbuffer_size(cb, 4 + 2))
+               return false;
+
+       /* check attribute length */
+
+       attribute_length = suck_u4(cb);
+
+       if (attribute_length != 2) {
+               exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute");
+               return false;
+       }
+
+       if (*signature != NULL) {
+               exceptions_throw_classformaterror(c, "Multiple Signature attributes");
+               return false;
+       }
+
+       /* get signature */
+
+       signature_index = suck_u2(cb);
+
+       *signature = (utf*) class_getconstant(c, signature_index, CONSTANT_Utf8);
+
+       if (*signature == NULL)
+               return false;
+
+       return true;
+}
+#endif /* defined(ENABLE_JAVASE) */
+
+
+/* load_class_from_sysloader ***************************************************
+
+   Load the class with the given name using the system class loader
+
+   IN:
+       name.............the classname
+
+   RETURN VALUE:
+       the loaded class, or
+          NULL if an exception has been thrown
+
+*******************************************************************************/
+
+classinfo *load_class_from_sysloader(utf *name)
+{
+       methodinfo    *m;
+       java_handle_t *clo;
+       classloader_t *cl;
+       classinfo     *c;
+
+       assert(class_java_lang_Object);
+       assert(class_java_lang_ClassLoader);
+       assert(class_java_lang_ClassLoader->state & CLASS_LINKED);
+       
+       m = class_resolveclassmethod(class_java_lang_ClassLoader,
+                                                                utf_getSystemClassLoader,
+                                                                utf_void__java_lang_ClassLoader,
+                                                                class_java_lang_Object,
+                                                                false);
+
+       if (!m)
+               return false;
+
+       clo = vm_call_method(m, NULL);
+
+       if (!clo)
+               return false;
+
+       cl = loader_hashtable_classloader_add(clo);
+
+       c = load_class_from_classloader(name, cl);
+
+       return c;
+}
+
+
+/* load_class_from_classloader *************************************************
+
+   Load the class with the given name using the given user-defined class loader.
+
+   IN:
+       name.............the classname
+          cl...............user-defined class loader
+          
+   RETURN VALUE:
+       the loaded class, or
+          NULL if an exception has been thrown
+
+*******************************************************************************/
+
+classinfo *load_class_from_classloader(utf *name, classloader_t *cl)
+{
+       java_handle_t *o;
+       classinfo     *c;
+       classinfo     *tmpc;
+       java_handle_t *string;
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_lookup, time_prepare, time_java, 
+                                       time_cache;
+#endif
+
+       RT_TIMING_GET_TIME(time_start);
+
+       assert(name);
+
+       /* lookup if this class has already been loaded */
+
+       c = classcache_lookup(cl, name);
+
+       RT_TIMING_GET_TIME(time_lookup);
+       RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_CL_LOOKUP);
+
+       if (c != NULL)
+               return c;
+
+       /* if other class loader than bootstrap, call it */
+
+       if (cl != NULL) {
+               methodinfo *lc;
+               char       *text;
+               s4          namelen;
+
+               text = name->text;
+               namelen = name->blength;
+
+               /* handle array classes */
+               if (text[0] == '[') {
+                       classinfo *comp;
+                       utf       *u;
+
+                       switch (text[1]) {
+                       case 'L':
+                               /* check for cases like `[L;' or `[L[I;' or `[Ljava.lang.Object' */
+                               if (namelen < 4 || text[2] == '[' || text[namelen - 1] != ';') {
+                                       exceptions_throw_classnotfoundexception(name);
+                                       return false;
+                               }
+
+                               u = utf_new(text + 2, namelen - 3);
+
+                               if (!(comp = load_class_from_classloader(u, cl)))
+                                       return false;
+
+                               /* create the array class */
+
+                               c = class_array_of(comp, false);
+
+                               tmpc = classcache_store(cl, c, true);
+
+                               if (tmpc == NULL) {
+                                       /* exception, free the loaded class */
+                                       c->state &= ~CLASS_LOADING;
+                                       class_free(c);
+                               }
+
+                               return tmpc;
+
+                       case '[':
+                               /* load the component class */
+
+                               u = utf_new(text + 1, namelen - 1);
+
+                               if (!(comp = load_class_from_classloader(u, cl)))
+                                       return false;
+
+                               /* create the array class */
+
+                               c = class_array_of(comp, false);
+
+                               tmpc = classcache_store(cl, c, true);
+
+                               if (tmpc == NULL) {
+                                       /* exception, free the loaded class */
+                                       c->state &= ~CLASS_LOADING;
+                                       class_free(c);
+                               }
+
+                               return tmpc;
+
+                       default:
+                               /* primitive array classes are loaded by the bootstrap loader */
+
+                               c = load_class_bootstrap(name);
+
+                               return c;
+                       }
+               }
+
+               LLNI_class_get(cl, c);
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+               /* OpenJDK uses this internal function because it's
+                  synchronized. */
+
+               lc = class_resolveclassmethod(c,
+                                                                         utf_loadClassInternal,
+                                                                         utf_java_lang_String__java_lang_Class,
+                                                                         NULL,
+                                                                         true);
+#else
+               lc = class_resolveclassmethod(c,
+                                                                         utf_loadClass,
+                                                                         utf_java_lang_String__java_lang_Class,
+                                                                         NULL,
+                                                                         true);
+#endif
+
+               if (lc == NULL)
+                       return false; /* exception */
+
+               /* move return value into `o' and cast it afterwards to a classinfo* */
+
+               string = javastring_new_slash_to_dot(name);
+
+               RT_TIMING_GET_TIME(time_prepare);
+
+               o = vm_call_method(lc, (java_handle_t *) cl, string);
+
+               RT_TIMING_GET_TIME(time_java);
+
+               c = LLNI_classinfo_unwrap(o);
+
+               if (c != NULL) {
+                       /* Store this class in the loaded class cache. If another
+                          class with the same (initloader,name) pair has been
+                          stored earlier it will be returned by classcache_store
+                          In this case classcache_store may not free the class
+                          because it has already been exposed to Java code which
+                          may have kept references to that class. */
+
+                   tmpc = classcache_store(cl, c, false);
+
+                       if (tmpc == NULL) {
+                               /* exception, free the loaded class */
+                               c->state &= ~CLASS_LOADING;
+                               class_free(c);
+                       }
+
+                       c = tmpc;
+               }
+
+               RT_TIMING_GET_TIME(time_cache);
+
+               RT_TIMING_TIME_DIFF(time_lookup , time_prepare, RT_TIMING_LOAD_CL_PREPARE);
+               RT_TIMING_TIME_DIFF(time_prepare, time_java   , RT_TIMING_LOAD_CL_JAVA);
+               RT_TIMING_TIME_DIFF(time_java   , time_cache  , RT_TIMING_LOAD_CL_CACHE);
+
+               /* SUN compatible -verbose:class output */
+
+               if (opt_verboseclass && (c != NULL) && (c->classloader == cl)) {
+                       printf("[Loaded ");
+                       utf_display_printable_ascii_classname(name);
+                       printf("]\n");
+               }
+
+#if defined(ENABLE_JVMTI)
+               /* fire Class Load JVMTI event */
+               if (jvmti) jvmti_ClassLoadPrepare(false, c);
+#endif
+
+
+               return c;
+       } 
+
+       c = load_class_bootstrap(name);
+
+       return c;
+}
+
+
+/* load_class_bootstrap ********************************************************
+       
+   Load the class with the given name using the bootstrap class loader.
+
+   IN:
+       name.............the classname
+
+   RETURN VALUE:
+       loaded classinfo, or
+          NULL if an exception has been thrown
+
+   SYNCHRONIZATION:
+       load_class_bootstrap is synchronized. It can be treated as an
+          atomic operation.
+
+*******************************************************************************/
+
+classinfo *load_class_bootstrap(utf *name)
+{
+       classbuffer *cb;
+       classinfo   *c;
+       classinfo   *r;
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_lookup, time_array, time_suck, 
+                                       time_load, time_cache;
+#endif
+
+       RT_TIMING_GET_TIME(time_start);
+
+       /* for debugging */
+
+       assert(name);
+
+       /* lookup if this class has already been loaded */
+
+       r = classcache_lookup(NULL, name);
+
+       if (r != NULL) {
+               RT_TIMING_GET_TIME(time_lookup);
+               RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_BOOT_LOOKUP);
+               
+               return r;
+       }
+
+       RT_TIMING_GET_TIME(time_lookup);
+       RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_BOOT_LOOKUP);
+               
+       /* create the classinfo */
+
+       c = class_create_classinfo(name);
+
+       /* handle array classes */
+
+       if (name->text[0] == '[') {
+               c = load_newly_created_array(c, NULL);
+
+               if (c == NULL)
+                       return NULL;
+
+               assert(c->state & CLASS_LOADED);
+
+               RT_TIMING_GET_TIME(time_array);
+               RT_TIMING_TIME_DIFF(time_start,time_array,RT_TIMING_LOAD_BOOT_ARRAY);
+               
+               return c;
+       }
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getcompilingtime)
+               compilingtime_stop();
+
+       if (opt_getloadingtime)
+               loadingtime_start();
+#endif
+
+       /* load classdata, throw exception on error */
+
+       cb = suck_start(c);
+
+       if (cb == NULL) {
+               exceptions_throw_classnotfoundexception(name);
+               return NULL;
+       }
+
+       RT_TIMING_GET_TIME(time_suck);
+       
+       /* load the class from the buffer */
+
+       r = load_class_from_classbuffer(cb);
+
+       RT_TIMING_GET_TIME(time_load);
+       
+       if (r == NULL) {
+               /* the class could not be loaded, free the classinfo struct */
+
+               class_free(c);
+       }
+       else {
+               /* Store this class in the loaded class cache this step also
+                  checks the loading constraints. If the class has been
+                  loaded before, the earlier loaded class is returned. */
+
+               classinfo *res = classcache_store(NULL, c, true);
+
+               if (res == NULL) {
+                       /* exception */
+                       class_free(c);
+               }
+               else {
+                       // Add the package name to the boot packages.
+                       Package::add(c->packagename);
+               }
+
+               r = res;
+       }
+
+       RT_TIMING_GET_TIME(time_cache);
+       
+       /* SUN compatible -verbose:class output */
+
+       if (opt_verboseclass && r) {
+               printf("[Loaded ");
+               utf_display_printable_ascii_classname(name);
+               printf(" from %s]\n", cb->path);
+       }
+
+       /* free memory */
+
+       suck_stop(cb);
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getloadingtime)
+               loadingtime_stop();
+
+       if (opt_getcompilingtime)
+               compilingtime_start();
+#endif
+
+       RT_TIMING_TIME_DIFF(time_lookup, time_suck , RT_TIMING_LOAD_BOOT_SUCK);
+       RT_TIMING_TIME_DIFF(time_suck  , time_load , RT_TIMING_LOAD_BOOT_LOAD);
+       RT_TIMING_TIME_DIFF(time_load  , time_cache, RT_TIMING_LOAD_BOOT_CACHE);
+       RT_TIMING_TIME_DIFF(time_lookup, time_cache, RT_TIMING_LOAD_BOOT_TOTAL);
+
+       return r;
+}
+
+
+/* load_class_from_classbuffer_intern ******************************************
+       
+   Loads a class from a classbuffer into a given classinfo structure.
+   Super-classes are also loaded at this point and some verfication
+   checks are done.
+
+   SYNCHRONIZATION:
+       This function is NOT synchronized!
+   
+*******************************************************************************/
+
+static bool load_class_from_classbuffer_intern(classbuffer *cb)
+{
+       classinfo          *c;
+       classinfo          *tc;
+       utf                *name;
+       utf                *supername;
+       utf               **interfacesnames;
+       utf                *u;
+       constant_classref  *cr;
+       int16_t             index;
+
+       u4 ma, mi;
+       descriptor_pool *descpool;
+#if defined(ENABLE_STATISTICS)
+       u4 classrefsize;
+       u4 descsize;
+#endif
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_checks, time_ndpool, time_cpool,
+                                       time_setup, time_fields, time_methods, time_classrefs,
+                                       time_descs,     time_setrefs, time_parsefds, time_parsemds,
+                                       time_parsecpool, time_verify, time_attrs;
+#endif
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       RT_TIMING_GET_TIME(time_start);
+
+       /* Get the classbuffer's class. */
+
+       c = cb->clazz;
+
+       if (!suck_check_classbuffer_size(cb, 4 + 2 + 2))
+               return false;
+
+       /* check signature */
+
+       if (suck_u4(cb) != MAGIC) {
+               exceptions_throw_classformaterror(c, "Bad magic number");
+               return false;
+       }
+
+       /* check version */
+
+       mi = suck_u2(cb);
+       ma = suck_u2(cb);
+
+       if (!(ma < MAJOR_VERSION || (ma == MAJOR_VERSION && mi <= MINOR_VERSION))) {
+               exceptions_throw_unsupportedclassversionerror(c, ma, mi);
+               return false;
+       }
+
+       RT_TIMING_GET_TIME(time_checks);
+
+       /* create a new descriptor pool */
+
+       descpool = descriptor_pool_new(c);
+
+       RT_TIMING_GET_TIME(time_ndpool);
+
+       /* load the constant pool */
+
+       if (!load_constantpool(cb, descpool))
+               return false;
+
+       RT_TIMING_GET_TIME(time_cpool);
+
+       /* ACC flags */
+
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       /* We OR the flags here, as we set already some flags in
+          class_create_classinfo. */
+
+       c->flags |= suck_u2(cb);
+
+       /* check ACC flags consistency */
+
+       if (c->flags & ACC_INTERFACE) {
+               if (!(c->flags & ACC_ABSTRACT)) {
+                       /* We work around this because interfaces in JDK 1.1 are
+                        * not declared abstract. */
+
+                       c->flags |= ACC_ABSTRACT;
+               }
+
+               if (c->flags & ACC_FINAL) {
+                       exceptions_throw_classformaterror(c,
+                                                                                         "Illegal class modifiers: 0x%X",
+                                                                                         c->flags);
+                       return false;
+               }
+
+               if (c->flags & ACC_SUPER) {
+                       c->flags &= ~ACC_SUPER; /* kjc seems to set this on interfaces */
+               }
+       }
+
+       if ((c->flags & (ACC_ABSTRACT | ACC_FINAL)) == (ACC_ABSTRACT | ACC_FINAL)) {
+               exceptions_throw_classformaterror(c,
+                                                                                 "Illegal class modifiers: 0x%X",
+                                                                                 c->flags);
+               return false;
+       }
+
+       if (!suck_check_classbuffer_size(cb, 2 + 2))
+               return false;
+
+       /* This class. */
+
+       index = suck_u2(cb);
+
+       name = (utf *) class_getconstant(c, index, CONSTANT_Class);
+
+       if (name == NULL)
+               return false;
+
+       if (c->name == utf_not_named_yet) {
+               /* we finally have a name for this class */
+               c->name = name;
+               class_set_packagename(c);
+       }
+       else if (name != c->name) {
+               exceptions_throw_noclassdeffounderror_wrong_name(c, name);
+               return false;
+       }
+
+       /* Retrieve superclass. */
+
+       c->super = NULL;
+
+       index = suck_u2(cb);
+
+       if (index == 0) {
+               supername = NULL;
+
+               /* This is only allowed for java.lang.Object. */
+
+               if (c->name != utf_java_lang_Object) {
+                       exceptions_throw_classformaterror(c, "Bad superclass index");
+                       return false;
+               }
+       }
+       else {
+               supername = (utf *) class_getconstant(c, index, CONSTANT_Class);
+
+               if (supername == NULL)
+                       return false;
+
+               /* java.lang.Object may not have a super class. */
+
+               if (c->name == utf_java_lang_Object) {
+                       exceptions_throw_classformaterror(NULL, "java.lang.Object with superclass");
+                       return false;
+               }
+
+               /* Detect circularity. */
+
+               if (supername == c->name) {
+                       exceptions_throw_classcircularityerror(c);
+                       return false;
+               }
+
+               /* Interfaces must have java.lang.Object as super class. */
+
+               if ((c->flags & ACC_INTERFACE) && (supername != utf_java_lang_Object)) {
+                       exceptions_throw_classformaterror(c, "Interfaces must have java.lang.Object as superclass");
+                       return false;
+               }
+       }
+
+       /* Parse the super interfaces. */
+
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       c->interfacescount = suck_u2(cb);
+
+       if (!suck_check_classbuffer_size(cb, 2 * c->interfacescount))
+               return false;
+
+       c->interfaces = MNEW(classinfo*, c->interfacescount);
+
+       /* Get the names of the super interfaces. */
+
+       interfacesnames = (utf**) DumpMemory::allocate(sizeof(utf*) * c->interfacescount);
+
+       for (int32_t i = 0; i < c->interfacescount; i++) {
+               index = suck_u2(cb);
+
+               u = (utf *) class_getconstant(c, index, CONSTANT_Class);
+
+               if (u == NULL)
+                       return false;
+
+               interfacesnames[i] = u;
+       }
+
+       RT_TIMING_GET_TIME(time_setup);
+
+       /* Parse fields. */
+
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       c->fieldscount = suck_u2(cb);
+       c->fields      = MNEW(fieldinfo, c->fieldscount);
+
+       MZERO(c->fields, fieldinfo, c->fieldscount);
+
+       for (int32_t i = 0; i < c->fieldscount; i++) {
+               if (!field_load(cb, &(c->fields[i]), descpool))
+                       return false;
+       }
+
+       RT_TIMING_GET_TIME(time_fields);
+
+       /* Parse methods. */
+
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       c->methodscount = suck_u2(cb);
+       c->methods      = MNEW(methodinfo, c->methodscount);
+
+       MZERO(c->methods, methodinfo, c->methodscount);
+       
+       for (int32_t i = 0; i < c->methodscount; i++) {
+               if (!method_load(cb, &(c->methods[i]), descpool))
+                       return false;
+       }
+
+       RT_TIMING_GET_TIME(time_methods);
+
+       /* create the class reference table */
+
+       c->classrefs =
+               descriptor_pool_create_classrefs(descpool, &(c->classrefcount));
+
+       RT_TIMING_GET_TIME(time_classrefs);
+
+       /* allocate space for the parsed descriptors */
+
+       descriptor_pool_alloc_parsed_descriptors(descpool);
+       c->parseddescs = (u1*) descriptor_pool_get_parsed_descriptors(descpool, &(c->parseddescsize));
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat) {
+               descriptor_pool_get_sizes(descpool, &classrefsize, &descsize);
+               count_classref_len += classrefsize;
+               count_parsed_desc_len += descsize;
+       }
+#endif
+
+       RT_TIMING_GET_TIME(time_descs);
+
+       /* put the classrefs in the constant pool */
+
+       for (int32_t i = 0; i < c->cpcount; i++) {
+               if (c->cptags[i] == CONSTANT_Class) {
+                       utf *name = (utf *) c->cpinfos[i];
+                       c->cpinfos[i] = descriptor_pool_lookup_classref(descpool, name);
+               }
+       }
+
+       /* Resolve the super class. */
+
+       if (supername != NULL) {
+               cr = descriptor_pool_lookup_classref(descpool, supername);
+
+               if (cr == NULL)
+                       return false;
+
+               /* XXX This should be done better. */
+               tc = resolve_classref_or_classinfo_eager(CLASSREF_OR_CLASSINFO(cr), false);
+
+               if (tc == NULL) {
+                       resolve_handle_pending_exception(true);
+                       return false;
+               }
+
+               /* Interfaces are not allowed as super classes. */
+
+               if (tc->flags & ACC_INTERFACE) {
+                       exceptions_throw_incompatibleclasschangeerror(c, "class %s has interface %s as super class");
+                       return false;
+               }
+
+               /* Don't allow extending final classes */
+
+               if (tc->flags & ACC_FINAL) {
+                       exceptions_throw_verifyerror(NULL,
+                                                                                "Cannot inherit from final class");
+                       return false;
+               }
+
+               /* Store the super class. */
+
+               c->super = tc;
+       }
+
+       /* Resolve the super interfaces. */
+
+       for (int32_t i = 0; i < c->interfacescount; i++) {
+               u  = interfacesnames[i];
+               cr = descriptor_pool_lookup_classref(descpool, u);
+
+               if (cr == NULL)
+                       return false;
+
+               /* XXX This should be done better. */
+               tc = resolve_classref_or_classinfo_eager(CLASSREF_OR_CLASSINFO(cr), false);
+
+               if (tc == NULL) {
+                       resolve_handle_pending_exception(true);
+                       return false;
+               }
+
+               /* Detect circularity. */
+
+               if (tc == c) {
+                       exceptions_throw_classcircularityerror(c);
+                       return false;
+               }
+
+               if (!(tc->flags & ACC_INTERFACE)) {
+                       exceptions_throw_incompatibleclasschangeerror(tc,
+                                                                                                                 "Implementing class");
+                       return false;
+               }
+
+               /* Store the super interface. */
+
+               c->interfaces[i] = tc;
+       }
+
+       RT_TIMING_GET_TIME(time_setrefs);
+
+       /* Parse the field descriptors. */
+
+       for (int32_t i = 0; i < c->fieldscount; i++) {
+               c->fields[i].parseddesc =
+                       descriptor_pool_parse_field_descriptor(descpool,
+                                                                                                  c->fields[i].descriptor);
+               if (!c->fields[i].parseddesc)
+                       return false;
+       }
+
+       RT_TIMING_GET_TIME(time_parsefds);
+
+       /* parse method descriptors */
+
+       for (int32_t i = 0; i < c->methodscount; i++) {
+               methodinfo *m = &c->methods[i];
+               m->parseddesc =
+                       descriptor_pool_parse_method_descriptor(descpool, m->descriptor,
+                                                                                                       m->flags, class_get_self_classref(m->clazz));
+               if (!m->parseddesc)
+                       return false;
+
+               for (int32_t j = 0; j < m->rawexceptiontablelength; j++) {
+                       if (!m->rawexceptiontable[j].catchtype.any)
+                               continue;
+
+                       if ((m->rawexceptiontable[j].catchtype.ref =
+                                descriptor_pool_lookup_classref(descpool,
+                                               (utf *) m->rawexceptiontable[j].catchtype.any)) == NULL)
+                               return false;
+               }
+
+               for (int32_t j = 0; j < m->thrownexceptionscount; j++) {
+                       if (!m->thrownexceptions[j].any)
+                               continue;
+
+                       if ((m->thrownexceptions[j].ref = descriptor_pool_lookup_classref(descpool,
+                                               (utf *) m->thrownexceptions[j].any)) == NULL)
+                               return false;
+               }
+       }
+
+       RT_TIMING_GET_TIME(time_parsemds);
+
+       /* parse the loaded descriptors */
+
+       for (int32_t i = 0; i < c->cpcount; i++) {
+               constant_FMIref *fmi;
+               s4               index;
+
+               switch (c->cptags[i]) {
+               case CONSTANT_Fieldref:
+                       fmi = (constant_FMIref *) c->cpinfos[i];
+                       fmi->parseddesc.fd =
+                               descriptor_pool_parse_field_descriptor(descpool,
+                                                                                                          fmi->descriptor);
+                       if (!fmi->parseddesc.fd)
+                               return false;
+
+                       index = fmi->p.index;
+                       fmi->p.classref =
+                               (constant_classref *) class_getconstant(c, index,
+                                                                                                               CONSTANT_Class);
+                       if (!fmi->p.classref)
+                               return false;
+                       break;
+               case CONSTANT_Methodref:
+               case CONSTANT_InterfaceMethodref:
+                       fmi = (constant_FMIref *) c->cpinfos[i];
+                       index = fmi->p.index;
+                       fmi->p.classref =
+                               (constant_classref *) class_getconstant(c, index,
+                                                                                                               CONSTANT_Class);
+                       if (!fmi->p.classref)
+                               return false;
+                       fmi->parseddesc.md =
+                               descriptor_pool_parse_method_descriptor(descpool,
+                                                                                                               fmi->descriptor,
+                                                                                                               ACC_UNDEF,
+                                                                                                               fmi->p.classref);
+                       if (!fmi->parseddesc.md)
+                               return false;
+                       break;
+               }
+       }
+
+       RT_TIMING_GET_TIME(time_parsecpool);
+
+#ifdef ENABLE_VERIFIER
+       /* Check if all fields and methods can be uniquely
+        * identified by (name,descriptor). */
+
+       if (opt_verify) {
+               /* We use a hash table here to avoid making the
+                * average case quadratic in # of methods, fields.
+                */
+               static int shift = 0;
+               u2 *hashtab;
+               u2 *next; /* for chaining colliding hash entries */
+               int32_t len;
+               int32_t hashlen;
+               u2 index;
+               u2 old;
+
+               /* Allocate hashtable */
+               len = c->methodscount;
+               if (len < c->fieldscount) len = c->fieldscount;
+               hashlen = 5 * len;
+               hashtab = MNEW(u2,(hashlen + len));
+               next = hashtab + hashlen;
+
+               /* Determine bitshift (to get good hash values) */
+               if (!shift) {
+                       len = sizeof(utf);
+                       while (len) {
+                               len >>= 1;
+                               shift++;
+                       }
+               }
+
+               /* Check fields */
+               memset(hashtab, 0, sizeof(u2) * (hashlen + len));
+
+               for (int32_t i = 0; i < c->fieldscount; ++i) {
+                       fieldinfo *fi = c->fields + i;
+
+                       /* It's ok if we lose bits here */
+                       index = ((((size_t) fi->name) +
+                                         ((size_t) fi->descriptor)) >> shift) % hashlen;
+
+                       if ((old = hashtab[index])) {
+                               old--;
+                               next[i] = old;
+                               do {
+                                       if (c->fields[old].name == fi->name &&
+                                               c->fields[old].descriptor == fi->descriptor) {
+                                               exceptions_throw_classformaterror(c, "Repetitive field name/signature");
+                                               return false;
+                                       }
+                               } while ((old = next[old]));
+                       }
+                       hashtab[index] = i + 1;
+               }
+
+               /* Check methods */
+               memset(hashtab, 0, sizeof(u2) * (hashlen + hashlen/5));
+
+               for (int32_t i = 0; i < c->methodscount; ++i) {
+                       methodinfo *mi = c->methods + i;
+
+                       /* It's ok if we lose bits here */
+                       index = ((((size_t) mi->name) +
+                                         ((size_t) mi->descriptor)) >> shift) % hashlen;
+
+                       if ((old = hashtab[index])) {
+                               old--;
+                               next[i] = old;
+                               do {
+                                       if (c->methods[old].name == mi->name &&
+                                               c->methods[old].descriptor == mi->descriptor) {
+                                               exceptions_throw_classformaterror(c, "Repetitive method name/signature");
+                                               return false;
+                                       }
+                               } while ((old = next[old]));
+                       }
+                       hashtab[index] = i + 1;
+               }
+
+               MFREE(hashtab, u2, (hashlen + len));
+       }
+#endif /* ENABLE_VERIFIER */
+
+       RT_TIMING_GET_TIME(time_verify);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat) {
+               size_classinfo  += sizeof(classinfo*) * c->interfacescount;
+               size_fieldinfo  += sizeof(fieldinfo)  * c->fieldscount;
+               size_methodinfo += sizeof(methodinfo) * c->methodscount;
+       }
+#endif
+
+       /* load attribute structures */
+
+       if (!class_load_attributes(cb))
+               return false;
+
+       /* Pre Java 1.5 version don't check this. This implementation is
+          like Java 1.5 do it: for class file version 45.3 we don't check
+          it, older versions are checked. */
+
+       if (((ma == 45) && (mi > 3)) || (ma > 45)) {
+               /* check if all data has been read */
+               s4 classdata_left = ((cb->data + cb->size) - cb->pos);
+
+               if (classdata_left > 0) {
+                       exceptions_throw_classformaterror(c, "Extra bytes at the end of class file");
+                       return false;
+               }
+       }
+
+       RT_TIMING_GET_TIME(time_attrs);
+
+       RT_TIMING_TIME_DIFF(time_start     , time_checks    , RT_TIMING_LOAD_CHECKS);
+       RT_TIMING_TIME_DIFF(time_checks    , time_ndpool    , RT_TIMING_LOAD_NDPOOL);
+       RT_TIMING_TIME_DIFF(time_ndpool    , time_cpool     , RT_TIMING_LOAD_CPOOL);
+       RT_TIMING_TIME_DIFF(time_cpool     , time_setup     , RT_TIMING_LOAD_SETUP);
+       RT_TIMING_TIME_DIFF(time_setup     , time_fields    , RT_TIMING_LOAD_FIELDS);
+       RT_TIMING_TIME_DIFF(time_fields    , time_methods   , RT_TIMING_LOAD_METHODS);
+       RT_TIMING_TIME_DIFF(time_methods   , time_classrefs , RT_TIMING_LOAD_CLASSREFS);
+       RT_TIMING_TIME_DIFF(time_classrefs , time_descs     , RT_TIMING_LOAD_DESCS);
+       RT_TIMING_TIME_DIFF(time_descs     , time_setrefs   , RT_TIMING_LOAD_SETREFS);
+       RT_TIMING_TIME_DIFF(time_setrefs   , time_parsefds  , RT_TIMING_LOAD_PARSEFDS);
+       RT_TIMING_TIME_DIFF(time_parsefds  , time_parsemds  , RT_TIMING_LOAD_PARSEMDS);
+       RT_TIMING_TIME_DIFF(time_parsemds  , time_parsecpool, RT_TIMING_LOAD_PARSECP);
+       RT_TIMING_TIME_DIFF(time_parsecpool, time_verify    , RT_TIMING_LOAD_VERIFY);
+       RT_TIMING_TIME_DIFF(time_verify    , time_attrs     , RT_TIMING_LOAD_ATTRS);
+       RT_TIMING_TIME_DIFF(time_start     , time_attrs     , RT_TIMING_LOAD_TOTAL);
+
+       return true;
+}
+
+
+/* load_class_from_classbuffer *************************************************
+
+   Convenience wrapper for load_class_from_classbuffer.
+
+   SYNCHRONIZATION:
+       This function is NOT synchronized!
+   
+*******************************************************************************/
+
+classinfo *load_class_from_classbuffer(classbuffer *cb)
+{
+       classinfo *c;
+       bool       result;
+
+       /* Get the classbuffer's class. */
+
+       c = cb->clazz;
+
+       /* Check if the class is already loaded. */
+
+       if (c->state & CLASS_LOADED)
+               return c;
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               count_class_loads++;
+#endif
+
+#if !defined(NDEBUG)
+       if (loadverbose)
+               log_message_class("Loading class: ", c);
+#endif
+
+       /* Class is currently loading. */
+
+       c->state |= CLASS_LOADING;
+
+       /* Parse the classbuffer. */
+
+       result = load_class_from_classbuffer_intern(cb);
+
+       /* An error occurred. */
+
+       if (result == false) {
+               /* Revert loading state. */
+
+               c->state = (c->state & ~CLASS_LOADING);
+
+               return NULL;
+       }
+
+       /* Revert loading state and set loaded. */
+
+       c->state = (c->state & ~CLASS_LOADING) | CLASS_LOADED;
+
+#if defined(ENABLE_JVMTI)
+       /* fire Class Prepare JVMTI event */
+
+       if (jvmti)
+               jvmti_ClassLoadPrepare(true, c);
+#endif
+
+#if !defined(NDEBUG)
+       if (loadverbose)
+               log_message_class("Loading done class: ", c);
+#endif
+
+       return c;
+}
+
+
+/* load_newly_created_array ****************************************************
+
+   Load a newly created array class.
+
+       RETURN VALUE:
+           c....................the array class C has been loaded
+               other classinfo......the array class was found in the class cache, 
+                                    C has been freed
+           NULL.................an exception has been thrown
+
+       Note:
+               This is an internal function. Do not use it unless you know exactly
+               what you are doing!
+
+               Use one of the load_class_... functions for general array class loading.
+
+*******************************************************************************/
+
+classinfo *load_newly_created_array(classinfo *c, classloader_t *loader)
+{
+       classinfo         *comp = NULL;
+       methodinfo        *clone;
+       methoddesc        *clonedesc;
+       constant_classref *classrefs;
+       char              *text;
+       s4                 namelen;
+       utf               *u;
+
+       text    = c->name->text;
+       namelen = c->name->blength;
+
+       /* Check array class name */
+
+       if ((namelen < 2) || (text[0] != '[')) {
+               exceptions_throw_classnotfoundexception(c->name);
+               return NULL;
+       }
+
+       /* Check the element type */
+
+       switch (text[1]) {
+       case '[':
+               /* c is an array of arrays. We have to create the component class. */
+
+               u = utf_new(text + 1, namelen - 1);
+
+               comp = load_class_from_classloader(u, loader);
+
+               if (comp == NULL)
+                       return NULL;
+
+               assert(comp->state & CLASS_LOADED);
+
+               /* the array's flags are that of the component class */
+               c->flags = (comp->flags & ~ACC_INTERFACE) | ACC_FINAL | ACC_ABSTRACT;
+               c->classloader = comp->classloader;
+               break;
+
+       case 'L':
+               /* c is an array of objects. */
+
+               /* check for cases like `[L;' or `[L[I;' or `[Ljava.lang.Object' */
+               if ((namelen < 4) || (text[2] == '[') || (text[namelen - 1] != ';')) {
+                       exceptions_throw_classnotfoundexception(c->name);
+                       return NULL;
+               }
+
+               u = utf_new(text + 2, namelen - 3);
+
+               if (!(comp = load_class_from_classloader(u, loader)))
+                       return NULL;
+
+               assert(comp->state & CLASS_LOADED);
+
+               /* the array's flags are that of the component class */
+               c->flags = (comp->flags & ~ACC_INTERFACE) | ACC_FINAL | ACC_ABSTRACT;
+               c->classloader = comp->classloader;
+               break;
+
+       default:
+               /* c is an array of a primitive type */
+
+               /* check for cases like `[II' and whether the character is a
+                  valid primitive type */
+
+               if ((namelen > 2) || (Primitive::get_class_by_char(text[1]) == NULL)) {
+                       exceptions_throw_classnotfoundexception(c->name);
+                       return NULL;
+               }
+
+               /* the accessibility of the array class is public (VM Spec 5.3.3) */
+               c->flags = ACC_PUBLIC | ACC_FINAL | ACC_ABSTRACT;
+               c->classloader = NULL;
+       }
+
+       assert(class_java_lang_Object);
+#if defined(ENABLE_JAVASE)
+       assert(class_java_lang_Cloneable);
+       assert(class_java_io_Serializable);
+#endif
+
+       /* Setup the array class. */
+
+       c->super = class_java_lang_Object;
+
+#if defined(ENABLE_JAVASE)
+
+       c->interfacescount = 2;
+    c->interfaces      = MNEW(classinfo*, 2);
+       c->interfaces[0]   = class_java_lang_Cloneable;
+       c->interfaces[1]   = class_java_io_Serializable;
+
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+
+       c->interfacescount = 0;
+       c->interfaces      = NULL;
+
+#else
+# error unknow Java configuration
+#endif
+
+       c->methodscount = 1;
+       c->methods      = MNEW(methodinfo, c->methodscount);
+
+       MZERO(c->methods, methodinfo, c->methodscount);
+
+       classrefs = MNEW(constant_classref, 2);
+
+       CLASSREF_INIT(classrefs[0], c, c->name);
+       CLASSREF_INIT(classrefs[1], c, utf_java_lang_Object);
+
+       /* create descriptor for clone method */
+       /* we need one paramslot which is reserved for the 'this' parameter */
+       clonedesc = NEW(methoddesc);
+       clonedesc->returntype.type = TYPE_ADR;
+       clonedesc->returntype.classref = classrefs + 1;
+       clonedesc->returntype.arraydim = 0;
+       /* initialize params to "empty", add real params below in
+          descriptor_params_from_paramtypes */
+       clonedesc->paramcount = 0;
+       clonedesc->paramslots = 0;
+       clonedesc->paramtypes[0].classref = classrefs + 0;
+       clonedesc->params = NULL;
+
+       /* create methodinfo */
+
+       clone = c->methods;
+       MSET(clone, 0, methodinfo, 1);
+
+       /* 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;
+       clone->parseddesc = clonedesc;
+       clone->clazz      = c;
+
+       /* parse the descriptor to get the register allocation */
+
+       if (!descriptor_params_from_paramtypes(clonedesc, clone->flags))
+               return false;
+
+       clone->code = NativeStub::generate(clone, BUILTIN_clone);
+
+       /* XXX: field: length? */
+
+       /* array classes are not loaded from class files */
+
+       c->state          |= CLASS_LOADED;
+       c->parseddescs    = (u1 *) clonedesc;
+       c->parseddescsize = sizeof(methodinfo);
+       c->classrefs      = classrefs;
+       c->classrefcount  = 1;
+
+       /* insert class into the loaded class cache */
+       /* XXX free classinfo if NULL returned? */
+
+       return classcache_store(loader, c, true);
+}
+
+
+/* loader_close ****************************************************************
+
+   Frees all resources.
+       
+*******************************************************************************/
+
+void loader_close(void)
+{
+       /* empty */
+}
+
+
+/*
+ * 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/loader.hpp b/src/vm/loader.hpp
new file mode 100644 (file)
index 0000000..3e30e4a
--- /dev/null
@@ -0,0 +1,191 @@
+/* src/vm/loader.hpp - class loader 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 _LOADER_HPP
+#define _LOADER_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct classbuffer classbuffer;
+
+
+#include "config.h"
+
+#include <stdio.h>
+
+#include "vm/types.h"
+
+#include "vm/descriptor.h"
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/method.hpp"
+#include "vm/references.h"
+#include "vm/utf8.h"
+
+
+/* constant pool entries *******************************************************
+
+       All constant pool entries need a data structure which contain the entrys
+       value. In some cases this structure exist already, in the remaining cases
+       this structure must be generated:
+
+               kind                      structure                     generated?
+       ----------------------------------------------------------------------
+    CONSTANT_Class               constant_classref                  yes
+    CONSTANT_Fieldref            constant_FMIref                    yes
+    CONSTANT_Methodref           constant_FMIref                    yes
+    CONSTANT_InterfaceMethodref  constant_FMIref                    yes
+    CONSTANT_String              unicode                             no
+    CONSTANT_Integer             constant_integer                   yes
+    CONSTANT_Float               constant_float                     yes
+    CONSTANT_Long                constant_long                      yes
+    CONSTANT_Double              constant_double                    yes
+    CONSTANT_NameAndType         constant_nameandtype               yes
+    CONSTANT_Utf8                unicode                             no
+    CONSTANT_UNUSED              -
+
+*******************************************************************************/
+
+typedef struct {            /* Integer                                        */
+       s4 value;
+} constant_integer;
+
+       
+typedef struct {            /* Float                                          */
+       float value;
+} constant_float;
+
+
+typedef struct {            /* Long                                           */
+       s8 value;
+} constant_long;
+       
+
+typedef struct {            /* Double                                         */
+       double value;
+} constant_double;
+
+
+typedef struct {            /* NameAndType (Field or Method)                  */
+       utf *name;              /* field/method name                              */
+       utf *descriptor;        /* field/method type descriptor string            */
+} constant_nameandtype;
+
+
+/* classbuffer ****************************************************************/
+
+struct classbuffer {
+       classinfo *clazz;                   /* pointer to classinfo structure     */
+       uint8_t   *data;                    /* pointer to byte code               */
+       int32_t    size;                    /* size of the byte code              */
+       uint8_t   *pos;                     /* current read position              */
+       char      *path;                    /* path to file (for debugging)       */
+};
+
+
+/* hashtable_classloader_entry *************************************************
+
+   ATTENTION: The pointer to the classloader object needs to be the
+   first field of the entry, so that it can be used as an indirection
+   cell. This is checked by gc_init() during startup.
+
+*******************************************************************************/
+
+typedef struct hashtable_classloader_entry hashtable_classloader_entry;
+
+struct hashtable_classloader_entry {
+       java_object_t               *object;
+       hashtable_classloader_entry *hashlink;
+};
+
+
+/* classloader *****************************************************************
+
+   [!ENABLE_HANDLES]: The classloader is a Java Object which cannot move.
+   [ENABLE_HANDLES] : The classloader entry itself is a static handle for a
+                      given classloader (use loader_hashtable_classloader_foo).
+
+*******************************************************************************/
+
+#if defined(ENABLE_HANDLES)
+typedef hashtable_classloader_entry classloader_t;
+#else
+typedef java_object_t               classloader_t;
+#endif
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void loader_preinit(void);
+void loader_init(void);
+
+/* classloader management functions */
+classloader_t *loader_hashtable_classloader_add(java_handle_t *cl);
+classloader_t *loader_hashtable_classloader_find(java_handle_t *cl);
+
+void loader_load_all_classes(void);
+
+bool loader_skip_attribute_body(classbuffer *cb);
+
+#if defined(ENABLE_JAVASE)
+bool loader_load_attribute_signature(classbuffer *cb, utf **signature);
+#endif
+
+/* free resources */
+void loader_close(void);
+
+/* class loading functions */
+classinfo *load_class_from_sysloader(utf *name);
+classinfo *load_class_from_classloader(utf *name, classloader_t *cl);
+classinfo *load_class_bootstrap(utf *name);
+
+/* (don't use the following directly) */
+classinfo *load_class_from_classbuffer(classbuffer *cb);
+classinfo *load_newly_created_array(classinfo *c, classloader_t *loader);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LOADER_HPP
+
+
+/*
+ * 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/method.cpp b/src/vm/method.cpp
new file mode 100644 (file)
index 0000000..59cafe9
--- /dev/null
@@ -0,0 +1,1226 @@
+/* src/vm/method.cpp - method 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 <stdint.h>
+#include <stdio.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "threads/mutex.hpp"
+
+#include "vm/array.hpp"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/linker.hpp"
+#include "vm/loader.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/resolve.hpp"
+#include "vm/suck.hpp"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+#include "vm/jit/code.hpp"
+#include "vm/jit/methodheader.h"
+#include "vm/jit/stubs.hpp"
+
+
+#if !defined(NDEBUG) && defined(ENABLE_INLINING)
+#define INLINELOG(code)  do { if (opt_TraceInlining) { code } } while (0)
+#else
+#define INLINELOG(code)
+#endif
+
+/* global variables ***********************************************************/
+
+methodinfo *method_java_lang_reflect_Method_invoke;
+
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+
+/* method_init *****************************************************************
+
+   Initialize method subsystem.
+
+*******************************************************************************/
+
+void method_init(void)
+{
+#if defined(ENABLE_JAVASE)
+       /* Sanity check. */
+
+       if (class_java_lang_reflect_Method == NULL)
+               vm_abort("method_init: class_java_lang_reflect_Method is NULL");
+
+       /* Cache java.lang.reflect.Method.invoke() */
+
+       method_java_lang_reflect_Method_invoke =
+               class_findmethod(class_java_lang_reflect_Method, utf_invoke, NULL);
+
+       if (method_java_lang_reflect_Method_invoke == NULL)
+               vm_abort("method_init: Could not resolve method java.lang.reflect.Method.invoke().");
+#endif
+}
+
+
+/* method_load *****************************************************************
+
+   Loads a method from the class file and fills an existing methodinfo
+   structure.
+
+   method_info {
+       u2 access_flags;
+          u2 name_index;
+          u2 descriptor_index;
+          u2 attributes_count;
+          attribute_info attributes[attribute_count];
+   }
+
+   attribute_info {
+       u2 attribute_name_index;
+          u4 attribute_length;
+          u1 info[attribute_length];
+   }
+
+   LineNumberTable_attribute {
+       u2 attribute_name_index;
+          u4 attribute_length;
+          u2 line_number_table_length;
+          {
+              u2 start_pc;
+                  u2 line_number;
+          } line_number_table[line_number_table_length];
+   }
+
+*******************************************************************************/
+
+bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool)
+{
+       classinfo *c;
+       int argcount;
+       s4         i, j, k, l;
+       utf       *u;
+       u2         name_index;
+       u2         descriptor_index;
+       u2         attributes_count;
+       u2         attribute_name_index;
+       utf       *attribute_name;
+       u2         code_attributes_count;
+       u2         code_attribute_name_index;
+       utf       *code_attribute_name;
+
+       /* get classinfo */
+
+       c = cb->clazz;
+
+       m->mutex = new Mutex();
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               count_all_methods++;
+#endif
+
+       /* all fields of m have been zeroed in load_class_from_classbuffer */
+
+       m->clazz = c;
+       
+       if (!suck_check_classbuffer_size(cb, 2 + 2 + 2))
+               return false;
+
+       /* access flags */
+
+       m->flags = suck_u2(cb);
+
+       /* name */
+
+       name_index = suck_u2(cb);
+
+       if (!(u = (utf*) class_getconstant(c, name_index, CONSTANT_Utf8)))
+               return false;
+
+       m->name = u;
+
+       /* descriptor */
+
+       descriptor_index = suck_u2(cb);
+
+       if (!(u = (utf*) class_getconstant(c, descriptor_index, CONSTANT_Utf8)))
+               return false;
+
+       m->descriptor = u;
+
+       if (!descriptor_pool_add(descpool, u, &argcount))
+               return false;
+
+#ifdef ENABLE_VERIFIER
+       if (opt_verify) {
+               if (!is_valid_name_utf(m->name)) {
+                       exceptions_throw_classformaterror(c, "Method with invalid name");
+                       return false;
+               }
+
+               if (m->name->text[0] == '<' &&
+                       m->name != utf_init && m->name != utf_clinit) {
+                       exceptions_throw_classformaterror(c, "Method with invalid special name");
+                       return false;
+               }
+       }
+#endif /* ENABLE_VERIFIER */
+       
+       if (!(m->flags & ACC_STATIC))
+               argcount++; /* count the 'this' argument */
+
+#ifdef ENABLE_VERIFIER
+       if (opt_verify) {
+               if (argcount > 255) {
+                       exceptions_throw_classformaterror(c, "Too many arguments in signature");
+                       return false;
+               }
+
+               /* check flag consistency */
+               if (m->name != utf_clinit) {
+                       i = (m->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED));
+
+                       if (i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) {
+                               exceptions_throw_classformaterror(c,
+                                                                                                 "Illegal method modifiers: 0x%X",
+                                                                                                 m->flags);
+                               return false;
+                       }
+
+                       if (m->flags & ACC_ABSTRACT) {
+                               if ((m->flags & (ACC_FINAL | ACC_NATIVE | ACC_PRIVATE |
+                                                                ACC_STATIC | ACC_STRICT | ACC_SYNCHRONIZED))) {
+                                       exceptions_throw_classformaterror(c,
+                                                                                                         "Illegal method modifiers: 0x%X",
+                                                                                                         m->flags);
+                                       return false;
+                               }
+                       }
+
+                       if (c->flags & ACC_INTERFACE) {
+                               if ((m->flags & (ACC_ABSTRACT | ACC_PUBLIC)) != (ACC_ABSTRACT | ACC_PUBLIC)) {
+                                       exceptions_throw_classformaterror(c,
+                                                                                                         "Illegal method modifiers: 0x%X",
+                                                                                                         m->flags);
+                                       return false;
+                               }
+                       }
+
+                       if (m->name == utf_init) {
+                               if (m->flags & (ACC_STATIC | ACC_FINAL | ACC_SYNCHRONIZED |
+                                                               ACC_NATIVE | ACC_ABSTRACT)) {
+                                       exceptions_throw_classformaterror(c, "Instance initialization method has invalid flags set");
+                                       return false;
+                               }
+                       }
+               }
+       }
+#endif /* ENABLE_VERIFIER */
+
+       /* mark the method as monomorphic until further notice */
+
+       m->flags |= ACC_METHOD_MONOMORPHIC;
+
+       /* non-abstract methods have an implementation in this class */
+
+       if (!(m->flags & ACC_ABSTRACT))
+               m->flags |= ACC_METHOD_IMPLEMENTED;
+               
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       /* attributes count */
+
+       attributes_count = suck_u2(cb);
+
+       for (i = 0; i < attributes_count; i++) {
+               if (!suck_check_classbuffer_size(cb, 2))
+                       return false;
+
+               /* attribute name index */
+
+               attribute_name_index = suck_u2(cb);
+
+               attribute_name =
+                       (utf*) class_getconstant(c, attribute_name_index, CONSTANT_Utf8);
+
+               if (attribute_name == NULL)
+                       return false;
+
+               if (attribute_name == utf_Code) {
+                       /* Code */
+
+                       if (m->flags & (ACC_ABSTRACT | ACC_NATIVE)) {
+                               exceptions_throw_classformaterror(c, "Code attribute in native or abstract methods");
+                               return false;
+                       }
+                       
+                       if (m->jcode) {
+                               exceptions_throw_classformaterror(c, "Multiple Code attributes");
+                               return false;
+                       }
+
+                       if (!suck_check_classbuffer_size(cb, 4 + 2 + 2))
+                               return false;
+
+                       suck_u4(cb);
+                       m->maxstack = suck_u2(cb);
+                       m->maxlocals = suck_u2(cb);
+
+                       if (m->maxlocals < argcount) {
+                               exceptions_throw_classformaterror(c, "Arguments can't fit into locals");
+                               return false;
+                       }
+                       
+                       if (!suck_check_classbuffer_size(cb, 4))
+                               return false;
+
+                       m->jcodelength = suck_u4(cb);
+
+                       if (m->jcodelength == 0) {
+                               exceptions_throw_classformaterror(c, "Code of a method has length 0");
+                               return false;
+                       }
+                       
+                       if (m->jcodelength > 65535) {
+                               exceptions_throw_classformaterror(c, "Code of a method longer than 65535 bytes");
+                               return false;
+                       }
+
+                       if (!suck_check_classbuffer_size(cb, m->jcodelength))
+                               return false;
+
+                       m->jcode = MNEW(u1, m->jcodelength);
+                       suck_nbytes(m->jcode, cb, m->jcodelength);
+
+                       if (!suck_check_classbuffer_size(cb, 2))
+                               return false;
+
+                       m->rawexceptiontablelength = suck_u2(cb);
+                       if (!suck_check_classbuffer_size(cb, (2 + 2 + 2 + 2) * m->rawexceptiontablelength))
+                               return false;
+
+                       m->rawexceptiontable = MNEW(raw_exception_entry, m->rawexceptiontablelength);
+
+#if defined(ENABLE_STATISTICS)
+                       if (opt_stat) {
+                               count_vmcode_len += m->jcodelength + 18;
+                               count_extable_len +=
+                                       m->rawexceptiontablelength * sizeof(raw_exception_entry);
+                       }
+#endif
+
+                       for (j = 0; j < m->rawexceptiontablelength; j++) {
+                               u4 idx;
+                               m->rawexceptiontable[j].startpc   = suck_u2(cb);
+                               m->rawexceptiontable[j].endpc     = suck_u2(cb);
+                               m->rawexceptiontable[j].handlerpc = suck_u2(cb);
+
+                               idx = suck_u2(cb);
+
+                               if (!idx) {
+                                       m->rawexceptiontable[j].catchtype.any = NULL;
+                               }
+                               else {
+                                       /* the classref is created later */
+                                       if (!(m->rawexceptiontable[j].catchtype.any =
+                                                 (utf *) class_getconstant(c, idx, CONSTANT_Class)))
+                                               return false;
+                               }
+                       }
+
+                       if (!suck_check_classbuffer_size(cb, 2))
+                               return false;
+
+                       /* code attributes count */
+
+                       code_attributes_count = suck_u2(cb);
+
+                       for (k = 0; k < code_attributes_count; k++) {
+                               if (!suck_check_classbuffer_size(cb, 2))
+                                       return false;
+
+                               /* code attribute name index */
+
+                               code_attribute_name_index = suck_u2(cb);
+
+                               code_attribute_name =
+                                       (utf*) class_getconstant(c, code_attribute_name_index, CONSTANT_Utf8);
+
+                               if (code_attribute_name == NULL)
+                                       return false;
+
+                               /* check which code attribute */
+
+                               if (code_attribute_name == utf_LineNumberTable) {
+                                       /* LineNumberTable */
+
+                                       if (!suck_check_classbuffer_size(cb, 4 + 2))
+                                               return false;
+
+                                       /* attribute length */
+
+                                       (void) suck_u4(cb);
+
+                                       /* line number table length */
+
+                                       m->linenumbercount = suck_u2(cb);
+
+                                       if (!suck_check_classbuffer_size(cb,
+                                                                                               (2 + 2) * m->linenumbercount))
+                                               return false;
+
+                                       m->linenumbers = MNEW(lineinfo, m->linenumbercount);
+
+#if defined(ENABLE_STATISTICS)
+                                       if (opt_stat)
+                                               size_lineinfo += sizeof(lineinfo) * m->linenumbercount;
+#endif
+                                       
+                                       for (l = 0; l < m->linenumbercount; l++) {
+                                               m->linenumbers[l].start_pc    = suck_u2(cb);
+                                               m->linenumbers[l].line_number = suck_u2(cb);
+                                       }
+                               }
+#if defined(ENABLE_JAVASE)
+                               else if (code_attribute_name == utf_StackMapTable) {
+                                       /* StackTableMap */
+
+                                       if (!stackmap_load_attribute_stackmaptable(cb, m))
+                                               return false;
+                               }
+#endif
+                               else {
+                                       /* unknown code attribute */
+
+                                       if (!loader_skip_attribute_body(cb))
+                                               return false;
+                               }
+                       }
+               }
+               else if (attribute_name == utf_Exceptions) {
+                       /* Exceptions */
+
+                       if (m->thrownexceptions != NULL) {
+                               exceptions_throw_classformaterror(c, "Multiple Exceptions attributes");
+                               return false;
+                       }
+
+                       if (!suck_check_classbuffer_size(cb, 4 + 2))
+                               return false;
+
+                       /* attribute length */
+
+                       (void) suck_u4(cb);
+
+                       m->thrownexceptionscount = suck_u2(cb);
+
+                       if (!suck_check_classbuffer_size(cb, 2 * m->thrownexceptionscount))
+                               return false;
+
+                       m->thrownexceptions = MNEW(classref_or_classinfo, m->thrownexceptionscount);
+
+                       for (j = 0; j < m->thrownexceptionscount; j++) {
+                               /* the classref is created later */
+                               if (!((m->thrownexceptions)[j].any =
+                                         (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Class)))
+                                       return false;
+                       }
+               }
+#if defined(ENABLE_JAVASE)
+               else if (attribute_name == utf_Signature) {
+                       /* Signature */
+
+                       if (!loader_load_attribute_signature(cb, &(m->signature)))
+                               return false;
+               }
+
+#if defined(ENABLE_ANNOTATIONS)
+               else if (attribute_name == utf_RuntimeVisibleAnnotations) {
+                       /* RuntimeVisibleAnnotations */
+                       if (!annotation_load_method_attribute_runtimevisibleannotations(cb, m))
+                               return false;
+               }
+               else if (attribute_name == utf_RuntimeInvisibleAnnotations) {
+                       /* RuntimeInvisibleAnnotations */
+                       if (!annotation_load_method_attribute_runtimeinvisibleannotations(cb, m))
+                               return false;
+               }
+               else if (attribute_name == utf_RuntimeVisibleParameterAnnotations) {
+                       /* RuntimeVisibleParameterAnnotations */
+                       if (!annotation_load_method_attribute_runtimevisibleparameterannotations(cb, m))
+                               return false;
+               }
+               else if (attribute_name == utf_RuntimeInvisibleParameterAnnotations) {
+                       /* RuntimeInvisibleParameterAnnotations */
+                       if (!annotation_load_method_attribute_runtimeinvisibleparameterannotations(cb, m))
+                               return false;
+               }
+               else if (attribute_name == utf_AnnotationDefault) {
+                       /* AnnotationDefault */
+                       if (!annotation_load_method_attribute_annotationdefault(cb, m))
+                               return false;
+               }
+#endif
+#endif
+               else {
+                       /* unknown attribute */
+
+                       if (!loader_skip_attribute_body(cb))
+                               return false;
+               }
+       }
+
+       if ((m->jcode == NULL) && !(m->flags & (ACC_ABSTRACT | ACC_NATIVE))) {
+               exceptions_throw_classformaterror(c, "Missing Code attribute");
+               return false;
+       }
+
+#if defined(ENABLE_REPLACEMENT)
+       /* initialize the hit countdown field */
+
+       m->hitcountdown = METHOD_INITIAL_HIT_COUNTDOWN;
+#endif
+
+       /* everything was ok */
+
+       return true;
+}
+
+
+/* method_free *****************************************************************
+
+   Frees all memory that was allocated for this method.
+
+*******************************************************************************/
+
+void method_free(methodinfo *m)
+{
+       if (m->mutex)
+               delete m->mutex;
+
+       if (m->jcode)
+               MFREE(m->jcode, u1, m->jcodelength);
+
+       if (m->rawexceptiontable)
+               MFREE(m->rawexceptiontable, raw_exception_entry, m->rawexceptiontablelength);
+
+       code_free_code_of_method(m);
+
+       if (m->stubroutine) {
+               if (m->flags & ACC_NATIVE) {
+                       NativeStub::remove(m->stubroutine);
+               }
+               else {
+                       CompilerStub::remove(m->stubroutine);
+               }
+       }
+}
+
+
+/* method_canoverwrite *********************************************************
+
+   Check if m and old are identical with respect to type and
+   name. This means that old can be overwritten with m.
+       
+*******************************************************************************/
+
+bool method_canoverwrite(methodinfo *m, methodinfo *old)
+{
+       if (m->name != old->name)
+               return false;
+
+       if (m->descriptor != old->descriptor)
+               return false;
+
+       if (m->flags & ACC_STATIC)
+               return false;
+
+       return true;
+}
+
+
+/* method_new_builtin **********************************************************
+
+   Creates a minimal methodinfo structure for builtins. This comes handy
+   when dealing with builtin stubs or stacktraces.
+
+*******************************************************************************/
+
+methodinfo *method_new_builtin(builtintable_entry *bte)
+{
+       methodinfo *m;
+
+       /* allocate the methodinfo structure */
+
+       m = NEW(methodinfo);
+
+       /* initialize methodinfo structure */
+
+       MZERO(m, methodinfo, 1);
+       
+       m->mutex      = new Mutex();
+       m->flags      = ACC_METHOD_BUILTIN;
+       m->parseddesc = bte->md;
+       m->name       = bte->name;
+       m->descriptor = bte->descriptor;
+
+       /* return the newly created methodinfo */
+
+       return m;
+}
+
+
+/* method_vftbl_lookup *********************************************************
+
+   Does a method lookup in the passed virtual function table.  This
+   function does exactly the same thing as JIT, but additionally
+   relies on the fact, that the methodinfo pointer is at the first
+   data segment slot (even for compiler stubs).
+
+*******************************************************************************/
+
+methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m)
+{
+       methodptr   mptr;
+       methodptr  *pmptr;
+       methodinfo *resm;                   /* pointer to new resolved method     */
+
+       /* If the method is not an instance method, just return it. */
+
+       if (m->flags & ACC_STATIC)
+               return m;
+
+       assert(vftbl);
+
+       /* Get the method from the virtual function table.  Is this an
+          interface method? */
+
+       if (m->clazz->flags & ACC_INTERFACE) {
+               pmptr = vftbl->interfacetable[-(m->clazz->index)];
+               mptr  = pmptr[(m - m->clazz->methods)];
+       }
+       else {
+               mptr = vftbl->table[m->vftblindex];
+       }
+
+       /* and now get the codeinfo pointer from the first data segment slot */
+
+       resm = code_get_methodinfo_for_pv(mptr);
+
+       return resm;
+}
+
+
+/* method_get_parametercount **************************************************
+
+   Use the descriptor of a method to determine the number of parameters
+   of the method. The this pointer of non-static methods is not counted.
+
+   IN:
+       m........the method of which the parameters should be counted
+
+   RETURN VALUE:
+       The parameter count or -1 on error.
+
+*******************************************************************************/
+
+int32_t method_get_parametercount(methodinfo *m)
+{
+       methoddesc *md;             /* method descriptor of m   */
+       int32_t     paramcount = 0; /* the parameter count of m */
+
+       md = m->parseddesc;
+       
+       /* is the descriptor fully parsed? */
+
+       if (md->params == NULL) {
+               if (!descriptor_params_from_paramtypes(md, m->flags)) {
+                       return -1;
+               }
+       }
+
+       paramcount = md->paramcount;
+
+       /* skip `this' pointer */
+
+       if (!(m->flags & ACC_STATIC)) {
+               --paramcount;
+       }
+
+       return paramcount;
+}
+
+
+/* method_get_parametertypearray ***********************************************
+
+   Use the descriptor of a method to generate a java.lang.Class array
+   which contains the classes of the parametertypes of the method.
+
+   This function is called by java.lang.reflect.{Constructor,Method}.
+
+*******************************************************************************/
+
+java_handle_objectarray_t *method_get_parametertypearray(methodinfo *m)
+{
+       methoddesc                *md;
+       typedesc                  *paramtypes;
+       int32_t                    paramcount;
+       java_handle_objectarray_t *oa;
+       int32_t                    i;
+       classinfo                 *c;
+
+       md = m->parseddesc;
+
+       /* is the descriptor fully parsed? */
+
+       if (m->parseddesc->params == NULL)
+               if (!descriptor_params_from_paramtypes(md, m->flags))
+                       return NULL;
+
+       paramtypes = md->paramtypes;
+       paramcount = md->paramcount;
+
+       /* skip `this' pointer */
+
+       if (!(m->flags & ACC_STATIC)) {
+               paramtypes++;
+               paramcount--;
+       }
+
+       /* create class-array */
+
+       oa = builtin_anewarray(paramcount, class_java_lang_Class);
+
+       if (oa == NULL)
+               return NULL;
+
+    /* get classes */
+
+       for (i = 0; i < paramcount; i++) {
+               if (!resolve_class_from_typedesc(&paramtypes[i], true, false, &c))
+                       return NULL;
+
+               LLNI_array_direct(oa, i) = (java_object_t *) c;
+       }
+
+       return oa;
+}
+
+
+/* method_get_exceptionarray ***************************************************
+
+   Get the exceptions which can be thrown by a method.
+
+*******************************************************************************/
+
+java_handle_objectarray_t *method_get_exceptionarray(methodinfo *m)
+{
+       java_handle_objectarray_t *oa;
+       classinfo                 *c;
+       s4                         i;
+
+       /* create class-array */
+
+       oa = builtin_anewarray(m->thrownexceptionscount, class_java_lang_Class);
+
+       if (oa == NULL)
+               return NULL;
+
+       /* iterate over all exceptions and store the class in the array */
+
+       for (i = 0; i < m->thrownexceptionscount; i++) {
+               c = resolve_classref_or_classinfo_eager(m->thrownexceptions[i], true);
+
+               if (c == NULL)
+                       return NULL;
+
+               LLNI_array_direct(oa, i) = (java_object_t *) c;
+       }
+
+       return oa;
+}
+
+
+/* method_returntype_get *******************************************************
+
+   Get the return type of the method.
+
+*******************************************************************************/
+
+classinfo *method_returntype_get(methodinfo *m)
+{
+       typedesc  *td;
+       classinfo *c;
+
+       td = &(m->parseddesc->returntype);
+
+       if (!resolve_class_from_typedesc(td, true, false, &c))
+               return NULL;
+
+       return c;
+}
+
+
+/* method_count_implementations ************************************************
+
+   Count the implementations of a method in a class cone (a class and all its
+   subclasses.)
+
+   IN:
+       m................the method to count
+          c................class at which to start the counting (this class and
+                           all its subclasses will be searched)
+
+   OUT:
+       *found...........if found != NULL, *found receives the method
+                           implementation that was found. This value is only
+                                               meaningful if the return value is 1.
+
+   RETURN VALUE:
+       the number of implementations found
+
+*******************************************************************************/
+
+s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found)
+{
+       s4          count;
+       methodinfo *mp;
+       methodinfo *mend;
+       classinfo  *child;
+
+       count = 0;
+
+       mp = c->methods;
+       mend = mp + c->methodscount;
+
+       for (; mp < mend; ++mp) {
+               if (method_canoverwrite(mp, m)) {
+                       if (found)
+                               *found = mp;
+                       count++;
+                       break;
+               }
+       }
+
+       for (child = c->sub; child != NULL; child = child->nextsub) {
+               count += method_count_implementations(m, child, found);
+       }
+
+       return count;
+}
+
+
+/* method_get_annotations ******************************************************
+
+   Get a methods' unparsed annotations in a byte array.
+
+   IN:
+       m........the method of which the annotations should be returned
+
+   RETURN VALUE:
+       The unparsed annotations in a byte array (or NULL if there aren't any).
+
+*******************************************************************************/
+
+java_handle_bytearray_t *method_get_annotations(methodinfo *m)
+{
+#if defined(ENABLE_ANNOTATIONS)
+       classinfo     *c;                  /* methods' declaring class          */
+       int            slot;               /* methods' slot                     */
+       java_handle_t *annotations;        /* methods' unparsed annotations     */
+       java_handle_t *method_annotations; /* all methods' unparsed annotations */
+                                          /* of the declaring class            */
+
+       c           = m->clazz;
+       slot        = m - c->methods;
+       annotations = NULL;
+
+       LLNI_classinfo_field_get(c, method_annotations, method_annotations);
+
+       /* the method_annotations array might be shorter then the method
+        * count if the methods above a certain index have no annotations.
+        */     
+       if (method_annotations != NULL &&
+               array_length_get(method_annotations) > slot) {
+               annotations = array_objectarray_element_get(
+                       (java_handle_objectarray_t*)method_annotations, slot);
+       }
+       
+       return (java_handle_bytearray_t*)annotations;
+#else
+       return NULL;
+#endif
+}
+
+
+/* method_get_parameterannotations ********************************************
+
+   Get a methods' unparsed parameter annotations in an array of byte
+   arrays.
+
+   IN:
+       m........the method of which the parameter annotations should be
+                   returned
+
+   RETURN VALUE:
+       The unparsed parameter annotations in a byte array (or NULL if
+          there aren't any).
+
+*******************************************************************************/
+
+java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m)
+{
+#if defined(ENABLE_ANNOTATIONS)
+       classinfo     *c;                           /* methods' declaring class */
+       int            slot;                        /* methods' slot            */
+       java_handle_t *parameterAnnotations;        /* methods' unparsed        */
+                                                   /* parameter annotations    */
+       java_handle_t *method_parameterannotations; /* all methods' unparsed    */
+                                                   /* parameter annotations of */
+                                                   /* the declaring class      */
+
+       c                    = m->clazz;
+       slot                 = m - c->methods;
+       parameterAnnotations = NULL;
+
+       LLNI_classinfo_field_get(
+               c, method_parameterannotations, method_parameterannotations);
+
+       /* the method_annotations array might be shorter then the method
+        * count if the methods above a certain index have no annotations.
+        */     
+       if (method_parameterannotations != NULL &&
+               array_length_get(method_parameterannotations) > slot) {
+               parameterAnnotations = array_objectarray_element_get(
+                               (java_handle_objectarray_t*)method_parameterannotations,
+                               slot);
+       }
+       
+       return (java_handle_bytearray_t*)parameterAnnotations;
+#else
+       return NULL;
+#endif
+}
+
+
+/* method_get_annotationdefault ***********************************************
+
+   Get a methods' unparsed annotation default value in a byte array.
+   
+   IN:
+       m........the method of which the annotation default value should be
+                   returned
+
+   RETURN VALUE:
+       The unparsed annotation default value in a byte array (or NULL if
+          there isn't one).
+
+*******************************************************************************/
+
+java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m)
+{
+#if defined(ENABLE_ANNOTATIONS)
+       classinfo     *c;                         /* methods' declaring class     */
+       int            slot;                      /* methods' slot                */
+       java_handle_t *annotationDefault;         /* methods' unparsed            */
+                                                 /* annotation default value     */
+       java_handle_t *method_annotationdefaults; /* all methods' unparsed        */
+                                                 /* annotation default values of */
+                                                 /* the declaring class          */
+
+       c                 = m->clazz;
+       slot              = m - c->methods;
+       annotationDefault = NULL;
+
+       LLNI_classinfo_field_get(
+               c, method_annotationdefaults, method_annotationdefaults);
+
+       /* the method_annotations array might be shorter then the method
+        * count if the methods above a certain index have no annotations.
+        */     
+       if (method_annotationdefaults != NULL &&
+               array_length_get(method_annotationdefaults) > slot) {
+               annotationDefault = array_objectarray_element_get(
+                               (java_handle_objectarray_t*)method_annotationdefaults, slot);
+       }
+       
+       return (java_handle_bytearray_t*)annotationDefault;
+#else
+       return NULL;
+#endif
+}
+
+
+/* method_add_to_worklist ******************************************************
+
+   Add the method to the given worklist. If the method already occurs in
+   the worklist, the worklist remains unchanged.
+
+*******************************************************************************/
+
+static void method_add_to_worklist(methodinfo *m, method_worklist **wl)
+{
+       method_worklist *wi;
+
+       for (wi = *wl; wi != NULL; wi = wi->next)
+               if (wi->m == m)
+                       return;
+
+       wi = NEW(method_worklist);
+       wi->next = *wl;
+       wi->m = m;
+
+       *wl = wi;
+}
+
+
+/* method_add_assumption_monomorphic *******************************************
+
+   Record the assumption that the method is monomorphic.
+
+   IN:
+      m.................the method
+         caller............the caller making the assumption
+
+*******************************************************************************/
+
+void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller)
+{
+       method_assumption *as;
+
+       /* XXX LOCKING FOR THIS FUNCTION? */
+
+       /* check if we already have registered this assumption */
+
+       for (as = m->assumptions; as != NULL; as = as->next) {
+               if (as->context == caller)
+                       return;
+       }
+
+       /* register the assumption */
+
+       as = NEW(method_assumption);
+       as->next = m->assumptions;
+       as->context = caller;
+
+       m->assumptions = as;
+}
+
+/* method_break_assumption_monomorphic *****************************************
+
+   Break the assumption that this method is monomorphic. All callers that
+   have registered this assumption are added to the worklist.
+
+   IN:
+      m.................the method
+         wl................worklist where to add invalidated callers
+
+*******************************************************************************/
+
+void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl)
+{
+       method_assumption *as;
+
+       /* XXX LOCKING FOR THIS FUNCTION? */
+
+       for (as = m->assumptions; as != NULL; as = as->next) {
+               INLINELOG(
+                       printf("ASSUMPTION BROKEN (monomorphism): ");
+                       method_print(m);
+                       printf(" in ");
+                       method_println(as->context);
+               );
+
+               method_add_to_worklist(as->context, wl);
+
+#if defined(ENABLE_TLH) && 0
+               /* XXX hack */
+               method_assumption *as2;
+               as2 = m->assumptions;
+               m->assumptions = NULL;
+               method_break_assumption_monomorphic(as->context, wl);
+               /*
+               assert(m->assumptions == NULL);
+               m->assumptions = as2;*/
+#endif
+
+       }
+}
+
+/* method_printflags ***********************************************************
+
+   Prints the flags of a method to stdout like.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void method_printflags(methodinfo *m)
+{
+       if (m == NULL) {
+               printf("NULL");
+               return;
+       }
+
+       if (m->flags & ACC_PUBLIC)             printf(" PUBLIC");
+       if (m->flags & ACC_PRIVATE)            printf(" PRIVATE");
+       if (m->flags & ACC_PROTECTED)          printf(" PROTECTED");
+       if (m->flags & ACC_STATIC)             printf(" STATIC");
+       if (m->flags & ACC_FINAL)              printf(" FINAL");
+       if (m->flags & ACC_SYNCHRONIZED)       printf(" SYNCHRONIZED");
+       if (m->flags & ACC_VOLATILE)           printf(" VOLATILE");
+       if (m->flags & ACC_TRANSIENT)          printf(" TRANSIENT");
+       if (m->flags & ACC_NATIVE)             printf(" NATIVE");
+       if (m->flags & ACC_INTERFACE)          printf(" INTERFACE");
+       if (m->flags & ACC_ABSTRACT)           printf(" ABSTRACT");
+       if (m->flags & ACC_METHOD_BUILTIN)     printf(" (builtin)");
+       if (m->flags & ACC_METHOD_MONOMORPHIC) printf(" (mono)");
+       if (m->flags & ACC_METHOD_IMPLEMENTED) printf(" (impl)");
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* method_print ****************************************************************
+
+   Prints a method to stdout like:
+
+   java.lang.Object.<init>()V
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void method_print(methodinfo *m)
+{
+       if (m == NULL) {
+               printf("NULL");
+               return;
+       }
+
+       if (m->clazz != NULL)
+               utf_display_printable_ascii_classname(m->clazz->name);
+       else
+               printf("NULL");
+       printf(".");
+       utf_display_printable_ascii(m->name);
+       utf_display_printable_ascii(m->descriptor);
+
+       method_printflags(m);
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* method_println **************************************************************
+
+   Prints a method plus new line to stdout like:
+
+   java.lang.Object.<init>()V
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void method_println(methodinfo *m)
+{
+       if (opt_debugcolor) printf("\033[31m"); /* red */
+       method_print(m);
+       if (opt_debugcolor) printf("\033[m");   
+       printf("\n");
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* method_methodref_print ******************************************************
+
+   Prints a method reference to stdout.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void method_methodref_print(constant_FMIref *mr)
+{
+       if (!mr) {
+               printf("(constant_FMIref *)NULL");
+               return;
+       }
+
+       if (IS_FMIREF_RESOLVED(mr)) {
+               printf("<method> ");
+               method_print(mr->p.method);
+       }
+       else {
+               printf("<methodref> ");
+               utf_display_printable_ascii_classname(mr->p.classref->name);
+               printf(".");
+               utf_display_printable_ascii(mr->name);
+               utf_display_printable_ascii(mr->descriptor);
+       }
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* method_methodref_println ****************************************************
+
+   Prints a method reference to stdout, followed by a newline.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void method_methodref_println(constant_FMIref *mr)
+{
+       method_methodref_print(mr);
+       printf("\n");
+}
+#endif /* !defined(NDEBUG) */
+
+#if defined(__cplusplus)
+}
+#endif
+
+/*
+ * 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/method.hpp b/src/vm/method.hpp
new file mode 100644 (file)
index 0000000..b7e12c8
--- /dev/null
@@ -0,0 +1,230 @@
+/* src/vm/method.hpp - method functions 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 _METHOD_H
+#define _METHOD_H
+
+/* forward typedefs ***********************************************************/
+
+typedef struct methodinfo          methodinfo; 
+typedef struct raw_exception_entry raw_exception_entry;
+typedef struct lineinfo            lineinfo; 
+typedef struct method_assumption   method_assumption;
+typedef struct method_worklist     method_worklist;
+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"
+#include "vm/linker.hpp"
+#include "vm/loader.hpp"
+#include "vm/references.h"
+
+#if defined(ENABLE_JAVASE)
+# include "vm/stackmap.h"
+#endif
+
+#include "vm/utf8.h"
+
+
+#if defined(ENABLE_REPLACEMENT)
+/* Initial value for the hit countdown field of each method. */
+#define METHOD_INITIAL_HIT_COUNTDOWN  1000
+#endif
+
+/* methodinfo *****************************************************************/
+
+struct methodinfo {                 /* method structure                       */
+       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     */
+#if defined(ENABLE_JAVASE)
+       utf          *signature;        /* Signature attribute                    */
+       stack_map_t  *stack_map;        /* StackMapTable attribute                */
+#endif
+
+       methoddesc   *parseddesc;       /* parsed descriptor                      */
+                            
+       classinfo    *clazz;            /* class, the method belongs to           */
+       s4            vftblindex;       /* index of method in virtual function    */
+                                       /* table (if it is a virtual method)      */
+       s4            maxstack;         /* maximum stack depth of method          */
+       s4            maxlocals;        /* maximum number of local variables      */
+       s4            jcodelength;      /* length of JavaVM code                  */
+       u1           *jcode;            /* pointer to JavaVM code                 */
+
+       s4            rawexceptiontablelength;  /* exceptiontable length          */
+       raw_exception_entry *rawexceptiontable; /* the exceptiontable             */
+
+       u2            thrownexceptionscount; /* number of exceptions attribute    */
+       classref_or_classinfo *thrownexceptions; /* except. a method may throw    */
+
+       u2            linenumbercount;  /* number of linenumber attributes        */
+       lineinfo     *linenumbers;      /* array of lineinfo items                */
+
+       u1           *stubroutine;      /* stub for compiling or calling natives  */
+       codeinfo     *code;             /* current code of this method            */
+
+#if defined(ENABLE_LSRA)
+       s4            maxlifetimes;     /* helper for lsra                        */
+#endif
+
+       methodinfo   *overwrites;       /* method that is directly overwritten    */
+       method_assumption *assumptions; /* list of assumptions about this method  */
+
+#if defined(ENABLE_REPLACEMENT)
+       s4            hitcountdown;     /* decreased for each hit                 */
+#endif
+
+#if defined(ENABLE_DEBUG_FILTER)
+       u1            filtermatches;    /* flags indicating which filters the method matches */
+#endif
+
+#if defined(ENABLE_ESCAPE)
+       u1           *paramescape;
+#endif
+};
+
+/* method_assumption ***********************************************************
+
+   This struct is used for registering assumptions about methods.
+
+*******************************************************************************/
+
+struct method_assumption {
+       method_assumption *next;
+       methodinfo        *context;
+};
+
+
+/* method_worklist *************************************************************
+
+   List node used for method worklists.
+
+*******************************************************************************/
+
+struct method_worklist {
+       method_worklist *next;
+       methodinfo      *m;
+};
+
+
+/* raw_exception_entry ********************************************************/
+
+/* exception table entry read by the loader */
+
+struct raw_exception_entry {    /* exceptiontable entry in a method           */
+       classref_or_classinfo catchtype; /* catchtype of exc. (0 == catchall)     */
+       u2              startpc;    /* start pc of guarded area (inclusive)       */
+       u2              endpc;      /* end pc of guarded area (exklusive)         */
+       u2              handlerpc;  /* pc of exception handler                    */
+};
+
+
+/* lineinfo *******************************************************************/
+
+struct lineinfo {
+       u2 start_pc;
+       u2 line_number;
+};
+
+
+/* global variables ***********************************************************/
+
+extern methodinfo *method_java_lang_reflect_Method_invoke;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* inline functions ***********************************************************/
+
+inline static bool method_is_builtin(methodinfo* m)
+{
+       return m->flags & ACC_METHOD_BUILTIN;
+}
+
+
+/* function prototypes ********************************************************/
+
+void method_init(void);
+
+bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool);
+void method_free(methodinfo *m);
+bool method_canoverwrite(methodinfo *m, methodinfo *old);
+
+methodinfo *method_new_builtin(builtintable_entry *bte);
+
+methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m);
+
+int32_t                    method_get_parametercount(methodinfo *m);
+java_handle_objectarray_t *method_get_parametertypearray(methodinfo *m);
+java_handle_objectarray_t *method_get_exceptionarray(methodinfo *m);
+classinfo                 *method_returntype_get(methodinfo *m);
+
+void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller);
+void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl);
+
+s4   method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found);
+
+java_handle_bytearray_t *method_get_annotations(methodinfo *m);
+java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m);
+java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m);
+
+#if !defined(NDEBUG)
+void method_printflags(methodinfo *m);
+void method_print(methodinfo *m);
+void method_println(methodinfo *m);
+void method_methodref_print(constant_FMIref *mr);
+void method_methodref_println(constant_FMIref *mr);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _METHOD_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/options.c b/src/vm/options.c
new file mode 100644 (file)
index 0000000..3c3bace
--- /dev/null
@@ -0,0 +1,856 @@
+/* src/vm/options.c - contains global options
+
+   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 <limits.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mm/memory.h"
+
+#include "vm/options.h"
+#include "vm/os.hpp"
+#include "vm/vm.hpp"
+
+
+/* command line option ********************************************************/
+
+s4    opt_index = 0;            /* index of processed arguments               */
+char *opt_arg;                  /* this one exports the option argument       */
+
+bool opt_foo = false;           /* option for development                     */
+
+bool opt_jar = false;
+
+#if defined(ENABLE_JIT)
+bool opt_jit = true;            /* JIT mode execution (default)               */
+bool opt_intrp = false;         /* interpreter mode execution                 */
+#else
+bool opt_jit = false;           /* JIT mode execution                         */
+bool opt_intrp = true;          /* interpreter mode execution (default)       */
+#endif
+
+bool opt_run = true;
+
+s4   opt_heapmaxsize   = 0;     /* maximum heap size                          */
+s4   opt_heapstartsize = 0;     /* initial heap size                          */
+s4   opt_stacksize     = 0;     /* thread stack size                          */
+
+bool opt_verbose = false;
+bool opt_debugcolor = false;   /* use ANSI terminal sequences                */
+bool compileall = false;
+
+bool loadverbose = false;
+bool initverbose = false;
+
+bool opt_verboseclass     = false;
+bool opt_verbosegc        = false;
+bool opt_verbosejni       = false;
+bool opt_verbosecall      = false;      /* trace all method invocation        */
+
+bool showmethods = false;
+bool showconstantpool = false;
+bool showutf = false;
+
+char *opt_method = NULL;
+char *opt_signature = NULL;
+
+bool compileverbose =  false;           /* trace compiler actions             */
+bool showstack = false;
+
+bool opt_showdisassemble    = false;    /* generate disassembler listing      */
+bool opt_showddatasegment   = false;    /* generate data segment listing      */
+bool opt_showintermediate   = false;    /* generate intermediate code listing */
+
+bool checkbounds = true;       /* check array bounds                         */
+bool checksync = true;         /* do synchronization                         */
+#if defined(ENABLE_LOOP)
+bool opt_loops = false;        /* optimize array accesses in loops           */
+#endif
+
+bool makeinitializations = true;
+
+#if defined(ENABLE_STATISTICS)
+bool opt_stat    = false;
+bool opt_getloadingtime = false;   /* to measure the runtime                 */
+bool opt_getcompilingtime = false; /* compute compile time                   */
+#endif
+#if defined(ENABLE_VERIFIER)
+bool opt_verify  = true;       /* true if classfiles should be verified      */
+#endif
+
+#if defined(ENABLE_PROFILING)
+bool opt_prof    = false;
+bool opt_prof_bb = false;
+#endif
+
+#if defined(ENABLE_OPAGENT)
+bool opt_opagent = false;
+#endif
+
+/* optimization options *******************************************************/
+
+#if defined(ENABLE_IFCONV)
+bool opt_ifconv = false;
+#endif
+
+#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
+bool opt_lsra = false;
+#endif
+#if defined(ENABLE_SSA)
+bool opt_ssa_dce = false;          /* enable dead code elemination */
+bool opt_ssa_cp = false;           /* enable copy propagation      */
+#endif
+
+
+/* interpreter options ********************************************************/
+
+#if defined(ENABLE_INTRP)
+bool opt_no_dynamic = false;            /* suppress dynamic superinstructions */
+bool opt_no_replication = false;        /* don't use replication in intrp     */
+bool opt_no_quicksuper = false;         /* instructions for quickening cannot be
+                                                                                  part of dynamic superinstructions */
+
+s4   opt_static_supers = 0x7fffffff;
+bool vm_debug = false;          /* XXX this should be called `opt_trace'      */
+#endif
+
+#if defined(ENABLE_DEBUG_FILTER)
+const char *opt_filter_verbosecall_include = 0;
+const char *opt_filter_verbosecall_exclude = 0;
+const char *opt_filter_show_method = 0;
+#endif
+
+
+/* -XX options ****************************************************************/
+
+/* NOTE: For better readability keep these alpha-sorted. */
+
+/* Options which must always be available (production options in
+   HotSpot). */
+
+int64_t  opt_MaxDirectMemorySize          = -1;
+int      opt_MaxPermSize                  = 0;
+int      opt_PermSize                     = 0;
+int      opt_ThreadStackSize              = 0;
+
+/* Debugging options which can be turned off. */
+
+bool     opt_AlwaysEmitLongBranches       = false;
+int      opt_DebugExceptions              = 0;
+int      opt_DebugFinalizer               = 0;
+int      opt_DebugLocalReferences         = 0;
+int      opt_DebugLocks                   = 0;
+int      opt_DebugPackage                 = 0;
+int      opt_DebugPatcher                 = 0;
+int      opt_DebugProperties              = 0;
+int      opt_DebugStackFrameInfo          = 0;
+int      opt_DebugStackTrace              = 0;
+int      opt_DebugThreads                 = 0;
+#if defined(ENABLE_DISASSEMBLER)
+int      opt_DisassembleStubs             = 0;
+#endif
+#if defined(ENABLE_OPAGENT)
+int      opt_EnableOpagent                = 0;
+#endif
+#if defined(ENABLE_GC_CACAO)
+int      opt_GCDebugRootSet               = 0;
+int      opt_GCStress                     = 0;
+#endif
+#if defined(ENABLE_INLINING)
+int      opt_Inline                       = 0;
+#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
+int      opt_InlineAll                    = 0;
+int      opt_InlineCount                  = INT_MAX;
+int      opt_InlineMaxSize                = INT_MAX;
+int      opt_InlineMinSize                = 0;
+#endif
+#endif
+int      opt_PrintConfig                  = 0;
+int      opt_ProfileGCMemoryUsage         = 0;
+int      opt_ProfileMemoryUsage           = 0;
+FILE    *opt_ProfileMemoryUsageGNUPlot    = NULL;
+#if defined(ENABLE_REPLACEMENT)
+int      opt_TestReplacement              = 0;
+#endif
+int      opt_TraceCompilerCalls           = 0;
+int      opt_TraceExceptions              = 0;
+int      opt_TraceHPI                     = 0;
+#if defined(ENABLE_INLINING) && !defined(NDEBUG)
+int      opt_TraceInlining                = 0;
+#endif
+int      opt_TraceJavaCalls               = 0;
+int      opt_TraceJNICalls                = 0;
+int      opt_TraceJVMCalls                = 0;
+int      opt_TraceJVMCallsVerbose         = 0;
+int      opt_TraceLinkClass               = 0;
+#if defined(ENABLE_REPLACEMENT)
+int      opt_TraceReplacement             = 0;
+#endif
+int      opt_TraceSubsystemInitialization = 0;
+int      opt_TraceTraps                   = 0;
+
+
+enum {
+       OPT_TYPE_BOOLEAN,
+       OPT_TYPE_VALUE
+};
+
+enum {
+       /* Options which must always be available (production options in
+          HotSpot). */
+
+       OPT_MaxDirectMemorySize,
+       OPT_MaxPermSize,
+       OPT_PermSize,
+       OPT_ThreadStackSize,
+
+       /* Debugging options which can be turned off. */
+
+       OPT_AlwaysEmitLongBranches,
+       OPT_DebugExceptions,
+       OPT_DebugFinalizer,
+       OPT_DebugLocalReferences,
+       OPT_DebugLocks,
+       OPT_DebugPackage,
+       OPT_DebugPatcher,
+       OPT_DebugProperties,
+       OPT_DebugStackFrameInfo,
+       OPT_DebugStackTrace,
+       OPT_DebugThreads,
+       OPT_DisassembleStubs,
+       OPT_EnableOpagent,
+       OPT_GCDebugRootSet,
+       OPT_GCStress,
+       OPT_Inline,
+       OPT_InlineAll,
+       OPT_InlineCount,
+       OPT_InlineMaxSize,
+       OPT_InlineMinSize,
+       OPT_PrintConfig,
+       OPT_ProfileGCMemoryUsage,
+       OPT_ProfileMemoryUsage,
+       OPT_ProfileMemoryUsageGNUPlot,
+       OPT_TestReplacement,
+       OPT_TraceCompilerCalls,
+       OPT_TraceExceptions,
+       OPT_TraceHPI,
+       OPT_TraceInlining,
+       OPT_TraceJavaCalls,
+       OPT_TraceJNICalls,
+       OPT_TraceJVMCalls,
+       OPT_TraceJVMCallsVerbose,
+       OPT_TraceLinkClass,
+       OPT_TraceReplacement,
+       OPT_TraceSubsystemInitialization,
+       OPT_TraceTraps,
+       OPT_Vmlog,
+       OPT_VmlogStrings,
+       OPT_VmlogIgnore
+};
+
+
+option_t options_XX[] = {
+       /* Options which must always be available (production options in
+          HotSpot). */
+
+       { "MaxDirectMemorySize",          OPT_MaxDirectMemorySize,          OPT_TYPE_VALUE,   "Maximum total size of NIO direct-buffer allocations" },
+       { "MaxPermSize",                  OPT_MaxPermSize,                  OPT_TYPE_VALUE,   "not implemented" },
+       { "PermSize",                     OPT_PermSize,                     OPT_TYPE_VALUE,   "not implemented" },
+       { "ThreadStackSize",              OPT_ThreadStackSize,              OPT_TYPE_VALUE,   "TODO" },
+
+       /* Debugging options which can be turned off. */
+
+       { "AlwaysEmitLongBranches",       OPT_AlwaysEmitLongBranches,       OPT_TYPE_BOOLEAN, "Always emit long-branches." },
+       { "DebugExceptions",              OPT_DebugExceptions,              OPT_TYPE_BOOLEAN, "debug exceptions" },
+       { "DebugFinalizer",               OPT_DebugFinalizer,               OPT_TYPE_BOOLEAN, "debug finalizer thread" },
+       { "DebugLocalReferences",         OPT_DebugLocalReferences,         OPT_TYPE_BOOLEAN, "print debug information for local reference tables" },
+       { "DebugLocks",                   OPT_DebugLocks,                   OPT_TYPE_BOOLEAN, "print debug information for locks" },
+       { "DebugPackage",                 OPT_DebugPackage,                 OPT_TYPE_BOOLEAN, "debug Java boot-packages" },
+       { "DebugPatcher",                 OPT_DebugPatcher,                 OPT_TYPE_BOOLEAN, "debug JIT code patching" },
+       { "DebugProperties",              OPT_DebugProperties,              OPT_TYPE_BOOLEAN, "print debug information for properties" },
+       { "DebugStackFrameInfo",          OPT_DebugStackFrameInfo,          OPT_TYPE_BOOLEAN, "TODO" },
+       { "DebugStackTrace",              OPT_DebugStackTrace,              OPT_TYPE_BOOLEAN, "debug stacktrace creation" },
+       { "DebugThreads",                 OPT_DebugThreads,                 OPT_TYPE_BOOLEAN, "print debug information for threads" },
+#if defined(ENABLE_DISASSEMBLER)
+       { "DisassembleStubs",             OPT_DisassembleStubs,             OPT_TYPE_BOOLEAN, "disassemble builtin and native stubs when generated" },
+#endif
+#if defined(ENABLE_OPAGENT)
+       { "EnableOpagent",                OPT_EnableOpagent,                OPT_TYPE_BOOLEAN, "enable providing JIT output to Oprofile" },
+#endif
+#if defined(ENABLE_GC_CACAO)
+       { "GCDebugRootSet",               OPT_GCDebugRootSet,               OPT_TYPE_BOOLEAN, "GC: print root-set at collection" },
+       { "GCStress",                     OPT_GCStress,                     OPT_TYPE_BOOLEAN, "GC: forced collection at every allocation" },
+#endif
+#if defined(ENABLE_INLINING)
+       { "Inline",                       OPT_Inline,                       OPT_TYPE_BOOLEAN, "enable method inlining" },
+#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
+       { "InlineAll",                    OPT_InlineAll,                    OPT_TYPE_BOOLEAN, "use inlining in all compilations" },
+       { "InlineCount",                  OPT_InlineCount,                  OPT_TYPE_VALUE,   "stop inlining after the given number of roots" },
+       { "InlineMaxSize",                OPT_InlineMaxSize,                OPT_TYPE_VALUE,   "maximum size for inlined result" },
+       { "InlineMinSize",                OPT_InlineMinSize,                OPT_TYPE_VALUE,   "minimum size for inlined result" },
+#endif
+#endif
+       { "PrintConfig",                  OPT_PrintConfig,                  OPT_TYPE_BOOLEAN, "print VM configuration" },
+       { "ProfileGCMemoryUsage",         OPT_ProfileGCMemoryUsage,         OPT_TYPE_VALUE,   "profiles GC memory usage in the given interval, <value> is in seconds (default: 5)" },
+       { "ProfileMemoryUsage",           OPT_ProfileMemoryUsage,           OPT_TYPE_VALUE,   "TODO" },
+       { "ProfileMemoryUsageGNUPlot",    OPT_ProfileMemoryUsageGNUPlot,    OPT_TYPE_VALUE,   "TODO" },
+#if defined(ENABLE_REPLACEMENT)
+       { "TestReplacement",              OPT_TestReplacement,              OPT_TYPE_BOOLEAN, "activate all replacement points during code generation" },
+#endif
+       { "TraceCompilerCalls",           OPT_TraceCompilerCalls,           OPT_TYPE_BOOLEAN, "trace JIT compiler calls" },
+       { "TraceExceptions",              OPT_TraceExceptions,              OPT_TYPE_BOOLEAN, "trace Exception throwing" },
+       { "TraceHPI",                     OPT_TraceHPI,                     OPT_TYPE_BOOLEAN, "Trace Host Porting Interface (HPI)" },
+#if defined(ENABLE_INLINING) && !defined(NDEBUG)
+       { "TraceInlining",                OPT_TraceInlining,                OPT_TYPE_VALUE,   "trace method inlining with the given verbosity level (default: 1)" },
+#endif
+#if !defined(ENABLE_VMLOG)
+       { "TraceJavaCalls",               OPT_TraceJavaCalls,               OPT_TYPE_BOOLEAN, "trace Java method calls" },
+#endif
+       { "TraceJNICalls",                OPT_TraceJNICalls,                OPT_TYPE_BOOLEAN, "trace JNI method calls" },
+       { "TraceJVMCalls",                OPT_TraceJVMCalls,                OPT_TYPE_BOOLEAN, "trace JVM method calls but omit very frequent ones" },
+       { "TraceJVMCallsVerbose",         OPT_TraceJVMCallsVerbose,         OPT_TYPE_BOOLEAN, "trace all JVM method calls" },
+       { "TraceLinkClass",               OPT_TraceLinkClass,               OPT_TYPE_BOOLEAN, "trace class linking" },
+#if defined(ENABLE_REPLACEMENT)
+       { "TraceReplacement",             OPT_TraceReplacement,             OPT_TYPE_VALUE,   "trace on-stack replacement with the given verbosity level (default: 1)" },
+#endif
+       { "TraceSubsystemInitialization", OPT_TraceSubsystemInitialization, OPT_TYPE_BOOLEAN, "trace initialization of subsystems" },
+       { "TraceTraps",                   OPT_TraceTraps,                   OPT_TYPE_BOOLEAN, "trace traps generated by JIT code" },
+#if defined(ENABLE_VMLOG)
+       { "Vmlog",                        OPT_Vmlog,                        OPT_TYPE_VALUE,   "prefix for vmlog trace files (enables vmlog)" },
+       { "VmlogStrings",                 OPT_VmlogStrings,                 OPT_TYPE_VALUE,   "prefix of vmlog string file to load" },
+       { "VmlogIgnore",                  OPT_VmlogIgnore,                  OPT_TYPE_VALUE,   "prefix of vmlog ignore file to load" },
+#endif
+
+       /* end marker */
+
+       { NULL,                           -1,                               -1,               NULL }
+};
+
+
+/* options_get *****************************************************************
+
+   DOCUMENT ME!!!
+
+*******************************************************************************/
+
+int options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
+{
+       char *option;
+       int   i;
+
+       if (opt_index >= vm_args->nOptions)
+               return OPT_DONE;
+
+       /* get the current option */
+
+       option = vm_args->options[opt_index].optionString;
+
+       if ((option == NULL) || (option[0] != '-'))
+               return OPT_DONE;
+
+       for (i = 0; opts[i].name; i++) {
+               if (!opts[i].arg) {
+                       /* boolean option found */
+
+                       if (strcmp(option + 1, opts[i].name) == 0) {
+                               opt_index++;
+                               return opts[i].value;
+                       }
+
+               } else {
+                       /* parameter option found */
+
+                       /* with a space between */
+
+                       if (strcmp(option + 1, opts[i].name) == 0) {
+                               opt_index++;
+
+                               if (opt_index < vm_args->nOptions) {
+                                       opt_arg = os_strdup(vm_args->options[opt_index].optionString);
+                                       opt_index++;
+                                       return opts[i].value;
+                               }
+
+                               return OPT_ERROR;
+
+                       } else {
+                               /* parameter and option have no space between */
+
+                               /* FIXME: this assumption is plain wrong, hits you if there is a
+                                * parameter with no argument starting with same letter as param with argument
+                                * but named after that one, ouch! */
+
+                               size_t l = os_strlen(opts[i].name);
+
+                               if (os_strlen(option + 1) > l) {
+                                       if (memcmp(option + 1, opts[i].name, l) == 0) {
+                                               opt_index++;
+                                               opt_arg = os_strdup(option + 1 + l);
+                                               return opts[i].value;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       return OPT_ERROR;
+}
+
+
+/* options_xxusage *************************************************************
+
+   Print usage message for debugging options.
+
+*******************************************************************************/
+
+static void options_xxusage(void)
+{
+       option_t   *opt;
+       int         length;
+       int         i;
+       const char *c;
+
+       /* Prevent compiler warning. */
+
+       length = 0;
+
+       for (opt = options_XX; opt->name != NULL; opt++) {
+               printf("    -XX:");
+
+               switch (opt->type) {
+               case OPT_TYPE_BOOLEAN:
+                       printf("+%s", opt->name);
+                       length = os_strlen("    -XX:+") + os_strlen(opt->name);
+                       break;
+
+               case OPT_TYPE_VALUE:
+                       printf("%s=<value>", opt->name);
+                       length = os_strlen("    -XX:") + os_strlen(opt->name) +
+                               os_strlen("=<value>");
+                       break;
+
+               default:
+                       vm_abort("options_xxusage: unkown option type %d", opt->type);
+               }
+
+               /* Check if the help fits into one 80-column line.
+                  Documentation starts at column 29. */
+
+               if (length < (29 - 1)) {
+                       /* Print missing spaces up to column 29. */
+
+                       for (i = length; i < 29; i++)
+                               printf(" ");
+               }
+               else {
+                       printf("\n");
+                       printf("                             "); /* 29 spaces */
+               }
+
+               /* Check documentation length. */
+
+               length = os_strlen(opt->doc);
+
+               if (length < (80 - 29)) {
+                       printf("%s", opt->doc);
+               }
+               else {
+                       for (c = opt->doc, i = 29; *c != 0; c++, i++) {
+                               /* If we are at the end of the line, break it. */
+
+                               if (i == 80) {
+                                       printf("\n");
+                                       printf("                             "); /* 29 spaces */
+                                       i = 29;
+                               }
+
+                               printf("%c", *c);
+                       }
+               }
+
+               printf("\n");
+       }
+
+       /* exit with error code */
+
+       exit(1);
+}
+
+
+/* options_xx ******************************************************************
+
+   Handle -XX: options.
+
+*******************************************************************************/
+
+void options_xx(JavaVMInitArgs *vm_args)
+{
+       const char *name;
+       const char *start;
+       char       *end;
+       int         length;
+       int         enable;
+       char       *value;
+       option_t   *opt;
+       char       *filename;
+       FILE       *file;
+       int         i;
+
+       /* Iterate over all passed options. */
+
+       for (i = 0; i < vm_args->nOptions; i++) {
+               /* Get the current option. */
+
+               name = vm_args->options[i].optionString;
+
+               /* Check for help (-XX). */
+
+               if (strcmp(name, "-XX") == 0)
+                       options_xxusage();
+
+               /* Check if the option start with -XX. */
+
+               start = strstr(name, "-XX:");
+
+               if ((start == NULL) || (start != name))
+                       continue;
+
+               /* Check if the option is a boolean option. */
+
+               if (name[4] == '+') {
+                       start  = name + 4 + 1;
+                       enable = 1;
+               }
+               else if (name[4] == '-') {
+                       start  = name + 4 + 1;
+                       enable = 0;
+               }
+               else {
+                       start  = name + 4;
+                       enable = -1;
+               }
+
+               /* Search for a '=' in the option name and get the option name
+                  length and the value of the option. */
+
+               end = strchr(start, '=');
+
+               if (end == NULL) {
+                       length = os_strlen(start);
+                       value  = NULL;
+               }
+               else {
+                       length = end - start;
+                       value  = end + 1;
+               }
+
+               /* Search the option in the option array. */
+
+               for (opt = options_XX; opt->name != NULL; opt++) {
+                       if (strncmp(opt->name, start, length) == 0) {
+                               /* Check if the options passed fits to the type. */
+
+                               switch (opt->type) {
+                               case OPT_TYPE_BOOLEAN:
+                                       if ((enable == -1) || (value != NULL))
+                                               options_xxusage();
+                                       break;
+                               case OPT_TYPE_VALUE:
+                                       if ((enable != -1) || (value == NULL))
+                                               options_xxusage();
+                                       break;
+                               default:
+                                       vm_abort("options_xx: unknown option type %d for option %s",
+                                                        opt->type, opt->name);
+                               }
+
+                               break;
+                       }
+               }
+
+               /* Process the option. */
+
+               switch (opt->value) {
+
+               /* Options which must always be available (production options
+                  in HotSpot). */
+
+               case OPT_MaxDirectMemorySize:
+                       opt_MaxDirectMemorySize = os_atoi(value);
+                       break;
+
+               case OPT_MaxPermSize:
+                       /* Currently ignored. */
+                       break;
+
+               case OPT_PermSize:
+                       /* Currently ignored. */
+                       break;
+
+               case OPT_ThreadStackSize:
+                       /* currently ignored */
+                       break;
+
+               /* Debugging options which can be turned off. */
+
+               case OPT_AlwaysEmitLongBranches:
+                       opt_AlwaysEmitLongBranches = enable;
+                       break;
+
+               case OPT_DebugExceptions:
+                       opt_DebugExceptions = enable;
+                       break;
+
+               case OPT_DebugFinalizer:
+                       opt_DebugFinalizer = enable;
+                       break;
+
+               case OPT_DebugLocalReferences:
+                       opt_DebugLocalReferences = enable;
+                       break;
+
+               case OPT_DebugLocks:
+                       opt_DebugLocks = enable;
+                       break;
+
+               case OPT_DebugPackage:
+                       opt_DebugPackage = enable;
+                       break;
+
+               case OPT_DebugPatcher:
+                       opt_DebugPatcher = enable;
+                       break;
+
+               case OPT_DebugProperties:
+                       opt_DebugProperties = enable;
+                       break;
+
+               case OPT_DebugStackFrameInfo:
+                       opt_DebugStackFrameInfo = enable;
+                       break;
+
+               case OPT_DebugStackTrace:
+                       opt_DebugStackTrace = enable;
+                       break;
+
+               case OPT_DebugThreads:
+                       opt_DebugThreads = enable;
+                       break;
+
+#if defined(ENABLE_DISASSEMBLER)
+               case OPT_DisassembleStubs:
+                       opt_DisassembleStubs = enable;
+                       break;
+#endif
+
+#if defined(ENABLE_OPAGENT)
+               case OPT_EnableOpagent:
+                       opt_EnableOpagent = enable;
+                       break;
+#endif
+
+#if defined(ENABLE_GC_CACAO)
+               case OPT_GCDebugRootSet:
+                       opt_GCDebugRootSet = enable;
+                       break;
+
+               case OPT_GCStress:
+                       opt_GCStress = enable;
+                       break;
+#endif
+
+#if defined(ENABLE_INLINING)
+               case OPT_Inline:
+                       opt_Inline = enable;
+                       break;
+#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
+               case OPT_InlineAll:
+                       opt_InlineAll = enable;
+                       break;
+
+               case OPT_InlineCount:
+                       if (value != NULL)
+                               opt_InlineCount = os_atoi(value);
+                       break;
+
+               case OPT_InlineMaxSize:
+                       if (value != NULL)
+                               opt_InlineMaxSize = os_atoi(value);
+                       break;
+
+               case OPT_InlineMinSize:
+                       if (value != NULL)
+                               opt_InlineMinSize = os_atoi(value);
+                       break;
+#endif
+#endif
+
+               case OPT_PrintConfig:
+                       opt_PrintConfig = enable;
+                       break;
+
+               case OPT_ProfileGCMemoryUsage:
+                       if (value == NULL)
+                               opt_ProfileGCMemoryUsage = 5;
+                       else
+                               opt_ProfileGCMemoryUsage = os_atoi(value);
+                       break;
+
+               case OPT_ProfileMemoryUsage:
+                       if (value == NULL)
+                               opt_ProfileMemoryUsage = 5;
+                       else
+                               opt_ProfileMemoryUsage = os_atoi(value);
+
+# if defined(ENABLE_STATISTICS)
+                       /* we also need statistics */
+
+                       opt_stat = true;
+# endif
+                       break;
+
+               case OPT_ProfileMemoryUsageGNUPlot:
+                       if (value == NULL)
+                               filename = "profile.dat";
+                       else
+                               filename = value;
+
+                       file = fopen(filename, "w");
+
+                       if (file == NULL)
+                               vm_abort_errno("options_xx: fopen failed");
+
+                       opt_ProfileMemoryUsageGNUPlot = file;
+                       break;
+
+#if defined(ENABLE_REPLACEMENT)
+               case OPT_TestReplacement:
+                       opt_TestReplacement = enable;
+                       break;
+#endif
+
+               case OPT_TraceCompilerCalls:
+                       opt_TraceCompilerCalls = enable;
+                       break;
+
+               case OPT_TraceExceptions:
+                       opt_TraceExceptions = enable;
+                       break;
+
+               case OPT_TraceHPI:
+                       opt_TraceHPI = enable;
+                       break;
+
+#if defined(ENABLE_INLINING) && !defined(NDEBUG)
+               case OPT_TraceInlining:
+                       if (value == NULL)
+                               opt_TraceInlining = 1;
+                       else
+                               opt_TraceInlining = os_atoi(value);
+                       break;
+#endif
+
+               case OPT_TraceJavaCalls:
+                       opt_verbosecall = enable;
+                       opt_TraceJavaCalls = enable;
+                       break;
+
+               case OPT_TraceJNICalls:
+                       opt_TraceJNICalls = enable;
+                       break;
+
+               case OPT_TraceJVMCalls:
+                       opt_TraceJVMCalls = enable;
+                       break;
+
+               case OPT_TraceJVMCallsVerbose:
+                       opt_TraceJVMCallsVerbose = enable;
+                       break;
+
+               case OPT_TraceLinkClass:
+                       opt_TraceLinkClass = enable;
+                       break;
+
+#if defined(ENABLE_REPLACEMENT)
+               case OPT_TraceReplacement:
+                       if (value == NULL)
+                               opt_TraceReplacement = 1;
+                       else
+                               opt_TraceReplacement = os_atoi(value);
+                       break;
+#endif
+
+               case OPT_TraceSubsystemInitialization:
+                       opt_TraceSubsystemInitialization = enable;
+                       break;
+
+               case OPT_TraceTraps:
+                       opt_TraceTraps = enable;
+                       break;
+
+#if defined(ENABLE_VMLOG)
+               case OPT_Vmlog:
+                       if (value == NULL)
+                               vmlog_cacao_set_prefix("vmlog");
+                       else
+                               vmlog_cacao_set_prefix(value);
+                       opt_verbosecall = 1;
+                       opt_TraceJavaCalls = 1;
+                       break;
+
+               case OPT_VmlogStrings:
+                       if (value != NULL)
+                               vmlog_cacao_set_stringprefix(value);
+                       break;
+
+               case OPT_VmlogIgnore:
+                       if (value != NULL)
+                               vmlog_cacao_set_ignoreprefix(value);
+                       break;
+#endif
+
+               default:
+                       printf("Unknown -XX option: %s\n", name);
+                       break;
+               }
+       }
+}
+
+
+/*
+ * 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:
+ */
diff --git a/src/vm/options.h b/src/vm/options.h
new file mode 100644 (file)
index 0000000..1758add
--- /dev/null
@@ -0,0 +1,277 @@
+/* src/vm/options.h - define global options extern
+
+   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 _OPTIONS_H
+#define _OPTIONS_H
+
+#include "config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#include "vm/types.h"
+
+#include "native/jni.hpp"
+
+#include "vm/global.h"
+
+
+/* reserved option numbers ****************************************************/
+
+/* define these negative since the other options are an enum */
+
+#define OPT_DONE       -1
+#define OPT_ERROR      -2
+#define OPT_IGNORE     -3
+
+
+typedef struct opt_struct opt_struct;
+
+struct opt_struct {
+       const char *name;
+       bool        arg;
+       int         value;
+};
+
+
+typedef struct option_t option_t;
+
+struct option_t {
+       const char *name;
+       int         value;
+       int         type;
+       const char *doc;
+};
+
+
+/* global variables ***********************************************************/
+
+extern s4    opt_index;
+extern char *opt_arg;
+
+extern bool opt_foo;
+
+extern bool opt_jit;
+extern bool opt_intrp;
+
+extern bool opt_jar;
+extern bool opt_run;
+
+extern s4   opt_heapmaxsize;
+extern s4   opt_heapstartsize;
+extern s4   opt_stacksize;
+
+extern bool opt_verbose;
+extern bool opt_debugcolor;
+extern bool compileall;
+
+extern bool loadverbose;         /* Print debug messages during loading */
+extern bool initverbose;         /* Log class initialization */ 
+
+extern bool opt_verboseclass;
+extern bool opt_verbosegc;
+extern bool opt_verbosejni;
+extern bool opt_verbosecall;
+
+extern bool showmethods;
+extern bool showconstantpool;
+extern bool showutf;
+
+extern char *opt_method;
+extern char *opt_signature;
+
+extern bool compileverbose;
+extern bool showstack;
+
+extern bool opt_showdisassemble;
+extern bool opt_showddatasegment;
+extern bool opt_showintermediate;
+
+extern bool checkbounds;
+extern bool checksync;
+#if defined(ENABLE_LOOP)
+extern bool opt_loops;
+#endif
+
+extern bool makeinitializations;
+
+#if defined(ENABLE_STATISTICS)
+extern bool opt_stat;
+extern bool opt_getloadingtime;
+extern bool opt_getcompilingtime;
+#endif
+#if defined(ENABLE_VERIFIER)
+extern bool opt_verify;
+#endif
+
+#if defined(ENABLE_PROFILING)
+extern bool opt_prof;
+extern bool opt_prof_bb;
+#endif
+
+/* optimization options *******************************************************/
+
+#if defined(ENABLE_IFCONV)
+extern bool opt_ifconv;
+#endif
+
+#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
+extern bool opt_lsra;
+#endif
+#if defined(ENABLE_SSA)
+extern bool opt_ssa_dce;          /* enable dead code elemination */
+extern bool opt_ssa_cp;           /* enable copy propagation      */
+#endif
+
+/* interpreter options ********************************************************/
+
+#if defined(ENABLE_INTRP)
+extern bool opt_no_dynamic;
+extern bool opt_no_replication;
+extern bool opt_no_quicksuper;
+
+extern s4   opt_static_supers;
+extern bool vm_debug;
+#endif
+
+/* debug output filtering options *********************************************/
+
+#if defined(ENABLE_DEBUG_FILTER)
+extern const char *opt_filter_verbosecall_include;
+extern const char *opt_filter_verbosecall_exclude;
+extern const char *opt_filter_show_method;
+#endif
+
+
+/* -XX options ****************************************************************/
+
+/* NOTE: For better readability keep these alpha-sorted. */
+
+/* Options which must always be available (production options in
+   HotSpot). */
+
+extern int64_t  opt_MaxDirectMemorySize;
+extern int      opt_MaxPermSize;
+extern int      opt_PermSize;
+extern int      opt_ThreadStackSize;
+
+/* Debugging options which can be turned off. */
+
+extern bool     opt_AlwaysEmitLongBranches;
+extern int      opt_DebugExceptions;
+extern int      opt_DebugFinalizer;
+extern int      opt_DebugLocalReferences;
+extern int      opt_DebugLocks;
+extern int      opt_DebugPatcher;
+extern int      opt_DebugPackage;
+extern int      opt_DebugProperties;
+extern int      opt_DebugStackFrameInfo;
+extern int      opt_DebugStackTrace;
+extern int      opt_DebugThreads;
+#if defined(ENABLE_DISASSEMBLER)
+extern int      opt_DisassembleStubs;
+#endif
+#if defined(ENABLE_OPAGENT)
+extern int      opt_EnableOpagent;
+#endif
+#if defined(ENABLE_GC_CACAO)
+extern int      opt_GCDebugRootSet;
+extern int      opt_GCStress;
+#endif
+#if defined(ENABLE_INLINING)
+extern int      opt_Inline;
+#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
+extern int      opt_InlineAll;
+extern int      opt_InlineCount;
+extern int      opt_InlineMaxSize;
+extern int      opt_InlineMinSize;
+#endif
+#endif
+extern int      opt_PrintConfig;
+extern int      opt_ProfileGCMemoryUsage;
+extern int      opt_ProfileMemoryUsage;
+extern FILE    *opt_ProfileMemoryUsageGNUPlot;
+#if defined(ENABLE_REPLACEMENT)
+extern int      opt_TestReplacement;
+#endif
+extern int      opt_TraceCompilerCalls;
+extern int      opt_TraceExceptions;
+extern int      opt_TraceHPI;
+#if defined(ENABLE_INLINING) && !defined(NDEBUG)
+extern int      opt_TraceInlining;
+#endif
+extern int      opt_TraceJavaCalls;
+extern int      opt_TraceJNICalls;
+extern int      opt_TraceJVMCalls;
+extern int      opt_TraceJVMCallsVerbose;
+extern int      opt_TraceLinkClass;
+#if defined(ENABLE_REPLACEMENT)
+extern int      opt_TraceReplacement;
+#endif
+extern int      opt_TraceSubsystemInitialization;
+extern int      opt_TraceTraps;
+
+
+/* function prototypes ********************************************************/
+
+int  options_get(opt_struct *opts, JavaVMInitArgs *vm_args);
+void options_xx(JavaVMInitArgs *vm_args);
+
+
+/* debug **********************************************************************/
+
+#if !defined(NDEBUG)
+# define TRACESUBSYSTEMINITIALIZATION(text)                                            \
+    do {                                                                                                               \
+        if (opt_TraceSubsystemInitialization) {                                        \
+            log_println("[Initializing subsystem: %s]", text); \
+        }                                                                                                              \
+    } while (0)
+#else
+# define TRACESUBSYSTEMINITIALIZATION(text)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OPTIONS_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:
+ */
diff --git a/src/vm/os.cpp b/src/vm/os.cpp
new file mode 100644 (file)
index 0000000..296834f
--- /dev/null
@@ -0,0 +1,300 @@
+/* src/vm/os.cpp - system (OS) functions
+
+   Copyright (C) 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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"
+
+/* NOTE: In this file we check for all system headers, because we wrap
+   all system calls into functions for better portability. */
+
+#if defined(HAVE_ERRNO_H)
+# include <errno.h>
+#endif
+
+#if defined(HAVE_STDINT_H)
+# include <stdint.h>
+#endif
+
+#if defined(HAVE_STRING_H)
+# include <string.h>
+#endif
+
+#if defined(HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#if defined(HAVE_SYS_MMAN_H)
+# include <sys/mman.h>
+#endif
+
+#if defined(__DARWIN__)
+# include <mach/mach.h>
+# include <mach/mach_host.h>
+# include <mach/host_info.h>
+#endif
+
+/* this should work on BSD */
+/* #include <sys/sysctl.h> */
+
+#include "vm/vm.hpp"
+
+
+/**
+ * Prints an error message and aborts the VM.
+ *
+ * @param text Error message to print.
+ */
+void os::abort(const char* text, ...)
+{
+       va_list ap;
+
+       // Print the log message.
+       log_start();
+
+       va_start(ap, text);
+       log_vprint(text, ap);
+       va_end(ap);
+
+       log_finish();
+
+       // Print a backtrace.
+       os::print_backtrace();
+
+       // Now abort the VM.
+       os::abort();
+}
+
+
+/**
+ * Prints an error message, appends ":" plus the strerror-message of
+ * errnum and aborts the VM.
+ *
+ * @param errnum Error number.
+ * @param text   Error message to print.
+ */
+void os::abort_errnum(int errnum, const char* text, ...)
+{
+       va_list ap;
+
+       // Print the log message.
+       log_start();
+
+       va_start(ap, text);
+       log_vprint(text, ap);
+       va_end(ap);
+
+       // Print the strerror-message of errnum.
+       log_print(": %s", os::strerror(errnum));
+
+       log_finish();
+
+       // Print a backtrace.
+       os::print_backtrace();
+
+       // Now abort the VM.
+       os::abort();
+}
+
+
+/**
+ * Equal to abort_errnum, but uses errno to get the error number.
+ *
+ * @param text Error message to print.
+ */
+void os::abort_errno(const char* text, ...)
+{
+       va_list ap;
+
+       va_start(ap, text);
+       abort_errnum(errno, text, ap);
+       va_end(ap);
+}
+
+
+/**
+ * Maps anonymous memory, even on systems not defining
+ * MAP_ANON(YMOUS).
+ *
+ * @param ...
+ */
+void* os::mmap_anonymous(void *addr, size_t len, int prot, int flags)
+{
+       void* p;
+
+#if defined(MAP_ANON) || defined(MAP_ANONYMOUS)
+       p = mmap(addr, len, prot,
+# if defined(MAP_ANON)
+                        MAP_ANON | flags,
+# else
+                        MAP_ANONYMOUS | flags,
+# endif
+                        -1, 0);
+#else
+       int fd;
+
+       fd = open("/dev/zero", O_RDONLY, 0);
+
+       if (fd == -1)
+               os::abort_errno("os::mmap_anonymous: open failed");
+
+       p = mmap(addr, len, prot, flags, fd, 0);
+#endif
+
+#if defined(MAP_FAILED)
+       if (p == MAP_FAILED)
+#else
+       if (p == (void *) -1)
+#endif
+               os::abort_errno("os::mmap_anonymous: mmap failed");
+
+       return p;
+}
+
+
+/**
+ * Print a C backtrace.
+ */
+void os::print_backtrace()
+{
+#define BACKTRACE_SIZE 100
+       void** array = new void*[SIZEOF_VOID_P * BACKTRACE_SIZE];
+
+       // Get the backtrace.
+       int size = backtrace(array, BACKTRACE_SIZE);
+
+       // Resolve the symbols.
+       char** strings = backtrace_symbols(array, size);
+
+       log_println("Backtrace (%d stack frames):", size);
+
+       for (int i = 0; i < size; i++)
+               log_println("%s", strings[i]);
+
+       // We have to free the strings.
+       free(strings);
+}
+
+
+/**
+ * Returns the number of online processors in the system.
+ *
+ * @return Number of online processors.
+ */
+int os::processors_online(void)
+{
+#if defined(_SC_NPROC_ONLN)
+
+       return (int) sysconf(_SC_NPROC_ONLN);
+
+#elif defined(_SC_NPROCESSORS_ONLN)
+
+       return (int) sysconf(_SC_NPROCESSORS_ONLN);
+
+#elif defined(__DARWIN__)
+
+       host_basic_info_data_t hinfo;
+       mach_msg_type_number_t hinfo_count = HOST_BASIC_INFO_COUNT;
+       kern_return_t rc;
+
+       rc = host_info(mach_host_self(), HOST_BASIC_INFO,
+                                  (host_info_t) &hinfo, &hinfo_count);
+       if (rc != KERN_SUCCESS) {
+               return -1;
+       }
+
+       /* XXX michi: according to my infos this should be
+          hinfo.max_cpus, can someone please confirm or deny that? */
+       return (int) hinfo.avail_cpus;
+
+#elif defined(__FREEBSD__)
+# error IMPLEMENT ME!
+
+       /* this should work in BSD */
+       /*
+       int ncpu, mib[2], rc;
+       size_t len;
+
+       mib[0] = CTL_HW;
+       mib[1] = HW_NCPU;
+       len = sizeof(ncpu);
+       rc = sysctl(mib, 2, &ncpu, &len, NULL, 0);
+
+       return (int32_t) ncpu;
+       */
+
+#else
+
+       return 1;
+
+#endif
+}
+
+
+// Legacy C interface.
+
+extern "C" {
+       void*  os_mmap_anonymous(void *addr, size_t len, int prot, int flags) { return os::mmap_anonymous(addr, len, prot, flags); }
+
+       void   os_abort(void) { os::abort(); }
+       int    os_access(const char* pathname, int mode) { return os::access(pathname, mode); }
+       int    os_atoi(const char* nptr) { return os::atoi(nptr); }
+       void*  os_calloc(size_t nmemb, size_t size) { return os::calloc(nmemb, size); }
+#if defined(ENABLE_JRE_LAYOUT)
+       char*  os_dirname(char* path) { return os::dirname(path); }
+#endif
+       char*  os_dlerror(void) { return os::dlerror(); }
+       void*  os_dlsym(void* handle, const char* symbol) { return os::dlsym(handle, symbol); }
+       int    os_fclose(FILE* fp) { return os::fclose(fp); }
+       FILE*  os_fopen(const char* path, const char* mode) { return os::fopen(path, mode); }
+       size_t os_fread(void* ptr, size_t size, size_t nmemb, FILE* stream) { return os::fread(ptr, size, nmemb, stream); }
+       void   os_free(void* ptr) { os::free(ptr); }
+       int    os_getpagesize(void) { return os::getpagesize(); }
+       void*  os_memcpy(void* dest, const void* src, size_t n) { return os::memcpy(dest, src, n); }
+       void*  os_memset(void* s, int c, size_t n) { return os::memset(s, c, n); }
+       int    os_mprotect(void* addr, size_t len, int prot) { return os::mprotect(addr, len, prot); }
+       int    os_scandir(const char* dir, struct dirent*** namelist, int(*filter)(const struct dirent*), int(*compar)(const void*, const void*)) { return os::scandir(dir, namelist, filter, compar); }
+       int    os_stat(const char* path, struct stat* buf) { return os::stat(path, buf); }
+       char*  os_strcat(char* dest, const char* src) { return os::strcat(dest, src); }
+       char*  os_strcpy(char* dest, const char* src) { return os::strcpy(dest, src); }
+       char*  os_strdup(const char* s) { return os::strdup(s); }
+       int    os_strlen(const char* s) { return os::strlen(s); }
+
+}
+
+
+/*
+ * 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/os.hpp b/src/vm/os.hpp
new file mode 100644 (file)
index 0000000..66de93d
--- /dev/null
@@ -0,0 +1,683 @@
+/* src/vm/os.hpp - system (OS) functions
+
+   Copyright (C) 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2008 Theobroma Systems Ltd.
+
+   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 _OS_HPP
+#define _OS_HPP
+
+#include "config.h"
+
+// NOTE: In this file we check for all system headers, because we wrap
+// all system calls into inline functions for better portability.
+
+// Please don't include CACAO headers here as this header should be a
+// very low-level one.
+
+#if defined(HAVE_DIRENT_H)
+# include <dirent.h>
+#endif
+
+#if defined(HAVE_DLFCN_H)
+# include <dlfcn.h>
+#endif
+
+#if defined(HAVE_ERRNO_H)
+# include <errno.h>
+#endif
+
+#if defined(HAVE_EXECINFO_H)
+# include <execinfo.h>
+#endif
+
+#if defined(HAVE_FCNTL_H)
+# include <fcntl.h>
+#endif
+
+#if defined(ENABLE_JRE_LAYOUT)
+# if defined(HAVE_LIBGEN_H)
+#  include <libgen.h>
+# endif
+#endif
+
+#if defined(HAVE_SIGNAL_H)
+# include <signal.h>
+#endif
+
+#if defined(HAVE_STDARG_H)
+# include <stdarg.h>
+#endif
+
+#if defined(HAVE_STDINT_H)
+# include <stdint.h>
+#endif
+
+#if defined(HAVE_STDIO_H)
+# include <stdio.h>
+#endif
+
+#if defined(HAVE_STDLIB_H)
+# include <stdlib.h>
+#endif
+
+#if defined(HAVE_STRING_H)
+# include <string.h>
+#endif
+
+#if defined(HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#if defined(HAVE_SYS_MMAN_H)
+# include <sys/mman.h>
+#endif
+
+#if defined(HAVE_SYS_SOCKET_H)
+# include <sys/socket.h>
+#endif
+
+#if defined(HAVE_SYS_STAT_H)
+# include <sys/stat.h>
+#endif
+
+#if defined(HAVE_SYS_TYPES_H)
+# include <sys/types.h>
+#endif
+
+
+#ifdef __cplusplus
+
+// Class wrapping system (OS) functions.
+class os {
+public:
+       // Inline functions.
+       static inline void    abort();
+       static inline int     accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen);
+       static inline int     access(const char *pathname, int mode);
+       static inline int     atoi(const char* nptr);
+       static inline int     backtrace(void** array, int size);
+       static inline char**  backtrace_symbols(void* const* array, int size) throw ();
+       static inline void*   calloc(size_t nmemb, size_t size);
+       static inline int     close(int fd);
+       static inline int     connect(int sockfd, const struct sockaddr* serv_addr, socklen_t addrlen);
+#if defined(ENABLE_JRE_LAYOUT)
+       static inline char*   dirname(char* path);
+#endif
+       static inline int     dlclose(void* handle);
+       static inline char*   dlerror(void);
+       static inline void*   dlopen(const char* filename, int flag);
+       static inline void*   dlsym(void* handle, const char* symbol);
+       static inline int     fclose(FILE* fp);
+       static inline FILE*   fopen(const char* path, const char* mode);
+       static inline int     fprintf(FILE* stream, const char* format, ...);
+       static inline size_t  fread(void* ptr, size_t size, size_t nmemb, FILE* stream);
+       static inline void    free(void* ptr);
+       static inline char*   getenv(const char* name);
+       static inline int     gethostname(char* name, size_t len);
+       static inline int     getpagesize(void);
+       static inline int     getsockname(int s, struct sockaddr* name, socklen_t* namelen);
+       static inline int     getsockopt(int s, int level, int optname, void* optval, socklen_t* optlen);
+       static inline int     listen(int sockfd, int backlog);
+       static inline void*   malloc(size_t size);
+       static inline void*   memcpy(void* dest, const void* src, size_t n);
+       static inline void*   memset(void* s, int c, size_t n);
+       static inline int     mprotect(void* addr, size_t len, int prot);
+       static inline ssize_t readlink(const char* path, char* buf, size_t bufsiz);
+       static inline int     scandir(const char* dir, struct dirent*** namelist, int(*filter)(const struct dirent*), int(*compar)(const void*, const void*));
+       static inline int     setsockopt(int s, int level, int optname, const void* optval, socklen_t optlen);
+       static inline int     shutdown(int s, int how);
+       static inline int     socket(int domain, int type, int protocol);
+       static inline int     stat(const char* path, struct stat* buf);
+#if defined(__SOLARIS__)
+       static inline int     str2sig(const char* str, int* signum);
+#endif
+       static inline char*   strcat(char* dest, const char* src);
+       static inline int     strcmp(const char* s1, const char* s2);
+       static inline char*   strcpy(char* dest, const char* src);
+       static inline char*   strdup(const char* s);
+       static inline size_t  strlen(const char* s);
+       static inline char*   strerror(int errnum);
+
+       // Convenience functions.
+       static void  abort(const char* text, ...);
+       static void  abort_errnum(int errnum, const char* text, ...);
+       static void  abort_errno(const char* text, ...);
+       static void* mmap_anonymous(void *addr, size_t len, int prot, int flags);
+       static void  print_backtrace();
+       static int   processors_online();
+};
+
+
+inline void os::abort(void)
+{
+#if defined(HAVE_ABORT)
+       ::abort();
+#else
+# error abort not available
+#endif
+}
+
+inline int os::accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen)
+{
+#if defined(HAVE_ACCEPT)
+       return ::accept(sockfd, addr, addrlen);
+#else
+# error accept not available
+#endif
+}
+
+inline int os::access(const char* pathname, int mode)
+{
+#if defined(HAVE_ACCESS)
+       return ::access(pathname, mode);
+#else
+# error access not available
+#endif
+}
+
+inline int os::atoi(const char* nptr)
+{
+#if defined(HAVE_ATOI)
+       return ::atoi(nptr);
+#else
+# error atoi not available
+#endif
+}
+
+inline int os::backtrace(void** array, int size)
+{
+#if defined(HAVE_BACKTRACE)
+       return ::backtrace(array, size);
+#else
+       fprintf(stderr, "os::backtrace: Not available.");
+       return 0;
+#endif
+}
+
+inline char** os::backtrace_symbols(void* const* array, int size) throw ()
+{
+#if defined(HAVE_BACKTRACE_SYMBOLS)
+       return ::backtrace_symbols(array, size);
+#else
+       fprintf(stderr, "os::backtrace_symbols: Not available.");
+       return NULL;
+#endif
+}
+
+inline void* os::calloc(size_t nmemb, size_t size)
+{
+#if defined(HAVE_CALLOC)
+       return ::calloc(nmemb, size);
+#else
+# error calloc not available
+#endif
+}
+
+inline int os::close(int fd)
+{
+#if defined(HAVE_CLOSE)
+       return ::close(fd);
+#else
+# error close not available
+#endif
+}
+
+inline int os::connect(int sockfd, const struct sockaddr* serv_addr, socklen_t addrlen)
+{
+#if defined(HAVE_CONNECT)
+       return ::connect(sockfd, serv_addr, addrlen);
+#else
+# error connect not available
+#endif
+}
+
+#if defined(ENABLE_JRE_LAYOUT)
+inline char* os::dirname(char* path)
+{
+#if defined(HAVE_DIRNAME)
+       return ::dirname(path);
+#else
+# error dirname not available
+#endif
+}
+#endif
+
+inline int os::dlclose(void* handle)
+{
+#if defined(HAVE_DLCLOSE)
+       return ::dlclose(handle);
+#else
+# error dlclose not available
+#endif
+}
+
+inline char* os::dlerror(void)
+{
+#if defined(HAVE_DLERROR)
+       // At least FreeBSD defines dlerror() to return a const char*, so
+       // we simply cast it.
+       return (char*) ::dlerror();
+#else
+# error dlerror not available
+#endif
+}
+
+inline void* os::dlopen(const char* filename, int flag)
+{
+#if defined(HAVE_DLOPEN)
+       return ::dlopen(filename, flag);
+#else
+# error dlopen not available
+#endif
+}
+
+inline void* os::dlsym(void* handle, const char* symbol)
+{
+#if defined(HAVE_DLSYM)
+       return ::dlsym(handle, symbol);
+#else
+# error dlsym not available
+#endif
+}
+
+inline int os::fclose(FILE* fp)
+{
+#if defined(HAVE_FCLOSE)
+       return ::fclose(fp);
+#else
+# error fclose not available
+#endif
+}
+
+inline FILE* os::fopen(const char* path, const char* mode)
+{
+#if defined(HAVE_FOPEN)
+       return ::fopen(path, mode);
+#else
+# error fopen not available
+#endif
+}
+
+inline int os::fprintf(FILE* stream, const char* format, ...)
+{
+#if defined(HAVE_FPRINTF)
+       va_list ap;
+       va_start(ap, format);
+       int result = ::fprintf(stream, format, ap);
+       va_end(ap);
+       return result;
+#else
+# error fprintf not available
+#endif
+}
+
+inline size_t os::fread(void* ptr, size_t size, size_t nmemb, FILE* stream)
+{
+#if defined(HAVE_FREAD)
+       return ::fread(ptr, size, nmemb, stream);
+#else
+# error fread not available
+#endif
+}
+
+inline void os::free(void* ptr)
+{
+#if defined(HAVE_FREE)
+       ::free(ptr);
+#else
+# error free not available
+#endif
+}
+
+inline static int system_fsync(int fd)
+{
+#if defined(HAVE_FSYNC)
+       return fsync(fd);
+#else
+# error fsync not available
+#endif
+}
+
+inline static int system_ftruncate(int fd, off_t length)
+{
+#if defined(HAVE_FTRUNCATE)
+       return ftruncate(fd, length);
+#else
+# error ftruncate not available
+#endif
+}
+
+inline char* os::getenv(const char* name)
+{
+#if defined(HAVE_GETENV)
+       return ::getenv(name);
+#else
+# error getenv not available
+#endif
+}
+
+inline int os::gethostname(char* name, size_t len)
+{
+#if defined(HAVE_GETHOSTNAME)
+       return ::gethostname(name, len);
+#else
+# error gethostname not available
+#endif
+}
+
+inline int os::getpagesize(void)
+{
+#if defined(HAVE_GETPAGESIZE)
+       return ::getpagesize();
+#else
+# error getpagesize not available
+#endif
+}
+
+inline int os::getsockname(int s, struct sockaddr* name, socklen_t* namelen)
+{
+#if defined(HAVE_GETSOCKNAME)
+       return ::getsockname(s, name, namelen);
+#else
+# error getsockname not available
+#endif
+}
+
+inline int os::getsockopt(int s, int level, int optname, void* optval, socklen_t* optlen)
+{
+#if defined(HAVE_GETSOCKOPT)
+       return ::getsockopt(s, level, optname, optval, optlen);
+#else
+# error getsockopt not available
+#endif
+}
+
+inline int os::listen(int sockfd, int backlog)
+{
+#if defined(HAVE_LISTEN)
+       return ::listen(sockfd, backlog);
+#else
+# error listen not available
+#endif
+}
+
+inline static off_t system_lseek(int fildes, off_t offset, int whence)
+{
+#if defined(HAVE_LSEEK)
+       return lseek(fildes, offset, whence);
+#else
+# error lseek not available
+#endif
+}
+
+inline void* os::malloc(size_t size)
+{
+#if defined(HAVE_MALLOC)
+       return ::malloc(size);
+#else
+# error malloc not available
+#endif
+}
+
+inline void* os::memcpy(void* dest, const void* src, size_t n)
+{
+#if defined(HAVE_MEMCPY)
+       return ::memcpy(dest, src, n);
+#else
+# error memcpy not available
+#endif
+}
+
+inline void* os::memset(void* s, int c, size_t n)
+{
+#if defined(HAVE_MEMSET)
+       return ::memset(s, c, n);
+#else
+# error memset not available
+#endif
+}
+
+inline int os::mprotect(void* addr, size_t len, int prot)
+{
+#if defined(HAVE_MPROTECT)
+       return ::mprotect(addr, len, prot);
+#else
+# error mprotect not available
+#endif
+}
+
+inline static int system_open(const char *pathname, int flags, mode_t mode)
+{
+#if defined(HAVE_OPEN)
+       return open(pathname, flags, mode);
+#else
+# error open not available
+#endif
+}
+
+inline static ssize_t system_read(int fd, void *buf, size_t count)
+{
+#if defined(HAVE_READ)
+       return read(fd, buf, count);
+#else
+# error read not available
+#endif
+}
+
+inline ssize_t os::readlink(const char* path, char* buf, size_t bufsiz)
+{
+#if defined(HAVE_READLINK)
+       return ::readlink(path, buf, bufsiz);
+#else
+# error readlink not available
+#endif
+}
+
+inline static void *system_realloc(void *ptr, size_t size)
+{
+#if defined(HAVE_REALLOC)
+       return realloc(ptr, size);
+#else
+# error realloc not available
+#endif
+}
+
+inline int os::scandir(const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *))
+/*
+#elif defined(__SOLARIS__)
+inline int os::scandir(const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const struct dirent **, const struct dirent **))
+#elif defined(__IRIX__)
+inline int os::scandir(const char *dir, struct dirent ***namelist, int(*filter)(dirent_t *), int(*compar)(dirent_t **, dirent_t **))
+#else
+inline int os::scandir(const char *dir, struct dirent ***namelist, int(*filter)(struct dirent *), int(*compar)(const void *, const void *))
+#endif
+*/
+{
+#if defined(HAVE_SCANDIR)
+# if defined(__LINUX__)
+       return ::scandir(dir, namelist, filter, compar);
+#elif defined(__SOLARIS__)
+       return ::scandir(dir, namelist, filter, (int (*)(const dirent**, const dirent**)) compar);
+# else
+       return ::scandir(dir, namelist, (int (*)(struct dirent*)) filter, compar);
+# endif
+#else
+# error scandir not available
+#endif
+}
+
+inline int os::setsockopt(int s, int level, int optname, const void* optval, socklen_t optlen)
+{
+#if defined(HAVE_SETSOCKOPT)
+       return ::setsockopt(s, level, optname, optval, optlen);
+#else
+# error setsockopt not available
+#endif
+}
+
+inline int os::shutdown(int s, int how)
+{
+#if defined(HAVE_SHUTDOWN)
+       return ::shutdown(s, how);
+#else
+# error shutdown not available
+#endif
+}
+
+inline int os::socket(int domain, int type, int protocol)
+{
+#if defined(HAVE_SOCKET)
+       return ::socket(domain, type, protocol);
+#else
+# error socket not available
+#endif
+}
+
+inline int os::stat(const char* path, struct stat* buf)
+{
+#if defined(HAVE_STAT)
+       return ::stat(path, buf);
+#else
+# error stat not available
+#endif
+}
+
+#if defined(__SOLARIS__)
+inline int os::str2sig(const char* str, int* signum)
+{
+#if defined(HAVE_STR2SIG)
+       return ::str2sig(str, signum);
+#else
+# error str2sig not available
+#endif
+}
+#endif
+
+inline char* os::strcat(char* dest, const char* src)
+{
+#if defined(HAVE_STRCAT)
+       return ::strcat(dest, src);
+#else
+# error strcat not available
+#endif
+}
+
+inline int os::strcmp(const char* s1, const char* s2)
+{
+#if defined(HAVE_STRCMP)
+       return ::strcmp(s1, s2);
+#else
+# error strcmp not available
+#endif
+}
+
+inline char* os::strcpy(char* dest, const char* src)
+{
+#if defined(HAVE_STRCPY)
+       return ::strcpy(dest, src);
+#else
+# error strcpy not available
+#endif
+}
+
+inline char* os::strdup(const char* s)
+{
+#if defined(HAVE_STRDUP)
+       return ::strdup(s);
+#else
+# error strdup not available
+#endif
+}
+
+inline char* os::strerror(int errnum)
+{
+#if defined(HAVE_STRERROR)
+       return ::strerror(errnum);
+#else
+# error strerror not available
+#endif
+}
+
+inline size_t os::strlen(const char* s)
+{
+#if defined(HAVE_STRLEN)
+       return ::strlen(s);
+#else
+# error strlen not available
+#endif
+}
+
+inline static ssize_t system_write(int fd, const void *buf, size_t count)
+{
+#if defined(HAVE_WRITE)
+       return write(fd, buf, count);
+#else
+# error write not available
+#endif
+}
+
+#else
+
+void*  os_mmap_anonymous(void *addr, size_t len, int prot, int flags);
+
+void   os_abort(void);
+int    os_access(const char* pathname, int mode);
+int    os_atoi(const char* nptr);
+void*  os_calloc(size_t nmemb, size_t size);
+char*  os_dirname(char* path);
+char*  os_dlerror(void);
+void*  os_dlsym(void* handle, const char* symbol);
+int    os_fclose(FILE* fp);
+FILE*  os_fopen(const char* path, const char* mode);
+size_t os_fread(void* ptr, size_t size, size_t nmemb, FILE* stream);
+void   os_free(void* ptr);
+int    os_getpagesize(void);
+void*  os_memcpy(void* dest, const void* src, size_t n);
+void*  os_memset(void* s, int c, size_t n);
+int    os_mprotect(void* addr, size_t len, int prot);
+int    os_scandir(const char* dir, struct dirent*** namelist, int(*filter)(const struct dirent*), int(*compar)(const void*, const void*));
+int    os_stat(const char* path, struct stat* buf);
+char*  os_strcat(char* dest, const char* src);
+char*  os_strcpy(char* dest, const char* src);
+char*  os_strdup(const char* s);
+int    os_strlen(const char* s);
+
+#endif
+
+#endif // _OS_HPP
+
+
+/*
+ * 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/package.c b/src/vm/package.c
deleted file mode 100644 (file)
index c544b96..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/* src/vm/package.c - Java boot-package functions
-
-   Copyright (C) 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 <stdint.h>
-
-#include "toolbox/list.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-
-#include "native/include/java_lang_String.h"
-
-#include "vm/package.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/options.h"
-#include "vmcore/utf8.h"
-
-
-/* internal property structure ************************************************/
-
-typedef struct list_package_entry_t list_package_entry_t;
-
-struct list_package_entry_t {
-/*     java_string_t *packagename; */
-       utf           *packagename;
-       listnode_t     linkage;
-};
-
-
-/* global variables ***********************************************************/
-
-static list_t *list_package = NULL;
-
-
-/* package_init ****************************************************************
-
-   Initialize the package list.
-
-*******************************************************************************/
-
-void package_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("package_init");
-
-       /* create the properties list */
-
-       list_package = list_create(OFFSET(list_package_entry_t, linkage));
-}
-
-
-/* package_add *****************************************************************
-
-   Add a package to the boot-package list.
-
-   IN:
-       packagename....package name as Java string
-
-*******************************************************************************/
-
-/* void package_add(java_handle_t *packagename) */
-void package_add(utf *packagename)
-{
-/*     java_string_t        *s; */
-       list_package_entry_t *lpe;
-
-       /* Intern the Java string to get a unique address. */
-
-/*     s = javastring_intern(packagename); */
-
-       /* Check if the package is already stored. */
-
-       if (package_find(packagename) != NULL)
-               return;
-
-       /* Add the package. */
-
-#if !defined(NDEBUG)
-       if (opt_DebugPackage) {
-               log_start();
-               log_print("[package_add: packagename=");
-               utf_display_printable_ascii(packagename);
-               log_print("]");
-               log_finish();
-       }
-#endif
-
-       lpe = NEW(list_package_entry_t);
-
-       lpe->packagename = packagename;
-
-       list_add_last(list_package, lpe);
-}
-
-
-/* package_find ****************************************************************
-
-   Find a package in the list.
-
-   IN:
-       packagename....package name as Java string
-
-   OUT:
-       package name as Java string
-
-*******************************************************************************/
-
-/* java_handle_t *package_find(java_handle_t *packagename) */
-utf *package_find(utf *packagename)
-{
-/*     java_string_t        *s; */
-       list_t               *l;
-       list_package_entry_t *lpe;
-
-       /* Intern the Java string to get a unique address. */
-
-/*     s = javastring_intern(packagename); */
-
-       /* For convenience. */
-
-       l = list_package;
-
-       for (lpe = list_first(l); lpe != NULL; lpe = list_next(l, lpe)) {
-/*             if (lpe->packagename == s) */
-               if (lpe->packagename == packagename)
-                       return lpe->packagename;
-       }
-
-       return NULL;
-}
-
-
-/*
- * 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/package.cpp b/src/vm/package.cpp
new file mode 100644 (file)
index 0000000..a112aca
--- /dev/null
@@ -0,0 +1,98 @@
+/* src/vm/package.cpp - Java boot-package functions
+
+   Copyright (C) 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 <stdint.h>
+
+#include "mm/memory.h"
+
+#include "vm/options.h"
+#include "vm/package.hpp"
+#include "vm/string.hpp"
+#include "vm/utf8.h"
+
+
+// Package list.
+
+std::set<utf*> Package::_packages;
+
+
+/**
+ * Add a package to the boot-package list.
+ *
+ * @param packagename Package name as Java string.
+ */
+void Package::add(utf* packagename)
+{
+       // Intern the Java string to get a unique address.
+/*     s = javastring_intern(packagename); */
+
+#if !defined(NDEBUG)
+       if (opt_DebugPackage) {
+               log_start();
+               log_print("[package_add: packagename=");
+               utf_display_printable_ascii(packagename);
+               log_print("]");
+               log_finish();
+       }
+#endif
+
+       // Add the package name.
+       _packages.insert(packagename);
+}
+
+
+/**
+ * Find a package in the list.
+ *
+ * @param packagename Package name as Java string.
+ *
+ * @return Package name as Java string.
+ */
+utf* Package::find(utf* packagename)
+{
+       std::set<utf*>::iterator it = _packages.find(packagename);
+
+       if (it == _packages.end())
+               return NULL;
+
+       return *it;
+}
+
+
+/*
+ * 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/package.h b/src/vm/package.h
deleted file mode 100644 (file)
index 95fcd54..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* src/vm/package.c - Java boot-package functions
-
-   Copyright (C) 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
-
-   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 _VM_PACKAGE_H
-#define _VM_PACKAGE_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-
-#include "vm/global.h"
-
-
-/* function prototypes ********************************************************/
-
-void           package_init(void);
-
-/* void           package_add(java_handle_t *packagename); */
-void           package_add(utf *packagename);
-/* java_handle_t *package_find(java_handle_t *packagename); */
-utf           *package_find(utf *packagename);
-
-#endif /* _VM_PACKAGE_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/package.hpp b/src/vm/package.hpp
new file mode 100644 (file)
index 0000000..7e7669b
--- /dev/null
@@ -0,0 +1,65 @@
+/* src/vm/package.hpp - Java boot-package functions
+
+   Copyright (C) 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 _VM_PACKAGE_HPP
+#define _VM_PACKAGE_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include <set>
+
+#include "vm/utf8.h"
+
+
+/**
+ *
+ */
+class Package {
+private:
+       static std::set<utf*> _packages;
+
+public:
+       static void add (utf* packagename);
+       static utf* find(utf* packagename);
+};
+
+#endif // _VM_PACKAGE_HPP
+
+
+/*
+ * 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/primitive.c b/src/vm/primitive.c
deleted file mode 100644 (file)
index ca55726..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
-/* src/vm/primitive.c - primitive types
-
-   Copyright (C) 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 <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.h"
-
-#include "native/include/java_lang_Boolean.h"
-#include "native/include/java_lang_Byte.h"
-#include "native/include/java_lang_Short.h"
-#include "native/include/java_lang_Character.h"
-#include "native/include/java_lang_Integer.h"
-#include "native/include/java_lang_Long.h"
-#include "native/include/java_lang_Float.h"
-#include "native/include/java_lang_Double.h"
-
-#include "vm/builtin.h"
-#include "vm/global.h"
-#include "vm/primitive.h"
-#include "vm/vm.h"
-
-#include "vmcore/class.h"
-#include "vmcore/utf8.h"
-
-
-/* primitive_class_get_by_name *************************************************
-
-   Returns the primitive class of the given class name.
-
-*******************************************************************************/
-
-classinfo *primitive_class_get_by_name(utf *name)
-{
-       int i;
-
-       /* search table of primitive classes */
-
-       for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
-               if (primitivetype_table[i].name == name)
-                       return primitivetype_table[i].class_primitive;
-
-       /* keep compiler happy */
-
-       return NULL;
-}
-
-
-/* primitive_class_get_by_type *************************************************
-
-   Returns the primitive class of the given type.
-
-*******************************************************************************/
-
-classinfo *primitive_class_get_by_type(int type)
-{
-       return primitivetype_table[type].class_primitive;
-}
-
-
-/* primitive_class_get_by_char *************************************************
-
-   Returns the primitive class of the given type.
-
-*******************************************************************************/
-
-classinfo *primitive_class_get_by_char(char ch)
-{
-       int index;
-
-       switch (ch) {
-       case 'I':
-               index = PRIMITIVETYPE_INT;
-               break;
-       case 'J':
-               index = PRIMITIVETYPE_LONG;
-               break;
-       case 'F':
-               index = PRIMITIVETYPE_FLOAT;
-               break;
-       case 'D':
-               index = PRIMITIVETYPE_DOUBLE;
-               break;
-       case 'B':
-               index = PRIMITIVETYPE_BYTE;
-               break;
-       case 'C':
-               index = PRIMITIVETYPE_CHAR;
-               break;
-       case 'S':
-               index = PRIMITIVETYPE_SHORT;
-               break;
-       case 'Z':
-               index = PRIMITIVETYPE_BOOLEAN;
-               break;
-       case 'V':
-               index = PRIMITIVETYPE_VOID;
-               break;
-       default:
-               return NULL;
-       }
-
-       return primitivetype_table[index].class_primitive;
-}
-
-
-/* primitive_arrayclass_get_by_name ********************************************
-
-   Returns the primitive array-class of the given primitive class
-   name.
-
-*******************************************************************************/
-
-classinfo *primitive_arrayclass_get_by_name(utf *name)
-{
-       int i;
-
-       /* search table of primitive classes */
-
-       for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
-               if (primitivetype_table[i].name == name)
-                       return primitivetype_table[i].arrayclass;
-
-       /* keep compiler happy */
-
-       return NULL;
-}
-
-
-/* primitive_arrayclass_get_by_type ********************************************
-
-   Returns the primitive array-class of the given type.
-
-*******************************************************************************/
-
-classinfo *primitive_arrayclass_get_by_type(int type)
-{
-       return primitivetype_table[type].arrayclass;
-}
-
-
-/* primitive_type_get_by_wrapperclass ******************************************
-
-   Returns the primitive type of the given wrapper-class.
-
-*******************************************************************************/
-
-int primitive_type_get_by_wrapperclass(classinfo *c)
-{
-       int i;
-
-       /* Search primitive table. */
-
-       for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
-               if (primitivetype_table[i].class_wrap == c)
-                       return i;
-
-       /* Invalid primitive wrapper-class. */
-
-       return -1;
-}
-
-
-/* primitive_box ***************************************************************
-
-   Box a primitive of the given type.  If the type is an object,
-   simply return it.
-
-*******************************************************************************/
-
-java_handle_t *primitive_box(int type, imm_union value)
-{
-       java_handle_t *o;
-
-       switch (type) {
-       case PRIMITIVETYPE_BOOLEAN:
-               o = primitive_box_boolean(value.i);
-               break;
-       case PRIMITIVETYPE_BYTE:
-               o = primitive_box_byte(value.i);
-               break;
-       case PRIMITIVETYPE_CHAR:
-               o = primitive_box_char(value.i);
-               break;
-       case PRIMITIVETYPE_SHORT:
-               o = primitive_box_short(value.i);
-               break;
-       case PRIMITIVETYPE_INT:
-               o = primitive_box_int(value.i);
-               break;
-       case PRIMITIVETYPE_LONG:
-               o = primitive_box_long(value.l);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               o = primitive_box_float(value.f);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               o = primitive_box_double(value.d);
-               break;
-       case PRIMITIVETYPE_VOID:
-               o = value.a;
-               break;
-       default:
-               o = NULL;
-               vm_abort("primitive_box: invalid primitive type %d", type);
-       }
-
-       return o;
-}
-
-
-/* primitive_unbox *************************************************************
-
-   Unbox a primitive of the given type.  If the type is an object,
-   simply return it.
-
-*******************************************************************************/
-
-imm_union primitive_unbox(java_handle_t *o)
-{
-       classinfo *c;
-       int        type;
-       imm_union  value;
-
-       if (o == NULL) {
-               value.a = NULL;
-               return value;
-       }
-
-       LLNI_class_get(o, c);
-
-       type = primitive_type_get_by_wrapperclass(c);
-
-       switch (type) {
-       case PRIMITIVETYPE_BOOLEAN:
-               value.i = primitive_unbox_boolean(o);
-               break;
-       case PRIMITIVETYPE_BYTE:
-               value.i = primitive_unbox_byte(o);
-               break;
-       case PRIMITIVETYPE_CHAR:
-               value.i = primitive_unbox_char(o);
-               break;
-       case PRIMITIVETYPE_SHORT:
-               value.i = primitive_unbox_short(o);
-               break;
-       case PRIMITIVETYPE_INT:
-               value.i = primitive_unbox_int(o);
-               break;
-       case PRIMITIVETYPE_LONG:
-               value.l = primitive_unbox_long(o);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               value.f = primitive_unbox_float(o);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               value.d = primitive_unbox_double(o);
-               break;
-       case -1:
-               /* If type is -1 the object is not a primitive box but a
-                  normal object. */
-               value.a = o;
-               break;
-       default:
-               vm_abort("primitive_unbox: invalid primitive type %d", type);
-       }
-
-       return value;
-}
-
-
-/* primitive_box_xxx ***********************************************************
-
-   Box a primitive type.
-
-*******************************************************************************/
-
-#define PRIMITIVE_BOX_TYPE(name, object, type)      \
-java_handle_t *primitive_box_##name(type value)     \
-{                                                   \
-       java_handle_t      *o;                          \
-       java_lang_##object *jo;                         \
-                                                    \
-       o = builtin_new(class_java_lang_##object);      \
-                                                    \
-       if (o == NULL)                                  \
-               return NULL;                                \
-                                                    \
-       jo = (java_lang_##object *) o;                  \
-                                                    \
-       LLNI_field_set_val(jo, value, value);           \
-                                                    \
-       return o;                                       \
-}
-
-PRIMITIVE_BOX_TYPE(boolean, Boolean,   int32_t)
-PRIMITIVE_BOX_TYPE(byte,    Byte,      int32_t)
-PRIMITIVE_BOX_TYPE(char,    Character, int32_t)
-PRIMITIVE_BOX_TYPE(short,   Short,     int32_t)
-PRIMITIVE_BOX_TYPE(int,     Integer,   int32_t)
-PRIMITIVE_BOX_TYPE(long,    Long,      int64_t)
-PRIMITIVE_BOX_TYPE(float,   Float,     float)
-PRIMITIVE_BOX_TYPE(double,  Double,    double)
-
-
-/* primitive_unbox_xxx *********************************************************
-
-   Unbox a primitive type.
-
-*******************************************************************************/
-
-#define PRIMITIVE_UNBOX_TYPE(name, object, type)  \
-type primitive_unbox_##name(java_handle_t *o)     \
-{                                                 \
-       java_lang_##object *jo;                       \
-       type                value;                    \
-                                                  \
-       jo = (java_lang_##object *) o;                \
-                                                  \
-       LLNI_field_get_val(jo, value, value);         \
-                                                  \
-       return value;                                 \
-}
-
-PRIMITIVE_UNBOX_TYPE(boolean, Boolean,   int32_t)
-PRIMITIVE_UNBOX_TYPE(byte,    Byte,      int32_t)
-PRIMITIVE_UNBOX_TYPE(char,    Character, int32_t)
-PRIMITIVE_UNBOX_TYPE(short,   Short,     int32_t)
-PRIMITIVE_UNBOX_TYPE(int,     Integer,   int32_t)
-PRIMITIVE_UNBOX_TYPE(long,    Long,      int64_t)
-PRIMITIVE_UNBOX_TYPE(float,   Float,     float)
-PRIMITIVE_UNBOX_TYPE(double,  Double,    double)
-
-
-/*
- * 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/primitive.cpp b/src/vm/primitive.cpp
new file mode 100644 (file)
index 0000000..4d3c654
--- /dev/null
@@ -0,0 +1,673 @@
+/* src/vm/primitive.cpp - primitive types
+
+   Copyright (C) 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 <stdint.h>
+
+#include "native/llni.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/options.h"
+#include "vm/os.hpp"
+#include "vm/primitive.hpp"
+#include "vm/utf8.h"
+
+
+/* primitivetype_table *********************************************************
+
+   Structure for primitive classes: contains the class for wrapping
+   the primitive type, the primitive class, the name of the class for
+   wrapping, the one character type signature and the name of the
+   primitive class.
+   CAUTION: Don't change the order of the types. This table is indexed
+   by the ARRAYTYPE_ constants (except ARRAYTYPE_OBJECT).
+
+*******************************************************************************/
+
+primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT] = {
+       { "int"     , NULL, NULL, NULL, "java/lang/Integer",   'I', "[I", NULL },
+       { "long"    , NULL, NULL, NULL, "java/lang/Long",      'J', "[J", NULL },
+       { "float"   , NULL, NULL, NULL, "java/lang/Float",     'F', "[F", NULL },
+       { "double"  , NULL, NULL, NULL, "java/lang/Double",    'D', "[D", NULL },
+       { NULL      , NULL, NULL, NULL, NULL,                   0 , NULL, NULL },
+       { "byte"    , NULL, NULL, NULL, "java/lang/Byte",      'B', "[B", NULL },
+       { "char"    , NULL, NULL, NULL, "java/lang/Character", 'C', "[C", NULL },
+       { "short"   , NULL, NULL, NULL, "java/lang/Short",     'S', "[S", NULL },
+       { "boolean" , NULL, NULL, NULL, "java/lang/Boolean",   'Z', "[Z", NULL },
+       { NULL      , NULL, NULL, NULL, NULL,                   0 , NULL, NULL },
+#if defined(ENABLE_JAVASE)
+       { "void"    , NULL, NULL, NULL, "java/lang/Void",      'V', NULL, NULL }
+#else
+       { NULL      , NULL, NULL, NULL, NULL,                   0 , NULL, NULL },
+#endif
+};
+
+
+/**
+ * Fill the primitive type table with the primitive-type classes,
+ * array-classes and wrapper classes.  This is important in the VM
+ * startup.
+ *
+ * We split this primitive-type table initialization because of
+ * annotations in the bootstrap classes.
+ *
+ * But we may get a problem if we have annotations in:
+ *
+ * java/lang/Object
+ * java/lang/Cloneable
+ * java/io/Serializable
+ *
+ * Also see: loader_preinit and linker_preinit.
+ */
+void Primitive::initialize_table()
+{  
+       utf       *name;
+       classinfo *c;
+       utf       *u;
+       classinfo *ac;
+
+       TRACESUBSYSTEMINITIALIZATION("primitive_init");
+
+       /* Load and link primitive-type classes and array-classes. */
+
+       for (int i = 0; i < PRIMITIVETYPE_COUNT; i++) {
+               /* Skip dummy entries. */
+
+               if (primitivetype_table[i].cname == NULL)
+                       continue;
+
+               /* create UTF-8 name */
+
+               name = utf_new_char(primitivetype_table[i].cname);
+
+               primitivetype_table[i].name = name;
+
+               /* create primitive class */
+
+               c = class_create_classinfo(name);
+
+               /* Primitive type classes don't have a super class. */
+
+               c->super = NULL;
+
+               /* set flags and mark it as primitive class */
+
+               c->flags = ACC_PUBLIC | ACC_FINAL | ACC_ABSTRACT | ACC_CLASS_PRIMITIVE;
+               
+               /* prevent loader from loading primitive class */
+
+               c->state |= CLASS_LOADED;
+
+               /* INFO: don't put primitive classes into the classcache */
+
+               if (!link_class(c))
+                       vm_abort("linker_init: linking failed");
+
+               /* Just to be sure. */
+
+               assert(c->state & CLASS_LOADED);
+               assert(c->state & CLASS_LINKED);
+
+               primitivetype_table[i].class_primitive = c;
+
+               /* Create primitive array class. */
+
+               if (primitivetype_table[i].arrayname != NULL) {
+                       u  = utf_new_char(primitivetype_table[i].arrayname);
+                       ac = class_create_classinfo(u);
+                       ac = load_newly_created_array(ac, NULL);
+
+                       if (ac == NULL)
+                               vm_abort("primitive_init: loading failed");
+
+                       assert(ac->state & CLASS_LOADED);
+
+                       if (!link_class(ac))
+                               vm_abort("primitive_init: linking failed");
+
+                       /* Just to be sure. */
+
+                       assert(ac->state & CLASS_LOADED);
+                       assert(ac->state & CLASS_LINKED);
+
+                       primitivetype_table[i].arrayclass = ac;
+               }
+       }
+
+       /* We use two for-loops to have the array-classes already in the
+          primitive-type table (hint: annotations in wrapper-classes). */
+
+       for (int i = 0; i < PRIMITIVETYPE_COUNT; i++) {
+               /* Skip dummy entries. */
+
+               if (primitivetype_table[i].cname == NULL)
+                       continue;
+
+               /* Create class for wrapping the primitive type. */
+
+               u = utf_new_char(primitivetype_table[i].wrapname);
+               c = load_class_bootstrap(u);
+
+               if (c == NULL)
+                       vm_abort("primitive_init: loading failed");
+
+               if (!link_class(c))
+                       vm_abort("primitive_init: linking failed");
+
+               /* Just to be sure. */
+
+               assert(c->state & CLASS_LOADED);
+               assert(c->state & CLASS_LINKED);
+
+               primitivetype_table[i].class_wrap = c;
+       }
+}
+
+
+/**
+ * Finish the primitive-type table initialization.  In this step we
+ * set the vftbl of the primitive-type classes.
+ *
+ * This is necessary because java/lang/Class is loaded and linked
+ * after the primitive types have been linked.
+ *
+ * We have to do that in an extra function, as the primitive types are
+ * not stored in the classcache.
+ */
+void Primitive::post_initialize_table()
+{
+       classinfo *c;
+       int        i;
+
+       TRACESUBSYSTEMINITIALIZATION("primitive_postinit");
+
+       assert(class_java_lang_Class);
+       assert(class_java_lang_Class->vftbl);
+
+       for (i = 0; i < PRIMITIVETYPE_COUNT; i++) {
+               /* Skip dummy entries. */
+
+               if (primitivetype_table[i].cname == NULL)
+                       continue;
+
+               c = primitivetype_table[i].class_primitive;
+
+               c->object.header.vftbl = class_java_lang_Class->vftbl;
+       }
+}
+
+
+/**
+ * Returns the primitive class of the given class name.
+ *
+ * @param name Name of the class.
+ *
+ * @return Class structure.
+ */
+classinfo* Primitive::get_class_by_name(utf *name)
+{
+       int i;
+
+       /* search table of primitive classes */
+
+       for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
+               if (primitivetype_table[i].name == name)
+                       return primitivetype_table[i].class_primitive;
+
+       /* keep compiler happy */
+
+       return NULL;
+}
+
+
+/**
+ * Returns the primitive class of the given type.
+ *
+ * @param type Integer type of the class.
+ *
+ * @return Class structure.
+ */
+classinfo* Primitive::get_class_by_type(int type)
+{
+       return primitivetype_table[type].class_primitive;
+}
+
+
+/**
+ * Returns the primitive class of the given type.
+ *
+ * @param ch 
+ *
+ * @return Class structure.
+ */
+classinfo* Primitive::get_class_by_char(char ch)
+{
+       int index;
+
+       switch (ch) {
+       case 'I':
+               index = PRIMITIVETYPE_INT;
+               break;
+       case 'J':
+               index = PRIMITIVETYPE_LONG;
+               break;
+       case 'F':
+               index = PRIMITIVETYPE_FLOAT;
+               break;
+       case 'D':
+               index = PRIMITIVETYPE_DOUBLE;
+               break;
+       case 'B':
+               index = PRIMITIVETYPE_BYTE;
+               break;
+       case 'C':
+               index = PRIMITIVETYPE_CHAR;
+               break;
+       case 'S':
+               index = PRIMITIVETYPE_SHORT;
+               break;
+       case 'Z':
+               index = PRIMITIVETYPE_BOOLEAN;
+               break;
+       case 'V':
+               index = PRIMITIVETYPE_VOID;
+               break;
+       default:
+               return NULL;
+       }
+
+       return primitivetype_table[index].class_primitive;
+}
+
+
+/**
+ * Returns the primitive array-class of the given primitive class
+ * name.
+ *
+ * @param name Name of the class.
+ *
+ * @return Class structure.
+ */
+classinfo* Primitive::get_arrayclass_by_name(utf *name)
+{
+       int i;
+
+       /* search table of primitive classes */
+
+       for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
+               if (primitivetype_table[i].name == name)
+                       return primitivetype_table[i].arrayclass;
+
+       /* keep compiler happy */
+
+       return NULL;
+}
+
+
+/**
+ * Returns the primitive array-class of the given type.
+ *
+ * @param type Integer type of the class.
+ *
+ * @return Class structure.
+ */
+classinfo* Primitive::get_arrayclass_by_type(int type)
+{
+       return primitivetype_table[type].arrayclass;
+}
+
+
+/**
+ * Returns the primitive type of the given wrapper-class.
+ *
+ * @param c Class structure.
+ *
+ * @return Integer type of the class.
+ */
+int Primitive::get_type_by_wrapperclass(classinfo *c)
+{
+       int i;
+
+       /* Search primitive table. */
+
+       for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
+               if (primitivetype_table[i].class_wrap == c)
+                       return i;
+
+       /* Invalid primitive wrapper-class. */
+
+       return -1;
+}
+
+
+/**
+ * Box a primitive of the given type.  If the type is an object,
+ * simply return it.
+ *
+ * @param type  Type of the passed value.
+ * @param value Value to box.
+ *
+ * @return Handle of the boxing Java object.
+ */
+java_handle_t* Primitive::box(int type, imm_union value)
+{
+       java_handle_t* o;
+
+       switch (type) {
+       case PRIMITIVETYPE_BOOLEAN:
+               o = box((uint8_t) value.i);
+               break;
+       case PRIMITIVETYPE_BYTE:
+               o = box((int8_t) value.i);
+               break;
+       case PRIMITIVETYPE_CHAR:
+               o = box((uint16_t) value.i);
+               break;
+       case PRIMITIVETYPE_SHORT:
+               o = box((int16_t) value.i);
+               break;
+       case PRIMITIVETYPE_INT:
+               o = box(value.i);
+               break;
+       case PRIMITIVETYPE_LONG:
+               o = box(value.l);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               o = box(value.f);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               o = box(value.d);
+               break;
+       case PRIMITIVETYPE_VOID:
+               o = (java_handle_t*) value.a;
+               break;
+       default:
+               o = NULL;
+               os::abort("Primitive::box: Invalid primitive type %d", type);
+       }
+
+       return o;
+}
+
+
+/**
+ * Unbox a primitive of the given type.  If the type is an object,
+ * simply return it.
+ *
+ * @param h Handle of the Java object.
+ *
+ * @return Unboxed value as union.
+ */
+imm_union Primitive::unbox(java_handle_t *h)
+{
+       classinfo *c;
+       int        type;
+       imm_union  value;
+
+       if (h == NULL) {
+               value.a = NULL;
+               return value;
+       }
+
+       LLNI_class_get(h, c);
+
+       type = get_type_by_wrapperclass(c);
+
+       switch (type) {
+       case PRIMITIVETYPE_BOOLEAN:
+               value.i = unbox_boolean(h);
+               break;
+       case PRIMITIVETYPE_BYTE:
+               value.i = unbox_byte(h);
+               break;
+       case PRIMITIVETYPE_CHAR:
+               value.i = unbox_char(h);
+               break;
+       case PRIMITIVETYPE_SHORT:
+               value.i = unbox_short(h);
+               break;
+       case PRIMITIVETYPE_INT:
+               value.i = unbox_int(h);
+               break;
+       case PRIMITIVETYPE_LONG:
+               value.l = unbox_long(h);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               value.f = unbox_float(h);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               value.d = unbox_double(h);
+               break;
+       case -1:
+               /* If type is -1 the object is not a primitive box but a
+                  normal object. */
+               value.a = h;
+               break;
+       default:
+               os::abort("Primitive::unbox: Invalid primitive type %d", type);
+       }
+
+       return value;
+}
+
+
+/**
+ * Box a primitive type.
+ */
+java_handle_t* Primitive::box(uint8_t value)
+{
+       java_handle_t *h = builtin_new(class_java_lang_Boolean);
+
+       if (h == NULL)
+               return NULL;
+
+       java_lang_Boolean b(h);
+       b.set_value(value);
+
+       return h;
+}
+
+java_handle_t* Primitive::box(int8_t value)
+{
+       java_handle_t *h = builtin_new(class_java_lang_Byte);
+
+       if (h == NULL)
+               return NULL;
+
+       java_lang_Byte b(h);
+       b.set_value(value);
+
+       return h;
+}
+
+java_handle_t* Primitive::box(uint16_t value)
+{
+       java_handle_t *h = builtin_new(class_java_lang_Character);
+
+       if (h == NULL)
+               return NULL;
+
+       java_lang_Character c(h);
+       c.set_value(value);
+
+       return h;
+}
+
+java_handle_t* Primitive::box(int16_t value)
+{
+       java_handle_t *h = builtin_new(class_java_lang_Short);
+
+       if (h == NULL)
+               return NULL;
+
+       java_lang_Short s(h);
+       s.set_value(value);
+
+       return h;
+}
+
+java_handle_t* Primitive::box(int32_t value)
+{
+       java_handle_t *h = builtin_new(class_java_lang_Integer);
+
+       if (h == NULL)
+               return NULL;
+
+       java_lang_Integer i(h);
+       i.set_value(value);
+
+       return h;
+}
+
+java_handle_t* Primitive::box(int64_t value)
+{
+       java_handle_t *h = builtin_new(class_java_lang_Long);
+
+       if (h == NULL)
+               return NULL;
+
+       java_lang_Long l(h);
+       l.set_value(value);
+
+       return h;
+}
+
+java_handle_t* Primitive::box(float value)
+{
+       java_handle_t *h = builtin_new(class_java_lang_Float);
+
+       if (h == NULL)
+               return NULL;
+
+       java_lang_Float f(h);
+       f.set_value(value);
+
+       return h;
+}
+
+java_handle_t* Primitive::box(double value)
+{
+       java_handle_t *h = builtin_new(class_java_lang_Double);
+
+       if (h == NULL)
+               return NULL;
+
+       java_lang_Double d(h);
+       d.set_value(value);
+
+       return h;
+}
+
+
+
+/**
+ * Unbox a primitive type.
+ */
+
+// template<class T> T Primitive::unbox(java_handle_t *h)
+// {
+//     return java_lang_Boolean::get_value(h);
+// }
+
+inline uint8_t Primitive::unbox_boolean(java_handle_t *h)
+{
+       java_lang_Boolean b(h);
+       return b.get_value();
+}
+
+inline int8_t Primitive::unbox_byte(java_handle_t *h)
+{
+       java_lang_Byte b(h);
+       return b.get_value();
+}
+
+inline uint16_t Primitive::unbox_char(java_handle_t *h)
+{
+       java_lang_Character c(h);
+       return c.get_value();
+}
+
+inline int16_t Primitive::unbox_short(java_handle_t *h)
+{
+       java_lang_Short s(h);
+       return s.get_value();
+}
+
+inline int32_t Primitive::unbox_int(java_handle_t *h)
+{
+       java_lang_Integer i(h);
+       return i.get_value();
+}
+
+inline int64_t Primitive::unbox_long(java_handle_t *h)
+{
+       java_lang_Long l(h);
+       return l.get_value();
+}
+
+inline float Primitive::unbox_float(java_handle_t *h)
+{
+       java_lang_Float f(h);
+       return f.get_value();
+}
+
+inline double Primitive::unbox_double(java_handle_t *h)
+{
+       java_lang_Double d(h);
+       return d.get_value();
+}
+
+
+
+// Legacy C interface.
+
+extern "C" {
+
+classinfo* Primitive_get_class_by_name(utf *name) { return Primitive::get_class_by_name(name); }
+classinfo* Primitive_get_class_by_type(int type) { return Primitive::get_class_by_type(type); }
+classinfo* Primitive_get_arrayclass_by_type(int type) { return Primitive::get_arrayclass_by_type(type); }
+}
+
+
+/*
+ * 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/primitive.h b/src/vm/primitive.h
deleted file mode 100644 (file)
index f5ce4d6..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/* src/vm/primitive.c - primitive types
-
-   Copyright (C) 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
-
-   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 _PRIMITIVE_H
-#define _PRIMITIVE_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/linker.h"
-#include "vmcore/utf8.h"
-
-
-/* primitive data types *******************************************************/
-
-/* These values are used in parsed descriptors and in some other
-   places were the different types handled internally as TYPE_INT have
-   to be distinguished. */
-
-#define PRIMITIVETYPE_COUNT  11  /* number of primitive types (+ dummies)     */
-
-/* CAUTION: Don't change the numerical values! These constants are
-   used as indices into the primitive type table. */
-
-#define PRIMITIVETYPE_INT     TYPE_INT
-#define PRIMITIVETYPE_LONG    TYPE_LNG
-#define PRIMITIVETYPE_FLOAT   TYPE_FLT
-#define PRIMITIVETYPE_DOUBLE  TYPE_DBL
-#define PRIMITIVETYPE_DUMMY1  TYPE_ADR     /* not used! */
-#define PRIMITIVETYPE_BYTE    5
-#define PRIMITIVETYPE_CHAR    6
-#define PRIMITIVETYPE_SHORT   7
-#define PRIMITIVETYPE_BOOLEAN 8
-#define PRIMITIVETYPE_DUMMY2  9            /* not used! */
-#define PRIMITIVETYPE_VOID    TYPE_VOID
-
-
-/* primitivetypeinfo **********************************************************/
-
-struct primitivetypeinfo {
-       char      *cname;                    /* char name of primitive class      */
-       utf       *name;                     /* name of primitive class           */
-       classinfo *class_wrap;               /* class for wrapping primitive type */
-       classinfo *class_primitive;          /* primitive class                   */
-       char      *wrapname;                 /* name of class for wrapping        */
-       char       typesig;                  /* one character type signature      */
-       char      *arrayname;                /* name of primitive array class     */
-       classinfo *arrayclass;               /* primitive array class             */
-};
-
-
-/* global variables ***********************************************************/
-
-/* This array can be indexed by the PRIMITIVETYPE_ and ARRAYTYPE_
-   constants (except ARRAYTYPE_OBJECT). */
-
-extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT];
-
-
-/* function prototypes ********************************************************/
-
-/* this function is in src/vmcore/primitivecore.c */
-void       primitive_init(void);
-void       primitive_postinit(void);
-
-classinfo *primitive_class_get_by_name(utf *name);
-classinfo *primitive_class_get_by_type(int type);
-classinfo *primitive_class_get_by_char(char ch);
-
-classinfo *primitive_arrayclass_get_by_name(utf *name);
-classinfo *primitive_arrayclass_get_by_type(int type);
-
-int        primitive_type_get_by_wrapperclass(classinfo *c);
-
-java_handle_t *primitive_box(int type, imm_union value);
-imm_union      primitive_unbox(java_handle_t *o);
-
-java_handle_t *primitive_box_boolean(int32_t value);
-java_handle_t *primitive_box_byte(int32_t value);
-java_handle_t *primitive_box_char(int32_t value);
-java_handle_t *primitive_box_short(int32_t value);
-java_handle_t *primitive_box_int(int32_t value);
-java_handle_t *primitive_box_long(int64_t value);
-java_handle_t *primitive_box_float(float value);
-java_handle_t *primitive_box_double(double value);
-
-int32_t        primitive_unbox_boolean(java_handle_t *o);
-int32_t        primitive_unbox_byte(java_handle_t *o);
-int32_t        primitive_unbox_char(java_handle_t *o);
-int32_t        primitive_unbox_short(java_handle_t *o);
-int32_t        primitive_unbox_int(java_handle_t *o);
-int64_t        primitive_unbox_long(java_handle_t *o);
-float          primitive_unbox_float(java_handle_t *o);
-double         primitive_unbox_double(java_handle_t *o);
-
-#endif /* _PRIMITIVE_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/primitive.hpp b/src/vm/primitive.hpp
new file mode 100644 (file)
index 0000000..314bb05
--- /dev/null
@@ -0,0 +1,150 @@
+/* src/vm/primitive.hpp - primitive types
+
+   Copyright (C) 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 _PRIMITIVE_HPP
+#define _PRIMITIVE_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/linker.hpp"
+#include "vm/utf8.h"
+
+
+#ifdef __cplusplus
+
+class Primitive {
+public:
+       static void initialize_table();
+       static void post_initialize_table();
+
+       static classinfo*     get_class_by_name(utf *name);
+       static classinfo*     get_class_by_type(int type);
+       static classinfo*     get_class_by_char(char ch);
+       static classinfo*     get_arrayclass_by_name(utf* name);
+       static classinfo*     get_arrayclass_by_type(int type);
+
+       static int            get_type_by_wrapperclass(classinfo *c);
+
+       static java_handle_t* box(int type, imm_union value);
+
+       static java_handle_t* box(uint8_t value);
+       static java_handle_t* box(int8_t value);
+       static java_handle_t* box(uint16_t value);
+       static java_handle_t* box(int16_t value);
+       static java_handle_t* box(int32_t value);
+       static java_handle_t* box(int64_t value);
+       static java_handle_t* box(float value);
+       static java_handle_t* box(double value);
+
+       static imm_union      unbox(java_handle_t *o);
+
+       static uint8_t        unbox_boolean(java_handle_t* o);
+       static int8_t         unbox_byte(java_handle_t* o);
+       static uint16_t       unbox_char(java_handle_t* o);
+       static int16_t        unbox_short(java_handle_t* o);
+       static int32_t        unbox_int(java_handle_t* o);
+       static int64_t        unbox_long(java_handle_t* o);
+       static float          unbox_float(java_handle_t* o);
+       static double         unbox_double(java_handle_t* o);
+};
+
+#endif
+
+/* primitive data types *******************************************************/
+
+/* These values are used in parsed descriptors and in some other
+   places were the different types handled internally as TYPE_INT have
+   to be distinguished. */
+
+#define PRIMITIVETYPE_COUNT  11  /* number of primitive types (+ dummies)     */
+
+/* CAUTION: Don't change the numerical values! These constants are
+   used as indices into the primitive type table. */
+
+#define PRIMITIVETYPE_INT     TYPE_INT
+#define PRIMITIVETYPE_LONG    TYPE_LNG
+#define PRIMITIVETYPE_FLOAT   TYPE_FLT
+#define PRIMITIVETYPE_DOUBLE  TYPE_DBL
+#define PRIMITIVETYPE_DUMMY1  TYPE_ADR     /* not used! */
+#define PRIMITIVETYPE_BYTE    5
+#define PRIMITIVETYPE_CHAR    6
+#define PRIMITIVETYPE_SHORT   7
+#define PRIMITIVETYPE_BOOLEAN 8
+#define PRIMITIVETYPE_DUMMY2  9            /* not used! */
+#define PRIMITIVETYPE_VOID    TYPE_VOID
+
+
+/* primitivetypeinfo **********************************************************/
+
+struct primitivetypeinfo {
+       const char* cname;                   /* char name of primitive class      */
+       utf*        name;                    /* name of primitive class           */
+       classinfo*  class_wrap;              /* class for wrapping primitive type */
+       classinfo*  class_primitive;         /* primitive class                   */
+       const char* wrapname;                /* name of class for wrapping        */
+       const char  typesig;                 /* one character type signature      */
+       const char* arrayname;               /* name of primitive array class     */
+       classinfo*  arrayclass;              /* primitive array class             */
+};
+
+
+/* global variables ***********************************************************/
+
+/* This array can be indexed by the PRIMITIVETYPE_ and ARRAYTYPE_
+   constants (except ARRAYTYPE_OBJECT). */
+
+extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT];
+
+/* this function is in src/vm/primitivecore.c */
+void       primitive_init(void);
+void       primitive_postinit(void);
+
+#ifndef __cplusplus
+// Legacy C interface.
+classinfo *Primitive_get_class_by_name(utf *name);
+classinfo *Primitive_get_class_by_type(int type);
+classinfo *Primitive_get_arrayclass_by_type(int type);
+#endif
+
+#endif // _PRIMITIVE_HPP
+
+
+/*
+ * 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/properties.c b/src/vm/properties.c
deleted file mode 100644 (file)
index ea98665..0000000
+++ /dev/null
@@ -1,756 +0,0 @@
-/* src/vm/properties.c - handling commandline properties
-
-   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 <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/utsname.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-
-#include "vm/global.h"                      /* required by java_lang_String.h */
-#include "native/include/java_lang_String.h"
-
-#include "toolbox/list.h"
-#include "toolbox/util.h"
-
-#include "vm/properties.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/asmpart.h"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-#include "vmcore/system.h"
-
-
-/* internal property structure ************************************************/
-
-typedef struct list_properties_entry_t list_properties_entry_t;
-
-struct list_properties_entry_t {
-       char       *key;
-       char       *value;
-       listnode_t  linkage;
-};
-
-
-/* global variables ***********************************************************/
-
-static list_t *list_properties = NULL;
-
-
-/* properties_init *************************************************************
-
-   Initialize the properties list and fill the list with default
-   values.
-
-*******************************************************************************/
-
-void properties_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("properties_init");
-
-       list_properties = list_create(OFFSET(list_properties_entry_t, linkage));
-}
-
-
-/* properties_set **************************************************************
-
-   Fill the properties list with default values.
-
-*******************************************************************************/
-
-void properties_set(void)
-{
-       int             len;
-       char           *p;
-
-       char           *java_home;
-       char           *boot_class_path;
-
-#if defined(ENABLE_JAVASE)
-       char           *class_path;
-       char           *boot_library_path;
-       char           *extdirs;
-       char           *endorseddirs;
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       char           *cwd;
-       char           *env_user;
-       char           *env_home;
-       char           *env_lang;
-       char           *lang;
-       char           *country;
-       struct utsname *utsnamebuf;
-
-       char           *java_library_path;
-# endif
-#endif
-
-#if defined(ENABLE_JRE_LAYOUT)
-       /* SUN also uses a buffer of 4096-bytes (strace is your friend). */
-
-       p = MNEW(char, 4096);
-
-       if (readlink("/proc/self/exe", p, 4095) == -1)
-               vm_abort("properties_set: readlink failed: %s\n", strerror(errno));
-
-       /* We have a path like:
-
-          /path/to/executable/bin/java
-
-          or
-          
-          /path/to/executeable/jre/bin/java
-
-          Now let's strip two levels. */
-
-       p = system_dirname(p);
-       p = system_dirname(p);
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       /* Set java.home. */
-
-       java_home = strdup(p);
-
-       /* Set the path to Java core native libraries. */
-
-       len = strlen(java_home) + strlen("/lib/classpath") + strlen("0");
-
-       boot_library_path = MNEW(char, len);
-
-       strcpy(boot_library_path, java_home);
-       strcat(boot_library_path, "/lib/classpath");
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       /* Find correct java.home.  We check if there is a JRE
-          co-located. */
-
-       /* NOTE: We use the server VM here as it should be available on
-          all architectures. */
-
-       len =
-               strlen(p) +
-               strlen("/jre/lib/"JAVA_ARCH"/server/libjvm.so") +
-               strlen("0");
-
-       java_home = MNEW(char, len);
-
-       strcpy(java_home, p);
-       strcat(java_home, "/jre/lib/"JAVA_ARCH"/server/libjvm.so");
-
-       /* Check if that libjvm.so exists. */
-
-       if (system_access(java_home, F_OK) == 0) {
-               /* Yes, we add /jre to java.home. */
-
-               strcpy(java_home, p);
-               strcat(java_home, "/jre");
-       }
-       else {
-               /* No, java.home is parent directory. */
-
-               strcpy(java_home, p);
-       }
-
-       /* Set the path to Java core native libraries. */
-
-       len = strlen(java_home) + strlen("/lib/"JAVA_ARCH) + strlen("0");
-
-       boot_library_path = MNEW(char, len);
-
-       strcpy(boot_library_path, java_home);
-       strcat(boot_library_path, "/lib/"JAVA_ARCH);
-
-# else
-#  error unknown classpath configuration
-# endif
-
-       /* Free path. */
-
-       MFREE(p, char, len);
-
-#else
-       java_home         = CACAO_PREFIX;
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       boot_library_path = JAVA_RUNTIME_LIBRARY_LIBDIR"/classpath";
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       boot_library_path = JAVA_RUNTIME_LIBRARY_LIBDIR;
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-
-       /* No boot_library_path required. */
-
-# else
-#  error unknown classpath configuration
-# endif
-#endif
-
-       properties_add("java.home", java_home);
-
-       /* Set the bootclasspath. */
-
-       p = getenv("BOOTCLASSPATH");
-
-       if (p != NULL) {
-               boot_class_path = MNEW(char, strlen(p) + strlen("0"));
-               strcpy(boot_class_path, p);
-       }
-       else {
-#if defined(ENABLE_JRE_LAYOUT)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-               len =
-                       strlen(java_home) + strlen("/share/cacao/vm.zip:") +
-                       strlen(java_home) + strlen("/share/classpath/glibj.zip") +
-                       strlen("0");
-
-               boot_class_path = MNEW(char, len);
-
-               strcpy(boot_class_path, java_home);
-               strcat(boot_class_path, "/share/cacao/vm.zip");
-               strcat(boot_class_path, ":");
-               strcat(boot_class_path, java_home);
-               strcat(boot_class_path, "/share/classpath/glibj.zip");
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-               /* This is the bootclasspath taken from HotSpot (see
-                  hotspot/src/share/vm/runtime/os.cpp
-                  (os::set_boot_path)). */
-
-               len =
-                       strlen(java_home) + strlen("/lib/resources.jar:") +
-                       strlen(java_home) + strlen("/lib/rt.jar:") +
-                       strlen(java_home) + strlen("/lib/sunrsasign.jar:") +
-                       strlen(java_home) + strlen("/lib/jsse.jar:") +
-                       strlen(java_home) + strlen("/lib/jce.jar:") +
-                       strlen(java_home) + strlen("/lib/charsets.jar:") +
-                       strlen(java_home) + strlen("/classes") +
-                       strlen("0");
-
-               boot_class_path = MNEW(char, len);
-
-               strcpy(boot_class_path, java_home);
-               strcat(boot_class_path, "/lib/resources.jar:");
-               strcat(boot_class_path, java_home);
-               strcat(boot_class_path, "/lib/rt.jar:");
-               strcat(boot_class_path, java_home);
-               strcat(boot_class_path, "/lib/sunrsasign.jar:");
-               strcat(boot_class_path, java_home);
-               strcat(boot_class_path, "/lib/jsse.jar:");
-               strcat(boot_class_path, java_home);
-               strcat(boot_class_path, "/lib/jce.jar:");
-               strcat(boot_class_path, java_home);
-               strcat(boot_class_path, "/lib/charsets.jar:");
-               strcat(boot_class_path, java_home);
-               strcat(boot_class_path, "/classes");
-
-# else
-#  error unknown classpath configuration
-# endif
-#else
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-               len =
-                       strlen(CACAO_VM_ZIP) +
-                       strlen(":") +
-                       strlen(JAVA_RUNTIME_LIBRARY_CLASSES) +
-                       strlen("0");
-
-               boot_class_path = MNEW(char, len);
-
-               strcpy(boot_class_path, CACAO_VM_ZIP);
-               strcat(boot_class_path, ":");
-               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_CLASSES);
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-               /* This is the bootclasspath taken from HotSpot (see
-                  hotspot/src/share/vm/runtime/os.cpp
-                  (os::set_boot_path)). */
-
-               len =
-                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/resources.jar:") +
-                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/rt.jar:") +
-                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/sunrsasign.jar:") +
-                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jsse.jar:") +
-                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jce.jar:") +
-                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/charsets.jar:") +
-                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/classes") +
-                       strlen("0");
-
-               boot_class_path = MNEW(char, len);
-
-               strcpy(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/resources.jar:");
-               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/rt.jar:");
-               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/sunrsasign.jar:");
-               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jsse.jar:");
-               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jce.jar:");
-               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/charsets.jar:");
-               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/classes");
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-
-               len =
-                       strlen(JAVA_RUNTIME_LIBRARY_CLASSES) +
-                       strlen("0");
-
-               boot_class_path = MNEW(char, len);
-
-               strcpy(boot_class_path, JAVA_RUNTIME_LIBRARY_CLASSES);
-
-# else
-#  error unknown classpath configuration
-# endif
-#endif
-       }
-
-       properties_add("sun.boot.class.path", boot_class_path);
-       properties_add("java.boot.class.path", boot_class_path);
-
-#if defined(ENABLE_JAVASE)
-
-       /* Set the classpath. */
-
-       p = getenv("CLASSPATH");
-
-       if (p != NULL) {
-               class_path = MNEW(char, strlen(p) + strlen("0"));
-               strcpy(class_path, p);
-       }
-       else {
-               class_path = MNEW(char, strlen(".") + strlen("0"));
-               strcpy(class_path, ".");
-       }
-
-       properties_add("java.class.path", class_path);
-
-       /* Add java.vm properties. */
-
-       properties_add("java.vm.specification.version", "1.0");
-       properties_add("java.vm.specification.vendor", "Sun Microsystems Inc.");
-       properties_add("java.vm.specification.name", "Java Virtual Machine Specification");
-       properties_add("java.vm.version", VERSION);
-       properties_add("java.vm.vendor", "CACAO Team");
-       properties_add("java.vm.name", "CACAO");
-
-# if defined(ENABLE_INTRP)
-       if (opt_intrp) {
-               /* XXX We don't support java.lang.Compiler */
-/*             properties_add("java.compiler", "cacao.intrp"); */
-               properties_add("java.vm.info", "interpreted mode");
-       }
-       else
-# endif
-       {
-               /* XXX We don't support java.lang.Compiler */
-/*             properties_add("java.compiler", "cacao.jit"); */
-               properties_add("java.vm.info", "JIT mode");
-       }
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       /* Get properties from system. */
-
-       cwd      = _Jv_getcwd();
-
-       env_user = getenv("USER");
-       env_home = getenv("HOME");
-       env_lang = getenv("LANG");
-
-       utsnamebuf = NEW(struct utsname);
-
-       uname(utsnamebuf);
-
-       properties_add("java.runtime.version", VERSION);
-       properties_add("java.runtime.name", "CACAO");
-
-       properties_add("java.specification.version", "1.5");
-       properties_add("java.specification.vendor", "Sun Microsystems Inc.");
-       properties_add("java.specification.name", "Java Platform API Specification");
-
-       properties_add("java.version", JAVA_VERSION);
-       properties_add("java.vendor", "GNU Classpath");
-       properties_add("java.vendor.url", "http://www.gnu.org/software/classpath/");
-
-       properties_add("java.class.version", CLASS_VERSION);
-
-       properties_add("gnu.classpath.boot.library.path", boot_library_path);
-
-       /* Get and set java.library.path. */
-
-       java_library_path = getenv("LD_LIBRARY_PATH");
-
-       if (java_library_path == NULL)
-               java_library_path = "";
-
-       properties_add("java.library.path", java_library_path);
-
-       properties_add("java.io.tmpdir", "/tmp");
-
-#  if defined(ENABLE_INTRP)
-       if (opt_intrp) {
-               properties_add("gnu.java.compiler.name", "cacao.intrp");
-       }
-       else
-#  endif
-       {
-               properties_add("gnu.java.compiler.name", "cacao.jit");
-       }
-
-       /* Set the java.ext.dirs property. */
-
-       len = strlen(java_home) + strlen("/jre/lib/ext") + strlen("0");
-
-       extdirs = MNEW(char, len);
-
-       sprintf(extdirs, "%s/jre/lib/ext", java_home);
-
-       properties_add("java.ext.dirs", extdirs);
-
-       /* Set the java.ext.endorsed property. */
-
-       len = strlen(java_home) + strlen("/jre/lib/endorsed") + strlen("0");
-
-       endorseddirs = MNEW(char, len);
-
-       sprintf(endorseddirs, "%s/jre/lib/endorsed", java_home);
-
-       properties_add("java.endorsed.dirs", endorseddirs);
-
-#  if defined(DISABLE_GC)
-       /* When we disable the GC, we mmap the whole heap to a specific
-          address, so we can compare call traces. For this reason we have
-          to add the same properties on different machines, otherwise
-          more memory may be allocated (e.g. strlen("i386")
-          vs. strlen("alpha"). */
-
-       properties_add("os.arch", "unknown");
-       properties_add("os.name", "unknown");
-       properties_add("os.version", "unknown");
-#  else
-       properties_add("os.arch", JAVA_ARCH);
-       properties_add("os.name", utsnamebuf->sysname);
-       properties_add("os.version", utsnamebuf->release);
-#  endif
-
-#  if WORDS_BIGENDIAN == 1
-       properties_add("gnu.cpu.endian", "big");
-#  else
-       properties_add("gnu.cpu.endian", "little");
-#  endif
-
-       properties_add("file.separator", "/");
-       properties_add("path.separator", ":");
-       properties_add("line.separator", "\n");
-
-       properties_add("user.name", env_user ? env_user : "null");
-       properties_add("user.home", env_home ? env_home : "null");
-       properties_add("user.dir", cwd ? cwd : "null");
-
-       /* get locale */
-
-       if (env_lang != NULL) {
-               /* get the local stuff from the environment */
-
-               if (strlen(env_lang) <= 2) {
-                       properties_add("user.language", env_lang);
-               }
-               else {
-                       if ((env_lang[2] == '_') && (strlen(env_lang) >= 5)) {
-                               lang = MNEW(char, 3);
-                               strncpy(lang, (char *) &env_lang[0], 2);
-                               lang[2] = '\0';
-
-                               country = MNEW(char, 3);
-                               strncpy(country, (char *) &env_lang[3], 2);
-                               country[2] = '\0';
-
-                               properties_add("user.language", lang);
-                               properties_add("user.country", country);
-                       }
-               }
-       }
-       else {
-               /* if no default locale was specified, use `en_US' */
-
-               properties_add("user.language", "en");
-               properties_add("user.country", "US");
-       }
-
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       /* Actually this property is set by OpenJDK, but we need it in
-          nativevm_preinit(). */
-
-       properties_add("sun.boot.library.path", boot_library_path);
-
-       /* Set the java.ext.dirs property. */
-
-       len =
-               strlen(java_home) + strlen("/lib/ext") +
-               strlen(":") +
-               strlen("/usr/java/packages/lib/ext") +
-               strlen("0");
-
-       extdirs = MNEW(char, len);
-
-       sprintf(extdirs, "%s/lib/ext:/usr/java/packages/lib/ext", java_home);
-
-       properties_add("java.ext.dirs", extdirs);
-
-       /* Set the java.ext.endorsed property. */
-
-       len = strlen(java_home) + strlen("/lib/endorsed") + strlen("0");
-
-       endorseddirs = MNEW(char, len);
-
-       sprintf(endorseddirs, "%s/lib/endorsed", java_home);
-
-       properties_add("java.endorsed.dirs", endorseddirs);
-
-# else
-
-#  error unknown classpath configuration
-
-# endif
-
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-
-    properties_add("microedition.configuration", "CLDC-1.1");
-    properties_add("microedition.platform", "generic");
-    properties_add("microedition.encoding", "ISO8859_1");
-    properties_add("microedition.profiles", "");
-
-#else
-
-# error unknown Java configuration
-
-#endif
-}
-
-
-/* properties_add **************************************************************
-
-   Adds a property entry to the internal property list.  If there's
-   already an entry with the same key, replace it.
-
-*******************************************************************************/
-
-void properties_add(char *key, char *value)
-{
-       list_properties_entry_t *pe;
-
-       /* search for the entry */
-
-       for (pe = list_first(list_properties); pe != NULL;
-                pe = list_next(list_properties, pe)) {
-               if (strcmp(pe->key, key) == 0) {
-                       /* entry was found, replace the value */
-
-#if !defined(NDEBUG)
-                       if (opt_DebugProperties) {
-                               printf("[properties_add: key=%s, old value=%s, new value=%s]\n",
-                                          key, pe->value, value);
-                       }
-#endif
-
-                       pe->value = value;
-
-                       return;
-               }
-       }
-
-       /* entry was not found, insert a new one */
-
-#if !defined(NDEBUG)
-       if (opt_DebugProperties) {
-               printf("[properties_add: key=%s, value=%s]\n", key, value);
-       }
-#endif
-
-       pe = NEW(list_properties_entry_t);
-
-       pe->key   = key;
-       pe->value = value;
-
-       list_add_last(list_properties, pe);
-}
-
-
-/* properties_get **************************************************************
-
-   Get a property entry from the internal property list.
-
-*******************************************************************************/
-
-char *properties_get(char *key)
-{
-       list_properties_entry_t *pe;
-
-       for (pe = list_first(list_properties); pe != NULL;
-                pe = list_next(list_properties, pe)) {
-               if (strcmp(pe->key, key) == 0)
-                       return pe->value;
-       }
-
-       return NULL;
-}
-
-
-/* properties_system_add *******************************************************
-
-   Adds a given property to the Java system properties.
-
-*******************************************************************************/
-
-void properties_system_add(java_handle_t *p, char *key, char *value)
-{
-       classinfo     *c;
-       methodinfo    *m;
-       java_handle_t *k;
-       java_handle_t *v;
-
-       /* search for method to add properties */
-
-       LLNI_class_get(p, c);
-
-       m = class_resolveclassmethod(c,
-                                                                utf_put,
-                                                                utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
-                                                                NULL,
-                                                                true);
-
-       if (m == NULL)
-               return;
-
-       /* add to the Java system properties */
-
-       k = javastring_new_from_utf_string(key);
-       v = javastring_new_from_utf_string(value);
-
-       (void) vm_call_method(m, p, k, v);
-}
-
-
-/* properties_system_add_all ***************************************************
-
-   Adds all properties from the properties list to the Java system
-   properties.
-
-   ARGUMENTS:
-       p.... is actually a java_util_Properties structure
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-void properties_system_add_all(java_handle_t *p)
-{
-       list_properties_entry_t *pe;
-       classinfo               *c;
-       methodinfo              *m;
-       java_handle_t           *key;
-       java_handle_t           *value;
-
-       /* search for method to add properties */
-
-       LLNI_class_get(p, c);
-
-       m = class_resolveclassmethod(c,
-                                                                utf_put,
-                                                                utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
-                                                                NULL,
-                                                                true);
-
-       if (m == NULL)
-               return;
-
-       /* process all properties stored in the internal table */
-
-       for (pe = list_first(list_properties); pe != NULL;
-                pe = list_next(list_properties, pe)) {
-               /* add to the Java system properties */
-
-               key   = javastring_new_from_utf_string(pe->key);
-               value = javastring_new_from_utf_string(pe->value);
-
-               (void) vm_call_method(m, (java_handle_t *) p, key, value);
-       }
-}
-#endif /* defined(ENABLE_JAVASE) */
-
-
-/* properties_dump *************************************************************
-
-   Dump all property entries.
-
-*******************************************************************************/
-
-void properties_dump(void)
-{
-       list_t                  *l;
-       list_properties_entry_t *pe;
-
-       /* For convenience. */
-
-       l = list_properties;
-
-       for (pe = list_first(l); pe != NULL; pe = list_next(l, pe)) {
-               log_println("[properties_dump: key=%s, value=%s]", pe->key, pe->value);
-       }
-}
-
-
-/*
- * 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:
- */
diff --git a/src/vm/properties.cpp b/src/vm/properties.cpp
new file mode 100644 (file)
index 0000000..f5b66db
--- /dev/null
@@ -0,0 +1,665 @@
+/* src/vm/properties.cpp - handling commandline properties
+
+   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 <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "toolbox/util.h"
+
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/os.hpp"
+#include "vm/properties.hpp"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/asmpart.h"
+
+
+/**
+ * Constructor fills the properties list with default values.
+ */
+Properties::Properties()
+{
+       int             len;
+       char           *p;
+
+       char           *boot_class_path;
+
+#if defined(ENABLE_JAVASE)
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       struct utsname *utsnamebuf;
+# endif
+#endif
+
+#if defined(ENABLE_JRE_LAYOUT)
+       /* SUN also uses a buffer of 4096-bytes (strace is your friend). */
+
+       p = MNEW(char, 4096);
+
+       if (os::readlink("/proc/self/exe", p, 4095) == -1)
+               os::abort_errno("readlink failed");
+
+       /* We have a path like:
+
+          /path/to/executable/bin/java
+
+          or
+          
+          /path/to/executeable/jre/bin/java
+
+          Now let's strip two levels. */
+
+       p = os::dirname(p);
+       p = os::dirname(p);
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       /* Set java.home. */
+
+       char* java_home = strdup(p);
+
+       /* Set the path to Java core native libraries. */
+
+       len = strlen(java_home) + strlen("/lib/classpath") + strlen("0");
+
+       char* boot_library_path = MNEW(char, len);
+
+       strcpy(boot_library_path, java_home);
+       strcat(boot_library_path, "/lib/classpath");
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       /* Find correct java.home.  We check if there is a JRE
+          co-located. */
+
+       /* NOTE: We use the server VM here as it should be available on
+          all architectures. */
+
+       len =
+               strlen(p) +
+               strlen("/jre/lib/"JAVA_ARCH"/server/libjvm.so") +
+               strlen("0");
+
+       char* java_home = MNEW(char, len);
+
+       strcpy(java_home, p);
+       strcat(java_home, "/jre/lib/"JAVA_ARCH"/server/libjvm.so");
+
+       // Check if that libjvm.so exists.
+       if (os::access(java_home, F_OK) == 0) {
+               // Yes, we add /jre to java.home.
+               strcpy(java_home, p);
+               strcat(java_home, "/jre");
+       }
+       else {
+               // No, java.home is parent directory.
+               strcpy(java_home, p);
+       }
+
+       /* Set the path to Java core native libraries. */
+
+       len = strlen(java_home) + strlen("/lib/"JAVA_ARCH) + strlen("0");
+
+       char* boot_library_path = MNEW(char, len);
+
+       strcpy(boot_library_path, java_home);
+       strcat(boot_library_path, "/lib/"JAVA_ARCH);
+
+# else
+#  error unknown classpath configuration
+# endif
+
+       /* Free path. */
+
+       MFREE(p, char, len);
+
+#else
+       const char* java_home = CACAO_PREFIX;
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       const char* boot_library_path = JAVA_RUNTIME_LIBRARY_LIBDIR"/classpath";
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       const char* boot_library_path = JAVA_RUNTIME_LIBRARY_LIBDIR;
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+       // No boot_library_path required.
+
+# else
+#  error unknown classpath configuration
+# endif
+#endif
+
+       put("java.home", java_home);
+
+       /* Set the bootclasspath. */
+
+       p = os::getenv("BOOTCLASSPATH");
+
+       if (p != NULL) {
+               boot_class_path = MNEW(char, strlen(p) + strlen("0"));
+               strcpy(boot_class_path, p);
+       }
+       else {
+#if defined(ENABLE_JRE_LAYOUT)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+               len =
+                       strlen(java_home) + strlen("/share/cacao/vm.zip:") +
+                       strlen(java_home) + strlen("/share/classpath/glibj.zip") +
+                       strlen("0");
+
+               boot_class_path = MNEW(char, len);
+
+               strcpy(boot_class_path, java_home);
+               strcat(boot_class_path, "/share/cacao/vm.zip");
+               strcat(boot_class_path, ":");
+               strcat(boot_class_path, java_home);
+               strcat(boot_class_path, "/share/classpath/glibj.zip");
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+               /* This is the bootclasspath taken from HotSpot (see
+                  hotspot/src/share/vm/runtime/os.cpp
+                  (os::set_boot_path)). */
+
+               len =
+                       strlen(java_home) + strlen("/lib/resources.jar:") +
+                       strlen(java_home) + strlen("/lib/rt.jar:") +
+                       strlen(java_home) + strlen("/lib/sunrsasign.jar:") +
+                       strlen(java_home) + strlen("/lib/jsse.jar:") +
+                       strlen(java_home) + strlen("/lib/jce.jar:") +
+                       strlen(java_home) + strlen("/lib/charsets.jar:") +
+                       strlen(java_home) + strlen("/classes") +
+                       strlen("0");
+
+               boot_class_path = MNEW(char, len);
+
+               strcpy(boot_class_path, java_home);
+               strcat(boot_class_path, "/lib/resources.jar:");
+               strcat(boot_class_path, java_home);
+               strcat(boot_class_path, "/lib/rt.jar:");
+               strcat(boot_class_path, java_home);
+               strcat(boot_class_path, "/lib/sunrsasign.jar:");
+               strcat(boot_class_path, java_home);
+               strcat(boot_class_path, "/lib/jsse.jar:");
+               strcat(boot_class_path, java_home);
+               strcat(boot_class_path, "/lib/jce.jar:");
+               strcat(boot_class_path, java_home);
+               strcat(boot_class_path, "/lib/charsets.jar:");
+               strcat(boot_class_path, java_home);
+               strcat(boot_class_path, "/classes");
+
+# else
+#  error unknown classpath configuration
+# endif
+#else
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+               len =
+                       strlen(CACAO_VM_ZIP) +
+                       strlen(":") +
+                       strlen(JAVA_RUNTIME_LIBRARY_CLASSES) +
+                       strlen("0");
+
+               boot_class_path = MNEW(char, len);
+
+               strcpy(boot_class_path, CACAO_VM_ZIP);
+               strcat(boot_class_path, ":");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_CLASSES);
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+               /* This is the bootclasspath taken from HotSpot (see
+                  hotspot/src/share/vm/runtime/os.cpp
+                  (os::set_boot_path)). */
+
+               len =
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/resources.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/rt.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/sunrsasign.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jsse.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jce.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/charsets.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/classes") +
+                       strlen("0");
+
+               boot_class_path = MNEW(char, len);
+
+               strcpy(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/resources.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/rt.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/sunrsasign.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jsse.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jce.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/charsets.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/classes");
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+               len =
+                       strlen(JAVA_RUNTIME_LIBRARY_CLASSES) +
+                       strlen("0");
+
+               boot_class_path = MNEW(char, len);
+
+               strcpy(boot_class_path, JAVA_RUNTIME_LIBRARY_CLASSES);
+
+# else
+#  error unknown classpath configuration
+# endif
+#endif
+       }
+
+       put("sun.boot.class.path", boot_class_path);
+       put("java.boot.class.path", boot_class_path);
+
+#if defined(ENABLE_JAVASE)
+
+       /* Set the classpath. */
+
+       p = os::getenv("CLASSPATH");
+
+       char* class_path;
+
+       if (p != NULL) {
+               class_path = MNEW(char, strlen(p) + strlen("0"));
+               strcpy(class_path, p);
+       }
+       else {
+               class_path = MNEW(char, strlen(".") + strlen("0"));
+               strcpy(class_path, ".");
+       }
+
+       put("java.class.path", class_path);
+
+       // Add java.vm properties.
+       put("java.vm.specification.version", "1.0");
+       put("java.vm.specification.vendor", "Sun Microsystems Inc.");
+       put("java.vm.specification.name", "Java Virtual Machine Specification");
+       put("java.vm.version", VERSION);
+       put("java.vm.vendor", "CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO");
+       put("java.vm.name", "CACAO");
+
+# if defined(ENABLE_INTRP)
+       if (opt_intrp) {
+               /* XXX We don't support java.lang.Compiler */
+/*             put("java.compiler", "cacao.intrp"); */
+               put("java.vm.info", "interpreted mode");
+       }
+       else
+# endif
+       {
+               /* XXX We don't support java.lang.Compiler */
+/*             put("java.compiler", "cacao.jit"); */
+               put("java.vm.info", "compiled mode");
+       }
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+       /* Get properties from system. */
+
+       char* cwd      = _Jv_getcwd();
+
+       char* env_user = os::getenv("USER");
+       char* env_home = os::getenv("HOME");
+       char* env_lang = os::getenv("LANG");
+
+       utsnamebuf = NEW(struct utsname);
+
+       uname(utsnamebuf);
+
+       put("java.runtime.version", VERSION);
+       put("java.runtime.name", "CACAO");
+
+       put("java.specification.version", "1.5");
+       put("java.specification.vendor", "Sun Microsystems Inc.");
+       put("java.specification.name", "Java Platform API Specification");
+
+       put("java.version", JAVA_VERSION);
+       put("java.vendor", "GNU Classpath");
+       put("java.vendor.url", "http://www.gnu.org/software/classpath/");
+
+       put("java.class.version", CLASS_VERSION);
+
+       put("gnu.classpath.boot.library.path", boot_library_path);
+
+       // Get and set java.library.path.
+       const char* java_library_path = os::getenv("LD_LIBRARY_PATH");
+
+       if (java_library_path == NULL)
+               java_library_path = "";
+
+       put("java.library.path", java_library_path);
+
+       put("java.io.tmpdir", "/tmp");
+
+#  if defined(ENABLE_INTRP)
+       if (opt_intrp) {
+               put("gnu.java.compiler.name", "cacao.intrp");
+       }
+       else
+#  endif
+       {
+               put("gnu.java.compiler.name", "cacao.jit");
+       }
+
+       /* Set the java.ext.dirs property. */
+
+       len = strlen(java_home) + strlen("/jre/lib/ext") + strlen("0");
+
+       char* extdirs = MNEW(char, len);
+
+       sprintf(extdirs, "%s/jre/lib/ext", java_home);
+
+       put("java.ext.dirs", extdirs);
+
+       /* Set the java.ext.endorsed property. */
+
+       len = strlen(java_home) + strlen("/jre/lib/endorsed") + strlen("0");
+
+       char* endorseddirs = MNEW(char, len);
+
+       sprintf(endorseddirs, "%s/jre/lib/endorsed", java_home);
+
+       put("java.endorsed.dirs", endorseddirs);
+
+#  if defined(DISABLE_GC)
+       /* When we disable the GC, we mmap the whole heap to a specific
+          address, so we can compare call traces. For this reason we have
+          to add the same properties on different machines, otherwise
+          more memory may be allocated (e.g. strlen("i386")
+          vs. strlen("alpha"). */
+
+       put("os.arch", "unknown");
+       put("os.name", "unknown");
+       put("os.version", "unknown");
+#  else
+       put("os.arch", JAVA_ARCH);
+       put("os.name", utsnamebuf->sysname);
+       put("os.version", utsnamebuf->release);
+#  endif
+
+#  if WORDS_BIGENDIAN == 1
+       put("gnu.cpu.endian", "big");
+#  else
+       put("gnu.cpu.endian", "little");
+#  endif
+
+       put("file.separator", "/");
+       put("path.separator", ":");
+       put("line.separator", "\n");
+
+       put("user.name", env_user ? env_user : "null");
+       put("user.home", env_home ? env_home : "null");
+       put("user.dir", cwd ? cwd : "null");
+
+       /* get locale */
+
+       if (env_lang != NULL) {
+               /* get the local stuff from the environment */
+
+               if (strlen(env_lang) <= 2) {
+                       put("user.language", env_lang);
+               }
+               else {
+                       if ((env_lang[2] == '_') && (strlen(env_lang) >= 5)) {
+                               char* lang = MNEW(char, 3);
+                               strncpy(lang, (char*) &env_lang[0], 2);
+                               lang[2] = '\0';
+
+                               char* country = MNEW(char, 3);
+                               strncpy(country, (char*) &env_lang[3], 2);
+                               country[2] = '\0';
+
+                               put("user.language", lang);
+                               put("user.country", country);
+                       }
+               }
+       }
+       else {
+               /* if no default locale was specified, use `en_US' */
+
+               put("user.language", "en");
+               put("user.country", "US");
+       }
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+       /* Actually this property is set by OpenJDK, but we need it in
+          nativevm_preinit(). */
+
+       put("sun.boot.library.path", boot_library_path);
+
+       // Set the java.ext.dirs property.
+       len =
+               strlen(java_home) + strlen("/lib/ext") +
+               strlen(":") +
+               strlen("/usr/java/packages/lib/ext") +
+               strlen("0");
+
+       char* extdirs = MNEW(char, len);
+
+       sprintf(extdirs, "%s/lib/ext:/usr/java/packages/lib/ext", java_home);
+
+       put("java.ext.dirs", extdirs);
+
+       // Set the java.ext.endorsed property.
+       len = strlen(java_home) + strlen("/lib/endorsed") + strlen("0");
+
+       char* endorseddirs = MNEW(char, len);
+
+       sprintf(endorseddirs, "%s/lib/endorsed", java_home);
+
+       put("java.endorsed.dirs", endorseddirs);
+
+# else
+
+#  error unknown classpath configuration
+
+# endif
+
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+
+    put("microedition.configuration", "CLDC-1.1");
+    put("microedition.platform", "generic");
+    put("microedition.encoding", "ISO8859_1");
+    put("microedition.profiles", "");
+
+#else
+
+# error unknown Java configuration
+
+#endif
+}
+
+
+/**
+ * Add the given property to the given Java system properties.
+ *
+ * @param p     Java properties object.
+ * @param key   Key.
+ * @param value Value.
+ */
+void Properties::put(java_handle_t* p, const char* key, const char* value)
+{
+       // Get Properties.put() method to add properties.
+       classinfo* c;
+       LLNI_class_get(p, c);
+
+       methodinfo* m = class_resolveclassmethod(c,
+                                                                                        utf_put,
+                                                                                        utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
+                                                                                        NULL,
+                                                                                        true);
+
+       if (m == NULL)
+               return;
+
+       // Add to the Java system properties.
+       java_handle_t* k = javastring_new_from_utf_string(key);
+       java_handle_t* v = javastring_new_from_utf_string(value);
+
+       (void) vm_call_method(m, p, k, v);
+}
+
+
+/**
+ * Put the given property into the internal property map.  If there's
+ * already an entry with the same key, replace it.
+ *
+ * @param key   Key.
+ * @param value Value.
+ */
+void Properties::put(const char* key, const char* value)
+{
+       // Try to find the key.
+       std::map<const char*, const char*>::iterator it = _properties.find(key);
+
+       // The key is already in the map.
+       if (it != _properties.end()) {
+#if !defined(NDEBUG)
+               if (opt_DebugProperties) {
+                       printf("[Properties::put: key=%s, old value=%s, new value=%s]\n",
+                                  key, it->second, value);
+               }
+#endif
+
+               // Replace the value in the current entry.
+               it->second = value;
+
+               return;
+       }
+
+       // The key was not found, insert the pair.
+#if !defined(NDEBUG)
+       if (opt_DebugProperties) {
+               printf("[Properties::put: key=%s, value=%s]\n", key, value);
+       }
+#endif
+
+       _properties.insert(std::make_pair(key, value));
+}
+
+
+/**
+ * Get a property entry from the internal property map.
+ *
+ * @param key Key.
+ *
+ * @return Value associated with the key or NULL when not found.
+ */
+const char* Properties::get(const char* key)
+{
+       // Try to find the key.
+       std::map<const char*, const char*>::iterator it = _properties.find(key);
+
+       // The key is not in the map.
+       if (it == _properties.end())
+               return NULL;
+
+       // Return the value.
+       return it->second;
+}
+
+
+/**
+ * Fill the given Java system properties with all properties from the
+ * internal properties map.
+ *
+ * @param p Java Properties object.
+ */
+#if defined(ENABLE_JAVASE)
+void Properties::fill(java_handle_t* p)
+{
+       // Get Properties.put() method to add properties.
+       classinfo* c;
+       LLNI_class_get(p, c);
+
+       methodinfo* m = class_resolveclassmethod(c,
+                                                                                        utf_put,
+                                                                                        utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
+                                                                                        NULL,
+                                                                                        true);
+
+       if (m == NULL)
+               return;
+
+       // Iterator over all properties.
+       for (std::map<const char*, const char*>::iterator it = _properties.begin(); it != _properties.end(); it++) {
+               // Put into the Java system properties.
+               java_handle_t* key   = javastring_new_from_utf_string(it->first);
+               java_handle_t* value = javastring_new_from_utf_string(it->second);
+
+               (void) vm_call_method(m, p, key, value);
+       }
+}
+#endif
+
+
+/**
+ * Dump all property entries.
+ */
+#if !defined(NDEBUG)
+void Properties::dump()
+{
+       for (std::map<const char*, const char*>::iterator it = _properties.begin(); it != _properties.end(); it++) {
+               log_println("[Properties::dump: key=%s, value=%s]", it->first, it->second);
+       }
+}
+#endif
+
+
+/*
+ * 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/properties.h b/src/vm/properties.h
deleted file mode 100644 (file)
index a468aec..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* src/vm/properties.h - handling commandline properties
-
-   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
-
-   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 _PROPERTIES_H
-#define _PROPERTIES_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/global.h"
-
-
-/* function prototypes ********************************************************/
-
-void  properties_init(void);
-void  properties_set(void);
-
-void  properties_add(char *key, char *value);
-char *properties_get(char *key);
-
-void  properties_system_add(java_handle_t *p, char *key, char *value);
-
-#if defined(ENABLE_JAVASE)
-void  properties_system_add_all(java_handle_t *p);
-#endif
-
-void  properties_dump(void);
-
-#endif /* _PROPERTIES_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:
- */
diff --git a/src/vm/properties.hpp b/src/vm/properties.hpp
new file mode 100644 (file)
index 0000000..b10a5a7
--- /dev/null
@@ -0,0 +1,91 @@
+/* src/vm/properties.hpp - handling commandline properties
+
+   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 _PROPERTIES_HPP
+#define _PROPERTIES_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+
+#include <map>
+
+#include "vm/os.hpp"
+
+
+class ltstr {
+public:
+       bool operator()(const char* s1, const char* s2) const
+       {
+               return os::strcmp(s1, s2) < 0;
+       }
+};
+
+
+/**
+ * Commandline properties.
+ */
+class Properties {
+private:
+       std::map<const char*, const char*, ltstr> _properties;
+
+private:
+       // Don't allow to copy the properties.
+       Properties(const Properties&);
+
+public:
+       Properties();
+
+       // Static function.
+       static void put(java_handle_t* p, const char* key, const char* value);
+
+       void        put(const char* key, const char* value);
+       const char* get(const char* key);
+       void        fill(java_handle_t* p);
+#if !defined(NDEBUG)
+       void        dump();
+#endif
+};
+
+#endif
+
+#endif // _PROPERTIES_HPP
+
+
+/*
+ * 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/references.h b/src/vm/references.h
new file mode 100644 (file)
index 0000000..be2455b
--- /dev/null
@@ -0,0 +1,167 @@
+/* src/vm/references.h - references to classes/fields/methods
+
+   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 _REFERENCES_H_
+#define _REFERENCES_H_
+
+/* forward typedefs ***********************************************************/
+
+typedef struct constant_classref constant_classref;
+typedef struct constant_FMIref   constant_FMIref;
+
+
+/* constant_classref **********************************************************/
+
+struct constant_classref {
+       void             *pseudo_vftbl; /* for distinguishing it from classinfo   */
+       struct classinfo *referer;    /* class containing the reference           */
+       struct utf       *name;       /* name of the class refered to             */
+};
+
+
+/* classref_or_classinfo ******************************************************/
+
+typedef union classref_or_classinfo {
+       constant_classref *ref;       /* a symbolic class reference               */
+       struct classinfo  *cls;       /* an already loaded class                  */
+       void              *any;       /* used for general access (x != NULL,...)  */
+} classref_or_classinfo;
+
+
+/* parseddesc_t ***************************************************************/
+
+typedef union parseddesc {
+       struct typedesc   *fd;        /* parsed field descriptor                  */
+       struct methoddesc *md;        /* parsed method descriptor                 */
+       void              *any;       /* used for simple test against NULL        */
+} parseddesc_t;
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/class.hpp"
+#include "vm/descriptor.h"
+#include "vm/field.hpp"
+#include "vm/global.h"
+#include "vm/method.hpp"
+#include "vm/utf8.h"
+
+
+/*----------------------------------------------------------------------------*/
+/* References                                                                 */
+/*                                                                            */
+/* This header files defines the following types used for references to       */
+/* classes/methods/fields and descriptors:                                    */
+/*                                                                            */
+/*     classinfo *                a loaded class                              */
+/*     constant_classref          a symbolic reference                        */
+/*     classref_or_classinfo      a loaded class or a symbolic reference      */
+/*                                                                            */
+/*     constant_FMIref            a symb. ref. to a field/method/intf.method  */
+/*                                                                            */
+/*     typedesc *                 describes a field type                      */
+/*     methoddesc *               descrives a method type                     */
+/*     parseddesc                 describes a field type or a method type     */
+/*----------------------------------------------------------------------------*/
+
+/* structs ********************************************************************/
+
+/* constant_FMIref ************************************************************/
+
+struct constant_FMIref{      /* Fieldref, Methodref and InterfaceMethodref    */
+       union {
+               s4                 index;     /* used only within the loader          */
+               constant_classref *classref;  /* class having this field/meth./intfm. */
+               fieldinfo         *field;     /* resolved field                       */
+               methodinfo        *method;    /* resolved method                      */
+       } p;
+       utf         *name;       /* field/method/interfacemethod name             */
+       utf         *descriptor; /* field/method/intfmeth. type descriptor string */
+       parseddesc_t parseddesc; /* parsed descriptor                             */
+};
+
+
+/* macros *********************************************************************/
+
+/* a value that never occurrs in classinfo.header.vftbl                       */
+#define CLASSREF_PSEUDO_VFTBL ((void *) 1)
+
+/* macro for testing if a classref_or_classinfo is a classref                 */
+/* `reforinfo` is only evaluated once                                         */
+#define IS_CLASSREF(reforinfo)  \
+       ((reforinfo).ref->pseudo_vftbl == CLASSREF_PSEUDO_VFTBL)
+
+/* macro for testing if a constant_FMIref has been resolved                   */
+/* `fmiref` is only evaluated once                                            */
+#define IS_FMIREF_RESOLVED(fmiref)  \
+       ((fmiref)->p.classref->pseudo_vftbl != CLASSREF_PSEUDO_VFTBL)
+
+/* the same as IS_CLASSREF, but also check against NULL */
+#define IS_XCLASSREF(reforinfo)  \
+       ((reforinfo).any && IS_CLASSREF(reforinfo))
+
+/* macro for casting a classref/classinfo * to a classref_or_classinfo        */
+#define CLASSREF_OR_CLASSINFO(value) \
+       (*((classref_or_classinfo *)(&(value))))
+
+/* macro for accessing the name of a classref/classinfo                       */
+#define CLASSREF_OR_CLASSINFO_NAME(value) \
+       (IS_CLASSREF(value) ? (value).ref->name : (value).cls->name)
+
+/* macro for accessing the class name of a method reference                   */
+#define METHODREF_CLASSNAME(fmiref) \
+       (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.method->clazz->name \
+                                                               : (fmiref)->p.classref->name)
+
+/* macro for accessing the class name of a method reference                   */
+#define FIELDREF_CLASSNAME(fmiref) \
+       (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.field->clazz->name \
+                                                               : (fmiref)->p.classref->name)
+
+/* initialize a constant_classref with referer `ref` and name `classname`     */
+
+#define CLASSREF_INIT(c,ref,classname) \
+    do { \
+        (c).pseudo_vftbl = CLASSREF_PSEUDO_VFTBL; \
+        (c).referer = (ref); \
+        (c).name = (classname); \
+    } while (0)
+
+#endif /* _REFERENCES_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/resolve.c b/src/vm/resolve.c
deleted file mode 100644 (file)
index b125bde..0000000
+++ /dev/null
@@ -1,3164 +0,0 @@
-/* src/vm/resolve.c - resolving classes/interfaces/fields/methods
-
-   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 "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "vm/access.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/primitive.h"
-#include "vm/resolve.h"
-
-#include "vm/jit/jit.h"
-#include "vm/jit/verify/typeinfo.h"
-
-#include "vmcore/classcache.h"
-#include "vmcore/descriptor.h"
-#include "vmcore/linker.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
-
-/******************************************************************************/
-/* DEBUG HELPERS                                                              */
-/******************************************************************************/
-
-/*#define RESOLVE_VERBOSE*/
-
-/* resolve_handle_pending_exception ********************************************
-
-   Convert a pending ClassNotFoundException into a
-   NoClassDefFoundError if requested.
-
-   See: hotspot/src/share/vm/classfile/systemDictionary.cpp
-   (handle_resolution_exception)
-
-   ARGUMENTS:
-       classname .... name of the class currently resolved
-       throwError ... if true throw a NoClassDefFoundError instead of
-                      a ClassNotFoundException
-
-*******************************************************************************/
-
-void resolve_handle_pending_exception(bool throwError)
-{
-       java_handle_t *e;
-
-       /* Get the current exception. */
-
-       e = exceptions_get_exception();
-
-       if (e != NULL) {
-               if (throwError == true) {
-                       /* Convert ClassNotFoundException to
-                          NoClassDefFoundError. */
-
-                       if (builtin_instanceof(e, class_java_lang_ClassNotFoundException)) {
-                               /* Clear exception, because we are calling Java code
-                                  again. */
-
-                               exceptions_clear_exception();
-
-                               /* create new error */
-
-                               exceptions_throw_noclassdeffounderror_cause(e);
-                       }
-                       else {
-                               return;
-                       }
-               }
-               else {
-                       /* An exception conversion was not requested.  Simply
-                          return. */
-
-                       return;
-               }
-       }
-}
-
-
-/******************************************************************************/
-/* CLASS RESOLUTION                                                           */
-/******************************************************************************/
-
-/* resolve_class_from_name *****************************************************
-   Resolve a symbolic class reference
-  
-   IN:
-       referer..........the class containing the reference
-       refmethod........the method from which resolution was triggered
-                        (may be NULL if not applicable)
-       classname........class name to resolve
-       mode.............mode of resolution:
-                            resolveLazy...only resolve if it does not
-                                          require loading classes
-                            resolveEager..load classes if necessary
-          checkaccess......if true, access rights to the class are checked
-          link.............if true, guarantee that the returned class, if any,
-                           has been linked
-  
-   OUT:
-       *result..........set to result of resolution, or to NULL if
-                        the reference has not been resolved
-                        In the case of an exception, *result is
-                        guaranteed to be set to NULL.
-  
-   RETURN VALUE:
-       true.............everything ok 
-                        (*result may still be NULL for resolveLazy)
-       false............an exception has been thrown
-
-   NOTE:
-       The returned class is *not* guaranteed to be linked!
-          (It is guaranteed to be loaded, though.)
-   
-*******************************************************************************/
-
-bool resolve_class_from_name(classinfo *referer,
-                                                        methodinfo *refmethod,
-                                                        utf *classname,
-                                                        resolve_mode_t mode,
-                                                        bool checkaccess,
-                                                        bool link,
-                                                        classinfo **result)
-{
-       classinfo *cls;
-       char      *utf_ptr;
-       int        len;
-       char      *msg;
-       s4         msglen;
-       utf       *u;
-
-       assert(result);
-       assert(referer);
-       assert(classname);
-       assert(mode == resolveLazy || mode == resolveEager);
-       
-       *result = NULL;
-
-#ifdef RESOLVE_VERBOSE
-       printf("resolve_class_from_name(");
-       utf_fprint_printable_ascii(stdout,referer->name);
-       printf(",%p,",(void*)referer->classloader);
-       utf_fprint_printable_ascii(stdout,classname);
-       printf(",%d,%d)\n",(int)checkaccess,(int)link);
-#endif
-
-       /* lookup if this class has already been loaded */
-
-       cls = classcache_lookup(referer->classloader, classname);
-
-#ifdef RESOLVE_VERBOSE
-       printf("    lookup result: %p\n",(void*)cls);
-#endif
-
-       if (!cls) {
-               /* resolve array types */
-
-               if (classname->text[0] == '[') {
-                       utf_ptr = classname->text + 1;
-                       len = classname->blength - 1;
-
-                       /* classname is an array type name */
-
-                       switch (*utf_ptr) {
-                               case 'L':
-                                       utf_ptr++;
-                                       len -= 2;
-                                       /* FALLTHROUGH */
-                               case '[':
-                                       /* the component type is a reference type */
-                                       /* resolve the component type */
-                                       if (!resolve_class_from_name(referer,refmethod,
-                                                                          utf_new(utf_ptr,len),
-                                                                          mode,checkaccess,link,&cls))
-                                               return false; /* exception */
-                                       if (!cls) {
-                                               assert(mode == resolveLazy);
-                                               return true; /* be lazy */
-                                       }
-                                       /* create the array class */
-                                       cls = class_array_of(cls,false);
-                                       if (!cls)
-                                               return false; /* exception */
-                       }
-               }
-               else {
-                       /* the class has not been loaded, yet */
-                       if (mode == resolveLazy)
-                               return true; /* be lazy */
-               }
-
-#ifdef RESOLVE_VERBOSE
-               printf("    loading...\n");
-#endif
-
-               /* load the class */
-
-               if (cls == NULL) {
-                       cls = load_class_from_classloader(classname, referer->classloader);
-
-                       if (cls == NULL)
-                               return false;
-               }
-       }
-
-       /* the class is now loaded */
-       assert(cls);
-       assert(cls->state & CLASS_LOADED);
-
-#ifdef RESOLVE_VERBOSE
-       printf("    checking access rights...\n");
-#endif
-       
-       /* check access rights of referer to refered class */
-
-       if (checkaccess && !access_is_accessible_class(referer,cls)) {
-               msglen =
-                       utf_bytes(cls->name) +
-                       utf_bytes(referer->name) +
-                       100;
-
-               msg = MNEW(char, msglen);
-
-               strcpy(msg, "class is not accessible (");
-               utf_cat_classname(msg, cls->name);
-               strcat(msg, " from ");
-               utf_cat_classname(msg, referer->name);
-               strcat(msg, ")");
-
-               u = utf_new_char(msg);
-
-               MFREE(msg, char, msglen);
-
-               exceptions_throw_illegalaccessexception(u);
-
-               return false; /* exception */
-       }
-
-       /* link the class if necessary */
-       if (link) {
-               if (!(cls->state & CLASS_LINKED))
-                       if (!link_class(cls))
-                               return false; /* exception */
-
-               assert(cls->state & CLASS_LINKED);
-       }
-
-       /* resolution succeeds */
-#ifdef RESOLVE_VERBOSE
-       printf("    success.\n");
-#endif
-       *result = cls;
-       return true;
-}
-
-/* resolve_classref ************************************************************
-   Resolve a symbolic class reference
-  
-   IN:
-       refmethod........the method from which resolution was triggered
-                        (may be NULL if not applicable)
-       ref..............class reference
-       mode.............mode of resolution:
-                            resolveLazy...only resolve if it does not
-                                          require loading classes
-                            resolveEager..load classes if necessary
-          checkaccess......if true, access rights to the class are checked
-          link.............if true, guarantee that the returned class, if any,
-                           has been linked
-  
-   OUT:
-       *result..........set to result of resolution, or to NULL if
-                        the reference has not been resolved
-                        In the case of an exception, *result is
-                        guaranteed to be set to NULL.
-  
-   RETURN VALUE:
-       true.............everything ok 
-                        (*result may still be NULL for resolveLazy)
-       false............an exception has been thrown
-   
-*******************************************************************************/
-
-bool resolve_classref(methodinfo *refmethod,
-                                         constant_classref *ref,
-                                         resolve_mode_t mode,
-                                         bool checkaccess,
-                                         bool link,
-                                         classinfo **result)
-{
-       return resolve_classref_or_classinfo(refmethod,CLASSREF_OR_CLASSINFO(ref),mode,checkaccess,link,result);
-}
-
-/* resolve_classref_or_classinfo ***********************************************
-   Resolve a symbolic class reference if necessary
-
-   NOTE: If given, refmethod->clazz is used as the referring class.
-         Otherwise, cls.ref->referer is used.
-
-   IN:
-       refmethod........the method from which resolution was triggered
-                        (may be NULL if not applicable)
-       cls..............class reference or classinfo
-       mode.............mode of resolution:
-                            resolveLazy...only resolve if it does not
-                                          require loading classes
-                            resolveEager..load classes if necessary
-          checkaccess......if true, access rights to the class are checked
-          link.............if true, guarantee that the returned class, if any,
-                           has been linked
-  
-   OUT:
-       *result..........set to result of resolution, or to NULL if
-                        the reference has not been resolved
-                        In the case of an exception, *result is
-                        guaranteed to be set to NULL.
-  
-   RETURN VALUE:
-       true.............everything ok 
-                        (*result may still be NULL for resolveLazy)
-       false............an exception has been thrown
-   
-*******************************************************************************/
-
-bool resolve_classref_or_classinfo(methodinfo *refmethod,
-                                                                  classref_or_classinfo cls,
-                                                                  resolve_mode_t mode,
-                                                                  bool checkaccess,
-                                                                  bool link,
-                                                                  classinfo **result)
-{
-       classinfo         *c;
-       classinfo         *referer;
-       
-       assert(cls.any);
-       assert(mode == resolveEager || mode == resolveLazy);
-       assert(result);
-
-#ifdef RESOLVE_VERBOSE
-       printf("resolve_classref_or_classinfo(");
-       utf_fprint_printable_ascii(stdout,(IS_CLASSREF(cls)) ? cls.ref->name : cls.cls->name);
-       printf(",%i,%i,%i)\n",mode,(int)checkaccess,(int)link);
-#endif
-
-       *result = NULL;
-
-       if (IS_CLASSREF(cls)) {
-               /* we must resolve this reference */
-
-               /* determine which class to use as the referer */
-
-               /* Common cases are refmethod == NULL or both referring classes */
-               /* being the same, so the referer usually is cls.ref->referer.    */
-               /* There is one important case where it is not: When we do a      */
-               /* deferred assignability check to a formal argument of a method, */
-               /* we must use refmethod->clazz (the caller's class) to resolve   */
-               /* the type of the formal argument.                               */
-
-               referer = (refmethod) ? refmethod->clazz : cls.ref->referer;
-
-               if (!resolve_class_from_name(referer, refmethod, cls.ref->name,
-                                                                        mode, checkaccess, link, &c))
-                       goto return_exception;
-
-       } else {
-               /* cls has already been resolved */
-               c = cls.cls;
-               assert(c->state & CLASS_LOADED);
-       }
-       assert(c || (mode == resolveLazy));
-
-       if (!c)
-               return true; /* be lazy */
-       
-       assert(c);
-       assert(c->state & CLASS_LOADED);
-
-       if (link) {
-               if (!(c->state & CLASS_LINKED))
-                       if (!link_class(c))
-                               goto return_exception;
-
-               assert(c->state & CLASS_LINKED);
-       }
-
-       /* succeeded */
-       *result = c;
-       return true;
-
- return_exception:
-       *result = NULL;
-       return false;
-}
-
-
-/* resolve_classref_or_classinfo_eager *****************************************
-   Resolve a symbolic class reference eagerly if necessary.
-   No attempt is made to link the class.
-
-   IN:
-       cls..............class reference or classinfo
-       checkaccess......if true, access rights to the class are checked
-  
-   RETURN VALUE:
-       classinfo *......the resolved class
-       NULL.............an exception has been thrown
-   
-*******************************************************************************/
-
-classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls,
-                                                                                          bool checkaccess)
-{
-       classinfo *c;
-
-       if (!resolve_classref_or_classinfo(NULL, cls, resolveEager, checkaccess, false, &c))
-               return NULL;
-
-       return c;
-}
-
-
-/* resolve_class_from_typedesc *************************************************
-   Return a classinfo * for the given type descriptor
-  
-   IN:
-       d................type descriptor
-          checkaccess......if true, access rights to the class are checked
-          link.............if true, guarantee that the returned class, if any,
-                           has been linked
-   OUT:
-       *result..........set to result of resolution, or to NULL if
-                        the reference has not been resolved
-                        In the case of an exception, *result is
-                        guaranteed to be set to NULL.
-  
-   RETURN VALUE:
-       true.............everything ok 
-       false............an exception has been thrown
-
-   NOTE:
-       This function always resolves eagerly.
-   
-*******************************************************************************/
-
-bool resolve_class_from_typedesc(typedesc *d, bool checkaccess, bool link, classinfo **result)
-{
-       classinfo *cls;
-       
-       assert(d);
-       assert(result);
-
-       *result = NULL;
-
-#ifdef RESOLVE_VERBOSE
-       printf("resolve_class_from_typedesc(");
-       descriptor_debug_print_typedesc(stdout,d);
-       printf(",%i,%i)\n",(int)checkaccess,(int)link);
-#endif
-
-       if (d->type == TYPE_ADR) {
-               /* a reference type */
-               assert(d->classref);
-               if (!resolve_classref_or_classinfo(NULL,CLASSREF_OR_CLASSINFO(d->classref),
-                                                                                  resolveEager,checkaccess,link,&cls))
-                       return false; /* exception */
-       }
-       else {
-               /* a primitive type */
-
-               cls = primitive_class_get_by_type(d->decltype);
-
-               assert(cls->state & CLASS_LOADED);
-
-               if (!(cls->state & CLASS_LINKED))
-                       if (!link_class(cls))
-                               return false; /* exception */
-       }
-
-       assert(cls);
-       assert(cls->state & CLASS_LOADED);
-       assert(!link || (cls->state & CLASS_LINKED));
-
-#ifdef RESOLVE_VERBOSE
-       printf("    result = ");utf_fprint_printable_ascii(stdout,cls->name);printf("\n");
-#endif
-
-       *result = cls;
-       return true;
-}
-
-/******************************************************************************/
-/* SUBTYPE SET CHECKS                                                         */
-/******************************************************************************/
-
-/* resolve_subtype_check *******************************************************
-   Resolve the given types lazily and perform a subtype check
-  
-   IN:
-       refmethod........the method triggering the resolution
-       subtype..........checked to be a subtype of supertype
-          supertype........the super type to check agaings
-          mode.............mode of resolution:
-                            resolveLazy...only resolve if it does not
-                                          require loading classes
-                            resolveEager..load classes if necessary
-       error............which type of exception to throw if
-                        the test fails. May be:
-                            resolveLinkageError, or
-                            resolveIllegalAccessError
-                                               IMPORTANT: If error==resolveIllegalAccessError,
-                                               then array types are not checked.
-
-   RETURN VALUE:
-       resolveSucceeded.....the check succeeded
-       resolveDeferred......the check could not be performed due to
-                               unresolved types. (This can only happen for
-                                                       mode == resolveLazy.)
-          resolveFailed........the check failed, an exception has been thrown.
-   
-   NOTE:
-          The types are resolved first, so any
-          exception which may occurr during resolution may
-          be thrown by this function.
-   
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-static resolve_result_t resolve_subtype_check(methodinfo *refmethod,
-                                                                                     classref_or_classinfo subtype,
-                                                                                         classref_or_classinfo supertype,
-                                                                                         resolve_mode_t mode,
-                                                                                         resolve_err_t error)
-{
-       classinfo        *subclass;
-       typeinfo_t          subti;
-       typecheck_result  r;
-       char             *msg;
-       s4                msglen;
-       utf              *u;
-
-       assert(refmethod);
-       assert(subtype.any);
-       assert(supertype.any);
-       assert(mode == resolveLazy || mode == resolveEager);
-       assert(error == resolveLinkageError || error == resolveIllegalAccessError);
-
-       /* resolve the subtype */
-
-       if (!resolve_classref_or_classinfo(refmethod,subtype,mode,false,true,&subclass)) {
-               /* the subclass could not be resolved. therefore we are sure that  */
-               /* no instances of this subclass will ever exist -> skip this test */
-               /* XXX this assumes that class loading has invariant results (as in JVM spec) */
-               exceptions_clear_exception();
-               return resolveSucceeded;
-       }
-       if (!subclass)
-               return resolveDeferred; /* be lazy */
-
-       assert(subclass->state & CLASS_LINKED);
-
-       /* do not check access to protected members of arrays */
-
-       if (error == resolveIllegalAccessError && subclass->name->text[0] == '[') {
-               return resolveSucceeded;
-       }
-
-       /* perform the subtype check */
-
-       typeinfo_init_classinfo(&subti,subclass);
-check_again:
-       r = typeinfo_is_assignable_to_class(&subti,supertype);
-       if (r == typecheck_FAIL)
-               return resolveFailed; /* failed, exception is already set */
-
-       if (r == typecheck_MAYBE) {
-               assert(IS_CLASSREF(supertype));
-               if (mode == resolveEager) {
-                       if (!resolve_classref_or_classinfo(refmethod,supertype,
-                                                                                          resolveEager,false,true,
-                                                                                          &supertype.cls))
-                       {
-                               return resolveFailed;
-                       }
-                       assert(supertype.cls);
-                       goto check_again;
-               }
-
-               return resolveDeferred; /* be lazy */
-       }
-
-       if (!r) {
-               /* sub class relationship is false */
-
-#if defined(RESOLVE_VERBOSE)
-               printf("SUBTYPE CHECK FAILED!\n");
-#endif
-
-               msglen =
-                       utf_bytes(subclass->name) +
-                       utf_bytes(CLASSREF_OR_CLASSINFO_NAME(supertype))
-                       + 200;
-
-               msg = MNEW(char, msglen);
-
-               strcpy(msg, (error == resolveIllegalAccessError) ?
-                          "illegal access to protected member (" :
-                          "subtype constraint violated (");
-
-               utf_cat_classname(msg, subclass->name);
-               strcat(msg, " is not a subclass of ");
-               utf_cat_classname(msg, CLASSREF_OR_CLASSINFO_NAME(supertype));
-               strcat(msg, ")");
-
-               u = utf_new_char(msg);
-
-               if (error == resolveIllegalAccessError)
-                       exceptions_throw_illegalaccessexception(u);
-               else
-                       exceptions_throw_linkageerror(msg, NULL);
-
-               /* ATTENTION: We probably need msg for
-                  exceptions_throw_linkageerror. */
-
-               MFREE(msg, char, msglen);
-
-               return resolveFailed; /* exception */
-       }
-
-       /* everything ok */
-
-       return resolveSucceeded;
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-/* resolve_lazy_subtype_checks *************************************************
-   Resolve the types to check lazily and perform subtype checks
-  
-   IN:
-       refmethod........the method triggering the resolution
-       subtinfo.........the typeinfo containing the subtypes
-       supertype........the supertype to test againgst
-          mode.............mode of resolution:
-                            resolveLazy...only resolve if it does not
-                                          require loading classes
-                            resolveEager..load classes if necessary
-       error............which type of exception to throw if
-                        the test fails. May be:
-                            resolveLinkageError, or
-                            resolveIllegalAccessError
-                                               IMPORTANT: If error==resolveIllegalAccessError,
-                                               then array types in the set are skipped.
-
-   RETURN VALUE:
-       resolveSucceeded.....the check succeeded
-       resolveDeferred......the check could not be performed due to
-                               unresolved types
-          resolveFailed........the check failed, an exception has been thrown.
-   
-   NOTE:
-       The references in the set are resolved first, so any
-       exception which may occurr during resolution may
-       be thrown by this function.
-   
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-static resolve_result_t resolve_lazy_subtype_checks(methodinfo *refmethod,
-                                                                                                       typeinfo_t *subtinfo,
-                                                                                                       classref_or_classinfo supertype,
-                                                                                                       resolve_err_t error)
-{
-       int count;
-       int i;
-       resolve_result_t result;
-
-       assert(refmethod);
-       assert(subtinfo);
-       assert(supertype.any);
-       assert(error == resolveLinkageError || error == resolveIllegalAccessError);
-
-       /* returnAddresses are illegal here */
-
-       if (TYPEINFO_IS_PRIMITIVE(*subtinfo)) {
-               exceptions_throw_verifyerror(refmethod,
-                               "Invalid use of returnAddress");
-               return resolveFailed;
-       }
-
-       /* uninitialized objects are illegal here */
-
-       if (TYPEINFO_IS_NEWOBJECT(*subtinfo)) {
-               exceptions_throw_verifyerror(refmethod,
-                               "Invalid use of uninitialized object");
-               return resolveFailed;
-       }
-
-       /* the nulltype is always assignable */
-
-       if (TYPEINFO_IS_NULLTYPE(*subtinfo))
-               return resolveSucceeded;
-
-       /* every type is assignable to (BOOTSTRAP)java.lang.Object */
-
-       if (supertype.cls == class_java_lang_Object
-               || (CLASSREF_OR_CLASSINFO_NAME(supertype) == utf_java_lang_Object
-                       && refmethod->clazz->classloader == NULL))
-       {
-               return resolveSucceeded;
-       }
-
-       if (subtinfo->merged) {
-
-               /* for a merged type we have to do a series of checks */
-
-               count = subtinfo->merged->count;
-               for (i=0; i<count; ++i) {
-                       classref_or_classinfo c = subtinfo->merged->list[i];
-                       if (subtinfo->dimension > 0) {
-                               /* a merge of array types */
-                               /* the merged list contains the possible _element_ types, */
-                               /* so we have to create array types with these elements.  */
-                               if (IS_CLASSREF(c)) {
-                                       c.ref = class_get_classref_multiarray_of(subtinfo->dimension,c.ref);
-                               }
-                               else {
-                                       c.cls = class_multiarray_of(subtinfo->dimension,c.cls,false);
-                               }
-                       }
-
-                       /* do the subtype check against the type c */
-
-                       result = resolve_subtype_check(refmethod,c,supertype,resolveLazy,error);
-                       if (result != resolveSucceeded)
-                               return result;
-               }
-       }
-       else {
-
-               /* a single type, this is the common case, hopefully */
-
-               if (CLASSREF_OR_CLASSINFO_NAME(subtinfo->typeclass)
-                       == CLASSREF_OR_CLASSINFO_NAME(supertype))
-               {
-                       /* the class names are the same */
-                   /* equality is guaranteed by the loading constraints */
-                       return resolveSucceeded;
-               }
-               else {
-
-                       /* some other type name, try to perform the check lazily */
-
-                       return resolve_subtype_check(refmethod,
-                                                                                subtinfo->typeclass,supertype,
-                                                                                resolveLazy,
-                                                                                error);
-               }
-       }
-
-       /* everything ok */
-       return resolveSucceeded;
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-/* resolve_and_check_subtype_set ***********************************************
-   Resolve the references in the given set and test subtype relationships
-  
-   IN:
-       refmethod........the method triggering the resolution
-       ref..............a set of class/interface references
-                        (may be empty)
-       typeref..........the type to test against the set
-       mode.............mode of resolution:
-                            resolveLazy...only resolve if it does not
-                                          require loading classes
-                            resolveEager..load classes if necessary
-       error............which type of exception to throw if
-                        the test fails. May be:
-                            resolveLinkageError, or
-                            resolveIllegalAccessError
-                                               IMPORTANT: If error==resolveIllegalAccessError,
-                                               then array types in the set are skipped.
-
-   RETURN VALUE:
-       resolveSucceeded.....the check succeeded
-       resolveDeferred......the check could not be performed due to
-                               unresolved types. (This can only happen if
-                                                       mode == resolveLazy.)
-          resolveFailed........the check failed, an exception has been thrown.
-   
-   NOTE:
-       The references in the set are resolved first, so any
-       exception which may occurr during resolution may
-       be thrown by this function.
-   
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-static resolve_result_t resolve_and_check_subtype_set(methodinfo *refmethod,
-                                                                         unresolved_subtype_set *ref,
-                                                                         classref_or_classinfo typeref,
-                                                                         resolve_mode_t mode,
-                                                                         resolve_err_t error)
-{
-       classref_or_classinfo *setp;
-       typecheck_result checkresult;
-
-       assert(refmethod);
-       assert(ref);
-       assert(typeref.any);
-       assert(mode == resolveLazy || mode == resolveEager);
-       assert(error == resolveLinkageError || error == resolveIllegalAccessError);
-
-#if defined(RESOLVE_VERBOSE)
-       printf("resolve_and_check_subtype_set:\n");
-       unresolved_subtype_set_debug_dump(ref, stdout);
-       if (IS_CLASSREF(typeref))
-               class_classref_println(typeref.ref);
-       else
-               class_println(typeref.cls);
-#endif
-
-       setp = ref->subtyperefs;
-
-       /* an empty set of tests always succeeds */
-       if (!setp || !setp->any) {
-               return resolveSucceeded;
-       }
-
-       /* first resolve the type if necessary */
-       if (!resolve_classref_or_classinfo(refmethod,typeref,mode,false,true,&(typeref.cls)))
-               return resolveFailed; /* exception */
-       if (!typeref.cls)
-               return resolveDeferred; /* be lazy */
-
-       assert(typeref.cls->state & CLASS_LINKED);
-
-       /* iterate over the set members */
-
-       for (; setp->any; ++setp) {
-               checkresult = resolve_subtype_check(refmethod,*setp,typeref,mode,error);
-#if defined(RESOLVE_VERBOSE)
-               if (checkresult != resolveSucceeded)
-                       printf("SUBTYPE CHECK FAILED!\n");
-#endif
-               if (checkresult != resolveSucceeded)
-                       return checkresult;
-       }
-
-       /* check succeeds */
-       return resolveSucceeded;
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-/******************************************************************************/
-/* CLASS RESOLUTION                                                           */
-/******************************************************************************/
-
-/* resolve_class ***************************************************************
-   Resolve an unresolved class reference. The class is also linked.
-  
-   IN:
-       ref..............struct containing the reference
-       mode.............mode of resolution:
-                            resolveLazy...only resolve if it does not
-                                          require loading classes
-                            resolveEager..load classes if necessary
-          checkaccess......if true, access rights to the class are checked
-   
-   OUT:
-       *result..........set to the result of resolution, or to NULL if
-                        the reference has not been resolved
-                        In the case of an exception, *result is
-                        guaranteed to be set to NULL.
-  
-   RETURN VALUE:
-       true.............everything ok 
-                        (*result may still be NULL for resolveLazy)
-       false............an exception has been thrown
-   
-*******************************************************************************/
-
-#ifdef ENABLE_VERIFIER
-bool resolve_class(unresolved_class *ref,
-                                  resolve_mode_t mode,
-                                  bool checkaccess,
-                                  classinfo **result)
-{
-       classinfo *cls;
-       resolve_result_t checkresult;
-       
-       assert(ref);
-       assert(result);
-       assert(mode == resolveLazy || mode == resolveEager);
-
-       *result = NULL;
-
-#ifdef RESOLVE_VERBOSE
-       unresolved_class_debug_dump(ref,stdout);
-#endif
-
-       /* first we must resolve the class */
-       if (!resolve_classref(ref->referermethod,
-                                             ref->classref,mode,checkaccess,true,&cls))
-       {
-               /* the class reference could not be resolved */
-               return false; /* exception */
-       }
-       if (!cls)
-               return true; /* be lazy */
-
-       assert(cls);
-       assert((cls->state & CLASS_LOADED) && (cls->state & CLASS_LINKED));
-
-       /* now we check the subtype constraints */
-       
-       checkresult = resolve_and_check_subtype_set(ref->referermethod,
-                                                                          &(ref->subtypeconstraints),
-                                                                          CLASSREF_OR_CLASSINFO(cls),
-                                                                          mode,
-                                                                          resolveLinkageError);
-       if (checkresult != resolveSucceeded)
-               return (bool) checkresult;
-
-       /* succeed */
-       *result = cls;
-       return true;
-}
-#endif /* ENABLE_VERIFIER */
-
-/* resolve_classref_eager ******************************************************
-   Resolve an unresolved class reference eagerly. The class is also linked and
-   access rights to the class are checked.
-  
-   IN:
-       ref..............constant_classref to the class
-   
-   RETURN VALUE:
-       classinfo * to the class, or
-          NULL if an exception has been thrown
-   
-*******************************************************************************/
-
-classinfo * resolve_classref_eager(constant_classref *ref)
-{
-       classinfo *c;
-
-       if (!resolve_classref(NULL,ref,resolveEager,true,true,&c))
-               return NULL;
-
-       return c;
-}
-
-/* resolve_classref_eager_nonabstract ******************************************
-   Resolve an unresolved class reference eagerly. The class is also linked and
-   access rights to the class are checked. A check is performed that the class
-   is not abstract.
-  
-   IN:
-       ref..............constant_classref to the class
-   
-   RETURN VALUE:
-       classinfo * to the class, or
-          NULL if an exception has been thrown
-   
-*******************************************************************************/
-
-classinfo * resolve_classref_eager_nonabstract(constant_classref *ref)
-{
-       classinfo *c;
-
-       if (!resolve_classref(NULL,ref,resolveEager,true,true,&c))
-               return NULL;
-
-       /* ensure that the class is not abstract */
-
-       if (c->flags & ACC_ABSTRACT) {
-               exceptions_throw_verifyerror(NULL,"creating instance of abstract class");
-               return NULL;
-       }
-
-       return c;
-}
-
-/* resolve_class_eager *********************************************************
-   Resolve an unresolved class reference eagerly. The class is also linked and
-   access rights to the class are checked.
-  
-   IN:
-       ref..............struct containing the reference
-   
-   RETURN VALUE:
-       classinfo * to the class, or
-          NULL if an exception has been thrown
-   
-*******************************************************************************/
-
-#ifdef ENABLE_VERIFIER
-classinfo * resolve_class_eager(unresolved_class *ref)
-{
-       classinfo *c;
-
-       if (!resolve_class(ref,resolveEager,true,&c))
-               return NULL;
-
-       return c;
-}
-#endif /* ENABLE_VERIFIER */
-
-/* resolve_class_eager_no_access_check *****************************************
-   Resolve an unresolved class reference eagerly. The class is also linked.
-   Access rights are _not_ checked.
-  
-   IN:
-       ref..............struct containing the reference
-   
-   RETURN VALUE:
-       classinfo * to the class, or
-          NULL if an exception has been thrown
-   
-*******************************************************************************/
-
-#ifdef ENABLE_VERIFIER
-classinfo * resolve_class_eager_no_access_check(unresolved_class *ref)
-{
-       classinfo *c;
-
-       if (!resolve_class(ref, resolveEager, false, &c))
-               return NULL;
-
-       return c;
-}
-#endif /* ENABLE_VERIFIER */
-
-/******************************************************************************/
-/* FIELD RESOLUTION                                                           */
-/******************************************************************************/
-
-/* resolve_field_verifier_checks *******************************************
-   Do the verifier checks necessary after field has been resolved.
-  
-   IN:
-       refmethod........the method containing the reference
-          fieldref.........the field reference
-          container........the class where the field was found
-          fi...............the fieldinfo of the resolved field
-          instanceti.......instance typeinfo, if available
-          valueti..........value typeinfo, if available
-          isstatic.........true if this is a *STATIC* instruction
-          isput............true if this is a PUT* instruction
-  
-   RETURN VALUE:
-       resolveSucceeded....everything ok
-          resolveDeferred.....tests could not be done, have been deferred
-       resolveFailed.......exception has been thrown
-   
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-resolve_result_t resolve_field_verifier_checks(methodinfo *refmethod,
-                                                                                          constant_FMIref *fieldref,
-                                                                                          classinfo *container,
-                                                                                          fieldinfo *fi,
-                                                                                          typeinfo_t *instanceti,
-                                                                                          typeinfo_t *valueti,
-                                                                                          bool isstatic,
-                                                                                          bool isput)
-{
-       classinfo         *declarer;
-       classinfo         *referer;
-       resolve_result_t   result;
-       constant_classref *fieldtyperef;
-       char              *msg;
-       s4                 msglen;
-       utf               *u;
-
-       assert(refmethod);
-       assert(fieldref);
-       assert(container);
-       assert(fi);
-
-       /* get the classinfos and the field type */
-
-       referer = refmethod->clazz;
-       assert(referer);
-
-       declarer = fi->clazz;
-       assert(declarer);
-       assert(referer->state & CLASS_LINKED);
-
-       fieldtyperef = fieldref->parseddesc.fd->classref;
-
-       /* check static */
-
-#if true != 1
-#error This code assumes that `true` is `1`. Otherwise, use the ternary operator below.
-#endif
-
-       if (((fi->flags & ACC_STATIC) != 0) != isstatic) {
-               /* a static field is accessed via an instance, or vice versa */
-               exceptions_throw_incompatibleclasschangeerror(declarer,
-                                                                                                         (fi->flags & ACC_STATIC)
-                                                                                                         ? "static field accessed via instance"
-                                                                                                         : "instance field  accessed without instance");
-
-               return resolveFailed;
-       }
-
-       /* check access rights */
-
-       if (!access_is_accessible_member(referer,declarer,fi->flags)) {
-               msglen =
-                       utf_bytes(declarer->name) +
-                       utf_bytes(fi->name) +
-                       utf_bytes(referer->name) +
-                       100;
-
-               msg = MNEW(char, msglen);
-
-               strcpy(msg, "field is not accessible (");
-               utf_cat_classname(msg, declarer->name);
-               strcat(msg, ".");
-               utf_cat(msg, fi->name);
-               strcat(msg, " from ");
-               utf_cat_classname(msg, referer->name);
-               strcat(msg, ")");
-
-               u = utf_new_char(msg);
-
-               MFREE(msg, char, msglen);
-
-               exceptions_throw_illegalaccessexception(u);
-
-               return resolveFailed; /* exception */
-       }
-
-       /* for non-static methods we have to check the constraints on the         */
-       /* instance type                                                          */
-
-       if (instanceti) {
-               typeinfo_t *insttip;
-               typeinfo_t tinfo;
-
-               /* The instanceslot must contain a reference to a non-array type */
-
-               if (!TYPEINFO_IS_REFERENCE(*instanceti)) {
-                       exceptions_throw_verifyerror(refmethod, "illegal instruction: field access on non-reference");
-                       return resolveFailed;
-               }
-               if (TYPEINFO_IS_ARRAY(*instanceti)) {
-                       exceptions_throw_verifyerror(refmethod, "illegal instruction: field access on array");
-                       return resolveFailed;
-               }
-
-               if (isput && TYPEINFO_IS_NEWOBJECT(*instanceti))
-               {
-                       /* The instruction writes a field in an uninitialized object. */
-                       /* This is only allowed when a field of an uninitialized 'this' object is */
-                       /* written inside an initialization method                                */
-
-                       classinfo *initclass;
-                       instruction *ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*instanceti);
-
-                       if (ins != NULL) {
-                               exceptions_throw_verifyerror(refmethod, "accessing field of uninitialized object");
-                               return resolveFailed;
-                       }
-
-                       /* XXX check that class of field == refmethod->clazz */
-                       initclass = referer; /* XXX classrefs */
-                       assert(initclass->state & CLASS_LINKED);
-
-                       typeinfo_init_classinfo(&tinfo, initclass);
-                       insttip = &tinfo;
-               }
-               else {
-                       insttip = instanceti;
-               }
-
-               result = resolve_lazy_subtype_checks(refmethod,
-                               insttip,
-                               CLASSREF_OR_CLASSINFO(container),
-                               resolveLinkageError);
-               if (result != resolveSucceeded)
-                       return result;
-
-               /* check protected access */
-
-               if (((fi->flags & ACC_PROTECTED) != 0) && !SAME_PACKAGE(declarer,referer))
-               {
-                       result = resolve_lazy_subtype_checks(refmethod,
-                                       instanceti,
-                                       CLASSREF_OR_CLASSINFO(referer),
-                                       resolveIllegalAccessError);
-                       if (result != resolveSucceeded)
-                               return result;
-               }
-
-       }
-
-       /* for PUT* instructions we have to check the constraints on the value type */
-
-       if (valueti) {
-               assert(fieldtyperef);
-
-               /* check subtype constraints */
-               result = resolve_lazy_subtype_checks(refmethod,
-                               valueti,
-                               CLASSREF_OR_CLASSINFO(fieldtyperef),
-                               resolveLinkageError);
-
-               if (result != resolveSucceeded)
-                       return result;
-       }
-
-       /* impose loading constraint on field type */
-
-       if (fi->type == TYPE_ADR) {
-               assert(fieldtyperef);
-               if (!classcache_add_constraint(declarer->classloader,
-                                                                          referer->classloader,
-                                                                          fieldtyperef->name))
-                       return resolveFailed;
-       }
-
-       /* XXX impose loading constraint on instance? */
-
-       /* everything ok */
-       return resolveSucceeded;
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-/* resolve_field_lazy **********************************************************
-   Resolve an unresolved field reference lazily
-
-   NOTE: This function does NOT do any verification checks. In case of a
-         successful resolution, you must call resolve_field_verifier_checks
-                in order to perform the necessary checks!
-  
-   IN:
-          refmethod........the referer method
-          fieldref.........the field reference
-  
-   RETURN VALUE:
-       resolveSucceeded.....the reference has been resolved
-       resolveDeferred......the resolving could not be performed lazily
-          resolveFailed........resolving failed, an exception has been thrown.
-   
-*******************************************************************************/
-
-resolve_result_t resolve_field_lazy(methodinfo *refmethod,
-                                                                       constant_FMIref *fieldref)
-{
-       classinfo *referer;
-       classinfo *container;
-       fieldinfo *fi;
-
-       assert(refmethod);
-
-       /* the class containing the reference */
-
-       referer = refmethod->clazz;
-       assert(referer);
-
-       /* check if the field itself is already resolved */
-
-       if (IS_FMIREF_RESOLVED(fieldref))
-               return resolveSucceeded;
-
-       /* first we must resolve the class containg the field */
-
-       /* XXX can/may lazyResolving trigger linking? */
-
-       if (!resolve_class_from_name(referer, refmethod,
-                  fieldref->p.classref->name, resolveLazy, true, true, &container))
-       {
-               /* the class reference could not be resolved */
-               return resolveFailed; /* exception */
-       }
-       if (!container)
-               return resolveDeferred; /* be lazy */
-
-       assert(container->state & CLASS_LINKED);
-
-       /* now we must find the declaration of the field in `container`
-        * or one of its superclasses */
-
-       fi = class_resolvefield(container,
-                                                       fieldref->name, fieldref->descriptor,
-                                                       referer, true);
-       if (!fi) {
-               /* The field does not exist. But since we were called lazily, */
-               /* this error must not be reported now. (It will be reported   */
-               /* if eager resolving of this field is ever tried.)           */
-
-               exceptions_clear_exception();
-               return resolveDeferred; /* be lazy */
-       }
-
-       /* cache the result of the resolution */
-
-       fieldref->p.field = fi;
-
-       /* everything ok */
-       return resolveSucceeded;
-}
-
-/* resolve_field ***************************************************************
-   Resolve an unresolved field reference
-  
-   IN:
-       ref..............struct containing the reference
-       mode.............mode of resolution:
-                            resolveLazy...only resolve if it does not
-                                          require loading classes
-                            resolveEager..load classes if necessary
-  
-   OUT:
-       *result..........set to the result of resolution, or to NULL if
-                        the reference has not been resolved
-                        In the case of an exception, *result is
-                        guaranteed to be set to NULL.
-  
-   RETURN VALUE:
-       true.............everything ok 
-                        (*result may still be NULL for resolveLazy)
-       false............an exception has been thrown
-   
-*******************************************************************************/
-
-bool resolve_field(unresolved_field *ref,
-                                  resolve_mode_t mode,
-                                  fieldinfo **result)
-{
-       classinfo *referer;
-       classinfo *container;
-       classinfo *declarer;
-       constant_classref *fieldtyperef;
-       fieldinfo *fi;
-       resolve_result_t checkresult;
-
-       assert(ref);
-       assert(result);
-       assert(mode == resolveLazy || mode == resolveEager);
-
-       *result = NULL;
-
-#ifdef RESOLVE_VERBOSE
-       unresolved_field_debug_dump(ref,stdout);
-#endif
-
-       /* the class containing the reference */
-
-       referer = ref->referermethod->clazz;
-       assert(referer);
-
-       /* check if the field itself is already resolved */
-       if (IS_FMIREF_RESOLVED(ref->fieldref)) {
-               fi = ref->fieldref->p.field;
-               container = fi->clazz;
-               goto resolved_the_field;
-       }
-
-       /* first we must resolve the class containg the field */
-       if (!resolve_class_from_name(referer,ref->referermethod,
-                                          ref->fieldref->p.classref->name,mode,true,true,&container))
-       {
-               /* the class reference could not be resolved */
-               return false; /* exception */
-       }
-       if (!container)
-               return true; /* be lazy */
-
-       assert(container);
-       assert(container->state & CLASS_LOADED);
-       assert(container->state & CLASS_LINKED);
-
-       /* now we must find the declaration of the field in `container`
-        * or one of its superclasses */
-
-#ifdef RESOLVE_VERBOSE
-               printf("    resolving field in class...\n");
-#endif
-
-       fi = class_resolvefield(container,
-                                                       ref->fieldref->name,ref->fieldref->descriptor,
-                                                       referer,true);
-       if (!fi) {
-               if (mode == resolveLazy) {
-                       /* The field does not exist. But since we were called lazily, */
-                       /* this error must not be reported now. (It will be reported   */
-                       /* if eager resolving of this field is ever tried.)           */
-
-                       exceptions_clear_exception();
-                       return true; /* be lazy */
-               }
-
-               return false; /* exception */
-       }
-
-       /* cache the result of the resolution */
-       ref->fieldref->p.field = fi;
-
-resolved_the_field:
-
-#ifdef ENABLE_VERIFIER
-       /* Checking opt_verify is ok here, because the NULL iptr guarantees */
-       /* that no missing parts of an instruction will be accessed.        */
-       if (opt_verify) {
-               checkresult = resolve_field_verifier_checks(
-                               ref->referermethod,
-                               ref->fieldref,
-                               container,
-                               fi,
-                               NULL, /* instanceti, handled by constraints below */
-                               NULL, /* valueti, handled by constraints below  */
-                               (ref->flags & RESOLVE_STATIC) != 0, /* isstatic */
-                               (ref->flags & RESOLVE_PUTFIELD) != 0 /* isput */);
-
-               if (checkresult != resolveSucceeded)
-                       return (bool) checkresult;
-
-               declarer = fi->clazz;
-               assert(declarer);
-               assert(declarer->state & CLASS_LOADED);
-               assert(declarer->state & CLASS_LINKED);
-
-               /* for non-static accesses we have to check the constraints on the */
-               /* instance type */
-
-               if (!(ref->flags & RESOLVE_STATIC)) {
-                       checkresult = resolve_and_check_subtype_set(ref->referermethod,
-                                       &(ref->instancetypes),
-                                       CLASSREF_OR_CLASSINFO(container),
-                                       mode, resolveLinkageError);
-                       if (checkresult != resolveSucceeded)
-                               return (bool) checkresult;
-               }
-
-               fieldtyperef = ref->fieldref->parseddesc.fd->classref;
-
-               /* for PUT* instructions we have to check the constraints on the value type */
-               if (((ref->flags & RESOLVE_PUTFIELD) != 0) && fi->type == TYPE_ADR) {
-                       assert(fieldtyperef);
-                       if (!SUBTYPESET_IS_EMPTY(ref->valueconstraints)) {
-                               /* check subtype constraints */
-                               checkresult = resolve_and_check_subtype_set(ref->referermethod,
-                                               &(ref->valueconstraints),
-                                               CLASSREF_OR_CLASSINFO(fieldtyperef),
-                                               mode, resolveLinkageError);
-                               if (checkresult != resolveSucceeded)
-                                       return (bool) checkresult;
-                       }
-               }
-
-               /* check protected access */
-               if (((fi->flags & ACC_PROTECTED) != 0) && !SAME_PACKAGE(declarer,referer)) {
-                       checkresult = resolve_and_check_subtype_set(ref->referermethod,
-                                       &(ref->instancetypes),
-                                       CLASSREF_OR_CLASSINFO(referer),
-                                       mode,
-                                       resolveIllegalAccessError);
-                       if (checkresult != resolveSucceeded)
-                               return (bool) checkresult;
-               }
-
-       }
-#endif /* ENABLE_VERIFIER */
-
-       /* succeed */
-       *result = fi;
-
-       return true;
-}
-
-/* resolve_field_eager *********************************************************
-   Resolve an unresolved field reference eagerly.
-  
-   IN:
-       ref..............struct containing the reference
-   
-   RETURN VALUE:
-       fieldinfo * to the field, or
-          NULL if an exception has been thrown
-   
-*******************************************************************************/
-
-fieldinfo * resolve_field_eager(unresolved_field *ref)
-{
-       fieldinfo *fi;
-
-       if (!resolve_field(ref,resolveEager,&fi))
-               return NULL;
-
-       return fi;
-}
-
-/******************************************************************************/
-/* METHOD RESOLUTION                                                          */
-/******************************************************************************/
-
-/* resolve_method_invokespecial_lookup *****************************************
-   Do the special lookup for methods invoked by INVOKESPECIAL
-  
-   IN:
-       refmethod........the method containing the reference
-          mi...............the methodinfo of the resolved method
-  
-   RETURN VALUE:
-       a methodinfo *...the result of the lookup,
-          NULL.............an exception has been thrown
-   
-*******************************************************************************/
-
-methodinfo * resolve_method_invokespecial_lookup(methodinfo *refmethod,
-                                                                                                methodinfo *mi)
-{
-       classinfo *declarer;
-       classinfo *referer;
-
-       assert(refmethod);
-       assert(mi);
-
-       /* get referer and declarer classes */
-
-       referer = refmethod->clazz;
-       assert(referer);
-
-       declarer = mi->clazz;
-       assert(declarer);
-       assert(referer->state & CLASS_LINKED);
-
-       /* checks for INVOKESPECIAL:                                       */
-       /* for <init> and methods of the current class we don't need any   */
-       /* special checks. Otherwise we must verify that the called method */
-       /* belongs to a super class of the current class                   */
-
-       if ((referer != declarer) && (mi->name != utf_init)) {
-               /* check that declarer is a super class of the current class   */
-
-               if (!class_issubclass(referer,declarer)) {
-                       exceptions_throw_verifyerror(refmethod,
-                                       "INVOKESPECIAL calling non-super class method");
-                       return NULL;
-               }
-
-               /* if the referer has ACC_SUPER set, we must do the special    */
-               /* lookup starting with the direct super class of referer      */
-
-               if ((referer->flags & ACC_SUPER) != 0) {
-                       mi = class_resolvemethod(referer->super,
-                                                                        mi->name,
-                                                                        mi->descriptor);
-
-                       if (mi == NULL) {
-                               /* the spec calls for an AbstractMethodError in this case */
-
-                               exceptions_throw_abstractmethoderror();
-
-                               return NULL;
-                       }
-               }
-       }
-
-       /* everything ok */
-       return mi;
-}
-
-/* resolve_method_verifier_checks ******************************************
-   Do the verifier checks necessary after a method has been resolved.
-  
-   IN:
-       refmethod........the method containing the reference
-          methodref........the method reference
-          mi...............the methodinfo of the resolved method
-          invokestatic.....true if the method is invoked by INVOKESTATIC
-  
-   RETURN VALUE:
-       resolveSucceeded....everything ok
-          resolveDeferred.....tests could not be done, have been deferred
-       resolveFailed.......exception has been thrown
-   
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-resolve_result_t resolve_method_verifier_checks(methodinfo *refmethod,
-                                                                                               constant_FMIref *methodref,
-                                                                                               methodinfo *mi,
-                                                                                               bool invokestatic)
-{
-       classinfo *declarer;
-       classinfo *referer;
-       char      *msg;
-       s4         msglen;
-       utf       *u;
-
-       assert(refmethod);
-       assert(methodref);
-       assert(mi);
-
-#ifdef RESOLVE_VERBOSE
-       printf("resolve_method_verifier_checks\n");
-       printf("    flags: %02x\n",mi->flags);
-#endif
-
-       /* get the classinfos and the method descriptor */
-
-       referer = refmethod->clazz;
-       assert(referer);
-
-       declarer = mi->clazz;
-       assert(declarer);
-
-       /* check static */
-
-       if (((mi->flags & ACC_STATIC) != 0) != (invokestatic != false)) {
-               /* a static method is accessed via an instance, or vice versa */
-               exceptions_throw_incompatibleclasschangeerror(declarer,
-                                                                                                         (mi->flags & ACC_STATIC)
-                                                                                                         ? "static method called via instance"
-                                                                                                         : "instance method called without instance");
-
-               return resolveFailed;
-       }
-
-       /* check access rights */
-
-       if (!access_is_accessible_member(referer,declarer,mi->flags)) {
-               /* XXX clean this up. this should be in exceptions.c */
-
-               msglen =
-                       utf_bytes(declarer->name) +
-                       utf_bytes(mi->name) +
-                       utf_bytes(mi->descriptor) +
-                       utf_bytes(referer->name) +
-                       100;
-
-               msg = MNEW(char, msglen);
-
-               strcpy(msg, "method is not accessible (");
-               utf_cat_classname(msg, declarer->name);
-               strcat(msg, ".");
-               utf_cat(msg, mi->name);
-               utf_cat(msg, mi->descriptor);
-               strcat(msg, " from ");
-               utf_cat_classname(msg, referer->name);
-               strcat(msg, ")");
-
-               u = utf_new_char(msg);
-
-               MFREE(msg, char, msglen);
-
-               exceptions_throw_illegalaccessexception(u);
-
-               return resolveFailed; /* exception */
-       }
-
-       /* everything ok */
-
-       return resolveSucceeded;
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-
-/* resolve_method_instance_type_checks *****************************************
-
-   Check the instance type of a method invocation.
-
-   IN:
-       refmethod........the method containing the reference
-          mi...............the methodinfo of the resolved method
-          instanceti.......typeinfo of the instance slot
-          invokespecial....true if the method is invoked by INVOKESPECIAL
-
-   RETURN VALUE:
-       resolveSucceeded....everything ok
-          resolveDeferred.....tests could not be done, have been deferred
-       resolveFailed.......exception has been thrown
-
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-resolve_result_t resolve_method_instance_type_checks(methodinfo *refmethod,
-                                                                                                        methodinfo *mi,
-                                                                                                        typeinfo_t *instanceti,
-                                                                                                        bool invokespecial)
-{
-       typeinfo_t         tinfo;
-       typeinfo_t        *tip;
-       resolve_result_t result;
-
-       if (invokespecial && TYPEINFO_IS_NEWOBJECT(*instanceti))
-       {   /* XXX clean up */
-               instruction *ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*instanceti);
-               classref_or_classinfo initclass = (ins) ? ins[-1].sx.val.c
-                                                                        : CLASSREF_OR_CLASSINFO(refmethod->clazz);
-               tip = &tinfo;
-               if (!typeinfo_init_class(tip, initclass))
-                       return false;
-       }
-       else {
-               tip = instanceti;
-       }
-
-       result = resolve_lazy_subtype_checks(refmethod,
-                                                                                tip,
-                                                                                CLASSREF_OR_CLASSINFO(mi->clazz),
-                                                                                resolveLinkageError);
-       if (result != resolveSucceeded)
-               return result;
-
-       /* check protected access */
-
-       /* XXX use other `declarer` than mi->clazz? */
-       if (((mi->flags & ACC_PROTECTED) != 0)
-                       && !SAME_PACKAGE(mi->clazz, refmethod->clazz))
-       {
-               result = resolve_lazy_subtype_checks(refmethod,
-                               tip,
-                               CLASSREF_OR_CLASSINFO(refmethod->clazz),
-                               resolveIllegalAccessError);
-               if (result != resolveSucceeded)
-                       return result;
-       }
-
-       /* everything ok */
-
-       return resolveSucceeded;
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-
-/* resolve_method_param_type_checks ********************************************
-
-   Check non-instance parameter types of a method invocation.
-
-   IN:
-          jd...............jitdata of the method doing the call
-       refmethod........the method containing the reference
-          iptr.............the invoke instruction
-          mi...............the methodinfo of the resolved method
-          invokestatic.....true if the method is invoked by INVOKESTATIC
-
-   RETURN VALUE:
-       resolveSucceeded....everything ok
-          resolveDeferred.....tests could not be done, have been deferred
-       resolveFailed.......exception has been thrown
-
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-resolve_result_t resolve_method_param_type_checks(jitdata *jd, 
-                                                                                                 methodinfo *refmethod,
-                                                                                                 instruction *iptr, 
-                                                                                                 methodinfo *mi,
-                                                                                                 bool invokestatic)
-{
-       varinfo         *param;
-       resolve_result_t result;
-       methoddesc      *md;
-       typedesc        *paramtypes;
-       s4               type;
-       s4               instancecount;
-       s4               i;
-
-       assert(jd);
-
-       instancecount = (invokestatic) ? 0 : 1;
-
-       /* check subtype constraints for TYPE_ADR parameters */
-
-       md = mi->parseddesc;
-       paramtypes = md->paramtypes;
-
-       for (i = md->paramcount-1-instancecount; i>=0; --i) {
-               param = VAR(iptr->sx.s23.s2.args[i+instancecount]);
-               type = md->paramtypes[i+instancecount].type;
-
-               assert(param);
-               assert(type == param->type);
-
-               if (type == TYPE_ADR) {
-                       result = resolve_lazy_subtype_checks(refmethod,
-                                       &(param->typeinfo),
-                                       CLASSREF_OR_CLASSINFO(paramtypes[i+instancecount].classref),
-                                       resolveLinkageError);
-                       if (result != resolveSucceeded)
-                               return result;
-               }
-       }
-
-       /* everything ok */
-
-       return resolveSucceeded;
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-
-/* resolve_method_param_type_checks_stackbased *********************************
-
-   Check non-instance parameter types of a method invocation.
-
-   IN:
-       refmethod........the method containing the reference
-          mi...............the methodinfo of the resolved method
-          invokestatic.....true if the method is invoked by INVOKESTATIC
-          stack............TOS before the INVOKE instruction
-
-   RETURN VALUE:
-       resolveSucceeded....everything ok
-          resolveDeferred.....tests could not be done, have been deferred
-       resolveFailed.......exception has been thrown
-
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-resolve_result_t resolve_method_param_type_checks_stackbased(
-               methodinfo *refmethod, 
-               methodinfo *mi,
-               bool invokestatic, 
-               typedescriptor_t *stack)
-{
-       typedescriptor_t  *param;
-       resolve_result_t result;
-       methoddesc      *md;
-       typedesc        *paramtypes;
-       s4               type;
-       s4               instancecount;
-       s4               i;
-
-       instancecount = (invokestatic) ? 0 : 1;
-
-       /* check subtype constraints for TYPE_ADR parameters */
-
-       md = mi->parseddesc;
-       paramtypes = md->paramtypes;
-
-       param = stack - (md->paramslots - 1 - instancecount);
-
-       for (i = instancecount; i < md->paramcount; ++i) {
-               type = md->paramtypes[i].type;
-
-               assert(type == param->type);
-
-               if (type == TYPE_ADR) {
-                       result = resolve_lazy_subtype_checks(refmethod,
-                                       &(param->typeinfo),
-                                       CLASSREF_OR_CLASSINFO(paramtypes[i].classref),
-                                       resolveLinkageError);
-                       if (result != resolveSucceeded)
-                               return result;
-               }
-
-               param += (IS_2_WORD_TYPE(type)) ? 2 : 1;
-       }
-
-       /* everything ok */
-
-       return resolveSucceeded;
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-
-/* resolve_method_loading_constraints ******************************************
-
-   Impose loading constraints on the parameters and return type of the
-   given method.
-
-   IN:
-       referer..........the class refering to the method
-          mi...............the method
-
-   RETURN VALUE:
-       true................everything ok
-          false...............an exception has been thrown
-
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-bool resolve_method_loading_constraints(classinfo *referer,
-                                                                               methodinfo *mi)
-{
-       methoddesc *md;
-       typedesc   *paramtypes;
-       utf        *name;
-       s4          i;
-       s4          instancecount;
-
-       /* impose loading constraints on parameters (including instance) */
-
-       md = mi->parseddesc;
-       paramtypes = md->paramtypes;
-       instancecount = (mi->flags & ACC_STATIC) / ACC_STATIC;
-
-       for (i = 0; i < md->paramcount; i++) {
-               if (i < instancecount || paramtypes[i].type == TYPE_ADR) {
-                       if (i < instancecount) {
-                               /* The type of the 'this' pointer is the class containing */
-                               /* the method definition. Since container is the same as, */
-                               /* or a subclass of declarer, we also constrain declarer  */
-                               /* by transitivity of loading constraints.                */
-                               name = mi->clazz->name;
-                       }
-                       else {
-                               name = paramtypes[i].classref->name;
-                       }
-
-                       /* The caller (referer) and the callee (container) must agree */
-                       /* on the types of the parameters.                            */
-                       if (!classcache_add_constraint(referer->classloader,
-                                                                                  mi->clazz->classloader, name))
-                               return false; /* exception */
-               }
-       }
-
-       /* impose loading constraint onto return type */
-
-       if (md->returntype.type == TYPE_ADR) {
-               /* The caller (referer) and the callee (container) must agree */
-               /* on the return type.                                        */
-               if (!classcache_add_constraint(referer->classloader,
-                                       mi->clazz->classloader,
-                                       md->returntype.classref->name))
-                       return false; /* exception */
-       }
-
-       /* everything ok */
-
-       return true;
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-
-/* resolve_method_lazy *********************************************************
-   Resolve an unresolved method reference lazily
-  
-   NOTE: This function does NOT do any verification checks. In case of a
-         successful resolution, you must call resolve_method_verifier_checks
-                in order to perform the necessary checks!
-  
-   IN:
-          refmethod........the referer method
-          methodref........the method reference
-          invokespecial....true if this is an INVOKESPECIAL instruction
-  
-   RETURN VALUE:
-       resolveSucceeded.....the reference has been resolved
-       resolveDeferred......the resolving could not be performed lazily
-          resolveFailed........resolving failed, an exception has been thrown.
-   
-*******************************************************************************/
-
-resolve_result_t resolve_method_lazy(methodinfo *refmethod,
-                                                                        constant_FMIref *methodref,
-                                                                        bool invokespecial)
-{
-       classinfo *referer;
-       classinfo *container;
-       methodinfo *mi;
-
-       assert(refmethod);
-
-#ifdef RESOLVE_VERBOSE
-       printf("resolve_method_lazy\n");
-#endif
-
-       /* the class containing the reference */
-
-       referer = refmethod->clazz;
-       assert(referer);
-
-       /* check if the method itself is already resolved */
-
-       if (IS_FMIREF_RESOLVED(methodref))
-               return resolveSucceeded;
-
-       /* first we must resolve the class containg the method */
-
-       if (!resolve_class_from_name(referer, refmethod,
-                  methodref->p.classref->name, resolveLazy, true, true, &container))
-       {
-               /* the class reference could not be resolved */
-               return resolveFailed; /* exception */
-       }
-       if (!container)
-               return resolveDeferred; /* be lazy */
-
-       assert(container->state & CLASS_LINKED);
-
-       /* now we must find the declaration of the method in `container`
-        * or one of its superclasses */
-
-       if (container->flags & ACC_INTERFACE) {
-               mi = class_resolveinterfacemethod(container,
-                                                                             methodref->name,
-                                                                                 methodref->descriptor,
-                                                                             referer, true);
-
-       } else {
-               mi = class_resolveclassmethod(container,
-                                                                         methodref->name,
-                                                                         methodref->descriptor,
-                                                                         referer, true);
-       }
-
-       if (!mi) {
-               /* The method does not exist. But since we were called lazily, */
-               /* this error must not be reported now. (It will be reported   */
-               /* if eager resolving of this method is ever tried.)           */
-
-               exceptions_clear_exception();
-               return resolveDeferred; /* be lazy */
-       }
-
-       if (invokespecial) {
-               mi = resolve_method_invokespecial_lookup(refmethod, mi);
-               if (!mi)
-                       return resolveFailed; /* exception */
-       }
-
-       /* have the method params already been parsed? no, do it. */
-
-       if (!mi->parseddesc->params)
-               if (!descriptor_params_from_paramtypes(mi->parseddesc, mi->flags))
-                       return resolveFailed;
-
-       /* cache the result of the resolution */
-
-       methodref->p.method = mi;
-
-       /* succeed */
-
-       return resolveSucceeded;
-}
-
-/* resolve_method **************************************************************
-   Resolve an unresolved method reference
-  
-   IN:
-       ref..............struct containing the reference
-       mode.............mode of resolution:
-                            resolveLazy...only resolve if it does not
-                                          require loading classes
-                            resolveEager..load classes if necessary
-  
-   OUT:
-       *result..........set to the result of resolution, or to NULL if
-                        the reference has not been resolved
-                        In the case of an exception, *result is
-                        guaranteed to be set to NULL.
-  
-   RETURN VALUE:
-       true.............everything ok 
-                        (*result may still be NULL for resolveLazy)
-       false............an exception has been thrown
-   
-*******************************************************************************/
-
-bool resolve_method(unresolved_method *ref, resolve_mode_t mode, methodinfo **result)
-{
-       classinfo *referer;
-       classinfo *container;
-       classinfo *declarer;
-       methodinfo *mi;
-       typedesc *paramtypes;
-       int instancecount;
-       int i;
-       resolve_result_t checkresult;
-
-       assert(ref);
-       assert(result);
-       assert(mode == resolveLazy || mode == resolveEager);
-
-#ifdef RESOLVE_VERBOSE
-       unresolved_method_debug_dump(ref,stdout);
-#endif
-
-       *result = NULL;
-
-       /* the class containing the reference */
-
-       referer = ref->referermethod->clazz;
-       assert(referer);
-
-       /* check if the method itself is already resolved */
-
-       if (IS_FMIREF_RESOLVED(ref->methodref)) {
-               mi = ref->methodref->p.method;
-               container = mi->clazz;
-               goto resolved_the_method;
-       }
-
-       /* first we must resolve the class containing the method */
-
-       if (!resolve_class_from_name(referer,ref->referermethod,
-                                          ref->methodref->p.classref->name,mode,true,true,&container))
-       {
-               /* the class reference could not be resolved */
-               return false; /* exception */
-       }
-       if (!container)
-               return true; /* be lazy */
-
-       assert(container);
-       assert(container->state & CLASS_LINKED);
-
-       /* now we must find the declaration of the method in `container`
-        * or one of its superclasses */
-
-       if (container->flags & ACC_INTERFACE) {
-               mi = class_resolveinterfacemethod(container,
-                                                                             ref->methodref->name,
-                                                                                 ref->methodref->descriptor,
-                                                                             referer, true);
-
-       } else {
-               mi = class_resolveclassmethod(container,
-                                                                         ref->methodref->name,
-                                                                         ref->methodref->descriptor,
-                                                                         referer, true);
-       }
-
-       if (!mi) {
-               if (mode == resolveLazy) {
-                       /* The method does not exist. But since we were called lazily, */
-                       /* this error must not be reported now. (It will be reported   */
-                       /* if eager resolving of this method is ever tried.)           */
-
-                       exceptions_clear_exception();
-                       return true; /* be lazy */
-               }
-
-               return false; /* exception */ /* XXX set exceptionptr? */
-       }
-
-       /* { the method reference has been resolved } */
-
-       if (ref->flags & RESOLVE_SPECIAL) {
-               mi = resolve_method_invokespecial_lookup(ref->referermethod,mi);
-               if (!mi)
-                       return false; /* exception */
-       }
-
-       /* have the method params already been parsed? no, do it. */
-
-       if (!mi->parseddesc->params)
-               if (!descriptor_params_from_paramtypes(mi->parseddesc, mi->flags))
-                       return false;
-
-       /* cache the resolution */
-
-       ref->methodref->p.method = mi;
-
-resolved_the_method:
-
-#ifdef ENABLE_VERIFIER
-       if (opt_verify) {
-
-               checkresult = resolve_method_verifier_checks(
-                               ref->referermethod,
-                               ref->methodref,
-                               mi,
-                               (ref->flags & RESOLVE_STATIC));
-
-               if (checkresult != resolveSucceeded)
-                       return (bool) checkresult;
-
-               /* impose loading constraints on params and return type */
-
-               if (!resolve_method_loading_constraints(referer, mi))
-                       return false;
-
-               declarer = mi->clazz;
-               assert(declarer);
-               assert(referer->state & CLASS_LINKED);
-
-               /* for non-static methods we have to check the constraints on the         */
-               /* instance type                                                          */
-
-               if (!(ref->flags & RESOLVE_STATIC)) {
-                       checkresult = resolve_and_check_subtype_set(ref->referermethod,
-                                       &(ref->instancetypes),
-                                       CLASSREF_OR_CLASSINFO(container),
-                                       mode,
-                                       resolveLinkageError);
-                       if (checkresult != resolveSucceeded)
-                               return (bool) checkresult;
-                       instancecount = 1;
-               }
-               else {
-                       instancecount = 0;
-               }
-
-               /* check subtype constraints for TYPE_ADR parameters */
-
-               assert(mi->parseddesc->paramcount == ref->methodref->parseddesc.md->paramcount);
-               paramtypes = mi->parseddesc->paramtypes;
-
-               for (i = 0; i < mi->parseddesc->paramcount-instancecount; i++) {
-                       if (paramtypes[i+instancecount].type == TYPE_ADR) {
-                               if (ref->paramconstraints) {
-                                       checkresult = resolve_and_check_subtype_set(ref->referermethod,
-                                                       ref->paramconstraints + i,
-                                                       CLASSREF_OR_CLASSINFO(paramtypes[i+instancecount].classref),
-                                                       mode,
-                                                       resolveLinkageError);
-                                       if (checkresult != resolveSucceeded)
-                                               return (bool) checkresult;
-                               }
-                       }
-               }
-
-               /* check protected access */
-
-               if (((mi->flags & ACC_PROTECTED) != 0) && !SAME_PACKAGE(declarer,referer))
-               {
-                       checkresult = resolve_and_check_subtype_set(ref->referermethod,
-                                       &(ref->instancetypes),
-                                       CLASSREF_OR_CLASSINFO(referer),
-                                       mode,
-                                       resolveIllegalAccessError);
-                       if (checkresult != resolveSucceeded)
-                               return (bool) checkresult;
-               }
-       }
-#endif /* ENABLE_VERIFIER */
-
-       /* succeed */
-       *result = mi;
-       return true;
-}
-
-/* resolve_method_eager ********************************************************
-   Resolve an unresolved method reference eagerly.
-  
-   IN:
-       ref..............struct containing the reference
-   
-   RETURN VALUE:
-       methodinfo * to the method, or
-          NULL if an exception has been thrown
-   
-*******************************************************************************/
-
-methodinfo * resolve_method_eager(unresolved_method *ref)
-{
-       methodinfo *mi;
-
-       if (!resolve_method(ref,resolveEager,&mi))
-               return NULL;
-
-       return mi;
-}
-
-/******************************************************************************/
-/* CREATING THE DATA STRUCTURES                                               */
-/******************************************************************************/
-
-#ifdef ENABLE_VERIFIER
-static bool unresolved_subtype_set_from_typeinfo(classinfo *referer,
-                                                                                                methodinfo *refmethod,
-                                                                                                unresolved_subtype_set *stset,
-                                                                                                typeinfo_t *tinfo,
-                                                                                                utf *declaredclassname)
-{
-       int count;
-       int i;
-
-       assert(stset);
-       assert(tinfo);
-
-#ifdef RESOLVE_VERBOSE
-       printf("unresolved_subtype_set_from_typeinfo\n");
-#ifdef TYPEINFO_DEBUG
-       typeinfo_print(stdout,tinfo,4);
-#endif
-       printf("    declared classname:");utf_fprint_printable_ascii(stdout,declaredclassname);
-       printf("\n");
-#endif
-
-       if (TYPEINFO_IS_PRIMITIVE(*tinfo)) {
-               exceptions_throw_verifyerror(refmethod,
-                               "Invalid use of returnAddress");
-               return false;
-       }
-
-       if (TYPEINFO_IS_NEWOBJECT(*tinfo)) {
-               exceptions_throw_verifyerror(refmethod,
-                               "Invalid use of uninitialized object");
-               return false;
-       }
-
-       /* the nulltype is always assignable */
-       if (TYPEINFO_IS_NULLTYPE(*tinfo))
-               goto empty_set;
-
-       /* every type is assignable to (BOOTSTRAP)java.lang.Object */
-       if (declaredclassname == utf_java_lang_Object
-                       && referer->classloader == NULL) /* XXX do loading constraints make the second check obsolete? */
-       {
-               goto empty_set;
-       }
-
-       if (tinfo->merged) {
-               count = tinfo->merged->count;
-               stset->subtyperefs = MNEW(classref_or_classinfo,count + 1);
-               for (i=0; i<count; ++i) {
-                       classref_or_classinfo c = tinfo->merged->list[i];
-                       if (tinfo->dimension > 0) {
-                               /* a merge of array types */
-                               /* the merged list contains the possible _element_ types, */
-                               /* so we have to create array types with these elements.  */
-                               if (IS_CLASSREF(c)) {
-                                       c.ref = class_get_classref_multiarray_of(tinfo->dimension,c.ref);
-                               }
-                               else {
-                                       c.cls = class_multiarray_of(tinfo->dimension,c.cls,false);
-                               }
-                       }
-                       stset->subtyperefs[i] = c;
-               }
-               stset->subtyperefs[count].any = NULL; /* terminate */
-       }
-       else {
-               if ((IS_CLASSREF(tinfo->typeclass)
-                                       ? tinfo->typeclass.ref->name
-                                       : tinfo->typeclass.cls->name) == declaredclassname)
-               {
-                       /* the class names are the same */
-                   /* equality is guaranteed by the loading constraints */
-                       goto empty_set;
-               }
-               else {
-                       stset->subtyperefs = MNEW(classref_or_classinfo,1 + 1);
-                       stset->subtyperefs[0] = tinfo->typeclass;
-                       stset->subtyperefs[1].any = NULL; /* terminate */
-               }
-       }
-
-       return true;
-
-empty_set:
-       UNRESOLVED_SUBTYPE_SET_EMTPY(*stset);
-       return true;
-}
-#endif /* ENABLE_VERIFIER */
-
-/* create_unresolved_class *****************************************************
-   Create an unresolved_class struct for the given class reference
-  
-   IN:
-          refmethod........the method triggering the resolution (if any)
-          classref.........the class reference
-          valuetype........value type to check against the resolved class
-                                               may be NULL, if no typeinfo is available
-
-   RETURN VALUE:
-       a pointer to a new unresolved_class struct, or
-          NULL if an exception has been thrown
-
-*******************************************************************************/
-
-#ifdef ENABLE_VERIFIER
-unresolved_class * create_unresolved_class(methodinfo *refmethod,
-                                                                                  constant_classref *classref,
-                                                                                  typeinfo_t *valuetype)
-{
-       unresolved_class *ref;
-
-#ifdef RESOLVE_VERBOSE
-       printf("create_unresolved_class\n");
-       printf("    referer: ");utf_fprint_printable_ascii(stdout,classref->referer->name);fputc('\n',stdout);
-       if (refmethod) {
-               printf("    rmethod: ");utf_fprint_printable_ascii(stdout,refmethod->name);fputc('\n',stdout);
-               printf("    rmdesc : ");utf_fprint_printable_ascii(stdout,refmethod->descriptor);fputc('\n',stdout);
-       }
-       printf("    name   : ");utf_fprint_printable_ascii(stdout,classref->name);fputc('\n',stdout);
-#endif
-
-       ref = NEW(unresolved_class);
-       ref->classref = classref;
-       ref->referermethod = refmethod;
-
-       if (valuetype) {
-               if (!unresolved_subtype_set_from_typeinfo(classref->referer,refmethod,
-                                       &(ref->subtypeconstraints),valuetype,classref->name))
-                       return NULL;
-       }
-       else {
-               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->subtypeconstraints);
-       }
-
-       return ref;
-}
-#endif /* ENABLE_VERIFIER */
-
-/* resolve_create_unresolved_field *********************************************
-   Create an unresolved_field struct for the given field access instruction
-  
-   IN:
-       referer..........the class containing the reference
-          refmethod........the method triggering the resolution (if any)
-          iptr.............the {GET,PUT}{FIELD,STATIC}{,CONST} instruction
-
-   RETURN VALUE:
-       a pointer to a new unresolved_field struct, or
-          NULL if an exception has been thrown
-
-*******************************************************************************/
-
-unresolved_field * resolve_create_unresolved_field(classinfo *referer,
-                                                                                                  methodinfo *refmethod,
-                                                                                                  instruction *iptr)
-{
-       unresolved_field *ref;
-       constant_FMIref *fieldref = NULL;
-
-#ifdef RESOLVE_VERBOSE
-       printf("create_unresolved_field\n");
-       printf("    referer: ");utf_fprint_printable_ascii(stdout,referer->name);fputc('\n',stdout);
-       printf("    rmethod: ");utf_fprint_printable_ascii(stdout,refmethod->name);fputc('\n',stdout);
-       printf("    rmdesc : ");utf_fprint_printable_ascii(stdout,refmethod->descriptor);fputc('\n',stdout);
-#endif
-
-       ref = NEW(unresolved_field);
-       ref->flags = 0;
-       ref->referermethod = refmethod;
-       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->valueconstraints);
-
-       switch (iptr->opc) {
-               case ICMD_PUTFIELD:
-                       ref->flags |= RESOLVE_PUTFIELD;
-                       break;
-
-               case ICMD_PUTFIELDCONST:
-                       ref->flags |= RESOLVE_PUTFIELD;
-                       break;
-
-               case ICMD_PUTSTATIC:
-                       ref->flags |= RESOLVE_PUTFIELD | RESOLVE_STATIC;
-                       break;
-
-               case ICMD_PUTSTATICCONST:
-                       ref->flags |= RESOLVE_PUTFIELD | RESOLVE_STATIC;
-                       break;
-
-               case ICMD_GETFIELD:
-                       break;
-
-               case ICMD_GETSTATIC:
-                       ref->flags |= RESOLVE_STATIC;
-                       break;
-
-#if !defined(NDEBUG)
-               default:
-                       assert(false);
-#endif
-       }
-
-       fieldref = iptr->sx.s23.s3.fmiref;
-
-       assert(fieldref);
-
-#ifdef RESOLVE_VERBOSE
-/*     printf("    class  : ");utf_fprint_printable_ascii(stdout,fieldref->p.classref->name);fputc('\n',stdout);*/
-       printf("    name   : ");utf_fprint_printable_ascii(stdout,fieldref->name);fputc('\n',stdout);
-       printf("    desc   : ");utf_fprint_printable_ascii(stdout,fieldref->descriptor);fputc('\n',stdout);
-       printf("    type   : ");descriptor_debug_print_typedesc(stdout,fieldref->parseddesc.fd);
-       fputc('\n',stdout);
-#endif
-
-       ref->fieldref = fieldref;
-
-       return ref;
-}
-
-/* resolve_constrain_unresolved_field ******************************************
-   Record subtype constraints for a field access.
-  
-   IN:
-       ref..............the unresolved_field structure of the access
-       referer..........the class containing the reference
-          refmethod........the method triggering the resolution (if any)
-          instanceti.......instance typeinfo, if available
-          valueti..........value typeinfo, if available
-
-   RETURN VALUE:
-       true.............everything ok
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-bool resolve_constrain_unresolved_field(unresolved_field *ref,
-                                                                               classinfo *referer, 
-                                                                               methodinfo *refmethod,
-                                                                           typeinfo_t *instanceti,
-                                                                           typeinfo_t *valueti)
-{
-       constant_FMIref *fieldref;
-       int type;
-       typeinfo_t tinfo;
-       typedesc *fd;
-
-       assert(ref);
-
-       fieldref = ref->fieldref;
-       assert(fieldref);
-
-#ifdef RESOLVE_VERBOSE
-       printf("constrain_unresolved_field\n");
-       printf("    referer: ");utf_fprint_printable_ascii(stdout,referer->name);fputc('\n',stdout);
-       printf("    rmethod: ");utf_fprint_printable_ascii(stdout,refmethod->name);fputc('\n',stdout);
-       printf("    rmdesc : ");utf_fprint_printable_ascii(stdout,refmethod->descriptor);fputc('\n',stdout);
-/*     printf("    class  : ");utf_fprint_printable_ascii(stdout,fieldref->p.classref->name);fputc('\n',stdout); */
-       printf("    name   : ");utf_fprint_printable_ascii(stdout,fieldref->name);fputc('\n',stdout);
-       printf("    desc   : ");utf_fprint_printable_ascii(stdout,fieldref->descriptor);fputc('\n',stdout);
-       printf("    type   : ");descriptor_debug_print_typedesc(stdout,fieldref->parseddesc.fd);
-       fputc('\n',stdout);
-#endif
-
-       assert(instanceti || ((ref->flags & RESOLVE_STATIC) != 0));
-       fd = fieldref->parseddesc.fd;
-       assert(fd);
-
-       /* record subtype constraints for the instance type, if any */
-       if (instanceti) {
-               typeinfo_t *insttip;
-
-               /* The instanceslot must contain a reference to a non-array type */
-               if (!TYPEINFO_IS_REFERENCE(*instanceti)) {
-                       exceptions_throw_verifyerror(refmethod, 
-                                       "illegal instruction: field access on non-reference");
-                       return false;
-               }
-               if (TYPEINFO_IS_ARRAY(*instanceti)) {
-                       exceptions_throw_verifyerror(refmethod, 
-                                       "illegal instruction: field access on array");
-                       return false;
-               }
-
-               if (((ref->flags & RESOLVE_PUTFIELD) != 0) &&
-                               TYPEINFO_IS_NEWOBJECT(*instanceti))
-               {
-                       /* The instruction writes a field in an uninitialized object. */
-                       /* This is only allowed when a field of an uninitialized 'this' object is */
-                       /* written inside an initialization method                                */
-
-                       classinfo *initclass;
-                       instruction *ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*instanceti);
-
-                       if (ins != NULL) {
-                               exceptions_throw_verifyerror(refmethod, 
-                                               "accessing field of uninitialized object");
-                               return false;
-                       }
-                       /* XXX check that class of field == refmethod->clazz */
-                       initclass = refmethod->clazz; /* XXX classrefs */
-                       assert(initclass->state & CLASS_LOADED);
-                       assert(initclass->state & CLASS_LINKED);
-
-                       typeinfo_init_classinfo(&tinfo, initclass);
-                       insttip = &tinfo;
-               }
-               else {
-                       insttip = instanceti;
-               }
-               if (!unresolved_subtype_set_from_typeinfo(referer, refmethod,
-                                       &(ref->instancetypes), insttip, 
-                                       FIELDREF_CLASSNAME(fieldref)))
-                       return false;
-       }
-       else {
-               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->instancetypes);
-       }
-
-       /* record subtype constraints for the value type, if any */
-       type = fd->type;
-       if (type == TYPE_ADR && ((ref->flags & RESOLVE_PUTFIELD) != 0)) {
-               assert(valueti);
-               if (!unresolved_subtype_set_from_typeinfo(referer, refmethod,
-                                       &(ref->valueconstraints), valueti, 
-                                       fieldref->parseddesc.fd->classref->name))
-                       return false;
-       }
-       else {
-               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->valueconstraints);
-       }
-
-       return true;
-}
-#endif /* ENABLE_VERIFIER */
-
-/* resolve_create_unresolved_method ********************************************
-   Create an unresolved_method struct for the given method invocation
-  
-   IN:
-       referer..........the class containing the reference
-          refmethod........the method triggering the resolution (if any)
-          iptr.............the INVOKE* instruction
-
-   RETURN VALUE:
-       a pointer to a new unresolved_method struct, or
-          NULL if an exception has been thrown
-
-*******************************************************************************/
-
-unresolved_method * resolve_create_unresolved_method(classinfo *referer,
-                                                                                                        methodinfo *refmethod,
-                                                                                                        constant_FMIref *methodref,
-                                                                                                        bool invokestatic,
-                                                                                                        bool invokespecial)
-{
-       unresolved_method *ref;
-
-       assert(methodref);
-
-#ifdef RESOLVE_VERBOSE
-       printf("create_unresolved_method\n");
-       printf("    referer: ");utf_fprint_printable_ascii(stdout,referer->name);fputc('\n',stdout);
-       printf("    rmethod: ");utf_fprint_printable_ascii(stdout,refmethod->name);fputc('\n',stdout);
-       printf("    rmdesc : ");utf_fprint_printable_ascii(stdout,refmethod->descriptor);fputc('\n',stdout);
-       printf("    name   : ");utf_fprint_printable_ascii(stdout,methodref->name);fputc('\n',stdout);
-       printf("    desc   : ");utf_fprint_printable_ascii(stdout,methodref->descriptor);fputc('\n',stdout);
-#endif
-
-       /* allocate params if necessary */
-       if (!methodref->parseddesc.md->params)
-               if (!descriptor_params_from_paramtypes(methodref->parseddesc.md,
-                                       (invokestatic) ? ACC_STATIC : ACC_NONE))
-                       return NULL;
-
-       /* create the data structure */
-       ref = NEW(unresolved_method);
-       ref->flags = ((invokestatic) ? RESOLVE_STATIC : 0)
-                          | ((invokespecial) ? RESOLVE_SPECIAL : 0);
-       ref->referermethod = refmethod;
-       ref->methodref = methodref;
-       ref->paramconstraints = NULL;
-       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->instancetypes);
-
-       return ref;
-}
-
-
-/* resolve_constrain_unresolved_method_instance ********************************
-   Record subtype constraints for the instance argument of a method call.
-  
-   IN:
-       ref..............the unresolved_method structure of the call
-       referer..........the class containing the reference
-          refmethod........the method triggering the resolution (if any)
-          iptr.............the INVOKE* instruction
-
-   RETURN VALUE:
-       true.............everything ok
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-bool resolve_constrain_unresolved_method_instance(unresolved_method *ref,
-                                                                                                 methodinfo *refmethod,
-                                                                                                 typeinfo_t *instanceti,
-                                                                                                 bool invokespecial)
-{
-       constant_FMIref   *methodref;
-       constant_classref *instanceref;
-       typeinfo_t           tinfo;
-       typeinfo_t          *tip;
-
-       assert(ref);
-       methodref = ref->methodref;
-       assert(methodref);
-
-       /* XXX clean this up */
-       instanceref = IS_FMIREF_RESOLVED(methodref)
-               ? class_get_self_classref(methodref->p.method->clazz)
-               : methodref->p.classref;
-
-#ifdef RESOLVE_VERBOSE
-       printf("resolve_constrain_unresolved_method_instance\n");
-       printf("    rmethod: "); method_println(refmethod);
-       printf("    mref   : "); method_methodref_println(methodref);
-#endif
-
-       /* record subtype constraints for the instance type, if any */
-
-       if (invokespecial && TYPEINFO_IS_NEWOBJECT(*instanceti))
-       {   /* XXX clean up */
-               instruction *ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*instanceti);
-               classref_or_classinfo initclass = (ins) ? ins[-1].sx.val.c
-                                                                        : CLASSREF_OR_CLASSINFO(refmethod->clazz);
-               tip = &tinfo;
-               if (!typeinfo_init_class(tip, initclass))
-                       return false;
-       }
-       else {
-               tip = instanceti;
-       }
-
-       if (!unresolved_subtype_set_from_typeinfo(refmethod->clazz, refmethod,
-                               &(ref->instancetypes),tip,instanceref->name))
-               return false;
-
-       return true;
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-
-/* resolve_constrain_unresolved_method_params  *********************************
-   Record subtype constraints for the non-instance arguments of a method call.
-  
-   IN:
-       jd...............current jitdata (for looking up variables)
-       ref..............the unresolved_method structure of the call
-          refmethod........the method triggering the resolution (if any)
-          iptr.............the INVOKE* instruction
-
-   RETURN VALUE:
-       true.............everything ok
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-bool resolve_constrain_unresolved_method_params(jitdata *jd,
-                                                                                               unresolved_method *ref,
-                                                                                               methodinfo *refmethod,
-                                                                                               instruction *iptr)
-{
-       constant_FMIref *methodref;
-       varinfo *param;
-       methoddesc *md;
-       int i,j;
-       int type;
-       int instancecount;
-
-       assert(ref);
-       methodref = ref->methodref;
-       assert(methodref);
-       md = methodref->parseddesc.md;
-       assert(md);
-       assert(md->params != NULL);
-
-#ifdef RESOLVE_VERBOSE
-       printf("resolve_constrain_unresolved_method_params\n");
-       printf("    rmethod: "); method_println(refmethod);
-       printf("    mref   : "); method_methodref_println(methodref);
-#endif
-
-       instancecount = (ref->flags & RESOLVE_STATIC) ? 0 : 1;
-
-       /* record subtype constraints for the parameter types, if any */
-
-       for (i=md->paramcount-1-instancecount; i>=0; --i) {
-               param = VAR(iptr->sx.s23.s2.args[i+instancecount]);
-               type = md->paramtypes[i+instancecount].type;
-
-               assert(param);
-               assert(type == param->type);
-
-               if (type == TYPE_ADR) {
-                       if (!ref->paramconstraints) {
-                               ref->paramconstraints = MNEW(unresolved_subtype_set,md->paramcount);
-                               for (j=md->paramcount-1-instancecount; j>i; --j)
-                                       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[j]);
-                       }
-                       assert(ref->paramconstraints);
-                       if (!unresolved_subtype_set_from_typeinfo(refmethod->clazz, refmethod,
-                                               ref->paramconstraints + i,&(param->typeinfo),
-                                               md->paramtypes[i+instancecount].classref->name))
-                               return false;
-               }
-               else {
-                       if (ref->paramconstraints)
-                               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[i]);
-               }
-       }
-
-       return true;
-}
-#endif /* ENABLE_VERIFIER */
-
-
-/* resolve_constrain_unresolved_method_params_stackbased ***********************
-   Record subtype constraints for the non-instance arguments of a method call.
-  
-   IN:
-       ref..............the unresolved_method structure of the call
-          refmethod........the method triggering the resolution (if any)
-          stack............TOS before the INVOKE instruction
-
-   RETURN VALUE:
-       true.............everything ok
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-bool resolve_constrain_unresolved_method_params_stackbased(
-               unresolved_method *ref,
-               methodinfo *refmethod,
-               typedescriptor_t *stack)
-{
-       constant_FMIref *methodref;
-       typedescriptor_t *param;
-       methoddesc *md;
-       int i,j;
-       int type;
-       int instancecount;
-
-       assert(ref);
-       methodref = ref->methodref;
-       assert(methodref);
-       md = methodref->parseddesc.md;
-       assert(md);
-       assert(md->params != NULL);
-
-#ifdef RESOLVE_VERBOSE
-       printf("resolve_constrain_unresolved_method_params_stackbased\n");
-       printf("    rmethod: "); method_println(refmethod);
-       printf("    mref   : "); method_methodref_println(methodref);
-#endif
-
-       instancecount = (ref->flags & RESOLVE_STATIC) ? 0 : 1;
-
-       /* record subtype constraints for the parameter types, if any */
-
-       param = stack - (md->paramslots - 1 - instancecount);
-
-       for (i = instancecount; i < md->paramcount; ++i) {
-               type = md->paramtypes[i].type;
-
-               assert(type == param->type);
-
-               if (type == TYPE_ADR) {
-                       if (!ref->paramconstraints) {
-                               ref->paramconstraints = MNEW(unresolved_subtype_set,md->paramcount);
-                               for (j = 0; j < i - instancecount; ++j)
-                                       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[j]);
-                       }
-                       assert(ref->paramconstraints);
-                       if (!unresolved_subtype_set_from_typeinfo(refmethod->clazz, refmethod,
-                                               ref->paramconstraints + i - instancecount,&(param->typeinfo),
-                                               md->paramtypes[i].classref->name))
-                               return false;
-               }
-               else {
-                       if (ref->paramconstraints)
-                               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[i]);
-               }
-
-               param += (IS_2_WORD_TYPE(type)) ? 2 : 1;
-       }
-
-       return true;
-}
-#endif /* ENABLE_VERIFIER */
-
-
-/******************************************************************************/
-/* FREEING MEMORY                                                             */
-/******************************************************************************/
-
-#ifdef ENABLE_VERIFIER
-inline static void unresolved_subtype_set_free_list(classref_or_classinfo *list)
-{
-       if (list) {
-               classref_or_classinfo *p = list;
-
-               /* this is silly. we *only* need to count the elements for MFREE */
-               while ((p++)->any)
-                       ;
-               MFREE(list,classref_or_classinfo,(p - list));
-       }
-}
-#endif /* ENABLE_VERIFIER */
-
-/* unresolved_class_free *******************************************************
-   Free the memory used by an unresolved_class
-  
-   IN:
-       ref..............the unresolved_class
-
-*******************************************************************************/
-
-void unresolved_class_free(unresolved_class *ref)
-{
-       assert(ref);
-
-#ifdef ENABLE_VERIFIER
-       unresolved_subtype_set_free_list(ref->subtypeconstraints.subtyperefs);
-#endif
-       FREE(ref,unresolved_class);
-}
-
-/* unresolved_field_free *******************************************************
-   Free the memory used by an unresolved_field
-  
-   IN:
-       ref..............the unresolved_field
-
-*******************************************************************************/
-
-void unresolved_field_free(unresolved_field *ref)
-{
-       assert(ref);
-
-#ifdef ENABLE_VERIFIER
-       unresolved_subtype_set_free_list(ref->instancetypes.subtyperefs);
-       unresolved_subtype_set_free_list(ref->valueconstraints.subtyperefs);
-#endif
-       FREE(ref,unresolved_field);
-}
-
-/* unresolved_method_free ******************************************************
-   Free the memory used by an unresolved_method
-  
-   IN:
-       ref..............the unresolved_method
-
-*******************************************************************************/
-
-void unresolved_method_free(unresolved_method *ref)
-{
-       assert(ref);
-
-#ifdef ENABLE_VERIFIER
-       unresolved_subtype_set_free_list(ref->instancetypes.subtyperefs);
-       if (ref->paramconstraints) {
-               int i;
-               int count = ref->methodref->parseddesc.md->paramcount;
-
-               for (i=0; i<count; ++i)
-                       unresolved_subtype_set_free_list(ref->paramconstraints[i].subtyperefs);
-               MFREE(ref->paramconstraints,unresolved_subtype_set,count);
-       }
-#endif
-       FREE(ref,unresolved_method);
-}
-
-/******************************************************************************/
-/* DEBUG DUMPS                                                                */
-/******************************************************************************/
-
-#if !defined(NDEBUG)
-
-/* unresolved_subtype_set_debug_dump *******************************************
-   Print debug info for unresolved_subtype_set to stream
-  
-   IN:
-       stset............the unresolved_subtype_set
-          file.............the stream
-
-*******************************************************************************/
-
-void unresolved_subtype_set_debug_dump(unresolved_subtype_set *stset,FILE *file)
-{
-       classref_or_classinfo *p;
-
-       if (SUBTYPESET_IS_EMPTY(*stset)) {
-               fprintf(file,"        (empty)\n");
-       }
-       else {
-               p = stset->subtyperefs;
-               for (;p->any; ++p) {
-                       if (IS_CLASSREF(*p)) {
-                               fprintf(file,"        ref: ");
-                               utf_fprint_printable_ascii(file,p->ref->name);
-                       }
-                       else {
-                               fprintf(file,"        cls: ");
-                               utf_fprint_printable_ascii(file,p->cls->name);
-                       }
-                       fputc('\n',file);
-               }
-       }
-}
-
-/* unresolved_class_debug_dump *************************************************
-   Print debug info for unresolved_class to stream
-  
-   IN:
-       ref..............the unresolved_class
-          file.............the stream
-
-*******************************************************************************/
-
-void unresolved_class_debug_dump(unresolved_class *ref,FILE *file)
-{
-       fprintf(file,"unresolved_class(%p):\n",(void *)ref);
-       if (ref) {
-               fprintf(file,"    referer   : ");
-               utf_fprint_printable_ascii(file,ref->classref->referer->name); fputc('\n',file);
-               fprintf(file,"    refmethod : ");
-               utf_fprint_printable_ascii(file,ref->referermethod->name); fputc('\n',file);
-               fprintf(file,"    refmethodd: ");
-               utf_fprint_printable_ascii(file,ref->referermethod->descriptor); fputc('\n',file);
-               fprintf(file,"    classname : ");
-               utf_fprint_printable_ascii(file,ref->classref->name); fputc('\n',file);
-               fprintf(file,"    subtypeconstraints:\n");
-               unresolved_subtype_set_debug_dump(&(ref->subtypeconstraints),file);
-       }
-}
-
-/* unresolved_field_debug_dump *************************************************
-   Print debug info for unresolved_field to stream
-  
-   IN:
-       ref..............the unresolved_field
-          file.............the stream
-
-*******************************************************************************/
-
-void unresolved_field_debug_dump(unresolved_field *ref,FILE *file)
-{
-       fprintf(file,"unresolved_field(%p):\n",(void *)ref);
-       if (ref) {
-               fprintf(file,"    referer   : ");
-               utf_fprint_printable_ascii(file,ref->referermethod->clazz->name); fputc('\n',file);
-               fprintf(file,"    refmethod : ");
-               utf_fprint_printable_ascii(file,ref->referermethod->name); fputc('\n',file);
-               fprintf(file,"    refmethodd: ");
-               utf_fprint_printable_ascii(file,ref->referermethod->descriptor); fputc('\n',file);
-               fprintf(file,"    classname : ");
-               utf_fprint_printable_ascii(file,FIELDREF_CLASSNAME(ref->fieldref)); fputc('\n',file);
-               fprintf(file,"    name      : ");
-               utf_fprint_printable_ascii(file,ref->fieldref->name); fputc('\n',file);
-               fprintf(file,"    descriptor: ");
-               utf_fprint_printable_ascii(file,ref->fieldref->descriptor); fputc('\n',file);
-               fprintf(file,"    parseddesc: ");
-               descriptor_debug_print_typedesc(file,ref->fieldref->parseddesc.fd); fputc('\n',file);
-               fprintf(file,"    flags     : %04x\n",ref->flags);
-               fprintf(file,"    instancetypes:\n");
-               unresolved_subtype_set_debug_dump(&(ref->instancetypes),file);
-               fprintf(file,"    valueconstraints:\n");
-               unresolved_subtype_set_debug_dump(&(ref->valueconstraints),file);
-       }
-}
-
-/* unresolved_method_debug_dump ************************************************
-   Print debug info for unresolved_method to stream
-  
-   IN:
-       ref..............the unresolved_method
-          file.............the stream
-
-*******************************************************************************/
-
-void unresolved_method_debug_dump(unresolved_method *ref,FILE *file)
-{
-       int i;
-
-       fprintf(file,"unresolved_method(%p):\n",(void *)ref);
-       if (ref) {
-               fprintf(file,"    referer   : ");
-               utf_fprint_printable_ascii(file,ref->referermethod->clazz->name); fputc('\n',file);
-               fprintf(file,"    refmethod : ");
-               utf_fprint_printable_ascii(file,ref->referermethod->name); fputc('\n',file);
-               fprintf(file,"    refmethodd: ");
-               utf_fprint_printable_ascii(file,ref->referermethod->descriptor); fputc('\n',file);
-               fprintf(file,"    classname : ");
-               utf_fprint_printable_ascii(file,METHODREF_CLASSNAME(ref->methodref)); fputc('\n',file);
-               fprintf(file,"    name      : ");
-               utf_fprint_printable_ascii(file,ref->methodref->name); fputc('\n',file);
-               fprintf(file,"    descriptor: ");
-               utf_fprint_printable_ascii(file,ref->methodref->descriptor); fputc('\n',file);
-               fprintf(file,"    parseddesc: ");
-               descriptor_debug_print_methoddesc(file,ref->methodref->parseddesc.md); fputc('\n',file);
-               fprintf(file,"    flags     : %04x\n",ref->flags);
-               fprintf(file,"    instancetypes:\n");
-               unresolved_subtype_set_debug_dump(&(ref->instancetypes),file);
-               fprintf(file,"    paramconstraints:\n");
-               if (ref->paramconstraints) {
-                       for (i=0; i<ref->methodref->parseddesc.md->paramcount; ++i) {
-                               fprintf(file,"      param %d:\n",i);
-                               unresolved_subtype_set_debug_dump(ref->paramconstraints + i,file);
-                       }
-               }
-               else {
-                       fprintf(file,"      (empty)\n");
-               }
-       }
-}
-#endif /* !defined(NDEBUG) */
-
-
-/*
- * 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/resolve.cpp b/src/vm/resolve.cpp
new file mode 100644 (file)
index 0000000..d4b4e96
--- /dev/null
@@ -0,0 +1,3164 @@
+/* src/vm/resolve.cpp - resolving classes/interfaces/fields/methods
+
+   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 "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "vm/access.hpp"
+#include "vm/classcache.hpp"
+#include "vm/descriptor.h"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/linker.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/primitive.hpp"
+#include "vm/resolve.hpp"
+
+#include "vm/jit/jit.hpp"
+#include "vm/jit/verify/typeinfo.hpp"
+
+
+/******************************************************************************/
+/* DEBUG HELPERS                                                              */
+/******************************************************************************/
+
+/*#define RESOLVE_VERBOSE*/
+
+/* resolve_handle_pending_exception ********************************************
+
+   Convert a pending ClassNotFoundException into a
+   NoClassDefFoundError if requested.
+
+   See: hotspot/src/share/vm/classfile/systemDictionary.cpp
+   (handle_resolution_exception)
+
+   ARGUMENTS:
+       classname .... name of the class currently resolved
+       throwError ... if true throw a NoClassDefFoundError instead of
+                      a ClassNotFoundException
+
+*******************************************************************************/
+
+void resolve_handle_pending_exception(bool throwError)
+{
+       java_handle_t *e;
+
+       /* Get the current exception. */
+
+       e = exceptions_get_exception();
+
+       if (e != NULL) {
+               if (throwError == true) {
+                       /* Convert ClassNotFoundException to
+                          NoClassDefFoundError. */
+
+                       if (builtin_instanceof(e, class_java_lang_ClassNotFoundException)) {
+                               /* Clear exception, because we are calling Java code
+                                  again. */
+
+                               exceptions_clear_exception();
+
+                               /* create new error */
+
+                               exceptions_throw_noclassdeffounderror_cause(e);
+                       }
+                       else {
+                               return;
+                       }
+               }
+               else {
+                       /* An exception conversion was not requested.  Simply
+                          return. */
+
+                       return;
+               }
+       }
+}
+
+
+/******************************************************************************/
+/* CLASS RESOLUTION                                                           */
+/******************************************************************************/
+
+/* resolve_class_from_name *****************************************************
+   Resolve a symbolic class reference
+  
+   IN:
+       referer..........the class containing the reference
+       refmethod........the method from which resolution was triggered
+                        (may be NULL if not applicable)
+       classname........class name to resolve
+       mode.............mode of resolution:
+                            resolveLazy...only resolve if it does not
+                                          require loading classes
+                            resolveEager..load classes if necessary
+          checkaccess......if true, access rights to the class are checked
+          link.............if true, guarantee that the returned class, if any,
+                           has been linked
+  
+   OUT:
+       *result..........set to result of resolution, or to NULL if
+                        the reference has not been resolved
+                        In the case of an exception, *result is
+                        guaranteed to be set to NULL.
+  
+   RETURN VALUE:
+       true.............everything ok 
+                        (*result may still be NULL for resolveLazy)
+       false............an exception has been thrown
+
+   NOTE:
+       The returned class is *not* guaranteed to be linked!
+          (It is guaranteed to be loaded, though.)
+   
+*******************************************************************************/
+
+bool resolve_class_from_name(classinfo *referer,
+                                                        methodinfo *refmethod,
+                                                        utf *classname,
+                                                        resolve_mode_t mode,
+                                                        bool checkaccess,
+                                                        bool link,
+                                                        classinfo **result)
+{
+       classinfo *cls;
+       char      *utf_ptr;
+       int        len;
+       char      *msg;
+       s4         msglen;
+       utf       *u;
+
+       assert(result);
+       assert(referer);
+       assert(classname);
+       assert(mode == resolveLazy || mode == resolveEager);
+       
+       *result = NULL;
+
+#ifdef RESOLVE_VERBOSE
+       printf("resolve_class_from_name(");
+       utf_fprint_printable_ascii(stdout,referer->name);
+       printf(",%p,",(void*)referer->classloader);
+       utf_fprint_printable_ascii(stdout,classname);
+       printf(",%d,%d)\n",(int)checkaccess,(int)link);
+#endif
+
+       /* lookup if this class has already been loaded */
+
+       cls = classcache_lookup(referer->classloader, classname);
+
+#ifdef RESOLVE_VERBOSE
+       printf("    lookup result: %p\n",(void*)cls);
+#endif
+
+       if (!cls) {
+               /* resolve array types */
+
+               if (classname->text[0] == '[') {
+                       utf_ptr = classname->text + 1;
+                       len = classname->blength - 1;
+
+                       /* classname is an array type name */
+
+                       switch (*utf_ptr) {
+                               case 'L':
+                                       utf_ptr++;
+                                       len -= 2;
+                                       /* FALLTHROUGH */
+                               case '[':
+                                       /* the component type is a reference type */
+                                       /* resolve the component type */
+                                       if (!resolve_class_from_name(referer,refmethod,
+                                                                          utf_new(utf_ptr,len),
+                                                                          mode,checkaccess,link,&cls))
+                                               return false; /* exception */
+                                       if (!cls) {
+                                               assert(mode == resolveLazy);
+                                               return true; /* be lazy */
+                                       }
+                                       /* create the array class */
+                                       cls = class_array_of(cls,false);
+                                       if (!cls)
+                                               return false; /* exception */
+                       }
+               }
+               else {
+                       /* the class has not been loaded, yet */
+                       if (mode == resolveLazy)
+                               return true; /* be lazy */
+               }
+
+#ifdef RESOLVE_VERBOSE
+               printf("    loading...\n");
+#endif
+
+               /* load the class */
+
+               if (cls == NULL) {
+                       cls = load_class_from_classloader(classname, referer->classloader);
+
+                       if (cls == NULL)
+                               return false;
+               }
+       }
+
+       /* the class is now loaded */
+       assert(cls);
+       assert(cls->state & CLASS_LOADED);
+
+#ifdef RESOLVE_VERBOSE
+       printf("    checking access rights...\n");
+#endif
+       
+       /* check access rights of referer to refered class */
+
+       if (checkaccess && !access_is_accessible_class(referer,cls)) {
+               msglen =
+                       utf_bytes(cls->name) +
+                       utf_bytes(referer->name) +
+                       100;
+
+               msg = MNEW(char, msglen);
+
+               strcpy(msg, "class is not accessible (");
+               utf_cat_classname(msg, cls->name);
+               strcat(msg, " from ");
+               utf_cat_classname(msg, referer->name);
+               strcat(msg, ")");
+
+               u = utf_new_char(msg);
+
+               MFREE(msg, char, msglen);
+
+               exceptions_throw_illegalaccessexception(u);
+
+               return false; /* exception */
+       }
+
+       /* link the class if necessary */
+       if (link) {
+               if (!(cls->state & CLASS_LINKED))
+                       if (!link_class(cls))
+                               return false; /* exception */
+
+               assert(cls->state & CLASS_LINKED);
+       }
+
+       /* resolution succeeds */
+#ifdef RESOLVE_VERBOSE
+       printf("    success.\n");
+#endif
+       *result = cls;
+       return true;
+}
+
+/* resolve_classref ************************************************************
+   Resolve a symbolic class reference
+  
+   IN:
+       refmethod........the method from which resolution was triggered
+                        (may be NULL if not applicable)
+       ref..............class reference
+       mode.............mode of resolution:
+                            resolveLazy...only resolve if it does not
+                                          require loading classes
+                            resolveEager..load classes if necessary
+          checkaccess......if true, access rights to the class are checked
+          link.............if true, guarantee that the returned class, if any,
+                           has been linked
+  
+   OUT:
+       *result..........set to result of resolution, or to NULL if
+                        the reference has not been resolved
+                        In the case of an exception, *result is
+                        guaranteed to be set to NULL.
+  
+   RETURN VALUE:
+       true.............everything ok 
+                        (*result may still be NULL for resolveLazy)
+       false............an exception has been thrown
+   
+*******************************************************************************/
+
+bool resolve_classref(methodinfo *refmethod,
+                                         constant_classref *ref,
+                                         resolve_mode_t mode,
+                                         bool checkaccess,
+                                         bool link,
+                                         classinfo **result)
+{
+       return resolve_classref_or_classinfo(refmethod,CLASSREF_OR_CLASSINFO(ref),mode,checkaccess,link,result);
+}
+
+/* resolve_classref_or_classinfo ***********************************************
+   Resolve a symbolic class reference if necessary
+
+   NOTE: If given, refmethod->clazz is used as the referring class.
+         Otherwise, cls.ref->referer is used.
+
+   IN:
+       refmethod........the method from which resolution was triggered
+                        (may be NULL if not applicable)
+       cls..............class reference or classinfo
+       mode.............mode of resolution:
+                            resolveLazy...only resolve if it does not
+                                          require loading classes
+                            resolveEager..load classes if necessary
+          checkaccess......if true, access rights to the class are checked
+          link.............if true, guarantee that the returned class, if any,
+                           has been linked
+  
+   OUT:
+       *result..........set to result of resolution, or to NULL if
+                        the reference has not been resolved
+                        In the case of an exception, *result is
+                        guaranteed to be set to NULL.
+  
+   RETURN VALUE:
+       true.............everything ok 
+                        (*result may still be NULL for resolveLazy)
+       false............an exception has been thrown
+   
+*******************************************************************************/
+
+bool resolve_classref_or_classinfo(methodinfo *refmethod,
+                                                                  classref_or_classinfo cls,
+                                                                  resolve_mode_t mode,
+                                                                  bool checkaccess,
+                                                                  bool link,
+                                                                  classinfo **result)
+{
+       classinfo         *c;
+       classinfo         *referer;
+       
+       assert(cls.any);
+       assert(mode == resolveEager || mode == resolveLazy);
+       assert(result);
+
+#ifdef RESOLVE_VERBOSE
+       printf("resolve_classref_or_classinfo(");
+       utf_fprint_printable_ascii(stdout,(IS_CLASSREF(cls)) ? cls.ref->name : cls.cls->name);
+       printf(",%i,%i,%i)\n",mode,(int)checkaccess,(int)link);
+#endif
+
+       *result = NULL;
+
+       if (IS_CLASSREF(cls)) {
+               /* we must resolve this reference */
+
+               /* determine which class to use as the referer */
+
+               /* Common cases are refmethod == NULL or both referring classes */
+               /* being the same, so the referer usually is cls.ref->referer.    */
+               /* There is one important case where it is not: When we do a      */
+               /* deferred assignability check to a formal argument of a method, */
+               /* we must use refmethod->clazz (the caller's class) to resolve   */
+               /* the type of the formal argument.                               */
+
+               referer = (refmethod) ? refmethod->clazz : cls.ref->referer;
+
+               if (!resolve_class_from_name(referer, refmethod, cls.ref->name,
+                                                                        mode, checkaccess, link, &c))
+                       goto return_exception;
+
+       } else {
+               /* cls has already been resolved */
+               c = cls.cls;
+               assert(c->state & CLASS_LOADED);
+       }
+       assert(c || (mode == resolveLazy));
+
+       if (!c)
+               return true; /* be lazy */
+       
+       assert(c);
+       assert(c->state & CLASS_LOADED);
+
+       if (link) {
+               if (!(c->state & CLASS_LINKED))
+                       if (!link_class(c))
+                               goto return_exception;
+
+               assert(c->state & CLASS_LINKED);
+       }
+
+       /* succeeded */
+       *result = c;
+       return true;
+
+ return_exception:
+       *result = NULL;
+       return false;
+}
+
+
+/* resolve_classref_or_classinfo_eager *****************************************
+   Resolve a symbolic class reference eagerly if necessary.
+   No attempt is made to link the class.
+
+   IN:
+       cls..............class reference or classinfo
+       checkaccess......if true, access rights to the class are checked
+  
+   RETURN VALUE:
+       classinfo *......the resolved class
+       NULL.............an exception has been thrown
+   
+*******************************************************************************/
+
+classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls,
+                                                                                          bool checkaccess)
+{
+       classinfo *c;
+
+       if (!resolve_classref_or_classinfo(NULL, cls, resolveEager, checkaccess, false, &c))
+               return NULL;
+
+       return c;
+}
+
+
+/* resolve_class_from_typedesc *************************************************
+   Return a classinfo * for the given type descriptor
+  
+   IN:
+       d................type descriptor
+          checkaccess......if true, access rights to the class are checked
+          link.............if true, guarantee that the returned class, if any,
+                           has been linked
+   OUT:
+       *result..........set to result of resolution, or to NULL if
+                        the reference has not been resolved
+                        In the case of an exception, *result is
+                        guaranteed to be set to NULL.
+  
+   RETURN VALUE:
+       true.............everything ok 
+       false............an exception has been thrown
+
+   NOTE:
+       This function always resolves eagerly.
+   
+*******************************************************************************/
+
+bool resolve_class_from_typedesc(typedesc *d, bool checkaccess, bool link, classinfo **result)
+{
+       classinfo *cls;
+       
+       assert(d);
+       assert(result);
+
+       *result = NULL;
+
+#ifdef RESOLVE_VERBOSE
+       printf("resolve_class_from_typedesc(");
+       descriptor_debug_print_typedesc(stdout,d);
+       printf(",%i,%i)\n",(int)checkaccess,(int)link);
+#endif
+
+       if (d->type == TYPE_ADR) {
+               /* a reference type */
+               assert(d->classref);
+               if (!resolve_classref_or_classinfo(NULL,CLASSREF_OR_CLASSINFO(d->classref),
+                                                                                  resolveEager,checkaccess,link,&cls))
+                       return false; /* exception */
+       }
+       else {
+               /* a primitive type */
+
+               cls = Primitive::get_class_by_type(d->primitivetype);
+
+               assert(cls->state & CLASS_LOADED);
+
+               if (!(cls->state & CLASS_LINKED))
+                       if (!link_class(cls))
+                               return false; /* exception */
+       }
+
+       assert(cls);
+       assert(cls->state & CLASS_LOADED);
+       assert(!link || (cls->state & CLASS_LINKED));
+
+#ifdef RESOLVE_VERBOSE
+       printf("    result = ");utf_fprint_printable_ascii(stdout,cls->name);printf("\n");
+#endif
+
+       *result = cls;
+       return true;
+}
+
+/******************************************************************************/
+/* SUBTYPE SET CHECKS                                                         */
+/******************************************************************************/
+
+/* resolve_subtype_check *******************************************************
+   Resolve the given types lazily and perform a subtype check
+  
+   IN:
+       refmethod........the method triggering the resolution
+       subtype..........checked to be a subtype of supertype
+          supertype........the super type to check agaings
+          mode.............mode of resolution:
+                            resolveLazy...only resolve if it does not
+                                          require loading classes
+                            resolveEager..load classes if necessary
+       error............which type of exception to throw if
+                        the test fails. May be:
+                            resolveLinkageError, or
+                            resolveIllegalAccessError
+                                               IMPORTANT: If error==resolveIllegalAccessError,
+                                               then array types are not checked.
+
+   RETURN VALUE:
+       resolveSucceeded.....the check succeeded
+       resolveDeferred......the check could not be performed due to
+                               unresolved types. (This can only happen for
+                                                       mode == resolveLazy.)
+          resolveFailed........the check failed, an exception has been thrown.
+   
+   NOTE:
+          The types are resolved first, so any
+          exception which may occurr during resolution may
+          be thrown by this function.
+   
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+static resolve_result_t resolve_subtype_check(methodinfo *refmethod,
+                                                                                     classref_or_classinfo subtype,
+                                                                                         classref_or_classinfo supertype,
+                                                                                         resolve_mode_t mode,
+                                                                                         resolve_err_t error)
+{
+       classinfo        *subclass;
+       typeinfo_t        subti;
+       typecheck_result  r;
+       char             *msg;
+       s4                msglen;
+       utf              *u;
+
+       assert(refmethod);
+       assert(subtype.any);
+       assert(supertype.any);
+       assert(mode == resolveLazy || mode == resolveEager);
+       assert(error == resolveLinkageError || error == resolveIllegalAccessError);
+
+       /* resolve the subtype */
+
+       if (!resolve_classref_or_classinfo(refmethod,subtype,mode,false,true,&subclass)) {
+               /* the subclass could not be resolved. therefore we are sure that  */
+               /* no instances of this subclass will ever exist -> skip this test */
+               /* XXX this assumes that class loading has invariant results (as in JVM spec) */
+               exceptions_clear_exception();
+               return resolveSucceeded;
+       }
+       if (!subclass)
+               return resolveDeferred; /* be lazy */
+
+       assert(subclass->state & CLASS_LINKED);
+
+       /* do not check access to protected members of arrays */
+
+       if (error == resolveIllegalAccessError && subclass->name->text[0] == '[') {
+               return resolveSucceeded;
+       }
+
+       /* perform the subtype check */
+
+       typeinfo_init_classinfo(&subti,subclass);
+check_again:
+       r = typeinfo_is_assignable_to_class(&subti,supertype);
+       if (r == typecheck_FAIL)
+               return resolveFailed; /* failed, exception is already set */
+
+       if (r == typecheck_MAYBE) {
+               assert(IS_CLASSREF(supertype));
+               if (mode == resolveEager) {
+                       if (!resolve_classref_or_classinfo(refmethod,supertype,
+                                                                                          resolveEager,false,true,
+                                                                                          &supertype.cls))
+                       {
+                               return resolveFailed;
+                       }
+                       assert(supertype.cls);
+                       goto check_again;
+               }
+
+               return resolveDeferred; /* be lazy */
+       }
+
+       if (!r) {
+               /* sub class relationship is false */
+
+#if defined(RESOLVE_VERBOSE)
+               printf("SUBTYPE CHECK FAILED!\n");
+#endif
+
+               msglen =
+                       utf_bytes(subclass->name) +
+                       utf_bytes(CLASSREF_OR_CLASSINFO_NAME(supertype))
+                       + 200;
+
+               msg = MNEW(char, msglen);
+
+               strcpy(msg, (error == resolveIllegalAccessError) ?
+                          "illegal access to protected member (" :
+                          "subtype constraint violated (");
+
+               utf_cat_classname(msg, subclass->name);
+               strcat(msg, " is not a subclass of ");
+               utf_cat_classname(msg, CLASSREF_OR_CLASSINFO_NAME(supertype));
+               strcat(msg, ")");
+
+               u = utf_new_char(msg);
+
+               if (error == resolveIllegalAccessError)
+                       exceptions_throw_illegalaccessexception(u);
+               else
+                       exceptions_throw_linkageerror(msg, NULL);
+
+               /* ATTENTION: We probably need msg for
+                  exceptions_throw_linkageerror. */
+
+               MFREE(msg, char, msglen);
+
+               return resolveFailed; /* exception */
+       }
+
+       /* everything ok */
+
+       return resolveSucceeded;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+/* resolve_lazy_subtype_checks *************************************************
+   Resolve the types to check lazily and perform subtype checks
+  
+   IN:
+       refmethod........the method triggering the resolution
+       subtinfo.........the typeinfo containing the subtypes
+       supertype........the supertype to test againgst
+          mode.............mode of resolution:
+                            resolveLazy...only resolve if it does not
+                                          require loading classes
+                            resolveEager..load classes if necessary
+       error............which type of exception to throw if
+                        the test fails. May be:
+                            resolveLinkageError, or
+                            resolveIllegalAccessError
+                                               IMPORTANT: If error==resolveIllegalAccessError,
+                                               then array types in the set are skipped.
+
+   RETURN VALUE:
+       resolveSucceeded.....the check succeeded
+       resolveDeferred......the check could not be performed due to
+                               unresolved types
+          resolveFailed........the check failed, an exception has been thrown.
+   
+   NOTE:
+       The references in the set are resolved first, so any
+       exception which may occurr during resolution may
+       be thrown by this function.
+   
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+static resolve_result_t resolve_lazy_subtype_checks(methodinfo *refmethod,
+                                                                                                       typeinfo_t *subtinfo,
+                                                                                                       classref_or_classinfo supertype,
+                                                                                                       resolve_err_t error)
+{
+       int count;
+       int i;
+       resolve_result_t result;
+
+       assert(refmethod);
+       assert(subtinfo);
+       assert(supertype.any);
+       assert(error == resolveLinkageError || error == resolveIllegalAccessError);
+
+       /* returnAddresses are illegal here */
+
+       if (TYPEINFO_IS_PRIMITIVE(*subtinfo)) {
+               exceptions_throw_verifyerror(refmethod,
+                               "Invalid use of returnAddress");
+               return resolveFailed;
+       }
+
+       /* uninitialized objects are illegal here */
+
+       if (TYPEINFO_IS_NEWOBJECT(*subtinfo)) {
+               exceptions_throw_verifyerror(refmethod,
+                               "Invalid use of uninitialized object");
+               return resolveFailed;
+       }
+
+       /* the nulltype is always assignable */
+
+       if (TYPEINFO_IS_NULLTYPE(*subtinfo))
+               return resolveSucceeded;
+
+       /* every type is assignable to (BOOTSTRAP)java.lang.Object */
+
+       if (supertype.cls == class_java_lang_Object
+               || (CLASSREF_OR_CLASSINFO_NAME(supertype) == utf_java_lang_Object
+                       && refmethod->clazz->classloader == NULL))
+       {
+               return resolveSucceeded;
+       }
+
+       if (subtinfo->merged) {
+
+               /* for a merged type we have to do a series of checks */
+
+               count = subtinfo->merged->count;
+               for (i=0; i<count; ++i) {
+                       classref_or_classinfo c = subtinfo->merged->list[i];
+                       if (subtinfo->dimension > 0) {
+                               /* a merge of array types */
+                               /* the merged list contains the possible _element_ types, */
+                               /* so we have to create array types with these elements.  */
+                               if (IS_CLASSREF(c)) {
+                                       c.ref = class_get_classref_multiarray_of(subtinfo->dimension,c.ref);
+                               }
+                               else {
+                                       c.cls = class_multiarray_of(subtinfo->dimension,c.cls,false);
+                               }
+                       }
+
+                       /* do the subtype check against the type c */
+
+                       result = resolve_subtype_check(refmethod,c,supertype,resolveLazy,error);
+                       if (result != resolveSucceeded)
+                               return result;
+               }
+       }
+       else {
+
+               /* a single type, this is the common case, hopefully */
+
+               if (CLASSREF_OR_CLASSINFO_NAME(subtinfo->typeclass)
+                       == CLASSREF_OR_CLASSINFO_NAME(supertype))
+               {
+                       /* the class names are the same */
+                   /* equality is guaranteed by the loading constraints */
+                       return resolveSucceeded;
+               }
+               else {
+
+                       /* some other type name, try to perform the check lazily */
+
+                       return resolve_subtype_check(refmethod,
+                                                                                subtinfo->typeclass,supertype,
+                                                                                resolveLazy,
+                                                                                error);
+               }
+       }
+
+       /* everything ok */
+       return resolveSucceeded;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+/* resolve_and_check_subtype_set ***********************************************
+   Resolve the references in the given set and test subtype relationships
+  
+   IN:
+       refmethod........the method triggering the resolution
+       ref..............a set of class/interface references
+                        (may be empty)
+       typeref..........the type to test against the set
+       mode.............mode of resolution:
+                            resolveLazy...only resolve if it does not
+                                          require loading classes
+                            resolveEager..load classes if necessary
+       error............which type of exception to throw if
+                        the test fails. May be:
+                            resolveLinkageError, or
+                            resolveIllegalAccessError
+                                               IMPORTANT: If error==resolveIllegalAccessError,
+                                               then array types in the set are skipped.
+
+   RETURN VALUE:
+       resolveSucceeded.....the check succeeded
+       resolveDeferred......the check could not be performed due to
+                               unresolved types. (This can only happen if
+                                                       mode == resolveLazy.)
+          resolveFailed........the check failed, an exception has been thrown.
+   
+   NOTE:
+       The references in the set are resolved first, so any
+       exception which may occurr during resolution may
+       be thrown by this function.
+   
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+static resolve_result_t resolve_and_check_subtype_set(methodinfo *refmethod,
+                                                                         unresolved_subtype_set *ref,
+                                                                         classref_or_classinfo typeref,
+                                                                         resolve_mode_t mode,
+                                                                         resolve_err_t error)
+{
+       classref_or_classinfo *setp;
+       resolve_result_t checkresult;
+
+       assert(refmethod);
+       assert(ref);
+       assert(typeref.any);
+       assert(mode == resolveLazy || mode == resolveEager);
+       assert(error == resolveLinkageError || error == resolveIllegalAccessError);
+
+#if defined(RESOLVE_VERBOSE)
+       printf("resolve_and_check_subtype_set:\n");
+       unresolved_subtype_set_debug_dump(ref, stdout);
+       if (IS_CLASSREF(typeref))
+               class_classref_println(typeref.ref);
+       else
+               class_println(typeref.cls);
+#endif
+
+       setp = ref->subtyperefs;
+
+       /* an empty set of tests always succeeds */
+       if (!setp || !setp->any) {
+               return resolveSucceeded;
+       }
+
+       /* first resolve the type if necessary */
+       if (!resolve_classref_or_classinfo(refmethod,typeref,mode,false,true,&(typeref.cls)))
+               return resolveFailed; /* exception */
+       if (!typeref.cls)
+               return resolveDeferred; /* be lazy */
+
+       assert(typeref.cls->state & CLASS_LINKED);
+
+       /* iterate over the set members */
+
+       for (; setp->any; ++setp) {
+               checkresult = resolve_subtype_check(refmethod,*setp,typeref,mode,error);
+#if defined(RESOLVE_VERBOSE)
+               if (checkresult != resolveSucceeded)
+                       printf("SUBTYPE CHECK FAILED!\n");
+#endif
+               if (checkresult != resolveSucceeded)
+                       return checkresult;
+       }
+
+       /* check succeeds */
+       return resolveSucceeded;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+/******************************************************************************/
+/* CLASS RESOLUTION                                                           */
+/******************************************************************************/
+
+/* resolve_class ***************************************************************
+   Resolve an unresolved class reference. The class is also linked.
+  
+   IN:
+       ref..............struct containing the reference
+       mode.............mode of resolution:
+                            resolveLazy...only resolve if it does not
+                                          require loading classes
+                            resolveEager..load classes if necessary
+          checkaccess......if true, access rights to the class are checked
+   
+   OUT:
+       *result..........set to the result of resolution, or to NULL if
+                        the reference has not been resolved
+                        In the case of an exception, *result is
+                        guaranteed to be set to NULL.
+  
+   RETURN VALUE:
+       true.............everything ok 
+                        (*result may still be NULL for resolveLazy)
+       false............an exception has been thrown
+   
+*******************************************************************************/
+
+#ifdef ENABLE_VERIFIER
+bool resolve_class(unresolved_class *ref,
+                                  resolve_mode_t mode,
+                                  bool checkaccess,
+                                  classinfo **result)
+{
+       classinfo *cls;
+       resolve_result_t checkresult;
+       
+       assert(ref);
+       assert(result);
+       assert(mode == resolveLazy || mode == resolveEager);
+
+       *result = NULL;
+
+#ifdef RESOLVE_VERBOSE
+       unresolved_class_debug_dump(ref,stdout);
+#endif
+
+       /* first we must resolve the class */
+       if (!resolve_classref(ref->referermethod,
+                                             ref->classref,mode,checkaccess,true,&cls))
+       {
+               /* the class reference could not be resolved */
+               return false; /* exception */
+       }
+       if (!cls)
+               return true; /* be lazy */
+
+       assert(cls);
+       assert((cls->state & CLASS_LOADED) && (cls->state & CLASS_LINKED));
+
+       /* now we check the subtype constraints */
+       
+       checkresult = resolve_and_check_subtype_set(ref->referermethod,
+                                                                          &(ref->subtypeconstraints),
+                                                                          CLASSREF_OR_CLASSINFO(cls),
+                                                                          mode,
+                                                                          resolveLinkageError);
+       if (checkresult != resolveSucceeded)
+               return (bool) checkresult;
+
+       /* succeed */
+       *result = cls;
+       return true;
+}
+#endif /* ENABLE_VERIFIER */
+
+/* resolve_classref_eager ******************************************************
+   Resolve an unresolved class reference eagerly. The class is also linked and
+   access rights to the class are checked.
+  
+   IN:
+       ref..............constant_classref to the class
+   
+   RETURN VALUE:
+       classinfo * to the class, or
+          NULL if an exception has been thrown
+   
+*******************************************************************************/
+
+classinfo * resolve_classref_eager(constant_classref *ref)
+{
+       classinfo *c;
+
+       if (!resolve_classref(NULL,ref,resolveEager,true,true,&c))
+               return NULL;
+
+       return c;
+}
+
+/* resolve_classref_eager_nonabstract ******************************************
+   Resolve an unresolved class reference eagerly. The class is also linked and
+   access rights to the class are checked. A check is performed that the class
+   is not abstract.
+  
+   IN:
+       ref..............constant_classref to the class
+   
+   RETURN VALUE:
+       classinfo * to the class, or
+          NULL if an exception has been thrown
+   
+*******************************************************************************/
+
+classinfo * resolve_classref_eager_nonabstract(constant_classref *ref)
+{
+       classinfo *c;
+
+       if (!resolve_classref(NULL,ref,resolveEager,true,true,&c))
+               return NULL;
+
+       /* ensure that the class is not abstract */
+
+       if (c->flags & ACC_ABSTRACT) {
+               exceptions_throw_verifyerror(NULL,"creating instance of abstract class");
+               return NULL;
+       }
+
+       return c;
+}
+
+/* resolve_class_eager *********************************************************
+   Resolve an unresolved class reference eagerly. The class is also linked and
+   access rights to the class are checked.
+  
+   IN:
+       ref..............struct containing the reference
+   
+   RETURN VALUE:
+       classinfo * to the class, or
+          NULL if an exception has been thrown
+   
+*******************************************************************************/
+
+#ifdef ENABLE_VERIFIER
+classinfo * resolve_class_eager(unresolved_class *ref)
+{
+       classinfo *c;
+
+       if (!resolve_class(ref,resolveEager,true,&c))
+               return NULL;
+
+       return c;
+}
+#endif /* ENABLE_VERIFIER */
+
+/* resolve_class_eager_no_access_check *****************************************
+   Resolve an unresolved class reference eagerly. The class is also linked.
+   Access rights are _not_ checked.
+  
+   IN:
+       ref..............struct containing the reference
+   
+   RETURN VALUE:
+       classinfo * to the class, or
+          NULL if an exception has been thrown
+   
+*******************************************************************************/
+
+#ifdef ENABLE_VERIFIER
+classinfo * resolve_class_eager_no_access_check(unresolved_class *ref)
+{
+       classinfo *c;
+
+       if (!resolve_class(ref, resolveEager, false, &c))
+               return NULL;
+
+       return c;
+}
+#endif /* ENABLE_VERIFIER */
+
+/******************************************************************************/
+/* FIELD RESOLUTION                                                           */
+/******************************************************************************/
+
+/* resolve_field_verifier_checks *******************************************
+   Do the verifier checks necessary after field has been resolved.
+  
+   IN:
+       refmethod........the method containing the reference
+          fieldref.........the field reference
+          container........the class where the field was found
+          fi...............the fieldinfo of the resolved field
+          instanceti.......instance typeinfo, if available
+          valueti..........value typeinfo, if available
+          isstatic.........true if this is a *STATIC* instruction
+          isput............true if this is a PUT* instruction
+  
+   RETURN VALUE:
+       resolveSucceeded....everything ok
+          resolveDeferred.....tests could not be done, have been deferred
+       resolveFailed.......exception has been thrown
+   
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+resolve_result_t resolve_field_verifier_checks(methodinfo *refmethod,
+                                                                                          constant_FMIref *fieldref,
+                                                                                          classinfo *container,
+                                                                                          fieldinfo *fi,
+                                                                                          typeinfo_t *instanceti,
+                                                                                          typeinfo_t *valueti,
+                                                                                          bool isstatic,
+                                                                                          bool isput)
+{
+       classinfo         *declarer;
+       classinfo         *referer;
+       resolve_result_t   result;
+       constant_classref *fieldtyperef;
+       char              *msg;
+       s4                 msglen;
+       utf               *u;
+
+       assert(refmethod);
+       assert(fieldref);
+       assert(container);
+       assert(fi);
+
+       /* get the classinfos and the field type */
+
+       referer = refmethod->clazz;
+       assert(referer);
+
+       declarer = fi->clazz;
+       assert(declarer);
+       assert(referer->state & CLASS_LINKED);
+
+       fieldtyperef = fieldref->parseddesc.fd->classref;
+
+       /* check static */
+
+#if true != 1
+#error This code assumes that `true` is `1`. Otherwise, use the ternary operator below.
+#endif
+
+       if (((fi->flags & ACC_STATIC) != 0) != isstatic) {
+               /* a static field is accessed via an instance, or vice versa */
+               exceptions_throw_incompatibleclasschangeerror(declarer,
+                                                                                                         (fi->flags & ACC_STATIC)
+                                                                                                         ? "static field accessed via instance"
+                                                                                                         : "instance field  accessed without instance");
+
+               return resolveFailed;
+       }
+
+       /* check access rights */
+
+       if (!access_is_accessible_member(referer,declarer,fi->flags)) {
+               msglen =
+                       utf_bytes(declarer->name) +
+                       utf_bytes(fi->name) +
+                       utf_bytes(referer->name) +
+                       100;
+
+               msg = MNEW(char, msglen);
+
+               strcpy(msg, "field is not accessible (");
+               utf_cat_classname(msg, declarer->name);
+               strcat(msg, ".");
+               utf_cat(msg, fi->name);
+               strcat(msg, " from ");
+               utf_cat_classname(msg, referer->name);
+               strcat(msg, ")");
+
+               u = utf_new_char(msg);
+
+               MFREE(msg, char, msglen);
+
+               exceptions_throw_illegalaccessexception(u);
+
+               return resolveFailed; /* exception */
+       }
+
+       /* for non-static methods we have to check the constraints on the         */
+       /* instance type                                                          */
+
+       if (instanceti) {
+               typeinfo_t *insttip;
+               typeinfo_t tinfo;
+
+               /* The instanceslot must contain a reference to a non-array type */
+
+               if (!TYPEINFO_IS_REFERENCE(*instanceti)) {
+                       exceptions_throw_verifyerror(refmethod, "illegal instruction: field access on non-reference");
+                       return resolveFailed;
+               }
+               if (TYPEINFO_IS_ARRAY(*instanceti)) {
+                       exceptions_throw_verifyerror(refmethod, "illegal instruction: field access on array");
+                       return resolveFailed;
+               }
+
+               if (isput && TYPEINFO_IS_NEWOBJECT(*instanceti))
+               {
+                       /* The instruction writes a field in an uninitialized object. */
+                       /* This is only allowed when a field of an uninitialized 'this' object is */
+                       /* written inside an initialization method                                */
+
+                       classinfo *initclass;
+                       instruction *ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*instanceti);
+
+                       if (ins != NULL) {
+                               exceptions_throw_verifyerror(refmethod, "accessing field of uninitialized object");
+                               return resolveFailed;
+                       }
+
+                       /* XXX check that class of field == refmethod->clazz */
+                       initclass = referer; /* XXX classrefs */
+                       assert(initclass->state & CLASS_LINKED);
+
+                       typeinfo_init_classinfo(&tinfo, initclass);
+                       insttip = &tinfo;
+               }
+               else {
+                       insttip = instanceti;
+               }
+
+               result = resolve_lazy_subtype_checks(refmethod,
+                               insttip,
+                               CLASSREF_OR_CLASSINFO(container),
+                               resolveLinkageError);
+               if (result != resolveSucceeded)
+                       return result;
+
+               /* check protected access */
+
+               if (((fi->flags & ACC_PROTECTED) != 0) && !SAME_PACKAGE(declarer,referer))
+               {
+                       result = resolve_lazy_subtype_checks(refmethod,
+                                       instanceti,
+                                       CLASSREF_OR_CLASSINFO(referer),
+                                       resolveIllegalAccessError);
+                       if (result != resolveSucceeded)
+                               return result;
+               }
+
+       }
+
+       /* for PUT* instructions we have to check the constraints on the value type */
+
+       if (valueti) {
+               assert(fieldtyperef);
+
+               /* check subtype constraints */
+               result = resolve_lazy_subtype_checks(refmethod,
+                               valueti,
+                               CLASSREF_OR_CLASSINFO(fieldtyperef),
+                               resolveLinkageError);
+
+               if (result != resolveSucceeded)
+                       return result;
+       }
+
+       /* impose loading constraint on field type */
+
+       if (fi->type == TYPE_ADR) {
+               assert(fieldtyperef);
+               if (!classcache_add_constraint(declarer->classloader,
+                                                                          referer->classloader,
+                                                                          fieldtyperef->name))
+                       return resolveFailed;
+       }
+
+       /* XXX impose loading constraint on instance? */
+
+       /* everything ok */
+       return resolveSucceeded;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+/* resolve_field_lazy **********************************************************
+   Resolve an unresolved field reference lazily
+
+   NOTE: This function does NOT do any verification checks. In case of a
+         successful resolution, you must call resolve_field_verifier_checks
+                in order to perform the necessary checks!
+  
+   IN:
+          refmethod........the referer method
+          fieldref.........the field reference
+  
+   RETURN VALUE:
+       resolveSucceeded.....the reference has been resolved
+       resolveDeferred......the resolving could not be performed lazily
+          resolveFailed........resolving failed, an exception has been thrown.
+   
+*******************************************************************************/
+
+resolve_result_t resolve_field_lazy(methodinfo *refmethod,
+                                                                       constant_FMIref *fieldref)
+{
+       classinfo *referer;
+       classinfo *container;
+       fieldinfo *fi;
+
+       assert(refmethod);
+
+       /* the class containing the reference */
+
+       referer = refmethod->clazz;
+       assert(referer);
+
+       /* check if the field itself is already resolved */
+
+       if (IS_FMIREF_RESOLVED(fieldref))
+               return resolveSucceeded;
+
+       /* first we must resolve the class containg the field */
+
+       /* XXX can/may lazyResolving trigger linking? */
+
+       if (!resolve_class_from_name(referer, refmethod,
+                  fieldref->p.classref->name, resolveLazy, true, true, &container))
+       {
+               /* the class reference could not be resolved */
+               return resolveFailed; /* exception */
+       }
+       if (!container)
+               return resolveDeferred; /* be lazy */
+
+       assert(container->state & CLASS_LINKED);
+
+       /* now we must find the declaration of the field in `container`
+        * or one of its superclasses */
+
+       fi = class_resolvefield(container,
+                                                       fieldref->name, fieldref->descriptor,
+                                                       referer);
+       if (!fi) {
+               /* The field does not exist. But since we were called lazily, */
+               /* this error must not be reported now. (It will be reported   */
+               /* if eager resolving of this field is ever tried.)           */
+
+               exceptions_clear_exception();
+               return resolveDeferred; /* be lazy */
+       }
+
+       /* cache the result of the resolution */
+
+       fieldref->p.field = fi;
+
+       /* everything ok */
+       return resolveSucceeded;
+}
+
+/* resolve_field ***************************************************************
+   Resolve an unresolved field reference
+  
+   IN:
+       ref..............struct containing the reference
+       mode.............mode of resolution:
+                            resolveLazy...only resolve if it does not
+                                          require loading classes
+                            resolveEager..load classes if necessary
+  
+   OUT:
+       *result..........set to the result of resolution, or to NULL if
+                        the reference has not been resolved
+                        In the case of an exception, *result is
+                        guaranteed to be set to NULL.
+  
+   RETURN VALUE:
+       true.............everything ok 
+                        (*result may still be NULL for resolveLazy)
+       false............an exception has been thrown
+   
+*******************************************************************************/
+
+bool resolve_field(unresolved_field *ref,
+                                  resolve_mode_t mode,
+                                  fieldinfo **result)
+{
+       classinfo *referer;
+       classinfo *container;
+       classinfo *declarer;
+       constant_classref *fieldtyperef;
+       fieldinfo *fi;
+       resolve_result_t checkresult;
+
+       assert(ref);
+       assert(result);
+       assert(mode == resolveLazy || mode == resolveEager);
+
+       *result = NULL;
+
+#ifdef RESOLVE_VERBOSE
+       unresolved_field_debug_dump(ref,stdout);
+#endif
+
+       /* the class containing the reference */
+
+       referer = ref->referermethod->clazz;
+       assert(referer);
+
+       /* check if the field itself is already resolved */
+       if (IS_FMIREF_RESOLVED(ref->fieldref)) {
+               fi = ref->fieldref->p.field;
+               container = fi->clazz;
+               goto resolved_the_field;
+       }
+
+       /* first we must resolve the class containg the field */
+       if (!resolve_class_from_name(referer,ref->referermethod,
+                                          ref->fieldref->p.classref->name,mode,true,true,&container))
+       {
+               /* the class reference could not be resolved */
+               return false; /* exception */
+       }
+       if (!container)
+               return true; /* be lazy */
+
+       assert(container);
+       assert(container->state & CLASS_LOADED);
+       assert(container->state & CLASS_LINKED);
+
+       /* now we must find the declaration of the field in `container`
+        * or one of its superclasses */
+
+#ifdef RESOLVE_VERBOSE
+               printf("    resolving field in class...\n");
+#endif
+
+       fi = class_resolvefield(container,
+                                                       ref->fieldref->name,ref->fieldref->descriptor,
+                                                       referer);
+       if (!fi) {
+               if (mode == resolveLazy) {
+                       /* The field does not exist. But since we were called lazily, */
+                       /* this error must not be reported now. (It will be reported   */
+                       /* if eager resolving of this field is ever tried.)           */
+
+                       exceptions_clear_exception();
+                       return true; /* be lazy */
+               }
+
+               return false; /* exception */
+       }
+
+       /* cache the result of the resolution */
+       ref->fieldref->p.field = fi;
+
+resolved_the_field:
+
+#ifdef ENABLE_VERIFIER
+       /* Checking opt_verify is ok here, because the NULL iptr guarantees */
+       /* that no missing parts of an instruction will be accessed.        */
+       if (opt_verify) {
+               checkresult = resolve_field_verifier_checks(
+                               ref->referermethod,
+                               ref->fieldref,
+                               container,
+                               fi,
+                               NULL, /* instanceti, handled by constraints below */
+                               NULL, /* valueti, handled by constraints below  */
+                               (ref->flags & RESOLVE_STATIC) != 0, /* isstatic */
+                               (ref->flags & RESOLVE_PUTFIELD) != 0 /* isput */);
+
+               if (checkresult != resolveSucceeded)
+                       return (bool) checkresult;
+
+               declarer = fi->clazz;
+               assert(declarer);
+               assert(declarer->state & CLASS_LOADED);
+               assert(declarer->state & CLASS_LINKED);
+
+               /* for non-static accesses we have to check the constraints on the */
+               /* instance type */
+
+               if (!(ref->flags & RESOLVE_STATIC)) {
+                       checkresult = resolve_and_check_subtype_set(ref->referermethod,
+                                       &(ref->instancetypes),
+                                       CLASSREF_OR_CLASSINFO(container),
+                                       mode, resolveLinkageError);
+                       if (checkresult != resolveSucceeded)
+                               return (bool) checkresult;
+               }
+
+               fieldtyperef = ref->fieldref->parseddesc.fd->classref;
+
+               /* for PUT* instructions we have to check the constraints on the value type */
+               if (((ref->flags & RESOLVE_PUTFIELD) != 0) && fi->type == TYPE_ADR) {
+                       assert(fieldtyperef);
+                       if (!SUBTYPESET_IS_EMPTY(ref->valueconstraints)) {
+                               /* check subtype constraints */
+                               checkresult = resolve_and_check_subtype_set(ref->referermethod,
+                                               &(ref->valueconstraints),
+                                               CLASSREF_OR_CLASSINFO(fieldtyperef),
+                                               mode, resolveLinkageError);
+                               if (checkresult != resolveSucceeded)
+                                       return (bool) checkresult;
+                       }
+               }
+
+               /* check protected access */
+               if (((fi->flags & ACC_PROTECTED) != 0) && !SAME_PACKAGE(declarer,referer)) {
+                       checkresult = resolve_and_check_subtype_set(ref->referermethod,
+                                       &(ref->instancetypes),
+                                       CLASSREF_OR_CLASSINFO(referer),
+                                       mode,
+                                       resolveIllegalAccessError);
+                       if (checkresult != resolveSucceeded)
+                               return (bool) checkresult;
+               }
+
+       }
+#endif /* ENABLE_VERIFIER */
+
+       /* succeed */
+       *result = fi;
+
+       return true;
+}
+
+/* resolve_field_eager *********************************************************
+   Resolve an unresolved field reference eagerly.
+  
+   IN:
+       ref..............struct containing the reference
+   
+   RETURN VALUE:
+       fieldinfo * to the field, or
+          NULL if an exception has been thrown
+   
+*******************************************************************************/
+
+fieldinfo * resolve_field_eager(unresolved_field *ref)
+{
+       fieldinfo *fi;
+
+       if (!resolve_field(ref,resolveEager,&fi))
+               return NULL;
+
+       return fi;
+}
+
+/******************************************************************************/
+/* METHOD RESOLUTION                                                          */
+/******************************************************************************/
+
+/* resolve_method_invokespecial_lookup *****************************************
+   Do the special lookup for methods invoked by INVOKESPECIAL
+  
+   IN:
+       refmethod........the method containing the reference
+          mi...............the methodinfo of the resolved method
+  
+   RETURN VALUE:
+       a methodinfo *...the result of the lookup,
+          NULL.............an exception has been thrown
+   
+*******************************************************************************/
+
+methodinfo * resolve_method_invokespecial_lookup(methodinfo *refmethod,
+                                                                                                methodinfo *mi)
+{
+       classinfo *declarer;
+       classinfo *referer;
+
+       assert(refmethod);
+       assert(mi);
+
+       /* get referer and declarer classes */
+
+       referer = refmethod->clazz;
+       assert(referer);
+
+       declarer = mi->clazz;
+       assert(declarer);
+       assert(referer->state & CLASS_LINKED);
+
+       /* checks for INVOKESPECIAL:                                       */
+       /* for <init> and methods of the current class we don't need any   */
+       /* special checks. Otherwise we must verify that the called method */
+       /* belongs to a super class of the current class                   */
+
+       if ((referer != declarer) && (mi->name != utf_init)) {
+               /* check that declarer is a super class of the current class   */
+
+               if (!class_issubclass(referer,declarer)) {
+                       exceptions_throw_verifyerror(refmethod,
+                                       "INVOKESPECIAL calling non-super class method");
+                       return NULL;
+               }
+
+               /* if the referer has ACC_SUPER set, we must do the special    */
+               /* lookup starting with the direct super class of referer      */
+
+               if ((referer->flags & ACC_SUPER) != 0) {
+                       mi = class_resolvemethod(referer->super,
+                                                                        mi->name,
+                                                                        mi->descriptor);
+
+                       if (mi == NULL) {
+                               /* the spec calls for an AbstractMethodError in this case */
+
+                               exceptions_throw_abstractmethoderror();
+
+                               return NULL;
+                       }
+               }
+       }
+
+       /* everything ok */
+       return mi;
+}
+
+/* resolve_method_verifier_checks ******************************************
+   Do the verifier checks necessary after a method has been resolved.
+  
+   IN:
+       refmethod........the method containing the reference
+          methodref........the method reference
+          mi...............the methodinfo of the resolved method
+          invokestatic.....true if the method is invoked by INVOKESTATIC
+  
+   RETURN VALUE:
+       resolveSucceeded....everything ok
+          resolveDeferred.....tests could not be done, have been deferred
+       resolveFailed.......exception has been thrown
+   
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+resolve_result_t resolve_method_verifier_checks(methodinfo *refmethod,
+                                                                                               constant_FMIref *methodref,
+                                                                                               methodinfo *mi,
+                                                                                               bool invokestatic)
+{
+       classinfo *declarer;
+       classinfo *referer;
+       char      *msg;
+       s4         msglen;
+       utf       *u;
+
+       assert(refmethod);
+       assert(methodref);
+       assert(mi);
+
+#ifdef RESOLVE_VERBOSE
+       printf("resolve_method_verifier_checks\n");
+       printf("    flags: %02x\n",mi->flags);
+#endif
+
+       /* get the classinfos and the method descriptor */
+
+       referer = refmethod->clazz;
+       assert(referer);
+
+       declarer = mi->clazz;
+       assert(declarer);
+
+       /* check static */
+
+       if (((mi->flags & ACC_STATIC) != 0) != (invokestatic != false)) {
+               /* a static method is accessed via an instance, or vice versa */
+               exceptions_throw_incompatibleclasschangeerror(declarer,
+                                                                                                         (mi->flags & ACC_STATIC)
+                                                                                                         ? "static method called via instance"
+                                                                                                         : "instance method called without instance");
+
+               return resolveFailed;
+       }
+
+       /* check access rights */
+
+       if (!access_is_accessible_member(referer,declarer,mi->flags)) {
+               /* XXX clean this up. this should be in exceptions.c */
+
+               msglen =
+                       utf_bytes(declarer->name) +
+                       utf_bytes(mi->name) +
+                       utf_bytes(mi->descriptor) +
+                       utf_bytes(referer->name) +
+                       100;
+
+               msg = MNEW(char, msglen);
+
+               strcpy(msg, "method is not accessible (");
+               utf_cat_classname(msg, declarer->name);
+               strcat(msg, ".");
+               utf_cat(msg, mi->name);
+               utf_cat(msg, mi->descriptor);
+               strcat(msg, " from ");
+               utf_cat_classname(msg, referer->name);
+               strcat(msg, ")");
+
+               u = utf_new_char(msg);
+
+               MFREE(msg, char, msglen);
+
+               exceptions_throw_illegalaccessexception(u);
+
+               return resolveFailed; /* exception */
+       }
+
+       /* everything ok */
+
+       return resolveSucceeded;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+
+/* resolve_method_instance_type_checks *****************************************
+
+   Check the instance type of a method invocation.
+
+   IN:
+       refmethod........the method containing the reference
+          mi...............the methodinfo of the resolved method
+          instanceti.......typeinfo of the instance slot
+          invokespecial....true if the method is invoked by INVOKESPECIAL
+
+   RETURN VALUE:
+       resolveSucceeded....everything ok
+          resolveDeferred.....tests could not be done, have been deferred
+       resolveFailed.......exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+resolve_result_t resolve_method_instance_type_checks(methodinfo *refmethod,
+                                                                                                        methodinfo *mi,
+                                                                                                        typeinfo_t *instanceti,
+                                                                                                        bool invokespecial)
+{
+       typeinfo_t         tinfo;
+       typeinfo_t        *tip;
+       resolve_result_t result;
+
+       if (invokespecial && TYPEINFO_IS_NEWOBJECT(*instanceti))
+       {   /* XXX clean up */
+               instruction *ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*instanceti);
+               classref_or_classinfo initclass = (ins) ? ins[-1].sx.val.c
+                                                                        : CLASSREF_OR_CLASSINFO(refmethod->clazz);
+               tip = &tinfo;
+               if (!typeinfo_init_class(tip, initclass))
+                       return resolveFailed;
+       }
+       else {
+               tip = instanceti;
+       }
+
+       result = resolve_lazy_subtype_checks(refmethod,
+                                                                                tip,
+                                                                                CLASSREF_OR_CLASSINFO(mi->clazz),
+                                                                                resolveLinkageError);
+       if (result != resolveSucceeded)
+               return result;
+
+       /* check protected access */
+
+       /* XXX use other `declarer` than mi->clazz? */
+       if (((mi->flags & ACC_PROTECTED) != 0)
+                       && !SAME_PACKAGE(mi->clazz, refmethod->clazz))
+       {
+               result = resolve_lazy_subtype_checks(refmethod,
+                               tip,
+                               CLASSREF_OR_CLASSINFO(refmethod->clazz),
+                               resolveIllegalAccessError);
+               if (result != resolveSucceeded)
+                       return result;
+       }
+
+       /* everything ok */
+
+       return resolveSucceeded;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+
+/* resolve_method_param_type_checks ********************************************
+
+   Check non-instance parameter types of a method invocation.
+
+   IN:
+          jd...............jitdata of the method doing the call
+       refmethod........the method containing the reference
+          iptr.............the invoke instruction
+          mi...............the methodinfo of the resolved method
+          invokestatic.....true if the method is invoked by INVOKESTATIC
+
+   RETURN VALUE:
+       resolveSucceeded....everything ok
+          resolveDeferred.....tests could not be done, have been deferred
+       resolveFailed.......exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+resolve_result_t resolve_method_param_type_checks(jitdata *jd, 
+                                                                                                 methodinfo *refmethod,
+                                                                                                 instruction *iptr, 
+                                                                                                 methodinfo *mi,
+                                                                                                 bool invokestatic)
+{
+       varinfo         *param;
+       resolve_result_t result;
+       methoddesc      *md;
+       typedesc        *paramtypes;
+       s4               type;
+       s4               instancecount;
+       s4               i;
+
+       assert(jd);
+
+       instancecount = (invokestatic) ? 0 : 1;
+
+       /* check subtype constraints for TYPE_ADR parameters */
+
+       md = mi->parseddesc;
+       paramtypes = md->paramtypes;
+
+       for (i = md->paramcount-1-instancecount; i>=0; --i) {
+               param = VAR(iptr->sx.s23.s2.args[i+instancecount]);
+               type = md->paramtypes[i+instancecount].type;
+
+               assert(param);
+               assert(type == param->type);
+
+               if (type == TYPE_ADR) {
+                       result = resolve_lazy_subtype_checks(refmethod,
+                                       &(param->typeinfo),
+                                       CLASSREF_OR_CLASSINFO(paramtypes[i+instancecount].classref),
+                                       resolveLinkageError);
+                       if (result != resolveSucceeded)
+                               return result;
+               }
+       }
+
+       /* everything ok */
+
+       return resolveSucceeded;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+
+/* resolve_method_param_type_checks_stackbased *********************************
+
+   Check non-instance parameter types of a method invocation.
+
+   IN:
+       refmethod........the method containing the reference
+          mi...............the methodinfo of the resolved method
+          invokestatic.....true if the method is invoked by INVOKESTATIC
+          stack............TOS before the INVOKE instruction
+
+   RETURN VALUE:
+       resolveSucceeded....everything ok
+          resolveDeferred.....tests could not be done, have been deferred
+       resolveFailed.......exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+resolve_result_t resolve_method_param_type_checks_stackbased(
+               methodinfo *refmethod, 
+               methodinfo *mi,
+               bool invokestatic, 
+               typedescriptor_t *stack)
+{
+       typedescriptor_t  *param;
+       resolve_result_t result;
+       methoddesc      *md;
+       typedesc        *paramtypes;
+       s4               type;
+       s4               instancecount;
+       s4               i;
+
+       instancecount = (invokestatic) ? 0 : 1;
+
+       /* check subtype constraints for TYPE_ADR parameters */
+
+       md = mi->parseddesc;
+       paramtypes = md->paramtypes;
+
+       param = stack - (md->paramslots - 1 - instancecount);
+
+       for (i = instancecount; i < md->paramcount; ++i) {
+               type = md->paramtypes[i].type;
+
+               assert(type == param->type);
+
+               if (type == TYPE_ADR) {
+                       result = resolve_lazy_subtype_checks(refmethod,
+                                       &(param->typeinfo),
+                                       CLASSREF_OR_CLASSINFO(paramtypes[i].classref),
+                                       resolveLinkageError);
+                       if (result != resolveSucceeded)
+                               return result;
+               }
+
+               param += (IS_2_WORD_TYPE(type)) ? 2 : 1;
+       }
+
+       /* everything ok */
+
+       return resolveSucceeded;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+
+/* resolve_method_loading_constraints ******************************************
+
+   Impose loading constraints on the parameters and return type of the
+   given method.
+
+   IN:
+       referer..........the class refering to the method
+          mi...............the method
+
+   RETURN VALUE:
+       true................everything ok
+          false...............an exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+bool resolve_method_loading_constraints(classinfo *referer,
+                                                                               methodinfo *mi)
+{
+       methoddesc *md;
+       typedesc   *paramtypes;
+       utf        *name;
+       s4          i;
+       s4          instancecount;
+
+       /* impose loading constraints on parameters (including instance) */
+
+       md = mi->parseddesc;
+       paramtypes = md->paramtypes;
+       instancecount = (mi->flags & ACC_STATIC) / ACC_STATIC;
+
+       for (i = 0; i < md->paramcount; i++) {
+               if (i < instancecount || paramtypes[i].type == TYPE_ADR) {
+                       if (i < instancecount) {
+                               /* The type of the 'this' pointer is the class containing */
+                               /* the method definition. Since container is the same as, */
+                               /* or a subclass of declarer, we also constrain declarer  */
+                               /* by transitivity of loading constraints.                */
+                               name = mi->clazz->name;
+                       }
+                       else {
+                               name = paramtypes[i].classref->name;
+                       }
+
+                       /* The caller (referer) and the callee (container) must agree */
+                       /* on the types of the parameters.                            */
+                       if (!classcache_add_constraint(referer->classloader,
+                                                                                  mi->clazz->classloader, name))
+                               return false; /* exception */
+               }
+       }
+
+       /* impose loading constraint onto return type */
+
+       if (md->returntype.type == TYPE_ADR) {
+               /* The caller (referer) and the callee (container) must agree */
+               /* on the return type.                                        */
+               if (!classcache_add_constraint(referer->classloader,
+                                       mi->clazz->classloader,
+                                       md->returntype.classref->name))
+                       return false; /* exception */
+       }
+
+       /* everything ok */
+
+       return true;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+
+/* resolve_method_lazy *********************************************************
+   Resolve an unresolved method reference lazily
+  
+   NOTE: This function does NOT do any verification checks. In case of a
+         successful resolution, you must call resolve_method_verifier_checks
+                in order to perform the necessary checks!
+  
+   IN:
+          refmethod........the referer method
+          methodref........the method reference
+          invokespecial....true if this is an INVOKESPECIAL instruction
+  
+   RETURN VALUE:
+       resolveSucceeded.....the reference has been resolved
+       resolveDeferred......the resolving could not be performed lazily
+          resolveFailed........resolving failed, an exception has been thrown.
+   
+*******************************************************************************/
+
+resolve_result_t resolve_method_lazy(methodinfo *refmethod,
+                                                                        constant_FMIref *methodref,
+                                                                        bool invokespecial)
+{
+       classinfo *referer;
+       classinfo *container;
+       methodinfo *mi;
+
+       assert(refmethod);
+
+#ifdef RESOLVE_VERBOSE
+       printf("resolve_method_lazy\n");
+#endif
+
+       /* the class containing the reference */
+
+       referer = refmethod->clazz;
+       assert(referer);
+
+       /* check if the method itself is already resolved */
+
+       if (IS_FMIREF_RESOLVED(methodref))
+               return resolveSucceeded;
+
+       /* first we must resolve the class containg the method */
+
+       if (!resolve_class_from_name(referer, refmethod,
+                  methodref->p.classref->name, resolveLazy, true, true, &container))
+       {
+               /* the class reference could not be resolved */
+               return resolveFailed; /* exception */
+       }
+       if (!container)
+               return resolveDeferred; /* be lazy */
+
+       assert(container->state & CLASS_LINKED);
+
+       /* now we must find the declaration of the method in `container`
+        * or one of its superclasses */
+
+       if (container->flags & ACC_INTERFACE) {
+               mi = class_resolveinterfacemethod(container,
+                                                                             methodref->name,
+                                                                                 methodref->descriptor,
+                                                                             referer, true);
+
+       } else {
+               mi = class_resolveclassmethod(container,
+                                                                         methodref->name,
+                                                                         methodref->descriptor,
+                                                                         referer, true);
+       }
+
+       if (!mi) {
+               /* The method does not exist. But since we were called lazily, */
+               /* this error must not be reported now. (It will be reported   */
+               /* if eager resolving of this method is ever tried.)           */
+
+               exceptions_clear_exception();
+               return resolveDeferred; /* be lazy */
+       }
+
+       if (invokespecial) {
+               mi = resolve_method_invokespecial_lookup(refmethod, mi);
+               if (!mi)
+                       return resolveFailed; /* exception */
+       }
+
+       /* have the method params already been parsed? no, do it. */
+
+       if (!mi->parseddesc->params)
+               if (!descriptor_params_from_paramtypes(mi->parseddesc, mi->flags))
+                       return resolveFailed;
+
+       /* cache the result of the resolution */
+
+       methodref->p.method = mi;
+
+       /* succeed */
+
+       return resolveSucceeded;
+}
+
+/* resolve_method **************************************************************
+   Resolve an unresolved method reference
+  
+   IN:
+       ref..............struct containing the reference
+       mode.............mode of resolution:
+                            resolveLazy...only resolve if it does not
+                                          require loading classes
+                            resolveEager..load classes if necessary
+  
+   OUT:
+       *result..........set to the result of resolution, or to NULL if
+                        the reference has not been resolved
+                        In the case of an exception, *result is
+                        guaranteed to be set to NULL.
+  
+   RETURN VALUE:
+       true.............everything ok 
+                        (*result may still be NULL for resolveLazy)
+       false............an exception has been thrown
+   
+*******************************************************************************/
+
+bool resolve_method(unresolved_method *ref, resolve_mode_t mode, methodinfo **result)
+{
+       classinfo *referer;
+       classinfo *container;
+       classinfo *declarer;
+       methodinfo *mi;
+       typedesc *paramtypes;
+       int instancecount;
+       int i;
+       resolve_result_t checkresult;
+
+       assert(ref);
+       assert(result);
+       assert(mode == resolveLazy || mode == resolveEager);
+
+#ifdef RESOLVE_VERBOSE
+       unresolved_method_debug_dump(ref,stdout);
+#endif
+
+       *result = NULL;
+
+       /* the class containing the reference */
+
+       referer = ref->referermethod->clazz;
+       assert(referer);
+
+       /* check if the method itself is already resolved */
+
+       if (IS_FMIREF_RESOLVED(ref->methodref)) {
+               mi = ref->methodref->p.method;
+               container = mi->clazz;
+               goto resolved_the_method;
+       }
+
+       /* first we must resolve the class containing the method */
+
+       if (!resolve_class_from_name(referer,ref->referermethod,
+                                          ref->methodref->p.classref->name,mode,true,true,&container))
+       {
+               /* the class reference could not be resolved */
+               return false; /* exception */
+       }
+       if (!container)
+               return true; /* be lazy */
+
+       assert(container);
+       assert(container->state & CLASS_LINKED);
+
+       /* now we must find the declaration of the method in `container`
+        * or one of its superclasses */
+
+       if (container->flags & ACC_INTERFACE) {
+               mi = class_resolveinterfacemethod(container,
+                                                                             ref->methodref->name,
+                                                                                 ref->methodref->descriptor,
+                                                                             referer, true);
+
+       } else {
+               mi = class_resolveclassmethod(container,
+                                                                         ref->methodref->name,
+                                                                         ref->methodref->descriptor,
+                                                                         referer, true);
+       }
+
+       if (!mi) {
+               if (mode == resolveLazy) {
+                       /* The method does not exist. But since we were called lazily, */
+                       /* this error must not be reported now. (It will be reported   */
+                       /* if eager resolving of this method is ever tried.)           */
+
+                       exceptions_clear_exception();
+                       return true; /* be lazy */
+               }
+
+               return false; /* exception */ /* XXX set exceptionptr? */
+       }
+
+       /* { the method reference has been resolved } */
+
+       if (ref->flags & RESOLVE_SPECIAL) {
+               mi = resolve_method_invokespecial_lookup(ref->referermethod,mi);
+               if (!mi)
+                       return false; /* exception */
+       }
+
+       /* have the method params already been parsed? no, do it. */
+
+       if (!mi->parseddesc->params)
+               if (!descriptor_params_from_paramtypes(mi->parseddesc, mi->flags))
+                       return false;
+
+       /* cache the resolution */
+
+       ref->methodref->p.method = mi;
+
+resolved_the_method:
+
+#ifdef ENABLE_VERIFIER
+       if (opt_verify) {
+
+               checkresult = resolve_method_verifier_checks(
+                               ref->referermethod,
+                               ref->methodref,
+                               mi,
+                               (ref->flags & RESOLVE_STATIC));
+
+               if (checkresult != resolveSucceeded)
+                       return (bool) checkresult;
+
+               /* impose loading constraints on params and return type */
+
+               if (!resolve_method_loading_constraints(referer, mi))
+                       return false;
+
+               declarer = mi->clazz;
+               assert(declarer);
+               assert(referer->state & CLASS_LINKED);
+
+               /* for non-static methods we have to check the constraints on the         */
+               /* instance type                                                          */
+
+               if (!(ref->flags & RESOLVE_STATIC)) {
+                       checkresult = resolve_and_check_subtype_set(ref->referermethod,
+                                       &(ref->instancetypes),
+                                       CLASSREF_OR_CLASSINFO(container),
+                                       mode,
+                                       resolveLinkageError);
+                       if (checkresult != resolveSucceeded)
+                               return (bool) checkresult;
+                       instancecount = 1;
+               }
+               else {
+                       instancecount = 0;
+               }
+
+               /* check subtype constraints for TYPE_ADR parameters */
+
+               assert(mi->parseddesc->paramcount == ref->methodref->parseddesc.md->paramcount);
+               paramtypes = mi->parseddesc->paramtypes;
+
+               for (i = 0; i < mi->parseddesc->paramcount-instancecount; i++) {
+                       if (paramtypes[i+instancecount].type == TYPE_ADR) {
+                               if (ref->paramconstraints) {
+                                       checkresult = resolve_and_check_subtype_set(ref->referermethod,
+                                                       ref->paramconstraints + i,
+                                                       CLASSREF_OR_CLASSINFO(paramtypes[i+instancecount].classref),
+                                                       mode,
+                                                       resolveLinkageError);
+                                       if (checkresult != resolveSucceeded)
+                                               return (bool) checkresult;
+                               }
+                       }
+               }
+
+               /* check protected access */
+
+               if (((mi->flags & ACC_PROTECTED) != 0) && !SAME_PACKAGE(declarer,referer))
+               {
+                       checkresult = resolve_and_check_subtype_set(ref->referermethod,
+                                       &(ref->instancetypes),
+                                       CLASSREF_OR_CLASSINFO(referer),
+                                       mode,
+                                       resolveIllegalAccessError);
+                       if (checkresult != resolveSucceeded)
+                               return (bool) checkresult;
+               }
+       }
+#endif /* ENABLE_VERIFIER */
+
+       /* succeed */
+       *result = mi;
+       return true;
+}
+
+/* resolve_method_eager ********************************************************
+   Resolve an unresolved method reference eagerly.
+  
+   IN:
+       ref..............struct containing the reference
+   
+   RETURN VALUE:
+       methodinfo * to the method, or
+          NULL if an exception has been thrown
+   
+*******************************************************************************/
+
+methodinfo * resolve_method_eager(unresolved_method *ref)
+{
+       methodinfo *mi;
+
+       if (!resolve_method(ref,resolveEager,&mi))
+               return NULL;
+
+       return mi;
+}
+
+/******************************************************************************/
+/* CREATING THE DATA STRUCTURES                                               */
+/******************************************************************************/
+
+#ifdef ENABLE_VERIFIER
+static bool unresolved_subtype_set_from_typeinfo(classinfo *referer,
+                                                                                                methodinfo *refmethod,
+                                                                                                unresolved_subtype_set *stset,
+                                                                                                typeinfo_t *tinfo,
+                                                                                                utf *declaredclassname)
+{
+       int count;
+       int i;
+
+       assert(stset);
+       assert(tinfo);
+
+#ifdef RESOLVE_VERBOSE
+       printf("unresolved_subtype_set_from_typeinfo\n");
+#ifdef TYPEINFO_DEBUG
+       typeinfo_print(stdout,tinfo,4);
+#endif
+       printf("    declared classname:");utf_fprint_printable_ascii(stdout,declaredclassname);
+       printf("\n");
+#endif
+
+       if (TYPEINFO_IS_PRIMITIVE(*tinfo)) {
+               exceptions_throw_verifyerror(refmethod,
+                               "Invalid use of returnAddress");
+               return false;
+       }
+
+       if (TYPEINFO_IS_NEWOBJECT(*tinfo)) {
+               exceptions_throw_verifyerror(refmethod,
+                               "Invalid use of uninitialized object");
+               return false;
+       }
+
+       /* the nulltype is always assignable */
+       if (TYPEINFO_IS_NULLTYPE(*tinfo))
+               goto empty_set;
+
+       /* every type is assignable to (BOOTSTRAP)java.lang.Object */
+       if (declaredclassname == utf_java_lang_Object
+                       && referer->classloader == NULL) /* XXX do loading constraints make the second check obsolete? */
+       {
+               goto empty_set;
+       }
+
+       if (tinfo->merged) {
+               count = tinfo->merged->count;
+               stset->subtyperefs = MNEW(classref_or_classinfo,count + 1);
+               for (i=0; i<count; ++i) {
+                       classref_or_classinfo c = tinfo->merged->list[i];
+                       if (tinfo->dimension > 0) {
+                               /* a merge of array types */
+                               /* the merged list contains the possible _element_ types, */
+                               /* so we have to create array types with these elements.  */
+                               if (IS_CLASSREF(c)) {
+                                       c.ref = class_get_classref_multiarray_of(tinfo->dimension,c.ref);
+                               }
+                               else {
+                                       c.cls = class_multiarray_of(tinfo->dimension,c.cls,false);
+                               }
+                       }
+                       stset->subtyperefs[i] = c;
+               }
+               stset->subtyperefs[count].any = NULL; /* terminate */
+       }
+       else {
+               if ((IS_CLASSREF(tinfo->typeclass)
+                                       ? tinfo->typeclass.ref->name
+                                       : tinfo->typeclass.cls->name) == declaredclassname)
+               {
+                       /* the class names are the same */
+                   /* equality is guaranteed by the loading constraints */
+                       goto empty_set;
+               }
+               else {
+                       stset->subtyperefs = MNEW(classref_or_classinfo,1 + 1);
+                       stset->subtyperefs[0] = tinfo->typeclass;
+                       stset->subtyperefs[1].any = NULL; /* terminate */
+               }
+       }
+
+       return true;
+
+empty_set:
+       UNRESOLVED_SUBTYPE_SET_EMTPY(*stset);
+       return true;
+}
+#endif /* ENABLE_VERIFIER */
+
+/* create_unresolved_class *****************************************************
+   Create an unresolved_class struct for the given class reference
+  
+   IN:
+          refmethod........the method triggering the resolution (if any)
+          classref.........the class reference
+          valuetype........value type to check against the resolved class
+                                               may be NULL, if no typeinfo is available
+
+   RETURN VALUE:
+       a pointer to a new unresolved_class struct, or
+          NULL if an exception has been thrown
+
+*******************************************************************************/
+
+#ifdef ENABLE_VERIFIER
+unresolved_class * create_unresolved_class(methodinfo *refmethod,
+                                                                                  constant_classref *classref,
+                                                                                  typeinfo_t *valuetype)
+{
+       unresolved_class *ref;
+
+#ifdef RESOLVE_VERBOSE
+       printf("create_unresolved_class\n");
+       printf("    referer: ");utf_fprint_printable_ascii(stdout,classref->referer->name);fputc('\n',stdout);
+       if (refmethod) {
+               printf("    rmethod: ");utf_fprint_printable_ascii(stdout,refmethod->name);fputc('\n',stdout);
+               printf("    rmdesc : ");utf_fprint_printable_ascii(stdout,refmethod->descriptor);fputc('\n',stdout);
+       }
+       printf("    name   : ");utf_fprint_printable_ascii(stdout,classref->name);fputc('\n',stdout);
+#endif
+
+       ref = NEW(unresolved_class);
+       ref->classref = classref;
+       ref->referermethod = refmethod;
+
+       if (valuetype) {
+               if (!unresolved_subtype_set_from_typeinfo(classref->referer,refmethod,
+                                       &(ref->subtypeconstraints),valuetype,classref->name))
+                       return NULL;
+       }
+       else {
+               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->subtypeconstraints);
+       }
+
+       return ref;
+}
+#endif /* ENABLE_VERIFIER */
+
+/* resolve_create_unresolved_field *********************************************
+   Create an unresolved_field struct for the given field access instruction
+  
+   IN:
+       referer..........the class containing the reference
+          refmethod........the method triggering the resolution (if any)
+          iptr.............the {GET,PUT}{FIELD,STATIC}{,CONST} instruction
+
+   RETURN VALUE:
+       a pointer to a new unresolved_field struct, or
+          NULL if an exception has been thrown
+
+*******************************************************************************/
+
+unresolved_field * resolve_create_unresolved_field(classinfo *referer,
+                                                                                                  methodinfo *refmethod,
+                                                                                                  instruction *iptr)
+{
+       unresolved_field *ref;
+       constant_FMIref *fieldref = NULL;
+
+#ifdef RESOLVE_VERBOSE
+       printf("create_unresolved_field\n");
+       printf("    referer: ");utf_fprint_printable_ascii(stdout,referer->name);fputc('\n',stdout);
+       printf("    rmethod: ");utf_fprint_printable_ascii(stdout,refmethod->name);fputc('\n',stdout);
+       printf("    rmdesc : ");utf_fprint_printable_ascii(stdout,refmethod->descriptor);fputc('\n',stdout);
+#endif
+
+       ref = NEW(unresolved_field);
+       ref->flags = 0;
+       ref->referermethod = refmethod;
+       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->valueconstraints);
+
+       switch (iptr->opc) {
+               case ICMD_PUTFIELD:
+                       ref->flags |= RESOLVE_PUTFIELD;
+                       break;
+
+               case ICMD_PUTFIELDCONST:
+                       ref->flags |= RESOLVE_PUTFIELD;
+                       break;
+
+               case ICMD_PUTSTATIC:
+                       ref->flags |= RESOLVE_PUTFIELD | RESOLVE_STATIC;
+                       break;
+
+               case ICMD_PUTSTATICCONST:
+                       ref->flags |= RESOLVE_PUTFIELD | RESOLVE_STATIC;
+                       break;
+
+               case ICMD_GETFIELD:
+                       break;
+
+               case ICMD_GETSTATIC:
+                       ref->flags |= RESOLVE_STATIC;
+                       break;
+
+#if !defined(NDEBUG)
+               default:
+                       assert(false);
+#endif
+       }
+
+       fieldref = iptr->sx.s23.s3.fmiref;
+
+       assert(fieldref);
+
+#ifdef RESOLVE_VERBOSE
+/*     printf("    class  : ");utf_fprint_printable_ascii(stdout,fieldref->p.classref->name);fputc('\n',stdout);*/
+       printf("    name   : ");utf_fprint_printable_ascii(stdout,fieldref->name);fputc('\n',stdout);
+       printf("    desc   : ");utf_fprint_printable_ascii(stdout,fieldref->descriptor);fputc('\n',stdout);
+       printf("    type   : ");descriptor_debug_print_typedesc(stdout,fieldref->parseddesc.fd);
+       fputc('\n',stdout);
+#endif
+
+       ref->fieldref = fieldref;
+
+       return ref;
+}
+
+/* resolve_constrain_unresolved_field ******************************************
+   Record subtype constraints for a field access.
+  
+   IN:
+       ref..............the unresolved_field structure of the access
+       referer..........the class containing the reference
+          refmethod........the method triggering the resolution (if any)
+          instanceti.......instance typeinfo, if available
+          valueti..........value typeinfo, if available
+
+   RETURN VALUE:
+       true.............everything ok
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+bool resolve_constrain_unresolved_field(unresolved_field *ref,
+                                                                               classinfo *referer, 
+                                                                               methodinfo *refmethod,
+                                                                           typeinfo_t *instanceti,
+                                                                           typeinfo_t *valueti)
+{
+       constant_FMIref *fieldref;
+       int type;
+       typeinfo_t tinfo;
+       typedesc *fd;
+
+       assert(ref);
+
+       fieldref = ref->fieldref;
+       assert(fieldref);
+
+#ifdef RESOLVE_VERBOSE
+       printf("constrain_unresolved_field\n");
+       printf("    referer: ");utf_fprint_printable_ascii(stdout,referer->name);fputc('\n',stdout);
+       printf("    rmethod: ");utf_fprint_printable_ascii(stdout,refmethod->name);fputc('\n',stdout);
+       printf("    rmdesc : ");utf_fprint_printable_ascii(stdout,refmethod->descriptor);fputc('\n',stdout);
+/*     printf("    class  : ");utf_fprint_printable_ascii(stdout,fieldref->p.classref->name);fputc('\n',stdout); */
+       printf("    name   : ");utf_fprint_printable_ascii(stdout,fieldref->name);fputc('\n',stdout);
+       printf("    desc   : ");utf_fprint_printable_ascii(stdout,fieldref->descriptor);fputc('\n',stdout);
+       printf("    type   : ");descriptor_debug_print_typedesc(stdout,fieldref->parseddesc.fd);
+       fputc('\n',stdout);
+#endif
+
+       assert(instanceti || ((ref->flags & RESOLVE_STATIC) != 0));
+       fd = fieldref->parseddesc.fd;
+       assert(fd);
+
+       /* record subtype constraints for the instance type, if any */
+       if (instanceti) {
+               typeinfo_t *insttip;
+
+               /* The instanceslot must contain a reference to a non-array type */
+               if (!TYPEINFO_IS_REFERENCE(*instanceti)) {
+                       exceptions_throw_verifyerror(refmethod, 
+                                       "illegal instruction: field access on non-reference");
+                       return false;
+               }
+               if (TYPEINFO_IS_ARRAY(*instanceti)) {
+                       exceptions_throw_verifyerror(refmethod, 
+                                       "illegal instruction: field access on array");
+                       return false;
+               }
+
+               if (((ref->flags & RESOLVE_PUTFIELD) != 0) &&
+                               TYPEINFO_IS_NEWOBJECT(*instanceti))
+               {
+                       /* The instruction writes a field in an uninitialized object. */
+                       /* This is only allowed when a field of an uninitialized 'this' object is */
+                       /* written inside an initialization method                                */
+
+                       classinfo *initclass;
+                       instruction *ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*instanceti);
+
+                       if (ins != NULL) {
+                               exceptions_throw_verifyerror(refmethod, 
+                                               "accessing field of uninitialized object");
+                               return false;
+                       }
+                       /* XXX check that class of field == refmethod->clazz */
+                       initclass = refmethod->clazz; /* XXX classrefs */
+                       assert(initclass->state & CLASS_LOADED);
+                       assert(initclass->state & CLASS_LINKED);
+
+                       typeinfo_init_classinfo(&tinfo, initclass);
+                       insttip = &tinfo;
+               }
+               else {
+                       insttip = instanceti;
+               }
+               if (!unresolved_subtype_set_from_typeinfo(referer, refmethod,
+                                       &(ref->instancetypes), insttip, 
+                                       FIELDREF_CLASSNAME(fieldref)))
+                       return false;
+       }
+       else {
+               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->instancetypes);
+       }
+
+       /* record subtype constraints for the value type, if any */
+       type = fd->type;
+       if (type == TYPE_ADR && ((ref->flags & RESOLVE_PUTFIELD) != 0)) {
+               assert(valueti);
+               if (!unresolved_subtype_set_from_typeinfo(referer, refmethod,
+                                       &(ref->valueconstraints), valueti, 
+                                       fieldref->parseddesc.fd->classref->name))
+                       return false;
+       }
+       else {
+               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->valueconstraints);
+       }
+
+       return true;
+}
+#endif /* ENABLE_VERIFIER */
+
+/* resolve_create_unresolved_method ********************************************
+   Create an unresolved_method struct for the given method invocation
+  
+   IN:
+       referer..........the class containing the reference
+          refmethod........the method triggering the resolution (if any)
+          iptr.............the INVOKE* instruction
+
+   RETURN VALUE:
+       a pointer to a new unresolved_method struct, or
+          NULL if an exception has been thrown
+
+*******************************************************************************/
+
+unresolved_method * resolve_create_unresolved_method(classinfo *referer,
+                                                                                                        methodinfo *refmethod,
+                                                                                                        constant_FMIref *methodref,
+                                                                                                        bool invokestatic,
+                                                                                                        bool invokespecial)
+{
+       unresolved_method *ref;
+
+       assert(methodref);
+
+#ifdef RESOLVE_VERBOSE
+       printf("create_unresolved_method\n");
+       printf("    referer: ");utf_fprint_printable_ascii(stdout,referer->name);fputc('\n',stdout);
+       printf("    rmethod: ");utf_fprint_printable_ascii(stdout,refmethod->name);fputc('\n',stdout);
+       printf("    rmdesc : ");utf_fprint_printable_ascii(stdout,refmethod->descriptor);fputc('\n',stdout);
+       printf("    name   : ");utf_fprint_printable_ascii(stdout,methodref->name);fputc('\n',stdout);
+       printf("    desc   : ");utf_fprint_printable_ascii(stdout,methodref->descriptor);fputc('\n',stdout);
+#endif
+
+       /* allocate params if necessary */
+       if (!methodref->parseddesc.md->params)
+               if (!descriptor_params_from_paramtypes(methodref->parseddesc.md,
+                                       (invokestatic) ? ACC_STATIC : ACC_NONE))
+                       return NULL;
+
+       /* create the data structure */
+       ref = NEW(unresolved_method);
+       ref->flags = ((invokestatic) ? RESOLVE_STATIC : 0)
+                          | ((invokespecial) ? RESOLVE_SPECIAL : 0);
+       ref->referermethod = refmethod;
+       ref->methodref = methodref;
+       ref->paramconstraints = NULL;
+       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->instancetypes);
+
+       return ref;
+}
+
+
+/* resolve_constrain_unresolved_method_instance ********************************
+   Record subtype constraints for the instance argument of a method call.
+  
+   IN:
+       ref..............the unresolved_method structure of the call
+       referer..........the class containing the reference
+          refmethod........the method triggering the resolution (if any)
+          iptr.............the INVOKE* instruction
+
+   RETURN VALUE:
+       true.............everything ok
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+bool resolve_constrain_unresolved_method_instance(unresolved_method *ref,
+                                                                                                 methodinfo *refmethod,
+                                                                                                 typeinfo_t *instanceti,
+                                                                                                 bool invokespecial)
+{
+       constant_FMIref   *methodref;
+       constant_classref *instanceref;
+       typeinfo_t           tinfo;
+       typeinfo_t          *tip;
+
+       assert(ref);
+       methodref = ref->methodref;
+       assert(methodref);
+
+       /* XXX clean this up */
+       instanceref = IS_FMIREF_RESOLVED(methodref)
+               ? class_get_self_classref(methodref->p.method->clazz)
+               : methodref->p.classref;
+
+#ifdef RESOLVE_VERBOSE
+       printf("resolve_constrain_unresolved_method_instance\n");
+       printf("    rmethod: "); method_println(refmethod);
+       printf("    mref   : "); method_methodref_println(methodref);
+#endif
+
+       /* record subtype constraints for the instance type, if any */
+
+       if (invokespecial && TYPEINFO_IS_NEWOBJECT(*instanceti))
+       {   /* XXX clean up */
+               instruction *ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*instanceti);
+               classref_or_classinfo initclass = (ins) ? ins[-1].sx.val.c
+                                                                        : CLASSREF_OR_CLASSINFO(refmethod->clazz);
+               tip = &tinfo;
+               if (!typeinfo_init_class(tip, initclass))
+                       return false;
+       }
+       else {
+               tip = instanceti;
+       }
+
+       if (!unresolved_subtype_set_from_typeinfo(refmethod->clazz, refmethod,
+                               &(ref->instancetypes),tip,instanceref->name))
+               return false;
+
+       return true;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+
+/* resolve_constrain_unresolved_method_params  *********************************
+   Record subtype constraints for the non-instance arguments of a method call.
+  
+   IN:
+       jd...............current jitdata (for looking up variables)
+       ref..............the unresolved_method structure of the call
+          refmethod........the method triggering the resolution (if any)
+          iptr.............the INVOKE* instruction
+
+   RETURN VALUE:
+       true.............everything ok
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+bool resolve_constrain_unresolved_method_params(jitdata *jd,
+                                                                                               unresolved_method *ref,
+                                                                                               methodinfo *refmethod,
+                                                                                               instruction *iptr)
+{
+       constant_FMIref *methodref;
+       varinfo *param;
+       methoddesc *md;
+       int i,j;
+       int type;
+       int instancecount;
+
+       assert(ref);
+       methodref = ref->methodref;
+       assert(methodref);
+       md = methodref->parseddesc.md;
+       assert(md);
+       assert(md->params != NULL);
+
+#ifdef RESOLVE_VERBOSE
+       printf("resolve_constrain_unresolved_method_params\n");
+       printf("    rmethod: "); method_println(refmethod);
+       printf("    mref   : "); method_methodref_println(methodref);
+#endif
+
+       instancecount = (ref->flags & RESOLVE_STATIC) ? 0 : 1;
+
+       /* record subtype constraints for the parameter types, if any */
+
+       for (i=md->paramcount-1-instancecount; i>=0; --i) {
+               param = VAR(iptr->sx.s23.s2.args[i+instancecount]);
+               type = md->paramtypes[i+instancecount].type;
+
+               assert(param);
+               assert(type == param->type);
+
+               if (type == TYPE_ADR) {
+                       if (!ref->paramconstraints) {
+                               ref->paramconstraints = MNEW(unresolved_subtype_set,md->paramcount);
+                               for (j=md->paramcount-1-instancecount; j>i; --j)
+                                       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[j]);
+                       }
+                       assert(ref->paramconstraints);
+                       if (!unresolved_subtype_set_from_typeinfo(refmethod->clazz, refmethod,
+                                               ref->paramconstraints + i,&(param->typeinfo),
+                                               md->paramtypes[i+instancecount].classref->name))
+                               return false;
+               }
+               else {
+                       if (ref->paramconstraints)
+                               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[i]);
+               }
+       }
+
+       return true;
+}
+#endif /* ENABLE_VERIFIER */
+
+
+/* resolve_constrain_unresolved_method_params_stackbased ***********************
+   Record subtype constraints for the non-instance arguments of a method call.
+  
+   IN:
+       ref..............the unresolved_method structure of the call
+          refmethod........the method triggering the resolution (if any)
+          stack............TOS before the INVOKE instruction
+
+   RETURN VALUE:
+       true.............everything ok
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+bool resolve_constrain_unresolved_method_params_stackbased(
+               unresolved_method *ref,
+               methodinfo *refmethod,
+               typedescriptor_t *stack)
+{
+       constant_FMIref *methodref;
+       typedescriptor_t *param;
+       methoddesc *md;
+       int i,j;
+       int type;
+       int instancecount;
+
+       assert(ref);
+       methodref = ref->methodref;
+       assert(methodref);
+       md = methodref->parseddesc.md;
+       assert(md);
+       assert(md->params != NULL);
+
+#ifdef RESOLVE_VERBOSE
+       printf("resolve_constrain_unresolved_method_params_stackbased\n");
+       printf("    rmethod: "); method_println(refmethod);
+       printf("    mref   : "); method_methodref_println(methodref);
+#endif
+
+       instancecount = (ref->flags & RESOLVE_STATIC) ? 0 : 1;
+
+       /* record subtype constraints for the parameter types, if any */
+
+       param = stack - (md->paramslots - 1 - instancecount);
+
+       for (i = instancecount; i < md->paramcount; ++i) {
+               type = md->paramtypes[i].type;
+
+               assert(type == param->type);
+
+               if (type == TYPE_ADR) {
+                       if (!ref->paramconstraints) {
+                               ref->paramconstraints = MNEW(unresolved_subtype_set,md->paramcount);
+                               for (j = 0; j < i - instancecount; ++j)
+                                       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[j]);
+                       }
+                       assert(ref->paramconstraints);
+                       if (!unresolved_subtype_set_from_typeinfo(refmethod->clazz, refmethod,
+                                               ref->paramconstraints + i - instancecount,&(param->typeinfo),
+                                               md->paramtypes[i].classref->name))
+                               return false;
+               }
+               else {
+                       if (ref->paramconstraints)
+                               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[i]);
+               }
+
+               param += (IS_2_WORD_TYPE(type)) ? 2 : 1;
+       }
+
+       return true;
+}
+#endif /* ENABLE_VERIFIER */
+
+
+/******************************************************************************/
+/* FREEING MEMORY                                                             */
+/******************************************************************************/
+
+#ifdef ENABLE_VERIFIER
+inline static void unresolved_subtype_set_free_list(classref_or_classinfo *list)
+{
+       if (list) {
+               classref_or_classinfo *p = list;
+
+               /* this is silly. we *only* need to count the elements for MFREE */
+               while ((p++)->any)
+                       ;
+               MFREE(list,classref_or_classinfo,(p - list));
+       }
+}
+#endif /* ENABLE_VERIFIER */
+
+/* unresolved_class_free *******************************************************
+   Free the memory used by an unresolved_class
+  
+   IN:
+       ref..............the unresolved_class
+
+*******************************************************************************/
+
+void unresolved_class_free(unresolved_class *ref)
+{
+       assert(ref);
+
+#ifdef ENABLE_VERIFIER
+       unresolved_subtype_set_free_list(ref->subtypeconstraints.subtyperefs);
+#endif
+       FREE(ref,unresolved_class);
+}
+
+/* unresolved_field_free *******************************************************
+   Free the memory used by an unresolved_field
+  
+   IN:
+       ref..............the unresolved_field
+
+*******************************************************************************/
+
+void unresolved_field_free(unresolved_field *ref)
+{
+       assert(ref);
+
+#ifdef ENABLE_VERIFIER
+       unresolved_subtype_set_free_list(ref->instancetypes.subtyperefs);
+       unresolved_subtype_set_free_list(ref->valueconstraints.subtyperefs);
+#endif
+       FREE(ref,unresolved_field);
+}
+
+/* unresolved_method_free ******************************************************
+   Free the memory used by an unresolved_method
+  
+   IN:
+       ref..............the unresolved_method
+
+*******************************************************************************/
+
+void unresolved_method_free(unresolved_method *ref)
+{
+       assert(ref);
+
+#ifdef ENABLE_VERIFIER
+       unresolved_subtype_set_free_list(ref->instancetypes.subtyperefs);
+       if (ref->paramconstraints) {
+               int i;
+               int count = ref->methodref->parseddesc.md->paramcount;
+
+               for (i=0; i<count; ++i)
+                       unresolved_subtype_set_free_list(ref->paramconstraints[i].subtyperefs);
+               MFREE(ref->paramconstraints,unresolved_subtype_set,count);
+       }
+#endif
+       FREE(ref,unresolved_method);
+}
+
+/******************************************************************************/
+/* DEBUG DUMPS                                                                */
+/******************************************************************************/
+
+#if !defined(NDEBUG)
+
+/* unresolved_subtype_set_debug_dump *******************************************
+   Print debug info for unresolved_subtype_set to stream
+  
+   IN:
+       stset............the unresolved_subtype_set
+          file.............the stream
+
+*******************************************************************************/
+
+void unresolved_subtype_set_debug_dump(unresolved_subtype_set *stset,FILE *file)
+{
+       classref_or_classinfo *p;
+
+       if (SUBTYPESET_IS_EMPTY(*stset)) {
+               fprintf(file,"        (empty)\n");
+       }
+       else {
+               p = stset->subtyperefs;
+               for (;p->any; ++p) {
+                       if (IS_CLASSREF(*p)) {
+                               fprintf(file,"        ref: ");
+                               utf_fprint_printable_ascii(file,p->ref->name);
+                       }
+                       else {
+                               fprintf(file,"        cls: ");
+                               utf_fprint_printable_ascii(file,p->cls->name);
+                       }
+                       fputc('\n',file);
+               }
+       }
+}
+
+/* unresolved_class_debug_dump *************************************************
+   Print debug info for unresolved_class to stream
+  
+   IN:
+       ref..............the unresolved_class
+          file.............the stream
+
+*******************************************************************************/
+
+void unresolved_class_debug_dump(unresolved_class *ref,FILE *file)
+{
+       fprintf(file,"unresolved_class(%p):\n",(void *)ref);
+       if (ref) {
+               fprintf(file,"    referer   : ");
+               utf_fprint_printable_ascii(file,ref->classref->referer->name); fputc('\n',file);
+               fprintf(file,"    refmethod : ");
+               utf_fprint_printable_ascii(file,ref->referermethod->name); fputc('\n',file);
+               fprintf(file,"    refmethodd: ");
+               utf_fprint_printable_ascii(file,ref->referermethod->descriptor); fputc('\n',file);
+               fprintf(file,"    classname : ");
+               utf_fprint_printable_ascii(file,ref->classref->name); fputc('\n',file);
+               fprintf(file,"    subtypeconstraints:\n");
+               unresolved_subtype_set_debug_dump(&(ref->subtypeconstraints),file);
+       }
+}
+
+/* unresolved_field_debug_dump *************************************************
+   Print debug info for unresolved_field to stream
+  
+   IN:
+       ref..............the unresolved_field
+          file.............the stream
+
+*******************************************************************************/
+
+void unresolved_field_debug_dump(unresolved_field *ref,FILE *file)
+{
+       fprintf(file,"unresolved_field(%p):\n",(void *)ref);
+       if (ref) {
+               fprintf(file,"    referer   : ");
+               utf_fprint_printable_ascii(file,ref->referermethod->clazz->name); fputc('\n',file);
+               fprintf(file,"    refmethod : ");
+               utf_fprint_printable_ascii(file,ref->referermethod->name); fputc('\n',file);
+               fprintf(file,"    refmethodd: ");
+               utf_fprint_printable_ascii(file,ref->referermethod->descriptor); fputc('\n',file);
+               fprintf(file,"    classname : ");
+               utf_fprint_printable_ascii(file,FIELDREF_CLASSNAME(ref->fieldref)); fputc('\n',file);
+               fprintf(file,"    name      : ");
+               utf_fprint_printable_ascii(file,ref->fieldref->name); fputc('\n',file);
+               fprintf(file,"    descriptor: ");
+               utf_fprint_printable_ascii(file,ref->fieldref->descriptor); fputc('\n',file);
+               fprintf(file,"    parseddesc: ");
+               descriptor_debug_print_typedesc(file,ref->fieldref->parseddesc.fd); fputc('\n',file);
+               fprintf(file,"    flags     : %04x\n",ref->flags);
+               fprintf(file,"    instancetypes:\n");
+               unresolved_subtype_set_debug_dump(&(ref->instancetypes),file);
+               fprintf(file,"    valueconstraints:\n");
+               unresolved_subtype_set_debug_dump(&(ref->valueconstraints),file);
+       }
+}
+
+/* unresolved_method_debug_dump ************************************************
+   Print debug info for unresolved_method to stream
+  
+   IN:
+       ref..............the unresolved_method
+          file.............the stream
+
+*******************************************************************************/
+
+void unresolved_method_debug_dump(unresolved_method *ref,FILE *file)
+{
+       int i;
+
+       fprintf(file,"unresolved_method(%p):\n",(void *)ref);
+       if (ref) {
+               fprintf(file,"    referer   : ");
+               utf_fprint_printable_ascii(file,ref->referermethod->clazz->name); fputc('\n',file);
+               fprintf(file,"    refmethod : ");
+               utf_fprint_printable_ascii(file,ref->referermethod->name); fputc('\n',file);
+               fprintf(file,"    refmethodd: ");
+               utf_fprint_printable_ascii(file,ref->referermethod->descriptor); fputc('\n',file);
+               fprintf(file,"    classname : ");
+               utf_fprint_printable_ascii(file,METHODREF_CLASSNAME(ref->methodref)); fputc('\n',file);
+               fprintf(file,"    name      : ");
+               utf_fprint_printable_ascii(file,ref->methodref->name); fputc('\n',file);
+               fprintf(file,"    descriptor: ");
+               utf_fprint_printable_ascii(file,ref->methodref->descriptor); fputc('\n',file);
+               fprintf(file,"    parseddesc: ");
+               descriptor_debug_print_methoddesc(file,ref->methodref->parseddesc.md); fputc('\n',file);
+               fprintf(file,"    flags     : %04x\n",ref->flags);
+               fprintf(file,"    instancetypes:\n");
+               unresolved_subtype_set_debug_dump(&(ref->instancetypes),file);
+               fprintf(file,"    paramconstraints:\n");
+               if (ref->paramconstraints) {
+                       for (i=0; i<ref->methodref->parseddesc.md->paramcount; ++i) {
+                               fprintf(file,"      param %d:\n",i);
+                               unresolved_subtype_set_debug_dump(ref->paramconstraints + i,file);
+                       }
+               }
+               else {
+                       fprintf(file,"      (empty)\n");
+               }
+       }
+}
+#endif /* !defined(NDEBUG) */
+
+
+/*
+ * 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/resolve.h b/src/vm/resolve.h
deleted file mode 100644 (file)
index 6813820..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/* src/vm/resolve.h - resolving classes/interfaces/fields/methods
-
-   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 _RESOLVE_H
-#define _RESOLVE_H
-
-/* forward declarations *******************************************************/
-
-typedef struct unresolved_class unresolved_class;
-typedef struct unresolved_field unresolved_field;
-typedef struct unresolved_method unresolved_method;
-typedef struct unresolved_subtype_set unresolved_subtype_set;
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#include "vm/jit/jit.h"
-#include "vm/jit/reg.h"
-#include "vm/jit/verify/typeinfo.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/method.h"
-#include "vmcore/references.h"
-
-
-/* constants ******************************************************************/
-
-#define RESOLVE_STATIC    0x0001  /* ref to static fields/methods             */
-#define RESOLVE_PUTFIELD  0x0002  /* field ref inside a PUT{FIELD,STATIC}...  */
-#define RESOLVE_SPECIAL   0x0004  /* method ref inside INVOKESPECIAL          */
-
-
-/* enums **********************************************************************/
-
-typedef enum {
-       resolveLazy,
-       resolveEager
-} resolve_mode_t;
-
-typedef enum {
-       resolveLinkageError,
-       resolveIllegalAccessError
-} resolve_err_t;
-
-typedef enum {
-       resolveFailed = false,  /* this must be a false value */
-       resolveDeferred = true, /* this must be a true value  */
-       resolveSucceeded
-} resolve_result_t;
-
-/* structs ********************************************************************/
-
-struct unresolved_subtype_set {
-       classref_or_classinfo *subtyperefs;     /* NULL terminated list */
-};
-
-struct unresolved_class {
-       constant_classref      *classref;
-       methodinfo                     *referermethod;
-       unresolved_subtype_set  subtypeconstraints;
-};
-
-/* XXX unify heads of unresolved_field and unresolved_method? */
-
-struct unresolved_field {
-       constant_FMIref *fieldref;
-       methodinfo      *referermethod;
-       s4               flags;
-       
-       unresolved_subtype_set  instancetypes;
-       unresolved_subtype_set  valueconstraints;
-};
-
-struct unresolved_method {
-       constant_FMIref *methodref;
-       methodinfo      *referermethod;
-       s4               flags;
-       
-       unresolved_subtype_set  instancetypes;
-       unresolved_subtype_set *paramconstraints;
-};
-
-#define SUBTYPESET_IS_EMPTY(stset) \
-       ((stset).subtyperefs == NULL)
-
-#define UNRESOLVED_SUBTYPE_SET_EMTPY(stset) \
-       do { (stset).subtyperefs = NULL; } while(0)
-
-
-/* function prototypes ********************************************************/
-
-void resolve_handle_pending_exception(bool throwError);
-
-bool resolve_class_from_name(classinfo* referer,methodinfo *refmethod,
-                                               utf *classname,
-                                               resolve_mode_t mode,
-                                               bool checkaccess,
-                                               bool link,
-                                               classinfo **result);
-
-bool resolve_classref(methodinfo *refmethod,
-                                constant_classref *ref,
-                                resolve_mode_t mode,
-                                bool checkaccess,
-                            bool link,
-                                classinfo **result);
-
-bool resolve_classref_or_classinfo(methodinfo *refmethod,
-                                                         classref_or_classinfo cls,
-                                                         resolve_mode_t mode,
-                                                         bool checkaccess,
-                                                         bool link,
-                                                         classinfo **result);
-
-classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool checkaccess);
-
-bool resolve_class_from_typedesc(typedesc *d,bool checkaccess,bool link,classinfo **result);
-
-#ifdef ENABLE_VERIFIER
-bool resolve_class(unresolved_class *ref,
-                         resolve_mode_t mode,
-                         bool checkaccess,
-                         classinfo **result);
-
-classinfo * resolve_class_eager(unresolved_class *ref);
-classinfo * resolve_class_eager_no_access_check(unresolved_class *ref);
-#endif /* ENABLE_VERIFIER */
-
-bool resolve_field(unresolved_field *ref,
-                         resolve_mode_t mode,
-                         fieldinfo **result);
-
-bool resolve_method(unresolved_method *ref,
-                         resolve_mode_t mode,
-                          methodinfo **result);
-
-classinfo * resolve_classref_eager(constant_classref *ref);
-classinfo * resolve_classref_eager_nonabstract(constant_classref *ref);
-fieldinfo * resolve_field_eager(unresolved_field *ref);
-methodinfo * resolve_method_eager(unresolved_method *ref);
-
-#ifdef ENABLE_VERIFIER
-unresolved_class * create_unresolved_class(methodinfo *refmethod,
-                                               constant_classref *classref,
-                                               typeinfo_t *valuetype);
-#endif
-
-unresolved_field *resolve_create_unresolved_field(classinfo *referer,
-                                                                                         methodinfo *refmethod,
-                                                                                         instruction *iptr);
-
-unresolved_method * resolve_create_unresolved_method(classinfo *referer,
-                                                                                                        methodinfo *refmethod,
-                                                                                                        constant_FMIref *methodref,
-                                                                                                        bool invokestatic,
-                                                                                                        bool invokespecial);
-
-void unresolved_class_free(unresolved_class *ref);
-void unresolved_field_free(unresolved_field *ref);
-void unresolved_method_free(unresolved_method *ref);
-
-resolve_result_t resolve_method_lazy(methodinfo *refmethod,
-                                                                        constant_FMIref *methodref,
-                                                                        bool invokespecial);
-
-resolve_result_t resolve_field_lazy(methodinfo *refmethod,
-                                                                       constant_FMIref *fieldref);
-
-#if defined(ENABLE_VERIFIER)
-resolve_result_t resolve_field_verifier_checks(methodinfo *refmethod,
-                                                                                          constant_FMIref *fieldref,
-                                                                                          classinfo *container,
-                                                                                          fieldinfo *fi,
-                                                                                          typeinfo_t *instanceti,
-                                                                                          typeinfo_t *valueti,
-                                                                                          bool isstatic,
-                                                                                          bool isput);
-
-bool resolve_constrain_unresolved_field(unresolved_field *ref,
-                                                                               classinfo *referer, 
-                                                                               methodinfo *refmethod,
-                                                                           typeinfo_t *instanceti,
-                                                                           typeinfo_t *valueti);
-
-resolve_result_t resolve_method_verifier_checks(methodinfo *refmethod,
-                                                                                               constant_FMIref *methodref,
-                                                                                               methodinfo *mi,
-                                                                                               bool invokestatic);
-
-resolve_result_t resolve_method_instance_type_checks(methodinfo *refmethod,
-                                                                                                        methodinfo *mi,
-                                                                                                        typeinfo_t *instanceti,
-                                                                                                        bool invokespecial);
-
-resolve_result_t resolve_method_param_type_checks(jitdata *jd, 
-                                                                                                 methodinfo *refmethod,
-                                                                                                 instruction *iptr, 
-                                                                                                 methodinfo *mi,
-                                                                                                 bool invokestatic);
-
-resolve_result_t resolve_method_param_type_checks_stackbased(
-               methodinfo *refmethod, 
-               methodinfo *mi,
-               bool invokestatic, 
-               typedescriptor_t *stack);
-
-bool resolve_method_loading_constraints(classinfo *referer,
-                                                                               methodinfo *mi);
-
-bool resolve_constrain_unresolved_method_instance(unresolved_method *ref,
-                                                                                                 methodinfo *refmethod,
-                                                                                                 typeinfo_t *instanceti,
-                                                                                                 bool invokespecial);
-
-bool resolve_constrain_unresolved_method_params(jitdata *jd,
-                                                                                               unresolved_method *ref,
-                                                                                               methodinfo *refmethod,
-                                                                                               instruction *iptr);
-
-bool resolve_constrain_unresolved_method_params_stackbased(
-               unresolved_method *ref,
-               methodinfo *refmethod,
-               typedescriptor_t *stack);
-
-#endif /* defined(ENABLE_VERIFIER) */
-
-#ifndef NDEBUG
-void unresolved_class_debug_dump(unresolved_class *ref,FILE *file);
-void unresolved_field_debug_dump(unresolved_field *ref,FILE *file);
-void unresolved_method_debug_dump(unresolved_method *ref,FILE *file);
-void unresolved_subtype_set_debug_dump(unresolved_subtype_set *stset,FILE *file);
-#endif
-       
-#endif /* _RESOLVE_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/resolve.hpp b/src/vm/resolve.hpp
new file mode 100644 (file)
index 0000000..f75f173
--- /dev/null
@@ -0,0 +1,284 @@
+/* src/vm/resolve.hpp - resolving classes/interfaces/fields/methods
+
+   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 _RESOLVE_HPP
+#define _RESOLVE_HPP
+
+/* forward declarations *******************************************************/
+
+typedef struct unresolved_class unresolved_class;
+typedef struct unresolved_field unresolved_field;
+typedef struct unresolved_method unresolved_method;
+typedef struct unresolved_subtype_set unresolved_subtype_set;
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/global.h"
+#include "vm/method.hpp"
+#include "vm/references.h"
+
+#include "vm/jit/jit.hpp"
+#include "vm/jit/reg.h"
+
+#include "vm/jit/ir/instruction.hpp"
+#include "vm/jit/verify/typeinfo.hpp"
+
+
+/* constants ******************************************************************/
+
+#define RESOLVE_STATIC    0x0001  /* ref to static fields/methods             */
+#define RESOLVE_PUTFIELD  0x0002  /* field ref inside a PUT{FIELD,STATIC}...  */
+#define RESOLVE_SPECIAL   0x0004  /* method ref inside INVOKESPECIAL          */
+
+
+/* enums **********************************************************************/
+
+typedef enum {
+       resolveLazy,
+       resolveEager
+} resolve_mode_t;
+
+typedef enum {
+       resolveLinkageError,
+       resolveIllegalAccessError
+} resolve_err_t;
+
+typedef enum {
+       resolveFailed = false,  /* this must be a false value */
+       resolveDeferred = true, /* this must be a true value  */
+       resolveSucceeded
+} resolve_result_t;
+
+/* structs ********************************************************************/
+
+struct unresolved_subtype_set {
+       classref_or_classinfo *subtyperefs;     /* NULL terminated list */
+};
+
+struct unresolved_class {
+       constant_classref      *classref;
+       methodinfo                     *referermethod;
+       unresolved_subtype_set  subtypeconstraints;
+};
+
+/* XXX unify heads of unresolved_field and unresolved_method? */
+
+struct unresolved_field {
+       constant_FMIref *fieldref;
+       methodinfo      *referermethod;
+       s4               flags;
+       
+       unresolved_subtype_set  instancetypes;
+       unresolved_subtype_set  valueconstraints;
+};
+
+struct unresolved_method {
+       constant_FMIref *methodref;
+       methodinfo      *referermethod;
+       s4               flags;
+       
+       unresolved_subtype_set  instancetypes;
+       unresolved_subtype_set *paramconstraints;
+};
+
+#define SUBTYPESET_IS_EMPTY(stset) \
+       ((stset).subtyperefs == NULL)
+
+#define UNRESOLVED_SUBTYPE_SET_EMTPY(stset) \
+       do { (stset).subtyperefs = NULL; } while(0)
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void resolve_handle_pending_exception(bool throwError);
+
+bool resolve_class_from_name(classinfo* referer,methodinfo *refmethod,
+                                               utf *classname,
+                                               resolve_mode_t mode,
+                                               bool checkaccess,
+                                               bool link,
+                                               classinfo **result);
+
+bool resolve_classref(methodinfo *refmethod,
+                                constant_classref *ref,
+                                resolve_mode_t mode,
+                                bool checkaccess,
+                            bool link,
+                                classinfo **result);
+
+bool resolve_classref_or_classinfo(methodinfo *refmethod,
+                                                         classref_or_classinfo cls,
+                                                         resolve_mode_t mode,
+                                                         bool checkaccess,
+                                                         bool link,
+                                                         classinfo **result);
+
+classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool checkaccess);
+
+bool resolve_class_from_typedesc(typedesc *d,bool checkaccess,bool link,classinfo **result);
+
+#ifdef ENABLE_VERIFIER
+bool resolve_class(unresolved_class *ref,
+                         resolve_mode_t mode,
+                         bool checkaccess,
+                         classinfo **result);
+
+classinfo * resolve_class_eager(unresolved_class *ref);
+classinfo * resolve_class_eager_no_access_check(unresolved_class *ref);
+#endif /* ENABLE_VERIFIER */
+
+bool resolve_field(unresolved_field *ref,
+                         resolve_mode_t mode,
+                         fieldinfo **result);
+
+bool resolve_method(unresolved_method *ref,
+                         resolve_mode_t mode,
+                          methodinfo **result);
+
+classinfo * resolve_classref_eager(constant_classref *ref);
+classinfo * resolve_classref_eager_nonabstract(constant_classref *ref);
+fieldinfo * resolve_field_eager(unresolved_field *ref);
+methodinfo * resolve_method_eager(unresolved_method *ref);
+
+#ifdef ENABLE_VERIFIER
+unresolved_class * create_unresolved_class(methodinfo *refmethod,
+                                               constant_classref *classref,
+                                               typeinfo_t *valuetype);
+#endif
+
+unresolved_field *resolve_create_unresolved_field(classinfo *referer,
+                                                                                         methodinfo *refmethod,
+                                                                                         instruction *iptr);
+
+unresolved_method * resolve_create_unresolved_method(classinfo *referer,
+                                                                                                        methodinfo *refmethod,
+                                                                                                        constant_FMIref *methodref,
+                                                                                                        bool invokestatic,
+                                                                                                        bool invokespecial);
+
+void unresolved_class_free(unresolved_class *ref);
+void unresolved_field_free(unresolved_field *ref);
+void unresolved_method_free(unresolved_method *ref);
+
+resolve_result_t resolve_method_lazy(methodinfo *refmethod,
+                                                                        constant_FMIref *methodref,
+                                                                        bool invokespecial);
+
+resolve_result_t resolve_field_lazy(methodinfo *refmethod,
+                                                                       constant_FMIref *fieldref);
+
+#if defined(ENABLE_VERIFIER)
+resolve_result_t resolve_field_verifier_checks(methodinfo *refmethod,
+                                                                                          constant_FMIref *fieldref,
+                                                                                          classinfo *container,
+                                                                                          fieldinfo *fi,
+                                                                                          typeinfo_t *instanceti,
+                                                                                          typeinfo_t *valueti,
+                                                                                          bool isstatic,
+                                                                                          bool isput);
+
+bool resolve_constrain_unresolved_field(unresolved_field *ref,
+                                                                               classinfo *referer, 
+                                                                               methodinfo *refmethod,
+                                                                           typeinfo_t *instanceti,
+                                                                           typeinfo_t *valueti);
+
+resolve_result_t resolve_method_verifier_checks(methodinfo *refmethod,
+                                                                                               constant_FMIref *methodref,
+                                                                                               methodinfo *mi,
+                                                                                               bool invokestatic);
+
+resolve_result_t resolve_method_instance_type_checks(methodinfo *refmethod,
+                                                                                                        methodinfo *mi,
+                                                                                                        typeinfo_t *instanceti,
+                                                                                                        bool invokespecial);
+
+resolve_result_t resolve_method_param_type_checks(jitdata *jd, 
+                                                                                                 methodinfo *refmethod,
+                                                                                                 instruction *iptr, 
+                                                                                                 methodinfo *mi,
+                                                                                                 bool invokestatic);
+
+resolve_result_t resolve_method_param_type_checks_stackbased(
+               methodinfo *refmethod, 
+               methodinfo *mi,
+               bool invokestatic, 
+               typedescriptor_t *stack);
+
+bool resolve_method_loading_constraints(classinfo *referer,
+                                                                               methodinfo *mi);
+
+bool resolve_constrain_unresolved_method_instance(unresolved_method *ref,
+                                                                                                 methodinfo *refmethod,
+                                                                                                 typeinfo_t *instanceti,
+                                                                                                 bool invokespecial);
+
+bool resolve_constrain_unresolved_method_params(jitdata *jd,
+                                                                                               unresolved_method *ref,
+                                                                                               methodinfo *refmethod,
+                                                                                               instruction *iptr);
+
+bool resolve_constrain_unresolved_method_params_stackbased(
+               unresolved_method *ref,
+               methodinfo *refmethod,
+               typedescriptor_t *stack);
+
+#endif /* defined(ENABLE_VERIFIER) */
+
+#ifndef NDEBUG
+void unresolved_class_debug_dump(unresolved_class *ref,FILE *file);
+void unresolved_field_debug_dump(unresolved_field *ref,FILE *file);
+void unresolved_method_debug_dump(unresolved_method *ref,FILE *file);
+void unresolved_subtype_set_debug_dump(unresolved_subtype_set *stset,FILE *file);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+       
+#endif /* _RESOLVE_HPP */
+
+/*
+ * 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/rt-timing.c b/src/vm/rt-timing.c
new file mode 100644 (file)
index 0000000..2064de2
--- /dev/null
@@ -0,0 +1,203 @@
+/* src/vm/rt-timing.c - POSIX real-time timing utilities
+
+   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 <errno.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "vm/global.h"
+#include "vm/rt-timing.h"
+
+
+struct rt_timing_stat {
+       int index;
+       int totalindex;
+       const char *name;
+};
+
+static struct rt_timing_stat rt_timing_stat_defs[] = {
+    { RT_TIMING_JIT_CHECKS      ,RT_TIMING_JIT_TOTAL , "checks at beginning" },
+    { RT_TIMING_JIT_PARSE       ,RT_TIMING_JIT_TOTAL , "parse" },
+    { RT_TIMING_JIT_STACK       ,RT_TIMING_JIT_TOTAL , "analyse_stack" },
+    { RT_TIMING_JIT_TYPECHECK   ,RT_TIMING_JIT_TOTAL , "typecheck" },
+    { RT_TIMING_JIT_LOOP        ,RT_TIMING_JIT_TOTAL , "loop" },
+    { RT_TIMING_JIT_IFCONV      ,RT_TIMING_JIT_TOTAL , "if conversion" },
+    { RT_TIMING_JIT_ALLOC       ,RT_TIMING_JIT_TOTAL , "register allocation" },
+    { RT_TIMING_JIT_RPLPOINTS   ,RT_TIMING_JIT_TOTAL , "replacement point generation" },
+    { RT_TIMING_JIT_CODEGEN     ,RT_TIMING_JIT_TOTAL , "codegen" },
+    { RT_TIMING_JIT_TOTAL       ,-1                  , "total compile time" },
+    { -1                        ,-1                  , "" },
+
+    { RT_TIMING_LINK_RESOLVE    ,RT_TIMING_LINK_TOTAL, "link: resolve superclass/superinterfaces"},
+    { RT_TIMING_LINK_C_VFTBL    ,RT_TIMING_LINK_TOTAL, "link: compute vftbl length"},
+    { RT_TIMING_LINK_ABSTRACT   ,RT_TIMING_LINK_TOTAL, "link: handle abstract methods"},
+    { RT_TIMING_LINK_C_IFTBL    ,RT_TIMING_LINK_TOTAL, "link: compute interface table"},
+    { RT_TIMING_LINK_F_VFTBL    ,RT_TIMING_LINK_TOTAL, "link: fill vftbl"},
+    { RT_TIMING_LINK_OFFSETS    ,RT_TIMING_LINK_TOTAL, "link: set offsets"},
+    { RT_TIMING_LINK_F_IFTBL    ,RT_TIMING_LINK_TOTAL, "link: fill interface table"},
+    { RT_TIMING_LINK_FINALIZER  ,RT_TIMING_LINK_TOTAL, "link: set finalizer"},
+    { RT_TIMING_LINK_EXCEPTS    ,RT_TIMING_LINK_TOTAL, "link: resolve exception classes"},
+    { RT_TIMING_LINK_SUBCLASS   ,RT_TIMING_LINK_TOTAL, "link: re-calculate subclass indices"},
+    { RT_TIMING_LINK_TOTAL      ,-1                  , "total link time" },
+    { -1                        ,-1                  , "" },
+       
+       { RT_TIMING_LOAD_CHECKS     ,RT_TIMING_LOAD_TOTAL, "load: initial checks"},
+       { RT_TIMING_LOAD_NDPOOL     ,RT_TIMING_LOAD_TOTAL, "load: new descriptor pool"},
+       { RT_TIMING_LOAD_CPOOL      ,RT_TIMING_LOAD_TOTAL, "load: load constant pool"},
+       { RT_TIMING_LOAD_SETUP      ,RT_TIMING_LOAD_TOTAL, "load: class setup"},
+       { RT_TIMING_LOAD_FIELDS     ,RT_TIMING_LOAD_TOTAL, "load: load fields"},
+       { RT_TIMING_LOAD_METHODS    ,RT_TIMING_LOAD_TOTAL, "load: load methods"},
+       { RT_TIMING_LOAD_CLASSREFS  ,RT_TIMING_LOAD_TOTAL, "load: create classrefs"},
+       { RT_TIMING_LOAD_DESCS      ,RT_TIMING_LOAD_TOTAL, "load: allocate descriptors"},
+       { RT_TIMING_LOAD_SETREFS    ,RT_TIMING_LOAD_TOTAL, "load: set classrefs"},
+       { RT_TIMING_LOAD_PARSEFDS   ,RT_TIMING_LOAD_TOTAL, "load: parse field descriptors"},
+       { RT_TIMING_LOAD_PARSEMDS   ,RT_TIMING_LOAD_TOTAL, "load: parse method descriptors"},
+       { RT_TIMING_LOAD_PARSECP    ,RT_TIMING_LOAD_TOTAL, "load: parse descriptors in constant pool"},
+       { RT_TIMING_LOAD_VERIFY     ,RT_TIMING_LOAD_TOTAL, "load: verifier checks"},
+       { RT_TIMING_LOAD_ATTRS      ,RT_TIMING_LOAD_TOTAL, "load: load attributes"},
+       { RT_TIMING_LOAD_TOTAL      ,-1                  , "total load time (from classbuffer)"},
+    { -1                        ,-1                  , "" },
+
+       { RT_TIMING_LOAD_BOOT_LOOKUP,-1                       , "boot: lookup in classcache"},
+       { RT_TIMING_LOAD_BOOT_ARRAY ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: load array classes"},
+       { RT_TIMING_LOAD_BOOT_SUCK  ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: suck class files"},
+       { RT_TIMING_LOAD_BOOT_LOAD  ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: load from class buffer"},
+       { RT_TIMING_LOAD_BOOT_CACHE ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: store in classcache"},
+       { RT_TIMING_LOAD_BOOT_TOTAL ,-1                       , "total bootstrap loader time"},
+    { -1                        ,-1                       , "" },
+
+       { RT_TIMING_LOAD_CL_LOOKUP  ,-1                       , "classloader: lookup in classcache" },
+       { RT_TIMING_LOAD_CL_PREPARE ,-1                       , "classloader: prepare loader call" },
+       { RT_TIMING_LOAD_CL_JAVA    ,-1                       , "classloader: loader Java code" },
+       { RT_TIMING_LOAD_CL_CACHE   ,-1                       , "classloader: store in classcache" },
+    { -1                        ,-1                       , "" },
+
+       { RT_TIMING_NEW_OBJECT      ,-1                       , "builtin_new time" },
+       { RT_TIMING_NEW_ARRAY       ,-1                       , "builtin_newarray time" },
+    { -1                        ,-1                       , "" },
+
+       { RT_TIMING_GC_ALLOC        ,-1                       , "heap allocation time" },
+#if defined(ENABLE_GC_CACAO)
+       { RT_TIMING_GC_SUSPEND      ,RT_TIMING_GC_TOTAL       , "gc: suspending threads" },
+       { RT_TIMING_GC_ROOTSET1     ,RT_TIMING_GC_TOTAL       , "gc: rootset finding" },
+       { RT_TIMING_GC_MARK         ,RT_TIMING_GC_TOTAL       , "gc: marking phase" },
+       { RT_TIMING_GC_COMPACT      ,RT_TIMING_GC_TOTAL       , "gc: compaction phase" },
+       { RT_TIMING_GC_ROOTSET2     ,RT_TIMING_GC_TOTAL       , "gc: rootset writeback" },
+       { RT_TIMING_GC_TOTAL        ,-1                       , "total garbage collection time" },
+#endif
+       { -1                        ,-1                       , "" },
+
+#if defined(ENABLE_REPLACEMENT)
+       { RT_TIMING_REPLACE         ,-1                       , "replacement" },
+       { -1                        ,-1                       , "" },
+#endif
+
+       { RT_TIMING_1               ,-1                       , "temporary timer 1" },
+       { RT_TIMING_2               ,-1                       , "temporary timer 2" },
+       { RT_TIMING_3               ,-1                       , "temporary timer 3" },
+       { RT_TIMING_4               ,-1                       , "temporary timer 4" },
+       { -1                        ,-1                       , "" },
+
+    { 0                         ,-1                       , NULL }
+};
+
+static long long rt_timing_sum[RT_TIMING_N] = { 0 };
+
+void rt_timing_gettime(struct timespec *ts)
+{
+       if (clock_gettime(CLOCK_THREAD_CPUTIME_ID,ts) != 0) {
+               fprintf(stderr,"could not get time by clock_gettime: %s\n",strerror(errno));
+               abort();
+       }
+}
+
+long rt_timing_diff_usec(struct timespec *a,struct timespec *b)
+{
+       long diff;
+       time_t atime;
+
+       diff = (b->tv_nsec - a->tv_nsec) / 1000;
+       atime = a->tv_sec;
+       while (atime < b->tv_sec) {
+               atime++;
+               diff += 1000000;
+       }
+       return diff;
+}
+
+void rt_timing_time_diff(struct timespec *a,struct timespec *b,int index)
+{
+       long diff;
+
+       diff = rt_timing_diff_usec(a,b);
+       rt_timing_sum[index] += diff;
+}
+
+void rt_timing_print_time_stats(FILE *file)
+{
+       struct rt_timing_stat *stats;
+       double total;
+
+       for (stats = rt_timing_stat_defs; stats->name; ++stats) {
+               if (stats->index < 0) {
+                       fprintf(file,"%s\n",stats->name);
+                       continue;
+               }
+               
+               if (stats->totalindex >= 0) {
+                       total = rt_timing_sum[stats->totalindex];
+                       fprintf(file,"%12lld usec %3.0f%% %s\n",
+                                       rt_timing_sum[stats->index],
+                                       (total != 0.0) ? rt_timing_sum[stats->index] / total * 100.0 : 0.0,
+                                       stats->name);
+               }
+               else {
+                       fprintf(file,"%12lld usec      %s\n",
+                                       rt_timing_sum[stats->index],
+                                       stats->name);
+               }
+       }
+}
+
+/*
+ * 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/rt-timing.h b/src/vm/rt-timing.h
new file mode 100644 (file)
index 0000000..26d31a4
--- /dev/null
@@ -0,0 +1,148 @@
+/* src/vm/rt-timing.h - POSIX real-time timing utilities
+
+   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 _RT_TIMING_H
+#define _RT_TIMING_H
+
+#include "config.h"
+
+#if defined(ENABLE_RT_TIMING)
+
+#include <time.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "vm/global.h"
+
+
+#define RT_TIMING_GET_TIME(ts) \
+       rt_timing_gettime(&(ts));
+
+#define RT_TIMING_TIME_DIFF(a,b,index) \
+       rt_timing_time_diff(&(a),&(b),(index));
+
+#define RT_TIMING_JIT_CHECKS       0
+#define RT_TIMING_JIT_PARSE        1
+#define RT_TIMING_JIT_STACK        2
+#define RT_TIMING_JIT_TYPECHECK    3
+#define RT_TIMING_JIT_LOOP         4
+#define RT_TIMING_JIT_IFCONV       5
+#define RT_TIMING_JIT_ALLOC        6
+#define RT_TIMING_JIT_RPLPOINTS    7
+#define RT_TIMING_JIT_CODEGEN      8
+#define RT_TIMING_JIT_TOTAL        9
+
+#define RT_TIMING_LINK_RESOLVE     10
+#define RT_TIMING_LINK_C_VFTBL     11
+#define RT_TIMING_LINK_ABSTRACT    12
+#define RT_TIMING_LINK_C_IFTBL     13
+#define RT_TIMING_LINK_F_VFTBL     14
+#define RT_TIMING_LINK_OFFSETS     15
+#define RT_TIMING_LINK_F_IFTBL     16
+#define RT_TIMING_LINK_FINALIZER   17
+#define RT_TIMING_LINK_EXCEPTS     18
+#define RT_TIMING_LINK_SUBCLASS    19
+#define RT_TIMING_LINK_TOTAL       20
+
+#define RT_TIMING_LOAD_CHECKS      21
+#define RT_TIMING_LOAD_NDPOOL      22
+#define RT_TIMING_LOAD_CPOOL       23
+#define RT_TIMING_LOAD_SETUP       24
+#define RT_TIMING_LOAD_FIELDS      25
+#define RT_TIMING_LOAD_METHODS     26
+#define RT_TIMING_LOAD_CLASSREFS   27
+#define RT_TIMING_LOAD_DESCS       28
+#define RT_TIMING_LOAD_SETREFS     29
+#define RT_TIMING_LOAD_PARSEFDS    30
+#define RT_TIMING_LOAD_PARSEMDS    31
+#define RT_TIMING_LOAD_PARSECP     32
+#define RT_TIMING_LOAD_VERIFY      33
+#define RT_TIMING_LOAD_ATTRS       34
+#define RT_TIMING_LOAD_TOTAL       35
+
+#define RT_TIMING_LOAD_BOOT_LOOKUP 36
+#define RT_TIMING_LOAD_BOOT_ARRAY  37
+#define RT_TIMING_LOAD_BOOT_SUCK   38
+#define RT_TIMING_LOAD_BOOT_LOAD   39
+#define RT_TIMING_LOAD_BOOT_CACHE  40
+#define RT_TIMING_LOAD_BOOT_TOTAL  41
+
+#define RT_TIMING_LOAD_CL_LOOKUP   42
+#define RT_TIMING_LOAD_CL_PREPARE  43
+#define RT_TIMING_LOAD_CL_JAVA     44
+#define RT_TIMING_LOAD_CL_CACHE    45
+
+#define RT_TIMING_NEW_OBJECT       46
+#define RT_TIMING_NEW_ARRAY        47
+
+#define RT_TIMING_GC_ALLOC         48
+#define RT_TIMING_GC_SUSPEND       49
+#define RT_TIMING_GC_ROOTSET1      50
+#define RT_TIMING_GC_MARK          51
+#define RT_TIMING_GC_COMPACT       52
+#define RT_TIMING_GC_ROOTSET2      53
+#define RT_TIMING_GC_TOTAL         54
+
+#define RT_TIMING_REPLACE          55
+
+#define RT_TIMING_1                56
+#define RT_TIMING_2                57
+#define RT_TIMING_3                58
+#define RT_TIMING_4                59
+
+#define RT_TIMING_N                60
+
+void rt_timing_gettime(struct timespec *ts);
+
+void rt_timing_time_diff(struct timespec *a,struct timespec *b,int index);
+
+long rt_timing_diff_usec(struct timespec *a,struct timespec *b);
+
+void rt_timing_print_time_stats(FILE *file);
+
+#else /* !defined(ENABLE_RT_TIMING) */
+
+#define RT_TIMING_GET_TIME(ts)
+#define RT_TIMING_TIME_DIFF(a,b,index)
+
+#endif /* defined(ENABLE_RT_TIMING) */
+
+#endif /* _RT_TIMING_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 f11a67bc6dabfeea24f6fa7d76deb7bbc753b53c..ed7d495e4d9273953ea74f2f25532f09e509fdbc 100644 (file)
 
 #include "arch.h"
 
-#include "threads/thread.h"
+#if defined(ENABLE_GC_BOEHM)
+# include "mm/memory.h"
+#endif
 
-#include "vm/exceptions.h"
-#include "vm/signallocal.h"
-#include "vm/vm.h"
+#include "threads/thread.hpp"
+#include "threads/threadlist.hpp"
 
-#include "vmcore/options.h"
+#include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/signallocal.h"
+#include "vm/vm.hpp"
 
 #if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
+# include "vm/statistics.h"
 #endif
 
 
@@ -133,7 +139,7 @@ bool signal_init(void)
                                                           SA_NODEFER | SA_SIGINFO);
 #  endif
 
-#  if defined(__ARM__) || defined(__I386__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__)
+#  if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__)
                /* XXX use better defines for that (in arch.h) */
                /* SIGILL handler */
 
@@ -185,7 +191,7 @@ bool signal_init(void)
 #if defined(ENABLE_THREADS)
        /* SIGHUP handler for threads_thread_interrupt */
 
-       signal_register_signal(SIGHUP, (functionptr) signal_handler_sighup, 0);
+       signal_register_signal(Signal_INTERRUPT_SYSTEM_CALL, (functionptr) signal_handler_sighup, 0);
 #endif
 
 #if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
@@ -246,6 +252,7 @@ static void signal_thread(void)
        threadobject *t;
        sigset_t      mask;
        int           sig;
+       int result;
 
        t = THREADOBJECT;
 
@@ -271,14 +278,14 @@ static void signal_thread(void)
                thread_set_state_waiting(t);
 #endif
 
-               /* XXX We don't check for an error here, although the man-page
-                  states sigwait does not return an error (which is wrong!),
-                  but it seems to make problems with Boehm-GC.  We should
-                  revisit this code with our new exact-GC. */
+               // sigwait can return EINTR (unlike what the Linux man-page
+               // says).
+               do {
+                       result = sigwait(&mask, &sig);
+               } while (result == EINTR);
 
-/*             if (sigwait(&mask, &sig) != 0) */
-/*                     vm_abort_errno("signal_thread: sigwait failed"); */
-               (void) sigwait(&mask, &sig);
+               if (result != 0)
+                       vm_abort_errnum(result, "signal_thread: sigwait failed");
 
 #if defined(ENABLE_THREADS)
                thread_set_state_runnable(t);
@@ -304,13 +311,13 @@ void signal_thread_handler(int sig)
        case SIGINT:
                /* exit the vm properly */
 
-               vm_exit(0);
+               vm_exit(1);
                break;
 
        case SIGQUIT:
                /* print a thread dump */
 #if defined(ENABLE_THREADS)
-               threads_dump();
+               ThreadList_dump_threads();
 #endif
 
 #if defined(ENABLE_STATISTICS)
@@ -318,6 +325,24 @@ void signal_thread_handler(int sig)
                        statistics_print_memory_usage();
 #endif
                break;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       default: {
+               // For OpenJDK we dispatch all unknown signals to Java.
+               methodinfo* m = class_resolvemethod(class_sun_misc_Signal, utf_dispatch, utf_int__void);
+               (void) vm_call_method(m, NULL, sig);
+
+               if (exceptions_get_exception()) {
+                       log_println("signal_thread_handler: Java signal handler throw an exception while dispatching signal %d:", sig);
+                       exceptions_print_stacktrace();
+                       vm_abort("signal_thread_handler: Aborting...");
+               }
+               break;
+       }
+#else
+       default:
+               vm_abort("signal_thread_handler: Unknown signal %d", sig);
+#endif
        }
 }
 
index 7d4e70e38944a5f12f940842618ddd10b22e9be1..469d949a47a05ec7a0904247dbc18bccf271e26e 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/signallocal.h - machine independent signal functions
 
-   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.
 
 
 #include "config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <signal.h>
 
 #include "vm/global.h"
 
 
+// Signal defines.
+
+#if defined(__LINUX__)
+// See openjdk/jdk/src/solaris/native/java/net/linux_close.c (sigWakeup)
+// See openjdk/jdk/src/solaris/native/sun/nio/ch/NativeThread.c (INTERRUPT_SIGNAL)
+# define Signal_INTERRUPT_SYSTEM_CALL    (__SIGRTMAX - 2)
+#else
+# define Signal_INTERRUPT_SYSTEM_CALL    SIGHUP
+#endif
+
+
 /* function prototypes ********************************************************/
 
 bool  signal_init(void);
@@ -51,7 +64,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p);
 void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p);
 #endif
 
-#if defined(__ARM__) || defined(__I386__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__)
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__)
 /* XXX use better defines for that (in arch.h) */
 void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p);
 #endif
@@ -65,6 +78,10 @@ void md_signal_handler_sigusr1(int sig, siginfo_t *siginfo, void *_p);
 
 void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _CACAO_SIGNAL_H */
 
 
diff --git a/src/vm/stackmap.c b/src/vm/stackmap.c
new file mode 100644 (file)
index 0000000..87117d0
--- /dev/null
@@ -0,0 +1,519 @@
+/* src/vm/stackmap.c - class attribute StackMapTable
+
+   Copyright (C) 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 "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "vm/class.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/stackmap.h"
+#include "vm/statistics.h"
+#include "vm/suck.hpp"
+
+
+/* stackmap_get_verification_type_info *****************************************
+
+   union verification_type_info {
+       Top_variable_info;
+          Integer_variable_info;
+          Float_variable_info;
+          Long_variable_info;
+          Double_variable_info;
+          Null_variable_info;
+          UninitializedThis_variable_info;
+          Object_variable_info;
+          Uninitialized_variable_info;
+   }
+
+   Top_variable_info {
+       u1 tag = ITEM_Top;  // 0
+   }
+
+   Integer_variable_info {
+       u1 tag = ITEM_Integer;  // 1
+   }
+
+   Float_variable_info {
+       u1 tag = ITEM_Float;  // 2
+   }
+
+   Long_variable_info {
+       u1 tag = ITEM_Long;  // 4
+   }
+
+   Double_variable_info {
+       u1 tag = ITEM_Double;  // 3
+   }
+
+   Null_variable_info {
+       u1 tag = ITEM_Null;  // 5
+   }
+
+   UninitializedThis_variable_info {
+       u1 tag = ITEM_UninitializedThis;  // 6
+   }
+
+   Object_variable_info {
+       u1 tag = ITEM_Object;  // 7
+          u2 cpool_index;
+   }
+
+   Uninitialized_variable_info {
+       u1 tag = ITEM_Uninitialized;  // 8
+          u2 offset;
+   }
+
+*******************************************************************************/
+
+static bool stackmap_get_verification_type_info(classbuffer *cb, verification_type_info_t *verification_type_info)
+{
+       /* get verification type */
+
+       if (!suck_check_classbuffer_size(cb, 1))
+               return false;
+
+       verification_type_info->tag = suck_u1(cb);
+
+       /* process the tag */
+
+       switch (verification_type_info->tag) {
+       case ITEM_Top:
+       case ITEM_Integer:
+       case ITEM_Float:
+       case ITEM_Long:
+       case ITEM_Double:
+       case ITEM_Null:
+       case ITEM_UninitializedThis:
+               break;
+
+       case ITEM_Object:
+               /* get constant pool index */
+
+               if (!suck_check_classbuffer_size(cb, 2))
+                       return false;
+
+               verification_type_info->Object_variable_info.cpool_index = suck_u2(cb);
+               break;
+
+       case ITEM_Uninitialized:
+               /* get offset */
+
+               if (!suck_check_classbuffer_size(cb, 2))
+                       return false;
+
+               verification_type_info->Uninitialized_variable_info.offset = suck_u2(cb);
+               break;
+       }
+
+       return true;
+}
+
+
+/* stackmap_get_same_locals_1_stack_item_frame *********************************
+
+   same_locals_1_stack_item_frame {
+       u1 frame_type = SAME_LOCALS_1_STACK_ITEM;  // 64-127
+          verification_type_info stack[1];
+   }
+
+*******************************************************************************/
+
+static bool stackmap_get_same_locals_1_stack_item_frame(classbuffer *cb, stack_map_frame_t *stack_map_frame)
+{
+       same_locals_1_stack_item_frame_t *same_locals_1_stack_item_frame;
+
+       /* for convenience */
+
+       same_locals_1_stack_item_frame =
+               &(stack_map_frame->same_locals_1_stack_item_frame);
+
+       if (!stackmap_get_verification_type_info(cb, &(same_locals_1_stack_item_frame->stack[0])))
+               return false;
+
+       return true;
+}
+
+
+/* stackmap_get_same_locals_1_stack_item_frame_extended ************************
+
+   same_locals_1_stack_item_frame_extended {
+       u1 frame_type = SAME_LOCALS_1_STACK_ITEM_EXTENDED;  // 247
+          u2 offset_delta;
+          verification_type_info stack[1];
+   }
+
+*******************************************************************************/
+
+static bool stackmap_get_same_locals_1_stack_item_frame_extended(classbuffer *cb, stack_map_frame_t *stack_map_frame)
+{
+       same_locals_1_stack_item_frame_extended_t *same_locals_1_stack_item_frame_extended;
+
+       /* for convenience */
+
+       same_locals_1_stack_item_frame_extended =
+               &(stack_map_frame->same_locals_1_stack_item_frame_extended);
+
+       /* check buffer size */
+
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       /* get offset delta */
+
+       same_locals_1_stack_item_frame_extended->offset_delta = suck_u2(cb);
+
+       /* process stack */
+
+       if (!stackmap_get_verification_type_info(cb, &(same_locals_1_stack_item_frame_extended->stack[0])))
+               return false;
+
+       return true;
+}
+
+
+/* stackmap_get_chop_frame *****************************************************
+
+   chop_frame {
+       u1 frame_type = CHOP_FRAME;  // 248-250
+          u2 offset_delta;
+   }
+
+*******************************************************************************/
+
+static bool stackmap_get_chop_frame(classbuffer *cb,
+                                                                       stack_map_frame_t *stack_map_frame)
+{
+       chop_frame_t *chop_frame;
+
+       /* for convenience */
+
+       chop_frame = &(stack_map_frame->chop_frame);
+
+       /* check buffer size */
+
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       /* get offset delta */
+
+       chop_frame->offset_delta = suck_u2(cb);
+
+       return true;
+}
+
+
+/* stackmap_get_same_frame_extended ********************************************
+
+   same_frame_extended {
+       u1 frame_type = SAME_FRAME_EXTENDED;  // 251
+          u2 offset_delta;
+   }
+
+*******************************************************************************/
+
+static bool stackmap_get_same_frame_extended(classbuffer *cb,
+                                                                                        stack_map_frame_t *stack_map_frame)
+{
+       same_frame_extended_t *same_frame_extended;
+
+       /* for convenience */
+
+       same_frame_extended = &(stack_map_frame->same_frame_extended);
+
+       /* check buffer size */
+
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       /* get offset delta */
+
+       same_frame_extended->offset_delta = suck_u2(cb);
+
+       return true;
+}
+
+
+/* stackmap_get_append_frame ***************************************************
+
+   append_frame {
+       u1 frame_type = APPEND_FRAME;  // 252-254
+          u2 offset_delta;
+          verification_type_info locals[frame_Type - 251];
+   }
+
+*******************************************************************************/
+
+static bool stackmap_get_append_frame(classbuffer *cb,
+                                                                         stack_map_frame_t *stack_map_frame)
+{
+       append_frame_t *append_frame;
+       s4              number_of_locals;
+       s4              i;
+
+       /* for convenience */
+
+       append_frame = &(stack_map_frame->append_frame);
+
+       /* check buffer size */
+
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       /* get offset delta */
+
+       append_frame->offset_delta = suck_u2(cb);
+
+       /* allocate locals array */
+
+       number_of_locals = append_frame->frame_type - 251;
+
+       append_frame->locals = DMNEW(verification_type_info_t, number_of_locals);
+
+       /* process all locals */
+
+       for (i = 0; i < number_of_locals; i++)
+               if (!stackmap_get_verification_type_info(cb, &(append_frame->locals[i])))
+                       return false;
+
+       return true;
+}
+
+
+/* stackmap_get_full_frame *****************************************************
+
+   full_frame {
+       u1 frame_type = FULL_FRAME;
+          u2 offset_delta;
+          u2 number_of_locals;
+          verification_type_info locals[number_of_locals];
+          u2 number_of_stack_items;
+          verification_type_info stack[number_of_stack_items];
+   }
+
+*******************************************************************************/
+
+static bool stackmap_get_full_frame(classbuffer *cb,
+                                                                       stack_map_frame_t *stack_map_frame)
+{
+       full_frame_t *full_frame;
+       s4 i;
+
+       /* for convenience */
+
+       full_frame = &(stack_map_frame->full_frame);
+
+       /* check buffer size */
+
+       if (!suck_check_classbuffer_size(cb, 2 + 2))
+               return false;
+
+       /*  get offset delta */
+
+       stack_map_frame->full_frame.offset_delta = suck_u2(cb);
+
+       /* get number of locals */
+
+       full_frame->number_of_locals = suck_u2(cb);
+
+       /* allocate locals array */
+
+       full_frame->locals =
+               DMNEW(verification_type_info_t, full_frame->number_of_locals);
+
+       /* process all locals */
+
+       for (i = 0; i < full_frame->number_of_locals; i++)
+               if (!stackmap_get_verification_type_info(cb, &(full_frame->locals[i])))
+                       return false;
+
+       /* get number of stack items */
+
+       if (!suck_check_classbuffer_size(cb, 2))
+               return false;
+
+       full_frame->number_of_stack_items = suck_u2(cb);
+
+       /* allocate stack array */
+
+       full_frame->stack =
+               DMNEW(verification_type_info_t, full_frame->number_of_stack_items);
+
+       /* process all stack items */
+
+       for (i = 0; i < full_frame->number_of_stack_items; i++)
+               if (!stackmap_get_verification_type_info(cb, &(full_frame->stack[i])))
+                       return false;
+
+       return true;
+}
+
+
+/* stackmap_load_attribute_stackmaptable ***************************************
+
+   stack_map {
+          u2 attribute_name_index;
+          u4 attribute_length;
+          u2 number_of_entries;
+          stack_map_frame entries[number_of_entries];
+   }
+
+   union stack_map_frame {
+       same_frame;
+          same_locals_1_stack_item_frame;
+          same_locals_1_stack_item_frame_extended;
+          chop_frame;
+          same_frame_extended;
+          append_frame;
+          full_frame;
+   }
+
+   same_frame {
+       u1 frame_type = SAME;  // 0-63
+   }
+
+*******************************************************************************/
+
+bool stackmap_load_attribute_stackmaptable(classbuffer *cb, methodinfo *m)
+{
+       classinfo       *c;
+       stack_map_t     *stack_map;
+       s4               i;
+       u1               frame_type;
+
+       /* get classinfo */
+
+       c = cb->clazz;
+
+       /* allocate stack map structure */
+
+       stack_map = DNEW(stack_map_t);
+
+       STATISTICS(size_stack_map += sizeof(stack_map_t));
+
+       /* check buffer size */
+
+       if (!suck_check_classbuffer_size(cb, 4 + 2))
+               return false;
+
+       /* attribute_length */
+
+       stack_map->attribute_length = suck_u4(cb);
+
+       if (!suck_check_classbuffer_size(cb, stack_map->attribute_length))
+               return false;
+
+       /* get number of entries */
+
+       stack_map->number_of_entries = suck_u2(cb);
+
+       /* process all entries */
+
+       stack_map->entries = DMNEW(stack_map_frame_t, stack_map->number_of_entries);
+
+       for (i = 0; i < stack_map->number_of_entries; i++) {
+               /* get the frame type */
+
+               frame_type = suck_u1(cb);
+
+               stack_map->entries[i].frame_type = frame_type;
+
+               /* process frame */
+
+               if (frame_type <= FRAME_TYPE_SAME) {
+                       /* same_frame */
+               }
+               else if (frame_type <= FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM) {
+                       /* same_locals_1_stack_item_frame */
+
+                       if (!stackmap_get_same_locals_1_stack_item_frame(cb, &(stack_map->entries[i])))
+                               return false;
+               }
+               else if (frame_type <= FRAME_TYPE_RESERVED) {
+                       /* reserved */
+
+                       exceptions_throw_classformaterror(c, "reserved frame type");
+                       return false;
+               }
+               else if (frame_type == FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM_EXTENDED) {
+                       /* same_locals_1_stack_item_frame_extended */
+
+                       if (!stackmap_get_same_locals_1_stack_item_frame_extended(cb, &(stack_map->entries[i])))
+                               return false;
+               }
+               else if (frame_type <= FRAME_TYPE_CHOP) {
+                       /* chop_frame */
+
+                       if (!stackmap_get_chop_frame(cb, &(stack_map->entries[i])))
+                               return false;
+               }
+               else if (frame_type == FRAME_TYPE_SAME_FRAME_EXTENDED) {
+                       /* same_frame_extended */
+
+                       if (!stackmap_get_same_frame_extended(cb, &(stack_map->entries[i])))
+                               return false;
+               }
+               else if (frame_type <= FRAME_TYPE_APPEND) {
+                       /* append_frame */
+
+                       if (!stackmap_get_append_frame(cb, &(stack_map->entries[i])))
+                               return false;
+               }
+               else if (frame_type == FRAME_TYPE_FULL_FRAME) {
+                       /* full_frame */
+
+                       if (!stackmap_get_full_frame(cb, &(stack_map->entries[i])))
+                               return false;
+               }
+       }
+
+       /* store stack map in method structure */
+
+#if 0
+       /* currently not used */
+
+       m->stack_map = stack_map;
+#endif
+
+       return true;
+}
+
+
+/*
+ * 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/stackmap.h b/src/vm/stackmap.h
new file mode 100644 (file)
index 0000000..fb90086
--- /dev/null
@@ -0,0 +1,236 @@
+/* src/vm/stackmap.h - class attribute StackMapTable
+
+   Copyright (C) 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 _STACKMAP_H
+#define _STACKMAP_H
+
+/* forward typedefs ***********************************************************/
+
+typedef struct stack_map_t                       stack_map_t;
+typedef union  stack_map_frame_t                 stack_map_frame_t;
+typedef struct same_locals_1_stack_item_frame_t  same_locals_1_stack_item_frame_t;
+typedef struct same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended_t;
+typedef struct chop_frame_t                      chop_frame_t;
+typedef struct same_frame_extended_t             same_frame_extended_t;
+typedef struct append_frame_t                    append_frame_t;
+typedef struct full_frame_t                      full_frame_t;
+
+typedef union  verification_type_info_t          verification_type_info_t;
+typedef struct Top_variable_info_t                  Top_variable_info_t;
+typedef struct Integer_variable_info_t           Integer_variable_info_t;
+typedef struct Float_variable_info_t             Float_variable_info_t;
+typedef struct Long_variable_info_t              Long_variable_info_t;
+typedef struct Double_variable_info_t            Double_variable_info_t;
+typedef struct Null_variable_info_t              Null_variable_info_t;
+typedef struct UninitializedThis_variable_info_t UninitializedThis_variable_info_t;
+typedef struct Object_variable_info_t            Object_variable_info_t;
+typedef struct Uninitialized_variable_info_t     Uninitialized_variable_info_t;
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/global.h"
+#include "vm/loader.hpp"
+#include "vm/method.hpp"
+
+
+/* verification_type_info *****************************************************/
+
+#define ITEM_Top                  0
+#define ITEM_Integer              1
+#define ITEM_Float                2
+#define ITEM_Double               3
+#define ITEM_Long                 4
+#define ITEM_Null                 5
+#define ITEM_UninitializedThis    6
+#define ITEM_Object               7
+#define ITEM_Uninitialized        8
+
+struct Top_variable_info_t {
+       u1 tag;
+};
+
+struct Integer_variable_info_t {
+       u1 tag;
+};
+
+struct Float_variable_info_t {
+       u1 tag;
+};
+
+struct Long_variable_info_t {
+       u1 tag;
+};
+
+struct Double_variable_info_t {
+       u1 tag;
+};
+
+struct Null_variable_info_t {
+       u1 tag;
+};
+
+struct UninitializedThis_variable_info_t {
+       u1 tag;
+};
+
+struct Object_variable_info_t {
+       u1 tag;
+       u2 cpool_index;
+};
+
+struct Uninitialized_variable_info_t {
+       u1 tag;
+       u2 offset;
+};
+
+union verification_type_info_t {
+       u1 tag;
+       Top_variable_info_t                   Top_variable_info;
+       Integer_variable_info_t           Integer_variable_info;
+       Float_variable_info_t             Float_variable_info;
+       Long_variable_info_t              Long_variable_info;
+       Double_variable_info_t            Double_variable_info;
+       Null_variable_info_t              Null_variable_info;
+       UninitializedThis_variable_info_t UninitializedThis_variable_info;
+       Object_variable_info_t            Object_variable_info;
+       Uninitialized_variable_info_t     Uninitialized_variable_info;
+};
+
+
+/* stack_map_t ****************************************************************/
+
+struct stack_map_t {
+       u2                 attribute_name_index;
+       u4                 attribute_length;
+       u2                 number_of_entries;
+       stack_map_frame_t *entries;
+};
+
+
+/* same_locals_1_stack_item_frame_t *******************************************/
+
+struct same_locals_1_stack_item_frame_t {
+       u1                       frame_type;
+       verification_type_info_t stack[1];
+};
+
+
+/* same_locals_1_stack_item_frame_extended_t **********************************/
+
+struct same_locals_1_stack_item_frame_extended_t {
+       u1                       frame_type;
+       u2                       offset_delta;
+       verification_type_info_t stack[1];
+};
+
+
+/* chop_frame_t ***************************************************************/
+
+struct chop_frame_t {
+       u1 frame_type;
+       u2 offset_delta;
+};
+
+
+/* same_frame_extended_t ******************************************************/
+
+struct same_frame_extended_t {
+       u1 frame_type;
+       u2 offset_delta;
+};
+
+
+/* append_frame_t *************************************************************/
+
+struct append_frame_t {
+       u1                        frame_type;
+       u2                        offset_delta;
+       verification_type_info_t *locals;
+};
+
+
+/* full_frame_t ***************************************************************/
+
+struct full_frame_t {
+       u1                        frame_type;
+       u2                        offset_delta;
+       u2                        number_of_locals;
+       verification_type_info_t *locals;
+       u2                        number_of_stack_items;
+       verification_type_info_t *stack;
+};
+
+
+/* stack_map_frame_t **********************************************************/
+
+#define FRAME_TYPE_SAME                                 63   /* 0-63          */
+#define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM             127  /* 0-127         */
+#define FRAME_TYPE_RESERVED                             246  /* 128-246       */
+#define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM_EXTENDED    247  /* 247           */
+#define FRAME_TYPE_CHOP                                 250  /* 248-250       */
+#define FRAME_TYPE_SAME_FRAME_EXTENDED                  251  /* 251           */
+#define FRAME_TYPE_APPEND                               254  /* 252-254       */
+#define FRAME_TYPE_FULL_FRAME                           255  /* 255           */
+
+union stack_map_frame_t {
+       u1                                        frame_type;
+       same_locals_1_stack_item_frame_t          same_locals_1_stack_item_frame;
+       same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended;
+       chop_frame_t                              chop_frame;
+       same_frame_extended_t                     same_frame_extended;
+       append_frame_t                            append_frame;
+       full_frame_t                              full_frame;
+};
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* function prototypes ********************************************************/
+
+bool stackmap_load_attribute_stackmaptable(classbuffer *cb, methodinfo *m);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* _STACKMAP_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/statistics.c b/src/vm/statistics.c
new file mode 100644 (file)
index 0000000..27926b5
--- /dev/null
@@ -0,0 +1,818 @@
+/* src/vm/statistics.c - global variables for statistics
+
+   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 <stdint.h>
+#include <string.h> 
+
+#if defined(HAVE_TIME_H)
+# include <time.h>
+#endif
+
+#if defined(HAVE_SYS_TIME_H)
+# include <sys/time.h>
+#endif
+
+#if defined(HAVE_SYS_RESOURCE_H)
+# include <sys/resource.h>
+#endif
+
+#include "vm/types.h"
+
+#include "mm/gc.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/global.h"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/statistics.h"
+
+#include "vm/jit/code.hpp"
+
+
+/* global variables ***********************************************************/
+
+static s8 loadingtime = 0;              /* accumulated loading time           */
+static s8 loadingstarttime = 0;
+static s8 loadingstoptime = 0;
+static s4 loadingtime_recursion = 0;
+
+static s8 compilingtime = 0;            /* accumulated compile time           */
+static s8 compilingstarttime = 0;
+static s8 compilingstoptime = 0;
+static s4 compilingtime_recursion = 0;
+
+s4 codememusage = 0;
+s4 maxcodememusage = 0;
+
+s4 memoryusage = 0;
+s4 maxmemusage = 0;
+
+s4 maxdumpsize = 0;
+
+s4 globalallocateddumpsize = 0;
+s4 globaluseddumpsize = 0;
+
+
+/* variables for measurements *************************************************/
+
+s4 size_classinfo        = 0;
+s4 size_fieldinfo        = 0;
+s4 size_methodinfo       = 0;
+s4 size_lineinfo         = 0;
+s4 size_codeinfo         = 0;
+
+s4 size_stub_native      = 0;
+
+s4 size_stack_map        = 0;
+s4 size_string           = 0;
+
+s4 size_threadobject     = 0;
+int32_t size_thread_index_t = 0;
+int32_t size_stacksize      = 0;
+
+s4 size_lock_record      = 0;
+s4 size_lock_hashtable   = 0;
+s4 size_lock_waiter      = 0;
+
+int32_t count_linenumbertable = 0;
+int32_t size_linenumbertable  = 0;
+
+s4 size_patchref         = 0;
+
+u8 count_calls_java_to_native = 0;
+u8 count_calls_native_to_java = 0;
+
+int count_const_pool_len = 0;
+int count_classref_len = 0;
+int count_parsed_desc_len = 0;
+int count_vftbl_len = 0;
+int count_all_methods = 0;
+int count_methods_marked_used = 0;  /* RTA */
+
+int count_vmcode_len = 0;
+int count_extable_len = 0;
+int count_class_loads = 0;
+int count_class_inits = 0;
+
+int count_utf_len = 0;                  /* size of utf hash                   */
+int count_utf_new = 0;                  /* calls of utf_new                   */
+int count_utf_new_found  = 0;           /* calls of utf_new with fast return  */
+
+int count_locals_conflicts = 0;         /* register allocator statistics */
+int count_locals_spilled = 0;
+int count_locals_register = 0;
+int count_ss_spilled = 0;
+int count_ss_register = 0;
+int count_methods_allocated_by_lsra = 0;
+int count_mem_move_bb = 0;
+int count_interface_size = 0;
+int count_argument_mem_ss = 0;
+int count_argument_reg_ss = 0;
+int count_method_in_register = 0;
+int count_mov_reg_reg = 0;
+int count_mov_mem_reg = 0;
+int count_mov_reg_mem = 0;
+int count_mov_mem_mem = 0;
+
+int count_jit_calls = 0;
+int count_methods = 0;
+int count_spills_read_ila = 0;
+int count_spills_read_flt = 0;
+int count_spills_read_dbl = 0;
+int count_spills_write_ila = 0;
+int count_spills_write_flt = 0;
+int count_spills_write_dbl = 0;
+int count_pcmd_activ = 0;
+int count_pcmd_drop = 0;
+int count_pcmd_zero = 0;
+int count_pcmd_const_store = 0;
+int count_pcmd_const_alu = 0;
+int count_pcmd_const_bra = 0;
+int count_pcmd_load = 0;
+int count_pcmd_move = 0;
+int count_load_instruction = 0;
+int count_pcmd_store = 0;
+int count_pcmd_store_comb = 0;
+int count_dup_instruction = 0;
+int count_pcmd_op = 0;
+int count_pcmd_mem = 0;
+int count_pcmd_met = 0;
+int count_pcmd_bra = 0;
+int count_pcmd_table = 0;
+int count_pcmd_return = 0;
+int count_pcmd_returnx = 0;
+int count_check_null = 0;
+int count_check_bound = 0;
+int count_max_basic_blocks = 0;
+int count_basic_blocks = 0;
+int count_javainstr = 0;
+int count_max_javainstr = 0;
+int count_javacodesize = 0;
+int count_javaexcsize = 0;
+int count_calls = 0;
+int count_tryblocks = 0;
+int count_code_len = 0;
+int count_data_len = 0;
+int count_cstub_len = 0;
+int count_max_new_stack = 0;
+int count_upper_bound_new_stack = 0;
+
+int count_emit_branch = 0;
+int count_emit_branch_8bit = 0;
+int count_emit_branch_16bit = 0;
+int count_emit_branch_32bit = 0;
+int count_emit_branch_64bit = 0;
+
+s4 count_branches_resolved   = 0;
+s4 count_branches_unresolved = 0;
+
+u8 count_jni_callXmethod_calls=0;
+u8 count_jni_calls=0;
+
+
+static int count_block_stack_init[11] = {
+       0, 0, 0, 0, 0, 
+       0, 0, 0, 0, 0, 
+       0
+};
+int *count_block_stack = count_block_stack_init;
+static int count_analyse_iterations_init[5] = {
+       0, 0, 0, 0, 0
+};
+int *count_analyse_iterations = count_analyse_iterations_init;
+static int count_method_bb_distribution_init[9] = {
+       0, 0, 0, 0, 0,
+       0, 0, 0, 0
+};
+int *count_method_bb_distribution = count_method_bb_distribution_init;
+static int count_block_size_distribution_init[18] = {
+       0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0,
+       0, 0, 0
+};
+int *count_block_size_distribution = count_block_size_distribution_init;
+static int count_store_length_init[21] = {
+       0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0,
+       0
+};
+int *count_store_length = count_store_length_init;
+static int count_store_depth_init[11] = {
+       0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0,
+       0
+};
+int *count_store_depth = count_store_depth_init;
+
+
+/* instruction scheduler statistics *******************************************/
+
+s4 count_schedule_basic_blocks = 0;
+s4 count_schedule_nodes = 0;
+s4 count_schedule_leaders = 0;
+s4 count_schedule_max_leaders = 0;
+s4 count_schedule_critical_path = 0;
+
+
+/* jnicallXmethodinvokation ***************************************************
+
+   increments the jni CallXMethod invokation count by one
+       
+*******************************************************************************/
+
+void jnicallXmethodnvokation(void)
+{
+       /* XXX do locking here */
+       count_jni_callXmethod_calls++;
+}
+
+
+/* jniinvokation *************************************************************
+
+   increments the jni overall  invokation count by one
+       
+*******************************************************************************/
+
+void jniinvokation(void)
+{
+       /* XXX do locking here */
+       count_jni_calls++;
+}
+
+
+/* getcputime *********************************** ******************************
+
+   Returns the used CPU time in microseconds
+       
+*******************************************************************************/
+
+s8 getcputime(void)
+{
+#if defined(HAVE_GETRUSAGE)
+       struct rusage ru;
+       int sec, usec;
+
+       getrusage(RUSAGE_SELF, &ru);
+
+       sec  = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec;
+       usec = ru.ru_utime.tv_usec + ru.ru_stime.tv_usec;
+
+       return sec * 1000000 + usec;
+#else
+       /* If we don't have getrusage, simply return 0. */
+
+       return 0;
+#endif
+}
+
+
+/* loadingtime_stop ************************************************************
+
+   XXX
+
+*******************************************************************************/
+
+void loadingtime_start(void)
+{
+       loadingtime_recursion++;
+
+       if (loadingtime_recursion == 1)
+               loadingstarttime = getcputime();
+}
+
+
+/* loadingtime_stop ************************************************************
+
+   XXX
+
+*******************************************************************************/
+
+void loadingtime_stop(void)
+{
+       if (loadingtime_recursion == 1) {
+               loadingstoptime = getcputime();
+               loadingtime += (loadingstoptime - loadingstarttime);
+       }
+
+       loadingtime_recursion--;
+}
+
+
+/* compilingtime_stop **********************************************************
+
+   XXX
+
+*******************************************************************************/
+
+void compilingtime_start(void)
+{
+       compilingtime_recursion++;
+
+       if (compilingtime_recursion == 1)
+               compilingstarttime = getcputime();
+}
+
+
+/* compilingtime_stop **********************************************************
+
+   XXX
+
+*******************************************************************************/
+
+void compilingtime_stop(void)
+{
+       if (compilingtime_recursion == 1) {
+               compilingstoptime = getcputime();
+               compilingtime += (compilingstoptime - compilingstarttime);
+       }
+
+       compilingtime_recursion--;
+}
+
+
+/* print_times *****************************************************************
+
+   Prints a summary of CPU time usage.
+
+*******************************************************************************/
+
+void print_times(void)
+{
+       s8 totaltime;
+       s8 runtime;
+
+       totaltime = getcputime();
+       runtime = totaltime - loadingtime - compilingtime;
+
+#if SIZEOF_VOID_P == 8
+       dolog("Time for loading classes: %6ld ms", loadingtime / 1000);
+       dolog("Time for compiling code:  %6ld ms", compilingtime / 1000);
+       dolog("Time for running program: %6ld ms", runtime / 1000);
+       dolog("Total time:               %6ld ms", totaltime / 1000);
+#else
+       dolog("Time for loading classes: %6lld ms", loadingtime / 1000);
+       dolog("Time for compiling code:  %6lld ms", compilingtime / 1000);
+       dolog("Time for running program: %6lld ms", runtime / 1000);
+       dolog("Total time:               %6lld ms", totaltime / 1000);
+#endif
+}
+
+
+/* print_stats *****************************************************************
+
+   outputs detailed compiler statistics
+
+*******************************************************************************/
+
+void print_stats(void)
+{
+       s4    i;
+       float f;
+       s4    sum;
+
+
+       dolog("Number of JIT compiler calls: %6d", count_jit_calls);
+       dolog("Number of compiled methods:   %6d", count_methods);
+
+       dolog("Number of compiled basic blocks:               %6d",
+                 count_basic_blocks);
+       dolog("Number of max. basic blocks per method:        %6d",
+                 count_max_basic_blocks);
+
+       dolog("Number of compiled JavaVM instructions:        %6d",
+                 count_javainstr);
+       dolog("Number of max. JavaVM instructions per method: %6d",
+                 count_max_javainstr);
+       dolog("Size of compiled JavaVM instructions:          %6d(%d)",
+                 count_javacodesize, count_javacodesize - count_methods * 18);
+
+       dolog("Size of compiled Exception Tables:      %d", count_javaexcsize);
+       dolog("Number of Machine-Instructions: %d", count_code_len >> 2);
+       dolog("Number of Spills (write to memory) <all [i/l/a|flt|dbl]>: %d [%d|%d|%d]",
+               count_spills_write_ila + count_spills_write_flt + count_spills_write_dbl,
+               count_spills_write_ila, count_spills_write_flt, count_spills_write_dbl);
+       dolog("Number of Spills (read from memory) <all [i/l/a|flt|dbl]>: %d [%d|%d|%d]",
+               count_spills_read_ila + count_spills_read_flt + count_spills_read_dbl,
+               count_spills_read_ila, count_spills_read_flt, count_spills_read_dbl);
+       dolog("Number of Activ    Pseudocommands: %6d", count_pcmd_activ);
+       dolog("Number of Drop     Pseudocommands: %6d", count_pcmd_drop);
+       dolog("Number of Const    Pseudocommands: %6d (zero:%5d)",
+                 count_pcmd_load, count_pcmd_zero);
+       dolog("Number of ConstAlu Pseudocommands: %6d (cmp: %5d, store:%5d)",
+                 count_pcmd_const_alu, count_pcmd_const_bra, count_pcmd_const_store);
+       dolog("Number of Move     Pseudocommands: %6d", count_pcmd_move);
+       dolog("Number of Load     Pseudocommands: %6d", count_load_instruction);
+       dolog("Number of Store    Pseudocommands: %6d (combined: %5d)",
+                 count_pcmd_store, count_pcmd_store - count_pcmd_store_comb);
+       dolog("Number of OP       Pseudocommands: %6d", count_pcmd_op);
+       dolog("Number of DUP      Pseudocommands: %6d", count_dup_instruction);
+       dolog("Number of Mem      Pseudocommands: %6d", count_pcmd_mem);
+       dolog("Number of Method   Pseudocommands: %6d", count_pcmd_met);
+       dolog("Number of Branch   Pseudocommands: %6d (rets:%5d, Xrets: %5d)",
+                 count_pcmd_bra, count_pcmd_return, count_pcmd_returnx);
+       log_println("                resolved branches: %6d", count_branches_resolved);
+       log_println("              unresolved branches: %6d", count_branches_unresolved);
+       dolog("Number of Table    Pseudocommands: %6d", count_pcmd_table);
+       dolog("Number of Useful   Pseudocommands: %6d", count_pcmd_table +
+                 count_pcmd_bra + count_pcmd_load + count_pcmd_mem + count_pcmd_op);
+       dolog("Number of Null Pointer Checks:     %6d", count_check_null);
+       dolog("Number of Array Bound Checks:      %6d", count_check_bound);
+       dolog("Number of Try-Blocks: %d", count_tryblocks);
+
+       dolog("Number of branch_emit (total, 8bit/16bit/32bit/64bit offset): %d, %d/%d/%d/%d",
+               count_emit_branch,  count_emit_branch_8bit,  count_emit_branch_16bit, 
+                                                       count_emit_branch_32bit, count_emit_branch_64bit);
+
+       dolog("Maximal count of stack elements:   %d", count_max_new_stack);
+       dolog("Upper bound of max stack elements: %d", count_upper_bound_new_stack);
+       dolog("Distribution of stack sizes at block boundary");
+       dolog("     0     1     2     3     4     5     6     7     8     9  >=10");
+       dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
+                 count_block_stack[0], count_block_stack[1], count_block_stack[2],
+                 count_block_stack[3], count_block_stack[4], count_block_stack[5],
+                 count_block_stack[6], count_block_stack[7], count_block_stack[8],
+                 count_block_stack[9], count_block_stack[10]);
+       dolog("Distribution of store stack depth");
+       dolog("     0     1     2     3     4     5     6     7     8     9  >=10");
+       dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
+                 count_store_depth[0], count_store_depth[1], count_store_depth[2],
+                 count_store_depth[3], count_store_depth[4], count_store_depth[5],
+                 count_store_depth[6], count_store_depth[7], count_store_depth[8],
+                 count_store_depth[9], count_store_depth[10]);
+       dolog("Distribution of store creator chains first part");
+       dolog("     0     1     2     3     4     5     6     7     8     9");
+       dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
+                 count_store_length[0], count_store_length[1], count_store_length[2],
+                 count_store_length[3], count_store_length[4], count_store_length[5],
+                 count_store_length[6], count_store_length[7], count_store_length[8],
+                 count_store_length[9]);
+       dolog("Distribution of store creator chains second part");
+       dolog("    10    11    12    13    14    15    16    17    18    19  >=20");
+       dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
+                 count_store_length[10], count_store_length[11],
+                 count_store_length[12], count_store_length[13],
+                 count_store_length[14], count_store_length[15],
+                 count_store_length[16], count_store_length[17],
+                 count_store_length[18], count_store_length[19],
+                 count_store_length[20]);
+       dolog("Distribution of analysis iterations");
+       dolog("     1     2     3     4   >=5");
+       dolog("%6d%6d%6d%6d%6d",
+                 count_analyse_iterations[0], count_analyse_iterations[1],
+                 count_analyse_iterations[2], count_analyse_iterations[3],
+                 count_analyse_iterations[4]);
+
+
+       /* Distribution of basic blocks per method ********************************/
+
+       log_println("Distribution of basic blocks per method:");
+       log_println("   <=5  <=10  <=15  <=20  <=30  <=40  <=50  <=75   >75");
+
+       log_start();
+       for (i = 0; i <= 8; i++)
+               log_print("%6d", count_method_bb_distribution[i]);
+       log_finish();
+
+       /* print ratio */
+
+       f = (float) count_methods;
+
+       log_start();
+       for (i = 0; i <= 8; i++)
+               log_print("%6.2f", (float) count_method_bb_distribution[i] / f);
+       log_finish();
+
+       /* print cumulated ratio */
+
+       log_start();
+       for (i = 0, sum = 0; i <= 8; i++) {
+               sum += count_method_bb_distribution[i];
+               log_print("%6.2f", (float) sum / f);
+       }
+       log_finish();
+
+
+       /* Distribution of basic block sizes **************************************/
+
+       log_println("Distribution of basic block sizes:");
+       log_println("     0     1     2     3     4     5     6     7     8     9   <13   <15   <17   <19   <21   <26   <31   >30");
+
+       /* print block sizes */
+
+       log_start();
+       for (i = 0; i <= 17; i++)
+               log_print("%6d", count_block_size_distribution[i]);
+       log_finish();
+
+       /* print ratio */
+
+       f = (float) count_basic_blocks;
+
+       log_start();
+       for (i = 0; i <= 17; i++)
+               log_print("%6.2f", (float) count_block_size_distribution[i] / f);
+       log_finish();
+
+       /* print cumulated ratio */
+
+       log_start();
+       for (i = 0, sum = 0; i <= 17; i++) {
+               sum += count_block_size_distribution[i];
+               log_print("%6.2f", (float) sum / f);
+       }
+       log_finish();
+
+       statistics_print_memory_usage();
+
+       dolog("Number of class loads:    %6d", count_class_loads);
+       dolog("Number of class inits:    %6d", count_class_inits);
+       dolog("Number of loaded Methods: %6d\n", count_all_methods);
+
+       dolog("Calls of utf_new:                 %6d", count_utf_new);
+       dolog("Calls of utf_new (element found): %6d\n", count_utf_new_found);
+
+
+       /* LSRA statistics ********************************************************/
+
+       dolog("Moves reg -> reg:     %6d", count_mov_reg_reg);
+       dolog("Moves mem -> reg:     %6d", count_mov_mem_reg);
+       dolog("Moves reg -> mem:     %6d", count_mov_reg_mem);
+       dolog("Moves mem -> mem:     %6d", count_mov_mem_mem);
+
+       dolog("Methods allocated by LSRA:         %6d",
+                 count_methods_allocated_by_lsra);
+       dolog("Conflicts between local Variables: %6d", count_locals_conflicts);
+       dolog("Local Variables held in Memory:    %6d", count_locals_spilled);
+       dolog("Local Variables held in Registers: %6d", count_locals_register);
+       dolog("Stackslots held in Memory:         %6d", count_ss_spilled);
+       dolog("Stackslots held in Registers:      %6d", count_ss_register);
+       dolog("Memory moves at BB Boundaries:     %6d", count_mem_move_bb);
+       dolog("Number of interface slots:         %6d\n", count_interface_size);
+       dolog("Number of Argument stack slots in register:  %6d",
+                 count_argument_reg_ss);
+       dolog("Number of Argument stack slots in memory:    %6d\n",
+                 count_argument_mem_ss);
+       dolog("Number of Methods kept in registers:         %6d\n",
+                 count_method_in_register);
+
+
+       /* instruction scheduler statistics ***************************************/
+
+#if defined(USE_SCHEDULER)
+       dolog("Instruction scheduler statistics:");
+       dolog("Number of basic blocks:       %7d", count_schedule_basic_blocks);
+       dolog("Number of nodes:              %7d", count_schedule_nodes);
+       dolog("Number of leaders nodes:      %7d", count_schedule_leaders);
+       dolog("Number of max. leaders nodes: %7d", count_schedule_max_leaders);
+       dolog("Length of critical path:      %7d\n", count_schedule_critical_path);
+#endif
+
+
+       /* call statistics ********************************************************/
+
+       dolog("Function call statistics:");
+       dolog("Number of jni->CallXMethod function invokations: %ld",
+                 count_jni_callXmethod_calls);
+       dolog("Overall number of jni invokations:               %ld",
+                 count_jni_calls);
+
+       log_println("java-to-native calls:   %10ld", count_calls_java_to_native);
+       log_println("native-to-java calls:   %10ld", count_calls_native_to_java);
+
+
+       /* now print other statistics ********************************************/
+
+#if defined(ENABLE_INTRP)
+       print_dynamic_super_statistics();
+#endif
+}
+
+
+/* statistics_print_date *******************************************************
+
+   Print current date and time.
+
+*******************************************************************************/
+
+void statistics_print_date(void)
+{
+  time_t t;
+  struct tm tm;
+
+#if defined(HAVE_TIME)
+  time(&t);
+#else
+# error !HAVE_TIME
+#endif
+
+#if defined(HAVE_LOCALTIME_R)
+  localtime_r(&t, &tm);
+#else
+# error !HAVE_LOCALTIME_R
+#endif
+
+  log_println("%d-%02d-%02d %02d:%02d:%02d",
+                         1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday,
+                         tm.tm_hour, tm.tm_min, tm.tm_sec);
+}
+
+
+/* statistics_print_memory_usage ***********************************************
+
+   Print current memory usage.
+
+*******************************************************************************/
+
+void statistics_print_memory_usage(void)
+{
+       s4 sum;
+
+       log_println("memory usage ----------------------");
+       log_println("");
+       log_println("code:                      %10d", count_code_len);
+       log_println("data:                      %10d", count_data_len);
+       log_println("                            ----------");
+
+       sum =
+               count_code_len +
+               count_data_len;
+
+       log_println("                           %10d", sum);
+
+       log_println("");
+
+       log_println("classinfo  (%3d B):        %10d", (int) sizeof(classinfo), size_classinfo);
+       log_println("fieldinfo  (%3d B):        %10d", (int) sizeof(fieldinfo), size_fieldinfo);
+       log_println("methodinfo (%3d B):        %10d", (int) sizeof(methodinfo), size_methodinfo);
+       log_println("lineinfo   (%3d B):        %10d", (int) sizeof(lineinfo), size_lineinfo);
+       log_println("codeinfo   (%3d B):        %10d", (int) sizeof(codeinfo), size_codeinfo);
+       log_println("                            ----------");
+
+       sum =
+               size_classinfo +
+               size_fieldinfo +
+               size_methodinfo +
+               size_lineinfo +
+               size_codeinfo;
+
+       log_println("                           %10d", sum);
+
+       log_println("");
+
+       log_println("linenumber tables (%5d): %10d", count_linenumbertable, size_linenumbertable);
+       log_println("exception tables:          %10d", count_extable_len);
+       log_println("patcher references:        %10d", size_patchref);
+       log_println("                            ----------");
+
+       sum =
+               size_linenumbertable +
+               count_extable_len +
+               size_patchref;
+
+       log_println("                           %10d", sum);
+
+       log_println("");
+
+       log_println("constant pool:             %10d", count_const_pool_len);
+       log_println("classref:                  %10d", count_classref_len);
+       log_println("parsed descriptors:        %10d", count_parsed_desc_len);
+       log_println("vftbl:                     %10d", count_vftbl_len);
+       log_println("compiler stubs:            %10d", count_cstub_len);
+       log_println("native stubs:              %10d", size_stub_native);
+       log_println("utf:                       %10d", count_utf_len);
+       log_println("vmcode:                    %10d", count_vmcode_len);
+       log_println("stack map:                 %10d", size_stack_map);
+       log_println("string:                    %10d", size_string);
+       log_println("threadobject:              %10d", size_threadobject);
+       log_println("thread index:              %10d", size_thread_index_t);
+       log_println("stack size:                %10d", size_stacksize);
+       log_println("lock record:               %10d", size_lock_record);
+       log_println("lock hashtable:            %10d", size_lock_hashtable);
+       log_println("lock waiter:               %10d", size_lock_waiter);
+       log_println("                            ----------");
+
+       sum =
+               count_const_pool_len +
+               count_classref_len +
+               count_parsed_desc_len + 
+               count_vftbl_len +
+               count_cstub_len +
+               size_stub_native +
+               count_utf_len +
+               count_vmcode_len +
+               size_stack_map +
+               size_string +
+               size_threadobject +
+               size_thread_index_t +
+               size_stacksize +
+               size_lock_record +
+               size_lock_hashtable +
+               size_lock_waiter;
+
+       log_println("                           %10d", sum);
+
+       log_println("");
+
+       log_println("max. code memory:          %10d", maxcodememusage);
+       log_println("max. heap memory:          %10d", maxmemusage);
+       log_println("max. dump memory:          %10d", maxdumpsize);
+       log_println("");
+       log_println("heap memory not freed:     %10d", (int32_t) memoryusage);
+       log_println("dump memory not freed:     %10d", (int32_t) globalallocateddumpsize);
+
+       log_println("");
+}
+
+
+/* statistics_print_gc_memory_usage ********************************************
+
+   Print current GC memory usage.
+
+*******************************************************************************/
+
+void statistics_print_gc_memory_usage(void)
+{
+       static int64_t count = 0;
+       int64_t max;
+       int64_t size;
+       int64_t free;
+       int64_t used;
+       int64_t total;
+
+       count++;
+
+       max   = gc_get_max_heap_size();
+       size  = gc_get_heap_size();
+       free  = gc_get_free_bytes();
+       used  = size - free;
+       total = gc_get_total_bytes();
+
+       if (opt_ProfileMemoryUsageGNUPlot) {
+               if (count == 1)
+                       fprintf(opt_ProfileMemoryUsageGNUPlot, "plot \"profile.dat\" using 1:2 with lines title \"max. Java heap size\", \"profile.dat\" using 1:3 with lines title \"Java heap size\", \"profile.dat\" using 1:4 with lines title \"used\", \"profile.dat\" using 1:5 with lines title \"free\"\n");
+
+#if SIZEOF_VOID_P == 8
+               fprintf(opt_ProfileMemoryUsageGNUPlot, "%ld %ld %ld %ld %ld\n", count, max, size, used, free);
+#else
+               fprintf(opt_ProfileMemoryUsageGNUPlot, "%lld %lld %lld %lld %lld\n", count, max, size, used, free);
+#endif
+
+               fflush(opt_ProfileMemoryUsageGNUPlot);
+       }
+       else {
+               log_println("GC memory usage -------------------");
+               log_println("");
+               log_println("max. Java heap size: %10lld", max);
+               log_println("");
+               log_println("Java heap size:      %10lld", size);
+               log_println("used:                %10lld", used);
+               log_println("free:                %10lld", free);
+               log_println("totally used:        %10lld", total);
+               log_println("");
+       }
+}
+
+
+/*
+ * 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/statistics.h b/src/vm/statistics.h
new file mode 100644 (file)
index 0000000..484fba1
--- /dev/null
@@ -0,0 +1,274 @@
+/* src/vm/statistics.h - exports global varables for statistics
+
+   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 _STATISTICS_H
+#define _STATISTICS_H
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/types.h"
+
+#include "vm/global.h"
+
+
+/* statistic macros ***********************************************************/
+
+#if defined(ENABLE_STATISTICS)
+#define STATISTICS(x) \
+    do { \
+        if (opt_stat) { \
+            x; \
+        } \
+    } while (0)
+#else
+#define STATISTICS(x)    /* nothing */
+#endif
+
+/* in_  inline statistics */
+
+#define IN_MAX                  9
+#define IN_UNIQUEVIRT           0x0000 
+#define IN_UNIQUE_INTERFACE     0x0001
+#define IN_OUTSIDERS            0x0004
+#define IN_MAXDEPTH             0x0008
+#define IN_MAXCODE              0x0010
+#define IN_JCODELENGTH          0x0020
+#define IN_EXCEPTION            0x0040
+#define IN_NOT_UNIQUE_VIRT      0x0080
+#define IN_NOT_UNIQUE_INTERFACE 0x0100
+
+#define N_UNIQUEVIRT            0
+#define N_UNIQUE_INTERFACE      1
+#define N_OUTSIDERS             2
+#define N_MAXDEPTH             3       
+#define N_MAXCODE               4 
+#define N_JCODELENGTH           5 
+#define N_EXCEPTION            6 
+#define N_NOT_UNIQUE_VIRT       7 
+#define N_NOT_UNIQUE_INTERFACE  8 
+
+
+/* global variables ***********************************************************/
+
+extern s4 codememusage;
+extern s4 maxcodememusage;
+
+extern s4 memoryusage;
+extern s4 maxmemusage;
+
+extern s4 maxdumpsize;
+
+extern s4 globalallocateddumpsize;
+extern s4 globaluseddumpsize;
+
+
+/* variables for measurements *************************************************/
+
+extern s4 size_classinfo;
+extern s4 size_fieldinfo;
+extern s4 size_methodinfo;
+extern s4 size_lineinfo;
+extern s4 size_codeinfo;
+
+extern s4 size_stub_native;
+
+extern s4 size_stack_map;
+extern s4 size_string;
+
+extern s4 size_threadobject;
+extern int32_t size_thread_index_t;
+extern int32_t size_stacksize;
+
+extern s4 size_lock_record;
+extern s4 size_lock_hashtable;
+extern s4 size_lock_waiter;
+
+extern int32_t count_linenumbertable;
+extern int32_t size_linenumbertable;
+
+extern s4 size_patchref;
+
+extern u8 count_calls_java_to_native;
+extern u8 count_calls_native_to_java;
+
+extern int count_const_pool_len;
+extern int count_classref_len;
+extern int count_parsed_desc_len;
+extern int count_vftbl_len;
+extern int count_all_methods;
+extern int count_methods_marked_used;  /*RTA*/
+extern int count_vmcode_len;
+extern int count_extable_len;
+extern int count_class_loads;
+extern int count_class_inits;
+
+extern int count_utf_len;               /* size of utf hash                   */
+extern int count_utf_new;
+extern int count_utf_new_found;
+
+extern int count_locals_conflicts;
+extern int count_locals_spilled;
+extern int count_locals_register;
+extern int count_ss_spilled;
+extern int count_ss_register;
+extern int count_methods_allocated_by_lsra;
+extern int count_mem_move_bb;
+extern int count_interface_size;
+extern int count_argument_mem_ss;
+extern int count_argument_reg_ss;
+extern int count_method_in_register;
+extern int count_mov_reg_reg;
+extern int count_mov_mem_reg;
+extern int count_mov_reg_mem;
+extern int count_mov_mem_mem;
+
+extern int count_jit_calls;
+extern int count_methods;
+extern int count_spills_read_ila;
+extern int count_spills_read_flt;
+extern int count_spills_read_dbl;
+extern int count_spills_write_ila;
+extern int count_spills_write_flt;
+extern int count_spills_write_dbl;
+extern int count_pcmd_activ;
+extern int count_pcmd_drop;
+extern int count_pcmd_zero;
+extern int count_pcmd_const_store;
+extern int count_pcmd_const_alu;
+extern int count_pcmd_const_bra;
+extern int count_pcmd_load;
+extern int count_pcmd_move;
+extern int count_load_instruction;
+extern int count_pcmd_store;
+extern int count_pcmd_store_comb;
+extern int count_dup_instruction;
+extern int count_pcmd_op;
+extern int count_pcmd_mem;
+extern int count_pcmd_met;
+extern int count_pcmd_bra;
+extern int count_pcmd_table;
+extern int count_pcmd_return;
+extern int count_pcmd_returnx;
+extern int count_check_null;
+extern int count_check_bound;
+extern int count_max_basic_blocks;
+extern int count_basic_blocks;
+extern int count_max_javainstr;
+extern int count_javainstr;
+extern int count_javacodesize;
+extern int count_javaexcsize;
+extern int count_calls;
+extern int count_tryblocks;
+extern int count_code_len;
+extern int count_data_len;
+extern int count_cstub_len;
+extern int count_max_new_stack;
+extern int count_upper_bound_new_stack;
+
+extern int count_emit_branch;
+extern int count_emit_branch_8bit;
+extern int count_emit_branch_16bit;
+extern int count_emit_branch_32bit;
+extern int count_emit_branch_64bit;
+
+extern s4 count_branches_resolved;
+extern s4 count_branches_unresolved;
+
+extern int *count_block_stack;
+extern int *count_analyse_iterations;
+extern int *count_method_bb_distribution;
+extern int *count_block_size_distribution;
+extern int *count_store_length;
+extern int *count_store_depth;
+                                /* in_  inline statistics */
+extern int count_in;
+extern int count_in_uniqVirt;
+extern int count_in_uniqIntf;
+extern int count_in_rejected;
+extern int count_in_rejected_mult;
+extern int count_in_outsiders;
+extern int count_in_uniqueVirt_not_inlined;
+extern int count_in_uniqueInterface_not_inlined;
+extern int count_in_maxDepth;
+extern int count_in_maxMethods;
+
+extern u2 count_in_not   [512];
+
+/* instruction scheduler statistics *******************************************/
+
+extern s4 count_schedule_basic_blocks;
+extern s4 count_schedule_nodes;
+extern s4 count_schedule_leaders;
+extern s4 count_schedule_max_leaders;
+extern s4 count_schedule_critical_path;
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+s8 getcputime(void);
+
+void loadingtime_start(void);
+void loadingtime_stop(void);
+void compilingtime_start(void);
+void compilingtime_stop(void);
+
+void print_times(void);
+void print_stats(void);
+
+void statistics_print_date(void);
+void statistics_print_memory_usage(void);
+void statistics_print_gc_memory_usage(void);
+
+void mem_usagelog(bool givewarnings);
+
+void compiledinvokation(void);
+void jnicallXmethodnvokation(void);
+void jniinvokation(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _STATISTICS_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:
+ */
diff --git a/src/vm/string.c b/src/vm/string.c
deleted file mode 100644 (file)
index f24e411..0000000
+++ /dev/null
@@ -1,805 +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.h"
-#include "vm/primitive.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#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_arrayclass_get_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_arrayclass_get_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..184f8f6
--- /dev/null
@@ -0,0 +1,712 @@
+/* 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 "vm/os.hpp"
+
+#include "vm/types.h"
+
+#include "vm/global.h"
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "threads/lock.hpp"
+
+#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/utf8.h"
+
+
+/* global variables ***********************************************************/
+
+/* hashsize must be power of 2 */
+
+#define HASHTABLE_STRING_SIZE    2048   /* initial size of javastring-hash    */
+
+static hashtable hashtable_string;      /* hashtable for javastrings          */
+static Mutex* mutex;
+
+
+/* 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);
+
+       mutex = new Mutex();
+
+       /* 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)
+{
+       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) {
+                               // FIXME
+                               java_lang_String js(LLNI_WRAP(s->string));
+                               
+                               if (js.is_null() || (js.get_value() == NULL)) {
+                                       /* error in hashtable found */
+                                       os::abort("stringtable_update: invalid literalstring in hashtable");
+                               }
+
+                               a = LLNI_UNWRAP(js.get_value());
+
+                               if (js.get_vftbl() == NULL)
+                                       // FIXME
+                                       LLNI_UNWRAP(js.get_handle())->vftbl = class_java_lang_String->vftbl;
+
+                               if (a->header.objheader.vftbl == 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    */
+
+       assert(buffer);
+
+       int32_t utflength = utf_get_number_of_u2s_for_buffer(buffer, blength);
+
+       java_handle_t*           h  = builtin_new(class_java_lang_String);
+       java_handle_chararray_t* ca = builtin_newarray_char(utflength);
+
+       /* javastring or character-array could not be created */
+
+       if ((h == NULL) || (ca == NULL))
+               return NULL;
+
+       /* decompress utf-string */
+
+       utf_ptr = buffer;
+
+       for (int32_t i = 0; i < utflength; i++)
+               LLNI_array_direct(ca, i) = utf_nextu2((char **) &utf_ptr);
+       
+       /* set fields of the javastring-object */
+
+       java_lang_String jls(h, ca, utflength);
+
+       return jls.get_handle();
+}
+
+
+/* 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)
+{
+       if (text == NULL)
+               return NULL;
+
+       /* Get number of bytes. We need this to completely emulate the messy */
+       /* behaviour of the RI. :(                                           */
+
+       int32_t nbytes = strlen(text);
+
+       /* calculate number of Java characters */
+
+       int32_t len = utf8_safe_number_of_u2s(text, nbytes);
+
+       /* allocate the String object and the char array */
+
+       java_handle_t*           h  = builtin_new(class_java_lang_String);
+       java_handle_chararray_t* ca = builtin_newarray_char(len);
+
+       /* javastring or character-array could not be created? */
+
+       if ((h == NULL) || (ca == NULL))
+               return NULL;
+
+       /* decompress UTF-8 string */
+
+       utf8_safe_convert_to_u2s(text, nbytes, LLNI_array_data(ca));
+
+       /* set fields of the String object */
+
+       java_lang_String jls(h, ca, len);
+
+       return jls.get_handle();
+}
+
+
+/* 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)
+{
+       if (u == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       char*   utf_ptr   = u->text;
+       int32_t utflength = utf_get_number_of_u2s(u);
+
+       java_handle_t*           h  = builtin_new(class_java_lang_String);
+       java_handle_chararray_t* ca = builtin_newarray_char(utflength);
+
+       /* javastring or character-array could not be created */
+
+       if ((h == NULL) || (ca == NULL))
+               return NULL;
+
+       /* decompress utf-string */
+
+       for (int32_t i = 0; i < utflength; i++)
+               LLNI_array_direct(ca, i) = utf_nextu2(&utf_ptr);
+       
+       /* set fields of the javastring-object */
+
+       java_lang_String jls(h, ca, utflength);
+
+       return jls.get_handle();
+}
+
+
+/* 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)
+{
+       if (u == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       char*   utf_ptr   = u->text;
+       int32_t utflength = utf_get_number_of_u2s(u);
+
+       java_handle_t*           h  = builtin_new(class_java_lang_String);
+       java_handle_chararray_t* ca = builtin_newarray_char(utflength);
+
+       /* javastring or character-array could not be created */
+       if ((h == NULL) || (ca == NULL))
+               return NULL;
+
+       /* decompress utf-string */
+
+       for (int32_t i = 0; i < utflength; i++) {
+               uint16_t ch = utf_nextu2(&utf_ptr);
+
+               if (ch == '/')
+                       ch = '.';
+
+               LLNI_array_direct(ca, i) = ch;
+       }
+       
+       /* set fields of the javastring-object */
+
+       java_lang_String jls(h, ca, utflength);
+
+       return jls.get_handle();
+}
+
+
+/* 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)
+{
+       if (text == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       int32_t len = strlen(text);
+
+       java_handle_t*           h  = builtin_new(class_java_lang_String);
+       java_handle_chararray_t* ca = builtin_newarray_char(len);
+
+       /* javastring or character-array could not be created */
+
+       if ((h == NULL) || (ca == NULL))
+               return NULL;
+
+       /* copy text */
+
+       for (int32_t i = 0; i < len; i++)
+               LLNI_array_direct(ca, i) = text[i];
+       
+       /* set fields of the javastring-object */
+
+       java_lang_String jls(h, ca, len);
+
+       return jls.get_handle();
+}
+
+
+/* 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* h)
+{
+       java_lang_String jls(h);
+
+       if (jls.is_null())
+               return (char*) "";
+
+       java_handle_chararray_t* ca = jls.get_value();
+
+       if (ca == NULL)
+               return (char*) "";
+
+       int32_t count  = jls.get_count();
+       int32_t offset = jls.get_offset();
+
+       char* buf = MNEW(char, count + 1);
+
+       int32_t i;
+       for (i = 0; i < count; i++)
+               buf[i] = LLNI_array_direct(ca, 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 jls(string);
+
+       if (jls.is_null())
+               return utf_null;
+
+       java_handle_chararray_t* value = jls.get_value();
+
+       if (jls.get_value() == NULL)
+               return utf_null;
+
+       int32_t count  = jls.get_count();
+       int32_t offset = jls.get_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                  */
+    java_chararray_t *ca;               /* copy of u2-array                   */
+    u4                key;
+    u4                slot;
+    u2                i;
+
+       mutex->lock();
+
+    /* 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) {
+               // FIXME
+               java_lang_String js(LLNI_WRAP(s->string));
+
+               if (length == js.get_count()) {
+                       /* compare text */
+
+                       for (i = 0; i < length; i++)
+                               // FIXME This is not handle capable!
+                               
+                               if (a->data[offset + i] != ((java_chararray_t*) LLNI_UNWRAP(js.get_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);
+
+                       mutex->unlock();
+
+                       return (java_object_t*) LLNI_UNWRAP(js.get_handle());
+               }
+
+       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 a new java.lang.String object on the system heap.
+       java_object_t* o = (java_object_t*) MNEW(uint8_t, class_java_lang_String->instancesize);
+       // FIXME
+       java_handle_t* h = LLNI_WRAP(o);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_string += sizeof(class_java_lang_String->instancesize);
+#endif
+
+#if defined(ENABLE_THREADS)
+       o->lockword.init();
+#endif
+
+       o->vftbl = class_java_lang_String->vftbl;
+
+       // FIXME
+       java_lang_String jls(h, LLNI_WRAP(ca), 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*) LLNI_UNWRAP(jls.get_handle());
+       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;
+               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;
+                               java_lang_String tmpjls(LLNI_WRAP(s->string));
+                               // FIXME This is not handle capable!
+                               slot  = unicode_hashkey(((java_chararray_t*) LLNI_UNWRAP(tmpjls.get_value()))->data, tmpjls.get_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;
+       }
+
+       mutex->unlock();
+
+       return (java_object_t*) LLNI_UNWRAP(jls.get_handle());
+}
+
+
+/* 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 *string)
+{
+       java_lang_String jls(string);
+
+       java_handle_chararray_t* value = jls.get_value();
+       // FIXME
+       java_chararray_t* ca = LLNI_UNWRAP(value); /* XXX see note above */
+
+       int32_t count  = jls.get_count();
+       int32_t offset = jls.get_offset();
+
+       java_object_t* o = literalstring_u2(ca, count, offset, true); /* XXX see note above */
+
+       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 jls(s);
+
+       java_handle_chararray_t* value = jls.get_value();
+
+       int32_t count  = jls.get_count();
+       int32_t offset = jls.get_offset();
+
+       for (int32_t i = offset; i < offset + count; i++) {
+               uint16_t 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..096f219
--- /dev/null
@@ -0,0 +1,108 @@
+/* src/vm/string.hpp - 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 "vm/types.h"
+
+#include "toolbox/hashtable.h"
+
+#include "vm/global.h"
+#include "vm/os.hpp"
+#include "vm/utf8.h"
+
+
+/* data structure of internal javastrings stored in global hashtable **********/
+
+struct literalstring {
+       literalstring     *hashlink;        /* link for external hash chain       */
+       java_object_t     *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 74ffc23..0000000
+++ /dev/null
@@ -1,106 +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
-
-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);
-
-#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/suck.cpp b/src/vm/suck.cpp
new file mode 100644 (file)
index 0000000..1c1664a
--- /dev/null
@@ -0,0 +1,619 @@
+/* src/vm/suck.cpp - functions to read LE ordered types from a buffer
+
+   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 <stdlib.h>
+
+#include "vm/types.h"
+
+#include "arch.h"
+
+#include "mm/memory.h"
+
+#include "threads/mutex.hpp"
+
+#include "toolbox/list.hpp"
+#include "toolbox/logging.h"
+#include "toolbox/util.h"
+
+#include "vm/exceptions.hpp"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/os.hpp"
+#include "vm/properties.hpp"
+#include "vm/suck.hpp"
+#include "vm/vm.hpp"
+#include "vm/zip.hpp"
+
+
+/* global variables ***********************************************************/
+
+List<list_classpath_entry*>* list_classpath_entries;
+
+
+/* suck_init *******************************************************************
+
+   Initializes the suck subsystem like initializing the classpath
+   entries list.
+
+*******************************************************************************/
+
+bool suck_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("suck_init");
+
+#warning Move this list into VM.
+       list_classpath_entries = new List<list_classpath_entry*>();
+
+       /* everything's ok */
+
+       return true;
+}
+
+
+/* scandir_filter **************************************************************
+
+   Filters for zip/jar files.
+
+*******************************************************************************/
+
+static int scandir_filter(const struct dirent *a)
+{
+       s4 namlen;
+
+#if defined(_DIRENT_HAVE_D_NAMLEN)
+       namlen = a->d_namlen;
+#else
+       namlen = strlen(a->d_name);
+#endif
+
+       if ((strncasecmp(a->d_name + namlen - 4, ".zip", 4) == 0) ||
+               (strncasecmp(a->d_name + namlen - 4, ".jar", 4) == 0))
+               return 1;
+
+       return 0;
+}
+
+
+/* suck_add ********************************************************************
+
+   Adds a classpath to the global classpath entries list.
+
+*******************************************************************************/
+
+void suck_add(char *classpath)
+{
+       list_classpath_entry *lce;
+       char                 *start;
+       char                 *end;
+       char                 *filename;
+       s4                    filenamelen;
+       bool                  is_zip;
+       char                 *cwd;
+       s4                    cwdlen;
+#if defined(ENABLE_ZLIB)
+       hashtable            *ht;
+#endif
+
+       /* parse the classpath string */
+
+       for (start = classpath; (*start) != '\0'; ) {
+
+               /* search for ':' delimiter to get the end of the current entry */
+               for (end = start; ((*end) != '\0') && ((*end) != ':'); end++);
+
+               if (start != end) {
+                       is_zip = false;
+                       filenamelen = end - start;
+
+                       if (filenamelen > 4) {
+                               if ((strncasecmp(end - 4, ".zip", 4) == 0) ||
+                                       (strncasecmp(end - 4, ".jar", 4) == 0)) {
+                                       is_zip = true;
+                               }
+                       }
+
+                       /* save classpath entries as absolute pathnames */
+
+                       cwd = NULL;
+                       cwdlen = 0;
+
+                       if (*start != '/') {                      /* XXX fix me for win32 */
+                               cwd = _Jv_getcwd();
+                               cwdlen = strlen(cwd) + strlen("/");
+                       }
+
+                       /* allocate memory for filename and fill it */
+
+                       filename = MNEW(char, filenamelen + cwdlen + strlen("/") +
+                                                       strlen("0"));
+
+                       if (cwd) {
+                               strcpy(filename, cwd);
+                               strcat(filename, "/");
+                               strncat(filename, start, filenamelen);
+
+                               /* add cwd length to file length */
+                               filenamelen += cwdlen;
+
+                       } else {
+                               strncpy(filename, start, filenamelen);
+                               filename[filenamelen] = '\0';
+                       }
+
+                       lce = NULL;
+
+                       if (is_zip) {
+#if defined(ENABLE_ZLIB)
+                               ht = zip_open(filename);
+
+                               if (ht != NULL) {
+                                       lce = NEW(list_classpath_entry);
+
+                                       lce->type      = CLASSPATH_ARCHIVE;
+                                       lce->htclasses = ht;
+                                       lce->path      = filename;
+                                       lce->pathlen   = filenamelen;
+
+                                       /* SUN compatible -verbose:class output */
+
+                                       if (opt_verboseclass)
+                                               printf("[Opened %s]\n", filename);
+                               }
+
+#else
+                               os::abort("suck_add: zip/jar files not supported");
+#endif
+                       }
+                       else {
+                               if (filename[filenamelen - 1] != '/') {/* XXX fixme for win32 */
+                                       filename[filenamelen] = '/';
+                                       filename[filenamelen + 1] = '\0';
+                                       filenamelen++;
+                               }
+
+                               lce = NEW(list_classpath_entry);
+
+                               lce->type    = CLASSPATH_PATH;
+                               lce->path    = filename;
+                               lce->pathlen = filenamelen;
+                       }
+
+                       /* add current classpath entry, if no error */
+
+                       if (lce != NULL)
+                               list_classpath_entries->push_back(lce);
+               }
+
+               /* goto next classpath entry, skip ':' delimiter */
+
+               if ((*end) == ':')
+                       start = end + 1;
+               else
+                       start = end;
+       }
+}
+
+
+/* suck_add_from_property ******************************************************
+
+   Adds a classpath form a property entry to the global classpath
+   entries list.
+
+*******************************************************************************/
+
+void suck_add_from_property(const char *key)
+{
+       const char     *value;
+       const char     *start;
+       const char     *end;
+       s4              pathlen;
+       struct dirent **namelist;
+       s4              n;
+       s4              i;
+       s4              namlen;
+       char           *p;
+
+       // Get the property value.
+       Properties& properties = VM::get_current()->get_properties();
+       value = properties.get(key);
+
+       if (value == NULL)
+               return;
+
+       /* get the directory entries of the property */
+
+       for (start = value; (*start) != '\0'; ) {
+
+               /* search for ':' delimiter to get the end of the current entry */
+
+               for (end = start; ((*end) != '\0') && ((*end) != ':'); end++);
+
+               /* found an entry */
+
+               if (start != end) {
+                       /* allocate memory for the path entry */
+
+                       pathlen = end - start;
+                       char* path = MNEW(char, pathlen + strlen("0"));
+
+                       /* copy and terminate the string */
+
+                       strncpy(path, start, pathlen);
+                       path[pathlen] = '\0';
+
+                       /* Reset namelist to NULL for the freeing in an error case
+                          (see below). */
+
+                       namelist = NULL;
+
+                       /* scan the directory found for zip/jar files */
+
+                       n = os::scandir((const char*) path, &namelist, &scandir_filter, (int (*)(const void*, const void*)) &alphasort);
+
+                       /* On error, just continue, this should be ok. */
+
+                       if (n > 0) {
+                               for (i = 0; i < n; i++) {
+#if defined(_DIRENT_HAVE_D_NAMLEN)
+                                       namlen = namelist[i]->d_namlen;
+#else
+                                       namlen = strlen(namelist[i]->d_name);
+#endif
+
+                                       /* Allocate memory for bootclasspath. */
+
+                                       // FIXME Make boot_class_path const char*.
+                                       char* boot_class_path = (char*) properties.get("sun.boot.class.path");
+
+                                       p = MNEW(char,
+                                                        pathlen + strlen("/") + namlen +
+                                                        strlen(":") +
+                                                        strlen(boot_class_path) +
+                                                        strlen("0"));
+
+                                       /* Prepend the file found to the bootclasspath. */
+
+                                       strcpy(p, path);
+                                       strcat(p, "/");
+                                       strcat(p, namelist[i]->d_name);
+                                       strcat(p, ":");
+                                       strcat(p, boot_class_path);
+
+                                       properties.put("sun.boot.class.path", p);
+                                       properties.put("java.boot.class.path", p);
+
+                                       MFREE(boot_class_path, char, strlen(boot_class_path));
+
+                                       /* free the memory allocated by scandir */
+                                       /* (We use `free` as the memory came from the C library.) */
+
+                                       free(namelist[i]);
+                               }
+                       }
+
+                       /* On some systems (like Linux) when n == 0, then namelist
+                          returned from scnadir is NULL, thus we don't have to
+                          free it.
+                          (Use `free` as the memory came from the C library.) */
+
+                       if (namelist != NULL)
+                               free(namelist);
+
+                       MFREE(path, char, pathlen + strlen("0"));
+               }
+
+               /* goto next entry, skip ':' delimiter */
+
+               if ((*end) == ':')
+                       start = end + 1;
+               else
+                       start = end;
+       }
+}
+
+
+/* suck_check_classbuffer_size *************************************************
+
+   Assert that at least <len> bytes are left to read <len> is limited
+   to the range of non-negative s4 values.
+
+*******************************************************************************/
+
+bool suck_check_classbuffer_size(classbuffer *cb, s4 len)
+{
+#ifdef ENABLE_VERIFIER
+       if (len < 0 || ((cb->data + cb->size) - cb->pos) < len) {
+               exceptions_throw_classformaterror(cb->clazz, "Truncated class file");
+               return false;
+       }
+#endif /* ENABLE_VERIFIER */
+
+       return true;
+}
+
+
+u1 suck_u1(classbuffer *cb)
+{
+       u1 a;
+
+       a = SUCK_BE_U1(cb->pos);
+       cb->pos++;
+
+       return a;
+}
+
+
+u2 suck_u2(classbuffer *cb)
+{
+       u2 a;
+
+       a = SUCK_BE_U2(cb->pos);
+       cb->pos += 2;
+
+       return a;
+}
+
+
+u4 suck_u4(classbuffer *cb)
+{
+       u4 a;
+
+       a = SUCK_BE_U4(cb->pos);
+       cb->pos += 4;
+
+       return a;
+}
+
+
+u8 suck_u8(classbuffer *cb)
+{
+       u8 a;
+
+       a = SUCK_BE_U8(cb->pos);
+       cb->pos += 8;
+
+       return a;
+}
+
+
+float suck_float(classbuffer *cb)
+{
+       float f;
+
+#if WORDS_BIGENDIAN == 0
+       u1 buffer[4];
+       u2 i;
+
+       for (i = 0; i < 4; i++)
+               buffer[3 - i] = suck_u1(cb);
+
+       MCOPY((u1 *) (&f), buffer, u1, 4);
+#else
+       suck_nbytes((u1*) (&f), cb, 4);
+#endif
+
+       assert(sizeof(float) == 4);
+       
+       return f;
+}
+
+
+double suck_double(classbuffer *cb)
+{
+       double d;
+
+#if WORDS_BIGENDIAN == 0
+       u1 buffer[8];
+       u2 i;   
+
+# if defined(__ARM__) && defined(__ARMEL__) && !defined(__VFP_FP__)
+       /*
+        * On little endian ARM processors when using FPA, word order
+        * of doubles is still big endian. So take that into account
+        * here. When using VFP, word order of doubles follows byte
+        * order. (michi 2005/07/24)
+        */
+       for (i = 0; i < 4; i++)
+               buffer[3 - i] = suck_u1(cb);
+       for (i = 0; i < 4; i++)
+               buffer[7 - i] = suck_u1(cb);
+# else
+       for (i = 0; i < 8; i++)
+               buffer[7 - i] = suck_u1(cb);
+# endif /* defined(__ARM__) && ... */
+
+       MCOPY((u1 *) (&d), buffer, u1, 8);
+#else 
+       suck_nbytes((u1*) (&d), cb, 8);
+#endif
+
+       assert(sizeof(double) == 8);
+       
+       return d;
+}
+
+
+/* suck_nbytes *****************************************************************
+
+   Transfer block of classfile data into a buffer.
+
+*******************************************************************************/
+
+void suck_nbytes(u1 *buffer, classbuffer *cb, s4 len)
+{
+       MCOPY(buffer, cb->pos, u1, len);
+       cb->pos += len;
+}
+
+
+/* suck_skip_nbytes ************************************************************
+
+   Skip block of classfile data.
+
+*******************************************************************************/
+
+void suck_skip_nbytes(classbuffer *cb, s4 len)
+{
+       cb->pos += len;
+}
+
+
+/* suck_start ******************************************************************
+
+   Returns true if classbuffer is already loaded or a file for the
+   specified class has succussfully been read in. All directories of
+   the searchpath are used to find the classfile (<classname>.class).
+   Returns NULL if no classfile is found and writes an error message.
+       
+*******************************************************************************/
+
+classbuffer *suck_start(classinfo *c)
+{
+       list_classpath_entry *lce;
+       char                 *filename;
+       s4                    filenamelen;
+       char                 *path;
+       FILE                 *classfile;
+       s4                    len;
+       struct stat           buffer;
+       classbuffer          *cb;
+
+       /* initialize return value */
+
+       cb = NULL;
+
+       /* get the classname as char string (do it here for the warning at
+       the end of the function) */
+
+       filenamelen = utf_bytes(c->name) + strlen(".class") + strlen("0");
+       filename = MNEW(char, filenamelen);
+
+       utf_copy(filename, c->name);
+       strcat(filename, ".class");
+
+       /* walk through all classpath entries */
+
+       for (List<list_classpath_entry*>::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end() && cb == NULL; it++) {
+               lce = *it;
+
+#if defined(ENABLE_ZLIB)
+               if (lce->type == CLASSPATH_ARCHIVE) {
+
+                       /* enter a monitor on zip/jar archives */
+
+                       lce->mutex->lock();
+
+                       /* try to get the file in current archive */
+
+                       cb = zip_get(lce, c);
+
+                       /* leave the monitor */
+
+                       lce->mutex->unlock();
+
+               } else {
+#endif /* defined(ENABLE_ZLIB) */
+                       path = MNEW(char, lce->pathlen + filenamelen);
+                       strcpy(path, lce->path);
+                       strcat(path, filename);
+
+                       classfile = os::fopen(path, "r");
+
+                       if (classfile) {                                   /* file exists */
+                               if (!os::stat(path, &buffer)) {     /* read classfile data */
+                                       cb = NEW(classbuffer);
+                                       cb->clazz = c;
+                                       cb->size  = buffer.st_size;
+                                       cb->data  = MNEW(u1, cb->size);
+                                       cb->pos   = cb->data;
+                                       cb->path  = lce->path;
+
+                                       /* read class data */
+
+                                       len = os::fread((void *) cb->data, 1, cb->size,
+                                                                          classfile);
+
+                                       if (len != buffer.st_size) {
+                                               suck_stop(cb);
+/*                                             if (ferror(classfile)) { */
+/*                                             } */
+                                       }
+
+                                       /* close the class file */
+
+                                       os::fclose(classfile);
+                               }
+                       }
+
+                       MFREE(path, char, lce->pathlen + filenamelen);
+#if defined(ENABLE_ZLIB)
+               }
+#endif
+       }
+
+       if (opt_verbose)
+               if (cb == NULL)
+                       dolog("Warning: Can not open class file '%s'", filename);
+
+       MFREE(filename, char, filenamelen);
+
+       return cb;
+}
+
+
+/* suck_stop *******************************************************************
+
+   Frees memory for buffer with classfile data.
+
+   CAUTION: This function may only be called if buffer has been
+   allocated by suck_start with reading a file.
+       
+*******************************************************************************/
+
+void suck_stop(classbuffer *cb)
+{
+       /* free memory */
+
+       MFREE(cb->data, u1, cb->size);
+       FREE(cb, classbuffer);
+}
+
+
+/*
+ * 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/suck.hpp b/src/vm/suck.hpp
new file mode 100644 (file)
index 0000000..20e2580
--- /dev/null
@@ -0,0 +1,206 @@
+/* src/vm/suck.hpp - functions to read LE ordered types from a buffer
+
+   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 _SUCK_HPP
+#define _SUCK_HPP
+
+#include "config.h"
+
+#include "vm/types.h"
+
+#include "threads/mutex.hpp"
+
+#include "toolbox/hashtable.h"
+#include "toolbox/list.hpp"
+
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/loader.hpp"
+
+
+/* list_classpath_entry *******************************************************/
+
+enum {
+       CLASSPATH_PATH,
+       CLASSPATH_ARCHIVE
+};
+
+typedef struct list_classpath_entry list_classpath_entry;
+
+struct list_classpath_entry {
+#if defined(ENABLE_THREADS)
+       Mutex             *mutex;               /* mutex locking on zip/jar files */
+#endif
+       s4                 type;
+       char              *path;
+       s4                 pathlen;
+#if defined(ENABLE_ZLIB)
+       hashtable         *htclasses;
+#endif
+};
+
+
+/* macros to read LE and BE types from a buffer ********************************
+
+   BE macros are for Java class file loading.
+   LE macros are for ZIP file loading.
+
+*******************************************************************************/
+
+/* LE macros (for ZIP files ) *************************************************/
+
+#if defined(__I386__) || defined(__X86_64__)
+
+/* we can optimize the LE access on little endian machines without alignment */
+
+#define SUCK_LE_U1(p)    *((u1 *) (p))
+#define SUCK_LE_U2(p)    *((u2 *) (p))
+#define SUCK_LE_U4(p)    *((u4 *) (p))
+#define SUCK_LE_U8(p)    *((u8 *) (p))
+
+#else /* defined(__I386__) || defined(__X86_64__) */
+
+#define SUCK_LE_U1(p) \
+      ((u1) (p)[0])
+
+#define SUCK_LE_U2(p) \
+    ((((u2) (p)[1]) << 8) + \
+      ((u2) (p)[0]))
+
+#define SUCK_LE_U4(p) \
+    ((((u4) (p)[3]) << 24) + \
+     (((u4) (p)[2]) << 16) + \
+     (((u4) (p)[1]) << 8) + \
+      ((u4) (p)[0]))
+
+#define SUCK_LE_U8(p) \
+    ((((u8) (p)[7]) << 56) + \
+     (((u8) (p)[6]) << 48) + \
+     (((u8) (p)[5]) << 40) + \
+     (((u8) (p)[4]) << 32) + \
+     (((u8) (p)[3]) << 24) + \
+     (((u8) (p)[2]) << 16) + \
+     (((u8) (p)[1]) << 8) + \
+      ((u8) (p)[0]))
+
+#endif /* defined(__I386__) || defined(__X86_64__) */
+
+
+/* BE macros (for Java class files ) ******************************************/
+
+#define SUCK_BE_U1(p) \
+      ((u1) (p)[0])
+
+#define SUCK_BE_U2(p) \
+    ((((u2) (p)[0]) << 8) + \
+      ((u2) (p)[1]))
+
+#define SUCK_BE_U4(p) \
+    ((((u4) (p)[0]) << 24) + \
+     (((u4) (p)[1]) << 16) + \
+     (((u4) (p)[2]) << 8) + \
+      ((u4) (p)[3]))
+
+#define SUCK_BE_U8(p) \
+    ((((u8) (p)[0]) << 56) + \
+     (((u8) (p)[1]) << 48) + \
+     (((u8) (p)[2]) << 40) + \
+     (((u8) (p)[3]) << 32) + \
+     (((u8) (p)[4]) << 24) + \
+     (((u8) (p)[5]) << 16) + \
+     (((u8) (p)[6]) << 8) + \
+      ((u8) (p)[7]))
+
+
+#define SUCK_BE_S1(p)    (s1) SUCK_BE_U1(p)
+#define SUCK_BE_S2(p)    (s2) SUCK_BE_U2(p)
+#define SUCK_BE_S4(p)    (s4) SUCK_BE_U4(p)
+#define SUCK_BE_S8(p)    (s8) SUCK_BE_U8(p)
+
+
+/* signed suck defines ********************************************************/
+
+#define suck_s1(a)    (s1) suck_u1((a))
+#define suck_s2(a)    (s2) suck_u2((a))
+#define suck_s4(a)    (s4) suck_u4((a))
+#define suck_s8(a)    (s8) suck_u8((a))
+
+
+/* export variables ***********************************************************/
+
+#ifdef __cplusplus
+extern List<list_classpath_entry*>* list_classpath_entries;
+#else
+extern List* list_classpath_entries;
+#endif
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool suck_init(void);
+
+void suck_add(char *classpath);
+void suck_add_from_property(const char *key);
+
+bool suck_check_classbuffer_size(classbuffer *cb, s4 len);
+
+u1 suck_u1(classbuffer *cb);
+u2 suck_u2(classbuffer *cb);
+u4 suck_u4(classbuffer *cb);
+u8 suck_u8(classbuffer *cb);
+
+float suck_float(classbuffer *cb);
+double suck_double(classbuffer *cb);
+
+void suck_nbytes(u1 *buffer, classbuffer *cb, s4 len);
+void suck_skip_nbytes(classbuffer *cb, s4 len);
+
+classbuffer *suck_start(classinfo *c);
+
+void suck_stop(classbuffer *cb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SUCK_HPP
+
+
+/*
+ * 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/utf8.c b/src/vm/utf8.c
new file mode 100644 (file)
index 0000000..1d7d760
--- /dev/null
@@ -0,0 +1,1934 @@
+/* src/vm/utf8.c - utf8 string 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 <string.h>
+#include <assert.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "threads/mutex.hpp"
+
+#include "toolbox/hashtable.h"
+
+#include "vm/exceptions.hpp"
+#include "vm/options.h"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#include "vm/utf8.h"
+
+
+/* global variables ***********************************************************/
+
+/* hashsize must be power of 2 */
+
+#define HASHTABLE_UTF_SIZE    16384     /* initial size of utf-hash           */
+
+hashtable *hashtable_utf;               /* hashtable for utf8-symbols         */
+
+
+/* utf-symbols for pointer comparison of frequently used strings **************/
+
+utf *utf_java_lang_Object;
+
+utf *utf_java_lang_Class;
+utf *utf_java_lang_ClassLoader;
+utf *utf_java_lang_Cloneable;
+utf *utf_java_lang_SecurityManager;
+utf *utf_java_lang_String;
+utf *utf_java_lang_ThreadGroup;
+utf *utf_java_lang_ref_SoftReference;
+utf *utf_java_lang_ref_WeakReference;
+utf *utf_java_lang_ref_PhantomReference;
+utf *utf_java_io_Serializable;
+
+utf *utf_java_lang_Throwable;
+utf *utf_java_lang_Error;
+
+utf *utf_java_lang_AbstractMethodError;
+utf *utf_java_lang_ClassCircularityError;
+utf *utf_java_lang_ClassFormatError;
+utf *utf_java_lang_ExceptionInInitializerError;
+utf *utf_java_lang_IncompatibleClassChangeError;
+utf *utf_java_lang_InstantiationError;
+utf *utf_java_lang_InternalError;
+utf *utf_java_lang_LinkageError;
+utf *utf_java_lang_NoClassDefFoundError;
+utf *utf_java_lang_NoSuchFieldError;
+utf *utf_java_lang_NoSuchMethodError;
+utf *utf_java_lang_OutOfMemoryError;
+utf *utf_java_lang_UnsatisfiedLinkError;
+utf *utf_java_lang_UnsupportedClassVersionError;
+utf *utf_java_lang_VerifyError;
+utf *utf_java_lang_VirtualMachineError;
+
+utf *utf_java_lang_Exception;
+
+utf *utf_java_lang_ArithmeticException;
+utf *utf_java_lang_ArrayIndexOutOfBoundsException;
+utf *utf_java_lang_ArrayStoreException;
+utf *utf_java_lang_ClassCastException;
+utf *utf_java_lang_ClassNotFoundException;
+utf *utf_java_lang_CloneNotSupportedException;
+utf *utf_java_lang_IllegalAccessException;
+utf *utf_java_lang_IllegalArgumentException;
+utf *utf_java_lang_IllegalMonitorStateException;
+utf *utf_java_lang_InstantiationException;
+utf *utf_java_lang_InterruptedException;
+utf *utf_java_lang_NegativeArraySizeException;
+utf *utf_java_lang_NullPointerException;
+utf *utf_java_lang_RuntimeException;
+utf *utf_java_lang_StringIndexOutOfBoundsException;
+
+utf *utf_java_lang_reflect_InvocationTargetException;
+
+utf *utf_java_security_PrivilegedActionException;
+
+#if defined(ENABLE_JAVASE)
+utf* utf_java_lang_Void;
+#endif
+
+utf* utf_java_lang_Boolean;
+utf* utf_java_lang_Byte;
+utf* utf_java_lang_Character;
+utf* utf_java_lang_Short;
+utf* utf_java_lang_Integer;
+utf* utf_java_lang_Long;
+utf* utf_java_lang_Float;
+utf* utf_java_lang_Double;
+
+#if defined(ENABLE_JAVASE)
+utf *utf_java_lang_StackTraceElement;
+utf *utf_java_lang_reflect_Constructor;
+utf *utf_java_lang_reflect_Field;
+utf *utf_java_lang_reflect_Method;
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+utf *utf_java_lang_reflect_VMConstructor;
+utf *utf_java_lang_reflect_VMField;
+utf *utf_java_lang_reflect_VMMethod;
+# endif
+
+utf *utf_java_util_Vector;
+#endif
+
+utf *utf_InnerClasses;                  /* InnerClasses                       */
+utf *utf_ConstantValue;                 /* ConstantValue                      */
+utf *utf_Code;                          /* Code                               */
+utf *utf_Exceptions;                    /* Exceptions                         */
+utf *utf_LineNumberTable;               /* LineNumberTable                    */
+utf *utf_SourceFile;                    /* SourceFile                         */
+
+#if defined(ENABLE_JAVASE)
+utf *utf_EnclosingMethod;
+utf *utf_Signature;
+utf *utf_StackMapTable;
+
+#if defined(ENABLE_ANNOTATIONS)
+utf *utf_RuntimeVisibleAnnotations;            /* RuntimeVisibleAnnotations            */
+utf *utf_RuntimeInvisibleAnnotations;          /* RuntimeInvisibleAnnotations          */
+utf *utf_RuntimeVisibleParameterAnnotations;   /* RuntimeVisibleParameterAnnotations   */
+utf *utf_RuntimeInvisibleParameterAnnotations; /* RuntimeInvisibleParameterAnnotations */
+utf *utf_AnnotationDefault;                    /* AnnotationDefault                    */
+#endif
+#endif
+
+utf *utf_init;                          /* <init>                             */
+utf *utf_clinit;                        /* <clinit>                           */
+utf *utf_clone;                         /* clone                              */
+utf *utf_finalize;                      /* finalize                           */
+utf *utf_invoke;
+utf *utf_main;
+utf *utf_run;                           /* run                                */
+
+utf *utf_add;
+utf *utf_dispatch;
+utf *utf_remove;
+utf *utf_addThread;
+utf *utf_removeThread;
+utf *utf_put;
+utf *utf_get;
+utf *utf_uncaughtException;
+utf *utf_value;
+
+utf *utf_fillInStackTrace;
+utf *utf_findNative;
+utf *utf_getSystemClassLoader;
+utf *utf_initCause;
+utf *utf_loadClass;
+utf *utf_loadClassInternal;
+utf *utf_printStackTrace;
+
+utf *utf_division_by_zero;
+
+utf *utf_Z;                             /* Z                                  */
+utf *utf_B;                             /* B                                  */
+utf *utf_C;                             /* C                                  */
+utf *utf_S;                             /* S                                  */
+utf *utf_I;                             /* I                                  */
+utf *utf_J;                             /* J                                  */
+utf *utf_F;                             /* F                                  */
+utf *utf_D;                             /* D                                  */
+
+utf *utf_void__void;                    /* ()V                                */
+utf *utf_boolean__void;                 /* (Z)V                               */
+utf *utf_byte__void;                    /* (B)V                               */
+utf *utf_char__void;                    /* (C)V                               */
+utf *utf_short__void;                   /* (S)V                               */
+utf *utf_int__void;                     /* (I)V                               */
+utf *utf_long__void;                    /* (J)V                               */
+utf *utf_float__void;                   /* (F)V                               */
+utf *utf_double__void;                  /* (D)V                               */
+
+utf *utf_void__java_lang_ClassLoader;   /* ()Ljava/lang/ClassLoader;          */
+utf *utf_void__java_lang_Object;        /* ()Ljava/lang/Object;               */
+utf *utf_void__java_lang_Throwable;     /* ()Ljava/lang/Throwable;            */
+utf *utf_java_lang_ClassLoader_java_lang_String__J;
+utf *utf_java_lang_Exception__V;        /* (Ljava/lang/Exception;)V           */
+utf *utf_java_lang_Object__java_lang_Object;
+utf *utf_java_lang_String__void;        /* (Ljava/lang/String;)V              */
+utf *utf_java_lang_String__java_lang_Class;
+utf *utf_java_lang_Thread__V;           /* (Ljava/lang/Thread;)V              */
+utf *utf_java_lang_Thread_java_lang_Throwable__V;
+utf *utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V;
+utf *utf_java_lang_Throwable__void;     /* (Ljava/lang/Throwable;)V           */
+utf *utf_java_lang_Throwable__java_lang_Throwable;
+
+utf *utf_not_named_yet;                 /* special name for unnamed classes   */
+utf *utf_null;
+utf *array_packagename;
+
+
+/* utf_init ********************************************************************
+
+   Initializes the utf8 subsystem.
+
+*******************************************************************************/
+
+void utf8_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("utf8_init");
+
+       /* create utf8 hashtable */
+
+       hashtable_utf = NEW(hashtable);
+
+       hashtable_create(hashtable_utf, HASHTABLE_UTF_SIZE);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               count_utf_len += sizeof(utf*) * hashtable_utf->size;
+#endif
+
+       /* create utf-symbols for pointer comparison of frequently used strings */
+
+       utf_java_lang_Object           = utf_new_char("java/lang/Object");
+
+       utf_java_lang_Class            = utf_new_char("java/lang/Class");
+       utf_java_lang_ClassLoader      = utf_new_char("java/lang/ClassLoader");
+       utf_java_lang_Cloneable        = utf_new_char("java/lang/Cloneable");
+       utf_java_lang_SecurityManager  = utf_new_char("java/lang/SecurityManager");
+       utf_java_lang_String           = utf_new_char("java/lang/String");
+       utf_java_lang_ThreadGroup      = utf_new_char("java/lang/ThreadGroup");
+
+       utf_java_lang_ref_SoftReference =
+               utf_new_char("java/lang/ref/SoftReference");
+
+       utf_java_lang_ref_WeakReference =
+               utf_new_char("java/lang/ref/WeakReference");
+
+       utf_java_lang_ref_PhantomReference =
+               utf_new_char("java/lang/ref/PhantomReference");
+
+       utf_java_io_Serializable       = utf_new_char("java/io/Serializable");
+
+       utf_java_lang_Throwable        = utf_new_char("java/lang/Throwable");
+       utf_java_lang_Error            = utf_new_char("java/lang/Error");
+
+       utf_java_lang_ClassCircularityError =
+               utf_new_char("java/lang/ClassCircularityError");
+
+       utf_java_lang_ClassFormatError = utf_new_char("java/lang/ClassFormatError");
+
+       utf_java_lang_ExceptionInInitializerError =
+               utf_new_char("java/lang/ExceptionInInitializerError");
+
+       utf_java_lang_IncompatibleClassChangeError =
+               utf_new_char("java/lang/IncompatibleClassChangeError");
+
+       utf_java_lang_InstantiationError =
+               utf_new_char("java/lang/InstantiationError");
+
+       utf_java_lang_InternalError    = utf_new_char("java/lang/InternalError");
+       utf_java_lang_LinkageError     = utf_new_char("java/lang/LinkageError");
+
+       utf_java_lang_NoClassDefFoundError =
+               utf_new_char("java/lang/NoClassDefFoundError");
+
+       utf_java_lang_OutOfMemoryError = utf_new_char("java/lang/OutOfMemoryError");
+
+       utf_java_lang_UnsatisfiedLinkError =
+               utf_new_char("java/lang/UnsatisfiedLinkError");
+
+       utf_java_lang_UnsupportedClassVersionError =
+               utf_new_char("java/lang/UnsupportedClassVersionError");
+
+       utf_java_lang_VerifyError      = utf_new_char("java/lang/VerifyError");
+
+       utf_java_lang_VirtualMachineError =
+               utf_new_char("java/lang/VirtualMachineError");
+
+#if defined(ENABLE_JAVASE)
+       utf_java_lang_AbstractMethodError =
+               utf_new_char("java/lang/AbstractMethodError");
+
+       utf_java_lang_NoSuchFieldError =
+               utf_new_char("java/lang/NoSuchFieldError");
+
+       utf_java_lang_NoSuchMethodError =
+               utf_new_char("java/lang/NoSuchMethodError");
+#endif
+
+       utf_java_lang_Exception        = utf_new_char("java/lang/Exception");
+
+       utf_java_lang_ArithmeticException =
+               utf_new_char("java/lang/ArithmeticException");
+
+       utf_java_lang_ArrayIndexOutOfBoundsException =
+               utf_new_char("java/lang/ArrayIndexOutOfBoundsException");
+
+       utf_java_lang_ArrayStoreException =
+               utf_new_char("java/lang/ArrayStoreException");
+
+       utf_java_lang_ClassCastException =
+               utf_new_char("java/lang/ClassCastException");
+
+       utf_java_lang_ClassNotFoundException =
+               utf_new_char("java/lang/ClassNotFoundException");
+
+       utf_java_lang_CloneNotSupportedException =
+               utf_new_char("java/lang/CloneNotSupportedException");
+
+       utf_java_lang_IllegalAccessException =
+               utf_new_char("java/lang/IllegalAccessException");
+
+       utf_java_lang_IllegalArgumentException =
+               utf_new_char("java/lang/IllegalArgumentException");
+
+       utf_java_lang_IllegalMonitorStateException =
+               utf_new_char("java/lang/IllegalMonitorStateException");
+
+       utf_java_lang_InstantiationException =
+               utf_new_char("java/lang/InstantiationException");
+
+       utf_java_lang_InterruptedException =
+               utf_new_char("java/lang/InterruptedException");
+
+       utf_java_lang_NegativeArraySizeException =
+               utf_new_char("java/lang/NegativeArraySizeException");
+
+       utf_java_lang_NullPointerException =
+               utf_new_char("java/lang/NullPointerException");
+
+       utf_java_lang_RuntimeException =
+               utf_new_char("java/lang/RuntimeException");
+
+       utf_java_lang_StringIndexOutOfBoundsException =
+               utf_new_char("java/lang/StringIndexOutOfBoundsException");
+
+       utf_java_lang_reflect_InvocationTargetException =
+               utf_new_char("java/lang/reflect/InvocationTargetException");
+
+       utf_java_security_PrivilegedActionException =
+               utf_new_char("java/security/PrivilegedActionException");
+#if defined(ENABLE_JAVASE)
+       utf_java_lang_Void             = utf_new_char("java/lang/Void");
+#endif
+
+       utf_java_lang_Boolean          = utf_new_char("java/lang/Boolean");
+       utf_java_lang_Byte             = utf_new_char("java/lang/Byte");
+       utf_java_lang_Character        = utf_new_char("java/lang/Character");
+       utf_java_lang_Short            = utf_new_char("java/lang/Short");
+       utf_java_lang_Integer          = utf_new_char("java/lang/Integer");
+       utf_java_lang_Long             = utf_new_char("java/lang/Long");
+       utf_java_lang_Float            = utf_new_char("java/lang/Float");
+       utf_java_lang_Double           = utf_new_char("java/lang/Double");
+
+#if defined(ENABLE_JAVASE)
+       utf_java_lang_StackTraceElement =
+               utf_new_char("java/lang/StackTraceElement");
+
+       utf_java_lang_reflect_Constructor =
+               utf_new_char("java/lang/reflect/Constructor");
+
+       utf_java_lang_reflect_Field    = utf_new_char("java/lang/reflect/Field");
+       utf_java_lang_reflect_Method   = utf_new_char("java/lang/reflect/Method");
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       utf_java_lang_reflect_VMConstructor = utf_new_char("java/lang/reflect/VMConstructor");
+       utf_java_lang_reflect_VMField       = utf_new_char("java/lang/reflect/VMField");
+       utf_java_lang_reflect_VMMethod      = utf_new_char("java/lang/reflect/VMMethod");
+# endif
+
+       utf_java_util_Vector           = utf_new_char("java/util/Vector");
+#endif
+
+       utf_InnerClasses               = utf_new_char("InnerClasses");
+       utf_ConstantValue              = utf_new_char("ConstantValue");
+       utf_Code                       = utf_new_char("Code");
+       utf_Exceptions                 = utf_new_char("Exceptions");
+       utf_LineNumberTable            = utf_new_char("LineNumberTable");
+       utf_SourceFile                 = utf_new_char("SourceFile");
+
+#if defined(ENABLE_JAVASE)
+       utf_EnclosingMethod            = utf_new_char("EnclosingMethod");
+       utf_Signature                  = utf_new_char("Signature");
+       utf_StackMapTable              = utf_new_char("StackMapTable");
+
+# if defined(ENABLE_ANNOTATIONS)
+       utf_RuntimeVisibleAnnotations            = utf_new_char("RuntimeVisibleAnnotations");
+       utf_RuntimeInvisibleAnnotations          = utf_new_char("RuntimeInvisibleAnnotations");
+       utf_RuntimeVisibleParameterAnnotations   = utf_new_char("RuntimeVisibleParameterAnnotations");
+       utf_RuntimeInvisibleParameterAnnotations = utf_new_char("RuntimeInvisibleParameterAnnotations");
+       utf_AnnotationDefault                    = utf_new_char("AnnotationDefault");
+# endif
+#endif
+
+       utf_init                           = utf_new_char("<init>");
+       utf_clinit                         = utf_new_char("<clinit>");
+       utf_clone                      = utf_new_char("clone");
+       utf_finalize                   = utf_new_char("finalize");
+       utf_invoke                     = utf_new_char("invoke");
+       utf_main                       = utf_new_char("main");
+       utf_run                        = utf_new_char("run");
+
+       utf_add                        = utf_new_char("add");
+       utf_dispatch                   = utf_new_char("dispatch");
+       utf_remove                     = utf_new_char("remove");
+       utf_addThread                  = utf_new_char("addThread");
+       utf_removeThread               = utf_new_char("removeThread");
+       utf_put                        = utf_new_char("put");
+       utf_get                        = utf_new_char("get");
+       utf_uncaughtException          = utf_new_char("uncaughtException");
+       utf_value                      = utf_new_char("value");
+
+       utf_fillInStackTrace           = utf_new_char("fillInStackTrace");
+       utf_findNative                 = utf_new_char("findNative");
+       utf_getSystemClassLoader       = utf_new_char("getSystemClassLoader");
+       utf_initCause                  = utf_new_char("initCause");
+       utf_loadClass                  = utf_new_char("loadClass");
+       utf_loadClassInternal          = utf_new_char("loadClassInternal");
+       utf_printStackTrace            = utf_new_char("printStackTrace");
+
+       utf_division_by_zero           = utf_new_char("/ by zero");
+
+       utf_Z                          = utf_new_char("Z");
+       utf_B                          = utf_new_char("B");
+       utf_C                          = utf_new_char("C");
+       utf_S                          = utf_new_char("S");
+       utf_I                          = utf_new_char("I");
+       utf_J                          = utf_new_char("J");
+       utf_F                          = utf_new_char("F");
+       utf_D                          = utf_new_char("D");
+
+       utf_void__void                 = utf_new_char("()V");
+       utf_boolean__void              = utf_new_char("(Z)V");
+       utf_byte__void                 = utf_new_char("(B)V");
+       utf_char__void                 = utf_new_char("(C)V");
+       utf_short__void                = utf_new_char("(S)V");
+       utf_int__void                  = utf_new_char("(I)V");
+       utf_long__void                 = utf_new_char("(J)V");
+       utf_float__void                = utf_new_char("(F)V");
+       utf_double__void               = utf_new_char("(D)V");
+       utf_void__java_lang_Object     = utf_new_char("()Ljava/lang/Object;");
+       utf_void__java_lang_Throwable  = utf_new_char("()Ljava/lang/Throwable;");
+
+       utf_void__java_lang_ClassLoader =
+               utf_new_char("()Ljava/lang/ClassLoader;");
+
+       utf_java_lang_ClassLoader_java_lang_String__J =
+               utf_new_char("(Ljava/lang/ClassLoader;Ljava/lang/String;)J");
+
+       utf_java_lang_Exception__V     = utf_new_char("(Ljava/lang/Exception;)V");
+
+       utf_java_lang_Object__java_lang_Object =
+               utf_new_char("(Ljava/lang/Object;)Ljava/lang/Object;");
+
+       utf_java_lang_String__void     = utf_new_char("(Ljava/lang/String;)V");
+
+       utf_java_lang_String__java_lang_Class =
+               utf_new_char("(Ljava/lang/String;)Ljava/lang/Class;");
+
+       utf_java_lang_Thread__V        = utf_new_char("(Ljava/lang/Thread;)V");
+
+       utf_java_lang_Thread_java_lang_Throwable__V =
+               utf_new_char("(Ljava/lang/Thread;Ljava/lang/Throwable;)V");
+
+       utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V =
+               utf_new_char("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V");
+
+       utf_java_lang_Throwable__void  = utf_new_char("(Ljava/lang/Throwable;)V");
+
+       utf_java_lang_Throwable__java_lang_Throwable =
+               utf_new_char("(Ljava/lang/Throwable;)Ljava/lang/Throwable;");
+
+       utf_null                       = utf_new_char("null");
+       utf_not_named_yet              = utf_new_char("\t<not_named_yet>");
+       array_packagename              = utf_new_char("\t<the array package>");
+}
+
+
+/* utf_hashkey *****************************************************************
+
+   The hashkey is computed from the utf-text by using up to 8
+   characters.  For utf-symbols longer than 15 characters 3 characters
+   are taken from the beginning and the end, 2 characters are taken
+   from the middle.
+
+*******************************************************************************/
+
+#define nbs(val) ((u4) *(++text) << val) /* get next byte, left shift by val  */
+#define fbs(val) ((u4) *(  text) << val) /* get first byte, left shift by val */
+
+u4 utf_hashkey(const char *text, u4 length)
+{
+       const char *start_pos = text;       /* pointer to utf text                */
+       u4 a;
+
+       switch (length) {
+       case 0: /* empty string */
+               return 0;
+
+       case 1: return fbs(0);
+       case 2: return fbs(0) ^ nbs(3);
+       case 3: return fbs(0) ^ nbs(3) ^ nbs(5);
+       case 4: return fbs(0) ^ nbs(2) ^ nbs(4) ^ nbs(6);
+       case 5: return fbs(0) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(6);
+       case 6: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(5) ^ nbs(6);
+       case 7: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6);
+       case 8: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7);
+
+       case 9:
+               a = fbs(0);
+               a ^= nbs(1);
+               a ^= nbs(2);
+               text++;
+               return a ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7) ^ nbs(8);
+
+       case 10:
+               a = fbs(0);
+               text++;
+               a ^= nbs(2);
+               a ^= nbs(3);
+               a ^= nbs(4);
+               text++;
+               return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9);
+
+       case 11:
+               a = fbs(0);
+               text++;
+               a ^= nbs(2);
+               a ^= nbs(3);
+               a ^= nbs(4);
+               text++;
+               return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9) ^ nbs(10);
+
+       case 12:
+               a = fbs(0);
+               text += 2;
+               a ^= nbs(2);
+               a ^= nbs(3);
+               text++;
+               a ^= nbs(5);
+               a ^= nbs(6);
+               a ^= nbs(7);
+               text++;
+               return a ^ nbs(9) ^ nbs(10);
+
+       case 13:
+               a = fbs(0);
+               a ^= nbs(1);
+               text++;
+               a ^= nbs(3);
+               a ^= nbs(4);
+               text += 2;      
+               a ^= nbs(7);
+               a ^= nbs(8);
+               text += 2;
+               return a ^ nbs(9) ^ nbs(10);
+
+       case 14:
+               a = fbs(0);
+               text += 2;      
+               a ^= nbs(3);
+               a ^= nbs(4);
+               text += 2;      
+               a ^= nbs(7);
+               a ^= nbs(8);
+               text += 2;
+               return a ^ nbs(9) ^ nbs(10) ^ nbs(11);
+
+       case 15:
+               a = fbs(0);
+               text += 2;      
+               a ^= nbs(3);
+               a ^= nbs(4);
+               text += 2;      
+               a ^= nbs(7);
+               a ^= nbs(8);
+               text += 2;
+               return a ^ nbs(9) ^ nbs(10) ^ nbs(11);
+
+       default:  /* 3 characters from beginning */
+               a = fbs(0);
+               text += 2;
+               a ^= nbs(3);
+               a ^= nbs(4);
+
+               /* 2 characters from middle */
+               text = start_pos + (length / 2);
+               a ^= fbs(5);
+               text += 2;
+               a ^= nbs(6);    
+
+               /* 3 characters from end */
+               text = start_pos + length - 4;
+
+               a ^= fbs(7);
+               text++;
+
+               return a ^ nbs(10) ^ nbs(11);
+    }
+}
+
+/* utf_full_hashkey ************************************************************
+
+   This function computes a hash value using all bytes in the string.
+
+   The algorithm is the "One-at-a-time" algorithm as published
+   by Bob Jenkins on http://burtleburtle.net/bob/hash/doobs.html.
+
+*******************************************************************************/
+
+u4 utf_full_hashkey(const char *text, u4 length)
+{
+       register const unsigned char *p = (const unsigned char *) text;
+       register u4 hash;
+       register u4 i;
+
+       hash = 0;
+       for (i=length; i--;)
+       {
+           hash += *p++;
+           hash += (hash << 10);
+           hash ^= (hash >> 6);
+       }
+       hash += (hash << 3);
+       hash ^= (hash >> 11);
+       hash += (hash << 15);
+
+       return hash;
+}
+
+/* unicode_hashkey *************************************************************
+
+   Compute the hashkey of a unicode string.
+
+*******************************************************************************/
+
+u4 unicode_hashkey(u2 *text, u2 len)
+{
+       return utf_hashkey((char *) text, len);
+}
+
+
+/* utf_new *********************************************************************
+
+   Creates a new utf-symbol, the text of the symbol is passed as a
+   u1-array. The function searches the utf-hashtable for a utf-symbol
+   with this text. On success the element returned, otherwise a new
+   hashtable element is created.
+
+   If the number of entries in the hashtable exceeds twice the size of
+   the hashtable slots a reorganization of the hashtable is done and
+   the utf symbols are copied to a new hashtable with doubled size.
+
+*******************************************************************************/
+
+utf *utf_new(const char *text, u2 length)
+{
+       u4 key;                             /* hashkey computed from utf-text     */
+       u4 slot;                            /* slot in hashtable                  */
+       utf *u;                             /* hashtable element                  */
+       u2 i;
+
+       Mutex_lock(hashtable_utf->mutex);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               count_utf_new++;
+#endif
+
+       key  = utf_hashkey(text, length);
+       slot = key & (hashtable_utf->size - 1);
+       u    = hashtable_utf->ptr[slot];
+
+       /* search external hash chain for utf-symbol */
+
+       while (u) {
+               if (u->blength == length) {
+                       /* compare text of hashtable elements */
+
+                       for (i = 0; i < length; i++)
+                               if (text[i] != u->text[i])
+                                       goto nomatch;
+                       
+#if defined(ENABLE_STATISTICS)
+                       if (opt_stat)
+                               count_utf_new_found++;
+#endif
+
+                       /* symbol found in hashtable */
+
+                       Mutex_unlock(hashtable_utf->mutex);
+
+                       return u;
+               }
+
+       nomatch:
+               u = u->hashlink; /* next element in external chain */
+       }
+
+       /* location in hashtable found, create new utf element */
+
+       u = NEW(utf);
+
+       u->blength  = length;               /* length in bytes of utfstring       */
+       u->hashlink = hashtable_utf->ptr[slot]; /* link in external hashchain     */
+       u->text     = mem_alloc(length + 1);/* allocate memory for utf-text       */
+
+       memcpy(u->text, text, length);      /* copy utf-text                      */
+       u->text[length] = '\0';
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               count_utf_len += sizeof(utf) + length + 1;
+#endif
+
+       hashtable_utf->ptr[slot] = u;       /* insert symbol into table           */
+       hashtable_utf->entries++;           /* update number of entries           */
+
+       if (hashtable_utf->entries > (hashtable_utf->size * 2)) {
+
+        /* reorganization of hashtable, average length of the external
+           chains is approx. 2 */
+
+               hashtable *newhash;                              /* the new hashtable */
+               u4         i;
+               utf       *u;
+               utf       *nextu;
+               u4         slot;
+
+               /* create new hashtable, double the size */
+
+               newhash = hashtable_resize(hashtable_utf, hashtable_utf->size * 2);
+
+#if defined(ENABLE_STATISTICS)
+               if (opt_stat)
+                       count_utf_len += sizeof(utf*) * hashtable_utf->size;
+#endif
+
+               /* transfer elements to new hashtable */
+
+               for (i = 0; i < hashtable_utf->size; i++) {
+                       u = hashtable_utf->ptr[i];
+
+                       while (u) {
+                               nextu = u->hashlink;
+                               slot  = utf_hashkey(u->text, u->blength) & (newhash->size - 1);
+                                               
+                               u->hashlink = (utf *) newhash->ptr[slot];
+                               newhash->ptr[slot] = u;
+
+                               /* follow link in external hash chain */
+
+                               u = nextu;
+                       }
+               }
+       
+               /* dispose old table */
+
+               hashtable_free(hashtable_utf);
+
+               hashtable_utf = newhash;
+       }
+
+       Mutex_unlock(hashtable_utf->mutex);
+
+       return u;
+}
+
+
+/* utf_new_u2 ******************************************************************
+
+   Make utf symbol from u2 array, if isclassname is true '.' is
+   replaced by '/'.
+
+*******************************************************************************/
+
+utf *utf_new_u2(u2 *unicode_pos, u4 unicode_length, bool isclassname)
+{
+       char *buffer;                   /* memory buffer for  unicode characters  */
+       char *pos;                      /* pointer to current position in buffer  */
+       u4 left;                        /* unicode characters left                */
+       u4 buflength;                   /* utf length in bytes of the u2 array    */
+       utf *result;                    /* resulting utf-string                   */
+       int i;
+
+       /* determine utf length in bytes and allocate memory */
+
+       buflength = u2_utflength(unicode_pos, unicode_length); 
+       buffer    = MNEW(char, buflength);
+       left = buflength;
+       pos  = buffer;
+
+       for (i = 0; i++ < unicode_length; unicode_pos++) {
+               /* next unicode character */
+               u2 c = *unicode_pos;
+               
+               if ((c != 0) && (c < 0x80)) {
+                       /* 1 character */       
+                       left--;
+               if ((int) left < 0) break;
+                       /* convert classname */
+                       if (isclassname && c == '.')
+                               *pos++ = '/';
+                       else
+                               *pos++ = (char) c;
+
+               } else if (c < 0x800) {             
+                       /* 2 characters */                              
+               unsigned char high = c >> 6;
+               unsigned char low  = c & 0x3F;
+                       left = left - 2;
+               if ((int) left < 0) break;
+               *pos++ = high | 0xC0; 
+               *pos++ = low  | 0x80;     
+
+               } else {         
+               /* 3 characters */                              
+               char low  = c & 0x3f;
+               char mid  = (c >> 6) & 0x3F;
+               char high = c >> 12;
+                       left = left - 3;
+               if ((int) left < 0) break;
+               *pos++ = high | 0xE0; 
+               *pos++ = mid  | 0x80;  
+               *pos++ = low  | 0x80;   
+               }
+       }
+       
+       /* insert utf-string into symbol-table */
+       result = utf_new(buffer,buflength);
+
+       MFREE(buffer, char, buflength);
+
+       return result;
+}
+
+
+/* utf_new_char ****************************************************************
+
+   Creates a new utf symbol, the text for this symbol is passed as a
+   c-string ( = char* ).
+
+*******************************************************************************/
+
+utf *utf_new_char(const char *text)
+{
+       return utf_new(text, strlen(text));
+}
+
+
+/* utf_new_char_classname ******************************************************
+
+   Creates a new utf symbol, the text for this symbol is passed as a
+   c-string ( = char* ) "." characters are going to be replaced by
+   "/". Since the above function is used often, this is a separte
+   function, instead of an if.
+
+*******************************************************************************/
+
+utf *utf_new_char_classname(const char *text)
+{
+       if (strchr(text, '.')) {
+               char *txt = strdup(text);
+               char *end = txt + strlen(txt);
+               char *c;
+               utf *tmpRes;
+
+               for (c = txt; c < end; c++)
+                       if (*c == '.') *c = '/';
+
+               tmpRes = utf_new(txt, strlen(txt));
+               FREE(txt, 0);
+
+               return tmpRes;
+
+       } else
+               return utf_new(text, strlen(text));
+}
+
+
+/* utf_nextu2 ******************************************************************
+
+   Read the next unicode character from the utf string and increment
+   the utf-string pointer accordingly.
+
+   CAUTION: This function is unsafe for input that was not checked 
+            by is_valid_utf!
+
+*******************************************************************************/
+
+u2 utf_nextu2(char **utf_ptr)
+{
+    /* uncompressed unicode character */
+    u2 unicode_char = 0;
+    /* current position in utf text */ 
+    unsigned char *utf = (unsigned char *) (*utf_ptr);
+    /* bytes representing the unicode character */
+    unsigned char ch1, ch2, ch3;
+    /* number of bytes used to represent the unicode character */
+    int len = 0;
+       
+    switch ((ch1 = utf[0]) >> 4) {
+       default: /* 1 byte */
+               (*utf_ptr)++;
+               return (u2) ch1;
+       case 0xC: 
+       case 0xD: /* 2 bytes */
+               if (((ch2 = utf[1]) & 0xC0) == 0x80) {
+                       unsigned char high = ch1 & 0x1F;
+                       unsigned char low  = ch2 & 0x3F;
+                       unicode_char = (high << 6) + low;
+                       len = 2;
+               }
+               break;
+
+       case 0xE: /* 2 or 3 bytes */
+               if (((ch2 = utf[1]) & 0xC0) == 0x80) {
+                       if (((ch3 = utf[2]) & 0xC0) == 0x80) {
+                               unsigned char low  = ch3 & 0x3f;
+                               unsigned char mid  = ch2 & 0x3f;
+                               unsigned char high = ch1 & 0x0f;
+                               unicode_char = (((high << 6) + mid) << 6) + low;
+                               len = 3;
+                       } else
+                               len = 2;                                           
+               }
+               break;
+    }
+
+    /* update position in utf-text */
+    *utf_ptr = (char *) (utf + len);
+
+    return unicode_char;
+}
+
+
+/* utf_bytes *******************************************************************
+
+   Determine number of bytes (aka. octets) in the utf string.
+
+   IN:
+      u............utf string
+
+   OUT:
+      The number of octets of this utf string.
+         There is _no_ terminating zero included in this count.
+
+*******************************************************************************/
+
+u4 utf_bytes(utf *u)
+{
+       return u->blength;
+}
+
+
+/* utf_get_number_of_u2s_for_buffer ********************************************
+
+   Determine number of UTF-16 u2s in the given UTF-8 buffer
+
+   CAUTION: This function is unsafe for input that was not checked 
+            by is_valid_utf!
+
+   CAUTION: Use this function *only* when you want to convert an UTF-8 buffer
+   to an array of u2s (UTF-16) and want to know how many of them you will get.
+   All other uses of this function are probably wrong.
+
+   IN:
+      buffer........points to first char in buffer
+         blength.......number of _bytes_ in the buffer
+
+   OUT:
+      the number of u2s needed to hold this string in UTF-16 encoding.
+         There is _no_ terminating zero included in this count.
+
+   NOTE: Unlike utf_get_number_of_u2s, this function never throws an
+   exception.
+
+*******************************************************************************/
+
+u4 utf_get_number_of_u2s_for_buffer(const char *buffer, u4 blength)
+{
+       const char *endpos;                 /* points behind utf string           */
+       const char *utf_ptr;                /* current position in utf text       */
+       u4 len = 0;                         /* number of unicode characters       */
+
+       utf_ptr = buffer;
+       endpos = utf_ptr + blength;
+
+       while (utf_ptr < endpos) {
+               len++;
+               /* next unicode character */
+               utf_nextu2((char **)&utf_ptr);
+       }
+
+       assert(utf_ptr == endpos);
+
+       return len;
+}
+
+
+/* utf_get_number_of_u2s *******************************************************
+
+   Determine number of UTF-16 u2s in the utf string.
+
+   CAUTION: This function is unsafe for input that was not checked 
+            by is_valid_utf!
+
+   CAUTION: Use this function *only* when you want to convert a utf string
+   to an array of u2s and want to know how many of them you will get.
+   All other uses of this function are probably wrong.
+
+   IN:
+      u............utf string
+
+   OUT:
+      the number of u2s needed to hold this string in UTF-16 encoding.
+         There is _no_ terminating zero included in this count.
+         XXX 0 if a NullPointerException has been thrown (see below)
+
+*******************************************************************************/
+
+u4 utf_get_number_of_u2s(utf *u)
+{
+       char *endpos;                       /* points behind utf string           */
+       char *utf_ptr;                      /* current position in utf text       */
+       u4 len = 0;                         /* number of unicode characters       */
+
+       /* XXX this is probably not checked by most callers! Review this after */
+       /* the invalid uses of this function have been eliminated */
+       if (u == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       endpos = UTF_END(u);
+       utf_ptr = u->text;
+
+       while (utf_ptr < endpos) {
+               len++;
+               /* next unicode character */
+               utf_nextu2(&utf_ptr);
+       }
+
+       if (utf_ptr != endpos) {
+               /* string ended abruptly */
+               exceptions_throw_internalerror("Illegal utf8 string");
+               return 0;
+       }
+
+       return len;
+}
+
+
+/* utf8_safe_number_of_u2s *****************************************************
+
+   Determine number of UTF-16 u2s needed for decoding the given UTF-8 string.
+   (For invalid UTF-8 the U+fffd replacement character will be counted.)
+
+   This function is safe even for invalid UTF-8 strings.
+
+   IN:
+      text..........zero-terminated(!) UTF-8 string (may be invalid)
+                       must NOT be NULL
+         nbytes........strlen(text). (This is needed to completely emulate
+                       the RI).
+
+   OUT:
+      the number of u2s needed to hold this string in UTF-16 encoding.
+         There is _no_ terminating zero included in this count.
+
+*******************************************************************************/
+
+s4 utf8_safe_number_of_u2s(const char *text, s4 nbytes) {
+       register const unsigned char *t;
+       register s4 byte;
+       register s4 len;
+       register const unsigned char *tlimit;
+       s4 byte1;
+       s4 byte2;
+       s4 byte3;
+       s4 value;
+       s4 skip;
+
+       assert(text);
+       assert(nbytes >= 0);
+
+       len = 0;
+       t = (const unsigned char *) text;
+       tlimit = t + nbytes;
+
+       /* CAUTION: Keep this code in sync with utf8_safe_convert_to_u2s! */
+
+       while (1) {
+               byte = *t++;
+
+               if (byte & 0x80) {
+                       /* highest bit set, non-ASCII character */
+
+                       if ((byte & 0xe0) == 0xc0) {
+                               /* 2-byte: should be 110..... 10...... ? */
+
+                               if ((*t++ & 0xc0) == 0x80)
+                                       ; /* valid 2-byte */
+                               else
+                                       t--; /* invalid */
+                       }
+                       else if ((byte & 0xf0) == 0xe0) {
+                               /* 3-byte: should be 1110.... 10...... 10...... */
+                               /*                            ^t                */
+
+                               if (t + 2 > tlimit)
+                                       return len + 1; /* invalid, stop here */
+
+                               if ((*t++ & 0xc0) == 0x80) {
+                                       if ((*t++ & 0xc0) == 0x80)
+                                               ; /* valid 3-byte */
+                                       else
+                                               t--; /* invalid */
+                               }
+                               else
+                                       t--; /* invalid */
+                       }
+                       else if ((byte & 0xf8) == 0xf0) {
+                               /* 4-byte: should be 11110... 10...... 10...... 10...... */
+                               /*                            ^t                         */
+
+                               if (t + 3 > tlimit)
+                                       return len + 1; /* invalid, stop here */
+
+                               if (((byte1 = *t++) & 0xc0) == 0x80) {
+                                       if (((byte2 = *t++) & 0xc0) == 0x80) {
+                                               if (((byte3 = *t++) & 0xc0) == 0x80) {
+                                                       /* valid 4-byte UTF-8? */
+                                                       value = ((byte  & 0x07) << 18)
+                                                                 | ((byte1 & 0x3f) << 12)
+                                                                 | ((byte2 & 0x3f) <<  6)
+                                                                 | ((byte3 & 0x3f)      );
+
+                                                       if (value > 0x10FFFF)
+                                                               ; /* invalid */
+                                                       else if (value > 0xFFFF)
+                                                               len += 1; /* we need surrogates */
+                                                       else
+                                                               ; /* 16bit suffice */
+                                               }
+                                               else
+                                                       t--; /* invalid */
+                                       }
+                                       else
+                                               t--; /* invalid */
+                               }
+                               else
+                                       t--; /* invalid */
+                       }
+                       else if ((byte & 0xfc) == 0xf8) {
+                               /* invalid 5-byte */
+                               if (t + 4 > tlimit)
+                                       return len + 1; /* invalid, stop here */
+
+                               skip = 4;
+                               for (; skip && ((*t & 0xc0) == 0x80); --skip)
+                                       t++;
+                       }
+                       else if ((byte & 0xfe) == 0xfc) {
+                               /* invalid 6-byte */
+                               if (t + 5 > tlimit)
+                                       return len + 1; /* invalid, stop here */
+
+                               skip = 5;
+                               for (; skip && ((*t & 0xc0) == 0x80); --skip)
+                                       t++;
+                       }
+                       else
+                               ; /* invalid */
+               }
+               else {
+                       /* NUL */
+
+                       if (byte == 0)
+                               break;
+
+                       /* ASCII character, common case */
+               }
+
+               len++;
+       }
+
+       return len;
+}
+
+
+/* utf8_safe_convert_to_u2s ****************************************************
+
+   Convert the given UTF-8 string to UTF-16 into a pre-allocated buffer.
+   (Invalid UTF-8 will be replaced with the U+fffd replacement character.)
+   Use utf8_safe_number_of_u2s to determine the number of u2s to allocate.
+
+   This function is safe even for invalid UTF-8 strings.
+
+   IN:
+      text..........zero-terminated(!) UTF-8 string (may be invalid)
+                       must NOT be NULL
+         nbytes........strlen(text). (This is needed to completely emulate
+                                       the RI).
+         buffer........a preallocated array of u2s to receive the decoded
+                       string. Use utf8_safe_number_of_u2s to get the
+                                       required number of u2s for allocating this.
+
+*******************************************************************************/
+
+#define UNICODE_REPLACEMENT  0xfffd
+
+void utf8_safe_convert_to_u2s(const char *text, s4 nbytes, u2 *buffer) {
+       register const unsigned char *t;
+       register s4 byte;
+       register const unsigned char *tlimit;
+       s4 byte1;
+       s4 byte2;
+       s4 byte3;
+       s4 value;
+       s4 skip;
+
+       assert(text);
+       assert(nbytes >= 0);
+
+       t = (const unsigned char *) text;
+       tlimit = t + nbytes;
+
+       /* CAUTION: Keep this code in sync with utf8_safe_number_of_u2s! */
+
+       while (1) {
+               byte = *t++;
+
+               if (byte & 0x80) {
+                       /* highest bit set, non-ASCII character */
+
+                       if ((byte & 0xe0) == 0xc0) {
+                               /* 2-byte: should be 110..... 10...... */
+
+                               if (((byte1 = *t++) & 0xc0) == 0x80) {
+                                       /* valid 2-byte UTF-8 */
+                                       *buffer++ = ((byte  & 0x1f) << 6)
+                                                         | ((byte1 & 0x3f)     );
+                               }
+                               else {
+                                       *buffer++ = UNICODE_REPLACEMENT;
+                                       t--;
+                               }
+                       }
+                       else if ((byte & 0xf0) == 0xe0) {
+                               /* 3-byte: should be 1110.... 10...... 10...... */
+
+                               if (t + 2 > tlimit) {
+                                       *buffer++ = UNICODE_REPLACEMENT;
+                                       return;
+                               }
+
+                               if (((byte1 = *t++) & 0xc0) == 0x80) {
+                                       if (((byte2 = *t++) & 0xc0) == 0x80) {
+                                               /* valid 3-byte UTF-8 */
+                                               *buffer++ = ((byte  & 0x0f) << 12)
+                                                                 | ((byte1 & 0x3f) <<  6)
+                                                                 | ((byte2 & 0x3f)      );
+                                       }
+                                       else {
+                                               *buffer++ = UNICODE_REPLACEMENT;
+                                               t--;
+                                       }
+                               }
+                               else {
+                                       *buffer++ = UNICODE_REPLACEMENT;
+                                       t--;
+                               }
+                       }
+                       else if ((byte & 0xf8) == 0xf0) {
+                               /* 4-byte: should be 11110... 10...... 10...... 10...... */
+
+                               if (t + 3 > tlimit) {
+                                       *buffer++ = UNICODE_REPLACEMENT;
+                                       return;
+                               }
+
+                               if (((byte1 = *t++) & 0xc0) == 0x80) {
+                                       if (((byte2 = *t++) & 0xc0) == 0x80) {
+                                               if (((byte3 = *t++) & 0xc0) == 0x80) {
+                                                       /* valid 4-byte UTF-8? */
+                                                       value = ((byte  & 0x07) << 18)
+                                                                 | ((byte1 & 0x3f) << 12)
+                                                                 | ((byte2 & 0x3f) <<  6)
+                                                                 | ((byte3 & 0x3f)      );
+
+                                                       if (value > 0x10FFFF) {
+                                                               *buffer++ = UNICODE_REPLACEMENT;
+                                                       }
+                                                       else if (value > 0xFFFF) {
+                                                               /* we need surrogates */
+                                                               *buffer++ = 0xd800 | ((value >> 10) - 0x40);
+                                                               *buffer++ = 0xdc00 | (value & 0x03ff);
+                                                       }
+                                                       else
+                                                               *buffer++ = value; /* 16bit suffice */
+                                               }
+                                               else {
+                                                       *buffer++ = UNICODE_REPLACEMENT;
+                                                       t--;
+                                               }
+                                       }
+                                       else {
+                                               *buffer++ = UNICODE_REPLACEMENT;
+                                               t--;
+                                       }
+                               }
+                               else {
+                                       *buffer++ = UNICODE_REPLACEMENT;
+                                       t--;
+                               }
+                       }
+                       else if ((byte & 0xfc) == 0xf8) {
+                               if (t + 4 > tlimit) {
+                                       *buffer++ = UNICODE_REPLACEMENT;
+                                       return;
+                               }
+
+                               skip = 4;
+                               for (; skip && ((*t & 0xc0) == 0x80); --skip)
+                                       t++;
+                               *buffer++ = UNICODE_REPLACEMENT;
+                       }
+                       else if ((byte & 0xfe) == 0xfc) {
+                               if (t + 5 > tlimit) {
+                                       *buffer++ = UNICODE_REPLACEMENT;
+                                       return;
+                               }
+
+                               skip = 5;
+                               for (; skip && ((*t & 0xc0) == 0x80); --skip)
+                                       t++;
+                               *buffer++ = UNICODE_REPLACEMENT;
+                       }
+                       else
+                               *buffer++ = UNICODE_REPLACEMENT;
+               }
+               else {
+                       /* NUL */
+
+                       if (byte == 0)
+                               break;
+
+                       /* ASCII character, common case */
+
+                       *buffer++ = byte;
+               }
+       }
+}
+
+
+/* u2_utflength ****************************************************************
+
+   Returns the utf length in bytes of a u2 array.
+
+*******************************************************************************/
+
+u4 u2_utflength(u2 *text, u4 u2_length)
+{
+       u4 result_len = 0;                  /* utf length in bytes                */
+       u2 ch;                              /* current unicode character          */
+       u4 len;
+       
+       for (len = 0; len < u2_length; len++) {
+               /* next unicode character */
+               ch = *text++;
+         
+               /* determine bytes required to store unicode character as utf */
+               if (ch && (ch < 0x80)) 
+                       result_len++;
+               else if (ch < 0x800)
+                       result_len += 2;        
+               else 
+                       result_len += 3;        
+       }
+
+    return result_len;
+}
+
+
+/* utf_copy ********************************************************************
+
+   Copy the given utf string byte-for-byte to a buffer.
+
+   IN:
+      buffer.......the buffer
+         u............the utf string
+
+*******************************************************************************/
+
+void utf_copy(char *buffer, utf *u)
+{
+       /* our utf strings are zero-terminated (done by utf_new) */
+       MCOPY(buffer, u->text, char, u->blength + 1);
+}
+
+
+/* utf_cat *********************************************************************
+
+   Append the given utf string byte-for-byte to a buffer.
+
+   IN:
+      buffer.......the buffer
+         u............the utf string
+
+*******************************************************************************/
+
+void utf_cat(char *buffer, utf *u)
+{
+       /* our utf strings are zero-terminated (done by utf_new) */
+       MCOPY(buffer + strlen(buffer), u->text, char, u->blength + 1);
+}
+
+
+/* utf_copy_classname **********************************************************
+
+   Copy the given utf classname byte-for-byte to a buffer.
+   '/' is replaced by '.'
+
+   IN:
+      buffer.......the buffer
+         u............the utf string
+
+*******************************************************************************/
+
+void utf_copy_classname(char *buffer, utf *u)
+{
+       char *bufptr;
+       char *srcptr;
+       char *endptr;
+       char ch;
+
+       bufptr = buffer;
+       srcptr = u->text;
+       endptr = UTF_END(u) + 1; /* utfs are zero-terminared by utf_new */
+
+       while (srcptr != endptr) {
+               ch = *srcptr++;
+               if (ch == '/')
+                       ch = '.';
+               *bufptr++ = ch;
+       }
+}
+
+
+/* utf_cat *********************************************************************
+
+   Append the given utf classname byte-for-byte to a buffer.
+   '/' is replaced by '.'
+
+   IN:
+      buffer.......the buffer
+         u............the utf string
+
+*******************************************************************************/
+
+void utf_cat_classname(char *buffer, utf *u)
+{
+       utf_copy_classname(buffer + strlen(buffer), u);
+}
+
+/* utf_display_printable_ascii *************************************************
+
+   Write utf symbol to stdout (for debugging purposes).
+   Non-printable and non-ASCII characters are printed as '?'.
+
+*******************************************************************************/
+
+void utf_display_printable_ascii(utf *u)
+{
+       char *endpos;                       /* points behind utf string           */
+       char *utf_ptr;                      /* current position in utf text       */
+
+       if (u == NULL) {
+               printf("NULL");
+               fflush(stdout);
+               return;
+       }
+
+       endpos = UTF_END(u);
+       utf_ptr = u->text;
+
+       while (utf_ptr < endpos) {
+               /* read next unicode character */
+
+               u2 c = utf_nextu2(&utf_ptr);
+
+               if ((c >= 32) && (c <= 127))
+                       printf("%c", c);
+               else
+                       printf("?");
+       }
+
+       fflush(stdout);
+}
+
+
+/* utf_display_printable_ascii_classname ***************************************
+
+   Write utf symbol to stdout with `/' converted to `.' (for debugging
+   purposes).
+   Non-printable and non-ASCII characters are printed as '?'.
+
+*******************************************************************************/
+
+void utf_display_printable_ascii_classname(utf *u)
+{
+       char *endpos;                       /* points behind utf string           */
+       char *utf_ptr;                      /* current position in utf text       */
+
+       if (u == NULL) {
+               printf("NULL");
+               fflush(stdout);
+               return;
+       }
+
+       endpos = UTF_END(u);
+       utf_ptr = u->text;
+
+       while (utf_ptr < endpos) {
+               /* read next unicode character */
+
+               u2 c = utf_nextu2(&utf_ptr);
+
+               if (c == '/')
+                       c = '.';
+
+               if ((c >= 32) && (c <= 127))
+                       printf("%c", c);
+               else
+                       printf("?");
+       }
+
+       fflush(stdout);
+}
+
+
+/* utf_sprint_convert_to_latin1 ************************************************
+       
+   Write utf symbol into c-string (for debugging purposes).
+   Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield
+   invalid results.
+
+*******************************************************************************/
+
+void utf_sprint_convert_to_latin1(char *buffer, utf *u)
+{
+       char *endpos;                       /* points behind utf string           */
+       char *utf_ptr;                      /* current position in utf text       */
+       u2 pos = 0;                         /* position in c-string               */
+
+       if (!u) {
+               strcpy(buffer, "NULL");
+               return;
+       }
+
+       endpos = UTF_END(u);
+       utf_ptr = u->text;
+
+       while (utf_ptr < endpos) 
+               /* copy next unicode character */       
+               buffer[pos++] = utf_nextu2(&utf_ptr);
+
+       /* terminate string */
+       buffer[pos] = '\0';
+}
+
+
+/* utf_sprint_convert_to_latin1_classname **************************************
+       
+   Write utf symbol into c-string with `/' converted to `.' (for debugging
+   purposes).
+   Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield
+   invalid results.
+
+*******************************************************************************/
+
+void utf_sprint_convert_to_latin1_classname(char *buffer, utf *u)
+{
+       char *endpos;                       /* points behind utf string           */
+       char *utf_ptr;                      /* current position in utf text       */
+       u2 pos = 0;                         /* position in c-string               */
+
+       if (!u) {
+               strcpy(buffer, "NULL");
+               return;
+       }
+
+       endpos = UTF_END(u);
+       utf_ptr = u->text;
+
+       while (utf_ptr < endpos) {
+               /* copy next unicode character */       
+               u2 c = utf_nextu2(&utf_ptr);
+               if (c == '/') c = '.';
+               buffer[pos++] = c;
+       }
+
+       /* terminate string */
+       buffer[pos] = '\0';
+}
+
+
+/* utf_strcat_convert_to_latin1 ************************************************
+       
+   Like libc strcat, but uses an utf8 string.
+   Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield
+   invalid results.
+
+*******************************************************************************/
+
+void utf_strcat_convert_to_latin1(char *buffer, utf *u)
+{
+       utf_sprint_convert_to_latin1(buffer + strlen(buffer), u);
+}
+
+
+/* utf_strcat_convert_to_latin1_classname **************************************
+       
+   Like libc strcat, but uses an utf8 string.
+   Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield
+   invalid results.
+
+*******************************************************************************/
+
+void utf_strcat_convert_to_latin1_classname(char *buffer, utf *u)
+{
+       utf_sprint_convert_to_latin1_classname(buffer + strlen(buffer), u);
+}
+
+
+/* utf_fprint_printable_ascii **************************************************
+       
+   Write utf symbol into file.
+   Non-printable and non-ASCII characters are printed as '?'.
+
+*******************************************************************************/
+
+void utf_fprint_printable_ascii(FILE *file, utf *u)
+{
+       char *endpos;                       /* points behind utf string           */
+       char *utf_ptr;                      /* current position in utf text       */
+
+       if (!u)
+               return;
+
+       endpos = UTF_END(u);
+       utf_ptr = u->text;
+
+       while (utf_ptr < endpos) { 
+               /* read next unicode character */                
+               u2 c = utf_nextu2(&utf_ptr);                            
+
+               if (c >= 32 && c <= 127) fprintf(file, "%c", c);
+               else fprintf(file, "?");
+       }
+}
+
+
+/* utf_fprint_printable_ascii_classname ****************************************
+       
+   Write utf symbol into file with `/' converted to `.'.
+   Non-printable and non-ASCII characters are printed as '?'.
+
+*******************************************************************************/
+
+void utf_fprint_printable_ascii_classname(FILE *file, utf *u)
+{
+       char *endpos;                       /* points behind utf string           */
+       char *utf_ptr;                      /* current position in utf text       */
+
+    if (!u)
+               return;
+
+       endpos = UTF_END(u);
+       utf_ptr = u->text;
+
+       while (utf_ptr < endpos) { 
+               /* read next unicode character */                
+               u2 c = utf_nextu2(&utf_ptr);                            
+               if (c == '/') c = '.';
+
+               if (c >= 32 && c <= 127) fprintf(file, "%c", c);
+               else fprintf(file, "?");
+       }
+}
+
+
+/* is_valid_utf ****************************************************************
+
+   Return true if the given string is a valid UTF-8 string.
+
+   utf_ptr...points to first character
+   end_pos...points after last character
+
+*******************************************************************************/
+
+/*  static unsigned long min_codepoint[6] = {0,1L<<7,1L<<11,1L<<16,1L<<21,1L<<26}; */
+
+bool is_valid_utf(char *utf_ptr, char *end_pos)
+{
+       int bytes;
+       int len,i;
+       char c;
+       unsigned long v;
+
+       if (end_pos < utf_ptr) return false;
+       bytes = end_pos - utf_ptr;
+       while (bytes--) {
+               c = *utf_ptr++;
+
+               if (!c) return false;                     /* 0x00 is not allowed */
+               if ((c & 0x80) == 0) continue;            /* ASCII */
+
+               if      ((c & 0xe0) == 0xc0) len = 1;     /* 110x xxxx */
+               else if ((c & 0xf0) == 0xe0) len = 2;     /* 1110 xxxx */
+               else if ((c & 0xf8) == 0xf0) len = 3;     /* 1111 0xxx */
+               else if ((c & 0xfc) == 0xf8) len = 4;     /* 1111 10xx */
+               else if ((c & 0xfe) == 0xfc) len = 5;     /* 1111 110x */
+               else return false;                        /* invalid leading byte */
+
+               if (len > 2) return false;                /* Java limitation */
+
+               v = (unsigned long)c & (0x3f >> len);
+               
+               if ((bytes -= len) < 0) return false;     /* missing bytes */
+
+               for (i = len; i--; ) {
+                       c = *utf_ptr++;
+                       if ((c & 0xc0) != 0x80)               /* 10xx xxxx */
+                               return false;
+                       v = (v << 6) | (c & 0x3f);
+               }
+
+               if (v == 0) {
+                       if (len != 1) return false;           /* Java special */
+
+               } else {
+                       /* Sun Java seems to allow overlong UTF-8 encodings */
+                       
+                       /* if (v < min_codepoint[len]) */
+                               /* XXX throw exception? */
+               }
+
+               /* surrogates in UTF-8 seem to be allowed in Java classfiles */
+               /* if (v >= 0xd800 && v <= 0xdfff) return false; */ /* surrogates */
+
+               /* even these seem to be allowed */
+               /* if (v == 0xfffe || v == 0xffff) return false; */ /* invalid codepoints */
+       }
+
+       return true;
+}
+
+
+/* is_valid_name ***************************************************************
+
+   Return true if the given string may be used as a class/field/method
+   name. (Currently this only disallows empty strings and control
+   characters.)
+
+   NOTE: The string is assumed to have passed is_valid_utf!
+
+   utf_ptr...points to first character
+   end_pos...points after last character
+
+*******************************************************************************/
+
+bool is_valid_name(char *utf_ptr, char *end_pos)
+{
+       if (end_pos <= utf_ptr) return false; /* disallow empty names */
+
+       while (utf_ptr < end_pos) {
+               unsigned char c = *utf_ptr++;
+
+               if (c < 0x20) return false; /* disallow control characters */
+               if (c == 0xc0 && (unsigned char) *utf_ptr == 0x80)  /* disallow zero */
+                       return false;
+       }
+
+       return true;
+}
+
+bool is_valid_name_utf(utf *u)
+{
+       return is_valid_name(u->text, UTF_END(u));
+}
+
+
+/* utf_show ********************************************************************
+
+   Writes the utf symbols in the utfhash to stdout and displays the
+   number of external hash chains grouped according to the chainlength
+   (for debugging purposes).
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void utf_show(void)
+{
+
+#define CHAIN_LIMIT 20               /* limit for seperated enumeration */
+
+       u4 chain_count[CHAIN_LIMIT]; /* numbers of chains */
+       u4 max_chainlength = 0;      /* maximum length of the chains */
+       u4 sum_chainlength = 0;      /* sum of the chainlengths */
+       u4 beyond_limit = 0;         /* number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */
+       u4 i;
+
+       printf("UTF-HASH:\n");
+
+       /* show element of utf-hashtable */
+
+       for (i = 0; i < hashtable_utf->size; i++) {
+               utf *u = hashtable_utf->ptr[i];
+
+               if (u) {
+                       printf("SLOT %d: ", (int) i);
+
+                       while (u) {
+                               printf("'");
+                               utf_display_printable_ascii(u);
+                               printf("' ");
+                               u = u->hashlink;
+                       }       
+                       printf("\n");
+               }
+       }
+
+       printf("UTF-HASH: %d slots for %d entries\n", 
+                  (int) hashtable_utf->size, (int) hashtable_utf->entries );
+
+       if (hashtable_utf->entries == 0)
+               return;
+
+       printf("chains:\n  chainlength    number of chains    %% of utfstrings\n");
+
+       for (i=0;i<CHAIN_LIMIT;i++)
+               chain_count[i]=0;
+
+       /* count numbers of hashchains according to their length */
+       for (i=0; i<hashtable_utf->size; i++) {
+                 
+               utf *u = (utf*) hashtable_utf->ptr[i];
+               u4 chain_length = 0;
+
+               /* determine chainlength */
+               while (u) {
+                       u = u->hashlink;
+                       chain_length++;
+               }
+
+               /* update sum of all chainlengths */
+               sum_chainlength+=chain_length;
+
+               /* determine the maximum length of the chains */
+               if (chain_length>max_chainlength)
+                       max_chainlength = chain_length;
+
+               /* update number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */
+               if (chain_length>=CHAIN_LIMIT) {
+                       beyond_limit+=chain_length;
+                       chain_length=CHAIN_LIMIT-1;
+               }
+
+               /* update number of hashchains of current length */
+               chain_count[chain_length]++;
+       }
+
+       /* display results */  
+       for (i=1;i<CHAIN_LIMIT-1;i++) 
+               printf("       %2d %17d %18.2f%%\n",i,chain_count[i],(((float) chain_count[i]*i*100)/hashtable_utf->entries));
+         
+       printf("     >=%2d %17d %18.2f%%\n",CHAIN_LIMIT-1,chain_count[CHAIN_LIMIT-1],((float) beyond_limit*100)/hashtable_utf->entries);
+
+
+       printf("max. chainlength:%5d\n",max_chainlength);
+
+       /* avg. chainlength = sum of chainlengths / number of chains */
+       printf("avg. chainlength:%5.2f\n",(float) sum_chainlength / (hashtable_utf->size-chain_count[0]));
+}
+#endif /* !defined(NDEBUG) */
+
+
+/*
+ * 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/utf8.h b/src/vm/utf8.h
new file mode 100644 (file)
index 0000000..8a1197e
--- /dev/null
@@ -0,0 +1,315 @@
+/* src/vm/utf8.h - utf8 string 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.
+
+*/
+
+
+#ifndef _UTF_H
+#define _UTF_H
+
+/* forward typedefs ***********************************************************/
+
+typedef struct utf utf;
+
+#include "config.h"
+
+#include <stdio.h>
+
+#include "vm/types.h"
+
+#include "vm/global.h"
+
+
+/* data structure for utf8 symbols ********************************************/
+
+struct utf {
+       utf  *hashlink;                     /* link for external hash chain       */
+       s4    blength;                      /* text length in bytes               */
+       char *text;                         /* pointer to text                    */
+};
+
+/* to determine the end of utf strings */
+
+#define UTF_END(u)    ((char *) u->text + u->blength)
+
+
+/* utf-symbols for pointer comparison of frequently used strings **************/
+
+extern utf *utf_java_lang_Object;
+
+extern utf *utf_java_lang_Class;
+extern utf *utf_java_lang_ClassLoader;
+extern utf *utf_java_lang_Cloneable;
+extern utf *utf_java_lang_SecurityManager;
+extern utf *utf_java_lang_String;
+extern utf *utf_java_lang_ThreadGroup;
+extern utf *utf_java_lang_ref_SoftReference;
+extern utf *utf_java_lang_ref_WeakReference;
+extern utf *utf_java_lang_ref_PhantomReference;
+extern utf *utf_java_io_Serializable;
+
+extern utf *utf_java_lang_Throwable;
+extern utf *utf_java_lang_Error;
+
+extern utf *utf_java_lang_AbstractMethodError;
+extern utf *utf_java_lang_ClassCircularityError;
+extern utf *utf_java_lang_ClassFormatError;
+extern utf *utf_java_lang_ExceptionInInitializerError;
+extern utf *utf_java_lang_IncompatibleClassChangeError;
+extern utf *utf_java_lang_InstantiationError;
+extern utf *utf_java_lang_InternalError;
+extern utf *utf_java_lang_LinkageError;
+extern utf *utf_java_lang_NoClassDefFoundError;
+extern utf *utf_java_lang_NoSuchFieldError;
+extern utf *utf_java_lang_NoSuchMethodError;
+extern utf *utf_java_lang_OutOfMemoryError;
+extern utf *utf_java_lang_UnsatisfiedLinkError;
+extern utf *utf_java_lang_UnsupportedClassVersionError;
+extern utf *utf_java_lang_VerifyError;
+extern utf *utf_java_lang_VirtualMachineError;
+
+extern utf *utf_java_lang_Exception;
+
+extern utf *utf_java_lang_ArithmeticException;
+extern utf *utf_java_lang_ArrayIndexOutOfBoundsException;
+extern utf *utf_java_lang_ArrayStoreException;
+extern utf *utf_java_lang_ClassCastException;
+extern utf *utf_java_lang_ClassNotFoundException;
+extern utf *utf_java_lang_CloneNotSupportedException;
+extern utf *utf_java_lang_IllegalAccessException;
+extern utf *utf_java_lang_IllegalArgumentException;
+extern utf *utf_java_lang_IllegalMonitorStateException;
+extern utf *utf_java_lang_InstantiationException;
+extern utf *utf_java_lang_InterruptedException;
+extern utf *utf_java_lang_NegativeArraySizeException;
+extern utf *utf_java_lang_NullPointerException;
+extern utf *utf_java_lang_RuntimeException;
+extern utf *utf_java_lang_StringIndexOutOfBoundsException;
+
+extern utf *utf_java_lang_reflect_InvocationTargetException;
+
+extern utf *utf_java_security_PrivilegedActionException;
+
+#if defined(ENABLE_JAVASE)
+extern utf* utf_java_lang_Void;
+#endif
+
+extern utf* utf_java_lang_Boolean;
+extern utf* utf_java_lang_Byte;
+extern utf* utf_java_lang_Character;
+extern utf* utf_java_lang_Short;
+extern utf* utf_java_lang_Integer;
+extern utf* utf_java_lang_Long;
+extern utf* utf_java_lang_Float;
+extern utf* utf_java_lang_Double;
+
+#if defined(ENABLE_JAVASE)
+extern utf *utf_java_lang_StackTraceElement;
+extern utf *utf_java_lang_reflect_Constructor;
+extern utf *utf_java_lang_reflect_Field;
+extern utf *utf_java_lang_reflect_Method;
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+extern utf *utf_java_lang_reflect_VMConstructor;
+extern utf *utf_java_lang_reflect_VMField;
+extern utf *utf_java_lang_reflect_VMMethod;
+# endif
+
+extern utf *utf_java_util_Vector;
+#endif
+
+extern utf *utf_InnerClasses;
+extern utf *utf_ConstantValue;
+extern utf *utf_Code;
+extern utf *utf_Exceptions;
+extern utf *utf_LineNumberTable;
+extern utf *utf_SourceFile;
+
+#if defined(ENABLE_JAVASE)
+extern utf *utf_EnclosingMethod;
+extern utf *utf_Signature;
+extern utf *utf_StackMapTable;
+
+#if defined(ENABLE_ANNOTATIONS)
+extern utf *utf_RuntimeVisibleAnnotations;
+extern utf *utf_RuntimeInvisibleAnnotations;
+extern utf *utf_RuntimeVisibleParameterAnnotations;
+extern utf *utf_RuntimeInvisibleParameterAnnotations;
+extern utf *utf_AnnotationDefault;
+#endif
+#endif
+
+extern utf *utf_init;
+extern utf *utf_clinit;
+extern utf *utf_clone;
+extern utf *utf_finalize;
+extern utf *utf_invoke;
+extern utf *utf_main;
+extern utf *utf_run;
+
+extern utf *utf_add;
+extern utf *utf_dispatch;
+extern utf *utf_remove;
+extern utf *utf_addThread;
+extern utf *utf_removeThread;
+extern utf *utf_put;
+extern utf *utf_get;
+extern utf *utf_uncaughtException;
+extern utf *utf_value;
+
+extern utf *utf_fillInStackTrace;
+extern utf *utf_findNative;
+extern utf *utf_getSystemClassLoader;
+extern utf *utf_initCause;
+extern utf *utf_loadClass;
+extern utf *utf_loadClassInternal;
+extern utf *utf_printStackTrace;
+
+extern utf *utf_division_by_zero;
+
+extern utf *utf_Z;
+extern utf *utf_B;
+extern utf *utf_C;
+extern utf *utf_S;
+extern utf *utf_I;
+extern utf *utf_J;
+extern utf *utf_F;
+extern utf *utf_D;
+
+extern utf *utf_void__void;
+extern utf *utf_boolean__void;
+extern utf *utf_byte__void;
+extern utf *utf_char__void;
+extern utf *utf_short__void;
+extern utf *utf_int__void;
+extern utf *utf_long__void;
+extern utf *utf_float__void;
+extern utf *utf_double__void;
+
+extern utf *utf_void__java_lang_ClassLoader;
+extern utf *utf_void__java_lang_Object;
+extern utf *utf_void__java_lang_Throwable;
+extern utf *utf_java_lang_ClassLoader_java_lang_String__J;
+extern utf *utf_java_lang_Exception__V;
+extern utf *utf_java_lang_Object__java_lang_Object;
+extern utf *utf_java_lang_String__void;
+extern utf *utf_java_lang_String__java_lang_Class;
+extern utf *utf_java_lang_Thread__V;
+extern utf *utf_java_lang_Thread_java_lang_Throwable__V;
+extern utf *utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V;
+extern utf *utf_java_lang_Throwable__void;
+extern utf *utf_java_lang_Throwable__java_lang_Throwable;
+
+extern utf *utf_not_named_yet;
+extern utf *utf_null;
+extern utf *array_packagename;
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* initialize the utf8 subsystem */
+void utf8_init(void);
+
+u4 utf_hashkey(const char *text, u4 length);
+u4 utf_full_hashkey(const char *text, u4 length);
+
+/* determine hashkey of a unicode-symbol */
+u4 unicode_hashkey(u2 *text, u2 length);
+
+/* create new utf-symbol */
+utf *utf_new(const char *text, u2 length);
+
+/* make utf symbol from u2 array */
+utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
+
+utf *utf_new_char(const char *text);
+utf *utf_new_char_classname(const char *text);
+
+/* get number of bytes */
+u4 utf_bytes(utf *u);
+
+/* get next unicode character of a utf-string */
+u2 utf_nextu2(char **utf);
+
+/* get (number of) unicode characters of a utf string (safe) */
+s4 utf8_safe_number_of_u2s(const char *text, s4 nbytes);
+void utf8_safe_convert_to_u2s(const char *text, s4 nbytes, u2 *buffer);
+
+/* get (number of) unicode characters of a utf string (UNSAFE!) */
+u4 utf_get_number_of_u2s(utf *u);
+u4 utf_get_number_of_u2s_for_buffer(const char *buffer, u4 blength);
+
+/* determine utf length in bytes of a u2 array */
+u4 u2_utflength(u2 *text, u4 u2_length);
+
+void utf_copy(char *buffer, utf *u);
+void utf_cat(char *buffer, utf *u);
+void utf_copy_classname(char *buffer, utf *u);
+void utf_cat_classname(char *buffer, utf *u);
+
+/* write utf symbol to file/buffer */
+void utf_display_printable_ascii(utf *u);
+void utf_display_printable_ascii_classname(utf *u);
+
+void utf_sprint_convert_to_latin1(char *buffer, utf *u);
+void utf_sprint_convert_to_latin1_classname(char *buffer, utf *u);
+
+void utf_strcat_convert_to_latin1(char *buffer, utf *u);
+void utf_strcat_convert_to_latin1_classname(char *buffer, utf *u);
+
+void utf_fprint_printable_ascii(FILE *file, utf *u);
+void utf_fprint_printable_ascii_classname(FILE *file, utf *u);
+
+/* check if a UTF-8 string is valid */
+bool is_valid_utf(char *utf_ptr, char *end_pos);
+
+/* check if a UTF-8 string may be used as a class/field/method name */
+bool is_valid_name(char *utf_ptr, char *end_pos);
+bool is_valid_name_utf(utf *u);
+
+/* show utf-table */
+void utf_show(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _UTF_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/vftbl.hpp b/src/vm/vftbl.hpp
new file mode 100644 (file)
index 0000000..0d47ad1
--- /dev/null
@@ -0,0 +1,137 @@
+/* src/vm/vftbl.hpp - virtual function table
+
+   Copyright (C) 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 _VFTBL_HPP
+#define _VFTBL_HPP
+
+// Forward declaration.
+typedef struct _vftbl vftbl_t;
+
+#include "config.h"
+
+
+/* virtual function table ******************************************************
+
+   The vtbl has a bidirectional layout with open ends at both sides.
+   interfacetablelength gives the number of entries of the interface
+   table at the start of the vftbl. The vftbl pointer points to
+   &interfacetable[0].  vftbllength gives the number of entries of
+   table at the end of the vftbl.
+
+   runtime type check (checkcast):
+
+   Different methods are used for runtime type check depending on the
+   argument of checkcast/instanceof.
+       
+   A check against a class is implemented via relative numbering on
+   the class hierachy tree. The tree is numbered in a depth first
+   traversal setting the base field and the diff field. The diff field
+   gets the result of (high - base) so that a range check can be
+   implemented by an unsigned compare. A sub type test is done by
+   checking the inclusion of base of the sub class in the range of the
+   superclass.
+
+   A check against an interface is implemented via the
+   interfacevftbl. If the interfacevftbl contains a nonnull value a
+   class is a subclass of this interface.
+
+   interfacetable:
+
+   Like standard virtual methods interface methods are called using
+   virtual function tables. All interfaces are numbered sequentially
+   (starting with zero). For each class there exist an interface table
+   of virtual function tables for each implemented interface. The
+   length of the interface table is determined by the highest number
+   of an implemented interface.
+
+   The following example assumes a class which implements interface 0 and 3:
+
+   interfacetablelength = 4
+
+                  | ...       |            +----------+
+                  +-----------+            | method 2 |---> method z
+                  | class     |            | method 1 |---> method y
+                  +-----------+            | method 0 |---> method x
+                  | ivftbl  0 |----------> +----------+
+    vftblptr ---> +-----------+
+                  | ivftbl -1 |--> NULL    +----------+
+                  | ivftbl -2 |--> NULL    | method 1 |---> method x
+                  | ivftbl -3 |-----+      | method 0 |---> method a
+                  +-----------+     +----> +----------+
+     
+                              +---------------+
+                              | length 3 = 2  |
+                              | length 2 = 0  |
+                              | length 1 = 0  |
+                              | length 0 = 3  |
+    interfacevftbllength ---> +---------------+
+
+*******************************************************************************/
+
+// Includes.
+#include "vm/class.hpp"
+#include "vm/references.h"
+
+#if USES_NEW_SUBTYPE
+#define DISPLAY_SIZE 4
+#endif
+
+struct _vftbl {
+       methodptr   *interfacetable[1];    /* interface table (access via macro)  */
+       classinfo   *clazz;                /* class, the vtbl belongs to          */
+       arraydescriptor *arraydesc;        /* for array classes, otherwise NULL   */
+       s4           vftbllength;          /* virtual function table length       */
+       s4           interfacetablelength; /* interface table length              */
+       s4           baseval;              /* base for runtime type check         */
+                                          /* (-index for interfaces)             */
+       s4           diffval;              /* high - base for runtime type check  */
+
+#if USES_NEW_SUBTYPE
+       s4 subtype_depth;
+       s4 subtype_offset;
+       struct _vftbl *subtype_display[DISPLAY_SIZE+1];  /* the last one is cache */
+       struct _vftbl **subtype_overflow;
+#endif
+
+       s4          *interfacevftbllength; /* length of interface vftbls          */
+       methodptr    table[1];             /* class vftbl                         */
+};
+
+#endif // _VFTBL_HPP
+
+
+/*
+ * 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/vm.c b/src/vm/vm.c
deleted file mode 100644 (file)
index 0a6536a..0000000
+++ /dev/null
@@ -1,2668 +0,0 @@
-/* src/vm/vm.c - VM startup and shutdown 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 <errno.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "vm/types.h"
-
-#include "arch.h"
-#include "md-abi.h"
-
-#include "vm/jit/abi-asm.h"
-
-#include "mm/codememory.h"
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/localref.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"             /* required by j.l.C */
-#include "native/include/java_lang_String.h"             /* required by j.l.C */
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-# include "native/include/java_nio_ByteBuffer.h"        /* required by j.l.CL */
-# include "native/include/java_lang_ClassLoader.h"       /* required by j.l.C */
-#endif
-
-#include "native/include/java_lang_Class.h"
-
-#include "native/vm/nativevm.h"
-
-#include "threads/lock-common.h"
-#include "threads/mutex.h"
-#include "threads/threadlist.h"
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/array.h"
-
-#if defined(ENABLE_ASSERTION)
-#include "vm/assertion.h"
-#endif
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/finalizer.h"
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/package.h"
-#include "vm/primitive.h"
-#include "vm/properties.h"
-#include "vm/signallocal.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/argument.h"
-#include "vm/jit/asmpart.h"
-#include "vm/jit/code.h"
-
-#if defined(ENABLE_DISASSEMBLER)
-# include "vm/jit/disass.h"
-#endif
-
-#include "vm/jit/jit.h"
-#include "vm/jit/methodtree.h"
-
-#if defined(ENABLE_PROFILING)
-# include "vm/jit/optimizing/profile.h"
-#endif
-
-#include "vm/jit/optimizing/recompile.h"
-
-#if defined(ENABLE_PYTHON)
-# include "vm/jit/python.h"
-#endif
-
-#include "vm/jit/trap.h"
-
-#include "vmcore/classcache.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-#include "vmcore/suck.h"
-#include "vmcore/system.h"
-
-#if defined(ENABLE_JVMTI)
-# include "native/jvmti/cacaodbg.h"
-#endif
-
-#if defined(ENABLE_VMLOG)
-#include <vmlog_cacao.h>
-#endif
-
-
-/* Invocation API variables ***************************************************/
-
-_Jv_JavaVM *_Jv_jvm;                    /* denotes a Java VM                  */
-_Jv_JNIEnv *_Jv_env;                    /* pointer to native method interface */
-
-
-/* global variables ***********************************************************/
-
-s4 vms = 0;                             /* number of VMs created              */
-
-bool vm_initializing = false;
-bool vm_created      = false;
-bool vm_exiting      = false;
-
-static classinfo *mainclass = NULL;
-
-#if defined(ENABLE_INTRP)
-u1 *intrp_main_stack = NULL;
-#endif
-
-
-/* define heap sizes **********************************************************/
-
-#define HEAP_MAXSIZE      128 * 1024 * 1024 /* default 128MB                  */
-#define HEAP_STARTSIZE      2 * 1024 * 1024 /* default 2MB                    */
-#define STACK_SIZE               128 * 1024 /* default 64kB                   */
-
-
-/* define command line options ************************************************/
-
-enum {
-       OPT_FOO,
-
-       /* Java options */
-
-       OPT_JAR,
-
-       OPT_D32,
-       OPT_D64,
-
-       OPT_CLASSPATH,
-       OPT_D,
-
-       OPT_VERBOSE,
-
-       OPT_VERSION,
-       OPT_SHOWVERSION,
-       OPT_FULLVERSION,
-
-       OPT_HELP,
-       OPT_X,
-       OPT_XX,
-
-       OPT_EA,
-       OPT_DA,
-       OPT_EA_NOARG,
-       OPT_DA_NOARG,
-    
-
-       OPT_ESA,
-       OPT_DSA,
-
-       /* Java non-standard options */
-
-       OPT_JIT,
-       OPT_INTRP,
-
-       OPT_BOOTCLASSPATH,
-       OPT_BOOTCLASSPATH_A,
-       OPT_BOOTCLASSPATH_P,
-
-       OPT_BOOTCLASSPATH_C,
-
-#if defined(ENABLE_PROFILING)
-       OPT_PROF,
-       OPT_PROF_OPTION,
-#endif
-
-       OPT_MS,
-       OPT_MX,
-
-       /* CACAO options */
-
-       OPT_VERBOSE1,
-       OPT_NOIEEE,
-
-#if defined(ENABLE_STATISTICS)
-       OPT_TIME,
-       OPT_STAT,
-#endif
-
-       OPT_LOG,
-       OPT_CHECK,
-       OPT_LOAD,
-       OPT_SHOW,
-       OPT_DEBUGCOLOR,
-
-#if !defined(NDEBUG)
-       OPT_ALL,
-       OPT_METHOD,
-       OPT_SIGNATURE,
-#endif
-
-#if defined(ENABLE_VERIFIER)
-       OPT_NOVERIFY,
-#if defined(TYPECHECK_VERBOSE)
-       OPT_VERBOSETC,
-#endif
-#endif /* defined(ENABLE_VERIFIER) */
-
-       /* optimization options */
-
-#if defined(ENABLE_LOOP)
-       OPT_OLOOP,
-#endif
-       
-#if defined(ENABLE_IFCONV)
-       OPT_IFCONV,
-#endif
-
-#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
-       OPT_LSRA,
-#endif
-
-#if defined(ENABLE_INTRP)
-       /* interpreter options */
-
-       OPT_NO_DYNAMIC,
-       OPT_NO_REPLICATION,
-       OPT_NO_QUICKSUPER,
-       OPT_STATIC_SUPERS,
-       OPT_TRACE,
-#endif
-
-       OPT_SS,
-
-#ifdef ENABLE_JVMTI
-       OPT_DEBUG,
-       OPT_XRUNJDWP,
-       OPT_NOAGENT,
-       OPT_AGENTLIB,
-       OPT_AGENTPATH,
-#endif
-
-#if defined(ENABLE_DEBUG_FILTER)
-       OPT_FILTER_VERBOSECALL_INCLUDE,
-       OPT_FILTER_VERBOSECALL_EXCLUDE,
-       OPT_FILTER_SHOW_METHOD,
-#endif
-
-       DUMMY
-};
-
-
-opt_struct opts[] = {
-       { "foo",               false, OPT_FOO },
-
-       /* Java options */
-
-       { "jar",               false, OPT_JAR },
-
-       { "d32",               false, OPT_D32 },
-       { "d64",               false, OPT_D64 },
-       { "client",            false, OPT_IGNORE },
-       { "server",            false, OPT_IGNORE },
-       { "jvm",               false, OPT_IGNORE },
-       { "hotspot",           false, OPT_IGNORE },
-
-       { "classpath",         true,  OPT_CLASSPATH },
-       { "cp",                true,  OPT_CLASSPATH },
-       { "D",                 true,  OPT_D },
-       { "version",           false, OPT_VERSION },
-       { "showversion",       false, OPT_SHOWVERSION },
-       { "fullversion",       false, OPT_FULLVERSION },
-       { "help",              false, OPT_HELP },
-       { "?",                 false, OPT_HELP },
-       { "X",                 false, OPT_X },
-       { "XX:",               true,  OPT_XX },
-
-       { "ea:",               true,  OPT_EA },
-       { "da:",               true,  OPT_DA },
-       { "ea",                false, OPT_EA_NOARG },
-       { "da",                false, OPT_DA_NOARG },
-
-       { "enableassertions:",  true,  OPT_EA },
-       { "disableassertions:", true,  OPT_DA },
-       { "enableassertions",   false, OPT_EA_NOARG },
-       { "disableassertions",  false, OPT_DA_NOARG },
-
-       { "esa",                     false, OPT_ESA },
-       { "enablesystemassertions",  false, OPT_ESA },
-       { "dsa",                     false, OPT_DSA },
-       { "disablesystemassertions", false, OPT_DSA },
-
-       { "noasyncgc",         false, OPT_IGNORE },
-#if defined(ENABLE_VERIFIER)
-       { "noverify",          false, OPT_NOVERIFY },
-       { "Xverify:none",      false, OPT_NOVERIFY },
-#endif
-       { "v",                 false, OPT_VERBOSE1 },
-       { "verbose:",          true,  OPT_VERBOSE },
-
-#if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
-       { "verbosetc",         false, OPT_VERBOSETC },
-#endif
-#if defined(__ALPHA__)
-       { "noieee",            false, OPT_NOIEEE },
-#endif
-#if defined(ENABLE_STATISTICS)
-       { "time",              false, OPT_TIME },
-       { "stat",              false, OPT_STAT },
-#endif
-       { "log",               true,  OPT_LOG },
-       { "c",                 true,  OPT_CHECK },
-       { "l",                 false, OPT_LOAD },
-
-#if !defined(NDEBUG)
-       { "all",               false, OPT_ALL },
-       { "sig",               true,  OPT_SIGNATURE },
-#endif
-
-#if defined(ENABLE_LOOP)
-       { "oloop",             false, OPT_OLOOP },
-#endif
-#if defined(ENABLE_IFCONV)
-       { "ifconv",            false, OPT_IFCONV },
-#endif
-#if defined(ENABLE_LSRA)
-       { "lsra",              false, OPT_LSRA },
-#endif
-#if  defined(ENABLE_SSA)
-       { "lsra",              true, OPT_LSRA },
-#endif
-
-#if defined(ENABLE_INTRP)
-       /* interpreter options */
-
-       { "trace",             false, OPT_TRACE },
-       { "static-supers",     true,  OPT_STATIC_SUPERS },
-       { "no-dynamic",        false, OPT_NO_DYNAMIC },
-       { "no-replication",    false, OPT_NO_REPLICATION },
-       { "no-quicksuper",     false, OPT_NO_QUICKSUPER },
-#endif
-
-       /* JVMTI Agent Command Line Options */
-#ifdef ENABLE_JVMTI
-       { "agentlib:",         true,  OPT_AGENTLIB },
-       { "agentpath:",        true,  OPT_AGENTPATH },
-#endif
-
-       /* Java non-standard options */
-
-       { "Xjit",              false, OPT_JIT },
-       { "Xint",              false, OPT_INTRP },
-       { "Xbootclasspath:",   true,  OPT_BOOTCLASSPATH },
-       { "Xbootclasspath/a:", true,  OPT_BOOTCLASSPATH_A },
-       { "Xbootclasspath/p:", true,  OPT_BOOTCLASSPATH_P },
-       { "Xbootclasspath/c:", true,  OPT_BOOTCLASSPATH_C },
-
-#ifdef ENABLE_JVMTI
-       { "Xdebug",            false, OPT_DEBUG },
-       { "Xnoagent",          false, OPT_NOAGENT },
-       { "Xrunjdwp",          true,  OPT_XRUNJDWP },
-#endif 
-
-       { "Xms",               true,  OPT_MS },
-       { "ms",                true,  OPT_MS },
-       { "Xmx",               true,  OPT_MX },
-       { "mx",                true,  OPT_MX },
-       { "Xss",               true,  OPT_SS },
-       { "ss",                true,  OPT_SS },
-
-#if defined(ENABLE_PROFILING)
-       { "Xprof:",            true,  OPT_PROF_OPTION },
-       { "Xprof",             false, OPT_PROF },
-#endif
-
-       /* keep these at the end of the list */
-
-#if !defined(NDEBUG)
-       { "m",                 true,  OPT_METHOD },
-#endif
-
-       { "s",                 true,  OPT_SHOW },
-       { "debug-color",      false,  OPT_DEBUGCOLOR },
-
-#if defined(ENABLE_DEBUG_FILTER)
-       { "XXfi",              true,  OPT_FILTER_VERBOSECALL_INCLUDE },
-       { "XXfx",              true,  OPT_FILTER_VERBOSECALL_EXCLUDE },
-       { "XXfm",              true,  OPT_FILTER_SHOW_METHOD },
-#endif
-
-       { NULL,                false, 0 }
-};
-
-
-/* usage ***********************************************************************
-
-   Prints the correct usage syntax to stdout.
-
-*******************************************************************************/
-
-void usage(void)
-{
-       puts("Usage: cacao [-options] classname [arguments]");
-       puts("               (to run a class file)");
-       puts("   or  cacao [-options] -jar jarfile [arguments]");
-       puts("               (to run a standalone jar file)\n");
-
-       puts("where options include:");
-       puts("    -d32                     use 32-bit data model if available");
-       puts("    -d64                     use 64-bit data model if available");
-       puts("    -client                  compatibility (currently ignored)");
-       puts("    -server                  compatibility (currently ignored)");
-       puts("    -jvm                     compatibility (currently ignored)");
-       puts("    -hotspot                 compatibility (currently ignored)\n");
-
-       puts("    -cp <path>               specify a path to look for classes");
-       puts("    -classpath <path>        specify a path to look for classes");
-       puts("    -D<name>=<value>         add an entry to the property list");
-       puts("    -verbose[:class|gc|jni]  enable specific verbose output");
-       puts("    -version                 print product version and exit");
-       puts("    -fullversion             print jpackage-compatible product version and exit");
-       puts("    -showversion             print product version and continue");
-       puts("    -help, -?                print this help message");
-       puts("    -X                       print help on non-standard Java options");
-       puts("    -XX                      print help on debugging options");
-    puts("    -ea[:<packagename>...|:<classname>]");
-    puts("    -enableassertions[:<packagename>...|:<classname>]");
-       puts("                             enable assertions with specified granularity");
-       puts("    -da[:<packagename>...|:<classname>]");
-       puts("    -disableassertions[:<packagename>...|:<classname>]");
-       puts("                             disable assertions with specified granularity");
-       puts("    -esa | -enablesystemassertions");
-       puts("                             enable system assertions");
-       puts("    -dsa | -disablesystemassertions");
-       puts("                             disable system assertions");
-
-#ifdef ENABLE_JVMTI
-       puts("    -agentlib:<agent-lib-name>=<options>  library to load containg JVMTI agent");
-       puts ("                                         for jdwp help use: -agentlib:jdwp=help");
-       puts("    -agentpath:<path-to-agent>=<options>  path to library containg JVMTI agent");
-#endif
-
-       /* exit with error code */
-
-       exit(1);
-}   
-
-
-static void Xusage(void)
-{
-#if defined(ENABLE_JIT)
-       puts("    -Xjit                    JIT mode execution (default)");
-#endif
-#if defined(ENABLE_INTRP)
-       puts("    -Xint                    interpreter mode execution");
-#endif
-       puts("    -Xbootclasspath:<zip/jar files and directories separated by :>");
-    puts("                             value is set as bootstrap class path");
-       puts("    -Xbootclasspath/a:<zip/jar files and directories separated by :>");
-       puts("                             value is appended to the bootstrap class path");
-       puts("    -Xbootclasspath/p:<zip/jar files and directories separated by :>");
-       puts("                             value is prepended to the bootstrap class path");
-       puts("    -Xbootclasspath/c:<zip/jar files and directories separated by :>");
-       puts("                             value is used as Java core library, but the");
-       puts("                             hardcoded VM interface classes are prepended");
-       printf("    -Xms<size>               set the initial size of the heap (default: %dMB)\n", HEAP_STARTSIZE / 1024 / 1024);
-       printf("    -Xmx<size>               set the maximum size of the heap (default: %dMB)\n", HEAP_MAXSIZE / 1024 / 1024);
-       printf("    -Xss<size>               set the thread stack size (default: %dkB)\n", STACK_SIZE / 1024);
-
-#if defined(ENABLE_PROFILING)
-       puts("    -Xprof[:bb]              collect and print profiling data");
-#endif
-
-#if defined(ENABLE_JVMTI)
-    /* -Xdebug option depend on gnu classpath JDWP options. options: 
-        transport=dt_socket,address=<hostname:port>,server=(y|n),suspend(y|n) */
-       puts("    -Xdebug                  enable remote debugging\n");
-       puts("    -Xrunjdwp transport=[dt_socket|...],address=<hostname:port>,server=[y|n],suspend=[y|n]\n");
-       puts("                             enable remote debugging\n");
-#endif 
-
-       /* exit with error code */
-
-       exit(1);
-}   
-
-
-#if 0
-static void XXusage(void)
-{
-       puts("    -v                       write state-information");
-#if !defined(NDEBUG)
-       puts("    -verbose:jit             enable specific verbose output");
-       puts("    -debug-color             colored output for ANSI terms");
-#endif
-#ifdef TYPECHECK_VERBOSE
-       puts("    -verbosetc               write debug messages while typechecking");
-#endif
-#if defined(__ALPHA__)
-       puts("    -noieee                  don't use ieee compliant arithmetic");
-#endif
-#if defined(ENABLE_VERIFIER)
-       puts("    -noverify                don't verify classfiles");
-#endif
-#if defined(ENABLE_STATISTICS)
-       puts("    -time                    measure the runtime");
-       puts("    -stat                    detailed compiler statistics");
-#endif
-       puts("    -log logfile             specify a name for the logfile");
-       puts("    -c(heck)b(ounds)         don't check array bounds");
-       puts("            s(ync)           don't check for synchronization");
-#if defined(ENABLE_LOOP)
-       puts("    -oloop                   optimize array accesses in loops");
-#endif
-       puts("    -l                       don't start the class after loading");
-#if !defined(NDEBUG)
-       puts("    -all                     compile all methods, no execution");
-       puts("    -m                       compile only a specific method");
-       puts("    -sig                     specify signature for a specific method");
-#endif
-
-       puts("    -s...                    show...");
-       puts("      (c)onstants            the constant pool");
-       puts("      (m)ethods              class fields and methods");
-       puts("      (u)tf                  the utf - hash");
-       puts("      (i)ntermediate         intermediate representation");
-#if defined(ENABLE_DISASSEMBLER)
-       puts("      (a)ssembler            disassembled listing");
-       puts("      n(o)ps                 show NOPs in disassembler output");
-#endif
-       puts("      (d)atasegment          data segment listing");
-
-#if defined(ENABLE_IFCONV)
-       puts("    -ifconv                  use if-conversion");
-#endif
-#if defined(ENABLE_LSRA)
-       puts("    -lsra                    use linear scan register allocation");
-#endif
-#if defined(ENABLE_SSA)
-       puts("    -lsra:...                use linear scan register allocation (with SSA)");
-       puts("       (d)ead code elimination");
-       puts("       (c)opy propagation");
-#endif
-#if defined(ENABLE_DEBUG_FILTER)
-       puts("    -XXfi <regex>            begin of dynamic scope for verbosecall filter");
-       puts("    -XXfx <regex>            end of dynamic scope for verbosecall filter");
-       puts("    -XXfm <regex>            filter for show options");
-#endif
-       /* exit with error code */
-
-       exit(1);
-}
-#endif
-
-
-/* version *********************************************************************
-
-   Only prints cacao version information.
-
-*******************************************************************************/
-
-static void version(bool opt_exit)
-{
-       puts("java version \""JAVA_VERSION"\"");
-       puts("CACAO version "VERSION"\n");
-
-       puts("Copyright (C) 1996-2005, 2006, 2007, 2008");
-       puts("CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO");
-       puts("This is free software; see the source for copying conditions.  There is NO");
-       puts("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.");
-
-       /* exit normally, if requested */
-
-       if (opt_exit)
-               exit(0);
-}
-
-
-/* fullversion *****************************************************************
-
-   Prints a Sun compatible version information (required e.g. by
-   jpackage, www.jpackage.org).
-
-*******************************************************************************/
-
-static void fullversion(void)
-{
-       puts("java full version \"cacao-"JAVA_VERSION"\"");
-
-       /* exit normally */
-
-       exit(0);
-}
-
-
-static void vm_printconfig(void)
-{
-       puts("Configure/Build options:\n");
-       puts("  ./configure: "VERSION_CONFIGURE_ARGS"");
-#if defined(__VERSION__)
-       puts("  CC         : "VERSION_CC" ("__VERSION__")");
-#else
-       puts("  CC         : "VERSION_CC"");
-#endif
-       puts("  CFLAGS     : "VERSION_CFLAGS"\n");
-
-       puts("Default variables:\n");
-       printf("  maximum heap size              : %d\n", HEAP_MAXSIZE);
-       printf("  initial heap size              : %d\n", HEAP_STARTSIZE);
-       printf("  stack size                     : %d\n", STACK_SIZE);
-
-#if defined(ENABLE_JRE_LAYOUT)
-       /* When we're building with JRE-layout, the default paths are the
-          same as the runtime paths. */
-#else
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       puts("  gnu.classpath.boot.library.path: "JAVA_RUNTIME_LIBRARY_LIBDIR);
-       puts("  java.boot.class.path           : "CACAO_VM_ZIP":"JAVA_RUNTIME_LIBRARY_CLASSES"");
-# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       puts("  sun.boot.library.path          : "JAVA_RUNTIME_LIBRARY_LIBDIR);
-       puts("  java.boot.class.path           : "JAVA_RUNTIME_LIBRARY_CLASSES);
-# endif
-#endif
-
-       puts("");
-
-       puts("Runtime variables:\n");
-       printf("  maximum heap size              : %d\n", opt_heapmaxsize);
-       printf("  initial heap size              : %d\n", opt_heapstartsize);
-       printf("  stack size                     : %d\n", opt_stacksize);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       printf("  gnu.classpath.boot.library.path: %s\n", properties_get("gnu.classpath.boot.library.path"));
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       printf("  sun.boot.library.path          : %s\n", properties_get("sun.boot.library.path"));
-#endif
-
-       printf("  java.boot.class.path           : %s\n", properties_get("java.boot.class.path"));
-       printf("  java.class.path                : %s\n", properties_get("java.class.path"));
-}
-
-
-/* forward declarations *******************************************************/
-
-static char *vm_get_mainclass_from_jar(char *mainstring);
-#if !defined(NDEBUG)
-static void  vm_compile_all(void);
-static void  vm_compile_method(char* mainname);
-#endif
-
-
-/* vm_createjvm ****************************************************************
-
-   Implementation for JNI_CreateJavaVM.
-
-*******************************************************************************/
-
-bool vm_createjvm(JavaVM **p_vm, void **p_env, void *vm_args)
-{
-       JavaVMInitArgs *_vm_args;
-       _Jv_JNIEnv     *env;
-       _Jv_JavaVM     *vm;
-
-       /* get the arguments for the new JVM */
-
-       _vm_args = (JavaVMInitArgs *) vm_args;
-
-       /* get the VM and Env tables (must be set before vm_create) */
-
-       env = NEW(_Jv_JNIEnv);
-
-#if defined(ENABLE_JNI)
-       env->env = &_Jv_JNINativeInterface;
-#endif
-
-       /* XXX Set the global variable.  Maybe we should do that differently. */
-
-       _Jv_env = env;
-
-       /* create and fill a JavaVM structure */
-
-       vm = NEW(_Jv_JavaVM);
-
-#if defined(ENABLE_JNI)
-       vm->functions = &_Jv_JNIInvokeInterface;
-#endif
-
-       /* XXX Set the global variable.  Maybe we should do that differently. */
-       /* XXX JVMTI Agents needs a JavaVM  */
-
-       _Jv_jvm = vm;
-
-       /* actually create the JVM */
-
-       if (!vm_create(_vm_args))
-               goto error;
-
-       /* now return the values */
-
-       *p_vm  = (JavaVM *) vm;
-       *p_env = (void *) env;
-
-       return true;
-
- error:
-       /* release allocated memory */
-
-       FREE(env, _Jv_JNIEnv);
-       FREE(vm, _Jv_JavaVM);
-
-       return false;
-}
-
-
-/* vm_create *******************************************************************
-
-   Creates a JVM.  Called by vm_createjvm.
-
-*******************************************************************************/
-
-bool vm_create(JavaVMInitArgs *vm_args)
-{
-       int   len;
-       char *p;
-       char *boot_class_path;
-       char *class_path;
-       int   opt;
-       int   i, j;
-       bool  opt_version;
-       bool  opt_exit;
-
-#if defined(ENABLE_JVMTI)
-       lt_dlhandle  handle;
-       char *libname, *agentarg;
-       bool jdwp,agentbypath;
-       jdwp = agentbypath = false;
-#endif
-
-#if defined(ENABLE_JNI)
-       /* Check the JNI version requested. */
-
-       if (!jni_version_check(vm_args->version))
-               return false;
-#endif
-
-       /* We only support 1 JVM instance. */
-
-       if (vms > 0)
-               return false;
-
-       /* Install the exit handler. */
-
-       if (atexit(vm_exit_handler))
-               vm_abort("atexit failed: %s\n", strerror(errno));
-
-       /* Set some options. */
-
-       opt_version       = false;
-       opt_exit          = false;
-
-       opt_noieee        = false;
-
-       opt_heapmaxsize   = HEAP_MAXSIZE;
-       opt_heapstartsize = HEAP_STARTSIZE;
-       opt_stacksize     = STACK_SIZE;
-
-       /* Initialize the properties list before command-line handling.
-          Otherwise -XX:+PrintConfig crashes. */
-
-       properties_init();
-
-       /* First of all, parse the -XX options. */
-
-#if defined(ENABLE_VMLOG)
-       vmlog_cacao_init_options();
-#endif
-
-       options_xx(vm_args);
-
-#if defined(ENABLE_VMLOG)
-       vmlog_cacao_init();
-#endif
-
-       /* We need to check if the actual size of a java.lang.Class object
-          is smaller or equal than the assumption made in
-          src/vmcore/class.h. */
-
-       if (sizeof(java_lang_Class) > sizeof(dummy_java_lang_Class))
-               vm_abort("vm_create: java_lang_Class structure is bigger than classinfo.object (%d > %d)", sizeof(java_lang_Class), sizeof(dummy_java_lang_Class));
-
-       /* set the VM starttime */
-
-       _Jv_jvm->starttime = builtin_currenttimemillis();
-
-#if defined(ENABLE_JVMTI)
-       /* initialize JVMTI related  **********************************************/
-       jvmti = false;
-#endif
-
-       /* Fill the properties before command-line handling. */
-
-       properties_set();
-
-       /* iterate over all passed options */
-
-       while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
-               switch (opt) {
-               case OPT_FOO:
-                       opt_foo = true;
-                       break;
-
-               case OPT_IGNORE:
-                       break;
-                       
-               case OPT_JAR:
-                       opt_jar = true;
-                       break;
-
-               case OPT_D32:
-#if SIZEOF_VOID_P == 8
-                       puts("Running a 32-bit JVM is not supported on this platform.");
-                       exit(1);
-#endif
-                       break;
-
-               case OPT_D64:
-#if SIZEOF_VOID_P == 4
-                       puts("Running a 64-bit JVM is not supported on this platform.");
-                       exit(1);
-#endif
-                       break;
-
-               case OPT_CLASSPATH:
-                       /* Forget old classpath and set the argument as new
-                          classpath. */
-
-                       class_path = properties_get("java.class.path");
-
-                       p = MNEW(char, strlen(opt_arg) + strlen("0"));
-
-                       strcpy(p, opt_arg);
-
-#if defined(ENABLE_JAVASE)
-                       properties_add("java.class.path", p);
-#endif
-
-                       MFREE(class_path, char, strlen(class_path));
-                       break;
-
-               case OPT_D:
-                       for (i = 0; i < strlen(opt_arg); i++) {
-                               if (opt_arg[i] == '=') {
-                                       opt_arg[i] = '\0';
-                                       properties_add(opt_arg, opt_arg + i + 1);
-                                       goto opt_d_done;
-                               }
-                       }
-
-                       /* if no '=' is given, just create an empty property */
-
-                       properties_add(opt_arg, "");
-
-               opt_d_done:
-                       break;
-
-               case OPT_BOOTCLASSPATH:
-                       /* Forget default bootclasspath and set the argument as
-                          new boot classpath. */
-
-                       boot_class_path = properties_get("sun.boot.class.path");
-
-                       p = MNEW(char, strlen(opt_arg) + strlen("0"));
-
-                       strcpy(p, opt_arg);
-
-                       properties_add("sun.boot.class.path", p);
-                       properties_add("java.boot.class.path", p);
-
-                       MFREE(boot_class_path, char, strlen(boot_class_path));
-                       break;
-
-               case OPT_BOOTCLASSPATH_A:
-                       /* Append to bootclasspath. */
-
-                       boot_class_path = properties_get("sun.boot.class.path");
-
-                       len = strlen(boot_class_path);
-
-                       p = MREALLOC(boot_class_path,
-                                                char,
-                                                len + strlen("0"),
-                                                len + strlen(":") +
-                                                strlen(opt_arg) + strlen("0"));
-
-                       strcat(p, ":");
-                       strcat(p, opt_arg);
-
-                       properties_add("sun.boot.class.path", p);
-                       properties_add("java.boot.class.path", p);
-                       break;
-
-               case OPT_BOOTCLASSPATH_P:
-                       /* Prepend to bootclasspath. */
-
-                       boot_class_path = properties_get("sun.boot.class.path");
-
-                       len = strlen(boot_class_path);
-
-                       p = MNEW(char, strlen(opt_arg) + strlen(":") + len + strlen("0"));
-
-                       strcpy(p, opt_arg);
-                       strcat(p, ":");
-                       strcat(p, boot_class_path);
-
-                       properties_add("sun.boot.class.path", p);
-                       properties_add("java.boot.class.path", p);
-
-                       MFREE(boot_class_path, char, len);
-                       break;
-
-               case OPT_BOOTCLASSPATH_C:
-                       /* Use as Java core library, but prepend VM interface
-                          classes. */
-
-                       boot_class_path = properties_get("sun.boot.class.path");
-
-                       len =
-                               strlen(CACAO_VM_ZIP) +
-                               strlen(":") +
-                               strlen(opt_arg) +
-                               strlen("0");
-
-                       p = MNEW(char, len);
-
-                       strcpy(p, CACAO_VM_ZIP);
-                       strcat(p, ":");
-                       strcat(p, opt_arg);
-
-                       properties_add("sun.boot.class.path", p);
-                       properties_add("java.boot.class.path", p);
-
-                       MFREE(boot_class_path, char, strlen(boot_class_path));
-                       break;
-
-#if defined(ENABLE_JVMTI)
-               case OPT_DEBUG:
-                       /* this option exists only for compatibility reasons */
-                       break;
-
-               case OPT_NOAGENT:
-                       /* I don't know yet what Xnoagent should do. This is only for 
-                          compatiblity with eclipse - motse */
-                       break;
-
-               case OPT_XRUNJDWP:
-                       agentbypath = true;
-                       jvmti       = true;
-                       jdwp        = true;
-
-                       len =
-                               strlen(CACAO_LIBDIR) +
-                               strlen("/libjdwp.so=") +
-                               strlen(opt_arg) +
-                               strlen("0");
-
-                       agentarg = MNEW(char, len);
-
-                       strcpy(agentarg, CACAO_LIBDIR);
-                       strcat(agentarg, "/libjdwp.so=");
-                       strcat(agentarg, &opt_arg[1]);
-                       break;
-
-               case OPT_AGENTPATH:
-                       agentbypath = true;
-
-               case OPT_AGENTLIB:
-                       jvmti = true;
-                       agentarg = opt_arg;
-                       break;
-#endif
-                       
-               case OPT_MX:
-               case OPT_MS:
-               case OPT_SS:
-                       {
-                               char c;
-                               c = opt_arg[strlen(opt_arg) - 1];
-
-                               if ((c == 'k') || (c == 'K')) {
-                                       j = atoi(opt_arg) * 1024;
-
-                               } else if ((c == 'm') || (c == 'M')) {
-                                       j = atoi(opt_arg) * 1024 * 1024;
-
-                               } else
-                                       j = atoi(opt_arg);
-
-                               if (opt == OPT_MX)
-                                       opt_heapmaxsize = j;
-                               else if (opt == OPT_MS)
-                                       opt_heapstartsize = j;
-                               else
-                                       opt_stacksize = j;
-                       }
-                       break;
-
-               case OPT_VERBOSE1:
-                       opt_verbose = true;
-                       break;
-
-               case OPT_VERBOSE:
-                       if (strcmp("class", opt_arg) == 0) {
-                               opt_verboseclass = true;
-                       }
-                       else if (strcmp("gc", opt_arg) == 0) {
-                               opt_verbosegc = true;
-                       }
-                       else if (strcmp("jni", opt_arg) == 0) {
-                               opt_verbosejni = true;
-                       }
-#if !defined(NDEBUG)
-                       else if (strcmp("jit", opt_arg) == 0) {
-                               opt_verbose = true;
-                               loadverbose = true;
-                               initverbose = true;
-                               compileverbose = true;
-                       }
-#endif
-                       else {
-                               printf("Unknown -verbose option: %s\n", opt_arg);
-                               usage();
-                       }
-                       break;
-
-               case OPT_DEBUGCOLOR:
-                       opt_debugcolor = true;
-                       break;
-
-#if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
-               case OPT_VERBOSETC:
-                       opt_typecheckverbose = true;
-                       break;
-#endif
-                               
-               case OPT_VERSION:
-                       opt_version = true;
-                       opt_exit    = true;
-                       break;
-
-               case OPT_FULLVERSION:
-                       fullversion();
-                       break;
-
-               case OPT_SHOWVERSION:
-                       opt_version = true;
-                       break;
-
-               case OPT_NOIEEE:
-                       opt_noieee = true;
-                       break;
-
-#if defined(ENABLE_VERIFIER)
-               case OPT_NOVERIFY:
-                       opt_verify = false;
-                       break;
-#endif
-
-#if defined(ENABLE_STATISTICS)
-               case OPT_TIME:
-                       opt_getcompilingtime = true;
-                       opt_getloadingtime = true;
-                       break;
-                                       
-               case OPT_STAT:
-                       opt_stat = true;
-                       break;
-#endif
-                                       
-               case OPT_LOG:
-                       log_init(opt_arg);
-                       break;
-                       
-               case OPT_CHECK:
-                       for (i = 0; i < strlen(opt_arg); i++) {
-                               switch (opt_arg[i]) {
-                               case 'b':
-                                       checkbounds = false;
-                                       break;
-                               case 's':
-                                       checksync = false;
-                                       break;
-                               default:
-                                       usage();
-                               }
-                       }
-                       break;
-                       
-               case OPT_LOAD:
-                       opt_run = false;
-                       makeinitializations = false;
-                       break;
-
-#if !defined(NDEBUG)
-               case OPT_ALL:
-                       compileall = true;
-                       opt_run = false;
-                       makeinitializations = false;
-                       break;
-
-               case OPT_METHOD:
-                       opt_run = false;
-                       opt_method = opt_arg;
-                       makeinitializations = false;
-                       break;
-
-               case OPT_SIGNATURE:
-                       opt_signature = opt_arg;
-                       break;
-#endif
-
-               case OPT_SHOW:       /* Display options */
-                       for (i = 0; i < strlen(opt_arg); i++) {         
-                               switch (opt_arg[i]) {
-                               case 'c':
-                                       showconstantpool = true;
-                                       break;
-
-                               case 'u':
-                                       showutf = true;
-                                       break;
-
-                               case 'm':
-                                       showmethods = true;
-                                       break;
-
-                               case 'i':
-                                       opt_showintermediate = true;
-                                       compileverbose = true;
-                                       break;
-
-#if defined(ENABLE_DISASSEMBLER)
-                               case 'a':
-                                       opt_showdisassemble = true;
-                                       compileverbose = true;
-                                       break;
-
-                               case 'o':
-                                       opt_shownops = true;
-                                       break;
-#endif
-
-                               case 'd':
-                                       opt_showddatasegment = true;
-                                       break;
-
-                               default:
-                                       usage();
-                               }
-                       }
-                       break;
-                       
-#if defined(ENABLE_LOOP)
-               case OPT_OLOOP:
-                       opt_loops = true;
-                       break;
-#endif
-
-#if defined(ENABLE_IFCONV)
-               case OPT_IFCONV:
-                       opt_ifconv = true;
-                       break;
-#endif
-
-#if defined(ENABLE_LSRA)
-               case OPT_LSRA:
-                       opt_lsra = true;
-                       break;
-#endif
-#if  defined(ENABLE_SSA)
-               case OPT_LSRA:
-                       opt_lsra = true;
-                       for (i = 0; i < strlen(opt_arg); i++) {         
-                               switch (opt_arg[i]) {
-                               case 'c':
-                                       opt_ssa_cp = true;
-                                       break;
-
-                               case 'd':
-                                       opt_ssa_dce = true;
-                                       break;
-
-                               case ':':
-                                       break;
-
-                               default:
-                                       usage();
-                               }
-                       }
-                       break;
-#endif
-
-               case OPT_HELP:
-                       usage();
-                       break;
-
-               case OPT_X:
-                       Xusage();
-                       break;
-
-               case OPT_XX:
-                       /* Already parsed. */
-                       break;
-
-               case OPT_EA:
-#if defined(ENABLE_ASSERTION)
-                       assertion_ea_da(opt_arg, true);
-#endif
-                       break;
-
-               case OPT_DA:
-#if defined(ENABLE_ASSERTION)
-                       assertion_ea_da(opt_arg, false);
-#endif
-                       break;
-
-               case OPT_EA_NOARG:
-#if defined(ENABLE_ASSERTION)
-                       assertion_user_enabled = true;
-#endif
-                       break;
-
-               case OPT_DA_NOARG:
-#if defined(ENABLE_ASSERTION)
-                       assertion_user_enabled = false;
-#endif
-                       break;
-
-               case OPT_ESA:
-#if defined(ENABLE_ASSERTION)
-                       assertion_system_enabled = true;
-#endif
-                       break;
-
-               case OPT_DSA:
-#if defined(ENABLE_ASSERTION)
-                       assertion_system_enabled = false;
-#endif
-                       break;
-
-#if defined(ENABLE_PROFILING)
-               case OPT_PROF_OPTION:
-                       /* use <= to get the last \0 too */
-
-                       for (i = 0, j = 0; i <= strlen(opt_arg); i++) {
-                               if (opt_arg[i] == ',')
-                                       opt_arg[i] = '\0';
-
-                               if (opt_arg[i] == '\0') {
-                                       if (strcmp("bb", opt_arg + j) == 0)
-                                               opt_prof_bb = true;
-
-                                       else {
-                                               printf("Unknown option: -Xprof:%s\n", opt_arg + j);
-                                               usage();
-                                       }
-
-                                       /* set k to next char */
-
-                                       j = i + 1;
-                               }
-                       }
-                       /* fall through */
-
-               case OPT_PROF:
-                       opt_prof = true;
-                       break;
-#endif
-
-               case OPT_JIT:
-#if defined(ENABLE_JIT)
-                       opt_jit = true;
-#else
-                       printf("-Xjit option not enabled.\n");
-                       exit(1);
-#endif
-                       break;
-
-               case OPT_INTRP:
-#if defined(ENABLE_INTRP)
-                       opt_intrp = true;
-#else
-                       printf("-Xint option not enabled.\n");
-                       exit(1);
-#endif
-                       break;
-
-#if defined(ENABLE_INTRP)
-               case OPT_STATIC_SUPERS:
-                       opt_static_supers = atoi(opt_arg);
-                       break;
-
-               case OPT_NO_DYNAMIC:
-                       opt_no_dynamic = true;
-                       break;
-
-               case OPT_NO_REPLICATION:
-                       opt_no_replication = true;
-                       break;
-
-               case OPT_NO_QUICKSUPER:
-                       opt_no_quicksuper = true;
-                       break;
-
-               case OPT_TRACE:
-                       vm_debug = true;
-                       break;
-#endif
-
-#if defined(ENABLE_DEBUG_FILTER)
-               case OPT_FILTER_VERBOSECALL_INCLUDE:
-                       opt_filter_verbosecall_include = opt_arg;
-                       break;
-
-               case OPT_FILTER_VERBOSECALL_EXCLUDE:
-                       opt_filter_verbosecall_exclude = opt_arg;
-                       break;
-
-               case OPT_FILTER_SHOW_METHOD:
-                       opt_filter_show_method = opt_arg;
-                       break;
-
-#endif
-               default:
-                       printf("Unknown option: %s\n",
-                                  vm_args->options[opt_index].optionString);
-                       usage();
-               }
-       }
-
-#if defined(ENABLE_JVMTI)
-       if (jvmti) {
-               jvmti_set_phase(JVMTI_PHASE_ONLOAD);
-               jvmti_agentload(agentarg, agentbypath, &handle, &libname);
-
-               if (jdwp)
-                       MFREE(agentarg, char, strlen(agentarg));
-
-               jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL);
-       }
-#endif
-
-       /* initialize this JVM ****************************************************/
-
-       vm_initializing = true;
-
-       /* initialize the garbage collector */
-
-       gc_init(opt_heapmaxsize, opt_heapstartsize);
-
-#if defined(ENABLE_THREADS)
-       /* BEFORE: threads_preinit */
-
-       threadlist_init();
-
-       /* AFTER: gc_init (directly after, as this initializes the
-          stopworldlock lock */
-
-       threads_preinit();
-       lock_init();
-       critical_init();
-#endif
-
-       /* install architecture dependent signal handlers */
-
-       if (!signal_init())
-               vm_abort("vm_create: signal_init failed");
-
-#if defined(ENABLE_INTRP)
-       /* Allocate main thread stack on the Java heap. */
-
-       if (opt_intrp) {
-               intrp_main_stack = GCMNEW(u1, opt_stacksize);
-               MSET(intrp_main_stack, 0, u1, opt_stacksize);
-       }
-#endif
-
-       /* AFTER: threads_preinit */
-
-       if (!string_init())
-               vm_abort("vm_create: string_init failed");
-
-       /* AFTER: threads_preinit */
-
-       utf8_init();
-
-       /* AFTER: thread_preinit */
-
-       if (!suck_init())
-               vm_abort("vm_create: suck_init failed");
-
-       suck_add_from_property("java.endorsed.dirs");
-
-       /* Now we have all options handled and we can print the version
-          information.
-
-          AFTER: suck_add_from_property("java.endorsed.dirs"); */
-
-       if (opt_version)
-               version(opt_exit);
-
-       /* AFTER: utf8_init */
-
-       boot_class_path = properties_get("sun.boot.class.path");
-       suck_add(boot_class_path);
-
-       /* initialize the classcache hashtable stuff: lock, hashtable
-          (must be done _after_ threads_preinit) */
-
-       if (!classcache_init())
-               vm_abort("vm_create: classcache_init failed");
-
-       /* Initialize the code memory management. */
-       /* AFTER: threads_preinit */
-
-       codememory_init();
-
-       /* initialize the finalizer stuff (must be done _after_
-          threads_preinit) */
-
-       if (!finalizer_init())
-               vm_abort("vm_create: finalizer_init failed");
-
-       /* Initialize the JIT compiler. */
-
-       jit_init();
-       code_init();
-       methodtree_init();
-
-#if defined(ENABLE_PYTHON)
-       pythonpass_init();
-#endif
-
-       /* BEFORE: loader_preinit */
-
-       package_init();
-
-       /* AFTER: utf8_init, classcache_init */
-
-       loader_preinit();
-       linker_preinit();
-
-       /* AFTER: loader_preinit, linker_preinit */
-
-       primitive_init();
-
-       loader_init();
-       linker_init();
-
-       /* AFTER: loader_init, linker_init */
-
-       primitive_postinit();
-       method_init();
-
-#if defined(ENABLE_JIT)
-       trap_init();
-#endif
-
-       if (!builtin_init())
-               vm_abort("vm_create: builtin_init failed");
-
-       /* Initialize the native subsystem. */
-       /* BEFORE: threads_init */
-
-       if (!native_init())
-               vm_abort("vm_create: native_init failed");
-
-       /* Register the native methods implemented in the VM. */
-       /* BEFORE: threads_init */
-
-       nativevm_preinit();
-
-#if defined(ENABLE_JNI)
-       /* Initialize the JNI subsystem (must be done _before_
-          threads_init, as threads_init can call JNI methods
-          (e.g. NewGlobalRef). */
-
-       if (!jni_init())
-               vm_abort("vm_create: jni_init failed");
-#endif
-
-#if defined(ENABLE_JNI) || defined(ENABLE_HANDLES)
-       /* Initialize the local reference table for the main thread. */
-       /* BEFORE: threads_init */
-
-       if (!localref_table_init())
-               vm_abort("vm_create: localref_table_init failed");
-#endif
-
-       /* Iinitialize some important system classes. */
-       /* BEFORE: threads_init */
-
-       initialize_init();
-
-#if defined(ENABLE_THREADS)
-       threads_init();
-#endif
-
-       /* Initialize the native VM subsystem. */
-       /* AFTER: threads_init (at least for SUN's classes) */
-
-       nativevm_init();
-
-#if defined(ENABLE_PROFILING)
-       /* initialize profiling */
-
-       if (!profile_init())
-               vm_abort("vm_create: profile_init failed");
-#endif
-
-#if defined(ENABLE_THREADS)
-       /* initialize recompilation */
-
-       if (!recompile_init())
-               vm_abort("vm_create: recompile_init failed");
-
-       /* start the signal handler thread */
-
-#if defined(__LINUX__)
-       /* XXX Remove for exact-GC. */
-       if (threads_pthreads_implementation_nptl)
-#endif
-               if (!signal_start_thread())
-                       vm_abort("vm_create: signal_start_thread failed");
-
-       /* finally, start the finalizer thread */
-
-       if (!finalizer_start_thread())
-               vm_abort("vm_create: finalizer_start_thread failed");
-
-# if !defined(NDEBUG)
-       /* start the memory profiling thread */
-
-       if (opt_ProfileMemoryUsage || opt_ProfileGCMemoryUsage)
-               if (!memory_start_thread())
-                       vm_abort("vm_create: memory_start_thread failed");
-# endif
-
-       /* start the recompilation thread (must be done before the
-          profiling thread) */
-
-       if (!recompile_start_thread())
-               vm_abort("vm_create: recompile_start_thread failed");
-
-# if defined(ENABLE_PROFILING)
-       /* start the profile sampling thread */
-
-/*     if (opt_prof) */
-/*             if (!profile_start_thread()) */
-/*                     vm_abort("vm_create: profile_start_thread failed"); */
-# endif
-#endif
-
-#if defined(ENABLE_JVMTI)
-# if defined(ENABLE_GC_CACAO)
-       /* XXX this will not work with the new indirection cells for classloaders!!! */
-       assert(0);
-# endif
-       if (jvmti) {
-               /* add agent library to native library hashtable */
-               native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle);
-       }
-#endif
-
-       /* Increment the number of VMs. */
-
-       vms++;
-
-       /* Initialization is done, VM is created.. */
-
-       vm_created      = true;
-       vm_initializing = false;
-
-       /* Print the VM configuration after all stuff is set and the VM is
-          initialized. */
-
-       if (opt_PrintConfig)
-               vm_printconfig();
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* vm_run **********************************************************************
-
-   Runs the main-method of the passed class.
-
-*******************************************************************************/
-
-void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
-{
-       char*                      option;
-       char*                      mainname;
-       char*                      p;
-       utf                       *mainutf;
-       classinfo                 *mainclass;
-       java_handle_t             *e;
-       methodinfo                *m;
-       java_handle_objectarray_t *oa; 
-       s4                         oalength;
-       utf                       *u;
-       java_handle_t             *s;
-       int                        status;
-       int                        i;
-
-#if defined(ENABLE_THREADS)
-       threadobject              *t;
-#endif
-
-#if !defined(NDEBUG)
-       if (compileall) {
-               vm_compile_all();
-               return;
-       }
-#endif
-
-       /* Get the main class plus it's arguments. */
-
-       mainname = NULL;
-
-       if (opt_index < vm_args->nOptions) {
-               /* Get main-class argument. */
-
-               mainname = vm_args->options[opt_index].optionString;
-
-               /* If the main class argument is a jar file, put it into the
-                  classpath. */
-
-               if (opt_jar == true) {
-                       p = MNEW(char, strlen(mainname) + strlen("0"));
-
-                       strcpy(p, mainname);
-
-#if defined(ENABLE_JAVASE)
-                       properties_add("java.class.path", p);
-#endif
-               }
-               else {
-                       /* Replace dots with slashes in the class name. */
-
-                       for (i = 0; i < strlen(mainname); i++)
-                               if (mainname[i] == '.')
-                                       mainname[i] = '/';
-               }
-
-               /* Build argument array.  Move index to first argument. */
-
-               opt_index++;
-
-               oalength = vm_args->nOptions - opt_index;
-
-               oa = builtin_anewarray(oalength, class_java_lang_String);
-
-               for (i = 0; i < oalength; i++) {
-                       option = vm_args->options[opt_index + i].optionString;
-
-                       u = utf_new_char(option);
-                       s = javastring_new(u);
-
-                       array_objectarray_element_set(oa, i, s);
-               }
-       }
-
-       /* Do we have a main-class argument? */
-
-       if (mainname == NULL)
-               usage();
-
-#if !defined(NDEBUG)
-       if (opt_method != NULL) {
-               vm_compile_method(mainname);
-               return;
-       }
-#endif
-
-       /* set return value to OK */
-
-       status = 0;
-
-       if (opt_jar == true) {
-               /* open jar file with java.util.jar.JarFile */
-
-               mainname = vm_get_mainclass_from_jar(mainname);
-
-               if (mainname == NULL)
-                       vm_exit(1);
-       }
-
-       /* load the main class */
-
-       mainutf = utf_new_char(mainname);
-
-#if defined(ENABLE_JAVAME_CLDC1_1)
-       mainclass = load_class_bootstrap(mainutf);
-#else
-       mainclass = load_class_from_sysloader(mainutf);
-#endif
-
-       /* error loading class */
-
-       e = exceptions_get_and_clear_exception();
-
-       if ((e != NULL) || (mainclass == NULL)) {
-               exceptions_throw_noclassdeffounderror_cause(e);
-               exceptions_print_stacktrace(); 
-               vm_exit(1);
-       }
-
-       if (!link_class(mainclass)) {
-               exceptions_print_stacktrace();
-               vm_exit(1);
-       }
-                       
-       /* find the `main' method of the main class */
-
-       m = class_resolveclassmethod(mainclass,
-                                                                utf_new_char("main"), 
-                                                                utf_new_char("([Ljava/lang/String;)V"),
-                                                                class_java_lang_Object,
-                                                                false);
-
-       if (exceptions_get_exception()) {
-               exceptions_print_stacktrace();
-               vm_exit(1);
-       }
-
-       /* there is no main method or it isn't static */
-
-       if ((m == NULL) || !(m->flags & ACC_STATIC)) {
-               exceptions_clear_exception();
-               exceptions_throw_nosuchmethoderror(mainclass,
-                                                                                  utf_new_char("main"), 
-                                                                                  utf_new_char("([Ljava/lang/String;)V"));
-
-               exceptions_print_stacktrace();
-               vm_exit(1);
-       }
-
-#ifdef TYPEINFO_DEBUG_TEST
-       /* test the typeinfo system */
-       typeinfo_test();
-#endif
-
-#if defined(ENABLE_JVMTI)
-       jvmti_set_phase(JVMTI_PHASE_LIVE);
-#endif
-
-       /* set ThreadMXBean variables */
-
-       _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++;
-       _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++;
-
-       if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount >
-               _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount)
-               _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount =
-                       _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount;
-
-       /* start the main thread */
-
-       (void) vm_call_method(m, NULL, oa);
-
-       /* exception occurred? */
-
-       if (exceptions_get_exception()) {
-               exceptions_print_stacktrace();
-               status = 1;
-       }
-
-#if defined(ENABLE_THREADS)
-    /* Detach the main thread so that it appears to have ended when
-          the application's main method exits. */
-
-       t = thread_get_current();
-
-       if (!threads_detach_thread(t))
-               vm_abort("vm_run: Could not detach main thread.");
-#endif
-
-       /* Destroy the JavaVM. */
-
-       (void) vm_destroy(vm);
-
-       /* And exit. */
-
-       vm_exit(status);
-}
-
-
-/* vm_destroy ******************************************************************
-
-   Unloads a Java VM and reclaims its resources.
-
-*******************************************************************************/
-
-int vm_destroy(JavaVM *vm)
-{
-#if defined(ENABLE_THREADS)
-       /* Create a a trivial new Java waiter thread called
-          "DestroyJavaVM". */
-
-       JavaVMAttachArgs args;
-
-       args.name  = "DestroyJavaVM";
-       args.group = NULL;
-
-       if (!threads_attach_current_thread(&args, false))
-               return 1;
-
-       /* Wait until we are the last non-daemon thread. */
-
-       threads_join_all_threads();
-#endif
-
-       /* VM is gone. */
-
-       vm_created = false;
-
-       /* Everything is ok. */
-
-       return 0;
-}
-
-
-/* vm_exit *********************************************************************
-
-   Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
-
-*******************************************************************************/
-
-void vm_exit(s4 status)
-{
-       methodinfo *m;
-
-       /* signal that we are exiting */
-
-       vm_exiting = true;
-
-       assert(class_java_lang_System);
-       assert(class_java_lang_System->state & CLASS_LOADED);
-
-#if defined(ENABLE_JVMTI)
-       if (jvmti || (dbgcom!=NULL)) {
-               jvmti_set_phase(JVMTI_PHASE_DEAD);
-               if (jvmti) jvmti_agentunload();
-       }
-#endif
-
-       if (!link_class(class_java_lang_System)) {
-               exceptions_print_stacktrace();
-               exit(1);
-       }
-
-       /* call java.lang.System.exit(I)V */
-
-       m = class_resolveclassmethod(class_java_lang_System,
-                                                                utf_new_char("exit"),
-                                                                utf_int__void,
-                                                                class_java_lang_Object,
-                                                                true);
-       
-       if (m == NULL) {
-               exceptions_print_stacktrace();
-               exit(1);
-       }
-
-       /* call the exit function with passed exit status */
-
-       (void) vm_call_method(m, NULL, status);
-
-       /* If we had an exception, just ignore the exception and exit with
-          the proper code. */
-
-       vm_shutdown(status);
-}
-
-
-/* vm_shutdown *****************************************************************
-
-   Terminates the system immediately without freeing memory explicitly
-   (to be used only for abnormal termination).
-       
-*******************************************************************************/
-
-void vm_shutdown(s4 status)
-{
-       if (opt_verbose 
-#if defined(ENABLE_STATISTICS)
-               || opt_getcompilingtime || opt_stat
-#endif
-          ) 
-       {
-               log_text("CACAO terminated by shutdown");
-               dolog("Exit status: %d\n", (s4) status);
-
-       }
-
-#if defined(ENABLE_JVMTI)
-       /* terminate cacaodbgserver */
-       if (dbgcom!=NULL) {
-               mutex_lock(&dbgcomlock);
-               dbgcom->running=1;
-               mutex_unlock(&dbgcomlock);
-               jvmti_cacaodbgserver_quit();
-       }       
-#endif
-
-       exit(status);
-}
-
-
-/* vm_exit_handler *************************************************************
-
-   The exit_handler function is called upon program termination.
-
-   ATTENTION: Don't free system resources here! Some threads may still
-   be running as this is called from VMRuntime.exit(). The OS does the
-   cleanup for us.
-
-*******************************************************************************/
-
-void vm_exit_handler(void)
-{
-#if !defined(NDEBUG)
-       if (showmethods)
-               class_showmethods(mainclass);
-
-       if (showconstantpool)
-               class_showconstantpool(mainclass);
-
-       if (showutf)
-               utf_show();
-
-# if defined(ENABLE_PROFILING)
-       if (opt_prof)
-               profile_printstats();
-# endif
-#endif /* !defined(NDEBUG) */
-
-#if defined(ENABLE_RT_TIMING)
-       rt_timing_print_time_stats(stderr);
-#endif
-
-#if defined(ENABLE_CYCLES_STATS)
-       builtin_print_cycles_stats(stderr);
-       stacktrace_print_cycles_stats(stderr);
-#endif
-
-       if (opt_verbose 
-#if defined(ENABLE_STATISTICS)
-               || opt_getcompilingtime || opt_stat
-#endif
-          ) 
-       {
-               log_text("CACAO terminated");
-
-#if defined(ENABLE_STATISTICS)
-               if (opt_stat) {
-                       print_stats();
-#ifdef TYPECHECK_STATISTICS
-                       typecheck_print_statistics(get_logfile());
-#endif
-               }
-
-               if (opt_getcompilingtime)
-                       print_times();
-#endif /* defined(ENABLE_STATISTICS) */
-       }
-       /* vm_print_profile(stderr);*/
-}
-
-
-/* vm_abort ********************************************************************
-
-   Prints an error message and aborts the VM.
-
-   IN:
-       text ... error message to print
-
-*******************************************************************************/
-
-void vm_abort(const char *text, ...)
-{
-       va_list ap;
-
-       /* Print the log message. */
-
-       log_start();
-
-       va_start(ap, text);
-       log_vprint(text, ap);
-       va_end(ap);
-
-       log_finish();
-
-       /* Now abort the VM. */
-
-       system_abort();
-}
-
-
-/* vm_abort_errnum *************************************************************
-
-   Prints an error message, appends ":" plus the strerror-message of
-   errnum and aborts the VM.
-
-   IN:
-       errnum ... error number
-       text ..... error message to print
-
-*******************************************************************************/
-
-void vm_abort_errnum(int errnum, const char *text, ...)
-{
-       va_list ap;
-
-       /* Print the log message. */
-
-       log_start();
-
-       va_start(ap, text);
-       log_vprint(text, ap);
-       va_end(ap);
-
-       /* Print the strerror-message of errnum. */
-
-       log_print(": %s", system_strerror(errnum));
-
-       log_finish();
-
-       /* Now abort the VM. */
-
-       system_abort();
-}
-
-
-/* vm_abort_errno **************************************************************
-
-   Equal to vm_abort_errnum, but uses errno to get the error number.
-
-   IN:
-       text ... error message to print
-
-*******************************************************************************/
-
-void vm_abort_errno(const char *text, ...)
-{
-       va_list ap;
-
-       va_start(ap, text);
-       vm_abort_errnum(errno, text, ap);
-       va_end(ap);
-}
-
-
-/* vm_abort_disassemble ********************************************************
-
-   Prints an error message, disassemble the given code range (if
-   enabled) and aborts the VM.
-
-   IN:
-       pc.......PC to disassemble
-          count....number of instructions to disassemble
-
-*******************************************************************************/
-
-void vm_abort_disassemble(void *pc, int count, const char *text, ...)
-{
-       va_list ap;
-#if defined(ENABLE_DISASSEMBLER)
-       int     i;
-#endif
-
-       /* Print debug message. */
-
-       log_start();
-
-       va_start(ap, text);
-       log_vprint(text, ap);
-       va_end(ap);
-
-       log_finish();
-
-       /* Print the PC. */
-
-#if SIZEOF_VOID_P == 8
-       log_println("PC=0x%016lx", pc);
-#else
-       log_println("PC=0x%08x", pc);
-#endif
-
-#if defined(ENABLE_DISASSEMBLER)
-       log_println("machine instructions at PC:");
-
-       /* Disassemble the given number of instructions. */
-
-       for (i = 0; i < count; i++)
-               pc = disassinstr(pc);
-#endif
-
-       vm_abort("Aborting...");
-}
-
-
-/* vm_get_mainclass_from_jar ***************************************************
-
-   Gets the name of the main class from a JAR's manifest file.
-
-*******************************************************************************/
-
-static char *vm_get_mainclass_from_jar(char *mainname)
-{
-       classinfo     *c;
-       java_handle_t *o;
-       methodinfo    *m;
-       java_handle_t *s;
-
-       c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
-
-       if (c == NULL) {
-               exceptions_print_stacktrace();
-               return NULL;
-       }
-
-       /* create JarFile object */
-
-       o = builtin_new(c);
-
-       if (o == NULL) {
-               exceptions_print_stacktrace();
-               return NULL;
-       }
-
-       m = class_resolveclassmethod(c,
-                                                                utf_init, 
-                                                                utf_java_lang_String__void,
-                                                                class_java_lang_Object,
-                                                                true);
-
-       if (m == NULL) {
-               exceptions_print_stacktrace();
-               return NULL;
-       }
-
-       s = javastring_new_from_ascii(mainname);
-
-       (void) vm_call_method(m, o, s);
-
-       if (exceptions_get_exception()) {
-               exceptions_print_stacktrace();
-               return NULL;
-       }
-
-       /* get manifest object */
-
-       m = class_resolveclassmethod(c,
-                                                                utf_new_char("getManifest"), 
-                                                                utf_new_char("()Ljava/util/jar/Manifest;"),
-                                                                class_java_lang_Object,
-                                                                true);
-
-       if (m == NULL) {
-               exceptions_print_stacktrace();
-               return NULL;
-       }
-
-       o = vm_call_method(m, o);
-
-       if (o == NULL) {
-               fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainname);
-               return NULL;
-       }
-
-
-       /* get Main Attributes */
-
-       LLNI_class_get(o, c);
-
-       m = class_resolveclassmethod(c,
-                                                                utf_new_char("getMainAttributes"), 
-                                                                utf_new_char("()Ljava/util/jar/Attributes;"),
-                                                                class_java_lang_Object,
-                                                                true);
-
-       if (m == NULL) {
-               exceptions_print_stacktrace();
-               return NULL;
-       }
-
-       o = vm_call_method(m, o);
-
-       if (o == NULL) {
-               fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainname);
-               return NULL;
-       }
-
-
-       /* get property Main-Class */
-
-       LLNI_class_get(o, c);
-
-       m = class_resolveclassmethod(c,
-                                                                utf_new_char("getValue"), 
-                                                                utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"),
-                                                                class_java_lang_Object,
-                                                                true);
-
-       if (m == NULL) {
-               exceptions_print_stacktrace();
-               return NULL;
-       }
-
-       s = javastring_new_from_ascii("Main-Class");
-
-       o = vm_call_method(m, o, s);
-
-       if (o == NULL) {
-               fprintf(stderr, "Failed to load Main-Class manifest attribute from\n");
-               fprintf(stderr, "%s\n", mainname);
-               return NULL;
-       }
-
-       return javastring_tochar(o);
-}
-
-
-/* vm_compile_all **************************************************************
-
-   Compile all methods found in the bootclasspath.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-static void vm_compile_all(void)
-{
-       classinfo              *c;
-       methodinfo             *m;
-       u4                      slot;
-       classcache_name_entry  *nmen;
-       classcache_class_entry *clsen;
-       s4                      i;
-
-       /* create all classes found in the bootclasspath */
-       /* XXX currently only works with zip/jar's */
-
-       loader_load_all_classes();
-
-       /* link all classes */
-
-       for (slot = 0; slot < hashtable_classcache.size; slot++) {
-               nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
-
-               for (; nmen; nmen = nmen->hashlink) {
-                       /* iterate over all class entries */
-
-                       for (clsen = nmen->classes; clsen; clsen = clsen->next) {
-                               c = clsen->classobj;
-
-                               if (c == NULL)
-                                       continue;
-
-                               if (!(c->state & CLASS_LINKED)) {
-                                       if (!link_class(c)) {
-                                               fprintf(stderr, "Error linking: ");
-                                               utf_fprint_printable_ascii_classname(stderr, c->name);
-                                               fprintf(stderr, "\n");
-
-                                               /* print out exception and cause */
-
-                                               exceptions_print_current_exception();
-
-                                               /* goto next class */
-
-                                               continue;
-                                       }
-                               }
-
-                               /* compile all class methods */
-
-                               for (i = 0; i < c->methodscount; i++) {
-                                       m = &(c->methods[i]);
-
-                                       if (m->jcode != NULL) {
-                                               if (!jit_compile(m)) {
-                                                       fprintf(stderr, "Error compiling: ");
-                                                       utf_fprint_printable_ascii_classname(stderr, c->name);
-                                                       fprintf(stderr, ".");
-                                                       utf_fprint_printable_ascii(stderr, m->name);
-                                                       utf_fprint_printable_ascii(stderr, m->descriptor);
-                                                       fprintf(stderr, "\n");
-
-                                                       /* print out exception and cause */
-
-                                                       exceptions_print_current_exception();
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-}
-#endif /* !defined(NDEBUG) */
-
-
-/* vm_compile_method ***********************************************************
-
-   Compile a specific method.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-static void vm_compile_method(char* mainname)
-{
-       methodinfo *m;
-
-       /* create, load and link the main class */
-
-       mainclass = load_class_bootstrap(utf_new_char(mainname));
-
-       if (mainclass == NULL)
-               exceptions_print_stacktrace();
-
-       if (!link_class(mainclass))
-               exceptions_print_stacktrace();
-
-       if (opt_signature != NULL) {
-               m = class_resolveclassmethod(mainclass,
-                                                                        utf_new_char(opt_method),
-                                                                        utf_new_char(opt_signature),
-                                                                        mainclass,
-                                                                        false);
-       }
-       else {
-               m = class_resolveclassmethod(mainclass,
-                                                                        utf_new_char(opt_method),
-                                                                        NULL,
-                                                                        mainclass,
-                                                                        false);
-       }
-
-       if (m == NULL)
-               vm_abort("vm_compile_method: java.lang.NoSuchMethodException: %s.%s",
-                                opt_method, opt_signature ? opt_signature : "");
-               
-       jit_compile(m);
-}
-#endif /* !defined(NDEBUG) */
-
-
-/* vm_call_array ***************************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   an argument array.
-
-   ATTENTION: This function has to be used outside the nativeworld.
-
-*******************************************************************************/
-
-#define VM_CALL_ARRAY(name, type)                                 \
-static type vm_call##name##_array(methodinfo *m, uint64_t *array) \
-{                                                                 \
-       methoddesc *md;                                               \
-       void       *pv;                                               \
-       type        value;                                            \
-                                                                  \
-       assert(m->code != NULL);                                      \
-                                                                  \
-       md = m->parseddesc;                                           \
-       pv = m->code->entrypoint;                                     \
-                                                                  \
-       STATISTICS(count_calls_native_to_java++);                     \
-                                                                  \
-       value = asm_vm_call_method##name(pv, array, md->memuse);      \
-                                                                  \
-       return value;                                                 \
-}
-
-static java_handle_t *vm_call_array(methodinfo *m, uint64_t *array)
-{
-       methoddesc    *md;
-       void          *pv;
-       java_object_t *o;
-
-       assert(m->code != NULL);
-
-       md = m->parseddesc;
-       pv = m->code->entrypoint;
-
-       STATISTICS(count_calls_native_to_java++);
-
-       o = asm_vm_call_method(pv, array, md->memuse);
-
-       if (md->returntype.type == TYPE_VOID)
-               o = NULL;
-
-       return LLNI_WRAP(o);
-}
-
-VM_CALL_ARRAY(_int,    int32_t)
-VM_CALL_ARRAY(_long,   int64_t)
-VM_CALL_ARRAY(_float,  float)
-VM_CALL_ARRAY(_double, double)
-
-
-/* vm_call_method **************************************************************
-
-   Calls a Java method with a variable number of arguments.
-
-*******************************************************************************/
-
-#define VM_CALL_METHOD(name, type)                                  \
-type vm_call_method##name(methodinfo *m, java_handle_t *o, ...)     \
-{                                                                   \
-       va_list ap;                                                     \
-       type    value;                                                  \
-                                                                    \
-       va_start(ap, o);                                                \
-       value = vm_call_method##name##_valist(m, o, ap);                \
-       va_end(ap);                                                     \
-                                                                    \
-       return value;                                                   \
-}
-
-VM_CALL_METHOD(,        java_handle_t *)
-VM_CALL_METHOD(_int,    int32_t)
-VM_CALL_METHOD(_long,   int64_t)
-VM_CALL_METHOD(_float,  float)
-VM_CALL_METHOD(_double, double)
-
-
-/* vm_call_method_valist *******************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a va_list.
-
-*******************************************************************************/
-
-#define VM_CALL_METHOD_VALIST(name, type)                               \
-type vm_call_method##name##_valist(methodinfo *m, java_handle_t *o,     \
-                                                                  va_list ap)                          \
-{                                                                       \
-       uint64_t *array;                                                    \
-       type      value;                                                    \
-       int32_t   dumpmarker;                                               \
-                                                                        \
-       if (m->code == NULL)                                                \
-               if (!jit_compile(m))                                            \
-                       return 0;                                                   \
-                                                                        \
-       THREAD_NATIVEWORLD_EXIT;                                            \
-       DMARKER;                                                            \
-                                                                        \
-       array = argument_vmarray_from_valist(m, o, ap);                     \
-       value = vm_call##name##_array(m, array);                            \
-                                                                        \
-       DRELEASE;                                                           \
-       THREAD_NATIVEWORLD_ENTER;                                           \
-                                                                        \
-       return value;                                                       \
-}
-
-VM_CALL_METHOD_VALIST(,        java_handle_t *)
-VM_CALL_METHOD_VALIST(_int,    int32_t)
-VM_CALL_METHOD_VALIST(_long,   int64_t)
-VM_CALL_METHOD_VALIST(_float,  float)
-VM_CALL_METHOD_VALIST(_double, double)
-
-
-/* vm_call_method_jvalue *******************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a jvalue array.
-
-*******************************************************************************/
-
-#define VM_CALL_METHOD_JVALUE(name, type)                               \
-type vm_call_method##name##_jvalue(methodinfo *m, java_handle_t *o,     \
-                                                          const jvalue *args)                  \
-{                                                                       \
-       uint64_t *array;                                                    \
-       type      value;                                                    \
-       int32_t   dumpmarker;                                               \
-                                                                        \
-       if (m->code == NULL)                                                \
-               if (!jit_compile(m))                                            \
-                       return 0;                                                   \
-                                                                        \
-       THREAD_NATIVEWORLD_EXIT;                                            \
-       DMARKER;                                                            \
-                                                                        \
-       array = argument_vmarray_from_jvalue(m, o, args);                   \
-       value = vm_call##name##_array(m, array);                            \
-                                                                        \
-       DRELEASE;                                                           \
-       THREAD_NATIVEWORLD_ENTER;                                           \
-                                                                        \
-       return value;                                                       \
-}
-
-VM_CALL_METHOD_JVALUE(,        java_handle_t *)
-VM_CALL_METHOD_JVALUE(_int,    int32_t)
-VM_CALL_METHOD_JVALUE(_long,   int64_t)
-VM_CALL_METHOD_JVALUE(_float,  float)
-VM_CALL_METHOD_JVALUE(_double, double)
-
-
-/* vm_call_method_objectarray **************************************************
-
-   Calls a Java method with a variable number if arguments, passed via
-   an objectarray of boxed values. Returns a boxed value.
-
-*******************************************************************************/
-
-java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o,
-                                                                                 java_handle_objectarray_t *params)
-{
-       uint64_t      *array;
-       java_handle_t *xptr;
-       java_handle_t *ro;
-       imm_union      value;
-       int32_t        dumpmarker;
-
-       /* Prevent compiler warnings. */
-
-       ro = NULL;
-
-       /* compile methods which are not yet compiled */
-
-       if (m->code == NULL)
-               if (!jit_compile(m))
-                       return NULL;
-
-       /* leave the nativeworld */
-
-       THREAD_NATIVEWORLD_EXIT;
-
-       /* mark start of dump memory area */
-
-       DMARKER;
-
-       /* Fill the argument array from a object-array. */
-
-       array = argument_vmarray_from_objectarray(m, o, params);
-
-       if (array == NULL) {
-               /* release dump area */
-
-               DRELEASE;
-
-               /* enter the nativeworld again */
-
-               THREAD_NATIVEWORLD_ENTER;
-
-               exceptions_throw_illegalargumentexception();
-
-               return NULL;
-       }
-
-       switch (m->parseddesc->returntype.decltype) {
-       case PRIMITIVETYPE_VOID:
-               value.a = vm_call_array(m, array);
-               break;
-
-       case PRIMITIVETYPE_BOOLEAN:
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               value.i = vm_call_int_array(m, array);
-               break;
-
-       case PRIMITIVETYPE_LONG:
-               value.l = vm_call_long_array(m, array);
-               break;
-
-       case PRIMITIVETYPE_FLOAT:
-               value.f = vm_call_float_array(m, array);
-               break;
-
-       case PRIMITIVETYPE_DOUBLE:
-               value.d = vm_call_double_array(m, array);
-               break;
-
-       case TYPE_ADR:
-               ro = vm_call_array(m, array);
-               break;
-
-       default:
-               vm_abort("vm_call_method_objectarray: invalid return type %d", m->parseddesc->returntype.decltype);
-       }
-
-       /* release dump area */
-
-       DRELEASE;
-
-       /* enter the nativeworld again */
-
-       THREAD_NATIVEWORLD_ENTER;
-
-       /* box the return value if necesarry */
-
-       if (m->parseddesc->returntype.decltype != TYPE_ADR)
-               ro = primitive_box(m->parseddesc->returntype.decltype, value);
-
-       /* check for an exception */
-
-       xptr = exceptions_get_exception();
-
-       if (xptr != NULL) {
-               /* clear exception pointer, we are calling JIT code again */
-
-               exceptions_clear_exception();
-
-               exceptions_throw_invocationtargetexception(xptr);
-       }
-
-       return ro;
-}
-
-
-/*
- * 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/vm.cpp b/src/vm/vm.cpp
new file mode 100644 (file)
index 0000000..3cd7343
--- /dev/null
@@ -0,0 +1,2589 @@
+/* src/vm/vm.cpp - VM startup and shutdown 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 <stdint.h>
+
+#include <exception>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "vm/types.h"
+
+#include "arch.h"
+#include "md-abi.h"
+
+#include "vm/jit/abi-asm.h"
+
+#include "mm/codememory.h"
+#include "mm/dumpmemory.hpp"
+#include "mm/gc.hpp"
+#include "mm/memory.h"
+
+#include "native/jni.hpp"
+#include "native/llni.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
+
+#include "native/vm/nativevm.hpp"
+
+#include "threads/lock.hpp"
+#include "threads/thread.hpp"
+
+#include "toolbox/logging.h"
+
+#include "vm/array.hpp"
+
+#if defined(ENABLE_ASSERTION)
+#include "vm/assertion.hpp"
+#endif
+
+#include "vm/jit/builtin.hpp"
+#include "vm/classcache.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/finalizer.h"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/os.hpp"
+#include "vm/primitive.hpp"
+#include "vm/properties.hpp"
+#include "vm/signallocal.h"
+#include "vm/statistics.h"
+#include "vm/string.hpp"
+#include "vm/suck.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/argument.hpp"
+#include "vm/jit/asmpart.h"
+#include "vm/jit/code.hpp"
+
+#if defined(ENABLE_DISASSEMBLER)
+# include "vm/jit/disass.h"
+#endif
+
+#include "vm/jit/jit.hpp"
+#include "vm/jit/methodtree.h"
+
+#if defined(ENABLE_PROFILING)
+# include "vm/jit/optimizing/profile.h"
+#endif
+
+#include "vm/jit/optimizing/recompiler.hpp"
+
+#if defined(ENABLE_PYTHON)
+# include "vm/jit/python.h"
+#endif
+
+#include "vm/jit/trap.h"
+
+#if defined(ENABLE_JVMTI)
+# include "native/jvmti/cacaodbg.h"
+#endif
+
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
+
+/**
+ * This is _the_ VM instance.
+ */
+VM* VM::_vm = NULL;
+
+
+/* global variables ***********************************************************/
+
+s4 vms = 0;                             /* number of VMs created              */
+
+static classinfo *mainclass = NULL;
+
+#if defined(ENABLE_INTRP)
+u1 *intrp_main_stack = NULL;
+#endif
+
+
+/* define heap sizes **********************************************************/
+
+#define HEAP_MAXSIZE      128 * 1024 * 1024 /* default 128MB                  */
+#define HEAP_STARTSIZE      2 * 1024 * 1024 /* default 2MB                    */
+#define STACK_SIZE               128 * 1024 /* default 64kB                   */
+
+
+/* define command line options ************************************************/
+
+enum {
+       OPT_FOO,
+
+       /* Java options */
+
+       OPT_JAR,
+
+       OPT_D32,
+       OPT_D64,
+
+       OPT_CLASSPATH,
+       OPT_D,
+
+       OPT_VERBOSE,
+
+       OPT_VERSION,
+       OPT_SHOWVERSION,
+       OPT_FULLVERSION,
+
+       OPT_HELP,
+       OPT_X,
+       OPT_XX,
+
+       OPT_EA,
+       OPT_DA,
+       OPT_EA_NOARG,
+       OPT_DA_NOARG,
+    
+
+       OPT_ESA,
+       OPT_DSA,
+
+       /* Java non-standard options */
+
+       OPT_JIT,
+       OPT_INTRP,
+
+       OPT_BOOTCLASSPATH,
+       OPT_BOOTCLASSPATH_A,
+       OPT_BOOTCLASSPATH_P,
+
+       OPT_BOOTCLASSPATH_C,
+
+#if defined(ENABLE_PROFILING)
+       OPT_PROF,
+       OPT_PROF_OPTION,
+#endif
+
+       OPT_MS,
+       OPT_MX,
+
+       /* CACAO options */
+
+       OPT_VERBOSE1,
+
+#if defined(ENABLE_STATISTICS)
+       OPT_TIME,
+       OPT_STAT,
+#endif
+
+       OPT_LOG,
+       OPT_CHECK,
+       OPT_LOAD,
+       OPT_SHOW,
+       OPT_DEBUGCOLOR,
+
+#if !defined(NDEBUG)
+       OPT_ALL,
+       OPT_METHOD,
+       OPT_SIGNATURE,
+#endif
+
+#if defined(ENABLE_VERIFIER)
+       OPT_NOVERIFY,
+#if defined(TYPECHECK_VERBOSE)
+       OPT_VERBOSETC,
+#endif
+#endif /* defined(ENABLE_VERIFIER) */
+
+       /* optimization options */
+
+#if defined(ENABLE_LOOP)
+       OPT_OLOOP,
+#endif
+       
+#if defined(ENABLE_IFCONV)
+       OPT_IFCONV,
+#endif
+
+#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
+       OPT_LSRA,
+#endif
+
+#if defined(ENABLE_INTRP)
+       /* interpreter options */
+
+       OPT_NO_DYNAMIC,
+       OPT_NO_REPLICATION,
+       OPT_NO_QUICKSUPER,
+       OPT_STATIC_SUPERS,
+       OPT_TRACE,
+#endif
+
+       OPT_SS,
+
+#ifdef ENABLE_JVMTI
+       OPT_DEBUG,
+       OPT_XRUNJDWP,
+       OPT_NOAGENT,
+       OPT_AGENTLIB,
+       OPT_AGENTPATH,
+#endif
+
+#if defined(ENABLE_DEBUG_FILTER)
+       OPT_FILTER_VERBOSECALL_INCLUDE,
+       OPT_FILTER_VERBOSECALL_EXCLUDE,
+       OPT_FILTER_SHOW_METHOD,
+#endif
+
+       DUMMY
+};
+
+
+opt_struct opts[] = {
+       { "foo",               false, OPT_FOO },
+
+       /* Java options */
+
+       { "jar",               false, OPT_JAR },
+
+       { "d32",               false, OPT_D32 },
+       { "d64",               false, OPT_D64 },
+       { "client",            false, OPT_IGNORE },
+       { "server",            false, OPT_IGNORE },
+       { "jvm",               false, OPT_IGNORE },
+       { "hotspot",           false, OPT_IGNORE },
+
+       { "classpath",         true,  OPT_CLASSPATH },
+       { "cp",                true,  OPT_CLASSPATH },
+       { "D",                 true,  OPT_D },
+       { "version",           false, OPT_VERSION },
+       { "showversion",       false, OPT_SHOWVERSION },
+       { "fullversion",       false, OPT_FULLVERSION },
+       { "help",              false, OPT_HELP },
+       { "?",                 false, OPT_HELP },
+       { "X",                 false, OPT_X },
+       { "XX:",               true,  OPT_XX },
+
+       { "ea:",               true,  OPT_EA },
+       { "da:",               true,  OPT_DA },
+       { "ea",                false, OPT_EA_NOARG },
+       { "da",                false, OPT_DA_NOARG },
+
+       { "enableassertions:",  true,  OPT_EA },
+       { "disableassertions:", true,  OPT_DA },
+       { "enableassertions",   false, OPT_EA_NOARG },
+       { "disableassertions",  false, OPT_DA_NOARG },
+
+       { "esa",                     false, OPT_ESA },
+       { "enablesystemassertions",  false, OPT_ESA },
+       { "dsa",                     false, OPT_DSA },
+       { "disablesystemassertions", false, OPT_DSA },
+
+       { "noasyncgc",         false, OPT_IGNORE },
+#if defined(ENABLE_VERIFIER)
+       { "noverify",          false, OPT_NOVERIFY },
+       { "Xverify:none",      false, OPT_NOVERIFY },
+#endif
+       { "v",                 false, OPT_VERBOSE1 },
+       { "verbose:",          true,  OPT_VERBOSE },
+
+#if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
+       { "verbosetc",         false, OPT_VERBOSETC },
+#endif
+#if defined(ENABLE_STATISTICS)
+       { "time",              false, OPT_TIME },
+       { "stat",              false, OPT_STAT },
+#endif
+       { "log",               true,  OPT_LOG },
+       { "c",                 true,  OPT_CHECK },
+       { "l",                 false, OPT_LOAD },
+
+#if !defined(NDEBUG)
+       { "all",               false, OPT_ALL },
+       { "sig",               true,  OPT_SIGNATURE },
+#endif
+
+#if defined(ENABLE_LOOP)
+       { "oloop",             false, OPT_OLOOP },
+#endif
+#if defined(ENABLE_IFCONV)
+       { "ifconv",            false, OPT_IFCONV },
+#endif
+#if defined(ENABLE_LSRA)
+       { "lsra",              false, OPT_LSRA },
+#endif
+#if  defined(ENABLE_SSA)
+       { "lsra",              true, OPT_LSRA },
+#endif
+
+#if defined(ENABLE_INTRP)
+       /* interpreter options */
+
+       { "trace",             false, OPT_TRACE },
+       { "static-supers",     true,  OPT_STATIC_SUPERS },
+       { "no-dynamic",        false, OPT_NO_DYNAMIC },
+       { "no-replication",    false, OPT_NO_REPLICATION },
+       { "no-quicksuper",     false, OPT_NO_QUICKSUPER },
+#endif
+
+       /* JVMTI Agent Command Line Options */
+#ifdef ENABLE_JVMTI
+       { "agentlib:",         true,  OPT_AGENTLIB },
+       { "agentpath:",        true,  OPT_AGENTPATH },
+#endif
+
+       /* Java non-standard options */
+
+       { "Xjit",              false, OPT_JIT },
+       { "Xint",              false, OPT_INTRP },
+       { "Xbootclasspath:",   true,  OPT_BOOTCLASSPATH },
+       { "Xbootclasspath/a:", true,  OPT_BOOTCLASSPATH_A },
+       { "Xbootclasspath/p:", true,  OPT_BOOTCLASSPATH_P },
+       { "Xbootclasspath/c:", true,  OPT_BOOTCLASSPATH_C },
+
+#ifdef ENABLE_JVMTI
+       { "Xdebug",            false, OPT_DEBUG },
+       { "Xnoagent",          false, OPT_NOAGENT },
+       { "Xrunjdwp",          true,  OPT_XRUNJDWP },
+#endif 
+
+       { "Xms",               true,  OPT_MS },
+       { "ms",                true,  OPT_MS },
+       { "Xmx",               true,  OPT_MX },
+       { "mx",                true,  OPT_MX },
+       { "Xss",               true,  OPT_SS },
+       { "ss",                true,  OPT_SS },
+
+#if defined(ENABLE_PROFILING)
+       { "Xprof:",            true,  OPT_PROF_OPTION },
+       { "Xprof",             false, OPT_PROF },
+#endif
+
+       /* keep these at the end of the list */
+
+#if !defined(NDEBUG)
+       { "m",                 true,  OPT_METHOD },
+#endif
+
+       { "s",                 true,  OPT_SHOW },
+       { "debug-color",      false,  OPT_DEBUGCOLOR },
+
+#if defined(ENABLE_DEBUG_FILTER)
+       { "XXfi",              true,  OPT_FILTER_VERBOSECALL_INCLUDE },
+       { "XXfx",              true,  OPT_FILTER_VERBOSECALL_EXCLUDE },
+       { "XXfm",              true,  OPT_FILTER_SHOW_METHOD },
+#endif
+
+       { NULL,                false, 0 }
+};
+
+
+/* usage ***********************************************************************
+
+   Prints the correct usage syntax to stdout.
+
+*******************************************************************************/
+
+void usage(void)
+{
+       puts("Usage: cacao [-options] classname [arguments]");
+       puts("               (to run a class file)");
+       puts("   or  cacao [-options] -jar jarfile [arguments]");
+       puts("               (to run a standalone jar file)\n");
+
+       puts("where options include:");
+       puts("    -d32                     use 32-bit data model if available");
+       puts("    -d64                     use 64-bit data model if available");
+       puts("    -client                  compatibility (currently ignored)");
+       puts("    -server                  compatibility (currently ignored)");
+       puts("    -jvm                     compatibility (currently ignored)");
+       puts("    -hotspot                 compatibility (currently ignored)\n");
+
+       puts("    -cp <path>               specify a path to look for classes");
+       puts("    -classpath <path>        specify a path to look for classes");
+       puts("    -D<name>=<value>         add an entry to the property list");
+       puts("    -verbose[:class|gc|jni]  enable specific verbose output");
+       puts("    -version                 print product version and exit");
+       puts("    -fullversion             print jpackage-compatible product version and exit");
+       puts("    -showversion             print product version and continue");
+       puts("    -help, -?                print this help message");
+       puts("    -X                       print help on non-standard Java options");
+       puts("    -XX                      print help on debugging options");
+    puts("    -ea[:<packagename>...|:<classname>]");
+    puts("    -enableassertions[:<packagename>...|:<classname>]");
+       puts("                             enable assertions with specified granularity");
+       puts("    -da[:<packagename>...|:<classname>]");
+       puts("    -disableassertions[:<packagename>...|:<classname>]");
+       puts("                             disable assertions with specified granularity");
+       puts("    -esa | -enablesystemassertions");
+       puts("                             enable system assertions");
+       puts("    -dsa | -disablesystemassertions");
+       puts("                             disable system assertions");
+
+#ifdef ENABLE_JVMTI
+       puts("    -agentlib:<agent-lib-name>=<options>  library to load containg JVMTI agent");
+       puts ("                                         for jdwp help use: -agentlib:jdwp=help");
+       puts("    -agentpath:<path-to-agent>=<options>  path to library containg JVMTI agent");
+#endif
+
+       /* exit with error code */
+
+       exit(1);
+}   
+
+
+static void Xusage(void)
+{
+#if defined(ENABLE_JIT)
+       puts("    -Xjit                    JIT mode execution (default)");
+#endif
+#if defined(ENABLE_INTRP)
+       puts("    -Xint                    interpreter mode execution");
+#endif
+       puts("    -Xbootclasspath:<zip/jar files and directories separated by :>");
+    puts("                             value is set as bootstrap class path");
+       puts("    -Xbootclasspath/a:<zip/jar files and directories separated by :>");
+       puts("                             value is appended to the bootstrap class path");
+       puts("    -Xbootclasspath/p:<zip/jar files and directories separated by :>");
+       puts("                             value is prepended to the bootstrap class path");
+       puts("    -Xbootclasspath/c:<zip/jar files and directories separated by :>");
+       puts("                             value is used as Java core library, but the");
+       puts("                             hardcoded VM interface classes are prepended");
+       printf("    -Xms<size>               set the initial size of the heap (default: %dMB)\n", HEAP_STARTSIZE / 1024 / 1024);
+       printf("    -Xmx<size>               set the maximum size of the heap (default: %dMB)\n", HEAP_MAXSIZE / 1024 / 1024);
+       printf("    -Xss<size>               set the thread stack size (default: %dkB)\n", STACK_SIZE / 1024);
+
+#if defined(ENABLE_PROFILING)
+       puts("    -Xprof[:bb]              collect and print profiling data");
+#endif
+
+#if defined(ENABLE_JVMTI)
+    /* -Xdebug option depend on gnu classpath JDWP options. options: 
+        transport=dt_socket,address=<hostname:port>,server=(y|n),suspend(y|n) */
+       puts("    -Xdebug                  enable remote debugging\n");
+       puts("    -Xrunjdwp transport=[dt_socket|...],address=<hostname:port>,server=[y|n],suspend=[y|n]\n");
+       puts("                             enable remote debugging\n");
+#endif 
+
+       /* exit with error code */
+
+       exit(1);
+}   
+
+
+#if 0
+static void XXusage(void)
+{
+       puts("    -v                       write state-information");
+#if !defined(NDEBUG)
+       puts("    -verbose:jit             enable specific verbose output");
+       puts("    -debug-color             colored output for ANSI terms");
+#endif
+#ifdef TYPECHECK_VERBOSE
+       puts("    -verbosetc               write debug messages while typechecking");
+#endif
+#if defined(ENABLE_VERIFIER)
+       puts("    -noverify                don't verify classfiles");
+#endif
+#if defined(ENABLE_STATISTICS)
+       puts("    -time                    measure the runtime");
+       puts("    -stat                    detailed compiler statistics");
+#endif
+       puts("    -log logfile             specify a name for the logfile");
+       puts("    -c(heck)b(ounds)         don't check array bounds");
+       puts("            s(ync)           don't check for synchronization");
+#if defined(ENABLE_LOOP)
+       puts("    -oloop                   optimize array accesses in loops");
+#endif
+       puts("    -l                       don't start the class after loading");
+#if !defined(NDEBUG)
+       puts("    -all                     compile all methods, no execution");
+       puts("    -m                       compile only a specific method");
+       puts("    -sig                     specify signature for a specific method");
+#endif
+
+       puts("    -s...                    show...");
+       puts("      (c)onstants            the constant pool");
+       puts("      (m)ethods              class fields and methods");
+       puts("      (u)tf                  the utf - hash");
+       puts("      (i)ntermediate         intermediate representation");
+#if defined(ENABLE_DISASSEMBLER)
+       puts("      (a)ssembler            disassembled listing");
+       puts("      n(o)ps                 show NOPs in disassembler output");
+#endif
+       puts("      (d)atasegment          data segment listing");
+
+#if defined(ENABLE_IFCONV)
+       puts("    -ifconv                  use if-conversion");
+#endif
+#if defined(ENABLE_LSRA)
+       puts("    -lsra                    use linear scan register allocation");
+#endif
+#if defined(ENABLE_SSA)
+       puts("    -lsra:...                use linear scan register allocation (with SSA)");
+       puts("       (d)ead code elimination");
+       puts("       (c)opy propagation");
+#endif
+#if defined(ENABLE_DEBUG_FILTER)
+       puts("    -XXfi <regex>            begin of dynamic scope for verbosecall filter");
+       puts("    -XXfx <regex>            end of dynamic scope for verbosecall filter");
+       puts("    -XXfm <regex>            filter for show options");
+#endif
+       /* exit with error code */
+
+       exit(1);
+}
+#endif
+
+
+/* version *********************************************************************
+
+   Only prints cacao version information.
+
+*******************************************************************************/
+
+static void version(bool opt_exit)
+{
+       puts("java version \""JAVA_VERSION"\"");
+       puts("CACAO version "VERSION"\n");
+
+       puts("Copyright (C) 1996-2005, 2006, 2007, 2008");
+       puts("CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO");
+       puts("This is free software; see the source for copying conditions.  There is NO");
+       puts("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.");
+
+       /* exit normally, if requested */
+
+       if (opt_exit)
+               exit(0);
+}
+
+
+/* fullversion *****************************************************************
+
+   Prints a Sun compatible version information (required e.g. by
+   jpackage, www.jpackage.org).
+
+*******************************************************************************/
+
+static void fullversion(void)
+{
+       puts("java full version \"cacao-"JAVA_VERSION"\"");
+
+       /* exit normally */
+
+       exit(0);
+}
+
+
+/* forward declarations *******************************************************/
+
+static char *vm_get_mainclass_from_jar(char *mainstring);
+#if !defined(NDEBUG)
+static void  vm_compile_all(void);
+static void  vm_compile_method(char* mainname);
+#endif
+
+
+/**
+ * Implementation for JNI_CreateJavaVM.  This function creates a VM
+ * object.
+ *
+ * @param p_vm
+ * @param p_env
+ * @param vm_args
+ *
+ * @return true on success, false otherwise.
+ */
+bool VM::create(JavaVM** p_vm, void** p_env, void* vm_args)
+{
+       JavaVMInitArgs* _vm_args;
+
+       // Get the arguments for the new JVM.
+       _vm_args = (JavaVMInitArgs *) vm_args;
+
+       // Instantiate a new VM.
+       try {
+               _vm = new VM(_vm_args);
+       }
+       catch (std::exception e) {
+               // FIXME How can we delete the resources allocated?
+//             /* release allocated memory */
+//             FREE(env, _Jv_JNIEnv);
+//             FREE(vm, _Jv_JavaVM);
+
+               _vm = NULL;
+
+               return false;
+       }
+
+       // Return the values.
+
+       *p_vm  = _vm->get_javavm();
+       *p_env = _vm->get_jnienv();
+
+       return true;
+}
+
+
+/**
+ * C wrapper for VM::create.
+ */
+extern "C" {
+       bool VM_create(JavaVM** p_vm, void** p_env, void* vm_args)
+       {
+               return VM::create(p_vm, p_env, vm_args);
+       }
+}
+
+
+/**
+ * VM constructor.
+ */
+VM::VM(JavaVMInitArgs* vm_args)
+{
+       // Very first thing to do: we are initializing.
+       _initializing = true;
+
+       // Make ourself globally visible.
+       // XXX Is this a good idea?
+       _vm = this;
+
+       /* create and fill a JavaVM structure */
+
+       _javavm = new JavaVM();
+
+#if defined(ENABLE_JNI)
+       _javavm->functions = &_Jv_JNIInvokeInterface;
+#endif
+
+       /* get the VM and Env tables (must be set before vm_create) */
+       /* XXX JVMTI Agents needs a JavaVM  */
+
+       _jnienv = new JNIEnv();
+
+#if defined(ENABLE_JNI)
+       _jnienv->functions = &_Jv_JNINativeInterface;
+#endif
+
+       /* actually create the JVM */
+
+       int   len;
+       char *p;
+       char *boot_class_path;
+       char *class_path;
+       int   opt;
+       bool  opt_version;
+       bool  opt_exit;
+
+#if defined(ENABLE_JVMTI)
+       lt_dlhandle  handle;
+       char *libname, *agentarg;
+       bool jdwp,agentbypath;
+       jdwp = agentbypath = false;
+#endif
+
+#if defined(ENABLE_JNI)
+       /* Check the JNI version requested. */
+
+       if (!jni_version_check(vm_args->version))
+               throw std::exception();
+#endif
+
+       /* We only support 1 JVM instance. */
+
+       if (vms > 0)
+               throw std::exception();
+
+       /* Install the exit handler. */
+
+       if (atexit(vm_exit_handler))
+               os::abort("atexit failed: %s\n", strerror(errno));
+
+       /* Set some options. */
+
+       opt_version       = false;
+       opt_exit          = false;
+
+       opt_heapmaxsize   = HEAP_MAXSIZE;
+       opt_heapstartsize = HEAP_STARTSIZE;
+       opt_stacksize     = STACK_SIZE;
+
+       // First of all, parse the -XX options.
+
+#if defined(ENABLE_VMLOG)
+       vmlog_cacao_init_options();
+#endif
+
+       options_xx(vm_args);
+
+       // After -XX options are parsed, print the build-time
+       // configuration, if requested.
+       if (opt_PrintConfig)
+               print_build_time_config();
+
+#if defined(ENABLE_VMLOG)
+       vmlog_cacao_init();
+#endif
+
+       /* We need to check if the actual size of a java.lang.Class object
+          is smaller or equal than the assumption made in
+          src/vm/class.hpp. */
+
+#warning FIXME We need to check the size of java.lang.Class!!!
+//     if (sizeof(java_lang_Class) > sizeof(dummy_java_lang_Class))
+//             vm_abort("vm_create: java_lang_Class structure is bigger than classinfo.object (%d > %d)", sizeof(java_lang_Class), sizeof(dummy_java_lang_Class));
+
+       /* set the VM starttime */
+
+       _starttime = builtin_currenttimemillis();
+
+#if defined(ENABLE_JVMTI)
+       /* initialize JVMTI related  **********************************************/
+       jvmti = false;
+#endif
+
+       /* iterate over all passed options */
+
+       while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
+               switch (opt) {
+               case OPT_FOO:
+                       opt_foo = true;
+                       break;
+
+               case OPT_IGNORE:
+                       break;
+                       
+               case OPT_JAR:
+                       opt_jar = true;
+                       break;
+
+               case OPT_D32:
+#if SIZEOF_VOID_P == 8
+                       puts("Running a 32-bit JVM is not supported on this platform.");
+                       exit(1);
+#endif
+                       break;
+
+               case OPT_D64:
+#if SIZEOF_VOID_P == 4
+                       puts("Running a 64-bit JVM is not supported on this platform.");
+                       exit(1);
+#endif
+                       break;
+
+               case OPT_CLASSPATH:
+                       /* Forget old classpath and set the argument as new
+                          classpath. */
+
+                       // FIXME Make class_path const char*.
+                       class_path = (char*) _properties.get("java.class.path");
+
+                       p = MNEW(char, strlen(opt_arg) + strlen("0"));
+
+                       strcpy(p, opt_arg);
+
+#if defined(ENABLE_JAVASE)
+                       _properties.put("java.class.path", p);
+#endif
+
+                       MFREE(class_path, char, strlen(class_path));
+                       break;
+
+               case OPT_D:
+                       for (unsigned int i = 0; i < strlen(opt_arg); i++) {
+                               if (opt_arg[i] == '=') {
+                                       opt_arg[i] = '\0';
+                                       _properties.put(opt_arg, opt_arg + i + 1);
+                                       goto opt_d_done;
+                               }
+                       }
+
+                       /* if no '=' is given, just create an empty property */
+
+                       _properties.put(opt_arg, "");
+
+               opt_d_done:
+                       break;
+
+               case OPT_BOOTCLASSPATH:
+                       /* Forget default bootclasspath and set the argument as
+                          new boot classpath. */
+
+                       // FIXME Make boot_class_path const char*.
+                       boot_class_path = (char*) _properties.get("sun.boot.class.path");
+
+                       p = MNEW(char, strlen(opt_arg) + strlen("0"));
+
+                       strcpy(p, opt_arg);
+
+                       _properties.put("sun.boot.class.path", p);
+                       _properties.put("java.boot.class.path", p);
+
+                       MFREE(boot_class_path, char, strlen(boot_class_path));
+                       break;
+
+               case OPT_BOOTCLASSPATH_A:
+                       /* Append to bootclasspath. */
+
+                       // FIXME Make boot_class_path const char*.
+                       boot_class_path = (char*) _properties.get("sun.boot.class.path");
+
+                       len = strlen(boot_class_path);
+
+                       // XXX (char*) quick hack
+                       p = (char*) MREALLOC(boot_class_path,
+                                                char,
+                                                len + strlen("0"),
+                                                len + strlen(":") +
+                                                strlen(opt_arg) + strlen("0"));
+
+                       strcat(p, ":");
+                       strcat(p, opt_arg);
+
+                       _properties.put("sun.boot.class.path", p);
+                       _properties.put("java.boot.class.path", p);
+                       break;
+
+               case OPT_BOOTCLASSPATH_P:
+                       /* Prepend to bootclasspath. */
+
+                       // FIXME Make boot_class_path const char*.
+                       boot_class_path = (char*) _properties.get("sun.boot.class.path");
+
+                       len = strlen(boot_class_path);
+
+                       p = MNEW(char, strlen(opt_arg) + strlen(":") + len + strlen("0"));
+
+                       strcpy(p, opt_arg);
+                       strcat(p, ":");
+                       strcat(p, boot_class_path);
+
+                       _properties.put("sun.boot.class.path", p);
+                       _properties.put("java.boot.class.path", p);
+
+                       MFREE(boot_class_path, char, len);
+                       break;
+
+               case OPT_BOOTCLASSPATH_C:
+                       /* Use as Java core library, but prepend VM interface
+                          classes. */
+
+                       // FIXME Make boot_class_path const char*.
+                       boot_class_path = (char*) _properties.get("sun.boot.class.path");
+
+                       len =
+                               strlen(CACAO_VM_ZIP) +
+                               strlen(":") +
+                               strlen(opt_arg) +
+                               strlen("0");
+
+                       p = MNEW(char, len);
+
+                       strcpy(p, CACAO_VM_ZIP);
+                       strcat(p, ":");
+                       strcat(p, opt_arg);
+
+                       _properties.put("sun.boot.class.path", p);
+                       _properties.put("java.boot.class.path", p);
+
+                       MFREE(boot_class_path, char, strlen(boot_class_path));
+                       break;
+
+#if defined(ENABLE_JVMTI)
+               case OPT_DEBUG:
+                       /* this option exists only for compatibility reasons */
+                       break;
+
+               case OPT_NOAGENT:
+                       /* I don't know yet what Xnoagent should do. This is only for 
+                          compatiblity with eclipse - motse */
+                       break;
+
+               case OPT_XRUNJDWP:
+                       agentbypath = true;
+                       jvmti       = true;
+                       jdwp        = true;
+
+                       len =
+                               strlen(CACAO_LIBDIR) +
+                               strlen("/libjdwp.so=") +
+                               strlen(opt_arg) +
+                               strlen("0");
+
+                       agentarg = MNEW(char, len);
+
+                       strcpy(agentarg, CACAO_LIBDIR);
+                       strcat(agentarg, "/libjdwp.so=");
+                       strcat(agentarg, &opt_arg[1]);
+                       break;
+
+               case OPT_AGENTPATH:
+                       agentbypath = true;
+
+               case OPT_AGENTLIB:
+                       jvmti = true;
+                       agentarg = opt_arg;
+                       break;
+#endif
+                       
+               case OPT_MX:
+               case OPT_MS:
+               case OPT_SS:
+                       {
+                               char c;
+                               int j;
+
+                               c = opt_arg[strlen(opt_arg) - 1];
+
+                               if ((c == 'k') || (c == 'K')) {
+                                       j = atoi(opt_arg) * 1024;
+
+                               } else if ((c == 'm') || (c == 'M')) {
+                                       j = atoi(opt_arg) * 1024 * 1024;
+
+                               } else
+                                       j = atoi(opt_arg);
+
+                               if (opt == OPT_MX)
+                                       opt_heapmaxsize = j;
+                               else if (opt == OPT_MS)
+                                       opt_heapstartsize = j;
+                               else
+                                       opt_stacksize = j;
+                       }
+                       break;
+
+               case OPT_VERBOSE1:
+                       opt_verbose = true;
+                       break;
+
+               case OPT_VERBOSE:
+                       if (strcmp("class", opt_arg) == 0) {
+                               opt_verboseclass = true;
+                       }
+                       else if (strcmp("gc", opt_arg) == 0) {
+                               opt_verbosegc = true;
+                       }
+                       else if (strcmp("jni", opt_arg) == 0) {
+                               opt_verbosejni = true;
+                       }
+#if !defined(NDEBUG)
+                       else if (strcmp("jit", opt_arg) == 0) {
+                               opt_verbose = true;
+                               loadverbose = true;
+                               initverbose = true;
+                               compileverbose = true;
+                       }
+#endif
+                       else {
+                               printf("Unknown -verbose option: %s\n", opt_arg);
+                               usage();
+                       }
+                       break;
+
+               case OPT_DEBUGCOLOR:
+                       opt_debugcolor = true;
+                       break;
+
+#if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
+               case OPT_VERBOSETC:
+                       opt_typecheckverbose = true;
+                       break;
+#endif
+                               
+               case OPT_VERSION:
+                       opt_version = true;
+                       opt_exit    = true;
+                       break;
+
+               case OPT_FULLVERSION:
+                       fullversion();
+                       break;
+
+               case OPT_SHOWVERSION:
+                       opt_version = true;
+                       break;
+
+#if defined(ENABLE_VERIFIER)
+               case OPT_NOVERIFY:
+                       opt_verify = false;
+                       break;
+#endif
+
+#if defined(ENABLE_STATISTICS)
+               case OPT_TIME:
+                       opt_getcompilingtime = true;
+                       opt_getloadingtime = true;
+                       break;
+                                       
+               case OPT_STAT:
+                       opt_stat = true;
+                       break;
+#endif
+                                       
+               case OPT_LOG:
+                       log_init(opt_arg);
+                       break;
+                       
+               case OPT_CHECK:
+                       for (unsigned int i = 0; i < strlen(opt_arg); i++) {
+                               switch (opt_arg[i]) {
+                               case 'b':
+                                       checkbounds = false;
+                                       break;
+                               case 's':
+                                       checksync = false;
+                                       break;
+                               default:
+                                       usage();
+                               }
+                       }
+                       break;
+                       
+               case OPT_LOAD:
+                       opt_run = false;
+                       makeinitializations = false;
+                       break;
+
+#if !defined(NDEBUG)
+               case OPT_ALL:
+                       compileall = true;
+                       opt_run = false;
+                       makeinitializations = false;
+                       break;
+
+               case OPT_METHOD:
+                       opt_run = false;
+                       opt_method = opt_arg;
+                       makeinitializations = false;
+                       break;
+
+               case OPT_SIGNATURE:
+                       opt_signature = opt_arg;
+                       break;
+#endif
+
+               case OPT_SHOW:       /* Display options */
+                       for (unsigned int i = 0; i < strlen(opt_arg); i++) {            
+                               switch (opt_arg[i]) {
+                               case 'c':
+                                       showconstantpool = true;
+                                       break;
+
+                               case 'u':
+                                       showutf = true;
+                                       break;
+
+                               case 'm':
+                                       showmethods = true;
+                                       break;
+
+                               case 'i':
+                                       opt_showintermediate = true;
+                                       compileverbose = true;
+                                       break;
+
+#if defined(ENABLE_DISASSEMBLER)
+                               case 'a':
+                                       opt_showdisassemble = true;
+                                       compileverbose = true;
+                                       break;
+#endif
+
+                               case 'd':
+                                       opt_showddatasegment = true;
+                                       break;
+
+                               default:
+                                       usage();
+                               }
+                       }
+                       break;
+                       
+#if defined(ENABLE_LOOP)
+               case OPT_OLOOP:
+                       opt_loops = true;
+                       break;
+#endif
+
+#if defined(ENABLE_IFCONV)
+               case OPT_IFCONV:
+                       opt_ifconv = true;
+                       break;
+#endif
+
+#if defined(ENABLE_LSRA)
+               case OPT_LSRA:
+                       opt_lsra = true;
+                       break;
+#endif
+#if  defined(ENABLE_SSA)
+               case OPT_LSRA:
+                       opt_lsra = true;
+                       for (unsigned int i = 0; i < strlen(opt_arg); i++) {            
+                               switch (opt_arg[i]) {
+                               case 'c':
+                                       opt_ssa_cp = true;
+                                       break;
+
+                               case 'd':
+                                       opt_ssa_dce = true;
+                                       break;
+
+                               case ':':
+                                       break;
+
+                               default:
+                                       usage();
+                               }
+                       }
+                       break;
+#endif
+
+               case OPT_HELP:
+                       usage();
+                       break;
+
+               case OPT_X:
+                       Xusage();
+                       break;
+
+               case OPT_XX:
+                       /* Already parsed. */
+                       break;
+
+               case OPT_EA:
+#if defined(ENABLE_ASSERTION)
+                       assertion_ea_da(opt_arg, true);
+#endif
+                       break;
+
+               case OPT_DA:
+#if defined(ENABLE_ASSERTION)
+                       assertion_ea_da(opt_arg, false);
+#endif
+                       break;
+
+               case OPT_EA_NOARG:
+#if defined(ENABLE_ASSERTION)
+                       assertion_user_enabled = true;
+#endif
+                       break;
+
+               case OPT_DA_NOARG:
+#if defined(ENABLE_ASSERTION)
+                       assertion_user_enabled = false;
+#endif
+                       break;
+
+               case OPT_ESA:
+#if defined(ENABLE_ASSERTION)
+                       assertion_system_enabled = true;
+#endif
+                       break;
+
+               case OPT_DSA:
+#if defined(ENABLE_ASSERTION)
+                       assertion_system_enabled = false;
+#endif
+                       break;
+
+#if defined(ENABLE_PROFILING)
+               case OPT_PROF_OPTION:
+                       /* use <= to get the last \0 too */
+
+                       for (unsigned int i = 0, j = 0; i <= strlen(opt_arg); i++) {
+                               if (opt_arg[i] == ',')
+                                       opt_arg[i] = '\0';
+
+                               if (opt_arg[i] == '\0') {
+                                       if (strcmp("bb", opt_arg + j) == 0)
+                                               opt_prof_bb = true;
+
+                                       else {
+                                               printf("Unknown option: -Xprof:%s\n", opt_arg + j);
+                                               usage();
+                                       }
+
+                                       /* set k to next char */
+
+                                       j = i + 1;
+                               }
+                       }
+                       /* fall through */
+
+               case OPT_PROF:
+                       opt_prof = true;
+                       break;
+#endif
+
+               case OPT_JIT:
+#if defined(ENABLE_JIT)
+                       opt_jit = true;
+#else
+                       printf("-Xjit option not enabled.\n");
+                       exit(1);
+#endif
+                       break;
+
+               case OPT_INTRP:
+#if defined(ENABLE_INTRP)
+                       opt_intrp = true;
+#else
+                       printf("-Xint option not enabled.\n");
+                       exit(1);
+#endif
+                       break;
+
+#if defined(ENABLE_INTRP)
+               case OPT_STATIC_SUPERS:
+                       opt_static_supers = atoi(opt_arg);
+                       break;
+
+               case OPT_NO_DYNAMIC:
+                       opt_no_dynamic = true;
+                       break;
+
+               case OPT_NO_REPLICATION:
+                       opt_no_replication = true;
+                       break;
+
+               case OPT_NO_QUICKSUPER:
+                       opt_no_quicksuper = true;
+                       break;
+
+               case OPT_TRACE:
+                       vm_debug = true;
+                       break;
+#endif
+
+#if defined(ENABLE_DEBUG_FILTER)
+               case OPT_FILTER_VERBOSECALL_INCLUDE:
+                       opt_filter_verbosecall_include = opt_arg;
+                       break;
+
+               case OPT_FILTER_VERBOSECALL_EXCLUDE:
+                       opt_filter_verbosecall_exclude = opt_arg;
+                       break;
+
+               case OPT_FILTER_SHOW_METHOD:
+                       opt_filter_show_method = opt_arg;
+                       break;
+
+#endif
+               default:
+                       printf("Unknown option: %s\n",
+                                  vm_args->options[opt_index].optionString);
+                       usage();
+               }
+       }
+
+       // Print the preliminary run-time VM configuration after options
+       // are parsed.
+       if (opt_PrintConfig)
+               print_run_time_config();
+
+#if defined(ENABLE_JVMTI)
+       if (jvmti) {
+               jvmti_set_phase(JVMTI_PHASE_ONLOAD);
+               jvmti_agentload(agentarg, agentbypath, &handle, &libname);
+
+               if (jdwp)
+                       MFREE(agentarg, char, strlen(agentarg));
+
+               jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL);
+       }
+#endif
+
+       /* initialize the garbage collector */
+
+       gc_init(opt_heapmaxsize, opt_heapstartsize);
+
+#if defined(ENABLE_THREADS)
+       /* AFTER: gc_init */
+
+       threads_preinit();
+       lock_init();
+#endif
+
+       /* install architecture dependent signal handlers */
+
+       if (!signal_init())
+               os::abort("vm_create: signal_init failed");
+
+#if defined(ENABLE_INTRP)
+       /* Allocate main thread stack on the Java heap. */
+
+       if (opt_intrp) {
+               intrp_main_stack = GCMNEW(u1, opt_stacksize);
+               MSET(intrp_main_stack, 0, u1, opt_stacksize);
+       }
+#endif
+
+       /* AFTER: threads_preinit */
+
+       if (!string_init())
+               os::abort("vm_create: string_init failed");
+
+       /* AFTER: threads_preinit */
+
+       utf8_init();
+
+       /* AFTER: thread_preinit */
+
+       if (!suck_init())
+               os::abort("vm_create: suck_init failed");
+
+       suck_add_from_property("java.endorsed.dirs");
+
+       /* Now we have all options handled and we can print the version
+          information.
+
+          AFTER: suck_add_from_property("java.endorsed.dirs"); */
+
+       if (opt_version)
+               version(opt_exit);
+
+       /* AFTER: utf8_init */
+
+       // FIXME Make boot_class_path const char*.
+       boot_class_path = (char*) _properties.get("sun.boot.class.path");
+       suck_add(boot_class_path);
+
+       /* initialize the classcache hashtable stuff: lock, hashtable
+          (must be done _after_ threads_preinit) */
+
+       if (!classcache_init())
+               os::abort("vm_create: classcache_init failed");
+
+       /* Initialize the code memory management. */
+       /* AFTER: threads_preinit */
+
+       codememory_init();
+
+       /* initialize the finalizer stuff (must be done _after_
+          threads_preinit) */
+
+       if (!finalizer_init())
+               os::abort("vm_create: finalizer_init failed");
+
+       /* Initialize the JIT compiler. */
+
+       jit_init();
+       code_init();
+       methodtree_init();
+
+#if defined(ENABLE_PYTHON)
+       pythonpass_init();
+#endif
+
+       /* AFTER: utf8_init, classcache_init */
+
+       loader_preinit();
+       linker_preinit();
+
+       // AFTER: loader_preinit, linker_preinit
+       Primitive::initialize_table();
+
+       loader_init();
+       linker_init();
+
+       // AFTER: loader_init, linker_init
+       Primitive::post_initialize_table();
+       method_init();
+
+#if defined(ENABLE_JIT)
+       trap_init();
+#endif
+
+       if (!builtin_init())
+               os::abort("vm_create: builtin_init failed");
+
+       /* Register the native methods implemented in the VM. */
+       /* BEFORE: threads_init */
+
+       nativevm_preinit();
+
+#if defined(ENABLE_JNI)
+       /* Initialize the JNI subsystem (must be done _before_
+          threads_init, as threads_init can call JNI methods
+          (e.g. NewGlobalRef). */
+
+       if (!jni_init())
+               os::abort("vm_create: jni_init failed");
+#endif
+
+#if defined(ENABLE_JNI) || defined(ENABLE_HANDLES)
+       /* Initialize the local reference table for the main thread. */
+       /* BEFORE: threads_init */
+
+       if (!localref_table_init())
+               os::abort("vm_create: localref_table_init failed");
+#endif
+
+       /* Iinitialize some important system classes. */
+       /* BEFORE: threads_init */
+
+       initialize_init();
+
+#if defined(ENABLE_THREADS)
+       threads_init();
+#endif
+
+       /* Initialize the native VM subsystem. */
+       /* AFTER: threads_init (at least for SUN's classes) */
+
+       nativevm_init();
+
+#if defined(ENABLE_PROFILING)
+       /* initialize profiling */
+
+       if (!profile_init())
+               os::abort("vm_create: profile_init failed");
+#endif
+
+#if defined(ENABLE_THREADS)
+       /* start the signal handler thread */
+
+#if defined(__LINUX__)
+       /* XXX Remove for exact-GC. */
+       if (threads_pthreads_implementation_nptl)
+#endif
+               if (!signal_start_thread())
+                       os::abort("vm_create: signal_start_thread failed");
+
+       /* finally, start the finalizer thread */
+
+       if (!finalizer_start_thread())
+               os::abort("vm_create: finalizer_start_thread failed");
+
+# if !defined(NDEBUG)
+       /* start the memory profiling thread */
+
+       if (opt_ProfileMemoryUsage || opt_ProfileGCMemoryUsage)
+               if (!memory_start_thread())
+                       os::abort("vm_create: memory_start_thread failed");
+# endif
+
+       // Start the recompilation thread (must be done before the
+       // profiling thread).
+       // FIXME Only works for one recompiler.
+       _recompiler.start();
+
+# if defined(ENABLE_PROFILING)
+       /* start the profile sampling thread */
+
+/*     if (opt_prof) */
+/*             if (!profile_start_thread()) */
+/*                     os::abort("vm_create: profile_start_thread failed"); */
+# endif
+#endif
+
+#if defined(ENABLE_JVMTI)
+# if defined(ENABLE_GC_CACAO)
+       /* XXX this will not work with the new indirection cells for classloaders!!! */
+       assert(0);
+# endif
+       if (jvmti) {
+               /* add agent library to native library hashtable */
+               native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle);
+       }
+#endif
+
+       /* Increment the number of VMs. */
+
+       vms++;
+
+       // Initialization is done, VM is created.
+       _created      = true;
+       _initializing = false;
+       
+       // Print the run-time VM configuration after all stuff is set and
+       // the VM is initialized.
+       if (opt_PrintConfig)
+               print_run_time_config();
+}
+
+
+/**
+ * Print build-time (default) VM configuration.
+ */
+void VM::print_build_time_config(void)
+{
+       puts("CACAO "VERSION" configure/build options:");
+       puts("");
+       puts("  ./configure: "VERSION_CONFIGURE_ARGS"");
+#if defined(__VERSION__)
+       puts("  CC         : "VERSION_CC" ("__VERSION__")");
+       puts("  CXX        : "VERSION_CXX" ("__VERSION__")");
+#else
+       puts("  CC         : "VERSION_CC"");
+       puts("  CXX        : "VERSION_CXX"");
+#endif
+       puts("  CFLAGS     : "VERSION_CFLAGS"");
+       puts("  CXXFLAGS   : "VERSION_CXXFLAGS"");
+
+       puts("");
+
+       puts("Build-time (default) variables:\n");
+       printf("  maximum heap size              : %d\n", HEAP_MAXSIZE);
+       printf("  initial heap size              : %d\n", HEAP_STARTSIZE);
+       printf("  stack size                     : %d\n", STACK_SIZE);
+
+#if defined(ENABLE_JRE_LAYOUT)
+       // When we're building with JRE-layout, the default paths are the
+       // same as the runtime paths.
+#else
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       puts("  gnu.classpath.boot.library.path: "JAVA_RUNTIME_LIBRARY_LIBDIR);
+       puts("  java.boot.class.path           : "CACAO_VM_ZIP":"JAVA_RUNTIME_LIBRARY_CLASSES"");
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       puts("  sun.boot.library.path          : "JAVA_RUNTIME_LIBRARY_LIBDIR);
+       puts("  java.boot.class.path           : "JAVA_RUNTIME_LIBRARY_CLASSES);
+# endif
+#endif
+
+       puts("");
+}
+
+
+/**
+ * Print run-time VM configuration.
+ */
+void VM::print_run_time_config()
+{
+       puts("Run-time variables:\n");
+       printf("  maximum heap size              : %d\n", opt_heapmaxsize);
+       printf("  initial heap size              : %d\n", opt_heapstartsize);
+       printf("  stack size                     : %d\n", opt_stacksize);
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       printf("  gnu.classpath.boot.library.path: %s\n", _properties.get("gnu.classpath.boot.library.path"));
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       printf("  sun.boot.library.path          : %s\n", _properties.get("sun.boot.library.path"));
+#endif
+
+       printf("  java.boot.class.path           : %s\n", _properties.get("java.boot.class.path"));
+       printf("  java.class.path                : %s\n", _properties.get("java.class.path"));
+
+       puts("");
+}
+
+
+/* vm_run **********************************************************************
+
+   Runs the main-method of the passed class.
+
+*******************************************************************************/
+
+void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
+{
+       char*                      option;
+       char*                      mainname;
+       char*                      p;
+       utf                       *mainutf;
+       classinfo                 *mainclass;
+       java_handle_t             *e;
+       methodinfo                *m;
+       java_handle_objectarray_t *oa; 
+       s4                         oalength;
+       utf                       *u;
+       java_handle_t             *s;
+       int                        status;
+
+       // Prevent compiler warnings.
+       oa = NULL;
+
+#if !defined(NDEBUG)
+       if (compileall) {
+               vm_compile_all();
+               return;
+       }
+#endif
+
+       /* Get the main class plus it's arguments. */
+
+       mainname = NULL;
+
+       if (opt_index < vm_args->nOptions) {
+               /* Get main-class argument. */
+
+               mainname = vm_args->options[opt_index].optionString;
+
+               /* If the main class argument is a jar file, put it into the
+                  classpath. */
+
+               if (opt_jar == true) {
+                       p = MNEW(char, strlen(mainname) + strlen("0"));
+
+                       strcpy(p, mainname);
+
+#if defined(ENABLE_JAVASE)
+                       VM::get_current()->get_properties().put("java.class.path", p);
+#endif
+               }
+               else {
+                       /* Replace dots with slashes in the class name. */
+
+                       for (unsigned int i = 0; i < strlen(mainname); i++)
+                               if (mainname[i] == '.')
+                                       mainname[i] = '/';
+               }
+
+               /* Build argument array.  Move index to first argument. */
+
+               opt_index++;
+
+               oalength = vm_args->nOptions - opt_index;
+
+               oa = builtin_anewarray(oalength, class_java_lang_String);
+
+               for (int i = 0; i < oalength; i++) {
+                       option = vm_args->options[opt_index + i].optionString;
+
+                       u = utf_new_char(option);
+                       s = javastring_new(u);
+
+                       array_objectarray_element_set(oa, i, s);
+               }
+       }
+
+       /* Do we have a main-class argument? */
+
+       if (mainname == NULL)
+               usage();
+
+#if !defined(NDEBUG)
+       if (opt_method != NULL) {
+               vm_compile_method(mainname);
+               return;
+       }
+#endif
+
+       /* set return value to OK */
+
+       status = 0;
+
+       if (opt_jar == true) {
+               /* open jar file with java.util.jar.JarFile */
+
+               mainname = vm_get_mainclass_from_jar(mainname);
+
+               if (mainname == NULL)
+                       vm_exit(1);
+       }
+
+       /* load the main class */
+
+       mainutf = utf_new_char(mainname);
+
+#if defined(ENABLE_JAVAME_CLDC1_1)
+       mainclass = load_class_bootstrap(mainutf);
+#else
+       mainclass = load_class_from_sysloader(mainutf);
+#endif
+
+       /* error loading class */
+
+       e = exceptions_get_and_clear_exception();
+
+       if ((e != NULL) || (mainclass == NULL)) {
+               exceptions_throw_noclassdeffounderror_cause(e);
+               exceptions_print_stacktrace(); 
+               vm_exit(1);
+       }
+
+       if (!link_class(mainclass)) {
+               exceptions_print_stacktrace();
+               vm_exit(1);
+       }
+                       
+       /* find the `main' method of the main class */
+
+       m = class_resolveclassmethod(mainclass,
+                                                                utf_new_char("main"), 
+                                                                utf_new_char("([Ljava/lang/String;)V"),
+                                                                class_java_lang_Object,
+                                                                false);
+
+       if (exceptions_get_exception()) {
+               exceptions_print_stacktrace();
+               vm_exit(1);
+       }
+
+       /* there is no main method or it isn't static */
+
+       if ((m == NULL) || !(m->flags & ACC_STATIC)) {
+               exceptions_clear_exception();
+               exceptions_throw_nosuchmethoderror(mainclass,
+                                                                                  utf_new_char("main"), 
+                                                                                  utf_new_char("([Ljava/lang/String;)V"));
+
+               exceptions_print_stacktrace();
+               vm_exit(1);
+       }
+
+#ifdef TYPEINFO_DEBUG_TEST
+       /* test the typeinfo system */
+       typeinfo_test();
+#endif
+
+#if defined(ENABLE_JVMTI)
+       jvmti_set_phase(JVMTI_PHASE_LIVE);
+#endif
+
+       /* set ThreadMXBean variables */
+
+//     _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++;
+//     _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++;
+
+//     if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount >
+//             _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount)
+//             _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount =
+//                     _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount;
+#warning Move to C++
+
+       /* start the main thread */
+
+       (void) vm_call_method(m, NULL, oa);
+
+       /* exception occurred? */
+
+       if (exceptions_get_exception()) {
+               exceptions_print_stacktrace();
+               status = 1;
+       }
+
+#if defined(ENABLE_THREADS)
+    /* Detach the main thread so that it appears to have ended when
+          the application's main method exits. */
+
+       if (!thread_detach_current_thread())
+               os::abort("vm_run: Could not detach main thread.");
+#endif
+
+       /* Destroy the JavaVM. */
+
+       (void) vm_destroy(vm);
+
+       /* And exit. */
+
+       vm_exit(status);
+}
+
+
+/* vm_destroy ******************************************************************
+
+   Unloads a Java VM and reclaims its resources.
+
+*******************************************************************************/
+
+int vm_destroy(JavaVM *vm)
+{
+#if defined(ENABLE_THREADS)
+       /* Create a a trivial new Java waiter thread called
+          "DestroyJavaVM". */
+
+       JavaVMAttachArgs args;
+
+       args.name  = (char*) "DestroyJavaVM";
+       args.group = NULL;
+
+       if (!thread_attach_current_thread(&args, false))
+               return 1;
+
+       /* Wait until we are the last non-daemon thread. */
+
+       threads_join_all_threads();
+#endif
+
+       /* VM is gone. */
+
+//     _created = false;
+#warning Move to C++
+
+       /* Everything is ok. */
+
+       return 0;
+}
+
+
+/* vm_exit *********************************************************************
+
+   Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
+
+*******************************************************************************/
+
+void vm_exit(s4 status)
+{
+       methodinfo *m;
+
+       /* signal that we are exiting */
+
+//     _exiting = true;
+#warning Move to C++
+
+       assert(class_java_lang_System);
+       assert(class_java_lang_System->state & CLASS_LOADED);
+
+#if defined(ENABLE_JVMTI)
+       if (jvmti || (dbgcom!=NULL)) {
+               jvmti_set_phase(JVMTI_PHASE_DEAD);
+               if (jvmti) jvmti_agentunload();
+       }
+#endif
+
+       if (!link_class(class_java_lang_System)) {
+               exceptions_print_stacktrace();
+               exit(1);
+       }
+
+       /* call java.lang.System.exit(I)V */
+
+       m = class_resolveclassmethod(class_java_lang_System,
+                                                                utf_new_char("exit"),
+                                                                utf_int__void,
+                                                                class_java_lang_Object,
+                                                                true);
+       
+       if (m == NULL) {
+               exceptions_print_stacktrace();
+               exit(1);
+       }
+
+       /* call the exit function with passed exit status */
+
+       (void) vm_call_method(m, NULL, status);
+
+       /* If we had an exception, just ignore the exception and exit with
+          the proper code. */
+
+       vm_shutdown(status);
+}
+
+
+/* vm_shutdown *****************************************************************
+
+   Terminates the system immediately without freeing memory explicitly
+   (to be used only for abnormal termination).
+       
+*******************************************************************************/
+
+void vm_shutdown(s4 status)
+{
+       if (opt_verbose 
+#if defined(ENABLE_STATISTICS)
+               || opt_getcompilingtime || opt_stat
+#endif
+          ) 
+       {
+               log_text("CACAO terminated by shutdown");
+               dolog("Exit status: %d\n", (s4) status);
+
+       }
+
+#if defined(ENABLE_JVMTI)
+       /* terminate cacaodbgserver */
+       if (dbgcom!=NULL) {
+               mutex_lock(&dbgcomlock);
+               dbgcom->running=1;
+               mutex_unlock(&dbgcomlock);
+               jvmti_cacaodbgserver_quit();
+       }       
+#endif
+
+       exit(status);
+}
+
+
+/* vm_exit_handler *************************************************************
+
+   The exit_handler function is called upon program termination.
+
+   ATTENTION: Don't free system resources here! Some threads may still
+   be running as this is called from VMRuntime.exit(). The OS does the
+   cleanup for us.
+
+*******************************************************************************/
+
+void vm_exit_handler(void)
+{
+#if !defined(NDEBUG)
+       if (showmethods)
+               class_showmethods(mainclass);
+
+       if (showconstantpool)
+               class_showconstantpool(mainclass);
+
+       if (showutf)
+               utf_show();
+
+# if defined(ENABLE_PROFILING)
+       if (opt_prof)
+               profile_printstats();
+# endif
+#endif /* !defined(NDEBUG) */
+
+#if defined(ENABLE_RT_TIMING)
+       rt_timing_print_time_stats(stderr);
+#endif
+
+#if defined(ENABLE_CYCLES_STATS)
+       builtin_print_cycles_stats(stderr);
+       stacktrace_print_cycles_stats(stderr);
+#endif
+
+       if (opt_verbose 
+#if defined(ENABLE_STATISTICS)
+               || opt_getcompilingtime || opt_stat
+#endif
+          ) 
+       {
+               log_text("CACAO terminated");
+
+#if defined(ENABLE_STATISTICS)
+               if (opt_stat) {
+                       print_stats();
+#ifdef TYPECHECK_STATISTICS
+                       typecheck_print_statistics(get_logfile());
+#endif
+               }
+
+               if (opt_getcompilingtime)
+                       print_times();
+#endif /* defined(ENABLE_STATISTICS) */
+       }
+       /* vm_print_profile(stderr);*/
+}
+
+
+/* vm_abort_disassemble ********************************************************
+
+   Prints an error message, disassemble the given code range (if
+   enabled) and aborts the VM.
+
+   IN:
+       pc.......PC to disassemble
+          count....number of instructions to disassemble
+
+*******************************************************************************/
+
+void vm_abort_disassemble(void *pc, int count, const char *text, ...)
+{
+       va_list ap;
+#if defined(ENABLE_DISASSEMBLER)
+       int     i;
+#endif
+
+       /* Print debug message. */
+
+       log_start();
+
+       va_start(ap, text);
+       log_vprint(text, ap);
+       va_end(ap);
+
+       log_finish();
+
+       /* Print the PC. */
+
+#if SIZEOF_VOID_P == 8
+       log_println("PC=0x%016lx", pc);
+#else
+       log_println("PC=0x%08x", pc);
+#endif
+
+#if defined(ENABLE_DISASSEMBLER)
+       log_println("machine instructions at PC:");
+
+       /* Disassemble the given number of instructions. */
+
+       for (i = 0; i < count; i++)
+               // FIXME disassinstr should use void*.
+               pc = disassinstr((u1*) pc);
+#endif
+
+       os::abort("Aborting...");
+}
+
+
+/* vm_get_mainclass_from_jar ***************************************************
+
+   Gets the name of the main class from a JAR's manifest file.
+
+*******************************************************************************/
+
+static char *vm_get_mainclass_from_jar(char *mainname)
+{
+       classinfo     *c;
+       java_handle_t *o;
+       methodinfo    *m;
+       java_handle_t *s;
+
+       c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
+
+       if (c == NULL) {
+               exceptions_print_stacktrace();
+               return NULL;
+       }
+
+       /* create JarFile object */
+
+       o = builtin_new(c);
+
+       if (o == NULL) {
+               exceptions_print_stacktrace();
+               return NULL;
+       }
+
+       m = class_resolveclassmethod(c,
+                                                                utf_init, 
+                                                                utf_java_lang_String__void,
+                                                                class_java_lang_Object,
+                                                                true);
+
+       if (m == NULL) {
+               exceptions_print_stacktrace();
+               return NULL;
+       }
+
+       s = javastring_new_from_ascii(mainname);
+
+       (void) vm_call_method(m, o, s);
+
+       if (exceptions_get_exception()) {
+               exceptions_print_stacktrace();
+               return NULL;
+       }
+
+       /* get manifest object */
+
+       m = class_resolveclassmethod(c,
+                                                                utf_new_char("getManifest"), 
+                                                                utf_new_char("()Ljava/util/jar/Manifest;"),
+                                                                class_java_lang_Object,
+                                                                true);
+
+       if (m == NULL) {
+               exceptions_print_stacktrace();
+               return NULL;
+       }
+
+       o = vm_call_method(m, o);
+
+       if (o == NULL) {
+               fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainname);
+               return NULL;
+       }
+
+
+       /* get Main Attributes */
+
+       LLNI_class_get(o, c);
+
+       m = class_resolveclassmethod(c,
+                                                                utf_new_char("getMainAttributes"), 
+                                                                utf_new_char("()Ljava/util/jar/Attributes;"),
+                                                                class_java_lang_Object,
+                                                                true);
+
+       if (m == NULL) {
+               exceptions_print_stacktrace();
+               return NULL;
+       }
+
+       o = vm_call_method(m, o);
+
+       if (o == NULL) {
+               fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainname);
+               return NULL;
+       }
+
+
+       /* get property Main-Class */
+
+       LLNI_class_get(o, c);
+
+       m = class_resolveclassmethod(c,
+                                                                utf_new_char("getValue"), 
+                                                                utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"),
+                                                                class_java_lang_Object,
+                                                                true);
+
+       if (m == NULL) {
+               exceptions_print_stacktrace();
+               return NULL;
+       }
+
+       s = javastring_new_from_ascii("Main-Class");
+
+       o = vm_call_method(m, o, s);
+
+       if (o == NULL) {
+               fprintf(stderr, "Failed to load Main-Class manifest attribute from\n");
+               fprintf(stderr, "%s\n", mainname);
+               return NULL;
+       }
+
+       return javastring_tochar(o);
+}
+
+
+/* vm_compile_all **************************************************************
+
+   Compile all methods found in the bootclasspath.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+static void vm_compile_all(void)
+{
+       classinfo              *c;
+       methodinfo             *m;
+       u4                      slot;
+       classcache_name_entry  *nmen;
+       classcache_class_entry *clsen;
+       s4                      i;
+
+       /* create all classes found in the bootclasspath */
+       /* XXX currently only works with zip/jar's */
+
+       loader_load_all_classes();
+
+       /* link all classes */
+
+       for (slot = 0; slot < hashtable_classcache.size; slot++) {
+               nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
+
+               for (; nmen; nmen = nmen->hashlink) {
+                       /* iterate over all class entries */
+
+                       for (clsen = nmen->classes; clsen; clsen = clsen->next) {
+                               c = clsen->classobj;
+
+                               if (c == NULL)
+                                       continue;
+
+                               if (!(c->state & CLASS_LINKED)) {
+                                       if (!link_class(c)) {
+                                               fprintf(stderr, "Error linking: ");
+                                               utf_fprint_printable_ascii_classname(stderr, c->name);
+                                               fprintf(stderr, "\n");
+
+                                               /* print out exception and cause */
+
+                                               exceptions_print_current_exception();
+
+                                               /* goto next class */
+
+                                               continue;
+                                       }
+                               }
+
+                               /* compile all class methods */
+
+                               for (i = 0; i < c->methodscount; i++) {
+                                       m = &(c->methods[i]);
+
+                                       if (m->jcode != NULL) {
+                                               if (!jit_compile(m)) {
+                                                       fprintf(stderr, "Error compiling: ");
+                                                       utf_fprint_printable_ascii_classname(stderr, c->name);
+                                                       fprintf(stderr, ".");
+                                                       utf_fprint_printable_ascii(stderr, m->name);
+                                                       utf_fprint_printable_ascii(stderr, m->descriptor);
+                                                       fprintf(stderr, "\n");
+
+                                                       /* print out exception and cause */
+
+                                                       exceptions_print_current_exception();
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* vm_compile_method ***********************************************************
+
+   Compile a specific method.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+static void vm_compile_method(char* mainname)
+{
+       methodinfo *m;
+
+       /* create, load and link the main class */
+
+       mainclass = load_class_bootstrap(utf_new_char(mainname));
+
+       if (mainclass == NULL)
+               exceptions_print_stacktrace();
+
+       if (!link_class(mainclass))
+               exceptions_print_stacktrace();
+
+       if (opt_signature != NULL) {
+               m = class_resolveclassmethod(mainclass,
+                                                                        utf_new_char(opt_method),
+                                                                        utf_new_char(opt_signature),
+                                                                        mainclass,
+                                                                        false);
+       }
+       else {
+               m = class_resolveclassmethod(mainclass,
+                                                                        utf_new_char(opt_method),
+                                                                        NULL,
+                                                                        mainclass,
+                                                                        false);
+       }
+
+       if (m == NULL)
+               os::abort("vm_compile_method: java.lang.NoSuchMethodException: %s.%s",
+                                opt_method, opt_signature ? opt_signature : "");
+               
+       jit_compile(m);
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* vm_call_array ***************************************************************
+
+   Calls a Java method with a variable number of arguments, passed via
+   an argument array.
+
+   ATTENTION: This function has to be used outside the nativeworld.
+
+*******************************************************************************/
+
+#define VM_CALL_ARRAY(name, type)                                 \
+static type vm_call##name##_array(methodinfo *m, uint64_t *array) \
+{                                                                 \
+       methoddesc *md;                                               \
+       void       *pv;                                               \
+       type        value;                                            \
+                                                                  \
+       assert(m->code != NULL);                                      \
+                                                                  \
+       md = m->parseddesc;                                           \
+       pv = m->code->entrypoint;                                     \
+                                                                  \
+       STATISTICS(count_calls_native_to_java++);                     \
+                                                                  \
+       value = asm_vm_call_method##name(pv, array, md->memuse);      \
+                                                                  \
+       return value;                                                 \
+}
+
+static java_handle_t *vm_call_array(methodinfo *m, uint64_t *array)
+{
+       methoddesc    *md;
+       void          *pv;
+       java_object_t *o;
+
+       assert(m->code != NULL);
+
+       md = m->parseddesc;
+       pv = m->code->entrypoint;
+
+       STATISTICS(count_calls_native_to_java++);
+
+       o = asm_vm_call_method(pv, array, md->memuse);
+
+       if (md->returntype.type == TYPE_VOID)
+               o = NULL;
+
+       return LLNI_WRAP(o);
+}
+
+VM_CALL_ARRAY(_int,    int32_t)
+VM_CALL_ARRAY(_long,   int64_t)
+VM_CALL_ARRAY(_float,  float)
+VM_CALL_ARRAY(_double, double)
+
+
+/* vm_call_method **************************************************************
+
+   Calls a Java method with a variable number of arguments.
+
+*******************************************************************************/
+
+#define VM_CALL_METHOD(name, type)                                  \
+type vm_call_method##name(methodinfo *m, java_handle_t *o, ...)     \
+{                                                                   \
+       va_list ap;                                                     \
+       type    value;                                                  \
+                                                                    \
+       va_start(ap, o);                                                \
+       value = vm_call_method##name##_valist(m, o, ap);                \
+       va_end(ap);                                                     \
+                                                                    \
+       return value;                                                   \
+}
+
+VM_CALL_METHOD(,        java_handle_t *)
+VM_CALL_METHOD(_int,    int32_t)
+VM_CALL_METHOD(_long,   int64_t)
+VM_CALL_METHOD(_float,  float)
+VM_CALL_METHOD(_double, double)
+
+
+/* vm_call_method_valist *******************************************************
+
+   Calls a Java method with a variable number of arguments, passed via
+   a va_list.
+
+*******************************************************************************/
+
+#define VM_CALL_METHOD_VALIST(name, type)                               \
+type vm_call_method##name##_valist(methodinfo *m, java_handle_t *o,     \
+                                                                  va_list ap)                          \
+{                                                                       \
+       uint64_t *array;                                                    \
+       type      value;                                                    \
+                                                                        \
+       if (m->code == NULL)                                                \
+               if (!jit_compile(m))                                            \
+                       return 0;                                                   \
+                                                                        \
+       THREAD_NATIVEWORLD_EXIT;                                            \
+                                                                                                                                               \
+       DumpMemoryArea dma;                                                                                                     \
+                                                                        \
+       array = argument_vmarray_from_valist(m, o, ap);                     \
+       value = vm_call##name##_array(m, array);                            \
+                                                                        \
+       THREAD_NATIVEWORLD_ENTER;                                           \
+                                                                        \
+       return value;                                                       \
+}
+
+VM_CALL_METHOD_VALIST(,        java_handle_t *)
+VM_CALL_METHOD_VALIST(_int,    int32_t)
+VM_CALL_METHOD_VALIST(_long,   int64_t)
+VM_CALL_METHOD_VALIST(_float,  float)
+VM_CALL_METHOD_VALIST(_double, double)
+
+
+/* vm_call_method_jvalue *******************************************************
+
+   Calls a Java method with a variable number of arguments, passed via
+   a jvalue array.
+
+*******************************************************************************/
+
+#define VM_CALL_METHOD_JVALUE(name, type)                               \
+type vm_call_method##name##_jvalue(methodinfo *m, java_handle_t *o,     \
+                                                          const jvalue *args)                  \
+{                                                                       \
+       uint64_t *array;                                                    \
+       type      value;                                                    \
+                                                                        \
+       if (m->code == NULL)                                                \
+               if (!jit_compile(m))                                            \
+                       return 0;                                                   \
+                                                                        \
+       THREAD_NATIVEWORLD_EXIT;                                            \
+                                                                                                                                               \
+       DumpMemoryArea dma;                                                                                                     \
+                                                                        \
+       array = argument_vmarray_from_jvalue(m, o, args);                   \
+       value = vm_call##name##_array(m, array);                            \
+                                                                        \
+       THREAD_NATIVEWORLD_ENTER;                                           \
+                                                                        \
+       return value;                                                       \
+}
+
+VM_CALL_METHOD_JVALUE(,        java_handle_t *)
+VM_CALL_METHOD_JVALUE(_int,    int32_t)
+VM_CALL_METHOD_JVALUE(_long,   int64_t)
+VM_CALL_METHOD_JVALUE(_float,  float)
+VM_CALL_METHOD_JVALUE(_double, double)
+
+
+/* vm_call_method_objectarray **************************************************
+
+   Calls a Java method with a variable number if arguments, passed via
+   an objectarray of boxed values. Returns a boxed value.
+
+*******************************************************************************/
+
+java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o,
+                                                                                 java_handle_objectarray_t *params)
+{
+       uint64_t      *array;
+       java_handle_t *xptr;
+       java_handle_t *ro;
+       imm_union      value;
+
+       /* Prevent compiler warnings. */
+
+       ro = NULL;
+
+       /* compile methods which are not yet compiled */
+
+       if (m->code == NULL)
+               if (!jit_compile(m))
+                       return NULL;
+
+       /* leave the nativeworld */
+
+       THREAD_NATIVEWORLD_EXIT;
+
+       // Create new dump memory area.
+       DumpMemoryArea dma;
+
+       /* Fill the argument array from a object-array. */
+
+       array = argument_vmarray_from_objectarray(m, o, params);
+
+       if (array == NULL) {
+               /* enter the nativeworld again */
+
+               THREAD_NATIVEWORLD_ENTER;
+
+               exceptions_throw_illegalargumentexception();
+
+               return NULL;
+       }
+
+       switch (m->parseddesc->returntype.primitivetype) {
+       case PRIMITIVETYPE_VOID:
+               value.a = vm_call_array(m, array);
+               break;
+
+       case PRIMITIVETYPE_BOOLEAN:
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               value.i = vm_call_int_array(m, array);
+               break;
+
+       case PRIMITIVETYPE_LONG:
+               value.l = vm_call_long_array(m, array);
+               break;
+
+       case PRIMITIVETYPE_FLOAT:
+               value.f = vm_call_float_array(m, array);
+               break;
+
+       case PRIMITIVETYPE_DOUBLE:
+               value.d = vm_call_double_array(m, array);
+               break;
+
+       case TYPE_ADR:
+               ro = vm_call_array(m, array);
+               break;
+
+       default:
+               os::abort("vm_call_method_objectarray: invalid return type %d", m->parseddesc->returntype.primitivetype);
+       }
+
+       /* enter the nativeworld again */
+
+       THREAD_NATIVEWORLD_ENTER;
+
+       /* box the return value if necesarry */
+
+       if (m->parseddesc->returntype.primitivetype != TYPE_ADR)
+               ro = Primitive::box(m->parseddesc->returntype.primitivetype, value);
+
+       /* check for an exception */
+
+       xptr = exceptions_get_exception();
+
+       if (xptr != NULL) {
+               /* clear exception pointer, we are calling JIT code again */
+
+               exceptions_clear_exception();
+
+               exceptions_throw_invocationtargetexception(xptr);
+       }
+
+       return ro;
+}
+
+
+/* Legacy C interface *********************************************************/
+
+extern "C" {
+
+JavaVM* VM_get_javavm()      { return VM::get_current()->get_javavm(); }
+JNIEnv* VM_get_jnienv()      { return VM::get_current()->get_jnienv(); }
+bool    VM_is_initializing() { return VM::get_current()->is_initializing(); }
+bool    VM_is_created()      { return VM::get_current()->is_created(); }
+int64_t VM_get_starttime()   { return VM::get_current()->get_starttime(); }
+
+void vm_abort(const char* text, ...)
+{
+       va_list ap;
+
+       va_start(ap, text);
+       os::abort(text, ap);
+       va_end(ap);
+}
+
+void vm_abort_errnum(int errnum, const char* text, ...)
+{
+       va_list ap;
+
+       va_start(ap, text);
+       os::abort_errnum(errnum, text, ap);
+       va_end(ap);
+}
+
+void vm_abort_errno(const char* text, ...)
+{
+       va_list ap;
+
+       va_start(ap, text);
+       os::abort_errno(text, ap);
+       va_end(ap);
+}
+
+}
+
+
+/*
+ * 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/vm.h b/src/vm/vm.h
deleted file mode 100644 (file)
index 6c5fe4e..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/* src/vm/vm.h - basic JVM 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.
-
-*/
-
-
-#ifndef _VM_H
-#define _VM_H
-
-#include "config.h"
-
-#include <stdarg.h>
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-
-
-/* export global variables ****************************************************/
-
-extern _Jv_JavaVM *_Jv_jvm;
-extern _Jv_JNIEnv *_Jv_env;
-
-extern bool vm_initializing;
-extern bool vm_created;
-extern bool vm_exiting;
-
-#if defined(ENABLE_INTRP)
-extern u1 *intrp_main_stack;
-#endif
-
-
-/* function prototypes ********************************************************/
-
-void usage(void);
-
-bool vm_createjvm(JavaVM **p_vm, void **p_env, void *vm_args);
-bool vm_create(JavaVMInitArgs *vm_args);
-void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args);
-s4   vm_destroy(JavaVM *vm);
-void vm_exit(s4 status);
-void vm_shutdown(s4 status);
-
-void vm_exit_handler(void);
-
-void vm_abort(const char *text, ...);
-void vm_abort_errnum(int errnum, const char *text, ...);
-void vm_abort_errno(const char *text, ...);
-void vm_abort_disassemble(void *pc, int count, const char *text, ...);
-
-/* Java method calling functions */
-
-java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...);
-java_handle_t *vm_call_method_valist(methodinfo *m, java_handle_t *o,
-                                                                                va_list ap);
-java_handle_t *vm_call_method_jvalue(methodinfo *m, java_handle_t *o,
-                                                                                const jvalue *args);
-
-int32_t vm_call_method_int(methodinfo *m, java_handle_t *o, ...);
-int32_t vm_call_method_int_valist(methodinfo *m, java_handle_t *o, va_list ap);
-int32_t vm_call_method_int_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
-
-int64_t vm_call_method_long(methodinfo *m, java_handle_t *o, ...);
-int64_t vm_call_method_long_valist(methodinfo *m, java_handle_t *o, va_list ap);
-int64_t vm_call_method_long_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
-
-float   vm_call_method_float(methodinfo *m, java_handle_t *o, ...);
-float   vm_call_method_float_valist(methodinfo *m, java_handle_t *o, va_list ap);
-float   vm_call_method_float_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
-
-double  vm_call_method_double(methodinfo *m, java_handle_t *o, ...);
-double  vm_call_method_double_valist(methodinfo *m, java_handle_t *o, va_list ap);
-double  vm_call_method_double_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
-
-java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params);
-
-#endif /* _VM_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/vm.hpp b/src/vm/vm.hpp
new file mode 100644 (file)
index 0000000..4a73ecc
--- /dev/null
@@ -0,0 +1,215 @@
+/* src/vm/vm.hpp - basic JVM 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.
+
+*/
+
+
+#ifndef _VM_HPP
+#define _VM_HPP
+
+#include "config.h"
+
+#include <stdarg.h>
+#include <stdint.h>
+
+// We need the JNI types for the VM class.
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+# include "native/vm/openjdk/hpi.hpp"
+# include "native/vm/openjdk/management.hpp"
+#endif
+
+#include "vm/properties.hpp"
+
+#include "vm/jit/optimizing/recompiler.hpp"
+
+
+#ifdef __cplusplus
+
+/**
+ * Represent an instance of a VM.
+ */
+class VM {
+private:
+       // This is _the_ VM instance.
+       static VM* _vm;
+
+       // JNI variables.
+       JavaVM* _javavm;
+       JNIEnv* _jnienv;
+
+       // VM variables.
+       bool    _initializing;
+       bool    _created;
+       bool    _exiting;
+       int64_t _starttime;
+
+       // Subsystems.
+       Properties      _properties;      ///< Commandline properties.
+#if defined(ENABLE_THREADS)
+       Recompiler      _recompiler;      ///< JIT recompilation framework.
+#endif
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       HPI             _hpi;             ///< Host Porting Interface.
+       Management      _management;      ///< Java management interface.
+#endif
+       NativeLibraries _nativelibraries; ///< Native library table.
+       NativeMethods   _nativemethods;   ///< Native methods table.
+
+public:
+       // Constructor, Destructor.
+       VM(JavaVMInitArgs*);
+       ~VM();
+
+       // Static methods.
+       static bool create(JavaVM** p_vm, void** p_env, void* vm_args);
+       static VM*  get_current() { return _vm; }
+
+       static void print_build_time_config();
+       void        print_run_time_config();
+
+       // Getters for private members.
+       JavaVM* get_javavm()      { return _javavm; }
+       JNIEnv* get_jnienv()      { return _jnienv; }
+       bool    is_initializing() { return _initializing; }
+       bool    is_created()      { return _created; }
+       bool    is_exiting()      { return _exiting; }
+       int64_t get_starttime()   { return _starttime; }
+
+       Properties&      get_properties     () { return _properties; }
+       Recompiler&      get_recompiler     () { return _recompiler; } // REMOVEME
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       HPI&             get_hpi            () { return _hpi; }
+       Management&      get_management     () { return _management; }
+#endif
+       NativeLibraries& get_nativelibraries() { return _nativelibraries; }
+       NativeMethods&   get_nativemethods  () { return _nativemethods; }
+};
+
+#else
+
+JavaVM* VM_get_javavm();
+JNIEnv* VM_get_jnienv();
+bool    VM_is_initializing();
+bool    VM_is_created();
+int64_t VM_get_starttime();
+
+#endif
+
+
+// Includes.
+#include "vm/global.h"
+#include "vm/method.hpp"
+
+
+/* These C methods are the exported interface. ********************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool VM_create(JavaVM** p_vm, void** p_env, void* vm_args);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* export global variables ****************************************************/
+
+#if defined(ENABLE_INTRP)
+extern uint8_t* intrp_main_stack;
+#endif
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void usage(void);
+
+bool vm_create(JavaVMInitArgs *vm_args);
+void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args);
+int32_t   vm_destroy(JavaVM *vm);
+void vm_exit(int32_t status);
+void vm_shutdown(int32_t status);
+
+void vm_exit_handler(void);
+
+void vm_abort_disassemble(void *pc, int count, const char *text, ...);
+
+/* Java method calling functions */
+
+java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...);
+java_handle_t *vm_call_method_valist(methodinfo *m, java_handle_t *o,
+                                                                                va_list ap);
+java_handle_t *vm_call_method_jvalue(methodinfo *m, java_handle_t *o,
+                                                                                const jvalue *args);
+
+int32_t vm_call_method_int(methodinfo *m, java_handle_t *o, ...);
+int32_t vm_call_method_int_valist(methodinfo *m, java_handle_t *o, va_list ap);
+int32_t vm_call_method_int_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
+
+int64_t vm_call_method_long(methodinfo *m, java_handle_t *o, ...);
+int64_t vm_call_method_long_valist(methodinfo *m, java_handle_t *o, va_list ap);
+int64_t vm_call_method_long_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
+
+float   vm_call_method_float(methodinfo *m, java_handle_t *o, ...);
+float   vm_call_method_float_valist(methodinfo *m, java_handle_t *o, va_list ap);
+float   vm_call_method_float_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
+
+double  vm_call_method_double(methodinfo *m, java_handle_t *o, ...);
+double  vm_call_method_double_valist(methodinfo *m, java_handle_t *o, va_list ap);
+double  vm_call_method_double_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
+
+java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params);
+
+
+// Legacy C interface.
+void vm_abort(const char* text, ...);
+void vm_abort_errnum(int errnum, const char* text, ...);
+void vm_abort_errno(const char* text, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _VM_HPP
+
+
+/*
+ * 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/zip.cpp b/src/vm/zip.cpp
new file mode 100644 (file)
index 0000000..b9c870c
--- /dev/null
@@ -0,0 +1,466 @@
+/* src/vm/zip.cpp - ZIP file handling for bootstrap classloader
+
+   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 <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <zlib.h>
+#include <sys/mman.h>
+
+#include "vm/types.h"
+
+#include "vm/descriptor.h" /* needed to prevent circular dependency */
+#include "toolbox/hashtable.h"
+
+#include "mm/memory.h"
+
+#include "vm/global.h"
+#include "vm/suck.hpp"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+#include "vm/zip.hpp"
+
+
+/* start size for classes hashtable *******************************************/
+
+#define HASHTABLE_CLASSES_SIZE    (1 << 10)
+
+
+/* info taken from:
+   http://www.pkware.com/business_and_developers/developer/popups/appnote.txt
+*/
+
+/* all signatures in the ZIP file have a length of 4 bytes ********************/
+
+#define SIGNATURE_LENGTH    4
+
+/* Central directory structure *************************************************
+
+   [file header 1]
+   .
+   .
+   . 
+   [file header n]
+   [digital signature] 
+   
+   File header:
+   
+     central file header signature   4 bytes  (0x02014b50)
+     version made by                 2 bytes
+     version needed to extract       2 bytes
+     general purpose bit flag        2 bytes
+     compression method              2 bytes
+     last mod file time              2 bytes
+     last mod file date              2 bytes
+     crc-32                          4 bytes
+     compressed size                 4 bytes
+     uncompressed size               4 bytes
+     file name length                2 bytes
+     extra field length              2 bytes
+     file comment length             2 bytes
+     disk number start               2 bytes
+     internal file attributes        2 bytes
+     external file attributes        4 bytes
+     relative offset of local header 4 bytes
+   
+     file name (variable size)
+     extra field (variable size)
+     file comment (variable size)
+
+   Digital signature:
+   
+     header signature                4 bytes  (0x05054b50)
+     size of data                    2 bytes
+     signature data (variable size)
+
+*******************************************************************************/
+
+#define CDSFH_HEADER_SIZE            46
+
+#define CDSFH_SIGNATURE              0x02014b50
+#define CDSFH_COMPRESSION_METHOD     10
+#define CDSFH_COMPRESSED_SIZE        20
+#define CDSFH_UNCOMPRESSED_SIZE      24
+#define CDSFH_FILE_NAME_LENGTH       28
+#define CDSFH_EXTRA_FIELD_LENGTH     30
+#define CDSFH_FILE_COMMENT_LENGTH    32
+#define CDSFH_RELATIVE_OFFSET        42
+#define CDSFH_FILENAME               46
+
+typedef struct cdsfh cdsfh;
+
+struct cdsfh {
+       u2 compressionmethod;
+       u4 compressedsize;
+       u4 uncompressedsize;
+       u2 filenamelength;
+       u2 extrafieldlength;
+       u2 filecommentlength;
+       u4 relativeoffset;
+};
+
+
+/* End of central directory record *********************************************
+
+   end of central dir signature    4 bytes  (0x06054b50)
+   number of this disk             2 bytes
+   number of the disk with the
+   start of the central directory  2 bytes
+   total number of entries in the
+   central directory on this disk  2 bytes
+   total number of entries in
+   the central directory           2 bytes
+   size of the central directory   4 bytes
+   offset of start of central
+   directory with respect to
+   the starting disk number        4 bytes
+   .ZIP file comment length        2 bytes
+   .ZIP file comment       (variable size)
+
+*******************************************************************************/
+
+#define EOCDR_SIGNATURE              0x06054b50
+#define EOCDR_ENTRIES                10
+#define EOCDR_OFFSET                 16
+
+typedef struct eocdr eocdr;
+
+struct eocdr {
+       u2 entries;
+       u4 offset;
+};
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* zip_open ********************************************************************
+
+   XXX
+
+*******************************************************************************/
+
+hashtable *zip_open(char *path)
+{
+       hashtable               *ht;
+       hashtable_zipfile_entry *htzfe;
+       int                      fd;
+       u1                       lfh_signature[SIGNATURE_LENGTH];
+       off_t                    len;
+       u1                      *filep;
+       s4                       i;
+       u1                      *p;
+       eocdr                    eocdr;
+       cdsfh                    cdsfh;
+       const char              *filename;
+       const char              *classext;
+       utf                     *u;
+       u4                       key;       /* hashkey computed from utf-text     */
+       u4                       slot;      /* slot in hashtable                  */
+
+       /* first of all, open the file */
+
+       if ((fd = open(path, O_RDONLY)) == -1)
+               return NULL;
+
+       /* check for signature in first local file header */
+
+       if (read(fd, lfh_signature, SIGNATURE_LENGTH) != SIGNATURE_LENGTH)
+               return NULL;
+
+       if (SUCK_LE_U4(lfh_signature) != LFH_SIGNATURE)
+               return NULL;
+
+       /* get the file length */
+
+       if ((len = lseek(fd, 0, SEEK_END)) == -1)
+               return NULL;
+
+       /* we better mmap the file */
+
+       filep = (u1*) mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0);
+
+       /* some older compilers, like DEC OSF cc, don't like comparisons
+       on void* types */
+
+       if ((ptrint) filep == (ptrint) MAP_FAILED)
+               return NULL;
+
+       /* find end of central directory record */
+
+       for (p = filep + len; p >= filep; p--)
+               if (SUCK_LE_U4(p) == EOCDR_SIGNATURE)
+                       break;
+
+       /* get number of entries in central directory */
+
+       eocdr.entries = SUCK_LE_U2(p + EOCDR_ENTRIES);
+       eocdr.offset  = SUCK_LE_U4(p + EOCDR_OFFSET);
+
+       /* create hashtable for filenames */
+
+       ht = NEW(hashtable);
+
+       hashtable_create(ht, HASHTABLE_CLASSES_SIZE);
+
+       /* add all file entries into the hashtable */
+
+       for (i = 0, p = filep + eocdr.offset; i < eocdr.entries; i++) {
+               /* check file header signature */
+
+               if (SUCK_LE_U4(p) != CDSFH_SIGNATURE)
+                       return NULL;
+
+               /* we found an entry */
+
+               cdsfh.compressionmethod = SUCK_LE_U2(p + CDSFH_COMPRESSION_METHOD);
+               cdsfh.compressedsize    = SUCK_LE_U4(p + CDSFH_COMPRESSED_SIZE);
+               cdsfh.uncompressedsize  = SUCK_LE_U4(p + CDSFH_UNCOMPRESSED_SIZE);
+               cdsfh.filenamelength    = SUCK_LE_U2(p + CDSFH_FILE_NAME_LENGTH);
+               cdsfh.extrafieldlength  = SUCK_LE_U2(p + CDSFH_EXTRA_FIELD_LENGTH);
+               cdsfh.filecommentlength = SUCK_LE_U2(p + CDSFH_FILE_COMMENT_LENGTH);
+               cdsfh.relativeoffset    = SUCK_LE_U4(p + CDSFH_RELATIVE_OFFSET);
+
+               /* create utf8 string of filename, strip .class from classes */
+
+               filename = (const char *) (p + CDSFH_FILENAME);
+               classext = filename + cdsfh.filenamelength - strlen(".class");
+
+               /* skip directory entries */
+
+               if (filename[cdsfh.filenamelength - 1] != '/') {
+                       if (strncmp(classext, ".class", strlen(".class")) == 0)
+                               u = utf_new(filename, cdsfh.filenamelength - strlen(".class"));
+                       else
+                               u = utf_new(filename, cdsfh.filenamelength);
+
+                       /* insert class into hashtable */
+
+                       htzfe = NEW(hashtable_zipfile_entry);
+
+                       htzfe->filename          = u;
+                       htzfe->compressionmethod = cdsfh.compressionmethod;
+                       htzfe->compressedsize    = cdsfh.compressedsize;
+                       htzfe->uncompressedsize  = cdsfh.uncompressedsize;
+                       htzfe->data              = filep + cdsfh.relativeoffset;
+
+                       /* get hashtable slot */
+
+                       key  = utf_hashkey(u->text, u->blength);
+                       slot = key & (ht->size - 1);
+
+                       /* insert into external chain */
+
+                       htzfe->hashlink = (hashtable_zipfile_entry*) ht->ptr[slot];
+
+                       /* insert hashtable zipfile entry */
+
+                       ht->ptr[slot] = htzfe;
+                       ht->entries++;
+               }
+
+               /* move to next central directory structure file header */
+
+               p = p +
+                       CDSFH_HEADER_SIZE +
+                       cdsfh.filenamelength +
+                       cdsfh.extrafieldlength +
+                       cdsfh.filecommentlength;
+       }
+
+       /* return pointer to hashtable */
+
+       return ht;
+}
+
+
+/* zip_find ********************************************************************
+
+   Search for the given filename in the classpath entries of a zip file.
+
+   NOTE: The '.class' extension is stripped when reading a zip file, so if
+   you want to find a .class file, you must search for its name _without_
+   the '.class' extension. 
+   XXX I dont like that, it makes foo and foo.class ambiguous. -Edwin
+
+   IN:
+      lce..........the classpath entries for the zip file
+         u............the filename to look for
+
+   RETURN VALUE:
+      hashtable_zipfile_entry * of the entry if found, or
+         NULL if not found
+
+*******************************************************************************/
+
+hashtable_zipfile_entry *zip_find(list_classpath_entry *lce, utf *u)
+{
+       hashtable               *ht;
+       u4                       key;       /* hashkey computed from utf-text     */
+       u4                       slot;      /* slot in hashtable                  */
+       hashtable_zipfile_entry *htzfe;     /* hashtable element                  */
+
+       /* get classes hashtable from the classpath entry */
+
+       ht = lce->htclasses;
+
+       /* get the hashtable slot of the name searched */
+
+       key   = utf_hashkey(u->text, u->blength);
+       slot  = key & (ht->size - 1);
+       htzfe = (hashtable_zipfile_entry*) ht->ptr[slot];
+
+       /* search external hash chain for utf-symbol */
+
+       while (htzfe) {
+               if (htzfe->filename == u)
+                       return htzfe;
+
+               /* next element in external chain */
+
+               htzfe = htzfe->hashlink;
+       }
+
+       /* file not found in this archive */
+
+       return NULL;
+}
+
+
+/* zip_get ********************************************************************
+
+   XXX
+
+*******************************************************************************/
+
+classbuffer *zip_get(list_classpath_entry *lce, classinfo *c)
+{
+       hashtable_zipfile_entry *htzfe;
+       lfh                      lfh;
+       u1                      *indata;
+       u1                      *outdata;
+       z_stream                 zs;
+       int                      err;
+       classbuffer             *cb;
+
+       /* try to find the class in the current archive */
+
+       htzfe = zip_find(lce, c->name);
+
+       if (htzfe == NULL)
+               return NULL;
+
+       /* read stuff from local file header */
+
+       lfh.filenamelength   = SUCK_LE_U2(htzfe->data + LFH_FILE_NAME_LENGTH);
+       lfh.extrafieldlength = SUCK_LE_U2(htzfe->data + LFH_EXTRA_FIELD_LENGTH);
+
+       indata = htzfe->data +
+               LFH_HEADER_SIZE +
+               lfh.filenamelength +
+               lfh.extrafieldlength;
+
+       /* allocate buffer for uncompressed data */
+
+       outdata = MNEW(u1, htzfe->uncompressedsize);
+
+       /* how is the file stored? */
+
+       switch (htzfe->compressionmethod) {
+       case Z_DEFLATED:
+               /* fill z_stream structure */
+
+               zs.next_in   = indata;
+               zs.avail_in  = htzfe->compressedsize;
+               zs.next_out  = outdata;
+               zs.avail_out = htzfe->uncompressedsize;
+
+               zs.zalloc = Z_NULL;
+               zs.zfree  = Z_NULL;
+               zs.opaque = Z_NULL;
+
+               /* initialize this inflate run */
+
+               if (inflateInit2(&zs, -MAX_WBITS) != Z_OK)
+                       vm_abort("zip_get: inflateInit2 failed: %s", strerror(errno));
+
+               /* decompress the file into buffer */
+
+               err = inflate(&zs, Z_SYNC_FLUSH);
+
+               if ((err != Z_STREAM_END) && (err != Z_OK))
+                       vm_abort("zip_get: inflate failed: %s", strerror(errno));
+
+               /* finish this inflate run */
+
+               if (inflateEnd(&zs) != Z_OK)
+                       vm_abort("zip_get: inflateEnd failed: %s", strerror(errno));
+               break;
+
+       case 0:
+               /* uncompressed file, just copy the data */
+               MCOPY(outdata, indata, u1, htzfe->compressedsize);
+               break;
+
+       default:
+               vm_abort("zip_get: unknown compression method %d",
+                                htzfe->compressionmethod);
+       }
+       
+       /* allocate classbuffer */
+
+       cb = NEW(classbuffer);
+
+       cb->clazz = c;
+       cb->size  = htzfe->uncompressedsize;
+       cb->data  = outdata;
+       cb->pos   = outdata;
+       cb->path  = lce->path;
+
+       /* return the filled classbuffer structure */
+
+       return cb;
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+/*
+ * 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/zip.hpp b/src/vm/zip.hpp
new file mode 100644 (file)
index 0000000..d79f8ef
--- /dev/null
@@ -0,0 +1,118 @@
+/* src/vm/zip.cpp - ZIP file handling for bootstrap classloader
+
+   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 _ZIP_HPP
+#define _ZIP_HPP
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "toolbox/hashtable.h"
+
+#include "vm/class.hpp"
+#include "vm/global.h"
+#include "vm/loader.hpp"
+#include "vm/suck.hpp"
+#include "vm/utf8.h"
+
+
+/* Local file header ***********************************************************
+
+   local file header signature     4 bytes  (0x04034b50)
+   version needed to extract       2 bytes
+   general purpose bit flag        2 bytes
+   compression method              2 bytes
+   last mod file time              2 bytes
+   last mod file date              2 bytes
+   crc-32                          4 bytes
+   compressed size                 4 bytes
+   uncompressed size               4 bytes
+   file name length                2 bytes
+   extra field length              2 bytes
+
+   file name (variable size)
+   extra field (variable size)
+
+*******************************************************************************/
+
+#define LFH_HEADER_SIZE              30
+
+#define LFH_SIGNATURE                0x04034b50
+#define LFH_FILE_NAME_LENGTH         26
+#define LFH_EXTRA_FIELD_LENGTH       28
+
+typedef struct lfh lfh;
+
+struct lfh {
+       u2 compressionmethod;
+       u4 compressedsize;
+       u4 uncompressedsize;
+       u2 filenamelength;
+       u2 extrafieldlength;
+};
+
+/* hashtable_zipfile_entry ****************************************************/
+
+typedef struct hashtable_zipfile_entry hashtable_zipfile_entry;
+
+struct hashtable_zipfile_entry {
+       utf                     *filename;
+       u2                       compressionmethod;
+       u4                       compressedsize;
+       u4                       uncompressedsize;
+       u1                      *data;
+       hashtable_zipfile_entry *hashlink;
+};
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+hashtable *zip_open(char *path);
+hashtable_zipfile_entry *zip_find(list_classpath_entry *lce, utf *u);
+classbuffer *zip_get(list_classpath_entry *lce, classinfo *c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ZIP_HPP */
+
+
+/*
+ * 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:
+ */
diff --git a/src/vmcore/Makefile.am b/src/vmcore/Makefile.am
deleted file mode 100644 (file)
index 1b288f4..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-## src/vmcore/Makefile.am
-##
-## Copyright (C) 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
-##
-## 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.
-
-
-AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR)
-
-LIBS =
-
-if ENABLE_JAVASE
-if ENABLE_ANNOTATIONS
-ANNOTATION_SOURCES = \
-       annotation.c \
-       annotation.h
-endif
-
-STACKMAP_SOURCES = \
-       stackmap.c \
-       stackmap.h
-endif
-
-if ENABLE_RT_TIMING
-RT_TIMING_SOURCES = \
-       rt-timing.c \
-       rt-timing.h
-endif
-
-if ENABLE_STATISTICS
-STATISTICS_SOURCES = \
-       statistics.c \
-       statistics.h
-endif
-
-if ENABLE_ZLIB
-ZLIB_SOURCES = \
-       zip.c \
-       zip.h
-endif
-
-noinst_LTLIBRARIES = \
-       libvmcore.la
-
-libvmcore_la_SOURCES = \
-       $(ANNOTATION_SOURCES) \
-       class.c \
-       class.h \
-       classcache.c \
-       classcache.h \
-       descriptor.c \
-       descriptor.h \
-       field.c \
-       field.h \
-       linker.c \
-       linker.h \
-       loader.c \
-       loader.h \
-       method.c \
-       method.h \
-       options.c \
-       options.h \
-       primitivecore.c \
-       references.h \
-       $(RT_TIMING_SOURCES) \
-       $(STACKMAP_SOURCES) \
-       $(STATISTICS_SOURCES) \
-       suck.c \
-       suck.h \
-       system.c \
-       system.h \
-       utf8.c \
-       utf8.h \
-       $(ZLIB_SOURCES)
-
-
-## Local variables:
-## mode: Makefile
-## indent-tabs-mode: t
-## c-basic-offset: 4
-## tab-width: 8
-## compile-command: "automake --add-missing"
-## End:
diff --git a/src/vmcore/annotation.c b/src/vmcore/annotation.c
deleted file mode 100644 (file)
index 4d7021d..0000000
+++ /dev/null
@@ -1,615 +0,0 @@
-/* src/vmcore/annotation.c - class annotations
-
-   Copyright (C) 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 <stdint.h>
-
-#include "native/llni.h"
-
-#include "vm/types.h"
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/primitive.h"
-
-#include "mm/memory.h"
-
-#include "toolbox/logging.h"
-
-#include "vmcore/annotation.h"
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/suck.h"
-
-#if !defined(ENABLE_ANNOTATIONS)
-# error annotation support has to be enabled when compling this file!
-#endif
-
-
-/* annotation_bytearrays_resize ***********************************************
-
-   Resize an array of bytearrays.
-
-   IN:
-       bytearrays.....array of bytearrays
-       size...........new size of the refered array
-   
-   RETURN VALUE:
-       The new array if a resize was neccessarry, the old if the given size
-       equals the current size or NULL if an error occured.
-
-*******************************************************************************/
-
-static java_handle_objectarray_t *annotation_bytearrays_resize(
-       java_handle_objectarray_t *bytearrays, uint32_t size)
-{
-       java_handle_objectarray_t *newbas = NULL; /* new array     */
-       uint32_t minsize = 0;      /* count of object refs to copy */
-       uint32_t oldsize = 0;      /* size of old array            */
-
-       if (bytearrays != NULL) {
-               oldsize = array_length_get((java_handle_t*)bytearrays);
-               
-               /* if the size already fits do nothing */
-               if (size == oldsize) {
-                       return bytearrays;
-               }
-       }
-       
-       newbas = builtin_anewarray(size,
-               primitive_arrayclass_get_by_type(PRIMITIVETYPE_BYTE));
-       
-       /* is there a old byte array array? */
-       if (newbas != NULL && bytearrays != NULL) {
-               minsize = size < oldsize ? size : oldsize;
-
-               LLNI_CRITICAL_START;
-               MCOPY(
-                       LLNI_array_data(newbas), LLNI_array_data(bytearrays),
-                       java_object_t*, minsize);
-               LLNI_CRITICAL_END;
-       }
-
-       return newbas;
-}
-
-
-/* annotation_bytearrays_insert ***********************************************
-
-   Insert a bytearray into an array of bytearrays.
-
-   IN:
-       bytearrays........array of bytearrays where 'bytearray' has to be
-                         inserted at position 'index'.
-       index.............position where 'ba' has to be inserted into
-                         'bytearrays'.
-       bytearray.........byte array which has to be inserted into
-                         'bytearrays'.
-
-   RETURN VALUE:
-       The new array if a resize was neccessarry, the old if the given size
-       equals the current size or NULL if an error occured.
-
-*******************************************************************************/
-
-static java_handle_t *annotation_bytearrays_insert(
-       java_handle_t *bytearrays, uint32_t index,
-       java_handle_bytearray_t *bytearray)
-{
-       java_handle_objectarray_t *bas; /* bytearrays                */
-       uint32_t size = 0;              /* current size of the array */
-
-       /* do nothing if NULL is inserted but no array exists */
-       if (bytearray == NULL && bytearrays == NULL) {
-               return NULL;
-       }
-
-       /* get lengths if array exists */
-       if (bytearrays != NULL) {
-               size = array_length_get(bytearrays);
-       }
-
-       bas = (java_handle_objectarray_t*)bytearrays;
-
-       if (bytearray == NULL) {
-               /* insert NULL only if array is big enough */
-               if (size > index) {
-                       array_objectarray_element_set(bas, index, NULL);
-               }
-       }
-       else {
-               /* resize array if it's not enough for inserted value */
-               if (size <= index) {
-                       bas = annotation_bytearrays_resize(bas, index + 1);
-
-                       if (bas == NULL) {
-                               /* out of memory */
-                               return NULL;
-                       }
-               }
-
-               array_objectarray_element_set(bas, index, (java_handle_t*)bytearray);
-       }
-       
-       return (java_handle_t*)bas;
-}
-
-
-/* annotation_load_attribute_body *********************************************
-
-   This function loads the body of a generic attribute.
-
-   XXX: Maybe this function should be called loader_load_attribute_body and
-        located in vmcore/loader.c?
-
-   attribute_info {
-       u2 attribute_name_index;
-       u4 attribute_length;
-       u1 info[attribute_length];
-   }
-
-   IN:
-       cb.................classbuffer from which to read the data.
-       errormsg_prefix....prefix for error messages (if any).
-
-   OUT:
-       attribute..........bytearray-pointer which will be set to the read data.
-   
-   RETURN VALUE:
-       true if all went good. false otherwhise.
-
-*******************************************************************************/
-
-static bool annotation_load_attribute_body(classbuffer *cb,
-       java_handle_bytearray_t **attribute, const char *errormsg_prefix)
-{
-       uint32_t                 size = 0;    /* size of the attribute     */
-       java_handle_bytearray_t *ba   = NULL; /* the raw attributes' bytes */
-
-       assert(cb != NULL);
-       assert(attribute != NULL);
-
-       if (!suck_check_classbuffer_size(cb, 4)) {
-               log_println("%s: size missing", errormsg_prefix);
-               return false;
-       }
-
-       /* load attribute_length */
-       size = suck_u4(cb);
-       
-       if (!suck_check_classbuffer_size(cb, size)) {
-               log_println("%s: invalid size", errormsg_prefix);
-               return false;
-       }
-       
-       /* if attribute_length == 0 then NULL is
-        * the right value for this attribute */
-       if (size > 0) {
-               ba = builtin_newarray_byte(size);
-
-               if (ba == NULL) {
-                       /* out of memory */
-                       return false;
-               }
-
-               /* load data */
-               LLNI_CRITICAL_START;
-
-               suck_nbytes((uint8_t*)LLNI_array_data(ba), cb, size);
-
-               LLNI_CRITICAL_END;
-
-               /* return data */
-               *attribute = ba;
-       }
-       
-       return true;
-}
-
-
-/* annotation_load_method_attribute_annotationdefault *************************
-
-   Load annotation default value.
-
-   AnnotationDefault_attribute {
-       u2 attribute_name_index;
-       u4 attribute_length;
-       element_value default_value;
-   }
-
-   IN:
-       cb.................classbuffer from which to read the data.
-       m..................methodinfo for the method of which the annotation
-                          default value is read and into which the value is
-                          stored into.
-
-   RETURN VALUE:
-       true if all went good. false otherwhise.
-
-*******************************************************************************/
-
-bool annotation_load_method_attribute_annotationdefault(
-               classbuffer *cb, methodinfo *m)
-{
-       int                      slot               = 0;
-                                /* the slot of the method                        */
-       java_handle_bytearray_t *annotationdefault  = NULL;
-                                /* unparsed annotation defalut value             */
-       java_handle_t           *annotationdefaults = NULL;
-                                /* array of unparsed annotation default values   */
-
-       assert(cb != NULL);
-       assert(m != NULL);
-
-       LLNI_classinfo_field_get(
-               m->clazz, method_annotationdefaults, annotationdefaults);
-
-       if (!annotation_load_attribute_body(
-                       cb, &annotationdefault,
-                       "invalid annotation default method attribute")) {
-               return false;
-       }
-
-       if (annotationdefault != NULL) {
-               slot = m - m->clazz->methods;
-               annotationdefaults = annotation_bytearrays_insert(
-                               annotationdefaults, slot, annotationdefault);
-
-               if (annotationdefaults == NULL) {
-                       return false;
-               }
-
-               LLNI_classinfo_field_set(
-                       m->clazz, method_annotationdefaults, annotationdefaults);
-       }
-
-       return true;
-}
-
-
-/* annotation_load_method_attribute_runtimevisibleparameterannotations ********
-
-   Load runtime visible parameter annotations.
-
-   RuntimeVisibleParameterAnnotations_attribute {
-       u2 attribute_name_index;
-       u4 attribute_length;
-       u1 num_parameters;
-       {
-           u2 num_annotations;
-           annotation annotations[num_annotations];
-       } parameter_annotations[num_parameters];
-   }
-
-   IN:
-       cb.................classbuffer from which to read the data.
-       m..................methodinfo for the method of which the parameter
-                          annotations are read and into which the parameter
-                          annotations are stored into.
-
-   RETURN VALUE:
-       true if all went good. false otherwhise.
-
-*******************************************************************************/
-
-bool annotation_load_method_attribute_runtimevisibleparameterannotations(
-               classbuffer *cb, methodinfo *m)
-{
-       int                      slot                 = 0;
-                                /* the slot of the method                  */
-       java_handle_bytearray_t *annotations          = NULL;
-                                /* unparsed parameter annotations          */
-       java_handle_t           *parameterannotations = NULL;
-                                /* array of unparsed parameter annotations */
-
-       assert(cb != NULL);
-       assert(m != NULL);
-
-       LLNI_classinfo_field_get(
-               m->clazz, method_parameterannotations, parameterannotations);
-
-       if (!annotation_load_attribute_body(
-                       cb, &annotations,
-                       "invalid runtime visible parameter annotations method attribute")) {
-               return false;
-       }
-
-       if (annotations != NULL) {
-               slot = m - m->clazz->methods;
-               parameterannotations = annotation_bytearrays_insert(
-                               parameterannotations, slot, annotations);
-
-               if (parameterannotations == NULL) {
-                       return false;
-               }
-
-               LLNI_classinfo_field_set(
-                       m->clazz, method_parameterannotations, parameterannotations);
-       }
-
-       return true;
-}
-
-
-/* annotation_load_method_attribute_runtimeinvisibleparameterannotations ******
-   Load runtime invisible parameter annotations.
-
-   <quote cite="http://jcp.org/en/jsr/detail?id=202">
-   The RuntimeInvisibleParameterAnnotations attribute is similar to the
-   RuntimeVisibleParameterAnnotations attribute, except that the annotations
-   represented by a RuntimeInvisibleParameterAnnotations attribute must not be
-   made available for return by reflective APIs, unless the the JVM has
-   specifically been instructed to retain these annotations via some
-   implementation-specific mechanism such as a command line flag. In the
-   absence of such instructions, the JVM ignores this attribute.
-   </quote>
-
-   Hotspot loads them into the same bytearray as the runtime visible parameter
-   annotations (after the runtime visible parameter annotations). But in J2SE
-   the bytearray will only be parsed as if there is only one annotation
-   structure in it, so the runtime invisible parameter annotatios will be
-   ignored.
-
-   Therefore I do not even bother to read them.
-
-   RuntimeInvisibleParameterAnnotations_attribute {
-       u2 attribute_name_index;
-       u4 attribute_length;
-       u1 num_parameters;
-       {
-           u2 num_annotations;
-           annotation annotations[num_annotations];
-       } parameter_annotations[num_parameters];
-   }
-
-   IN:
-       cb.................classbuffer from which to read the data.
-       m..................methodinfo for the method of which the parameter
-                          annotations are read and into which the parameter
-                          annotations are stored into.
-
-   RETURN VALUE:
-       true if all went good. false otherwhise.
-
-*******************************************************************************/
-
-bool annotation_load_method_attribute_runtimeinvisibleparameterannotations(
-               classbuffer *cb, methodinfo *m)
-{
-       return loader_skip_attribute_body(cb);
-}
-
-
-/* annotation_load_class_attribute_runtimevisibleannotations ******************
-   
-   Load runtime visible annotations of a class.
-   
-   IN:
-       cb........the classbuffer from which the attribute has to be loaded.
-
-   RETURN VALUE:
-       true if all went good. false otherwhise.
-
-*******************************************************************************/
-
-bool annotation_load_class_attribute_runtimevisibleannotations(
-       classbuffer *cb)
-{
-       java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
-       
-       if (!annotation_load_attribute_body(
-                       cb, &annotations,
-                       "invalid runtime visible annotations class attribute")) {
-               return false;
-       }
-
-       LLNI_classinfo_field_set(cb->clazz, annotations, (java_handle_t*)annotations);
-
-       return true;
-}
-
-
-/* annotation_load_class_attribute_runtimeinvisibleannotations ****************
-   
-   Load runtime invisible annotations of a class (just skip them).
-   
-   IN:
-       cb........the classbuffer from which the attribute has to be loaded.
-
-   RETURN VALUE:
-       true if all went good. false otherwhise.
-
-*******************************************************************************/
-
-bool annotation_load_class_attribute_runtimeinvisibleannotations(
-       classbuffer *cb)
-{
-       return loader_skip_attribute_body(cb);
-}
-
-
-/* annotation_load_method_attribute_runtimevisibleannotations *****************
-   
-   Load runtime visible annotations of a method.
-  
-   IN:
-       cb........the classbuffer from which the attribute has to be loaded.
-       m.........the method of which the runtime visible annotations have
-                 to be loaded.
-
-   RETURN VALUE:
-       true if all went good. false otherwhise.
-
-*******************************************************************************/
-
-bool annotation_load_method_attribute_runtimevisibleannotations(
-       classbuffer *cb, methodinfo *m)
-{
-       int                      slot               = 0;
-                                /* slot of the method */
-       java_handle_bytearray_t *annotations        = NULL;
-                                /* unparsed annotations */
-       java_handle_t           *method_annotations = NULL;
-                                /* array of unparsed method annotations */
-
-       assert(cb != NULL);
-       assert(m != NULL);
-
-       LLNI_classinfo_field_get(
-               m->clazz, method_annotations, method_annotations);
-
-       if (!annotation_load_attribute_body(
-                       cb, &annotations,
-                       "invalid runtime visible annotations method attribute")) {
-               return false;
-       }
-
-       if (annotations != NULL) {
-               slot = m - m->clazz->methods;
-               method_annotations = annotation_bytearrays_insert(
-                               method_annotations, slot, annotations);
-
-               if (method_annotations == NULL) {
-                       return false;
-               }
-               
-               LLNI_classinfo_field_set(
-                       m->clazz, method_annotations, method_annotations);
-       }
-
-       return true;
-}
-
-
-/* annotation_load_method_attribute_runtimeinvisibleannotations ****************
-   
-   Load runtime invisible annotations of a method (just skip them).
-   
-   IN:
-       cb........the classbuffer from which the attribute has to be loaded.
-       m.........the method of which the runtime invisible annotations have
-                 to be loaded.
-
-   RETURN VALUE:
-       true if all went good. false otherwhise.
-
-*******************************************************************************/
-
-bool annotation_load_method_attribute_runtimeinvisibleannotations(
-       classbuffer *cb, methodinfo *m)
-{
-       return loader_skip_attribute_body(cb);
-}
-
-
-/* annotation_load_field_attribute_runtimevisibleannotations ******************
-   
-   Load runtime visible annotations of a field.
-   
-   IN:
-       cb........the classbuffer from which the attribute has to be loaded.
-       f.........the field of which the runtime visible annotations have
-                 to be loaded.
-
-   RETURN VALUE:
-       true if all went good. false otherwhise.
-
-*******************************************************************************/
-
-bool annotation_load_field_attribute_runtimevisibleannotations(
-       classbuffer *cb, fieldinfo *f)
-{
-       int                      slot              = 0;
-                                /* slot of the field                   */
-       java_handle_bytearray_t *annotations       = NULL;
-                                /* unparsed annotations                */
-       java_handle_t           *field_annotations = NULL;
-                                /* array of unparsed field annotations */
-
-       assert(cb != NULL);
-       assert(f != NULL);
-
-       LLNI_classinfo_field_get(
-               f->clazz, field_annotations, field_annotations);
-
-       if (!annotation_load_attribute_body(
-                       cb, &annotations,
-                       "invalid runtime visible annotations field attribute")) {
-               return false;
-       }
-
-       if (annotations != NULL) {
-               slot = f - f->clazz->fields;
-               field_annotations = annotation_bytearrays_insert(
-                               field_annotations, slot, annotations);
-
-               if (field_annotations == NULL) {
-                       return false;
-               }
-
-               LLNI_classinfo_field_set(
-                       f->clazz, field_annotations, field_annotations);
-       }
-
-       return true;
-}
-
-
-/* annotation_load_field_attribute_runtimeinvisibleannotations ****************
-   
-   Load runtime invisible annotations of a field (just skip them).
-   
-   IN:
-       cb........the classbuffer from which the attribute has to be loaded.
-       f.........the field of which the runtime invisible annotations have
-                 to be loaded.
-
-   RETURN VALUE:
-       true if all went good. false otherwhise.
-
-*******************************************************************************/
-
-bool annotation_load_field_attribute_runtimeinvisibleannotations(
-       classbuffer *cb, fieldinfo *f)
-{
-       return loader_skip_attribute_body(cb);
-}
-
-
-/*
- * 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/vmcore/annotation.h b/src/vmcore/annotation.h
deleted file mode 100644 (file)
index 7ec071d..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* src/vmcore/annotation.h - class annotations
-
-   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
-
-   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 _ANNOTATION_H
-#define _ANNOTATION_H
-
-
-#include "config.h"
-
-#include "vm/types.h"
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-
-
-/* function prototypes ********************************************************/
-
-bool annotation_load_class_attribute_runtimevisibleannotations(
-       classbuffer *cb);
-
-bool annotation_load_class_attribute_runtimeinvisibleannotations(
-       classbuffer *cb);
-
-bool annotation_load_method_attribute_runtimevisibleannotations(
-       classbuffer *cb, methodinfo *m);
-
-bool annotation_load_method_attribute_runtimeinvisibleannotations(
-       classbuffer *cb, methodinfo *m);
-
-bool annotation_load_field_attribute_runtimevisibleannotations(
-       classbuffer *cb, fieldinfo *f);
-
-bool annotation_load_field_attribute_runtimeinvisibleannotations(
-       classbuffer *cb, fieldinfo *f);
-
-bool annotation_load_method_attribute_annotationdefault(
-       classbuffer *cb, methodinfo *m);
-
-bool annotation_load_method_attribute_runtimevisibleparameterannotations(
-       classbuffer *cb, methodinfo *m);
-
-bool annotation_load_method_attribute_runtimeinvisibleparameterannotations(
-       classbuffer *cb, methodinfo *m);
-
-#endif /* _ANNOTATION_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/vmcore/class.c b/src/vmcore/class.c
deleted file mode 100644 (file)
index 983339f..0000000
+++ /dev/null
@@ -1,2601 +0,0 @@
-/* src/vmcore/class.c - class 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "arch.h"
-
-#include "mm/memory.h"
-
-#include "native/llni.h"
-
-#include "threads/lock-common.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/resolve.h"
-
-#include "vm/jit/asmpart.h"
-
-#include "vmcore/class.h"
-#include "vmcore/classcache.h"
-#include "vmcore/linker.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
-#include "vmcore/suck.h"
-#include "vmcore/utf8.h"
-
-
-#if defined(ENABLE_JAVASE)
-/* We need to define some reflection functions here since we cannot
-   include native/vm/reflect.h as it includes generated header
-   files. */
-
-java_object_t *reflect_constructor_new(methodinfo *m);
-java_object_t *reflect_field_new(fieldinfo *f);
-java_object_t *reflect_method_new(methodinfo *m);
-#endif
-
-
-/* global variables ***********************************************************/
-
-/* frequently used classes ****************************************************/
-
-/* Important system classes. */
-
-classinfo *class_java_lang_Object;
-classinfo *class_java_lang_Class;
-classinfo *class_java_lang_ClassLoader;
-classinfo *class_java_lang_Cloneable;
-classinfo *class_java_lang_SecurityManager;
-classinfo *class_java_lang_String;
-classinfo *class_java_lang_System;
-classinfo *class_java_lang_Thread;
-classinfo *class_java_lang_ThreadGroup;
-classinfo *class_java_lang_Throwable;
-classinfo *class_java_io_Serializable;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-classinfo *class_java_lang_VMSystem;
-classinfo *class_java_lang_VMThread;
-classinfo *class_java_lang_VMThrowable;
-#endif
-
-/* Important system exceptions. */
-
-classinfo *class_java_lang_Exception;
-classinfo *class_java_lang_ClassNotFoundException;
-classinfo *class_java_lang_RuntimeException;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-classinfo *class_sun_reflect_MagicAccessorImpl;
-#endif
-
-#if defined(ENABLE_JAVASE)
-classinfo *class_java_lang_Void;
-#endif
-classinfo *class_java_lang_Boolean;
-classinfo *class_java_lang_Byte;
-classinfo *class_java_lang_Character;
-classinfo *class_java_lang_Short;
-classinfo *class_java_lang_Integer;
-classinfo *class_java_lang_Long;
-classinfo *class_java_lang_Float;
-classinfo *class_java_lang_Double;
-
-/* some classes which may be used more often */
-
-#if defined(ENABLE_JAVASE)
-classinfo *class_java_lang_StackTraceElement;
-classinfo *class_java_lang_reflect_Constructor;
-classinfo *class_java_lang_reflect_Field;
-classinfo *class_java_lang_reflect_Method;
-classinfo *class_java_security_PrivilegedAction;
-classinfo *class_java_util_Vector;
-classinfo *class_java_util_HashMap;
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-classinfo *class_java_lang_reflect_VMConstructor;
-classinfo *class_java_lang_reflect_VMField;
-classinfo *class_java_lang_reflect_VMMethod;
-# endif
-
-classinfo *arrayclass_java_lang_Object;
-
-# if defined(ENABLE_ANNOTATIONS)
-classinfo *class_sun_reflect_ConstantPool;
-#  if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-classinfo *class_sun_reflect_annotation_AnnotationParser;
-#  endif
-# endif
-#endif
-
-/* pseudo classes for the typechecker */
-
-classinfo *pseudo_class_Arraystub;
-classinfo *pseudo_class_Null;
-classinfo *pseudo_class_New;
-
-
-/* class_set_packagename *******************************************************
-
-   Derive the package name from the class name and store it in the
-   struct.
-
-   An internal package name consists of the package name plus the
-   trailing '/', e.g. "java/lang/".
-
-   For classes in the unnamed package, the package name is set to
-   NULL.
-
-*******************************************************************************/
-
-void class_set_packagename(classinfo *c)
-{
-       char *p;
-       char *start;
-
-       p     = UTF_END(c->name) - 1;
-       start = c->name->text;
-
-       if (c->name->text[0] == '[') {
-               /* Set packagename of arrays to the element's package. */
-
-               for (; *start == '['; start++);
-
-               /* Skip the 'L' in arrays of references. */
-
-               if (*start == 'L')
-                       start++;
-       }
-
-       /* Search for last '/'. */
-
-       for (; (p > start) && (*p != '/'); --p);
-
-       /* If we found a '/' we set the package name plus the trailing
-          '/'.  Otherwise we set the packagename to NULL. */
-
-       if (p > start)
-               c->packagename = utf_new(start, p - start + 1);
-       else
-               c->packagename = NULL;
-}
-
-
-/* class_create_classinfo ******************************************************
-
-   Create a new classinfo struct. The class name is set to the given utf *,
-   most other fields are initialized to zero.
-
-   Note: classname may be NULL. In this case a not-yet-named classinfo is
-         created. The name must be filled in later and class_set_packagename
-                must be called after that.
-
-*******************************************************************************/
-
-classinfo *class_create_classinfo(utf *classname)
-{
-       classinfo *c;
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_classinfo += sizeof(classinfo);
-#endif
-
-       /* we use a safe name for temporarily unnamed classes */
-
-       if (classname == NULL)
-               classname = utf_not_named_yet;
-
-#if !defined(NDEBUG)
-       if (initverbose)
-               log_message_utf("Creating class: ", classname);
-#endif
-
-#if !defined(ENABLE_GC_BOEHM)
-       c = (classinfo *) heap_alloc_uncollectable(sizeof(classinfo));
-       /*c = NEW(classinfo);
-       MZERO(c, classinfo, 1);*/
-#else
-       c = GCNEW_UNCOLLECTABLE(classinfo, 1);
-       /* GCNEW_UNCOLLECTABLE clears the allocated memory */
-#endif
-
-       c->name = classname;
-
-       /* Set the header.vftbl of all loaded classes to the one of
-       java.lang.Class, so Java code can use a class as object. */
-
-       if (class_java_lang_Class != NULL)
-               if (class_java_lang_Class->vftbl != NULL)
-                       c->object.header.vftbl = class_java_lang_Class->vftbl;
-
-#if defined(ENABLE_JAVASE)
-       /* check if the class is a reference class and flag it */
-
-       if (classname == utf_java_lang_ref_SoftReference) {
-               c->flags |= ACC_CLASS_REFERENCE_SOFT;
-       }
-       else if (classname == utf_java_lang_ref_WeakReference) {
-               c->flags |= ACC_CLASS_REFERENCE_WEAK;
-       }
-       else if (classname == utf_java_lang_ref_PhantomReference) {
-               c->flags |= ACC_CLASS_REFERENCE_PHANTOM;
-       }
-#endif
-
-       if (classname != utf_not_named_yet)
-               class_set_packagename(c);
-
-       LOCK_INIT_OBJECT_LOCK(&c->object.header);
-
-       return c;
-}
-
-
-/* class_postset_header_vftbl **************************************************
-
-   Set the header.vftbl of all classes created before java.lang.Class
-   was linked.  This is necessary that Java code can use a class as
-   object.
-
-*******************************************************************************/
-
-void class_postset_header_vftbl(void)
-{
-       classinfo *c;
-       u4 slot;
-       classcache_name_entry *nmen;
-       classcache_class_entry *clsen;
-
-       assert(class_java_lang_Class);
-
-       for (slot = 0; slot < hashtable_classcache.size; slot++) {
-               nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
-
-               for (; nmen; nmen = nmen->hashlink) {
-                       /* iterate over all class entries */
-
-                       for (clsen = nmen->classes; clsen; clsen = clsen->next) {
-                               c = clsen->classobj;
-
-                               /* now set the the vftbl */
-
-                               if (c->object.header.vftbl == NULL)
-                                       c->object.header.vftbl = class_java_lang_Class->vftbl;
-                       }
-               }
-       }
-}
-
-/* class_define ****************************************************************
-
-   Calls the loader and defines a class in the VM.
-
-*******************************************************************************/
-
-classinfo *class_define(utf *name, classloader_t *cl, int32_t length, uint8_t *data, java_handle_t *pd)
-{
-       classinfo   *c;
-       classinfo   *r;
-       classbuffer *cb;
-
-       if (name != NULL) {
-               /* check if this class has already been defined */
-
-               c = classcache_lookup_defined_or_initiated(cl, name);
-
-               if (c != NULL) {
-                       exceptions_throw_linkageerror("duplicate class definition: ", c);
-                       return NULL;
-               }
-       } 
-
-       /* create a new classinfo struct */
-
-       c = class_create_classinfo(name);
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getloadingtime)
-               loadingtime_start();
-#endif
-
-       /* build a classbuffer with the given data */
-
-       cb = NEW(classbuffer);
-
-       cb->clazz = c;
-       cb->size  = length;
-       cb->data  = data;
-       cb->pos   = cb->data;
-
-       /* preset the defining classloader */
-
-       c->classloader = cl;
-
-       /* load the class from this buffer */
-
-       r = load_class_from_classbuffer(cb);
-
-       /* free memory */
-
-       FREE(cb, classbuffer);
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getloadingtime)
-               loadingtime_stop();
-#endif
-
-       if (r == NULL) {
-               /* If return value is NULL, we had a problem and the class is
-                  not loaded.  Now free the allocated memory, otherwise we
-                  could run into a DOS. */
-
-               class_free(c);
-
-               return NULL;
-       }
-
-#if defined(ENABLE_JAVASE)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       /* Store the protection domain. */
-
-       c->protectiondomain = pd;
-# endif
-#endif
-
-       /* Store the newly defined class in the class cache. This call
-          also checks whether a class of the same name has already been
-          defined by the same defining loader, and if so, replaces the
-          newly created class by the one defined earlier. */
-
-       /* Important: The classinfo given to classcache_store must be
-                     fully prepared because another thread may return
-                     this pointer after the lookup at to top of this
-                     function directly after the class cache lock has
-                     been released. */
-
-       c = classcache_store(cl, c, true);
-
-       return c;
-}
-
-
-/* class_load_attribute_sourcefile *********************************************
-
-   SourceFile_attribute {
-       u2 attribute_name_index;
-       u4 attribute_length;
-          u2 sourcefile_index;
-   }
-
-*******************************************************************************/
-
-static bool class_load_attribute_sourcefile(classbuffer *cb)
-{
-       classinfo *c;
-       u4         attribute_length;
-       u2         sourcefile_index;
-       utf       *sourcefile;
-
-       /* get classinfo */
-
-       c = cb->clazz;
-
-       /* check buffer size */
-
-       if (!suck_check_classbuffer_size(cb, 4 + 2))
-               return false;
-
-       /* check attribute length */
-
-       attribute_length = suck_u4(cb);
-
-       if (attribute_length != 2) {
-               exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute");
-               return false;
-       }
-
-       /* there can be no more than one SourceFile attribute */
-
-       if (c->sourcefile != NULL) {
-               exceptions_throw_classformaterror(c, "Multiple SourceFile attributes");
-               return false;
-       }
-
-       /* get sourcefile */
-
-       sourcefile_index = suck_u2(cb);
-       sourcefile = class_getconstant(c, sourcefile_index, CONSTANT_Utf8);
-
-       if (sourcefile == NULL)
-               return false;
-
-       /* store sourcefile */
-
-       c->sourcefile = sourcefile;
-
-       return true;
-}
-
-
-/* class_load_attribute_enclosingmethod ****************************************
-
-   EnclosingMethod_attribute {
-       u2 attribute_name_index;
-       u4 attribute_length;
-          u2 class_index;
-          u2 method_index;
-   }
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-static bool class_load_attribute_enclosingmethod(classbuffer *cb)
-{
-       classinfo             *c;
-       u4                     attribute_length;
-       u2                     class_index;
-       u2                     method_index;
-       classref_or_classinfo  cr;
-       constant_nameandtype  *cn;
-
-       /* get classinfo */
-
-       c = cb->clazz;
-
-       /* check buffer size */
-
-       if (!suck_check_classbuffer_size(cb, 4 + 2 + 2))
-               return false;
-
-       /* check attribute length */
-
-       attribute_length = suck_u4(cb);
-
-       if (attribute_length != 4) {
-               exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute");
-               return false;
-       }
-
-       /* there can be no more than one EnclosingMethod attribute */
-
-       if (c->enclosingmethod != NULL) {
-               exceptions_throw_classformaterror(c, "Multiple EnclosingMethod attributes");
-               return false;
-       }
-
-       /* get class index */
-
-       class_index = suck_u2(cb);
-       cr.ref = innerclass_getconstant(c, class_index, CONSTANT_Class);
-
-       /* get method index */
-
-       method_index = suck_u2(cb);
-       cn = innerclass_getconstant(c, method_index, CONSTANT_NameAndType);
-
-       /* store info in classinfo */
-
-       c->enclosingclass.any = cr.any;
-       c->enclosingmethod    = cn;
-
-       return true;
-}
-#endif /* defined(ENABLE_JAVASE) */
-
-
-/* class_load_attributes *******************************************************
-
-   Read attributes from ClassFile.
-
-   attribute_info {
-       u2 attribute_name_index;
-       u4 attribute_length;
-       u1 info[attribute_length];
-   }
-
-   InnerClasses_attribute {
-       u2 attribute_name_index;
-       u4 attribute_length;
-   }
-
-*******************************************************************************/
-
-bool class_load_attributes(classbuffer *cb)
-{
-       classinfo             *c;
-       uint16_t               attributes_count;
-       uint16_t               attribute_name_index;
-       utf                   *attribute_name;
-       innerclassinfo        *info;
-       classref_or_classinfo  inner;
-       classref_or_classinfo  outer;
-       utf                   *name;
-       uint16_t               flags;
-       int                    i, j;
-
-       c = cb->clazz;
-
-       /* get attributes count */
-
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       attributes_count = suck_u2(cb);
-
-       for (i = 0; i < attributes_count; i++) {
-               /* get attribute name */
-
-               if (!suck_check_classbuffer_size(cb, 2))
-                       return false;
-
-               attribute_name_index = suck_u2(cb);
-               attribute_name =
-                       class_getconstant(c, attribute_name_index, CONSTANT_Utf8);
-
-               if (attribute_name == NULL)
-                       return false;
-
-               if (attribute_name == utf_InnerClasses) {
-                       /* InnerClasses */
-
-                       if (c->innerclass != NULL) {
-                               exceptions_throw_classformaterror(c, "Multiple InnerClasses attributes");
-                               return false;
-                       }
-                               
-                       if (!suck_check_classbuffer_size(cb, 4 + 2))
-                               return false;
-
-                       /* skip attribute length */
-                       suck_u4(cb);
-
-                       /* number of records */
-                       c->innerclasscount = suck_u2(cb);
-
-                       if (!suck_check_classbuffer_size(cb, (2 + 2 + 2 + 2) * c->innerclasscount))
-                               return false;
-
-                       /* allocate memory for innerclass structure */
-                       c->innerclass = MNEW(innerclassinfo, c->innerclasscount);
-
-                       for (j = 0; j < c->innerclasscount; j++) {
-                               /* The innerclass structure contains a class with an encoded
-                                  name, its defining scope, its simple name and a bitmask of
-                                  the access flags. */
-                                                               
-                               info = c->innerclass + j;
-
-                               inner.ref = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class);
-                               outer.ref = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class);
-                               name      = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Utf8);
-                               flags     = suck_u2(cb);
-
-                               /* If the current inner-class is the currently loaded
-                                  class check for some special flags. */
-
-                               if (inner.ref->name == c->name) {
-                                       /* If an inner-class is not a member, its
-                                          outer-class is NULL. */
-
-                                       if (outer.ref != NULL) {
-                                               c->flags |= ACC_CLASS_MEMBER;
-
-                                               /* A member class doesn't have an
-                                                  EnclosingMethod attribute, so set the
-                                                  enclosing-class to be the same as the
-                                                  declaring-class. */
-
-                                               c->declaringclass = outer;
-                                               c->enclosingclass = outer;
-                                       }
-
-                                       /* If an inner-class is anonymous, its name is
-                                          NULL. */
-
-                                       if (name == NULL)
-                                               c->flags |= ACC_CLASS_ANONYMOUS;
-                               }
-
-                               info->inner_class = inner;
-                               info->outer_class = outer;
-                               info->name        = name;
-                               info->flags       = flags;
-                       }
-               }
-               else if (attribute_name == utf_SourceFile) {
-                       /* SourceFile */
-
-                       if (!class_load_attribute_sourcefile(cb))
-                               return false;
-               }
-#if defined(ENABLE_JAVASE)
-               else if (attribute_name == utf_EnclosingMethod) {
-                       /* EnclosingMethod */
-
-                       if (!class_load_attribute_enclosingmethod(cb))
-                               return false;
-               }
-               else if (attribute_name == utf_Signature) {
-                       /* Signature */
-
-                       if (!loader_load_attribute_signature(cb, &(c->signature)))
-                               return false;
-               }
-#endif
-
-#if defined(ENABLE_ANNOTATIONS)
-               else if (attribute_name == utf_RuntimeVisibleAnnotations) {
-                       /* RuntimeVisibleAnnotations */
-                       if (!annotation_load_class_attribute_runtimevisibleannotations(cb))
-                               return false;
-               }
-               else if (attribute_name == utf_RuntimeInvisibleAnnotations) {
-                       /* RuntimeInvisibleAnnotations */
-                       if (!annotation_load_class_attribute_runtimeinvisibleannotations(cb))
-                               return false;
-               }
-#endif
-
-               else {
-                       /* unknown attribute */
-
-                       if (!loader_skip_attribute_body(cb))
-                               return false;
-               }
-       }
-
-       return true;
-}
-
-
-/* class_freepool **************************************************************
-
-       Frees all resources used by this classes Constant Pool.
-
-*******************************************************************************/
-
-static void class_freecpool(classinfo *c)
-{
-       u4 idx;
-       u4 tag;
-       voidptr info;
-       
-       if (c->cptags && c->cpinfos) {
-               for (idx = 0; idx < c->cpcount; idx++) {
-                       tag = c->cptags[idx];
-                       info = c->cpinfos[idx];
-               
-                       if (info != NULL) {
-                               switch (tag) {
-                               case CONSTANT_Fieldref:
-                               case CONSTANT_Methodref:
-                               case CONSTANT_InterfaceMethodref:
-                                       FREE(info, constant_FMIref);
-                                       break;
-                               case CONSTANT_Integer:
-                                       FREE(info, constant_integer);
-                                       break;
-                               case CONSTANT_Float:
-                                       FREE(info, constant_float);
-                                       break;
-                               case CONSTANT_Long:
-                                       FREE(info, constant_long);
-                                       break;
-                               case CONSTANT_Double:
-                                       FREE(info, constant_double);
-                                       break;
-                               case CONSTANT_NameAndType:
-                                       FREE(info, constant_nameandtype);
-                                       break;
-                               }
-                       }
-               }
-       }
-
-       if (c->cptags)
-               MFREE(c->cptags, u1, c->cpcount);
-
-       if (c->cpinfos)
-               MFREE(c->cpinfos, voidptr, c->cpcount);
-}
-
-
-/* class_getconstant ***********************************************************
-
-   Retrieves the value at position 'pos' of the constantpool of a
-   class. If the type of the value is other than 'ctype', an error is
-   thrown.
-
-*******************************************************************************/
-
-voidptr class_getconstant(classinfo *c, u4 pos, u4 ctype)
-{
-       /* check index and type of constantpool entry */
-       /* (pos == 0 is caught by type comparison) */
-
-       if ((pos >= c->cpcount) || (c->cptags[pos] != ctype)) {
-               exceptions_throw_classformaterror(c, "Illegal constant pool index");
-               return NULL;
-       }
-
-       return c->cpinfos[pos];
-}
-
-
-/* innerclass_getconstant ******************************************************
-
-   Like class_getconstant, but if cptags is ZERO, null is returned.
-       
-*******************************************************************************/
-
-voidptr innerclass_getconstant(classinfo *c, u4 pos, u4 ctype)
-{
-       /* invalid position in constantpool */
-
-       if (pos >= c->cpcount) {
-               exceptions_throw_classformaterror(c, "Illegal constant pool index");
-               return NULL;
-       }
-
-       /* constantpool entry of type 0 */      
-
-       if (c->cptags[pos] == 0)
-               return NULL;
-
-       /* check type of constantpool entry */
-
-       if (c->cptags[pos] != ctype) {
-               exceptions_throw_classformaterror(c, "Illegal constant pool index");
-               return NULL;
-       }
-               
-       return c->cpinfos[pos];
-}
-
-
-/* class_free ******************************************************************
-
-   Frees all resources used by the class.
-
-*******************************************************************************/
-
-void class_free(classinfo *c)
-{
-       s4 i;
-       vftbl_t *v;
-
-       class_freecpool(c);
-
-       if (c->interfaces != NULL)
-               MFREE(c->interfaces, classinfo*, c->interfacescount);
-
-       if (c->fields) {
-               for (i = 0; i < c->fieldscount; i++)
-                       field_free(&(c->fields[i]));
-               MFREE(c->fields, fieldinfo, c->fieldscount);
-       }
-       
-       if (c->methods) {
-               for (i = 0; i < c->methodscount; i++)
-                       method_free(&(c->methods[i]));
-               MFREE(c->methods, methodinfo, c->methodscount);
-       }
-
-       if ((v = c->vftbl) != NULL) {
-               if (v->arraydesc)
-                       mem_free(v->arraydesc,sizeof(arraydescriptor));
-               
-               for (i = 0; i < v->interfacetablelength; i++) {
-                       MFREE(v->interfacetable[-i], methodptr, v->interfacevftbllength[i]);
-               }
-               MFREE(v->interfacevftbllength, s4, v->interfacetablelength);
-
-               i = sizeof(vftbl_t) + sizeof(methodptr) * (v->vftbllength - 1) +
-                   sizeof(methodptr*) * (v->interfacetablelength -
-                                        (v->interfacetablelength > 0));
-               v = (vftbl_t*) (((methodptr*) v) -
-                                               (v->interfacetablelength - 1) * (v->interfacetablelength > 1));
-               mem_free(v, i);
-       }
-
-       if (c->innerclass)
-               MFREE(c->innerclass, innerclassinfo, c->innerclasscount);
-
-       /*      if (c->classvftbl)
-               mem_free(c->header.vftbl, sizeof(vftbl) + sizeof(methodptr)*(c->vftbl->vftbllength-1)); */
-       
-/*     GCFREE(c); */
-}
-
-
-/* get_array_class *************************************************************
-
-   Returns the array class with the given name for the given
-   classloader, or NULL if an exception occurred.
-
-   Note: This function does eager loading. 
-
-*******************************************************************************/
-
-static classinfo *get_array_class(utf *name,classloader_t *initloader,
-                                                                                       classloader_t *defloader,bool link)
-{
-       classinfo *c;
-       
-       /* lookup this class in the classcache */
-       c = classcache_lookup(initloader,name);
-       if (!c)
-               c = classcache_lookup_defined(defloader,name);
-
-       if (!c) {
-               /* we have to create it */
-               c = class_create_classinfo(name);
-               c = load_newly_created_array(c,initloader);
-               if (c == NULL)
-                       return NULL;
-       }
-
-       assert(c);
-       assert(c->state & CLASS_LOADED);
-       assert(c->classloader == defloader);
-
-       if (link && !(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return NULL;
-
-       assert(!link || (c->state & CLASS_LINKED));
-
-       return c;
-}
-
-
-/* class_array_of **************************************************************
-
-   Returns an array class with the given component class. The array
-   class is dynamically created if neccessary.
-
-*******************************************************************************/
-
-classinfo *class_array_of(classinfo *component, bool link)
-{
-       classloader_t     *cl;
-    s4                 namelen;
-    char              *namebuf;
-       utf               *u;
-       classinfo         *c;
-       int32_t            dumpmarker;
-
-       cl = component->classloader;
-
-       DMARKER;
-
-    /* Assemble the array class name */
-    namelen = component->name->blength;
-    
-    if (component->name->text[0] == '[') {
-        /* the component is itself an array */
-        namebuf = DMNEW(char, namelen + 1);
-        namebuf[0] = '[';
-        MCOPY(namebuf + 1, component->name->text, char, namelen);
-        namelen++;
-    }
-       else {
-        /* the component is a non-array class */
-        namebuf = DMNEW(char, namelen + 3);
-        namebuf[0] = '[';
-        namebuf[1] = 'L';
-        MCOPY(namebuf + 2, component->name->text, char, namelen);
-        namebuf[2 + namelen] = ';';
-        namelen += 3;
-    }
-
-       u = utf_new(namebuf, namelen);
-
-       c = get_array_class(u, cl, cl, link);
-
-       DRELEASE;
-
-       return c;
-}
-
-
-/* class_multiarray_of *********************************************************
-
-   Returns an array class with the given dimension and element class.
-   The array class is dynamically created if neccessary.
-
-*******************************************************************************/
-
-classinfo *class_multiarray_of(s4 dim, classinfo *element, bool link)
-{
-    s4 namelen;
-    char *namebuf;
-       classinfo *c;
-       int32_t    dumpmarker;
-
-       DMARKER;
-
-       if (dim < 1) {
-               log_text("Invalid array dimension requested");
-               assert(0);
-       }
-
-    /* Assemble the array class name */
-    namelen = element->name->blength;
-    
-    if (element->name->text[0] == '[') {
-        /* the element is itself an array */
-        namebuf = DMNEW(char, namelen + dim);
-        memcpy(namebuf + dim, element->name->text, namelen);
-        namelen += dim;
-    }
-    else {
-        /* the element is a non-array class */
-        namebuf = DMNEW(char, namelen + 2 + dim);
-        namebuf[dim] = 'L';
-        memcpy(namebuf + dim + 1, element->name->text, namelen);
-        namelen += (2 + dim);
-        namebuf[namelen - 1] = ';';
-    }
-       memset(namebuf, '[', dim);
-
-       c = get_array_class(utf_new(namebuf, namelen),
-                                               element->classloader,
-                                               element->classloader,
-                                               link);
-
-       DRELEASE;
-
-       return c;
-}
-
-
-/* class_lookup_classref *******************************************************
-
-   Looks up the constant_classref for a given classname in the classref
-   tables of a class.
-
-   IN:
-       cls..............the class containing the reference
-          name.............the name of the class refered to
-
-    RETURN VALUE:
-          a pointer to a constant_classref, or 
-          NULL if the reference was not found
-   
-*******************************************************************************/
-
-constant_classref *class_lookup_classref(classinfo *cls, utf *name)
-{
-       constant_classref *ref;
-       extra_classref *xref;
-       int count;
-
-       assert(cls);
-       assert(name);
-       assert(!cls->classrefcount || cls->classrefs);
-       
-       /* first search the main classref table */
-       count = cls->classrefcount;
-       ref = cls->classrefs;
-       for (; count; --count, ++ref)
-               if (ref->name == name)
-                       return ref;
-
-       /* next try the list of extra classrefs */
-       for (xref = cls->extclassrefs; xref; xref = xref->next) {
-               if (xref->classref.name == name)
-                       return &(xref->classref);
-       }
-
-       /* not found */
-       return NULL;
-}
-
-
-/* class_get_classref **********************************************************
-
-   Returns the constant_classref for a given classname.
-
-   IN:
-       cls..............the class containing the reference
-          name.............the name of the class refered to
-
-   RETURN VALUE:
-       a pointer to a constant_classref (never NULL)
-
-   NOTE:
-       The given name is not checked for validity!
-   
-*******************************************************************************/
-
-constant_classref *class_get_classref(classinfo *cls, utf *name)
-{
-       constant_classref *ref;
-       extra_classref *xref;
-
-       assert(cls);
-       assert(name);
-
-       ref = class_lookup_classref(cls,name);
-       if (ref)
-               return ref;
-
-       xref = NEW(extra_classref);
-       CLASSREF_INIT(xref->classref,cls,name);
-
-       xref->next = cls->extclassrefs;
-       cls->extclassrefs = xref;
-
-       return &(xref->classref);
-}
-
-
-/* class_get_self_classref *****************************************************
-
-   Returns the constant_classref to the class itself.
-
-   IN:
-       cls..............the class containing the reference
-
-   RETURN VALUE:
-       a pointer to a constant_classref (never NULL)
-
-*******************************************************************************/
-
-constant_classref *class_get_self_classref(classinfo *cls)
-{
-       /* XXX this should be done in a faster way. Maybe always make */
-       /* the classref of index 0 a self reference.                  */
-       return class_get_classref(cls,cls->name);
-}
-
-/* class_get_classref_multiarray_of ********************************************
-
-   Returns an array type reference with the given dimension and element class
-   reference.
-
-   IN:
-       dim..............the requested dimension
-                           dim must be in [1;255]. This is NOT checked!
-          ref..............the component class reference
-
-   RETURN VALUE:
-       a pointer to the class reference for the array type
-
-   NOTE:
-       The referer of `ref` is used as the referer for the new classref.
-
-*******************************************************************************/
-
-constant_classref *class_get_classref_multiarray_of(s4 dim, constant_classref *ref)
-{
-    s4 namelen;
-    char *namebuf;
-       constant_classref *cr;
-       int32_t            dumpmarker;
-
-       assert(ref);
-       assert(dim >= 1 && dim <= 255);
-
-       DMARKER;
-
-    /* Assemble the array class name */
-    namelen = ref->name->blength;
-    
-    if (ref->name->text[0] == '[') {
-        /* the element is itself an array */
-        namebuf = DMNEW(char, namelen + dim);
-        memcpy(namebuf + dim, ref->name->text, namelen);
-        namelen += dim;
-    }
-    else {
-        /* the element is a non-array class */
-        namebuf = DMNEW(char, namelen + 2 + dim);
-        namebuf[dim] = 'L';
-        memcpy(namebuf + dim + 1, ref->name->text, namelen);
-        namelen += (2 + dim);
-        namebuf[namelen - 1] = ';';
-    }
-       memset(namebuf, '[', dim);
-
-    cr = class_get_classref(ref->referer,utf_new(namebuf, namelen));
-
-       DRELEASE;
-
-       return cr;
-}
-
-
-/* class_get_classref_component_of *********************************************
-
-   Returns the component classref of a given array type reference
-
-   IN:
-       ref..............the array type reference
-
-   RETURN VALUE:
-       a reference to the component class, or
-          NULL if `ref` is not an object array type reference
-
-   NOTE:
-       The referer of `ref` is used as the referer for the new classref.
-
-*******************************************************************************/
-
-constant_classref *class_get_classref_component_of(constant_classref *ref)
-{
-       s4 namelen;
-       char *name;
-       
-       assert(ref);
-
-       name = ref->name->text;
-       if (*name++ != '[')
-               return NULL;
-       
-       namelen = ref->name->blength - 1;
-       if (*name == 'L') {
-               name++;
-               namelen -= 2;
-       }
-       else if (*name != '[') {
-               return NULL;
-       }
-
-    return class_get_classref(ref->referer, utf_new(name, namelen));
-}
-
-
-/* class_findmethod ************************************************************
-       
-   Searches a 'classinfo' structure for a method having the given name
-   and descriptor. If descriptor is NULL, it is ignored.
-
-*******************************************************************************/
-
-methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc)
-{
-       methodinfo *m;
-       s4          i;
-
-       for (i = 0; i < c->methodscount; i++) {
-               m = &(c->methods[i]);
-
-               if ((m->name == name) && ((desc == NULL) || (m->descriptor == desc)))
-                       return m;
-       }
-
-       return NULL;
-}
-
-
-/* class_resolvemethod *********************************************************
-       
-   Searches a class and it's super classes for a method.
-
-   Superinterfaces are *not* searched.
-
-*******************************************************************************/
-
-methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *desc)
-{
-       methodinfo *m;
-
-       while (c) {
-               m = class_findmethod(c, name, desc);
-
-               if (m)
-                       return m;
-
-               /* JVM Specification bug: 
-
-                  It is important NOT to resolve special <init> and <clinit>
-                  methods to super classes or interfaces; yet, this is not
-                  explicited in the specification.  Section 5.4.3.3 should be
-                  updated appropriately.  */
-
-               if (name == utf_init || name == utf_clinit)
-                       return NULL;
-
-               c = c->super;
-       }
-
-       return NULL;
-}
-
-
-/* class_resolveinterfacemethod_intern *****************************************
-
-   Internally used helper function. Do not use this directly.
-
-*******************************************************************************/
-
-static methodinfo *class_resolveinterfacemethod_intern(classinfo *c,
-                                                                                                          utf *name, utf *desc)
-{
-       methodinfo *m;
-       s4          i;
-
-       /* try to find the method in the class */
-
-       m = class_findmethod(c, name, desc);
-
-       if (m != NULL)
-               return m;
-
-       /* No method found?  Try the super interfaces. */
-
-       for (i = 0; i < c->interfacescount; i++) {
-               m = class_resolveinterfacemethod_intern(c->interfaces[i], name, desc);
-
-               if (m != NULL)
-                       return m;
-       }
-
-       /* no method found */
-
-       return NULL;
-}
-
-
-/* class_resolveclassmethod ****************************************************
-       
-   Resolves a reference from REFERER to a method with NAME and DESC in
-   class C.
-
-   If the method cannot be resolved the return value is NULL. If
-   EXCEPT is true *exceptionptr is set, too.
-
-*******************************************************************************/
-
-methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *desc,
-                                                                        classinfo *referer, bool throwexception)
-{
-       classinfo  *cls;
-       methodinfo *m;
-       s4          i;
-
-/*     if (c->flags & ACC_INTERFACE) { */
-/*             if (throwexception) */
-/*                     *exceptionptr = */
-/*                             new_exception(string_java_lang_IncompatibleClassChangeError); */
-/*             return NULL; */
-/*     } */
-
-       /* try class c and its superclasses */
-
-       cls = c;
-
-       m = class_resolvemethod(cls, name, desc);
-
-       if (m != NULL)
-               goto found;
-
-       /* Try the super interfaces. */
-
-       for (i = 0; i < c->interfacescount; i++) {
-               m = class_resolveinterfacemethod_intern(c->interfaces[i], name, desc);
-
-               if (m != NULL)
-                       goto found;
-       }
-       
-       if (throwexception)
-               exceptions_throw_nosuchmethoderror(c, name, desc);
-
-       return NULL;
-
- found:
-       if ((m->flags & ACC_ABSTRACT) && !(c->flags & ACC_ABSTRACT)) {
-               if (throwexception)
-                       exceptions_throw_abstractmethoderror();
-
-               return NULL;
-       }
-
-       /* XXX check access rights */
-
-       return m;
-}
-
-
-/* class_resolveinterfacemethod ************************************************
-
-   Resolves a reference from REFERER to a method with NAME and DESC in
-   interface C.
-
-   If the method cannot be resolved the return value is NULL. If
-   EXCEPT is true *exceptionptr is set, too.
-
-*******************************************************************************/
-
-methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *desc,
-                                                                                classinfo *referer, bool throwexception)
-{
-       methodinfo *mi;
-
-       if (!(c->flags & ACC_INTERFACE)) {
-               if (throwexception)
-                       exceptions_throw_incompatibleclasschangeerror(c, "Not an interface");
-
-               return NULL;
-       }
-
-       mi = class_resolveinterfacemethod_intern(c, name, desc);
-
-       if (mi != NULL)
-               return mi;
-
-       /* try class java.lang.Object */
-
-       mi = class_findmethod(class_java_lang_Object, name, desc);
-
-       if (mi != NULL)
-               return mi;
-
-       if (throwexception)
-               exceptions_throw_nosuchmethoderror(c, name, desc);
-
-       return NULL;
-}
-
-
-/* class_findfield *************************************************************
-       
-   Searches for field with specified name and type in a classinfo
-   structure. If no such field is found NULL is returned.
-
-*******************************************************************************/
-
-fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc)
-{
-       s4 i;
-
-       for (i = 0; i < c->fieldscount; i++)
-               if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc))
-                       return &(c->fields[i]);
-
-       if (c->super != NULL)
-               return class_findfield(c->super, name, desc);
-
-       return NULL;
-}
-
-
-/* class_findfield_approx ******************************************************
-       
-   Searches in 'classinfo'-structure for a field with the specified
-   name.
-
-*******************************************************************************/
-fieldinfo *class_findfield_by_name(classinfo *c, utf *name)
-{
-       s4 i;
-
-       /* get field index */
-
-       i = class_findfield_index_by_name(c, name);
-
-       /* field was not found, return */
-
-       if (i == -1)
-               return NULL;
-
-       /* return field address */
-
-       return &(c->fields[i]);
-}
-
-
-s4 class_findfield_index_by_name(classinfo *c, utf *name)
-{
-       s4 i;
-
-       for (i = 0; i < c->fieldscount; i++) {
-               /* compare field names */
-
-               if ((c->fields[i].name == name))
-                       return i;
-       }
-
-       /* field was not found, raise exception */      
-
-       exceptions_throw_nosuchfielderror(c, name);
-
-       return -1;
-}
-
-
-/****************** Function: class_resolvefield_int ***************************
-
-    This is an internally used helper function. Do not use this directly.
-
-       Tries to resolve a field having the given name and type.
-    If the field cannot be resolved, NULL is returned.
-
-*******************************************************************************/
-
-static fieldinfo *class_resolvefield_int(classinfo *c, utf *name, utf *desc)
-{
-       fieldinfo *fi;
-       s4         i;
-
-       /* search for field in class c */
-
-       for (i = 0; i < c->fieldscount; i++) { 
-               if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc)) {
-                       return &(c->fields[i]);
-               }
-    }
-
-       /* Try super interfaces recursively. */
-
-       for (i = 0; i < c->interfacescount; i++) {
-               fi = class_resolvefield_int(c->interfaces[i], name, desc);
-
-               if (fi != NULL)
-                       return fi;
-       }
-
-       /* Try super class. */
-
-       if (c->super != NULL)
-               return class_resolvefield_int(c->super, name, desc);
-
-       /* not found */
-
-       return NULL;
-}
-
-
-/********************* Function: class_resolvefield ***************************
-       
-       Resolves a reference from REFERER to a field with NAME and DESC in class C.
-
-    If the field cannot be resolved the return value is NULL. If EXCEPT is
-    true *exceptionptr is set, too.
-
-*******************************************************************************/
-
-fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc,
-                                                         classinfo *referer, bool throwexception)
-{
-       fieldinfo *fi;
-
-       fi = class_resolvefield_int(c, name, desc);
-
-       if (!fi) {
-               if (throwexception)
-                       exceptions_throw_nosuchfielderror(c, name);
-
-               return NULL;
-       }
-
-       /* XXX check access rights */
-
-       return fi;
-}
-
-
-/* class_issubclass ************************************************************
-
-   Checks if sub is a descendant of super.
-       
-*******************************************************************************/
-
-bool class_issubclass(classinfo *sub, classinfo *super)
-{
-       classinfo *c;
-
-       c = sub;
-
-       for (;;) {
-               /* We reached java/lang/Object and did not find the requested
-                  super class. */
-
-               if (c == NULL)
-                       return false;
-
-               /* We found the requested super class. */
-
-               if (c == super)
-                       return true;
-
-               c = c->super;
-       }
-}
-
-
-/* class_isanysubclass *********************************************************
-
-   Checks a subclass relation between two classes. Implemented
-   interfaces are interpreted as super classes.
-
-   Return value: 1 ... sub is subclass of super
-                 0 ... otherwise
-
-*******************************************************************************/
-
-bool class_isanysubclass(classinfo *sub, classinfo *super)
-{
-       uint32_t diffval;
-       bool     result;
-
-       /* This is the trivial case. */
-
-       if (sub == super)
-               return true;
-
-       /* Primitive classes are only subclasses of themselves. */
-
-       if (class_is_primitive(sub) || class_is_primitive(super))
-               return false;
-
-       /* Check for interfaces. */
-
-       if (super->flags & ACC_INTERFACE) {
-               result = (sub->vftbl->interfacetablelength > super->index) &&
-                       (sub->vftbl->interfacetable[-super->index] != NULL);
-       }
-       else {
-               /* java.lang.Object is the only super class of any
-                  interface. */
-
-               if (sub->flags & ACC_INTERFACE)
-                       return (super == class_java_lang_Object);
-
-#if USES_NEW_SUBTYPE
-               result = fast_subtype_check(sub->vftbl, super->vftbl);
-#else
-               LOCK_CLASSRENUMBER_LOCK;
-
-               diffval = sub->vftbl->baseval - super->vftbl->baseval;
-               result  = diffval <= (uint32_t) super->vftbl->diffval;
-
-               UNLOCK_CLASSRENUMBER_LOCK;
-#endif
-       }
-
-       return result;
-}
-
-
-/* class_is_assignable_from ****************************************************
-
-   Return whether an instance of the "from" class parameter would be
-   an instance of this class "to" as well.
-
-   ARGUMENTS:
-       to ..... class
-          from ... class
-
-   RETURN:
-       true .... is assignable
-          false ... is not assignable
-
-*******************************************************************************/
-
-bool class_is_assignable_from(classinfo *to, classinfo *from)
-{
-       if (!(to->state & CLASS_LINKED))
-               if (!link_class(to))
-                       return false;
-
-       if (!(from->state & CLASS_LINKED))
-               if (!link_class(from))
-                       return false;
-
-       return class_isanysubclass(from, to);
-}
-
-
-/* class_is_instance ***********************************************************
-
-   Return if the given Java object is an instance of the given class.
-
-   ARGUMENTS:
-       c ... class
-          h ... Java object
-
-   RETURN:
-       true .... is instance
-          false ... is not instance
-
-*******************************************************************************/
-
-bool class_is_instance(classinfo *c, java_handle_t *h)
-{
-       if (!(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return false;
-
-       return builtin_instanceof(h, c);
-}
-
-
-/* class_get_componenttype *****************************************************
-
-   Return the component class of the given class.  If the given class
-   is not an array, return NULL.
-
-*******************************************************************************/
-
-classinfo *class_get_componenttype(classinfo *c)
-{
-       classinfo       *component;
-       arraydescriptor *ad;
-       
-       /* XXX maybe we could find a way to do this without linking. */
-       /* This way should be safe and easy, however.                */
-
-       if (!(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return NULL;
-
-       ad = c->vftbl->arraydesc;
-       
-       if (ad == NULL)
-               return NULL;
-       
-       if (ad->arraytype == ARRAYTYPE_OBJECT)
-               component = ad->componentvftbl->clazz;
-       else
-               component = primitive_class_get_by_type(ad->arraytype);
-               
-       return component;
-}
-
-
-/* class_get_declaredclasses ***************************************************
-
-   Return an array of declared classes of the given class.
-
-*******************************************************************************/
-
-java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOnly)
-{
-       classref_or_classinfo  inner;
-       classref_or_classinfo  outer;
-       utf                   *outername;
-       int                    declaredclasscount;  /* number of declared classes */
-       int                    pos;                     /* current declared class */
-       java_handle_objectarray_t *oa;               /* array of declared classes */
-       int                    i;
-       classinfo             *ic;
-
-       declaredclasscount = 0;
-
-       if (!class_is_primitive(c) && !class_is_array(c)) {
-               /* Determine number of declared classes. */
-
-               for (i = 0; i < c->innerclasscount; i++) {
-                       /* Get outer-class.  If the inner-class is not a member
-                          class, the outer-class is NULL. */
-
-                       outer = c->innerclass[i].outer_class;
-
-                       if (outer.any == NULL)
-                               continue;
-
-                       /* Check if outer-class is a classref or a real class and
-               get the class name from the structure. */
-
-                       outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name;
-
-                       /* Outer class is this class. */
-
-                       if ((outername == c->name) &&
-                               ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC)))
-                               declaredclasscount++;
-               }
-       }
-
-       /* Allocate Class[] and check for OOM. */
-
-       oa = builtin_anewarray(declaredclasscount, class_java_lang_Class);
-
-       if (oa == NULL)
-               return NULL;
-
-       for (i = 0, pos = 0; i < c->innerclasscount; i++) {
-               inner = c->innerclass[i].inner_class;
-               outer = c->innerclass[i].outer_class;
-
-               /* Get outer-class.  If the inner-class is not a member class,
-                  the outer-class is NULL. */
-
-               if (outer.any == NULL)
-                       continue;
-
-               /* Check if outer_class is a classref or a real class and get
-                  the class name from the structure. */
-
-               outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name;
-
-               /* Outer class is this class. */
-
-               if ((outername == c->name) &&
-                       ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC))) {
-
-                       ic = resolve_classref_or_classinfo_eager(inner, false);
-
-                       if (ic == NULL)
-                               return NULL;
-
-                       if (!(ic->state & CLASS_LINKED))
-                               if (!link_class(ic))
-                                       return NULL;
-
-                       LLNI_array_direct(oa, pos++) = (java_object_t *) ic;
-               }
-       }
-
-       return oa;
-}
-
-
-/**
- * Return an array of declared constructors of the given class.
- *
- * @param c          class to get the constructors of
- * @param publicOnly show only public fields
- *
- * @return array of java.lang.reflect.Constructor
- */
-#if defined(ENABLE_JAVASE)
-java_handle_objectarray_t *class_get_declaredconstructors(classinfo *c, bool publicOnly)
-{
-       methodinfo*                m;
-       java_handle_objectarray_t* oa;
-       java_handle_t*             rc;
-       int                        count;
-       int                        index;
-       int                        i;
-
-       /* Determine number of constructors. */
-
-       count = 0;
-
-       for (i = 0; i < c->methodscount; i++) {
-               m = &(c->methods[i]);
-
-               if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) &&
-                       (m->name == utf_init))
-                       count++;
-       }
-
-       /* Create array of constructors. */
-
-       oa = builtin_anewarray(count, class_java_lang_reflect_Constructor);
-
-       if (oa == NULL)
-               return NULL;
-
-       /* Get the constructors and store them in the array. */
-
-       for (i = 0, index = 0; i < c->methodscount; i++) {
-               m = &(c->methods[i]);
-
-               if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) &&
-                       (m->name == utf_init)) {
-                       /* Create Constructor object.  This is actualy a
-                          java_lang_reflect_Constructor pointer, but we use a
-                          java_handle_t here, because we don't have the header
-                          available when building vmcore. */
-
-                       rc = reflect_constructor_new(m);
-
-                       /* Store object into array. */
-
-                       array_objectarray_element_set(oa, index, rc);
-                       index++;
-               }
-       }
-
-       return oa;
-}
-#endif
-
-
-/* class_get_declaredfields ****************************************************
-
-   Return an array of declared fields of the given class.
-
-   ARGUMENTS:
-       c ............ class to get the fields of
-          publicOnly ... show only public fields
-
-   RETURN:
-       array of java.lang.reflect.Field
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-java_handle_objectarray_t *class_get_declaredfields(classinfo *c, bool publicOnly)
-{
-       java_handle_objectarray_t *oa;
-       fieldinfo                 *f;
-       java_handle_t             *h;
-       int                        count;
-       int                        index;
-       int                        i;
-
-       /* Determine number of fields. */
-
-       count = 0;
-
-       for (i = 0; i < c->fieldscount; i++)
-               if ((c->fields[i].flags & ACC_PUBLIC) || (publicOnly == 0))
-                       count++;
-
-       /* Create array of fields. */
-
-       oa = builtin_anewarray(count, class_java_lang_reflect_Field);
-
-       if (oa == NULL)
-               return NULL;
-
-       /* Get the fields and store them in the array. */
-
-       for (i = 0, index = 0; i < c->fieldscount; i++) {
-               f = &(c->fields[i]);
-
-               if ((f->flags & ACC_PUBLIC) || (publicOnly == 0)) {
-                       /* Create Field object.  This is actualy a
-                          java_lang_reflect_Field pointer, but we use a
-                          java_handle_t here, because we don't have the header
-                          available when building vmcore. */
-
-                       h = reflect_field_new(f);
-
-                       /* Store object into array. */
-
-                       array_objectarray_element_set(oa, index, h);
-                       index++;
-               }
-       }
-
-       return oa;
-}
-#endif
-
-
-/* class_get_declaredmethods ***************************************************
-
-   Return an array of declared methods of the given class.
-
-   ARGUMENTS:
-       c ............ class to get the methods of
-          publicOnly ... show only public methods
-
-   RETURN:
-       array of java.lang.reflect.Method
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-java_handle_objectarray_t *class_get_declaredmethods(classinfo *c, bool publicOnly)
-{
-       java_handle_objectarray_t *oa;         /* result: array of Method-objects */
-       methodinfo                *m;     /* the current method to be represented */
-       java_handle_t             *h;
-       int                        count;
-       int                        index;
-       int                        i;
-
-       /* JOWENN: array classes do not declare methods according to mauve
-          test.  It should be considered, if we should return to my old
-          clone method overriding instead of declaring it as a member
-          function. */
-
-       if (class_is_array(c))
-               return builtin_anewarray(0, class_java_lang_reflect_Method);
-
-       /* Determine number of methods. */
-
-       count = 0;
-
-       for (i = 0; i < c->methodscount; i++) {
-               m = &(c->methods[i]);
-
-               if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) &&
-                       ((m->name != utf_init) && (m->name != utf_clinit)) &&
-                       !(m->flags & ACC_MIRANDA))
-                       count++;
-       }
-
-       /* Create array of methods. */
-
-       oa = builtin_anewarray(count, class_java_lang_reflect_Method);
-
-       if (oa == NULL)
-               return NULL;
-
-       /* Get the methods and store them in the array. */
-
-       for (i = 0, index = 0; i < c->methodscount; i++) {
-               m = &(c->methods[i]);
-
-               if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) && 
-                       ((m->name != utf_init) && (m->name != utf_clinit)) &&
-                       !(m->flags & ACC_MIRANDA)) {
-                       /* Create method object.  This is actualy a
-                          java_lang_reflect_Method pointer, but we use a
-                          java_handle_t here, because we don't have the header
-                          available when building vmcore. */
-
-                       h = reflect_method_new(m);
-
-                       /* Store object into array. */
-
-                       array_objectarray_element_set(oa, index, h);
-                       index++;
-               }
-       }
-
-       return oa;
-}
-#endif
-
-
-/* class_get_declaringclass ****************************************************
-
-   If the class or interface given is a member of another class,
-   return the declaring class.  For array and primitive classes return
-   NULL.
-
-*******************************************************************************/
-
-classinfo *class_get_declaringclass(classinfo *c)
-{
-       classref_or_classinfo  cr;
-       classinfo             *dc;
-
-       /* Get declaring class. */
-
-       cr = c->declaringclass;
-
-       if (cr.any == NULL)
-               return NULL;
-
-       /* Resolve the class if necessary. */
-
-       if (IS_CLASSREF(cr)) {
-/*             dc = resolve_classref_eager(cr.ref); */
-               dc = resolve_classref_or_classinfo_eager(cr, true);
-
-               if (dc == NULL)
-                       return NULL;
-
-               /* Store the resolved class in the class structure. */
-
-               cr.cls = dc;
-       }
-
-       dc = cr.cls;
-
-       return dc;
-}
-
-
-/* class_get_enclosingclass ****************************************************
-
-   Return the enclosing class for the given class.
-
-*******************************************************************************/
-
-classinfo *class_get_enclosingclass(classinfo *c)
-{
-       classref_or_classinfo  cr;
-       classinfo             *ec;
-
-       /* Get enclosing class. */
-
-       cr = c->enclosingclass;
-
-       if (cr.any == NULL)
-               return NULL;
-
-       /* Resolve the class if necessary. */
-
-       if (IS_CLASSREF(cr)) {
-/*             ec = resolve_classref_eager(cr.ref); */
-               ec = resolve_classref_or_classinfo_eager(cr, true);
-
-               if (ec == NULL)
-                       return NULL;
-
-               /* Store the resolved class in the class structure. */
-
-               cr.cls = ec;
-       }
-
-       ec = cr.cls;
-
-       return ec;
-}
-
-
-/**
- * Return the enclosing constructor as java.lang.reflect.Constructor
- * object for the given class.
- *
- * @param c class to return the enclosing constructor for
- *
- * @return java.lang.reflect.Constructor object of the enclosing
- * constructor
- */
-#if defined(ENABLE_JAVASE)
-java_handle_t* class_get_enclosingconstructor(classinfo *c)
-{
-       methodinfo*    m;
-       java_handle_t* rc;
-
-       m = class_get_enclosingmethod_raw(c);
-
-       if (m == NULL)
-               return NULL;
-
-       /* Check for <init>. */
-
-       if (m->name != utf_init)
-               return NULL;
-
-       /* Create Constructor object. */
-
-       rc = reflect_constructor_new(m);
-
-       return rc;
-}
-#endif
-
-
-/* class_get_enclosingmethod ***************************************************
-
-   Return the enclosing method for the given class.
-
-   IN:
-       c ... class to return the enclosing method for
-
-   RETURN:
-       methodinfo of the enclosing method
-
-*******************************************************************************/
-
-methodinfo *class_get_enclosingmethod_raw(classinfo *c)
-{
-       constant_nameandtype *cn;
-       classinfo            *ec;
-       methodinfo           *m;
-
-       /* get enclosing class and method */
-
-       ec = class_get_enclosingclass(c);
-       cn = c->enclosingmethod;
-
-       /* check for enclosing class and method */
-
-       if (ec == NULL)
-               return NULL;
-
-       if (cn == NULL)
-               return NULL;
-
-       /* find method in enclosing class */
-
-       m = class_findmethod(ec, cn->name, cn->descriptor);
-
-       if (m == NULL) {
-               exceptions_throw_internalerror("Enclosing method doesn't exist");
-               return NULL;
-       }
-
-       return m;
-}
-
-
-/**
- * Return the enclosing method as java.lang.reflect.Method object for
- * the given class.
- *
- * @param c class to return the enclosing method for
- *
- * @return java.lang.reflect.Method object of the enclosing method
- */
-#if defined(ENABLE_JAVASE)
-java_handle_t* class_get_enclosingmethod(classinfo *c)
-{
-       methodinfo*    m;
-       java_handle_t* rm;
-
-       m = class_get_enclosingmethod_raw(c);
-
-       if (m == NULL)
-               return NULL;
-
-       /* check for <init> */
-
-       if (m->name == utf_init)
-               return NULL;
-
-       /* create java.lang.reflect.Method object */
-
-       rm = reflect_method_new(m);
-
-       return rm;
-}
-#endif
-
-
-/* class_get_interfaces ********************************************************
-
-   Return an array of interfaces of the given class.
-
-*******************************************************************************/
-
-java_handle_objectarray_t *class_get_interfaces(classinfo *c)
-{
-       classinfo                 *ic;
-       java_handle_objectarray_t *oa;
-       u4                         i;
-
-       if (!(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return NULL;
-
-       oa = builtin_anewarray(c->interfacescount, class_java_lang_Class);
-
-       if (oa == NULL)
-               return NULL;
-
-       for (i = 0; i < c->interfacescount; i++) {
-               ic = c->interfaces[i];
-
-               LLNI_array_direct(oa, i) = (java_object_t *) ic;
-       }
-
-       return oa;
-}
-
-
-/* class_get_annotations *******************************************************
-
-   Get the unparsed declared annotations in a byte array
-   of the given class.
-
-   IN:
-       c........the class of which the annotations should be returned
-
-   RETURN VALUE:
-       The unparsed declared annotations in a byte array
-       (or NULL if there aren't any).
-
-*******************************************************************************/
-
-java_handle_bytearray_t *class_get_annotations(classinfo *c)
-{
-#if defined(ENABLE_ANNOTATIONS)
-       java_handle_t *annotations; /* unparsed annotations */
-
-       LLNI_classinfo_field_get(c, annotations, annotations);
-
-       return (java_handle_bytearray_t*)annotations;
-#else
-       return NULL;
-#endif
-}
-
-
-/* class_get_modifiers *********************************************************
-
-   Get the modifier flags of the given class.
-
-   IN:
-       c....the class of which the modifier flags should be returned
-          ignoreInnerClassesAttrib
-   RETURN VALUE:
-       modifier flags
-
-*******************************************************************************/
-
-int32_t class_get_modifiers(classinfo *c, bool ignoreInnerClassesAttrib)
-{
-       classref_or_classinfo  inner;
-       classref_or_classinfo  outer;
-       utf                   *innername;
-       int                    i;
-
-       if (!ignoreInnerClassesAttrib && (c->innerclasscount != 0)) {
-               /* search for passed class as inner class */
-
-               for (i = 0; i < c->innerclasscount; i++) {
-                       inner = c->innerclass[i].inner_class;
-                       outer = c->innerclass[i].outer_class;
-
-                       /* Check if inner is a classref or a real class and get
-               the name of the structure */
-
-                       innername = IS_CLASSREF(inner) ? inner.ref->name : inner.cls->name;
-
-                       /* innerclass is this class */
-
-                       if (innername == c->name) {
-                               /* has the class actually an outer class? */
-
-                               if (outer.any)
-                                       /* return flags got from the outer class file */
-                                       return c->innerclass[i].flags & ACC_CLASS_REFLECT_MASK;
-                               else
-                                       return c->flags & ACC_CLASS_REFLECT_MASK;
-                       }
-               }
-       }
-
-       /* passed class is no inner class or it was not requested */
-
-       return c->flags & ACC_CLASS_REFLECT_MASK;
-}
-
-
-/* class_get_signature *********************************************************
-
-   Return the signature of the given class.  For array and primitive
-   classes return NULL.
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-utf *class_get_signature(classinfo *c)
-{
-       /* For array and primitive classes return NULL. */
-
-       if (class_is_array(c) || class_is_primitive(c))
-               return NULL;
-
-       return c->signature;
-}
-#endif
-
-
-/* class_printflags ************************************************************
-
-   Prints flags of a class.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void class_printflags(classinfo *c)
-{
-       if (c == NULL) {
-               printf("NULL");
-               return;
-       }
-
-       if (c->flags & ACC_PUBLIC)       printf(" PUBLIC");
-       if (c->flags & ACC_PRIVATE)      printf(" PRIVATE");
-       if (c->flags & ACC_PROTECTED)    printf(" PROTECTED");
-       if (c->flags & ACC_STATIC)       printf(" STATIC");
-       if (c->flags & ACC_FINAL)        printf(" FINAL");
-       if (c->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED");
-       if (c->flags & ACC_VOLATILE)     printf(" VOLATILE");
-       if (c->flags & ACC_TRANSIENT)    printf(" TRANSIENT");
-       if (c->flags & ACC_NATIVE)       printf(" NATIVE");
-       if (c->flags & ACC_INTERFACE)    printf(" INTERFACE");
-       if (c->flags & ACC_ABSTRACT)     printf(" ABSTRACT");
-}
-#endif
-
-
-/* class_print *****************************************************************
-
-   Prints classname plus flags.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void class_print(classinfo *c)
-{
-       if (c == NULL) {
-               printf("NULL");
-               return;
-       }
-
-       utf_display_printable_ascii(c->name);
-       class_printflags(c);
-}
-#endif
-
-
-/* class_classref_print ********************************************************
-
-   Prints classname plus referer class.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void class_classref_print(constant_classref *cr)
-{
-       if (cr == NULL) {
-               printf("NULL");
-               return;
-       }
-
-       utf_display_printable_ascii(cr->name);
-       printf("(ref.by ");
-       if (cr->referer)
-               class_print(cr->referer);
-       else
-               printf("NULL");
-       printf(")");
-}
-#endif
-
-
-/* class_println ***************************************************************
-
-   Prints classname plus flags and new line.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void class_println(classinfo *c)
-{
-       class_print(c);
-       printf("\n");
-}
-#endif
-
-
-/* class_classref_println ******************************************************
-
-   Prints classname plus referer class and new line.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void class_classref_println(constant_classref *cr)
-{
-       class_classref_print(cr);
-       printf("\n");
-}
-#endif
-
-
-/* class_classref_or_classinfo_print *******************************************
-
-   Prints classname plus referer class.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void class_classref_or_classinfo_print(classref_or_classinfo c)
-{
-       if (c.any == NULL) {
-               printf("(classref_or_classinfo) NULL");
-               return;
-       }
-       if (IS_CLASSREF(c))
-               class_classref_print(c.ref);
-       else
-               class_print(c.cls);
-}
-#endif
-
-
-/* class_classref_or_classinfo_println *****************************************
-
-   Prints classname plus referer class and a newline.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void class_classref_or_classinfo_println(classref_or_classinfo c)
-{
-       class_classref_or_classinfo_print(c);
-       printf("\n");
-}
-#endif
-
-
-/* class_showconstantpool ******************************************************
-
-   Dump the constant pool of the given class to stdout.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void class_showconstantpool (classinfo *c) 
-{
-       u4 i;
-       voidptr e;
-
-       printf ("---- dump of constant pool ----\n");
-
-       for (i=0; i<c->cpcount; i++) {
-               printf ("#%d:  ", (int) i);
-               
-               e = c -> cpinfos [i];
-               if (e) {
-                       
-                       switch (c -> cptags [i]) {
-                       case CONSTANT_Class:
-                               printf ("Classreference -> ");
-                               utf_display_printable_ascii ( ((constant_classref*)e) -> name );
-                               break;
-                       case CONSTANT_Fieldref:
-                               printf ("Fieldref -> ");
-                               field_fieldref_print((constant_FMIref *) e);
-                               break;
-                       case CONSTANT_Methodref:
-                               printf ("Methodref -> ");
-                               method_methodref_print((constant_FMIref *) e);
-                               break;
-                       case CONSTANT_InterfaceMethodref:
-                               printf ("InterfaceMethod -> ");
-                               method_methodref_print((constant_FMIref *) e);
-                               break;
-                       case CONSTANT_String:
-                               printf ("String -> ");
-                               utf_display_printable_ascii (e);
-                               break;
-                       case CONSTANT_Integer:
-                               printf ("Integer -> %d", (int) ( ((constant_integer*)e) -> value) );
-                               break;
-                       case CONSTANT_Float:
-                               printf ("Float -> %f", ((constant_float*)e) -> value);
-                               break;
-                       case CONSTANT_Double:
-                               printf ("Double -> %f", ((constant_double*)e) -> value);
-                               break;
-                       case CONSTANT_Long:
-                               {
-                                       u8 v = ((constant_long*)e) -> value;
-#if U8_AVAILABLE
-                                       printf ("Long -> %ld", (long int) v);
-#else
-                                       printf ("Long -> HI: %ld, LO: %ld\n", 
-                                                       (long int) v.high, (long int) v.low);
-#endif 
-                               }
-                               break;
-                       case CONSTANT_NameAndType:
-                               {
-                                       constant_nameandtype *cnt = e;
-                                       printf ("NameAndType: ");
-                                       utf_display_printable_ascii (cnt->name);
-                                       printf (" ");
-                                       utf_display_printable_ascii (cnt->descriptor);
-                               }
-                               break;
-                       case CONSTANT_Utf8:
-                               printf ("Utf8 -> ");
-                               utf_display_printable_ascii (e);
-                               break;
-                       default: 
-                               log_text("Invalid type of ConstantPool-Entry");
-                               assert(0);
-                       }
-               }
-
-               printf ("\n");
-       }
-}
-#endif /* !defined(NDEBUG) */
-
-
-/* class_showmethods ***********************************************************
-
-   Dump info about the fields and methods of the given class to stdout.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void class_showmethods (classinfo *c)
-{
-       s4 i;
-       
-       printf("--------- Fields and Methods ----------------\n");
-       printf("Flags: ");
-       class_printflags(c);
-       printf("\n");
-
-       printf("This: ");
-       utf_display_printable_ascii(c->name);
-       printf("\n");
-
-       if (c->super) {
-               printf("Super: ");
-               utf_display_printable_ascii(c->super->name);
-               printf ("\n");
-       }
-
-       printf("Index: %d\n", c->index);
-       
-       printf("Interfaces:\n");        
-       for (i = 0; i < c->interfacescount; i++) {
-               printf("   ");
-               utf_display_printable_ascii(c->interfaces[i]->name);
-               printf (" (%d)\n", c->interfaces[i]->index);
-       }
-
-       printf("Fields:\n");
-       for (i = 0; i < c->fieldscount; i++)
-               field_println(&(c->fields[i]));
-
-       printf("Methods:\n");
-       for (i = 0; i < c->methodscount; i++) {
-               methodinfo *m = &(c->methods[i]);
-
-               if (!(m->flags & ACC_STATIC))
-                       printf("vftblindex: %d   ", m->vftblindex);
-
-               method_println(m);
-       }
-
-       printf ("Virtual function table:\n");
-       for (i = 0; i < c->vftbl->vftbllength; i++)
-               printf ("entry: %d,  %ld\n", i, (long int) (c->vftbl->table[i]));
-}
-#endif /* !defined(NDEBUG) */
-
-
-/*
- * 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/vmcore/class.h b/src/vmcore/class.h
deleted file mode 100644 (file)
index 13c85d8..0000000
+++ /dev/null
@@ -1,569 +0,0 @@
-/* src/vmcore/class.h - class related functions 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 _CLASS_H
-#define _CLASS_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct classinfo      classinfo; 
-typedef struct innerclassinfo innerclassinfo;
-typedef struct extra_classref extra_classref;
-typedef struct castinfo       castinfo;
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "toolbox/list.h"
-
-#include "vm/global.h"
-#include "vm/stringlocal.h"
-
-#if defined(ENABLE_JAVASE)
-# include "vmcore/annotation.h"
-#endif
-
-#include "vmcore/field.h"
-#include "vmcore/linker.h"
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-#include "vmcore/references.h"
-#include "vmcore/utf8.h"
-
-
-/* class state defines ********************************************************/
-
-#define CLASS_LOADING         0x0001
-#define CLASS_LOADED          0x0002
-#define CLASS_LINKING         0x0004
-#define CLASS_LINKED          0x0008
-#define CLASS_INITIALIZING    0x0010
-#define CLASS_INITIALIZED     0x0020
-#define CLASS_ERROR           0x0040
-
-
-/* some macros ****************************************************************/
-
-#define CLASS_IS_OR_ALMOST_INITIALIZED(c) \
-    (((c)->state & CLASS_INITIALIZING) || ((c)->state & CLASS_INITIALIZED))
-
-
-/* classinfo ******************************************************************/
-
-/* We define this dummy structure of java_lang_Class so we can
-   bootstrap cacaoh without needing a java_lang_Class.h file.  Whether
-   the size of the dummy structure is big enough is checked during
-   runtime in vm_create. */
-
-typedef struct {
-       java_object_t      header;
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       intptr_t           padding[4];
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       intptr_t           padding[19];
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-       intptr_t           padding[3];
-#else
-# error unknown classpath configuration
-#endif
-} dummy_java_lang_Class;
-
-struct classinfo {                /* class structure                          */
-       dummy_java_lang_Class object;
-
-       s4          flags;            /* ACC flags                                */
-       utf        *name;             /* class name                               */
-
-       s4          cpcount;          /* number of entries in constant pool       */
-       u1         *cptags;           /* constant pool tags                       */
-       voidptr    *cpinfos;          /* pointer to constant pool info structures */
-
-       s4          classrefcount;    /* number of symbolic class references      */
-       constant_classref *classrefs; /* table of symbolic class references       */
-       extra_classref *extclassrefs; /* additional classrefs                     */
-       s4          parseddescsize;   /* size of the parsed descriptors block     */
-       u1         *parseddescs;      /* parsed descriptors                       */
-
-       classinfo  *super;            /* super class                              */
-       classinfo  *sub;              /* sub class pointer                        */
-       classinfo  *nextsub;          /* pointer to next class in sub class list  */
-
-       int32_t     interfacescount;  /* number of interfaces                     */
-       classinfo **interfaces;       /* super interfaces                         */
-
-       int32_t     fieldscount;      /* number of fields                         */
-       fieldinfo  *fields;           /* field table                              */
-
-       int32_t     methodscount;     /* number of methods                        */
-       methodinfo *methods;          /* method table                             */
-
-       s4          state;            /* current class state                      */
-       s4          index;            /* hierarchy depth (classes) or index       */
-                                     /* (interfaces)                             */
-       s4          instancesize;     /* size of an instance of this class        */
-
-       vftbl_t    *vftbl;            /* pointer to virtual function table        */
-
-       methodinfo *finalizer;        /* finalizer method                         */
-
-       u2          innerclasscount;  /* number of inner classes                  */
-       innerclassinfo *innerclass;
-
-       classref_or_classinfo  declaringclass;
-       classref_or_classinfo  enclosingclass;  /* enclosing class                */
-       constant_nameandtype  *enclosingmethod; /* enclosing method               */
-
-       utf        *packagename;      /* full name of the package                 */
-       utf        *sourcefile;       /* SourceFile attribute                     */
-#if defined(ENABLE_JAVASE)
-       utf        *signature;        /* Signature attribute                      */
-#if defined(ENABLE_ANNOTATIONS)
-       /* All the annotation attributes are NULL (and not a zero length array)   */
-       /* if there is nothing.                                                   */
-       java_object_t *annotations;   /* annotations of this class                */
-       
-       java_object_t *method_annotations; /* array of annotations of the methods */
-       java_object_t *method_parameterannotations; /* array of parameter         */
-                                     /* annotations of the methods               */
-       java_object_t *method_annotationdefaults; /* array of annotation default  */
-                                     /* values of the methods                    */
-
-       java_object_t *field_annotations; /* array of annotations of the fields   */
-
-#endif
-#endif
-       classloader_t *classloader;       /* NULL for bootstrap classloader         */
-
-#if defined(ENABLE_JAVASE)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       java_object_t      *protectiondomain;
-       java_objectarray_t *signers;
-# endif
-#endif
-};
-
-
-/* innerclassinfo *************************************************************/
-
-struct innerclassinfo {
-       classref_or_classinfo inner_class; /* inner class pointer                 */
-       classref_or_classinfo outer_class; /* outer class pointer                 */
-       utf                  *name;        /* innerclass name                     */
-       s4                    flags;       /* ACC flags                           */
-};
-
-
-/* extra_classref **************************************************************
-
-   for classrefs not occurring within descriptors
-
-*******************************************************************************/
-
-struct extra_classref {
-       extra_classref    *next;
-       constant_classref  classref;
-};
-
-
-/* castinfo *******************************************************************/
-
-struct castinfo {
-       s4 super_baseval;
-       s4 super_diffval;
-       s4 sub_baseval;
-};
-
-
-/* global variables ***********************************************************/
-
-/* frequently used classes ****************************************************/
-
-/* Important system classes. */
-
-extern classinfo *class_java_lang_Object;
-extern classinfo *class_java_lang_Class;
-extern classinfo *class_java_lang_ClassLoader;
-extern classinfo *class_java_lang_Cloneable;
-extern classinfo *class_java_lang_SecurityManager;
-extern classinfo *class_java_lang_String;
-extern classinfo *class_java_lang_System;
-extern classinfo *class_java_lang_Thread;
-extern classinfo *class_java_lang_ThreadGroup;
-extern classinfo *class_java_lang_Throwable;
-extern classinfo *class_java_io_Serializable;
-
-/* Important system exceptions. */
-
-extern classinfo *class_java_lang_Exception;
-extern classinfo *class_java_lang_ClassNotFoundException;
-extern classinfo *class_java_lang_RuntimeException;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-extern classinfo *class_java_lang_VMSystem;
-extern classinfo *class_java_lang_VMThread;
-extern classinfo *class_java_lang_VMThrowable;
-#endif
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-extern classinfo *class_sun_reflect_MagicAccessorImpl;
-#endif
-
-#if defined(ENABLE_JAVASE)
-extern classinfo *class_java_lang_Void;
-#endif
-
-extern classinfo *class_java_lang_Boolean;
-extern classinfo *class_java_lang_Byte;
-extern classinfo *class_java_lang_Character;
-extern classinfo *class_java_lang_Short;
-extern classinfo *class_java_lang_Integer;
-extern classinfo *class_java_lang_Long;
-extern classinfo *class_java_lang_Float;
-extern classinfo *class_java_lang_Double;
-
-/* some classes which may be used more often */
-
-#if defined(ENABLE_JAVASE)
-extern classinfo *class_java_lang_StackTraceElement;
-extern classinfo *class_java_lang_reflect_Constructor;
-extern classinfo *class_java_lang_reflect_Field;
-extern classinfo *class_java_lang_reflect_Method;
-extern classinfo *class_java_security_PrivilegedAction;
-extern classinfo *class_java_util_Vector;
-extern classinfo *class_java_util_HashMap;
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-extern classinfo *class_java_lang_reflect_VMConstructor;
-extern classinfo *class_java_lang_reflect_VMField;
-extern classinfo *class_java_lang_reflect_VMMethod;
-# endif
-
-extern classinfo *arrayclass_java_lang_Object;
-
-# if defined(ENABLE_ANNOTATIONS)
-extern classinfo *class_sun_reflect_ConstantPool;
-#  if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-extern classinfo *class_sun_reflect_annotation_AnnotationParser;
-#  endif
-# endif
-#endif
-
-
-/* pseudo classes for the type checker ****************************************/
-
-/*
- * pseudo_class_Arraystub
- *     (extends Object implements Cloneable, java.io.Serializable)
- *
- *     If two arrays of incompatible component types are merged,
- *     the resulting reference has no accessible components.
- *     The result does, however, implement the interfaces Cloneable
- *     and java.io.Serializable. This pseudo class is used internally
- *     to represent such results. (They are *not* considered arrays!)
- *
- * pseudo_class_Null
- *
- *     This pseudo class is used internally to represent the
- *     null type.
- *
- * pseudo_class_New
- *
- *     This pseudo class is used internally to represent the
- *     the 'uninitialized object' type.
- */
-
-extern classinfo *pseudo_class_Arraystub;
-extern classinfo *pseudo_class_Null;
-extern classinfo *pseudo_class_New;
-
-
-/* inline functions ***********************************************************/
-
-/**
- * Returns the classname of the class, where slashes ('/') are
- * replaced by dots ('.').
- *
- * @param c class to get name of
- * @return classname
- */
-inline static java_handle_t* class_get_classname(classinfo* c)
-{
-       java_handle_t *s;
-
-       /* Create a java string. */
-
-       s = javastring_new_slash_to_dot(c->name);
-
-       return s;
-}
-
-
-/* class_is_primitive **********************************************************
-
-   Checks if the given class is a primitive class.
-
-*******************************************************************************/
-
-static inline bool class_is_primitive(classinfo *c)
-{
-       if (c->flags & ACC_CLASS_PRIMITIVE)
-               return true;
-
-       return false;
-}
-
-
-/* class_is_anonymousclass *****************************************************
-
-   Checks if the given class is an anonymous class.
-
-*******************************************************************************/
-
-static inline bool class_is_anonymousclass(classinfo *c)
-{
-       if (c->flags & ACC_CLASS_ANONYMOUS)
-               return true;
-
-       return false;
-}
-
-
-/* class_is_array **************************************************************
-
-   Checks if the given class is an array class.
-
-*******************************************************************************/
-
-static inline bool class_is_array(classinfo *c)
-{
-       if (!(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return false;
-
-       return (c->vftbl->arraydesc != NULL);
-}
-
-
-/* class_is_interface **********************************************************
-
-   Checks if the given class is an interface.
-
-*******************************************************************************/
-
-static inline bool class_is_interface(classinfo *c)
-{
-       if (c->flags & ACC_INTERFACE)
-               return true;
-
-       return false;
-}
-
-
-/* class_is_localclass *********************************************************
-
-   Checks if the given class is a local class.
-
-*******************************************************************************/
-
-static inline bool class_is_localclass(classinfo *c)
-{
-       if ((c->enclosingmethod != NULL) && !class_is_anonymousclass(c))
-               return true;
-
-       return false;
-}
-
-
-/* class_is_memberclass ********************************************************
-
-   Checks if the given class is a member class.
-
-*******************************************************************************/
-
-static inline bool class_is_memberclass(classinfo *c)
-{
-       if (c->flags & ACC_CLASS_MEMBER)
-               return true;
-
-       return false;
-}
-
-
-/* class_get_classloader *******************************************************
-
-   Return the classloader of the given class.
-
-*******************************************************************************/
-
-static inline classloader_t *class_get_classloader(classinfo *c)
-{
-       classloader_t *cl;
-
-       cl = c->classloader;
-
-       /* The classloader may be NULL. */
-
-       return cl;
-}
-
-
-/* class_get_superclass ********************************************************
-
-   Return the super class of the given class.
-
-*******************************************************************************/
-
-static inline classinfo *class_get_superclass(classinfo *c)
-{
-       /* For interfaces we return NULL. */
-
-       if (c->flags & ACC_INTERFACE)
-               return NULL;
-
-       /* For java/lang/Object, primitive-type and Void classes c->super
-          is NULL and we return NULL. */
-
-       return c->super;
-}
-
-
-/* function prototypes ********************************************************/
-
-classinfo *class_create_classinfo(utf *u);
-void       class_postset_header_vftbl(void);
-classinfo *class_define(utf *name, classloader_t *cl, int32_t length, uint8_t *data, java_handle_t *pd);
-void       class_set_packagename(classinfo *c);
-
-bool       class_load_attributes(classbuffer *cb);
-
-/* retrieve constantpool element */
-voidptr class_getconstant(classinfo *class, u4 pos, u4 ctype);
-voidptr innerclass_getconstant(classinfo *c, u4 pos, u4 ctype);
-
-/* frees all resources used by the class */
-void class_free(classinfo *);
-
-/* return an array class with the given component class */
-classinfo *class_array_of(classinfo *component,bool link);
-
-/* return an array class with the given dimension and element class */
-classinfo *class_multiarray_of(s4 dim, classinfo *element,bool link);
-
-/* return a classref for the given class name */
-/* (does a linear search!)                    */
-constant_classref *class_lookup_classref(classinfo *cls,utf *name);
-
-/* return a classref for the given class name */
-/* (does a linear search!)                    */
-constant_classref *class_get_classref(classinfo *cls,utf *name);
-
-/* return a classref to the class itself */
-/* (does a linear search!)                    */
-constant_classref *class_get_self_classref(classinfo *cls);
-
-/* return a classref for an array with the given dimension of with the */
-/* given component type */
-constant_classref *class_get_classref_multiarray_of(s4 dim,constant_classref *ref);
-
-/* return a classref for the component type of the given array type */
-constant_classref *class_get_classref_component_of(constant_classref *ref);
-
-/* get a class' field by name and descriptor */
-fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc);
-
-/* search 'classinfo'-structure for a field with the specified name */
-fieldinfo *class_findfield_by_name(classinfo *c, utf *name);
-s4 class_findfield_index_by_name(classinfo *c, utf *name);
-
-/* search class for a field */
-fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc, classinfo *referer, bool throwexception);
-
-/* search for a method with a specified name and descriptor */
-methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc);
-methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *dest);
-methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception);
-methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception);
-
-bool                       class_issubclass(classinfo *sub, classinfo *super);
-bool                       class_isanysubclass(classinfo *sub, classinfo *super);
-bool                       class_is_assignable_from(classinfo *to, classinfo *from);
-bool                       class_is_instance(classinfo *c, java_handle_t *h);
-
-classloader_t             *class_get_classloader(classinfo *c);
-classinfo                 *class_get_superclass(classinfo *c);
-classinfo                 *class_get_componenttype(classinfo *c);
-java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOnly);
-java_handle_objectarray_t *class_get_declaredconstructors(classinfo *c, bool publicOnly);
-java_handle_objectarray_t *class_get_declaredfields(classinfo *c, bool publicOnly);
-java_handle_objectarray_t *class_get_declaredmethods(classinfo *c, bool publicOnly);
-classinfo                 *class_get_declaringclass(classinfo *c);
-classinfo                 *class_get_enclosingclass(classinfo *c);
-java_handle_t*             class_get_enclosingconstructor(classinfo *c);
-methodinfo*                class_get_enclosingmethod_raw(classinfo *c);
-java_handle_t*             class_get_enclosingmethod(classinfo *c);
-java_handle_objectarray_t *class_get_interfaces(classinfo *c);
-java_handle_bytearray_t   *class_get_annotations(classinfo *c);
-int32_t                    class_get_modifiers(classinfo *c, bool ignoreInnerClassesAttrib);
-java_handle_t             *class_get_name(classinfo *c);
-
-#if defined(ENABLE_JAVASE)
-utf                       *class_get_signature(classinfo *c);
-#endif
-
-/* some debugging functions */
-
-#if !defined(NDEBUG)
-void class_printflags(classinfo *c);
-void class_print(classinfo *c);
-void class_println(classinfo *c);
-void class_classref_print(constant_classref *cr);
-void class_classref_println(constant_classref *cr);
-void class_classref_or_classinfo_print(classref_or_classinfo c);
-void class_classref_or_classinfo_println(classref_or_classinfo c);
-#endif
-
-/* debug purposes */
-void class_showmethods(classinfo *c);
-void class_showconstantpool(classinfo *c);
-
-#endif /* _CLASS_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:
- */
diff --git a/src/vmcore/classcache.c b/src/vmcore/classcache.c
deleted file mode 100644 (file)
index 76fc825..0000000
+++ /dev/null
@@ -1,1588 +0,0 @@
-/* src/vmcore/classcache.c - loaded class cache and loading constraints
-
-   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 "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "threads/lock-common.h"
-
-#include "toolbox/hashtable.h"
-#include "toolbox/logging.h"
-
-#include "vm/exceptions.h"
-
-#include "vmcore/classcache.h"
-#include "vmcore/options.h"
-#include "vmcore/utf8.h"
-
-
-/*************************************************************************
-
-  Class Cache
-
-  The classcache has two functions:
-  
-       1) caching the resolution of class references
-       2) storing and checking loading constraints
-
-  We will use the following terms in this description:
-
-       N          a class name: a utf string
-       (N,L)      a class reference with initiating loader L and class name N
-       C          a class (object): the result of resolving a reference (N,L)
-               We will write resultion as
-                               C = *(N,L)
-       (N,L1,L2)  a loading constraint indicating that (N,L1) and (N,L2) must
-                  resolve to the same class C. So (N,L1,L2) means
-                               *(N,L1) = *(N,L2)
-
-  The functions of the classcache require:
-
-    1) a mapping (N,L) |--> C for looking up prior resolution results.
-       2) storing the current set of loading constraints { (N,L1,L2) }
-
-  These functions can be rearranged like that:
-
-    a mapping N |--> (a mapping L |--> C or NULL, 
-                         a set of constraints {(L1,L2)})
-
-  Thus we can treat the mapping and constraints for each name N
-  separately. The implementation does this by keeping a hash table
-  mapping a name N to a `classcache_name_entry` which contains all
-  info with respect to N.
-
-  For a class name N we can define an equivalence relation ~N~ on
-  class loaders:
-
-       L1 ~N~ L2  <==>  *(N,L1) = *(N,L2)
-
-  A loading constraint (N,L1,L2) implies L1 ~N~ L2.
-
-  Also, if two references (N,L1) and (N,L2) resolve to the same class C
-  we have L1 ~N~ L2 because class loaders are required to return
-  consistent resolutions for a name N [XXX].
-
-  A `classcache_name_entry` keeps a set of tuples { (Cx,IL,CL) },
-  where
-               Cx...is a class C or NULL
-               IL...is the set of initiating loaders
-               CL...is the set of constrained loaders
-               
-  Such a tuple is called `classcache_class_entry` in the source code.
-
-  The following holds for each tuple (Cx,IL,CL):
-
-    .  (Cx is NULL) implies IL = {}.
-          
-       .  If Cx is a class, IL is the set of loaders that have been
-          recorded as initiating loaders for Cx. IL may be the
-          empty set {} in case Cx has already been defined but no
-          initiating loader has been recorded, yet.
-  
-    .  (IL u CL) is a subset of an equivalence class of ~N~.
-
-                (This means that all loaders in IL and CL must resolve
-                the name N to the same class.)
-
-  The following holds for the set of tuples { (Cx,IL,CL) }:
-
-    .  For a given class C there is at most one tuple with Cx = C
-          in the set. (There may be an arbitrary number of tuples
-          with Cx = NULL, however.)
-
-       .  For a given loader L there is at most one tuple with
-          L in (IL u CL).
-
-  The implementation stores sets of loaders as linked lists of
-  `classcache_loader_entry`s.
-
-  Comments about manipulating the classcache can be found in the
-  individual functions below.
-*************************************************************************/
-
-
-/* initial number of slots in the classcache hash table */
-#define CLASSCACHE_INIT_SIZE  2048
-
-/*============================================================================*/
-/* DEBUG HELPERS                                                              */
-/*============================================================================*/
-
-/* #define CLASSCACHE_VERBOSE */
-
-/*============================================================================*/
-/* STATISTICS                                                                 */
-/*============================================================================*/
-
-/*#define CLASSCACHE_STATS*/
-
-#ifdef CLASSCACHE_STATS
-static int stat_classnames_stored = 0;
-static int stat_classes_stored = 0;
-static int stat_trivial_constraints = 0;
-static int stat_nontriv_constraints = 0;
-static int stat_nontriv_constraints_both = 0;
-static int stat_nontriv_constraints_merged = 0;
-static int stat_nontriv_constraints_one = 0;
-static int stat_nontriv_constraints_none = 0;
-static int stat_new_loader_entry = 0;
-static int stat_merge_class_entries = 0;
-static int stat_merge_loader_entries = 0;
-static int stat_lookup = 0;
-static int stat_lookup_class_entry_checked = 0;
-static int stat_lookup_loader_checked = 0;
-static int stat_lookup_name = 0;
-static int stat_lookup_name_entry = 0;
-static int stat_lookup_name_notfound = 0;
-static int stat_lookup_new_name = 0;
-static int stat_lookup_new_name_entry = 0;
-static int stat_lookup_new_name_collisions = 0;
-static int stat_rehash_names = 0;
-static int stat_rehash_names_collisions = 0;
-
-#define CLASSCACHE_COUNT(cnt)  (cnt)++
-#define CLASSCACHE_COUNTIF(cond,cnt)  do{if(cond) (cnt)++;} while(0)
-
-void classcache_print_statistics(FILE *file) {
-       fprintf(file,"classnames stored   : %8d\n",stat_classnames_stored);
-       fprintf(file,"classes stored      : %8d\n",stat_classes_stored);
-       fprintf(file,"trivial constraints : %8d\n",stat_trivial_constraints);
-       fprintf(file,"non-triv constraints: %8d\n",stat_nontriv_constraints);
-       fprintf(file,"   both loaders rec.: %8d\n",stat_nontriv_constraints_both);
-       fprintf(file,"       merged       : %8d\n",stat_nontriv_constraints_merged);
-       fprintf(file,"   one loader rec.  : %8d\n",stat_nontriv_constraints_one);
-       fprintf(file,"   no loaders rec.  : %8d\n",stat_nontriv_constraints_none);
-       fprintf(file,"new loader entries  : %8d\n",stat_new_loader_entry);
-       fprintf(file,"merge class entries : %8d\n",stat_merge_class_entries);
-       fprintf(file,"merge loader entries: %8d\n",stat_merge_loader_entries);
-       fprintf(file,"lookups             : %8d\n",stat_lookup);
-       fprintf(file,"   class entries ckd: %8d\n",stat_lookup_class_entry_checked);
-       fprintf(file,"   loader checked   : %8d\n",stat_lookup_loader_checked);
-       fprintf(file,"lookup name         : %8d\n",stat_lookup_name);
-       fprintf(file,"   entries checked  : %8d\n",stat_lookup_name_entry);
-       fprintf(file,"   not found        : %8d\n",stat_lookup_name_notfound);
-       fprintf(file,"lookup (new) name   : %8d\n",stat_lookup_new_name);
-       fprintf(file,"   entries checked  : %8d\n",stat_lookup_new_name_entry);
-       fprintf(file,"   new collisions   : %8d\n",stat_lookup_new_name_collisions);
-       fprintf(file,"names rehashed      : %8d times\n",stat_rehash_names);
-       fprintf(file,"    collisions      : %8d\n",stat_rehash_names_collisions);
-}
-#else
-#define CLASSCACHE_COUNT(cnt)
-#define CLASSCACHE_COUNTIF(cond,cnt)
-#endif
-
-/*============================================================================*/
-/* THREAD-SAFE LOCKING                                                        */
-/*============================================================================*/
-
-       /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-       /* CAUTION: The static functions below are */
-       /*          NOT synchronized!              */
-       /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-
-#if defined(ENABLE_THREADS)
-# define CLASSCACHE_LOCK()      LOCK_MONITOR_ENTER(lock_hashtable_classcache)
-# define CLASSCACHE_UNLOCK()    LOCK_MONITOR_EXIT(lock_hashtable_classcache)
-#else
-# define CLASSCACHE_LOCK()
-# define CLASSCACHE_UNLOCK()
-#endif
-
-/*============================================================================*/
-/* GLOBAL VARIABLES                                                           */
-/*============================================================================*/
-
-hashtable hashtable_classcache;
-
-#if defined(ENABLE_THREADS)
-static java_object_t *lock_hashtable_classcache;
-#endif
-
-
-/*============================================================================*/
-/*                                                                            */
-/*============================================================================*/
-
-/* prototypes */
-
-static void classcache_free_class_entry(classcache_class_entry *clsen);
-static void classcache_remove_class_entry(classcache_name_entry *en,
-                                                                                 classcache_class_entry *clsen);
-
-/* hash function to use */
-
-#define CLASSCACHE_HASH utf_full_hashkey
-
-/* classcache_init *************************************************************
-   Initialize the class cache
-
-   Note: NOT synchronized!
-  
-*******************************************************************************/
-
-bool classcache_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("classcache_init");
-
-       /* create the hashtable */
-
-       hashtable_create(&hashtable_classcache, CLASSCACHE_INIT_SIZE);
-
-#if defined(ENABLE_THREADS)
-       /* create utf hashtable lock object */
-
-       lock_hashtable_classcache = NEW(java_object_t);
-
-       LOCK_INIT_OBJECT_LOCK(lock_hashtable_classcache);
-#endif
-
-       /* everything's ok */
-
-       return true;
-}
-
-/* classcache_new_loader_entry *************************************************
-   Create a new classcache_loader_entry struct
-   (internally used helper function)
-  
-   IN:
-       loader...........the ClassLoader object
-          next.............the next classcache_loader_entry
-
-   RETURN VALUE:
-       the new classcache_loader_entry
-  
-*******************************************************************************/
-
-static classcache_loader_entry * classcache_new_loader_entry(
-                                                                       classloader_t * loader,
-                                                                       classcache_loader_entry * next)
-{
-       classcache_loader_entry *lden;
-
-       lden = NEW(classcache_loader_entry);
-       lden->loader = loader;
-       lden->next = next;
-       CLASSCACHE_COUNT(stat_new_loader_entry);
-
-       return lden;
-}
-
-/* classcache_merge_loaders ****************************************************
-   Merge two lists of loaders into one
-   (internally used helper function)
-  
-   IN:
-       lista............first list (may be NULL)
-          listb............second list (may be NULL)
-
-   RETURN VALUE:
-       the merged list (may be NULL)
-
-   NOTE:
-       The lists given as arguments are destroyed!
-  
-*******************************************************************************/
-
-static classcache_loader_entry * classcache_merge_loaders(
-                                                                       classcache_loader_entry * lista,
-                                                                       classcache_loader_entry * listb)
-{
-       classcache_loader_entry *result;
-       classcache_loader_entry *ldenA;
-       classcache_loader_entry *ldenB;
-       classcache_loader_entry **chain;
-
-       CLASSCACHE_COUNT(stat_merge_loader_entries);
-
-       /* XXX This is a quadratic algorithm. If this ever
-        * becomes a problem, the loader lists should be
-        * stored as sorted lists and merged in linear time. */
-
-       result = NULL;
-       chain = &result;
-
-       for (ldenA = lista; ldenA; ldenA = ldenA->next) {
-
-               for (ldenB = listb; ldenB; ldenB = ldenB->next) {
-                       if (ldenB->loader == ldenA->loader)
-                               goto common_element;
-               }
-
-               /* this loader is only in lista */
-               *chain = ldenA;
-               chain = &(ldenA->next);
-
-         common_element:
-               /* XXX free the duplicated element */
-               ;
-       }
-
-       /* concat listb to the result */
-       *chain = listb;
-
-       return result;
-}
-
-/* classcache_merge_class_entries **********************************************
-   Merge two `classcache_class_entry`s into one.
-   (internally used helper function)
-  
-   IN:
-       en...............the classcache_name_entry containing both class entries
-       clsenA...........first class entry, will receive the result
-          clsenB...........second class entry
-
-   PRE-CONDITION:
-       Either both entries must have the same classobj, or one of them has
-          classobj == NULL.
-
-   NOTE:
-       clsenB is freed by this function!
-  
-*******************************************************************************/
-
-static void classcache_merge_class_entries(classcache_name_entry *en,
-                                                                                  classcache_class_entry *clsenA,
-                                                                                  classcache_class_entry *clsenB)
-{
-#ifdef CLASSCACHE_VERBOSE
-       char logbuffer[1024];
-#endif
-       
-       assert(en);
-       assert(clsenA);
-       assert(clsenB);
-       assert(!clsenA->classobj || !clsenB->classobj || clsenA->classobj == clsenB->classobj);
-
-#ifdef CLASSCACHE_VERBOSE
-       sprintf(logbuffer,"classcache_merge_class_entries(%p,%p->%p,%p->%p) ", 
-                       (void*)en,(void*)clsenA,(void*)clsenA->classobj,(void*)clsenB,(void*)clsenB->classobj);
-       if (clsenA->classobj)
-               utf_cat_classname(logbuffer, clsenA->classobj->name);
-       if (clsenB->classobj)
-               utf_cat_classname(logbuffer, clsenB->classobj->name);
-       log_println(logbuffer);
-#endif
-
-       CLASSCACHE_COUNT(stat_merge_class_entries);
-
-       /* clsenB will be merged into clsenA */
-       clsenA->loaders = classcache_merge_loaders(clsenA->loaders, clsenB->loaders);
-       clsenB->loaders = NULL; /* these have been freed or reused */
-
-       clsenA->constraints = classcache_merge_loaders(clsenA->constraints,
-                                                                                                  clsenB->constraints);
-       clsenB->constraints = NULL; /* these have been freed or reused */
-
-       if (!clsenA->classobj)
-               clsenA->classobj = clsenB->classobj;
-
-       /* remove clsenB from the list of class entries */
-       classcache_remove_class_entry(en, clsenB);
-}
-
-
-/* classcache_lookup_name ******************************************************
-   Lookup a name in the first level of the cache
-   (internally used helper function)
-   
-   IN:
-       name.............the name to look up
-  
-   RETURN VALUE:
-       a pointer to the classcache_name_entry for this name, or
-       null if no entry was found.
-          
-*******************************************************************************/
-
-static classcache_name_entry *classcache_lookup_name(utf *name)
-{
-       classcache_name_entry *c;           /* hash table element                 */
-       u4 key;                             /* hashkey computed from classname    */
-       u4 slot;                            /* slot in hashtable                  */
-
-       CLASSCACHE_COUNT(stat_lookup_name);
-
-       key  = CLASSCACHE_HASH(name->text, (u4) name->blength);
-       slot = key & (hashtable_classcache.size - 1);
-       c    = hashtable_classcache.ptr[slot];
-
-       /* search external hash chain for the entry */
-
-       while (c) {
-               /* entry found in hashtable */
-               CLASSCACHE_COUNT(stat_lookup_name_entry);
-
-               if (c->name == name)
-                       return c;
-
-               c = c->hashlink;                    /* next element in external chain */
-       }
-
-       /* not found */
-
-       CLASSCACHE_COUNT(stat_lookup_name_notfound);
-       return NULL;
-}
-
-
-/* classcache_new_name *********************************************************
-   Return a classcache_name_entry for the given name. The entry is created
-   if it is not already in the cache.
-   (internally used helper function)
-   
-   IN:
-       name.............the name to look up / create an entry for
-  
-   RETURN VALUE:
-       a pointer to the classcache_name_entry for this name
-          
-*******************************************************************************/
-
-static classcache_name_entry *classcache_new_name(utf *name)
-{
-       classcache_name_entry *c;       /* hash table element */
-       u4 key;                                         /* hashkey computed from classname */
-       u4 slot;                                        /* slot in hashtable               */
-       u4 i;
-
-       CLASSCACHE_COUNT(stat_lookup_new_name);
-
-       key  = CLASSCACHE_HASH(name->text, (u4) name->blength);
-       slot = key & (hashtable_classcache.size - 1);
-       c    = hashtable_classcache.ptr[slot];
-
-       /* search external hash chain for the entry */
-
-       while (c) {
-               /* entry found in hashtable */
-               CLASSCACHE_COUNT(stat_lookup_new_name_entry);
-
-               if (c->name == name)
-                       return c;
-
-               c = c->hashlink;                    /* next element in external chain */
-       }
-
-       /* location in hashtable found, create new entry */
-
-       c = NEW(classcache_name_entry);
-
-       c->name = name;
-       c->classes = NULL;
-
-       /* insert entry into hashtable */
-       c->hashlink = (classcache_name_entry *) hashtable_classcache.ptr[slot];
-       CLASSCACHE_COUNTIF(c->hashlink,stat_lookup_new_name_collisions);
-       hashtable_classcache.ptr[slot] = c;
-
-       /* update number of hashtable-entries */
-       hashtable_classcache.entries++;
-       CLASSCACHE_COUNT(stat_classnames_stored);
-
-       if ((hashtable_classcache.entries*2) > hashtable_classcache.size) {
-               /* reorganization of hashtable */ 
-
-               classcache_name_entry *c2;
-               hashtable newhash;              /* the new hashtable */
-
-               CLASSCACHE_COUNT(stat_rehash_names);
-
-               /* create new hashtable, double the size */
-
-               hashtable_create(&newhash, hashtable_classcache.size * 2);
-               newhash.entries = hashtable_classcache.entries;
-
-               /* transfer elements to new hashtable */
-
-               for (i = 0; i < hashtable_classcache.size; i++) {
-                       c2 = (classcache_name_entry *) hashtable_classcache.ptr[i];
-                       while (c2) {
-                               classcache_name_entry *nextc = c2->hashlink;
-                               u4 newslot =
-                                       (CLASSCACHE_HASH(c2->name->text, (u4) c2->name->blength)) & (newhash.size - 1);
-
-                               c2->hashlink = (classcache_name_entry *) newhash.ptr[newslot];
-                               CLASSCACHE_COUNTIF(c2->hashlink,stat_rehash_names_collisions);
-                               newhash.ptr[newslot] = c2;
-
-                               c2 = nextc;
-                       }
-               }
-
-               /* dispose old table */
-
-               MFREE(hashtable_classcache.ptr, void *, hashtable_classcache.size);
-               hashtable_classcache = newhash;
-       }
-
-       return c;
-}
-
-
-/* classcache_lookup ***********************************************************
-   Lookup a possibly loaded class
-  
-   IN:
-       initloader.......initiating loader for resolving the class name
-       classname........class name to look up
-  
-   RETURN VALUE:
-       The return value is a pointer to the cached class object,
-       or NULL, if the class is not in the cache.
-
-   Note: synchronized with global tablelock
-   
-*******************************************************************************/
-
-classinfo *classcache_lookup(classloader_t *initloader, utf *classname)
-{
-       classcache_name_entry *en;
-       classcache_class_entry *clsen;
-       classcache_loader_entry *lden;
-       classinfo *cls = NULL;
-
-       CLASSCACHE_LOCK();
-
-       CLASSCACHE_COUNT(stat_lookup);
-       en = classcache_lookup_name(classname);
-
-       if (en) {
-               /* iterate over all class entries */
-
-               for (clsen = en->classes; clsen; clsen = clsen->next) {
-                       CLASSCACHE_COUNT(stat_lookup_class_entry_checked);
-                       /* check if this entry has been loaded by initloader */
-
-                       for (lden = clsen->loaders; lden; lden = lden->next) {
-                               CLASSCACHE_COUNT(stat_lookup_loader_checked);
-                               if (lden->loader == initloader) {
-                                       /* found the loaded class entry */
-
-                                       assert(clsen->classobj);
-                                       cls = clsen->classobj;
-                                       goto found;
-                               }
-                       }
-               }
-       }
-
-  found:
-       CLASSCACHE_UNLOCK();
-       return cls;
-}
-
-
-/* classcache_lookup_defined ***************************************************
-   Lookup a class with the given name and defining loader
-  
-   IN:
-       defloader........defining loader
-       classname........class name
-  
-   RETURN VALUE:
-       The return value is a pointer to the cached class object,
-       or NULL, if the class is not in the cache.
-   
-*******************************************************************************/
-
-classinfo *classcache_lookup_defined(classloader_t *defloader, utf *classname)
-{
-       classcache_name_entry *en;
-       classcache_class_entry *clsen;
-       classinfo *cls = NULL;
-
-       CLASSCACHE_LOCK();
-
-       en = classcache_lookup_name(classname);
-
-       if (en) {
-               /* iterate over all class entries */
-               for (clsen = en->classes; clsen; clsen = clsen->next) {
-                       if (!clsen->classobj)
-                               continue;
-
-                       /* check if this entry has been defined by defloader */
-                       if (clsen->classobj->classloader == defloader) {
-                               cls = clsen->classobj;
-                               goto found;
-                       }
-               }
-       }
-
-  found:
-       CLASSCACHE_UNLOCK();
-       return cls;
-}
-
-
-/* classcache_lookup_defined_or_initiated **************************************
-   Lookup a class that has been defined or initiated by the given loader
-  
-   IN:
-       loader...........defining or initiating loader
-       classname........class name to look up
-  
-   RETURN VALUE:
-       The return value is a pointer to the cached class object,
-       or NULL, if the class is not in the cache.
-
-   Note: synchronized with global tablelock
-   
-*******************************************************************************/
-
-classinfo *classcache_lookup_defined_or_initiated(classloader_t *loader, 
-                                                                                                 utf *classname)
-{
-       classcache_name_entry *en;
-       classcache_class_entry *clsen;
-       classcache_loader_entry *lden;
-       classinfo *cls = NULL;
-
-       CLASSCACHE_LOCK();
-
-       en = classcache_lookup_name(classname);
-
-       if (en) {
-               /* iterate over all class entries */
-
-               for (clsen = en->classes; clsen; clsen = clsen->next) {
-
-                       /* check if this entry has been defined by loader */
-                       if (clsen->classobj && clsen->classobj->classloader == loader) {
-                               cls = clsen->classobj;
-                               goto found;
-                       }
-                       
-                       /* check if this entry has been initiated by loader */
-                       for (lden = clsen->loaders; lden; lden = lden->next) {
-                               if (lden->loader == loader) {
-                                       /* found the loaded class entry */
-
-                                       assert(clsen->classobj);
-                                       cls = clsen->classobj;
-                                       goto found;
-                               }
-                       }
-               }
-       }
-
-  found:
-       CLASSCACHE_UNLOCK();
-       return cls;
-}
-
-
-/* classcache_store ************************************************************
-   
-   Store a loaded class. If a class of the same name has already been stored
-   with the same initiating loader, then the given class CLS is freed (if
-   possible) and the previously stored class is returned.
-  
-   IN:
-       initloader.......initiating loader used to load the class
-                           (may be NULL indicating the bootstrap loader)
-       cls..............class object to cache
-          mayfree..........true if CLS may be freed in case another class is
-                           returned
-  
-   RETURN VALUE:
-       cls..............everything ok, the class was stored in the cache,
-          other classinfo..another class with the same (initloader,name) has been
-                           stored earlier. CLS has been freed[1] and the earlier
-                                               stored class is returned.
-       NULL.............an exception has been thrown.
-   
-   Note: synchronized with global tablelock
-
-   [1]...in case MAYFREE is true
-   
-*******************************************************************************/
-
-classinfo *classcache_store(classloader_t *initloader, classinfo *cls,
-                                                       bool mayfree)
-{
-       classcache_name_entry *en;
-       classcache_class_entry *clsen;
-       classcache_class_entry *clsenB;
-       classcache_loader_entry *lden;
-#ifdef CLASSCACHE_VERBOSE
-       char logbuffer[1024];
-#endif
-       
-       assert(cls);
-       assert(cls->state & CLASS_LOADED);
-
-       CLASSCACHE_LOCK();
-
-#ifdef CLASSCACHE_VERBOSE
-       sprintf(logbuffer,"classcache_store (%p,%d,%p=", (void*)initloader,mayfree,(void*)cls);
-       utf_cat_classname(logbuffer, cls->name);
-       strcat(logbuffer,")");
-       log_println(logbuffer);
-#endif
-
-       en = classcache_new_name(cls->name);
-
-       assert(en);
-
-       /* iterate over all class entries */
-       for (clsen = en->classes; clsen; clsen = clsen->next) {
-
-               /* check if this entry has already been loaded by initloader */
-               for (lden = clsen->loaders; lden; lden = lden->next) {
-                       if (lden->loader == initloader) {
-                          if (clsen->classobj != cls) {
-                                       /* A class with the same (initloader,name) pair has been stored already. */
-                                       /* We free the given class and return the earlier one.                   */
-#ifdef CLASSCACHE_VERBOSE
-                                       log_println("replacing %p with earlier loaded class %p",cls,clsen->classobj);
-#endif
-                                       assert(clsen->classobj);
-                                       if (mayfree)
-                                               class_free(cls);
-                                       cls = clsen->classobj;
-                          }
-                          goto return_success;
-                       }
-               }
-
-               /* {This entry has not been resolved with initloader} */
-
-               /* check if initloader is constrained to this entry */
-               for (lden = clsen->constraints; lden; lden = lden->next) {
-                       if (lden->loader == initloader) {
-                               /* we have to use this entry. check if it has been resolved */
-                               if (clsen->classobj) {
-                                       /* check if is has already been resolved to another class */
-                                       if (clsen->classobj != cls) {
-                                               /* a loading constraint is violated */
-                                               exceptions_throw_linkageerror("loading constraint violated: ", cls);
-                                               goto return_exception;
-                                       }
-
-                                       /* record initloader as initiating loader */
-                                       clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders);
-                                       goto return_success;
-                               }
-
-                               /* {this is the first resolution for this entry} */
-                               /* record initloader as initiating loader */
-                               clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders);
-
-                               /* maybe we can merge this entry with another one */
-                               for (clsenB = en->classes; clsenB; clsenB = clsenB->next) {
-                                       /* we dont want the entry that we have already */
-                                       if (clsenB->classobj == cls) {
-                                               /* this entry has the same classobj. let's merge them */
-                                               classcache_merge_class_entries(en,clsen,clsenB);
-                                               goto return_success;
-                                       }
-                               }
-
-                               /* record the loaded class object */
-                               clsen->classobj = cls;
-                               CLASSCACHE_COUNT(stat_classes_stored);
-
-                               /* done */
-                               goto return_success;
-                       }
-               }
-
-       }
-
-       /* {There is no class entry containing initloader as initiating 
-        *  or constrained loader.} */
-
-       /* we look for a class entry with the same classobj we want to store */
-       for (clsen = en->classes; clsen; clsen = clsen->next) {
-               if (clsen->classobj == cls) {
-                       /* this entry is about the same classobj. let's use it */
-                       /* check if this entry has already been loaded by initloader */
-                       for (lden = clsen->loaders; lden; lden = lden->next) {
-                               if (lden->loader == initloader)
-                                       goto return_success;
-                       }
-                       clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders);
-                       goto return_success;
-               }
-       }
-
-       /* create a new class entry for this class object with */
-       /* initiating loader initloader                        */
-
-       clsen = NEW(classcache_class_entry);
-       clsen->classobj = cls;
-       clsen->loaders = classcache_new_loader_entry(initloader, NULL);
-       clsen->constraints = NULL;
-
-       clsen->next = en->classes;
-       en->classes = clsen;
-       CLASSCACHE_COUNT(stat_classes_stored);
-
-  return_success:
-#ifdef CLASSCACHE_VERBOSE
-       classcache_debug_dump(stdout,cls->name);
-#endif
-       CLASSCACHE_UNLOCK();
-       return cls;
-
-  return_exception:
-       CLASSCACHE_UNLOCK();
-       return NULL;                            /* exception */
-}
-
-/* classcache_store_unique *****************************************************
-   
-   Store a loaded class as loaded by the bootstrap loader. This is a wrapper 
-   aroung classcache_store that throws an exception if a class with the same 
-   name has already been loaded by the bootstrap loader.
-
-   This function is used to register a few special classes during startup.
-   It should not be used otherwise.
-  
-   IN:
-       cls..............class object to cache
-  
-   RETURN VALUE:
-       true.............everything ok, the class was stored.
-       false............an exception has been thrown.
-   
-   Note: synchronized with global tablelock
-   
-*******************************************************************************/
-
-bool classcache_store_unique(classinfo *cls)
-{
-       classinfo *result;
-
-       result = classcache_store(NULL,cls,false);
-       if (result == NULL)
-               return false;
-
-       if (result != cls) {
-               exceptions_throw_internalerror("class already stored in the class cache");
-               return false;
-       }
-
-       return true;
-}
-
-/* classcache_store_defined ****************************************************
-   
-   Store a loaded class after it has been defined. If the class has already
-   been defined by the same defining loader in another thread, free the given
-   class and returned the one which has been defined earlier.
-  
-   IN:
-       cls..............class object to store. classloader must be set
-                           (classloader may be NULL, for bootloader)
-  
-   RETURN VALUE:
-       cls..............everything ok, the class was stored the cache,
-          other classinfo..the class had already been defined, CLS was freed, the
-                           class which was defined earlier is returned,
-       NULL.............an exception has been thrown.
-   
-*******************************************************************************/
-
-classinfo *classcache_store_defined(classinfo *cls)
-{
-       classcache_name_entry *en;
-       classcache_class_entry *clsen;
-#ifdef CLASSCACHE_VERBOSE
-       char logbuffer[1024];
-#endif
-
-       assert(cls);
-       assert(cls->state & CLASS_LOADED);
-
-       CLASSCACHE_LOCK();
-
-#ifdef CLASSCACHE_VERBOSE
-       sprintf(logbuffer,"classcache_store_defined (%p,", (void*)cls->classloader);
-       utf_cat_classname(logbuffer, cls->name);
-       strcat(logbuffer,")");
-       log_println(logbuffer);
-#endif
-
-       en = classcache_new_name(cls->name);
-
-       assert(en);
-
-       /* iterate over all class entries */
-       for (clsen = en->classes; clsen; clsen = clsen->next) {
-               
-               /* check if this class has been defined by the same classloader */
-               if (clsen->classobj && clsen->classobj->classloader == cls->classloader) {
-                       /* we found an earlier definition, delete the newer one */
-                       /* (if it is a different classinfo)                     */
-                       if (clsen->classobj != cls) {
-#ifdef CLASSCACHE_VERBOSE
-                               log_println("replacing %p with earlier defined class %p",cls,clsen->classobj);
-#endif
-                               class_free(cls);
-                               cls = clsen->classobj;
-                       }
-                       goto return_success;
-               }
-       }
-
-       /* create a new class entry for this class object */
-       /* the list of initiating loaders is empty at this point */
-
-       clsen = NEW(classcache_class_entry);
-       clsen->classobj = cls;
-       clsen->loaders = NULL;
-       clsen->constraints = NULL;
-
-       clsen->next = en->classes;
-       en->classes = clsen;
-       CLASSCACHE_COUNT(stat_classes_stored);
-
-return_success:
-#ifdef CLASSCACHE_VERBOSE
-       classcache_debug_dump(stdout,cls->name);
-#endif
-       CLASSCACHE_UNLOCK();
-       return cls;
-}
-
-/* classcache_find_loader ******************************************************
-   Find the class entry loaded by or constrained to a given loader
-   (internally used helper function)
-  
-   IN:
-       entry............the classcache_name_entry
-       loader...........the loader to look for
-  
-   RETURN VALUE:
-       the classcache_class_entry for the given loader, or
-          NULL if no entry was found
-   
-*******************************************************************************/
-
-static classcache_class_entry * classcache_find_loader(
-                                                                       classcache_name_entry * entry,
-                                                                       classloader_t * loader)
-{
-       classcache_class_entry *clsen;
-       classcache_loader_entry *lden;
-
-       assert(entry);
-
-       /* iterate over all class entries */
-       for (clsen = entry->classes; clsen; clsen = clsen->next) {
-
-               /* check if this entry has already been loaded by initloader */
-               for (lden = clsen->loaders; lden; lden = lden->next) {
-                       if (lden->loader == loader)
-                               return clsen;   /* found */
-               }
-
-               /* check if loader is constrained to this entry */
-               for (lden = clsen->constraints; lden; lden = lden->next) {
-                       if (lden->loader == loader)
-                               return clsen;   /* found */
-               }
-       }
-
-       /* not found */
-       return NULL;
-}
-
-/* classcache_free_class_entry *************************************************
-   Free the memory used by a class entry
-  
-   IN:
-       clsen............the classcache_class_entry to free  
-          
-*******************************************************************************/
-
-static void classcache_free_class_entry(classcache_class_entry * clsen)
-{
-       classcache_loader_entry *lden;
-       classcache_loader_entry *next;
-
-       assert(clsen);
-
-       for (lden = clsen->loaders; lden; lden = next) {
-               next = lden->next;
-               FREE(lden, classcache_loader_entry);
-       }
-       for (lden = clsen->constraints; lden; lden = next) {
-               next = lden->next;
-               FREE(lden, classcache_loader_entry);
-       }
-
-       FREE(clsen, classcache_class_entry);
-}
-
-/* classcache_remove_class_entry ***********************************************
-   Remove a classcache_class_entry from the list of possible resolution of
-   a name entry
-   (internally used helper function)
-  
-   IN:
-       entry............the classcache_name_entry
-       clsen............the classcache_class_entry to remove
-  
-*******************************************************************************/
-
-static void classcache_remove_class_entry(classcache_name_entry * entry,
-                                                                                 classcache_class_entry * clsen)
-{
-       classcache_class_entry **chain;
-
-       assert(entry);
-       assert(clsen);
-
-       chain = &(entry->classes);
-       while (*chain) {
-               if (*chain == clsen) {
-                       *chain = clsen->next;
-                       classcache_free_class_entry(clsen);
-                       return;
-               }
-               chain = &((*chain)->next);
-       }
-}
-
-/* classcache_free_name_entry **************************************************
-   Free the memory used by a name entry
-  
-   IN:
-       entry............the classcache_name_entry to free  
-          
-*******************************************************************************/
-
-static void classcache_free_name_entry(classcache_name_entry * entry)
-{
-       classcache_class_entry *clsen;
-       classcache_class_entry *next;
-
-       assert(entry);
-
-       for (clsen = entry->classes; clsen; clsen = next) {
-               next = clsen->next;
-               classcache_free_class_entry(clsen);
-       }
-
-       FREE(entry, classcache_name_entry);
-}
-
-/* classcache_free *************************************************************
-   Free the memory used by the class cache
-
-   NOTE:
-       The class cache may not be used any more after this call, except
-          when it is reinitialized with classcache_init.
-  
-   Note: NOT synchronized!
-  
-*******************************************************************************/
-
-void classcache_free(void)
-{
-       u4 slot;
-       classcache_name_entry *entry;
-       classcache_name_entry *next;
-
-       for (slot = 0; slot < hashtable_classcache.size; ++slot) {
-               for (entry = (classcache_name_entry *) hashtable_classcache.ptr[slot]; entry; entry = next) {
-                       next = entry->hashlink;
-                       classcache_free_name_entry(entry);
-               }
-       }
-
-       MFREE(hashtable_classcache.ptr, voidptr, hashtable_classcache.size);
-       hashtable_classcache.size = 0;
-       hashtable_classcache.entries = 0;
-       hashtable_classcache.ptr = NULL;
-}
-
-/* classcache_add_constraint ***************************************************
-   Add a loading constraint
-  
-   IN:
-       a................first initiating loader
-       b................second initiating loader
-       classname........class name
-  
-   RETURN VALUE:
-       true.............everything ok, the constraint has been added,
-       false............an exception has been thrown.
-   
-   Note: synchronized with global tablelock
-   
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-bool classcache_add_constraint(classloader_t * a,
-                                                          classloader_t * b,
-                                                          utf * classname)
-{
-       classcache_name_entry *en;
-       classcache_class_entry *clsenA;
-       classcache_class_entry *clsenB;
-
-       assert(classname);
-
-#ifdef CLASSCACHE_VERBOSE
-       log_start();
-       log_print("classcache_add_constraint(%p,%p,", (void *) a, (void *) b);
-       utf_fprint_printable_ascii_classname(stdout, classname);
-       log_print(")\n");
-       log_finish();
-#endif
-
-       /* a constraint with a == b is trivially satisfied */
-       if (a == b) {
-               CLASSCACHE_COUNT(stat_trivial_constraints);
-               return true;
-       }
-
-       CLASSCACHE_LOCK();
-
-       en = classcache_new_name(classname);
-
-       assert(en);
-       CLASSCACHE_COUNT(stat_nontriv_constraints);
-
-       /* find the entry loaded by / constrained to each loader */
-       clsenA = classcache_find_loader(en, a);
-       clsenB = classcache_find_loader(en, b);
-
-       if (clsenA && clsenB) {
-               /* { both loaders have corresponding entries } */
-               CLASSCACHE_COUNT(stat_nontriv_constraints_both);
-
-               /* if the entries are the same, the constraint is already recorded */
-               if (clsenA == clsenB)
-                       goto return_success;
-
-               /* check if the entries can be merged */
-               if (clsenA->classobj && clsenB->classobj
-                       && clsenA->classobj != clsenB->classobj) {
-                       /* no, the constraint is violated */
-                       exceptions_throw_linkageerror("loading constraint violated: ",
-                                                                                 clsenA->classobj);
-                       goto return_exception;
-               }
-
-               /* yes, merge the entries */
-               classcache_merge_class_entries(en,clsenA,clsenB);
-               CLASSCACHE_COUNT(stat_nontriv_constraints_merged);
-       }
-       else {
-               /* { at most one of the loaders has a corresponding entry } */
-
-               /* set clsenA to the single class entry we have */
-               if (!clsenA)
-                       clsenA = clsenB;
-
-               if (!clsenA) {
-                       /* { no loader has a corresponding entry } */
-                       CLASSCACHE_COUNT(stat_nontriv_constraints_none);
-
-                       /* create a new class entry with the constraint (a,b,en->name) */
-                       clsenA = NEW(classcache_class_entry);
-                       clsenA->classobj = NULL;
-                       clsenA->loaders = NULL;
-                       clsenA->constraints = classcache_new_loader_entry(b, NULL);
-                       clsenA->constraints = classcache_new_loader_entry(a, clsenA->constraints);
-
-                       clsenA->next = en->classes;
-                       en->classes = clsenA;
-               }
-               else {
-                       CLASSCACHE_COUNT(stat_nontriv_constraints_one);
-
-                       /* make b the loader that has no corresponding entry */
-                       if (clsenB)
-                               b = a;
-
-                       /* loader b must be added to entry clsenA */
-                       clsenA->constraints = classcache_new_loader_entry(b, clsenA->constraints);
-               }
-       }
-
-  return_success:
-       CLASSCACHE_UNLOCK();
-       return true;
-
-  return_exception:
-       CLASSCACHE_UNLOCK();
-       return false;                           /* exception */
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-/* classcache_add_constraints_for_params ***************************************
-   Add loading constraints for the parameters and return type of 
-   the given method.
-  
-   IN:
-       a................first initiating loader
-       b................second initiating loader
-       m................methodinfo 
-  
-   RETURN VALUE:
-       true.............everything ok, the constraints have been added,
-       false............an exception has been thrown.
-   
-   Note: synchronized with global tablelock
-   
-*******************************************************************************/
-
-#if defined(ENABLE_VERIFIER)
-bool classcache_add_constraints_for_params(classloader_t * a,
-                                                                                  classloader_t * b,
-                                                                                  methodinfo *m)
-{
-       methoddesc *md;
-       typedesc *td;
-       s4 i;
-
-       /* a constraint with a == b is trivially satisfied */
-
-       if (a == b) {
-               return true;
-       }
-
-       /* get the parsed descriptor */
-
-       assert(m);
-       md = m->parseddesc;
-       assert(md);
-
-       /* constrain the return type */
-
-       if (md->returntype.type == TYPE_ADR) {
-               if (!classcache_add_constraint(a, b, md->returntype.classref->name))
-                       return false; /* exception */
-       }
-
-       /* constrain each reference type used in the parameters */
-
-       td = md->paramtypes;
-       i = md->paramcount;
-       for (; i--; td++) {
-               if (td->type != TYPE_ADR)
-                       continue;
-
-               if (!classcache_add_constraint(a, b, td->classref->name))
-                       return false; /* exception */
-       }
-
-       /* everything ok */
-       return true;
-}
-#endif /* defined(ENABLE_VERIFIER) */
-
-
-/* classcache_number_of_loaded_classes *****************************************
-
-   Counts the number of loaded classes and returns it.
-
-   Note: This function assumes that the CLASSCACHE_LOCK is held by the
-   caller!
-
-*******************************************************************************/
-
-static s4 classcache_number_of_loaded_classes(void)
-{
-       classcache_name_entry  *en;
-       classcache_class_entry *clsen;
-       s4                      number;
-       s4                      i;
-
-       /* initialize class counter */
-
-       number = 0;
-
-       for (i = 0; i < hashtable_classcache.size; i++) {
-               /* iterate over hashlink */
-
-               for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) {
-                       /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */
-
-                       if (en->name->text[0] == '$')
-                               continue;
-
-                       /* iterate over classes with same name */
-
-                       for (clsen = en->classes; clsen != NULL; clsen = clsen->next) {
-                               /* get only loaded classes */
-
-                               if (clsen->classobj != NULL)
-                                       number++;
-                       }
-               }
-       }
-
-       return number;
-}
-
-
-/* classcache_get_loaded_class_count *******************************************
-
-   Counts the number of loaded classes and returns it.
-
-*******************************************************************************/
-
-s4 classcache_get_loaded_class_count(void)
-{
-       s4 count;
-
-       CLASSCACHE_LOCK();
-
-       count = classcache_number_of_loaded_classes();
-       
-       CLASSCACHE_UNLOCK();
-
-       return count;
-}
-
-
-/* classcache_get_loaded_classes ***********************************************
-
-   Returns an array of all loaded classes as array.  The array is
-   allocaed on the Java heap.
-
-*******************************************************************************/
-
-#if defined(ENABLE_JVMTI)
-void classcache_get_loaded_classes(s4 *class_count_ptr,
-                                                                  classinfo ***classes_ptr)
-{
-       classinfo              **classes;
-       s4                       class_count;
-       classcache_name_entry   *en;
-       classcache_class_entry  *clsen;
-       s4                       i;
-       s4                       j;
-
-       CLASSCACHE_LOCK();
-
-       /* get the number of loaded classes and allocate the array */
-
-       class_count = classcache_number_of_loaded_classes();
-
-       classes = GCMNEW(classinfo*, class_count);
-
-       /* look in every slot of the hashtable */
-
-       for (i = 0, j = 0; i < hashtable_classcache.size; i++) {
-               /* iterate over hashlink */
-
-               for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) {
-                       /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */
-
-                       if (en->name->text[0] == '$')
-                               continue;
-
-                       /* iterate over classes with same name */
-
-                       for (clsen = en->classes; clsen != NULL; clsen = clsen->next) {
-                               /* get only loaded classes */
-
-                               if (clsen->classobj != NULL) {
-                                       classes[j] = clsen->classobj;
-                                       j++;
-                               }
-                       }
-               }
-       }
-
-       /* pass the return values */
-
-       *class_count_ptr = class_count;
-       *classes_ptr     = classes;
-
-       CLASSCACHE_UNLOCK();
-}
-#endif /* defined(ENABLE_JVMTI) */
-
-
-/* classcache_foreach_loaded_class *********************************************
-
-   Calls the given function for each loaded class.
-
-*******************************************************************************/
-
-void classcache_foreach_loaded_class(classcache_foreach_functionptr_t func,
-                                                                        void *data)
-{
-       classcache_name_entry   *en;
-       classcache_class_entry  *clsen;
-       s4                       i;
-
-       CLASSCACHE_LOCK();
-
-       /* look in every slot of the hashtable */
-
-       for (i = 0; i < hashtable_classcache.size; i++) {
-               /* iterate over hashlink */
-
-               for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) {
-                       /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */
-
-                       if (en->name->text[0] == '$')
-                               continue;
-
-                       /* iterate over classes with same name */
-
-                       for (clsen = en->classes; clsen != NULL; clsen = clsen->next) {
-                               /* get only loaded classes */
-
-                               if (clsen->classobj != NULL) {
-                                       (*func)(clsen->classobj, data);
-                               }
-                       }
-               }
-       }
-
-       CLASSCACHE_UNLOCK();
-}
-
-
-/*============================================================================*/
-/* DEBUG DUMPS                                                                */
-/*============================================================================*/
-
-/* classcache_debug_dump *******************************************************
-   Print the contents of the loaded class cache to a stream
-  
-   IN:
-       file.............output stream
-          only.............if != NULL, only print entries for this name
-                           (Currently we print also the rest of the hash chain to
-                                                get a feel for the average length of hash chains.)
-  
-   Note: synchronized with global tablelock
-   
-*******************************************************************************/
-
-#ifndef NDEBUG
-void classcache_debug_dump(FILE * file,utf *only)
-{
-       classcache_name_entry *c;
-       classcache_class_entry *clsen;
-       classcache_loader_entry *lden;
-       u4 slot;
-
-       CLASSCACHE_LOCK();
-
-       log_println("=== [loaded class cache] =====================================");
-       log_println("hash size   : %d", (int) hashtable_classcache.size);
-       log_println("hash entries: %d", (int) hashtable_classcache.entries);
-       log_println("");
-
-       if (only) {
-               c = classcache_lookup_name(only);
-               slot = 0; /* avoid compiler warning */
-               goto dump_it;
-       }
-
-       for (slot = 0; slot < hashtable_classcache.size; ++slot) {
-               c = (classcache_name_entry *) hashtable_classcache.ptr[slot];
-
-dump_it:
-               for (; c; c = c->hashlink) {
-                       utf_fprint_printable_ascii_classname(file, c->name);
-                       fprintf(file, "\n");
-
-                       /* iterate over all class entries */
-                       for (clsen = c->classes; clsen; clsen = clsen->next) {
-                               if (clsen->classobj) {
-                                       log_println("    loaded %p", (void *) clsen->classobj);
-                               }
-                               else {
-                                       log_println("    unresolved");
-                               }
-
-                               log_start();
-                               log_print("        loaders: ");
-                               for (lden = clsen->loaders; lden; lden = lden->next) {
-                                       log_print("<%p> %p ", (void *) lden, (void *) lden->loader);
-                               }
-                               log_finish();
-
-                               log_start();
-                               log_print("        constraints: ");
-                               for (lden = clsen->constraints; lden; lden = lden->next) {
-                                       log_print("<%p> %p ", (void *) lden, (void *) lden->loader);
-                               }
-                               log_finish();
-                       }
-               }
-
-               if (only)
-                       break;
-       }
-       fprintf(file, "\n==============================================================\n\n");
-
-       CLASSCACHE_UNLOCK();
-}
-#endif /* NDEBUG */
-
-/*
- * 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/vmcore/classcache.h b/src/vmcore/classcache.h
deleted file mode 100644 (file)
index bbdba5c..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/* src/vmcore/classcache.h - loaded class cache and loading constraints
-
-   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 _CLASSCACHE_H
-#define _CLASSCACHE_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include <stdio.h>  /* for FILE */
-
-#if defined(ENABLE_JVMTI)
-# include "native/jni.h"
-#endif
-
-#include "toolbox/hashtable.h"
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/references.h"
-
-
-/* forward declarations *******************************************************/
-
-typedef struct classcache_name_entry classcache_name_entry;
-typedef struct classcache_class_entry classcache_class_entry;
-typedef struct classcache_loader_entry classcache_loader_entry;
-
-/* global variables ***********************************************************/
-
-extern hashtable hashtable_classcache;
-
-
-/* structs ********************************************************************/
-
-/*----------------------------------------------------------------------------*/
-/* The Loaded Class Cache                                                     */
-/*                                                                            */
-/* The loaded class cache is implemented as a two-level data structure.       */
-/*                                                                            */
-/* The first level is a hash table indexed by class names. For each class     */
-/* name in the cache there is a classcache_name_entry, which collects all     */
-/* information about classes with this class name.                            */
-/*                                                                            */
-/* Second level: For each classcache_name_entry there is a list of            */
-/* classcache_class_entry:s representing the possible different resolutions   */
-/* of the class name.                                                         */
-/*                                                                            */
-/* A classcache_class_entry records the following:                            */
-/*                                                                            */
-/* - the loaded class object, if this entry has been resolved, otherwise NULL */
-/* - the list of initiating loaders which have resolved the class name to     */
-/*   this class object                                                        */
-/* - the list of initiating loaders which are constrained to resolve this     */
-/*   class name to this class object in the future                            */
-/*                                                                            */
-/* The classcache_class_entry:s approximate the equivalence classes created   */
-/* by the loading constraints and the equivalence of loaded classes.          */
-/*                                                                            */
-/* When a loading constraint (loaderA,loaderB,NAME) is added, then the        */
-/* classcache_class_entry:s for NAME containing loaderA and loaderB resp.     */
-/* must be merged into one entry. If this is impossible, because the entries  */
-/* have already been resolved to different class objects, then the constraint */
-/* is violated and an expception must be thrown.                              */
-/*----------------------------------------------------------------------------*/
-
-
-/* classcache_name_entry
- *
- * For each classname a classcache_name_entry struct is created.
- */
-
-struct classcache_name_entry
-{
-       utf                     *name;        /* class name                       */
-       classcache_name_entry   *hashlink;    /* link for external chaining       */
-       classcache_class_entry  *classes;     /* equivalence classes for this name*/
-};
-
-struct classcache_class_entry
-{
-       classinfo               *classobj;    /* the loaded class object, or NULL */
-       classcache_loader_entry *loaders;
-       classcache_loader_entry *constraints;
-       classcache_class_entry  *next;        /* next class entry for same name   */
-};
-
-struct classcache_loader_entry
-{
-       classloader_t            *loader;     /* class loader object              */
-       classcache_loader_entry  *next;       /* next loader entry in the list    */
-};
-
-
-/* callback function type for  classcache_foreach_loaded_class */
-
-typedef void (*classcache_foreach_functionptr_t)(classinfo *, void *);
-
-
-/* function prototypes ********************************************************/
-
-/* initialize the loaded class cache */
-bool classcache_init(void);
-void classcache_free(void);
-
-classinfo * classcache_lookup(classloader_t *initloader,utf *classname);
-classinfo * classcache_lookup_defined(classloader_t *defloader,utf *classname);
-classinfo * classcache_lookup_defined_or_initiated(classloader_t *loader,utf *classname);
-
-bool classcache_store_unique(classinfo *cls);
-classinfo * classcache_store(classloader_t *initloader,classinfo *cls,bool mayfree);
-classinfo * classcache_store_defined(classinfo *cls);
-
-#if defined(ENABLE_VERIFIER)
-bool classcache_add_constraint(classloader_t *a,classloader_t *b,utf *classname);
-bool classcache_add_constraints_for_params(classloader_t *a,classloader_t *b,
-                                                                                  methodinfo *m);
-#endif
-
-s4 classcache_get_loaded_class_count(void);
-
-void classcache_foreach_loaded_class(classcache_foreach_functionptr_t func,
-                                                                        void *data);
-
-#if defined(ENABLE_JVMTI)
-void classcache_get_loaded_classes(s4 *class_count_ptr,
-                                                                  classinfo ***classes_ptr);
-#endif
-
-#ifndef NDEBUG
-void classcache_debug_dump(FILE *file,utf *only);
-#endif
-       
-#endif /* _CLASSCACHE_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/vmcore/descriptor.c b/src/vmcore/descriptor.c
deleted file mode 100644 (file)
index f49e050..0000000
+++ /dev/null
@@ -1,1398 +0,0 @@
-/* src/vmcore/descriptor.c - checking and parsing of field / method descriptors
-
-   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 "vm/types.h"
-
-#include "md-abi.h"
-
-#include "mm/memory.h"
-
-#include "vm/exceptions.h"
-#include "vm/jit_interface.h"
-#include "vm/primitive.h"
-#include "vm/vm.h"
-
-#include "vmcore/descriptor.h"
-#include "vmcore/options.h"
-
-
-/* constants (private to descriptor.c) ****************************************/
-
-/* initial number of entries for the classrefhash of a descriptor_pool */
-/* (currently the hash is never grown!) */
-#define CLASSREFHASH_INIT_SIZE  64
-
-/* initial number of entries for the descriptorhash of a descriptor_pool */
-/* (currently the hash is never grown!) */
-#define DESCRIPTORHASH_INIT_SIZE  128
-
-/* data structures (private to descriptor.c) **********************************/
-
-typedef struct classref_hash_entry classref_hash_entry;
-typedef struct descriptor_hash_entry descriptor_hash_entry;
-
-/* entry struct for the classrefhash of descriptor_pool */
-struct classref_hash_entry {
-       classref_hash_entry *hashlink;  /* for hash chaining            */
-       utf                 *name;      /* name of the class refered to */
-       u2                   index;     /* index into classref table    */
-};
-
-/* entry struct for the descriptorhash of descriptor_pool */
-struct descriptor_hash_entry {
-       descriptor_hash_entry *hashlink;
-       utf                   *desc;
-       parseddesc_t           parseddesc;
-       s2                     paramslots; /* number of params, LONG/DOUBLE counted as 2 */
-};
-
-
-/****************************************************************************/
-/* MACROS FOR DESCRIPTOR PARSING (private to descriptor.c)                  */
-/****************************************************************************/
-
-/* SKIP_FIELDDESCRIPTOR:
- * utf_ptr must point to the first character of a field descriptor.
- * After the macro call utf_ptr points to the first character after
- * the field descriptor.
- *
- * CAUTION: This macro does not check for an unexpected end of the
- * descriptor. Better use SKIP_FIELDDESCRIPTOR_SAFE.
- */
-#define SKIP_FIELDDESCRIPTOR(utf_ptr)                                                  \
-       do { while (*(utf_ptr)=='[') (utf_ptr)++;                                       \
-               if (*(utf_ptr)++=='L')                                                                  \
-                       while(*(utf_ptr)++ != ';') /* skip */; } while(0)
-
-/* SKIP_FIELDDESCRIPTOR_SAFE:
- * utf_ptr must point to the first character of a field descriptor.
- * After the macro call utf_ptr points to the first character after
- * the field descriptor.
- *
- * Input:
- *     utf_ptr....points to first char of descriptor
- *     end_ptr....points to first char after the end of the string
- *     errorflag..must be initialized (to false) by the caller!
- * Output:
- *     utf_ptr....points to first char after the descriptor
- *     errorflag..set to true if the string ended unexpectedly
- */
-#define SKIP_FIELDDESCRIPTOR_SAFE(utf_ptr,end_ptr,errorflag)                   \
-       do { while ((utf_ptr) != (end_ptr) && *(utf_ptr)=='[') (utf_ptr)++;     \
-               if ((utf_ptr) == (end_ptr))                                                                             \
-                       (errorflag) = true;                                                                                     \
-               else                                                                                                                    \
-                       if (*(utf_ptr)++=='L') {                                                                        \
-                               while((utf_ptr) != (end_ptr) && *(utf_ptr)++ != ';')    \
-                                       /* skip */;                                                                                     \
-                               if ((utf_ptr)[-1] != ';')                                                               \
-                                       (errorflag) = true; }} while(0)
-
-
-/****************************************************************************/
-/* DEBUG HELPERS                                                            */
-/****************************************************************************/
-
-/*#define DESCRIPTOR_VERBOSE*/
-
-/****************************************************************************/
-/* FUNCTIONS                                                                */
-/****************************************************************************/
-
-/* descriptor_to_basic_type ****************************************************
-
-   Return the basic type to use for a value with this descriptor.
-
-   IN:
-       utf..............descriptor utf string
-
-   OUT:
-       A TYPE_* constant.
-
-   PRECONDITIONS:
-       This function assumes that the descriptor has passed 
-          descriptor_pool_add checks and that it does not start with '('.
-
-*******************************************************************************/
-
-int descriptor_to_basic_type(utf *descriptor)
-{
-       assert(descriptor->blength >= 1);
-       
-       switch (descriptor->text[0]) {
-       case 'Z':
-       case 'B':
-       case 'C':
-       case 'S':
-       case 'I':
-               return TYPE_INT;
-
-       case 'J':
-               return TYPE_LNG;
-
-       case 'F':
-               return TYPE_FLT;
-
-       case 'D':
-               return TYPE_DBL;
-
-       case 'L':
-       case '[':
-               return TYPE_ADR;
-
-       default:
-               vm_abort("descriptor_to_basic_type: invalid type %c",
-                                descriptor->text[0]);
-       }
-
-       /* keep the compiler happy */
-
-       return 0;
-}
-
-
-/* descriptor_typesize *********************************************************
-
-   Return the size in bytes needed for the given type.
-
-   IN:
-       td..............typedesc describing the type
-
-   OUT:
-       The number of bytes
-
-*******************************************************************************/
-
-int descriptor_typesize(typedesc *td)
-{
-       assert(td);
-
-       switch (td->type) {
-       case TYPE_INT:
-       case TYPE_FLT:
-               return 4;
-
-       case TYPE_LNG:
-       case TYPE_DBL:
-               return 8;
-
-       case TYPE_ADR:
-               return SIZEOF_VOID_P;
-
-       default:
-               vm_abort("descriptor_typesize: invalid type %d", td->type);
-       }
-
-       /* keep the compiler happy */
-
-       return 0;
-}
-
-
-/* name_from_descriptor ********************************************************
-
-   Return the class name indicated by the given descriptor
-   (Internally used helper function)
-
-   IN:
-       c................class containing the descriptor
-       utf_ptr..........first character of descriptor
-       end_ptr..........first character after the end of the string
-       mode.............a combination (binary or) of the following flags:
-
-               (Flags marked with * are the default settings.)
-
-               How to handle "V" descriptors:
-
-                            * DESCRIPTOR_VOID.....handle it like other primitive types
-                   DESCRIPTOR_NOVOID...treat it as an error
-
-               How to deal with extra characters after the end of the
-               descriptor:
-
-                            * DESCRIPTOR_NOCHECKEND...ignore (useful for parameter lists)
-                   DESCRIPTOR_CHECKEND.....treat them as an error
-
-   OUT:
-       *next............if non-NULL, *next is set to the first character after
-                        the descriptor. (Undefined if an error occurs.)
-       *name............set to the utf name of the class
-
-   RETURN VALUE:
-       true.............descriptor parsed successfully
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-#define DESCRIPTOR_VOID          0      /* default */
-#define DESCRIPTOR_NOVOID        0x0040
-#define DESCRIPTOR_NOCHECKEND    0      /* default */
-#define DESCRIPTOR_CHECKEND      0x1000
-
-static bool 
-name_from_descriptor(classinfo *c,
-                                        char *utf_ptr, char *end_ptr,
-                                        char **next, int mode, utf **name)
-{
-       char *start = utf_ptr;
-       bool error = false;
-
-       assert(c);
-       assert(utf_ptr);
-       assert(end_ptr);
-       assert(name);
-       
-       *name = NULL;           
-       SKIP_FIELDDESCRIPTOR_SAFE(utf_ptr, end_ptr, error);
-
-       if (mode & DESCRIPTOR_CHECKEND)
-               error |= (utf_ptr != end_ptr);
-       
-       if (!error) {
-               if (next) *next = utf_ptr;
-               
-               switch (*start) {
-                 case 'V':
-                         if (mode & DESCRIPTOR_NOVOID)
-                                 break;
-                         /* FALLTHROUGH! */
-                 case 'I':
-                 case 'J':
-                 case 'F':
-                 case 'D':
-                 case 'B':
-                 case 'C':
-                 case 'S':
-                 case 'Z':
-                         return true;
-                         
-                 case 'L':
-                         start++;
-                         utf_ptr--;
-                         /* FALLTHROUGH! */
-                 case '[':
-                         *name = utf_new(start, utf_ptr - start);
-                         return true;
-               }
-       }
-
-       exceptions_throw_classformaterror(c, "Invalid descriptor");
-       return false;
-}
-
-
-/* descriptor_to_typedesc ******************************************************
-   Parse the given type descriptor and fill a typedesc struct
-   (Internally used helper function)
-
-   IN:
-       pool.............the descriptor pool
-          utf_ptr..........points to first character of type descriptor
-          end_pos..........points after last character of the whole descriptor
-
-   OUT:
-       *next............set to next character after type descriptor
-          *d...............filled with parsed information
-
-   RETURN VALUE:
-       true.............parsing succeeded  
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-static bool
-descriptor_to_typedesc(descriptor_pool *pool, char *utf_ptr, char *end_pos,
-                                          char **next, typedesc *td)
-{
-       utf *name;
-       
-       if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, next, 0, &name))
-               return false;
-
-       if (name) {
-               /* a reference type */
-               td->type = TYPE_ADR;
-               td->decltype = TYPE_ADR;
-               td->arraydim = 0;
-               for (utf_ptr = name->text; *utf_ptr == '['; ++utf_ptr)
-                       td->arraydim++;
-               td->classref = descriptor_pool_lookup_classref(pool, name);
-
-       } else {
-               /* a primitive type */
-               switch (*utf_ptr) {
-               case 'B': 
-                       td->decltype = PRIMITIVETYPE_BYTE;
-                       td->type = TYPE_INT;
-                       break;
-               case 'C':
-                       td->decltype = PRIMITIVETYPE_CHAR;
-                       td->type = TYPE_INT;
-                       break;
-               case 'S':  
-                       td->decltype = PRIMITIVETYPE_SHORT;
-                       td->type = TYPE_INT;
-                       break;
-               case 'Z':
-                       td->decltype = PRIMITIVETYPE_BOOLEAN;
-                       td->type = TYPE_INT;
-                       break;
-               case 'I':
-                       td->decltype = PRIMITIVETYPE_INT;
-                       td->type = TYPE_INT;
-                       break;
-               case 'D':
-                       td->decltype = PRIMITIVETYPE_DOUBLE;
-                       td->type = TYPE_DBL;
-                       break;
-               case 'F':
-                       td->decltype = PRIMITIVETYPE_FLOAT;
-                       td->type = TYPE_FLT;
-                       break;
-               case 'J':
-                       td->decltype = PRIMITIVETYPE_LONG;
-                       td->type = TYPE_LNG;
-                       break;
-               case 'V':
-                       td->decltype = PRIMITIVETYPE_VOID;
-                       td->type = TYPE_VOID;
-                       break;
-               default:
-                       assert(false);
-               }
-
-               td->arraydim = 0;
-               td->classref = NULL;
-       }
-
-       return true;
-}
-
-
-/* descriptor_pool_new *********************************************************
-   Allocate a new descriptor_pool
-
-   IN:
-       referer..........class for which to create the pool
-
-   RETURN VALUE:
-       a pointer to the new descriptor_pool
-
-*******************************************************************************/
-
-descriptor_pool * 
-descriptor_pool_new(classinfo *referer)
-{
-       descriptor_pool *pool;
-       u4 hashsize;
-       u4 slot;
-
-       pool = DNEW(descriptor_pool);
-       assert(pool);
-
-       pool->referer = referer;
-       pool->fieldcount = 0;
-       pool->methodcount = 0;
-       pool->paramcount = 0;
-       pool->descriptorsize = 0;
-       pool->descriptors = NULL;
-       pool->descriptors_next = NULL;
-       pool->classrefs = NULL;
-       pool->descriptor_kind = NULL;
-       pool->descriptor_kind_next = NULL;
-
-       hashsize = CLASSREFHASH_INIT_SIZE;
-       pool->classrefhash.size = hashsize;
-       pool->classrefhash.entries = 0;
-       pool->classrefhash.ptr = DMNEW(voidptr,hashsize);
-       for (slot=0; slot<hashsize; ++slot)
-               pool->classrefhash.ptr[slot] = NULL;
-
-       hashsize = DESCRIPTORHASH_INIT_SIZE;
-       pool->descriptorhash.size = hashsize;
-       pool->descriptorhash.entries = 0;
-       pool->descriptorhash.ptr = DMNEW(voidptr,hashsize);
-       for (slot=0; slot<hashsize; ++slot)
-               pool->descriptorhash.ptr[slot] = NULL;
-
-       return pool;
-}
-
-
-/* descriptor_pool_add_class ***************************************************
-   Add the given class reference to the pool
-
-   IN:
-       pool.............the descriptor_pool
-          name.............the class reference to add
-
-   RETURN VALUE:
-       true.............reference has been added
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-bool 
-descriptor_pool_add_class(descriptor_pool *pool, utf *name)
-{
-       u4 key,slot;
-       classref_hash_entry *c;
-       
-       assert(pool);
-       assert(name);
-
-#ifdef DESCRIPTOR_VERBOSE
-       fprintf(stderr,"descriptor_pool_add_class(%p,",(void*)pool);
-       utf_fprint_printable_ascii(stderr,name);fprintf(stderr,")\n");
-#endif
-
-       /* find a place in the hashtable */
-
-       key = utf_hashkey(name->text, name->blength);
-       slot = key & (pool->classrefhash.size - 1);
-       c = (classref_hash_entry *) pool->classrefhash.ptr[slot];
-
-       while (c) {
-               if (c->name == name)
-                       return true; /* already stored */
-               c = c->hashlink;
-       }
-
-       /* check if the name is a valid classname */
-
-       if (!is_valid_name(name->text,UTF_END(name))) {
-               exceptions_throw_classformaterror(pool->referer, "Invalid class name");
-               return false; /* exception */
-       }
-
-       /* XXX check maximum array dimension */
-       
-       c = DNEW(classref_hash_entry);
-       c->name = name;
-       c->index = pool->classrefhash.entries++;
-       c->hashlink = (classref_hash_entry *) pool->classrefhash.ptr[slot];
-       pool->classrefhash.ptr[slot] = c;
-
-       return true;
-}
-
-
-/* descriptor_pool_add *********************************************************
-   Check the given descriptor and add it to the pool
-
-   IN:
-       pool.............the descriptor_pool
-          desc.............the descriptor to add. Maybe a field or method desc.
-
-   OUT:
-       *paramslots......if non-NULL, set to the number of parameters.
-                           LONG and DOUBLE are counted twice
-
-   RETURN VALUE:
-       true.............descriptor has been added
-          false............an exception has been thrown
-
-*******************************************************************************/
-
-bool 
-descriptor_pool_add(descriptor_pool *pool, utf *desc, int *paramslots)
-{
-       u4 key,slot;
-       descriptor_hash_entry *d;
-       char *utf_ptr;
-       char *end_pos;
-       utf *name;
-       s4 argcount = 0;
-       
-#ifdef DESCRIPTOR_VERBOSE
-       fprintf(stderr,"descriptor_pool_add(%p,",(void*)pool);
-       utf_fprint_printable_ascii(stderr,desc);fprintf(stderr,")\n");
-#endif
-
-       assert(pool);
-       assert(desc);
-
-       /* find a place in the hashtable */
-
-       key = utf_hashkey(desc->text, desc->blength);
-       slot = key & (pool->descriptorhash.size - 1);
-       d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot];
-
-       /* Save all method descriptors in the hashtable, since the parsed         */
-       /* descriptor may vary between differenf methods (static vs. non-static). */
-
-       utf_ptr = desc->text;
-
-       if (*utf_ptr != '(') {
-               while (d) {
-                       if (d->desc == desc) {
-                               if (paramslots)
-                                       *paramslots = d->paramslots;
-                               return true; /* already stored */
-                       }
-                       d = d->hashlink;
-               }
-       }
-
-       /* add the descriptor to the pool */
-
-       d = DNEW(descriptor_hash_entry);
-       d->desc = desc;
-       d->parseddesc.any = NULL;
-       d->hashlink = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot];
-       pool->descriptorhash.ptr[slot] = d;
-
-       /* now check the descriptor */
-
-       end_pos = UTF_END(desc);
-       
-       if (*utf_ptr == '(') {
-               /* a method descriptor */
-
-               pool->methodcount++;
-               utf_ptr++;
-
-               /* check arguments */
-
-               while ((utf_ptr != end_pos) && (*utf_ptr != ')')) {
-                       pool->paramcount++;
-
-                       /* We cannot count the `this' argument here because
-                        * we don't know if the method is static. */
-
-                       if (*utf_ptr == 'J' || *utf_ptr == 'D')
-                               argcount += 2;
-                       else
-                               argcount++;
-
-                       if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, &utf_ptr,
-                                                                     DESCRIPTOR_NOVOID, &name))
-                               return false;
-
-                       if (name)
-                               if (!descriptor_pool_add_class(pool, name))
-                                       return false;
-               }
-
-               if (utf_ptr == end_pos) {
-                       exceptions_throw_classformaterror(pool->referer,
-                                                                                         "Missing ')' in method descriptor");
-                       return false;
-               }
-
-               utf_ptr++; /* skip ')' */
-
-               if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, NULL,
-                                                                 DESCRIPTOR_CHECKEND, &name))
-                       return false;
-
-               if (name)
-                       if (!descriptor_pool_add_class(pool,name))
-                               return false;
-
-               if (argcount > 255) {
-                       exceptions_throw_classformaterror(pool->referer,
-                                                                                         "Too many arguments in signature");
-                       return false;
-               }
-
-       } else {
-               /* a field descriptor */
-
-               pool->fieldcount++;
-               
-           if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, NULL,
-                                                         DESCRIPTOR_NOVOID | DESCRIPTOR_CHECKEND,
-                                                                 &name))
-                       return false;
-
-               if (name)
-                       if (!descriptor_pool_add_class(pool,name))
-                               return false;
-       }
-
-       d->paramslots = argcount;
-
-       if (paramslots)
-               *paramslots = argcount;
-
-       return true;
-}
-
-
-/* descriptor_pool_create_classrefs ********************************************
-   Create a table containing all the classrefs which were added to the pool
-
-   IN:
-       pool.............the descriptor_pool
-
-   OUT:
-       *count...........if count is non-NULL, this is set to the number
-                           of classrefs in the table
-
-   RETURN VALUE:
-       a pointer to the constant_classref table
-
-*******************************************************************************/
-
-constant_classref * 
-descriptor_pool_create_classrefs(descriptor_pool *pool, s4 *count)
-{
-       u4 nclasses;
-       u4 slot;
-       classref_hash_entry *c;
-       constant_classref *ref;
-       
-       assert(pool);
-
-       nclasses = pool->classrefhash.entries;
-       pool->classrefs = MNEW(constant_classref,nclasses);
-
-       /* fill the constant_classref structs */
-
-       for (slot = 0; slot < pool->classrefhash.size; ++slot) {
-               c = (classref_hash_entry *) pool->classrefhash.ptr[slot];
-               while (c) {
-                       ref = pool->classrefs + c->index;
-                       CLASSREF_INIT(*ref, pool->referer, c->name);
-                       c = c->hashlink;
-               }
-       }
-
-       if (count)
-               *count = nclasses;
-
-       return pool->classrefs;
-}
-
-
-/* descriptor_pool_lookup_classref *********************************************
-   Return the constant_classref for the given class name
-
-   IN:
-       pool.............the descriptor_pool
-          classname........name of the class to look up
-
-   RETURN VALUE:
-       a pointer to the constant_classref, or
-          NULL if an exception has been thrown
-
-*******************************************************************************/
-
-constant_classref * 
-descriptor_pool_lookup_classref(descriptor_pool *pool, utf *classname)
-{
-       u4 key,slot;
-       classref_hash_entry *c;
-
-       assert(pool);
-       assert(pool->classrefs);
-       assert(classname);
-
-       key = utf_hashkey(classname->text, classname->blength);
-       slot = key & (pool->classrefhash.size - 1);
-       c = (classref_hash_entry *) pool->classrefhash.ptr[slot];
-
-       while (c) {
-               if (c->name == classname)
-                       return pool->classrefs + c->index;
-               c = c->hashlink;
-       }
-
-       exceptions_throw_internalerror("Class reference not found in descriptor pool");
-       return NULL;
-}
-
-
-/* descriptor_pool_alloc_parsed_descriptors ************************************
-   Allocate space for the parsed descriptors
-
-   IN:
-       pool.............the descriptor_pool
-
-   NOTE:
-       This function must be called after all descriptors have been added
-          with descriptor_pool_add.
-
-*******************************************************************************/
-
-void 
-descriptor_pool_alloc_parsed_descriptors(descriptor_pool *pool)
-{
-       u4 size;
-       
-       assert(pool);
-
-       /* TWISTI: paramcount + 1: we don't know if the method is static or   */
-       /* not, i have no better solution yet.                                */
-
-       size =
-               pool->fieldcount * sizeof(typedesc) +
-               pool->methodcount * (sizeof(methoddesc) - sizeof(typedesc)) +
-               pool->paramcount * sizeof(typedesc) +
-               pool->methodcount * sizeof(typedesc);      /* possible `this' pointer */
-
-       pool->descriptorsize = size;
-       if (size) {
-               pool->descriptors = MNEW(u1, size);
-               pool->descriptors_next = pool->descriptors;
-       }
-
-       size = pool->fieldcount + pool->methodcount;
-       if (size) {
-               pool->descriptor_kind = DMNEW(u1, size);
-               pool->descriptor_kind_next = pool->descriptor_kind;
-       }
-}
-
-
-/* descriptor_pool_parse_field_descriptor **************************************
-   Parse the given field descriptor
-
-   IN:
-       pool.............the descriptor_pool
-          desc.............the field descriptor
-
-   RETURN VALUE:
-       a pointer to the parsed field descriptor, or
-          NULL if an exception has been thrown
-
-   NOTE:
-       descriptor_pool_alloc_parsed_descriptors must be called (once)
-       before this function is used.
-
-*******************************************************************************/
-
-typedesc * 
-descriptor_pool_parse_field_descriptor(descriptor_pool *pool, utf *desc)
-{
-       u4 key,slot;
-       descriptor_hash_entry *d;
-       typedesc *td;
-
-       assert(pool);
-       assert(pool->descriptors);
-       assert(pool->descriptors_next);
-
-       /* lookup the descriptor in the hashtable */
-
-       key = utf_hashkey(desc->text, desc->blength);
-       slot = key & (pool->descriptorhash.size - 1);
-       d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot];
-
-       while (d) {
-               if (d->desc == desc) {
-                       /* found */
-                       if (d->parseddesc.fd)
-                               return d->parseddesc.fd;
-                       break;
-               }
-               d = d->hashlink;
-       }
-
-       assert(d);
-       
-       if (desc->text[0] == '(') {
-               exceptions_throw_classformaterror(pool->referer,
-                                                                                 "Method descriptor used in field reference");
-               return NULL;
-       }
-
-       td = (typedesc *) pool->descriptors_next;
-       pool->descriptors_next += sizeof(typedesc);
-       
-       if (!descriptor_to_typedesc(pool, desc->text, UTF_END(desc), NULL, td))
-               return NULL;
-
-       *(pool->descriptor_kind_next++) = 'f';
-
-       d->parseddesc.fd = td;
-
-       return td;
-}
-
-
-/* descriptor_pool_parse_method_descriptor *************************************
-   Parse the given method descriptor
-
-   IN:
-       pool.............the descriptor_pool
-       desc.............the method descriptor
-       mflags...........the method flags
-          thisclass........classref to the class containing the method.
-                                               This is ignored if mflags contains ACC_STATIC.
-                                               The classref is stored for inserting the 'this' argument.
-
-   RETURN VALUE:
-       a pointer to the parsed method descriptor, or
-          NULL if an exception has been thrown
-
-   NOTE: 
-       descriptor_pool_alloc_parsed_descriptors must be called
-       (once) before this function is used.
-
-*******************************************************************************/
-
-methoddesc * 
-descriptor_pool_parse_method_descriptor(descriptor_pool *pool, utf *desc,
-                                                                               s4 mflags,constant_classref *thisclass)
-{
-       u4 key, slot;
-       descriptor_hash_entry *d;
-       methoddesc            *md;
-       typedesc              *td;
-       char *utf_ptr;
-       char *end_pos;
-       s2 paramcount = 0;
-       s2 paramslots = 0;
-
-#ifdef DESCRIPTOR_VERBOSE
-       fprintf(stderr,"descriptor_pool_parse_method_descriptor(%p,%d,%p,",
-                       (void*)pool,(int)mflags,(void*)thisclass);
-       utf_fprint_printable_ascii(stderr,desc); fprintf(stderr,")\n");
-#endif
-
-       assert(pool);
-       assert(pool->descriptors);
-       assert(pool->descriptors_next);
-
-       /* check that it is a method descriptor */
-       
-       if (desc->text[0] != '(') {
-               exceptions_throw_classformaterror(pool->referer,
-                                                                                 "Field descriptor used in method reference");
-               return NULL;
-       }
-
-       /* lookup the descriptor in the hashtable */
-
-       key = utf_hashkey(desc->text, desc->blength);
-       slot = key & (pool->descriptorhash.size - 1);
-       d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot];
-
-       /* find an un-parsed descriptor */
-
-       while (d) {
-               if (d->desc == desc)
-                       if (!d->parseddesc.md)
-                               break;
-               d = d->hashlink;
-       }
-
-       assert(d);
-
-       md = (methoddesc *) pool->descriptors_next;
-       pool->descriptors_next += sizeof(methoddesc) - sizeof(typedesc);
-
-       utf_ptr = desc->text + 1; /* skip '(' */
-       end_pos = UTF_END(desc);
-
-       td = md->paramtypes;
-
-       /* count the `this' pointer */
-
-       if ((mflags != ACC_UNDEF) && !(mflags & ACC_STATIC)) {
-               td->type = TYPE_ADR;
-               td->decltype = TYPE_ADR;
-               td->arraydim = 0;
-               td->classref = thisclass;
-
-               td++;
-               pool->descriptors_next += sizeof(typedesc);
-               paramcount++;
-               paramslots++;
-       }
-
-       while (*utf_ptr != ')') {
-               /* parse a parameter type */
-
-               if (!descriptor_to_typedesc(pool, utf_ptr, end_pos, &utf_ptr, td))
-                       return NULL;
-
-               if (IS_2_WORD_TYPE(td->type))
-                       paramslots++;
-               
-               td++;
-               pool->descriptors_next += sizeof(typedesc);
-               paramcount++;
-               paramslots++;
-       }
-       utf_ptr++; /* skip ')' */
-
-       /* Skip possible `this' pointer in paramtypes array to allow a possible   */
-       /* memory move later in parse.                                            */
-       /* We store the thisclass reference, so we can later correctly fill in    */
-       /* the parameter slot of the 'this' argument.                             */
-
-       if (mflags == ACC_UNDEF) {
-               td->classref = thisclass;
-               td++;
-               pool->descriptors_next += sizeof(typedesc);
-       }
-
-       /* parse return type */
-
-       if (!descriptor_to_typedesc(pool, utf_ptr, end_pos, NULL,
-                                                               &(md->returntype)))
-               return NULL;
-
-       md->paramcount = paramcount;
-       md->paramslots = paramslots;
-
-       /* If mflags != ACC_UNDEF we parse a real loaded method, so do
-          param prealloc.  Otherwise we do this in stack analysis. */
-
-       if (mflags != ACC_UNDEF) {
-               if (md->paramcount > 0) {
-                       /* allocate memory for params */
-
-                       md->params = MNEW(paramdesc, md->paramcount);
-               }
-               else {
-                       md->params = METHODDESC_NOPARAMS;
-               }
-
-               /* fill the paramdesc */
-               /* md_param_alloc has to be called if md->paramcount == 0,
-                  too, so it can make the reservation for the Linkage Area,
-                  Return Register... */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-               if (!opt_intrp)
-# endif
-                       {
-                               /* As builtin-functions are native functions, we have
-                                  to pre-allocate for the native ABI. */
-
-                               if (mflags & ACC_METHOD_BUILTIN)
-                                       md_param_alloc_native(md);
-                               else
-                                       md_param_alloc(md);
-                       }
-#endif
-       }
-       else {
-               /* params will be allocated later by
-                  descriptor_params_from_paramtypes if necessary */
-
-               md->params = NULL;
-       }
-
-       *(pool->descriptor_kind_next++) = 'm';
-
-       d->parseddesc.md = md;
-
-       return md;
-}
-
-/* descriptor_params_from_paramtypes *******************************************
-   Create the paramdescs for a method descriptor. This function is called
-   when we know whether the method is static or not. This function may only
-   be called once for each methoddesc, and only if md->params == NULL.
-
-   IN:
-       md...............the parsed method descriptor
-                           md->params MUST be NULL.
-          mflags...........the ACC_* access flags of the method. Only the
-                           ACC_STATIC bit is checked.
-                                               The value ACC_UNDEF is NOT allowed.
-
-   RETURN VALUE:
-       true.............the paramdescs were created successfully
-          false............an exception has been thrown
-
-   POSTCONDITION:
-       md->parms != NULL
-
-*******************************************************************************/
-
-bool descriptor_params_from_paramtypes(methoddesc *md, s4 mflags)
-{
-       typedesc *td;
-
-       assert(md);
-       assert(md->params == NULL);
-       assert(mflags != ACC_UNDEF);
-
-       td = md->paramtypes;
-
-       /* check for `this' pointer */
-
-       if (!(mflags & ACC_STATIC)) {
-               constant_classref *thisclass;
-
-               /* fetch class reference from reserved param slot */
-               thisclass = td[md->paramcount].classref;
-               assert(thisclass);
-
-               if (md->paramcount > 0) {
-                       /* shift param types by 1 argument */
-                       MMOVE(td + 1, td, typedesc, md->paramcount);
-               }
-
-               /* fill in first argument `this' */
-
-               td->type = TYPE_ADR;
-               td->decltype = TYPE_ADR;
-               td->arraydim = 0;
-               td->classref = thisclass;
-
-               md->paramcount++;
-               md->paramslots++;
-       }
-
-       /* if the method has params, process them */
-
-       if (md->paramcount > 0) {
-               /* allocate memory for params */
-
-               md->params = MNEW(paramdesc, md->paramcount);
-
-       } else {
-               md->params = METHODDESC_NOPARAMS;
-       }
-
-       /* fill the paramdesc */
-       /* md_param_alloc has to be called if md->paramcount == 0, too, so
-          it can make the reservation for the Linkage Area, Return
-          Register.. */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (!opt_intrp)
-# endif
-               {
-                       /* As builtin-functions are native functions, we have to
-                          pre-allocate for the native ABI. */
-
-                       if (mflags & ACC_METHOD_BUILTIN)
-                               md_param_alloc_native(md);
-                       else
-                               md_param_alloc(md);
-               }
-#endif
-
-       return true;
-}
-
-
-/* descriptor_pool_get_parsed_descriptors **************************************
-   Return a pointer to the block of parsed descriptors
-
-   IN:
-       pool.............the descriptor_pool
-
-   OUT:
-          *size............if size is non-NULL, this is set to the size of the
-                           parsed descriptor block (in u1)
-
-   RETURN VALUE:
-       a pointer to the block of parsed descriptors
-
-   NOTE:
-       descriptor_pool_alloc_parsed_descriptors must be called (once)
-       before this function is used.
-
-*******************************************************************************/
-
-void * 
-descriptor_pool_get_parsed_descriptors(descriptor_pool *pool, s4 *size)
-{
-       assert(pool);
-       assert((!pool->fieldcount && !pool->methodcount) || pool->descriptors);
-       
-       if (size)
-               *size = pool->descriptorsize;
-
-       return pool->descriptors;
-}
-
-
-/* descriptor_pool_get_sizes ***************************************************
-   Get the sizes of the class reference table and the parsed descriptors
-
-   IN:
-       pool.............the descriptor_pool
-
-   OUT:
-       *classrefsize....set to size of the class reference table
-          *descsize........set to size of the parsed descriptors
-
-   NOTE:
-       This function may only be called after both
-              descriptor_pool_create_classrefs, and
-                  descriptor_pool_alloc_parsed_descriptors
-          have been called.
-
-*******************************************************************************/
-
-void 
-descriptor_pool_get_sizes(descriptor_pool *pool, u4 *classrefsize, u4 *descsize)
-{
-       assert(pool);
-       assert((!pool->fieldcount && !pool->methodcount) || pool->descriptors);
-       assert(pool->classrefs);
-       assert(classrefsize);
-       assert(descsize);
-
-       *classrefsize = pool->classrefhash.entries * sizeof(constant_classref);
-       *descsize = pool->descriptorsize;
-}
-
-
-/****************************************************************************/
-/* DEBUG HELPERS                                                            */
-/****************************************************************************/
-
-#ifndef NDEBUG
-/* descriptor_debug_print_typedesc *********************************************
-   Print the given typedesc to the given stream
-
-   IN:
-          file.............stream to print to
-          d................the parsed descriptor
-
-*******************************************************************************/
-
-void 
-descriptor_debug_print_typedesc(FILE *file,typedesc *d)
-{
-       int ch;
-
-       if (!d) {
-               fprintf(file,"(typedesc *)NULL");
-               return;
-       }
-       
-       if (d->type == TYPE_ADR) {
-               if (d->classref)
-                       utf_fprint_printable_ascii(file,d->classref->name);
-               else
-                       fprintf(file,"<class=NULL>");
-       }
-       else {
-               switch (d->decltype) {
-                       case PRIMITIVETYPE_INT    : ch='I'; break;
-                       case PRIMITIVETYPE_CHAR   : ch='C'; break;
-                       case PRIMITIVETYPE_BYTE   : ch='B'; break;
-                       case PRIMITIVETYPE_SHORT  : ch='S'; break;
-                       case PRIMITIVETYPE_BOOLEAN: ch='Z'; break;
-                       case PRIMITIVETYPE_LONG   : ch='J'; break;
-                       case PRIMITIVETYPE_FLOAT  : ch='F'; break;
-                       case PRIMITIVETYPE_DOUBLE : ch='D'; break;
-                       case PRIMITIVETYPE_VOID   : ch='V'; break;
-                       default                   : ch='!';
-               }
-               fputc(ch,file);
-       }
-       if (d->arraydim)
-               fprintf(file,"[%d]",d->arraydim);
-}
-
-/* descriptor_debug_print_paramdesc ********************************************
-   Print the given paramdesc to the given stream
-
-   IN:
-          file.............stream to print to
-          d................the parameter descriptor
-
-*******************************************************************************/
-
-void
-descriptor_debug_print_paramdesc(FILE *file,paramdesc *d)
-{
-       if (!d) {
-               fprintf(file,"(paramdesc *)NULL");
-               return;
-       }
-       
-       if (d->inmemory) {
-               fprintf(file,"<m%d>",d->regoff);
-       }
-       else {
-               fprintf(file,"<r%d>",d->regoff);
-       }
-}
-
-/* descriptor_debug_print_methoddesc *******************************************
-   Print the given methoddesc to the given stream
-
-   IN:
-          file.............stream to print to
-          d................the parsed descriptor
-
-*******************************************************************************/
-
-void 
-descriptor_debug_print_methoddesc(FILE *file,methoddesc *d)
-{
-       int i;
-       
-       if (!d) {
-               fprintf(file,"(methoddesc *)NULL");
-               return;
-       }
-       
-       fputc('(',file);
-       for (i=0; i<d->paramcount; ++i) {
-               if (i)
-                       fputc(',',file);
-               descriptor_debug_print_typedesc(file,d->paramtypes + i);
-               if (d->params) {
-                       descriptor_debug_print_paramdesc(file,d->params + i);
-               }
-       }
-       if (d->params == METHODDESC_NOPARAMS)
-               fputs("<NOPARAMS>",file);
-       fputc(')',file);
-       descriptor_debug_print_typedesc(file,&(d->returntype));
-}
-
-/* descriptor_pool_debug_dump **************************************************
-   Print the state of the descriptor_pool to the given stream
-
-   IN:
-       pool.............the descriptor_pool
-          file.............stream to print to
-
-*******************************************************************************/
-
-void 
-descriptor_pool_debug_dump(descriptor_pool *pool,FILE *file)
-{
-       u4 slot;
-       u1 *pos;
-       u1 *kind;
-       u4 size;
-       
-       fprintf(file,"======[descriptor_pool for ");
-       utf_fprint_printable_ascii(file,pool->referer->name);
-       fprintf(file,"]======\n");
-
-       fprintf(file,"fieldcount:     %d\n",pool->fieldcount);
-       fprintf(file,"methodcount:    %d\n",pool->methodcount);
-       fprintf(file,"paramcount:     %d\n",pool->paramcount);
-       fprintf(file,"classrefcount:  %d\n",pool->classrefhash.entries);
-       fprintf(file,"descriptorsize: %d bytes\n",pool->descriptorsize);
-       fprintf(file,"classrefsize:   %d bytes\n",
-                       (int)(pool->classrefhash.entries * sizeof(constant_classref)));
-
-       fprintf(file,"class references:\n");
-       for (slot=0; slot<pool->classrefhash.size; ++slot) {
-               classref_hash_entry *c = (classref_hash_entry *) pool->classrefhash.ptr[slot];
-               while (c) {
-                       fprintf(file,"    %4d: ",c->index);
-                       utf_fprint_printable_ascii(file,c->name);
-                       fprintf(file,"\n");
-                       c = c->hashlink;
-               }
-       }
-
-       fprintf(file,"hashed descriptors:\n");
-       for (slot=0; slot<pool->descriptorhash.size; ++slot) {
-               descriptor_hash_entry *c = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot];
-               while (c) {
-                       fprintf(file,"    %p: ",c->parseddesc.any);
-                       utf_fprint_printable_ascii(file,c->desc);
-                       fprintf(file,"\n");
-                       c = c->hashlink;
-               }
-       }
-
-       fprintf(file,"descriptors:\n");
-       if (pool->descriptors) {
-               pos = pool->descriptors;
-               size = pool->descriptors_next - pool->descriptors;
-               fprintf(file,"    size: %d bytes\n",size);
-               
-               if (pool->descriptor_kind) {
-                       kind = pool->descriptor_kind;
-
-                       while (pos < (pool->descriptors + size)) {
-                               fprintf(file,"    %p: ",pos);
-                               switch (*kind++) {
-                                       case 'f':
-                                               descriptor_debug_print_typedesc(file,(typedesc*)pos);
-                                               pos += sizeof(typedesc);
-                                               break;
-                                       case 'm':
-                                               descriptor_debug_print_methoddesc(file,(methoddesc*)pos);
-                                               pos += ((methoddesc*)pos)->paramcount * sizeof(typedesc);
-                                               pos += sizeof(methoddesc) - sizeof(typedesc);
-                                               break;
-                                       default:
-                                               fprintf(file,"INVALID KIND");
-                               }
-                               fputc('\n',file);
-                       }
-               }
-               else {
-                       while (size >= sizeof(voidptr)) {
-                               fprintf(file,"    %p\n",*((voidptr*)pos));
-                               pos += sizeof(voidptr);
-                               size -= sizeof(voidptr);
-                       }
-               }
-       }
-
-       fprintf(file,"==========================================================\n");
-}
-#endif /* !defined(NDEBUG) */
-
-/*
- * 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/vmcore/descriptor.h b/src/vmcore/descriptor.h
deleted file mode 100644 (file)
index dae43e7..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/* src/vmcore/descriptor.h - checking and parsing of field / method descriptors
-
-   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
-
-   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 _DESCRIPTOR_H
-#define _DESCRIPTOR_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct descriptor_pool descriptor_pool;
-typedef struct typedesc        typedesc;
-typedef struct paramdesc       paramdesc;
-typedef struct methoddesc      methoddesc;
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "toolbox/hashtable.h"
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/references.h"
-#include "vmcore/utf8.h"
-
-#include "arch.h"              /* needed for HAS_ADDRESS_REGISTER_FILE */
-
-/* data structures ************************************************************/
-
-/*----------------------------------------------------------------------------*/
-/* Descriptor Pools                                                           */
-/*                                                                            */
-/* A descriptor_pool is a temporary data structure used during loading of     */
-/* a class. The descriptor_pool is used to allocate the table of              */
-/* constant_classrefs the class uses, and for parsing the field and method    */
-/* descriptors which occurr within the class. The inner workings of           */
-/* descriptor_pool are not important for outside code.                        */
-/*                                                                            */
-/* You use a descriptor_pool as follows:                                      */
-/*                                                                            */
-/* 1. create one with descriptor_pool_new                                     */
-/* 2. add all explicit class references with descriptor_pool_add_class        */
-/* 3. add all field/method descriptors with descriptor_pool_add               */
-/* 4. call descriptor_pool_create_classrefs                                   */
-/*    You can now lookup classrefs with descriptor_pool_lookup_classref       */
-/* 5. call descriptor_pool_alloc_parsed_descriptors                           */
-/* 6. for each field descriptor call descriptor_pool_parse_field_descriptor   */
-/*    for each method descriptor call descriptor_pool_parse_method_descriptor */
-/* 7. call descriptor_pool_get_parsed_descriptors                             */
-/*                                                                            */
-/* IMPORTANT: The descriptor_pool functions use DNEW and DMNEW for allocating */
-/*            memory which can be thrown away when the steps above have been  */
-/*            done.                                                           */
-/*----------------------------------------------------------------------------*/
-
-struct descriptor_pool {
-       classinfo         *referer;
-       u4                 fieldcount;
-       u4                 methodcount;
-       u4                 paramcount;
-       u4                 descriptorsize;
-       u1                *descriptors;
-       u1                *descriptors_next;
-       hashtable          descriptorhash;
-       constant_classref *classrefs;
-       hashtable          classrefhash;
-       u1                *descriptor_kind;       /* useful for debugging */
-       u1                *descriptor_kind_next;  /* useful for debugging */
-};
-
-
-/* data structures for parsed field/method descriptors ************************/
-
-struct typedesc {
-       constant_classref *classref;   /* class reference for TYPE_ADR types      */
-       u1                 type;       /* TYPE_??? constant [1]                   */
-       u1                 decltype;   /* (PRIMITIVE)TYPE_??? constant [2]        */
-       u1                 arraydim;   /* array dimension (0 if no array)         */
-};
-
-/* [1]...the type field contains the basic type used within the VM. So ints,  */
-/*       shorts, chars, bytes, booleans all have TYPE_INT.                    */
-/* [2]...the decltype field contains the declared type.                       */
-/*       So short is PRIMITIVETYPE_SHORT, char is PRIMITIVETYPE_CHAR.         */
-/*       For non-primitive types decltype is TYPE_ADR.                        */
-
-struct paramdesc {
-#if defined(__MIPS__)
-       u1   type;                  /* TYPE_??? of the register allocated         */
-#endif
-       bool     inmemory;          /* argument in register or on stack           */
-       uint32_t index;             /* index into argument register array         */
-       uint32_t regoff;            /* register index or stack offset             */
-};
-
-struct methoddesc {
-       s2         paramcount;      /* number of parameters                       */
-       s2         paramslots;      /* like above but LONG,DOUBLE count twice     */
-       s4         argintreguse;    /* number of used integer argument registers  */
-       s4         argfltreguse;    /* number of used float argument registers    */
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-       s4         argadrreguse;    /* number of used address registers */
-#endif
-       s4         memuse;          /* number of stack slots used                 */
-       paramdesc *params;          /* allocated parameter descriptions [3]       */
-       typedesc   returntype;      /* parsed descriptor of the return type       */
-       typedesc   paramtypes[1];   /* parameter types, variable length!          */
-};
-
-/* [3]...If params is NULL, the parameter descriptions have not yet been      */
-/*       allocated. In this case ___the possible 'this' pointer of the method */
-/*       is NOT counted in paramcount/paramslots and it is NOT included in    */
-/*       the paramtypes array___.                                             */
-/*       If params != NULL, the parameter descriptions have been              */
-/*       allocated, and the 'this' pointer of the method, if any, IS included.*/
-/*       In case the method has no parameters at all, the special value       */
-/*       METHODDESC_NO_PARAMS is used (see below).                            */
-
-/* METHODDESC_NO_PARAMS is a special value for the methoddesc.params field    */
-/* indicating that the method is a static method without any parameters.      */
-/* This special value must be != NULL and it may only be set if               */
-/* md->paramcount == 0.                                                       */
-
-#define METHODDESC_NOPARAMS  ((paramdesc*)1)
-
-/* function prototypes ********************************************************/
-
-descriptor_pool * descriptor_pool_new(classinfo *referer);
-
-bool descriptor_pool_add_class(descriptor_pool *pool,utf *name);
-bool descriptor_pool_add(descriptor_pool *pool,utf *desc,int *paramslots);
-
-int  descriptor_to_basic_type(utf *desc);
-int  descriptor_typesize(typedesc *td);
-
-constant_classref * descriptor_pool_create_classrefs(descriptor_pool *pool,
-                                                                                                        s4 *count);
-constant_classref * descriptor_pool_lookup_classref(descriptor_pool *pool,utf *classname);
-
-void descriptor_pool_alloc_parsed_descriptors(descriptor_pool *pool);
-
-typedesc *descriptor_pool_parse_field_descriptor(descriptor_pool *pool, utf *desc);
-methoddesc *descriptor_pool_parse_method_descriptor(descriptor_pool *pool, utf *desc, s4 mflags,
-                                                                                                       constant_classref *thisclass);
-
-bool descriptor_params_from_paramtypes(methoddesc *md, s4 mflags);
-
-void *descriptor_pool_get_parsed_descriptors(descriptor_pool *pool, s4 *size);
-void descriptor_pool_get_sizes(descriptor_pool *pool, u4 *classrefsize,
-                                                          u4 *descsize);
-
-#ifndef NDEBUG
-void descriptor_debug_print_typedesc(FILE *file,typedesc *d);
-void descriptor_debug_print_methoddesc(FILE *file,methoddesc *d);
-void descriptor_debug_print_paramdesc(FILE *file,paramdesc *d);
-void descriptor_pool_debug_dump(descriptor_pool *pool, FILE *file);
-#endif /* !defined(NDEBUG) */
-
-#endif /* _DESCRIPTOR_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/vmcore/field.c b/src/vmcore/field.c
deleted file mode 100644 (file)
index 00c0680..0000000
+++ /dev/null
@@ -1,562 +0,0 @@
-/* src/vmcore/field.c - field 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 <stdint.h>
-#include <stdio.h>
-
-#include "mm/memory.h"
-
-#include "native/llni.h"
-
-#include "vm/types.h"
-
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/primitive.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vmcore/annotation.h"
-#include "vmcore/class.h"
-#include "vmcore/descriptor.h"
-#include "vmcore/field.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/references.h"
-#include "vmcore/suck.h"
-#include "vmcore/utf8.h"
-
-
-/* field_load ******************************************************************
-
-   Load everything about a class field from the class file and fill a
-   fieldinfo structure.
-
-*******************************************************************************/
-
-#define field_load_NOVALUE  0xffffffff /* must be bigger than any u2 value! */
-
-bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool)
-{
-       classinfo *c;
-       u4 attrnum, i;
-       u4 pindex = field_load_NOVALUE;     /* constantvalue_index */
-       utf *u;
-
-       /* Get class. */
-
-       c = cb->clazz;
-
-       f->clazz = c;
-
-       /* Get access flags. */
-
-       if (!suck_check_classbuffer_size(cb, 2 + 2 + 2))
-               return false;
-
-       f->flags = suck_u2(cb);
-
-       /* Get name. */
-
-       if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
-               return false;
-
-       f->name = u;
-
-       /* Get descriptor. */
-
-       if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
-               return false;
-
-       f->descriptor = u;
-       f->parseddesc = NULL;
-
-       if (!descriptor_pool_add(descpool, u, NULL))
-               return false;
-
-       /* descriptor_pool_add accepts method descriptors, so we have to
-          check against them here before the call of
-          descriptor_to_basic_type below. */
-
-       if (u->text[0] == '(') {
-               exceptions_throw_classformaterror(c, "Method descriptor used for field");
-               return false;
-       }
-
-#ifdef ENABLE_VERIFIER
-       if (opt_verify) {
-               /* check name */
-               if (!is_valid_name_utf(f->name) || f->name->text[0] == '<') {
-                       exceptions_throw_classformaterror(c,
-                                                                                         "Illegal Field name \"%s\"",
-                                                                                         f->name->text);
-                       return false;
-               }
-
-               /* check flag consistency */
-               i = f->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED);
-
-               if ((i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) ||
-                       ((f->flags & (ACC_FINAL | ACC_VOLATILE)) == (ACC_FINAL | ACC_VOLATILE))) {
-                       exceptions_throw_classformaterror(c,
-                                                                                         "Illegal field modifiers: 0x%X",
-                                                                                         f->flags);
-                       return false;
-               }
-
-               if (c->flags & ACC_INTERFACE) {
-                       if (((f->flags & (ACC_STATIC | ACC_PUBLIC | ACC_FINAL))
-                               != (ACC_STATIC | ACC_PUBLIC | ACC_FINAL)) ||
-                               f->flags & ACC_TRANSIENT) {
-                               exceptions_throw_classformaterror(c,
-                                                                                                 "Illegal field modifiers: 0x%X",
-                                                                                                 f->flags);
-                               return false;
-                       }
-               }
-       }
-#endif /* ENABLE_VERIFIER */
-
-       /* data type */
-
-       f->type = descriptor_to_basic_type(f->descriptor);
-
-       /* For static-fields allocate memory for the value and set the
-          value to 0. */
-
-       if (f->flags & ACC_STATIC) {
-               switch (f->type) {
-               case TYPE_INT:
-               case TYPE_LNG:
-               case TYPE_FLT:
-               case TYPE_DBL:
-                       f->value = NEW(imm_union);
-                       break;
-
-               case TYPE_ADR:
-#if !defined(ENABLE_GC_BOEHM)
-                       f->value = NEW(imm_union);
-#else
-                       f->value = GCNEW_UNCOLLECTABLE(imm_union, 1);
-#endif
-                       break;
-
-               default:
-                       vm_abort("field_load: invalid field type %d", f->type);
-               }
-
-               /* Set the field to zero, for float and double fields set the
-                  correct 0.0 value. */
-
-               switch (f->type) {
-               case TYPE_INT:
-               case TYPE_LNG:
-               case TYPE_ADR:
-                       f->value->l = 0;
-                       break;
-
-               case TYPE_FLT:
-                       f->value->f = 0.0;
-                       break;
-
-               case TYPE_DBL:
-                       f->value->d = 0.0;
-                       break;
-               }
-       }
-       else {
-               /* For instance-fields set the offset to 0. */
-
-               f->offset = 0;
-
-               /* For final fields, which are not static, we need a value
-                  structure. */
-
-               if (f->flags & ACC_FINAL) {
-                       f->value = NEW(imm_union);
-                       /* XXX hack */
-                       f->value->l = 0;
-               }
-
-               switch (f->type) {
-               case TYPE_ADR:
-                       c->flags |= ACC_CLASS_HAS_POINTERS;
-                       break;
-               }
-       }
-
-       /* read attributes */
-
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       attrnum = suck_u2(cb);
-
-       for (i = 0; i < attrnum; i++) {
-               if (!suck_check_classbuffer_size(cb, 2))
-                       return false;
-
-               if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
-                       return false;
-
-               if (u == utf_ConstantValue) {
-                       if (!suck_check_classbuffer_size(cb, 4 + 2))
-                               return false;
-
-                       /* check attribute length */
-
-                       if (suck_u4(cb) != 2) {
-                               exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute");
-                               return false;
-                       }
-                       
-                       /* constant value attribute */
-
-                       if (pindex != field_load_NOVALUE) {
-                               exceptions_throw_classformaterror(c, "Multiple ConstantValue attributes");
-                               return false;
-                       }
-                       
-                       /* index of value in constantpool */
-
-                       pindex = suck_u2(cb);
-               
-                       /* initialize field with value from constantpool */             
-
-                       switch (f->type) {
-                       case TYPE_INT: {
-                               constant_integer *ci; 
-
-                               if (!(ci = class_getconstant(c, pindex, CONSTANT_Integer)))
-                                       return false;
-
-                               f->value->i = ci->value;
-                       }
-                       break;
-                                       
-                       case TYPE_LNG: {
-                               constant_long *cl; 
-
-                               if (!(cl = class_getconstant(c, pindex, CONSTANT_Long)))
-                                       return false;
-
-                               f->value->l = cl->value;
-                       }
-                       break;
-
-                       case TYPE_FLT: {
-                               constant_float *cf;
-
-                               if (!(cf = class_getconstant(c, pindex, CONSTANT_Float)))
-                                       return false;
-
-                               f->value->f = cf->value;
-                       }
-                       break;
-                                                                                       
-                       case TYPE_DBL: {
-                               constant_double *cd;
-
-                               if (!(cd = class_getconstant(c, pindex, CONSTANT_Double)))
-                                       return false;
-
-                               f->value->d = cd->value;
-                       }
-                       break;
-                                               
-                       case TYPE_ADR:
-                               if (!(u = class_getconstant(c, pindex, CONSTANT_String)))
-                                       return false;
-
-                               /* Create Java-string from compressed UTF8-string. */
-
-                               f->value->a = literalstring_new(u);
-                               break;
-       
-                       default: 
-                               vm_abort("field_load: invalid field type %d", f->type);
-                       }
-               }
-#if defined(ENABLE_JAVASE)
-               else if (u == utf_Signature) {
-                       /* Signature */
-
-                       if (!loader_load_attribute_signature(cb, &(f->signature)))
-                               return false;
-               }
-
-#if defined(ENABLE_ANNOTATIONS)
-               else if (u == utf_RuntimeVisibleAnnotations) {
-                       /* RuntimeVisibleAnnotations */
-                       if (!annotation_load_field_attribute_runtimevisibleannotations(cb, f))
-                               return false;
-               }
-               else if (u == utf_RuntimeInvisibleAnnotations) {
-                       /* RuntimeInvisibleAnnotations */
-                       if (!annotation_load_field_attribute_runtimeinvisibleannotations(cb, f))
-                               return false;
-               }
-#endif
-#endif
-               else {
-                       /* unknown attribute */
-
-                       if (!loader_skip_attribute_body(cb))
-                               return false;
-               }
-       }
-
-       /* everything was ok */
-
-       return true;
-}
-
-
-/* field_get_type **************************************************************
-
-   Returns the type of the field as class.
-
-*******************************************************************************/
-
-classinfo *field_get_type(fieldinfo *f)
-{
-       typedesc  *td;
-       utf       *u;
-       classinfo *c;
-
-       td = f->parseddesc;
-
-       if (td->type == TYPE_ADR) {
-               assert(td->classref);
-
-               u = td->classref->name;
-
-               /* load the class of the field-type with the field's
-                  classloader */
-
-               c = load_class_from_classloader(u, f->clazz->classloader);
-       }
-       else {
-               c = primitive_class_get_by_type(td->decltype);
-       }
-
-       return c;
-}
-
-
-/* field_free ******************************************************************
-
-   Frees a fields' resources.
-
-*******************************************************************************/
-
-void field_free(fieldinfo *f)
-{
-       /* free memory for fields which have a value */
-
-       if (f->value)
-#if defined(ENABLE_GC_BOEHM)
-               if (f->type != TYPE_ADR)
-#endif
-                       FREE(f->value, imm_union);
-}
-
-
-/* field_get_annotations ******************************************************
-
-   Get a fields' unparsed annotations in a byte array.
-
-   IN:
-       f........the field of which the annotations should be returned
-
-   RETURN VALUE:
-       The unparsed annotations in a byte array (or NULL if there aren't any).
-
-*******************************************************************************/
-
-java_handle_bytearray_t *field_get_annotations(fieldinfo *f)
-{
-#if defined(ENABLE_ANNOTATIONS)
-       classinfo               *c;           /* declaring class           */
-       int                      slot;        /* slot of this field        */
-       java_handle_bytearray_t *annotations; /* unparsed annotations      */
-       java_handle_t           *field_annotations;  /* array of unparsed  */
-                      /* annotations of all fields of the declaring class */
-
-       c           = f->clazz;
-       slot        = f - c->fields;
-       annotations = NULL;
-
-       LLNI_classinfo_field_get(c, field_annotations, field_annotations);
-
-       /* the field_annotations array might be shorter then the field
-        * count if the fields above a certain index have no annotations.
-        */
-       if (field_annotations != NULL &&
-               array_length_get(field_annotations) > slot) {
-               annotations = (java_handle_bytearray_t*)array_objectarray_element_get(
-                               (java_handle_objectarray_t*)field_annotations, slot);
-       }
-       
-       return annotations;
-#else
-       return NULL;
-#endif
-}
-
-
-/* field_printflags ************************************************************
-
-   (debugging only)
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void field_printflags(fieldinfo *f)
-{
-       if (f == NULL) {
-               printf("NULL");
-               return;
-       }
-
-       if (f->flags & ACC_PUBLIC)       printf(" PUBLIC");
-       if (f->flags & ACC_PRIVATE)      printf(" PRIVATE");
-       if (f->flags & ACC_PROTECTED)    printf(" PROTECTED");
-       if (f->flags & ACC_STATIC)       printf(" STATIC");
-       if (f->flags & ACC_FINAL)        printf(" FINAL");
-       if (f->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED");
-       if (f->flags & ACC_VOLATILE)     printf(" VOLATILE");
-       if (f->flags & ACC_TRANSIENT)    printf(" TRANSIENT");
-       if (f->flags & ACC_NATIVE)       printf(" NATIVE");
-       if (f->flags & ACC_INTERFACE)    printf(" INTERFACE");
-       if (f->flags & ACC_ABSTRACT)     printf(" ABSTRACT");
-}
-#endif
-
-
-/* field_print *****************************************************************
-
-   (debugging only)
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void field_print(fieldinfo *f)
-{
-       if (f == NULL) {
-               printf("(fieldinfo*)NULL");
-               return;
-       }
-
-       utf_display_printable_ascii_classname(f->clazz->name);
-       printf(".");
-       utf_display_printable_ascii(f->name);
-       printf(" ");
-       utf_display_printable_ascii(f->descriptor);     
-
-       field_printflags(f);
-
-       if (!(f->flags & ACC_STATIC)) {
-               printf(", offset: %d", f->offset);
-       }
-}
-#endif
-
-
-/* field_println ***************************************************************
-
-   (debugging only)
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void field_println(fieldinfo *f)
-{
-       field_print(f);
-       printf("\n");
-}
-#endif
-
-/* field_fieldref_print ********************************************************
-
-   (debugging only)
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void field_fieldref_print(constant_FMIref *fr)
-{
-       if (fr == NULL) {
-               printf("(constant_FMIref *)NULL");
-               return;
-       }
-
-       if (IS_FMIREF_RESOLVED(fr)) {
-               printf("<field> ");
-               field_print(fr->p.field);
-       }
-       else {
-               printf("<fieldref> ");
-               utf_display_printable_ascii_classname(fr->p.classref->name);
-               printf(".");
-               utf_display_printable_ascii(fr->name);
-               printf(" ");
-               utf_display_printable_ascii(fr->descriptor);
-       }
-}
-#endif
-
-/* field_fieldref_println ******************************************************
-
-   (debugging only)
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void field_fieldref_println(constant_FMIref *fr)
-{
-       field_fieldref_print(fr);
-       printf("\n");
-}
-#endif
-
-/*
- * 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/vmcore/field.h b/src/vmcore/field.h
deleted file mode 100644 (file)
index 32c3871..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* src/vmcore/field.h - field functions 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 _FIELD_H
-#define _FIELD_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct fieldinfo fieldinfo; 
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#include "vmcore/descriptor.h"
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/references.h"
-#include "vmcore/utf8.h"
-
-
-/* fieldinfo ******************************************************************/
-
-struct fieldinfo {           /* field of a class                                 */
-
-       /* CAUTION: The first field must be a pointer that is never the same      */
-       /*          value as CLASSREF_PSEUDO_VFTBL! This is used to check whether */
-       /*          a constant_FMIref has been resolved.                          */
-
-       classinfo *clazz;     /* needed by typechecker. Could be optimized        */
-                             /* away by using constant_FMIref instead of         */
-                             /* fieldinfo throughout the compiler.               */
-
-       s4         flags;     /* ACC flags                                        */
-       s4         type;      /* basic data type                                  */
-       utf       *name;      /* name of field                                    */
-       utf       *descriptor;/* JavaVM descriptor string of field                */
-       utf       *signature; /* Signature attribute string                       */
-       typedesc  *parseddesc;/* parsed descriptor                                */
-
-       int32_t    offset;    /* offset from start of object (instance variables) */
-       imm_union *value;     /* storage for static values (class variables)      */
-};
-
-
-/* function prototypes ********************************************************/
-
-bool       field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool);
-classinfo *field_get_type(fieldinfo *f);
-void       field_free(fieldinfo *f);
-
-java_handle_bytearray_t *field_get_annotations(fieldinfo *f);
-
-#if !defined(NDEBUG)
-void field_printflags(fieldinfo *f);
-void field_print(fieldinfo *f);
-void field_println(fieldinfo *f);
-void field_fieldref_print(constant_FMIref *fr);
-void field_fieldref_println(constant_FMIref *fr);
-#endif
-
-#endif /* _FIELD_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:
- */
diff --git a/src/vmcore/linker.c b/src/vmcore/linker.c
deleted file mode 100644 (file)
index 2f36f9e..0000000
+++ /dev/null
@@ -1,1467 +0,0 @@
-/* src/vmcore/linker.c - class linker 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 <stdint.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/native.h"
-
-#include "threads/lock-common.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/access.h"
-#include "vm/array.h"
-#include "vm/exceptions.h"
-#include "vm/primitive.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit_interface.h"
-
-#include "vmcore/class.h"
-#include "vmcore/classcache.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/rt-timing.h"
-
-
-/* debugging macros ***********************************************************/
-
-#if !defined(NDEBUG)
-# define TRACELINKCLASS(c) \
-    do { \
-        if (opt_TraceLinkClass) { \
-            log_start(); \
-            log_print("[Linking "); \
-            class_print((c)); \
-            log_print("]"); \
-            log_finish(); \
-        } \
-    } while (0)
-#else
-# define TRACELINKCLASS(c)
-#endif
-
-
-/* #include "vm/resolve.h" */
-/* copied prototype to avoid bootstrapping problem: */
-classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool checkaccess);
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
-#if !defined(NDEBUG) && defined(ENABLE_INLINING)
-#define INLINELOG(code)  do { if (opt_TraceInlining) { code } } while (0)
-#else
-#define INLINELOG(code)
-#endif
-
-
-/* global variables ***********************************************************/
-
-static s4 interfaceindex;       /* sequential numbering of interfaces         */
-static s4 classvalue;
-
-#if !USES_NEW_SUBTYPE
-java_object_t *linker_classrenumber_lock;
-#endif
-
-
-/* private functions **********************************************************/
-
-static classinfo *link_class_intern(classinfo *c);
-static arraydescriptor *link_array(classinfo *c);
-static void linker_compute_class_values(classinfo *c);
-static void linker_compute_subclasses(classinfo *c);
-static bool linker_addinterface(classinfo *c, classinfo *ic);
-static s4 class_highestinterface(classinfo *c);
-
-
-/* dummy structures for alinment checks ***************************************/
-
-typedef struct dummy_alignment_long_t   dummy_alignment_long_t;
-typedef struct dummy_alignment_double_t dummy_alignment_double_t;
-
-struct dummy_alignment_long_t {
-       int32_t i;
-       int64_t l;
-};
-
-struct dummy_alignment_double_t {
-       int32_t i;
-       double  d;
-};
-
-
-/* linker_init *****************************************************************
-
-   Initializes the linker subsystem and links classes required for the
-   primitive table.
-
-*******************************************************************************/
-
-void linker_preinit(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("linker_preinit");
-
-       /* Check for if alignment for long and double matches what we
-          assume for the current architecture. */
-
-#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) || (defined(__POWERPC__) && defined(__DARWIN__)) || defined(__M68K__)
-       /* Define a define here which is later checked when we use this
-          offset. */
-
-# define LINKER_ALIGNMENT_LONG_DOUBLE 4
-
-       if (OFFSET(dummy_alignment_long_t, l) != 4)
-               vm_abort("linker_preinit: long alignment is different from what assumed: %d != %d",
-                                OFFSET(dummy_alignment_long_t, l), 4);
-
-       if (OFFSET(dummy_alignment_double_t, d) != 4)
-               vm_abort("linker_preinit: double alignment is different from what assumed: %d != %d",
-                                OFFSET(dummy_alignment_double_t, d), 4);
-#else
-
-# define LINKER_ALIGNMENT_LONG_DOUBLE 8
-
-       if (OFFSET(dummy_alignment_long_t, l) != 8)
-               vm_abort("linker_preinit: long alignment is different from what assumed: %d != %d",
-                                OFFSET(dummy_alignment_long_t, l), 8);
-
-       if (OFFSET(dummy_alignment_double_t, d) != 8)
-               vm_abort("linker_preinit: double alignment is different from what assumed: %d != %d",
-                                OFFSET(dummy_alignment_double_t, d), 8);
-#endif
-
-       /* Reset interface index. */
-
-       interfaceindex = 0;
-
-#if defined(ENABLE_THREADS) && !USES_NEW_SUBTYPE
-       /* create the global lock object */
-
-       linker_classrenumber_lock = NEW(java_object_t);
-
-       LOCK_INIT_OBJECT_LOCK(linker_classrenumber_lock);
-#endif
-
-       /* Link the most basic classes. */
-
-       if (!link_class(class_java_lang_Object))
-               vm_abort("linker_preinit: linking java/lang/Object failed");
-
-#if defined(ENABLE_JAVASE)
-       if (!link_class(class_java_lang_Cloneable))
-               vm_abort("linker_preinit: linking java/lang/Cloneable failed");
-
-       if (!link_class(class_java_io_Serializable))
-               vm_abort("linker_preinit: linking java/io/Serializable failed");
-#endif
-}
-
-
-/* linker_init *****************************************************************
-
-   Links all classes required in the VM.
-
-*******************************************************************************/
-
-void linker_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("linker_init");
-
-       /* Link java.lang.Class as first class of the system, because we
-       need it's vftbl for all other classes so we can use a class as
-       object. */
-
-       if (!link_class(class_java_lang_Class))
-               vm_abort("linker_init: linking java/lang/Class failed");
-
-       /* Now set the header.vftbl of all classes which were created
-       before java.lang.Class was linked. */
-
-       class_postset_header_vftbl();
-
-       /* Link primitive-type wrapping classes. */
-
-#if defined(ENABLE_JAVASE)
-       if (!link_class(class_java_lang_Void))
-               vm_abort("linker_init: linking failed");
-#endif
-
-       if (!link_class(class_java_lang_Boolean))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_Byte))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_Character))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_Short))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_Integer))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_Long))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_Float))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_Double))
-               vm_abort("linker_init: linking failed");
-
-       /* Link important system classes. */
-
-       if (!link_class(class_java_lang_String))
-               vm_abort("linker_init: linking java/lang/String failed");
-
-#if defined(ENABLE_JAVASE)
-       if (!link_class(class_java_lang_ClassLoader))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_SecurityManager))
-               vm_abort("linker_init: linking failed");
-#endif
-
-       if (!link_class(class_java_lang_System))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_Thread))
-               vm_abort("linker_init: linking failed");
-
-#if defined(ENABLE_JAVASE)
-       if (!link_class(class_java_lang_ThreadGroup))
-               vm_abort("linker_init: linking failed");
-#endif
-
-       if (!link_class(class_java_lang_Throwable))
-               vm_abort("linker_init: linking failed");
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       if (!link_class(class_java_lang_VMSystem))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_VMThread))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_VMThrowable))
-               vm_abort("linker_init: linking failed");
-#endif
-
-       /* Important system exceptions. */
-
-       if (!link_class(class_java_lang_Exception))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_ClassNotFoundException))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_RuntimeException))
-               vm_abort("linker_init: linking failed");
-
-       /* some classes which may be used more often */
-
-#if defined(ENABLE_JAVASE)
-       if (!link_class(class_java_lang_StackTraceElement))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_reflect_Constructor))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_reflect_Field))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_reflect_Method))
-               vm_abort("linker_init: linking failed");
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       if (!link_class(class_java_lang_reflect_VMConstructor))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_reflect_VMField))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_lang_reflect_VMMethod))
-               vm_abort("linker_init: linking failed");
-# endif
-
-       if (!link_class(class_java_security_PrivilegedAction))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_util_Vector))
-               vm_abort("linker_init: linking failed");
-
-       if (!link_class(class_java_util_HashMap))
-               vm_abort("linker_init: linking failed");
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       if (!link_class(class_sun_reflect_MagicAccessorImpl))
-               vm_abort("linker_init: linking failed");
-# endif
-
-       if (!link_class(arrayclass_java_lang_Object))
-               vm_abort("linker_init: linking failed");
-#endif
-
-
-       /* create pseudo classes used by the typechecker */
-
-    /* pseudo class for Arraystubs (extends java.lang.Object) */
-
-       pseudo_class_Arraystub                   =
-               class_create_classinfo(utf_new_char("$ARRAYSTUB$"));
-       pseudo_class_Arraystub->state           |= CLASS_LOADED;
-       pseudo_class_Arraystub->super            = class_java_lang_Object;
-
-#if defined(ENABLE_JAVASE)
-
-       pseudo_class_Arraystub->interfacescount  = 2;
-       pseudo_class_Arraystub->interfaces       = MNEW(classinfo*, 2);
-       pseudo_class_Arraystub->interfaces[0]    = class_java_lang_Cloneable;
-       pseudo_class_Arraystub->interfaces[1]    = class_java_io_Serializable;
-
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-
-       pseudo_class_Arraystub->interfacescount    = 0;
-       pseudo_class_Arraystub->interfaces         = NULL;
-
-#else
-# error unknown Java configuration
-#endif
-
-       if (!classcache_store_unique(pseudo_class_Arraystub))
-               vm_abort("linker_init: could not cache pseudo_class_Arraystub");
-
-       if (!link_class(pseudo_class_Arraystub))
-               vm_abort("linker_init: linking pseudo_class_Arraystub failed");
-
-       /* pseudo class representing the null type */
-
-       pseudo_class_Null         = class_create_classinfo(utf_new_char("$NULL$"));
-       pseudo_class_Null->state |= CLASS_LOADED;
-       pseudo_class_Null->super  = class_java_lang_Object;
-
-       if (!classcache_store_unique(pseudo_class_Null))
-               vm_abort("linker_init: could not cache pseudo_class_Null");
-
-       if (!link_class(pseudo_class_Null))
-               vm_abort("linker_init: linking failed");
-
-       /* pseudo class representing new uninitialized objects */
-    
-       pseudo_class_New         = class_create_classinfo(utf_new_char("$NEW$"));
-       pseudo_class_New->state |= CLASS_LOADED;
-       pseudo_class_New->state |= CLASS_LINKED; /* XXX is this allright? */
-       pseudo_class_New->super  = class_java_lang_Object;
-
-       if (!classcache_store_unique(pseudo_class_New))
-               vm_abort("linker_init: could not cache pseudo_class_New");
-
-       /* Correct vftbl-entries (retarded loading and linking of class
-          java/lang/String). */
-
-       stringtable_update();
-}
-
-
-/* link_class ******************************************************************
-
-   Wrapper function for link_class_intern to ease monitor enter/exit
-   and exception handling.
-
-*******************************************************************************/
-
-classinfo *link_class(classinfo *c)
-{
-       classinfo *r;
-#if defined(ENABLE_RT_TIMING)
-       struct timespec time_start, time_end;
-#endif
-
-       RT_TIMING_GET_TIME(time_start);
-
-       if (c == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       LOCK_MONITOR_ENTER(c);
-
-       /* Maybe the class is currently linking or is already linked.*/
-
-       if ((c->state & CLASS_LINKING) || (c->state & CLASS_LINKED)) {
-               LOCK_MONITOR_EXIT(c);
-
-               return c;
-       }
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getcompilingtime)
-               compilingtime_stop();
-
-       if (opt_getloadingtime)
-               loadingtime_start();
-#endif
-
-       /* call the internal function */
-
-       r = link_class_intern(c);
-
-       /* If return value is NULL, we had a problem and the class is not
-          linked. */
-
-       if (r == NULL)
-               c->state &= ~CLASS_LINKING;
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getloadingtime)
-               loadingtime_stop();
-
-       if (opt_getcompilingtime)
-               compilingtime_start();
-#endif
-
-       LOCK_MONITOR_EXIT(c);
-
-       RT_TIMING_GET_TIME(time_end);
-
-       RT_TIMING_TIME_DIFF(time_start,time_end,RT_TIMING_LINK_TOTAL);
-
-       return r;
-}
-
-
-/* linker_overwrite_method *****************************************************
-
-   Overwrite a method with another one, update method flags and check
-   assumptions.
-
-   IN:
-      mg................the general method being overwritten
-         ms................the overwriting (more specialized) method
-         wl................worklist where to add invalidated methods
-
-   RETURN VALUE:
-      true..............everything ok
-         false.............an exception has been thrown
-
-*******************************************************************************/
-
-static bool linker_overwrite_method(methodinfo *mg,
-                                                                       methodinfo *ms,
-                                                                       method_worklist **wl)
-{
-       classinfo *cg;
-       classinfo *cs;
-
-       cg = mg->clazz;
-       cs = ms->clazz;
-
-       /* overriding a final method is illegal */
-
-       if (mg->flags & ACC_FINAL) {
-               exceptions_throw_verifyerror(mg, "Overriding final method");
-               return false;
-       }
-
-       /* method ms overwrites method mg */
-
-#if defined(ENABLE_VERIFIER)
-       /* Add loading constraints (for the more general types of method mg). */
-       /* Not for <init>, as it is not invoked virtually.                    */
-
-       if ((ms->name != utf_init)
-                       && !classcache_add_constraints_for_params(
-                               cs->classloader, cg->classloader, mg))
-       {
-               return false;
-       }
-#endif
-
-       /* inherit the vftbl index, and record the overwriting */
-
-       ms->vftblindex = mg->vftblindex;
-       ms->overwrites = mg;
-
-       /* update flags and check assumptions */
-       /* <init> methods are a special case, as they are never dispatched dynamically */
-
-       if ((ms->flags & ACC_METHOD_IMPLEMENTED) && ms->name != utf_init) {
-               do {
-                       if (mg->flags & ACC_METHOD_IMPLEMENTED) {
-                               /* this adds another implementation */
-
-                               mg->flags &= ~ACC_METHOD_MONOMORPHIC;
-
-                               INLINELOG( printf("becomes polymorphic: "); method_println(mg); );
-
-                               method_break_assumption_monomorphic(mg, wl);
-                       }
-                       else {
-                               /* this is the first implementation */
-
-                               mg->flags |= ACC_METHOD_IMPLEMENTED;
-
-                               INLINELOG( printf("becomes implemented: "); method_println(mg); );
-                       }
-
-                       ms = mg;
-                       mg = mg->overwrites;
-               } while (mg != NULL);
-       }
-
-       return true;
-}
-
-
-#if USES_NEW_SUBTYPE
-/* build_display ***************************************************************
-
-   Builds the entire display for a class. This entails filling the fixed part
-   as well as allocating and initializing the overflow part.
-
-   See Cliff Click and John Rose: Fast subtype checking in the Hotspot JVM.
-
-*******************************************************************************/
-
-static classinfo *build_display(classinfo *c)
-{
-       int depth, i;
-       int depth_fixed;
-       classinfo *super;
-
-       do {
-               /* Handle arrays. */
-               if (c->vftbl->arraydesc) {
-                       arraydescriptor *a = c->vftbl->arraydesc;
-                       if (a->elementvftbl && a->elementvftbl->clazz->super) {
-                               classinfo *cls = a->elementvftbl->clazz->super;
-                               int n;
-                               for (n=0; n<a->dimension; n++)
-                                       cls = class_array_of(cls, true);
-                               super = cls;
-                               break;
-                       }
-                       if (a->componentvftbl && a->elementvftbl) {
-                               super = a->componentvftbl->clazz;
-                               break;
-                       }
-               }
-               /* Normal classes. */
-               super = c->super;
-       } while (false);
-       if (super) {
-               if (!link_class(super))
-                       return NULL;
-               depth = super->vftbl->subtype_depth + 1;
-       } else
-               /* java.lang.Object doesn't have a super class. */
-               depth = 0;
-
-       /* Now copy super's display, append c->vftbl and initialize the remaining fields. */
-       if (depth >= DISPLAY_SIZE) {
-               c->vftbl->subtype_overflow = MNEW(vftbl_t *, depth - DISPLAY_SIZE + 1);
-#if defined(ENABLE_STATISTICS)
-               if (opt_stat)
-                       count_vftbl_len += sizeof(vftbl_t*) * (depth - DISPLAY_SIZE + 1);
-#endif
-               memcpy(c->vftbl->subtype_overflow, super->vftbl->subtype_overflow, sizeof(vftbl_t*) * (depth - DISPLAY_SIZE));
-               c->vftbl->subtype_overflow[depth - DISPLAY_SIZE] = c->vftbl;
-               depth_fixed = DISPLAY_SIZE;
-       }
-       else {
-               depth_fixed = depth;
-               c->vftbl->subtype_display[depth] = c->vftbl;
-       }
-
-       if (super)
-               memcpy(c->vftbl->subtype_display, super->vftbl->subtype_display, sizeof(vftbl_t*) * depth_fixed);
-       for (i=depth_fixed+1; i<=DISPLAY_SIZE; i++)
-               c->vftbl->subtype_display[i] = NULL;
-       c->vftbl->subtype_offset = OFFSET(vftbl_t, subtype_display[0]) + sizeof(vftbl_t*) * depth_fixed;
-       c->vftbl->subtype_depth = depth;
-
-       return c;
-}
-#endif
-
-/* link_class_intern ***********************************************************
-
-   Tries to link a class. The function calculates the length in bytes
-   that an instance of this class requires as well as the VTBL for
-   methods and interface methods.
-       
-*******************************************************************************/
-
-static classinfo *link_class_intern(classinfo *c)
-{
-       classinfo *super;             /* super class                              */
-       classinfo *tc;                /* temporary class variable                 */
-       s4 supervftbllength;          /* vftbllegnth of super class               */
-       s4 vftbllength;               /* vftbllength of current class             */
-       s4 interfacetablelength;      /* interface table length                   */
-       vftbl_t *v;                   /* vftbl of current class                   */
-       s4 i;                         /* interface/method/field counter           */
-       arraydescriptor *arraydesc;   /* descriptor for array classes             */
-       method_worklist *worklist;    /* worklist for recompilation               */
-#if defined(ENABLE_RT_TIMING)
-       struct timespec time_start, time_resolving, time_compute_vftbl,
-                                       time_abstract, time_compute_iftbl, time_fill_vftbl,
-                                       time_offsets, time_fill_iftbl, time_finalizer,
-                                       time_subclasses;
-#endif
-
-       RT_TIMING_GET_TIME(time_start);
-
-       TRACELINKCLASS(c);
-
-       /* the class must be loaded */
-
-       /* XXX should this be a specific exception? */
-       assert(c->state & CLASS_LOADED);
-
-       /* This is check in link_class. */
-
-       assert(!(c->state & CLASS_LINKED));
-
-       /* cache the self-reference of this class                          */
-       /* we do this for cases where the defining loader of the class     */
-       /* has not yet been recorded as an initiating loader for the class */
-       /* this is needed so subsequent code can assume that self-refs     */
-       /* will always resolve lazily                                      */
-       /* No need to do it for the bootloader - it is always registered   */
-       /* as initiating loader for the classes it loads.                  */
-       if (c->classloader)
-               classcache_store(c->classloader,c,false);
-
-       /* this class is currently linking */
-
-       c->state |= CLASS_LINKING;
-
-       arraydesc = NULL;
-       worklist = NULL;
-
-       /* Link the super interfaces. */
-
-       for (i = 0; i < c->interfacescount; i++) {
-               tc = c->interfaces[i];
-
-               if (!(tc->state & CLASS_LINKED))
-                       if (!link_class(tc))
-                               return NULL;
-       }
-       
-       /* check super class */
-
-       super = NULL;
-
-       /* Check for java/lang/Object. */
-
-       if (c->super == NULL) {
-               c->index = 0;
-               c->instancesize = sizeof(java_object_t);
-               
-               vftbllength = supervftbllength = 0;
-
-               c->finalizer = NULL;
-       }
-       else {
-               /* Get super class. */
-
-               super = c->super;
-
-               /* Link the super class if necessary. */
-               
-               if (!(super->state & CLASS_LINKED))
-                       if (!link_class(super))
-                               return NULL;
-
-               /* OR the ACC_CLASS_HAS_POINTERS and the ACC_CLASS_REFERENCE_*
-                  flags. */
-
-               c->flags |= (super->flags &
-                                        (ACC_CLASS_HAS_POINTERS | ACC_CLASS_REFERENCE_MASK));
-
-               /* handle array classes */
-
-               if (c->name->text[0] == '[')
-                       if (!(arraydesc = link_array(c)))
-                               return NULL;
-
-               if (c->flags & ACC_INTERFACE)
-                       c->index = interfaceindex++;
-               else
-                       c->index = super->index + 1;
-               
-               c->instancesize = super->instancesize;
-
-               vftbllength = supervftbllength = super->vftbl->vftbllength;
-               
-               c->finalizer = super->finalizer;
-       }
-       RT_TIMING_GET_TIME(time_resolving);
-
-
-       /* compute vftbl length */
-
-       for (i = 0; i < c->methodscount; i++) {
-               methodinfo *m = &(c->methods[i]);
-
-               if (!(m->flags & ACC_STATIC)) { /* is instance method */
-                       tc = super;
-
-                       while (tc) {
-                               s4 j;
-
-                               for (j = 0; j < tc->methodscount; j++) {
-                                       if (method_canoverwrite(m, &(tc->methods[j]))) {
-                                               if (tc->methods[j].flags & ACC_PRIVATE)
-                                                       goto notfoundvftblindex;
-
-                                               /* package-private methods in other packages */
-                                               /* must not be overridden                    */
-                                               /* (see Java Language Specification 8.4.8.1) */
-                                               if ( !(tc->methods[j].flags & (ACC_PUBLIC | ACC_PROTECTED)) 
-                                                        && !SAME_PACKAGE(c,tc) ) 
-                                               {
-                                                   goto notfoundvftblindex;
-                                               }
-
-                                               if (!linker_overwrite_method(&(tc->methods[j]), m, &worklist))
-                                                       return NULL;
-
-                                               goto foundvftblindex;
-                                       }
-                               }
-
-                               tc = tc->super;
-                       }
-
-               notfoundvftblindex:
-                       m->vftblindex = (vftbllength++);
-               foundvftblindex:
-                       ;
-               }
-       }
-       RT_TIMING_GET_TIME(time_compute_vftbl);
-
-
-       /* Check all interfaces of an abstract class (maybe be an
-          interface too) for unimplemented methods.  Such methods are
-          called miranda-methods and are marked with the ACC_MIRANDA
-          flag.  VMClass.getDeclaredMethods does not return such
-          methods. */
-
-       if (c->flags & ACC_ABSTRACT) {
-               classinfo  *ic;
-               methodinfo *im;
-               s4 abstractmethodscount;
-               s4 j;
-               s4 k;
-
-               abstractmethodscount = 0;
-
-               /* check all interfaces of the abstract class */
-
-               for (i = 0; i < c->interfacescount; i++) {
-                       ic = c->interfaces[i];
-
-                       for (j = 0; j < ic->methodscount; j++) {
-                               im = &(ic->methods[j]);
-
-                               /* skip `<clinit>' and `<init>' */
-
-                               if ((im->name == utf_clinit) || (im->name == utf_init))
-                                       continue;
-
-                               for (tc = c; tc != NULL; tc = tc->super) {
-                                       for (k = 0; k < tc->methodscount; k++) {
-                                               if (method_canoverwrite(im, &(tc->methods[k])))
-                                                       goto noabstractmethod;
-                                       }
-                               }
-
-                               abstractmethodscount++;
-
-                       noabstractmethod:
-                               ;
-                       }
-               }
-
-               if (abstractmethodscount > 0) {
-                       methodinfo *am;
-
-                       /* reallocate methods memory */
-
-                       c->methods = MREALLOC(c->methods, methodinfo, c->methodscount,
-                                                                 c->methodscount + abstractmethodscount);
-
-                       for (i = 0; i < c->interfacescount; i++) {
-                               ic = c->interfaces[i];
-
-                               for (j = 0; j < ic->methodscount; j++) {
-                                       im = &(ic->methods[j]);
-
-                                       /* skip `<clinit>' and `<init>' */
-
-                                       if ((im->name == utf_clinit) || (im->name == utf_init))
-                                               continue;
-
-                                       for (tc = c; tc != NULL; tc = tc->super) {
-                                               for (k = 0; k < tc->methodscount; k++) {
-                                                       if (method_canoverwrite(im, &(tc->methods[k])))
-                                                               goto noabstractmethod2;
-                                               }
-                                       }
-
-                                       /* Copy the method found into the new c->methods
-                                          array and tag it as miranda-method. */
-
-                                       am = &(c->methods[c->methodscount]);
-                                       c->methodscount++;
-
-                                       MCOPY(am, im, methodinfo, 1);
-
-                                       am->vftblindex  = (vftbllength++);
-                                       am->clazz       = c;
-                                       am->flags      |= ACC_MIRANDA;
-
-                               noabstractmethod2:
-                                       ;
-                               }
-                       }
-               }
-       }
-       RT_TIMING_GET_TIME(time_abstract);
-
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               count_vftbl_len +=
-                       sizeof(vftbl_t) + (sizeof(methodptr) * (vftbllength - 1));
-#endif
-
-       /* compute interfacetable length */
-
-       interfacetablelength = 0;
-
-       for (tc = c; tc != NULL; tc = tc->super) {
-               for (i = 0; i < tc->interfacescount; i++) {
-                       s4 h = class_highestinterface(tc->interfaces[i]) + 1;
-
-                       if (h > interfacetablelength)
-                               interfacetablelength = h;
-               }
-       }
-       RT_TIMING_GET_TIME(time_compute_iftbl);
-
-       /* allocate virtual function table */
-
-       v = (vftbl_t *) mem_alloc(sizeof(vftbl_t) +
-                                                         sizeof(methodptr) * (vftbllength - 1) +
-                                                         sizeof(methodptr*) * (interfacetablelength - (interfacetablelength > 0)));
-       v = (vftbl_t *) (((methodptr *) v) +
-                                        (interfacetablelength - 1) * (interfacetablelength > 1));
-
-       c->vftbl                = v;
-       v->clazz                = c;
-       v->vftbllength          = vftbllength;
-       v->interfacetablelength = interfacetablelength;
-       v->arraydesc            = arraydesc;
-
-       /* store interface index in vftbl */
-
-       if (c->flags & ACC_INTERFACE)
-               v->baseval = -(c->index);
-
-       /* copy virtual function table of super class */
-
-       for (i = 0; i < supervftbllength; i++) 
-               v->table[i] = super->vftbl->table[i];
-
-       /* Fill the remaining vftbl slots with the AbstractMethodError
-          stub (all after the super class slots, because they are already
-          initialized). */
-
-       for (; i < vftbllength; i++) {
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-               if (opt_intrp)
-                       v->table[i] = (methodptr) (ptrint) &intrp_asm_abstractmethoderror;
-               else
-# endif
-                       v->table[i] = (methodptr) (ptrint) &asm_abstractmethoderror;
-#else
-               v->table[i] = (methodptr) (ptrint) &intrp_asm_abstractmethoderror;
-#endif
-       }
-
-       /* add method stubs into virtual function table */
-
-       for (i = 0; i < c->methodscount; i++) {
-               methodinfo *m = &(c->methods[i]);
-
-               assert(m->stubroutine == NULL);
-
-               /* Don't create a compiler stub for abstract methods as they
-                  throw an AbstractMethodError with the default stub in the
-                  vftbl.  This entry is simply copied by sub-classes. */
-
-               if (m->flags & ACC_ABSTRACT)
-                       continue;
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-               if (opt_intrp)
-                       m->stubroutine = intrp_createcompilerstub(m);
-               else
-#endif
-                       m->stubroutine = codegen_generate_stub_compiler(m);
-#else
-               m->stubroutine = intrp_createcompilerstub(m);
-#endif
-
-               /* static methods are not in the vftbl */
-
-               if (m->flags & ACC_STATIC)
-                       continue;
-
-               /* insert the stubroutine into the vftbl */
-
-               v->table[m->vftblindex] = (methodptr) (ptrint) m->stubroutine;
-       }
-       RT_TIMING_GET_TIME(time_fill_vftbl);
-
-       /* compute instance size and offset of each field */
-       
-       for (i = 0; i < c->fieldscount; i++) {
-               s4 dsize;
-               fieldinfo *f = &(c->fields[i]);
-               
-               if (!(f->flags & ACC_STATIC)) {
-                       dsize = descriptor_typesize(f->parseddesc);
-
-#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) || (defined(__POWERPC__) && defined(__DARWIN__)) || defined(__M68K__)
-                       /* On some architectures and configurations we need to
-                          align long (int64_t) and double fields to 4-bytes to
-                          match what GCC does for struct members.  We must do the
-                          same as GCC here because the offsets in native header
-                          structs like java_lang_Double must match the offsets of
-                          the Java fields (eg. java.lang.Double.value). */
-
-# if LINKER_ALIGNMENT_LONG_DOUBLE != 4
-#  error alignment of long and double is not 4
-# endif
-
-                       c->instancesize = MEMORY_ALIGN(c->instancesize, 4);
-#else
-
-# if LINKER_ALIGNMENT_LONG_DOUBLE != 8
-#  error alignment of long and double is not 8
-# endif
-
-                       c->instancesize = MEMORY_ALIGN(c->instancesize, dsize);
-#endif
-
-                       f->offset = c->instancesize;
-                       c->instancesize += dsize;
-               }
-       }
-       RT_TIMING_GET_TIME(time_offsets);
-
-       /* initialize interfacetable and interfacevftbllength */
-
-       v->interfacevftbllength = MNEW(s4, interfacetablelength);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               count_vftbl_len += (4 + sizeof(s4)) * v->interfacetablelength;
-#endif
-
-       for (i = 0; i < interfacetablelength; i++) {
-               v->interfacevftbllength[i] = 0;
-               v->interfacetable[-i] = NULL;
-       }
-
-       /* add interfaces */
-
-       for (tc = c; tc != NULL; tc = tc->super)
-               for (i = 0; i < tc->interfacescount; i++)
-                       if (!linker_addinterface(c, tc->interfaces[i]))
-                               return NULL;
-
-       RT_TIMING_GET_TIME(time_fill_iftbl);
-
-       /* add finalizer method (not for java.lang.Object) */
-
-       if (super) {
-               methodinfo *fi;
-
-               fi = class_findmethod(c, utf_finalize, utf_void__void);
-
-               if (fi)
-                       if (!(fi->flags & ACC_STATIC))
-                               c->finalizer = fi;
-       }
-       RT_TIMING_GET_TIME(time_finalizer);
-
-       /* final tasks */
-
-       linker_compute_subclasses(c);
-
-       /* FIXME: this is completely useless now */
-       RT_TIMING_GET_TIME(time_subclasses);
-
-#if USES_NEW_SUBTYPE
-       if (!build_display(c))
-               return NULL;
-#endif
-
-       /* revert the linking state and class is linked */
-
-       c->state = (c->state & ~CLASS_LINKING) | CLASS_LINKED;
-
-       /* check worklist */
-
-       /* XXX must this also be done in case of exception? */
-
-       while (worklist != NULL) {
-               method_worklist *wi = worklist;
-
-               worklist = worklist->next;
-
-               INLINELOG( printf("MUST BE RECOMPILED: "); method_println(wi->m); );
-               jit_invalidate_code(wi->m);
-
-               /* XXX put worklist into dump memory? */
-               FREE(wi, method_worklist);
-       }
-
-       RT_TIMING_TIME_DIFF(time_start        ,time_resolving    ,RT_TIMING_LINK_RESOLVE);
-       RT_TIMING_TIME_DIFF(time_resolving    ,time_compute_vftbl,RT_TIMING_LINK_C_VFTBL);
-       RT_TIMING_TIME_DIFF(time_compute_vftbl,time_abstract     ,RT_TIMING_LINK_ABSTRACT);
-       RT_TIMING_TIME_DIFF(time_abstract     ,time_compute_iftbl,RT_TIMING_LINK_C_IFTBL);
-       RT_TIMING_TIME_DIFF(time_compute_iftbl,time_fill_vftbl   ,RT_TIMING_LINK_F_VFTBL);
-       RT_TIMING_TIME_DIFF(time_fill_vftbl   ,time_offsets      ,RT_TIMING_LINK_OFFSETS);
-       RT_TIMING_TIME_DIFF(time_offsets      ,time_fill_iftbl   ,RT_TIMING_LINK_F_IFTBL);
-       RT_TIMING_TIME_DIFF(time_fill_iftbl   ,time_finalizer    ,RT_TIMING_LINK_FINALIZER);
-       RT_TIMING_TIME_DIFF(time_finalizer    ,time_subclasses   ,RT_TIMING_LINK_SUBCLASS);
-
-       /* just return c to show that we didn't had a problem */
-
-       return c;
-}
-
-
-/* link_array ******************************************************************
-
-   This function is called by link_class to create the arraydescriptor
-   for an array class.
-
-   This function returns NULL if the array cannot be linked because
-   the component type has not been linked yet.
-
-*******************************************************************************/
-
-static arraydescriptor *link_array(classinfo *c)
-{
-       classinfo       *comp;
-       s4               namelen;
-       arraydescriptor *desc;
-       vftbl_t         *compvftbl;
-       utf             *u;
-
-       comp = NULL;
-       namelen = c->name->blength;
-
-       /* Check the component type */
-
-       switch (c->name->text[1]) {
-       case '[':
-               /* c is an array of arrays. */
-               u = utf_new(c->name->text + 1, namelen - 1);
-               if (!(comp = load_class_from_classloader(u, c->classloader)))
-                       return NULL;
-               break;
-
-       case 'L':
-               /* c is an array of objects. */
-               u = utf_new(c->name->text + 2, namelen - 3);
-               if (!(comp = load_class_from_classloader(u, c->classloader)))
-                       return NULL;
-               break;
-       }
-
-       /* If the component type has not been linked, link it now */
-
-       assert(!comp || (comp->state & CLASS_LOADED));
-
-       if (comp && !(comp->state & CLASS_LINKED))
-               if (!link_class(comp))
-                       return NULL;
-
-       /* Allocate the arraydescriptor */
-
-       desc = NEW(arraydescriptor);
-
-       if (comp) {
-               /* c is an array of references */
-               desc->arraytype = ARRAYTYPE_OBJECT;
-               desc->componentsize = sizeof(void*);
-               desc->dataoffset = OFFSET(java_objectarray_t, data);
-               
-               compvftbl = comp->vftbl;
-
-               if (!compvftbl) {
-                       log_text("Component class has no vftbl");
-                       assert(0);
-               }
-
-               desc->componentvftbl = compvftbl;
-               
-               if (compvftbl->arraydesc) {
-                       desc->elementvftbl = compvftbl->arraydesc->elementvftbl;
-
-                       if (compvftbl->arraydesc->dimension >= 255) {
-                               log_text("Creating array of dimension >255");
-                               assert(0);
-                       }
-
-                       desc->dimension = compvftbl->arraydesc->dimension + 1;
-                       desc->elementtype = compvftbl->arraydesc->elementtype;
-
-               } else {
-                       desc->elementvftbl = compvftbl;
-                       desc->dimension = 1;
-                       desc->elementtype = ARRAYTYPE_OBJECT;
-               }
-
-       } else {
-               /* c is an array of a primitive type */
-               switch (c->name->text[1]) {
-               case 'Z':
-                       desc->arraytype = ARRAYTYPE_BOOLEAN;
-                       desc->dataoffset = OFFSET(java_booleanarray_t,data);
-                       desc->componentsize = sizeof(u1);
-                       break;
-
-               case 'B':
-                       desc->arraytype = ARRAYTYPE_BYTE;
-                       desc->dataoffset = OFFSET(java_bytearray_t,data);
-                       desc->componentsize = sizeof(u1);
-                       break;
-
-               case 'C':
-                       desc->arraytype = ARRAYTYPE_CHAR;
-                       desc->dataoffset = OFFSET(java_chararray_t,data);
-                       desc->componentsize = sizeof(u2);
-                       break;
-
-               case 'D':
-                       desc->arraytype = ARRAYTYPE_DOUBLE;
-                       desc->dataoffset = OFFSET(java_doublearray_t,data);
-                       desc->componentsize = sizeof(double);
-                       break;
-
-               case 'F':
-                       desc->arraytype = ARRAYTYPE_FLOAT;
-                       desc->dataoffset = OFFSET(java_floatarray_t,data);
-                       desc->componentsize = sizeof(float);
-                       break;
-
-               case 'I':
-                       desc->arraytype = ARRAYTYPE_INT;
-                       desc->dataoffset = OFFSET(java_intarray_t,data);
-                       desc->componentsize = sizeof(s4);
-                       break;
-
-               case 'J':
-                       desc->arraytype = ARRAYTYPE_LONG;
-                       desc->dataoffset = OFFSET(java_longarray_t,data);
-                       desc->componentsize = sizeof(s8);
-                       break;
-
-               case 'S':
-                       desc->arraytype = ARRAYTYPE_SHORT;
-                       desc->dataoffset = OFFSET(java_shortarray_t,data);
-                       desc->componentsize = sizeof(s2);
-                       break;
-
-               default:
-                       exceptions_throw_noclassdeffounderror(c->name);
-                       return NULL;
-               }
-               
-               desc->componentvftbl = NULL;
-               desc->elementvftbl = NULL;
-               desc->dimension = 1;
-               desc->elementtype = desc->arraytype;
-       }
-
-       return desc;
-}
-
-
-/* linker_compute_subclasses ***************************************************
-
-   XXX
-
-   ATTENTION: DO NOT REMOVE ANY OF THE LOCKING MECHANISMS BELOW:
-   This function needs to take the class renumber lock and stop the
-   world during class renumbering. The lock is used in C code which
-   is not that performance critical. Whereas JIT code uses critical
-   sections to atomically access the class values.
-
-*******************************************************************************/
-
-static void linker_compute_subclasses(classinfo *c)
-{
-#if 0 && defined(ENABLE_THREADS) && !defined(DISABLE_GC)
-       threads_stopworld();
-#endif
-
-       LOCK_CLASSRENUMBER_LOCK;
-
-       if (!(c->flags & ACC_INTERFACE)) {
-               c->nextsub = NULL;
-               c->sub     = NULL;
-#if USES_NEW_SUBTYPE
-               c->vftbl->baseval = 1; /* so it does not look like an interface */
-#endif
-       }
-
-       if (!(c->flags & ACC_INTERFACE) && (c->super != NULL)) {
-               c->nextsub    = c->super->sub;
-               c->super->sub = c;
-       }
-
-       classvalue = 0;
-
-#if !USES_NEW_SUBTYPE
-       /* compute class values */
-
-       linker_compute_class_values(class_java_lang_Object);
-#endif
-
-       UNLOCK_CLASSRENUMBER_LOCK;
-
-#if 0 && defined(ENABLE_THREADS) && !defined(DISABLE_GC)
-       threads_startworld();
-#endif
-}
-
-
-/* linker_compute_class_values *************************************************
-
-   XXX
-
-*******************************************************************************/
-
-static void linker_compute_class_values(classinfo *c)
-{
-       classinfo *subs;
-
-       c->vftbl->baseval = ++classvalue;
-
-       subs = c->sub;
-
-       while (subs) {
-               linker_compute_class_values(subs);
-
-               subs = subs->nextsub;
-       }
-
-       c->vftbl->diffval = classvalue - c->vftbl->baseval;
-}
-
-
-/* linker_addinterface *********************************************************
-
-   Is needed by link_class for adding a VTBL to a class. All
-   interfaces implemented by ic are added as well.
-
-   RETURN VALUE:
-      true.........everything ok
-         false........an exception has been thrown
-
-*******************************************************************************/
-
-static bool linker_addinterface(classinfo *c, classinfo *ic)
-{
-       s4          j, k;
-       vftbl_t    *v;
-       s4          i;
-       classinfo  *sc;
-       methodinfo *m;
-
-       v = c->vftbl;
-       i = ic->index;
-
-       if (i >= v->interfacetablelength)
-               vm_abort("Internal error: interfacetable overflow");
-
-       /* if this interface has already been added, return immediately */
-
-       if (v->interfacetable[-i] != NULL)
-               return true;
-
-       if (ic->methodscount == 0) {  /* fake entry needed for subtype test */
-               v->interfacevftbllength[i] = 1;
-               v->interfacetable[-i]      = MNEW(methodptr, 1);
-               v->interfacetable[-i][0]   = NULL;
-       }
-       else {
-               v->interfacevftbllength[i] = ic->methodscount;
-               v->interfacetable[-i]      = MNEW(methodptr, ic->methodscount);
-
-#if defined(ENABLE_STATISTICS)
-               if (opt_stat)
-                       count_vftbl_len += sizeof(methodptr) *
-                               (ic->methodscount + (ic->methodscount == 0));
-#endif
-
-               for (j = 0; j < ic->methodscount; j++) {
-                       for (sc = c; sc != NULL; sc = sc->super) {
-                               for (k = 0; k < sc->methodscount; k++) {
-                                       m = &(sc->methods[k]);
-
-                                       if (method_canoverwrite(m, &(ic->methods[j]))) {
-                                               /* method m overwrites the (abstract) method */
-#if defined(ENABLE_VERIFIER)
-                                               /* Add loading constraints (for the more
-                                                  general types of the method
-                                                  ic->methods[j]).  */
-                                               if (!classcache_add_constraints_for_params(
-                                                                       c->classloader, ic->classloader,
-                                                                       &(ic->methods[j])))
-                                               {
-                                                       return false;
-                                               }
-#endif
-
-                                               /* XXX taken from gcj */
-                                               /* check for ACC_STATIC: IncompatibleClassChangeError */
-
-                                               /* check for !ACC_PUBLIC: IllegalAccessError */
-
-                                               /* check for ACC_ABSTRACT: AbstracMethodError,
-                                                  not sure about that one */
-
-                                               v->interfacetable[-i][j] = v->table[m->vftblindex];
-                                               goto foundmethod;
-                                       }
-                               }
-                       }
-
-                       /* If no method was found, insert the AbstractMethodError
-                          stub. */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-                       if (opt_intrp)
-                               v->interfacetable[-i][j] =
-                                       (methodptr) (ptrint) &intrp_asm_abstractmethoderror;
-                       else
-# endif
-                               v->interfacetable[-i][j] =
-                                       (methodptr) (ptrint) &asm_abstractmethoderror;
-#else
-                       v->interfacetable[-i][j] =
-                               (methodptr) (ptrint) &intrp_asm_abstractmethoderror;
-#endif
-
-               foundmethod:
-                       ;
-               }
-       }
-
-       /* add superinterfaces of this interface */
-
-       for (j = 0; j < ic->interfacescount; j++)
-               if (!linker_addinterface(c, ic->interfaces[j]))
-                       return false;
-
-       /* everything ok */
-
-       return true;
-}
-
-
-/* class_highestinterface ******************************************************
-
-   Used by the function link_class to determine the amount of memory
-   needed for the interface table.
-
-*******************************************************************************/
-
-static s4 class_highestinterface(classinfo *c)
-{
-       s4 h;
-       s4 h2;
-       s4 i;
-       
-    /* check for ACC_INTERFACE bit already done in link_class_intern */
-
-    h = c->index;
-
-       for (i = 0; i < c->interfacescount; i++) {
-               h2 = class_highestinterface(c->interfaces[i]);
-
-               if (h2 > h)
-                       h = h2;
-       }
-
-       return 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/vmcore/linker.h b/src/vmcore/linker.h
deleted file mode 100644 (file)
index 309ba6f..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/* src/vmcore/linker.h - class linker header
-
-   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
-
-   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 _LINKER_H
-#define _LINKER_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct _vftbl vftbl_t;
-typedef struct arraydescriptor arraydescriptor;
-typedef struct primitivetypeinfo primitivetypeinfo;
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vmcore/class.h"
-#include "vmcore/references.h"
-
-
-/* virtual function table ******************************************************
-
-   The vtbl has a bidirectional layout with open ends at both sides.
-   interfacetablelength gives the number of entries of the interface
-   table at the start of the vftbl. The vftbl pointer points to
-   &interfacetable[0].  vftbllength gives the number of entries of
-   table at the end of the vftbl.
-
-   runtime type check (checkcast):
-
-   Different methods are used for runtime type check depending on the
-   argument of checkcast/instanceof.
-       
-   A check against a class is implemented via relative numbering on
-   the class hierachy tree. The tree is numbered in a depth first
-   traversal setting the base field and the diff field. The diff field
-   gets the result of (high - base) so that a range check can be
-   implemented by an unsigned compare. A sub type test is done by
-   checking the inclusion of base of the sub class in the range of the
-   superclass.
-
-   A check against an interface is implemented via the
-   interfacevftbl. If the interfacevftbl contains a nonnull value a
-   class is a subclass of this interface.
-
-   interfacetable:
-
-   Like standard virtual methods interface methods are called using
-   virtual function tables. All interfaces are numbered sequentially
-   (starting with zero). For each class there exist an interface table
-   of virtual function tables for each implemented interface. The
-   length of the interface table is determined by the highest number
-   of an implemented interface.
-
-   The following example assumes a class which implements interface 0 and 3:
-
-   interfacetablelength = 4
-
-                  | ...       |            +----------+
-                  +-----------+            | method 2 |---> method z
-                  | class     |            | method 1 |---> method y
-                  +-----------+            | method 0 |---> method x
-                  | ivftbl  0 |----------> +----------+
-    vftblptr ---> +-----------+
-                  | ivftbl -1 |--> NULL    +----------+
-                  | ivftbl -2 |--> NULL    | method 1 |---> method x
-                  | ivftbl -3 |-----+      | method 0 |---> method a
-                  +-----------+     +----> +----------+
-     
-                              +---------------+
-                              | length 3 = 2  |
-                              | length 2 = 0  |
-                              | length 1 = 0  |
-                              | length 0 = 3  |
-    interfacevftbllength ---> +---------------+
-
-*******************************************************************************/
-
-#if USES_NEW_SUBTYPE
-#define DISPLAY_SIZE 4
-#endif
-
-struct _vftbl {
-       methodptr   *interfacetable[1];    /* interface table (access via macro)  */
-       classinfo   *clazz;                /* class, the vtbl belongs to          */
-       arraydescriptor *arraydesc;        /* for array classes, otherwise NULL   */
-       s4           vftbllength;          /* virtual function table length       */
-       s4           interfacetablelength; /* interface table length              */
-       s4           baseval;              /* base for runtime type check         */
-                                          /* (-index for interfaces)             */
-       s4           diffval;              /* high - base for runtime type check  */
-
-#if USES_NEW_SUBTYPE
-       s4 subtype_depth;
-       s4 subtype_offset;
-       struct _vftbl *subtype_display[DISPLAY_SIZE+1];  /* the last one is cache */
-       struct _vftbl **subtype_overflow;
-#endif
-
-       s4          *interfacevftbllength; /* length of interface vftbls          */
-       methodptr    table[1];             /* class vftbl                         */
-};
-
-
-/* arraydescriptor *************************************************************
-
-   For every array class an arraydescriptor is allocated which
-   describes the array class. The arraydescriptor is referenced from
-   the vftbl of the array class.
-
-*******************************************************************************/
-
-struct arraydescriptor {
-       vftbl_t *componentvftbl; /* vftbl of the component type, NULL for primit. */
-       vftbl_t *elementvftbl;   /* vftbl of the element type, NULL for primitive */
-       s2       arraytype;      /* ARRAYTYPE_* constant                          */
-       s2       dimension;      /* dimension of the array (always >= 1)          */
-       s4       dataoffset;     /* offset of the array data from object pointer  */
-       s4       componentsize;  /* size of a component in bytes                  */
-       s2       elementtype;    /* ARRAYTYPE_* constant                          */
-};
-
-
-/* global variables ***********************************************************/
-
-/* This lock must be taken while renumbering classes or while atomically      */
-/* accessing classes.                                                         */
-
-#if USES_NEW_SUBTYPE
-
-#define LOCK_CLASSRENUMBER_LOCK   /* nothing */
-#define UNLOCK_CLASSRENUMBER_LOCK /* nothing */
-
-#else
-extern java_object_t *linker_classrenumber_lock;
-
-#define LOCK_CLASSRENUMBER_LOCK   LOCK_MONITOR_ENTER(linker_classrenumber_lock)
-#define UNLOCK_CLASSRENUMBER_LOCK LOCK_MONITOR_EXIT(linker_classrenumber_lock)
-
-#endif
-
-
-/* function prototypes ********************************************************/
-
-void       linker_preinit(void);
-void       linker_init(void);
-classinfo *link_class(classinfo *c);
-
-#endif /* _LINKER_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:
- */
diff --git a/src/vmcore/loader.c b/src/vmcore/loader.c
deleted file mode 100644 (file)
index a1d730c..0000000
+++ /dev/null
@@ -1,2228 +0,0 @@
-/* src/vmcore/loader.c - class loader 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 <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/llni.h"
-
-#include "threads/lock-common.h"
-
-#include "toolbox/hashtable.h"
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/package.h"
-#include "vm/primitive.h"
-#include "vm/resolve.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit_interface.h"
-
-#if defined(ENABLE_JAVASE)
-# include "vmcore/annotation.h"
-# include "vmcore/stackmap.h"
-#endif
-
-#include "vmcore/classcache.h"
-#include "vmcore/field.h"
-#include "vmcore/linker.h"
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-#include "vmcore/rt-timing.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
-#include "vmcore/suck.h"
-
-#if defined(ENABLE_ZLIB)
-# include "vmcore/zip.h"
-#endif
-
-#if defined(ENABLE_JVMTI)
-# include "native/jvmti/cacaodbg.h"
-#endif
-
-
-/* global variables ***********************************************************/
-
-static hashtable *hashtable_classloader;
-
-
-/* loader_preinit **************************************************************
-
-   Initializes the classpath list and loads classes required for the
-   primitive table.
-
-   NOTE: Exceptions thrown during VM initialization are caught in the
-         exception functions themselves.
-
-*******************************************************************************/
-void loader_preinit(void)
-{
-#if defined(ENABLE_THREADS)
-       list_classpath_entry *lce;
-#endif
-
-       TRACESUBSYSTEMINITIALIZATION("loader_preinit");
-
-#if defined(ENABLE_THREADS)
-       /* Initialize the monitor pointer for zip/jar file locking. */
-
-       for (lce = list_first(list_classpath_entries); lce != NULL;
-                lce = list_next(list_classpath_entries, lce)) {
-               if (lce->type == CLASSPATH_ARCHIVE)
-                       LOCK_INIT_OBJECT_LOCK(lce);
-       }
-#endif
-
-       /* initialize classloader hashtable, 10 entries should be enough */
-
-       hashtable_classloader = NEW(hashtable);
-       hashtable_create(hashtable_classloader, 10);
-
-       /* Load the most basic classes. */
-
-       assert(vm_initializing == true);
-
-       class_java_lang_Object     = load_class_bootstrap(utf_java_lang_Object);
-
-#if defined(ENABLE_JAVASE)
-       class_java_lang_Cloneable  = load_class_bootstrap(utf_java_lang_Cloneable);
-       class_java_io_Serializable = load_class_bootstrap(utf_java_io_Serializable);
-#endif
-}
-
-
-/* loader_init *****************************************************************
-
-   Loads all classes required in the VM.
-
-   NOTE: Exceptions thrown during VM initialization are caught in the
-         exception functions themselves.
-
-*******************************************************************************/
-void loader_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("loader_init");
-
-       /* Load primitive-type wrapping classes. */
-
-       assert(vm_initializing == true);
-
-#if defined(ENABLE_JAVASE)
-       class_java_lang_Void       = load_class_bootstrap(utf_java_lang_Void);
-#endif
-
-       class_java_lang_Boolean    = load_class_bootstrap(utf_java_lang_Boolean);
-       class_java_lang_Byte       = load_class_bootstrap(utf_java_lang_Byte);
-       class_java_lang_Character  = load_class_bootstrap(utf_java_lang_Character);
-       class_java_lang_Short      = load_class_bootstrap(utf_java_lang_Short);
-       class_java_lang_Integer    = load_class_bootstrap(utf_java_lang_Integer);
-       class_java_lang_Long       = load_class_bootstrap(utf_java_lang_Long);
-       class_java_lang_Float      = load_class_bootstrap(utf_java_lang_Float);
-       class_java_lang_Double     = load_class_bootstrap(utf_java_lang_Double);
-
-       /* Load important system classes. */
-
-       class_java_lang_Class      = load_class_bootstrap(utf_java_lang_Class);
-       class_java_lang_String     = load_class_bootstrap(utf_java_lang_String);
-
-#if defined(ENABLE_JAVASE)
-       class_java_lang_ClassLoader =
-               load_class_bootstrap(utf_java_lang_ClassLoader);
-
-       class_java_lang_SecurityManager =
-               load_class_bootstrap(utf_java_lang_SecurityManager);
-#endif
-
-       class_java_lang_System     =
-               load_class_bootstrap(utf_new_char("java/lang/System"));
-
-       class_java_lang_Thread     =
-               load_class_bootstrap(utf_new_char("java/lang/Thread"));
-
-#if defined(ENABLE_JAVASE)
-       class_java_lang_ThreadGroup =
-               load_class_bootstrap(utf_java_lang_ThreadGroup);
-#endif
-
-       class_java_lang_Throwable  = load_class_bootstrap(utf_java_lang_Throwable);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       class_java_lang_VMSystem   =
-               load_class_bootstrap(utf_new_char("java/lang/VMSystem"));
-
-       class_java_lang_VMThread   =
-               load_class_bootstrap(utf_new_char("java/lang/VMThread"));
-
-       class_java_lang_VMThrowable =
-               load_class_bootstrap(utf_new_char("java/lang/VMThrowable"));
-#endif
-
-       /* Important system exceptions. */
-
-       class_java_lang_Exception  = load_class_bootstrap(utf_java_lang_Exception);
-
-       class_java_lang_ClassNotFoundException =
-               load_class_bootstrap(utf_java_lang_ClassNotFoundException);
-
-       class_java_lang_RuntimeException =
-               load_class_bootstrap(utf_java_lang_RuntimeException);
-
-       /* Some classes which may be used often. */
-
-#if defined(ENABLE_JAVASE)
-       class_java_lang_StackTraceElement      = load_class_bootstrap(utf_java_lang_StackTraceElement);
-
-       class_java_lang_reflect_Constructor    = load_class_bootstrap(utf_java_lang_reflect_Constructor);
-       class_java_lang_reflect_Field          = load_class_bootstrap(utf_java_lang_reflect_Field);
-       class_java_lang_reflect_Method         = load_class_bootstrap(utf_java_lang_reflect_Method);
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       class_java_lang_reflect_VMConstructor  = load_class_bootstrap(utf_java_lang_reflect_VMConstructor);
-       class_java_lang_reflect_VMField        = load_class_bootstrap(utf_java_lang_reflect_VMField);
-       class_java_lang_reflect_VMMethod       = load_class_bootstrap(utf_java_lang_reflect_VMMethod);
-# endif
-
-       class_java_security_PrivilegedAction   = load_class_bootstrap(utf_new_char("java/security/PrivilegedAction"));
-
-       class_java_util_HashMap                = load_class_bootstrap(utf_new_char("java/util/HashMap"));
-       class_java_util_Vector                 = load_class_bootstrap(utf_java_util_Vector);
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       class_sun_reflect_MagicAccessorImpl =
-               load_class_bootstrap(utf_new_char("sun/reflect/MagicAccessorImpl"));
-# endif
-
-       arrayclass_java_lang_Object =
-               load_class_bootstrap(utf_new_char("[Ljava/lang/Object;"));
-
-# if defined(ENABLE_ANNOTATIONS)
-       /* needed by annotation support */
-       class_sun_reflect_ConstantPool =
-               load_class_bootstrap(utf_new_char("sun/reflect/ConstantPool"));
-
-#  if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       /* needed by GNU Classpaths annotation support */
-       class_sun_reflect_annotation_AnnotationParser =
-               load_class_bootstrap(utf_new_char("sun/reflect/annotation/AnnotationParser"));
-#  endif
-# endif
-#endif
-}
-
-
-/* loader_hashtable_classloader_add ********************************************
-
-   Adds an entry to the classloader hashtable.
-
-   REMEMBER: Also use this to register native loaders!
-
-*******************************************************************************/
-
-classloader_t *loader_hashtable_classloader_add(java_handle_t *cl)
-{
-       hashtable_classloader_entry *cle;
-       u4   key;
-       u4   slot;
-
-       if (cl == NULL)
-               return NULL;
-
-       LOCK_MONITOR_ENTER(hashtable_classloader->header);
-
-       LLNI_CRITICAL_START;
-
-       /* key for entry is the hashcode of the classloader;
-          aligned to 16-byte boundaries */
-
-       key  = heap_hashcode(LLNI_DIRECT(cl)) >> 4;
-       slot = key & (hashtable_classloader->size - 1);
-       cle  = hashtable_classloader->ptr[slot];
-
-       /* search hashchain for existing entry */
-
-       while (cle) {
-               if (cle->object == LLNI_DIRECT(cl))
-                       break;
-
-               cle = cle->hashlink;
-       }
-
-       LLNI_CRITICAL_END;
-
-       /* if no classloader was found, we create a new entry here */
-
-       if (cle == NULL) {
-               cle = NEW(hashtable_classloader_entry);
-
-#if defined(ENABLE_GC_CACAO)
-               /* register the classloader object with the GC */
-
-               gc_reference_register(&(cle->object), GC_REFTYPE_CLASSLOADER);
-#endif
-
-               LLNI_CRITICAL_START;
-
-               cle->object = LLNI_DIRECT(cl);
-
-               LLNI_CRITICAL_END;
-
-/*#define LOADER_DEBUG_CLASSLOADER*/
-#ifdef LOADER_DEBUG_CLASSLOADER
-               printf("CLASSLOADER: adding new classloader entry %p for %p: ", cle, cl);
-               class_print(LLNI_vftbl_direct(cl)->class);
-               printf("\n");
-               fflush(stdout);
-#endif
-
-               /* insert entry into hashtable */
-
-               cle->hashlink = hashtable_classloader->ptr[slot];
-               hashtable_classloader->ptr[slot] = cle;
-
-               /* update number of entries */
-
-               hashtable_classloader->entries++;
-       }
-
-
-       LOCK_MONITOR_EXIT(hashtable_classloader->header);
-
-#if defined(ENABLE_HANDLES)
-       return cle;
-#else
-       return cl;
-#endif
-}
-
-
-/* loader_hashtable_classloader_find *******************************************
-
-   Find an entry in the classloader hashtable.
-
-*******************************************************************************/
-
-classloader_t *loader_hashtable_classloader_find(java_handle_t *cl)
-{
-       hashtable_classloader_entry *cle;
-       u4   key;
-       u4   slot;
-
-       if (cl == NULL)
-               return NULL;
-
-       LLNI_CRITICAL_START;
-
-       /* key for entry is the hashcode of the classloader;
-          aligned to 16-byte boundaries */
-
-       key  = heap_hashcode(LLNI_DIRECT(cl)) >> 4;
-       slot = key & (hashtable_classloader->size - 1);
-       cle  = hashtable_classloader->ptr[slot];
-
-       /* search hashchain for existing entry */
-
-       while (cle) {
-               if (cle->object == LLNI_DIRECT(cl))
-                       break;
-
-               cle = cle->hashlink;
-       }
-
-#ifdef LOADER_DEBUG_CLASSLOADER
-       if (cle == NULL) {
-               printf("CLASSLOADER: unable to find classloader entry for %p: ", cl);
-               class_print(LLNI_vftbl_direct(cl)->class);
-               printf("\n");
-               fflush(stdout);
-       }
-#endif
-
-       LLNI_CRITICAL_END;
-
-#if defined(ENABLE_HANDLES)
-       return cle;
-#else
-       return cl;
-#endif
-}
-
-
-/* loader_load_all_classes *****************************************************
-
-   Loads all classes specified in the BOOTCLASSPATH.
-
-*******************************************************************************/
-
-void loader_load_all_classes(void)
-{
-       list_classpath_entry    *lce;
-#if defined(ENABLE_ZLIB)
-       hashtable               *ht;
-       s4                       slot;
-       hashtable_zipfile_entry *htzfe;
-       utf                     *u;
-#endif
-
-       for (lce = list_first(list_classpath_entries); lce != NULL;
-                lce = list_next(list_classpath_entries, lce)) {
-#if defined(ENABLE_ZLIB)
-               if (lce->type == CLASSPATH_ARCHIVE) {
-                       /* get the classes hashtable */
-
-                       ht = lce->htclasses;
-
-                       for (slot = 0; slot < ht->size; slot++) {
-                               htzfe = (hashtable_zipfile_entry *) ht->ptr[slot];
-
-                               for (; htzfe; htzfe = htzfe->hashlink) {
-                                       u = htzfe->filename;
-
-                                       /* skip all entries in META-INF and .properties,
-                       .png files */
-
-                                       if (!strncmp(u->text, "META-INF", strlen("META-INF")) ||
-                                               strstr(u->text, ".properties") ||
-                                               strstr(u->text, ".png"))
-                                               continue;
-
-                                       /* load class from bootstrap classloader */
-
-                                       if (!load_class_bootstrap(u)) {
-                                               fprintf(stderr, "Error loading: ");
-                                               utf_fprint_printable_ascii_classname(stderr, u);
-                                               fprintf(stderr, "\n");
-
-#if !defined(NDEBUG)
-                                               /* print out exception and cause */
-
-                                               exceptions_print_current_exception();
-#endif
-                                       }
-                               }
-                       }
-
-               } else {
-#endif
-#if defined(ENABLE_ZLIB)
-               }
-#endif
-       }
-}
-
-
-/* loader_skip_attribute_body **************************************************
-
-   Skips an attribute the attribute_name_index has already been read.
-       
-   attribute_info {
-       u2 attribute_name_index;
-       u4 attribute_length;
-       u1 info[attribute_length];
-   }
-
-*******************************************************************************/
-
-bool loader_skip_attribute_body(classbuffer *cb)
-{
-       u4 attribute_length;
-
-       if (!suck_check_classbuffer_size(cb, 4))
-               return false;
-
-       attribute_length = suck_u4(cb);
-
-       if (!suck_check_classbuffer_size(cb, attribute_length))
-               return false;
-
-       suck_skip_nbytes(cb, attribute_length);
-
-       return true;
-}
-
-
-/* load_constantpool ***********************************************************
-
-   Loads the constantpool of a class, the entries are transformed into
-   a simpler format by resolving references (a detailed overview of
-   the compact structures can be found in global.h).
-
-*******************************************************************************/
-
-static bool load_constantpool(classbuffer *cb, descriptor_pool *descpool)
-{
-
-       /* The following structures are used to save information which cannot be 
-          processed during the first pass. After the complete constantpool has 
-          been traversed the references can be resolved. 
-          (only in specific order)                                                */
-       
-       /* CONSTANT_Class entries */
-       typedef struct forward_class {
-               struct forward_class *next;
-               u2 thisindex;
-               u2 name_index;
-       } forward_class;
-
-       /* CONSTANT_String */
-       typedef struct forward_string {
-               struct forward_string *next;
-               u2 thisindex;
-               u2 string_index;
-       } forward_string;
-
-       /* CONSTANT_NameAndType */
-       typedef struct forward_nameandtype {
-               struct forward_nameandtype *next;
-               u2 thisindex;
-               u2 name_index;
-               u2 sig_index;
-       } forward_nameandtype;
-
-       /* CONSTANT_Fieldref, CONSTANT_Methodref or CONSTANT_InterfaceMethodref */
-       typedef struct forward_fieldmethint {
-               struct forward_fieldmethint *next;
-               u2 thisindex;
-               u1 tag;
-               u2 class_index;
-               u2 nameandtype_index;
-       } forward_fieldmethint;
-
-
-       classinfo *c;
-       u4 idx;
-
-       forward_class *forward_classes = NULL;
-       forward_string *forward_strings = NULL;
-       forward_nameandtype *forward_nameandtypes = NULL;
-       forward_fieldmethint *forward_fieldmethints = NULL;
-
-       forward_class *nfc;
-       forward_string *nfs;
-       forward_nameandtype *nfn;
-       forward_fieldmethint *nff;
-
-       u4 cpcount;
-       u1 *cptags;
-       voidptr *cpinfos;
-
-       c = cb->clazz;
-
-       /* number of entries in the constant_pool table plus one */
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       cpcount = c->cpcount = suck_u2(cb);
-
-       /* allocate memory */
-       cptags  = c->cptags  = MNEW(u1, cpcount);
-       cpinfos = c->cpinfos = MNEW(voidptr, cpcount);
-
-       if (cpcount < 1) {
-               exceptions_throw_classformaterror(c, "Illegal constant pool size");
-               return false;
-       }
-       
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               count_const_pool_len += (sizeof(u1) + sizeof(voidptr)) * cpcount;
-#endif
-       
-       /* initialize constantpool */
-       for (idx = 0; idx < cpcount; idx++) {
-               cptags[idx] = CONSTANT_UNUSED;
-               cpinfos[idx] = NULL;
-       }
-
-                       
-       /******* first pass *******/
-       /* entries which cannot be resolved now are written into 
-          temporary structures and traversed again later        */
-                  
-       idx = 1;
-       while (idx < cpcount) {
-               u4 t;
-
-               /* get constant type */
-               if (!suck_check_classbuffer_size(cb, 1))
-                       return false;
-
-               t = suck_u1(cb);
-
-               switch (t) {
-               case CONSTANT_Class:
-                       nfc = DNEW(forward_class);
-
-                       nfc->next = forward_classes;
-                       forward_classes = nfc;
-
-                       nfc->thisindex = idx;
-                       /* reference to CONSTANT_NameAndType */
-                       if (!suck_check_classbuffer_size(cb, 2))
-                               return false;
-
-                       nfc->name_index = suck_u2(cb);
-
-                       idx++;
-                       break;
-                       
-               case CONSTANT_String:
-                       nfs = DNEW(forward_string);
-                               
-                       nfs->next = forward_strings;
-                       forward_strings = nfs;
-                               
-                       nfs->thisindex = idx;
-
-                       /* reference to CONSTANT_Utf8_info with string characters */
-                       if (!suck_check_classbuffer_size(cb, 2))
-                               return false;
-
-                       nfs->string_index = suck_u2(cb);
-                               
-                       idx++;
-                       break;
-
-               case CONSTANT_NameAndType:
-                       nfn = DNEW(forward_nameandtype);
-                               
-                       nfn->next = forward_nameandtypes;
-                       forward_nameandtypes = nfn;
-                               
-                       nfn->thisindex = idx;
-
-                       if (!suck_check_classbuffer_size(cb, 2 + 2))
-                               return false;
-
-                       /* reference to CONSTANT_Utf8_info containing simple name */
-                       nfn->name_index = suck_u2(cb);
-
-                       /* reference to CONSTANT_Utf8_info containing field or method
-                          descriptor */
-                       nfn->sig_index = suck_u2(cb);
-                               
-                       idx++;
-                       break;
-
-               case CONSTANT_Fieldref:
-               case CONSTANT_Methodref:
-               case CONSTANT_InterfaceMethodref:
-                       nff = DNEW(forward_fieldmethint);
-                       
-                       nff->next = forward_fieldmethints;
-                       forward_fieldmethints = nff;
-
-                       nff->thisindex = idx;
-                       /* constant type */
-                       nff->tag = t;
-
-                       if (!suck_check_classbuffer_size(cb, 2 + 2))
-                               return false;
-
-                       /* class or interface type that contains the declaration of the
-                          field or method */
-                       nff->class_index = suck_u2(cb);
-
-                       /* name and descriptor of the field or method */
-                       nff->nameandtype_index = suck_u2(cb);
-
-                       idx++;
-                       break;
-                               
-               case CONSTANT_Integer: {
-                       constant_integer *ci = NEW(constant_integer);
-
-#if defined(ENABLE_STATISTICS)
-                       if (opt_stat)
-                               count_const_pool_len += sizeof(constant_integer);
-#endif
-
-                       if (!suck_check_classbuffer_size(cb, 4))
-                               return false;
-
-                       ci->value = suck_s4(cb);
-                       cptags[idx] = CONSTANT_Integer;
-                       cpinfos[idx] = ci;
-
-                       idx++;
-                       break;
-               }
-                               
-               case CONSTANT_Float: {
-                       constant_float *cf = NEW(constant_float);
-
-#if defined(ENABLE_STATISTICS)
-                       if (opt_stat)
-                               count_const_pool_len += sizeof(constant_float);
-#endif
-
-                       if (!suck_check_classbuffer_size(cb, 4))
-                               return false;
-
-                       cf->value = suck_float(cb);
-                       cptags[idx] = CONSTANT_Float;
-                       cpinfos[idx] = cf;
-
-                       idx++;
-                       break;
-               }
-                               
-               case CONSTANT_Long: {
-                       constant_long *cl = NEW(constant_long);
-                                       
-#if defined(ENABLE_STATISTICS)
-                       if (opt_stat)
-                               count_const_pool_len += sizeof(constant_long);
-#endif
-
-                       if (!suck_check_classbuffer_size(cb, 8))
-                               return false;
-
-                       cl->value = suck_s8(cb);
-                       cptags[idx] = CONSTANT_Long;
-                       cpinfos[idx] = cl;
-                       idx += 2;
-                       if (idx > cpcount) {
-                               exceptions_throw_classformaterror(c, "Invalid constant pool entry");
-                               return false;
-                       }
-                       break;
-               }
-                       
-               case CONSTANT_Double: {
-                       constant_double *cd = NEW(constant_double);
-                               
-#if defined(ENABLE_STATISTICS)
-                       if (opt_stat)
-                               count_const_pool_len += sizeof(constant_double);
-#endif
-
-                       if (!suck_check_classbuffer_size(cb, 8))
-                               return false;
-
-                       cd->value = suck_double(cb);
-                       cptags[idx] = CONSTANT_Double;
-                       cpinfos[idx] = cd;
-                       idx += 2;
-                       if (idx > cpcount) {
-                               exceptions_throw_classformaterror(c, "Invalid constant pool entry");
-                               return false;
-                       }
-                       break;
-               }
-                               
-               case CONSTANT_Utf8: { 
-                       u4 length;
-
-                       /* number of bytes in the bytes array (not string-length) */
-                       if (!suck_check_classbuffer_size(cb, 2))
-                               return false;
-
-                       length = suck_u2(cb);
-                       cptags[idx] = CONSTANT_Utf8;
-
-                       /* validate the string */
-                       if (!suck_check_classbuffer_size(cb, length))
-                               return false;
-
-#ifdef ENABLE_VERIFIER
-                       if (opt_verify &&
-                               !is_valid_utf((char *) cb->pos, (char *) (cb->pos + length))) 
-                       {
-                               exceptions_throw_classformaterror(c, "Invalid UTF-8 string");
-                               return false;
-                       }
-#endif /* ENABLE_VERIFIER */
-                       /* insert utf-string into the utf-symboltable */
-                       cpinfos[idx] = utf_new((char *) cb->pos, length);
-
-                       /* skip bytes of the string (buffer size check above) */
-                       suck_skip_nbytes(cb, length);
-                       idx++;
-                       break;
-               }
-                                                                               
-               default:
-                       exceptions_throw_classformaterror(c, "Illegal constant pool type");
-                       return false;
-               }  /* end switch */
-       } /* end while */
-
-
-       /* resolve entries in temporary structures */
-
-       while (forward_classes) {
-               utf *name =
-                       class_getconstant(c, forward_classes->name_index, CONSTANT_Utf8);
-               if (!name)
-                       return false;
-
-#ifdef ENABLE_VERIFIER
-               if (opt_verify && !is_valid_name_utf(name)) {
-                       exceptions_throw_classformaterror(c, "Class reference with invalid name");
-                       return false;
-               }
-#endif /* ENABLE_VERIFIER */
-
-               /* add all class references to the descriptor_pool */
-
-               if (!descriptor_pool_add_class(descpool, name))
-                       return false;
-
-               cptags[forward_classes->thisindex] = CONSTANT_Class;
-
-               /* the classref is created later */
-               cpinfos[forward_classes->thisindex] = name;
-
-               nfc = forward_classes;
-               forward_classes = forward_classes->next;
-       }
-
-       while (forward_strings) {
-               utf *text =
-                       class_getconstant(c, forward_strings->string_index, CONSTANT_Utf8);
-               if (!text)
-                       return false;
-
-               /* resolve utf-string */
-               cptags[forward_strings->thisindex] = CONSTANT_String;
-               cpinfos[forward_strings->thisindex] = text;
-               
-               nfs = forward_strings;
-               forward_strings = forward_strings->next;
-       }
-
-       while (forward_nameandtypes) {
-               constant_nameandtype *cn = NEW(constant_nameandtype);   
-
-#if defined(ENABLE_STATISTICS)
-               if (opt_stat)
-                       count_const_pool_len += sizeof(constant_nameandtype);
-#endif
-
-               /* resolve simple name and descriptor */
-               cn->name = class_getconstant(c,
-                                                                        forward_nameandtypes->name_index,
-                                                                        CONSTANT_Utf8);
-               if (!cn->name)
-                       return false;
-
-               cn->descriptor = class_getconstant(c,
-                                                                                  forward_nameandtypes->sig_index,
-                                                                                  CONSTANT_Utf8);
-               if (!cn->descriptor)
-                       return false;
-
-#ifdef ENABLE_VERIFIER
-               if (opt_verify) {
-                       /* check name */
-                       if (!is_valid_name_utf(cn->name)) {
-                               exceptions_throw_classformaterror(c,
-                                                                                                 "Illegal Field name \"%s\"",
-                                                                                                 cn->name->text);
-
-                               return false;
-                       }
-
-                       /* disallow referencing <clinit> among others */
-                       if (cn->name->text[0] == '<' && cn->name != utf_init) {
-                               exceptions_throw_classformaterror(c, "Illegal reference to special method");
-                               return false;
-                       }
-               }
-#endif /* ENABLE_VERIFIER */
-
-               cptags[forward_nameandtypes->thisindex] = CONSTANT_NameAndType;
-               cpinfos[forward_nameandtypes->thisindex] = cn;
-
-               nfn = forward_nameandtypes;
-               forward_nameandtypes = forward_nameandtypes->next;
-       }
-
-       while (forward_fieldmethints) {
-               constant_nameandtype *nat;
-               constant_FMIref *fmi = NEW(constant_FMIref);
-
-#if defined(ENABLE_STATISTICS)
-               if (opt_stat)
-                       count_const_pool_len += sizeof(constant_FMIref);
-#endif
-               /* resolve simple name and descriptor */
-
-               nat = class_getconstant(c,
-                                                               forward_fieldmethints->nameandtype_index,
-                                                               CONSTANT_NameAndType);
-               if (!nat)
-                       return false;
-
-               /* add all descriptors in {Field,Method}ref to the descriptor_pool */
-
-               if (!descriptor_pool_add(descpool, nat->descriptor, NULL))
-                       return false;
-
-               /* the classref is created later */
-
-               fmi->p.index = forward_fieldmethints->class_index;
-               fmi->name = nat->name;
-               fmi->descriptor = nat->descriptor;
-
-               cptags[forward_fieldmethints->thisindex] = forward_fieldmethints->tag;
-               cpinfos[forward_fieldmethints->thisindex] = fmi;
-       
-               nff = forward_fieldmethints;
-               forward_fieldmethints = forward_fieldmethints->next;
-       }
-
-       /* everything was ok */
-
-       return true;
-}
-
-
-/* loader_load_attribute_signature *********************************************
-
-   Signature_attribute {
-       u2 attribute_name_index;
-          u4 atrribute_length;
-          u2 signature_index;
-   }
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-bool loader_load_attribute_signature(classbuffer *cb, utf **signature)
-{
-       classinfo *c;
-       u4         attribute_length;
-       u2         signature_index;
-
-       /* get classinfo */
-
-       c = cb->clazz;
-
-       /* check remaining bytecode */
-
-       if (!suck_check_classbuffer_size(cb, 4 + 2))
-               return false;
-
-       /* check attribute length */
-
-       attribute_length = suck_u4(cb);
-
-       if (attribute_length != 2) {
-               exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute");
-               return false;
-       }
-
-       if (*signature != NULL) {
-               exceptions_throw_classformaterror(c, "Multiple Signature attributes");
-               return false;
-       }
-
-       /* get signature */
-
-       signature_index = suck_u2(cb);
-
-       if (!(*signature = class_getconstant(c, signature_index, CONSTANT_Utf8)))
-               return false;
-
-       return true;
-}
-#endif /* defined(ENABLE_JAVASE) */
-
-
-/* load_class_from_sysloader ***************************************************
-
-   Load the class with the given name using the system class loader
-
-   IN:
-       name.............the classname
-
-   RETURN VALUE:
-       the loaded class, or
-          NULL if an exception has been thrown
-
-*******************************************************************************/
-
-classinfo *load_class_from_sysloader(utf *name)
-{
-       methodinfo    *m;
-       java_handle_t *clo;
-       classloader_t *cl;
-       classinfo     *c;
-
-       assert(class_java_lang_Object);
-       assert(class_java_lang_ClassLoader);
-       assert(class_java_lang_ClassLoader->state & CLASS_LINKED);
-       
-       m = class_resolveclassmethod(class_java_lang_ClassLoader,
-                                                                utf_getSystemClassLoader,
-                                                                utf_void__java_lang_ClassLoader,
-                                                                class_java_lang_Object,
-                                                                false);
-
-       if (!m)
-               return false;
-
-       clo = vm_call_method(m, NULL);
-
-       if (!clo)
-               return false;
-
-       cl = loader_hashtable_classloader_add(clo);
-
-       c = load_class_from_classloader(name, cl);
-
-       return c;
-}
-
-
-/* load_class_from_classloader *************************************************
-
-   Load the class with the given name using the given user-defined class loader.
-
-   IN:
-       name.............the classname
-          cl...............user-defined class loader
-          
-   RETURN VALUE:
-       the loaded class, or
-          NULL if an exception has been thrown
-
-*******************************************************************************/
-
-classinfo *load_class_from_classloader(utf *name, classloader_t *cl)
-{
-       java_handle_t *o;
-       classinfo     *c;
-       classinfo     *tmpc;
-       java_handle_t *string;
-#if defined(ENABLE_RT_TIMING)
-       struct timespec time_start, time_lookup, time_prepare, time_java, 
-                                       time_cache;
-#endif
-
-       RT_TIMING_GET_TIME(time_start);
-
-       assert(name);
-
-       /* lookup if this class has already been loaded */
-
-       c = classcache_lookup(cl, name);
-
-       RT_TIMING_GET_TIME(time_lookup);
-       RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_CL_LOOKUP);
-
-       if (c != NULL)
-               return c;
-
-       /* if other class loader than bootstrap, call it */
-
-       if (cl != NULL) {
-               methodinfo *lc;
-               char       *text;
-               s4          namelen;
-
-               text = name->text;
-               namelen = name->blength;
-
-               /* handle array classes */
-               if (text[0] == '[') {
-                       classinfo *comp;
-                       utf       *u;
-
-                       switch (text[1]) {
-                       case 'L':
-                               /* check for cases like `[L;' or `[L[I;' or `[Ljava.lang.Object' */
-                               if (namelen < 4 || text[2] == '[' || text[namelen - 1] != ';') {
-                                       exceptions_throw_classnotfoundexception(name);
-                                       return false;
-                               }
-
-                               u = utf_new(text + 2, namelen - 3);
-
-                               if (!(comp = load_class_from_classloader(u, cl)))
-                                       return false;
-
-                               /* create the array class */
-
-                               c = class_array_of(comp, false);
-
-                               tmpc = classcache_store(cl, c, true);
-
-                               if (tmpc == NULL) {
-                                       /* exception, free the loaded class */
-                                       c->state &= ~CLASS_LOADING;
-                                       class_free(c);
-                               }
-
-                               return tmpc;
-
-                       case '[':
-                               /* load the component class */
-
-                               u = utf_new(text + 1, namelen - 1);
-
-                               if (!(comp = load_class_from_classloader(u, cl)))
-                                       return false;
-
-                               /* create the array class */
-
-                               c = class_array_of(comp, false);
-
-                               tmpc = classcache_store(cl, c, true);
-
-                               if (tmpc == NULL) {
-                                       /* exception, free the loaded class */
-                                       c->state &= ~CLASS_LOADING;
-                                       class_free(c);
-                               }
-
-                               return tmpc;
-
-                       default:
-                               /* primitive array classes are loaded by the bootstrap loader */
-
-                               c = load_class_bootstrap(name);
-
-                               return c;
-                       }
-               }
-
-               LLNI_class_get(cl, c);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-               /* OpenJDK uses this internal function because it's
-                  synchronized. */
-
-               lc = class_resolveclassmethod(c,
-                                                                         utf_loadClassInternal,
-                                                                         utf_java_lang_String__java_lang_Class,
-                                                                         NULL,
-                                                                         true);
-#else
-               lc = class_resolveclassmethod(c,
-                                                                         utf_loadClass,
-                                                                         utf_java_lang_String__java_lang_Class,
-                                                                         NULL,
-                                                                         true);
-#endif
-
-               if (lc == NULL)
-                       return false; /* exception */
-
-               /* move return value into `o' and cast it afterwards to a classinfo* */
-
-               string = javastring_new_slash_to_dot(name);
-
-               RT_TIMING_GET_TIME(time_prepare);
-
-               o = vm_call_method(lc, (java_handle_t *) cl, string);
-
-               RT_TIMING_GET_TIME(time_java);
-
-               c = LLNI_classinfo_unwrap(o);
-
-               if (c != NULL) {
-                       /* Store this class in the loaded class cache. If another
-                          class with the same (initloader,name) pair has been
-                          stored earlier it will be returned by classcache_store
-                          In this case classcache_store may not free the class
-                          because it has already been exposed to Java code which
-                          may have kept references to that class. */
-
-                   tmpc = classcache_store(cl, c, false);
-
-                       if (tmpc == NULL) {
-                               /* exception, free the loaded class */
-                               c->state &= ~CLASS_LOADING;
-                               class_free(c);
-                       }
-
-                       c = tmpc;
-               }
-
-               RT_TIMING_GET_TIME(time_cache);
-
-               RT_TIMING_TIME_DIFF(time_lookup , time_prepare, RT_TIMING_LOAD_CL_PREPARE);
-               RT_TIMING_TIME_DIFF(time_prepare, time_java   , RT_TIMING_LOAD_CL_JAVA);
-               RT_TIMING_TIME_DIFF(time_java   , time_cache  , RT_TIMING_LOAD_CL_CACHE);
-
-               /* SUN compatible -verbose:class output */
-
-               if (opt_verboseclass && (c != NULL) && (c->classloader == cl)) {
-                       printf("[Loaded ");
-                       utf_display_printable_ascii_classname(name);
-                       printf("]\n");
-               }
-
-#if defined(ENABLE_JVMTI)
-               /* fire Class Load JVMTI event */
-               if (jvmti) jvmti_ClassLoadPrepare(false, c);
-#endif
-
-
-               return c;
-       } 
-
-       c = load_class_bootstrap(name);
-
-       return c;
-}
-
-
-/* load_class_bootstrap ********************************************************
-       
-   Load the class with the given name using the bootstrap class loader.
-
-   IN:
-       name.............the classname
-
-   RETURN VALUE:
-       loaded classinfo, or
-          NULL if an exception has been thrown
-
-   SYNCHRONIZATION:
-       load_class_bootstrap is synchronized. It can be treated as an
-          atomic operation.
-
-*******************************************************************************/
-
-classinfo *load_class_bootstrap(utf *name)
-{
-       classbuffer *cb;
-       classinfo   *c;
-       classinfo   *r;
-#if defined(ENABLE_RT_TIMING)
-       struct timespec time_start, time_lookup, time_array, time_suck, 
-                                       time_load, time_cache;
-#endif
-
-       RT_TIMING_GET_TIME(time_start);
-
-       /* for debugging */
-
-       assert(name);
-
-       /* lookup if this class has already been loaded */
-
-       r = classcache_lookup(NULL, name);
-
-       if (r != NULL) {
-               RT_TIMING_GET_TIME(time_lookup);
-               RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_BOOT_LOOKUP);
-               
-               return r;
-       }
-
-       RT_TIMING_GET_TIME(time_lookup);
-       RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_BOOT_LOOKUP);
-               
-       /* create the classinfo */
-
-       c = class_create_classinfo(name);
-
-       /* handle array classes */
-
-       if (name->text[0] == '[') {
-               c = load_newly_created_array(c, NULL);
-
-               if (c == NULL)
-                       return NULL;
-
-               assert(c->state & CLASS_LOADED);
-
-               RT_TIMING_GET_TIME(time_array);
-               RT_TIMING_TIME_DIFF(time_start,time_array,RT_TIMING_LOAD_BOOT_ARRAY);
-               
-               return c;
-       }
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getcompilingtime)
-               compilingtime_stop();
-
-       if (opt_getloadingtime)
-               loadingtime_start();
-#endif
-
-       /* load classdata, throw exception on error */
-
-       cb = suck_start(c);
-
-       if (cb == NULL) {
-               exceptions_throw_classnotfoundexception(name);
-               return NULL;
-       }
-
-       RT_TIMING_GET_TIME(time_suck);
-       
-       /* load the class from the buffer */
-
-       r = load_class_from_classbuffer(cb);
-
-       RT_TIMING_GET_TIME(time_load);
-       
-       if (r == NULL) {
-               /* the class could not be loaded, free the classinfo struct */
-
-               class_free(c);
-       }
-       else {
-               /* Store this class in the loaded class cache this step also
-                  checks the loading constraints. If the class has been
-                  loaded before, the earlier loaded class is returned. */
-
-               classinfo *res = classcache_store(NULL, c, true);
-
-               if (res == NULL) {
-                       /* exception */
-                       class_free(c);
-               }
-               else {
-                       /* Add the package name to the boot packages. */
-
-                       package_add(c->packagename);
-               }
-
-               r = res;
-       }
-
-       RT_TIMING_GET_TIME(time_cache);
-       
-       /* SUN compatible -verbose:class output */
-
-       if (opt_verboseclass && r) {
-               printf("[Loaded ");
-               utf_display_printable_ascii_classname(name);
-               printf(" from %s]\n", cb->path);
-       }
-
-       /* free memory */
-
-       suck_stop(cb);
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getloadingtime)
-               loadingtime_stop();
-
-       if (opt_getcompilingtime)
-               compilingtime_start();
-#endif
-
-       RT_TIMING_TIME_DIFF(time_lookup, time_suck , RT_TIMING_LOAD_BOOT_SUCK);
-       RT_TIMING_TIME_DIFF(time_suck  , time_load , RT_TIMING_LOAD_BOOT_LOAD);
-       RT_TIMING_TIME_DIFF(time_load  , time_cache, RT_TIMING_LOAD_BOOT_CACHE);
-       RT_TIMING_TIME_DIFF(time_lookup, time_cache, RT_TIMING_LOAD_BOOT_TOTAL);
-
-       return r;
-}
-
-
-/* load_class_from_classbuffer_intern ******************************************
-       
-   Loads a class from a classbuffer into a given classinfo structure.
-   Super-classes are also loaded at this point and some verfication
-   checks are done.
-
-   SYNCHRONIZATION:
-       This function is NOT synchronized!
-   
-*******************************************************************************/
-
-static bool load_class_from_classbuffer_intern(classbuffer *cb)
-{
-       classinfo          *c;
-       classinfo          *tc;
-       utf                *name;
-       utf                *supername;
-       utf               **interfacesnames;
-       utf                *u;
-       constant_classref  *cr;
-       int16_t             index;
-
-       u4 i,j;
-       u4 ma, mi;
-       descriptor_pool *descpool;
-#if defined(ENABLE_STATISTICS)
-       u4 classrefsize;
-       u4 descsize;
-#endif
-#if defined(ENABLE_RT_TIMING)
-       struct timespec time_start, time_checks, time_ndpool, time_cpool,
-                                       time_setup, time_fields, time_methods, time_classrefs,
-                                       time_descs,     time_setrefs, time_parsefds, time_parsemds,
-                                       time_parsecpool, time_verify, time_attrs;
-#endif
-
-       RT_TIMING_GET_TIME(time_start);
-
-       /* Get the classbuffer's class. */
-
-       c = cb->clazz;
-
-       if (!suck_check_classbuffer_size(cb, 4 + 2 + 2))
-               return false;
-
-       /* check signature */
-
-       if (suck_u4(cb) != MAGIC) {
-               exceptions_throw_classformaterror(c, "Bad magic number");
-               return false;
-       }
-
-       /* check version */
-
-       mi = suck_u2(cb);
-       ma = suck_u2(cb);
-
-       if (!(ma < MAJOR_VERSION || (ma == MAJOR_VERSION && mi <= MINOR_VERSION))) {
-               exceptions_throw_unsupportedclassversionerror(c, ma, mi);
-               return false;
-       }
-
-       RT_TIMING_GET_TIME(time_checks);
-
-       /* create a new descriptor pool */
-
-       descpool = descriptor_pool_new(c);
-
-       RT_TIMING_GET_TIME(time_ndpool);
-
-       /* load the constant pool */
-
-       if (!load_constantpool(cb, descpool))
-               return false;
-
-       RT_TIMING_GET_TIME(time_cpool);
-
-       /* ACC flags */
-
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       /* We OR the flags here, as we set already some flags in
-          class_create_classinfo. */
-
-       c->flags |= suck_u2(cb);
-
-       /* check ACC flags consistency */
-
-       if (c->flags & ACC_INTERFACE) {
-               if (!(c->flags & ACC_ABSTRACT)) {
-                       /* We work around this because interfaces in JDK 1.1 are
-                        * not declared abstract. */
-
-                       c->flags |= ACC_ABSTRACT;
-               }
-
-               if (c->flags & ACC_FINAL) {
-                       exceptions_throw_classformaterror(c,
-                                                                                         "Illegal class modifiers: 0x%X",
-                                                                                         c->flags);
-                       return false;
-               }
-
-               if (c->flags & ACC_SUPER) {
-                       c->flags &= ~ACC_SUPER; /* kjc seems to set this on interfaces */
-               }
-       }
-
-       if ((c->flags & (ACC_ABSTRACT | ACC_FINAL)) == (ACC_ABSTRACT | ACC_FINAL)) {
-               exceptions_throw_classformaterror(c,
-                                                                                 "Illegal class modifiers: 0x%X",
-                                                                                 c->flags);
-               return false;
-       }
-
-       if (!suck_check_classbuffer_size(cb, 2 + 2))
-               return false;
-
-       /* This class. */
-
-       index = suck_u2(cb);
-
-       name = (utf *) class_getconstant(c, index, CONSTANT_Class);
-
-       if (name == NULL)
-               return false;
-
-       if (c->name == utf_not_named_yet) {
-               /* we finally have a name for this class */
-               c->name = name;
-               class_set_packagename(c);
-       }
-       else if (name != c->name) {
-               exceptions_throw_noclassdeffounderror_wrong_name(c, name);
-               return false;
-       }
-
-       /* Retrieve superclass. */
-
-       c->super = NULL;
-
-       index = suck_u2(cb);
-
-       if (index == 0) {
-               supername = NULL;
-
-               /* This is only allowed for java.lang.Object. */
-
-               if (c->name != utf_java_lang_Object) {
-                       exceptions_throw_classformaterror(c, "Bad superclass index");
-                       return false;
-               }
-       }
-       else {
-               supername = (utf *) class_getconstant(c, index, CONSTANT_Class);
-
-               if (supername == NULL)
-                       return false;
-
-               /* java.lang.Object may not have a super class. */
-
-               if (c->name == utf_java_lang_Object) {
-                       exceptions_throw_classformaterror(NULL, "java.lang.Object with superclass");
-                       return false;
-               }
-
-               /* Detect circularity. */
-
-               if (supername == c->name) {
-                       exceptions_throw_classcircularityerror(c);
-                       return false;
-               }
-
-               /* Interfaces must have java.lang.Object as super class. */
-
-               if ((c->flags & ACC_INTERFACE) && (supername != utf_java_lang_Object)) {
-                       exceptions_throw_classformaterror(c, "Interfaces must have java.lang.Object as superclass");
-                       return false;
-               }
-       }
-
-       /* Parse the super interfaces. */
-
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       c->interfacescount = suck_u2(cb);
-
-       if (!suck_check_classbuffer_size(cb, 2 * c->interfacescount))
-               return false;
-
-       c->interfaces = MNEW(classinfo*, c->interfacescount);
-
-       /* Get the names of the super interfaces. */
-
-       interfacesnames = DMNEW(utf*, c->interfacescount);
-
-       for (i = 0; i < c->interfacescount; i++) {
-               index = suck_u2(cb);
-
-               u = (utf *) class_getconstant(c, index, CONSTANT_Class);
-
-               if (u == NULL)
-                       return false;
-
-               interfacesnames[i] = u;
-       }
-
-       RT_TIMING_GET_TIME(time_setup);
-
-       /* Parse fields. */
-
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       c->fieldscount = suck_u2(cb);
-       c->fields      = MNEW(fieldinfo, c->fieldscount);
-
-       MZERO(c->fields, fieldinfo, c->fieldscount);
-
-       for (i = 0; i < c->fieldscount; i++) {
-               if (!field_load(cb, &(c->fields[i]), descpool))
-                       return false;
-       }
-
-       RT_TIMING_GET_TIME(time_fields);
-
-       /* Parse methods. */
-
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       c->methodscount = suck_u2(cb);
-       c->methods      = MNEW(methodinfo, c->methodscount);
-
-       MZERO(c->methods, methodinfo, c->methodscount);
-       
-       for (i = 0; i < c->methodscount; i++) {
-               if (!method_load(cb, &(c->methods[i]), descpool))
-                       return false;
-       }
-
-       RT_TIMING_GET_TIME(time_methods);
-
-       /* create the class reference table */
-
-       c->classrefs =
-               descriptor_pool_create_classrefs(descpool, &(c->classrefcount));
-
-       RT_TIMING_GET_TIME(time_classrefs);
-
-       /* allocate space for the parsed descriptors */
-
-       descriptor_pool_alloc_parsed_descriptors(descpool);
-       c->parseddescs =
-               descriptor_pool_get_parsed_descriptors(descpool, &(c->parseddescsize));
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat) {
-               descriptor_pool_get_sizes(descpool, &classrefsize, &descsize);
-               count_classref_len += classrefsize;
-               count_parsed_desc_len += descsize;
-       }
-#endif
-
-       RT_TIMING_GET_TIME(time_descs);
-
-       /* put the classrefs in the constant pool */
-
-       for (i = 0; i < c->cpcount; i++) {
-               if (c->cptags[i] == CONSTANT_Class) {
-                       utf *name = (utf *) c->cpinfos[i];
-                       c->cpinfos[i] = descriptor_pool_lookup_classref(descpool, name);
-               }
-       }
-
-       /* Resolve the super class. */
-
-       if (supername != NULL) {
-               cr = descriptor_pool_lookup_classref(descpool, supername);
-
-               if (cr == NULL)
-                       return false;
-
-               /* XXX This should be done better. */
-               tc = resolve_classref_or_classinfo_eager(CLASSREF_OR_CLASSINFO(cr), false);
-
-               if (tc == NULL) {
-                       resolve_handle_pending_exception(true);
-                       return false;
-               }
-
-               /* Interfaces are not allowed as super classes. */
-
-               if (tc->flags & ACC_INTERFACE) {
-                       exceptions_throw_incompatibleclasschangeerror(c, "class %s has interface %s as super class");
-                       return false;
-               }
-
-               /* Don't allow extending final classes */
-
-               if (tc->flags & ACC_FINAL) {
-                       exceptions_throw_verifyerror(NULL,
-                                                                                "Cannot inherit from final class");
-                       return false;
-               }
-
-               /* Store the super class. */
-
-               c->super = tc;
-       }
-
-       /* Resolve the super interfaces. */
-
-       for (i = 0; i < c->interfacescount; i++) {
-               u  = interfacesnames[i];
-               cr = descriptor_pool_lookup_classref(descpool, u);
-
-               if (cr == NULL)
-                       return false;
-
-               /* XXX This should be done better. */
-               tc = resolve_classref_or_classinfo_eager(CLASSREF_OR_CLASSINFO(cr), false);
-
-               if (tc == NULL) {
-                       resolve_handle_pending_exception(true);
-                       return false;
-               }
-
-               /* Detect circularity. */
-
-               if (tc == c) {
-                       exceptions_throw_classcircularityerror(c);
-                       return false;
-               }
-
-               if (!(tc->flags & ACC_INTERFACE)) {
-                       exceptions_throw_incompatibleclasschangeerror(tc,
-                                                                                                                 "Implementing class");
-                       return false;
-               }
-
-               /* Store the super interface. */
-
-               c->interfaces[i] = tc;
-       }
-
-       RT_TIMING_GET_TIME(time_setrefs);
-
-       /* Parse the field descriptors. */
-
-       for (i = 0; i < c->fieldscount; i++) {
-               c->fields[i].parseddesc =
-                       descriptor_pool_parse_field_descriptor(descpool,
-                                                                                                  c->fields[i].descriptor);
-               if (!c->fields[i].parseddesc)
-                       return false;
-       }
-
-       RT_TIMING_GET_TIME(time_parsefds);
-
-       /* parse method descriptors */
-
-       for (i = 0; i < c->methodscount; i++) {
-               methodinfo *m = &c->methods[i];
-               m->parseddesc =
-                       descriptor_pool_parse_method_descriptor(descpool, m->descriptor,
-                                                                                                       m->flags, class_get_self_classref(m->clazz));
-               if (!m->parseddesc)
-                       return false;
-
-               for (j = 0; j < m->rawexceptiontablelength; j++) {
-                       if (!m->rawexceptiontable[j].catchtype.any)
-                               continue;
-
-                       if ((m->rawexceptiontable[j].catchtype.ref =
-                                descriptor_pool_lookup_classref(descpool,
-                                               (utf *) m->rawexceptiontable[j].catchtype.any)) == NULL)
-                               return false;
-               }
-
-               for (j = 0; j < m->thrownexceptionscount; j++) {
-                       if (!m->thrownexceptions[j].any)
-                               continue;
-
-                       if ((m->thrownexceptions[j].ref = descriptor_pool_lookup_classref(descpool,
-                                               (utf *) m->thrownexceptions[j].any)) == NULL)
-                               return false;
-               }
-       }
-
-       RT_TIMING_GET_TIME(time_parsemds);
-
-       /* parse the loaded descriptors */
-
-       for (i = 0; i < c->cpcount; i++) {
-               constant_FMIref *fmi;
-               s4               index;
-
-               switch (c->cptags[i]) {
-               case CONSTANT_Fieldref:
-                       fmi = (constant_FMIref *) c->cpinfos[i];
-                       fmi->parseddesc.fd =
-                               descriptor_pool_parse_field_descriptor(descpool,
-                                                                                                          fmi->descriptor);
-                       if (!fmi->parseddesc.fd)
-                               return false;
-
-                       index = fmi->p.index;
-                       fmi->p.classref =
-                               (constant_classref *) class_getconstant(c, index,
-                                                                                                               CONSTANT_Class);
-                       if (!fmi->p.classref)
-                               return false;
-                       break;
-               case CONSTANT_Methodref:
-               case CONSTANT_InterfaceMethodref:
-                       fmi = (constant_FMIref *) c->cpinfos[i];
-                       index = fmi->p.index;
-                       fmi->p.classref =
-                               (constant_classref *) class_getconstant(c, index,
-                                                                                                               CONSTANT_Class);
-                       if (!fmi->p.classref)
-                               return false;
-                       fmi->parseddesc.md =
-                               descriptor_pool_parse_method_descriptor(descpool,
-                                                                                                               fmi->descriptor,
-                                                                                                               ACC_UNDEF,
-                                                                                                               fmi->p.classref);
-                       if (!fmi->parseddesc.md)
-                               return false;
-                       break;
-               }
-       }
-
-       RT_TIMING_GET_TIME(time_parsecpool);
-
-#ifdef ENABLE_VERIFIER
-       /* Check if all fields and methods can be uniquely
-        * identified by (name,descriptor). */
-
-       if (opt_verify) {
-               /* We use a hash table here to avoid making the
-                * average case quadratic in # of methods, fields.
-                */
-               static int shift = 0;
-               u2 *hashtab;
-               u2 *next; /* for chaining colliding hash entries */
-               size_t len;
-               size_t hashlen;
-               u2 index;
-               u2 old;
-
-               /* Allocate hashtable */
-               len = c->methodscount;
-               if (len < c->fieldscount) len = c->fieldscount;
-               hashlen = 5 * len;
-               hashtab = MNEW(u2,(hashlen + len));
-               next = hashtab + hashlen;
-
-               /* Determine bitshift (to get good hash values) */
-               if (!shift) {
-                       len = sizeof(utf);
-                       while (len) {
-                               len >>= 1;
-                               shift++;
-                       }
-               }
-
-               /* Check fields */
-               memset(hashtab, 0, sizeof(u2) * (hashlen + len));
-
-               for (i = 0; i < c->fieldscount; ++i) {
-                       fieldinfo *fi = c->fields + i;
-
-                       /* It's ok if we lose bits here */
-                       index = ((((size_t) fi->name) +
-                                         ((size_t) fi->descriptor)) >> shift) % hashlen;
-
-                       if ((old = hashtab[index])) {
-                               old--;
-                               next[i] = old;
-                               do {
-                                       if (c->fields[old].name == fi->name &&
-                                               c->fields[old].descriptor == fi->descriptor) {
-                                               exceptions_throw_classformaterror(c, "Repetitive field name/signature");
-                                               return false;
-                                       }
-                               } while ((old = next[old]));
-                       }
-                       hashtab[index] = i + 1;
-               }
-
-               /* Check methods */
-               memset(hashtab, 0, sizeof(u2) * (hashlen + hashlen/5));
-
-               for (i = 0; i < c->methodscount; ++i) {
-                       methodinfo *mi = c->methods + i;
-
-                       /* It's ok if we lose bits here */
-                       index = ((((size_t) mi->name) +
-                                         ((size_t) mi->descriptor)) >> shift) % hashlen;
-
-                       if ((old = hashtab[index])) {
-                               old--;
-                               next[i] = old;
-                               do {
-                                       if (c->methods[old].name == mi->name &&
-                                               c->methods[old].descriptor == mi->descriptor) {
-                                               exceptions_throw_classformaterror(c, "Repetitive method name/signature");
-                                               return false;
-                                       }
-                               } while ((old = next[old]));
-                       }
-                       hashtab[index] = i + 1;
-               }
-
-               MFREE(hashtab, u2, (hashlen + len));
-       }
-#endif /* ENABLE_VERIFIER */
-
-       RT_TIMING_GET_TIME(time_verify);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat) {
-               size_classinfo  += sizeof(classinfo*) * c->interfacescount;
-               size_fieldinfo  += sizeof(fieldinfo)  * c->fieldscount;
-               size_methodinfo += sizeof(methodinfo) * c->methodscount;
-       }
-#endif
-
-       /* load attribute structures */
-
-       if (!class_load_attributes(cb))
-               return false;
-
-       /* Pre Java 1.5 version don't check this. This implementation is
-          like Java 1.5 do it: for class file version 45.3 we don't check
-          it, older versions are checked. */
-
-       if (((ma == 45) && (mi > 3)) || (ma > 45)) {
-               /* check if all data has been read */
-               s4 classdata_left = ((cb->data + cb->size) - cb->pos);
-
-               if (classdata_left > 0) {
-                       exceptions_throw_classformaterror(c, "Extra bytes at the end of class file");
-                       return false;
-               }
-       }
-
-       RT_TIMING_GET_TIME(time_attrs);
-
-       RT_TIMING_TIME_DIFF(time_start     , time_checks    , RT_TIMING_LOAD_CHECKS);
-       RT_TIMING_TIME_DIFF(time_checks    , time_ndpool    , RT_TIMING_LOAD_NDPOOL);
-       RT_TIMING_TIME_DIFF(time_ndpool    , time_cpool     , RT_TIMING_LOAD_CPOOL);
-       RT_TIMING_TIME_DIFF(time_cpool     , time_setup     , RT_TIMING_LOAD_SETUP);
-       RT_TIMING_TIME_DIFF(time_setup     , time_fields    , RT_TIMING_LOAD_FIELDS);
-       RT_TIMING_TIME_DIFF(time_fields    , time_methods   , RT_TIMING_LOAD_METHODS);
-       RT_TIMING_TIME_DIFF(time_methods   , time_classrefs , RT_TIMING_LOAD_CLASSREFS);
-       RT_TIMING_TIME_DIFF(time_classrefs , time_descs     , RT_TIMING_LOAD_DESCS);
-       RT_TIMING_TIME_DIFF(time_descs     , time_setrefs   , RT_TIMING_LOAD_SETREFS);
-       RT_TIMING_TIME_DIFF(time_setrefs   , time_parsefds  , RT_TIMING_LOAD_PARSEFDS);
-       RT_TIMING_TIME_DIFF(time_parsefds  , time_parsemds  , RT_TIMING_LOAD_PARSEMDS);
-       RT_TIMING_TIME_DIFF(time_parsemds  , time_parsecpool, RT_TIMING_LOAD_PARSECP);
-       RT_TIMING_TIME_DIFF(time_parsecpool, time_verify    , RT_TIMING_LOAD_VERIFY);
-       RT_TIMING_TIME_DIFF(time_verify    , time_attrs     , RT_TIMING_LOAD_ATTRS);
-       RT_TIMING_TIME_DIFF(time_start     , time_attrs     , RT_TIMING_LOAD_TOTAL);
-
-       return true;
-}
-
-
-/* load_class_from_classbuffer *************************************************
-
-   Convenience wrapper for load_class_from_classbuffer.
-
-   SYNCHRONIZATION:
-       This function is NOT synchronized!
-   
-*******************************************************************************/
-
-classinfo *load_class_from_classbuffer(classbuffer *cb)
-{
-       classinfo *c;
-       bool       result;
-       int32_t    dumpmarker;
-
-       /* Get the classbuffer's class. */
-
-       c = cb->clazz;
-
-       /* Check if the class is already loaded. */
-
-       if (c->state & CLASS_LOADED)
-               return c;
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               count_class_loads++;
-#endif
-
-#if !defined(NDEBUG)
-       if (loadverbose)
-               log_message_class("Loading class: ", c);
-#endif
-
-       /* Mark start of dump memory area. */
-
-       DMARKER;
-
-       /* Class is currently loading. */
-
-       c->state |= CLASS_LOADING;
-
-       /* Parse the classbuffer. */
-
-       result = load_class_from_classbuffer_intern(cb);
-
-       /* Release dump area. */
-
-       DRELEASE;
-
-       /* An error occurred. */
-
-       if (result == false) {
-               /* Revert loading state. */
-
-               c->state = (c->state & ~CLASS_LOADING);
-
-               return NULL;
-       }
-
-       /* Revert loading state and set loaded. */
-
-       c->state = (c->state & ~CLASS_LOADING) | CLASS_LOADED;
-
-#if defined(ENABLE_JVMTI)
-       /* fire Class Prepare JVMTI event */
-
-       if (jvmti)
-               jvmti_ClassLoadPrepare(true, c);
-#endif
-
-#if !defined(NDEBUG)
-       if (loadverbose)
-               log_message_class("Loading done class: ", c);
-#endif
-
-       return c;
-}
-
-
-/* load_newly_created_array ****************************************************
-
-   Load a newly created array class.
-
-       RETURN VALUE:
-           c....................the array class C has been loaded
-               other classinfo......the array class was found in the class cache, 
-                                    C has been freed
-           NULL.................an exception has been thrown
-
-       Note:
-               This is an internal function. Do not use it unless you know exactly
-               what you are doing!
-
-               Use one of the load_class_... functions for general array class loading.
-
-*******************************************************************************/
-
-classinfo *load_newly_created_array(classinfo *c, classloader_t *loader)
-{
-       classinfo         *comp = NULL;
-       methodinfo        *clone;
-       methoddesc        *clonedesc;
-       constant_classref *classrefs;
-       char              *text;
-       s4                 namelen;
-       utf               *u;
-
-       text    = c->name->text;
-       namelen = c->name->blength;
-
-       /* Check array class name */
-
-       if ((namelen < 2) || (text[0] != '[')) {
-               exceptions_throw_classnotfoundexception(c->name);
-               return NULL;
-       }
-
-       /* Check the element type */
-
-       switch (text[1]) {
-       case '[':
-               /* c is an array of arrays. We have to create the component class. */
-
-               u = utf_new(text + 1, namelen - 1);
-
-               comp = load_class_from_classloader(u, loader);
-
-               if (comp == NULL)
-                       return NULL;
-
-               assert(comp->state & CLASS_LOADED);
-
-               /* the array's flags are that of the component class */
-               c->flags = (comp->flags & ~ACC_INTERFACE) | ACC_FINAL | ACC_ABSTRACT;
-               c->classloader = comp->classloader;
-               break;
-
-       case 'L':
-               /* c is an array of objects. */
-
-               /* check for cases like `[L;' or `[L[I;' or `[Ljava.lang.Object' */
-               if ((namelen < 4) || (text[2] == '[') || (text[namelen - 1] != ';')) {
-                       exceptions_throw_classnotfoundexception(c->name);
-                       return NULL;
-               }
-
-               u = utf_new(text + 2, namelen - 3);
-
-               if (!(comp = load_class_from_classloader(u, loader)))
-                       return NULL;
-
-               assert(comp->state & CLASS_LOADED);
-
-               /* the array's flags are that of the component class */
-               c->flags = (comp->flags & ~ACC_INTERFACE) | ACC_FINAL | ACC_ABSTRACT;
-               c->classloader = comp->classloader;
-               break;
-
-       default:
-               /* c is an array of a primitive type */
-
-               /* check for cases like `[II' and whether the character is a
-                  valid primitive type */
-
-               if ((namelen > 2) || (primitive_class_get_by_char(text[1]) == NULL)) {
-                       exceptions_throw_classnotfoundexception(c->name);
-                       return NULL;
-               }
-
-               /* the accessibility of the array class is public (VM Spec 5.3.3) */
-               c->flags = ACC_PUBLIC | ACC_FINAL | ACC_ABSTRACT;
-               c->classloader = NULL;
-       }
-
-       assert(class_java_lang_Object);
-#if defined(ENABLE_JAVASE)
-       assert(class_java_lang_Cloneable);
-       assert(class_java_io_Serializable);
-#endif
-
-       /* Setup the array class. */
-
-       c->super = class_java_lang_Object;
-
-#if defined(ENABLE_JAVASE)
-
-       c->interfacescount = 2;
-    c->interfaces      = MNEW(classinfo*, 2);
-       c->interfaces[0]   = class_java_lang_Cloneable;
-       c->interfaces[1]   = class_java_io_Serializable;
-
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-
-       c->interfacescount = 0;
-       c->interfaces      = NULL;
-
-#else
-# error unknow Java configuration
-#endif
-
-       c->methodscount = 1;
-       c->methods      = MNEW(methodinfo, c->methodscount);
-
-       MZERO(c->methods, methodinfo, c->methodscount);
-
-       classrefs = MNEW(constant_classref, 2);
-
-       CLASSREF_INIT(classrefs[0], c, c->name);
-       CLASSREF_INIT(classrefs[1], c, utf_java_lang_Object);
-
-       /* create descriptor for clone method */
-       /* we need one paramslot which is reserved for the 'this' parameter */
-       clonedesc = NEW(methoddesc);
-       clonedesc->returntype.type = TYPE_ADR;
-       clonedesc->returntype.classref = classrefs + 1;
-       clonedesc->returntype.arraydim = 0;
-       /* initialize params to "empty", add real params below in
-          descriptor_params_from_paramtypes */
-       clonedesc->paramcount = 0;
-       clonedesc->paramslots = 0;
-       clonedesc->paramtypes[0].classref = classrefs + 0;
-       clonedesc->params = NULL;
-
-       /* create methodinfo */
-
-       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->flags      = ACC_PUBLIC | ACC_NATIVE;
-       clone->name       = utf_clone;
-       clone->descriptor = utf_void__java_lang_Object;
-       clone->parseddesc = clonedesc;
-       clone->clazz      = c;
-
-       /* parse the descriptor to get the register allocation */
-
-       if (!descriptor_params_from_paramtypes(clonedesc, clone->flags))
-               return false;
-
-       clone->code = codegen_generate_stub_native(clone, BUILTIN_clone);
-
-       /* XXX: field: length? */
-
-       /* array classes are not loaded from class files */
-
-       c->state          |= CLASS_LOADED;
-       c->parseddescs    = (u1 *) clonedesc;
-       c->parseddescsize = sizeof(methodinfo);
-       c->classrefs      = classrefs;
-       c->classrefcount  = 1;
-
-       /* insert class into the loaded class cache */
-       /* XXX free classinfo if NULL returned? */
-
-       return classcache_store(loader, c, true);
-}
-
-
-/* loader_close ****************************************************************
-
-   Frees all resources.
-       
-*******************************************************************************/
-
-void loader_close(void)
-{
-       /* empty */
-}
-
-
-/*
- * 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/vmcore/loader.h b/src/vmcore/loader.h
deleted file mode 100644 (file)
index faa9ba5..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/* src/vmcore/loader.h - class loader 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 _LOADER_H
-#define _LOADER_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct classbuffer classbuffer;
-
-
-#include "config.h"
-
-#include <stdio.h>
-
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#include "vmcore/descriptor.h"
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/references.h"
-#include "vmcore/utf8.h"
-
-
-/* constant pool entries *******************************************************
-
-       All constant pool entries need a data structure which contain the entrys
-       value. In some cases this structure exist already, in the remaining cases
-       this structure must be generated:
-
-               kind                      structure                     generated?
-       ----------------------------------------------------------------------
-    CONSTANT_Class               constant_classref                  yes
-    CONSTANT_Fieldref            constant_FMIref                    yes
-    CONSTANT_Methodref           constant_FMIref                    yes
-    CONSTANT_InterfaceMethodref  constant_FMIref                    yes
-    CONSTANT_String              unicode                             no
-    CONSTANT_Integer             constant_integer                   yes
-    CONSTANT_Float               constant_float                     yes
-    CONSTANT_Long                constant_long                      yes
-    CONSTANT_Double              constant_double                    yes
-    CONSTANT_NameAndType         constant_nameandtype               yes
-    CONSTANT_Utf8                unicode                             no
-    CONSTANT_UNUSED              -
-
-*******************************************************************************/
-
-typedef struct {            /* Integer                                        */
-       s4 value;
-} constant_integer;
-
-       
-typedef struct {            /* Float                                          */
-       float value;
-} constant_float;
-
-
-typedef struct {            /* Long                                           */
-       s8 value;
-} constant_long;
-       
-
-typedef struct {            /* Double                                         */
-       double value;
-} constant_double;
-
-
-typedef struct {            /* NameAndType (Field or Method)                  */
-       utf *name;              /* field/method name                              */
-       utf *descriptor;        /* field/method type descriptor string            */
-} constant_nameandtype;
-
-
-/* classbuffer ****************************************************************/
-
-struct classbuffer {
-       classinfo *clazz;                   /* pointer to classinfo structure     */
-       uint8_t   *data;                    /* pointer to byte code               */
-       int32_t    size;                    /* size of the byte code              */
-       uint8_t   *pos;                     /* current read position              */
-       char      *path;                    /* path to file (for debugging)       */
-};
-
-
-/* hashtable_classloader_entry *************************************************
-
-   ATTENTION: The pointer to the classloader object needs to be the
-   first field of the entry, so that it can be used as an indirection
-   cell. This is checked by gc_init() during startup.
-
-*******************************************************************************/
-
-typedef struct hashtable_classloader_entry hashtable_classloader_entry;
-
-struct hashtable_classloader_entry {
-       java_object_t               *object;
-       hashtable_classloader_entry *hashlink;
-};
-
-
-/* classloader *****************************************************************
-
-   [!ENABLE_HANDLES]: The classloader is a Java Object which cannot move.
-   [ENABLE_HANDLES] : The classloader entry itself is a static handle for a
-                      given classloader (use loader_hashtable_classloader_foo).
-
-*******************************************************************************/
-
-#if defined(ENABLE_HANDLES)
-typedef hashtable_classloader_entry classloader_t;
-#else
-typedef java_object_t               classloader_t;
-#endif
-
-
-/* function prototypes ********************************************************/
-
-void loader_preinit(void);
-void loader_init(void);
-
-/* classloader management functions */
-classloader_t *loader_hashtable_classloader_add(java_handle_t *cl);
-classloader_t *loader_hashtable_classloader_find(java_handle_t *cl);
-
-void loader_load_all_classes(void);
-
-bool loader_skip_attribute_body(classbuffer *cb);
-
-#if defined(ENABLE_JAVASE)
-bool loader_load_attribute_signature(classbuffer *cb, utf **signature);
-#endif
-
-/* free resources */
-void loader_close(void);
-
-/* class loading functions */
-classinfo *load_class_from_sysloader(utf *name);
-classinfo *load_class_from_classloader(utf *name, classloader_t *cl);
-classinfo *load_class_bootstrap(utf *name);
-
-/* (don't use the following directly) */
-classinfo *load_class_from_classbuffer(classbuffer *cb);
-classinfo *load_newly_created_array(classinfo *c, classloader_t *loader);
-
-#endif /* _LOADER_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/vmcore/method.c b/src/vmcore/method.c
deleted file mode 100644 (file)
index 393ad44..0000000
+++ /dev/null
@@ -1,1207 +0,0 @@
-/* src/vmcore/method.c - method 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 <stdint.h>
-#include <stdio.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/llni.h"
-
-#include "threads/lock-common.h"
-
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/resolve.h"
-#include "vm/vm.h"
-
-#include "vm/jit/code.h"
-#include "vm/jit/methodheader.h"
-
-#include "vm/jit_interface.h"
-
-#include "vmcore/class.h"
-#include "vmcore/linker.h"
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-#include "vmcore/suck.h"
-#include "vmcore/utf8.h"
-
-
-#if !defined(NDEBUG) && defined(ENABLE_INLINING)
-#define INLINELOG(code)  do { if (opt_TraceInlining) { code } } while (0)
-#else
-#define INLINELOG(code)
-#endif
-
-
-/* global variables ***********************************************************/
-
-methodinfo *method_java_lang_reflect_Method_invoke;
-
-
-/* method_init *****************************************************************
-
-   Initialize method subsystem.
-
-*******************************************************************************/
-
-void method_init(void)
-{
-#if defined(ENABLE_JAVASE)
-       /* Sanity check. */
-
-       if (class_java_lang_reflect_Method == NULL)
-               vm_abort("method_init: class_java_lang_reflect_Method is NULL");
-
-       /* Cache java.lang.reflect.Method.invoke() */
-
-       method_java_lang_reflect_Method_invoke =
-               class_findmethod(class_java_lang_reflect_Method, utf_invoke, NULL);
-
-       if (method_java_lang_reflect_Method_invoke == NULL)
-               vm_abort("method_init: Could not resolve method java.lang.reflect.Method.invoke().");
-#endif
-}
-
-
-/* method_load *****************************************************************
-
-   Loads a method from the class file and fills an existing methodinfo
-   structure.
-
-   method_info {
-       u2 access_flags;
-          u2 name_index;
-          u2 descriptor_index;
-          u2 attributes_count;
-          attribute_info attributes[attribute_count];
-   }
-
-   attribute_info {
-       u2 attribute_name_index;
-          u4 attribute_length;
-          u1 info[attribute_length];
-   }
-
-   LineNumberTable_attribute {
-       u2 attribute_name_index;
-          u4 attribute_length;
-          u2 line_number_table_length;
-          {
-              u2 start_pc;
-                  u2 line_number;
-          } line_number_table[line_number_table_length];
-   }
-
-*******************************************************************************/
-
-bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool)
-{
-       classinfo *c;
-       int argcount;
-       s4         i, j, k, l;
-       utf       *u;
-       u2         name_index;
-       u2         descriptor_index;
-       u2         attributes_count;
-       u2         attribute_name_index;
-       utf       *attribute_name;
-       u2         code_attributes_count;
-       u2         code_attribute_name_index;
-       utf       *code_attribute_name;
-
-       /* get classinfo */
-
-       c = cb->clazz;
-
-       LOCK_INIT_OBJECT_LOCK(&(m->header));
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               count_all_methods++;
-#endif
-
-       /* all fields of m have been zeroed in load_class_from_classbuffer */
-
-       m->clazz = c;
-       
-       if (!suck_check_classbuffer_size(cb, 2 + 2 + 2))
-               return false;
-
-       /* access flags */
-
-       m->flags = suck_u2(cb);
-
-       /* name */
-
-       name_index = suck_u2(cb);
-
-       if (!(u = class_getconstant(c, name_index, CONSTANT_Utf8)))
-               return false;
-
-       m->name = u;
-
-       /* descriptor */
-
-       descriptor_index = suck_u2(cb);
-
-       if (!(u = class_getconstant(c, descriptor_index, CONSTANT_Utf8)))
-               return false;
-
-       m->descriptor = u;
-
-       if (!descriptor_pool_add(descpool, u, &argcount))
-               return false;
-
-#ifdef ENABLE_VERIFIER
-       if (opt_verify) {
-               if (!is_valid_name_utf(m->name)) {
-                       exceptions_throw_classformaterror(c, "Method with invalid name");
-                       return false;
-               }
-
-               if (m->name->text[0] == '<' &&
-                       m->name != utf_init && m->name != utf_clinit) {
-                       exceptions_throw_classformaterror(c, "Method with invalid special name");
-                       return false;
-               }
-       }
-#endif /* ENABLE_VERIFIER */
-       
-       if (!(m->flags & ACC_STATIC))
-               argcount++; /* count the 'this' argument */
-
-#ifdef ENABLE_VERIFIER
-       if (opt_verify) {
-               if (argcount > 255) {
-                       exceptions_throw_classformaterror(c, "Too many arguments in signature");
-                       return false;
-               }
-
-               /* check flag consistency */
-               if (m->name != utf_clinit) {
-                       i = (m->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED));
-
-                       if (i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) {
-                               exceptions_throw_classformaterror(c,
-                                                                                                 "Illegal method modifiers: 0x%X",
-                                                                                                 m->flags);
-                               return false;
-                       }
-
-                       if (m->flags & ACC_ABSTRACT) {
-                               if ((m->flags & (ACC_FINAL | ACC_NATIVE | ACC_PRIVATE |
-                                                                ACC_STATIC | ACC_STRICT | ACC_SYNCHRONIZED))) {
-                                       exceptions_throw_classformaterror(c,
-                                                                                                         "Illegal method modifiers: 0x%X",
-                                                                                                         m->flags);
-                                       return false;
-                               }
-                       }
-
-                       if (c->flags & ACC_INTERFACE) {
-                               if ((m->flags & (ACC_ABSTRACT | ACC_PUBLIC)) != (ACC_ABSTRACT | ACC_PUBLIC)) {
-                                       exceptions_throw_classformaterror(c,
-                                                                                                         "Illegal method modifiers: 0x%X",
-                                                                                                         m->flags);
-                                       return false;
-                               }
-                       }
-
-                       if (m->name == utf_init) {
-                               if (m->flags & (ACC_STATIC | ACC_FINAL | ACC_SYNCHRONIZED |
-                                                               ACC_NATIVE | ACC_ABSTRACT)) {
-                                       exceptions_throw_classformaterror(c, "Instance initialization method has invalid flags set");
-                                       return false;
-                               }
-                       }
-               }
-       }
-#endif /* ENABLE_VERIFIER */
-
-       /* mark the method as monomorphic until further notice */
-
-       m->flags |= ACC_METHOD_MONOMORPHIC;
-
-       /* non-abstract methods have an implementation in this class */
-
-       if (!(m->flags & ACC_ABSTRACT))
-               m->flags |= ACC_METHOD_IMPLEMENTED;
-               
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       /* attributes count */
-
-       attributes_count = suck_u2(cb);
-
-       for (i = 0; i < attributes_count; i++) {
-               if (!suck_check_classbuffer_size(cb, 2))
-                       return false;
-
-               /* attribute name index */
-
-               attribute_name_index = suck_u2(cb);
-
-               attribute_name =
-                       class_getconstant(c, attribute_name_index, CONSTANT_Utf8);
-
-               if (attribute_name == NULL)
-                       return false;
-
-               if (attribute_name == utf_Code) {
-                       /* Code */
-
-                       if (m->flags & (ACC_ABSTRACT | ACC_NATIVE)) {
-                               exceptions_throw_classformaterror(c, "Code attribute in native or abstract methods");
-                               return false;
-                       }
-                       
-                       if (m->jcode) {
-                               exceptions_throw_classformaterror(c, "Multiple Code attributes");
-                               return false;
-                       }
-
-                       if (!suck_check_classbuffer_size(cb, 4 + 2 + 2))
-                               return false;
-
-                       suck_u4(cb);
-                       m->maxstack = suck_u2(cb);
-                       m->maxlocals = suck_u2(cb);
-
-                       if (m->maxlocals < argcount) {
-                               exceptions_throw_classformaterror(c, "Arguments can't fit into locals");
-                               return false;
-                       }
-                       
-                       if (!suck_check_classbuffer_size(cb, 4))
-                               return false;
-
-                       m->jcodelength = suck_u4(cb);
-
-                       if (m->jcodelength == 0) {
-                               exceptions_throw_classformaterror(c, "Code of a method has length 0");
-                               return false;
-                       }
-                       
-                       if (m->jcodelength > 65535) {
-                               exceptions_throw_classformaterror(c, "Code of a method longer than 65535 bytes");
-                               return false;
-                       }
-
-                       if (!suck_check_classbuffer_size(cb, m->jcodelength))
-                               return false;
-
-                       m->jcode = MNEW(u1, m->jcodelength);
-                       suck_nbytes(m->jcode, cb, m->jcodelength);
-
-                       if (!suck_check_classbuffer_size(cb, 2))
-                               return false;
-
-                       m->rawexceptiontablelength = suck_u2(cb);
-                       if (!suck_check_classbuffer_size(cb, (2 + 2 + 2 + 2) * m->rawexceptiontablelength))
-                               return false;
-
-                       m->rawexceptiontable = MNEW(raw_exception_entry, m->rawexceptiontablelength);
-
-#if defined(ENABLE_STATISTICS)
-                       if (opt_stat) {
-                               count_vmcode_len += m->jcodelength + 18;
-                               count_extable_len +=
-                                       m->rawexceptiontablelength * sizeof(raw_exception_entry);
-                       }
-#endif
-
-                       for (j = 0; j < m->rawexceptiontablelength; j++) {
-                               u4 idx;
-                               m->rawexceptiontable[j].startpc   = suck_u2(cb);
-                               m->rawexceptiontable[j].endpc     = suck_u2(cb);
-                               m->rawexceptiontable[j].handlerpc = suck_u2(cb);
-
-                               idx = suck_u2(cb);
-
-                               if (!idx) {
-                                       m->rawexceptiontable[j].catchtype.any = NULL;
-                               }
-                               else {
-                                       /* the classref is created later */
-                                       if (!(m->rawexceptiontable[j].catchtype.any =
-                                                 (utf *) class_getconstant(c, idx, CONSTANT_Class)))
-                                               return false;
-                               }
-                       }
-
-                       if (!suck_check_classbuffer_size(cb, 2))
-                               return false;
-
-                       /* code attributes count */
-
-                       code_attributes_count = suck_u2(cb);
-
-                       for (k = 0; k < code_attributes_count; k++) {
-                               if (!suck_check_classbuffer_size(cb, 2))
-                                       return false;
-
-                               /* code attribute name index */
-
-                               code_attribute_name_index = suck_u2(cb);
-
-                               code_attribute_name =
-                                       class_getconstant(c, code_attribute_name_index, CONSTANT_Utf8);
-
-                               if (code_attribute_name == NULL)
-                                       return false;
-
-                               /* check which code attribute */
-
-                               if (code_attribute_name == utf_LineNumberTable) {
-                                       /* LineNumberTable */
-
-                                       if (!suck_check_classbuffer_size(cb, 4 + 2))
-                                               return false;
-
-                                       /* attribute length */
-
-                                       (void) suck_u4(cb);
-
-                                       /* line number table length */
-
-                                       m->linenumbercount = suck_u2(cb);
-
-                                       if (!suck_check_classbuffer_size(cb,
-                                                                                               (2 + 2) * m->linenumbercount))
-                                               return false;
-
-                                       m->linenumbers = MNEW(lineinfo, m->linenumbercount);
-
-#if defined(ENABLE_STATISTICS)
-                                       if (opt_stat)
-                                               size_lineinfo += sizeof(lineinfo) * m->linenumbercount;
-#endif
-                                       
-                                       for (l = 0; l < m->linenumbercount; l++) {
-                                               m->linenumbers[l].start_pc    = suck_u2(cb);
-                                               m->linenumbers[l].line_number = suck_u2(cb);
-                                       }
-                               }
-#if defined(ENABLE_JAVASE)
-                               else if (code_attribute_name == utf_StackMapTable) {
-                                       /* StackTableMap */
-
-                                       if (!stackmap_load_attribute_stackmaptable(cb, m))
-                                               return false;
-                               }
-#endif
-                               else {
-                                       /* unknown code attribute */
-
-                                       if (!loader_skip_attribute_body(cb))
-                                               return false;
-                               }
-                       }
-               }
-               else if (attribute_name == utf_Exceptions) {
-                       /* Exceptions */
-
-                       if (m->thrownexceptions != NULL) {
-                               exceptions_throw_classformaterror(c, "Multiple Exceptions attributes");
-                               return false;
-                       }
-
-                       if (!suck_check_classbuffer_size(cb, 4 + 2))
-                               return false;
-
-                       /* attribute length */
-
-                       (void) suck_u4(cb);
-
-                       m->thrownexceptionscount = suck_u2(cb);
-
-                       if (!suck_check_classbuffer_size(cb, 2 * m->thrownexceptionscount))
-                               return false;
-
-                       m->thrownexceptions = MNEW(classref_or_classinfo, m->thrownexceptionscount);
-
-                       for (j = 0; j < m->thrownexceptionscount; j++) {
-                               /* the classref is created later */
-                               if (!((m->thrownexceptions)[j].any =
-                                         (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Class)))
-                                       return false;
-                       }
-               }
-#if defined(ENABLE_JAVASE)
-               else if (attribute_name == utf_Signature) {
-                       /* Signature */
-
-                       if (!loader_load_attribute_signature(cb, &(m->signature)))
-                               return false;
-               }
-
-#if defined(ENABLE_ANNOTATIONS)
-               else if (attribute_name == utf_RuntimeVisibleAnnotations) {
-                       /* RuntimeVisibleAnnotations */
-                       if (!annotation_load_method_attribute_runtimevisibleannotations(cb, m))
-                               return false;
-               }
-               else if (attribute_name == utf_RuntimeInvisibleAnnotations) {
-                       /* RuntimeInvisibleAnnotations */
-                       if (!annotation_load_method_attribute_runtimeinvisibleannotations(cb, m))
-                               return false;
-               }
-               else if (attribute_name == utf_RuntimeVisibleParameterAnnotations) {
-                       /* RuntimeVisibleParameterAnnotations */
-                       if (!annotation_load_method_attribute_runtimevisibleparameterannotations(cb, m))
-                               return false;
-               }
-               else if (attribute_name == utf_RuntimeInvisibleParameterAnnotations) {
-                       /* RuntimeInvisibleParameterAnnotations */
-                       if (!annotation_load_method_attribute_runtimeinvisibleparameterannotations(cb, m))
-                               return false;
-               }
-               else if (attribute_name == utf_AnnotationDefault) {
-                       /* AnnotationDefault */
-                       if (!annotation_load_method_attribute_annotationdefault(cb, m))
-                               return false;
-               }
-#endif
-#endif
-               else {
-                       /* unknown attribute */
-
-                       if (!loader_skip_attribute_body(cb))
-                               return false;
-               }
-       }
-
-       if ((m->jcode == NULL) && !(m->flags & (ACC_ABSTRACT | ACC_NATIVE))) {
-               exceptions_throw_classformaterror(c, "Missing Code attribute");
-               return false;
-       }
-
-#if defined(ENABLE_REPLACEMENT)
-       /* initialize the hit countdown field */
-
-       m->hitcountdown = METHOD_INITIAL_HIT_COUNTDOWN;
-#endif
-
-       /* everything was ok */
-
-       return true;
-}
-
-
-/* method_free *****************************************************************
-
-   Frees all memory that was allocated for this method.
-
-*******************************************************************************/
-
-void method_free(methodinfo *m)
-{
-       if (m->jcode)
-               MFREE(m->jcode, u1, m->jcodelength);
-
-       if (m->rawexceptiontable)
-               MFREE(m->rawexceptiontable, raw_exception_entry, m->rawexceptiontablelength);
-
-       code_free_code_of_method(m);
-
-       if (m->stubroutine) {
-               if (m->flags & ACC_NATIVE) {
-                       removenativestub(m->stubroutine);
-
-               } else {
-                       removecompilerstub(m->stubroutine);
-               }
-       }
-}
-
-
-/* method_canoverwrite *********************************************************
-
-   Check if m and old are identical with respect to type and
-   name. This means that old can be overwritten with m.
-       
-*******************************************************************************/
-
-bool method_canoverwrite(methodinfo *m, methodinfo *old)
-{
-       if (m->name != old->name)
-               return false;
-
-       if (m->descriptor != old->descriptor)
-               return false;
-
-       if (m->flags & ACC_STATIC)
-               return false;
-
-       return true;
-}
-
-
-/* method_new_builtin **********************************************************
-
-   Creates a minimal methodinfo structure for builtins. This comes handy
-   when dealing with builtin stubs or stacktraces.
-
-*******************************************************************************/
-
-methodinfo *method_new_builtin(builtintable_entry *bte)
-{
-       methodinfo *m;
-
-       /* allocate the methodinfo structure */
-
-       m = NEW(methodinfo);
-
-       /* initialize methodinfo structure */
-
-       MZERO(m, methodinfo, 1);
-       LOCK_INIT_OBJECT_LOCK(&(m->header));
-
-       m->flags      = ACC_METHOD_BUILTIN;
-       m->parseddesc = bte->md;
-       m->name       = bte->name;
-       m->descriptor = bte->descriptor;
-
-       /* return the newly created methodinfo */
-
-       return m;
-}
-
-
-/* method_vftbl_lookup *********************************************************
-
-   Does a method lookup in the passed virtual function table.  This
-   function does exactly the same thing as JIT, but additionally
-   relies on the fact, that the methodinfo pointer is at the first
-   data segment slot (even for compiler stubs).
-
-*******************************************************************************/
-
-methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m)
-{
-       methodptr   mptr;
-       methodptr  *pmptr;
-       methodinfo *resm;                   /* pointer to new resolved method     */
-
-       /* If the method is not an instance method, just return it. */
-
-       if (m->flags & ACC_STATIC)
-               return m;
-
-       assert(vftbl);
-
-       /* Get the method from the virtual function table.  Is this an
-          interface method? */
-
-       if (m->clazz->flags & ACC_INTERFACE) {
-               pmptr = vftbl->interfacetable[-(m->clazz->index)];
-               mptr  = pmptr[(m - m->clazz->methods)];
-       }
-       else {
-               mptr = vftbl->table[m->vftblindex];
-       }
-
-       /* and now get the codeinfo pointer from the first data segment slot */
-
-       resm = code_get_methodinfo_for_pv(mptr);
-
-       return resm;
-}
-
-
-/* method_get_parametercount **************************************************
-
-   Use the descriptor of a method to determine the number of parameters
-   of the method. The this pointer of non-static methods is not counted.
-
-   IN:
-       m........the method of which the parameters should be counted
-
-   RETURN VALUE:
-       The parameter count or -1 on error.
-
-*******************************************************************************/
-
-int32_t method_get_parametercount(methodinfo *m)
-{
-       methoddesc *md;             /* method descriptor of m   */
-       int32_t     paramcount = 0; /* the parameter count of m */
-
-       md = m->parseddesc;
-       
-       /* is the descriptor fully parsed? */
-
-       if (md->params == NULL) {
-               if (!descriptor_params_from_paramtypes(md, m->flags)) {
-                       return -1;
-               }
-       }
-
-       paramcount = md->paramcount;
-
-       /* skip `this' pointer */
-
-       if (!(m->flags & ACC_STATIC)) {
-               --paramcount;
-       }
-
-       return paramcount;
-}
-
-
-/* method_get_parametertypearray ***********************************************
-
-   Use the descriptor of a method to generate a java.lang.Class array
-   which contains the classes of the parametertypes of the method.
-
-   This function is called by java.lang.reflect.{Constructor,Method}.
-
-*******************************************************************************/
-
-java_handle_objectarray_t *method_get_parametertypearray(methodinfo *m)
-{
-       methoddesc                *md;
-       typedesc                  *paramtypes;
-       int32_t                    paramcount;
-       java_handle_objectarray_t *oa;
-       int32_t                    i;
-       classinfo                 *c;
-
-       md = m->parseddesc;
-
-       /* is the descriptor fully parsed? */
-
-       if (m->parseddesc->params == NULL)
-               if (!descriptor_params_from_paramtypes(md, m->flags))
-                       return NULL;
-
-       paramtypes = md->paramtypes;
-       paramcount = md->paramcount;
-
-       /* skip `this' pointer */
-
-       if (!(m->flags & ACC_STATIC)) {
-               paramtypes++;
-               paramcount--;
-       }
-
-       /* create class-array */
-
-       oa = builtin_anewarray(paramcount, class_java_lang_Class);
-
-       if (oa == NULL)
-               return NULL;
-
-    /* get classes */
-
-       for (i = 0; i < paramcount; i++) {
-               if (!resolve_class_from_typedesc(&paramtypes[i], true, false, &c))
-                       return NULL;
-
-               LLNI_array_direct(oa, i) = (java_object_t *) c;
-       }
-
-       return oa;
-}
-
-
-/* method_get_exceptionarray ***************************************************
-
-   Get the exceptions which can be thrown by a method.
-
-*******************************************************************************/
-
-java_handle_objectarray_t *method_get_exceptionarray(methodinfo *m)
-{
-       java_handle_objectarray_t *oa;
-       classinfo                 *c;
-       s4                         i;
-
-       /* create class-array */
-
-       oa = builtin_anewarray(m->thrownexceptionscount, class_java_lang_Class);
-
-       if (oa == NULL)
-               return NULL;
-
-       /* iterate over all exceptions and store the class in the array */
-
-       for (i = 0; i < m->thrownexceptionscount; i++) {
-               c = resolve_classref_or_classinfo_eager(m->thrownexceptions[i], true);
-
-               if (c == NULL)
-                       return NULL;
-
-               LLNI_array_direct(oa, i) = (java_object_t *) c;
-       }
-
-       return oa;
-}
-
-
-/* method_returntype_get *******************************************************
-
-   Get the return type of the method.
-
-*******************************************************************************/
-
-classinfo *method_returntype_get(methodinfo *m)
-{
-       typedesc  *td;
-       classinfo *c;
-
-       td = &(m->parseddesc->returntype);
-
-       if (!resolve_class_from_typedesc(td, true, false, &c))
-               return NULL;
-
-       return c;
-}
-
-
-/* method_count_implementations ************************************************
-
-   Count the implementations of a method in a class cone (a class and all its
-   subclasses.)
-
-   IN:
-       m................the method to count
-          c................class at which to start the counting (this class and
-                           all its subclasses will be searched)
-
-   OUT:
-       *found...........if found != NULL, *found receives the method
-                           implementation that was found. This value is only
-                                               meaningful if the return value is 1.
-
-   RETURN VALUE:
-       the number of implementations found
-
-*******************************************************************************/
-
-s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found)
-{
-       s4          count;
-       methodinfo *mp;
-       methodinfo *mend;
-       classinfo  *child;
-
-       count = 0;
-
-       mp = c->methods;
-       mend = mp + c->methodscount;
-
-       for (; mp < mend; ++mp) {
-               if (method_canoverwrite(mp, m)) {
-                       if (found)
-                               *found = mp;
-                       count++;
-                       break;
-               }
-       }
-
-       for (child = c->sub; child != NULL; child = child->nextsub) {
-               count += method_count_implementations(m, child, found);
-       }
-
-       return count;
-}
-
-
-/* method_get_annotations ******************************************************
-
-   Get a methods' unparsed annotations in a byte array.
-
-   IN:
-       m........the method of which the annotations should be returned
-
-   RETURN VALUE:
-       The unparsed annotations in a byte array (or NULL if there aren't any).
-
-*******************************************************************************/
-
-java_handle_bytearray_t *method_get_annotations(methodinfo *m)
-{
-#if defined(ENABLE_ANNOTATIONS)
-       classinfo     *c;                  /* methods' declaring class          */
-       int            slot;               /* methods' slot                     */
-       java_handle_t *annotations;        /* methods' unparsed annotations     */
-       java_handle_t *method_annotations; /* all methods' unparsed annotations */
-                                          /* of the declaring class            */
-
-       c           = m->clazz;
-       slot        = m - c->methods;
-       annotations = NULL;
-
-       LLNI_classinfo_field_get(c, method_annotations, method_annotations);
-
-       /* the method_annotations array might be shorter then the method
-        * count if the methods above a certain index have no annotations.
-        */     
-       if (method_annotations != NULL &&
-               array_length_get(method_annotations) > slot) {
-               annotations = array_objectarray_element_get(
-                       (java_handle_objectarray_t*)method_annotations, slot);
-       }
-       
-       return (java_handle_bytearray_t*)annotations;
-#else
-       return NULL;
-#endif
-}
-
-
-/* method_get_parameterannotations ********************************************
-
-   Get a methods' unparsed parameter annotations in an array of byte
-   arrays.
-
-   IN:
-       m........the method of which the parameter annotations should be
-                   returned
-
-   RETURN VALUE:
-       The unparsed parameter annotations in a byte array (or NULL if
-          there aren't any).
-
-*******************************************************************************/
-
-java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m)
-{
-#if defined(ENABLE_ANNOTATIONS)
-       classinfo     *c;                           /* methods' declaring class */
-       int            slot;                        /* methods' slot            */
-       java_handle_t *parameterAnnotations;        /* methods' unparsed        */
-                                                   /* parameter annotations    */
-       java_handle_t *method_parameterannotations; /* all methods' unparsed    */
-                                                   /* parameter annotations of */
-                                                   /* the declaring class      */
-
-       c                    = m->clazz;
-       slot                 = m - c->methods;
-       parameterAnnotations = NULL;
-
-       LLNI_classinfo_field_get(
-               c, method_parameterannotations, method_parameterannotations);
-
-       /* the method_annotations array might be shorter then the method
-        * count if the methods above a certain index have no annotations.
-        */     
-       if (method_parameterannotations != NULL &&
-               array_length_get(method_parameterannotations) > slot) {
-               parameterAnnotations = array_objectarray_element_get(
-                               (java_handle_objectarray_t*)method_parameterannotations,
-                               slot);
-       }
-       
-       return (java_handle_bytearray_t*)parameterAnnotations;
-#else
-       return NULL;
-#endif
-}
-
-
-/* method_get_annotationdefault ***********************************************
-
-   Get a methods' unparsed annotation default value in a byte array.
-   
-   IN:
-       m........the method of which the annotation default value should be
-                   returned
-
-   RETURN VALUE:
-       The unparsed annotation default value in a byte array (or NULL if
-          there isn't one).
-
-*******************************************************************************/
-
-java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m)
-{
-#if defined(ENABLE_ANNOTATIONS)
-       classinfo     *c;                         /* methods' declaring class     */
-       int            slot;                      /* methods' slot                */
-       java_handle_t *annotationDefault;         /* methods' unparsed            */
-                                                 /* annotation default value     */
-       java_handle_t *method_annotationdefaults; /* all methods' unparsed        */
-                                                 /* annotation default values of */
-                                                 /* the declaring class          */
-
-       c                 = m->clazz;
-       slot              = m - c->methods;
-       annotationDefault = NULL;
-
-       LLNI_classinfo_field_get(
-               c, method_annotationdefaults, method_annotationdefaults);
-
-       /* the method_annotations array might be shorter then the method
-        * count if the methods above a certain index have no annotations.
-        */     
-       if (method_annotationdefaults != NULL &&
-               array_length_get(method_annotationdefaults) > slot) {
-               annotationDefault = array_objectarray_element_get(
-                               (java_handle_objectarray_t*)method_annotationdefaults, slot);
-       }
-       
-       return (java_handle_bytearray_t*)annotationDefault;
-#else
-       return NULL;
-#endif
-}
-
-
-/* method_add_to_worklist ******************************************************
-
-   Add the method to the given worklist. If the method already occurs in
-   the worklist, the worklist remains unchanged.
-
-*******************************************************************************/
-
-static void method_add_to_worklist(methodinfo *m, method_worklist **wl)
-{
-       method_worklist *wi;
-
-       for (wi = *wl; wi != NULL; wi = wi->next)
-               if (wi->m == m)
-                       return;
-
-       wi = NEW(method_worklist);
-       wi->next = *wl;
-       wi->m = m;
-
-       *wl = wi;
-}
-
-
-/* method_add_assumption_monomorphic *******************************************
-
-   Record the assumption that the method is monomorphic.
-
-   IN:
-      m.................the method
-         caller............the caller making the assumption
-
-*******************************************************************************/
-
-void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller)
-{
-       method_assumption *as;
-
-       /* XXX LOCKING FOR THIS FUNCTION? */
-
-       /* check if we already have registered this assumption */
-
-       for (as = m->assumptions; as != NULL; as = as->next) {
-               if (as->context == caller)
-                       return;
-       }
-
-       /* register the assumption */
-
-       as = NEW(method_assumption);
-       as->next = m->assumptions;
-       as->context = caller;
-
-       m->assumptions = as;
-}
-
-
-/* method_break_assumption_monomorphic *****************************************
-
-   Break the assumption that this method is monomorphic. All callers that
-   have registered this assumption are added to the worklist.
-
-   IN:
-      m.................the method
-         wl................worklist where to add invalidated callers
-
-*******************************************************************************/
-
-void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl)
-{
-       method_assumption *as;
-
-       /* XXX LOCKING FOR THIS FUNCTION? */
-
-       for (as = m->assumptions; as != NULL; as = as->next) {
-               INLINELOG(
-                       printf("ASSUMPTION BROKEN (monomorphism): ");
-                       method_print(m);
-                       printf(" in ");
-                       method_println(as->context);
-               );
-
-               method_add_to_worklist(as->context, wl);
-       }
-}
-
-
-/* method_printflags ***********************************************************
-
-   Prints the flags of a method to stdout like.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void method_printflags(methodinfo *m)
-{
-       if (m == NULL) {
-               printf("NULL");
-               return;
-       }
-
-       if (m->flags & ACC_PUBLIC)             printf(" PUBLIC");
-       if (m->flags & ACC_PRIVATE)            printf(" PRIVATE");
-       if (m->flags & ACC_PROTECTED)          printf(" PROTECTED");
-       if (m->flags & ACC_STATIC)             printf(" STATIC");
-       if (m->flags & ACC_FINAL)              printf(" FINAL");
-       if (m->flags & ACC_SYNCHRONIZED)       printf(" SYNCHRONIZED");
-       if (m->flags & ACC_VOLATILE)           printf(" VOLATILE");
-       if (m->flags & ACC_TRANSIENT)          printf(" TRANSIENT");
-       if (m->flags & ACC_NATIVE)             printf(" NATIVE");
-       if (m->flags & ACC_INTERFACE)          printf(" INTERFACE");
-       if (m->flags & ACC_ABSTRACT)           printf(" ABSTRACT");
-       if (m->flags & ACC_METHOD_BUILTIN)     printf(" (builtin)");
-       if (m->flags & ACC_METHOD_MONOMORPHIC) printf(" (mono)");
-       if (m->flags & ACC_METHOD_IMPLEMENTED) printf(" (impl)");
-}
-#endif /* !defined(NDEBUG) */
-
-
-/* method_print ****************************************************************
-
-   Prints a method to stdout like:
-
-   java.lang.Object.<init>()V
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void method_print(methodinfo *m)
-{
-       if (m == NULL) {
-               printf("NULL");
-               return;
-       }
-
-       if (m->clazz != NULL)
-               utf_display_printable_ascii_classname(m->clazz->name);
-       else
-               printf("NULL");
-       printf(".");
-       utf_display_printable_ascii(m->name);
-       utf_display_printable_ascii(m->descriptor);
-
-       method_printflags(m);
-}
-#endif /* !defined(NDEBUG) */
-
-
-/* method_println **************************************************************
-
-   Prints a method plus new line to stdout like:
-
-   java.lang.Object.<init>()V
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void method_println(methodinfo *m)
-{
-       if (opt_debugcolor) printf("\033[31m"); /* red */
-       method_print(m);
-       if (opt_debugcolor) printf("\033[m");   
-       printf("\n");
-}
-#endif /* !defined(NDEBUG) */
-
-
-/* method_methodref_print ******************************************************
-
-   Prints a method reference to stdout.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void method_methodref_print(constant_FMIref *mr)
-{
-       if (!mr) {
-               printf("(constant_FMIref *)NULL");
-               return;
-       }
-
-       if (IS_FMIREF_RESOLVED(mr)) {
-               printf("<method> ");
-               method_print(mr->p.method);
-       }
-       else {
-               printf("<methodref> ");
-               utf_display_printable_ascii_classname(mr->p.classref->name);
-               printf(".");
-               utf_display_printable_ascii(mr->name);
-               utf_display_printable_ascii(mr->descriptor);
-       }
-}
-#endif /* !defined(NDEBUG) */
-
-
-/* method_methodref_println ****************************************************
-
-   Prints a method reference to stdout, followed by a newline.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void method_methodref_println(constant_FMIref *mr)
-{
-       method_methodref_print(mr);
-       printf("\n");
-}
-#endif /* !defined(NDEBUG) */
-
-
-/*
- * 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/vmcore/method.h b/src/vmcore/method.h
deleted file mode 100644 (file)
index ff28286..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/* src/vmcore/method.h - method functions 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 _METHOD_H
-#define _METHOD_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct methodinfo          methodinfo; 
-typedef struct raw_exception_entry raw_exception_entry;
-typedef struct lineinfo            lineinfo; 
-typedef struct method_assumption   method_assumption;
-typedef struct method_worklist     method_worklist;
-typedef struct codeinfo            codeinfo;
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/builtin.h"
-#include "vm/global.h"
-
-#include "vmcore/descriptor.h"
-#include "vmcore/references.h"
-#include "vmcore/linker.h"
-#include "vmcore/loader.h"
-
-#if defined(ENABLE_JAVASE)
-# include "vmcore/stackmap.h"
-#endif
-
-#include "vmcore/utf8.h"
-
-
-#if defined(ENABLE_REPLACEMENT)
-/* Initial value for the hit countdown field of each method. */
-#define METHOD_INITIAL_HIT_COUNTDOWN  1000
-#endif
-
-
-/* methodinfo *****************************************************************/
-
-struct methodinfo {                 /* method structure                       */
-       java_object_t header;           /* we need this in jit's monitorenter     */
-       s4            flags;            /* ACC flags                              */
-       utf          *name;             /* name of method                         */
-       utf          *descriptor;       /* JavaVM descriptor string of method     */
-#if defined(ENABLE_JAVASE)
-       utf          *signature;        /* Signature attribute                    */
-       stack_map_t  *stack_map;        /* StackMapTable attribute                */
-#endif
-
-       methoddesc   *parseddesc;       /* parsed descriptor                      */
-                            
-       classinfo    *clazz;            /* class, the method belongs to           */
-       s4            vftblindex;       /* index of method in virtual function    */
-                                       /* table (if it is a virtual method)      */
-       s4            maxstack;         /* maximum stack depth of method          */
-       s4            maxlocals;        /* maximum number of local variables      */
-       s4            jcodelength;      /* length of JavaVM code                  */
-       u1           *jcode;            /* pointer to JavaVM code                 */
-
-       s4            rawexceptiontablelength;  /* exceptiontable length          */
-       raw_exception_entry *rawexceptiontable; /* the exceptiontable             */
-
-       u2            thrownexceptionscount; /* number of exceptions attribute    */
-       classref_or_classinfo *thrownexceptions; /* except. a method may throw    */
-
-       u2            linenumbercount;  /* number of linenumber attributes        */
-       lineinfo     *linenumbers;      /* array of lineinfo items                */
-
-       u1           *stubroutine;      /* stub for compiling or calling natives  */
-       codeinfo     *code;             /* current code of this method            */
-
-#if defined(ENABLE_LSRA)
-       s4            maxlifetimes;     /* helper for lsra                        */
-#endif
-
-       methodinfo   *overwrites;       /* method that is directly overwritten    */
-       method_assumption *assumptions; /* list of assumptions about this method  */
-
-#if defined(ENABLE_REPLACEMENT)
-       s4            hitcountdown;     /* decreased for each hit                 */
-#endif
-
-#if defined(ENABLE_DEBUG_FILTER)
-       u1            filtermatches;    /* flags indicating which filters the method matches */
-#endif
-
-#if defined(ENABLE_ESCAPE)
-       u1           *paramescape;
-#endif
-};
-
-/* method_assumption ***********************************************************
-
-   This struct is used for registering assumptions about methods.
-
-*******************************************************************************/
-
-struct method_assumption {
-       method_assumption *next;
-       methodinfo        *context;
-};
-
-
-/* method_worklist *************************************************************
-
-   List node used for method worklists.
-
-*******************************************************************************/
-
-struct method_worklist {
-       method_worklist *next;
-       methodinfo      *m;
-};
-
-
-/* raw_exception_entry ********************************************************/
-
-/* exception table entry read by the loader */
-
-struct raw_exception_entry {    /* exceptiontable entry in a method           */
-       classref_or_classinfo catchtype; /* catchtype of exc. (0 == catchall)     */
-       u2              startpc;    /* start pc of guarded area (inclusive)       */
-       u2              endpc;      /* end pc of guarded area (exklusive)         */
-       u2              handlerpc;  /* pc of exception handler                    */
-};
-
-
-/* lineinfo *******************************************************************/
-
-struct lineinfo {
-       u2 start_pc;
-       u2 line_number;
-};
-
-
-/* global variables ***********************************************************/
-
-extern methodinfo *method_java_lang_reflect_Method_invoke;
-
-
-/* inline functions ***********************************************************/
-
-inline static bool method_is_builtin(methodinfo* m)
-{
-       return m->flags & ACC_METHOD_BUILTIN;
-}
-
-
-/* function prototypes ********************************************************/
-
-void method_init(void);
-
-bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool);
-void method_free(methodinfo *m);
-bool method_canoverwrite(methodinfo *m, methodinfo *old);
-
-methodinfo *method_new_builtin(builtintable_entry *bte);
-
-methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m);
-
-int32_t                    method_get_parametercount(methodinfo *m);
-java_handle_objectarray_t *method_get_parametertypearray(methodinfo *m);
-java_handle_objectarray_t *method_get_exceptionarray(methodinfo *m);
-classinfo                 *method_returntype_get(methodinfo *m);
-
-void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller);
-void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl);
-
-s4   method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found);
-
-java_handle_bytearray_t *method_get_annotations(methodinfo *m);
-java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m);
-java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m);
-
-#if !defined(NDEBUG)
-void method_printflags(methodinfo *m);
-void method_print(methodinfo *m);
-void method_println(methodinfo *m);
-void method_methodref_print(constant_FMIref *mr);
-void method_methodref_println(constant_FMIref *mr);
-#endif
-
-#endif /* _METHOD_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/vmcore/options.c b/src/vmcore/options.c
deleted file mode 100644 (file)
index e9ae46f..0000000
+++ /dev/null
@@ -1,838 +0,0 @@
-/* src/vmcore/options.c - contains global options
-
-   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 <limits.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-
-#include "vm/vm.h"
-
-#include "vmcore/options.h"
-#include "vmcore/system.h"
-
-
-/* command line option ********************************************************/
-
-s4    opt_index = 0;            /* index of processed arguments               */
-char *opt_arg;                  /* this one exports the option argument       */
-
-bool opt_foo = false;           /* option for development                     */
-
-bool opt_jar = false;
-
-#if defined(ENABLE_JIT)
-bool opt_jit = true;            /* JIT mode execution (default)               */
-bool opt_intrp = false;         /* interpreter mode execution                 */
-#else
-bool opt_jit = false;           /* JIT mode execution                         */
-bool opt_intrp = true;          /* interpreter mode execution (default)       */
-#endif
-
-bool opt_run = true;
-
-s4   opt_heapmaxsize   = 0;     /* maximum heap size                          */
-s4   opt_heapstartsize = 0;     /* initial heap size                          */
-s4   opt_stacksize     = 0;     /* thread stack size                          */
-
-bool opt_verbose = false;
-bool opt_debugcolor = false;   /* use ANSI terminal sequences                */
-bool compileall = false;
-
-bool loadverbose = false;
-bool initverbose = false;
-
-bool opt_verboseclass     = false;
-bool opt_verbosegc        = false;
-bool opt_verbosejni       = false;
-bool opt_verbosecall      = false;      /* trace all method invocation        */
-
-bool showmethods = false;
-bool showconstantpool = false;
-bool showutf = false;
-
-char *opt_method = NULL;
-char *opt_signature = NULL;
-
-bool compileverbose =  false;           /* trace compiler actions             */
-bool showstack = false;
-
-bool opt_showdisassemble    = false;    /* generate disassembler listing      */
-bool opt_shownops           = false;
-bool opt_showddatasegment   = false;    /* generate data segment listing      */
-bool opt_showintermediate   = false;    /* generate intermediate code listing */
-
-bool checkbounds = true;       /* check array bounds                         */
-bool opt_noieee = false;       /* don't implement ieee compliant floats      */
-bool checksync = true;         /* do synchronization                         */
-#if defined(ENABLE_LOOP)
-bool opt_loops = false;        /* optimize array accesses in loops           */
-#endif
-
-bool makeinitializations = true;
-
-#if defined(ENABLE_STATISTICS)
-bool opt_stat    = false;
-bool opt_getloadingtime = false;   /* to measure the runtime                 */
-bool opt_getcompilingtime = false; /* compute compile time                   */
-#endif
-#if defined(ENABLE_VERIFIER)
-bool opt_verify  = true;       /* true if classfiles should be verified      */
-#endif
-
-#if defined(ENABLE_PROFILING)
-bool opt_prof    = false;
-bool opt_prof_bb = false;
-#endif
-
-
-/* optimization options *******************************************************/
-
-#if defined(ENABLE_IFCONV)
-bool opt_ifconv = false;
-#endif
-
-#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
-bool opt_lsra = false;
-#endif
-#if defined(ENABLE_SSA)
-bool opt_ssa_dce = false;          /* enable dead code elemination */
-bool opt_ssa_cp = false;           /* enable copy propagation      */
-#endif
-
-
-/* interpreter options ********************************************************/
-
-#if defined(ENABLE_INTRP)
-bool opt_no_dynamic = false;            /* suppress dynamic superinstructions */
-bool opt_no_replication = false;        /* don't use replication in intrp     */
-bool opt_no_quicksuper = false;         /* instructions for quickening cannot be
-                                                                                  part of dynamic superinstructions */
-
-s4   opt_static_supers = 0x7fffffff;
-bool vm_debug = false;          /* XXX this should be called `opt_trace'      */
-#endif
-
-#if defined(ENABLE_DEBUG_FILTER)
-const char *opt_filter_verbosecall_include = 0;
-const char *opt_filter_verbosecall_exclude = 0;
-const char *opt_filter_show_method = 0;
-#endif
-
-
-/* -XX options ****************************************************************/
-
-/* NOTE: For better readability keep these alpha-sorted. */
-
-/* Options which must always be available (production options in
-   HotSpot). */
-
-int64_t  opt_MaxDirectMemorySize          = -1;
-int      opt_MaxPermSize                  = 0;
-int      opt_PermSize                     = 0;
-int      opt_ThreadStackSize              = 0;
-
-/* Debugging options which can be turned off. */
-
-int      opt_DebugExceptions              = 0;
-int      opt_DebugFinalizer               = 0;
-int      opt_DebugLocalReferences         = 0;
-int      opt_DebugLocks                   = 0;
-int      opt_DebugPackage                 = 0;
-int      opt_DebugPatcher                 = 0;
-int      opt_DebugProperties              = 0;
-int      opt_DebugStackFrameInfo          = 0;
-int      opt_DebugStackTrace              = 0;
-int      opt_DebugThreads                 = 0;
-#if defined(ENABLE_DISASSEMBLER)
-int      opt_DisassembleStubs             = 0;
-#endif
-#if defined(ENABLE_GC_CACAO)
-int      opt_GCDebugRootSet               = 0;
-int      opt_GCStress                     = 0;
-#endif
-#if defined(ENABLE_INLINING)
-int      opt_Inline                       = 0;
-#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
-int      opt_InlineAll                    = 0;
-int      opt_InlineCount                  = INT_MAX;
-int      opt_InlineMaxSize                = INT_MAX;
-int      opt_InlineMinSize                = 0;
-#endif
-#endif
-int      opt_PrintConfig                  = 0;
-int      opt_ProfileGCMemoryUsage         = 0;
-int      opt_ProfileMemoryUsage           = 0;
-FILE    *opt_ProfileMemoryUsageGNUPlot    = NULL;
-#if defined(ENABLE_REPLACEMENT)
-int      opt_TestReplacement              = 0;
-#endif
-int      opt_TraceCompilerCalls           = 0;
-int      opt_TraceExceptions              = 0;
-int      opt_TraceHPI                     = 0;
-#if defined(ENABLE_INLINING) && !defined(NDEBUG)
-int      opt_TraceInlining                = 0;
-#endif
-int      opt_TraceJavaCalls               = 0;
-int      opt_TraceJNICalls                = 0;
-int      opt_TraceJVMCalls                = 0;
-int      opt_TraceJVMCallsVerbose         = 0;
-int      opt_TraceLinkClass               = 0;
-#if defined(ENABLE_REPLACEMENT)
-int      opt_TraceReplacement             = 0;
-#endif
-int      opt_TraceSubsystemInitialization = 0;
-int      opt_TraceTraps                   = 0;
-
-
-enum {
-       OPT_TYPE_BOOLEAN,
-       OPT_TYPE_VALUE
-};
-
-enum {
-       /* Options which must always be available (production options in
-          HotSpot). */
-
-       OPT_MaxDirectMemorySize,
-       OPT_MaxPermSize,
-       OPT_PermSize,
-       OPT_ThreadStackSize,
-
-       /* Debugging options which can be turned off. */
-
-       OPT_DebugExceptions,
-       OPT_DebugFinalizer,
-       OPT_DebugLocalReferences,
-       OPT_DebugLocks,
-       OPT_DebugPackage,
-       OPT_DebugPatcher,
-       OPT_DebugProperties,
-       OPT_DebugStackFrameInfo,
-       OPT_DebugStackTrace,
-       OPT_DebugThreads,
-       OPT_DisassembleStubs,
-       OPT_GCDebugRootSet,
-       OPT_GCStress,
-       OPT_Inline,
-       OPT_InlineAll,
-       OPT_InlineCount,
-       OPT_InlineMaxSize,
-       OPT_InlineMinSize,
-       OPT_PrintConfig,
-       OPT_ProfileGCMemoryUsage,
-       OPT_ProfileMemoryUsage,
-       OPT_ProfileMemoryUsageGNUPlot,
-       OPT_TestReplacement,
-       OPT_TraceCompilerCalls,
-       OPT_TraceExceptions,
-       OPT_TraceHPI,
-       OPT_TraceInlining,
-       OPT_TraceJavaCalls,
-       OPT_TraceJNICalls,
-       OPT_TraceJVMCalls,
-       OPT_TraceJVMCallsVerbose,
-       OPT_TraceLinkClass,
-       OPT_TraceReplacement,
-       OPT_TraceSubsystemInitialization,
-       OPT_TraceTraps,
-       OPT_Vmlog,
-       OPT_VmlogStrings,
-       OPT_VmlogIgnore
-};
-
-
-option_t options_XX[] = {
-       /* Options which must always be available (production options in
-          HotSpot). */
-
-       { "MaxDirectMemorySize",          OPT_MaxDirectMemorySize,          OPT_TYPE_VALUE,   "Maximum total size of NIO direct-buffer allocations" },
-       { "MaxPermSize",                  OPT_MaxPermSize,                  OPT_TYPE_VALUE,   "not implemented" },
-       { "PermSize",                     OPT_PermSize,                     OPT_TYPE_VALUE,   "not implemented" },
-       { "ThreadStackSize",              OPT_ThreadStackSize,              OPT_TYPE_VALUE,   "TODO" },
-
-       /* Debugging options which can be turned off. */
-
-       { "DebugExceptions",              OPT_DebugExceptions,              OPT_TYPE_BOOLEAN, "debug exceptions" },
-       { "DebugFinalizer",               OPT_DebugFinalizer,               OPT_TYPE_BOOLEAN, "debug finalizer thread" },
-       { "DebugLocalReferences",         OPT_DebugLocalReferences,         OPT_TYPE_BOOLEAN, "print debug information for local reference tables" },
-       { "DebugLocks",                   OPT_DebugLocks,                   OPT_TYPE_BOOLEAN, "print debug information for locks" },
-       { "DebugPackage",                 OPT_DebugPackage,                 OPT_TYPE_BOOLEAN, "debug Java boot-packages" },
-       { "DebugPatcher",                 OPT_DebugPatcher,                 OPT_TYPE_BOOLEAN, "debug JIT code patching" },
-       { "DebugProperties",              OPT_DebugProperties,              OPT_TYPE_BOOLEAN, "print debug information for properties" },
-       { "DebugStackFrameInfo",          OPT_DebugStackFrameInfo,          OPT_TYPE_BOOLEAN, "TODO" },
-       { "DebugStackTrace",              OPT_DebugStackTrace,              OPT_TYPE_BOOLEAN, "debug stacktrace creation" },
-       { "DebugThreads",                 OPT_DebugThreads,                 OPT_TYPE_BOOLEAN, "print debug information for threads" },
-#if defined(ENABLE_DISASSEMBLER)
-       { "DisassembleStubs",             OPT_DisassembleStubs,             OPT_TYPE_BOOLEAN, "disassemble builtin and native stubs when generated" },
-#endif
-#if defined(ENABLE_GC_CACAO)
-       { "GCDebugRootSet",               OPT_GCDebugRootSet,               OPT_TYPE_BOOLEAN, "GC: print root-set at collection" },
-       { "GCStress",                     OPT_GCStress,                     OPT_TYPE_BOOLEAN, "GC: forced collection at every allocation" },
-#endif
-#if defined(ENABLE_INLINING)
-       { "Inline",                       OPT_Inline,                       OPT_TYPE_BOOLEAN, "enable method inlining" },
-#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
-       { "InlineAll",                    OPT_InlineAll,                    OPT_TYPE_BOOLEAN, "use inlining in all compilations" },
-       { "InlineCount",                  OPT_InlineCount,                  OPT_TYPE_VALUE,   "stop inlining after the given number of roots" },
-       { "InlineMaxSize",                OPT_InlineMaxSize,                OPT_TYPE_VALUE,   "maximum size for inlined result" },
-       { "InlineMinSize",                OPT_InlineMinSize,                OPT_TYPE_VALUE,   "minimum size for inlined result" },
-#endif
-#endif
-       { "PrintConfig",                  OPT_PrintConfig,                  OPT_TYPE_BOOLEAN, "print VM configuration" },
-       { "ProfileGCMemoryUsage",         OPT_ProfileGCMemoryUsage,         OPT_TYPE_VALUE,   "profiles GC memory usage in the given interval, <value> is in seconds (default: 5)" },
-       { "ProfileMemoryUsage",           OPT_ProfileMemoryUsage,           OPT_TYPE_VALUE,   "TODO" },
-       { "ProfileMemoryUsageGNUPlot",    OPT_ProfileMemoryUsageGNUPlot,    OPT_TYPE_VALUE,   "TODO" },
-#if defined(ENABLE_REPLACEMENT)
-       { "TestReplacement",              OPT_TestReplacement,              OPT_TYPE_BOOLEAN, "activate all replacement points during code generation" },
-#endif
-       { "TraceCompilerCalls",           OPT_TraceCompilerCalls,           OPT_TYPE_BOOLEAN, "trace JIT compiler calls" },
-       { "TraceExceptions",              OPT_TraceExceptions,              OPT_TYPE_BOOLEAN, "trace Exception throwing" },
-       { "TraceHPI",                     OPT_TraceHPI,                     OPT_TYPE_BOOLEAN, "Trace Host Porting Interface (HPI)" },
-#if defined(ENABLE_INLINING) && !defined(NDEBUG)
-       { "TraceInlining",                OPT_TraceInlining,                OPT_TYPE_VALUE,   "trace method inlining with the given verbosity level (default: 1)" },
-#endif
-#if !defined(ENABLE_VMLOG)
-       { "TraceJavaCalls",               OPT_TraceJavaCalls,               OPT_TYPE_BOOLEAN, "trace Java method calls" },
-#endif
-       { "TraceJNICalls",                OPT_TraceJNICalls,                OPT_TYPE_BOOLEAN, "trace JNI method calls" },
-       { "TraceJVMCalls",                OPT_TraceJVMCalls,                OPT_TYPE_BOOLEAN, "trace JVM method calls but omit very frequent ones" },
-       { "TraceJVMCallsVerbose",         OPT_TraceJVMCallsVerbose,         OPT_TYPE_BOOLEAN, "trace all JVM method calls" },
-       { "TraceLinkClass",               OPT_TraceLinkClass,               OPT_TYPE_BOOLEAN, "trace class linking" },
-#if defined(ENABLE_REPLACEMENT)
-       { "TraceReplacement",             OPT_TraceReplacement,             OPT_TYPE_VALUE,   "trace on-stack replacement with the given verbosity level (default: 1)" },
-#endif
-       { "TraceSubsystemInitialization", OPT_TraceSubsystemInitialization, OPT_TYPE_BOOLEAN, "trace initialization of subsystems" },
-       { "TraceTraps",                   OPT_TraceTraps,                   OPT_TYPE_BOOLEAN, "trace traps generated by JIT code" },
-#if defined(ENABLE_VMLOG)
-       { "Vmlog",                        OPT_Vmlog,                        OPT_TYPE_VALUE,   "prefix for vmlog trace files (enables vmlog)" },
-       { "VmlogStrings",                 OPT_VmlogStrings,                 OPT_TYPE_VALUE,   "prefix of vmlog string file to load" },
-       { "VmlogIgnore",                  OPT_VmlogIgnore,                  OPT_TYPE_VALUE,   "prefix of vmlog ignore file to load" },
-#endif
-
-       /* end marker */
-
-       { NULL,                           -1,                               -1,               NULL }
-};
-
-
-/* options_get *****************************************************************
-
-   DOCUMENT ME!!!
-
-*******************************************************************************/
-
-int options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
-{
-       char *option;
-       int   i;
-
-       if (opt_index >= vm_args->nOptions)
-               return OPT_DONE;
-
-       /* get the current option */
-
-       option = vm_args->options[opt_index].optionString;
-
-       if ((option == NULL) || (option[0] != '-'))
-               return OPT_DONE;
-
-       for (i = 0; opts[i].name; i++) {
-               if (!opts[i].arg) {
-                       /* boolean option found */
-
-                       if (strcmp(option + 1, opts[i].name) == 0) {
-                               opt_index++;
-                               return opts[i].value;
-                       }
-
-               } else {
-                       /* parameter option found */
-
-                       /* with a space between */
-
-                       if (strcmp(option + 1, opts[i].name) == 0) {
-                               opt_index++;
-
-                               if (opt_index < vm_args->nOptions) {
-                                       opt_arg = system_strdup(vm_args->options[opt_index].optionString);
-                                       opt_index++;
-                                       return opts[i].value;
-                               }
-
-                               return OPT_ERROR;
-
-                       } else {
-                               /* parameter and option have no space between */
-
-                               /* FIXME: this assumption is plain wrong, hits you if there is a
-                                * parameter with no argument starting with same letter as param with argument
-                                * but named after that one, ouch! */
-
-                               size_t l = system_strlen(opts[i].name);
-
-                               if (system_strlen(option + 1) > l) {
-                                       if (memcmp(option + 1, opts[i].name, l) == 0) {
-                                               opt_index++;
-                                               opt_arg = system_strdup(option + 1 + l);
-                                               return opts[i].value;
-                                       }
-                               }
-                       }
-               }
-       }
-
-       return OPT_ERROR;
-}
-
-
-/* options_xxusage *************************************************************
-
-   Print usage message for debugging options.
-
-*******************************************************************************/
-
-static void options_xxusage(void)
-{
-       option_t *opt;
-       int       length;
-       int       i;
-       char     *c;
-
-       /* Prevent compiler warning. */
-
-       length = 0;
-
-       for (opt = options_XX; opt->name != NULL; opt++) {
-               printf("    -XX:");
-
-               switch (opt->type) {
-               case OPT_TYPE_BOOLEAN:
-                       printf("+%s", opt->name);
-                       length = system_strlen("    -XX:+") + system_strlen(opt->name);
-                       break;
-
-               case OPT_TYPE_VALUE:
-                       printf("%s=<value>", opt->name);
-                       length = system_strlen("    -XX:") + system_strlen(opt->name) +
-                               system_strlen("=<value>");
-                       break;
-
-               default:
-                       vm_abort("options_xxusage: unkown option type %d", opt->type);
-               }
-
-               /* Check if the help fits into one 80-column line.
-                  Documentation starts at column 29. */
-
-               if (length < (29 - 1)) {
-                       /* Print missing spaces up to column 29. */
-
-                       for (i = length; i < 29; i++)
-                               printf(" ");
-               }
-               else {
-                       printf("\n");
-                       printf("                             "); /* 29 spaces */
-               }
-
-               /* Check documentation length. */
-
-               length = system_strlen(opt->doc);
-
-               if (length < (80 - 29)) {
-                       printf("%s", opt->doc);
-               }
-               else {
-                       for (c = opt->doc, i = 29; *c != 0; c++, i++) {
-                               /* If we are at the end of the line, break it. */
-
-                               if (i == 80) {
-                                       printf("\n");
-                                       printf("                             "); /* 29 spaces */
-                                       i = 29;
-                               }
-
-                               printf("%c", *c);
-                       }
-               }
-
-               printf("\n");
-       }
-
-       /* exit with error code */
-
-       exit(1);
-}
-
-
-/* options_xx ******************************************************************
-
-   Handle -XX: options.
-
-*******************************************************************************/
-
-void options_xx(JavaVMInitArgs *vm_args)
-{
-       const char *name;
-       const char *start;
-       char       *end;
-       int         length;
-       int         enable;
-       char       *value;
-       option_t   *opt;
-       char       *filename;
-       FILE       *file;
-       int         i;
-
-       /* Iterate over all passed options. */
-
-       for (i = 0; i < vm_args->nOptions; i++) {
-               /* Get the current option. */
-
-               name = vm_args->options[i].optionString;
-
-               /* Check for help (-XX). */
-
-               if (strcmp(name, "-XX") == 0)
-                       options_xxusage();
-
-               /* Check if the option start with -XX. */
-
-               start = strstr(name, "-XX:");
-
-               if ((start == NULL) || (start != name))
-                       continue;
-
-               /* Check if the option is a boolean option. */
-
-               if (name[4] == '+') {
-                       start  = name + 4 + 1;
-                       enable = 1;
-               }
-               else if (name[4] == '-') {
-                       start  = name + 4 + 1;
-                       enable = 0;
-               }
-               else {
-                       start  = name + 4;
-                       enable = -1;
-               }
-
-               /* Search for a '=' in the option name and get the option name
-                  length and the value of the option. */
-
-               end = strchr(start, '=');
-
-               if (end == NULL) {
-                       length = system_strlen(start);
-                       value  = NULL;
-               }
-               else {
-                       length = end - start;
-                       value  = end + 1;
-               }
-
-               /* Search the option in the option array. */
-
-               for (opt = options_XX; opt->name != NULL; opt++) {
-                       if (strncmp(opt->name, start, length) == 0) {
-                               /* Check if the options passed fits to the type. */
-
-                               switch (opt->type) {
-                               case OPT_TYPE_BOOLEAN:
-                                       if ((enable == -1) || (value != NULL))
-                                               options_xxusage();
-                                       break;
-                               case OPT_TYPE_VALUE:
-                                       if ((enable != -1) || (value == NULL))
-                                               options_xxusage();
-                                       break;
-                               default:
-                                       vm_abort("options_xx: unknown option type %d for option %s",
-                                                        opt->type, opt->name);
-                               }
-
-                               break;
-                       }
-               }
-
-               /* Process the option. */
-
-               switch (opt->value) {
-
-               /* Options which must always be available (production options
-                  in HotSpot). */
-
-               case OPT_MaxDirectMemorySize:
-                       opt_MaxDirectMemorySize = system_atoi(value);
-                       break;
-
-               case OPT_MaxPermSize:
-                       /* Currently ignored. */
-                       break;
-
-               case OPT_PermSize:
-                       /* Currently ignored. */
-                       break;
-
-               case OPT_ThreadStackSize:
-                       /* currently ignored */
-                       break;
-
-               /* Debugging options which can be turned off. */
-
-               case OPT_DebugExceptions:
-                       opt_DebugExceptions = enable;
-                       break;
-
-               case OPT_DebugFinalizer:
-                       opt_DebugFinalizer = enable;
-                       break;
-
-               case OPT_DebugLocalReferences:
-                       opt_DebugLocalReferences = enable;
-                       break;
-
-               case OPT_DebugLocks:
-                       opt_DebugLocks = enable;
-                       break;
-
-               case OPT_DebugPackage:
-                       opt_DebugPackage = enable;
-                       break;
-
-               case OPT_DebugPatcher:
-                       opt_DebugPatcher = enable;
-                       break;
-
-               case OPT_DebugProperties:
-                       opt_DebugProperties = enable;
-                       break;
-
-               case OPT_DebugStackFrameInfo:
-                       opt_DebugStackFrameInfo = enable;
-                       break;
-
-               case OPT_DebugStackTrace:
-                       opt_DebugStackTrace = enable;
-                       break;
-
-               case OPT_DebugThreads:
-                       opt_DebugThreads = enable;
-                       break;
-
-#if defined(ENABLE_DISASSEMBLER)
-               case OPT_DisassembleStubs:
-                       opt_DisassembleStubs = enable;
-                       break;
-#endif
-
-#if defined(ENABLE_GC_CACAO)
-               case OPT_GCDebugRootSet:
-                       opt_GCDebugRootSet = enable;
-                       break;
-
-               case OPT_GCStress:
-                       opt_GCStress = enable;
-                       break;
-#endif
-
-#if defined(ENABLE_INLINING)
-               case OPT_Inline:
-                       opt_Inline = enable;
-                       break;
-#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
-               case OPT_InlineAll:
-                       opt_InlineAll = enable;
-                       break;
-
-               case OPT_InlineCount:
-                       if (value != NULL)
-                               opt_InlineCount = system_atoi(value);
-                       break;
-
-               case OPT_InlineMaxSize:
-                       if (value != NULL)
-                               opt_InlineMaxSize = system_atoi(value);
-                       break;
-
-               case OPT_InlineMinSize:
-                       if (value != NULL)
-                               opt_InlineMinSize = system_atoi(value);
-                       break;
-#endif
-#endif
-
-               case OPT_PrintConfig:
-                       opt_PrintConfig = enable;
-                       break;
-
-               case OPT_ProfileGCMemoryUsage:
-                       if (value == NULL)
-                               opt_ProfileGCMemoryUsage = 5;
-                       else
-                               opt_ProfileGCMemoryUsage = system_atoi(value);
-                       break;
-
-               case OPT_ProfileMemoryUsage:
-                       if (value == NULL)
-                               opt_ProfileMemoryUsage = 5;
-                       else
-                               opt_ProfileMemoryUsage = system_atoi(value);
-
-# if defined(ENABLE_STATISTICS)
-                       /* we also need statistics */
-
-                       opt_stat = true;
-# endif
-                       break;
-
-               case OPT_ProfileMemoryUsageGNUPlot:
-                       if (value == NULL)
-                               filename = "profile.dat";
-                       else
-                               filename = value;
-
-                       file = fopen(filename, "w");
-
-                       if (file == NULL)
-                               vm_abort_errno("options_xx: fopen failed");
-
-                       opt_ProfileMemoryUsageGNUPlot = file;
-                       break;
-
-#if defined(ENABLE_REPLACEMENT)
-               case OPT_TestReplacement:
-                       opt_TestReplacement = enable;
-                       break;
-#endif
-
-               case OPT_TraceCompilerCalls:
-                       opt_TraceCompilerCalls = enable;
-                       break;
-
-               case OPT_TraceExceptions:
-                       opt_TraceExceptions = enable;
-                       break;
-
-               case OPT_TraceHPI:
-                       opt_TraceHPI = enable;
-                       break;
-
-#if defined(ENABLE_INLINING) && !defined(NDEBUG)
-               case OPT_TraceInlining:
-                       if (value == NULL)
-                               opt_TraceInlining = 1;
-                       else
-                               opt_TraceInlining = system_atoi(value);
-                       break;
-#endif
-
-               case OPT_TraceJavaCalls:
-                       opt_verbosecall = enable;
-                       opt_TraceJavaCalls = enable;
-                       break;
-
-               case OPT_TraceJNICalls:
-                       opt_TraceJNICalls = enable;
-                       break;
-
-               case OPT_TraceJVMCalls:
-                       opt_TraceJVMCalls = enable;
-                       break;
-
-               case OPT_TraceJVMCallsVerbose:
-                       opt_TraceJVMCallsVerbose = enable;
-                       break;
-
-               case OPT_TraceLinkClass:
-                       opt_TraceLinkClass = enable;
-                       break;
-
-#if defined(ENABLE_REPLACEMENT)
-               case OPT_TraceReplacement:
-                       if (value == NULL)
-                               opt_TraceReplacement = 1;
-                       else
-                               opt_TraceReplacement = system_atoi(value);
-                       break;
-#endif
-
-               case OPT_TraceSubsystemInitialization:
-                       opt_TraceSubsystemInitialization = enable;
-                       break;
-
-               case OPT_TraceTraps:
-                       opt_TraceTraps = enable;
-                       break;
-
-#if defined(ENABLE_VMLOG)
-               case OPT_Vmlog:
-                       if (value == NULL)
-                               vmlog_cacao_set_prefix("vmlog");
-                       else
-                               vmlog_cacao_set_prefix(value);
-                       opt_verbosecall = 1;
-                       opt_TraceJavaCalls = 1;
-                       break;
-
-               case OPT_VmlogStrings:
-                       if (value != NULL)
-                               vmlog_cacao_set_stringprefix(value);
-                       break;
-
-               case OPT_VmlogIgnore:
-                       if (value != NULL)
-                               vmlog_cacao_set_ignoreprefix(value);
-                       break;
-#endif
-
-               default:
-                       printf("Unknown -XX option: %s\n", name);
-                       break;
-               }
-       }
-}
-
-
-/*
- * 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:
- */
diff --git a/src/vmcore/options.h b/src/vmcore/options.h
deleted file mode 100644 (file)
index ca4e096..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/* src/vmcore/options.h - define global options extern
-
-   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 _OPTIONS_H
-#define _OPTIONS_H
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-
-#include "vm/global.h"
-
-
-/* reserved option numbers ****************************************************/
-
-/* define these negative since the other options are an enum */
-
-#define OPT_DONE       -1
-#define OPT_ERROR      -2
-#define OPT_IGNORE     -3
-
-
-typedef struct opt_struct opt_struct;
-
-struct opt_struct {
-       char *name;
-       bool  arg;
-       int   value;
-};
-
-
-typedef struct option_t option_t;
-
-struct option_t {
-       char *name;
-       int   value;
-       int   type;
-       char *doc;
-};
-
-
-/* global variables ***********************************************************/
-
-extern s4    opt_index;
-extern char *opt_arg;
-
-extern bool opt_foo;
-
-extern bool opt_jit;
-extern bool opt_intrp;
-
-extern bool opt_jar;
-extern bool opt_run;
-
-extern s4   opt_heapmaxsize;
-extern s4   opt_heapstartsize;
-extern s4   opt_stacksize;
-
-extern bool opt_verbose;
-extern bool opt_debugcolor;
-extern bool compileall;
-
-extern bool loadverbose;         /* Print debug messages during loading */
-extern bool initverbose;         /* Log class initialization */ 
-
-extern bool opt_verboseclass;
-extern bool opt_verbosegc;
-extern bool opt_verbosejni;
-extern bool opt_verbosecall;
-
-extern bool showmethods;
-extern bool showconstantpool;
-extern bool showutf;
-
-extern char *opt_method;
-extern char *opt_signature;
-
-extern bool compileverbose;
-extern bool showstack;
-
-extern bool opt_showdisassemble;
-extern bool opt_shownops;
-extern bool opt_showddatasegment;
-extern bool opt_showintermediate;
-
-extern bool checkbounds;
-extern bool opt_noieee;
-extern bool checksync;
-#if defined(ENABLE_LOOP)
-extern bool opt_loops;
-#endif
-
-extern bool makeinitializations;
-
-#if defined(ENABLE_STATISTICS)
-extern bool opt_stat;
-extern bool opt_getloadingtime;
-extern bool opt_getcompilingtime;
-#endif
-#if defined(ENABLE_VERIFIER)
-extern bool opt_verify;
-#endif
-
-#if defined(ENABLE_PROFILING)
-extern bool opt_prof;
-extern bool opt_prof_bb;
-#endif
-
-/* optimization options *******************************************************/
-
-#if defined(ENABLE_IFCONV)
-extern bool opt_ifconv;
-#endif
-
-#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
-extern bool opt_lsra;
-#endif
-#if defined(ENABLE_SSA)
-extern bool opt_ssa_dce;          /* enable dead code elemination */
-extern bool opt_ssa_cp;           /* enable copy propagation      */
-#endif
-
-/* interpreter options ********************************************************/
-
-#if defined(ENABLE_INTRP)
-extern bool opt_no_dynamic;
-extern bool opt_no_replication;
-extern bool opt_no_quicksuper;
-
-extern s4   opt_static_supers;
-extern bool vm_debug;
-#endif
-
-/* debug output filtering options *********************************************/
-
-#if defined(ENABLE_DEBUG_FILTER)
-extern const char *opt_filter_verbosecall_include;
-extern const char *opt_filter_verbosecall_exclude;
-extern const char *opt_filter_show_method;
-#endif
-
-
-/* -XX options ****************************************************************/
-
-/* NOTE: For better readability keep these alpha-sorted. */
-
-/* Options which must always be available (production options in
-   HotSpot). */
-
-extern int64_t  opt_MaxDirectMemorySize;
-extern int      opt_MaxPermSize;
-extern int      opt_PermSize;
-extern int      opt_ThreadStackSize;
-
-/* Debugging options which can be turned off. */
-
-extern int      opt_DebugExceptions;
-extern int      opt_DebugFinalizer;
-extern int      opt_DebugLocalReferences;
-extern int      opt_DebugLocks;
-extern int      opt_DebugPatcher;
-extern int      opt_DebugPackage;
-extern int      opt_DebugProperties;
-extern int      opt_DebugStackFrameInfo;
-extern int      opt_DebugStackTrace;
-extern int      opt_DebugThreads;
-#if defined(ENABLE_DISASSEMBLER)
-extern int      opt_DisassembleStubs;
-#endif
-#if defined(ENABLE_GC_CACAO)
-extern int      opt_GCDebugRootSet;
-extern int      opt_GCStress;
-#endif
-#if defined(ENABLE_INLINING)
-extern int      opt_Inline;
-#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
-extern int      opt_InlineAll;
-extern int      opt_InlineCount;
-extern int      opt_InlineMaxSize;
-extern int      opt_InlineMinSize;
-#endif
-#endif
-extern int      opt_PrintConfig;
-extern int      opt_ProfileGCMemoryUsage;
-extern int      opt_ProfileMemoryUsage;
-extern FILE    *opt_ProfileMemoryUsageGNUPlot;
-#if defined(ENABLE_REPLACEMENT)
-extern int      opt_TestReplacement;
-#endif
-extern int      opt_TraceCompilerCalls;
-extern int      opt_TraceExceptions;
-extern int      opt_TraceHPI;
-#if defined(ENABLE_INLINING) && !defined(NDEBUG)
-extern int      opt_TraceInlining;
-#endif
-extern int      opt_TraceJavaCalls;
-extern int      opt_TraceJNICalls;
-extern int      opt_TraceJVMCalls;
-extern int      opt_TraceJVMCallsVerbose;
-extern int      opt_TraceLinkClass;
-#if defined(ENABLE_REPLACEMENT)
-extern int      opt_TraceReplacement;
-#endif
-extern int      opt_TraceSubsystemInitialization;
-extern int      opt_TraceTraps;
-
-
-/* function prototypes ********************************************************/
-
-int  options_get(opt_struct *opts, JavaVMInitArgs *vm_args);
-void options_xx(JavaVMInitArgs *vm_args);
-
-
-/* debug **********************************************************************/
-
-#if !defined(NDEBUG)
-# define TRACESUBSYSTEMINITIALIZATION(text)                                            \
-    do {                                                                                                               \
-        if (opt_TraceSubsystemInitialization) {                                        \
-            log_println("[Initializing subsystem: %s]", text); \
-        }                                                                                                              \
-    } while (0)
-#else
-# define TRACESUBSYSTEMINITIALIZATION(text)
-#endif
-
-#endif /* _OPTIONS_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:
- */
diff --git a/src/vmcore/primitivecore.c b/src/vmcore/primitivecore.c
deleted file mode 100644 (file)
index d55da76..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/* src/vmcore/primitivecore.c - core functions for primitive types
-
-   Copyright (C) 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 <stdint.h>
-
-#include "vm/global.h"
-#include "vm/primitive.h"
-#include "vm/vm.h"
-
-#include "vmcore/class.h"
-#include "vmcore/options.h"
-#include "vmcore/utf8.h"
-
-
-/* primitivetype_table *********************************************************
-
-   Structure for primitive classes: contains the class for wrapping
-   the primitive type, the primitive class, the name of the class for
-   wrapping, the one character type signature and the name of the
-   primitive class.
-   CAUTION: Don't change the order of the types. This table is indexed
-   by the ARRAYTYPE_ constants (except ARRAYTYPE_OBJECT).
-
-*******************************************************************************/
-
-primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT] = {
-       { "int"     , NULL, NULL, NULL, "java/lang/Integer",   'I', "[I", NULL },
-       { "long"    , NULL, NULL, NULL, "java/lang/Long",      'J', "[J", NULL },
-       { "float"   , NULL, NULL, NULL, "java/lang/Float",     'F', "[F", NULL },
-       { "double"  , NULL, NULL, NULL, "java/lang/Double",    'D', "[D", NULL },
-       { NULL      , NULL, NULL, NULL, NULL,                   0 , NULL, NULL },
-       { "byte"    , NULL, NULL, NULL, "java/lang/Byte",      'B', "[B", NULL },
-       { "char"    , NULL, NULL, NULL, "java/lang/Character", 'C', "[C", NULL },
-       { "short"   , NULL, NULL, NULL, "java/lang/Short",     'S', "[S", NULL },
-       { "boolean" , NULL, NULL, NULL, "java/lang/Boolean",   'Z', "[Z", NULL },
-       { NULL      , NULL, NULL, NULL, NULL,                   0 , NULL, NULL },
-#if defined(ENABLE_JAVASE)
-       { "void"    , NULL, NULL, NULL, "java/lang/Void",      'V', NULL, NULL }
-#else
-       { NULL      , NULL, NULL, NULL, NULL,                   0 , NULL, NULL },
-#endif
-};
-
-
-/* primitive_init **************************************************************
-
-   Fill the primitive type table with the primitive-type classes,
-   array-classes and wrapper classes.  This is important in the VM
-   startup.
-
-   We split this primitive-type table initialization because of
-   annotations in the bootstrap classes.
-
-   But we may get a problem if we have annotations in:
-
-   java/lang/Object
-   java/lang/Cloneable
-   java/io/Serializable
-
-   Also see: loader_preinit and linker_preinit.
-
-*******************************************************************************/
-
-void primitive_init(void)
-{  
-       utf       *name;
-       classinfo *c;
-       utf       *u;
-       classinfo *ac;
-       int        i;
-
-       TRACESUBSYSTEMINITIALIZATION("primitive_init");
-
-       /* Load and link primitive-type classes and array-classes. */
-
-       for (i = 0; i < PRIMITIVETYPE_COUNT; i++) {
-               /* Skip dummy entries. */
-
-               if (primitivetype_table[i].cname == NULL)
-                       continue;
-
-               /* create UTF-8 name */
-
-               name = utf_new_char(primitivetype_table[i].cname);
-
-               primitivetype_table[i].name = name;
-
-               /* create primitive class */
-
-               c = class_create_classinfo(name);
-
-               /* Primitive type classes don't have a super class. */
-
-               c->super = NULL;
-
-               /* set flags and mark it as primitive class */
-
-               c->flags = ACC_PUBLIC | ACC_FINAL | ACC_ABSTRACT | ACC_CLASS_PRIMITIVE;
-               
-               /* prevent loader from loading primitive class */
-
-               c->state |= CLASS_LOADED;
-
-               /* INFO: don't put primitive classes into the classcache */
-
-               if (!link_class(c))
-                       vm_abort("linker_init: linking failed");
-
-               /* Just to be sure. */
-
-               assert(c->state & CLASS_LOADED);
-               assert(c->state & CLASS_LINKED);
-
-               primitivetype_table[i].class_primitive = c;
-
-               /* Create primitive array class. */
-
-               if (primitivetype_table[i].arrayname != NULL) {
-                       u  = utf_new_char(primitivetype_table[i].arrayname);
-                       ac = class_create_classinfo(u);
-                       ac = load_newly_created_array(ac, NULL);
-
-                       if (ac == NULL)
-                               vm_abort("primitive_init: loading failed");
-
-                       assert(ac->state & CLASS_LOADED);
-
-                       if (!link_class(ac))
-                               vm_abort("primitive_init: linking failed");
-
-                       /* Just to be sure. */
-
-                       assert(ac->state & CLASS_LOADED);
-                       assert(ac->state & CLASS_LINKED);
-
-                       primitivetype_table[i].arrayclass = ac;
-               }
-       }
-
-       /* We use two for-loops to have the array-classes already in the
-          primitive-type table (hint: annotations in wrapper-classes). */
-
-       for (i = 0; i < PRIMITIVETYPE_COUNT; i++) {
-               /* Skip dummy entries. */
-
-               if (primitivetype_table[i].cname == NULL)
-                       continue;
-
-               /* Create class for wrapping the primitive type. */
-
-               u = utf_new_char(primitivetype_table[i].wrapname);
-               c = load_class_bootstrap(u);
-
-               if (c == NULL)
-                       vm_abort("primitive_init: loading failed");
-
-               if (!link_class(c))
-                       vm_abort("primitive_init: linking failed");
-
-               /* Just to be sure. */
-
-               assert(c->state & CLASS_LOADED);
-               assert(c->state & CLASS_LINKED);
-
-               primitivetype_table[i].class_wrap = c;
-       }
-}
-
-
-/* primitive_postinit **********************************************************
-
-   Finish the primitive-type table initialization.  In this step we
-   set the vftbl of the primitive-type classes.
-
-   This is necessary because java/lang/Class is loaded and linked
-   after the primitive types have been linked.
-
-   We have to do that in an extra function, as the primitive types are
-   not stored in the classcache.
-
-*******************************************************************************/
-
-void primitive_postinit(void)
-{
-       classinfo *c;
-       int        i;
-
-       TRACESUBSYSTEMINITIALIZATION("primitive_postinit");
-
-       assert(class_java_lang_Class);
-       assert(class_java_lang_Class->vftbl);
-
-       for (i = 0; i < PRIMITIVETYPE_COUNT; i++) {
-               /* Skip dummy entries. */
-
-               if (primitivetype_table[i].cname == NULL)
-                       continue;
-
-               c = primitivetype_table[i].class_primitive;
-
-               c->object.header.vftbl = class_java_lang_Class->vftbl;
-       }
-}
-
-
-/*
- * 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/vmcore/references.h b/src/vmcore/references.h
deleted file mode 100644 (file)
index 6ac2336..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/* src/vmcore/references.h - references to classes/fields/methods
-
-   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 _REFERENCES_H_
-#define _REFERENCES_H_
-
-/* forward typedefs ***********************************************************/
-
-typedef struct constant_classref constant_classref;
-typedef struct constant_FMIref   constant_FMIref;
-
-
-/* constant_classref **********************************************************/
-
-struct constant_classref {
-       void             *pseudo_vftbl; /* for distinguishing it from classinfo   */
-       struct classinfo *referer;    /* class containing the reference           */
-       struct utf       *name;       /* name of the class refered to             */
-};
-
-
-/* classref_or_classinfo ******************************************************/
-
-typedef union classref_or_classinfo {
-       constant_classref *ref;       /* a symbolic class reference               */
-       struct classinfo  *cls;       /* an already loaded class                  */
-       void              *any;       /* used for general access (x != NULL,...)  */
-} classref_or_classinfo;
-
-
-/* parseddesc_t ***************************************************************/
-
-typedef union parseddesc {
-       struct typedesc   *fd;        /* parsed field descriptor                  */
-       struct methoddesc *md;        /* parsed method descriptor                 */
-       void              *any;       /* used for simple test against NULL        */
-} parseddesc_t;
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/descriptor.h"
-#include "vmcore/field.h"
-#include "vmcore/method.h"
-#include "vmcore/utf8.h"
-
-
-/*----------------------------------------------------------------------------*/
-/* References                                                                 */
-/*                                                                            */
-/* This header files defines the following types used for references to       */
-/* classes/methods/fields and descriptors:                                    */
-/*                                                                            */
-/*     classinfo *                a loaded class                              */
-/*     constant_classref          a symbolic reference                        */
-/*     classref_or_classinfo      a loaded class or a symbolic reference      */
-/*                                                                            */
-/*     constant_FMIref            a symb. ref. to a field/method/intf.method  */
-/*                                                                            */
-/*     typedesc *                 describes a field type                      */
-/*     methoddesc *               descrives a method type                     */
-/*     parseddesc                 describes a field type or a method type     */
-/*----------------------------------------------------------------------------*/
-
-/* structs ********************************************************************/
-
-/* constant_FMIref ************************************************************/
-
-struct constant_FMIref{      /* Fieldref, Methodref and InterfaceMethodref    */
-       union {
-               s4                 index;     /* used only within the loader          */
-               constant_classref *classref;  /* class having this field/meth./intfm. */
-               fieldinfo         *field;     /* resolved field                       */
-               methodinfo        *method;    /* resolved method                      */
-       } p;
-       utf         *name;       /* field/method/interfacemethod name             */
-       utf         *descriptor; /* field/method/intfmeth. type descriptor string */
-       parseddesc_t parseddesc; /* parsed descriptor                             */
-};
-
-
-/* macros *********************************************************************/
-
-/* a value that never occurrs in classinfo.header.vftbl                       */
-#define CLASSREF_PSEUDO_VFTBL ((void *) 1)
-
-/* macro for testing if a classref_or_classinfo is a classref                 */
-/* `reforinfo` is only evaluated once                                         */
-#define IS_CLASSREF(reforinfo)  \
-       ((reforinfo).ref->pseudo_vftbl == CLASSREF_PSEUDO_VFTBL)
-
-/* macro for testing if a constant_FMIref has been resolved                   */
-/* `fmiref` is only evaluated once                                            */
-#define IS_FMIREF_RESOLVED(fmiref)  \
-       ((fmiref)->p.classref->pseudo_vftbl != CLASSREF_PSEUDO_VFTBL)
-
-/* the same as IS_CLASSREF, but also check against NULL */
-#define IS_XCLASSREF(reforinfo)  \
-       ((reforinfo).any && IS_CLASSREF(reforinfo))
-
-/* macro for casting a classref/classinfo * to a classref_or_classinfo        */
-#define CLASSREF_OR_CLASSINFO(value) \
-       (*((classref_or_classinfo *)(&(value))))
-
-/* macro for accessing the name of a classref/classinfo                       */
-#define CLASSREF_OR_CLASSINFO_NAME(value) \
-       (IS_CLASSREF(value) ? (value).ref->name : (value).cls->name)
-
-/* macro for accessing the class name of a method reference                   */
-#define METHODREF_CLASSNAME(fmiref) \
-       (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.method->clazz->name \
-                                                               : (fmiref)->p.classref->name)
-
-/* macro for accessing the class name of a method reference                   */
-#define FIELDREF_CLASSNAME(fmiref) \
-       (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.field->clazz->name \
-                                                               : (fmiref)->p.classref->name)
-
-/* initialize a constant_classref with referer `ref` and name `classname`     */
-
-#define CLASSREF_INIT(c,ref,classname) \
-    do { \
-        (c).pseudo_vftbl = CLASSREF_PSEUDO_VFTBL; \
-        (c).referer = (ref); \
-        (c).name = (classname); \
-    } while (0)
-
-#endif /* _REFERENCES_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/vmcore/rt-timing.c b/src/vmcore/rt-timing.c
deleted file mode 100644 (file)
index 7e535be..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/* src/vmcore/rt-timing.c - POSIX real-time timing utilities
-
-   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
-
-   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 <errno.h>
-#include <stdlib.h>
-#include <time.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "vm/global.h"
-
-#include "vmcore/rt-timing.h"
-
-
-struct rt_timing_stat {
-       int index;
-       int totalindex;
-       const char *name;
-};
-
-static struct rt_timing_stat rt_timing_stat_defs[] = {
-    { RT_TIMING_JIT_CHECKS      ,RT_TIMING_JIT_TOTAL , "checks at beginning" },
-    { RT_TIMING_JIT_PARSE       ,RT_TIMING_JIT_TOTAL , "parse" },
-    { RT_TIMING_JIT_STACK       ,RT_TIMING_JIT_TOTAL , "analyse_stack" },
-    { RT_TIMING_JIT_TYPECHECK   ,RT_TIMING_JIT_TOTAL , "typecheck" },
-    { RT_TIMING_JIT_LOOP        ,RT_TIMING_JIT_TOTAL , "loop" },
-    { RT_TIMING_JIT_IFCONV      ,RT_TIMING_JIT_TOTAL , "if conversion" },
-    { RT_TIMING_JIT_ALLOC       ,RT_TIMING_JIT_TOTAL , "register allocation" },
-    { RT_TIMING_JIT_RPLPOINTS   ,RT_TIMING_JIT_TOTAL , "replacement point generation" },
-    { RT_TIMING_JIT_CODEGEN     ,RT_TIMING_JIT_TOTAL , "codegen" },
-    { RT_TIMING_JIT_TOTAL       ,-1                  , "total compile time" },
-    { -1                        ,-1                  , "" },
-
-    { RT_TIMING_LINK_RESOLVE    ,RT_TIMING_LINK_TOTAL, "link: resolve superclass/superinterfaces"},
-    { RT_TIMING_LINK_C_VFTBL    ,RT_TIMING_LINK_TOTAL, "link: compute vftbl length"},
-    { RT_TIMING_LINK_ABSTRACT   ,RT_TIMING_LINK_TOTAL, "link: handle abstract methods"},
-    { RT_TIMING_LINK_C_IFTBL    ,RT_TIMING_LINK_TOTAL, "link: compute interface table"},
-    { RT_TIMING_LINK_F_VFTBL    ,RT_TIMING_LINK_TOTAL, "link: fill vftbl"},
-    { RT_TIMING_LINK_OFFSETS    ,RT_TIMING_LINK_TOTAL, "link: set offsets"},
-    { RT_TIMING_LINK_F_IFTBL    ,RT_TIMING_LINK_TOTAL, "link: fill interface table"},
-    { RT_TIMING_LINK_FINALIZER  ,RT_TIMING_LINK_TOTAL, "link: set finalizer"},
-    { RT_TIMING_LINK_EXCEPTS    ,RT_TIMING_LINK_TOTAL, "link: resolve exception classes"},
-    { RT_TIMING_LINK_SUBCLASS   ,RT_TIMING_LINK_TOTAL, "link: re-calculate subclass indices"},
-    { RT_TIMING_LINK_TOTAL      ,-1                  , "total link time" },
-    { -1                        ,-1                  , "" },
-       
-       { RT_TIMING_LOAD_CHECKS     ,RT_TIMING_LOAD_TOTAL, "load: initial checks"},
-       { RT_TIMING_LOAD_NDPOOL     ,RT_TIMING_LOAD_TOTAL, "load: new descriptor pool"},
-       { RT_TIMING_LOAD_CPOOL      ,RT_TIMING_LOAD_TOTAL, "load: load constant pool"},
-       { RT_TIMING_LOAD_SETUP      ,RT_TIMING_LOAD_TOTAL, "load: class setup"},
-       { RT_TIMING_LOAD_FIELDS     ,RT_TIMING_LOAD_TOTAL, "load: load fields"},
-       { RT_TIMING_LOAD_METHODS    ,RT_TIMING_LOAD_TOTAL, "load: load methods"},
-       { RT_TIMING_LOAD_CLASSREFS  ,RT_TIMING_LOAD_TOTAL, "load: create classrefs"},
-       { RT_TIMING_LOAD_DESCS      ,RT_TIMING_LOAD_TOTAL, "load: allocate descriptors"},
-       { RT_TIMING_LOAD_SETREFS    ,RT_TIMING_LOAD_TOTAL, "load: set classrefs"},
-       { RT_TIMING_LOAD_PARSEFDS   ,RT_TIMING_LOAD_TOTAL, "load: parse field descriptors"},
-       { RT_TIMING_LOAD_PARSEMDS   ,RT_TIMING_LOAD_TOTAL, "load: parse method descriptors"},
-       { RT_TIMING_LOAD_PARSECP    ,RT_TIMING_LOAD_TOTAL, "load: parse descriptors in constant pool"},
-       { RT_TIMING_LOAD_VERIFY     ,RT_TIMING_LOAD_TOTAL, "load: verifier checks"},
-       { RT_TIMING_LOAD_ATTRS      ,RT_TIMING_LOAD_TOTAL, "load: load attributes"},
-       { RT_TIMING_LOAD_TOTAL      ,-1                  , "total load time (from classbuffer)"},
-    { -1                        ,-1                  , "" },
-
-       { RT_TIMING_LOAD_BOOT_LOOKUP,-1                       , "boot: lookup in classcache"},
-       { RT_TIMING_LOAD_BOOT_ARRAY ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: load array classes"},
-       { RT_TIMING_LOAD_BOOT_SUCK  ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: suck class files"},
-       { RT_TIMING_LOAD_BOOT_LOAD  ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: load from class buffer"},
-       { RT_TIMING_LOAD_BOOT_CACHE ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: store in classcache"},
-       { RT_TIMING_LOAD_BOOT_TOTAL ,-1                       , "total bootstrap loader time"},
-    { -1                        ,-1                       , "" },
-
-       { RT_TIMING_LOAD_CL_LOOKUP  ,-1                       , "classloader: lookup in classcache" },
-       { RT_TIMING_LOAD_CL_PREPARE ,-1                       , "classloader: prepare loader call" },
-       { RT_TIMING_LOAD_CL_JAVA    ,-1                       , "classloader: loader Java code" },
-       { RT_TIMING_LOAD_CL_CACHE   ,-1                       , "classloader: store in classcache" },
-    { -1                        ,-1                       , "" },
-
-       { RT_TIMING_NEW_OBJECT      ,-1                       , "builtin_new time" },
-       { RT_TIMING_NEW_ARRAY       ,-1                       , "builtin_newarray time" },
-    { -1                        ,-1                       , "" },
-
-       { RT_TIMING_GC_ALLOC        ,-1                       , "heap allocation time" },
-#if defined(ENABLE_GC_CACAO)
-       { RT_TIMING_GC_SUSPEND      ,RT_TIMING_GC_TOTAL       , "gc: suspending threads" },
-       { RT_TIMING_GC_ROOTSET1     ,RT_TIMING_GC_TOTAL       , "gc: rootset finding" },
-       { RT_TIMING_GC_MARK         ,RT_TIMING_GC_TOTAL       , "gc: marking phase" },
-       { RT_TIMING_GC_COMPACT      ,RT_TIMING_GC_TOTAL       , "gc: compaction phase" },
-       { RT_TIMING_GC_ROOTSET2     ,RT_TIMING_GC_TOTAL       , "gc: rootset writeback" },
-       { RT_TIMING_GC_TOTAL        ,-1                       , "total garbage collection time" },
-       { -1                        ,-1                       , "" },
-#endif
-
-    { 0                         ,-1                       , NULL }
-};
-
-static long long rt_timing_sum[RT_TIMING_N] = { 0 };
-
-void rt_timing_gettime(struct timespec *ts)
-{
-       if (clock_gettime(CLOCK_THREAD_CPUTIME_ID,ts) != 0) {
-               fprintf(stderr,"could not get time by clock_gettime: %s\n",strerror(errno));
-               abort();
-       }
-}
-
-long rt_timing_diff_usec(struct timespec *a,struct timespec *b)
-{
-       long diff;
-       time_t atime;
-
-       diff = (b->tv_nsec - a->tv_nsec) / 1000;
-       atime = a->tv_sec;
-       while (atime < b->tv_sec) {
-               atime++;
-               diff += 1000000;
-       }
-       return diff;
-}
-
-void rt_timing_time_diff(struct timespec *a,struct timespec *b,int index)
-{
-       long diff;
-
-       diff = rt_timing_diff_usec(a,b);
-       rt_timing_sum[index] += diff;
-}
-
-void rt_timing_print_time_stats(FILE *file)
-{
-       struct rt_timing_stat *stats;
-       double total;
-
-       for (stats = rt_timing_stat_defs; stats->name; ++stats) {
-               if (stats->index < 0) {
-                       fprintf(file,"%s\n",stats->name);
-                       continue;
-               }
-               
-               if (stats->totalindex >= 0) {
-                       total = rt_timing_sum[stats->totalindex];
-                       fprintf(file,"%12lld usec %3.0f%% %s\n",
-                                       rt_timing_sum[stats->index],
-                                       (total != 0.0) ? rt_timing_sum[stats->index] / total * 100.0 : 0.0,
-                                       stats->name);
-               }
-               else {
-                       fprintf(file,"%12lld usec      %s\n",
-                                       rt_timing_sum[stats->index],
-                                       stats->name);
-               }
-       }
-}
-
-/*
- * 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/vmcore/rt-timing.h b/src/vmcore/rt-timing.h
deleted file mode 100644 (file)
index d78e8c9..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/* src/vmcore/rt-timing.h - POSIX real-time timing utilities
-
-   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
-
-   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 _RT_TIMING_H
-#define _RT_TIMING_H
-
-#include "config.h"
-
-#if defined(ENABLE_RT_TIMING)
-
-#include <time.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "vm/global.h"
-
-
-#define RT_TIMING_GET_TIME(ts) \
-       rt_timing_gettime(&(ts));
-
-#define RT_TIMING_TIME_DIFF(a,b,index) \
-       rt_timing_time_diff(&(a),&(b),(index));
-
-#define RT_TIMING_JIT_CHECKS       0
-#define RT_TIMING_JIT_PARSE        1
-#define RT_TIMING_JIT_STACK        2
-#define RT_TIMING_JIT_TYPECHECK    3
-#define RT_TIMING_JIT_LOOP         4
-#define RT_TIMING_JIT_IFCONV       5
-#define RT_TIMING_JIT_ALLOC        6
-#define RT_TIMING_JIT_RPLPOINTS    7
-#define RT_TIMING_JIT_CODEGEN      8
-#define RT_TIMING_JIT_TOTAL        9
-
-#define RT_TIMING_LINK_RESOLVE     10
-#define RT_TIMING_LINK_C_VFTBL     11
-#define RT_TIMING_LINK_ABSTRACT    12
-#define RT_TIMING_LINK_C_IFTBL     13
-#define RT_TIMING_LINK_F_VFTBL     14
-#define RT_TIMING_LINK_OFFSETS     15
-#define RT_TIMING_LINK_F_IFTBL     16
-#define RT_TIMING_LINK_FINALIZER   17
-#define RT_TIMING_LINK_EXCEPTS     18
-#define RT_TIMING_LINK_SUBCLASS    19
-#define RT_TIMING_LINK_TOTAL       20
-
-#define RT_TIMING_LOAD_CHECKS      21
-#define RT_TIMING_LOAD_NDPOOL      22
-#define RT_TIMING_LOAD_CPOOL       23
-#define RT_TIMING_LOAD_SETUP       24
-#define RT_TIMING_LOAD_FIELDS      25
-#define RT_TIMING_LOAD_METHODS     26
-#define RT_TIMING_LOAD_CLASSREFS   27
-#define RT_TIMING_LOAD_DESCS       28
-#define RT_TIMING_LOAD_SETREFS     29
-#define RT_TIMING_LOAD_PARSEFDS    30
-#define RT_TIMING_LOAD_PARSEMDS    31
-#define RT_TIMING_LOAD_PARSECP     32
-#define RT_TIMING_LOAD_VERIFY      33
-#define RT_TIMING_LOAD_ATTRS       34
-#define RT_TIMING_LOAD_TOTAL       35
-
-#define RT_TIMING_LOAD_BOOT_LOOKUP 36
-#define RT_TIMING_LOAD_BOOT_ARRAY  37
-#define RT_TIMING_LOAD_BOOT_SUCK   38
-#define RT_TIMING_LOAD_BOOT_LOAD   39
-#define RT_TIMING_LOAD_BOOT_CACHE  40
-#define RT_TIMING_LOAD_BOOT_TOTAL  41
-
-#define RT_TIMING_LOAD_CL_LOOKUP   42
-#define RT_TIMING_LOAD_CL_PREPARE  43
-#define RT_TIMING_LOAD_CL_JAVA     44
-#define RT_TIMING_LOAD_CL_CACHE    45
-
-#define RT_TIMING_NEW_OBJECT       46
-#define RT_TIMING_NEW_ARRAY        47
-
-#define RT_TIMING_GC_ALLOC         48
-#define RT_TIMING_GC_SUSPEND       49
-#define RT_TIMING_GC_ROOTSET1      50
-#define RT_TIMING_GC_MARK          51
-#define RT_TIMING_GC_COMPACT       52
-#define RT_TIMING_GC_ROOTSET2      53
-#define RT_TIMING_GC_TOTAL         54
-
-#define RT_TIMING_N                55
-
-void rt_timing_gettime(struct timespec *ts);
-
-void rt_timing_time_diff(struct timespec *a,struct timespec *b,int index);
-
-long rt_timing_diff_usec(struct timespec *a,struct timespec *b);
-
-void rt_timing_print_time_stats(FILE *file);
-
-#else /* !defined(ENABLE_RT_TIMING) */
-
-#define RT_TIMING_GET_TIME(ts)
-#define RT_TIMING_TIME_DIFF(a,b,index)
-
-#endif /* defined(ENABLE_RT_TIMING) */
-
-#endif /* _RT_TIMING_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/vmcore/stackmap.c b/src/vmcore/stackmap.c
deleted file mode 100644 (file)
index 40ee97e..0000000
+++ /dev/null
@@ -1,520 +0,0 @@
-/* src/vmcore/stackmap.c - class attribute StackMapTable
-
-   Copyright (C) 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 "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "vm/exceptions.h"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-#include "vmcore/stackmap.h"
-#include "vmcore/statistics.h"
-#include "vmcore/suck.h"
-
-
-/* stackmap_get_verification_type_info *****************************************
-
-   union verification_type_info {
-       Top_variable_info;
-          Integer_variable_info;
-          Float_variable_info;
-          Long_variable_info;
-          Double_variable_info;
-          Null_variable_info;
-          UninitializedThis_variable_info;
-          Object_variable_info;
-          Uninitialized_variable_info;
-   }
-
-   Top_variable_info {
-       u1 tag = ITEM_Top;  // 0
-   }
-
-   Integer_variable_info {
-       u1 tag = ITEM_Integer;  // 1
-   }
-
-   Float_variable_info {
-       u1 tag = ITEM_Float;  // 2
-   }
-
-   Long_variable_info {
-       u1 tag = ITEM_Long;  // 4
-   }
-
-   Double_variable_info {
-       u1 tag = ITEM_Double;  // 3
-   }
-
-   Null_variable_info {
-       u1 tag = ITEM_Null;  // 5
-   }
-
-   UninitializedThis_variable_info {
-       u1 tag = ITEM_UninitializedThis;  // 6
-   }
-
-   Object_variable_info {
-       u1 tag = ITEM_Object;  // 7
-          u2 cpool_index;
-   }
-
-   Uninitialized_variable_info {
-       u1 tag = ITEM_Uninitialized;  // 8
-          u2 offset;
-   }
-
-*******************************************************************************/
-
-static bool stackmap_get_verification_type_info(classbuffer *cb, verification_type_info_t *verification_type_info)
-{
-       /* get verification type */
-
-       if (!suck_check_classbuffer_size(cb, 1))
-               return false;
-
-       verification_type_info->tag = suck_u1(cb);
-
-       /* process the tag */
-
-       switch (verification_type_info->tag) {
-       case ITEM_Top:
-       case ITEM_Integer:
-       case ITEM_Float:
-       case ITEM_Long:
-       case ITEM_Double:
-       case ITEM_Null:
-       case ITEM_UninitializedThis:
-               break;
-
-       case ITEM_Object:
-               /* get constant pool index */
-
-               if (!suck_check_classbuffer_size(cb, 2))
-                       return false;
-
-               verification_type_info->Object_variable_info.cpool_index = suck_u2(cb);
-               break;
-
-       case ITEM_Uninitialized:
-               /* get offset */
-
-               if (!suck_check_classbuffer_size(cb, 2))
-                       return false;
-
-               verification_type_info->Uninitialized_variable_info.offset = suck_u2(cb);
-               break;
-       }
-
-       return true;
-}
-
-
-/* stackmap_get_same_locals_1_stack_item_frame *********************************
-
-   same_locals_1_stack_item_frame {
-       u1 frame_type = SAME_LOCALS_1_STACK_ITEM;  // 64-127
-          verification_type_info stack[1];
-   }
-
-*******************************************************************************/
-
-static bool stackmap_get_same_locals_1_stack_item_frame(classbuffer *cb, stack_map_frame_t *stack_map_frame)
-{
-       same_locals_1_stack_item_frame_t *same_locals_1_stack_item_frame;
-
-       /* for convenience */
-
-       same_locals_1_stack_item_frame =
-               &(stack_map_frame->same_locals_1_stack_item_frame);
-
-       if (!stackmap_get_verification_type_info(cb, &(same_locals_1_stack_item_frame->stack[0])))
-               return false;
-
-       return true;
-}
-
-
-/* stackmap_get_same_locals_1_stack_item_frame_extended ************************
-
-   same_locals_1_stack_item_frame_extended {
-       u1 frame_type = SAME_LOCALS_1_STACK_ITEM_EXTENDED;  // 247
-          u2 offset_delta;
-          verification_type_info stack[1];
-   }
-
-*******************************************************************************/
-
-static bool stackmap_get_same_locals_1_stack_item_frame_extended(classbuffer *cb, stack_map_frame_t *stack_map_frame)
-{
-       same_locals_1_stack_item_frame_extended_t *same_locals_1_stack_item_frame_extended;
-
-       /* for convenience */
-
-       same_locals_1_stack_item_frame_extended =
-               &(stack_map_frame->same_locals_1_stack_item_frame_extended);
-
-       /* check buffer size */
-
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       /* get offset delta */
-
-       same_locals_1_stack_item_frame_extended->offset_delta = suck_u2(cb);
-
-       /* process stack */
-
-       if (!stackmap_get_verification_type_info(cb, &(same_locals_1_stack_item_frame_extended->stack[0])))
-               return false;
-
-       return true;
-}
-
-
-/* stackmap_get_chop_frame *****************************************************
-
-   chop_frame {
-       u1 frame_type = CHOP_FRAME;  // 248-250
-          u2 offset_delta;
-   }
-
-*******************************************************************************/
-
-static bool stackmap_get_chop_frame(classbuffer *cb,
-                                                                       stack_map_frame_t *stack_map_frame)
-{
-       chop_frame_t *chop_frame;
-
-       /* for convenience */
-
-       chop_frame = &(stack_map_frame->chop_frame);
-
-       /* check buffer size */
-
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       /* get offset delta */
-
-       chop_frame->offset_delta = suck_u2(cb);
-
-       return true;
-}
-
-
-/* stackmap_get_same_frame_extended ********************************************
-
-   same_frame_extended {
-       u1 frame_type = SAME_FRAME_EXTENDED;  // 251
-          u2 offset_delta;
-   }
-
-*******************************************************************************/
-
-static bool stackmap_get_same_frame_extended(classbuffer *cb,
-                                                                                        stack_map_frame_t *stack_map_frame)
-{
-       same_frame_extended_t *same_frame_extended;
-
-       /* for convenience */
-
-       same_frame_extended = &(stack_map_frame->same_frame_extended);
-
-       /* check buffer size */
-
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       /* get offset delta */
-
-       same_frame_extended->offset_delta = suck_u2(cb);
-
-       return true;
-}
-
-
-/* stackmap_get_append_frame ***************************************************
-
-   append_frame {
-       u1 frame_type = APPEND_FRAME;  // 252-254
-          u2 offset_delta;
-          verification_type_info locals[frame_Type - 251];
-   }
-
-*******************************************************************************/
-
-static bool stackmap_get_append_frame(classbuffer *cb,
-                                                                         stack_map_frame_t *stack_map_frame)
-{
-       append_frame_t *append_frame;
-       s4              number_of_locals;
-       s4              i;
-
-       /* for convenience */
-
-       append_frame = &(stack_map_frame->append_frame);
-
-       /* check buffer size */
-
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       /* get offset delta */
-
-       append_frame->offset_delta = suck_u2(cb);
-
-       /* allocate locals array */
-
-       number_of_locals = append_frame->frame_type - 251;
-
-       append_frame->locals = DMNEW(verification_type_info_t, number_of_locals);
-
-       /* process all locals */
-
-       for (i = 0; i < number_of_locals; i++)
-               if (!stackmap_get_verification_type_info(cb, &(append_frame->locals[i])))
-                       return false;
-
-       return true;
-}
-
-
-/* stackmap_get_full_frame *****************************************************
-
-   full_frame {
-       u1 frame_type = FULL_FRAME;
-          u2 offset_delta;
-          u2 number_of_locals;
-          verification_type_info locals[number_of_locals];
-          u2 number_of_stack_items;
-          verification_type_info stack[number_of_stack_items];
-   }
-
-*******************************************************************************/
-
-static bool stackmap_get_full_frame(classbuffer *cb,
-                                                                       stack_map_frame_t *stack_map_frame)
-{
-       full_frame_t *full_frame;
-       s4 i;
-
-       /* for convenience */
-
-       full_frame = &(stack_map_frame->full_frame);
-
-       /* check buffer size */
-
-       if (!suck_check_classbuffer_size(cb, 2 + 2))
-               return false;
-
-       /*  get offset delta */
-
-       stack_map_frame->full_frame.offset_delta = suck_u2(cb);
-
-       /* get number of locals */
-
-       full_frame->number_of_locals = suck_u2(cb);
-
-       /* allocate locals array */
-
-       full_frame->locals =
-               DMNEW(verification_type_info_t, full_frame->number_of_locals);
-
-       /* process all locals */
-
-       for (i = 0; i < full_frame->number_of_locals; i++)
-               if (!stackmap_get_verification_type_info(cb, &(full_frame->locals[i])))
-                       return false;
-
-       /* get number of stack items */
-
-       if (!suck_check_classbuffer_size(cb, 2))
-               return false;
-
-       full_frame->number_of_stack_items = suck_u2(cb);
-
-       /* allocate stack array */
-
-       full_frame->stack =
-               DMNEW(verification_type_info_t, full_frame->number_of_stack_items);
-
-       /* process all stack items */
-
-       for (i = 0; i < full_frame->number_of_stack_items; i++)
-               if (!stackmap_get_verification_type_info(cb, &(full_frame->stack[i])))
-                       return false;
-
-       return true;
-}
-
-
-/* stackmap_load_attribute_stackmaptable ***************************************
-
-   stack_map {
-          u2 attribute_name_index;
-          u4 attribute_length;
-          u2 number_of_entries;
-          stack_map_frame entries[number_of_entries];
-   }
-
-   union stack_map_frame {
-       same_frame;
-          same_locals_1_stack_item_frame;
-          same_locals_1_stack_item_frame_extended;
-          chop_frame;
-          same_frame_extended;
-          append_frame;
-          full_frame;
-   }
-
-   same_frame {
-       u1 frame_type = SAME;  // 0-63
-   }
-
-*******************************************************************************/
-
-bool stackmap_load_attribute_stackmaptable(classbuffer *cb, methodinfo *m)
-{
-       classinfo       *c;
-       stack_map_t     *stack_map;
-       s4               i;
-       u1               frame_type;
-
-       /* get classinfo */
-
-       c = cb->clazz;
-
-       /* allocate stack map structure */
-
-       stack_map = DNEW(stack_map_t);
-
-       STATISTICS(size_stack_map += sizeof(stack_map_t));
-
-       /* check buffer size */
-
-       if (!suck_check_classbuffer_size(cb, 4 + 2))
-               return false;
-
-       /* attribute_length */
-
-       stack_map->attribute_length = suck_u4(cb);
-
-       if (!suck_check_classbuffer_size(cb, stack_map->attribute_length))
-               return false;
-
-       /* get number of entries */
-
-       stack_map->number_of_entries = suck_u2(cb);
-
-       /* process all entries */
-
-       stack_map->entries = DMNEW(stack_map_frame_t, stack_map->number_of_entries);
-
-       for (i = 0; i < stack_map->number_of_entries; i++) {
-               /* get the frame type */
-
-               frame_type = suck_u1(cb);
-
-               stack_map->entries[i].frame_type = frame_type;
-
-               /* process frame */
-
-               if (frame_type <= FRAME_TYPE_SAME) {
-                       /* same_frame */
-               }
-               else if (frame_type <= FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM) {
-                       /* same_locals_1_stack_item_frame */
-
-                       if (!stackmap_get_same_locals_1_stack_item_frame(cb, &(stack_map->entries[i])))
-                               return false;
-               }
-               else if (frame_type <= FRAME_TYPE_RESERVED) {
-                       /* reserved */
-
-                       exceptions_throw_classformaterror(c, "reserved frame type");
-                       return false;
-               }
-               else if (frame_type == FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM_EXTENDED) {
-                       /* same_locals_1_stack_item_frame_extended */
-
-                       if (!stackmap_get_same_locals_1_stack_item_frame_extended(cb, &(stack_map->entries[i])))
-                               return false;
-               }
-               else if (frame_type <= FRAME_TYPE_CHOP) {
-                       /* chop_frame */
-
-                       if (!stackmap_get_chop_frame(cb, &(stack_map->entries[i])))
-                               return false;
-               }
-               else if (frame_type == FRAME_TYPE_SAME_FRAME_EXTENDED) {
-                       /* same_frame_extended */
-
-                       if (!stackmap_get_same_frame_extended(cb, &(stack_map->entries[i])))
-                               return false;
-               }
-               else if (frame_type <= FRAME_TYPE_APPEND) {
-                       /* append_frame */
-
-                       if (!stackmap_get_append_frame(cb, &(stack_map->entries[i])))
-                               return false;
-               }
-               else if (frame_type == FRAME_TYPE_FULL_FRAME) {
-                       /* full_frame */
-
-                       if (!stackmap_get_full_frame(cb, &(stack_map->entries[i])))
-                               return false;
-               }
-       }
-
-       /* store stack map in method structure */
-
-#if 0
-       /* currently not used */
-
-       m->stack_map = stack_map;
-#endif
-
-       return true;
-}
-
-
-/*
- * 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/vmcore/stackmap.h b/src/vmcore/stackmap.h
deleted file mode 100644 (file)
index 973941a..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-/* src/vmcore/stackmap.h - class attribute StackMapTable
-
-   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
-
-   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 _STACKMAP_H
-#define _STACKMAP_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct stack_map_t                       stack_map_t;
-typedef union  stack_map_frame_t                 stack_map_frame_t;
-typedef struct same_locals_1_stack_item_frame_t  same_locals_1_stack_item_frame_t;
-typedef struct same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended_t;
-typedef struct chop_frame_t                      chop_frame_t;
-typedef struct same_frame_extended_t             same_frame_extended_t;
-typedef struct append_frame_t                    append_frame_t;
-typedef struct full_frame_t                      full_frame_t;
-
-typedef union  verification_type_info_t          verification_type_info_t;
-typedef struct Top_variable_info_t                  Top_variable_info_t;
-typedef struct Integer_variable_info_t           Integer_variable_info_t;
-typedef struct Float_variable_info_t             Float_variable_info_t;
-typedef struct Long_variable_info_t              Long_variable_info_t;
-typedef struct Double_variable_info_t            Double_variable_info_t;
-typedef struct Null_variable_info_t              Null_variable_info_t;
-typedef struct UninitializedThis_variable_info_t UninitializedThis_variable_info_t;
-typedef struct Object_variable_info_t            Object_variable_info_t;
-typedef struct Uninitialized_variable_info_t     Uninitialized_variable_info_t;
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-
-
-/* verification_type_info *****************************************************/
-
-#define ITEM_Top                  0
-#define ITEM_Integer              1
-#define ITEM_Float                2
-#define ITEM_Double               3
-#define ITEM_Long                 4
-#define ITEM_Null                 5
-#define ITEM_UninitializedThis    6
-#define ITEM_Object               7
-#define ITEM_Uninitialized        8
-
-struct Top_variable_info_t {
-       u1 tag;
-};
-
-struct Integer_variable_info_t {
-       u1 tag;
-};
-
-struct Float_variable_info_t {
-       u1 tag;
-};
-
-struct Long_variable_info_t {
-       u1 tag;
-};
-
-struct Double_variable_info_t {
-       u1 tag;
-};
-
-struct Null_variable_info_t {
-       u1 tag;
-};
-
-struct UninitializedThis_variable_info_t {
-       u1 tag;
-};
-
-struct Object_variable_info_t {
-       u1 tag;
-       u2 cpool_index;
-};
-
-struct Uninitialized_variable_info_t {
-       u1 tag;
-       u2 offset;
-};
-
-union verification_type_info_t {
-       u1 tag;
-       Top_variable_info_t                   Top_variable_info;
-       Integer_variable_info_t           Integer_variable_info;
-       Float_variable_info_t             Float_variable_info;
-       Long_variable_info_t              Long_variable_info;
-       Double_variable_info_t            Double_variable_info;
-       Null_variable_info_t              Null_variable_info;
-       UninitializedThis_variable_info_t UninitializedThis_variable_info;
-       Object_variable_info_t            Object_variable_info;
-       Uninitialized_variable_info_t     Uninitialized_variable_info;
-};
-
-
-/* stack_map_t ****************************************************************/
-
-struct stack_map_t {
-       u2                 attribute_name_index;
-       u4                 attribute_length;
-       u2                 number_of_entries;
-       stack_map_frame_t *entries;
-};
-
-
-/* same_locals_1_stack_item_frame_t *******************************************/
-
-struct same_locals_1_stack_item_frame_t {
-       u1                       frame_type;
-       verification_type_info_t stack[1];
-};
-
-
-/* same_locals_1_stack_item_frame_extended_t **********************************/
-
-struct same_locals_1_stack_item_frame_extended_t {
-       u1                       frame_type;
-       u2                       offset_delta;
-       verification_type_info_t stack[1];
-};
-
-
-/* chop_frame_t ***************************************************************/
-
-struct chop_frame_t {
-       u1 frame_type;
-       u2 offset_delta;
-};
-
-
-/* same_frame_extended_t ******************************************************/
-
-struct same_frame_extended_t {
-       u1 frame_type;
-       u2 offset_delta;
-};
-
-
-/* append_frame_t *************************************************************/
-
-struct append_frame_t {
-       u1                        frame_type;
-       u2                        offset_delta;
-       verification_type_info_t *locals;
-};
-
-
-/* full_frame_t ***************************************************************/
-
-struct full_frame_t {
-       u1                        frame_type;
-       u2                        offset_delta;
-       u2                        number_of_locals;
-       verification_type_info_t *locals;
-       u2                        number_of_stack_items;
-       verification_type_info_t *stack;
-};
-
-
-/* stack_map_frame_t **********************************************************/
-
-#define FRAME_TYPE_SAME                                 63   /* 0-63          */
-#define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM             127  /* 0-127         */
-#define FRAME_TYPE_RESERVED                             246  /* 128-246       */
-#define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM_EXTENDED    247  /* 247           */
-#define FRAME_TYPE_CHOP                                 250  /* 248-250       */
-#define FRAME_TYPE_SAME_FRAME_EXTENDED                  251  /* 251           */
-#define FRAME_TYPE_APPEND                               254  /* 252-254       */
-#define FRAME_TYPE_FULL_FRAME                           255  /* 255           */
-
-union stack_map_frame_t {
-       u1                                        frame_type;
-       same_locals_1_stack_item_frame_t          same_locals_1_stack_item_frame;
-       same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended;
-       chop_frame_t                              chop_frame;
-       same_frame_extended_t                     same_frame_extended;
-       append_frame_t                            append_frame;
-       full_frame_t                              full_frame;
-};
-
-
-/* function prototypes ********************************************************/
-
-bool stackmap_load_attribute_stackmaptable(classbuffer *cb, methodinfo *m);
-
-#endif /* _STACKMAP_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/vmcore/statistics.c b/src/vmcore/statistics.c
deleted file mode 100644 (file)
index 99781e8..0000000
+++ /dev/null
@@ -1,821 +0,0 @@
-/* src/vmcore/statistics.c - global varables for statistics
-
-   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
-
-   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 <stdint.h>
-#include <string.h> 
-
-#if defined(HAVE_TIME_H)
-# include <time.h>
-#endif
-
-#if defined(HAVE_SYS_TIME_H)
-# include <sys/time.h>
-#endif
-
-#if defined(HAVE_SYS_RESOURCE_H)
-# include <sys/resource.h>
-#endif
-
-#include "vm/types.h"
-
-#include "mm/gc-common.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/global.h"
-
-#include "vm/jit/code.h"
-
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-
-
-/* global variables ***********************************************************/
-
-static s8 loadingtime = 0;              /* accumulated loading time           */
-static s8 loadingstarttime = 0;
-static s8 loadingstoptime = 0;
-static s4 loadingtime_recursion = 0;
-
-static s8 compilingtime = 0;            /* accumulated compile time           */
-static s8 compilingstarttime = 0;
-static s8 compilingstoptime = 0;
-static s4 compilingtime_recursion = 0;
-
-s4 codememusage = 0;
-s4 maxcodememusage = 0;
-
-s4 memoryusage = 0;
-s4 maxmemusage = 0;
-
-s4 maxdumpsize = 0;
-
-s4 globalallocateddumpsize = 0;
-s4 globaluseddumpsize = 0;
-
-
-/* variables for measurements *************************************************/
-
-s4 size_classinfo        = 0;
-s4 size_fieldinfo        = 0;
-s4 size_methodinfo       = 0;
-s4 size_lineinfo         = 0;
-s4 size_codeinfo         = 0;
-
-s4 size_stub_native      = 0;
-
-s4 size_stack_map        = 0;
-s4 size_string           = 0;
-
-s4 size_threadobject     = 0;
-int32_t size_thread_index_t = 0;
-int32_t size_stacksize      = 0;
-
-s4 size_lock_record      = 0;
-s4 size_lock_hashtable   = 0;
-s4 size_lock_waiter      = 0;
-
-int32_t count_linenumbertable = 0;
-int32_t size_linenumbertable  = 0;
-
-s4 size_patchref         = 0;
-
-u8 count_calls_java_to_native = 0;
-u8 count_calls_native_to_java = 0;
-
-int count_const_pool_len = 0;
-int count_classref_len = 0;
-int count_parsed_desc_len = 0;
-int count_vftbl_len = 0;
-int count_all_methods = 0;
-int count_methods_marked_used = 0;  /* RTA */
-
-int count_vmcode_len = 0;
-int count_extable_len = 0;
-int count_class_loads = 0;
-int count_class_inits = 0;
-
-int count_utf_len = 0;                  /* size of utf hash                   */
-int count_utf_new = 0;                  /* calls of utf_new                   */
-int count_utf_new_found  = 0;           /* calls of utf_new with fast return  */
-
-int count_locals_conflicts = 0;         /* register allocator statistics */
-int count_locals_spilled = 0;
-int count_locals_register = 0;
-int count_ss_spilled = 0;
-int count_ss_register = 0;
-int count_methods_allocated_by_lsra = 0;
-int count_mem_move_bb = 0;
-int count_interface_size = 0;
-int count_argument_mem_ss = 0;
-int count_argument_reg_ss = 0;
-int count_method_in_register = 0;
-int count_mov_reg_reg = 0;
-int count_mov_mem_reg = 0;
-int count_mov_reg_mem = 0;
-int count_mov_mem_mem = 0;
-
-int count_jit_calls = 0;
-int count_methods = 0;
-int count_spills_read_ila = 0;
-int count_spills_read_flt = 0;
-int count_spills_read_dbl = 0;
-int count_spills_write_ila = 0;
-int count_spills_write_flt = 0;
-int count_spills_write_dbl = 0;
-int count_pcmd_activ = 0;
-int count_pcmd_drop = 0;
-int count_pcmd_zero = 0;
-int count_pcmd_const_store = 0;
-int count_pcmd_const_alu = 0;
-int count_pcmd_const_bra = 0;
-int count_pcmd_load = 0;
-int count_pcmd_move = 0;
-int count_load_instruction = 0;
-int count_pcmd_store = 0;
-int count_pcmd_store_comb = 0;
-int count_dup_instruction = 0;
-int count_pcmd_op = 0;
-int count_pcmd_mem = 0;
-int count_pcmd_met = 0;
-int count_pcmd_bra = 0;
-int count_pcmd_table = 0;
-int count_pcmd_return = 0;
-int count_pcmd_returnx = 0;
-int count_check_null = 0;
-int count_check_bound = 0;
-int count_max_basic_blocks = 0;
-int count_basic_blocks = 0;
-int count_javainstr = 0;
-int count_max_javainstr = 0;
-int count_javacodesize = 0;
-int count_javaexcsize = 0;
-int count_calls = 0;
-int count_tryblocks = 0;
-int count_code_len = 0;
-int count_data_len = 0;
-int count_cstub_len = 0;
-int count_max_new_stack = 0;
-int count_upper_bound_new_stack = 0;
-
-int count_emit_branch = 0;
-int count_emit_branch_8bit = 0;
-int count_emit_branch_16bit = 0;
-int count_emit_branch_32bit = 0;
-int count_emit_branch_64bit = 0;
-
-s4 count_branches_resolved   = 0;
-s4 count_branches_unresolved = 0;
-
-u8 count_jni_callXmethod_calls=0;
-u8 count_jni_calls=0;
-
-
-static int count_block_stack_init[11] = {
-       0, 0, 0, 0, 0, 
-       0, 0, 0, 0, 0, 
-       0
-};
-int *count_block_stack = count_block_stack_init;
-static int count_analyse_iterations_init[5] = {
-       0, 0, 0, 0, 0
-};
-int *count_analyse_iterations = count_analyse_iterations_init;
-static int count_method_bb_distribution_init[9] = {
-       0, 0, 0, 0, 0,
-       0, 0, 0, 0
-};
-int *count_method_bb_distribution = count_method_bb_distribution_init;
-static int count_block_size_distribution_init[18] = {
-       0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0,
-       0, 0, 0
-};
-int *count_block_size_distribution = count_block_size_distribution_init;
-static int count_store_length_init[21] = {
-       0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0,
-       0
-};
-int *count_store_length = count_store_length_init;
-static int count_store_depth_init[11] = {
-       0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0,
-       0
-};
-int *count_store_depth = count_store_depth_init;
-
-
-/* instruction scheduler statistics *******************************************/
-
-s4 count_schedule_basic_blocks = 0;
-s4 count_schedule_nodes = 0;
-s4 count_schedule_leaders = 0;
-s4 count_schedule_max_leaders = 0;
-s4 count_schedule_critical_path = 0;
-
-
-/* jnicallXmethodinvokation ***************************************************
-
-   increments the jni CallXMethod invokation count by one
-       
-*******************************************************************************/
-
-void jnicallXmethodnvokation(void)
-{
-       /* XXX do locking here */
-       count_jni_callXmethod_calls++;
-}
-
-
-/* jniinvokation *************************************************************
-
-   increments the jni overall  invokation count by one
-       
-*******************************************************************************/
-
-void jniinvokation(void)
-{
-       /* XXX do locking here */
-       count_jni_calls++;
-}
-
-
-/* getcputime *********************************** ******************************
-
-   Returns the used CPU time in microseconds
-       
-*******************************************************************************/
-
-s8 getcputime(void)
-{
-#if defined(HAVE_GETRUSAGE)
-       struct rusage ru;
-       int sec, usec;
-
-       getrusage(RUSAGE_SELF, &ru);
-
-       sec  = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec;
-       usec = ru.ru_utime.tv_usec + ru.ru_stime.tv_usec;
-
-       return sec * 1000000 + usec;
-#else
-       /* If we don't have getrusage, simply return 0. */
-
-       return 0;
-#endif
-}
-
-
-/* loadingtime_stop ************************************************************
-
-   XXX
-
-*******************************************************************************/
-
-void loadingtime_start(void)
-{
-       loadingtime_recursion++;
-
-       if (loadingtime_recursion == 1)
-               loadingstarttime = getcputime();
-}
-
-
-/* loadingtime_stop ************************************************************
-
-   XXX
-
-*******************************************************************************/
-
-void loadingtime_stop(void)
-{
-       if (loadingtime_recursion == 1) {
-               loadingstoptime = getcputime();
-               loadingtime += (loadingstoptime - loadingstarttime);
-       }
-
-       loadingtime_recursion--;
-}
-
-
-/* compilingtime_stop **********************************************************
-
-   XXX
-
-*******************************************************************************/
-
-void compilingtime_start(void)
-{
-       compilingtime_recursion++;
-
-       if (compilingtime_recursion == 1)
-               compilingstarttime = getcputime();
-}
-
-
-/* compilingtime_stop **********************************************************
-
-   XXX
-
-*******************************************************************************/
-
-void compilingtime_stop(void)
-{
-       if (compilingtime_recursion == 1) {
-               compilingstoptime = getcputime();
-               compilingtime += (compilingstoptime - compilingstarttime);
-       }
-
-       compilingtime_recursion--;
-}
-
-
-/* print_times *****************************************************************
-
-   Prints a summary of CPU time usage.
-
-*******************************************************************************/
-
-void print_times(void)
-{
-       s8 totaltime;
-       s8 runtime;
-
-       totaltime = getcputime();
-       runtime = totaltime - loadingtime - compilingtime;
-
-#if SIZEOF_VOID_P == 8
-       dolog("Time for loading classes: %6ld ms", loadingtime / 1000);
-       dolog("Time for compiling code:  %6ld ms", compilingtime / 1000);
-       dolog("Time for running program: %6ld ms", runtime / 1000);
-       dolog("Total time:               %6ld ms", totaltime / 1000);
-#else
-       dolog("Time for loading classes: %6lld ms", loadingtime / 1000);
-       dolog("Time for compiling code:  %6lld ms", compilingtime / 1000);
-       dolog("Time for running program: %6lld ms", runtime / 1000);
-       dolog("Total time:               %6lld ms", totaltime / 1000);
-#endif
-}
-
-
-/* print_stats *****************************************************************
-
-   outputs detailed compiler statistics
-
-*******************************************************************************/
-
-void print_stats(void)
-{
-       s4    i;
-       float f;
-       s4    sum;
-
-
-       dolog("Number of JIT compiler calls: %6d", count_jit_calls);
-       dolog("Number of compiled methods:   %6d", count_methods);
-
-       dolog("Number of compiled basic blocks:               %6d",
-                 count_basic_blocks);
-       dolog("Number of max. basic blocks per method:        %6d",
-                 count_max_basic_blocks);
-
-       dolog("Number of compiled JavaVM instructions:        %6d",
-                 count_javainstr);
-       dolog("Number of max. JavaVM instructions per method: %6d",
-                 count_max_javainstr);
-       dolog("Size of compiled JavaVM instructions:          %6d(%d)",
-                 count_javacodesize, count_javacodesize - count_methods * 18);
-
-       dolog("Size of compiled Exception Tables:      %d", count_javaexcsize);
-       dolog("Number of Machine-Instructions: %d", count_code_len >> 2);
-       dolog("Number of Spills (write to memory) <all [i/l/a|flt|dbl]>: %d [%d|%d|%d]",
-               count_spills_write_ila + count_spills_write_flt + count_spills_write_dbl,
-               count_spills_write_ila, count_spills_write_flt, count_spills_write_dbl);
-       dolog("Number of Spills (read from memory) <all [i/l/a|flt|dbl]>: %d [%d|%d|%d]",
-               count_spills_read_ila + count_spills_read_flt + count_spills_read_dbl,
-               count_spills_read_ila, count_spills_read_flt, count_spills_read_dbl);
-       dolog("Number of Activ    Pseudocommands: %6d", count_pcmd_activ);
-       dolog("Number of Drop     Pseudocommands: %6d", count_pcmd_drop);
-       dolog("Number of Const    Pseudocommands: %6d (zero:%5d)",
-                 count_pcmd_load, count_pcmd_zero);
-       dolog("Number of ConstAlu Pseudocommands: %6d (cmp: %5d, store:%5d)",
-                 count_pcmd_const_alu, count_pcmd_const_bra, count_pcmd_const_store);
-       dolog("Number of Move     Pseudocommands: %6d", count_pcmd_move);
-       dolog("Number of Load     Pseudocommands: %6d", count_load_instruction);
-       dolog("Number of Store    Pseudocommands: %6d (combined: %5d)",
-                 count_pcmd_store, count_pcmd_store - count_pcmd_store_comb);
-       dolog("Number of OP       Pseudocommands: %6d", count_pcmd_op);
-       dolog("Number of DUP      Pseudocommands: %6d", count_dup_instruction);
-       dolog("Number of Mem      Pseudocommands: %6d", count_pcmd_mem);
-       dolog("Number of Method   Pseudocommands: %6d", count_pcmd_met);
-       dolog("Number of Branch   Pseudocommands: %6d (rets:%5d, Xrets: %5d)",
-                 count_pcmd_bra, count_pcmd_return, count_pcmd_returnx);
-       log_println("                resolved branches: %6d", count_branches_resolved);
-       log_println("              unresolved branches: %6d", count_branches_unresolved);
-       dolog("Number of Table    Pseudocommands: %6d", count_pcmd_table);
-       dolog("Number of Useful   Pseudocommands: %6d", count_pcmd_table +
-                 count_pcmd_bra + count_pcmd_load + count_pcmd_mem + count_pcmd_op);
-       dolog("Number of Null Pointer Checks:     %6d", count_check_null);
-       dolog("Number of Array Bound Checks:      %6d", count_check_bound);
-       dolog("Number of Try-Blocks: %d", count_tryblocks);
-
-       dolog("Number of branch_emit (total, 8bit/16bit/32bit/64bit offset): %d, %d/%d/%d/%d",
-               count_emit_branch,  count_emit_branch_8bit,  count_emit_branch_16bit, 
-                                                       count_emit_branch_32bit, count_emit_branch_64bit);
-
-       dolog("Maximal count of stack elements:   %d", count_max_new_stack);
-       dolog("Upper bound of max stack elements: %d", count_upper_bound_new_stack);
-       dolog("Distribution of stack sizes at block boundary");
-       dolog("     0     1     2     3     4     5     6     7     8     9  >=10");
-       dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
-                 count_block_stack[0], count_block_stack[1], count_block_stack[2],
-                 count_block_stack[3], count_block_stack[4], count_block_stack[5],
-                 count_block_stack[6], count_block_stack[7], count_block_stack[8],
-                 count_block_stack[9], count_block_stack[10]);
-       dolog("Distribution of store stack depth");
-       dolog("     0     1     2     3     4     5     6     7     8     9  >=10");
-       dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
-                 count_store_depth[0], count_store_depth[1], count_store_depth[2],
-                 count_store_depth[3], count_store_depth[4], count_store_depth[5],
-                 count_store_depth[6], count_store_depth[7], count_store_depth[8],
-                 count_store_depth[9], count_store_depth[10]);
-       dolog("Distribution of store creator chains first part");
-       dolog("     0     1     2     3     4     5     6     7     8     9");
-       dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
-                 count_store_length[0], count_store_length[1], count_store_length[2],
-                 count_store_length[3], count_store_length[4], count_store_length[5],
-                 count_store_length[6], count_store_length[7], count_store_length[8],
-                 count_store_length[9]);
-       dolog("Distribution of store creator chains second part");
-       dolog("    10    11    12    13    14    15    16    17    18    19  >=20");
-       dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
-                 count_store_length[10], count_store_length[11],
-                 count_store_length[12], count_store_length[13],
-                 count_store_length[14], count_store_length[15],
-                 count_store_length[16], count_store_length[17],
-                 count_store_length[18], count_store_length[19],
-                 count_store_length[20]);
-       dolog("Distribution of analysis iterations");
-       dolog("     1     2     3     4   >=5");
-       dolog("%6d%6d%6d%6d%6d",
-                 count_analyse_iterations[0], count_analyse_iterations[1],
-                 count_analyse_iterations[2], count_analyse_iterations[3],
-                 count_analyse_iterations[4]);
-
-
-       /* Distribution of basic blocks per method ********************************/
-
-       log_println("Distribution of basic blocks per method:");
-       log_println("   <=5  <=10  <=15  <=20  <=30  <=40  <=50  <=75   >75");
-
-       log_start();
-       for (i = 0; i <= 8; i++)
-               log_print("%6d", count_method_bb_distribution[i]);
-       log_finish();
-
-       /* print ratio */
-
-       f = (float) count_methods;
-
-       log_start();
-       for (i = 0; i <= 8; i++)
-               log_print("%6.2f", (float) count_method_bb_distribution[i] / f);
-       log_finish();
-
-       /* print cumulated ratio */
-
-       log_start();
-       for (i = 0, sum = 0; i <= 8; i++) {
-               sum += count_method_bb_distribution[i];
-               log_print("%6.2f", (float) sum / f);
-       }
-       log_finish();
-
-
-       /* Distribution of basic block sizes **************************************/
-
-       log_println("Distribution of basic block sizes:");
-       log_println("     0     1     2     3     4     5     6     7     8     9   <13   <15   <17   <19   <21   <26   <31   >30");
-
-       /* print block sizes */
-
-       log_start();
-       for (i = 0; i <= 17; i++)
-               log_print("%6d", count_block_size_distribution[i]);
-       log_finish();
-
-       /* print ratio */
-
-       f = (float) count_basic_blocks;
-
-       log_start();
-       for (i = 0; i <= 17; i++)
-               log_print("%6.2f", (float) count_block_size_distribution[i] / f);
-       log_finish();
-
-       /* print cumulated ratio */
-
-       log_start();
-       for (i = 0, sum = 0; i <= 17; i++) {
-               sum += count_block_size_distribution[i];
-               log_print("%6.2f", (float) sum / f);
-       }
-       log_finish();
-
-       statistics_print_memory_usage();
-
-       dolog("Number of class loads:    %6d", count_class_loads);
-       dolog("Number of class inits:    %6d", count_class_inits);
-       dolog("Number of loaded Methods: %6d\n", count_all_methods);
-
-       dolog("Calls of utf_new:                 %6d", count_utf_new);
-       dolog("Calls of utf_new (element found): %6d\n", count_utf_new_found);
-
-
-       /* LSRA statistics ********************************************************/
-
-       dolog("Moves reg -> reg:     %6d", count_mov_reg_reg);
-       dolog("Moves mem -> reg:     %6d", count_mov_mem_reg);
-       dolog("Moves reg -> mem:     %6d", count_mov_reg_mem);
-       dolog("Moves mem -> mem:     %6d", count_mov_mem_mem);
-
-       dolog("Methods allocated by LSRA:         %6d",
-                 count_methods_allocated_by_lsra);
-       dolog("Conflicts between local Variables: %6d", count_locals_conflicts);
-       dolog("Local Variables held in Memory:    %6d", count_locals_spilled);
-       dolog("Local Variables held in Registers: %6d", count_locals_register);
-       dolog("Stackslots held in Memory:         %6d", count_ss_spilled);
-       dolog("Stackslots held in Registers:      %6d", count_ss_register);
-       dolog("Memory moves at BB Boundaries:     %6d", count_mem_move_bb);
-       dolog("Number of interface slots:         %6d\n", count_interface_size);
-       dolog("Number of Argument stack slots in register:  %6d",
-                 count_argument_reg_ss);
-       dolog("Number of Argument stack slots in memory:    %6d\n",
-                 count_argument_mem_ss);
-       dolog("Number of Methods kept in registers:         %6d\n",
-                 count_method_in_register);
-
-
-       /* instruction scheduler statistics ***************************************/
-
-#if defined(USE_SCHEDULER)
-       dolog("Instruction scheduler statistics:");
-       dolog("Number of basic blocks:       %7d", count_schedule_basic_blocks);
-       dolog("Number of nodes:              %7d", count_schedule_nodes);
-       dolog("Number of leaders nodes:      %7d", count_schedule_leaders);
-       dolog("Number of max. leaders nodes: %7d", count_schedule_max_leaders);
-       dolog("Length of critical path:      %7d\n", count_schedule_critical_path);
-#endif
-
-
-       /* call statistics ********************************************************/
-
-       dolog("Function call statistics:");
-       dolog("Number of jni->CallXMethod function invokations: %ld",
-                 count_jni_callXmethod_calls);
-       dolog("Overall number of jni invokations:               %ld",
-                 count_jni_calls);
-
-       log_println("java-to-native calls:   %10ld", count_calls_java_to_native);
-       log_println("native-to-java calls:   %10ld", count_calls_native_to_java);
-
-
-       /* now print other statistics ********************************************/
-
-#if defined(ENABLE_INTRP)
-       print_dynamic_super_statistics();
-#endif
-}
-
-
-/* statistics_print_date *******************************************************
-
-   Print current date and time.
-
-*******************************************************************************/
-
-void statistics_print_date(void)
-{
-  time_t t;
-  struct tm tm;
-
-#if defined(HAVE_TIME)
-  time(&t);
-#else
-# error !HAVE_TIME
-#endif
-
-#if defined(HAVE_LOCALTIME_R)
-  localtime_r(&t, &tm);
-#else
-# error !HAVE_LOCALTIME_R
-#endif
-
-  log_println("%d-%02d-%02d %02d:%02d:%02d",
-                         1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday,
-                         tm.tm_hour, tm.tm_min, tm.tm_sec);
-}
-
-
-/* statistics_print_memory_usage ***********************************************
-
-   Print current memory usage.
-
-*******************************************************************************/
-
-void statistics_print_memory_usage(void)
-{
-       s4 sum;
-
-       log_println("memory usage ----------------------");
-       log_println("");
-       log_println("code:                      %10d", count_code_len);
-       log_println("data:                      %10d", count_data_len);
-       log_println("                            ----------");
-
-       sum =
-               count_code_len +
-               count_data_len;
-
-       log_println("                           %10d", sum);
-
-       log_println("");
-
-       log_println("classinfo  (%3d B):        %10d", (int) sizeof(classinfo), size_classinfo);
-       log_println("fieldinfo  (%3d B):        %10d", (int) sizeof(fieldinfo), size_fieldinfo);
-       log_println("methodinfo (%3d B):        %10d", (int) sizeof(methodinfo), size_methodinfo);
-       log_println("lineinfo   (%3d B):        %10d", (int) sizeof(lineinfo), size_lineinfo);
-       log_println("codeinfo   (%3d B):        %10d", (int) sizeof(codeinfo), size_codeinfo);
-       log_println("                            ----------");
-
-       sum =
-               size_classinfo +
-               size_fieldinfo +
-               size_methodinfo +
-               size_lineinfo +
-               size_codeinfo;
-
-       log_println("                           %10d", sum);
-
-       log_println("");
-
-       log_println("linenumber tables (%5d): %10d", count_linenumbertable, size_linenumbertable);
-       log_println("exception tables:          %10d", count_extable_len);
-       log_println("patcher references:        %10d", size_patchref);
-       log_println("                            ----------");
-
-       sum =
-               size_linenumbertable +
-               count_extable_len +
-               size_patchref;
-
-       log_println("                           %10d", sum);
-
-       log_println("");
-
-       log_println("constant pool:             %10d", count_const_pool_len);
-       log_println("classref:                  %10d", count_classref_len);
-       log_println("parsed descriptors:        %10d", count_parsed_desc_len);
-       log_println("vftbl:                     %10d", count_vftbl_len);
-       log_println("compiler stubs:            %10d", count_cstub_len);
-       log_println("native stubs:              %10d", size_stub_native);
-       log_println("utf:                       %10d", count_utf_len);
-       log_println("vmcode:                    %10d", count_vmcode_len);
-       log_println("stack map:                 %10d", size_stack_map);
-       log_println("string:                    %10d", size_string);
-       log_println("threadobject:              %10d", size_threadobject);
-       log_println("thread index:              %10d", size_thread_index_t);
-       log_println("stack size:                %10d", size_stacksize);
-       log_println("lock record:               %10d", size_lock_record);
-       log_println("lock hashtable:            %10d", size_lock_hashtable);
-       log_println("lock waiter:               %10d", size_lock_waiter);
-       log_println("                            ----------");
-
-       sum =
-               count_const_pool_len +
-               count_classref_len +
-               count_parsed_desc_len + 
-               count_vftbl_len +
-               count_cstub_len +
-               size_stub_native +
-               count_utf_len +
-               count_vmcode_len +
-               size_stack_map +
-               size_string +
-               size_threadobject +
-               size_thread_index_t +
-               size_stacksize +
-               size_lock_record +
-               size_lock_hashtable +
-               size_lock_waiter;
-
-       log_println("                           %10d", sum);
-
-       log_println("");
-
-       log_println("max. code memory:          %10d", maxcodememusage);
-       log_println("max. heap memory:          %10d", maxmemusage);
-       log_println("max. dump memory:          %10d", maxdumpsize);
-       log_println("");
-       log_println("heap memory not freed:     %10d", (int32_t) memoryusage);
-       log_println("dump memory not freed:     %10d", (int32_t) globalallocateddumpsize);
-
-       log_println("");
-}
-
-
-/* statistics_print_gc_memory_usage ********************************************
-
-   Print current GC memory usage.
-
-*******************************************************************************/
-
-void statistics_print_gc_memory_usage(void)
-{
-       static int64_t count = 0;
-       int64_t max;
-       int64_t size;
-       int64_t free;
-       int64_t used;
-       int64_t total;
-
-       count++;
-
-       max   = gc_get_max_heap_size();
-       size  = gc_get_heap_size();
-       free  = gc_get_free_bytes();
-       used  = size - free;
-       total = gc_get_total_bytes();
-
-       if (opt_ProfileMemoryUsageGNUPlot) {
-               if (count == 1)
-                       fprintf(opt_ProfileMemoryUsageGNUPlot, "plot \"profile.dat\" using 1:2 with lines title \"max. Java heap size\", \"profile.dat\" using 1:3 with lines title \"Java heap size\", \"profile.dat\" using 1:4 with lines title \"used\", \"profile.dat\" using 1:5 with lines title \"free\"\n");
-
-#if SIZEOF_VOID_P == 8
-               fprintf(opt_ProfileMemoryUsageGNUPlot, "%ld %ld %ld %ld %ld\n", count, max, size, used, free);
-#else
-               fprintf(opt_ProfileMemoryUsageGNUPlot, "%lld %lld %lld %lld %lld\n", count, max, size, used, free);
-#endif
-
-               fflush(opt_ProfileMemoryUsageGNUPlot);
-       }
-       else {
-               log_println("GC memory usage -------------------");
-               log_println("");
-               log_println("max. Java heap size: %10lld", max);
-               log_println("");
-               log_println("Java heap size:      %10lld", size);
-               log_println("used:                %10lld", used);
-               log_println("free:                %10lld", free);
-               log_println("totally used:        %10lld", total);
-               log_println("");
-       }
-}
-
-
-/*
- * 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/vmcore/statistics.h b/src/vmcore/statistics.h
deleted file mode 100644 (file)
index 62730ce..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/* src/vmcore/statistics.h - exports global varables for statistics
-
-   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
-
-   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 _STATISTICS_H
-#define _STATISTICS_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-
-/* statistic macros ***********************************************************/
-
-#if defined(ENABLE_STATISTICS)
-#define STATISTICS(x) \
-    do { \
-        if (opt_stat) { \
-            x; \
-        } \
-    } while (0)
-#else
-#define STATISTICS(x)    /* nothing */
-#endif
-
-/* in_  inline statistics */
-
-#define IN_MAX                  9
-#define IN_UNIQUEVIRT           0x0000 
-#define IN_UNIQUE_INTERFACE     0x0001
-#define IN_OUTSIDERS            0x0004
-#define IN_MAXDEPTH             0x0008
-#define IN_MAXCODE              0x0010
-#define IN_JCODELENGTH          0x0020
-#define IN_EXCEPTION            0x0040
-#define IN_NOT_UNIQUE_VIRT      0x0080
-#define IN_NOT_UNIQUE_INTERFACE 0x0100
-
-#define N_UNIQUEVIRT            0
-#define N_UNIQUE_INTERFACE      1
-#define N_OUTSIDERS             2
-#define N_MAXDEPTH             3       
-#define N_MAXCODE               4 
-#define N_JCODELENGTH           5 
-#define N_EXCEPTION            6 
-#define N_NOT_UNIQUE_VIRT       7 
-#define N_NOT_UNIQUE_INTERFACE  8 
-
-
-/* global variables ***********************************************************/
-
-extern s4 codememusage;
-extern s4 maxcodememusage;
-
-extern s4 memoryusage;
-extern s4 maxmemusage;
-
-extern s4 maxdumpsize;
-
-extern s4 globalallocateddumpsize;
-extern s4 globaluseddumpsize;
-
-
-/* variables for measurements *************************************************/
-
-extern s4 size_classinfo;
-extern s4 size_fieldinfo;
-extern s4 size_methodinfo;
-extern s4 size_lineinfo;
-extern s4 size_codeinfo;
-
-extern s4 size_stub_native;
-
-extern s4 size_stack_map;
-extern s4 size_string;
-
-extern s4 size_threadobject;
-extern int32_t size_thread_index_t;
-extern int32_t size_stacksize;
-
-extern s4 size_lock_record;
-extern s4 size_lock_hashtable;
-extern s4 size_lock_waiter;
-
-extern int32_t count_linenumbertable;
-extern int32_t size_linenumbertable;
-
-extern s4 size_patchref;
-
-extern u8 count_calls_java_to_native;
-extern u8 count_calls_native_to_java;
-
-extern int count_const_pool_len;
-extern int count_classref_len;
-extern int count_parsed_desc_len;
-extern int count_vftbl_len;
-extern int count_all_methods;
-extern int count_methods_marked_used;  /*RTA*/
-extern int count_vmcode_len;
-extern int count_extable_len;
-extern int count_class_loads;
-extern int count_class_inits;
-
-extern int count_utf_len;               /* size of utf hash                   */
-extern int count_utf_new;
-extern int count_utf_new_found;
-
-extern int count_locals_conflicts;
-extern int count_locals_spilled;
-extern int count_locals_register;
-extern int count_ss_spilled;
-extern int count_ss_register;
-extern int count_methods_allocated_by_lsra;
-extern int count_mem_move_bb;
-extern int count_interface_size;
-extern int count_argument_mem_ss;
-extern int count_argument_reg_ss;
-extern int count_method_in_register;
-extern int count_mov_reg_reg;
-extern int count_mov_mem_reg;
-extern int count_mov_reg_mem;
-extern int count_mov_mem_mem;
-
-extern int count_jit_calls;
-extern int count_methods;
-extern int count_spills_read_ila;
-extern int count_spills_read_flt;
-extern int count_spills_read_dbl;
-extern int count_spills_write_ila;
-extern int count_spills_write_flt;
-extern int count_spills_write_dbl;
-extern int count_pcmd_activ;
-extern int count_pcmd_drop;
-extern int count_pcmd_zero;
-extern int count_pcmd_const_store;
-extern int count_pcmd_const_alu;
-extern int count_pcmd_const_bra;
-extern int count_pcmd_load;
-extern int count_pcmd_move;
-extern int count_load_instruction;
-extern int count_pcmd_store;
-extern int count_pcmd_store_comb;
-extern int count_dup_instruction;
-extern int count_pcmd_op;
-extern int count_pcmd_mem;
-extern int count_pcmd_met;
-extern int count_pcmd_bra;
-extern int count_pcmd_table;
-extern int count_pcmd_return;
-extern int count_pcmd_returnx;
-extern int count_check_null;
-extern int count_check_bound;
-extern int count_max_basic_blocks;
-extern int count_basic_blocks;
-extern int count_max_javainstr;
-extern int count_javainstr;
-extern int count_javacodesize;
-extern int count_javaexcsize;
-extern int count_calls;
-extern int count_tryblocks;
-extern int count_code_len;
-extern int count_data_len;
-extern int count_cstub_len;
-extern int count_max_new_stack;
-extern int count_upper_bound_new_stack;
-
-extern int count_emit_branch;
-extern int count_emit_branch_8bit;
-extern int count_emit_branch_16bit;
-extern int count_emit_branch_32bit;
-extern int count_emit_branch_64bit;
-
-extern s4 count_branches_resolved;
-extern s4 count_branches_unresolved;
-
-extern int *count_block_stack;
-extern int *count_analyse_iterations;
-extern int *count_method_bb_distribution;
-extern int *count_block_size_distribution;
-extern int *count_store_length;
-extern int *count_store_depth;
-                                /* in_  inline statistics */
-extern int count_in;
-extern int count_in_uniqVirt;
-extern int count_in_uniqIntf;
-extern int count_in_rejected;
-extern int count_in_rejected_mult;
-extern int count_in_outsiders;
-extern int count_in_uniqueVirt_not_inlined;
-extern int count_in_uniqueInterface_not_inlined;
-extern int count_in_maxDepth;
-extern int count_in_maxMethods;
-
-extern u2 count_in_not   [512];
-
-/* instruction scheduler statistics *******************************************/
-
-extern s4 count_schedule_basic_blocks;
-extern s4 count_schedule_nodes;
-extern s4 count_schedule_leaders;
-extern s4 count_schedule_max_leaders;
-extern s4 count_schedule_critical_path;
-
-
-/* function prototypes ********************************************************/
-
-s8 getcputime(void);
-
-void loadingtime_start(void);
-void loadingtime_stop(void);
-void compilingtime_start(void);
-void compilingtime_stop(void);
-
-void print_times(void);
-void print_stats(void);
-
-void statistics_print_date(void);
-void statistics_print_memory_usage(void);
-void statistics_print_gc_memory_usage(void);
-
-void mem_usagelog(bool givewarnings);
-
-void compiledinvokation(void);
-void jnicallXmethodnvokation(void);
-void jniinvokation(void);
-
-#endif /* _STATISTICS_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:
- */
diff --git a/src/vmcore/suck.c b/src/vmcore/suck.c
deleted file mode 100644 (file)
index 933ceab..0000000
+++ /dev/null
@@ -1,631 +0,0 @@
-/* src/vmcore/suck.c - functions to read LE ordered types from a buffer
-
-   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 <stdlib.h>
-
-#include "vm/types.h"
-
-#include "arch.h"
-
-#include "mm/memory.h"
-
-#include "threads/lock-common.h"
-
-#include "toolbox/list.h"
-#include "toolbox/logging.h"
-#include "toolbox/util.h"
-
-#include "vm/exceptions.h"
-#include "vm/properties.h"
-#include "vm/vm.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/suck.h"
-#include "vmcore/system.h"
-#include "vmcore/zip.h"
-
-
-/* global variables ***********************************************************/
-
-list_t *list_classpath_entries;
-
-
-/* suck_init *******************************************************************
-
-   Initializes the suck subsystem like initializing the classpath
-   entries list.
-
-*******************************************************************************/
-
-bool suck_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("suck_init");
-
-       list_classpath_entries = list_create(OFFSET(list_classpath_entry, linkage));
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* scandir_filter **************************************************************
-
-   Filters for zip/jar files.
-
-*******************************************************************************/
-
-#if defined(__LINUX__)
-static int scandir_filter(const struct dirent *a)
-#else
-static int scandir_filter(struct dirent *a)
-#endif
-{
-       s4 namlen;
-
-#if defined(_DIRENT_HAVE_D_NAMLEN)
-       namlen = a->d_namlen;
-#else
-       namlen = strlen(a->d_name);
-#endif
-
-       if ((strncasecmp(a->d_name + namlen - 4, ".zip", 4) == 0) ||
-               (strncasecmp(a->d_name + namlen - 4, ".jar", 4) == 0))
-               return 1;
-
-       return 0;
-}
-
-
-/* suck_add ********************************************************************
-
-   Adds a classpath to the global classpath entries list.
-
-*******************************************************************************/
-
-void suck_add(char *classpath)
-{
-       list_classpath_entry *lce;
-       char                 *start;
-       char                 *end;
-       char                 *filename;
-       s4                    filenamelen;
-       bool                  is_zip;
-       char                 *cwd;
-       s4                    cwdlen;
-#if defined(ENABLE_ZLIB)
-       hashtable            *ht;
-#endif
-
-       /* parse the classpath string */
-
-       for (start = classpath; (*start) != '\0'; ) {
-
-               /* search for ':' delimiter to get the end of the current entry */
-               for (end = start; ((*end) != '\0') && ((*end) != ':'); end++);
-
-               if (start != end) {
-                       is_zip = false;
-                       filenamelen = end - start;
-
-                       if (filenamelen > 4) {
-                               if ((strncasecmp(end - 4, ".zip", 4) == 0) ||
-                                       (strncasecmp(end - 4, ".jar", 4) == 0)) {
-                                       is_zip = true;
-                               }
-                       }
-
-                       /* save classpath entries as absolute pathnames */
-
-                       cwd = NULL;
-                       cwdlen = 0;
-
-                       if (*start != '/') {                      /* XXX fix me for win32 */
-                               cwd = _Jv_getcwd();
-                               cwdlen = strlen(cwd) + strlen("/");
-                       }
-
-                       /* allocate memory for filename and fill it */
-
-                       filename = MNEW(char, filenamelen + cwdlen + strlen("/") +
-                                                       strlen("0"));
-
-                       if (cwd) {
-                               strcpy(filename, cwd);
-                               strcat(filename, "/");
-                               strncat(filename, start, filenamelen);
-
-                               /* add cwd length to file length */
-                               filenamelen += cwdlen;
-
-                       } else {
-                               strncpy(filename, start, filenamelen);
-                               filename[filenamelen] = '\0';
-                       }
-
-                       lce = NULL;
-
-                       if (is_zip) {
-#if defined(ENABLE_ZLIB)
-                               ht = zip_open(filename);
-
-                               if (ht != NULL) {
-                                       lce = NEW(list_classpath_entry);
-
-                                       lce->type      = CLASSPATH_ARCHIVE;
-                                       lce->htclasses = ht;
-                                       lce->path      = filename;
-                                       lce->pathlen   = filenamelen;
-
-                                       /* SUN compatible -verbose:class output */
-
-                                       if (opt_verboseclass)
-                                               printf("[Opened %s]\n", filename);
-                               }
-
-#else
-                               vm_abort("suck_add: zip/jar files not supported");
-#endif
-                       }
-                       else {
-                               if (filename[filenamelen - 1] != '/') {/* XXX fixme for win32 */
-                                       filename[filenamelen] = '/';
-                                       filename[filenamelen + 1] = '\0';
-                                       filenamelen++;
-                               }
-
-                               lce = NEW(list_classpath_entry);
-
-                               lce->type    = CLASSPATH_PATH;
-                               lce->path    = filename;
-                               lce->pathlen = filenamelen;
-                       }
-
-                       /* add current classpath entry, if no error */
-
-                       if (lce != NULL)
-                               list_add_last(list_classpath_entries, lce);
-               }
-
-               /* goto next classpath entry, skip ':' delimiter */
-
-               if ((*end) == ':')
-                       start = end + 1;
-               else
-                       start = end;
-       }
-}
-
-
-/* suck_add_from_property ******************************************************
-
-   Adds a classpath form a property entry to the global classpath
-   entries list.
-
-*******************************************************************************/
-
-void suck_add_from_property(char *key)
-{
-       char           *value;
-       char           *start;
-       char           *end;
-       char           *path;
-       s4              pathlen;
-       struct dirent **namelist;
-       s4              n;
-       s4              i;
-       s4              namlen;
-       char           *boot_class_path;
-       char           *p;
-
-       /* get the property value */
-
-       value = properties_get(key);
-
-       if (value == NULL)
-               return;
-
-       /* get the directory entries of the property */
-
-       for (start = value; (*start) != '\0'; ) {
-
-               /* search for ':' delimiter to get the end of the current entry */
-
-               for (end = start; ((*end) != '\0') && ((*end) != ':'); end++);
-
-               /* found an entry */
-
-               if (start != end) {
-                       /* allocate memory for the path entry */
-
-                       pathlen = end - start;
-                       path = MNEW(char, pathlen + strlen("0"));
-
-                       /* copy and terminate the string */
-
-                       strncpy(path, start, pathlen);
-                       path[pathlen] = '\0';
-
-                       /* Reset namelist to NULL for the freeing in an error case
-                          (see below). */
-
-                       namelist = NULL;
-
-                       /* scan the directory found for zip/jar files */
-
-                       n = system_scandir(path, &namelist, scandir_filter, alphasort);
-
-                       /* On error, just continue, this should be ok. */
-
-                       if (n > 0) {
-                               for (i = 0; i < n; i++) {
-#if defined(_DIRENT_HAVE_D_NAMLEN)
-                                       namlen = namelist[i]->d_namlen;
-#else
-                                       namlen = strlen(namelist[i]->d_name);
-#endif
-
-                                       /* Allocate memory for bootclasspath. */
-
-                                       boot_class_path = properties_get("sun.boot.class.path");
-
-                                       p = MNEW(char,
-                                                        pathlen + strlen("/") + namlen +
-                                                        strlen(":") +
-                                                        strlen(boot_class_path) +
-                                                        strlen("0"));
-
-                                       /* Prepend the file found to the bootclasspath. */
-
-                                       strcpy(p, path);
-                                       strcat(p, "/");
-                                       strcat(p, namelist[i]->d_name);
-                                       strcat(p, ":");
-                                       strcat(p, boot_class_path);
-
-                                       properties_add("sun.boot.class.path", p);
-                                       properties_add("java.boot.class.path", p);
-
-                                       MFREE(boot_class_path, char, strlen(boot_class_path));
-
-                                       /* free the memory allocated by scandir */
-                                       /* (We use `free` as the memory came from the C library.) */
-
-                                       free(namelist[i]);
-                               }
-                       }
-
-                       /* On some systems (like Linux) when n == 0, then namelist
-                          returned from scnadir is NULL, thus we don't have to
-                          free it.
-                          (Use `free` as the memory came from the C library.) */
-
-                       if (namelist != NULL)
-                               free(namelist);
-
-                       MFREE(path, char, pathlen + strlen("0"));
-               }
-
-               /* goto next entry, skip ':' delimiter */
-
-               if ((*end) == ':')
-                       start = end + 1;
-               else
-                       start = end;
-       }
-}
-
-
-/* suck_check_classbuffer_size *************************************************
-
-   Assert that at least <len> bytes are left to read <len> is limited
-   to the range of non-negative s4 values.
-
-*******************************************************************************/
-
-bool suck_check_classbuffer_size(classbuffer *cb, s4 len)
-{
-#ifdef ENABLE_VERIFIER
-       if (len < 0 || ((cb->data + cb->size) - cb->pos) < len) {
-               exceptions_throw_classformaterror(cb->clazz, "Truncated class file");
-               return false;
-       }
-#endif /* ENABLE_VERIFIER */
-
-       return true;
-}
-
-
-u1 suck_u1(classbuffer *cb)
-{
-       u1 a;
-
-       a = SUCK_BE_U1(cb->pos);
-       cb->pos++;
-
-       return a;
-}
-
-
-u2 suck_u2(classbuffer *cb)
-{
-       u2 a;
-
-       a = SUCK_BE_U2(cb->pos);
-       cb->pos += 2;
-
-       return a;
-}
-
-
-u4 suck_u4(classbuffer *cb)
-{
-       u4 a;
-
-       a = SUCK_BE_U4(cb->pos);
-       cb->pos += 4;
-
-       return a;
-}
-
-
-u8 suck_u8(classbuffer *cb)
-{
-#if U8_AVAILABLE == 1
-       u8 a;
-
-       a = SUCK_BE_U8(cb->pos);
-       cb->pos += 8;
-
-       return a;
-#else
-       u8 v;
-
-       v.high = suck_u4(cb);
-       v.low = suck_u4(cb);
-
-       return v;
-#endif
-}
-
-
-float suck_float(classbuffer *cb)
-{
-       float f;
-
-#if WORDS_BIGENDIAN == 0
-       u1 buffer[4];
-       u2 i;
-
-       for (i = 0; i < 4; i++)
-               buffer[3 - i] = suck_u1(cb);
-
-       MCOPY((u1 *) (&f), buffer, u1, 4);
-#else
-       suck_nbytes((u1*) (&f), cb, 4);
-#endif
-
-       assert(sizeof(float) == 4);
-       
-       return f;
-}
-
-
-double suck_double(classbuffer *cb)
-{
-       double d;
-
-#if WORDS_BIGENDIAN == 0
-       u1 buffer[8];
-       u2 i;   
-
-# if defined(__ARM__) && defined(__ARMEL__) && !defined(__VFP_FP__)
-       /*
-        * On little endian ARM processors when using FPA, word order
-        * of doubles is still big endian. So take that into account
-        * here. When using VFP, word order of doubles follows byte
-        * order. (michi 2005/07/24)
-        */
-       for (i = 0; i < 4; i++)
-               buffer[3 - i] = suck_u1(cb);
-       for (i = 0; i < 4; i++)
-               buffer[7 - i] = suck_u1(cb);
-# else
-       for (i = 0; i < 8; i++)
-               buffer[7 - i] = suck_u1(cb);
-# endif /* defined(__ARM__) && ... */
-
-       MCOPY((u1 *) (&d), buffer, u1, 8);
-#else 
-       suck_nbytes((u1*) (&d), cb, 8);
-#endif
-
-       assert(sizeof(double) == 8);
-       
-       return d;
-}
-
-
-/* suck_nbytes *****************************************************************
-
-   Transfer block of classfile data into a buffer.
-
-*******************************************************************************/
-
-void suck_nbytes(u1 *buffer, classbuffer *cb, s4 len)
-{
-       MCOPY(buffer, cb->pos, u1, len);
-       cb->pos += len;
-}
-
-
-/* suck_skip_nbytes ************************************************************
-
-   Skip block of classfile data.
-
-*******************************************************************************/
-
-void suck_skip_nbytes(classbuffer *cb, s4 len)
-{
-       cb->pos += len;
-}
-
-
-/* suck_start ******************************************************************
-
-   Returns true if classbuffer is already loaded or a file for the
-   specified class has succussfully been read in. All directories of
-   the searchpath are used to find the classfile (<classname>.class).
-   Returns NULL if no classfile is found and writes an error message.
-       
-*******************************************************************************/
-
-classbuffer *suck_start(classinfo *c)
-{
-       list_classpath_entry *lce;
-       char                 *filename;
-       s4                    filenamelen;
-       char                 *path;
-       FILE                 *classfile;
-       s4                    len;
-       struct stat           buffer;
-       classbuffer          *cb;
-
-       /* initialize return value */
-
-       cb = NULL;
-
-       /* get the classname as char string (do it here for the warning at
-       the end of the function) */
-
-       filenamelen = utf_bytes(c->name) + strlen(".class") + strlen("0");
-       filename = MNEW(char, filenamelen);
-
-       utf_copy(filename, c->name);
-       strcat(filename, ".class");
-
-       /* walk through all classpath entries */
-
-       for (lce = list_first(list_classpath_entries); lce != NULL && cb == NULL;
-                lce = list_next(list_classpath_entries, lce)) {
-#if defined(ENABLE_ZLIB)
-               if (lce->type == CLASSPATH_ARCHIVE) {
-
-                       /* enter a monitor on zip/jar archives */
-
-                       LOCK_MONITOR_ENTER(lce);
-
-                       /* try to get the file in current archive */
-
-                       cb = zip_get(lce, c);
-
-                       /* leave the monitor */
-
-                       LOCK_MONITOR_EXIT(lce);
-
-               } else {
-#endif /* defined(ENABLE_ZLIB) */
-                       path = MNEW(char, lce->pathlen + filenamelen);
-                       strcpy(path, lce->path);
-                       strcat(path, filename);
-
-                       classfile = system_fopen(path, "r");
-
-                       if (classfile) {                                   /* file exists */
-                               if (!system_stat(path, &buffer)) {     /* read classfile data */
-                                       cb = NEW(classbuffer);
-                                       cb->clazz = c;
-                                       cb->size  = buffer.st_size;
-                                       cb->data  = MNEW(u1, cb->size);
-                                       cb->pos   = cb->data;
-                                       cb->path  = lce->path;
-
-                                       /* read class data */
-
-                                       len = system_fread((void *) cb->data, 1, cb->size,
-                                                                          classfile);
-
-                                       if (len != buffer.st_size) {
-                                               suck_stop(cb);
-/*                                             if (ferror(classfile)) { */
-/*                                             } */
-                                       }
-
-                                       /* close the class file */
-
-                                       system_fclose(classfile);
-                               }
-                       }
-
-                       MFREE(path, char, lce->pathlen + filenamelen);
-#if defined(ENABLE_ZLIB)
-               }
-#endif
-       }
-
-       if (opt_verbose)
-               if (cb == NULL)
-                       dolog("Warning: Can not open class file '%s'", filename);
-
-       MFREE(filename, char, filenamelen);
-
-       return cb;
-}
-
-
-/* suck_stop *******************************************************************
-
-   Frees memory for buffer with classfile data.
-
-   CAUTION: This function may only be called if buffer has been
-   allocated by suck_start with reading a file.
-       
-*******************************************************************************/
-
-void suck_stop(classbuffer *cb)
-{
-       /* free memory */
-
-       MFREE(cb->data, u1, cb->size);
-       FREE(cb, classbuffer);
-}
-
-
-/*
- * 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:
- */
diff --git a/src/vmcore/suck.h b/src/vmcore/suck.h
deleted file mode 100644 (file)
index cc29e06..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/* src/vmcore/suck.h - functions to read LE ordered types from a buffer
-
-   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
-
-   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 _SUCK_H
-#define _SUCK_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "toolbox/hashtable.h"
-#include "toolbox/list.h"
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-
-
-/* list_classpath_entry *******************************************************/
-
-enum {
-       CLASSPATH_PATH,
-       CLASSPATH_ARCHIVE
-};
-
-typedef struct list_classpath_entry list_classpath_entry;
-
-struct list_classpath_entry {
-#if defined(ENABLE_THREADS)
-       java_object_t      header;              /* monitor locking on zip/jar files   */
-#endif
-       s4                 type;
-       char              *path;
-       s4                 pathlen;
-#if defined(ENABLE_ZLIB)
-       hashtable         *htclasses;
-#endif
-       listnode_t         linkage;
-};
-
-
-/* macros to read LE and BE types from a buffer ********************************
-
-   BE macros are for Java class file loading.
-   LE macros are for ZIP file loading.
-
-*******************************************************************************/
-
-/* LE macros (for ZIP files ) *************************************************/
-
-#if defined(__I386__) || defined(__X86_64__)
-
-/* we can optimize the LE access on little endian machines without alignment */
-
-#define SUCK_LE_U1(p)    *((u1 *) (p))
-#define SUCK_LE_U2(p)    *((u2 *) (p))
-#define SUCK_LE_U4(p)    *((u4 *) (p))
-
-#if U8_AVAILABLE == 1
-#define SUCK_LE_U8(p)    *((u8 *) (p))
-#endif
-
-#else /* defined(__I386__) || defined(__X86_64__) */
-
-#define SUCK_LE_U1(p) \
-      ((u1) (p)[0])
-
-#define SUCK_LE_U2(p) \
-    ((((u2) (p)[1]) << 8) + \
-      ((u2) (p)[0]))
-
-#define SUCK_LE_U4(p) \
-    ((((u4) (p)[3]) << 24) + \
-     (((u4) (p)[2]) << 16) + \
-     (((u4) (p)[1]) << 8) + \
-      ((u4) (p)[0]))
-
-#if U8_AVAILABLE == 1
-#define SUCK_LE_U8(p) \
-    ((((u8) (p)[7]) << 56) + \
-     (((u8) (p)[6]) << 48) + \
-     (((u8) (p)[5]) << 40) + \
-     (((u8) (p)[4]) << 32) + \
-     (((u8) (p)[3]) << 24) + \
-     (((u8) (p)[2]) << 16) + \
-     (((u8) (p)[1]) << 8) + \
-      ((u8) (p)[0]))
-#endif
-
-#endif /* defined(__I386__) || defined(__X86_64__) */
-
-
-/* BE macros (for Java class files ) ******************************************/
-
-#define SUCK_BE_U1(p) \
-      ((u1) (p)[0])
-
-#define SUCK_BE_U2(p) \
-    ((((u2) (p)[0]) << 8) + \
-      ((u2) (p)[1]))
-
-#define SUCK_BE_U4(p) \
-    ((((u4) (p)[0]) << 24) + \
-     (((u4) (p)[1]) << 16) + \
-     (((u4) (p)[2]) << 8) + \
-      ((u4) (p)[3]))
-
-#if U8_AVAILABLE == 1
-#define SUCK_BE_U8(p) \
-    ((((u8) (p)[0]) << 56) + \
-     (((u8) (p)[1]) << 48) + \
-     (((u8) (p)[2]) << 40) + \
-     (((u8) (p)[3]) << 32) + \
-     (((u8) (p)[4]) << 24) + \
-     (((u8) (p)[5]) << 16) + \
-     (((u8) (p)[6]) << 8) + \
-      ((u8) (p)[7]))
-#endif
-
-
-#define SUCK_BE_S1(p)    (s1) SUCK_BE_U1(p)
-#define SUCK_BE_S2(p)    (s2) SUCK_BE_U2(p)
-#define SUCK_BE_S4(p)    (s4) SUCK_BE_U4(p)
-#define SUCK_BE_S8(p)    (s8) SUCK_BE_U8(p)
-
-
-/* signed suck defines ********************************************************/
-
-#define suck_s1(a)    (s1) suck_u1((a))
-#define suck_s2(a)    (s2) suck_u2((a))
-#define suck_s4(a)    (s4) suck_u4((a))
-#define suck_s8(a)    (s8) suck_u8((a))
-
-
-/* export variables ***********************************************************/
-
-extern list_t *list_classpath_entries;
-
-
-/* function prototypes ********************************************************/
-
-bool suck_init(void);
-
-void suck_add(char *classpath);
-void suck_add_from_property(char *key);
-
-bool suck_check_classbuffer_size(classbuffer *cb, s4 len);
-
-u1 suck_u1(classbuffer *cb);
-u2 suck_u2(classbuffer *cb);
-u4 suck_u4(classbuffer *cb);
-u8 suck_u8(classbuffer *cb);
-
-float suck_float(classbuffer *cb);
-double suck_double(classbuffer *cb);
-
-void suck_nbytes(u1 *buffer, classbuffer *cb, s4 len);
-void suck_skip_nbytes(classbuffer *cb, s4 len);
-
-classbuffer *suck_start(classinfo *c);
-
-void suck_stop(classbuffer *cb);
-
-#endif /* _SUCK_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:
- */
diff --git a/src/vmcore/system.c b/src/vmcore/system.c
deleted file mode 100644 (file)
index be474a9..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/* src/vmcore/system.c - system (OS) functions
-
-   Copyright (C) 2007
-   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"
-
-/* NOTE: In this file we check for all system headers, because we wrap
-   all system calls into functions for better portability. */
-
-#if defined(HAVE_ERRNO_H)
-# include <errno.h>
-#endif
-
-#if defined(HAVE_STDINT_H)
-# include <stdint.h>
-#endif
-
-#if defined(HAVE_STRING_H)
-# include <string.h>
-#endif
-
-#if defined(HAVE_UNISTD_H)
-# include <unistd.h>
-#endif
-
-#if defined(HAVE_SYS_MMAN_H)
-# include <sys/mman.h>
-#endif
-
-#if defined(__DARWIN__)
-# include <mach/mach.h>
-# include <mach/mach_host.h>
-# include <mach/host_info.h>
-#endif
-
-/* this should work on BSD */
-/* #include <sys/sysctl.h> */
-
-#include "vm/vm.h"
-
-
-/* system_mmap_anonymous *******************************************************
-
-   Maps anonymous memory, even on systems not defining
-   MAP_ANON(YMOUS).
-
-*******************************************************************************/
-
-void *system_mmap_anonymous(void *addr, size_t len, int prot, int flags)
-{
-       void *p;
-
-#if defined(MAP_ANON) || defined(MAP_ANONYMOUS)
-       p = mmap(addr, len, prot,
-# if defined(MAP_ANON)
-                        MAP_ANON | flags,
-# else
-                        MAP_ANONYMOUS | flags,
-# endif
-                        -1, 0);
-#else
-       int fd;
-
-       fd = open("/dev/zero", O_RDONLY, 0);
-
-       if (fd == -1)
-               vm_abort("system_mmap_anonymous: open failed: %s", strerror(errno));
-
-       p = mmap(addr, len, prot, flags, fd, 0);
-#endif
-
-#if defined(MAP_FAILED)
-       if (p == MAP_FAILED)
-#else
-       if (p == (void *) -1)
-#endif
-               vm_abort("system_mmap_anonymous: mmap failed: %s", strerror(errno));
-
-       return p;
-}
-
-
-/* system_processors_online ****************************************************
-
-   Returns the number of online processors in the system.
-
-   RETURN:
-       online processor count
-
-*******************************************************************************/
-
-int system_processors_online(void)
-{
-#if defined(_SC_NPROC_ONLN)
-
-       return (int) sysconf(_SC_NPROC_ONLN);
-
-#elif defined(_SC_NPROCESSORS_ONLN)
-
-       return (int) sysconf(_SC_NPROCESSORS_ONLN);
-
-#elif defined(__DARWIN__)
-
-       host_basic_info_data_t hinfo;
-       mach_msg_type_number_t hinfo_count = HOST_BASIC_INFO_COUNT;
-       kern_return_t rc;
-
-       rc = host_info(mach_host_self(), HOST_BASIC_INFO,
-                                  (host_info_t) &hinfo, &hinfo_count);
-       if (rc != KERN_SUCCESS) {
-               return -1;
-       }
-
-       /* XXX michi: according to my infos this should be
-          hinfo.max_cpus, can someone please confirm or deny that? */
-       return (int) hinfo.avail_cpus;
-
-#elif defined(__FREEBSD__)
-# error IMPLEMENT ME!
-
-       /* this should work in BSD */
-       /*
-       int ncpu, mib[2], rc;
-       size_t len;
-
-       mib[0] = CTL_HW;
-       mib[1] = HW_NCPU;
-       len = sizeof(ncpu);
-       rc = sysctl(mib, 2, &ncpu, &len, NULL, 0);
-
-       return (int32_t) ncpu;
-       */
-
-#else
-
-       return 1;
-
-#endif
-}
-
-
-/*
- * 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/vmcore/system.h b/src/vmcore/system.h
deleted file mode 100644 (file)
index 6d6e683..0000000
+++ /dev/null
@@ -1,458 +0,0 @@
-/* src/vmcore/system.h - system (OS) functions
-
-   Copyright (C) 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 _VMCORE_SYSTEM_H
-#define _VMCORE_SYSTEM_H
-
-#include "config.h"
-
-/* NOTE: In this file we check for all system headers, because we wrap
-   all system calls into inline functions for better portability. */
-
-#if defined(HAVE_DIRENT_H)
-# include <dirent.h>
-#endif
-
-#if defined(HAVE_FCNTL_H)
-# include <fcntl.h>
-#endif
-
-#if defined(ENABLE_JRE_LAYOUT)
-# if defined(HAVE_LIBGEN_H)
-#  include <libgen.h>
-# endif
-#endif
-
-#if defined(HAVE_STDINT_H)
-# include <stdint.h>
-#endif
-
-#if defined(HAVE_STDIO_H)
-# include <stdio.h>
-#endif
-
-#if defined(HAVE_STDLIB_H)
-# include <stdlib.h>
-#endif
-
-#if defined(HAVE_STRING_H)
-# include <string.h>
-#endif
-
-#if defined(HAVE_UNISTD_H)
-# include <unistd.h>
-#endif
-
-#if defined(HAVE_SYS_MMAN_H)
-# include <sys/mman.h>
-#endif
-
-#if defined(HAVE_SYS_SOCKET_H)
-# include <sys/socket.h>
-#endif
-
-#if defined(HAVE_SYS_STAT_H)
-# include <sys/stat.h>
-#endif
-
-#if defined(HAVE_SYS_TYPES_H)
-# include <sys/types.h>
-#endif
-
-
-/* inline functions ***********************************************************/
-
-inline static void system_abort(void)
-{
-#if defined(HAVE_ABORT)
-       abort();
-#else
-# error abort not available
-#endif
-}
-
-inline static int system_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
-{
-#if defined(HAVE_ACCEPT)
-       return accept(sockfd, addr, addrlen);
-#else
-# error accept not available
-#endif
-}
-
-inline static int system_access(const char *pathname, int mode)
-{
-#if defined(HAVE_ACCESS)
-       return access(pathname, mode);
-#else
-# error access not available
-#endif
-}
-
-inline static int system_atoi(const char *nptr)
-{
-#if defined(HAVE_ATOI)
-       return atoi(nptr);
-#else
-# error atoi not available
-#endif
-}
-
-inline static void *system_calloc(size_t nmemb, size_t size)
-{
-#if defined(HAVE_CALLOC)
-       return calloc(nmemb, size);
-#else
-# error calloc not available
-#endif
-}
-
-inline static int system_close(int fd)
-{
-#if defined(HAVE_CLOSE)
-       return close(fd);
-#else
-# error close not available
-#endif
-}
-
-inline static int system_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen)
-{
-#if defined(HAVE_CONNECT)
-       return connect(sockfd, serv_addr, addrlen);
-#else
-# error connect not available
-#endif
-}
-
-#if defined(ENABLE_JRE_LAYOUT)
-inline static char *system_dirname(char *path)
-{
-#if defined(HAVE_DIRNAME)
-       return dirname(path);
-#else
-# error dirname not available
-#endif
-}
-#endif
-
-inline static FILE *system_fopen(const char *path, const char *mode)
-{
-#if defined(HAVE_FOPEN)
-       return fopen(path, mode);
-#else
-# error fopen not available
-#endif
-}
-
-inline static int system_fclose(FILE *fp)
-{
-#if defined(HAVE_FCLOSE)
-       return fclose(fp);
-#else
-# error fclose not available
-#endif
-}
-
-inline static size_t system_fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
-{
-#if defined(HAVE_FREAD)
-       return fread(ptr, size, nmemb, stream);
-#else
-# error fread not available
-#endif
-}
-
-inline static void system_free(void *ptr)
-{
-#if defined(HAVE_FREE)
-       free(ptr);
-#else
-# error free not available
-#endif
-}
-
-inline static int system_fsync(int fd)
-{
-#if defined(HAVE_FSYNC)
-       return fsync(fd);
-#else
-# error fsync not available
-#endif
-}
-
-inline static int system_ftruncate(int fd, off_t length)
-{
-#if defined(HAVE_FTRUNCATE)
-       return ftruncate(fd, length);
-#else
-# error ftruncate not available
-#endif
-}
-
-inline static int system_gethostname(char *name, size_t len)
-{
-#if defined(HAVE_GETHOSTNAME)
-       return gethostname(name, len);
-#else
-# error gethostname not available
-#endif
-}
-
-inline static int system_getpagesize(void)
-{
-#if defined(HAVE_GETPAGESIZE)
-       return getpagesize();
-#else
-# error getpagesize not available
-#endif
-}
-
-inline static int system_getsockname(int s, struct sockaddr *name, socklen_t *namelen)
-{
-#if defined(HAVE_GETSOCKNAME)
-       return getsockname(s, name, namelen);
-#else
-# error getsockname not available
-#endif
-}
-
-inline static int system_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
-{
-#if defined(HAVE_GETSOCKOPT)
-       return getsockopt(s, level, optname, optval, optlen);
-#else
-# error getsockopt not available
-#endif
-}
-
-inline static int system_listen(int sockfd, int backlog)
-{
-#if defined(HAVE_LISTEN)
-       return listen(sockfd, backlog);
-#else
-# error listen not available
-#endif
-}
-
-inline static off_t system_lseek(int fildes, off_t offset, int whence)
-{
-#if defined(HAVE_LSEEK)
-       return lseek(fildes, offset, whence);
-#else
-# error lseek not available
-#endif
-}
-
-inline static void *system_malloc(size_t size)
-{
-#if defined(HAVE_MALLOC)
-       return malloc(size);
-#else
-# error malloc not available
-#endif
-}
-
-inline static void *system_memcpy(void *dest, const void *src, size_t n)
-{
-#if defined(HAVE_MEMCPY)
-       return memcpy(dest, src, n);
-#else
-# error memcpy not available
-#endif
-}
-
-inline static void *system_memset(void *s, int c, size_t n)
-{
-#if defined(HAVE_MEMSET)
-       return memset(s, c, n);
-#else
-# error memset not available
-#endif
-}
-
-inline static int system_mprotect(void *addr, size_t len, int prot)
-{
-#if defined(HAVE_MPROTECT)
-       return mprotect(addr, len, prot);
-#else
-# error mprotect not available
-#endif
-}
-
-inline static int system_open(const char *pathname, int flags, mode_t mode)
-{
-#if defined(HAVE_OPEN)
-       return open(pathname, flags, mode);
-#else
-# error open not available
-#endif
-}
-
-inline static ssize_t system_read(int fd, void *buf, size_t count)
-{
-#if defined(HAVE_READ)
-       return read(fd, buf, count);
-#else
-# error read not available
-#endif
-}
-
-inline static void *system_realloc(void *ptr, size_t size)
-{
-#if defined(HAVE_REALLOC)
-       return realloc(ptr, size);
-#else
-# error realloc not available
-#endif
-}
-
-#if defined(__LINUX__)
-inline static int system_scandir(const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *))
-#elif defined(__IRIX__)
-inline static int system_scandir(const char *dir, struct dirent ***namelist, int(*filter)(dirent_t *), int(*compar)(dirent_t **, dirent_t **))
-#else
-inline static int system_scandir(const char *dir, struct dirent ***namelist, int(*filter)(struct dirent *), int(*compar)(const void *, const void *))
-#endif
-{
-#if defined(HAVE_SCANDIR)
-       return scandir(dir, namelist, filter, compar);
-#else
-# error scandir not available
-#endif
-}
-
-inline static int system_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
-{
-#if defined(HAVE_SETSOCKOPT)
-       return setsockopt(s, level, optname, optval, optlen);
-#else
-# error setsockopt not available
-#endif
-}
-
-inline static int system_shutdown(int s, int how)
-{
-#if defined(HAVE_SHUTDOWN)
-       return shutdown(s, how);
-#else
-# error shutdown not available
-#endif
-}
-
-inline static int system_socket(int domain, int type, int protocol)
-{
-#if defined(HAVE_SOCKET)
-       return socket(domain, type, protocol);
-#else
-# error socket not available
-#endif
-}
-
-inline static int system_stat(const char *path, struct stat *buf)
-{
-#if defined(HAVE_STAT)
-       return stat(path, buf);
-#else
-# error stat not available
-#endif
-}
-
-inline static char *system_strcat(char *dest, const char *src)
-{
-#if defined(HAVE_STRCAT)
-       return strcat(dest, src);
-#else
-# error strcat not available
-#endif
-}
-
-inline static char *system_strcpy(char *dest, const char *src)
-{
-#if defined(HAVE_STRCPY)
-       return strcpy(dest, src);
-#else
-# error strcpy not available
-#endif
-}
-
-inline static char *system_strdup(const char *s)
-{
-#if defined(HAVE_STRDUP)
-       return strdup(s);
-#else
-# error strdup not available
-#endif
-}
-
-inline static char *system_strerror(int errnum)
-{
-#if defined(HAVE_STRERROR)
-       return strerror(errnum);
-#else
-# error strerror not available
-#endif
-}
-
-inline static size_t system_strlen(const char *s)
-{
-#if defined(HAVE_STRLEN)
-       return strlen(s);
-#else
-# error strlen not available
-#endif
-}
-
-inline static ssize_t system_write(int fd, const void *buf, size_t count)
-{
-#if defined(HAVE_WRITE)
-       return write(fd, buf, count);
-#else
-# error write not available
-#endif
-}
-
-
-/* function prototypes ********************************************************/
-
-void *system_mmap_anonymous(void *addr, size_t len, int prot, int flags);
-int   system_processors_online(void);
-
-#endif /* _VMCORE_SYSTEM_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/vmcore/utf8.c b/src/vmcore/utf8.c
deleted file mode 100644 (file)
index b292d95..0000000
+++ /dev/null
@@ -1,1933 +0,0 @@
-/* src/vmcore/utf8.c - utf8 string 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 <string.h>
-#include <assert.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "threads/lock-common.h"
-
-#include "toolbox/hashtable.h"
-
-#include "vm/exceptions.h"
-
-#include "vmcore/options.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
-#endif
-
-#include "vmcore/utf8.h"
-
-
-/* global variables ***********************************************************/
-
-/* hashsize must be power of 2 */
-
-#define HASHTABLE_UTF_SIZE    16384     /* initial size of utf-hash           */
-
-hashtable *hashtable_utf;               /* hashtable for utf8-symbols         */
-
-
-/* utf-symbols for pointer comparison of frequently used strings **************/
-
-utf *utf_java_lang_Object;
-
-utf *utf_java_lang_Class;
-utf *utf_java_lang_ClassLoader;
-utf *utf_java_lang_Cloneable;
-utf *utf_java_lang_SecurityManager;
-utf *utf_java_lang_String;
-utf *utf_java_lang_ThreadGroup;
-utf *utf_java_lang_ref_SoftReference;
-utf *utf_java_lang_ref_WeakReference;
-utf *utf_java_lang_ref_PhantomReference;
-utf *utf_java_io_Serializable;
-
-utf *utf_java_lang_Throwable;
-utf *utf_java_lang_Error;
-
-utf *utf_java_lang_AbstractMethodError;
-utf *utf_java_lang_ClassCircularityError;
-utf *utf_java_lang_ClassFormatError;
-utf *utf_java_lang_ExceptionInInitializerError;
-utf *utf_java_lang_IncompatibleClassChangeError;
-utf *utf_java_lang_InstantiationError;
-utf *utf_java_lang_InternalError;
-utf *utf_java_lang_LinkageError;
-utf *utf_java_lang_NoClassDefFoundError;
-utf *utf_java_lang_NoSuchFieldError;
-utf *utf_java_lang_NoSuchMethodError;
-utf *utf_java_lang_OutOfMemoryError;
-utf *utf_java_lang_UnsatisfiedLinkError;
-utf *utf_java_lang_UnsupportedClassVersionError;
-utf *utf_java_lang_VerifyError;
-utf *utf_java_lang_VirtualMachineError;
-
-utf *utf_java_lang_Exception;
-
-utf *utf_java_lang_ArithmeticException;
-utf *utf_java_lang_ArrayIndexOutOfBoundsException;
-utf *utf_java_lang_ArrayStoreException;
-utf *utf_java_lang_ClassCastException;
-utf *utf_java_lang_ClassNotFoundException;
-utf *utf_java_lang_CloneNotSupportedException;
-utf *utf_java_lang_IllegalAccessException;
-utf *utf_java_lang_IllegalArgumentException;
-utf *utf_java_lang_IllegalMonitorStateException;
-utf *utf_java_lang_InstantiationException;
-utf *utf_java_lang_InterruptedException;
-utf *utf_java_lang_NegativeArraySizeException;
-utf *utf_java_lang_NullPointerException;
-utf *utf_java_lang_RuntimeException;
-utf *utf_java_lang_StringIndexOutOfBoundsException;
-
-utf *utf_java_lang_reflect_InvocationTargetException;
-
-utf *utf_java_security_PrivilegedActionException;
-
-#if defined(ENABLE_JAVASE)
-utf* utf_java_lang_Void;
-#endif
-
-utf* utf_java_lang_Boolean;
-utf* utf_java_lang_Byte;
-utf* utf_java_lang_Character;
-utf* utf_java_lang_Short;
-utf* utf_java_lang_Integer;
-utf* utf_java_lang_Long;
-utf* utf_java_lang_Float;
-utf* utf_java_lang_Double;
-
-#if defined(ENABLE_JAVASE)
-utf *utf_java_lang_StackTraceElement;
-utf *utf_java_lang_reflect_Constructor;
-utf *utf_java_lang_reflect_Field;
-utf *utf_java_lang_reflect_Method;
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-utf *utf_java_lang_reflect_VMConstructor;
-utf *utf_java_lang_reflect_VMField;
-utf *utf_java_lang_reflect_VMMethod;
-# endif
-
-utf *utf_java_util_Vector;
-#endif
-
-utf *utf_InnerClasses;                  /* InnerClasses                       */
-utf *utf_ConstantValue;                 /* ConstantValue                      */
-utf *utf_Code;                          /* Code                               */
-utf *utf_Exceptions;                    /* Exceptions                         */
-utf *utf_LineNumberTable;               /* LineNumberTable                    */
-utf *utf_SourceFile;                    /* SourceFile                         */
-
-#if defined(ENABLE_JAVASE)
-utf *utf_EnclosingMethod;
-utf *utf_Signature;
-utf *utf_StackMapTable;
-
-#if defined(ENABLE_ANNOTATIONS)
-utf *utf_RuntimeVisibleAnnotations;            /* RuntimeVisibleAnnotations            */
-utf *utf_RuntimeInvisibleAnnotations;          /* RuntimeInvisibleAnnotations          */
-utf *utf_RuntimeVisibleParameterAnnotations;   /* RuntimeVisibleParameterAnnotations   */
-utf *utf_RuntimeInvisibleParameterAnnotations; /* RuntimeInvisibleParameterAnnotations */
-utf *utf_AnnotationDefault;                    /* AnnotationDefault                    */
-#endif
-#endif
-
-utf *utf_init;                          /* <init>                             */
-utf *utf_clinit;                        /* <clinit>                           */
-utf *utf_clone;                         /* clone                              */
-utf *utf_finalize;                      /* finalize                           */
-utf *utf_invoke;
-utf *utf_main;
-utf *utf_run;                           /* run                                */
-
-utf *utf_add;
-utf *utf_remove;
-utf *utf_addThread;
-utf *utf_removeThread;
-utf *utf_put;
-utf *utf_get;
-utf *utf_uncaughtException;
-utf *utf_value;
-
-utf *utf_fillInStackTrace;
-utf *utf_findNative;
-utf *utf_getSystemClassLoader;
-utf *utf_initCause;
-utf *utf_loadClass;
-utf *utf_loadClassInternal;
-utf *utf_printStackTrace;
-
-utf *utf_division_by_zero;
-
-utf *utf_Z;                             /* Z                                  */
-utf *utf_B;                             /* B                                  */
-utf *utf_C;                             /* C                                  */
-utf *utf_S;                             /* S                                  */
-utf *utf_I;                             /* I                                  */
-utf *utf_J;                             /* J                                  */
-utf *utf_F;                             /* F                                  */
-utf *utf_D;                             /* D                                  */
-
-utf *utf_void__void;                    /* ()V                                */
-utf *utf_boolean__void;                 /* (Z)V                               */
-utf *utf_byte__void;                    /* (B)V                               */
-utf *utf_char__void;                    /* (C)V                               */
-utf *utf_short__void;                   /* (S)V                               */
-utf *utf_int__void;                     /* (I)V                               */
-utf *utf_long__void;                    /* (J)V                               */
-utf *utf_float__void;                   /* (F)V                               */
-utf *utf_double__void;                  /* (D)V                               */
-
-utf *utf_void__java_lang_ClassLoader;   /* ()Ljava/lang/ClassLoader;          */
-utf *utf_void__java_lang_Object;        /* ()Ljava/lang/Object;               */
-utf *utf_void__java_lang_Throwable;     /* ()Ljava/lang/Throwable;            */
-utf *utf_java_lang_ClassLoader_java_lang_String__J;
-utf *utf_java_lang_Exception__V;        /* (Ljava/lang/Exception;)V           */
-utf *utf_java_lang_Object__java_lang_Object;
-utf *utf_java_lang_String__void;        /* (Ljava/lang/String;)V              */
-utf *utf_java_lang_String__java_lang_Class;
-utf *utf_java_lang_Thread__V;           /* (Ljava/lang/Thread;)V              */
-utf *utf_java_lang_Thread_java_lang_Throwable__V;
-utf *utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V;
-utf *utf_java_lang_Throwable__void;     /* (Ljava/lang/Throwable;)V           */
-utf *utf_java_lang_Throwable__java_lang_Throwable;
-
-utf *utf_not_named_yet;                 /* special name for unnamed classes   */
-utf *utf_null;
-utf *array_packagename;
-
-
-/* utf_init ********************************************************************
-
-   Initializes the utf8 subsystem.
-
-*******************************************************************************/
-
-void utf8_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("utf8_init");
-
-       /* create utf8 hashtable */
-
-       hashtable_utf = NEW(hashtable);
-
-       hashtable_create(hashtable_utf, HASHTABLE_UTF_SIZE);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               count_utf_len += sizeof(utf*) * hashtable_utf->size;
-#endif
-
-       /* create utf-symbols for pointer comparison of frequently used strings */
-
-       utf_java_lang_Object           = utf_new_char("java/lang/Object");
-
-       utf_java_lang_Class            = utf_new_char("java/lang/Class");
-       utf_java_lang_ClassLoader      = utf_new_char("java/lang/ClassLoader");
-       utf_java_lang_Cloneable        = utf_new_char("java/lang/Cloneable");
-       utf_java_lang_SecurityManager  = utf_new_char("java/lang/SecurityManager");
-       utf_java_lang_String           = utf_new_char("java/lang/String");
-       utf_java_lang_ThreadGroup      = utf_new_char("java/lang/ThreadGroup");
-
-       utf_java_lang_ref_SoftReference =
-               utf_new_char("java/lang/ref/SoftReference");
-
-       utf_java_lang_ref_WeakReference =
-               utf_new_char("java/lang/ref/WeakReference");
-
-       utf_java_lang_ref_PhantomReference =
-               utf_new_char("java/lang/ref/PhantomReference");
-
-       utf_java_io_Serializable       = utf_new_char("java/io/Serializable");
-
-       utf_java_lang_Throwable        = utf_new_char("java/lang/Throwable");
-       utf_java_lang_Error            = utf_new_char("java/lang/Error");
-
-       utf_java_lang_ClassCircularityError =
-               utf_new_char("java/lang/ClassCircularityError");
-
-       utf_java_lang_ClassFormatError = utf_new_char("java/lang/ClassFormatError");
-
-       utf_java_lang_ExceptionInInitializerError =
-               utf_new_char("java/lang/ExceptionInInitializerError");
-
-       utf_java_lang_IncompatibleClassChangeError =
-               utf_new_char("java/lang/IncompatibleClassChangeError");
-
-       utf_java_lang_InstantiationError =
-               utf_new_char("java/lang/InstantiationError");
-
-       utf_java_lang_InternalError    = utf_new_char("java/lang/InternalError");
-       utf_java_lang_LinkageError     = utf_new_char("java/lang/LinkageError");
-
-       utf_java_lang_NoClassDefFoundError =
-               utf_new_char("java/lang/NoClassDefFoundError");
-
-       utf_java_lang_OutOfMemoryError = utf_new_char("java/lang/OutOfMemoryError");
-
-       utf_java_lang_UnsatisfiedLinkError =
-               utf_new_char("java/lang/UnsatisfiedLinkError");
-
-       utf_java_lang_UnsupportedClassVersionError =
-               utf_new_char("java/lang/UnsupportedClassVersionError");
-
-       utf_java_lang_VerifyError      = utf_new_char("java/lang/VerifyError");
-
-       utf_java_lang_VirtualMachineError =
-               utf_new_char("java/lang/VirtualMachineError");
-
-#if defined(ENABLE_JAVASE)
-       utf_java_lang_AbstractMethodError =
-               utf_new_char("java/lang/AbstractMethodError");
-
-       utf_java_lang_NoSuchFieldError =
-               utf_new_char("java/lang/NoSuchFieldError");
-
-       utf_java_lang_NoSuchMethodError =
-               utf_new_char("java/lang/NoSuchMethodError");
-#endif
-
-       utf_java_lang_Exception        = utf_new_char("java/lang/Exception");
-
-       utf_java_lang_ArithmeticException =
-               utf_new_char("java/lang/ArithmeticException");
-
-       utf_java_lang_ArrayIndexOutOfBoundsException =
-               utf_new_char("java/lang/ArrayIndexOutOfBoundsException");
-
-       utf_java_lang_ArrayStoreException =
-               utf_new_char("java/lang/ArrayStoreException");
-
-       utf_java_lang_ClassCastException =
-               utf_new_char("java/lang/ClassCastException");
-
-       utf_java_lang_ClassNotFoundException =
-               utf_new_char("java/lang/ClassNotFoundException");
-
-       utf_java_lang_CloneNotSupportedException =
-               utf_new_char("java/lang/CloneNotSupportedException");
-
-       utf_java_lang_IllegalAccessException =
-               utf_new_char("java/lang/IllegalAccessException");
-
-       utf_java_lang_IllegalArgumentException =
-               utf_new_char("java/lang/IllegalArgumentException");
-
-       utf_java_lang_IllegalMonitorStateException =
-               utf_new_char("java/lang/IllegalMonitorStateException");
-
-       utf_java_lang_InstantiationException =
-               utf_new_char("java/lang/InstantiationException");
-
-       utf_java_lang_InterruptedException =
-               utf_new_char("java/lang/InterruptedException");
-
-       utf_java_lang_NegativeArraySizeException =
-               utf_new_char("java/lang/NegativeArraySizeException");
-
-       utf_java_lang_NullPointerException =
-               utf_new_char("java/lang/NullPointerException");
-
-       utf_java_lang_RuntimeException =
-               utf_new_char("java/lang/RuntimeException");
-
-       utf_java_lang_StringIndexOutOfBoundsException =
-               utf_new_char("java/lang/StringIndexOutOfBoundsException");
-
-       utf_java_lang_reflect_InvocationTargetException =
-               utf_new_char("java/lang/reflect/InvocationTargetException");
-
-       utf_java_security_PrivilegedActionException =
-               utf_new_char("java/security/PrivilegedActionException");
-#if defined(ENABLE_JAVASE)
-       utf_java_lang_Void             = utf_new_char("java/lang/Void");
-#endif
-
-       utf_java_lang_Boolean          = utf_new_char("java/lang/Boolean");
-       utf_java_lang_Byte             = utf_new_char("java/lang/Byte");
-       utf_java_lang_Character        = utf_new_char("java/lang/Character");
-       utf_java_lang_Short            = utf_new_char("java/lang/Short");
-       utf_java_lang_Integer          = utf_new_char("java/lang/Integer");
-       utf_java_lang_Long             = utf_new_char("java/lang/Long");
-       utf_java_lang_Float            = utf_new_char("java/lang/Float");
-       utf_java_lang_Double           = utf_new_char("java/lang/Double");
-
-#if defined(ENABLE_JAVASE)
-       utf_java_lang_StackTraceElement =
-               utf_new_char("java/lang/StackTraceElement");
-
-       utf_java_lang_reflect_Constructor =
-               utf_new_char("java/lang/reflect/Constructor");
-
-       utf_java_lang_reflect_Field    = utf_new_char("java/lang/reflect/Field");
-       utf_java_lang_reflect_Method   = utf_new_char("java/lang/reflect/Method");
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-       utf_java_lang_reflect_VMConstructor = utf_new_char("java/lang/reflect/VMConstructor");
-       utf_java_lang_reflect_VMField       = utf_new_char("java/lang/reflect/VMField");
-       utf_java_lang_reflect_VMMethod      = utf_new_char("java/lang/reflect/VMMethod");
-# endif
-
-       utf_java_util_Vector           = utf_new_char("java/util/Vector");
-#endif
-
-       utf_InnerClasses               = utf_new_char("InnerClasses");
-       utf_ConstantValue              = utf_new_char("ConstantValue");
-       utf_Code                       = utf_new_char("Code");
-       utf_Exceptions                 = utf_new_char("Exceptions");
-       utf_LineNumberTable            = utf_new_char("LineNumberTable");
-       utf_SourceFile                 = utf_new_char("SourceFile");
-
-#if defined(ENABLE_JAVASE)
-       utf_EnclosingMethod            = utf_new_char("EnclosingMethod");
-       utf_Signature                  = utf_new_char("Signature");
-       utf_StackMapTable              = utf_new_char("StackMapTable");
-
-# if defined(ENABLE_ANNOTATIONS)
-       utf_RuntimeVisibleAnnotations            = utf_new_char("RuntimeVisibleAnnotations");
-       utf_RuntimeInvisibleAnnotations          = utf_new_char("RuntimeInvisibleAnnotations");
-       utf_RuntimeVisibleParameterAnnotations   = utf_new_char("RuntimeVisibleParameterAnnotations");
-       utf_RuntimeInvisibleParameterAnnotations = utf_new_char("RuntimeInvisibleParameterAnnotations");
-       utf_AnnotationDefault                    = utf_new_char("AnnotationDefault");
-# endif
-#endif
-
-       utf_init                           = utf_new_char("<init>");
-       utf_clinit                         = utf_new_char("<clinit>");
-       utf_clone                      = utf_new_char("clone");
-       utf_finalize                   = utf_new_char("finalize");
-       utf_invoke                     = utf_new_char("invoke");
-       utf_main                       = utf_new_char("main");
-       utf_run                        = utf_new_char("run");
-
-       utf_add                        = utf_new_char("add");
-       utf_remove                     = utf_new_char("remove");
-       utf_addThread                  = utf_new_char("addThread");
-       utf_removeThread               = utf_new_char("removeThread");
-       utf_put                        = utf_new_char("put");
-       utf_get                        = utf_new_char("get");
-       utf_uncaughtException          = utf_new_char("uncaughtException");
-       utf_value                      = utf_new_char("value");
-
-       utf_fillInStackTrace           = utf_new_char("fillInStackTrace");
-       utf_findNative                 = utf_new_char("findNative");
-       utf_getSystemClassLoader       = utf_new_char("getSystemClassLoader");
-       utf_initCause                  = utf_new_char("initCause");
-       utf_loadClass                  = utf_new_char("loadClass");
-       utf_loadClassInternal          = utf_new_char("loadClassInternal");
-       utf_printStackTrace            = utf_new_char("printStackTrace");
-
-       utf_division_by_zero           = utf_new_char("/ by zero");
-
-       utf_Z                          = utf_new_char("Z");
-       utf_B                          = utf_new_char("B");
-       utf_C                          = utf_new_char("C");
-       utf_S                          = utf_new_char("S");
-       utf_I                          = utf_new_char("I");
-       utf_J                          = utf_new_char("J");
-       utf_F                          = utf_new_char("F");
-       utf_D                          = utf_new_char("D");
-
-       utf_void__void                 = utf_new_char("()V");
-       utf_boolean__void              = utf_new_char("(Z)V");
-       utf_byte__void                 = utf_new_char("(B)V");
-       utf_char__void                 = utf_new_char("(C)V");
-       utf_short__void                = utf_new_char("(S)V");
-       utf_int__void                  = utf_new_char("(I)V");
-       utf_long__void                 = utf_new_char("(J)V");
-       utf_float__void                = utf_new_char("(F)V");
-       utf_double__void               = utf_new_char("(D)V");
-       utf_void__java_lang_Object     = utf_new_char("()Ljava/lang/Object;");
-       utf_void__java_lang_Throwable  = utf_new_char("()Ljava/lang/Throwable;");
-
-       utf_void__java_lang_ClassLoader =
-               utf_new_char("()Ljava/lang/ClassLoader;");
-
-       utf_java_lang_ClassLoader_java_lang_String__J =
-               utf_new_char("(Ljava/lang/ClassLoader;Ljava/lang/String;)J");
-
-       utf_java_lang_Exception__V     = utf_new_char("(Ljava/lang/Exception;)V");
-
-       utf_java_lang_Object__java_lang_Object =
-               utf_new_char("(Ljava/lang/Object;)Ljava/lang/Object;");
-
-       utf_java_lang_String__void     = utf_new_char("(Ljava/lang/String;)V");
-
-       utf_java_lang_String__java_lang_Class =
-               utf_new_char("(Ljava/lang/String;)Ljava/lang/Class;");
-
-       utf_java_lang_Thread__V        = utf_new_char("(Ljava/lang/Thread;)V");
-
-       utf_java_lang_Thread_java_lang_Throwable__V =
-               utf_new_char("(Ljava/lang/Thread;Ljava/lang/Throwable;)V");
-
-       utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V =
-               utf_new_char("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V");
-
-       utf_java_lang_Throwable__void  = utf_new_char("(Ljava/lang/Throwable;)V");
-
-       utf_java_lang_Throwable__java_lang_Throwable =
-               utf_new_char("(Ljava/lang/Throwable;)Ljava/lang/Throwable;");
-
-       utf_null                       = utf_new_char("null");
-       utf_not_named_yet              = utf_new_char("\t<not_named_yet>");
-       array_packagename              = utf_new_char("\t<the array package>");
-}
-
-
-/* utf_hashkey *****************************************************************
-
-   The hashkey is computed from the utf-text by using up to 8
-   characters.  For utf-symbols longer than 15 characters 3 characters
-   are taken from the beginning and the end, 2 characters are taken
-   from the middle.
-
-*******************************************************************************/
-
-#define nbs(val) ((u4) *(++text) << val) /* get next byte, left shift by val  */
-#define fbs(val) ((u4) *(  text) << val) /* get first byte, left shift by val */
-
-u4 utf_hashkey(const char *text, u4 length)
-{
-       const char *start_pos = text;       /* pointer to utf text                */
-       u4 a;
-
-       switch (length) {
-       case 0: /* empty string */
-               return 0;
-
-       case 1: return fbs(0);
-       case 2: return fbs(0) ^ nbs(3);
-       case 3: return fbs(0) ^ nbs(3) ^ nbs(5);
-       case 4: return fbs(0) ^ nbs(2) ^ nbs(4) ^ nbs(6);
-       case 5: return fbs(0) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(6);
-       case 6: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(5) ^ nbs(6);
-       case 7: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6);
-       case 8: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7);
-
-       case 9:
-               a = fbs(0);
-               a ^= nbs(1);
-               a ^= nbs(2);
-               text++;
-               return a ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7) ^ nbs(8);
-
-       case 10:
-               a = fbs(0);
-               text++;
-               a ^= nbs(2);
-               a ^= nbs(3);
-               a ^= nbs(4);
-               text++;
-               return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9);
-
-       case 11:
-               a = fbs(0);
-               text++;
-               a ^= nbs(2);
-               a ^= nbs(3);
-               a ^= nbs(4);
-               text++;
-               return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9) ^ nbs(10);
-
-       case 12:
-               a = fbs(0);
-               text += 2;
-               a ^= nbs(2);
-               a ^= nbs(3);
-               text++;
-               a ^= nbs(5);
-               a ^= nbs(6);
-               a ^= nbs(7);
-               text++;
-               return a ^ nbs(9) ^ nbs(10);
-
-       case 13:
-               a = fbs(0);
-               a ^= nbs(1);
-               text++;
-               a ^= nbs(3);
-               a ^= nbs(4);
-               text += 2;      
-               a ^= nbs(7);
-               a ^= nbs(8);
-               text += 2;
-               return a ^ nbs(9) ^ nbs(10);
-
-       case 14:
-               a = fbs(0);
-               text += 2;      
-               a ^= nbs(3);
-               a ^= nbs(4);
-               text += 2;      
-               a ^= nbs(7);
-               a ^= nbs(8);
-               text += 2;
-               return a ^ nbs(9) ^ nbs(10) ^ nbs(11);
-
-       case 15:
-               a = fbs(0);
-               text += 2;      
-               a ^= nbs(3);
-               a ^= nbs(4);
-               text += 2;      
-               a ^= nbs(7);
-               a ^= nbs(8);
-               text += 2;
-               return a ^ nbs(9) ^ nbs(10) ^ nbs(11);
-
-       default:  /* 3 characters from beginning */
-               a = fbs(0);
-               text += 2;
-               a ^= nbs(3);
-               a ^= nbs(4);
-
-               /* 2 characters from middle */
-               text = start_pos + (length / 2);
-               a ^= fbs(5);
-               text += 2;
-               a ^= nbs(6);    
-
-               /* 3 characters from end */
-               text = start_pos + length - 4;
-
-               a ^= fbs(7);
-               text++;
-
-               return a ^ nbs(10) ^ nbs(11);
-    }
-}
-
-/* utf_full_hashkey ************************************************************
-
-   This function computes a hash value using all bytes in the string.
-
-   The algorithm is the "One-at-a-time" algorithm as published
-   by Bob Jenkins on http://burtleburtle.net/bob/hash/doobs.html.
-
-*******************************************************************************/
-
-u4 utf_full_hashkey(const char *text, u4 length)
-{
-       register const unsigned char *p = (const unsigned char *) text;
-       register u4 hash;
-       register u4 i;
-
-       hash = 0;
-       for (i=length; i--;)
-       {
-           hash += *p++;
-           hash += (hash << 10);
-           hash ^= (hash >> 6);
-       }
-       hash += (hash << 3);
-       hash ^= (hash >> 11);
-       hash += (hash << 15);
-
-       return hash;
-}
-
-/* unicode_hashkey *************************************************************
-
-   Compute the hashkey of a unicode string.
-
-*******************************************************************************/
-
-u4 unicode_hashkey(u2 *text, u2 len)
-{
-       return utf_hashkey((char *) text, len);
-}
-
-
-/* utf_new *********************************************************************
-
-   Creates a new utf-symbol, the text of the symbol is passed as a
-   u1-array. The function searches the utf-hashtable for a utf-symbol
-   with this text. On success the element returned, otherwise a new
-   hashtable element is created.
-
-   If the number of entries in the hashtable exceeds twice the size of
-   the hashtable slots a reorganization of the hashtable is done and
-   the utf symbols are copied to a new hashtable with doubled size.
-
-*******************************************************************************/
-
-utf *utf_new(const char *text, u2 length)
-{
-       u4 key;                             /* hashkey computed from utf-text     */
-       u4 slot;                            /* slot in hashtable                  */
-       utf *u;                             /* hashtable element                  */
-       u2 i;
-
-       LOCK_MONITOR_ENTER(hashtable_utf->header);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               count_utf_new++;
-#endif
-
-       key  = utf_hashkey(text, length);
-       slot = key & (hashtable_utf->size - 1);
-       u    = hashtable_utf->ptr[slot];
-
-       /* search external hash chain for utf-symbol */
-
-       while (u) {
-               if (u->blength == length) {
-                       /* compare text of hashtable elements */
-
-                       for (i = 0; i < length; i++)
-                               if (text[i] != u->text[i])
-                                       goto nomatch;
-                       
-#if defined(ENABLE_STATISTICS)
-                       if (opt_stat)
-                               count_utf_new_found++;
-#endif
-
-                       /* symbol found in hashtable */
-
-                       LOCK_MONITOR_EXIT(hashtable_utf->header);
-
-                       return u;
-               }
-
-       nomatch:
-               u = u->hashlink; /* next element in external chain */
-       }
-
-       /* location in hashtable found, create new utf element */
-
-       u = NEW(utf);
-
-       u->blength  = length;               /* length in bytes of utfstring       */
-       u->hashlink = hashtable_utf->ptr[slot]; /* link in external hashchain     */
-       u->text     = mem_alloc(length + 1);/* allocate memory for utf-text       */
-
-       memcpy(u->text, text, length);      /* copy utf-text                      */
-       u->text[length] = '\0';
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               count_utf_len += sizeof(utf) + length + 1;
-#endif
-
-       hashtable_utf->ptr[slot] = u;       /* insert symbol into table           */
-       hashtable_utf->entries++;           /* update number of entries           */
-
-       if (hashtable_utf->entries > (hashtable_utf->size * 2)) {
-
-        /* reorganization of hashtable, average length of the external
-           chains is approx. 2 */
-
-               hashtable *newhash;                              /* the new hashtable */
-               u4         i;
-               utf       *u;
-               utf       *nextu;
-               u4         slot;
-
-               /* create new hashtable, double the size */
-
-               newhash = hashtable_resize(hashtable_utf, hashtable_utf->size * 2);
-
-#if defined(ENABLE_STATISTICS)
-               if (opt_stat)
-                       count_utf_len += sizeof(utf*) * hashtable_utf->size;
-#endif
-
-               /* transfer elements to new hashtable */
-
-               for (i = 0; i < hashtable_utf->size; i++) {
-                       u = hashtable_utf->ptr[i];
-
-                       while (u) {
-                               nextu = u->hashlink;
-                               slot  = utf_hashkey(u->text, u->blength) & (newhash->size - 1);
-                                               
-                               u->hashlink = (utf *) newhash->ptr[slot];
-                               newhash->ptr[slot] = u;
-
-                               /* follow link in external hash chain */
-
-                               u = nextu;
-                       }
-               }
-       
-               /* dispose old table */
-
-               hashtable_free(hashtable_utf);
-
-               hashtable_utf = newhash;
-       }
-
-       LOCK_MONITOR_EXIT(hashtable_utf->header);
-
-       return u;
-}
-
-
-/* utf_new_u2 ******************************************************************
-
-   Make utf symbol from u2 array, if isclassname is true '.' is
-   replaced by '/'.
-
-*******************************************************************************/
-
-utf *utf_new_u2(u2 *unicode_pos, u4 unicode_length, bool isclassname)
-{
-       char *buffer;                   /* memory buffer for  unicode characters  */
-       char *pos;                      /* pointer to current position in buffer  */
-       u4 left;                        /* unicode characters left                */
-       u4 buflength;                   /* utf length in bytes of the u2 array    */
-       utf *result;                    /* resulting utf-string                   */
-       int i;          
-
-       /* determine utf length in bytes and allocate memory */
-
-       buflength = u2_utflength(unicode_pos, unicode_length); 
-       buffer    = MNEW(char, buflength);
-       left = buflength;
-       pos  = buffer;
-
-       for (i = 0; i++ < unicode_length; unicode_pos++) {
-               /* next unicode character */
-               u2 c = *unicode_pos;
-               
-               if ((c != 0) && (c < 0x80)) {
-                       /* 1 character */       
-                       left--;
-               if ((int) left < 0) break;
-                       /* convert classname */
-                       if (isclassname && c == '.')
-                               *pos++ = '/';
-                       else
-                               *pos++ = (char) c;
-
-               } else if (c < 0x800) {             
-                       /* 2 characters */                              
-               unsigned char high = c >> 6;
-               unsigned char low  = c & 0x3F;
-                       left = left - 2;
-               if ((int) left < 0) break;
-               *pos++ = high | 0xC0; 
-               *pos++ = low  | 0x80;     
-
-               } else {         
-               /* 3 characters */                              
-               char low  = c & 0x3f;
-               char mid  = (c >> 6) & 0x3F;
-               char high = c >> 12;
-                       left = left - 3;
-               if ((int) left < 0) break;
-               *pos++ = high | 0xE0; 
-               *pos++ = mid  | 0x80;  
-               *pos++ = low  | 0x80;   
-               }
-       }
-       
-       /* insert utf-string into symbol-table */
-       result = utf_new(buffer,buflength);
-
-       MFREE(buffer, char, buflength);
-
-       return result;
-}
-
-
-/* utf_new_char ****************************************************************
-
-   Creates a new utf symbol, the text for this symbol is passed as a
-   c-string ( = char* ).
-
-*******************************************************************************/
-
-utf *utf_new_char(const char *text)
-{
-       return utf_new(text, strlen(text));
-}
-
-
-/* utf_new_char_classname ******************************************************
-
-   Creates a new utf symbol, the text for this symbol is passed as a
-   c-string ( = char* ) "." characters are going to be replaced by
-   "/". Since the above function is used often, this is a separte
-   function, instead of an if.
-
-*******************************************************************************/
-
-utf *utf_new_char_classname(const char *text)
-{
-       if (strchr(text, '.')) {
-               char *txt = strdup(text);
-               char *end = txt + strlen(txt);
-               char *c;
-               utf *tmpRes;
-
-               for (c = txt; c < end; c++)
-                       if (*c == '.') *c = '/';
-
-               tmpRes = utf_new(txt, strlen(txt));
-               FREE(txt, 0);
-
-               return tmpRes;
-
-       } else
-               return utf_new(text, strlen(text));
-}
-
-
-/* utf_nextu2 ******************************************************************
-
-   Read the next unicode character from the utf string and increment
-   the utf-string pointer accordingly.
-
-   CAUTION: This function is unsafe for input that was not checked 
-            by is_valid_utf!
-
-*******************************************************************************/
-
-u2 utf_nextu2(char **utf_ptr)
-{
-    /* uncompressed unicode character */
-    u2 unicode_char = 0;
-    /* current position in utf text */ 
-    unsigned char *utf = (unsigned char *) (*utf_ptr);
-    /* bytes representing the unicode character */
-    unsigned char ch1, ch2, ch3;
-    /* number of bytes used to represent the unicode character */
-    int len = 0;
-       
-    switch ((ch1 = utf[0]) >> 4) {
-       default: /* 1 byte */
-               (*utf_ptr)++;
-               return (u2) ch1;
-       case 0xC: 
-       case 0xD: /* 2 bytes */
-               if (((ch2 = utf[1]) & 0xC0) == 0x80) {
-                       unsigned char high = ch1 & 0x1F;
-                       unsigned char low  = ch2 & 0x3F;
-                       unicode_char = (high << 6) + low;
-                       len = 2;
-               }
-               break;
-
-       case 0xE: /* 2 or 3 bytes */
-               if (((ch2 = utf[1]) & 0xC0) == 0x80) {
-                       if (((ch3 = utf[2]) & 0xC0) == 0x80) {
-                               unsigned char low  = ch3 & 0x3f;
-                               unsigned char mid  = ch2 & 0x3f;
-                               unsigned char high = ch1 & 0x0f;
-                               unicode_char = (((high << 6) + mid) << 6) + low;
-                               len = 3;
-                       } else
-                               len = 2;                                           
-               }
-               break;
-    }
-
-    /* update position in utf-text */
-    *utf_ptr = (char *) (utf + len);
-
-    return unicode_char;
-}
-
-
-/* utf_bytes *******************************************************************
-
-   Determine number of bytes (aka. octets) in the utf string.
-
-   IN:
-      u............utf string
-
-   OUT:
-      The number of octets of this utf string.
-         There is _no_ terminating zero included in this count.
-
-*******************************************************************************/
-
-u4 utf_bytes(utf *u)
-{
-       return u->blength;
-}
-
-
-/* utf_get_number_of_u2s_for_buffer ********************************************
-
-   Determine number of UTF-16 u2s in the given UTF-8 buffer
-
-   CAUTION: This function is unsafe for input that was not checked 
-            by is_valid_utf!
-
-   CAUTION: Use this function *only* when you want to convert an UTF-8 buffer
-   to an array of u2s (UTF-16) and want to know how many of them you will get.
-   All other uses of this function are probably wrong.
-
-   IN:
-      buffer........points to first char in buffer
-         blength.......number of _bytes_ in the buffer
-
-   OUT:
-      the number of u2s needed to hold this string in UTF-16 encoding.
-         There is _no_ terminating zero included in this count.
-
-   NOTE: Unlike utf_get_number_of_u2s, this function never throws an
-   exception.
-
-*******************************************************************************/
-
-u4 utf_get_number_of_u2s_for_buffer(const char *buffer, u4 blength)
-{
-       const char *endpos;                 /* points behind utf string           */
-       const char *utf_ptr;                /* current position in utf text       */
-       u4 len = 0;                         /* number of unicode characters       */
-
-       utf_ptr = buffer;
-       endpos = utf_ptr + blength;
-
-       while (utf_ptr < endpos) {
-               len++;
-               /* next unicode character */
-               utf_nextu2((char **)&utf_ptr);
-       }
-
-       assert(utf_ptr == endpos);
-
-       return len;
-}
-
-
-/* utf_get_number_of_u2s *******************************************************
-
-   Determine number of UTF-16 u2s in the utf string.
-
-   CAUTION: This function is unsafe for input that was not checked 
-            by is_valid_utf!
-
-   CAUTION: Use this function *only* when you want to convert a utf string
-   to an array of u2s and want to know how many of them you will get.
-   All other uses of this function are probably wrong.
-
-   IN:
-      u............utf string
-
-   OUT:
-      the number of u2s needed to hold this string in UTF-16 encoding.
-         There is _no_ terminating zero included in this count.
-         XXX 0 if a NullPointerException has been thrown (see below)
-
-*******************************************************************************/
-
-u4 utf_get_number_of_u2s(utf *u)
-{
-       char *endpos;                       /* points behind utf string           */
-       char *utf_ptr;                      /* current position in utf text       */
-       u4 len = 0;                         /* number of unicode characters       */
-
-       /* XXX this is probably not checked by most callers! Review this after */
-       /* the invalid uses of this function have been eliminated */
-       if (u == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       endpos = UTF_END(u);
-       utf_ptr = u->text;
-
-       while (utf_ptr < endpos) {
-               len++;
-               /* next unicode character */
-               utf_nextu2(&utf_ptr);
-       }
-
-       if (utf_ptr != endpos) {
-               /* string ended abruptly */
-               exceptions_throw_internalerror("Illegal utf8 string");
-               return 0;
-       }
-
-       return len;
-}
-
-
-/* utf8_safe_number_of_u2s *****************************************************
-
-   Determine number of UTF-16 u2s needed for decoding the given UTF-8 string.
-   (For invalid UTF-8 the U+fffd replacement character will be counted.)
-
-   This function is safe even for invalid UTF-8 strings.
-
-   IN:
-      text..........zero-terminated(!) UTF-8 string (may be invalid)
-                       must NOT be NULL
-         nbytes........strlen(text). (This is needed to completely emulate
-                       the RI).
-
-   OUT:
-      the number of u2s needed to hold this string in UTF-16 encoding.
-         There is _no_ terminating zero included in this count.
-
-*******************************************************************************/
-
-s4 utf8_safe_number_of_u2s(const char *text, s4 nbytes) {
-       register const unsigned char *t;
-       register s4 byte;
-       register s4 len;
-       register const unsigned char *tlimit;
-       s4 byte1;
-       s4 byte2;
-       s4 byte3;
-       s4 value;
-       s4 skip;
-
-       assert(text);
-       assert(nbytes >= 0);
-
-       len = 0;
-       t = (const unsigned char *) text;
-       tlimit = t + nbytes;
-
-       /* CAUTION: Keep this code in sync with utf8_safe_convert_to_u2s! */
-
-       while (1) {
-               byte = *t++;
-
-               if (byte & 0x80) {
-                       /* highest bit set, non-ASCII character */
-
-                       if ((byte & 0xe0) == 0xc0) {
-                               /* 2-byte: should be 110..... 10...... ? */
-
-                               if ((*t++ & 0xc0) == 0x80)
-                                       ; /* valid 2-byte */
-                               else
-                                       t--; /* invalid */
-                       }
-                       else if ((byte & 0xf0) == 0xe0) {
-                               /* 3-byte: should be 1110.... 10...... 10...... */
-                               /*                            ^t                */
-
-                               if (t + 2 > tlimit)
-                                       return len + 1; /* invalid, stop here */
-
-                               if ((*t++ & 0xc0) == 0x80) {
-                                       if ((*t++ & 0xc0) == 0x80)
-                                               ; /* valid 3-byte */
-                                       else
-                                               t--; /* invalid */
-                               }
-                               else
-                                       t--; /* invalid */
-                       }
-                       else if ((byte & 0xf8) == 0xf0) {
-                               /* 4-byte: should be 11110... 10...... 10...... 10...... */
-                               /*                            ^t                         */
-
-                               if (t + 3 > tlimit)
-                                       return len + 1; /* invalid, stop here */
-
-                               if (((byte1 = *t++) & 0xc0) == 0x80) {
-                                       if (((byte2 = *t++) & 0xc0) == 0x80) {
-                                               if (((byte3 = *t++) & 0xc0) == 0x80) {
-                                                       /* valid 4-byte UTF-8? */
-                                                       value = ((byte  & 0x07) << 18)
-                                                                 | ((byte1 & 0x3f) << 12)
-                                                                 | ((byte2 & 0x3f) <<  6)
-                                                                 | ((byte3 & 0x3f)      );
-
-                                                       if (value > 0x10FFFF)
-                                                               ; /* invalid */
-                                                       else if (value > 0xFFFF)
-                                                               len += 1; /* we need surrogates */
-                                                       else
-                                                               ; /* 16bit suffice */
-                                               }
-                                               else
-                                                       t--; /* invalid */
-                                       }
-                                       else
-                                               t--; /* invalid */
-                               }
-                               else
-                                       t--; /* invalid */
-                       }
-                       else if ((byte & 0xfc) == 0xf8) {
-                               /* invalid 5-byte */
-                               if (t + 4 > tlimit)
-                                       return len + 1; /* invalid, stop here */
-
-                               skip = 4;
-                               for (; skip && ((*t & 0xc0) == 0x80); --skip)
-                                       t++;
-                       }
-                       else if ((byte & 0xfe) == 0xfc) {
-                               /* invalid 6-byte */
-                               if (t + 5 > tlimit)
-                                       return len + 1; /* invalid, stop here */
-
-                               skip = 5;
-                               for (; skip && ((*t & 0xc0) == 0x80); --skip)
-                                       t++;
-                       }
-                       else
-                               ; /* invalid */
-               }
-               else {
-                       /* NUL */
-
-                       if (byte == 0)
-                               break;
-
-                       /* ASCII character, common case */
-               }
-
-               len++;
-       }
-
-       return len;
-}
-
-
-/* utf8_safe_convert_to_u2s ****************************************************
-
-   Convert the given UTF-8 string to UTF-16 into a pre-allocated buffer.
-   (Invalid UTF-8 will be replaced with the U+fffd replacement character.)
-   Use utf8_safe_number_of_u2s to determine the number of u2s to allocate.
-
-   This function is safe even for invalid UTF-8 strings.
-
-   IN:
-      text..........zero-terminated(!) UTF-8 string (may be invalid)
-                       must NOT be NULL
-         nbytes........strlen(text). (This is needed to completely emulate
-                                       the RI).
-         buffer........a preallocated array of u2s to receive the decoded
-                       string. Use utf8_safe_number_of_u2s to get the
-                                       required number of u2s for allocating this.
-
-*******************************************************************************/
-
-#define UNICODE_REPLACEMENT  0xfffd
-
-void utf8_safe_convert_to_u2s(const char *text, s4 nbytes, u2 *buffer) {
-       register const unsigned char *t;
-       register s4 byte;
-       register const unsigned char *tlimit;
-       s4 byte1;
-       s4 byte2;
-       s4 byte3;
-       s4 value;
-       s4 skip;
-
-       assert(text);
-       assert(nbytes >= 0);
-
-       t = (const unsigned char *) text;
-       tlimit = t + nbytes;
-
-       /* CAUTION: Keep this code in sync with utf8_safe_number_of_u2s! */
-
-       while (1) {
-               byte = *t++;
-
-               if (byte & 0x80) {
-                       /* highest bit set, non-ASCII character */
-
-                       if ((byte & 0xe0) == 0xc0) {
-                               /* 2-byte: should be 110..... 10...... */
-
-                               if (((byte1 = *t++) & 0xc0) == 0x80) {
-                                       /* valid 2-byte UTF-8 */
-                                       *buffer++ = ((byte  & 0x1f) << 6)
-                                                         | ((byte1 & 0x3f)     );
-                               }
-                               else {
-                                       *buffer++ = UNICODE_REPLACEMENT;
-                                       t--;
-                               }
-                       }
-                       else if ((byte & 0xf0) == 0xe0) {
-                               /* 3-byte: should be 1110.... 10...... 10...... */
-
-                               if (t + 2 > tlimit) {
-                                       *buffer++ = UNICODE_REPLACEMENT;
-                                       return;
-                               }
-
-                               if (((byte1 = *t++) & 0xc0) == 0x80) {
-                                       if (((byte2 = *t++) & 0xc0) == 0x80) {
-                                               /* valid 3-byte UTF-8 */
-                                               *buffer++ = ((byte  & 0x0f) << 12)
-                                                                 | ((byte1 & 0x3f) <<  6)
-                                                                 | ((byte2 & 0x3f)      );
-                                       }
-                                       else {
-                                               *buffer++ = UNICODE_REPLACEMENT;
-                                               t--;
-                                       }
-                               }
-                               else {
-                                       *buffer++ = UNICODE_REPLACEMENT;
-                                       t--;
-                               }
-                       }
-                       else if ((byte & 0xf8) == 0xf0) {
-                               /* 4-byte: should be 11110... 10...... 10...... 10...... */
-
-                               if (t + 3 > tlimit) {
-                                       *buffer++ = UNICODE_REPLACEMENT;
-                                       return;
-                               }
-
-                               if (((byte1 = *t++) & 0xc0) == 0x80) {
-                                       if (((byte2 = *t++) & 0xc0) == 0x80) {
-                                               if (((byte3 = *t++) & 0xc0) == 0x80) {
-                                                       /* valid 4-byte UTF-8? */
-                                                       value = ((byte  & 0x07) << 18)
-                                                                 | ((byte1 & 0x3f) << 12)
-                                                                 | ((byte2 & 0x3f) <<  6)
-                                                                 | ((byte3 & 0x3f)      );
-
-                                                       if (value > 0x10FFFF) {
-                                                               *buffer++ = UNICODE_REPLACEMENT;
-                                                       }
-                                                       else if (value > 0xFFFF) {
-                                                               /* we need surrogates */
-                                                               *buffer++ = 0xd800 | ((value >> 10) - 0x40);
-                                                               *buffer++ = 0xdc00 | (value & 0x03ff);
-                                                       }
-                                                       else
-                                                               *buffer++ = value; /* 16bit suffice */
-                                               }
-                                               else {
-                                                       *buffer++ = UNICODE_REPLACEMENT;
-                                                       t--;
-                                               }
-                                       }
-                                       else {
-                                               *buffer++ = UNICODE_REPLACEMENT;
-                                               t--;
-                                       }
-                               }
-                               else {
-                                       *buffer++ = UNICODE_REPLACEMENT;
-                                       t--;
-                               }
-                       }
-                       else if ((byte & 0xfc) == 0xf8) {
-                               if (t + 4 > tlimit) {
-                                       *buffer++ = UNICODE_REPLACEMENT;
-                                       return;
-                               }
-
-                               skip = 4;
-                               for (; skip && ((*t & 0xc0) == 0x80); --skip)
-                                       t++;
-                               *buffer++ = UNICODE_REPLACEMENT;
-                       }
-                       else if ((byte & 0xfe) == 0xfc) {
-                               if (t + 5 > tlimit) {
-                                       *buffer++ = UNICODE_REPLACEMENT;
-                                       return;
-                               }
-
-                               skip = 5;
-                               for (; skip && ((*t & 0xc0) == 0x80); --skip)
-                                       t++;
-                               *buffer++ = UNICODE_REPLACEMENT;
-                       }
-                       else
-                               *buffer++ = UNICODE_REPLACEMENT;
-               }
-               else {
-                       /* NUL */
-
-                       if (byte == 0)
-                               break;
-
-                       /* ASCII character, common case */
-
-                       *buffer++ = byte;
-               }
-       }
-}
-
-
-/* u2_utflength ****************************************************************
-
-   Returns the utf length in bytes of a u2 array.
-
-*******************************************************************************/
-
-u4 u2_utflength(u2 *text, u4 u2_length)
-{
-       u4 result_len = 0;                  /* utf length in bytes                */
-       u2 ch;                              /* current unicode character          */
-       u4 len;
-       
-       for (len = 0; len < u2_length; len++) {
-               /* next unicode character */
-               ch = *text++;
-         
-               /* determine bytes required to store unicode character as utf */
-               if (ch && (ch < 0x80)) 
-                       result_len++;
-               else if (ch < 0x800)
-                       result_len += 2;        
-               else 
-                       result_len += 3;        
-       }
-
-    return result_len;
-}
-
-
-/* utf_copy ********************************************************************
-
-   Copy the given utf string byte-for-byte to a buffer.
-
-   IN:
-      buffer.......the buffer
-         u............the utf string
-
-*******************************************************************************/
-
-void utf_copy(char *buffer, utf *u)
-{
-       /* our utf strings are zero-terminated (done by utf_new) */
-       MCOPY(buffer, u->text, char, u->blength + 1);
-}
-
-
-/* utf_cat *********************************************************************
-
-   Append the given utf string byte-for-byte to a buffer.
-
-   IN:
-      buffer.......the buffer
-         u............the utf string
-
-*******************************************************************************/
-
-void utf_cat(char *buffer, utf *u)
-{
-       /* our utf strings are zero-terminated (done by utf_new) */
-       MCOPY(buffer + strlen(buffer), u->text, char, u->blength + 1);
-}
-
-
-/* utf_copy_classname **********************************************************
-
-   Copy the given utf classname byte-for-byte to a buffer.
-   '/' is replaced by '.'
-
-   IN:
-      buffer.......the buffer
-         u............the utf string
-
-*******************************************************************************/
-
-void utf_copy_classname(char *buffer, utf *u)
-{
-       char *bufptr;
-       char *srcptr;
-       char *endptr;
-       char ch;
-
-       bufptr = buffer;
-       srcptr = u->text;
-       endptr = UTF_END(u) + 1; /* utfs are zero-terminared by utf_new */
-
-       while (srcptr != endptr) {
-               ch = *srcptr++;
-               if (ch == '/')
-                       ch = '.';
-               *bufptr++ = ch;
-       }
-}
-
-
-/* utf_cat *********************************************************************
-
-   Append the given utf classname byte-for-byte to a buffer.
-   '/' is replaced by '.'
-
-   IN:
-      buffer.......the buffer
-         u............the utf string
-
-*******************************************************************************/
-
-void utf_cat_classname(char *buffer, utf *u)
-{
-       utf_copy_classname(buffer + strlen(buffer), u);
-}
-
-/* utf_display_printable_ascii *************************************************
-
-   Write utf symbol to stdout (for debugging purposes).
-   Non-printable and non-ASCII characters are printed as '?'.
-
-*******************************************************************************/
-
-void utf_display_printable_ascii(utf *u)
-{
-       char *endpos;                       /* points behind utf string           */
-       char *utf_ptr;                      /* current position in utf text       */
-
-       if (u == NULL) {
-               printf("NULL");
-               fflush(stdout);
-               return;
-       }
-
-       endpos = UTF_END(u);
-       utf_ptr = u->text;
-
-       while (utf_ptr < endpos) {
-               /* read next unicode character */
-
-               u2 c = utf_nextu2(&utf_ptr);
-
-               if ((c >= 32) && (c <= 127))
-                       printf("%c", c);
-               else
-                       printf("?");
-       }
-
-       fflush(stdout);
-}
-
-
-/* utf_display_printable_ascii_classname ***************************************
-
-   Write utf symbol to stdout with `/' converted to `.' (for debugging
-   purposes).
-   Non-printable and non-ASCII characters are printed as '?'.
-
-*******************************************************************************/
-
-void utf_display_printable_ascii_classname(utf *u)
-{
-       char *endpos;                       /* points behind utf string           */
-       char *utf_ptr;                      /* current position in utf text       */
-
-       if (u == NULL) {
-               printf("NULL");
-               fflush(stdout);
-               return;
-       }
-
-       endpos = UTF_END(u);
-       utf_ptr = u->text;
-
-       while (utf_ptr < endpos) {
-               /* read next unicode character */
-
-               u2 c = utf_nextu2(&utf_ptr);
-
-               if (c == '/')
-                       c = '.';
-
-               if ((c >= 32) && (c <= 127))
-                       printf("%c", c);
-               else
-                       printf("?");
-       }
-
-       fflush(stdout);
-}
-
-
-/* utf_sprint_convert_to_latin1 ************************************************
-       
-   Write utf symbol into c-string (for debugging purposes).
-   Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield
-   invalid results.
-
-*******************************************************************************/
-
-void utf_sprint_convert_to_latin1(char *buffer, utf *u)
-{
-       char *endpos;                       /* points behind utf string           */
-       char *utf_ptr;                      /* current position in utf text       */
-       u2 pos = 0;                         /* position in c-string               */
-
-       if (!u) {
-               strcpy(buffer, "NULL");
-               return;
-       }
-
-       endpos = UTF_END(u);
-       utf_ptr = u->text;
-
-       while (utf_ptr < endpos) 
-               /* copy next unicode character */       
-               buffer[pos++] = utf_nextu2(&utf_ptr);
-
-       /* terminate string */
-       buffer[pos] = '\0';
-}
-
-
-/* utf_sprint_convert_to_latin1_classname **************************************
-       
-   Write utf symbol into c-string with `/' converted to `.' (for debugging
-   purposes).
-   Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield
-   invalid results.
-
-*******************************************************************************/
-
-void utf_sprint_convert_to_latin1_classname(char *buffer, utf *u)
-{
-       char *endpos;                       /* points behind utf string           */
-       char *utf_ptr;                      /* current position in utf text       */
-       u2 pos = 0;                         /* position in c-string               */
-
-       if (!u) {
-               strcpy(buffer, "NULL");
-               return;
-       }
-
-       endpos = UTF_END(u);
-       utf_ptr = u->text;
-
-       while (utf_ptr < endpos) {
-               /* copy next unicode character */       
-               u2 c = utf_nextu2(&utf_ptr);
-               if (c == '/') c = '.';
-               buffer[pos++] = c;
-       }
-
-       /* terminate string */
-       buffer[pos] = '\0';
-}
-
-
-/* utf_strcat_convert_to_latin1 ************************************************
-       
-   Like libc strcat, but uses an utf8 string.
-   Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield
-   invalid results.
-
-*******************************************************************************/
-
-void utf_strcat_convert_to_latin1(char *buffer, utf *u)
-{
-       utf_sprint_convert_to_latin1(buffer + strlen(buffer), u);
-}
-
-
-/* utf_strcat_convert_to_latin1_classname **************************************
-       
-   Like libc strcat, but uses an utf8 string.
-   Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield
-   invalid results.
-
-*******************************************************************************/
-
-void utf_strcat_convert_to_latin1_classname(char *buffer, utf *u)
-{
-       utf_sprint_convert_to_latin1_classname(buffer + strlen(buffer), u);
-}
-
-
-/* utf_fprint_printable_ascii **************************************************
-       
-   Write utf symbol into file.
-   Non-printable and non-ASCII characters are printed as '?'.
-
-*******************************************************************************/
-
-void utf_fprint_printable_ascii(FILE *file, utf *u)
-{
-       char *endpos;                       /* points behind utf string           */
-       char *utf_ptr;                      /* current position in utf text       */
-
-       if (!u)
-               return;
-
-       endpos = UTF_END(u);
-       utf_ptr = u->text;
-
-       while (utf_ptr < endpos) { 
-               /* read next unicode character */                
-               u2 c = utf_nextu2(&utf_ptr);                            
-
-               if (c >= 32 && c <= 127) fprintf(file, "%c", c);
-               else fprintf(file, "?");
-       }
-}
-
-
-/* utf_fprint_printable_ascii_classname ****************************************
-       
-   Write utf symbol into file with `/' converted to `.'.
-   Non-printable and non-ASCII characters are printed as '?'.
-
-*******************************************************************************/
-
-void utf_fprint_printable_ascii_classname(FILE *file, utf *u)
-{
-       char *endpos;                       /* points behind utf string           */
-       char *utf_ptr;                      /* current position in utf text       */
-
-    if (!u)
-               return;
-
-       endpos = UTF_END(u);
-       utf_ptr = u->text;
-
-       while (utf_ptr < endpos) { 
-               /* read next unicode character */                
-               u2 c = utf_nextu2(&utf_ptr);                            
-               if (c == '/') c = '.';
-
-               if (c >= 32 && c <= 127) fprintf(file, "%c", c);
-               else fprintf(file, "?");
-       }
-}
-
-
-/* is_valid_utf ****************************************************************
-
-   Return true if the given string is a valid UTF-8 string.
-
-   utf_ptr...points to first character
-   end_pos...points after last character
-
-*******************************************************************************/
-
-/*  static unsigned long min_codepoint[6] = {0,1L<<7,1L<<11,1L<<16,1L<<21,1L<<26}; */
-
-bool is_valid_utf(char *utf_ptr, char *end_pos)
-{
-       int bytes;
-       int len,i;
-       char c;
-       unsigned long v;
-
-       if (end_pos < utf_ptr) return false;
-       bytes = end_pos - utf_ptr;
-       while (bytes--) {
-               c = *utf_ptr++;
-
-               if (!c) return false;                     /* 0x00 is not allowed */
-               if ((c & 0x80) == 0) continue;            /* ASCII */
-
-               if      ((c & 0xe0) == 0xc0) len = 1;     /* 110x xxxx */
-               else if ((c & 0xf0) == 0xe0) len = 2;     /* 1110 xxxx */
-               else if ((c & 0xf8) == 0xf0) len = 3;     /* 1111 0xxx */
-               else if ((c & 0xfc) == 0xf8) len = 4;     /* 1111 10xx */
-               else if ((c & 0xfe) == 0xfc) len = 5;     /* 1111 110x */
-               else return false;                        /* invalid leading byte */
-
-               if (len > 2) return false;                /* Java limitation */
-
-               v = (unsigned long)c & (0x3f >> len);
-               
-               if ((bytes -= len) < 0) return false;     /* missing bytes */
-
-               for (i = len; i--; ) {
-                       c = *utf_ptr++;
-                       if ((c & 0xc0) != 0x80)               /* 10xx xxxx */
-                               return false;
-                       v = (v << 6) | (c & 0x3f);
-               }
-
-               if (v == 0) {
-                       if (len != 1) return false;           /* Java special */
-
-               } else {
-                       /* Sun Java seems to allow overlong UTF-8 encodings */
-                       
-                       /* if (v < min_codepoint[len]) */
-                               /* XXX throw exception? */
-               }
-
-               /* surrogates in UTF-8 seem to be allowed in Java classfiles */
-               /* if (v >= 0xd800 && v <= 0xdfff) return false; */ /* surrogates */
-
-               /* even these seem to be allowed */
-               /* if (v == 0xfffe || v == 0xffff) return false; */ /* invalid codepoints */
-       }
-
-       return true;
-}
-
-
-/* is_valid_name ***************************************************************
-
-   Return true if the given string may be used as a class/field/method
-   name. (Currently this only disallows empty strings and control
-   characters.)
-
-   NOTE: The string is assumed to have passed is_valid_utf!
-
-   utf_ptr...points to first character
-   end_pos...points after last character
-
-*******************************************************************************/
-
-bool is_valid_name(char *utf_ptr, char *end_pos)
-{
-       if (end_pos <= utf_ptr) return false; /* disallow empty names */
-
-       while (utf_ptr < end_pos) {
-               unsigned char c = *utf_ptr++;
-
-               if (c < 0x20) return false; /* disallow control characters */
-               if (c == 0xc0 && (unsigned char) *utf_ptr == 0x80)  /* disallow zero */
-                       return false;
-       }
-
-       return true;
-}
-
-bool is_valid_name_utf(utf *u)
-{
-       return is_valid_name(u->text, UTF_END(u));
-}
-
-
-/* utf_show ********************************************************************
-
-   Writes the utf symbols in the utfhash to stdout and displays the
-   number of external hash chains grouped according to the chainlength
-   (for debugging purposes).
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void utf_show(void)
-{
-
-#define CHAIN_LIMIT 20               /* limit for seperated enumeration */
-
-       u4 chain_count[CHAIN_LIMIT]; /* numbers of chains */
-       u4 max_chainlength = 0;      /* maximum length of the chains */
-       u4 sum_chainlength = 0;      /* sum of the chainlengths */
-       u4 beyond_limit = 0;         /* number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */
-       u4 i;
-
-       printf("UTF-HASH:\n");
-
-       /* show element of utf-hashtable */
-
-       for (i = 0; i < hashtable_utf->size; i++) {
-               utf *u = hashtable_utf->ptr[i];
-
-               if (u) {
-                       printf("SLOT %d: ", (int) i);
-
-                       while (u) {
-                               printf("'");
-                               utf_display_printable_ascii(u);
-                               printf("' ");
-                               u = u->hashlink;
-                       }       
-                       printf("\n");
-               }
-       }
-
-       printf("UTF-HASH: %d slots for %d entries\n", 
-                  (int) hashtable_utf->size, (int) hashtable_utf->entries );
-
-       if (hashtable_utf->entries == 0)
-               return;
-
-       printf("chains:\n  chainlength    number of chains    %% of utfstrings\n");
-
-       for (i=0;i<CHAIN_LIMIT;i++)
-               chain_count[i]=0;
-
-       /* count numbers of hashchains according to their length */
-       for (i=0; i<hashtable_utf->size; i++) {
-                 
-               utf *u = (utf*) hashtable_utf->ptr[i];
-               u4 chain_length = 0;
-
-               /* determine chainlength */
-               while (u) {
-                       u = u->hashlink;
-                       chain_length++;
-               }
-
-               /* update sum of all chainlengths */
-               sum_chainlength+=chain_length;
-
-               /* determine the maximum length of the chains */
-               if (chain_length>max_chainlength)
-                       max_chainlength = chain_length;
-
-               /* update number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */
-               if (chain_length>=CHAIN_LIMIT) {
-                       beyond_limit+=chain_length;
-                       chain_length=CHAIN_LIMIT-1;
-               }
-
-               /* update number of hashchains of current length */
-               chain_count[chain_length]++;
-       }
-
-       /* display results */  
-       for (i=1;i<CHAIN_LIMIT-1;i++) 
-               printf("       %2d %17d %18.2f%%\n",i,chain_count[i],(((float) chain_count[i]*i*100)/hashtable_utf->entries));
-         
-       printf("     >=%2d %17d %18.2f%%\n",CHAIN_LIMIT-1,chain_count[CHAIN_LIMIT-1],((float) beyond_limit*100)/hashtable_utf->entries);
-
-
-       printf("max. chainlength:%5d\n",max_chainlength);
-
-       /* avg. chainlength = sum of chainlengths / number of chains */
-       printf("avg. chainlength:%5.2f\n",(float) sum_chainlength / (hashtable_utf->size-chain_count[0]));
-}
-#endif /* !defined(NDEBUG) */
-
-
-/*
- * 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/vmcore/utf8.h b/src/vmcore/utf8.h
deleted file mode 100644 (file)
index 6f76610..0000000
+++ /dev/null
@@ -1,306 +0,0 @@
-/* src/vmcore/utf8.h - utf8 string 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.
-
-*/
-
-
-#ifndef _UTF_H
-#define _UTF_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct utf utf;
-
-#include "config.h"
-
-#include <stdio.h>
-
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-
-/* data structure for utf8 symbols ********************************************/
-
-struct utf {
-       utf  *hashlink;                     /* link for external hash chain       */
-       s4    blength;                      /* text length in bytes               */
-       char *text;                         /* pointer to text                    */
-};
-
-/* to determine the end of utf strings */
-
-#define UTF_END(u)    ((char *) u->text + u->blength)
-
-
-/* utf-symbols for pointer comparison of frequently used strings **************/
-
-extern utf *utf_java_lang_Object;
-
-extern utf *utf_java_lang_Class;
-extern utf *utf_java_lang_ClassLoader;
-extern utf *utf_java_lang_Cloneable;
-extern utf *utf_java_lang_SecurityManager;
-extern utf *utf_java_lang_String;
-extern utf *utf_java_lang_ThreadGroup;
-extern utf *utf_java_lang_ref_SoftReference;
-extern utf *utf_java_lang_ref_WeakReference;
-extern utf *utf_java_lang_ref_PhantomReference;
-extern utf *utf_java_io_Serializable;
-
-extern utf *utf_java_lang_Throwable;
-extern utf *utf_java_lang_Error;
-
-extern utf *utf_java_lang_AbstractMethodError;
-extern utf *utf_java_lang_ClassCircularityError;
-extern utf *utf_java_lang_ClassFormatError;
-extern utf *utf_java_lang_ExceptionInInitializerError;
-extern utf *utf_java_lang_IncompatibleClassChangeError;
-extern utf *utf_java_lang_InstantiationError;
-extern utf *utf_java_lang_InternalError;
-extern utf *utf_java_lang_LinkageError;
-extern utf *utf_java_lang_NoClassDefFoundError;
-extern utf *utf_java_lang_NoSuchFieldError;
-extern utf *utf_java_lang_NoSuchMethodError;
-extern utf *utf_java_lang_OutOfMemoryError;
-extern utf *utf_java_lang_UnsatisfiedLinkError;
-extern utf *utf_java_lang_UnsupportedClassVersionError;
-extern utf *utf_java_lang_VerifyError;
-extern utf *utf_java_lang_VirtualMachineError;
-
-extern utf *utf_java_lang_Exception;
-
-extern utf *utf_java_lang_ArithmeticException;
-extern utf *utf_java_lang_ArrayIndexOutOfBoundsException;
-extern utf *utf_java_lang_ArrayStoreException;
-extern utf *utf_java_lang_ClassCastException;
-extern utf *utf_java_lang_ClassNotFoundException;
-extern utf *utf_java_lang_CloneNotSupportedException;
-extern utf *utf_java_lang_IllegalAccessException;
-extern utf *utf_java_lang_IllegalArgumentException;
-extern utf *utf_java_lang_IllegalMonitorStateException;
-extern utf *utf_java_lang_InstantiationException;
-extern utf *utf_java_lang_InterruptedException;
-extern utf *utf_java_lang_NegativeArraySizeException;
-extern utf *utf_java_lang_NullPointerException;
-extern utf *utf_java_lang_RuntimeException;
-extern utf *utf_java_lang_StringIndexOutOfBoundsException;
-
-extern utf *utf_java_lang_reflect_InvocationTargetException;
-
-extern utf *utf_java_security_PrivilegedActionException;
-
-#if defined(ENABLE_JAVASE)
-extern utf* utf_java_lang_Void;
-#endif
-
-extern utf* utf_java_lang_Boolean;
-extern utf* utf_java_lang_Byte;
-extern utf* utf_java_lang_Character;
-extern utf* utf_java_lang_Short;
-extern utf* utf_java_lang_Integer;
-extern utf* utf_java_lang_Long;
-extern utf* utf_java_lang_Float;
-extern utf* utf_java_lang_Double;
-
-#if defined(ENABLE_JAVASE)
-extern utf *utf_java_lang_StackTraceElement;
-extern utf *utf_java_lang_reflect_Constructor;
-extern utf *utf_java_lang_reflect_Field;
-extern utf *utf_java_lang_reflect_Method;
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-extern utf *utf_java_lang_reflect_VMConstructor;
-extern utf *utf_java_lang_reflect_VMField;
-extern utf *utf_java_lang_reflect_VMMethod;
-# endif
-
-extern utf *utf_java_util_Vector;
-#endif
-
-extern utf *utf_InnerClasses;
-extern utf *utf_ConstantValue;
-extern utf *utf_Code;
-extern utf *utf_Exceptions;
-extern utf *utf_LineNumberTable;
-extern utf *utf_SourceFile;
-
-#if defined(ENABLE_JAVASE)
-extern utf *utf_EnclosingMethod;
-extern utf *utf_Signature;
-extern utf *utf_StackMapTable;
-
-#if defined(ENABLE_ANNOTATIONS)
-extern utf *utf_RuntimeVisibleAnnotations;
-extern utf *utf_RuntimeInvisibleAnnotations;
-extern utf *utf_RuntimeVisibleParameterAnnotations;
-extern utf *utf_RuntimeInvisibleParameterAnnotations;
-extern utf *utf_AnnotationDefault;
-#endif
-#endif
-
-extern utf *utf_init;
-extern utf *utf_clinit;
-extern utf *utf_clone;
-extern utf *utf_finalize;
-extern utf *utf_invoke;
-extern utf *utf_main;
-extern utf *utf_run;
-
-extern utf *utf_add;
-extern utf *utf_remove;
-extern utf *utf_addThread;
-extern utf *utf_removeThread;
-extern utf *utf_put;
-extern utf *utf_get;
-extern utf *utf_uncaughtException;
-extern utf *utf_value;
-
-extern utf *utf_fillInStackTrace;
-extern utf *utf_findNative;
-extern utf *utf_getSystemClassLoader;
-extern utf *utf_initCause;
-extern utf *utf_loadClass;
-extern utf *utf_loadClassInternal;
-extern utf *utf_printStackTrace;
-
-extern utf *utf_division_by_zero;
-
-extern utf *utf_Z;
-extern utf *utf_B;
-extern utf *utf_C;
-extern utf *utf_S;
-extern utf *utf_I;
-extern utf *utf_J;
-extern utf *utf_F;
-extern utf *utf_D;
-
-extern utf *utf_void__void;
-extern utf *utf_boolean__void;
-extern utf *utf_byte__void;
-extern utf *utf_char__void;
-extern utf *utf_short__void;
-extern utf *utf_int__void;
-extern utf *utf_long__void;
-extern utf *utf_float__void;
-extern utf *utf_double__void;
-
-extern utf *utf_void__java_lang_ClassLoader;
-extern utf *utf_void__java_lang_Object;
-extern utf *utf_void__java_lang_Throwable;
-extern utf *utf_java_lang_ClassLoader_java_lang_String__J;
-extern utf *utf_java_lang_Exception__V;
-extern utf *utf_java_lang_Object__java_lang_Object;
-extern utf *utf_java_lang_String__void;
-extern utf *utf_java_lang_String__java_lang_Class;
-extern utf *utf_java_lang_Thread__V;
-extern utf *utf_java_lang_Thread_java_lang_Throwable__V;
-extern utf *utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V;
-extern utf *utf_java_lang_Throwable__void;
-extern utf *utf_java_lang_Throwable__java_lang_Throwable;
-
-extern utf *utf_not_named_yet;
-extern utf *utf_null;
-extern utf *array_packagename;
-
-
-/* function prototypes ********************************************************/
-
-/* initialize the utf8 subsystem */
-void utf8_init(void);
-
-u4 utf_hashkey(const char *text, u4 length);
-u4 utf_full_hashkey(const char *text, u4 length);
-
-/* determine hashkey of a unicode-symbol */
-u4 unicode_hashkey(u2 *text, u2 length);
-
-/* create new utf-symbol */
-utf *utf_new(const char *text, u2 length);
-
-/* make utf symbol from u2 array */
-utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
-
-utf *utf_new_char(const char *text);
-utf *utf_new_char_classname(const char *text);
-
-/* get number of bytes */
-u4 utf_bytes(utf *u);
-
-/* get next unicode character of a utf-string */
-u2 utf_nextu2(char **utf);
-
-/* get (number of) unicode characters of a utf string (safe) */
-s4 utf8_safe_number_of_u2s(const char *text, s4 nbytes);
-void utf8_safe_convert_to_u2s(const char *text, s4 nbytes, u2 *buffer);
-
-/* get (number of) unicode characters of a utf string (UNSAFE!) */
-u4 utf_get_number_of_u2s(utf *u);
-u4 utf_get_number_of_u2s_for_buffer(const char *buffer, u4 blength);
-
-/* determine utf length in bytes of a u2 array */
-u4 u2_utflength(u2 *text, u4 u2_length);
-
-void utf_copy(char *buffer, utf *u);
-void utf_cat(char *buffer, utf *u);
-void utf_copy_classname(char *buffer, utf *u);
-void utf_cat_classname(char *buffer, utf *u);
-
-/* write utf symbol to file/buffer */
-void utf_display_printable_ascii(utf *u);
-void utf_display_printable_ascii_classname(utf *u);
-
-void utf_sprint_convert_to_latin1(char *buffer, utf *u);
-void utf_sprint_convert_to_latin1_classname(char *buffer, utf *u);
-
-void utf_strcat_convert_to_latin1(char *buffer, utf *u);
-void utf_strcat_convert_to_latin1_classname(char *buffer, utf *u);
-
-void utf_fprint_printable_ascii(FILE *file, utf *u);
-void utf_fprint_printable_ascii_classname(FILE *file, utf *u);
-
-/* check if a UTF-8 string is valid */
-bool is_valid_utf(char *utf_ptr, char *end_pos);
-
-/* check if a UTF-8 string may be used as a class/field/method name */
-bool is_valid_name(char *utf_ptr, char *end_pos);
-bool is_valid_name_utf(utf *u);
-
-/* show utf-table */
-void utf_show(void);
-
-#endif /* _UTF_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/vmcore/zip.c b/src/vmcore/zip.c
deleted file mode 100644 (file)
index c3644e2..0000000
+++ /dev/null
@@ -1,460 +0,0 @@
-/* src/vmcore/zip.c - ZIP file handling for bootstrap classloader
-
-   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 <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <zlib.h>
-#include <sys/mman.h>
-
-#include "vm/types.h"
-
-#include "toolbox/hashtable.h"
-
-#include "mm/memory.h"
-
-#include "vm/global.h"
-#include "vm/vm.h"
-
-#include "vmcore/suck.h"
-#include "vmcore/utf8.h"
-#include "vmcore/zip.h"
-
-
-/* start size for classes hashtable *******************************************/
-
-#define HASHTABLE_CLASSES_SIZE    (1 << 10)
-
-
-/* info taken from:
-   http://www.pkware.com/business_and_developers/developer/popups/appnote.txt
-*/
-
-/* all signatures in the ZIP file have a length of 4 bytes ********************/
-
-#define SIGNATURE_LENGTH    4
-
-/* Central directory structure *************************************************
-
-   [file header 1]
-   .
-   .
-   . 
-   [file header n]
-   [digital signature] 
-   
-   File header:
-   
-     central file header signature   4 bytes  (0x02014b50)
-     version made by                 2 bytes
-     version needed to extract       2 bytes
-     general purpose bit flag        2 bytes
-     compression method              2 bytes
-     last mod file time              2 bytes
-     last mod file date              2 bytes
-     crc-32                          4 bytes
-     compressed size                 4 bytes
-     uncompressed size               4 bytes
-     file name length                2 bytes
-     extra field length              2 bytes
-     file comment length             2 bytes
-     disk number start               2 bytes
-     internal file attributes        2 bytes
-     external file attributes        4 bytes
-     relative offset of local header 4 bytes
-   
-     file name (variable size)
-     extra field (variable size)
-     file comment (variable size)
-
-   Digital signature:
-   
-     header signature                4 bytes  (0x05054b50)
-     size of data                    2 bytes
-     signature data (variable size)
-
-*******************************************************************************/
-
-#define CDSFH_HEADER_SIZE            46
-
-#define CDSFH_SIGNATURE              0x02014b50
-#define CDSFH_COMPRESSION_METHOD     10
-#define CDSFH_COMPRESSED_SIZE        20
-#define CDSFH_UNCOMPRESSED_SIZE      24
-#define CDSFH_FILE_NAME_LENGTH       28
-#define CDSFH_EXTRA_FIELD_LENGTH     30
-#define CDSFH_FILE_COMMENT_LENGTH    32
-#define CDSFH_RELATIVE_OFFSET        42
-#define CDSFH_FILENAME               46
-
-typedef struct cdsfh cdsfh;
-
-struct cdsfh {
-       u2 compressionmethod;
-       u4 compressedsize;
-       u4 uncompressedsize;
-       u2 filenamelength;
-       u2 extrafieldlength;
-       u2 filecommentlength;
-       u4 relativeoffset;
-};
-
-
-/* End of central directory record *********************************************
-
-   end of central dir signature    4 bytes  (0x06054b50)
-   number of this disk             2 bytes
-   number of the disk with the
-   start of the central directory  2 bytes
-   total number of entries in the
-   central directory on this disk  2 bytes
-   total number of entries in
-   the central directory           2 bytes
-   size of the central directory   4 bytes
-   offset of start of central
-   directory with respect to
-   the starting disk number        4 bytes
-   .ZIP file comment length        2 bytes
-   .ZIP file comment       (variable size)
-
-*******************************************************************************/
-
-#define EOCDR_SIGNATURE              0x06054b50
-#define EOCDR_ENTRIES                10
-#define EOCDR_OFFSET                 16
-
-typedef struct eocdr eocdr;
-
-struct eocdr {
-       u2 entries;
-       u4 offset;
-};
-
-
-/* zip_open ********************************************************************
-
-   XXX
-
-*******************************************************************************/
-
-hashtable *zip_open(char *path)
-{
-       hashtable               *ht;
-       hashtable_zipfile_entry *htzfe;
-       int                      fd;
-       u1                       lfh_signature[SIGNATURE_LENGTH];
-       off_t                    len;
-       u1                      *filep;
-       s4                       i;
-       u1                      *p;
-       eocdr                    eocdr;
-       cdsfh                    cdsfh;
-       const char              *filename;
-       const char              *classext;
-       utf                     *u;
-       u4                       key;       /* hashkey computed from utf-text     */
-       u4                       slot;      /* slot in hashtable                  */
-
-       /* first of all, open the file */
-
-       if ((fd = open(path, O_RDONLY)) == -1)
-               return NULL;
-
-       /* check for signature in first local file header */
-
-       if (read(fd, lfh_signature, SIGNATURE_LENGTH) != SIGNATURE_LENGTH)
-               return NULL;
-
-       if (SUCK_LE_U4(lfh_signature) != LFH_SIGNATURE)
-               return NULL;
-
-       /* get the file length */
-
-       if ((len = lseek(fd, 0, SEEK_END)) == -1)
-               return NULL;
-
-       /* we better mmap the file */
-
-       filep = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0);
-
-       /* some older compilers, like DEC OSF cc, don't like comparisons
-       on void* types */
-
-       if ((ptrint) filep == (ptrint) MAP_FAILED)
-               return NULL;
-
-       /* find end of central directory record */
-
-       for (p = filep + len; p >= filep; p--)
-               if (SUCK_LE_U4(p) == EOCDR_SIGNATURE)
-                       break;
-
-       /* get number of entries in central directory */
-
-       eocdr.entries = SUCK_LE_U2(p + EOCDR_ENTRIES);
-       eocdr.offset  = SUCK_LE_U4(p + EOCDR_OFFSET);
-
-       /* create hashtable for filenames */
-
-       ht = NEW(hashtable);
-
-       hashtable_create(ht, HASHTABLE_CLASSES_SIZE);
-
-       /* add all file entries into the hashtable */
-
-       for (i = 0, p = filep + eocdr.offset; i < eocdr.entries; i++) {
-               /* check file header signature */
-
-               if (SUCK_LE_U4(p) != CDSFH_SIGNATURE)
-                       return NULL;
-
-               /* we found an entry */
-
-               cdsfh.compressionmethod = SUCK_LE_U2(p + CDSFH_COMPRESSION_METHOD);
-               cdsfh.compressedsize    = SUCK_LE_U4(p + CDSFH_COMPRESSED_SIZE);
-               cdsfh.uncompressedsize  = SUCK_LE_U4(p + CDSFH_UNCOMPRESSED_SIZE);
-               cdsfh.filenamelength    = SUCK_LE_U2(p + CDSFH_FILE_NAME_LENGTH);
-               cdsfh.extrafieldlength  = SUCK_LE_U2(p + CDSFH_EXTRA_FIELD_LENGTH);
-               cdsfh.filecommentlength = SUCK_LE_U2(p + CDSFH_FILE_COMMENT_LENGTH);
-               cdsfh.relativeoffset    = SUCK_LE_U4(p + CDSFH_RELATIVE_OFFSET);
-
-               /* create utf8 string of filename, strip .class from classes */
-
-               filename = (const char *) (p + CDSFH_FILENAME);
-               classext = filename + cdsfh.filenamelength - strlen(".class");
-
-               /* skip directory entries */
-
-               if (filename[cdsfh.filenamelength - 1] != '/') {
-                       if (strncmp(classext, ".class", strlen(".class")) == 0)
-                               u = utf_new(filename, cdsfh.filenamelength - strlen(".class"));
-                       else
-                               u = utf_new(filename, cdsfh.filenamelength);
-
-                       /* insert class into hashtable */
-
-                       htzfe = NEW(hashtable_zipfile_entry);
-
-                       htzfe->filename          = u;
-                       htzfe->compressionmethod = cdsfh.compressionmethod;
-                       htzfe->compressedsize    = cdsfh.compressedsize;
-                       htzfe->uncompressedsize  = cdsfh.uncompressedsize;
-                       htzfe->data              = filep + cdsfh.relativeoffset;
-
-                       /* get hashtable slot */
-
-                       key  = utf_hashkey(u->text, u->blength);
-                       slot = key & (ht->size - 1);
-
-                       /* insert into external chain */
-
-                       htzfe->hashlink = ht->ptr[slot];
-
-                       /* insert hashtable zipfile entry */
-
-                       ht->ptr[slot] = htzfe;
-                       ht->entries++;
-               }
-
-               /* move to next central directory structure file header */
-
-               p = p +
-                       CDSFH_HEADER_SIZE +
-                       cdsfh.filenamelength +
-                       cdsfh.extrafieldlength +
-                       cdsfh.filecommentlength;
-       }
-
-       /* return pointer to hashtable */
-
-       return ht;
-}
-
-
-/* zip_find ********************************************************************
-
-   Search for the given filename in the classpath entries of a zip file.
-
-   NOTE: The '.class' extension is stripped when reading a zip file, so if
-   you want to find a .class file, you must search for its name _without_
-   the '.class' extension. 
-   XXX I dont like that, it makes foo and foo.class ambiguous. -Edwin
-
-   IN:
-      lce..........the classpath entries for the zip file
-         u............the filename to look for
-
-   RETURN VALUE:
-      hashtable_zipfile_entry * of the entry if found, or
-         NULL if not found
-
-*******************************************************************************/
-
-hashtable_zipfile_entry *zip_find(list_classpath_entry *lce, utf *u)
-{
-       hashtable               *ht;
-       u4                       key;       /* hashkey computed from utf-text     */
-       u4                       slot;      /* slot in hashtable                  */
-       hashtable_zipfile_entry *htzfe;     /* hashtable element                  */
-
-       /* get classes hashtable from the classpath entry */
-
-       ht = lce->htclasses;
-
-       /* get the hashtable slot of the name searched */
-
-       key   = utf_hashkey(u->text, u->blength);
-       slot  = key & (ht->size - 1);
-       htzfe = ht->ptr[slot];
-
-       /* search external hash chain for utf-symbol */
-
-       while (htzfe) {
-               if (htzfe->filename == u)
-                       return htzfe;
-
-               /* next element in external chain */
-
-               htzfe = htzfe->hashlink;
-       }
-
-       /* file not found in this archive */
-
-       return NULL;
-}
-
-
-/* zip_get ********************************************************************
-
-   XXX
-
-*******************************************************************************/
-
-classbuffer *zip_get(list_classpath_entry *lce, classinfo *c)
-{
-       hashtable_zipfile_entry *htzfe;
-       lfh                      lfh;
-       u1                      *indata;
-       u1                      *outdata;
-       z_stream                 zs;
-       int                      err;
-       classbuffer             *cb;
-
-       /* try to find the class in the current archive */
-
-       htzfe = zip_find(lce, c->name);
-
-       if (htzfe == NULL)
-               return NULL;
-
-       /* read stuff from local file header */
-
-       lfh.filenamelength   = SUCK_LE_U2(htzfe->data + LFH_FILE_NAME_LENGTH);
-       lfh.extrafieldlength = SUCK_LE_U2(htzfe->data + LFH_EXTRA_FIELD_LENGTH);
-
-       indata = htzfe->data +
-               LFH_HEADER_SIZE +
-               lfh.filenamelength +
-               lfh.extrafieldlength;
-
-       /* allocate buffer for uncompressed data */
-
-       outdata = MNEW(u1, htzfe->uncompressedsize);
-
-       /* how is the file stored? */
-
-       switch (htzfe->compressionmethod) {
-       case Z_DEFLATED:
-               /* fill z_stream structure */
-
-               zs.next_in   = indata;
-               zs.avail_in  = htzfe->compressedsize;
-               zs.next_out  = outdata;
-               zs.avail_out = htzfe->uncompressedsize;
-
-               zs.zalloc = Z_NULL;
-               zs.zfree  = Z_NULL;
-               zs.opaque = Z_NULL;
-
-               /* initialize this inflate run */
-
-               if (inflateInit2(&zs, -MAX_WBITS) != Z_OK)
-                       vm_abort("zip_get: inflateInit2 failed: %s", strerror(errno));
-
-               /* decompress the file into buffer */
-
-               err = inflate(&zs, Z_SYNC_FLUSH);
-
-               if ((err != Z_STREAM_END) && (err != Z_OK))
-                       vm_abort("zip_get: inflate failed: %s", strerror(errno));
-
-               /* finish this inflate run */
-
-               if (inflateEnd(&zs) != Z_OK)
-                       vm_abort("zip_get: inflateEnd failed: %s", strerror(errno));
-               break;
-
-       case 0:
-               /* uncompressed file, just copy the data */
-               MCOPY(outdata, indata, u1, htzfe->compressedsize);
-               break;
-
-       default:
-               vm_abort("zip_get: unknown compression method %d",
-                                htzfe->compressionmethod);
-       }
-       
-       /* allocate classbuffer */
-
-       cb = NEW(classbuffer);
-
-       cb->clazz = c;
-       cb->size  = htzfe->uncompressedsize;
-       cb->data  = outdata;
-       cb->pos   = outdata;
-       cb->path  = lce->path;
-
-       /* return the filled classbuffer structure */
-
-       return cb;
-}
-
-
-/*
- * 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/vmcore/zip.h b/src/vmcore/zip.h
deleted file mode 100644 (file)
index 0d09aa5..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* src/vmcore/zip.c - ZIP file handling for bootstrap classloader
-
-   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
-
-   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 _ZIP_H
-#define _ZIP_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "toolbox/hashtable.h"
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/suck.h"
-#include "vmcore/utf8.h"
-
-
-/* Local file header ***********************************************************
-
-   local file header signature     4 bytes  (0x04034b50)
-   version needed to extract       2 bytes
-   general purpose bit flag        2 bytes
-   compression method              2 bytes
-   last mod file time              2 bytes
-   last mod file date              2 bytes
-   crc-32                          4 bytes
-   compressed size                 4 bytes
-   uncompressed size               4 bytes
-   file name length                2 bytes
-   extra field length              2 bytes
-
-   file name (variable size)
-   extra field (variable size)
-
-*******************************************************************************/
-
-#define LFH_HEADER_SIZE              30
-
-#define LFH_SIGNATURE                0x04034b50
-#define LFH_FILE_NAME_LENGTH         26
-#define LFH_EXTRA_FIELD_LENGTH       28
-
-typedef struct lfh lfh;
-
-struct lfh {
-       u2 compressionmethod;
-       u4 compressedsize;
-       u4 uncompressedsize;
-       u2 filenamelength;
-       u2 extrafieldlength;
-};
-
-/* hashtable_zipfile_entry ****************************************************/
-
-typedef struct hashtable_zipfile_entry hashtable_zipfile_entry;
-
-struct hashtable_zipfile_entry {
-       utf                     *filename;
-       u2                       compressionmethod;
-       u4                       compressedsize;
-       u4                       uncompressedsize;
-       u1                      *data;
-       hashtable_zipfile_entry *hashlink;
-};
-
-
-/* function prototypes ********************************************************/
-
-hashtable *zip_open(char *path);
-hashtable_zipfile_entry *zip_find(list_classpath_entry *lce, utf *u);
-classbuffer *zip_get(list_classpath_entry *lce, classinfo *c);
-
-#endif /* _ZIP_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:
- */
index 1481cac0bbb04c5f1a577c87fb544c79a10d9cd2..3f58045eedcb0f4c4994aa60dbe5ea555cba543f 100644 (file)
 
 
 SUBDIRS = \
+       base \
        assertion \
        bugzilla \
        jasmin \
-       junit \
        native \
        resolving
 
diff --git a/tests/regression/base/All.java b/tests/regression/base/All.java
new file mode 100644 (file)
index 0000000..9d9c8e8
--- /dev/null
@@ -0,0 +1,37 @@
+/* tests/regression/junit/All.java - runs all CACAO regression unit tests
+
+   Copyright (C) 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.
+
+*/
+
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+
+@Suite.SuiteClasses({
+TestExceptionInStaticClassInitializer.class,
+TestPatcher.class
+})
+
+public class All {
+}
diff --git a/tests/regression/base/Makefile.am b/tests/regression/base/Makefile.am
new file mode 100644 (file)
index 0000000..a00fc60
--- /dev/null
@@ -0,0 +1,49 @@
+## tests/regression/junit/Makefile.am
+##
+## Copyright (C) 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.
+
+
+JAVA     = LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs $(top_builddir)/src/cacao/cacao
+JAVACMD  = $(JAVA) -Xbootclasspath:$(BOOTCLASSPATH)
+JAVACCMD = $(JAVAC) -source 1.5 -target 1.5 -nowarn -bootclasspath $(BOOTCLASSPATH)
+
+EXTRA_DIST = \
+       $(srcdir)/*.java
+
+CLEANFILES = \
+       *.class
+
+check: build run
+
+build:
+       $(JAVACCMD) -classpath $(JUNIT_JAR) -d . $(srcdir)/*.java
+
+run:
+       $(JAVACMD) -classpath $(JUNIT_JAR):. org.junit.runner.JUnitCore All
+
+
+## Local variables:
+## mode: Makefile
+## indent-tabs-mode: t
+## c-basic-offset: 4
+## tab-width: 8
+## compile-command: "automake --add-missing"
+## End:
diff --git a/tests/regression/base/TestExceptionInStaticClassInitializer.java b/tests/regression/base/TestExceptionInStaticClassInitializer.java
new file mode 100644 (file)
index 0000000..61ab65c
--- /dev/null
@@ -0,0 +1,59 @@
+/* tests/regression/bugzilla/TestExceptionInStaticClassInitializer.java
+
+   Copyright (C) 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.
+
+*/
+
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class TestExceptionInStaticClassInitializer {
+    @Test
+    public void test() {
+        try {
+            TestExceptionInStaticClassInitializer_x.i = 1;
+            fail("Should throw ExceptionInInitializerError");
+        }
+        catch (ExceptionInInitializerError success) {
+            Throwable cause = success.getCause();
+
+            assertTrue("Cause should be RuntimeException but is " + cause.getClass(), cause.getClass() == RuntimeException.class);
+
+            StackTraceElement[] ste = cause.getStackTrace();
+
+            assertTrue("Linenumber should be " + LINE + " but is " + ste[0].getLineNumber(), ste[0].getLineNumber() == LINE);
+        }
+    }
+
+    // This linenumber must be the one from...
+    final static int LINE = 57;
+}
+
+class TestExceptionInStaticClassInitializer_x {
+    static int i;
+
+    static {
+        if (true)
+            // ...the following line.
+            throw new RuntimeException();
+    }
+}
diff --git a/tests/regression/base/TestPatcher.java b/tests/regression/base/TestPatcher.java
new file mode 100644 (file)
index 0000000..cbf8a13
--- /dev/null
@@ -0,0 +1,643 @@
+/* tests/regression/bugzilla/TestPatcher.java
+
+   Copyright (C) 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.
+
+*/
+
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import java.io.*;
+
+public class TestPatcher {
+    static boolean doit = true;
+
+    final static int    i = 123;
+    final static long   l = 1234567890123L;
+    final static float  f = 123.456F;
+    final static double d = 789.012;
+    final static Object o = new Object();
+
+    @Test
+    public void testNormal() {
+        invokestatic();
+        invokespecial();
+
+        getstatic();
+        putstatic();
+        putstaticconst();
+
+        getfield();
+        putfield();
+        putfieldconst();
+
+        newarray();
+        multianewarray();
+
+        checkcast();
+        _instanceof();
+
+        aastoreconst();
+    }
+
+    public void testWithoutClasses() {
+        // Delete all classes.
+        //new File("TestPatcher$invokestatic.class").delete();
+
+        invokestatic();
+        invokespecial();
+
+        getstatic();
+        putstatic();
+        putstaticconst();
+
+        getfield();
+        putfield();
+        putfieldconst();
+
+        newarray();
+        multianewarray();
+
+        checkcast();
+        _instanceof();
+
+        aastoreconst();
+    }
+
+    private void invokestatic() {
+        try {
+            if (doit)
+                invokestatic.sub();
+        } catch (NoClassDefFoundError e) {
+            fail(e.toString());
+        }
+    }
+
+    private void getstatic() {
+        try {
+            if (doit)
+                assertTrue(getstaticI.i + " != " + i, getstaticI.i == i);
+        } catch (NoClassDefFoundError e) {
+            fail(e.toString());
+        }
+
+        try {
+            if (doit)
+                assertTrue(getstaticJ.l + " != " + l, getstaticJ.l == l);
+        } catch (NoClassDefFoundError e) {
+            fail(e.toString());
+        }
+
+        try {
+            if (doit)
+                assertTrue(getstaticF.f + " != " + f, getstaticF.f == f);
+        } catch (NoClassDefFoundError e) {
+            fail(e.toString());
+        }
+
+        try {
+            if (doit)
+                assertTrue(getstaticD.d + " != " + d, getstaticD.d == d);
+        } catch (NoClassDefFoundError e) {
+            fail(e.toString());
+        }
+
+        try {
+            if (doit)
+                assertTrue(getstaticL.o + " != null", getstaticL.o == null);
+        } catch (NoClassDefFoundError e) {
+            fail(e.toString());
+        }
+    }
+
+    private void putstatic() {
+        try {
+            if (doit) {
+                putstaticI.i = i;
+                assertTrue(putstaticI.i + " != " + i, putstaticI.i == i);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticJ.l = l;
+                assertTrue(putstaticJ.l + " != " + l, putstaticJ.l == l);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticF.f = f;
+                assertTrue(putstaticF.f + " != " + f, putstaticF.f == f);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticD.d = d;
+                assertTrue(putstaticD.d + " != " + d, putstaticD.d == d);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+
+        try {
+            if (doit) {
+                putstaticL.o = o;
+                assertTrue(putstaticL.o + " != " + o, putstaticL.o == o);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+    }
+
+    private void putstaticconst() {
+        try {
+            if (doit) {
+                putstaticconstI.i = i;
+                assertTrue(putstaticconstI.i + " != " + i, putstaticconstI.i == i);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticconstJ.l = l;
+                assertTrue(putstaticconstJ.l + " != " + l, putstaticconstJ.l == l);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticconstF.f = f;
+                assertTrue(putstaticconstF.f + " != " + f, putstaticconstF.f == f);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticconstD.d = d;
+                assertTrue(putstaticconstD.d + " != " + d, putstaticconstD.d == d);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticconstI.i = 0;
+                assertTrue(putstaticconstI.i + " != " + 0, putstaticconstI.i == 0);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticconstJ.l = 0L;
+                assertTrue(putstaticconstJ.l + " != " + 0L, putstaticconstJ.l == 0L);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticconstF.f = 0.0F;
+                assertTrue(putstaticconstF.f + " != " + 0.0F, putstaticconstF.f == 0.0F);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticconstD.d = 0.0;
+                assertTrue(putstaticconstD.d + " != " + 0.0, putstaticconstD.d == 0.0);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticconstL.o = null;
+                assertTrue(putstaticconstL.o + " != " + null, putstaticconstL.o == null);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putstaticconstC.c = putstaticconstC.class;
+                assertTrue(putstaticconstC.c + " != " + Class.forName("TestPatcher$putstaticconstC"), putstaticconstC.c == Class.forName("TestPatcher$putstaticconstC"));
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        } catch (ClassNotFoundException t) {
+            fail(t.toString());
+        }
+    }
+
+    private void getfield() {
+        try {
+            if (doit)
+                assertTrue(new getfieldI().i + " != " + i, new getfieldI().i == i);
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit)
+                assertTrue(new getfieldJ().l + " != " + l, new getfieldJ().l == l);
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit)
+                assertTrue(new getfieldF().f + " != " + f, new getfieldF().f == f);
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit)
+                assertTrue(new getfieldD().d + " != " + d, new getfieldD().d == d);
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit)
+                assertTrue(new getfieldL().o + " != " + null, new getfieldL().o == null);
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+    }
+
+    private void putfield() {
+        try {
+            if (doit) {
+                TestPatcher.putfieldI pfi = new TestPatcher.putfieldI();
+                pfi.i = i;
+                assertTrue(pfi.i + " != " + i, pfi.i == i);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putfieldJ pfj = new putfieldJ();
+                pfj.l = l;
+                assertTrue(pfj.l + " != " + l, pfj.l == l);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putfieldF pff = new putfieldF();
+                pff.f = f;
+                assertTrue(pff.f + " != " + f, pff.f == f);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putfieldD pfd = new putfieldD();
+                pfd.d = d;
+                assertTrue(pfd.d + " != " + d, pfd.d == d);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putfieldL pfl = new putfieldL();
+                pfl.o = o;
+                assertTrue(pfl.o + " != " + o, pfl.o == o);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+    }
+
+    private void putfieldconst() {
+        try {
+            if (doit) {
+                putfieldconstI pfci = new putfieldconstI();
+                pfci.i = i;
+                assertTrue(pfci.i + " != " + i, pfci.i == i);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+        try {
+            if (doit) {
+                putfieldconstJ pfcj = new putfieldconstJ();
+                pfcj.l = l;
+                assertTrue(pfcj.l + " != " + l, pfcj.l == l);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putfieldconstF pfcf = new putfieldconstF();
+                pfcf.f = f;
+                assertTrue(pfcf.f + " != " + f, pfcf.f == f);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+        try {
+            if (doit) {
+                putfieldconstD pfcd = new putfieldconstD();
+                pfcd.d = d;
+                assertTrue(pfcd.d + " != " + d, pfcd.d == d);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putfieldconstI pfci = new putfieldconstI();
+                pfci.i = 0;
+                assertTrue(pfci.i + " != " + 0, pfci.i == 0);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+        try {
+            if (doit) {
+                putfieldconstJ pfcj = new putfieldconstJ();
+                pfcj.l = 0L;
+                assertTrue(pfcj.l + " != " + 0L, pfcj.l == 0L);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putfieldconstF pfcf = new putfieldconstF();
+                pfcf.f = 0.0F;
+                assertTrue(pfcf.f + " != " + 0.0F, pfcf.f == 0.0F);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+        try {
+            if (doit) {
+                putfieldconstD pfcd = new putfieldconstD();
+                pfcd.d = 0.0;
+                assertTrue(pfcd.d + " != " + 0.0, pfcd.d == 0.0);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putfieldconstL pfcl = new putfieldconstL();
+                pfcl.o = null;
+                assertTrue(pfcl.o + " != " + null, pfcl.o == null);
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit) {
+                putfieldconstC pfcc = new putfieldconstC();
+                pfcc.c = putfieldconstC.class;
+                assertTrue(pfcc.c + " != " + Class.forName("TestPatcher$putfieldconstC"), pfcc.c == Class.forName("TestPatcher$putfieldconstC"));
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        } catch (ClassNotFoundException t) {
+            fail(t.toString());
+        }
+    }
+
+    private void newarray() {
+        try {
+            if (doit) {
+                newarray[] na = new newarray[1];
+                na[0] = null;
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+    }
+
+    private void multianewarray() {
+        try {
+            if (doit) {
+                multianewarray[][] ma = new multianewarray[1][1];
+                ma[0][0] = null;
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+    }
+
+    private void invokespecial() {
+        try {
+            if (doit)
+                new invokespecial();
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+    }
+
+    private void checkcast() {
+        Object o = new Object();
+
+        // class
+        try {
+            if (doit) {
+                checkcastC cc = (checkcastC) o;
+                fail();
+            }
+        } catch (ClassCastException success) {
+            // This is OK.
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        // interface
+        try {
+            if (doit) {
+                checkcastI ci = (checkcastI) o;
+                fail();
+            }
+        } catch (ClassCastException success) {
+            // This is OK.
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+
+        // array
+        Object[] oa = new Object[1];
+
+        try {
+            if (doit) {
+                checkcastC[] cca = (checkcastC[]) oa;
+                fail();
+            }
+        } catch (ClassCastException e) {
+            // This is OK.
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+    }
+
+    private void _instanceof() {
+        Object o = new Object();
+
+        try {
+            if (doit)
+                if (o instanceof instanceofC)
+                    fail();
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+        try {
+            if (doit)
+                if (o instanceof instanceofI)
+                    fail();
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+
+
+        // array
+        Object[] oa = new Object[1];
+
+        try {
+            if (doit)
+                if (oa instanceof instanceofC[])
+                    fail();
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        }
+    }
+
+    private void aastoreconst() {
+        Class[] ca = new Class[1];
+
+        try {
+            if (doit) {
+                ca[0] = aastoreconstClass.class;
+
+                if (ca[0] == null)
+                    fail();
+
+                assertTrue(ca[0] + " != " + Class.forName("TestPatcher$aastoreconstClass") , ca[0] == Class.forName("TestPatcher$aastoreconstClass"));
+            }
+        } catch (NoClassDefFoundError t) {
+            fail(t.toString());
+        } catch (ClassNotFoundException t) {
+            fail(t.toString());
+        }
+    }
+
+    static class invokestatic  { static void sub() {} }
+    static class invokespecial { void invokespecial() {} }
+
+    static class getstaticI { static int    i = TestPatcher.i; }
+    static class getstaticJ { static long   l = TestPatcher.l; }
+    static class getstaticF { static float  f = TestPatcher.f; }
+    static class getstaticD { static double d = TestPatcher.d; }
+    static class getstaticL { static Object o = null; }
+
+    static class putstaticI { static int    i; }
+    static class putstaticJ { static long   l; }
+    static class putstaticF { static float  f; }
+    static class putstaticD { static double d; }
+    static class putstaticL { static Object o; }
+
+    static class putstaticconstI { static int    i; }
+    static class putstaticconstJ { static long   l; }
+    static class putstaticconstF { static float  f; }
+    static class putstaticconstD { static double d; }
+    static class putstaticconstL { static Object o; }
+    static class putstaticconstC { static Class<putstaticconstC> c; }
+
+    static class getfieldI { int    i = TestPatcher.i; }
+    static class getfieldJ { long   l = TestPatcher.l; }
+    static class getfieldF { float  f = TestPatcher.f; }
+    static class getfieldD { double d = TestPatcher.d; }
+    static class getfieldL { Object o = null; }
+
+    static class putfieldI { int    i; }
+    static class putfieldJ { long   l; }
+    static class putfieldF { float  f; }
+    static class putfieldD { double d; }
+    static class putfieldL { Object o; }
+
+    static class putfieldconstI { int    i; }
+    static class putfieldconstJ { long   l; }
+    static class putfieldconstF { float  f; }
+    static class putfieldconstD { double d; }
+    static class putfieldconstL { Object o; }
+    static class putfieldconstC { Class<putfieldconstC> c; }
+
+    static class newarray {}
+    static class multianewarray {}
+
+    static class instanceofC {}
+    static interface instanceofI {}
+
+    static class checkcastC {}
+    static interface checkcastI {}
+
+    static class aastoreconstClass {}
+}
index e5fcac12fcd6a887401a612f84436059f1e2f23e..94e7d3d33c0fecd07b11cc7ec6d6b87605235627 100644 (file)
 */
 
 
-import junit.framework.*;
-import junit.textui.*;
-
-public class All extends TestCase {
-    /**
-     * Runs all CACAO regression unit tests using
-     * junit.textui.TestRunner
-     */
-    public static void main(String[] args) {
-        Test s = suite();
-        TestRunner.run(s);
-    }
-
-    /**
-     * Collects all CACAO regression unit tests as one suite
-     */
-    public static Test suite() {
-        TestSuite suite = new TestSuite("CACAO Regression Unit Tests");
-
-        // Add your test here.
-
-        suite.addTest(new TestSuite(PR52.class));
-        suite.addTest(new TestSuite(PR57.class));
-        suite.addTest(new TestSuite(PR58.class));
-        suite.addTest(new TestSuite(PR65.class));
-
-        return suite;
-    }
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+
+@Suite.SuiteClasses({
+PR52.class,
+PR57.class,
+PR58.class,
+PR65.class,
+PR80.class,
+PR89.class
+})
+
+public class All {
 }
index b22e5a2d999beb7ce95bcca490a5def153231804..f56d5df0370bb7673e7e6152f0c1f7c4d66501f8 100644 (file)
@@ -23,7 +23,7 @@
 
 JAVA     = LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs $(top_builddir)/src/cacao/cacao
 JAVACMD  = $(JAVA) -Xbootclasspath:$(BOOTCLASSPATH)
-JAVACCMD = $(JAVAC) -bootclasspath $(BOOTCLASSPATH)
+JAVACCMD = $(JAVAC) -source 1.5 -target 1.5 -nowarn -bootclasspath $(BOOTCLASSPATH)
 
 EXTRA_DIST = \
        $(srcdir)/*.java
@@ -34,10 +34,10 @@ CLEANFILES = \
 check: build run
 
 build:
-       $(JAVACCMD) -classpath /usr/share/java/junit4.jar -d . $(srcdir)/*.java
+       $(JAVACCMD) -classpath $(JUNIT_JAR) -d . $(srcdir)/*.java
 
 run:
-       $(JAVACMD) -classpath /usr/share/java/junit4.jar:. org.junit.runner.JUnitCore All
+       $(JAVACMD) -classpath $(JUNIT_JAR):. org.junit.runner.JUnitCore All
 
 
 ## Local variables:
index fae85f1cab33f74e59e87449c560fdaaaf9a7fdd..c189a2eb8058a9711e4caa373040e6d01deda15d 100644 (file)
 */
 
 
-import junit.framework.*;
-import junit.textui.*;
+import org.junit.Test;
 
 import java.security.*;
 
-public class PR52 extends TestCase {
-    public static void main(String[] args) {
-        TestRunner.run(suite());
-    }
-
-    public static Test suite() {
-        return new TestSuite(PR52.class);
-    }
-
+public class PR52 {
+    @Test
     public void test() {
         // This one only triggers with GNU Classpath.
         AccessController.getContext();
index b8a960fe636efd0875d82f550e4c8cce25fca002..2bd11f5d04f0aa2bc1274f56e6fdc416597894cc 100644 (file)
 */
 
 
-import junit.framework.*;
-import junit.textui.*;
+import org.junit.Test;
 
-public class PR57 extends TestCase {
-    public static void main(String[] args) {
-        TestRunner.run(suite());
-    }
-
-    public static Test suite() {
-        return new TestSuite(PR57.class);
-    }
-
-    public void test() {
-        try {
-            Class.forName("x");
-            fail("Should throw ClassNotFoundException");
-        }
-        catch (ClassNotFoundException success) {
-        }
+public class PR57 {
+    @Test ( expected = ClassNotFoundException.class )
+    public void test() throws ClassNotFoundException {
+        Class.forName("x");
     }
 }
index d70281c294ae1fa367c728bdcd70a6eb4a0652f2..e8c9db083e7557e374eca4d42b57f0f64964573b 100644 (file)
 */
 
 
-import junit.framework.*;
-import junit.textui.*;
+import org.junit.Test;
+import static org.junit.Assert.*;
 
 import java.io.*;
 
-public class PR58 extends TestCase {
-    public static void main(String[] args) {
-        TestRunner.run(suite());
-    }
-
-    public static Test suite() {
-        return new TestSuite(PR58.class);
-    }
-
+public class PR58 {
     class x extends y {}
     class y {}
 
+    @Test
     public void testSuperClass() {
         // Delete the class file which is extended.
         new File("PR58$y.class").delete();
@@ -60,6 +53,7 @@ public class PR58 extends TestCase {
     interface i {}
     class j implements i {}
 
+    @Test
     public void testSuperInterface() {
         // Delete the interface file which is implemented.
         new File("PR58$i.class").delete();
index 400a3e61acd44b85877adb88658f66db17994315..8fd14180643bf735660fa968b708297613b9a8a9 100644 (file)
 */
 
 
-import junit.framework.*;
-import junit.textui.*;
-
-public class PR65 extends TestCase {
-    public static void main(String[] args) {
-        TestRunner.run(suite());
-    }
-
-    public static Test suite() {
-        return new TestSuite(PR65.class);
-    }
-
-    public void test() {
-        try {
-            Object o = new int[2][1];
-            Number[][] na = (Number[][]) o;
-            na[0][0] = null;
-            fail("Should throw ClassCastException");
-        } catch (ClassCastException success) {
-        }
+import org.junit.Test;
+
+public class PR65 {
+    @Test ( expected = ClassCastException.class )
+    public void test() throws ClassCastException {
+        Object o = new int[2][1];
+        Number[][] na = (Number[][]) o;
+        na[0][0] = null;
     }
 }
diff --git a/tests/regression/bugzilla/PR80.java b/tests/regression/bugzilla/PR80.java
new file mode 100644 (file)
index 0000000..85f23d8
--- /dev/null
@@ -0,0 +1,36 @@
+/* tests/regression/bugzilla/PR80.java
+
+   Copyright (C) 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.
+
+*/
+
+
+import org.junit.Test;
+
+public class PR80 {
+    @Test ( expected = ArrayIndexOutOfBoundsException.class )
+    public void test() throws ArrayIndexOutOfBoundsException {
+        // Taken from Mauve gnu.testlet.java.lang.System.arraycopy
+        int[] a = new int[5];
+        int[] b = new int[5];
+        System.arraycopy(a, 4, b, 4, Integer.MAX_VALUE);
+    }
+}
diff --git a/tests/regression/bugzilla/PR89.java b/tests/regression/bugzilla/PR89.java
new file mode 100644 (file)
index 0000000..506ac21
--- /dev/null
@@ -0,0 +1,62 @@
+/* tests/regression/bugzilla/PR89.java
+
+   Copyright (C) 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.
+
+*/
+
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import java.lang.reflect.*;
+
+public class PR89 {
+    final static float  f = 123.456f;
+    final static double d = 789.012;
+
+    @Test
+    public void testFloat() throws Exception {
+        FloatReflect floatReflect = new FloatReflect();
+        Method m = FloatReflect.class.getMethod("returnFloat", null);
+        Float ret = (Float) m.invoke(floatReflect, null);
+        assertEquals(f, ret, 0.0);
+    }
+
+    @Test
+    public void testDouble() throws Exception {
+        DoubleReflect doubleReflect = new DoubleReflect();
+        Method m = DoubleReflect.class.getMethod("returnDouble", null);
+        Double ret = (Double) m.invoke(doubleReflect, null);
+        assertEquals(d, ret, 0.0);
+    }
+
+    class FloatReflect {
+        public float returnFloat() {
+            return f;
+        }
+    }
+
+    class DoubleReflect {
+        public double returnDouble() {
+            return d;
+        }
+    }
+}
index 7584b3be3bed807082edf1a0111f5cafa83f320e..25d689f6b66a17777e05503a2d6a3c22ae6f03c8 100644 (file)
@@ -37,7 +37,7 @@ CLEANFILES = \
 check: build run
 
 build:
-       $(JAVACMD) -cp /usr/share/java/cup.jar:/usr/share/java/jasmin-sable.jar jasmin.Main $(srcdir)/*.j
+       $(JAVACMD) -cp $(JASMIN_JAR) jasmin.Main $(srcdir)/*.j
 
 run:
        @LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs JAVA="$(top_builddir)/src/cacao/cacao -Xbootclasspath:$(BOOTCLASSPATH)" $(srcdir)/runtest $(srcdir)/*.j
diff --git a/tests/regression/junit/All.java b/tests/regression/junit/All.java
deleted file mode 100644 (file)
index 15a5523..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* tests/regression/junit/All.java - runs all CACAO regression unit tests
-
-   Copyright (C) 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.
-
-*/
-
-
-import junit.framework.*;
-import junit.textui.*;
-
-public class All extends TestCase {
-    /**
-     * Runs all CACAO regression unit tests using
-     * junit.textui.TestRunner
-     */
-    public static void main(String[] args) {
-        Test s = suite();
-        TestRunner.run(s);
-    }
-
-    /**
-     * Collects all CACAO regression unit tests as one suite.
-     */
-    public static Test suite() {
-        TestSuite suite = new TestSuite("CACAO Regression Unit Tests");
-
-        // Add your test here.
-
-        suite.addTest(new TestSuite(TestPatcher.class));
-        suite.addTest(new TestSuite(TestExceptionInStaticClassInitializer.class));
-
-        return suite;
-    }
-}
diff --git a/tests/regression/junit/Makefile.am b/tests/regression/junit/Makefile.am
deleted file mode 100644 (file)
index d43942e..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-## tests/regression/junit/Makefile.am
-##
-## Copyright (C) 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.
-
-
-JAVA     = LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs $(top_builddir)/src/cacao/cacao
-JAVACMD  = $(JAVA) -Xbootclasspath:$(BOOTCLASSPATH)
-JAVACCMD = $(JAVAC) -source 1.5 -target 1.5 -nowarn -bootclasspath $(BOOTCLASSPATH)
-
-EXTRA_DIST = \
-       $(srcdir)/*.java
-
-CLEANFILES = \
-       *.class
-
-check: build run
-
-build:
-       $(JAVACCMD) -classpath /usr/share/java/junit4.jar -d . $(srcdir)/*.java
-
-run:
-       $(JAVACMD) -classpath /usr/share/java/junit4.jar:. org.junit.runner.JUnitCore All
-
-
-## Local variables:
-## mode: Makefile
-## indent-tabs-mode: t
-## c-basic-offset: 4
-## tab-width: 8
-## compile-command: "automake --add-missing"
-## End:
diff --git a/tests/regression/junit/TestExceptionInStaticClassInitializer.java b/tests/regression/junit/TestExceptionInStaticClassInitializer.java
deleted file mode 100644 (file)
index e6cc93e..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* tests/regression/bugzilla/TestExceptionInStaticClassInitializer.java
-
-   Copyright (C) 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.
-
-*/
-
-
-import junit.framework.*;
-import junit.textui.*;
-
-public class TestExceptionInStaticClassInitializer extends TestCase {
-    public static void main(String[] args) {
-        TestRunner.run(suite());
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestExceptionInStaticClassInitializer.class);
-    }
-
-    public void test() {
-        try {
-            TestExceptionInStaticClassInitializer_x.i = 1;
-            fail("Should throw ExceptionInInitializerError");
-        }
-        catch (ExceptionInInitializerError success) {
-            Throwable cause = success.getCause();
-
-            assertTrue("Cause should be RuntimeException but is " + cause.getClass(), cause.getClass() == RuntimeException.class);
-
-            StackTraceElement[] ste = cause.getStackTrace();
-
-            assertTrue("Linenumber should be " + LINE + " but is " + ste[0].getLineNumber(), ste[0].getLineNumber() == LINE);
-        }
-    }
-
-    // This linenumber must be the one from...
-    final static int LINE = 64;
-}
-
-class TestExceptionInStaticClassInitializer_x {
-    static int i;
-
-    static {
-        if (true)
-            // ...the following line.
-            throw new RuntimeException();
-    }
-}
diff --git a/tests/regression/junit/TestPatcher.java b/tests/regression/junit/TestPatcher.java
deleted file mode 100644 (file)
index 8417608..0000000
+++ /dev/null
@@ -1,650 +0,0 @@
-/* tests/regression/bugzilla/TestPatcher.java
-
-   Copyright (C) 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.
-
-*/
-
-
-import junit.framework.*;
-import junit.textui.*;
-
-import java.io.*;
-
-public class TestPatcher extends TestCase {
-    public static void main(String[] args) {
-        TestRunner.run(suite());
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestPatcher.class);
-    }
-
-    static boolean doit = true;
-
-    final static int    i = 123;
-    final static long   l = 1234567890123L;
-    final static float  f = 123.456F;
-    final static double d = 789.012;
-    final static Object o = new Object();
-
-    public void testNormal() {
-        invokestatic();
-        invokespecial();
-
-        getstatic();
-        putstatic();
-        putstaticconst();
-
-        getfield();
-        putfield();
-        putfieldconst();
-
-        newarray();
-        multianewarray();
-
-        checkcast();
-        _instanceof();
-
-        aastoreconst();
-    }
-
-    public void testWithoutClasses() {
-        // Delete all classes.
-        //new File("TestPatcher$invokestatic.class").delete();
-
-        invokestatic();
-        invokespecial();
-
-        getstatic();
-        putstatic();
-        putstaticconst();
-
-        getfield();
-        putfield();
-        putfieldconst();
-
-        newarray();
-        multianewarray();
-
-        checkcast();
-        _instanceof();
-
-        aastoreconst();
-    }
-
-    private void invokestatic() {
-        try {
-            if (doit)
-                invokestatic.sub();
-        } catch (NoClassDefFoundError e) {
-            fail(e.toString());
-        }
-    }
-
-    private void getstatic() {
-        try {
-            if (doit)
-                assertTrue(getstaticI.i + " != " + i, getstaticI.i == i);
-        } catch (NoClassDefFoundError e) {
-            fail(e.toString());
-        }
-
-        try {
-            if (doit)
-                assertTrue(getstaticJ.l + " != " + l, getstaticJ.l == l);
-        } catch (NoClassDefFoundError e) {
-            fail(e.toString());
-        }
-
-        try {
-            if (doit)
-                assertTrue(getstaticF.f + " != " + f, getstaticF.f == f);
-        } catch (NoClassDefFoundError e) {
-            fail(e.toString());
-        }
-
-        try {
-            if (doit)
-                assertTrue(getstaticD.d + " != " + d, getstaticD.d == d);
-        } catch (NoClassDefFoundError e) {
-            fail(e.toString());
-        }
-
-        try {
-            if (doit)
-                assertTrue(getstaticL.o + " != null", getstaticL.o == null);
-        } catch (NoClassDefFoundError e) {
-            fail(e.toString());
-        }
-    }
-
-    private void putstatic() {
-        try {
-            if (doit) {
-                putstaticI.i = i;
-                assertTrue(putstaticI.i + " != " + i, putstaticI.i == i);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticJ.l = l;
-                assertTrue(putstaticJ.l + " != " + l, putstaticJ.l == l);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticF.f = f;
-                assertTrue(putstaticF.f + " != " + f, putstaticF.f == f);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticD.d = d;
-                assertTrue(putstaticD.d + " != " + d, putstaticD.d == d);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-
-        try {
-            if (doit) {
-                putstaticL.o = o;
-                assertTrue(putstaticL.o + " != " + o, putstaticL.o == o);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-    }
-
-    private void putstaticconst() {
-        try {
-            if (doit) {
-                putstaticconstI.i = i;
-                assertTrue(putstaticconstI.i + " != " + i, putstaticconstI.i == i);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticconstJ.l = l;
-                assertTrue(putstaticconstJ.l + " != " + l, putstaticconstJ.l == l);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticconstF.f = f;
-                assertTrue(putstaticconstF.f + " != " + f, putstaticconstF.f == f);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticconstD.d = d;
-                assertTrue(putstaticconstD.d + " != " + d, putstaticconstD.d == d);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticconstI.i = 0;
-                assertTrue(putstaticconstI.i + " != " + 0, putstaticconstI.i == 0);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticconstJ.l = 0L;
-                assertTrue(putstaticconstJ.l + " != " + 0L, putstaticconstJ.l == 0L);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticconstF.f = 0.0F;
-                assertTrue(putstaticconstF.f + " != " + 0.0F, putstaticconstF.f == 0.0F);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticconstD.d = 0.0;
-                assertTrue(putstaticconstD.d + " != " + 0.0, putstaticconstD.d == 0.0);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticconstL.o = null;
-                assertTrue(putstaticconstL.o + " != " + null, putstaticconstL.o == null);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putstaticconstC.c = putstaticconstC.class;
-                assertTrue(putstaticconstC.c + " != " + Class.forName("TestPatcher$putstaticconstC"), putstaticconstC.c == Class.forName("TestPatcher$putstaticconstC"));
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        } catch (ClassNotFoundException t) {
-            fail(t.toString());
-        }
-    }
-
-    private void getfield() {
-        try {
-            if (doit)
-                assertTrue(new getfieldI().i + " != " + i, new getfieldI().i == i);
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit)
-                assertTrue(new getfieldJ().l + " != " + l, new getfieldJ().l == l);
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit)
-                assertTrue(new getfieldF().f + " != " + f, new getfieldF().f == f);
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit)
-                assertTrue(new getfieldD().d + " != " + d, new getfieldD().d == d);
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit)
-                assertTrue(new getfieldL().o + " != " + null, new getfieldL().o == null);
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-    }
-
-    private void putfield() {
-        try {
-            if (doit) {
-                TestPatcher.putfieldI pfi = new TestPatcher.putfieldI();
-                pfi.i = i;
-                assertTrue(pfi.i + " != " + i, pfi.i == i);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putfieldJ pfj = new putfieldJ();
-                pfj.l = l;
-                assertTrue(pfj.l + " != " + l, pfj.l == l);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putfieldF pff = new putfieldF();
-                pff.f = f;
-                assertTrue(pff.f + " != " + f, pff.f == f);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putfieldD pfd = new putfieldD();
-                pfd.d = d;
-                assertTrue(pfd.d + " != " + d, pfd.d == d);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putfieldL pfl = new putfieldL();
-                pfl.o = o;
-                assertTrue(pfl.o + " != " + o, pfl.o == o);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-    }
-
-    private void putfieldconst() {
-        try {
-            if (doit) {
-                putfieldconstI pfci = new putfieldconstI();
-                pfci.i = i;
-                assertTrue(pfci.i + " != " + i, pfci.i == i);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-        try {
-            if (doit) {
-                putfieldconstJ pfcj = new putfieldconstJ();
-                pfcj.l = l;
-                assertTrue(pfcj.l + " != " + l, pfcj.l == l);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putfieldconstF pfcf = new putfieldconstF();
-                pfcf.f = f;
-                assertTrue(pfcf.f + " != " + f, pfcf.f == f);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-        try {
-            if (doit) {
-                putfieldconstD pfcd = new putfieldconstD();
-                pfcd.d = d;
-                assertTrue(pfcd.d + " != " + d, pfcd.d == d);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putfieldconstI pfci = new putfieldconstI();
-                pfci.i = 0;
-                assertTrue(pfci.i + " != " + 0, pfci.i == 0);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-        try {
-            if (doit) {
-                putfieldconstJ pfcj = new putfieldconstJ();
-                pfcj.l = 0L;
-                assertTrue(pfcj.l + " != " + 0L, pfcj.l == 0L);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putfieldconstF pfcf = new putfieldconstF();
-                pfcf.f = 0.0F;
-                assertTrue(pfcf.f + " != " + 0.0F, pfcf.f == 0.0F);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-        try {
-            if (doit) {
-                putfieldconstD pfcd = new putfieldconstD();
-                pfcd.d = 0.0;
-                assertTrue(pfcd.d + " != " + 0.0, pfcd.d == 0.0);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putfieldconstL pfcl = new putfieldconstL();
-                pfcl.o = null;
-                assertTrue(pfcl.o + " != " + null, pfcl.o == null);
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit) {
-                putfieldconstC pfcc = new putfieldconstC();
-                pfcc.c = putfieldconstC.class;
-                assertTrue(pfcc.c + " != " + Class.forName("TestPatcher$putfieldconstC"), pfcc.c == Class.forName("TestPatcher$putfieldconstC"));
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        } catch (ClassNotFoundException t) {
-            fail(t.toString());
-        }
-    }
-
-    private void newarray() {
-        try {
-            if (doit) {
-                newarray[] na = new newarray[1];
-                na[0] = null;
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-    }
-
-    private void multianewarray() {
-        try {
-            if (doit) {
-                multianewarray[][] ma = new multianewarray[1][1];
-                ma[0][0] = null;
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-    }
-
-    private void invokespecial() {
-        try {
-            if (doit)
-                new invokespecial();
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-    }
-
-    private void checkcast() {
-        Object o = new Object();
-
-        // class
-        try {
-            if (doit) {
-                checkcastC cc = (checkcastC) o;
-                fail();
-            }
-        } catch (ClassCastException success) {
-            // This is OK.
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        // interface
-        try {
-            if (doit) {
-                checkcastI ci = (checkcastI) o;
-                fail();
-            }
-        } catch (ClassCastException success) {
-            // This is OK.
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-
-        // array
-        Object[] oa = new Object[1];
-
-        try {
-            if (doit) {
-                checkcastC[] cca = (checkcastC[]) oa;
-                fail();
-            }
-        } catch (ClassCastException e) {
-            // This is OK.
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-    }
-
-    private void _instanceof() {
-        Object o = new Object();
-
-        try {
-            if (doit)
-                if (o instanceof instanceofC)
-                    fail();
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-        try {
-            if (doit)
-                if (o instanceof instanceofI)
-                    fail();
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-
-
-        // array
-        Object[] oa = new Object[1];
-
-        try {
-            if (doit)
-                if (oa instanceof instanceofC[])
-                    fail();
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        }
-    }
-
-    private void aastoreconst() {
-        Class[] ca = new Class[1];
-
-        try {
-            if (doit) {
-                ca[0] = aastoreconstClass.class;
-
-                if (ca[0] == null)
-                    fail();
-
-                assertTrue(ca[0] + " != " + Class.forName("TestPatcher$aastoreconstClass") , ca[0] == Class.forName("TestPatcher$aastoreconstClass"));
-            }
-        } catch (NoClassDefFoundError t) {
-            fail(t.toString());
-        } catch (ClassNotFoundException t) {
-            fail(t.toString());
-        }
-    }
-
-    static class invokestatic  { static void sub() {} }
-    static class invokespecial { void invokespecial() {} }
-
-    static class getstaticI { static int    i = TestPatcher.i; }
-    static class getstaticJ { static long   l = TestPatcher.l; }
-    static class getstaticF { static float  f = TestPatcher.f; }
-    static class getstaticD { static double d = TestPatcher.d; }
-    static class getstaticL { static Object o = null; }
-
-    static class putstaticI { static int    i; }
-    static class putstaticJ { static long   l; }
-    static class putstaticF { static float  f; }
-    static class putstaticD { static double d; }
-    static class putstaticL { static Object o; }
-
-    static class putstaticconstI { static int    i; }
-    static class putstaticconstJ { static long   l; }
-    static class putstaticconstF { static float  f; }
-    static class putstaticconstD { static double d; }
-    static class putstaticconstL { static Object o; }
-    static class putstaticconstC { static Class<putstaticconstC> c; }
-
-    static class getfieldI { int    i = TestPatcher.i; }
-    static class getfieldJ { long   l = TestPatcher.l; }
-    static class getfieldF { float  f = TestPatcher.f; }
-    static class getfieldD { double d = TestPatcher.d; }
-    static class getfieldL { Object o = null; }
-
-    static class putfieldI { int    i; }
-    static class putfieldJ { long   l; }
-    static class putfieldF { float  f; }
-    static class putfieldD { double d; }
-    static class putfieldL { Object o; }
-
-    static class putfieldconstI { int    i; }
-    static class putfieldconstJ { long   l; }
-    static class putfieldconstF { float  f; }
-    static class putfieldconstD { double d; }
-    static class putfieldconstL { Object o; }
-    static class putfieldconstC { Class<putfieldconstC> c; }
-
-    static class newarray {}
-    static class multianewarray {}
-
-    static class instanceofC {}
-    static interface instanceofI {}
-
-    static class checkcastC {}
-    static interface checkcastI {}
-
-    static class aastoreconstClass {}
-}
index 62a57afe71e6fcfde6771adacdf1e1027ddf3070..5d7eca6246a7aadfd587534a72129e49462d53c0 100644 (file)
@@ -1,9 +1,7 @@
 /* src/tests/native/checkjni.c - for testing JNI stuff
 
-   Copyright (C) 1996-2005, 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,
-   TU Wien
+   Copyright (C) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
 */
 
 
+#include "config.h"
+
 #include <stdio.h>
 #include <string.h>
 
-#include "config.h"
-#include "native/jni.h"
+#include INCLUDE_JNI_MD_H
+#include INCLUDE_JNI_H
 
 
 JNIEXPORT jboolean JNICALL Java_checkjni_IsAssignableFrom(JNIEnv *env, jclass clazz, jclass sub, jclass sup)
index 3d568f66dafa9fb825abdc49f18843d76225996d..f6a0777496511cfb5bfd400897ef948763c57c6c 100644 (file)
@@ -1,9 +1,7 @@
 /* tests/native/test.c - for testing native stuff
 
-   Copyright (C) 1996-2005, 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,
-   TU Wien
+   Copyright (C) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-
 */
 
 
+#include "config.h"
+
 #include <stdio.h>
 
-#include "config.h"
-#include "native/jni.h"
+#include "native/jni.hpp"
 
 
 JNIEXPORT void JNICALL Java_test_nsub(JNIEnv *env, jclass clazz)
index bc7be27c52c0de4bf940e988039fa4b3545a9640..d2b3f36c37b57825c9e00ff5b176ba7e4e47feb8 100644 (file)
@@ -1,9 +1,7 @@
 /* tests/regression/native/testarguments.c - tests argument passing
 
-   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,
-   TU Wien
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
 
 #include "config.h"
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "native/jni.h"
+#include INCLUDE_JNI_MD_H
+#include INCLUDE_JNI_H
 
 
 JNIEXPORT jobject JNICALL Java_testarguments_adr(JNIEnv *env, jclass clazz, jint i)
index 2bce8e1f10a09e0c9bf956ff03d689497b958e3e..961025bf4b46dda946f8ef95a9d3f03c6e8ae68c 100644 (file)
@@ -1,9 +1,7 @@
 /* tests/native/testgetobjectclass0.c - tests argument passing
 
-   Copyright (C) 1996-2005, 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,
-   TU Wien
+   Copyright (C) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Joseph Wenninger
-
-
 */
 
 
 #include "config.h"
-#include "native/jni.h"
+#include "native/jni.hpp"
 
 
 JNIEXPORT void JNICALL Java_testgetobjectclass0_getobjectclass0(JNIEnv *env, jclass clazz)
diff --git a/tests/threads/sableContention.java b/tests/threads/sableContention.java
new file mode 100644 (file)
index 0000000..184dc31
--- /dev/null
@@ -0,0 +1,91 @@
+// This pathological test tries to grow a FLC list as long as possible before
+// the threads from the previous FLC list have resumed running. Every one on
+// the old list then has to scan the entire new list.
+
+// The CACAO patch in file sableContention.patch can be used to examine the
+// maximum length. With 500 threads on a quad-core system, I managed to get to
+// about 120.
+
+class sableContention {
+       public Object a[] = null;
+       public tt ts[] = null;
+       final int NUM = 500;
+
+       class tt extends Thread {
+               sableContention y;
+               int x;
+               tt(sableContention y, int x) {
+                       this.y = y;
+                       this.x = x;
+               }
+               public void run() {
+                       int i = 1;
+                       synchronized(y.a[x]) {
+                               if (x==0) {
+                                       for (; i<NUM*3/4; i++)
+                                               y.ts[i].start();
+                                       y.a[x].notify();
+                               }
+                       }
+                       if (x==0)
+                               for (; i<NUM; i++)
+                                       y.ts[i].start();
+                       for (int j=0; j<NUM/10; j++)
+                               synchronized(y.a[(x+j)%(NUM-1)+1]) {
+                               }
+               }
+       }
+
+       private void l(int f) {
+               try {
+                       synchronized(a[NUM-1-f]) {
+                               if (f > 0) {
+                                       l(f-1);
+                                       if (f<10)
+                                               Thread.sleep(0, f*100 * 1000);
+                               }
+                               else {
+                                       ts = new tt[NUM];
+                                       for (int i=0; i<NUM; i++)
+                                               ts[i] = new tt(this, i);
+                                       ts[0].start();
+                                       a[0].wait();
+                               }
+                       }
+               } catch (InterruptedException e) {
+               }
+       }
+
+       private void r() {
+               for (;;) {
+                       a = new Object[NUM];
+                       for (int i=0; i<NUM; i++)
+                               a[i] = new Object();
+                       l(NUM-1);
+                       for (int i=0; i<NUM; i++)
+                               try {
+                                       ts[i].join();
+                               } catch (InterruptedException e) {
+                               }
+                       System.out.println("running");
+               }
+       }
+
+       public static void main(String[] args) {
+               new sableContention().r();
+       }
+}
+
+/*
+ * 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: java
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/tests/threads/sableContention.patch b/tests/threads/sableContention.patch
new file mode 100644 (file)
index 0000000..f83a4a6
--- /dev/null
@@ -0,0 +1,29 @@
+--- a/src/threads/lock.cpp     Thu Sep 11 14:52:50 2008 +0200
++++ b/src/threads/lock.cpp     Thu Sep 11 15:13:24 2008 +0200
+@@ -717,6 +717,7 @@
+               for (;;)
+               {
+                       threadobject *current;
++                      int i = 0;
+                       // Wait until another thread sees the flc bit and notifies
+                       // us of unlocking.
+@@ -726,8 +727,17 @@
+                               break;
+                       /* Traverse FLC list looking if we're still there */
+                       current = t_other->flc_list;
+-                      while (current && current != t)
++                      while (current && current != t) {
++                              i++;
+                               current = current->flc_next;
++                      }
++                      {
++                              static int umax = 0;
++                              if (i>umax) {
++                                      printf("sable len %d\n", i);
++                                      umax = i;
++                              }
++                      }
+                       if (!current)
+                               /* not in list anymore, can stop waiting */
+                               break;
diff --git a/tests/threads/threadpooltest.java b/tests/threads/threadpooltest.java
new file mode 100644 (file)
index 0000000..3094c96
--- /dev/null
@@ -0,0 +1,51 @@
+// Use with "nc localhost 8080 < /dev/null"
+// Idle threads are parked by the jsr166 framework and caused lots of CPU usage
+// before the addition of park/unpark to CACAO.
+
+import java.net.*;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.net.InetSocketAddress;
+
+public class threadpooltest {
+       private static final int NTHREADS = 3;
+       private static final Executor exec = Executors.newFixedThreadPool(NTHREADS);
+       
+       private static void handleRequest(Socket s) {
+               String ss = "hello";
+               try {
+                       if (Thread.currentThread().isInterrupted())
+                               ss += " (wasinterrupted)";
+                       ss += " " + Thread.currentThread().toString();
+                       PrintWriter pw = new PrintWriter(s.getOutputStream());
+                       //Thread.currentThread().interrupt();
+                       pw.println(ss);
+                       pw.flush();
+                       Thread.sleep(100);
+                       pw.println("closing");
+                       pw.flush();
+                       s.close();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public static void main(String[] args) throws IOException {
+               ServerSocket socket = new ServerSocket();
+               socket.setReuseAddress(true);
+               socket.bind(new InetSocketAddress(8080));
+               while (true) {
+                       final Socket connection = socket.accept();
+                       Runnable task = new Runnable() {
+                               public void run() {
+                                       handleRequest(connection);
+                               }
+                       };
+                       exec.execute(task);
+               }
+       }
+}